Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Graphiti » Hide create feature of pattern from palette
Hide create feature of pattern from palette [message #1403373] Wed, 23 July 2014 10:34 Go to next message
Homer S is currently offline Homer SFriend
Messages: 13
Registered: June 2014
Junior Member
In my editor project I am currently using the pattern based approach.

I would like to know if it is possible to hide a specific pattern implementation from the Objects palette, as if there doesn't exist a create feature when one would use the feature based approach.

Thanks in advance.
Re: Hide create feature of pattern from palette [message #1403708 is a reply to message #1403373] Fri, 25 July 2014 13:05 Go to previous messageGo to next message
Michael Wenz is currently offline Michael WenzFriend
Messages: 1894
Registered: July 2009
Location: Walldorf, Germany
Senior Member
Homer,

by default the DefaultToolBehaviorProvider will add entries for all create
create and create connection features provided by the feature provider. You
may change that by overriding getPalette in your tool behavior provider.

Michael
Re: Hide create feature of pattern from palette [message #1405110 is a reply to message #1403708] Wed, 06 August 2014 16:02 Go to previous messageGo to next message
Homer S is currently offline Homer SFriend
Messages: 13
Registered: June 2014
Junior Member
Thanks for the hint.
For anyone who is using patterns and interested in my solution:

public class MyToolBehaviourProvider extends DefaultToolBehaviorProvider {

	public MyToolBehaviourProvider(IDiagramTypeProvider diagramTypeProvider) {
		super(diagramTypeProvider);
	}

	@Override
	public IPaletteCompartmentEntry[] getPalette() {
		// array of labels of tool entries to hide 
		String[] toolsToHide = new String[] { <CreateNameOfFeaturesToBeHidden> };

		// iterate connection and object creation entries
		IPaletteCompartmentEntry[] compartments = super.getPalette();
		for (IPaletteCompartmentEntry compartmentEntry : compartments) {
			Iterator<IToolEntry> it = compartmentEntry.getToolEntries().iterator();
			while (it.hasNext()) {
				IToolEntry toolEntry = it.next();
				// delete when array contains label of current tool entry
				if (Arrays.asList(toolsToHide).contains(toolEntry.getLabel())) {
					it.remove();
				}

			}
		}
		return compartments;
	}
}
Re: Hide create feature of pattern from palette [message #1691151 is a reply to message #1405110] Thu, 02 April 2015 14:56 Go to previous message
Manisha Ghule is currently offline Manisha GhuleFriend
Messages: 6
Registered: April 2015
Junior Member
I am not sure which version of Graphiti was used in the question; but I could achieve the same by overriding isPaletteApplicable() method in my pattern class (returned false in this overridden version).
Previous Topic:Palette-Items Customize before/at Editor start
Next Topic:Local build with buckminster
Goto Forum:
  


Current Time: Mon Jul 16 23:50:45 GMT 2018

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

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

Back to the top