Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » configure palette dynamically
configure palette dynamically [message #198805] Thu, 24 July 2008 13:50 Go to next message
Eclipse UserFriend
Originally posted by: jacek.pospychala.pl.ibm.com

Hi,
I have read following article about configuring GMF palette:
http://help.eclipse.org/stable/index.jsp?topic=/org.eclipse. gmf.doc/tutorials/diagram/paletteConfigurationTutorial.html

But is there a way to add/remove palette elements programatically,
instead of static definition in plugin.xml (as described in above doc)?

thanks

Jacek
Re: configure palette dynamically [message #198816 is a reply to message #198805] Thu, 24 July 2008 14:37 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: ajaykemparaj.in.bosch.com

Hi Jacek,

In the PaletteFactory (this is generated ) class (Search for
createPaletteRoot in your DiagramEditor ) there are methods where you can
add the tool entries programatically.

I am attaching a sample snippet which may be useful for you ,



/**
* @generated
*/
public class SamplePaletteFactory {

private Properties properties = null;

/**
* @generated NOT
*/
public void fillPalette(PaletteRoot paletteRoot) {
paletteRoot.add(createConnection2CreationGroup());

}

private PaletteContainer createConnection2CreationGroup() {
PaletteGroup paletteContainer = new PaletteGroup("SampleTools");
paletteContainer.add(createConnection2CreationTool());
return paletteContainer;
}



/**
* @generated
*/
private ToolEntry createContainer1CreationTool() {
ToolEntry entry = new ToolEntry(
mypackage.Messages.Container1CreationTool_title,
mypackage.Messages.Container1CreationTool_desc,
null, null) {
};
return entry;
}

/**
* @generated NOT
*/
private ToolEntry createConnection2CreationTool() {
List/*<IElementType>*/types = new ArrayList/*<IElementType>*/(1);
types
.add(mypackage.diagram.providers.DiagramElementTypes.Connect ion_3003);
LinkToolEntry entry = new LinkToolEntry("User Connections",
"Sample Connections", types);
entry.setSmallIcon(DiagramHelper.getDiagramHelper().getImage Descriptor( "Sample.gif"));
entry.setDescription("Sample user defined connections");
entry.setLargeIcon(entry.getSmallIcon());
return entry;
}




/**
* @generated
*/
private static class NodeToolEntry extends ToolEntry {

/**
* @generated
*/
private final List elementTypes;

/**
* @generated
*/
private NodeToolEntry(String title, String description,
List elementTypes) {
super(title, description, null, null);
this.elementTypes = elementTypes;
}

/**
* @generated
*/
public Tool createTool() {
Tool tool = new UnspecifiedTypeCreationTool(elementTypes);
tool.setProperties(getToolProperties());
return tool;
}

}

/**
* @generated
*/
private static class LinkToolEntry extends ToolEntry {

/**
* @generated
*/
private final List relationshipTypes;

/**
* @generated
*/
private LinkToolEntry(String title, String description,
List relationshipTypes) {
super(title, description, null, null);
this.relationshipTypes = relationshipTypes;
}

/**
* @generated
*/
public Tool createTool() {
Tool tool = new UnspecifiedTypeConnectionTool(relationshipTypes);
tool.setProperties(getToolProperties());



return tool;
}
}

Regards,
Ajay K


Jacek Pospychala wrote:

> Hi,
> I have read following article about configuring GMF palette:
>
http://help.eclipse.org/stable/index.jsp?topic=/org.eclipse. gmf.doc/tutorials/diagram/paletteConfigurationTutorial.html

> But is there a way to add/remove palette elements programatically,
> instead of static definition in plugin.xml (as described in above doc)?

> thanks

> Jacek
Re: configure palette dynamically [message #198992 is a reply to message #198816] Fri, 25 July 2008 13:35 Go to previous message
Eclipse UserFriend
Originally posted by: jacek.pospychala.pl.ibm.com

Ajay, thanks for your help.
I actually meant to add tools from external plugins to an already
existing editor, which code I can't change.

Ajay pisze:
> Hi Jacek,
>
> In the PaletteFactory (this is generated ) class (Search for
> createPaletteRoot in your DiagramEditor ) there are methods where you
> can add the tool entries programatically.
>
> I am attaching a sample snippet which may be useful for you ,
>
>
>
> /**
> * @generated
> */
> public class SamplePaletteFactory {
>
> private Properties properties = null;
>
> /**
> * @generated NOT
> */
> public void fillPalette(PaletteRoot paletteRoot) {
> paletteRoot.add(createConnection2CreationGroup());
>
> }
>
> private PaletteContainer createConnection2CreationGroup() {
> PaletteGroup paletteContainer = new PaletteGroup("SampleTools");
> paletteContainer.add(createConnection2CreationTool());
> return paletteContainer;
> }
>
>
>
> /**
> * @generated
> */
> private ToolEntry createContainer1CreationTool() {
> ToolEntry entry = new ToolEntry(
> mypackage.Messages.Container1CreationTool_title,
> mypackage.Messages.Container1CreationTool_desc,
> null, null) {
> };
> return entry;
> }
>
> /**
> * @generated NOT
> */
> private ToolEntry createConnection2CreationTool() {
> List/*<IElementType>*/types = new ArrayList/*<IElementType>*/(1);
> types
>
> .add(mypackage.diagram.providers.DiagramElementTypes.Connect ion_3003);
> LinkToolEntry entry = new LinkToolEntry("User Connections",
> "Sample Connections", types);
>
> entry.setSmallIcon(DiagramHelper.getDiagramHelper().getImage Descriptor( "Sample.gif"));
>
> entry.setDescription("Sample user defined connections");
> entry.setLargeIcon(entry.getSmallIcon());
> return entry;
> }
>
>
>
>
> /**
> * @generated
> */
> private static class NodeToolEntry extends ToolEntry {
>
> /**
> * @generated
> */
> private final List elementTypes;
>
> /**
> * @generated
> */
> private NodeToolEntry(String title, String description,
> List elementTypes) {
> super(title, description, null, null);
> this.elementTypes = elementTypes;
> }
>
> /**
> * @generated
> */
> public Tool createTool() {
> Tool tool = new UnspecifiedTypeCreationTool(elementTypes);
> tool.setProperties(getToolProperties());
> return tool;
> }
>
> }
>
> /**
> * @generated
> */
> private static class LinkToolEntry extends ToolEntry {
>
> /**
> * @generated
> */
> private final List relationshipTypes;
>
> /**
> * @generated
> */
> private LinkToolEntry(String title, String description,
> List relationshipTypes) {
> super(title, description, null, null);
> this.relationshipTypes = relationshipTypes;
> }
>
> /**
> * @generated
> */
> public Tool createTool() {
> Tool tool = new
> UnspecifiedTypeConnectionTool(relationshipTypes);
> tool.setProperties(getToolProperties());
>
>
>
> return tool;
> }
> }
>
> Regards,
> Ajay K
>
>
> Jacek Pospychala wrote:
>
>> Hi,
>> I have read following article about configuring GMF palette:
>>
> http://help.eclipse.org/stable/index.jsp?topic=/org.eclipse. gmf.doc/tutorials/diagram/paletteConfigurationTutorial.html
>
>
>> But is there a way to add/remove palette elements programatically,
>> instead of static definition in plugin.xml (as described in above doc)?
>
>> thanks
>
>> Jacek
>
>
Previous Topic:audit rule doesn't work
Next Topic:Custom Shape - black ellipse inside a white one ???
Goto Forum:
  


Current Time: Tue Apr 23 08:19:12 GMT 2024

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

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

Back to the top