Coverage details for net.sourceforge.demetrix.ui.PopupMenu

LineHitsSource
1 /*******************************************************************************
2  * Demetrix process modelling system
3  *
4  * Copyright (c) 2003, 2004 Dimitri A. Pissarenko
5  *
6  * This file is part of Demetrix.
7  *
8  * Demetrix is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2.1 of the License, or
11  * (at your option) any later version.
12  *
13  * Demetrix is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with Demetrix; if not, write to the Free Software
20  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21  *
22  * For further information you may
23  *
24  * - send an e-mail in Russian, German or English to dimitri.pissarenko@gmx.net
25  * - look at http://sourceforge.net/projects/demetrix/
26  * - look at http://demetrix.sourceforge.net/
27  * - look at http://members.inode.at/d.pissarenko/
28  *
29  *****************************************************************************/
30 package net.sourceforge.demetrix.ui;
31 import java.awt.event.ActionEvent;
32 import javax.swing.AbstractAction;
33 import javax.swing.Action;
34 import javax.swing.JMenuItem;
35 import javax.swing.JPopupMenu;
36 import net.sourceforge.demetrix.model.Task;
37 import org.apache.log4j.Logger;
38 import org.jgraph.graph.DefaultGraphCell;
39 import org.swixml.SwingEngine;
40 /**
41  * @author Dimitri Pissarenko
42  *
43  */
44 public class PopupMenu implements CurrentlySelectedNodeObserver {
45     private Logger logger = Logger.getLogger(getClass());
46     private JPopupMenu popupMenu;
47     public JMenuItem createTaskSubGraph;
48     public JMenuItem balanceSheet;
49     public JMenuItem delete;
50     private int currentLocationX;
51     private int currentLocationY;
52     public JMenuItem descendIntoSubGraph;
539    public Action deleteAction = new AbstractAction() {
54         public void actionPerformed(ActionEvent event) {
55             ProcessChainEditor.getInstance().deleteAction.actionPerformed(null);
56         }
57     };
58  
599    public Action descendIntoSubGraphAction = new AbstractAction() {
60         public void actionPerformed(ActionEvent event) {
61             ProcessChainEditor
62                 .getInstance()
63                 .descendIntoSubGraphAction
64                 .actionPerformed(
65                 event);
66         }
67     };
689    public Action createTaskSubGraphAction = new AbstractAction() {
69         public void actionPerformed(ActionEvent event) {
70             ProcessChainEditor
71                 .getInstance()
72                 .createTaskSubGraphAction
73                 .actionPerformed(
74                 event);
75         }
76     };
779    public Action newTaskAction = new AbstractAction() {
78         public void actionPerformed(ActionEvent event) {
79             ProcessChainEditor.getInstance().newTaskPopupAction(
80                 getCurrentLocationX(),
81                 getCurrentLocationY());
82         }
83     };
849    public Action newResourceAction = new AbstractAction() {
85         public void actionPerformed(ActionEvent event) {
86             ProcessChainEditor.getInstance().newResourcePopupAction(
87                 getCurrentLocationX(),
88                 getCurrentLocationY());
89         }
90     };
919    public Action newLinkAction = new AbstractAction() {
92         public void actionPerformed(ActionEvent event) {
93             ProcessChainEditor.getInstance().newLinkAction.actionPerformed(
94                 event);
95         }
96     };
979    public Action balanceSheetAction = new AbstractAction() {
98         public void actionPerformed(ActionEvent event) {
99             ProcessChainEditor
100                 .getInstance()
101                 .balanceSheetAction
102                 .actionPerformed(
103                 event);
104         }
105     };
106     public final static String UI_DEF_FILE_NAME="net/sourceforge/demetrix/ui/PopupMenu.xml";
1079    public PopupMenu() {
108         
109         try {
1109            this.popupMenu =
111                 (JPopupMenu) (new SwingEngine(this)).render(
112             ClassLoader.getSystemClassLoader().getResource(UI_DEF_FILE_NAME));
1130        } catch (Exception exception) {
114             this.logger.error("", exception);
1159        }
1169    this.delete.setEnabled(false);
1179        CurrentlySelectedNodeSingleton.getInstance().attach(this);
118         
1199    }
120     /**
121      * @return
122      */
123     public JPopupMenu getPopupMenu() {
1241        return popupMenu;
125     }
126     /* (non-Javadoc)
127      * @see net.sourceforge.demetrix.ui.CurrentlySelectedNodeObserver#currentlySelectedNodeChanged()
128      */
129     public void currentlySelectedNodeChanged() {
13068        DefaultGraphCell cell = null;
13168        Object[] cells = null;
13268        cell =
133             CurrentlySelectedNodeSingleton
134                 .getInstance()
135                 .getCurrentlySelectedNode();
13668        if (cell != null) {
13744            if (cell.getUserObject() instanceof Task) {
13828                this.balanceSheet.setEnabled(true);
139             } else {
14016                this.balanceSheet.setEnabled(false);
141             }
142         } else {
14324            this.balanceSheet.setEnabled(false);
144         }
14568        cells =
146             CurrentlySelectedNodeSingleton
147                 .getInstance()
148                 .getCurrentlySelectedCells();
14968        if (cells != null) {
15039            if (cells.length > 1) {
15130                this.createTaskSubGraph.setEnabled(true);
152             } else {
1539                this.createTaskSubGraph.setEnabled(false);
154             }
155         } else {
15629            this.createTaskSubGraph.setEnabled(false);
157         }
158         
15968        this.delete.setEnabled(ProcessChainEditor.getInstance().getStateOfDeleteMenuItem());
16068    }
161     /**
162      * @return
163      */
164     public int getCurrentLocationX() {
1650        return currentLocationX;
166     }
167     /**
168      * @return
169      */
170     public int getCurrentLocationY() {
1710        return currentLocationY;
172     }
173     /**
174      * @param i
175      */
176     public void setCurrentLocationX(int i) {
1770        currentLocationX = i;
1780    }
179     /**
180      * @param i
181      */
182     public void setCurrentLocationY(int i) {
1830        currentLocationY = i;
1840    }
185 }

this report was generated by version 1.0.5 of jcoverage.
visit www.jcoverage.com for updates.

copyright © 2003, jcoverage ltd. all rights reserved.
Java is a trademark of Sun Microsystems, Inc. in the United States and other countries.