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