Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: d28b1e2f6be91fdff2ea29c0c81b6aafc7c526e2 (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
/*
 * Copyright (c) 2007, 2009 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:
 *    Dmitry Stadnik (Borland) - initial API and implementation
 */
«IMPORT 'http://www.eclipse.org/gmf/2009/GenModel'»

«EXTENSION xpt::editor::Utils»

«DEFINE CreationWizardPage FOR gmfgen::GenDiagram-»
«EXPAND xpt::Common::copyright FOR editorGen-»
package «editorGen.editor.packageName»;

«EXPAND xpt::Common::generatedClassComment»
public class «creationWizardPageClassName» extends
	«IF editorGen.application = null-»
		org.eclipse.ui.dialogs.WizardNewFileCreationPage
	«ELSE-»
		«editorGen.application.packageName».WizardNewFileCreationPage
	«ENDIF-»
		{

	«EXPAND xpt::Common::generatedMemberComment»
	private final String fileExtension;

	«EXPAND xpt::Common::generatedMemberComment»
	public «creationWizardPageClassName»(String pageName,
			org.eclipse.jface.viewers.IStructuredSelection selection, String fileExtension) {
		super(pageName, selection);
		this.fileExtension = fileExtension;
	}

	/**
	 * Override to create files with this extension.
	 * 
	 * @generated
	 */
	protected String getExtension() {
		return fileExtension;
	}

	«EXPAND xpt::Common::generatedMemberComment»
	public org.eclipse.emf.common.util.URI getURI() {
	«IF editorGen.application = null-»
		return org.eclipse.emf.common.util.URI.createPlatformResourceURI(getFilePath().toString(), false);
	«ELSE-»
		return org.eclipse.emf.common.util.URI.createFileURI(getFilePath().toString());
	«ENDIF-»
	}
	«IF editorGen.application = null-»

	«EXPAND xpt::Common::generatedMemberComment»
	protected org.eclipse.core.runtime.IPath getFilePath() {
		org.eclipse.core.runtime.IPath path = getContainerFullPath();
		if (path == null) {
			path = new org.eclipse.core.runtime.Path(""); //$NON-NLS-1$
		}
		String fileName = getFileName();
		if (fileName != null) {
			path = path.append(fileName);
		}
		return path;
	}
	«ENDIF-»

	«EXPAND xpt::Common::generatedMemberComment»
	public void createControl(org.eclipse.swt.widgets.Composite parent) {
		super.createControl(parent);
		setFileName(«getDiagramEditorUtilQualifiedClassName()».getUniqueFileName(
				getContainerFullPath(), getFileName(), getExtension()));
		setPageComplete(validatePage());
	}

	«EXPAND xpt::Common::generatedMemberComment»
	protected boolean validatePage() {
		if (!super.validatePage()) {
			return false;
		}
		String extension = getExtension();
		if (extension != null && !getFilePath().toString().endsWith("." + extension)) {
			setErrorMessage(org.eclipse.osgi.util.NLS.bind(
					«EXPAND xpt::Externalizer::accessorCall(i18nKeyForCreationWizardPageExtensionError(self)) FOR editorGen», extension));
			return false;
		}
		return true;
	}
	«EXPAND additions-»
}
«ENDDEFINE»

«DEFINE additions FOR gmfgen::GenDiagram»«ENDDEFINE»

«DEFINE i18nValues FOR gmfgen::GenDiagram-»
«EXPAND xpt::Externalizer::messageEntry(i18nKeyForCreationWizardPageExtensionError(self), 'File name should have {0} extension.')-»
«ENDDEFINE»

«DEFINE i18nAccessors FOR gmfgen::GenDiagram-»
	«EXPAND xpt::Externalizer::accessorField(i18nKeyForCreationWizardPageExtensionError(self))-»
«ENDDEFINE»

Back to the top