Changeset 5590
- Timestamp:
- 08/29/08 16:29:05 (3 months ago)
- Location:
- trunk/SRC/org/openmicroscopy/shoola/agents/editor
- Files:
-
- 12 added
- 1 removed
- 26 modified
-
actions/CloseEditorAction.java (modified) (2 diffs)
-
actions/OpenFileAction.java (modified) (2 diffs)
-
browser/Browser.java (modified) (2 diffs)
-
browser/BrowserComponent.java (modified) (5 diffs)
-
browser/BrowserControl.java (modified) (8 diffs)
-
browser/BrowserFactory.java (modified) (3 diffs)
-
browser/BrowserModel.java (modified) (4 diffs)
-
browser/BrowserUI.java (modified) (5 diffs)
-
browser/ContiguousChildSelectionModel.java (modified) (10 diffs)
-
browser/DefaultFieldEditor.java (modified) (8 diffs)
-
browser/EditableTree.java (modified) (3 diffs)
-
browser/FieldPanel.java (modified) (28 diffs)
-
browser/FieldRenderer.java (modified) (7 diffs)
-
browser/MyBasicTreeUI.java (modified) (2 diffs)
-
browser/NavTree.java (modified) (3 diffs)
-
browser/NonEditableTree.java (deleted)
-
browser/ToolBar.java (added)
-
browser/TreeOutlineCellRenderer.java (modified) (2 diffs)
-
browser/actions (added)
-
browser/actions/BrowserAction.java (added)
-
browser/actions/EditAction.java (added)
-
browser/paramUIs/editTemplate/FieldEditorPanel.java (modified) (1 diff)
-
browser/undo (added)
-
browser/undo/ObservableUndoManager.java (added)
-
browser/undo/UndoRedoListener.java (added)
-
browser/undo/UndoRedoObservable.java (added)
-
model/TreeModelFactory.java (modified) (2 diffs)
-
model/TreeModelMethods.java (added)
-
model/params/AbstractParam.java (modified) (5 diffs)
-
model/params/DateTimeParam.java (modified) (12 diffs)
-
model/params/FieldParamsFactory.java (modified) (6 diffs)
-
model/params/IParam.java (modified) (5 diffs)
-
model/params/SingleParam.java (modified) (2 diffs)
-
model/params/TimeParam.java (modified) (2 diffs)
-
model/undoableEdits (added)
-
model/undoableEdits/AttributeEdit.java (added)
-
model/undoableEdits/AttributesEdit.java (added)
-
uiComponents/ImageBorderFactory.java (modified) (2 diffs)
-
view/EditorModel.java (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/SRC/org/openmicroscopy/shoola/agents/editor/actions/CloseEditorAction.java
r5588 r5590 28 28 import java.awt.event.ActionEvent; 29 29 30 import javax.swing.Action;31 32 30 //Third-party libraries 33 31 … … 36 34 import org.openmicroscopy.shoola.agents.editor.IconManager; 37 35 import org.openmicroscopy.shoola.agents.editor.view.Editor; 38 import org.openmicroscopy.shoola.util.ui.UIUtilities;39 36 40 37 /** -
trunk/SRC/org/openmicroscopy/shoola/agents/editor/actions/OpenFileAction.java
r5588 r5590 23 23 package org.openmicroscopy.shoola.agents.editor.actions; 24 24 25 //Java imports 26 25 27 import java.awt.event.ActionEvent; 26 28 import java.io.File; 27 29 28 import javax.swing.Action;29 30 import javax.swing.event.ChangeEvent; 30 31 import javax.swing.event.ChangeListener; 31 32 import org.openmicroscopy.shoola.agents.editor.IconManager;33 import org.openmicroscopy.shoola.agents.editor.view.Editor;34 import org.openmicroscopy.shoola.util.ui.UIUtilities;35 36 //Java imports37 32 38 33 //Third-party libraries … … 40 35 //Application-internal dependencies 41 36 37 import org.openmicroscopy.shoola.agents.editor.IconManager; 38 import org.openmicroscopy.shoola.agents.editor.view.Editor; 39 42 40 /** 43 * 41 * Opens a file. 44 42 * 45 43 * @author William Moore -
trunk/SRC/org/openmicroscopy/shoola/agents/editor/browser/Browser.java
r5584 r5590 50 50 { 51 51 /** 52 * A String that specifies that the UI should be for tree display only, 53 * not for editing. Used by BrowserFactory 52 * A Flag to denote the <i>Display</i> state. 53 * Specifies that the UI should be for tree display only, 54 * not for editing. 54 55 */ 55 public static final String TREE_DISPLAY = "treeDisplay";56 public static final int TREE_DISPLAY = 0; 56 57 57 58 /** 58 * A String that specifies that the UI should be for tree editing, not 59 * simply display. Used by BrowserFactory 59 * A Flag to denote the <i>Edit</i> state. 60 * This specifies that the UI should be for tree editing, not 61 * simply display. 60 62 */ 61 public static final String TREE_EDIT = "treeEdit";63 public static final int TREE_EDIT = 1; 62 64 63 65 /** … … 75 77 public JComponent getUI(); 76 78 79 /** 80 * Sets the Editable state of the Browser. 81 * If editable is false, no editing of the data is possible. View only. 82 * 83 * @param editable True will allow the data to be edited. 84 */ 85 public void setEditable(boolean editable); 86 87 /** 88 * Queries the current state. 89 * 90 * @return One of the state flags defined by this interface. 91 */ 92 public int getState(); 77 93 } -
trunk/SRC/org/openmicroscopy/shoola/agents/editor/browser/BrowserComponent.java
r5584 r5590 32 32 //Application-internal dependencies 33 33 34 import org.openmicroscopy.shoola.agents.editor.view.Editor; 34 35 import org.openmicroscopy.shoola.util.ui.component.AbstractComponent; 35 36 36 37 /** 37 38 * Implements the {@link Browser} interface to provide the functionality 38 * required of the tree viewer component.39 * required of the editor browser component. 39 40 * This class is the component hub and embeds the component's MVC triad. 40 41 * It delegates actual functionality to the … … 52 53 public class BrowserComponent 53 54 extends AbstractComponent 54 implements Browser {55 55 implements Browser 56 { 56 57 57 58 /** The Model sub-component. */ … … 64 65 private BrowserControl controller; 65 66 66 BrowserComponent(BrowserModel model, String viewingMode) { 67 /** 68 * Creates an instance. 69 * Also initialises the controller and the view. 70 * 71 * @param model The model of the MVC 72 * @param viewingMode A string to define the view/ edit mode of the UI 73 */ 74 BrowserComponent(BrowserModel model) 75 { 67 76 this.model = model; 68 77 controller = new BrowserControl(this); 69 78 70 view = new BrowserUI( viewingMode);79 view = new BrowserUI(); 71 80 } 72 81 … … 84 93 } 85 94 95 /** 96 * Implemented as specified by the {@link Browser} interface. 97 * @see Browser#setTreeModel(TreeModel treeModel) 98 */ 86 99 public void setTreeModel(TreeModel treeModel) 87 100 { … … 99 112 } 100 113 114 /** 115 * Implemented as specified by the {@link Browser} interface. 116 * @see Browser#getUI() 117 */ 118 public void setEditable(boolean editable) 119 { 120 model.setEditable(editable); 121 fireStateChange(); 122 } 123 124 /** 125 * Implemented as specified by the {@link Browser} interface. 126 * @see Browser#getState() 127 */ 128 public int getState() { return model.getState(); } 129 101 130 } -
trunk/SRC/org/openmicroscopy/shoola/agents/editor/browser/BrowserControl.java
r5584 r5590 29 29 30 30 import javax.swing.Action; 31 import javax.swing.JTree; 31 32 import javax.swing.event.ChangeEvent; 32 33 import javax.swing.event.ChangeListener; 34 import javax.swing.event.UndoableEditEvent; 35 import javax.swing.event.UndoableEditListener; 36 import javax.swing.tree.TreeNode; 37 import javax.swing.undo.UndoManager; 38 import javax.swing.undo.UndoableEdit; 39 import javax.swing.undo.UndoableEditSupport; 33 40 34 41 //Third-party libraries … … 36 43 //Application-internal dependencies 37 44 45 import org.openmicroscopy.shoola.agents.editor.browser.actions.EditAction; 46 import org.openmicroscopy.shoola.agents.editor.browser.undo.ObservableUndoManager; 47 import org.openmicroscopy.shoola.agents.editor.model.IAttributes; 48 import org.openmicroscopy.shoola.agents.editor.model.undoableEdits.AttributeEdit; 49 import org.openmicroscopy.shoola.agents.editor.model.undoableEdits.AttributesEdit; 50 38 51 /** 39 * The Controller in the Browser MVC. 52 * The Controller in the Browser MVC. 53 * Also manages undo/redo queue. 40 54 * 41 55 * @author William Moore … … 51 65 { 52 66 53 /** Identifies the <code> Collapse</code> action. */54 static final Integer COLLAPSE= new Integer(0);67 /** Identifies the <code>Edit</code> action. */ 68 static final Integer EDIT = new Integer(0); 55 69 56 70 /** … … 58 72 * is regarded as the Model. 59 73 */ 60 private Browser model; 61 62 /** Reference to the View. */ 63 private BrowserUI view; 74 private Browser model; 75 76 /** 77 * Reference to the View. 78 */ 79 private BrowserUI view; 64 80 65 81 /** Maps actions ids onto actual <code>Action</code> object. */ 66 private Map<Integer, Action> actionsMap; 82 private Map<Integer, Action> actionsMap; 83 84 /** 85 * An undo manager to handle undo/redo queue. 86 */ 87 private UndoManager undoManager; 88 89 /** 90 * Support for the undo/redo. 91 */ 92 private UndoableEditSupport undoSupport; 67 93 68 94 /** Helper method to create all the UI actions. */ 69 95 private void createActions() 70 96 { 71 // actionsMap.put(COLLAPSE, new CollapseAction(model));97 actionsMap.put(EDIT, new EditAction(model)); 72 98 } 73 99 … … 88 114 actionsMap = new HashMap<Integer, Action>(); 89 115 createActions(); 116 117 // initialize the undo.redo system 118 undoManager = new ObservableUndoManager(); 119 undoSupport = new UndoableEditSupport(); 120 undoSupport.addUndoableEditListener(new UndoAdapter()); 90 121 } 91 122 … … 101 132 model.addChangeListener(this); 102 133 } 103 104 105 134 106 135 /** … … 110 139 * @return The specified action. 111 140 */ 112 Action getAction(Integer id) { return actionsMap.get(id); }141 public Action getAction(Integer id) { return actionsMap.get(id); } 113 142 114 143 /** … … 119 148 public void stateChanged(ChangeEvent e) 120 149 { 121 /* Not sure if I need to use states?? 122 123 int state = model.getState(); 124 switch (state) { 125 case Browser.BROWING_DATA: 126 127 break; 128 129 default: 130 break; 131 } 132 */ 133 //view.onStateChanged(state == Browser.READY); 134 } 150 //int state = model.getState(); 151 152 view.onStateChanged(); 153 } 154 155 156 /** 157 * This method adds an attributeEdit to the undo/redo queue and then 158 * update the JTree UI. 159 * JTree update (optional) requires that JTree and TreeNode are not null. 160 * But they are not required for editing of the data. 161 * TODO Would be better for changes to the data to notify the TreeModel 162 * in which the data is held (without the classes modifying the data 163 * having to manually call DefaultTreeModel.nodeChanged(node); 164 * 165 * @param attributes The collection of attributes to edit 166 * @param name The name of the attribute to edit 167 * @param value The new value for the named attribute. 168 * @param tree The JTree displaying the data. This can be null 169 * @param node The node in the JTree that holds data. Can be null. 170 */ 171 public void editAttribute(IAttributes attributes, String name, String value, 172 String displayName, JTree tree, TreeNode node) 173 { 174 UndoableEdit edit = new AttributeEdit(attributes, name, value, 175 displayName, tree, node); 176 undoSupport.postEdit(edit); 177 } 178 179 /** 180 * This method adds an attributesEdit to the undo/redo queue and then 181 * update the JTree UI. 182 * JTree update (optional) requires that JTree and TreeNode are not null. 183 * But they are not required for editing of the data. 184 * TODO Would be better for changes to the data to notify the TreeModel 185 * in which the data is held (without the classes modifying the data 186 * having to manually call DefaultTreeModel.nodeChanged(node); 187 * 188 * @param attributes The collection of attributes to edit 189 * @param displayName A name for display on undo/redo 190 * @param newValues The new values in an attribute map 191 * @param tree The JTree displaying the data. This can be null 192 * @param node The node in the JTree that holds data. Can be null. 193 */ 194 public void editAttributes(IAttributes attributes, String displayName, 195 HashMap<String,String> newValues, JTree tree, TreeNode node) 196 { 197 UndoableEdit edit = new AttributesEdit(attributes, displayName, 198 newValues, tree, node); 199 undoSupport.postEdit(edit); 200 } 201 202 /** 203 * An undo/redo adpater. The adpater is notified when 204 * an undo edit occur(e.g. add or remove from the list) 205 * The adptor extract the edit from the event, add it 206 * to the UndoManager, and refresh the GUI 207 * http://www.javaworld.com/javaworld/jw-06-1998/jw-06-undoredo.html 208 */ 209 private class UndoAdapter implements UndoableEditListener 210 { 211 public void undoableEditHappened (UndoableEditEvent evt) { 212 UndoableEdit edit = evt.getEdit(); 213 undoManager.addEdit( edit ); 214 } 215 } 135 216 } -
trunk/SRC/org/openmicroscopy/shoola/agents/editor/browser/BrowserFactory.java
r5584 r5590 1 1 /* 2 * org.openmicroscopy.shoola.agents. treeviewer.browser.BrowserFactory2 * org.openmicroscopy.shoola.agents.editor.browser.BrowserFactory 3 3 * 4 4 *------------------------------------------------------------------------------ … … 52 52 * @return A browser component. 53 53 */ 54 public static Browser createBrowser( String viewingMode)54 public static Browser createBrowser(int viewingState) 55 55 { 56 BrowserModel model = new BrowserModel( );57 BrowserComponent component = new BrowserComponent(model , viewingMode);56 BrowserModel model = new BrowserModel(viewingState); 57 BrowserComponent component = new BrowserComponent(model); 58 58 model.initialize(component); 59 59 component.initialize(); … … 61 61 } 62 62 63 /** 64 * Creates a new {@link Browser}, with a UI either in the Display mode. 65 * 66 * @return A browser component. 67 */ 68 public static Browser createBrowser() { 69 return createBrowser(Browser.TREE_DISPLAY); 70 } 71 63 72 } -
trunk/SRC/org/openmicroscopy/shoola/agents/editor/browser/BrowserModel.java
r5584 r5590 27 27 import javax.swing.tree.TreeModel; 28 28 29 import org.openmicroscopy.shoola.agents.editor.view.Editor; 30 29 31 //Third-party libraries 30 32 … … 46 48 { 47 49 50 /** Holds one of the state flags defined by {@link Browser}. */ 51 private int state; 52 48 53 /** Reference to the component that embeds this model. */ 49 54 protected Browser component; … … 54 59 /** 55 60 * Creates an instance. 61 * 62 * @param The editing state of the browser. 63 * One of the flags defined by the {@link Browser} interface. 56 64 */ 57 BrowserModel() { 65 BrowserModel(int state) 66 { 67 this.state = state; 58 68 } 59 69 … … 82 92 this.treeModel = model; 83 93 } 94 95 /** 96 * Returns the current state. 97 * 98 * @return One of the flags defined by the {@link Browser} interface. 99 */ 100 int getState() { return state; } 101 102 /** 103 * Sets the Editable state of the Browser. 104 * If editable is false, no editing of the data is possible. View only. 105 * 106 * @param editable True will allow the data to be edited. 107 */ 108 public void setEditable(boolean editable) { 109 110 if (editable) 111 state = Browser.TREE_EDIT; 112 else 113 state = Browser.TREE_DISPLAY; 114 } 84 115 } -
trunk/SRC/org/openmicroscopy/shoola/agents/editor/browser/BrowserUI.java
r5584 r5590 56 56 57 57 /** 58 * A String that defines the UI model. Either View-only, or Editing.59 */60 private String viewingMode;61 62 /**63 58 * An outline view of the Tree, displayed on the left, used 64 59 * to navigate … … 80 75 private void createTrees() 81 76 { 82 if (viewingMode.equals(Browser.TREE_EDIT))83 treeDisplay = new EditableTree(controller);84 85 else86 treeDisplay = new NonEditableTree();77 treeDisplay = new EditableTree(controller); 78 79 int state = model.getState(); 80 if (state == Browser.TREE_EDIT) 81 treeDisplay.setEditable(true); 87 82 88 83 treeOutline = new NavTree(treeDisplay); … … 109 104 110 105 add(splitPane, BorderLayout.CENTER); 106 107 add(new ToolBar(controller), BorderLayout.NORTH); 111 108 } 112 109 … … 117 114 * should be called straight after to link this View to the Controller. 118 115 */ 119 BrowserUI( String viewingMode)116 BrowserUI() 120 117 { 121 this.viewingMode = viewingMode;122 118 } 123 119 … … 149 145 } 150 146 147 /** 148 * The state has changed. 149 * Update the editable status of the main tree display. 150 */ 151 void onStateChanged() { 152 int state = model.getState(); 153 treeDisplay.setEditable(state == Browser.TREE_EDIT); 154 } 151 155 } -
trunk/SRC/org/openmicroscopy/shoola/agents/editor/browser/ContiguousChildSelectionModel.java
r5584 r5590 1 1 /* 2 * editorDynamicTree.ContiguousChildSelectionModel2 * org.openmicroscopy.shoola.agents.editor.browser.ContiguousChildSelectionModel 3 3 * 4 4 *------------------------------------------------------------------------------ … … 56 56 */ 57 57 public class ContiguousChildSelectionModel 58 extends DefaultTreeSelectionModel { 59 60 public ContiguousChildSelectionModel() { 58 extends DefaultTreeSelectionModel 59 { 60 61 /** 62 * Creates an instance. 63 * Sets selectionMode to {@link DISCONTIGUOUS_TREE_SELECTION} 64 */ 65 public ContiguousChildSelectionModel() 66 { 61 67 super(); 62 68 setSelectionMode(DISCONTIGUOUS_TREE_SELECTION); … …
