01: package org.enhydra.jawe.components.graph.actions;
02:
03: import java.awt.event.ActionEvent;
04:
05: import javax.swing.JOptionPane;
06:
07: import org.enhydra.jawe.ActionBase;
08: import org.enhydra.jawe.JaWEComponent;
09: import org.enhydra.jawe.JaWEManager;
10: import org.enhydra.jawe.ResourceManager;
11: import org.enhydra.jawe.Utils;
12: import org.enhydra.jawe.base.controller.JaWEController;
13: import org.enhydra.jawe.base.controller.JaWEFrame;
14: import org.enhydra.shark.xpdl.XMLElement;
15: import org.enhydra.shark.xpdl.elements.Activity;
16:
17: /**
18: * @author Sasa Bojanic
19: */
20: public class ActivityReferredDocument extends ActionBase {
21:
22: public ActivityReferredDocument(JaWEComponent jawecomponent) {
23: super (jawecomponent);
24: }
25:
26: public void enableDisableAction() {
27: JaWEController jc = JaWEManager.getInstance()
28: .getJaWEController();
29:
30: boolean isEnabled = false;
31: if (jc.getSelectionManager().getSelectedElements().size() == 1) {
32: XMLElement el = jc.getSelectionManager()
33: .getSelectedElement();
34: if (el instanceof Activity) {
35: Activity a = (Activity) el;
36:
37: String doc = a.getDocumentation();
38: if (doc.trim().length() > 0)
39: isEnabled = true;
40: }
41: }
42:
43: setEnabled(isEnabled);
44: }
45:
46: public void actionPerformed(ActionEvent e) {
47: JaWEController jc = JaWEManager.getInstance()
48: .getJaWEController();
49: XMLElement el = jc.getSelectionManager().getSelectedElement();
50: if (el instanceof Activity) {
51: Activity a = (Activity) el;
52:
53: String doc = a.getDocumentation();
54: boolean ok = Utils.showExternalDocument(doc);
55: if (!ok) {
56: JaWEFrame jf = jc.getJaWEFrame();
57: JOptionPane
58: .showMessageDialog(
59: jf,
60: doc
61: + ": "
62: + ResourceManager
63: .getLanguageDependentString("InformationFileNotReadable"),
64: jf.getAppTitle(),
65: JOptionPane.INFORMATION_MESSAGE);
66: }
67: }
68: }
69:
70: }
|