Community
Participate
Working Groups
A regression introduced in GEF 3.7 now that EditParts have to be explicitly selectable when AbstractEditPart.setSelected(true) is called. I have a GEF Editor with Pallete. The PaletteRoot class uses all of the new Marquee Selection Tools introduced in GEF 3.7 to create them in a PaletteStack in a PaletteToolbar. Like this: public PaletteToolbar createControlsGroup() { PaletteToolbar toolbar = new PaletteToolbar("Tools"); PaletteStack stack = new PaletteStack("Marquee Selection Tools", "Selection Tools", null); toolbar.add(stack); MarqueeToolEntry marquee = new MarqueeToolEntry("Select contained nodes and related connections"); marquee.setToolProperty(MarqueeSelectionTool.PROPERTY_MARQUEE_BEHAVIOR, new Integer(MarqueeSelectionTool.BEHAVIOR_NODES_CONTAINED_AND_RELATED_CONNECTIONS)); stack.add(marquee); marquee = new MarqueeToolEntry("Select touched nodes and related connections"); marquee.setToolProperty(MarqueeSelectionTool.PROPERTY_MARQUEE_BEHAVIOR, new Integer(MarqueeSelectionTool.BEHAVIOR_NODES_TOUCHED_AND_RELATED_CONNECTIONS)); stack.add(marquee); marquee = new MarqueeToolEntry("Select contained connections"); marquee.setToolProperty(MarqueeSelectionTool.PROPERTY_MARQUEE_BEHAVIOR, new Integer(MarqueeSelectionTool.BEHAVIOR_CONNECTIONS_CONTAINED)); stack.add(marquee); marquee = new MarqueeToolEntry("Select touched connections"); marquee.setToolProperty(MarqueeSelectionTool.PROPERTY_MARQUEE_BEHAVIOR, new Integer(MarqueeSelectionTool.BEHAVIOR_CONNECTIONS_TOUCHED)); stack.add(marquee); marquee = new MarqueeToolEntry("Select contained nodes"); marquee.setToolProperty(MarqueeSelectionTool.PROPERTY_MARQUEE_BEHAVIOR, new Integer(MarqueeSelectionTool.BEHAVIOR_NODES_CONTAINED)); stack.add(marquee); marquee = new MarqueeToolEntry("Select touched nodes"); marquee.setToolProperty(MarqueeSelectionTool.PROPERTY_MARQUEE_BEHAVIOR, new Integer(MarqueeSelectionTool.BEHAVIOR_NODES_TOUCHED)); stack.add(marquee); return toolbar; } The problem occurs when the user selects a different Marquee selection tool from the PaletteStack: java.lang.IllegalArgumentException: An EditPart has to be selectable (isSelectable() == true) in order to get selected. at org.eclipse.core.runtime.Assert.isLegal(Assert.java:63) at org.eclipse.gef.editparts.AbstractEditPart.setSelected(AbstractEditPart.java:1060) at org.eclipse.gef.internal.ui.palette.editparts.ToolEntryEditPart.setSelected(ToolEntryEditPart.java:525) at org.eclipse.gef.SelectionManager.appendSelection(SelectionManager.java:75) at org.eclipse.gef.ui.parts.AbstractEditPartViewer.appendSelection(AbstractEditPartViewer.java:190) at org.eclipse.gef.ui.actions.SetActivePaletteToolAction.run(SetActivePaletteToolAction.java:63) at org.eclipse.jface.action.Action.runWithEvent(Action.java:498) at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:584) at org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java:501) at org.eclipse.jface.action.ActionContributionItem$5.handleEvent(ActionContributionItem.java:411) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1053) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4165) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3754) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2696) at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2660) at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2494) at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:674) at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:667) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149) at uk.ac.bolton.archimate.editor.Application.start(Application.java:59) 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:344) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:622) at org.eclipse.equinox.launcher.Main.basicRun(Main.java:577) at org.eclipse.equinox.launcher.Main.run(Main.java:1410) at org.eclipse.equinox.launcher.Main.main(Main.java:1386)
Created attachment 197838 [details] Patch to show the bug Attached is a patch for the ShapesEditorPaletteFactory.java file in the Shapes example. This adds a PaletteStack with the Marquee Selection tools. Run it and create a Shapes example. Change the marquee selection tool in the PaletteStack a few times. Keep you eye on the Console for the exception...
I changed the title of the bug because it happens with any ToolEntry in a PaletteStack and thus any ToolEntryEditPart. My MarqueeToolEntry example still shows a good case of the bug, though.
As this used to work in GEF 3.6, some debugging reveals changes in 3.7: AbstractEditPart.setSelected() asserts the following: Assert.isLegal( isSelectable() || value == SELECTED_NONE, "An EditPart has to be selectable (isSelectable() == true) in order to get selected."); //$NON-NLS-1$ New to 3.7 in AbstractGraphicalEditPart: public boolean isSelectable() { return super.isSelectable() && getFigure() != null && getFigure().isShowing(); } So perhaps getFigure().isShowing() returns false?
Yes, the selection methods have been changed as part of bug #330859, to prevent graphical edit parts without visible figures from becoming selected. I will take a look on how to address this issue. I will take a look at the problem to identify what is the best solution to deal with this in ToolEntryEditParts.
(In reply to comment #4) > Yes, the selection methods have been changed as part of bug #330859, to prevent > graphical edit parts without visible figures from becoming selected. I will > take a look on how to address this issue. > > I will take a look at the problem to identify what is the best solution to deal > with this in ToolEntryEditParts. Thanks, Alexander. I would be very happy if a solution could be found. GEF 3.7 looks good so far, fixing many things on Mac ;-) but this issue has broken our Palettes in our proposed Archi application version 2.0 (http://archi.cetis.ac.uk). If it is not possible to fix this soon, I would be happy to help with a workaround. Regards, Phil
Created attachment 197881 [details] Patch for PaletteEditPart I think the best solution will probably be to overwrite isSelectable within PaletteEditPart. I have attached a patch that demonstrates this. However, 3.7 is already frozen, so we may not apply this before 3.7.1.
OK. I can understand the freeze on 3.7. As a workaround that doesn't require patching GEF itself I created this class: public class TempPaletteEditPartFactory extends PaletteEditPartFactory { @Override protected EditPart createEntryEditPart(EditPart parentEditPart, Object model) { return new ToolEntryEditPart((PaletteEntry) model) { @Override public boolean isSelectable() { return getFigure() != null; } }; } } Then in my GraphicalEditorWithFlyoutPalette instance over-ride createPaletteViewerProvider(): @Override protected PaletteViewerProvider createPaletteViewerProvider() { return new PaletteViewerProvider(getEditDomain()) { @Override protected void hookPaletteViewer(PaletteViewer viewer) { viewer.setEditPartFactory(new TempPaletteEditPartFactory()); super.hookPaletteViewer(viewer); } }; } So far this works. Do you see any problems with this?
No, looks as a good temporary workaround until 3.7 RC1 is out.
(In reply to comment #8) > No, looks as a good temporary workaround until 3.7 RC1 is out. I meant 3.7 SR1 of course :-).
Is there a current 3.7.1 development stream open now that this could be fixed in?
(In reply to comment #10) > Is there a current 3.7.1 development stream open now that this could be fixed > in? Yes, we can add it to the 3.7 maintenance branch, but ... I was quite sure I could reproduce it with the logic editor, which I am currently not able to do? Is it reproducible for you, using the logic example?
Created attachment 199310 [details] Patch to show bug in Logic example It only throws the exception if the PaletteStack is a child of a PaletteToolbar. Patch attached to show this. Select different marquee tools until the exception is thrown.
isSelected() is now overwritten within PaletteEditPart to ensure PaletteEditParts are always selectable by default. Committed changes to R_3_7_maintenance branch as well as HEAD. Resolving as fixed.
This fix looks important, but I don't see any consumable 3.7.1 builds yet ? Will these be made available anytime soon ?
Well, maybe we could run an integration build tomorrow. Anthony?
(In reply to comment #15) > Well, maybe we could run an integration build tomorrow. Anthony? +1
Comment on attachment 199310 [details] Patch to show bug in Logic example This patch was only used to reproduce the issue. Marking it as obsolete.