Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: cbe92b735c19c73cabd180d21699e87d4c64636f (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
/*
 * Copyright (c) 2007 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:
 *    bblajer (Borland) - initial API and implementation
 */

«IMPORT "http://www.eclipse.org/gmf/2005/GenModel/2.0"»
«IMPORT "http://www.eclipse.org/emf/2002/Ecore"»
«IMPORT "http://www.eclipse.org/emf/2002/GenModel"»

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

«EXPAND xpt::Common::generatedClassComment»
public class «loadResourceActionClassName» implements org.eclipse.ui.IObjectActionDelegate {
	«EXPAND xpt::Common::generatedMemberComment»
	private «getEditPartQualifiedClassName()» mySelectedElement;
	
	«EXPAND xpt::Common::generatedMemberComment»
	private org.eclipse.swt.widgets.Shell myShell;

	«EXPAND xpt::Common::generatedMemberComment»
	public void setActivePart(org.eclipse.jface.action.IAction action, org.eclipse.ui.IWorkbenchPart targetPart) {
		myShell = targetPart.getSite().getShell();
	}

«EXPAND run-»
«EXPAND selectionChanged-»
«EXPAND getEditingDomain-»
«EXPAND additions-»
}
«ENDDEFINE»

«DEFINE run FOR gmfgen::GenDiagram-»
	«EXPAND xpt::Common::generatedMemberComment»
	public void run(org.eclipse.jface.action.IAction action) {
		org.eclipse.emf.edit.ui.action.LoadResourceAction.LoadResourceDialog loadResourceDialog = new org.eclipse.emf.edit.ui.action.LoadResourceAction.LoadResourceDialog(myShell, getEditingDomain());
		loadResourceDialog.open();
	}
«ENDDEFINE»

«DEFINE getEditingDomain FOR gmfgen::GenDiagram-»
«EXPAND xpt::Common::generatedMemberComment»
private org.eclipse.emf.edit.domain.EditingDomain getEditingDomain() {
	return org.eclipse.emf.transaction.util.TransactionUtil.getEditingDomain(mySelectedElement.getDiagram());
}
«ENDDEFINE»

«DEFINE selectionChanged FOR gmfgen::GenDiagram-»
	«EXPAND xpt::Common::generatedMemberComment»
	public void selectionChanged(org.eclipse.jface.action.IAction action, org.eclipse.jface.viewers.ISelection selection) {
		mySelectedElement = null;
		if (selection instanceof org.eclipse.jface.viewers.IStructuredSelection) {
			org.eclipse.jface.viewers.IStructuredSelection structuredSelection = (org.eclipse.jface.viewers.IStructuredSelection) selection;
			if (structuredSelection.size() == 1 && structuredSelection.getFirstElement() instanceof «getEditPartQualifiedClassName()») {
				mySelectedElement = («getEditPartQualifiedClassName()») structuredSelection.getFirstElement();
			}
		}
		action.setEnabled(mySelectedElement != null);
	}
«ENDDEFINE»

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

Back to the top