|
Lines 41-62
Link Here
|
| 41 |
import org.eclipse.uml2.uml.UMLPackage; |
41 |
import org.eclipse.uml2.uml.UMLPackage; |
| 42 |
|
42 |
|
| 43 |
/** |
43 |
/** |
| 44 |
* The Wizard creates a Papyrus Project and a Papyrus Model inside it |
44 |
* The Wizard creates a Papyrus Project and a Papyrus Model inside it. |
| 45 |
*/ |
45 |
*/ |
| 46 |
|
|
|
| 47 |
public class NewPapyrusProjectWizard extends BasicNewProjectResourceWizard { |
46 |
public class NewPapyrusProjectWizard extends BasicNewProjectResourceWizard { |
| 48 |
|
47 |
|
|
|
48 |
/** The new project page. */ |
| 49 |
private WizardNewProjectCreationPage myNewProjectPage; |
49 |
private WizardNewProjectCreationPage myNewProjectPage; |
| 50 |
|
50 |
|
|
|
51 |
/** The diagram kind page. */ |
| 51 |
private SelectDiagramKindPage myDiagramKindPage; |
52 |
private SelectDiagramKindPage myDiagramKindPage; |
| 52 |
|
53 |
|
|
|
54 |
/** The initial project name. */ |
| 53 |
private String initialProjectName; |
55 |
private String initialProjectName; |
| 54 |
|
56 |
|
|
|
57 |
/** |
| 58 |
* @see org.eclipse.ui.wizards.newresource.BasicNewProjectResourceWizard#init(org.eclipse.ui.IWorkbench, |
| 59 |
* org.eclipse.jface.viewers.IStructuredSelection) |
| 60 |
* |
| 61 |
* @param workbench |
| 62 |
* @param selection |
| 63 |
*/ |
| 55 |
public void init(IWorkbench workbench, IStructuredSelection selection) { |
64 |
public void init(IWorkbench workbench, IStructuredSelection selection) { |
| 56 |
super.init(workbench, selection); |
65 |
super.init(workbench, selection); |
| 57 |
setWindowTitle("New Papyrus Project"); |
66 |
setWindowTitle("New Papyrus Project"); |
| 58 |
} |
67 |
} |
| 59 |
|
68 |
|
|
|
69 |
/** |
| 70 |
* @see org.eclipse.ui.wizards.newresource.BasicNewProjectResourceWizard#addPages() |
| 71 |
* |
| 72 |
*/ |
| 60 |
public void addPages() { |
73 |
public void addPages() { |
| 61 |
super.addPages(); |
74 |
super.addPages(); |
| 62 |
myNewProjectPage = (WizardNewProjectCreationPage)getPage("basicNewProjectPage"); //$NON-NLS-1$ |
75 |
myNewProjectPage = (WizardNewProjectCreationPage)getPage("basicNewProjectPage"); //$NON-NLS-1$ |
|
Lines 67-72
Link Here
|
| 67 |
} |
80 |
} |
| 68 |
|
81 |
|
| 69 |
myDiagramKindPage = new SelectDiagramKindPage("Select kind of diagram") { |
82 |
myDiagramKindPage = new SelectDiagramKindPage("Select kind of diagram") { |
|
|
83 |
|
| 70 |
protected boolean validatePage() { |
84 |
protected boolean validatePage() { |
| 71 |
return true; |
85 |
return true; |
| 72 |
}; |
86 |
}; |
|
Lines 74-96
Link Here
|
| 74 |
addPage(myDiagramKindPage); |
88 |
addPage(myDiagramKindPage); |
| 75 |
} |
89 |
} |
| 76 |
|
90 |
|
|
|
91 |
/** |
| 92 |
* Creates the file. |
| 93 |
* |
| 94 |
* @return the file |
| 95 |
*/ |
| 77 |
private IFile createFile() { |
96 |
private IFile createFile() { |
| 78 |
IPath newFilePath = myNewProjectPage.getProjectHandle().getFullPath().append(NewModelFilePage.DEFAULT_NAME + "." + NewModelFilePage.DIAGRAM_EXTENSION); |
97 |
IPath newFilePath = myNewProjectPage.getProjectHandle().getFullPath().append(NewModelFilePage.DEFAULT_NAME + "." + NewModelFilePage.DIAGRAM_EXTENSION); |
| 79 |
return ResourcesPlugin.getWorkspace().getRoot().getFile(newFilePath); |
98 |
return ResourcesPlugin.getWorkspace().getRoot().getFile(newFilePath); |
| 80 |
} |
99 |
} |
| 81 |
|
100 |
|
|
|
101 |
/** |
| 102 |
* @see org.eclipse.ui.wizards.newresource.BasicNewProjectResourceWizard#performFinish() |
| 103 |
* |
| 104 |
* @return |
| 105 |
*/ |
| 82 |
public boolean performFinish() { |
106 |
public boolean performFinish() { |
| 83 |
boolean created = super.performFinish(); |
107 |
boolean created = super.performFinish(); |
| 84 |
if (!created) { |
108 |
if(!created) { |
| 85 |
return false; |
109 |
return false; |
| 86 |
} |
110 |
} |
| 87 |
// if the user wants to create a diagram |
111 |
// if the user wants to create a diagram |
| 88 |
if (myDiagramKindPage.getCreationCommand() != null) { |
112 |
if(myDiagramKindPage.getCreationCommand() != null) { |
| 89 |
return createPapyrusModel(); |
113 |
return createPapyrusModel(); |
| 90 |
} |
114 |
} |
| 91 |
return true; |
115 |
return true; |
| 92 |
} |
116 |
} |
| 93 |
|
117 |
|
|
|
118 |
/** |
| 119 |
* Creates the papyrus model. |
| 120 |
* |
| 121 |
* @return true, if successful |
| 122 |
*/ |
| 94 |
private boolean createPapyrusModel() { |
123 |
private boolean createPapyrusModel() { |
| 95 |
final DiResourceSet diResourceSet = new DiResourceSet(); |
124 |
final DiResourceSet diResourceSet = new DiResourceSet(); |
| 96 |
try { |
125 |
try { |
|
Lines 147-171
Link Here
|
| 147 |
return true; |
176 |
return true; |
| 148 |
} |
177 |
} |
| 149 |
|
178 |
|
|
|
179 |
/** |
| 180 |
* Initialize model resource. |
| 181 |
* |
| 182 |
* @param resource |
| 183 |
* the domain model resource |
| 184 |
* @param rootElementName |
| 185 |
* the root element name |
| 186 |
*/ |
| 150 |
private void initializeModelResource(Resource resource, String rootElementName) { |
187 |
private void initializeModelResource(Resource resource, String rootElementName) { |
| 151 |
// // fjcano #293135 :: support model templates |
188 |
// // fjcano #293135 :: support model templates |
| 152 |
// if(!isInitializeFromTemplate()) { |
189 |
// if(!isInitializeFromTemplate()) { |
| 153 |
Model model = UMLFactory.eINSTANCE.createModel(); |
190 |
Model model = UMLFactory.eINSTANCE.createModel(); |
| 154 |
model.setName(rootElementName); |
191 |
model.setName(rootElementName); |
| 155 |
resource.getContents().add(model); |
192 |
resource.getContents().add(model); |
| 156 |
// } else { |
193 |
// } else { |
| 157 |
// super.initializeModelResource(resource, rootElementName); |
194 |
// super.initializeModelResource(resource, rootElementName); |
| 158 |
// } |
195 |
// } |
| 159 |
} |
196 |
} |
| 160 |
|
197 |
|
|
|
198 |
/** |
| 199 |
* Sets the initial project name. |
| 200 |
* |
| 201 |
* @param initialProjectName |
| 202 |
* the new initial project name |
| 203 |
*/ |
| 161 |
public void setInitialProjectName(String initialProjectName) { |
204 |
public void setInitialProjectName(String initialProjectName) { |
| 162 |
this.initialProjectName = initialProjectName; |
205 |
this.initialProjectName = initialProjectName; |
| 163 |
} |
206 |
} |
| 164 |
|
207 |
|
|
|
208 |
/** |
| 209 |
* Gets the model content type. |
| 210 |
* |
| 211 |
* @return the model content type |
| 212 |
*/ |
| 165 |
protected String getModelContentType() { |
213 |
protected String getModelContentType() { |
| 166 |
return UMLPackage.eCONTENT_TYPE; |
214 |
return UMLPackage.eCONTENT_TYPE; |
| 167 |
} |
215 |
} |
| 168 |
|
216 |
|
|
|
217 |
/** |
| 218 |
* Gets the model file extension. |
| 219 |
* |
| 220 |
* @return the model file extension |
| 221 |
*/ |
| 169 |
protected String getModelFileExtension() { |
222 |
protected String getModelFileExtension() { |
| 170 |
return "uml"; |
223 |
return "uml"; |
| 171 |
} |
224 |
} |