01: package newprocess.diagram.part;
02:
03: import org.eclipse.emf.edit.ui.action.LoadResourceAction.LoadResourceDialog;
04: import org.eclipse.jface.action.IAction;
05: import org.eclipse.jface.viewers.ISelection;
06: import org.eclipse.jface.viewers.IStructuredSelection;
07: import org.eclipse.swt.widgets.Shell;
08: import org.eclipse.ui.IObjectActionDelegate;
09: import org.eclipse.ui.IWorkbenchPart;
10: import newprocess.diagram.edit.parts.ProcessEditPart;
11:
12: /**
13: * @generated
14: */
15: public class New_processLoadResourceAction implements
16: IObjectActionDelegate {
17:
18: /**
19: * @generated
20: */
21: private ProcessEditPart mySelectedElement;
22:
23: /**
24: * @generated
25: */
26: private Shell myShell;
27:
28: /**
29: * @generated
30: */
31: public void setActivePart(IAction action, IWorkbenchPart targetPart) {
32: myShell = targetPart.getSite().getShell();
33: }
34:
35: /**
36: * @generated
37: */
38: public void run(IAction action) {
39: LoadResourceDialog loadResourceDialog = new LoadResourceDialog(
40: myShell, mySelectedElement.getEditingDomain());
41: loadResourceDialog.open();
42: }
43:
44: /**
45: * @generated
46: */
47: public void selectionChanged(IAction action, ISelection selection) {
48: mySelectedElement = null;
49: if (selection instanceof IStructuredSelection) {
50: IStructuredSelection structuredSelection = (IStructuredSelection) selection;
51: if (structuredSelection.size() == 1
52: && structuredSelection.getFirstElement() instanceof ProcessEditPart) {
53: mySelectedElement = (ProcessEditPart) structuredSelection
54: .getFirstElement();
55: }
56: }
57: action.setEnabled(isEnabled());
58: }
59:
60: /**
61: * @generated
62: */
63: private boolean isEnabled() {
64: return mySelectedElement != null;
65: }
66:
67: }
|