KickJava   Java API By Example, From Geeks To Geeks.

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


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 change the place of a behaviors tree node
38  *
39  * @author JC Meillaud
40  * @author A Peyrard
41  */

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

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

55     public NodeUpperAction(ApplicationWindow w) {
56         cat.debug("-> constructor");
57         this.window = (ScenarioGUIEditor) w;
58         this.setText("To up");
59         this.setToolTipText("Change the place of a child node, to the up");
60         try {
61             this.setImageDescriptor(ImageDescriptor.createFromURL(new URL JavaDoc(
62                     "file:" + FileName.UP_ARROW_ICON)));
63         } catch (Exception JavaDoc e) {
64             cat.warn("Unable to find exit icon file");
65         }
66     }
67
68     public void run() {
69         cat.debug("-> run");
70         this.viewer = this.window.getTreeViewer();
71         ScenarioNode child = this.viewer.getSelectedNode();
72         if (child == null)
73             return;
74         (TreeManager.getTreeManager(null)).changeChildPlace(child, true);
75         this.viewer.refresh();
76     }
77 }
Popular Tags