KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > enhydra > jawe > actions > Delete


1 /*
2  * Authors:
3  * Stefanovic Nenad chupo@iis.ns.ac.yu
4  * Bojanic Sasa sasaboy@neobee.net
5  * Puskas Vladimir vpuskas@eunet.yu
6  * Pilipovic Goran zboniek@uns.ac.yu
7  *
8  */

9
10 package org.enhydra.jawe.actions;
11
12 import org.enhydra.jawe.*;
13 import org.enhydra.jawe.xml.elements.WorkflowProcess;
14
15 import org.jgraph.graph.*;
16
17 import java.awt.event.ActionEvent JavaDoc;
18 import javax.swing.tree.DefaultMutableTreeNode JavaDoc;
19 import javax.swing.JOptionPane JavaDoc;
20
21 /**
22  * Class that realizes <B>delete</B> action.
23  * Deletes selected cells and their descendants.
24  */

25 public class Delete extends ActionBase {
26
27    public Delete (AbstractEditor editor) {
28       super(editor);
29    }
30
31    public void actionPerformed(ActionEvent JavaDoc e) {
32       if (editor instanceof ProcessEditor) {
33          Object JavaDoc[] cells = editor.getGraph().getSelectionCells();
34          WorkflowManager dm=editor.getGraph().getWorkflowManager();
35          dm.removeCellsAndArrangeParticipants(cells);
36       } else {
37          Object JavaDoc cell = editor.getGraph().getSelectionCell();
38          if (cell!=null && !(cell instanceof Port)) {
39             org.enhydra.jawe.xml.elements.WorkflowProcess wp=
40                (org.enhydra.jawe.xml.elements.WorkflowProcess)
41                ((DefaultMutableTreeNode JavaDoc)cell).getUserObject();
42             if (wp.getCollection().canRemoveElement(wp)) {
43                WorkflowManager dm=editor.getGraph().getWorkflowManager();
44                dm.removeCellsAndArrangeParticipants(new Object JavaDoc[] {cell});
45             } else {
46                JaWE.getInstance().message(ResourceManager.getLanguageDependentString(
47                   "WarningCannotDeleteProcessThatIsInUseBySomeSubflowActivity"),
48                   JOptionPane.WARNING_MESSAGE);
49             }
50          }
51       }
52    }
53
54
55 }
56
Popular Tags