blob: 889aaa1766a0d3b228bdacf9b0ab0e7948682ab6 (
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
|
/*
* Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) 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:
* Martin Fluegge - initial API and implementation
*
*/
package org.eclipse.emf.cdo.dawn.examples.acore.diagram.part;
import org.eclipse.emf.common.util.URI;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.dialogs.WizardNewFileCreationPage;
/**
* @generated
*/
public class AcoreCreationWizardPage extends WizardNewFileCreationPage
{
/**
* @generated
*/
private final String fileExtension;
/**
* @generated
*/
public AcoreCreationWizardPage(String pageName, IStructuredSelection selection, String fileExtension)
{
super(pageName, selection);
this.fileExtension = fileExtension;
}
/**
* Override to create files with this extension.
*
* @generated
*/
protected String getExtension()
{
return fileExtension;
}
/**
* @generated
*/
public URI getURI()
{
return URI.createPlatformResourceURI(getFilePath().toString(), false);
}
/**
* @generated
*/
protected IPath getFilePath()
{
IPath path = getContainerFullPath();
if (path == null)
{
path = new Path(""); //$NON-NLS-1$
}
String fileName = getFileName();
if (fileName != null)
{
path = path.append(fileName);
}
return path;
}
/**
* @generated
*/
public void createControl(Composite parent)
{
super.createControl(parent);
setFileName(AcoreDiagramEditorUtil.getUniqueFileName(getContainerFullPath(), getFileName(), getExtension()));
setPageComplete(validatePage());
}
/**
* @generated
*/
protected boolean validatePage()
{
if (!super.validatePage())
{
return false;
}
String extension = getExtension();
if (extension != null && !getFilePath().toString().endsWith("." + extension))
{
setErrorMessage(NLS.bind(Messages.AcoreCreationWizardPageExtensionError, extension));
return false;
}
return true;
}
}
|