### Eclipse Workspace Patch 1.0
#P org.eclipse.gmf.graphdef.codegen.ui
Index: src/org/eclipse/gmf/internal/graphdef/codegen/ui/ConverterSection.java
===================================================================
RCS file: /cvsroot/technology/org.eclipse.gmf/plugins/org.eclipse.gmf.graphdef.codegen.ui/src/org/eclipse/gmf/internal/graphdef/codegen/ui/ConverterSection.java,v
retrieving revision 1.2
diff -u -r1.2 ConverterSection.java
--- src/org/eclipse/gmf/internal/graphdef/codegen/ui/ConverterSection.java 2 Mar 2006 13:16:16 -0000 1.2
+++ src/org/eclipse/gmf/internal/graphdef/codegen/ui/ConverterSection.java 7 Mar 2006 11:38:00 -0000
@@ -61,16 +61,20 @@
public static final String OPTION_MAIN_PACKAGE_NAME = SECTION_ID + ".mainPackageName";
public static final String OPTION_NEEDS_MAP_MODE = SECTION_ID + ".needsMapMode";
public static final String OPTION_INPUT_RESOURCE_FULL_PATH = SECTION_ID + ".inputResource";
+ public static final String OPTION_OUTPUT_RESOURCE_FULL_PATH = SECTION_ID + ".outputResource";
private TemplateOption myPackageNameOption;
private FileNameOption myInputPathOption;
+ private FileNameOption myOutputGalleryPathOption;
private final CachedInputValidationState myCachedInputValidationState;
private ManifestElement[] myRequiredBundles;
public ConverterSection(){
setPageCount(THE_ONLY_PAGE_INDEX + 1);
myPackageNameOption = addOption(OPTION_MAIN_PACKAGE_NAME, "Generate figures package", null, THE_ONLY_PAGE_INDEX);
- myInputPathOption = addFileNameOption(OPTION_INPUT_RESOURCE_FULL_PATH, "Input GMFGraph instance", "", THE_ONLY_PAGE_INDEX);
+ myInputPathOption = addFileNameOption(false, OPTION_INPUT_RESOURCE_FULL_PATH, "Input GMFGraph instance", "", THE_ONLY_PAGE_INDEX);
+ myOutputGalleryPathOption = addFileNameOption(true, OPTION_OUTPUT_RESOURCE_FULL_PATH, "Create Figure Gallery", "", THE_ONLY_PAGE_INDEX);
+ myOutputGalleryPathOption.setRequired(false);
addOption(OPTION_NEEDS_MAP_MODE, "Use IMapMode", false, THE_ONLY_PAGE_INDEX);
myCachedInputValidationState = new CachedInputValidationState();
}
@@ -84,6 +88,7 @@
markPagesAdded();
validateOptions(myPackageNameOption);
validateOptions(myInputPathOption);
+ validateOptions(myOutputGalleryPathOption);
}
public IPluginReference[] getDependencies(String schemaVersion) {
@@ -118,6 +123,22 @@
if (!generator.getRunStatus().isOK()){
throw new CoreException(generator.getRunStatus());
}
+ createFigureGallery(generator.getGenerationInfo());
+ }
+
+ private void createFigureGallery(StandaloneGenerator.GenerationInfo info) throws CoreException {
+ if (!myOutputGalleryPathOption.isEmpty()){
+ String path = myOutputGalleryPathOption.getText();
+ Resource galleryResource = new ResourceSetImpl().createResource(URI.createFileURI(path));
+ galleryResource.getContents().add(new StandaloneGalleryConverter().convertFigureGallery(info));
+ try {
+ galleryResource.save(null);
+ } catch (IOException e) {
+ throw new CoreException(new Status(//
+ IStatus.ERROR, MY_PLUGIN_ID, 0, e.getMessage(), e
+ ));
+ }
+ }
}
private void readRequiredBundles() throws CoreException, IOException {
@@ -190,6 +211,9 @@
if (!validateInputPath()){
return;
}
+ if (!validateOutputGalleryPath()){
+ return;
+ }
resetPageState();
}
@@ -253,8 +277,9 @@
return buffer.toString().toLowerCase(Locale.ENGLISH);
}
- private FileNameOption addFileNameOption(String name, String label, String value, int pageIndex) {
+ private FileNameOption addFileNameOption(boolean saveNotLoad, String name, String label, String value, int pageIndex) {
FileNameOption result = new FileNameOption(this, name, label, new String[] {"*.gmfgraph"});
+ result.setSaveNotLoad(saveNotLoad);
registerOption(result, value, pageIndex);
return result;
}
@@ -281,6 +306,23 @@
}
return true;
}
+
+ private boolean validateOutputGalleryPath() {
+ if (myOutputGalleryPathOption.isEmpty()){
+ //optional -- ok
+ return true;
+ }
+ String path = myOutputGalleryPathOption.getText();
+ try {
+ URI.createFileURI(path);
+ } catch (IllegalArgumentException e){
+ String message = MessageFormat.format("Path {0} is invalid", new Object[] {path});
+ getTheOnlyPage().setPageComplete(false);
+ getTheOnlyPage().setErrorMessage(message);
+ return false;
+ }
+ return true;
+ }
private WizardPage getTheOnlyPage() {
return getPage(THE_ONLY_PAGE_INDEX);
Index: src/org/eclipse/gmf/internal/graphdef/codegen/ui/FileNameOption.java
===================================================================
RCS file: /cvsroot/technology/org.eclipse.gmf/plugins/org.eclipse.gmf.graphdef.codegen.ui/src/org/eclipse/gmf/internal/graphdef/codegen/ui/FileNameOption.java,v
retrieving revision 1.2
diff -u -r1.2 FileNameOption.java
--- src/org/eclipse/gmf/internal/graphdef/codegen/ui/FileNameOption.java 2 Mar 2006 13:16:16 -0000 1.2
+++ src/org/eclipse/gmf/internal/graphdef/codegen/ui/FileNameOption.java 7 Mar 2006 11:38:01 -0000
@@ -36,6 +36,7 @@
private Label myLabelControl;
private Button myBrowseButton;
private boolean myIgnoreListener;
+ private boolean mySaveNotLoad;
/**
* @param section
@@ -51,6 +52,10 @@
myExtensions = extensions;
}
+ public void setSaveNotLoad(boolean saveNotLoad){
+ mySaveNotLoad = saveNotLoad;
+ }
+
/**
* A utility version of the getValue() method that converts
* the current value into the String object.
@@ -109,7 +114,7 @@
groupLayout.marginWidth = 0;
groupLayout.marginHeight = 0;
groupLayout.verticalSpacing = 0;
- groupLayout.horizontalSpacing = 0;
+ groupLayout.horizontalSpacing = 5;
textAndButtonGroup.setLayout(groupLayout);
GridData groupLayoutData = new GridData(GridData.FILL_HORIZONTAL);
@@ -145,11 +150,15 @@
}
public void widgetSelected(SelectionEvent e) {
- FileDialog fileDialog = new FileDialog(e.display.getActiveShell(), SWT.PRIMARY_MODAL | SWT.OPEN);
+ FileDialog fileDialog = new FileDialog(e.display.getActiveShell(), getSaveNotLoadDialogStyle() | SWT.PRIMARY_MODAL);
fileDialog.setFilterExtensions(myExtensions);
setText(fileDialog.open());
getSection().validateOptions(FileNameOption.this);
}
+
+ private int getSaveNotLoadDialogStyle(){
+ return FileNameOption.this.isSaveNotLoad() ? SWT.SAVE : SWT.OPEN;
+ }
});
}
@@ -176,4 +185,8 @@
myBrowseButton.setEnabled(enabled);
}
}
+
+ private boolean isSaveNotLoad(){
+ return mySaveNotLoad;
+ }
}
Index: src/org/eclipse/gmf/internal/graphdef/codegen/ui/StandaloneGalleryConverter.java
===================================================================
RCS file: src/org/eclipse/gmf/internal/graphdef/codegen/ui/StandaloneGalleryConverter.java
diff -N src/org/eclipse/gmf/internal/graphdef/codegen/ui/StandaloneGalleryConverter.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/gmf/internal/graphdef/codegen/ui/StandaloneGalleryConverter.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2006 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:
+ * Michael Golubev (Borland) - initial API and implementation
+ */
+
+package org.eclipse.gmf.internal.graphdef.codegen.ui;
+
+import java.util.Enumeration;
+
+import org.eclipse.gmf.gmfgraph.ConnectionFigure;
+import org.eclipse.gmf.gmfgraph.CustomFigure;
+import org.eclipse.gmf.gmfgraph.DecorationFigure;
+import org.eclipse.gmf.gmfgraph.Figure;
+import org.eclipse.gmf.gmfgraph.FigureGallery;
+import org.eclipse.gmf.gmfgraph.GMFGraphFactory;
+import org.eclipse.gmf.graphdef.codegen.StandaloneGenerator;
+
+public class StandaloneGalleryConverter {
+ public FigureGallery convertFigureGallery(StandaloneGenerator.GenerationInfo generationInfo){
+ FigureGallery result = GMFGraphFactory.eINSTANCE.createFigureGallery();
+ String generatedBundle = generationInfo.getConfig().getPluginID();
+ result.setImplementationBundle(generatedBundle);
+
+ for (Enumeration originalFigures = generationInfo.getProcessedFigures(); originalFigures.hasMoreElements();){
+ Figure nextOriginal = (Figure) originalFigures.nextElement();
+ String nextConvertedFqn = generationInfo.getGeneratedClassFQN(nextOriginal);
+ CustomFigure custom = createCustomFigure(nextOriginal);
+ custom.setBundleName(generatedBundle);
+ custom.setQualifiedClassName(nextConvertedFqn);
+
+ result.getFigures().add(custom);
+ }
+ return result;
+ }
+
+ private CustomFigure createCustomFigure(Figure original){
+ GMFGraphFactory factory = GMFGraphFactory.eINSTANCE;
+ if (original instanceof DecorationFigure){
+ return factory.createCustomDecoration();
+ }
+ if (original instanceof ConnectionFigure){
+ return factory.createCustomConnection();
+ }
+ return factory.createCustomFigure();
+ }
+
+}
#P org.eclipse.gmf.graphdef.codegen
Index: src/org/eclipse/gmf/graphdef/codegen/StandaloneGenerator.java
===================================================================
RCS file: /cvsroot/technology/org.eclipse.gmf/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/StandaloneGenerator.java,v
retrieving revision 1.1
diff -u -r1.1 StandaloneGenerator.java
--- src/org/eclipse/gmf/graphdef/codegen/StandaloneGenerator.java 2 Mar 2006 13:16:15 -0000 1.1
+++ src/org/eclipse/gmf/graphdef/codegen/StandaloneGenerator.java 7 Mar 2006 11:38:02 -0000
@@ -14,9 +14,12 @@
import java.net.URL;
import java.util.Arrays;
import java.util.Collections;
+import java.util.Enumeration;
import java.util.HashSet;
+import java.util.IdentityHashMap;
import java.util.Iterator;
import java.util.List;
+import java.util.Map;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.Path;
@@ -36,6 +39,13 @@
private final StandaloneEmitters myAuxiliaryGenerators;
private boolean mySkipPluginStructire;
private final FigureQualifiedNameSwitch myFigureNameSwitch;
+ private final GenerationInfoImpl myGenerationInfo;
+
+ public interface GenerationInfo {
+ public Config getConfig();
+ public Enumeration/*