Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 86050f52d444368b6a53b43e37f0c0e45b765732 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
<%@ jet package="org.eclipse.gmf.codegen.templates.editor" class="CreationWizardGenerator"
    imports="org.eclipse.gmf.codegen.gmfgen.* org.eclipse.gmf.common.codegen.*"%>
<%
final GenDiagram genDiagram = (GenDiagram) ((Object[]) argument)[0];
final ImportAssistant importManager = (ImportAssistant) ((Object[]) argument)[1];
%>
<%@ include file="../copyright4java.jetinc"%>
<%importManager.emitPackageStatement(stringBuffer);%>

import java.lang.reflect.InvocationTargetException;

import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.jface.dialogs.ErrorDialog;
import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.wizard.Wizard;
import org.eclipse.ui.INewWizard;
import org.eclipse.ui.IWorkbench;
<%importManager.markImportLocation(stringBuffer);%>

/**
 * @generated
 */
public class <%=importManager.getCompilationUnitName()%> extends Wizard implements INewWizard {

	/**
	 * @generated
	 */
	private IWorkbench workbench;

	/**
	 * @generated
	 */
    protected IStructuredSelection selection;

	/**
	 * @generated
	 */
	protected <%=importManager.getImportedName(genDiagram.getCreationWizardPageQualifiedClassName())%> page;

	/**
	 * @generated
	 */
	protected Resource diagram;

	/**
	 * @generated
	 */
	private boolean openNewlyCreatedDiagramEditor = true;

	/**
	 * @generated
	 */
    public IWorkbench getWorkbench() {
        return workbench;
    }

	/**
	 * @generated
	 */
	public IStructuredSelection getSelection() {
        return selection;
    }

	/**
	 * @generated
	 */
	public final Resource getDiagram() {
		return diagram;
	}

	/**
	 * @generated
	 */
	public final boolean isOpenNewlyCreatedDiagramEditor() {
		return openNewlyCreatedDiagramEditor;
	}

	/**
	 * @generated
	 */
	public void setOpenNewlyCreatedDiagramEditor(boolean openNewlyCreatedDiagramEditor) {
		this.openNewlyCreatedDiagramEditor = openNewlyCreatedDiagramEditor;
	}

	/**
	 * @generated
	 */
	public void init(IWorkbench workbench, IStructuredSelection selection) {
        this.workbench = workbench;
        this.selection = selection;
		setWindowTitle("New <%=genDiagram.getEditorGen().getModelID()%> Diagram");
<%
final String iconNameStem;
// @see Generator#generateWizardBanner
if (genDiagram.getDomainDiagramElement() != null) {
	iconNameStem = genDiagram.getDomainDiagramElement().getGenPackage().getPrefix();
} else {
	iconNameStem = ""; //$NON-NLS-1$
}
final String pluginClassName = importManager.getImportedName(genDiagram.getEditorGen().getPlugin().getActivatorQualifiedClassName());
%>
		setDefaultPageImageDescriptor(<%=pluginClassName%>.getBundledImageDescriptor("icons/wizban/New<%=iconNameStem%>Wizard.gif")); //$NON-NLS-1$
		setNeedsProgressMonitor(true);
	}

	/**
	 * @generated
	 */
	public void addPages() {
		page = new <%=importManager.getImportedName(genDiagram.getCreationWizardPageQualifiedClassName())%>("CreationWizardPage", getSelection()); //$NON-NLS-1$
		page.setTitle("Create <%=genDiagram.getEditorGen().getModelID()%> Diagram");
		page.setDescription("Create a new <%=genDiagram.getEditorGen().getModelID()%> diagram.");
		addPage(page);
	}

	/**
	 * @generated
	 */
	public boolean performFinish() {
		IRunnableWithProgress op =
<%if (genDiagram.getEditorGen().getApplication() == null) {%>
				new <%=importManager.getImportedName("org.eclipse.ui.actions.WorkspaceModifyOperation")%>(null) {

			protected void execute(IProgressMonitor monitor) throws CoreException, InterruptedException {
<%} else {%>
				new IRunnableWithProgress() {

			public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
<%}%>
				diagram = <%=importManager.getImportedName(genDiagram.getDiagramEditorUtilQualifiedClassName())%>.createDiagram(page.getContainerFullPath(), page.getFileName(), monitor);
				if (isOpenNewlyCreatedDiagramEditor() && diagram != null) {
					<%=importManager.getImportedName(genDiagram.getDiagramEditorUtilQualifiedClassName())%>.openDiagram(diagram);
				}
			}
		};
		try {
			getContainer().run(false, true, op);
		} catch (InterruptedException e) {
			return false;
		} catch (InvocationTargetException e) {
			if (e.getTargetException() instanceof CoreException) {
				ErrorDialog.openError(getContainer().getShell(), "Creation Problems", null, ((CoreException) e.getTargetException()).getStatus());
			} else {
				<%=pluginClassName%>.getInstance().logError("Error creating diagram", e.getTargetException()); //$NON-NLS-1$
			}
			return false;
		}
		return diagram != null;
	}
}
<%importManager.emitSortedImports();%>

Back to the top