| Line | Hits | Source |
|---|---|---|
| 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; | |
| 53 | 9 | public Action deleteAction = new AbstractAction() { |
| 54 | public void actionPerformed(ActionEvent event) { | |
| 55 | ProcessChainEditor.getInstance().deleteAction.actionPerformed(null); | |
| 56 | } | |
| 57 | }; | |
| 58 | ||
| 59 | 9 | public Action descendIntoSubGraphAction = new AbstractAction() { |
| 60 | public void actionPerformed(ActionEvent event) { | |
| 61 | ProcessChainEditor | |
| 62 | .getInstance() | |
| 63 | .descendIntoSubGraphAction | |
| 64 | .actionPerformed( | |
| 65 | event); | |
| 66 | } | |
| 67 | }; | |
| 68 | 9 | public Action createTaskSubGraphAction = new AbstractAction() { |
| 69 | public void actionPerformed(ActionEvent event) { | |
| 70 | ProcessChainEditor | |
| 71 | .getInstance() | |
| 72 | .createTaskSubGraphAction | |
| 73 | .actionPerformed( | |
| 74 | event); | |
| 75 | } | |
| 76 | }; | |
| 77 | 9 | public Action newTaskAction = new AbstractAction() { |
| 78 | public void actionPerformed(ActionEvent event) { | |
| 79 | ProcessChainEditor.getInstance().newTaskPopupAction( | |
| 80 | getCurrentLocationX(), | |
| 81 | getCurrentLocationY()); | |
| 82 | } | |
| 83 | }; | |
| 84 | 9 | public Action newResourceAction = new AbstractAction() { |
| 85 | public void actionPerformed(ActionEvent event) { | |
| 86 | ProcessChainEditor.getInstance().newResourcePopupAction( | |
| 87 | getCurrentLocationX(), | |
| 88 | getCurrentLocationY()); | |
| 89 | } | |
| 90 | }; | |
| 91 | 9 | public Action newLinkAction = new AbstractAction() { |
| 92 | public void actionPerformed(ActionEvent event) { | |
| 93 | ProcessChainEditor.getInstance().newLinkAction.actionPerformed( | |
| 94 | event); | |
| 95 | } | |
| 96 | }; | |
| 97 | 9 | 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"; | |
| 107 | 9 | public PopupMenu() { |
| 108 | ||
| 109 | try { | |
| 110 | 9 | this.popupMenu = |
| 111 | (JPopupMenu) (new SwingEngine(this)).render( | |
| 112 | ClassLoader.getSystemClassLoader().getResource(UI_DEF_FILE_NAME)); | |
| 113 | 0 | } catch (Exception exception) { |
| 114 | this.logger.error("", exception); | |
| 115 | 9 | } |
| 116 | 9 | this.delete.setEnabled(false); |
| 117 | 9 | CurrentlySelectedNodeSingleton.getInstance().attach(this); |
| 118 | ||
| 119 | 9 | } |
| 120 | /** | |
| 121 | * @return | |
| 122 | */ | |
| 123 | public JPopupMenu getPopupMenu() { | |
| 124 | 1 | return popupMenu; |
| 125 | } | |
| 126 | /* (non-Javadoc) | |
| 127 | * @see net.sourceforge.demetrix.ui.CurrentlySelectedNodeObserver#currentlySelectedNodeChanged() | |
| 128 | */ | |
| 129 | public void currentlySelectedNodeChanged() { | |
| 130 | 68 | DefaultGraphCell cell = null; |
| 131 | 68 | Object[] cells = null; |
| 132 | 68 | cell = |
| 133 | CurrentlySelectedNodeSingleton | |
| 134 | .getInstance() | |
| 135 | .getCurrentlySelectedNode(); | |
| 136 | 68 | if (cell != null) { |
| 137 | 44 | if (cell.getUserObject() instanceof Task) { |
| 138 | 28 | this.balanceSheet.setEnabled(true); |
| 139 | } else { | |
| 140 | 16 | this.balanceSheet.setEnabled(false); |
| 141 | } | |
| 142 | } else { | |
| 143 | 24 | this.balanceSheet.setEnabled(false); |
| 144 | } | |
| 145 | 68 | cells = |
| 146 | CurrentlySelectedNodeSingleton | |
| 147 | .getInstance() | |
| 148 | .getCurrentlySelectedCells(); | |
| 149 | 68 | if (cells != null) { |
| 150 | 39 | if (cells.length > 1) { |
| 151 | 30 | this.createTaskSubGraph.setEnabled(true); |
| 152 | } else { | |
| 153 | 9 | this.createTaskSubGraph.setEnabled(false); |
| 154 | } | |
| 155 | } else { | |
| 156 | 29 | this.createTaskSubGraph.setEnabled(false); |
| 157 | } | |
| 158 | ||
| 159 | 68 | this.delete.setEnabled(ProcessChainEditor.getInstance().getStateOfDeleteMenuItem()); |
| 160 | 68 | } |
| 161 | /** | |
| 162 | * @return | |
| 163 | */ | |
| 164 | public int getCurrentLocationX() { | |
| 165 | 0 | return currentLocationX; |
| 166 | } | |
| 167 | /** | |
| 168 | * @return | |
| 169 | */ | |
| 170 | public int getCurrentLocationY() { | |
| 171 | 0 | return currentLocationY; |
| 172 | } | |
| 173 | /** | |
| 174 | * @param i | |
| 175 | */ | |
| 176 | public void setCurrentLocationX(int i) { | |
| 177 | 0 | currentLocationX = i; |
| 178 | 0 | } |
| 179 | /** | |
| 180 | * @param i | |
| 181 | */ | |
| 182 | public void setCurrentLocationY(int i) { | |
| 183 | 0 | currentLocationY = i; |
| 184 | 0 | } |
| 185 | } |
|
this report was generated by version 1.0.5 of jcoverage. |
copyright © 2003, jcoverage ltd. all rights reserved. |