Changeset 5625
- Timestamp:
- 09/23/08 16:35:30 (2 months ago)
- Location:
- trunk/SRC/org/openmicroscopy/shoola/agents/editor
- Files:
-
- 6 added
- 7 modified
-
IconManager.java (modified) (3 diffs)
-
actions/OpenLocalFileAction.java (modified) (1 diff)
-
browser/BrowserControl.java (modified) (3 diffs)
-
browser/ToolBar.java (modified) (1 diff)
-
browser/actions/IndentLeftAction.java (added)
-
browser/actions/IndentRightAction.java (added)
-
graphx/nuvola_indent_left16.png (added)
-
graphx/nuvola_indent_right16.png (added)
-
model/TreeModelFactory.java (modified) (1 diff)
-
model/TreeModelMethods.java (modified) (2 diffs)
-
model/undoableEdits/DeleteFieldsEdit.java (modified) (1 diff)
-
model/undoableEdits/IndentLeftEdit.java (added)
-
model/undoableEdits/IndentRightEdit.java (added)
Legend:
- Unmodified
- Added
- Removed
-
trunk/SRC/org/openmicroscopy/shoola/agents/editor/IconManager.java
r5613 r5625 224 224 /** The <code>Open Folder</code> icon. */ 225 225 public static int OPEN_FOLDER = 52; 226 227 /** The <code>Open Folder</code> icon. */ 228 public static int INDENT_RIGHT = 53; 229 230 /** The <code>Open Folder</code> icon. */ 231 public static int INDENT_LEFT = 54; 232 226 233 227 234 /** … … 229 236 * Allows to correctly build arrays for direct indexing. 230 237 */ 231 private static int MAX_ID = 5 2;238 private static int MAX_ID = 54; 232 239 233 240 /** Paths of the icon files. */ … … 294 301 relPaths[CONFIGURE_ICON] = "nuvola_package_utilities16.png"; 295 302 relPaths[OPEN_FOLDER] = "nuvola_folder_open16.png"; 303 relPaths[INDENT_RIGHT] = "nuvola_indent_right16.png"; 304 relPaths[INDENT_LEFT] = "nuvola_indent_left16.png"; 296 305 } 297 306 -
trunk/SRC/org/openmicroscopy/shoola/agents/editor/actions/OpenLocalFileAction.java
r5613 r5625 94 94 { 95 95 FileChooser chooser = new FileChooser(null, FileChooser.LOAD, 96 " Browse File", "Attach a file to the selected element",96 "Open File", "Choose a file to open in the Editor", 97 97 filters); 98 98 chooser.addPropertyChangeListener( -
trunk/SRC/org/openmicroscopy/shoola/agents/editor/browser/BrowserControl.java
r5610 r5625 46 46 import org.openmicroscopy.shoola.agents.editor.browser.actions.DeleteFieldsAction; 47 47 import org.openmicroscopy.shoola.agents.editor.browser.actions.EditAction; 48 import org.openmicroscopy.shoola.agents.editor.browser.actions.IndentLeftAction; 49 import org.openmicroscopy.shoola.agents.editor.browser.actions.IndentRightAction; 48 50 import org.openmicroscopy.shoola.agents.editor.browser.actions.RedoEditAction; 49 51 import org.openmicroscopy.shoola.agents.editor.browser.actions.UndoEditAction; … … 90 92 static final Integer DELETE_FIELD_ACTION = new Integer(4); 91 93 94 /** Identifies the <code>Indent Right</code> action. */ 95 static final Integer INDENT_RIGHT_ACTION = new Integer(5); 96 97 /** Identifies the <code>Indent Left</code> action. */ 98 static final Integer INDENT_LEFT_ACTION = new Integer(6); 99 92 100 /** 93 101 * Reference to the {@link Browser} component, which, in this context, … … 124 132 actionsMap.put(ADD_FIELD_ACTION, new AddFieldAction(undoSupport, model)); 125 133 actionsMap.put(DELETE_FIELD_ACTION, new DeleteFieldsAction 134 (undoSupport, model)); 135 actionsMap.put(INDENT_RIGHT_ACTION, new IndentRightAction 136 (undoSupport, model)); 137 actionsMap.put(INDENT_LEFT_ACTION, new IndentLeftAction 126 138 (undoSupport, model)); 127 139 } -
trunk/SRC/org/openmicroscopy/shoola/agents/editor/browser/ToolBar.java
r5594 r5625 79 79 add(createButton(BrowserControl.ADD_FIELD_ACTION)); 80 80 add(createButton(BrowserControl.DELETE_FIELD_ACTION)); 81 add(createButton(BrowserControl.INDENT_LEFT_ACTION)); 82 add(createButton(BrowserControl.INDENT_RIGHT_ACTION)); 81 83 } 82 84 -
trunk/SRC/org/openmicroscopy/shoola/agents/editor/model/TreeModelFactory.java
r5596 r5625 354 354 } 355 355 356 public static void saveTreeToFile(File file, TreeModel treeModel) { 357 358 } 356 359 357 360 /** -
trunk/SRC/org/openmicroscopy/shoola/agents/editor/model/TreeModelMethods.java
r5594 r5625 126 126 } 127 127 128 /** 129 * Sets the selected nodes in the tree. 130 * Delegates to {@link #selectNodes(List, JTree)} 131 * 132 * @param nodes The List of nodes to select 133 * @param tree The JTree in which these nodes exist 134 */ 135 public static void selectDNodes(List<DefaultMutableTreeNode> nodes, JTree tree) 136 { 137 ArrayList<MutableTreeNode> mtNodes = new ArrayList<MutableTreeNode>(); 138 for (MutableTreeNode node : nodes) { 139 mtNodes.add(node); 140 } 141 selectNodes(mtNodes, tree); 142 } 128 143 129 144 /** … … 174 189 } 175 190 191 /** 192 * This method 'indents' the nodes to the right, by 193 * making them all children of the first node's previous sibling. 194 * It is intended that all the nodes 195 * in the list are contiguous siblings. 196 * If the first node has no previous sibling, nothing happens. 197 * 198 * @param nodes The list of nodes to move. 199 * @param treeModel The treeModel being edited. Will notify JTree of update 200 * 201 */ 202 public static void indentNodesRight(List<DefaultMutableTreeNode> nodes, 203 DefaultTreeModel treeModel) 204 { 205 if (nodes == null) return; 206 if (nodes.isEmpty()) return; 207 208 DefaultMutableTreeNode firstNode = nodes.get(0); 209 210 // fields need to become children of their preceding sibling 211 DefaultMutableTreeNode previousSibling = firstNode.getPreviousSibling(); 212 213 // if no previous sibling, can't indent 214 if (previousSibling == null) return; 215 216 // move each node to be a child of the previous sibling 217 for (DefaultMutableTreeNode node: nodes) { 218 previousSibling.add(node); 219 } 220 treeModel.nodeStructureChanged(previousSibling.getParent()); 221 } 222 223 /** 224 * Indents nodes to the left in the tree structure (move to a higher level). 225 * Nodes become siblings of their parent. 226 * Siblings of the nodes stay at the same level in the tree: 227 * - Previous siblings are not moved 228 * - Subsequent siblings become children of the last node before it is 229 * promoted (indented left) 230 * 231 * @param nodes The list of nodes to indent left (move to a higher 232 * level in the tree hierarchy). 233 * @param treeModel The treeModel being edited. Will notify JTree of update 234 */ 235 public static void indentNodesLeft(List<DefaultMutableTreeNode> nodes, 236 DefaultTreeModel treeModel) 237 { 238 if (nodes == null) return; 239 if (nodes.isEmpty()) return; 240 241 DefaultMutableTreeNode firstNode = nodes.get(0); 242 DefaultMutableTreeNode parentNode = (DefaultMutableTreeNode) 243 firstNode.getParent(); 244 if (parentNode == null) return; 245 DefaultMutableTreeNode grandParentNode = (DefaultMutableTreeNode) 246 parentNode.getParent(); 247 248 // if parent is root (grandparent null) then can't promote 249 if (grandParentNode == null) return; 250 251 // any fields that are subsequent siblings of the last to be promoted, 252 // must first become children of that node. 253 DefaultMutableTreeNode lastNode = nodes.get(nodes.size()-1); 254 DefaultMutableTreeNode lastNodeSibling = lastNode.getNextSibling(); 255 while (lastNodeSibling != null) { 256 lastNode.add(lastNodeSibling); 257 lastNodeSibling = lastNode.getNextSibling(); 258 } 259 260 // now you can indent nodes left 261 for (DefaultMutableTreeNode node: nodes) { 262 indentNodeLeft(node); 263 } 264 treeModel.nodeStructureChanged(grandParentNode); 265 } 266 267 /** 268 * Indents a single node to the left (one level higher in the tree 269 * hierarchy). 270 * The node will become the next sibling of it's parent. 271 * If the node has no grandparent, nothing happens. 272 * 273 * @param node The node to indent (promote to sibling of it's parent) 274 * @param treeModel The treeModel being edited. Will notify JTree of update 275 */ 276 public static void indentNodeLeft(DefaultMutableTreeNode node) 277 { 278 if (node == null) return; 279 DefaultMutableTreeNode parentNode = (DefaultMutableTreeNode) 280 node.getParent(); 281 if (parentNode == null) return; 282 DefaultMutableTreeNode grandParentNode = (DefaultMutableTreeNode) 283 parentNode.getParent(); 284 if (grandParentNode == null) return; 285 286 int indexOfParent = grandParentNode.getIndex(parentNode); 287 288 // adds after parent 289 grandParentNode.insert(node, indexOfParent + 1); 290 } 291 176 292 } -
trunk/SRC/org/openmicroscopy/shoola/agents/editor/model/undoableEdits/DeleteFieldsEdit.java
r5610 r5625 131 131 * Keep a list of references to the Nodes to be deleted 132 132 */ 133 DefaultMutableTreeNode currentNode; 134 MutableTreeNode parent; 133 135 for (int i=0; i<selectedPaths.length; i++) { 134 DefaultMutableTreeNodecurrentNode = (DefaultMutableTreeNode)136 currentNode = (DefaultMutableTreeNode) 135 137 selectedPaths[i].getLastPathComponent(); 136 MutableTreeNodeparent = (MutableTreeNode)(currentNode.getParent());138 parent = (MutableTreeNode)(currentNode.getParent()); 137 139 if (parent != null) { 138 140 treeModel.removeNodeFromParent(currentNode);
