Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/palette/PaletteFactory.xpt')
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/palette/PaletteFactory.xpt278
1 files changed, 278 insertions, 0 deletions
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/palette/PaletteFactory.xpt b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/palette/PaletteFactory.xpt
new file mode 100644
index 000000000..70b2d2be3
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/editor/palette/PaletteFactory.xpt
@@ -0,0 +1,278 @@
+/*
+ * Copyright (c) 2006, 2008 Borland Software Corporation
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Artem Tikhomirov (Borland) - initial API and implementation
+ */
+
+«IMPORT 'http://www.eclipse.org/gmf/2008/GenModel'»
+«IMPORT 'http://www.eclipse.org/emf/2002/Ecore'»
+«EXTENSION xpt::editor::palette::Utils»
+
+«DEFINE Factory FOR gmfgen::Palette»
+«EXPAND xpt::Common::copyright FOR diagram.editorGen-»
+package «packageName»;
+
+«EXPAND xpt::Common::generatedClassComment»
+public class «factoryClassName» {
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ public void fillPalette(org.eclipse.gef.palette.PaletteRoot paletteRoot) {
+«IF definesStandardTools()-»
+ cleanStandardTools(paletteRoot);
+«ENDIF-»
+ «EXPAND addEntry('paletteRoot') FOREACH groups-»
+ }
+«IF definesStandardTools()»
+«EXPAND cleanStandardToolsHack-»
+«ENDIF-»
+
+«EXPAND createGroup FOREACH collectGroups(self)»
+«EXPAND createEntry FOREACH collectTools(self)»
+
+«IF needsNodeToolEntryClass(self)»«EXPAND nodeToolEntry»«ENDIF-»
+«IF needsLinkToolEntryClass(self)»«EXPAND linkToolEntry»«ENDIF-»
+}
+«ENDDEFINE»
+
+«DEFINE createGroup FOR gmfgen::ToolGroup-»
+ «EXPAND xpt::Common::generatedMemberComment('Creates "' + title + '" palette tool group')»
+ private org.eclipse.gef.palette.PaletteContainer «createMethodName»() {
+ «EXPAND newContainer('paletteContainer')-»
+ «EXPAND setDescription('paletteContainer', self) FOR description-»
+ «EXPAND setSmallImage('paletteContainer', palette)-»
+ «EXPAND setLargeImage('paletteContainer', palette)-»
+ «EXPAND addEntry('paletteContainer') FOREACH entries-»
+ return paletteContainer;
+ }
+«ENDDEFINE»
+
+«DEFINE newContainer(varName : String) FOR gmfgen::ToolGroup-»
+«IF collapse and toolsOnly-»
+ org.eclipse.gef.palette.PaletteDrawer «varName» = new org.eclipse.gef.palette.PaletteDrawer(«EXPAND i18nTitle»);
+«ELSEIF stack-»
+ org.eclipse.gef.palette.PaletteStack «varName» = new org.eclipse.gef.palette.PaletteStack(«EXPAND i18nTitle», null, null);
+«ELSE-»
+ org.eclipse.gef.palette.PaletteGroup «varName» = new org.eclipse.gef.palette.PaletteGroup(«EXPAND i18nTitle»);
+«ENDIF-»
+«ENDDEFINE»
+
+«DEFINE setDescription(varName : String, gr : gmfgen::ToolGroup) FOR String-»
+«varName».setDescription(«EXPAND i18nDesc FOR gr»);
+«ENDDEFINE»
+
+«DEFINE addEntry(varName : String) FOR gmfgen::ToolGroupItem»
+«ERROR 'abstract addEntry(ToolGroupItem,String) template'»
+«ENDDEFINE»
+
+«DEFINE addEntry(varName : String) FOR gmfgen::AbstractToolEntry-»
+«varName».add(«createMethodName»());
+«IF _default and group.stack-»
+«varName».setActiveEntry((org.eclipse.gef.palette.ToolEntry) paletteContainer.getChildren().get(paletteContainer.getChildren().size() - 1));
+«ENDIF-»
+«ENDDEFINE»
+
+«DEFINE addEntry(varName : String) FOR gmfgen::Separator-»
+«varName».add(new org.eclipse.gef.palette.PaletteSeparator());
+«ENDDEFINE»
+
+«DEFINE addEntry(varName : String) FOR gmfgen::ToolGroup-»
+«varName».add(«createMethodName»());
+«ENDDEFINE»
+
+«DEFINE createEntry FOR gmfgen::AbstractToolEntry-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ private org.eclipse.gef.palette.ToolEntry «createMethodName»() {
+ «EXPAND newEntry('entry')-»
+ «EXPAND setSmallImage('entry', group.palette)-»
+ «EXPAND setLargeImage('entry', group.palette)-»
+ «EXPAND setToolClass('entry')-»
+ «EXPAND setToolProperty('entry') FOREACH properties-»
+ return entry;
+ }
+«ENDDEFINE»
+
+«DEFINE newEntry(toolVarName : String) FOR gmfgen::AbstractToolEntry-»
+«ERROR 'abstract newEntry(AbstractToolEntry,String) template'»
+«ENDDEFINE»
+
+«DEFINE newEntry(toolVarName : String) FOR gmfgen::ToolEntry-»
+«IF elements->isEmpty()-»
+org.eclipse.gef.palette.ToolEntry «toolVarName» = new org.eclipse.gef.palette.ToolEntry(«EXPAND i18nTitle», «EXPAND i18nDesc», null, null) {};
+«ELSE-»
+«LET (if genNodes->isEmpty() then 'LinkToolEntry' else 'NodeToolEntry' endif) AS toolEntryClass-»
+java.util.List/*<IElementType>*/ types = new java.util.ArrayList/*<IElementType>*/(«elements->size()»);
+«FOREACH elements->asSequence() AS e-»
+types.add(«EXPAND xpt::providers::ElementTypes::accessElementType FOR e»);
+«ENDFOREACH-»
+«toolEntryClass» «toolVarName» = new «toolEntryClass»(«EXPAND i18nTitle», «EXPAND i18nDesc», types);
+«ENDLET-»
+«ENDIF-»
+«ENDDEFINE»
+
+«DEFINE newEntry(toolVarName : String) FOR gmfgen::StandardEntry-»
+«IF gmfgen::StandardEntryKind::SELECT = kind -»
+«EXPAND newStdSelectEntry(toolVarName)-»
+«ELSEIF kind = gmfgen::StandardEntryKind::MARQUEE-»
+«EXPAND newStdMarqueeEntry(toolVarName)-»
+«ELSEIF kind = gmfgen::StandardEntryKind::ZOOM-»
+«EXPAND newStdZoomEntry(toolVarName)-»
+«ELSE-»
+«EXPAND newStdOtherEntry(toolVarName)-»
+«ENDIF-»
+«ENDDEFINE»
+
+«DEFINE newStdSelectEntry(toolVarName : String) FOR gmfgen::StandardEntry-»
+org.eclipse.gef.palette.PanningSelectionToolEntry «toolVarName» = new org.eclipse.gef.palette.PanningSelectionToolEntry();
+«ENDDEFINE»
+
+«DEFINE newStdMarqueeEntry(toolVarName : String) FOR gmfgen::StandardEntry-»
+org.eclipse.gef.palette.MarqueeToolEntry «toolVarName» = new org.eclipse.gef.palette.MarqueeToolEntry();
+«ENDDEFINE»
+
+«DEFINE newStdZoomEntry(toolVarName : String) FOR gmfgen::StandardEntry-»
+FIXME
+«ENDDEFINE»
+
+«DEFINE newStdOtherEntry(toolVarName : String) FOR gmfgen::StandardEntry-»
+«ERROR 'override newStdOtherEntry(StandardEntry, String) for kind ' + kind.repr()»
+«ENDDEFINE»
+
+// FIXME: odd code - FOR EntryBase, while most of the template is valid for ToolEntry only!!!
+«DEFINE setSmallImage(toolVarName : String, palette : gmfgen::Palette) FOR gmfgen::EntryBase-»
+«IF null <> smallIconPath-»
+«toolVarName».setSmallIcon(«palette.activatorFQN()».findImageDescriptor("«smallIconPath»"));«EXPAND xpt::Common::nonNLS»
+«ELSEIF not (Sequence { self })[gmfgen::ToolEntry].elements->isEmpty()-»
+«LET self.oclAsType(gmfgen::ToolEntry) AS toolEntry-»
+«toolVarName».setSmallIcon(«palette.diagram.getElementTypesQualifiedClassName()».getImageDescriptor(«EXPAND xpt::providers::ElementTypes::accessElementType FOR toolEntry.elements->first().oclAsType(gmfgen::GenCommonBase)»));
+«ENDLET-»
+«ENDIF-»
+«ENDDEFINE»
+
+«DEFINE setLargeImage(toolVarName : String, palette : gmfgen::Palette) FOR gmfgen::EntryBase-»
+«IF null <> largeIconPath-»
+«toolVarName».setLargeIcon(«palette.activatorFQN()».findImageDescriptor("«largeIconPath»")); «EXPAND xpt::Common::nonNLS»
+«ELSEIF not (Sequence { self })[gmfgen::ToolEntry].elements->isEmpty()-»
+«toolVarName».setLargeIcon(«toolVarName».getSmallIcon());
+«ENDIF-»
+«ENDDEFINE»
+
+«DEFINE setToolClass(toolVarName : String) FOR gmfgen::AbstractToolEntry-»
+«IF null <> qualifiedToolName-»
+«toolVarName».setToolClass(«qualifiedToolName».class);
+«ENDIF-»
+«ENDDEFINE»
+
+«DEFINE setToolProperty(toolVarName : String) FOR ecore::EStringToStringMapEntry-»
+«toolVarName».setToolProperty(«key», «value»);
+«ENDDEFINE»
+
+«DEFINE i18nTitle FOR gmfgen::ToolEntry-»
+«IF title = null»null«ELSE»«EXPAND xpt::Externalizer::accessorCall(i18nTitleKey(self)) FOR group.palette.diagram.editorGen»«ENDIF-»
+«ENDDEFINE»
+
+«DEFINE i18nTitle FOR gmfgen::ToolGroup-»
+«IF title = null»null«ELSE»«EXPAND xpt::Externalizer::accessorCall(i18nTitleKey(self)) FOR palette.diagram.editorGen»«ENDIF-»
+«ENDDEFINE»
+
+«DEFINE i18nDesc FOR gmfgen::ToolEntry-»
+«IF null = description»null«ELSE»«EXPAND xpt::Externalizer::accessorCall(i18nDescKey(self)) FOR group.palette.diagram.editorGen»«ENDIF-»
+«ENDDEFINE»
+
+«DEFINE i18nDesc FOR gmfgen::ToolGroup-»
+«IF null = description»null«ELSE»«EXPAND xpt::Externalizer::accessorCall(i18nDescKey(self)) FOR palette.diagram.editorGen»«ENDIF-»
+«ENDDEFINE»
+
+«DEFINE i18nAccessors FOR gmfgen::Palette-»
+«EXPAND internal_i18n_accessors FOREACH collectGroups(self)-»
+«EXPAND internal_i18n_accessors FOREACH collectTools(self)-»
+«ENDDEFINE»
+
+«DEFINE i18nValues FOR gmfgen::Palette-»
+«EXPAND internal_i18n_values FOREACH collectGroups(self)-»
+«EXPAND internal_i18n_values FOREACH collectTools(self)-»
+«ENDDEFINE»
+
+«DEFINE internal_i18n_accessors FOR gmfgen::EntryBase-»
+«IF null <> title»«EXPAND xpt::Externalizer::accessorField(i18nTitleKey(self))»«ENDIF-»
+«IF null <> description»«EXPAND xpt::Externalizer::accessorField(i18nDescKey(self))»«ENDIF-»
+«ENDDEFINE»
+
+«DEFINE internal_i18n_values FOR gmfgen::EntryBase-»
+«IF null <> title»«EXPAND xpt::Externalizer::messageEntry(i18nTitleKey(self), title)»«ENDIF-»
+«IF null <> description»«EXPAND xpt::Externalizer::messageEntry(i18nDescKey(self), description)»«ENDIF-»
+«ENDDEFINE»
+
+«DEFINE cleanStandardToolsHack FOR gmfgen::Palette»
+ «EXPAND xpt::Common::generatedMemberComment('Workaround for https://bugs.eclipse.org/bugs/show_bug.cgi?id=159289')»
+ private void cleanStandardTools(org.eclipse.gef.palette.PaletteRoot paletteRoot) {
+ for (java.util.Iterator it = paletteRoot.getChildren().iterator(); it.hasNext();) {
+ org.eclipse.gef.palette.PaletteEntry entry = (org.eclipse.gef.palette.PaletteEntry) it.next();
+ if (!"standardGroup".equals(entry.getId())) { «EXPAND xpt::Common::nonNLS»
+ continue;
+ }
+ for (java.util.Iterator it2 = ((org.eclipse.gef.palette.PaletteContainer) entry).getChildren().iterator(); it2.hasNext();) {
+ org.eclipse.gef.palette.PaletteEntry entry2 = (org.eclipse.gef.palette.PaletteEntry) it2.next();
+ if ("zoomTool".equals(entry2.getId())) { «EXPAND xpt::Common::nonNLS»
+ it2.remove();
+ } else if ("noteStack".equals(entry2.getId())) { «EXPAND xpt::Common::nonNLS»
+ it2.remove();
+ } else if ("selectionTool".equals(entry2.getId())) { «EXPAND xpt::Common::nonNLS»
+ it2.remove();
+ }
+ if (paletteRoot.getDefaultEntry() == entry2) {
+ paletteRoot.setDefaultEntry(null);
+ }
+ }
+ }
+ }
+«ENDDEFINE»
+
+«DEFINE nodeToolEntry FOR OclAny»
+ «EXPAND xpt::Common::generatedClassComment»
+ private static class NodeToolEntry extends org.eclipse.gef.palette.ToolEntry {
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ private final java.util.List elementTypes;
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ private NodeToolEntry(String title, String description, java.util.List elementTypes) {
+ super(title, description, null, null);
+ this.elementTypes = elementTypes;
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ public org.eclipse.gef.Tool createTool() {
+ org.eclipse.gef.Tool tool = new org.eclipse.gmf.runtime.diagram.ui.tools.UnspecifiedTypeCreationTool(elementTypes);
+ tool.setProperties(getToolProperties());
+ return tool;
+ }
+ }
+«ENDDEFINE»
+
+«DEFINE linkToolEntry FOR OclAny»
+ «EXPAND xpt::Common::generatedClassComment»
+ private static class LinkToolEntry extends org.eclipse.gef.palette.ToolEntry {
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ private final java.util.List relationshipTypes;
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ private LinkToolEntry(String title, String description, java.util.List relationshipTypes) {
+ super(title, description, null, null);
+ this.relationshipTypes = relationshipTypes;
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ public org.eclipse.gef.Tool createTool() {
+ org.eclipse.gef.Tool tool = new org.eclipse.gmf.runtime.diagram.ui.tools.UnspecifiedTypeConnectionTool(relationshipTypes);
+ tool.setProperties(getToolProperties());
+ return tool;
+ }
+ }
+«ENDDEFINE»

Back to the top