| /* |
| * 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» |