Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [udig-devel] Fixing merge tool with operation: ViewPart howto?

Try to go with Display.getDefault() and let me know what happens.


On Thu, Jun 21, 2012 at 12:54 PM, Marco Foi <foimarco@xxxxxxxxx> wrote:
> Yes.. ..I am trying to do right that: open a view.
> The problem is that your code suggest to start with:
>
>    IWorkbenchPage activePage = window.getActivePage();
>
> but to get a "window" I need something like:
>
>    IWorkbenchWindow window
> = PlatformUI.getWorkbench().getActiveWorkbenchWindow()
>
> Unfortunately I ALWAYS get tuck at this point:
> the getActiveWorkbenchWindow() method uses a Display.getCurrent() call that,
> IN MY CASE, returns NULL and, ultimately, leads to a NPE.
>
> The comments in the Workbench.class state this:
>
> public IWorkbenchWindow getActiveWorkbenchWindow() {
> // Return null if called from a non-UI thread.
> // This is not spec'ed behaviour and is misleading, however this is how
> // it
> // worked in 2.1 and we cannot change it now.
> // For more details, see [Bug 57384] [RCP] Main window not active on
> // startup
> if (Display.getCurrent() == null) {
> return null;                  <<<<<=== I ALWAYS GET HERE !!
> }
> [...]
>
> Does this suggest you any way around?
> or
> What I am doing wrong?
>
> Marco
>
>
>
> 2012/6/21 andrea antonello <andrea.antonello@xxxxxxxxx>
>>
>> Hi Marco,
>> sorry to be a bit quick, but it might be that you find it here:
>>
>> http://jgrasstechtips.blogspot.it/2008/01/how-to-open-view-from-action-and.html
>>
>> I hope your question was about how to open a view through its id :)
>>
>> Ciao,
>> Andrea
>>
>>
>> On Thu, Jun 21, 2012 at 12:03 PM, Marco Foi <foimarco@xxxxxxxxx> wrote:
>> > With the explicit intent of both informing the dev community and asking
>> > for
>> > help, I am reporting my activities within the GSoC project.
>> >
>> > I decided to add an operation to the eu.udig.tools.merge to allow for
>> > merging features selected with the core selection tools (suggested by
>> > Jody
>> > https://jira.codehaus.org/browse/UDIG-1921 ).
>> >
>> > The workflow is:
>> > - the users adds a layer
>> > - the users selects a number of features of his interest using "Box
>> > selection" or "Feature selection" core tools
>> > - the users right-clicks on the layer -> operation -> "Merge selected"
>> > (the
>> > newly added operation!)
>> > - the selected features are "passed" to the MergeView (available in the
>> > eu.merge.tools.merge.internal.view): the view that ultimately calls the
>> > methods to process geometries.
>> >
>> > The workflow (should) proceed as before, using the MergeView features to
>> > eventually remove features and select text attributes of the output
>> > merged
>> > feature.
>> >
>> >
>> > THE PROBLEM
>> >
>> > How can a ViewPart be opened in uDig by code? (MergeView extends
>> > ViewPart)
>> > I can retrieve selected features but I found no way to open the view (to
>> > use
>> > its addSourceFeatures() method)
>> > It seems that since the operation I created is not in the UI-therad (or
>> > something like that), a pretty basic code line such:
>> >
>> > MergeView view = (MergeView) ApplicationGIS.getView(true, MergeView.ID);
>> >
>> > fails with a NullPointerException, caused by a Display.getCurrent()
>> > returning null in a private method down inside ApplicationGIS.
>> >
>> > Any hint?
>> >
>> > Marco
>> >
>> >
>> > _______________________________________________
>> > User-friendly Desktop Internet GIS (uDig)
>> > http://udig.refractions.net
>> > http://lists.refractions.net/mailman/listinfo/udig-devel
>> >
>> _______________________________________________
>> User-friendly Desktop Internet GIS (uDig)
>> http://udig.refractions.net
>> http://lists.refractions.net/mailman/listinfo/udig-devel
>
>
>
> _______________________________________________
> User-friendly Desktop Internet GIS (uDig)
> http://udig.refractions.net
> http://lists.refractions.net/mailman/listinfo/udig-devel
>


Back to the top