• Views
  • Iteration Report
  • My Iteration Report
  •  
OMERO.clients
  • Login
  • Help/Guide
  • About Trac
  • Preferences
  • Wiki
  • Timeline
  • Roadmap
  • Browse Source
  • View Tickets
  • Search

Context Navigation

  • ← Previous Changeset
  • Next Changeset →

Changeset 5625

Show
Ignore:
Timestamp:
09/23/08 16:35:30 (2 months ago)
Author:
will
Message:

Actions etc for Indenting nodes left and right.

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  
    224224    /** The <code>Open Folder</code> icon. */ 
    225225    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     
    226233     
    227234    /**  
    … …  
    229236     * Allows to correctly build arrays for direct indexing.  
    230237     */ 
    231     private static int          MAX_ID = 52; 
     238    private static int          MAX_ID = 54; 
    232239     
    233240    /** Paths of the icon files. */ 
    … …  
    294301        relPaths[CONFIGURE_ICON] = "nuvola_package_utilities16.png"; 
    295302        relPaths[OPEN_FOLDER] = "nuvola_folder_open16.png"; 
     303        relPaths[INDENT_RIGHT] = "nuvola_indent_right16.png"; 
     304        relPaths[INDENT_LEFT] = "nuvola_indent_left16.png"; 
    296305    } 
    297306     
  • trunk/SRC/org/openmicroscopy/shoola/agents/editor/actions/OpenLocalFileAction.java

    r5613 r5625  
    9494   { 
    9595           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",  
    9797                                filters); 
    9898                chooser.addPropertyChangeListener( 
  • trunk/SRC/org/openmicroscopy/shoola/agents/editor/browser/BrowserControl.java

    r5610 r5625  
    4646import org.openmicroscopy.shoola.agents.editor.browser.actions.DeleteFieldsAction; 
    4747import org.openmicroscopy.shoola.agents.editor.browser.actions.EditAction; 
     48import org.openmicroscopy.shoola.agents.editor.browser.actions.IndentLeftAction; 
     49import org.openmicroscopy.shoola.agents.editor.browser.actions.IndentRightAction; 
    4850import org.openmicroscopy.shoola.agents.editor.browser.actions.RedoEditAction; 
    4951import org.openmicroscopy.shoola.agents.editor.browser.actions.UndoEditAction; 
    … …  
    9092        static final Integer    DELETE_FIELD_ACTION = new Integer(4); 
    9193         
     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         
    92100        /**  
    93101     * Reference to the {@link Browser} component, which, in this context, 
    … …  
    124132       actionsMap.put(ADD_FIELD_ACTION, new AddFieldAction(undoSupport, model)); 
    125133       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 
    126138                   (undoSupport, model)); 
    127139    } 
  • trunk/SRC/org/openmicroscopy/shoola/agents/editor/browser/ToolBar.java

    r5594 r5625  
    7979                add(createButton(BrowserControl.ADD_FIELD_ACTION)); 
    8080                add(createButton(BrowserControl.DELETE_FIELD_ACTION)); 
     81                add(createButton(BrowserControl.INDENT_LEFT_ACTION)); 
     82                add(createButton(BrowserControl.INDENT_RIGHT_ACTION)); 
    8183        } 
    8284         
  • trunk/SRC/org/openmicroscopy/shoola/agents/editor/model/TreeModelFactory.java

    r5596 r5625  
    354354        } 
    355355 
     356        public static void saveTreeToFile(File file, TreeModel treeModel) { 
     357                 
     358        } 
    356359 
    357360        /** 
  • trunk/SRC/org/openmicroscopy/shoola/agents/editor/model/TreeModelMethods.java

    r5594 r5625  
    126126        } 
    127127         
     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        } 
    128143         
    129144        /** 
    … …  
    174189        } 
    175190         
     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         
    176292} 
  • trunk/SRC/org/openmicroscopy/shoola/agents/editor/model/undoableEdits/DeleteFieldsEdit.java

    r5610 r5625  
    131131                         * Keep a list of references to the Nodes to be deleted 
    132132                         */ 
     133                        DefaultMutableTreeNode currentNode; 
     134                        MutableTreeNode parent; 
    133135                        for (int i=0; i<selectedPaths.length; i++) { 
    134                                 DefaultMutableTreeNode currentNode = (DefaultMutableTreeNode) 
     136                                currentNode = (DefaultMutableTreeNode) 
    135137                                                selectedPaths[i].getLastPathComponent(); 
    136                                 MutableTreeNode parent = (MutableTreeNode)(currentNode.getParent()); 
     138                                parent = (MutableTreeNode)(currentNode.getParent()); 
    137139                    if (parent != null) { 
    138140                        treeModel.removeNodeFromParent(currentNode); 

Download in other formats:

  • Unified Diff
  • Zip Archive

Trac Powered

Powered by Trac 0.11
By Edgewall Software.

Visit the Trac open source project at
http://trac.edgewall.org/