422
|
1 |
/*
|
|
2 |
* Copyright (c) 2007 Borland Software Corporation
|
|
3 |
*
|
|
4 |
* All rights reserved. This program and the accompanying materials
|
|
5 |
* are made available under the terms of the Eclipse Public License v1.0
|
|
6 |
* which accompanies this distribution, and is available at
|
|
7 |
* http://www.eclipse.org/legal/epl-v10.html
|
|
8 |
*
|
|
9 |
* Contributors:
|
|
10 |
* Alexander Shatalin (Borland) - initial API and implementation
|
|
11 |
*/
|
|
12 |
|
|
13 |
«IMPORT "http://www.eclipse.org/gmf/2008/GenModel"»
|
|
14 |
|
|
15 |
«DEFINE LoadResourceAction FOR gmfgen::GenDiagram-»
|
|
16 |
«EXPAND xpt::Common::copyright FOR editorGen-»
|
|
17 |
package «editorGen.editor.packageName»;
|
|
18 |
|
|
19 |
«EXPAND xpt::Common::generatedClassComment»
|
|
20 |
public class «loadResourceActionClassName» implements org.eclipse.ui.IObjectActionDelegate {
|
|
21 |
|
|
22 |
«EXPAND attributes-»
|
|
23 |
|
|
24 |
«EXPAND setActivePart-»
|
|
25 |
|
|
26 |
«EXPAND run-»
|
|
27 |
|
|
28 |
«EXPAND selectionChanged-»
|
|
29 |
|
|
30 |
«EXPAND isEnabled-»
|
|
31 |
|
|
32 |
«EXPAND additions-»
|
|
33 |
}
|
|
34 |
«ENDDEFINE»
|
|
35 |
|
|
36 |
«DEFINE attributes FOR gmfgen::GenDiagram-»
|
|
37 |
«EXPAND xpt::Common::generatedMemberComment»
|
|
38 |
private «getEditPartQualifiedClassName()» mySelectedElement;
|
|
39 |
|
|
40 |
«EXPAND xpt::Common::generatedMemberComment»
|
|
41 |
private org.eclipse.swt.widgets.Shell myShell;
|
|
42 |
«ENDDEFINE»
|
|
43 |
|
|
44 |
«DEFINE setActivePart FOR gmfgen::GenDiagram-»
|
|
45 |
«EXPAND xpt::Common::generatedMemberComment»
|
|
46 |
public void setActivePart(org.eclipse.jface.action.IAction action, org.eclipse.ui.IWorkbenchPart targetPart) {
|
|
47 |
myShell = targetPart.getSite().getShell();
|
|
48 |
}
|
|
49 |
«ENDDEFINE»
|
|
50 |
|
|
51 |
«DEFINE run FOR gmfgen::GenDiagram-»
|
|
52 |
«EXPAND xpt::Common::generatedMemberComment»
|
|
53 |
public void run(org.eclipse.jface.action.IAction action) {
|
|
54 |
org.eclipse.emf.edit.ui.action.LoadResourceAction.LoadResourceDialog loadResourceDialog = new org.eclipse.emf.edit.ui.action.LoadResourceAction.LoadResourceDialog(myShell, mySelectedElement.getEditingDomain());
|
|
55 |
loadResourceDialog.open();
|
|
56 |
}
|
|
57 |
«ENDDEFINE»
|
|
58 |
|
|
59 |
«DEFINE selectionChanged FOR gmfgen::GenDiagram-»
|
|
60 |
«EXPAND xpt::Common::generatedMemberComment»
|
|
61 |
public void selectionChanged(org.eclipse.jface.action.IAction action, org.eclipse.jface.viewers.ISelection selection) {
|
|
62 |
mySelectedElement = null;
|
|
63 |
if (selection instanceof org.eclipse.jface.viewers.IStructuredSelection) {
|
|
64 |
org.eclipse.jface.viewers.IStructuredSelection structuredSelection = (org.eclipse.jface.viewers.IStructuredSelection) selection;
|
|
65 |
if (structuredSelection.size() == 1 && structuredSelection.getFirstElement() instanceof «getEditPartQualifiedClassName()») {
|
|
66 |
mySelectedElement = («getEditPartQualifiedClassName()») structuredSelection.getFirstElement();
|
|
67 |
}
|
|
68 |
}
|
|
69 |
action.setEnabled(isEnabled());
|
|
70 |
}
|
|
71 |
«ENDDEFINE»
|
|
72 |
|
|
73 |
«DEFINE isEnabled FOR gmfgen::GenDiagram-»
|
|
74 |
«EXPAND xpt::Common::generatedMemberComment»
|
|
75 |
private boolean isEnabled() {
|
|
76 |
return mySelectedElement != null;
|
|
77 |
}
|
|
78 |
«ENDDEFINE»
|
|
79 |
|
|
80 |
«DEFINE additions FOR gmfgen::GenDiagram-»
|
|
81 |
«ENDDEFINE» |