瀏覽代碼

TextdialogPropertyDescirptor added

Andreas Mülder 14 年之前
父節點
當前提交
7ec6be5389

+ 1 - 3
plugins/org.yakindu.sct.ui.editor/plugin.xml

@@ -300,11 +300,9 @@
                            </content>
                      </expand>
             </entry>
-            
             <entry
-                  kind="stack" id="stack" path="/tools/">
+                  kind="stack" id="stack" path="/tools/" >
             </entry>
-            
              <entry
                   description="Creates a composite state"
                   id="org.yakindu.sct.ui.editor.CompositeState"

+ 147 - 0
plugins/org.yakindu.sct.ui.editor/src/org/yakindu/sct/ui/editor/dialogs/SelectSubmachineDialog.java

@@ -0,0 +1,147 @@
+/**
+ * Copyright (c) 2011 committers of YAKINDU and others.
+ * 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:
+ * 	committers of YAKINDU - initial API and implementation
+ * 
+ */
+package org.yakindu.sct.ui.editor.dialogs;
+
+import java.io.IOException;
+import java.util.Collections;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.emf.common.ui.dialogs.WorkspaceResourceDialog;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.Resource.Factory;
+import org.eclipse.emf.ecore.resource.impl.ResourceFactoryRegistryImpl;
+import org.eclipse.emf.ecore.util.EcoreUtil;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerFilter;
+import org.eclipse.jface.wizard.WizardDialog;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Link;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.model.WorkbenchContentProvider;
+import org.eclipse.ui.model.WorkbenchLabelProvider;
+import org.eclipse.ui.wizards.IWizardDescriptor;
+import org.yakindu.sct.model.sgraph.SGraphPackage;
+import org.yakindu.sct.model.sgraph.Statechart;
+import org.yakindu.sct.ui.editor.StatechartImages;
+import org.yakindu.sct.ui.editor.wizards.CreationWizard;
+
+/**
+ * Basic resource selection dialog for Statecharts with a link that opens the
+ * new project wizard.
+ * 
+ * @author andreas muelder - Initial contribution and API
+ * 
+ */
+public class SelectSubmachineDialog extends WorkspaceResourceDialog {
+
+	public SelectSubmachineDialog(Shell parent) {
+		super(parent, new WorkbenchLabelProvider(),
+				new WorkbenchContentProvider());
+		initDialog();
+	}
+
+	protected void initDialog() {
+		setAllowMultiple(false);
+		setTitle("Select Submachine");
+		setMessage("Select the Submachine to include include into the Submachine State.");
+		setImage(StatechartImages.LOGO.image());
+		addFilter(new StatechartViewerFilter());
+		loadContents();
+	}
+
+	@Override
+	protected Control createDialogArea(Composite parent) {
+		Composite composite = (Composite) super.createDialogArea(parent);
+		Link link = new Link(composite, SWT.NONE);
+		link.setText("Open the new project wizard to <a>create new statechart</a>.");
+		link.addListener(SWT.Selection, new OpenCreationWizardListener(
+				getSelection()));
+		return composite;
+	}
+
+	private IStructuredSelection getSelection() {
+		return new StructuredSelection(getSelectedContainers());
+	}
+
+	public Statechart getSelectedSubmachine() {
+		Object[] result = getResult();
+		if (result.length == 1 && result[0] instanceof IFile) {
+			IFile selectedFile = (IFile) result[0];
+			return loadFromFile(selectedFile);
+		}
+		return null;
+	}
+
+	public static Statechart loadFromFile(IFile fileResource) {
+		URI platformURI = URI.createPlatformResourceURI(fileResource
+				.getFullPath().toString(), true);
+		Factory factory = ResourceFactoryRegistryImpl.INSTANCE
+				.getFactory(platformURI);
+		Resource resource = factory.createResource(platformURI);
+		if (resource == null)
+			return null;
+		try {
+			resource.load(Collections.emptyMap());
+		} catch (IOException e) {
+			e.printStackTrace();
+		}
+		Statechart statechart = (Statechart) EcoreUtil.getObjectByType(
+				resource.getContents(), SGraphPackage.Literals.STATECHART);
+		return statechart;
+	}
+
+	protected static class OpenCreationWizardListener implements Listener {
+
+		private final IStructuredSelection selection;
+
+		public OpenCreationWizardListener(IStructuredSelection selection) {
+			this.selection = selection;
+		}
+
+		public void handleEvent(Event event) {
+			IWizardDescriptor descriptor = PlatformUI.getWorkbench()
+					.getNewWizardRegistry().findWizard(CreationWizard.ID);
+			try {
+				CreationWizard wizard = (CreationWizard) descriptor
+						.createWizard();
+				wizard.setOpenOnCreate(false);
+				wizard.init(PlatformUI.getWorkbench(), selection);
+				WizardDialog wd = new WizardDialog(Display.getDefault()
+						.getActiveShell(), wizard);
+				wd.setTitle(wizard.getWindowTitle());
+				wd.open();
+			} catch (CoreException e) {
+				e.printStackTrace();
+			}
+		}
+	}
+
+	protected static class StatechartViewerFilter extends ViewerFilter {
+		@Override
+		public boolean select(Viewer viewer, Object parentElement,
+				Object element) {
+			if (element instanceof IFile) {
+				return ((IFile) element).getFileExtension().endsWith("sct");
+			}
+			return true;
+		}
+	}
+}

+ 26 - 1
plugins/org.yakindu.sct.ui.editor/src/org/yakindu/sct/ui/editor/edithelper/SubmachineStateEditHelper.java

@@ -10,6 +10,15 @@
  */
 package org.yakindu.sct.ui.editor.edithelper;
 
+import org.eclipse.gmf.runtime.common.core.command.ICommand;
+import org.eclipse.gmf.runtime.emf.type.core.commands.SetValueCommand;
+import org.eclipse.gmf.runtime.emf.type.core.requests.ConfigureRequest;
+import org.eclipse.gmf.runtime.emf.type.core.requests.SetRequest;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.swt.widgets.Shell;
+import org.yakindu.sct.model.sgraph.SGraphPackage;
+import org.yakindu.sct.model.sgraph.Statechart;
+import org.yakindu.sct.ui.editor.dialogs.SelectSubmachineDialog;
 
 /**
  * 
@@ -18,5 +27,21 @@ package org.yakindu.sct.ui.editor.edithelper;
  */
 public class SubmachineStateEditHelper extends VertexEditHelper {
 
-	// TODO: Open the dialog here
+	/**
+	 * Prompts the user to select the submachine resource
+	 */
+	@Override
+	protected ICommand getConfigureCommand(ConfigureRequest req) {
+		SelectSubmachineDialog dialog = new SelectSubmachineDialog(new Shell());
+		if (Dialog.OK == dialog.open()) {
+			Statechart selectedSubmachine = dialog.getSelectedSubmachine();
+			if (selectedSubmachine != null) {
+				return new SetValueCommand(new SetRequest(
+						req.getElementToConfigure(),
+						SGraphPackage.Literals.SUBMACHINE_STATE__SUBSTATECHART,
+						selectedSubmachine));
+			}
+		}
+		return null;
+	}
 }

+ 1 - 1
plugins/org.yakindu.sct.ui.editor/src/org/yakindu/sct/ui/editor/editparts/SubmachineStateEditPart.java

@@ -27,7 +27,7 @@ public class SubmachineStateEditPart extends AbstractStateEditPart {
 	public SubmachineStateEditPart(View view) {
 		super(view);
 	}
-
+	
 	@Override
 	protected void createDefaultEditPolicies() {
 		super.createDefaultEditPolicies();

+ 3 - 1
plugins/org.yakindu.sct.ui.editor/src/org/yakindu/sct/ui/editor/pictogram/OpenSubstatechartHandler.java

@@ -14,6 +14,7 @@ import org.eclipse.core.commands.AbstractHandler;
 import org.eclipse.core.commands.ExecutionEvent;
 import org.eclipse.core.commands.ExecutionException;
 import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.resource.Resource;
 import org.eclipse.emf.workspace.util.WorkspaceSynchronizer;
 import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
 import org.eclipse.jface.viewers.ISelection;
@@ -40,8 +41,9 @@ public class OpenSubstatechartHandler extends AbstractHandler {
 		if (selectedState == null)
 			return null;
 		Statechart substatechart = selectedState.getSubstatechart();
+		Resource eResource = substatechart.eResource();
 		FileEditorInput fileEditorInput = new FileEditorInput(
-				WorkspaceSynchronizer.getFile(substatechart.eResource()));
+				WorkspaceSynchronizer.getFile(eResource));
 
 		final IWorkbenchPage page = PlatformUI.getWorkbench()
 				.getActiveWorkbenchWindow().getActivePage();

+ 134 - 0
plugins/org.yakindu.sct.ui.editor/src/org/yakindu/sct/ui/editor/propertysheets/SubmachineSelectionDialogPropertyDescriptor.java

@@ -0,0 +1,134 @@
+/**
+ * Copyright (c) 2011 itemis AG and others.
+ * 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:
+ *         itemis AG - initial API and implementation
+ *
+ */
+package org.yakindu.sct.ui.editor.propertysheets;
+
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.commands.operations.OperationHistoryFactory;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.draw2d.ColorConstants;
+import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.emf.common.notify.impl.AdapterImpl;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.gmf.runtime.emf.type.core.commands.SetValueCommand;
+import org.eclipse.gmf.runtime.emf.type.core.requests.SetRequest;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.layout.GridDataFactory;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+import org.yakindu.sct.model.sgraph.SGraphPackage;
+import org.yakindu.sct.model.sgraph.Statechart;
+import org.yakindu.sct.model.sgraph.SubmachineState;
+import org.yakindu.sct.ui.editor.dialogs.SelectSubmachineDialog;
+
+import de.itemis.gmf.runtime.commons.properties.descriptors.IFormPropertyDescriptor;
+
+/**
+ * 
+ * @author andreas muelder - Initial contribution and API
+ * 
+ */
+public class SubmachineSelectionDialogPropertyDescriptor implements
+		IFormPropertyDescriptor {
+
+	private final class UpdateLabelAdapter extends AdapterImpl {
+		@Override
+		public void notifyChanged(Notification msg) {
+			if (msg.getFeature() == SGraphPackage.Literals.SUBMACHINE_STATE__SUBSTATECHART) {
+				updateLabel(submachine);
+			}
+		}
+	}
+
+	private SubmachineState submachine;
+	private Label label;
+	private UpdateLabelAdapter updateLabelAdapter;
+
+	public void bindToModel(EObject eObject) {
+		this.submachine = (SubmachineState) eObject;
+		updateLabel(submachine);
+		if (updateLabelAdapter == null) {
+			updateLabelAdapter = new UpdateLabelAdapter();
+			submachine.eAdapters().add(updateLabelAdapter);
+		}
+
+	}
+
+	private void updateLabel(SubmachineState state) {
+		Statechart substatechart = submachine.getSubstatechart();
+		if (substatechart != null) {
+			label.setText(substatechart.eResource().getURI().toString());
+		}
+	}
+
+	public void createLabelColumn(Composite parent) {
+		FormToolkit toolkit = new FormToolkit(parent.getDisplay());
+		Label label = toolkit.createLabel(parent, "Submachine:");
+		GridDataFactory.fillDefaults().applyTo(label);
+		toolkit.dispose();
+
+	}
+
+	public void createControlColumn(final Composite parent) {
+		Composite composite = new Composite(parent, SWT.NONE);
+		GridDataFactory.fillDefaults().grab(true, false).applyTo(composite);
+		composite.setBackground(ColorConstants.white);
+		GridLayout layout = new GridLayout(2, false);
+		layout.marginLeft = 0;
+		layout.marginRight = 0;
+		composite.setLayout(layout);
+		label = new Label(composite, SWT.BORDER);
+		GridDataFactory.fillDefaults().grab(true, false).applyTo(label);
+		Button openDialog = new Button(composite, SWT.NONE);
+		GridDataFactory.fillDefaults().hint(SWT.DEFAULT, 10)
+				.applyTo(openDialog);
+		openDialog.setText("...");
+		openDialog.addListener(SWT.Selection, new Listener() {
+			public void handleEvent(Event event) {
+				SelectSubmachineDialog dialog = new SelectSubmachineDialog(
+						parent.getShell());
+				if (Dialog.OK == dialog.open()) {
+					Statechart selectedSubmachine = dialog
+							.getSelectedSubmachine();
+					if (selectedSubmachine != null) {
+						SetValueCommand command = new SetValueCommand(
+								new SetRequest(
+										submachine,
+										SGraphPackage.Literals.SUBMACHINE_STATE__SUBSTATECHART,
+										selectedSubmachine));
+						try {
+							OperationHistoryFactory.getOperationHistory()
+									.execute(command,
+											new NullProgressMonitor(), null);
+						} catch (ExecutionException e) {
+							e.printStackTrace();
+						}
+					}
+				}
+			}
+		});
+
+	}
+
+	public void createHelpColumn(Composite parent) {
+		// No help provided
+	}
+
+	public void dispose() {
+		submachine.eAdapters().remove(updateLabelAdapter);
+	}
+}

+ 3 - 7
plugins/org.yakindu.sct.ui.editor/src/org/yakindu/sct/ui/editor/propertysheets/SubmachineStatePropertySection.java

@@ -12,13 +12,12 @@ package org.yakindu.sct.ui.editor.propertysheets;
 
 import java.util.List;
 
-import org.yakindu.sct.model.sgraph.SGraphPackage;
-
 import de.itemis.gmf.runtime.commons.properties.descriptors.IFormPropertyDescriptor;
+
 /**
  * 
  * @author andreas muelder - Initial contribution and API
- *
+ * 
  */
 public class SubmachineStatePropertySection extends StatePropertySection {
 
@@ -26,11 +25,8 @@ public class SubmachineStatePropertySection extends StatePropertySection {
 	protected void createPropertyDescriptors(
 			List<IFormPropertyDescriptor> descriptors) {
 		super.createPropertyDescriptors(descriptors);
-
 		// Submachine reference
-		TextDialogPropertyDescriptor submachineDescriptor = new TextDialogPropertyDescriptor(
-				SGraphPackage.Literals.SUBMACHINE_STATE__SUBSTATECHART,
-				"Submachine:");
+		SubmachineSelectionDialogPropertyDescriptor submachineDescriptor = new SubmachineSelectionDialogPropertyDescriptor();
 		descriptors.add(submachineDescriptor);
 	}
 

+ 0 - 169
plugins/org.yakindu.sct.ui.editor/src/org/yakindu/sct/ui/editor/propertysheets/TextDialogPropertyDescriptor.java

@@ -1,169 +0,0 @@
-/**
- * Copyright (c) 2011 itemis AG and others.
- * 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:
- *         itemis AG - initial API and implementation
- *
- */
-package org.yakindu.sct.ui.editor.propertysheets;
-
-import java.io.IOException;
-import java.util.Collections;
-import java.util.List;
-
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.commands.operations.IOperationHistory;
-import org.eclipse.core.commands.operations.OperationHistoryFactory;
-import org.eclipse.core.databinding.observable.value.IObservableValue;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.draw2d.ColorConstants;
-import org.eclipse.emf.common.ui.dialogs.ResourceDialog;
-import org.eclipse.emf.common.util.URI;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EStructuralFeature;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.emf.ecore.resource.Resource.Factory;
-import org.eclipse.emf.ecore.resource.impl.ResourceFactoryRegistryImpl;
-import org.eclipse.emf.ecore.util.EcoreUtil;
-import org.eclipse.gmf.runtime.emf.type.core.commands.SetValueCommand;
-import org.eclipse.gmf.runtime.emf.type.core.requests.SetRequest;
-import org.eclipse.jface.databinding.swt.WidgetProperties;
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.layout.GridDataFactory;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Shell;
-import org.yakindu.sct.model.sgraph.SGraphPackage;
-import org.yakindu.sct.model.sgraph.Statechart;
-import org.yakindu.sct.model.sgraph.SubmachineState;
-
-import de.itemis.gmf.runtime.commons.properties.descriptors.AbstractPropertyDescriptor;
-
-/**
- * 
- * @author andreas muelder - Initial contribution and API
- * 
- */
-public class TextDialogPropertyDescriptor extends AbstractPropertyDescriptor {
-
-	private EObject eObject;
-	private Label text;
-
-	public TextDialogPropertyDescriptor(EStructuralFeature feature,
-			String labelName) {
-		super(feature, labelName);
-	}
-
-	@Override
-	protected Control createControl(Composite parent) {
-		
-		
-		
-		Composite composite = new Composite(parent, SWT.NONE);
-		GridDataFactory.fillDefaults().grab(true, false).applyTo(composite);
-		composite.setBackground(ColorConstants.white);
-		GridLayout layout = new GridLayout(2, false);
-		layout.marginLeft = 0;
-		layout.marginRight = 0;
-		composite.setLayout(layout);
-		text = new Label(composite, SWT.BORDER);
-		GridDataFactory.fillDefaults().grab(true, false).applyTo(text);
-		Button openDialog = new Button(composite, SWT.NONE);
-		GridDataFactory.fillDefaults().hint(SWT.DEFAULT, 10)
-				.applyTo(openDialog);
-		openDialog.setText("...");
-
-		openDialog.addSelectionListener(new SelectionListener() {
-
-			public void widgetSelected(SelectionEvent arg0) {
-				ResourceDialog dialog = new ResourceDialog(new Shell(),
-						"Title", SWT.SINGLE | SWT.OPEN);
-
-				if (dialog.open() == Dialog.OK) {
-					List<URI> urIs = dialog.getURIs();
-					if (urIs.size() == 1) {
-						String string = urIs.get(0).toString();
-						Statechart statechart = loadFromResource(string);
-						if (statechart != null) {
-							executeSetCommand(new SetRequest(
-									eObject,
-									SGraphPackage.Literals.SUBMACHINE_STATE__SUBSTATECHART,
-									statechart));
-							getControl().setText(string);
-						}
-					}
-				}
-			}
-
-			public void widgetDefaultSelected(SelectionEvent arg0) {
-			}
-		});
-
-		return text;
-	}
-
-	protected void executeSetCommand(SetRequest request) {
-		SetValueCommand command = new SetValueCommand(request);
-		System.out.println("Can execute: " + command.canExecute());
-		IOperationHistory operationHistory = OperationHistoryFactory
-				.getOperationHistory();
-		try {
-			operationHistory.execute(command, new NullProgressMonitor(), null);
-		} catch (ExecutionException e) {
-			e.printStackTrace();
-		}
-	}
-
-	@Override
-	public Label getControl() {
-		return (Label) super.getControl();
-	}
-
-	@Override
-	protected IObservableValue getWidgetValue() {
-		return WidgetProperties.text(SWT.Modify | SWT.FocusOut).observe(
-				getControl());
-	}
-
-	@Override
-	public void bindToModel(EObject eObject) {
-		this.eObject = eObject;
-		SubmachineState state = (SubmachineState) eObject;
-		Statechart substatechart = state.getSubstatechart();
-		// TODO: Handle unresolvable proxy
-		if (substatechart != null && !substatechart.eIsProxy())
-			text.setText(substatechart.eResource().getURI().toString());
-
-	}
-
-	private Statechart loadFromResource(String resourceUriString) {
-		String uri = (String) resourceUriString;
-		if (uri == null || uri.trim().length() == 0)
-			return null;
-		URI platformURI = URI.createURI(uri, true);
-		Factory factory = ResourceFactoryRegistryImpl.INSTANCE
-				.getFactory(platformURI);
-		Resource resource = factory.createResource(platformURI);
-		if (resource == null)
-			return null;
-		try {
-			resource.load(Collections.emptyMap());
-		} catch (IOException e) {
-			e.printStackTrace();
-		}
-		Statechart statechart = (Statechart) EcoreUtil.getObjectByType(
-				resource.getContents(), SGraphPackage.Literals.STATECHART);
-		return statechart;
-	}
-
-}

+ 47 - 18
plugins/org.yakindu.sct.ui.editor/src/org/yakindu/sct/ui/editor/wizards/CreationWizard.java

@@ -36,6 +36,7 @@ import org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCo
 import org.eclipse.gmf.runtime.emf.core.GMFEditingDomainFactory;
 import org.eclipse.jface.operation.IRunnableWithProgress;
 import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.StructuredSelection;
 import org.eclipse.jface.wizard.Wizard;
 import org.eclipse.ui.INewWizard;
 import org.eclipse.ui.IWorkbench;
@@ -44,30 +45,42 @@ import org.eclipse.ui.PartInitException;
 import org.eclipse.ui.PlatformUI;
 import org.eclipse.ui.actions.WorkspaceModifyOperation;
 import org.eclipse.ui.part.FileEditorInput;
+import org.yakindu.sct.ui.editor.StatechartImages;
 import org.yakindu.sct.ui.editor.editor.StatechartDiagramEditor;
 import org.yakindu.sct.ui.editor.factories.FactoryUtils;
 
+/**
+ * 
+ * @author andreas muelder - Initial contribution and API
+ * 
+ */
 public class CreationWizard extends Wizard implements INewWizard {
 
-	protected IStructuredSelection selection;
+	public static final String ID = "org.yakindu.sct.ui.editor.StatechartDiagramWizard";
+
+	protected IStructuredSelection selection = new StructuredSelection();
 
 	protected CreationWizardPage modelFilePage;
 
 	protected Resource diagram;
 
-	private final boolean openOnCreate = true;
+	private boolean openOnCreate = true;
 
 	public void init(IWorkbench workbench, IStructuredSelection selection) {
 		this.selection = selection;
 		setWindowTitle("New YAKINDU Statechart");
 		setNeedsProgressMonitor(true);
+
 	}
 
 	@Override
 	public void addPages() {
-		modelFilePage = new CreationWizardPage("DiagramModelFile", getSelection(), "sct");
+		modelFilePage = new CreationWizardPage("DiagramModelFile",
+				getSelection(), "sct");
 		modelFilePage.setTitle("YAKINDU SCT Diagram");
 		modelFilePage.setDescription("Create a new YAKINDU SCT Diagram File");
+		modelFilePage.setImageDescriptor(StatechartImages.LOGO
+				.imageDescriptor());
 		addPage(modelFilePage);
 	}
 
@@ -76,8 +89,10 @@ public class CreationWizard extends Wizard implements INewWizard {
 		IRunnableWithProgress op = new WorkspaceModifyOperation(null) {
 
 			@Override
-			protected void execute(IProgressMonitor monitor) throws CoreException, InterruptedException {
-				diagram = createDiagram(modelFilePage.getURI(), modelFilePage.getURI(), monitor);
+			protected void execute(IProgressMonitor monitor)
+					throws CoreException, InterruptedException {
+				diagram = createDiagram(modelFilePage.getURI(),
+						modelFilePage.getURI(), monitor);
 				if (isOpenOnCreate() && diagram != null) {
 					try {
 						openDiagram(diagram);
@@ -95,24 +110,33 @@ public class CreationWizard extends Wizard implements INewWizard {
 		return diagram != null;
 	}
 
-	public static boolean openDiagram(Resource diagram) throws PartInitException {
+	public static boolean openDiagram(Resource diagram)
+			throws PartInitException {
 		String path = diagram.getURI().toPlatformString(true);
-		IResource workspaceResource = ResourcesPlugin.getWorkspace().getRoot().findMember(new Path(path));
+		IResource workspaceResource = ResourcesPlugin.getWorkspace().getRoot()
+				.findMember(new Path(path));
 		if (workspaceResource instanceof IFile) {
-			IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
-			return null != page.openEditor(new FileEditorInput((IFile) workspaceResource), StatechartDiagramEditor.ID);
+			IWorkbenchPage page = PlatformUI.getWorkbench()
+					.getActiveWorkbenchWindow().getActivePage();
+			return null != page.openEditor(new FileEditorInput(
+					(IFile) workspaceResource), StatechartDiagramEditor.ID);
 		}
 		return false;
 	}
 
-	public static Resource createDiagram(URI diagramURI, URI modelURI, IProgressMonitor progressMonitor) {
-		TransactionalEditingDomain editingDomain = GMFEditingDomainFactory.INSTANCE.createEditingDomain();
+	public static Resource createDiagram(URI diagramURI, URI modelURI,
+			IProgressMonitor progressMonitor) {
+		TransactionalEditingDomain editingDomain = GMFEditingDomainFactory.INSTANCE
+				.createEditingDomain();
 		progressMonitor.beginTask("Creating diagram file ...", 3);
-		final Resource resource = editingDomain.getResourceSet().createResource(modelURI);
-		AbstractTransactionalCommand command = new AbstractTransactionalCommand(editingDomain,
-				"Creating diagram file ...", Collections.EMPTY_LIST) {
+		final Resource resource = editingDomain.getResourceSet()
+				.createResource(modelURI);
+		AbstractTransactionalCommand command = new AbstractTransactionalCommand(
+				editingDomain, "Creating diagram file ...",
+				Collections.EMPTY_LIST) {
 			@Override
-			protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info)
+			protected CommandResult doExecuteWithResult(
+					IProgressMonitor monitor, IAdaptable info)
 					throws ExecutionException {
 
 				FactoryUtils.createStatechartModel(resource);
@@ -127,8 +151,8 @@ public class CreationWizard extends Wizard implements INewWizard {
 
 		};
 		try {
-			OperationHistoryFactory.getOperationHistory().execute(command, new SubProgressMonitor(progressMonitor, 1),
-					null);
+			OperationHistoryFactory.getOperationHistory().execute(command,
+					new SubProgressMonitor(progressMonitor, 1), null);
 		} catch (ExecutionException e) {
 			e.printStackTrace();
 		}
@@ -139,7 +163,8 @@ public class CreationWizard extends Wizard implements INewWizard {
 	public static Map<String, String> getSaveOptions() {
 		Map<String, String> saveOptions = new HashMap<String, String>();
 		saveOptions.put(XMLResource.OPTION_ENCODING, "UTF-8");
-		saveOptions.put(Resource.OPTION_SAVE_ONLY_IF_CHANGED, Resource.OPTION_SAVE_ONLY_IF_CHANGED_MEMORY_BUFFER);
+		saveOptions.put(Resource.OPTION_SAVE_ONLY_IF_CHANGED,
+				Resource.OPTION_SAVE_ONLY_IF_CHANGED_MEMORY_BUFFER);
 		return saveOptions;
 	}
 
@@ -166,4 +191,8 @@ public class CreationWizard extends Wizard implements INewWizard {
 		return openOnCreate;
 	}
 
+	public void setOpenOnCreate(boolean openOnCreate) {
+		this.openOnCreate = openOnCreate;
+	}
+
 }

+ 18 - 4
plugins/org.yakindu.sct.ui.editor/src/org/yakindu/sct/ui/editor/wizards/CreationWizardPage.java

@@ -1,3 +1,13 @@
+/**
+ * Copyright (c) 2010 committers of YAKINDU and others.
+ * 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:
+ * 	committers of YAKINDU - initial API and implementation
+ * 
+ */
 package org.yakindu.sct.ui.editor.wizards;
 
 import org.eclipse.core.resources.ResourcesPlugin;
@@ -13,7 +23,8 @@ public class CreationWizardPage extends WizardNewFileCreationPage {
 
 	private final String fileExtension;
 
-	public CreationWizardPage(String pageName, IStructuredSelection selection, String fileExtension) {
+	public CreationWizardPage(String pageName, IStructuredSelection selection,
+			String fileExtension) {
 		super(pageName, selection);
 		this.fileExtension = fileExtension;
 	}
@@ -41,7 +52,8 @@ public class CreationWizardPage extends WizardNewFileCreationPage {
 	@Override
 	public void createControl(Composite parent) {
 		super.createControl(parent);
-		setFileName(getUniqueFileName(getContainerFullPath(), getFileName(), getExtension()));
+		setFileName(getUniqueFileName(getContainerFullPath(), getFileName(),
+				getExtension()));
 		setPageComplete(validatePage());
 	}
 
@@ -51,14 +63,16 @@ public class CreationWizardPage extends WizardNewFileCreationPage {
 			return false;
 		}
 		String extension = getExtension();
-		if (extension != null && !getFilePath().toString().endsWith("." + extension)) {
+		if (extension != null
+				&& !getFilePath().toString().endsWith("." + extension)) {
 			setErrorMessage(NLS.bind("file extension is not valid!", extension));
 			return false;
 		}
 		return true;
 	}
 
-	public static String getUniqueFileName(IPath containerFullPath, String fileName, String extension) {
+	public static String getUniqueFileName(IPath containerFullPath,
+			String fileName, String extension) {
 		if (containerFullPath == null) {
 			containerFullPath = new Path(""); //$NON-NLS-1$
 		}