001: package newprocess.diagram.part;
002:
003: import org.eclipse.core.resources.IFile;
004: import org.eclipse.ui.wizards.newresource.BasicNewResourceWizard;
005: import java.lang.reflect.InvocationTargetException;
006:
007: import org.eclipse.core.runtime.CoreException;
008: import org.eclipse.core.runtime.IProgressMonitor;
009: import org.eclipse.emf.ecore.resource.Resource;
010: import org.eclipse.jface.dialogs.ErrorDialog;
011: import org.eclipse.jface.operation.IRunnableWithProgress;
012: import org.eclipse.jface.viewers.IStructuredSelection;
013: import org.eclipse.jface.wizard.Wizard;
014: import org.eclipse.ui.INewWizard;
015: import org.eclipse.ui.IWorkbench;
016: import org.eclipse.ui.PartInitException;
017: import org.eclipse.ui.actions.WorkspaceModifyOperation;
018:
019: /**
020: * @generated
021: */
022: public class New_processCreationWizard extends Wizard implements
023: INewWizard {
024:
025: /**
026: * @generated
027: */
028: private IWorkbench workbench;
029:
030: /**
031: * @generated
032: */
033: protected IStructuredSelection selection;
034:
035: /**
036: * @generated
037: */
038: protected New_processCreationWizardPage diagramModelFilePage;
039:
040: /**
041: * @generated
042: */
043: protected New_processCreationWizardPage domainModelFilePage;
044:
045: /**
046: * @generated
047: */
048: protected Resource diagram;
049:
050: /**
051: * @generated
052: */
053: private boolean openNewlyCreatedDiagramEditor = true;
054:
055: /**
056: * @generated
057: */
058: public IWorkbench getWorkbench() {
059: return workbench;
060: }
061:
062: /**
063: * @generated
064: */
065: public IStructuredSelection getSelection() {
066: return selection;
067: }
068:
069: /**
070: * @generated
071: */
072: public final Resource getDiagram() {
073: return diagram;
074: }
075:
076: /**
077: * @generated
078: */
079: public final boolean isOpenNewlyCreatedDiagramEditor() {
080: return openNewlyCreatedDiagramEditor;
081: }
082:
083: /**
084: * @generated
085: */
086: public void setOpenNewlyCreatedDiagramEditor(
087: boolean openNewlyCreatedDiagramEditor) {
088: this .openNewlyCreatedDiagramEditor = openNewlyCreatedDiagramEditor;
089: }
090:
091: /**
092: * @generated
093: */
094: public void init(IWorkbench workbench,
095: IStructuredSelection selection) {
096: this .workbench = workbench;
097: this .selection = selection;
098: setWindowTitle("New New_process Diagram");
099: setDefaultPageImageDescriptor(New_processDiagramEditorPlugin
100: .getBundledImageDescriptor("icons/wizban/NewNewprocessWizard.gif")); //$NON-NLS-1$
101: setNeedsProgressMonitor(true);
102: }
103:
104: /**
105: * @generated
106: */
107: public void addPages() {
108: diagramModelFilePage = new New_processCreationWizardPage(
109: "DiagramModelFile", getSelection(), "concept_diagram"); //$NON-NLS-1$ //$NON-NLS-2$
110: diagramModelFilePage.setTitle("Create New_process Diagram");
111: diagramModelFilePage
112: .setDescription("Select file that will contain diagram model.");
113: addPage(diagramModelFilePage);
114:
115: domainModelFilePage = new New_processCreationWizardPage(
116: "DomainModelFile", getSelection(), "concept"); //$NON-NLS-1$ //$NON-NLS-2$
117: domainModelFilePage.setTitle("Create New_process Diagram");
118: domainModelFilePage
119: .setDescription("Select file that will contain domain model.");
120: addPage(domainModelFilePage);
121: }
122:
123: /**
124: * @generated
125: */
126: public boolean performFinish() {
127: IRunnableWithProgress op = new WorkspaceModifyOperation(null) {
128:
129: protected void execute(IProgressMonitor monitor)
130: throws CoreException, InterruptedException {
131: diagram = New_processDiagramEditorUtil.createDiagram(
132: diagramModelFilePage.getURI(),
133: domainModelFilePage.getURI(), monitor);
134: if (isOpenNewlyCreatedDiagramEditor()
135: && diagram != null) {
136: try {
137: New_processDiagramEditorUtil
138: .openDiagram(diagram);
139: } catch (PartInitException e) {
140: ErrorDialog.openError(
141: getContainer().getShell(),
142: "Error opening diagram editor", null, e
143: .getStatus());
144: }
145: }
146: }
147: };
148: try {
149: getContainer().run(false, true, op);
150: } catch (InterruptedException e) {
151: return false;
152: } catch (InvocationTargetException e) {
153: if (e.getTargetException() instanceof CoreException) {
154: ErrorDialog.openError(getContainer().getShell(),
155: "Creation Problems", null, ((CoreException) e
156: .getTargetException()).getStatus());
157: } else {
158: New_processDiagramEditorPlugin
159: .getInstance()
160: .logError(
161: "Error creating diagram", e.getTargetException()); //$NON-NLS-1$
162: }
163: return false;
164: }
165: return diagram != null;
166: }
167: }
|