Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse 4 » How to prevent a part to be moved to a special stack?
How to prevent a part to be moved to a special stack? [message #1386937] Mon, 23 June 2014 08:11 Go to next message
Marina Knieling is currently offline Marina KnielingFriend
Messages: 83
Registered: February 2013
Member
Hey guys,

please read carefully, I don't want to prevent a part to be moved,
that's possible with adding the NoMove tag.

What I want to achieve is that a part can't be moved to a special stack.
I have two stacks that shall only host one part each (it's going to be a
web like menu) and I don't want any other part to be moved in that
stack. I've read about a tag named "STANDALONE" but I can't find the
article again or any other documentation about this tag. Neither can I
figure out whether this is correct or where to add it.

Any hints on this are appreciated.

Thanks in advance
Marina
Re: How to prevent a part to be moved to a special stack? [message #1386938 is a reply to message #1386937] Mon, 23 June 2014 08:15 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
You need to fork the DnDAddon and implement your custom logic.

Tom

On 23.06.14 10:11, Marina Knieling wrote:
> Hey guys,
>
> please read carefully, I don't want to prevent a part to be moved,
> that's possible with adding the NoMove tag.
>
> What I want to achieve is that a part can't be moved to a special stack.
> I have two stacks that shall only host one part each (it's going to be a
> web like menu) and I don't want any other part to be moved in that
> stack. I've read about a tag named "STANDALONE" but I can't find the
> article again or any other documentation about this tag. Neither can I
> figure out whether this is correct or where to add it.
>
> Any hints on this are appreciated.
>
> Thanks in advance
> Marina
Re: How to prevent a part to be moved to a special stack? [message #1387499 is a reply to message #1386938] Wed, 25 June 2014 07:10 Go to previous messageGo to next message
Marina Knieling is currently offline Marina KnielingFriend
Messages: 83
Registered: February 2013
Member
The DnDAddon is quite comprehensive (Addon, Manager, Info, Processor,
lots of *Agent classes). Any hints on where to best hook in my custom
logic? I guess the *DropAgents is a good start, but maybe you can point
me to a concrete method.

And Tom (or anyone else), could you please have a look at my other
question concerning the DnDAddon in this forum? I simply need to know
whether to file a bug or - again - implement my own logic. Thanks

Marina

On 23.06.2014 10:15, Tom Schindl wrote:
> You need to fork the DnDAddon and implement your custom logic.
>
> Tom
>
> On 23.06.14 10:11, Marina Knieling wrote:
>> Hey guys,
>>
>> please read carefully, I don't want to prevent a part to be moved,
>> that's possible with adding the NoMove tag.
>>
>> What I want to achieve is that a part can't be moved to a special stack.
>> I have two stacks that shall only host one part each (it's going to be a
>> web like menu) and I don't want any other part to be moved in that
>> stack. I've read about a tag named "STANDALONE" but I can't find the
>> article again or any other documentation about this tag. Neither can I
>> figure out whether this is correct or where to add it.
>>
>> Any hints on this are appreciated.
>>
>> Thanks in advance
>> Marina
>
Re: How to prevent a part to be moved to a special stack? [message #1387555 is a reply to message #1387499] Wed, 25 June 2014 08:49 Go to previous messageGo to next message
Eclipse UserFriend
Extend StackDropAgent class, override canDrop method, add ' if (stack.getElementId is your stack's id) return false; ' and replace the DnDaddon in your app model with your own addon.
Re: How to prevent a part to be moved to a special stack? [message #1387655 is a reply to message #1387555] Wed, 25 June 2014 11:49 Go to previous messageGo to next message
Marina Knieling is currently offline Marina KnielingFriend
Messages: 83
Registered: February 2013
Member
Hallo Sopot,

thanks for the hint. This worked once (don't ask me why only once) but
now I get a ClassCastException:

!ENTRY org.eclipse.equinox.event 4 0 2014-06-25 13:40:00.379
!MESSAGE Exception while dispatching event org.osgi.service.event.Event
[topic=org/eclipse/e4/ui/model/ui/UIElement/widget/SET] to handler
org.eclipse.e4.ui.services.internal.events.UIEventHandler@19a574b
!STACK 0
java.lang.ClassCastException:
org.eclipse.e4.ui.workbench.addons.dndaddon.DnDManager cannot be cast to
addons.dndaddon.MyDnDManager
at addons.dndaddon.MyDnDAddon$1.handleEvent(MyDnDAddon.java:45)
at
org.eclipse.e4.ui.services.internal.events.UIEventHandler$1.run(UIEventHandler.java:41)
at org.eclipse.swt.widgets.Synchronizer.syncExec(Synchronizer.java:180)
at org.eclipse.swt.widgets.Display.syncExec(Display.java:4688)
at
org.eclipse.e4.ui.internal.workbench.swt.E4Application$1.syncExec(E4Application.java:205)
at
org.eclipse.e4.ui.services.internal.events.UIEventHandler.handleEvent(UIEventHandler.java:38)
at
org.eclipse.equinox.internal.event.EventHandlerWrapper.handleEvent(EventHandlerWrapper.java:197)
at
org.eclipse.equinox.internal.event.EventHandlerTracker.dispatchEvent(EventHandlerTracker.java:197)
at
org.eclipse.equinox.internal.event.EventHandlerTracker.dispatchEvent(EventHandlerTracker.java:1)
at
org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230)
at
org.eclipse.osgi.framework.eventmgr.ListenerQueue.dispatchEventSynchronous(ListenerQueue.java:148)
at
org.eclipse.equinox.internal.event.EventAdminImpl.dispatchEvent(EventAdminImpl.java:135)
at
org.eclipse.equinox.internal.event.EventAdminImpl.sendEvent(EventAdminImpl.java:78)
at
org.eclipse.equinox.internal.event.EventComponent.sendEvent(EventComponent.java:39)
at
org.eclipse.e4.ui.services.internal.events.EventBroker.send(EventBroker.java:80)
at
org.eclipse.e4.ui.internal.workbench.UIEventPublisher.notifyChanged(UIEventPublisher.java:58)
at
org.eclipse.emf.common.notify.impl.BasicNotifierImpl.eNotify(BasicNotifierImpl.java:374)
at
org.eclipse.e4.ui.model.application.ui.impl.UIElementImpl.setWidget(UIElementImpl.java:248)
at
org.eclipse.e4.ui.workbench.renderers.swt.SWTPartRenderer.bindWidget(SWTPartRenderer.java:134)
at
org.eclipse.e4.ui.workbench.renderers.swt.WBWRenderer.createWidget(WBWRenderer.java:387)
at
org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.createWidget(PartRenderingEngine.java:949)
at
org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.safeCreateGui(PartRenderingEngine.java:633)
at
org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.safeCreateGui(PartRenderingEngine.java:735)
at
org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.access$2(PartRenderingEngine.java:706)
at
org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$7.run(PartRenderingEngine.java:700)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
at
org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.createGui(PartRenderingEngine.java:685)
at
org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$9.run(PartRenderingEngine.java:1038)
at
org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
at
org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:997)
at
org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:140)
at
org.eclipse.e4.ui.internal.workbench.swt.E4Application.start(E4Application.java:162)
at
org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
at
org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
at
org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
at
org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:354)
at
org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:181)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:636)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:591)
at org.eclipse.equinox.launcher.Main.run(Main.java:1450)
at org.eclipse.equinox.launcher.Main.main(Main.java:1426)

What I've done so far:
I copied all sources of the DnDAddon into my project in a package named
addons.dndaddon. I added the line above to the StackDropAgent. In my
Application.e4xmi I removed the original DnDAddon entry and added the
DnDAddon class from my own package.

As I said, the edit worked once after making the changes (I also tried
to change the SplitDropAgent and I thought it is that change that is
causing the problems, but reverting those changes didn't help).

Any ideas why or where eclipse is trying to incorporate the class from
the original addon although it is not added to the Application.e4xmi?
As I also use the MinMaxAddon the whole workbench.addons.swt plugin is
in my run config, if that is of any help for you.

On 25.06.2014 10:49, Sopot Cela wrote:
> Extend StackDropAgent class, override canDrop method, add ' if
> (stack.getElementId is your stack's id) return false; ' and replace the
> DnDaddon in your app model with your own addon.
Re: How to prevent a part to be moved to a special stack? [message #1387677 is a reply to message #1387655] Wed, 25 June 2014 12:31 Go to previous messageGo to next message
Eclipse UserFriend
In your custom DnDAddon class, installHook event handler, third 'if' condition, there is a widget.setData .... . What are you setting there?
Re: How to prevent a part to be moved to a special stack? [message #1387678 is a reply to message #1387655] Wed, 25 June 2014 12:31 Go to previous messageGo to next message
Marina Knieling is currently offline Marina KnielingFriend
Messages: 83
Registered: February 2013
Member
Seems like the DnDProcessor in the workbench.addons.swt plugins is
responsible for loading the addon and this is hardcoded to
"bundleclass://org.eclipse.e4.ui.workbench.addons.swt/org.eclipse.e4.ui.workbench.addons.dndaddon.DnDAddon"

I tried to add another processor in my own plugin.xml but this didn't
work. Do I have to remove the addons plugin and copy all the
functionality to my own application just because of the processors? or
is there another way?

On 25.06.2014 13:49, Marina Knieling wrote:
> Hallo Sopot,
>
> thanks for the hint. This worked once (don't ask me why only once) but
> now I get a ClassCastException:
>
> !ENTRY org.eclipse.equinox.event 4 0 2014-06-25 13:40:00.379
> !MESSAGE Exception while dispatching event org.osgi.service.event.Event
> [topic=org/eclipse/e4/ui/model/ui/UIElement/widget/SET] to handler
> org.eclipse.e4.ui.services.internal.events.UIEventHandler@19a574b
> !STACK 0
> java.lang.ClassCastException:
> org.eclipse.e4.ui.workbench.addons.dndaddon.DnDManager cannot be cast to
> addons.dndaddon.MyDnDManager
> at addons.dndaddon.MyDnDAddon$1.handleEvent(MyDnDAddon.java:45)
> at
> org.eclipse.e4.ui.services.internal.events.UIEventHandler$1.run(UIEventHandler.java:41)
>
> at
> org.eclipse.swt.widgets.Synchronizer.syncExec(Synchronizer.java:180)
> at org.eclipse.swt.widgets.Display.syncExec(Display.java:4688)
> at
> org.eclipse.e4.ui.internal.workbench.swt.E4Application$1.syncExec(E4Application.java:205)
>
> at
> org.eclipse.e4.ui.services.internal.events.UIEventHandler.handleEvent(UIEventHandler.java:38)
>
> at
> org.eclipse.equinox.internal.event.EventHandlerWrapper.handleEvent(EventHandlerWrapper.java:197)
>
> at
> org.eclipse.equinox.internal.event.EventHandlerTracker.dispatchEvent(EventHandlerTracker.java:197)
>
> at
> org.eclipse.equinox.internal.event.EventHandlerTracker.dispatchEvent(EventHandlerTracker.java:1)
>
> at
> org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230)
>
> at
> org.eclipse.osgi.framework.eventmgr.ListenerQueue.dispatchEventSynchronous(ListenerQueue.java:148)
>
> at
> org.eclipse.equinox.internal.event.EventAdminImpl.dispatchEvent(EventAdminImpl.java:135)
>
> at
> org.eclipse.equinox.internal.event.EventAdminImpl.sendEvent(EventAdminImpl.java:78)
>
> at
> org.eclipse.equinox.internal.event.EventComponent.sendEvent(EventComponent.java:39)
>
> at
> org.eclipse.e4.ui.services.internal.events.EventBroker.send(EventBroker.java:80)
>
> at
> org.eclipse.e4.ui.internal.workbench.UIEventPublisher.notifyChanged(UIEventPublisher.java:58)
>
> at
> org.eclipse.emf.common.notify.impl.BasicNotifierImpl.eNotify(BasicNotifierImpl.java:374)
>
> at
> org.eclipse.e4.ui.model.application.ui.impl.UIElementImpl.setWidget(UIElementImpl.java:248)
>
> at
> org.eclipse.e4.ui.workbench.renderers.swt.SWTPartRenderer.bindWidget(SWTPartRenderer.java:134)
>
> at
> org.eclipse.e4.ui.workbench.renderers.swt.WBWRenderer.createWidget(WBWRenderer.java:387)
>
> at
> org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.createWidget(PartRenderingEngine.java:949)
>
> at
> org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.safeCreateGui(PartRenderingEngine.java:633)
>
> at
> org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.safeCreateGui(PartRenderingEngine.java:735)
>
> at
> org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.access$2(PartRenderingEngine.java:706)
>
> at
> org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$7.run(PartRenderingEngine.java:700)
>
> at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
> at
> org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.createGui(PartRenderingEngine.java:685)
>
> at
> org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$9.run(PartRenderingEngine.java:1038)
>
> at
> org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
>
> at
> org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:997)
>
> at
> org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:140)
>
> at
> org.eclipse.e4.ui.internal.workbench.swt.E4Application.start(E4Application.java:162)
>
> at
> org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
>
> at
> org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
>
> at
> org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
>
> at
> org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:354)
>
> at
> org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:181)
>
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
> at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
> at java.lang.reflect.Method.invoke(Unknown Source)
> at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:636)
> at org.eclipse.equinox.launcher.Main.basicRun(Main.java:591)
> at org.eclipse.equinox.launcher.Main.run(Main.java:1450)
> at org.eclipse.equinox.launcher.Main.main(Main.java:1426)
>
> What I've done so far:
> I copied all sources of the DnDAddon into my project in a package named
> addons.dndaddon. I added the line above to the StackDropAgent. In my
> Application.e4xmi I removed the original DnDAddon entry and added the
> DnDAddon class from my own package.
>
> As I said, the edit worked once after making the changes (I also tried
> to change the SplitDropAgent and I thought it is that change that is
> causing the problems, but reverting those changes didn't help).
>
> Any ideas why or where eclipse is trying to incorporate the class from
> the original addon although it is not added to the Application.e4xmi?
> As I also use the MinMaxAddon the whole workbench.addons.swt plugin is
> in my run config, if that is of any help for you.
>
> On 25.06.2014 10:49, Sopot Cela wrote:
>> Extend StackDropAgent class, override canDrop method, add ' if
>> (stack.getElementId is your stack's id) return false; ' and replace the
>> DnDaddon in your app model with your own addon.
>
Re: How to prevent a part to be moved to a special stack? [message #1387679 is a reply to message #1387677] Wed, 25 June 2014 12:34 Go to previous messageGo to next message
Marina Knieling is currently offline Marina KnielingFriend
Messages: 83
Registered: February 2013
Member
I only changed the names of the classes in order to find out where the
problem is. I didn't change the logic there, just the name.

Widget widget = (Widget) event.getProperty(EventTags.NEW_VALUE);
if (widget instanceof Shell && !widget.isDisposed()) {
MyDnDManager theManager = (MyDnDManager)
widget.getData("DnDManager"); //$NON-NLS-1$
if (theManager == null) {
theManager = new MyDnDManager((MWindow) changedElement);
widget.setData("DnDManager", theManager); //$NON-NLS-1$
}
}

On 25.06.2014 14:31, Sopot Cela wrote:
> In your custom DnDAddon class, installHook event handler, third 'if'
> condition, there is a widget.setData .... . What are you setting there?
Re: How to prevent a part to be moved to a special stack? [message #1387692 is a reply to message #1387679] Wed, 25 June 2014 12:55 Go to previous messageGo to next message
Eclipse UserFriend
I see. There is an 'if' check in the DnDProcessor regarding the contributionURI so try making sure that your class is called DnDAddon and your package name ends with ui.workbench.addons.dndaddon. So something like 'my.custom.ui.workbench.addons.dndaddon.DnDAddon'.

In the mean time I'll file a bug to make this easier for Mars. Let me know how it goes.
Re: How to prevent a part to be moved to a special stack? [message #1387706 is a reply to message #1387692] Wed, 25 June 2014 13:25 Go to previous messageGo to next message
Marina Knieling is currently offline Marina KnielingFriend
Messages: 83
Registered: February 2013
Member
Works like a charm now. Thanks a lot for your help.

On 25.06.2014 14:55, Sopot Cela wrote:
> I see. There is an 'if' check in the DnDProcessor regarding the
> contributionURI so try making sure that your class is called DnDAddon
> and your package name ends with ui.workbench.addons.dndaddon. So
> something like 'my.custom.ui.workbench.addons.dndaddon.DnDAddon'.
>
> In the mean time I'll file a bug to make this easier for Mars. Let me
> know how it goes.
Re: How to prevent a part to be moved to a special stack? [message #1387716 is a reply to message #1387706] Wed, 25 June 2014 13:40 Go to previous messageGo to next message
Eclipse UserFriend
Great! Anytime.
Re: How to prevent a part to be moved to a special stack? [message #1387721 is a reply to message #1387716] Wed, 25 June 2014 13:45 Go to previous message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
Generally speaking i think we should provide a service definition which
allows people to veto moves in Mars.

Something like:

IDnDPolicyService {
public boolean allowDrop(MUIElement element, MUIElement
originalOwner, MUIElement newOwner);
}

On 25.06.14 15:40, Sopot Cela wrote:
> Great! Anytime.
Previous Topic:Provide a way to clear the workspace
Next Topic:Eclipse 4.3.2 R2 Can't Startup
Goto Forum:
  


Current Time: Tue Apr 16 21:22:31 GMT 2024

Powered by FUDForum. Page generated in 9.45394 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top