Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » Using pallete tools from context menu(Using pallete tools from context menu and context menu entries from palette tools)
Using pallete tools from context menu [message #899093] Mon, 30 July 2012 14:27 Go to next message
Iulian M is currently offline Iulian MFriend
Messages: 4
Registered: July 2012
Junior Member
Hello everybody!

I have a GEF graphic that contain a palette with three basic entries: 'Select', 'Add node', 'Add connection'. The context menu has 'Zoom', 'Undo', 'Redo', 'Delete' actions.

What do I want to do:
- add tool entries 'Add node' and 'Add connection' to the context menu
- add the 'Delete' action to the palette

My question is: is that possible? Is it an 'easy' way to do it without having to reimplement the logic twice?

Thank you in advance

Re: Using pallete tools from context menu [message #899230 is a reply to message #899093] Tue, 31 July 2012 07:39 Go to previous messageGo to next message
Jan Krakora is currently offline Jan KrakoraFriend
Messages: 477
Registered: December 2009
Location: Prague
Senior Member
Hi,

you have to create either an Action or a Command and a Handler for it. There you have to get the EditDomain (eg. activeEditorPart.getAdapter(EditDomain.class)) and the tool you need to activate, then you call editDomain.setActiveTool(tool).

What does it mean 'add Delete Action to the palette'?
Re: Using pallete tools from context menu [message #899249 is a reply to message #899230] Tue, 31 July 2012 08:34 Go to previous messageGo to next message
Iulian M is currently offline Iulian MFriend
Messages: 4
Registered: July 2012
Junior Member
Thanks I'll try this.

Jan Krakora wrote on Tue, 31 July 2012 03:39
Hi,
.......
What does it mean 'add Delete Action to the palette'?


I want to create a tool that does the same thing as the 'Delete' action from the context menu.
Re: Using pallete tools from context menu [message #899295 is a reply to message #899249] Tue, 31 July 2012 11:49 Go to previous messageGo to next message
Jan Krakora is currently offline Jan KrakoraFriend
Messages: 477
Registered: December 2009
Location: Prague
Senior Member
Well, I can't imagine what is that useful for, but there is a hint for you
public class MyEditor extends GraphicalEditorWithFlyoutPalette {

        ...

        @Override
	protected PaletteRoot getPaletteRoot() {
		PaletteRoot paletteRoot = ...;

		PaletteGroup group = new PaletteGroup(null);
		controlGroup.add(new ToolEntry("Delete", null, null, null, AAA.class) {});
		paletteRoot.add(controlGroup);

		return paletteRoot;
	}

	public static class AAA extends AbstractTool {

		@Override
		protected String getCommandName() {
			return null;
		}

		@Override
		public void activate() {
			super.activate();
			IAction action = ((ActionRegistry) (((DefaultEditDomain) getDomain()).getEditorPart().getAdapter(ActionRegistry.class))).getAction(ActionFactory.DELETE.getId());
			if (action.isEnabled()) {
				action.run();
			}
			setState(STATE_TERMINAL);
			handleFinished();
		}
	}

        ...
}
Re: Using pallete tools from context menu [message #900577 is a reply to message #899295] Tue, 07 August 2012 15:40 Go to previous messageGo to next message
Iulian M is currently offline Iulian MFriend
Messages: 4
Registered: July 2012
Junior Member
Thanks a lot Jan!
I managed to implement the required functionality using your 'hints' Very Happy
Re: Using pallete tools from context menu [message #901673 is a reply to message #900577] Tue, 14 August 2012 05:23 Go to previous messageGo to next message
Karthikeyan Missing name is currently offline Karthikeyan Missing nameFriend
Messages: 47
Registered: July 2011
Member
Hi,

Have you achieved that one. If so kindly post the code, me too in need of that one.

index.php/fa/11174/0/

Thanks & Regards,
Karthikeyan.B

[Updated on: Tue, 14 August 2012 05:24]

Report message to a moderator

Re: Using pallete tools from context menu [message #902905 is a reply to message #900577] Tue, 21 August 2012 05:11 Go to previous messageGo to next message
Karthikeyan Missing name is currently offline Karthikeyan Missing nameFriend
Messages: 47
Registered: July 2011
Member
Hi,

Have you achieved that above one. We too in need to provide connection in our context menu. If you have achieved, kindly let me know the steps. We have created the connection and set active tool as connectionCreationTool, but its feedback dummy connection is not get created.

Thanks & Regards,
Karthikeyan.B
Re: Using pallete tools from context menu [message #909085 is a reply to message #902905] Thu, 06 September 2012 14:00 Go to previous message
Iulian M is currently offline Iulian MFriend
Messages: 4
Registered: July 2012
Junior Member
Hi,
If you have the connectionCreationTool then it should be simple: create the action that will be added to the context menu, and in the 'run' method just call 'editDomain.setActiveTool(connectionCreationTool)' like Jan said
Previous Topic:how can i chage connection rulles of gef logic example
Next Topic:Moving parent
Goto Forum:
  


Current Time: Thu Apr 18 21:34:44 GMT 2024

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

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

Back to the top