KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > clif > scenario > util > isac > gui > action > DeleteNodeAction


1 /*
2  * CLIF is a Load Injection Framework
3  * Copyright (C) 2004 France Telecom R&D
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18  *
19  * CLIF
20  *
21  * Contact: clif@objectweb.org
22  */

23 package org.objectweb.clif.scenario.util.isac.gui.action;
24
25 import java.net.URL JavaDoc;
26
27 import org.apache.log4j.Category;
28 import org.eclipse.jface.action.Action;
29 import org.eclipse.jface.resource.ImageDescriptor;
30 import org.eclipse.jface.window.ApplicationWindow;
31 import org.objectweb.clif.scenario.util.isac.FileName;
32 import org.objectweb.clif.scenario.util.isac.gui.ScenarioGUIEditor;
33 import org.objectweb.clif.scenario.util.isac.gui.tree.ScenarioTreeViewer;
34 import org.objectweb.clif.scenario.util.isac.util.tree.ScenarioNode;
35 import org.objectweb.clif.scenario.util.isac.util.tree.TreeManager;
36 /**
37  * Action which delete a behaviors tree node
38  *
39  * @author JC Meillaud
40  * @author A Peyrard
41  */

42 public class DeleteNodeAction extends Action {
43     /**
44      * The application window, which launch this action
45      */

46     ScenarioGUIEditor window;
47     ScenarioTreeViewer viewer;
48     static Category cat = Category
49             .getInstance(DeleteNodeAction.class.getName());
50     /**
51      * Build a new delete node action
52      *
53      * @param w
54      * The application window, in wich we will use this action
55      */

56     public DeleteNodeAction(ApplicationWindow w) {
57         cat.debug("-> constructor");
58         this.window = (ScenarioGUIEditor) w;
59         this.setText("Delete node");
60         this
61                 .setToolTipText("Delete the selected node, in the treeViewer which has the focus");
62         try {
63             this.setImageDescriptor(ImageDescriptor.createFromURL(new URL JavaDoc(
64                     "file:" + FileName.DELETE_ICON)));
65         } catch (Exception JavaDoc e) {
66             cat.warn("Unable to find exit icon file");
67         }
68     }
69
70     public void run() {
71         cat.debug("-> run");
72         this.viewer = this.window.getTreeViewer();
73         ScenarioNode node = this.viewer.getSelectedNode();
74         if (node == null)
75             return;
76         (TreeManager.getTreeManager(null)).deleteBehaviorsTreeNode(node);
77         this.viewer.refresh();
78         // set the saved state false, because we do some changes
79
this.window.setScenarioSavedState(false);
80     }
81 }
Popular Tags