01: package org.enhydra.jawe.base.controller.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.base.controller.JaWEController;
11:
12: /**
13: * Class that realizes <B>reopen</B> action.
14: * @author Sasa Bojanic
15: */
16: public class Reopen extends ActionBase {
17:
18: public Reopen(JaWEComponent jawecomponent) {
19: super (jawecomponent);
20: }
21:
22: public void enableDisableAction() {
23: JaWEController jc = (JaWEController) jawecomponent;
24: boolean en = false;
25: if (jc.getMainPackage() != null) {
26: String name = jc.getPackageFilename(jc.getMainPackageId());
27: if (name != null
28: && jc.isPackageModified(jc.getMainPackageId())) {
29: en = true;
30: }
31: }
32: setEnabled(en);
33: }
34:
35: public void actionPerformed(ActionEvent e) {
36: JaWEController jc = JaWEManager.getInstance()
37: .getJaWEController();
38: String name = jc.getPackageFilename(jc.getMainPackageId());
39: if (name == null) {
40: String msg = jc.getSettings().getLanguageDependentString(
41: "WarningCannotReopenXPDL");
42: jc.getJaWEFrame().message(msg, JOptionPane.WARNING_MESSAGE);
43: return;
44: }
45: if (jc.tryToClosePackage(jc.getMainPackageId(), false)) {
46: jc.openPackageFromFile(name);
47: }
48: }
49:
50: }
|