Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordstadnik2006-02-23 15:46:48 +0000
committerdstadnik2006-02-23 15:46:48 +0000
commit2d27770ccea726cd3a448759299b2448322f8d86 (patch)
tree7accc647c0852250fd8b7abd3c371af1dcd3e9e0 /plugins/org.eclipse.gmf.codegen.ui
parente1d1cdb37a9ef131f2b3cad277dfa546db65a9be (diff)
downloadorg.eclipse.gmf-tooling-2d27770ccea726cd3a448759299b2448322f8d86.tar.gz
org.eclipse.gmf-tooling-2d27770ccea726cd3a448759299b2448322f8d86.tar.xz
org.eclipse.gmf-tooling-2d27770ccea726cd3a448759299b2448322f8d86.zip
#126532 Allow to manually resolve domain entity into node or link in wizards that infer tooling and graph definitions from domain model
Diffstat (limited to 'plugins/org.eclipse.gmf.codegen.ui')
-rw-r--r--plugins/org.eclipse.gmf.codegen.ui/icons/full/obj16/checked.gifbin0 -> 343 bytes
-rw-r--r--plugins/org.eclipse.gmf.codegen.ui/icons/full/obj16/unchecked.gifbin0 -> 148 bytes
-rw-r--r--plugins/org.eclipse.gmf.codegen.ui/src/org/eclipse/gmf/internal/codegen/CodeGenUIPlugin.java10
-rw-r--r--plugins/org.eclipse.gmf.codegen.ui/src/org/eclipse/gmf/internal/codegen/resolver/Resolution.java45
-rw-r--r--plugins/org.eclipse.gmf.codegen.ui/src/org/eclipse/gmf/internal/codegen/resolver/ResolvedItem.java91
-rw-r--r--plugins/org.eclipse.gmf.codegen.ui/src/org/eclipse/gmf/internal/codegen/resolver/StructureBuilder.java66
-rw-r--r--plugins/org.eclipse.gmf.codegen.ui/src/org/eclipse/gmf/internal/codegen/wizards/DefinitionPage.java209
-rw-r--r--plugins/org.eclipse.gmf.codegen.ui/src/org/eclipse/gmf/internal/codegen/wizards/GMFGraphSimpleModelWizard.java104
-rw-r--r--plugins/org.eclipse.gmf.codegen.ui/src/org/eclipse/gmf/internal/codegen/wizards/GMFToolSimpleModelWizard.java86
-rw-r--r--plugins/org.eclipse.gmf.codegen.ui/src/org/eclipse/gmf/internal/codegen/wizards/GraphDefBuilder.java118
-rw-r--r--plugins/org.eclipse.gmf.codegen.ui/src/org/eclipse/gmf/internal/codegen/wizards/ToolDefBuilder.java86
-rw-r--r--plugins/org.eclipse.gmf.codegen.ui/src/org/eclipse/gmf/internal/codegen/wizards/WizardUtil.java19
12 files changed, 602 insertions, 232 deletions
diff --git a/plugins/org.eclipse.gmf.codegen.ui/icons/full/obj16/checked.gif b/plugins/org.eclipse.gmf.codegen.ui/icons/full/obj16/checked.gif
new file mode 100644
index 000000000..9cacb96dc
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen.ui/icons/full/obj16/checked.gif
Binary files differ
diff --git a/plugins/org.eclipse.gmf.codegen.ui/icons/full/obj16/unchecked.gif b/plugins/org.eclipse.gmf.codegen.ui/icons/full/obj16/unchecked.gif
new file mode 100644
index 000000000..f6b9f8a59
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen.ui/icons/full/obj16/unchecked.gif
Binary files differ
diff --git a/plugins/org.eclipse.gmf.codegen.ui/src/org/eclipse/gmf/internal/codegen/CodeGenUIPlugin.java b/plugins/org.eclipse.gmf.codegen.ui/src/org/eclipse/gmf/internal/codegen/CodeGenUIPlugin.java
index c5fa65e8f..6744b9f38 100644
--- a/plugins/org.eclipse.gmf.codegen.ui/src/org/eclipse/gmf/internal/codegen/CodeGenUIPlugin.java
+++ b/plugins/org.eclipse.gmf.codegen.ui/src/org/eclipse/gmf/internal/codegen/CodeGenUIPlugin.java
@@ -30,6 +30,8 @@ public class CodeGenUIPlugin extends AbstractUIPlugin {
public static final String TDM_ICON = "/icons/full/obj16/GMFToolModelFile.gif";
public static final String MM_ICON = "/icons/full/obj16/GMFMapModelFile.gif";
public static final String GM_ICON = "/icons/full/obj16/GMFGenModelFile.gif";
+ public static final String CHECKED_ICON = "/icons/full/obj16/checked.gif";
+ public static final String UNCHECKED_ICON = "/icons/full/obj16/unchecked.gif";
private static CodeGenUIPlugin plugin;
@@ -75,6 +77,14 @@ public class CodeGenUIPlugin extends AbstractUIPlugin {
if (id != null) {
reg.put(GM_ICON, id);
}
+ id = imageDescriptorFromPlugin(getBundle().getSymbolicName(), CHECKED_ICON);
+ if (id != null) {
+ reg.put(CHECKED_ICON, id);
+ }
+ id = imageDescriptorFromPlugin(getBundle().getSymbolicName(), UNCHECKED_ICON);
+ if (id != null) {
+ reg.put(UNCHECKED_ICON, id);
+ }
}
public static String getBundleString(String key) {
diff --git a/plugins/org.eclipse.gmf.codegen.ui/src/org/eclipse/gmf/internal/codegen/resolver/Resolution.java b/plugins/org.eclipse.gmf.codegen.ui/src/org/eclipse/gmf/internal/codegen/resolver/Resolution.java
new file mode 100644
index 000000000..2a531e374
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen.ui/src/org/eclipse/gmf/internal/codegen/resolver/Resolution.java
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2006 Eclipse.org
+ *
+ * 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:
+ * Dmitry Stadnik - initial API and implementation
+ */
+package org.eclipse.gmf.internal.codegen.resolver;
+
+/**
+ * @author dstadnik
+ */
+public class Resolution {
+
+ public static final Resolution NODE = new Resolution("Node");
+
+ public static final Resolution LINK = new Resolution("Link");
+
+ public static final Resolution LABEL = new Resolution("Label");
+
+ private final String name;
+
+ private Resolution(String name) {
+ this.name = name;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public static Resolution getByName(String name) {
+ if (NODE.name.equals(name)) {
+ return NODE;
+ } else if (LINK.name.equals(name)) {
+ return LINK;
+ } else if (LABEL.name.equals(name)) {
+ return LABEL;
+ }
+ return null;
+ }
+}
diff --git a/plugins/org.eclipse.gmf.codegen.ui/src/org/eclipse/gmf/internal/codegen/resolver/ResolvedItem.java b/plugins/org.eclipse.gmf.codegen.ui/src/org/eclipse/gmf/internal/codegen/resolver/ResolvedItem.java
new file mode 100644
index 000000000..99a9da23e
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen.ui/src/org/eclipse/gmf/internal/codegen/resolver/ResolvedItem.java
@@ -0,0 +1,91 @@
+/*
+ * Copyright (c) 2006 Eclipse.org
+ *
+ * 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:
+ * Dmitry Stadnik - initial API and implementation
+ */
+package org.eclipse.gmf.internal.codegen.resolver;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author dstadnik
+ */
+public class ResolvedItem {
+
+ public static final Resolution[] DEFAULT_RESOLUTIONS = { null };
+
+ public static final Resolution[] ALL_RESOLUTIONS = { null, Resolution.NODE, Resolution.LINK, Resolution.LABEL };
+
+ public static final Resolution[] NODE_LINK_RESOLUTIONS = { null, Resolution.NODE, Resolution.LINK };
+
+ public static final Resolution[] LINK_RESOLUTIONS = { null, Resolution.LINK };
+
+ public static final Resolution[] LABEL_RESOLUTIONS = { null, Resolution.LABEL };
+
+ private Resolution resolution;
+
+ private Object domainRef;
+
+ private Resolution[] possibleResolutions;
+
+ private ResolvedItem parent;
+
+ private List children = new ArrayList();
+
+ public ResolvedItem(Resolution resolution, Object domainRef, Resolution[] possibleResolutions) {
+ this.resolution = resolution;
+ this.domainRef = domainRef;
+ this.possibleResolutions = possibleResolutions;
+ }
+
+ public Resolution[] getPossibleResolutions() {
+ return possibleResolutions;
+ }
+
+ public boolean isPossibleResolution(Resolution possibleResolution) {
+ for (int i = 0; i < possibleResolutions.length; i++) {
+ if (possibleResolutions[i] == possibleResolution) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public Resolution getResolution() {
+ return resolution;
+ }
+
+ public void setResolution(Resolution resolution) {
+ this.resolution = resolution;
+ }
+
+ public Object getDomainRef() {
+ return domainRef;
+ }
+
+ public ResolvedItem getParent() {
+ return parent;
+ }
+
+ public void addChild(ResolvedItem child) {
+ children.add(child);
+ child.parent = this;
+ }
+
+ public void removeChild(ResolvedItem child) {
+ if (children.remove(child)) {
+ child.parent = null;
+ }
+ }
+
+ public List getChildren() {
+ return children;
+ }
+}
diff --git a/plugins/org.eclipse.gmf.codegen.ui/src/org/eclipse/gmf/internal/codegen/resolver/StructureBuilder.java b/plugins/org.eclipse.gmf.codegen.ui/src/org/eclipse/gmf/internal/codegen/resolver/StructureBuilder.java
new file mode 100644
index 000000000..fe1af01a6
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen.ui/src/org/eclipse/gmf/internal/codegen/resolver/StructureBuilder.java
@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) 2006 Eclipse.org
+ *
+ * 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:
+ * Dmitry Stadnik - initial API and implementation
+ */
+package org.eclipse.gmf.internal.codegen.resolver;
+
+import java.util.Iterator;
+
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EPackage;
+
+/**
+ * @author dstadnik
+ */
+public class StructureBuilder {
+
+ private StructureResolver resolver;
+
+ public StructureBuilder(StructureResolver resolver) {
+ this.resolver = resolver;
+ }
+
+ public ResolvedItem process(EPackage domainPackage) {
+ ResolvedItem item = new ResolvedItem(null, domainPackage, ResolvedItem.DEFAULT_RESOLUTIONS);
+ for (Iterator it = domainPackage.getEClassifiers().iterator(); it.hasNext();) {
+ Object next = it.next();
+ if (next instanceof EClass) {
+ item.addChild(process((EClass) next));
+ }
+ }
+ return item;
+ }
+
+ public ResolvedItem process(EClass domainClass) {
+ ResolvedItem item;
+ TypePattern pattern = resolver.resolve(domainClass);
+ if (pattern instanceof NodePattern) {
+ item = new ResolvedItem(Resolution.NODE, domainClass, ResolvedItem.NODE_LINK_RESOLUTIONS);
+ NodePattern nodePattern = (NodePattern) pattern;
+ addLabels(item, nodePattern);
+ for (int i = 0; i < nodePattern.getRefLinks().length; i++) {
+ item.addChild(new ResolvedItem(Resolution.LINK, nodePattern.getRefLinks()[i], ResolvedItem.LINK_RESOLUTIONS));
+ }
+ } else if (pattern instanceof TypeLinkPattern) {
+ item = new ResolvedItem(Resolution.LINK, domainClass, ResolvedItem.NODE_LINK_RESOLUTIONS);
+ TypeLinkPattern linkPattern = (TypeLinkPattern) pattern;
+ addLabels(item, linkPattern);
+ } else {
+ item = new ResolvedItem(null, domainClass, ResolvedItem.DEFAULT_RESOLUTIONS);
+ }
+ return item;
+ }
+
+ protected void addLabels(ResolvedItem typeItem, TypePattern pattern) {
+ for (int i = 0; i < pattern.getLabels().length; i++) {
+ typeItem.addChild(new ResolvedItem(Resolution.LABEL, pattern.getLabels()[i], ResolvedItem.LABEL_RESOLUTIONS));
+ }
+ }
+}
diff --git a/plugins/org.eclipse.gmf.codegen.ui/src/org/eclipse/gmf/internal/codegen/wizards/DefinitionPage.java b/plugins/org.eclipse.gmf.codegen.ui/src/org/eclipse/gmf/internal/codegen/wizards/DefinitionPage.java
index bdc6a7e11..ef55cecee 100644
--- a/plugins/org.eclipse.gmf.codegen.ui/src/org/eclipse/gmf/internal/codegen/wizards/DefinitionPage.java
+++ b/plugins/org.eclipse.gmf.codegen.ui/src/org/eclipse/gmf/internal/codegen/wizards/DefinitionPage.java
@@ -7,37 +7,52 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * dstadnik - initial API and implementation
+ * Dmitry Stadnik - initial API and implementation
*/
package org.eclipse.gmf.internal.codegen.wizards;
+import java.util.List;
+
import org.eclipse.core.resources.IFile;
import org.eclipse.emf.common.notify.AdapterFactory;
import org.eclipse.emf.common.util.URI;
-import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EPackage;
-import org.eclipse.emf.ecore.EReference;
import org.eclipse.emf.ecore.provider.EcoreItemProviderAdapterFactory;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
import org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider;
-import org.eclipse.gmf.internal.codegen.resolver.NodePattern;
-import org.eclipse.gmf.internal.codegen.resolver.StructureResolver;
-import org.eclipse.gmf.internal.codegen.resolver.TypeLinkPattern;
-import org.eclipse.gmf.internal.codegen.resolver.TypePattern;
-import org.eclipse.jface.viewers.CheckboxTreeViewer;
-import org.eclipse.jface.viewers.StructuredViewer;
+import org.eclipse.gmf.internal.codegen.CodeGenUIPlugin;
+import org.eclipse.gmf.internal.codegen.resolver.Resolution;
+import org.eclipse.gmf.internal.codegen.resolver.ResolvedItem;
+import org.eclipse.gmf.internal.codegen.resolver.StructureBuilder;
+import org.eclipse.jface.viewers.CellEditor;
+import org.eclipse.jface.viewers.CheckboxCellEditor;
+import org.eclipse.jface.viewers.ColumnWeightData;
+import org.eclipse.jface.viewers.ICellModifier;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.ITableLabelProvider;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.TableLayout;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.wizard.WizardPage;
import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Tree;
+import org.eclipse.swt.widgets.TreeColumn;
+import org.eclipse.swt.widgets.TreeItem;
public class DefinitionPage extends WizardPage {
- private StructureResolver resolver;
+ protected static final String ELEMENT_PROPERTY = "element";
+
+ private StructureBuilder structureBuilder;
private DomainModelSelectionPage domainModelSelectionPage;
@@ -45,11 +60,11 @@ public class DefinitionPage extends WizardPage {
protected Label msg;
- protected StructuredViewer viewer;
+ protected TreeViewer viewer;
- public DefinitionPage(String pageId, StructureResolver resolver, DomainModelSelectionPage domainModelSelectionPage) {
+ public DefinitionPage(String pageId, StructureBuilder structureBuilder, DomainModelSelectionPage domainModelSelectionPage) {
super(pageId);
- this.resolver = resolver;
+ this.structureBuilder = structureBuilder;
this.domainModelSelectionPage = domainModelSelectionPage;
}
@@ -65,6 +80,7 @@ public class DefinitionPage extends WizardPage {
data.verticalAlignment = GridData.FILL;
data.grabExcessVerticalSpace = true;
data.horizontalAlignment = GridData.FILL;
+ data.grabExcessHorizontalSpace = true;
composite.setLayoutData(data);
}
msg = new Label(composite, SWT.NONE);
@@ -88,56 +104,60 @@ public class DefinitionPage extends WizardPage {
setControl(composite);
}
- protected StructuredViewer createViewer(Composite parent) {
- StructuredViewer viewer = new CheckboxTreeViewer(parent);
+ protected TreeViewer createViewer(Composite parent) {
+ Tree tree = new Tree(parent, SWT.SINGLE | SWT.V_SCROLL | SWT.BORDER | SWT.FULL_SELECTION);
+ TableLayout layout = new TableLayout();
+ tree.setLayout(layout);
+ tree.setHeaderVisible(true);
+ tree.setLinesVisible(true);
+
+ TreeColumn elementColumn = new TreeColumn(tree, SWT.LEFT);
+ elementColumn.setText("Element");
+ elementColumn.setResizable(true);
+ layout.addColumnData(new ColumnWeightData(5, 32, true));
+
+ addResolutionColumn(tree, Resolution.NODE);
+ addResolutionColumn(tree, Resolution.LINK);
+ addResolutionColumn(tree, Resolution.LABEL);
+
+ final TreeViewer viewer = new TreeViewer(tree);
+ viewer.setContentProvider(new ResolverContentProvider());
AdapterFactory adapterFactory = new EcoreItemProviderAdapterFactory();
- viewer.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory) {
-
- public String getText(Object object) {
- String label = super.getText(object);
- if (object instanceof EClass) {
- TypePattern pattern = resolver.resolve((EClass) object);
- if (pattern instanceof NodePattern) {
- label += " : Node";
- } else if (pattern instanceof TypeLinkPattern) {
- label += " : Link";
- }
- } else if (object instanceof EReference) {
- label += " : Link";
- }
- return label;
- }
- });
- viewer.setContentProvider(new FilteredAdapterFactoryContentProvider(adapterFactory) {
+ viewer.setLabelProvider(new ResolverLabelProvider(new AdapterFactoryLabelProvider(adapterFactory)));
+
+ viewer.setColumnProperties(new String[] { ELEMENT_PROPERTY, Resolution.NODE.getName(), Resolution.LINK.getName(), Resolution.LABEL.getName() });
+ viewer.setCellEditors(new CellEditor[] { null, new CheckboxCellEditor(), new CheckboxCellEditor(), new CheckboxCellEditor() });
+ viewer.setCellModifier(new ICellModifier() {
- protected boolean isShown(Object element) {
- return isDomainElementShown(element);
+ public Object getValue(Object element, String property) {
+ ResolvedItem item = (ResolvedItem) element;
+ return Boolean.valueOf(item.getResolution() == Resolution.getByName(property));
}
- });
- return viewer;
- }
- protected boolean isDomainElementShown(Object element) {
- if (element instanceof EPackage) {
- return true;
- } else if (element instanceof EClass) {
- TypePattern pattern = resolver.resolve((EClass) element);
- if (pattern != null) {
+ public boolean canModify(Object element, String property) {
return true;
}
- } else if (element instanceof EReference) {
- EReference ref = (EReference) element;
- TypePattern pattern = resolver.resolve(ref.getEContainingClass());
- if (pattern instanceof NodePattern) {
- EReference[] refLinks = ((NodePattern) pattern).getRefLinks();
- for (int i = 0; i < refLinks.length; i++) {
- if (refLinks[i] == ref) {
- return true;
- }
+
+ public void modify(Object element, String property, Object value) {
+ ResolvedItem item = (ResolvedItem) ((TreeItem) element).getData();
+ Resolution resolution = Resolution.getByName(property);
+ if (!item.isPossibleResolution(resolution)) {
+ return;
}
+ item.setResolution(((Boolean) value).booleanValue() ? resolution : null);
+ viewer.update(item, new String[] { Resolution.NODE.getName(), Resolution.LINK.getName(), Resolution.LABEL.getName() });
}
- }
- return false;
+ });
+
+ return viewer;
+ }
+
+ protected TreeColumn addResolutionColumn(Tree tree, Resolution resolution) {
+ TreeColumn column = new TreeColumn(tree, SWT.LEFT);
+ column.setText(resolution.getName());
+ column.setResizable(true);
+ ((TableLayout) tree.getLayout()).addColumnData(new ColumnWeightData(1, 16, true));
+ return column;
}
protected void createAdditionalControls(Composite parent) {
@@ -168,8 +188,8 @@ public class DefinitionPage extends WizardPage {
ResourceSet rs = new ResourceSetImpl();
Resource r = rs.getResource(uri, true);
contents = (EPackage) r.getContents().get(0);
- viewer.setInput(contents);
- processNewDomainModel(contents);
+ viewer.setInput(structureBuilder.process(contents));
+ viewer.expandAll();
setPageComplete(validatePage());
return "Domain model elements to process:";
} catch (Exception e) {
@@ -179,6 +199,79 @@ public class DefinitionPage extends WizardPage {
}
}
- protected void processNewDomainModel(EPackage contents) {
+ public final TreeViewer getViewer() {
+ return viewer;
+ }
+
+ protected static class ResolverContentProvider implements ITreeContentProvider {
+
+ public void dispose() {
+ }
+
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ }
+
+ public Object getParent(Object element) {
+ return ((ResolvedItem) element).getParent();
+ }
+
+ public Object[] getChildren(Object parentElement) {
+ List children = ((ResolvedItem) parentElement).getChildren();
+ return children.toArray();
+ }
+
+ public boolean hasChildren(Object element) {
+ List children = ((ResolvedItem) element).getChildren();
+ return !children.isEmpty();
+ }
+
+ public Object[] getElements(Object inputElement) {
+ return getChildren(inputElement);
+ }
+ }
+
+ protected static class ResolverLabelProvider extends LabelProvider implements ITableLabelProvider {
+
+ private ILabelProvider domainLabelProvider;
+
+ public ResolverLabelProvider(ILabelProvider domainLabelProvider) {
+ this.domainLabelProvider = domainLabelProvider;
+ }
+
+ public String getColumnText(Object element, int columnIndex) {
+ if (columnIndex == 0) {
+ Object domainRef = ((ResolvedItem) element).getDomainRef();
+ return domainLabelProvider.getText(domainRef);
+ } else {
+ return null;
+ }
+ }
+
+ public Image getColumnImage(Object element, int columnIndex) {
+ if (columnIndex == 0) {
+ Object domainRef = ((ResolvedItem) element).getDomainRef();
+ return domainLabelProvider.getImage(domainRef);
+ }
+ ResolvedItem item = (ResolvedItem) element;
+ Image checkedIcon = CodeGenUIPlugin.getDefault().getImageRegistry().get(CodeGenUIPlugin.CHECKED_ICON);
+ Image uncheckedIcon = CodeGenUIPlugin.getDefault().getImageRegistry().get(CodeGenUIPlugin.UNCHECKED_ICON);
+ if (columnIndex == 1) {
+ if (!item.isPossibleResolution(Resolution.NODE)) {
+ return null;
+ }
+ return Resolution.NODE == item.getResolution() ? checkedIcon : uncheckedIcon;
+ } else if (columnIndex == 2) {
+ if (!item.isPossibleResolution(Resolution.LINK)) {
+ return null;
+ }
+ return Resolution.LINK == item.getResolution() ? checkedIcon : uncheckedIcon;
+ } else if (columnIndex == 3) {
+ if (!item.isPossibleResolution(Resolution.LABEL)) {
+ return null;
+ }
+ return Resolution.LABEL == item.getResolution() ? checkedIcon : uncheckedIcon;
+ }
+ return null;
+ }
}
}
diff --git a/plugins/org.eclipse.gmf.codegen.ui/src/org/eclipse/gmf/internal/codegen/wizards/GMFGraphSimpleModelWizard.java b/plugins/org.eclipse.gmf.codegen.ui/src/org/eclipse/gmf/internal/codegen/wizards/GMFGraphSimpleModelWizard.java
index 5424e8dbf..e6fb2506c 100644
--- a/plugins/org.eclipse.gmf.codegen.ui/src/org/eclipse/gmf/internal/codegen/wizards/GMFGraphSimpleModelWizard.java
+++ b/plugins/org.eclipse.gmf.codegen.ui/src/org/eclipse/gmf/internal/codegen/wizards/GMFGraphSimpleModelWizard.java
@@ -11,26 +11,13 @@
*/
package org.eclipse.gmf.internal.codegen.wizards;
-import java.util.Iterator;
-
import org.eclipse.core.resources.IFile;
-import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EPackage;
-import org.eclipse.emf.ecore.EReference;
-import org.eclipse.gmf.gmfgraph.Canvas;
-import org.eclipse.gmf.gmfgraph.Connection;
-import org.eclipse.gmf.gmfgraph.DecorationFigure;
-import org.eclipse.gmf.gmfgraph.FigureGallery;
-import org.eclipse.gmf.gmfgraph.Node;
-import org.eclipse.gmf.gmfgraph.PolylineConnection;
-import org.eclipse.gmf.gmfgraph.Rectangle;
import org.eclipse.gmf.gmfgraph.presentation.GMFGraphModelWizard;
-import org.eclipse.gmf.internal.codegen.resolver.NodePattern;
+import org.eclipse.gmf.internal.codegen.resolver.ResolvedItem;
+import org.eclipse.gmf.internal.codegen.resolver.StructureBuilder;
import org.eclipse.gmf.internal.codegen.resolver.StructureResolver;
-import org.eclipse.gmf.internal.codegen.resolver.TypeLinkPattern;
-import org.eclipse.gmf.internal.codegen.resolver.TypePattern;
-import org.eclipse.jface.viewers.CheckboxTreeViewer;
+import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.jface.wizard.IWizardPage;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Composite;
@@ -39,70 +26,12 @@ public class GMFGraphSimpleModelWizard extends GMFGraphModelWizard {
protected DomainModelSelectionPage domainModelSelectionPage;
- protected GraphicalDefinitionPage graphicalDefinitionPage;
-
- protected StructureResolver resolver;
+ protected DefinitionPage graphicalDefinitionPage;
protected EObject createInitialModel() {
- Canvas canvas = gmfGraphFactory.createCanvas();
- CheckboxTreeViewer viewer = graphicalDefinitionPage.getViewer();
- EPackage ePackage = (EPackage) viewer.getInput();
- if (ePackage != null) {
- canvas.setName(ePackage.getName());
- FigureGallery fGallery = gmfGraphFactory.createFigureGallery();
- fGallery.setName("default");
- canvas.getFigures().add(fGallery);
- for (Iterator ePackageIt = ePackage.eAllContents(); ePackageIt.hasNext();) {
- EObject ePackageObj = (EObject) ePackageIt.next();
- if (!viewer.getChecked(ePackageObj)) {
- continue;
- }
- if (ePackageObj instanceof EClass) {
- TypePattern pattern = resolver.resolve((EClass) ePackageObj);
- String baseName = pattern.getType().getName();
- if (pattern instanceof NodePattern) {
- Rectangle figure = gmfGraphFactory.createRectangle();
- figure.setName(baseName + "Figure");
- fGallery.getFigures().add(figure);
- Node dElement = gmfGraphFactory.createNode();
- dElement.setFigure(figure);
- dElement.setName(baseName + "Node");
- canvas.getNodes().add(dElement);
- } else if (pattern instanceof TypeLinkPattern) {
- PolylineConnection figure = gmfGraphFactory.createPolylineConnection();
- figure.setName(baseName + "Figure");
- fGallery.getFigures().add(figure);
- Connection dElement = gmfGraphFactory.createConnection();
- dElement.setFigure(figure);
- dElement.setName(baseName + "Link");
- canvas.getConnections().add(dElement);
- }
- } else if (ePackageObj instanceof EReference) {
- EReference ref = (EReference) ePackageObj;
- TypePattern pattern = resolver.resolve(ref.getEContainingClass());
- String baseName = pattern.getType().getName();
- if (ref.getName().length() > 0) {
- baseName += Character.toUpperCase(ref.getName().charAt(0));
- }
- if (ref.getName().length() > 1) {
- baseName += ref.getName().substring(1);
- }
- if (pattern instanceof NodePattern) {
- PolylineConnection figure = gmfGraphFactory.createPolylineConnection();
- figure.setName(baseName + "Figure");
- DecorationFigure decoration = gmfGraphFactory.createPolylineDecoration();
- decoration.setName(baseName + "TargetDecoration");
- figure.setTargetDecoration(decoration);
- fGallery.getFigures().add(figure);
- Connection dElement = gmfGraphFactory.createConnection();
- dElement.setFigure(figure);
- dElement.setName(baseName + "Link");
- canvas.getConnections().add(dElement);
- }
- }
- }
- }
- return canvas;
+ GraphDefBuilder builder = new GraphDefBuilder();
+ TreeViewer viewer = graphicalDefinitionPage.getViewer();
+ return builder.process((ResolvedItem) viewer.getInput());
}
public void addPages() {
@@ -123,7 +52,7 @@ public class GMFGraphSimpleModelWizard extends GMFGraphModelWizard {
domainModelSelectionPage.setDescription("Select file with ecore domain model");
addPage(domainModelSelectionPage);
- graphicalDefinitionPage = new GraphicalDefinitionPage("GraphicalDefinitionPage", resolver = new StructureResolver(), domainModelSelectionPage);
+ graphicalDefinitionPage = new DefinitionPage("GraphicalDefinitionPage", new StructureBuilder(new StructureResolver()), domainModelSelectionPage);
graphicalDefinitionPage.setTitle("Graphical Definition");
graphicalDefinitionPage.setDescription("Specify basic graphical definition of the domain model");
addPage(graphicalDefinitionPage);
@@ -163,21 +92,4 @@ public class GMFGraphSimpleModelWizard extends GMFGraphModelWizard {
return "UTF-8";
}
}
-
- public class GraphicalDefinitionPage extends DefinitionPage {
-
- public GraphicalDefinitionPage(String pageId, StructureResolver resolver, DomainModelSelectionPage domainModelSelectionPage) {
- super(pageId, resolver, domainModelSelectionPage);
- }
-
- protected void processNewDomainModel(EPackage contents) {
- CheckboxTreeViewer viewer = getViewer();
- viewer.expandAll();
- viewer.setAllChecked(true);
- }
-
- public final CheckboxTreeViewer getViewer() {
- return (CheckboxTreeViewer) viewer;
- }
- }
}
diff --git a/plugins/org.eclipse.gmf.codegen.ui/src/org/eclipse/gmf/internal/codegen/wizards/GMFToolSimpleModelWizard.java b/plugins/org.eclipse.gmf.codegen.ui/src/org/eclipse/gmf/internal/codegen/wizards/GMFToolSimpleModelWizard.java
index 8f4c44ab7..3979edcb0 100644
--- a/plugins/org.eclipse.gmf.codegen.ui/src/org/eclipse/gmf/internal/codegen/wizards/GMFToolSimpleModelWizard.java
+++ b/plugins/org.eclipse.gmf.codegen.ui/src/org/eclipse/gmf/internal/codegen/wizards/GMFToolSimpleModelWizard.java
@@ -7,26 +7,17 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * dstadnik - initial API and implementation
+ * Dmitry Stadnik - initial API and implementation
*/
package org.eclipse.gmf.internal.codegen.wizards;
-import java.util.Iterator;
-
import org.eclipse.core.resources.IFile;
-import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EPackage;
-import org.eclipse.emf.ecore.EReference;
-import org.eclipse.gmf.internal.codegen.resolver.NodePattern;
+import org.eclipse.gmf.internal.codegen.resolver.ResolvedItem;
+import org.eclipse.gmf.internal.codegen.resolver.StructureBuilder;
import org.eclipse.gmf.internal.codegen.resolver.StructureResolver;
-import org.eclipse.gmf.internal.codegen.resolver.TypePattern;
-import org.eclipse.gmf.tooldef.CreationTool;
-import org.eclipse.gmf.tooldef.Palette;
-import org.eclipse.gmf.tooldef.ToolGroup;
-import org.eclipse.gmf.tooldef.ToolRegistry;
import org.eclipse.gmf.tooldef.presentation.GMFToolModelWizard;
-import org.eclipse.jface.viewers.CheckboxTreeViewer;
+import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.jface.wizard.IWizardPage;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Composite;
@@ -35,56 +26,14 @@ public class GMFToolSimpleModelWizard extends GMFToolModelWizard {
protected DomainModelSelectionPage domainModelSelectionPage;
- protected ToolDefinitionPage toolDefinitionPage;
+ protected DefinitionPage toolDefinitionPage;
protected StructureResolver resolver;
protected EObject createInitialModel() {
- ToolRegistry toolRegistry = gmfToolFactory.createToolRegistry();
- CheckboxTreeViewer viewer = toolDefinitionPage.getViewer();
- EPackage ePackage = (EPackage) viewer.getInput();
- if (ePackage != null) {
- Palette palette = gmfToolFactory.createPalette();
- toolRegistry.setPalette(palette);
- ToolGroup group = gmfToolFactory.createToolGroup();
- group.setTitle(ePackage.getName());
- palette.getTools().add(group);
- for (Iterator ePackageIt = ePackage.eAllContents(); ePackageIt.hasNext();) {
- EObject ePackageObj = (EObject) ePackageIt.next();
- if (!viewer.getChecked(ePackageObj)) {
- continue;
- }
- if (ePackageObj instanceof EClass) {
- EClass eClass = (EClass) ePackageObj;
- String baseName = eClass.getName();
- CreationTool tool = gmfToolFactory.createCreationTool();
- tool.setTitle(baseName);
- tool.setDescription("Create new " + baseName);
- tool.setSmallIcon(gmfToolFactory.createDefaultImage());
- tool.setLargeIcon(gmfToolFactory.createDefaultImage());
- group.getTools().add(tool);
- } else if (ePackageObj instanceof EReference) {
- EReference ref = (EReference) ePackageObj;
- TypePattern pattern = resolver.resolve(ref.getEContainingClass());
- String baseName = pattern.getType().getName();
- if (ref.getName().length() > 0) {
- baseName += Character.toUpperCase(ref.getName().charAt(0));
- }
- if (ref.getName().length() > 1) {
- baseName += ref.getName().substring(1);
- }
- if (pattern instanceof NodePattern) {
- CreationTool tool = gmfToolFactory.createCreationTool();
- tool.setTitle(baseName);
- tool.setDescription("Create new " + baseName);
- tool.setSmallIcon(gmfToolFactory.createDefaultImage());
- tool.setLargeIcon(gmfToolFactory.createDefaultImage());
- group.getTools().add(tool);
- }
- }
- }
- }
- return toolRegistry;
+ ToolDefBuilder builder = new ToolDefBuilder();
+ TreeViewer viewer = toolDefinitionPage.getViewer();
+ return builder.process((ResolvedItem) viewer.getInput());
}
public void addPages() {
@@ -105,7 +54,7 @@ public class GMFToolSimpleModelWizard extends GMFToolModelWizard {
domainModelSelectionPage.setDescription("Select file with ecore domain model");
addPage(domainModelSelectionPage);
- toolDefinitionPage = new ToolDefinitionPage("ToolDefinitionPage", resolver = new StructureResolver(), domainModelSelectionPage);
+ toolDefinitionPage = new DefinitionPage("ToolDefinitionPage", new StructureBuilder(resolver = new StructureResolver()), domainModelSelectionPage);
toolDefinitionPage.setTitle("Tooling Definition");
toolDefinitionPage.setDescription("Specify basic tooling definition of the domain model");
addPage(toolDefinitionPage);
@@ -145,21 +94,4 @@ public class GMFToolSimpleModelWizard extends GMFToolModelWizard {
return "UTF-8";
}
}
-
- public class ToolDefinitionPage extends DefinitionPage {
-
- public ToolDefinitionPage(String pageId, StructureResolver resolver, DomainModelSelectionPage domainModelSelectionPage) {
- super(pageId, resolver, domainModelSelectionPage);
- }
-
- protected void processNewDomainModel(EPackage contents) {
- CheckboxTreeViewer viewer = getViewer();
- viewer.expandAll();
- viewer.setAllChecked(true);
- }
-
- public final CheckboxTreeViewer getViewer() {
- return (CheckboxTreeViewer) viewer;
- }
- }
}
diff --git a/plugins/org.eclipse.gmf.codegen.ui/src/org/eclipse/gmf/internal/codegen/wizards/GraphDefBuilder.java b/plugins/org.eclipse.gmf.codegen.ui/src/org/eclipse/gmf/internal/codegen/wizards/GraphDefBuilder.java
new file mode 100644
index 000000000..5ac7dfbec
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen.ui/src/org/eclipse/gmf/internal/codegen/wizards/GraphDefBuilder.java
@@ -0,0 +1,118 @@
+/*
+ * Copyright (c) 2006 Eclipse.org
+ *
+ * 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:
+ * Dmitry Stadnik - initial API and implementation
+ */
+package org.eclipse.gmf.internal.codegen.wizards;
+
+import java.util.Iterator;
+
+import org.eclipse.emf.ecore.EAttribute;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.ecore.EReference;
+import org.eclipse.gmf.gmfgraph.Canvas;
+import org.eclipse.gmf.gmfgraph.Connection;
+import org.eclipse.gmf.gmfgraph.DecorationFigure;
+import org.eclipse.gmf.gmfgraph.DiagramLabel;
+import org.eclipse.gmf.gmfgraph.FigureGallery;
+import org.eclipse.gmf.gmfgraph.GMFGraphFactory;
+import org.eclipse.gmf.gmfgraph.GMFGraphPackage;
+import org.eclipse.gmf.gmfgraph.Label;
+import org.eclipse.gmf.gmfgraph.Node;
+import org.eclipse.gmf.gmfgraph.PolylineConnection;
+import org.eclipse.gmf.gmfgraph.Rectangle;
+import org.eclipse.gmf.internal.codegen.resolver.Resolution;
+import org.eclipse.gmf.internal.codegen.resolver.ResolvedItem;
+
+/**
+ * @author dstadnik
+ */
+public class GraphDefBuilder {
+
+ protected GMFGraphPackage gmfGraphPackage = GMFGraphPackage.eINSTANCE;
+
+ protected GMFGraphFactory gmfGraphFactory = gmfGraphPackage.getGMFGraphFactory();
+
+ public Canvas process(ResolvedItem item) {
+ Canvas canvas = gmfGraphFactory.createCanvas();
+ if (item != null) {
+ EPackage ePackage = (EPackage) item.getDomainRef();
+ canvas.setName(ePackage.getName());
+ FigureGallery fGallery = gmfGraphFactory.createFigureGallery();
+ fGallery.setName("default");
+ canvas.getFigures().add(fGallery);
+ for (Iterator it = item.getChildren().iterator(); it.hasNext();) {
+ process((ResolvedItem) it.next(), canvas, fGallery);
+ }
+ }
+ return canvas;
+ }
+
+ protected void process(ResolvedItem item, Canvas canvas, FigureGallery fGallery) {
+ boolean descend = false;
+ if (item.getDomainRef() instanceof EClass) {
+ EClass type = (EClass) item.getDomainRef();
+ String baseName = type.getName();
+ if (item.getResolution() == Resolution.NODE) {
+ Rectangle figure = gmfGraphFactory.createRectangle();
+ figure.setName(baseName + "Figure");
+ fGallery.getFigures().add(figure);
+ Node dElement = gmfGraphFactory.createNode();
+ dElement.setFigure(figure);
+ dElement.setName(baseName + "Node");
+ canvas.getNodes().add(dElement);
+ descend = true;
+ } else if (item.getResolution() == Resolution.LINK) {
+ PolylineConnection figure = gmfGraphFactory.createPolylineConnection();
+ figure.setName(baseName + "Figure");
+ fGallery.getFigures().add(figure);
+ Connection dElement = gmfGraphFactory.createConnection();
+ dElement.setFigure(figure);
+ dElement.setName(baseName + "Link");
+ canvas.getConnections().add(dElement);
+ descend = true;
+ }
+ } else if (item.getDomainRef() instanceof EReference) {
+ EReference ref = (EReference) item.getDomainRef();
+ String baseName = WizardUtil.getCapName(ref);
+ if (item.getResolution() == Resolution.LINK) {
+ PolylineConnection figure = gmfGraphFactory.createPolylineConnection();
+ figure.setName(baseName + "Figure");
+ DecorationFigure decoration = gmfGraphFactory.createPolylineDecoration();
+ decoration.setName(baseName + "TargetDecoration");
+ figure.setTargetDecoration(decoration);
+ fGallery.getFigures().add(figure);
+ Connection dElement = gmfGraphFactory.createConnection();
+ dElement.setFigure(figure);
+ dElement.setName(baseName + "Link");
+ canvas.getConnections().add(dElement);
+ descend = true;
+ }
+ } else if (item.getDomainRef() instanceof EAttribute) {
+ EAttribute attr = (EAttribute) item.getDomainRef();
+ String baseName = WizardUtil.getCapName(attr);
+ if (item.getResolution() == Resolution.LABEL) {
+ Label figure = gmfGraphFactory.createLabel();
+ figure.setName(baseName + "Figure");
+ fGallery.getFigures().add(figure);
+ DiagramLabel dElement = gmfGraphFactory.createDiagramLabel();
+ dElement.setFigure(figure);
+ dElement.setName(baseName + "Label");
+ canvas.getLabels().add(dElement);
+ descend = true;
+ }
+ }
+ if (descend) {
+ for (Iterator it = item.getChildren().iterator(); it.hasNext();) {
+ process((ResolvedItem) it.next(), canvas, fGallery);
+ }
+ }
+ }
+}
diff --git a/plugins/org.eclipse.gmf.codegen.ui/src/org/eclipse/gmf/internal/codegen/wizards/ToolDefBuilder.java b/plugins/org.eclipse.gmf.codegen.ui/src/org/eclipse/gmf/internal/codegen/wizards/ToolDefBuilder.java
new file mode 100644
index 000000000..86d9e9dcc
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen.ui/src/org/eclipse/gmf/internal/codegen/wizards/ToolDefBuilder.java
@@ -0,0 +1,86 @@
+/*
+ * Copyright (c) 2006 Eclipse.org
+ *
+ * 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:
+ * Dmitry Stadnik - initial API and implementation
+ */
+package org.eclipse.gmf.internal.codegen.wizards;
+
+import java.util.Iterator;
+
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.ecore.EReference;
+import org.eclipse.gmf.internal.codegen.resolver.Resolution;
+import org.eclipse.gmf.internal.codegen.resolver.ResolvedItem;
+import org.eclipse.gmf.tooldef.CreationTool;
+import org.eclipse.gmf.tooldef.GMFToolFactory;
+import org.eclipse.gmf.tooldef.GMFToolPackage;
+import org.eclipse.gmf.tooldef.Palette;
+import org.eclipse.gmf.tooldef.ToolGroup;
+import org.eclipse.gmf.tooldef.ToolRegistry;
+
+/**
+ * @author dstadnik
+ */
+public class ToolDefBuilder {
+
+ protected GMFToolPackage gmfToolPackage = GMFToolPackage.eINSTANCE;
+
+ protected GMFToolFactory gmfToolFactory = gmfToolPackage.getGMFToolFactory();
+
+ protected ToolRegistry process(ResolvedItem item) {
+ ToolRegistry toolRegistry = gmfToolFactory.createToolRegistry();
+ if (item != null) {
+ EPackage ePackage = (EPackage) item.getDomainRef();
+ Palette palette = gmfToolFactory.createPalette();
+ toolRegistry.setPalette(palette);
+ ToolGroup group = gmfToolFactory.createToolGroup();
+ group.setTitle(ePackage.getName());
+ palette.getTools().add(group);
+ for (Iterator it = item.getChildren().iterator(); it.hasNext();) {
+ process((ResolvedItem) it.next(), toolRegistry, group);
+ }
+ }
+ return toolRegistry;
+ }
+
+ protected void process(ResolvedItem item, ToolRegistry toolRegistry, ToolGroup group) {
+ boolean descend = false;
+ if (item.getDomainRef() instanceof EClass) {
+ EClass type = (EClass) item.getDomainRef();
+ String baseName = type.getName();
+ if (item.getResolution() == Resolution.NODE || item.getResolution() == Resolution.LINK) {
+ addCreationTool(baseName, group);
+ descend = true;
+ }
+ } else if (item.getDomainRef() instanceof EReference) {
+ EReference ref = (EReference) item.getDomainRef();
+ String baseName = WizardUtil.getCapName(ref);
+ if (item.getResolution() == Resolution.LINK) {
+ addCreationTool(baseName, group);
+ descend = true;
+ }
+ }
+ if (descend) {
+ for (Iterator it = item.getChildren().iterator(); it.hasNext();) {
+ process((ResolvedItem) it.next(), toolRegistry, group);
+ }
+ }
+ }
+
+ protected CreationTool addCreationTool(String baseName, ToolGroup group) {
+ CreationTool tool = gmfToolFactory.createCreationTool();
+ tool.setTitle(baseName);
+ tool.setDescription("Create new " + baseName);
+ tool.setSmallIcon(gmfToolFactory.createDefaultImage());
+ tool.setLargeIcon(gmfToolFactory.createDefaultImage());
+ group.getTools().add(tool);
+ return tool;
+ }
+}
diff --git a/plugins/org.eclipse.gmf.codegen.ui/src/org/eclipse/gmf/internal/codegen/wizards/WizardUtil.java b/plugins/org.eclipse.gmf.codegen.ui/src/org/eclipse/gmf/internal/codegen/wizards/WizardUtil.java
index 12a436755..4e3373655 100644
--- a/plugins/org.eclipse.gmf.codegen.ui/src/org/eclipse/gmf/internal/codegen/wizards/WizardUtil.java
+++ b/plugins/org.eclipse.gmf.codegen.ui/src/org/eclipse/gmf/internal/codegen/wizards/WizardUtil.java
@@ -7,12 +7,17 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * dstadnik - initial API and implementation
+ * Dmitry Stadnik - initial API and implementation
*/
package org.eclipse.gmf.internal.codegen.wizards;
import org.eclipse.core.resources.IFile;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EStructuralFeature;
+/**
+ * @author dstadnik
+ */
public class WizardUtil {
private WizardUtil() {
@@ -29,4 +34,16 @@ public class WizardUtil {
}
return modelFilename;
}
+
+ public static String getCapName(EStructuralFeature feature) {
+ EClass type = feature.getEContainingClass();
+ String name = type.getName();
+ if (feature.getName().length() > 0) {
+ name += Character.toUpperCase(feature.getName().charAt(0));
+ }
+ if (feature.getName().length() > 1) {
+ name += feature.getName().substring(1);
+ }
+ return name;
+ }
}

Back to the top