Changeset 4309
- Timestamp:
- 2003-05-23T16:33:15+12:00 (21 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gli/src/org/greenstone/gatherer/gui/MetaEditPane.java
r4293 r4309 65 65 import org.greenstone.gatherer.valuetree.GValueTree; 66 66 import org.greenstone.gatherer.valuetree.GValueModel; 67 import org.greenstone.gatherer.valuetree.GValueNode; 67 68 import org.w3c.dom.Element; 68 69 /** Provides a view of controls for the editing of metadata. It makes use of several other important components such as a GTree, GTable and GValueTree. While much of the gui content is left to these components, the MetaEditPane is resposible for actioning metadata edit requests, listing for mouse clicks within its scope and other data functionality (such as providing a list of the selected files). … … 73 74 extends JPanel 74 75 implements ActionListener, ListSelectionListener, TreeModelListener, TreeSelectionListener { 75 /** <i>true</i> if the selection has changed since the last time it was asked for, <i>false</i> otherwise. */76 public boolean has_changed = false;77 /** The GValueTree graphically shows the available metadata that has been previously assigned, and provides controls for adding, updating and removing metadata, depending on the users selections in the other important components. */78 public GValueTree tree = null;76 /** <i>true</i> if the selection has changed since the last time it was asked for, <i>false</i> otherwise. */ 77 public boolean has_changed = false; 78 /** The GValueTree graphically shows the available metadata that has been previously assigned, and provides controls for adding, updating and removing metadata, depending on the users selections in the other important components. */ 79 public GValueTree tree = null; 79 80 /** If only files are selected, then show folder is not available. */ 80 81 private boolean show_folder_enabled = false; 81 /** The layout manager used to display either the GTable (when records are selected) or a placeholder panel with the immortal words 'No Record Selected'. */82 private CardLayout card_layout = null;83 /** The layout manager used to display either the GValueTree (when records are selected) or a placeholder panel with the immortal words 'No Record Selected'. */84 private CardLayout card_layout2 = null;85 /** Used to dynamically filter the collection tree at user request. Note that this is synchronized with the collection tree filter in the Gather view. */86 private Filter filter = null;87 /** The data model behind the GTable, to which we hold a reference for convenient access. */88 private GTableModel model = null;89 /** The currently reported selection. Note that this may actually be incorrect, but if so the changed flag will be set, and the selection will be updated the next time it is needed. */90 private FileNode records[] = null;91 /** Records which of the three GTable views is currently being shown, so we can determine what view to change to next (as they cycle). */92 private int current_table_view;93 /** The mode is determined by the metadata edit action choosen. */94 private int mode;95 /** The button, which when clicked, adds metadata to the selected records. */96 private JButton add;97 /** The button, which when clicked, removes the selected metadata from the selected records. */98 private JButton remove;99 /** The button, which when clicked, changes the currently shown GTable view. */100 private JButton table_view;101 /** The button, which when clicked, updates the selected metadata from the selected records. */102 private JButton update;103 /** The label at the top of the collection tree, which shows the collection name. */104 private JLabel collection_label;105 /** The panel in which the metadata value card layout resides. */106 private JPanel control_pane;107 /** The panel in which the metadata table card layout resides. */108 private JPanel table_card_pane;109 /** The panel the table is added to. */110 private JPanel table_pane;82 /** The layout manager used to display either the GTable (when records are selected) or a placeholder panel with the immortal words 'No Record Selected'. */ 83 private CardLayout card_layout = null; 84 /** The layout manager used to display either the GValueTree (when records are selected) or a placeholder panel with the immortal words 'No Record Selected'. */ 85 private CardLayout card_layout2 = null; 86 /** Used to dynamically filter the collection tree at user request. Note that this is synchronized with the collection tree filter in the Gather view. */ 87 private Filter filter = null; 88 /** The data model behind the GTable, to which we hold a reference for convenient access. */ 89 private GTableModel model = null; 90 /** The currently reported selection. Note that this may actually be incorrect, but if so the changed flag will be set, and the selection will be updated the next time it is needed. */ 91 private FileNode records[] = null; 92 /** Records which of the three GTable views is currently being shown, so we can determine what view to change to next (as they cycle). */ 93 //private int current_table_view; 94 /** The mode is determined by the metadata edit action choosen. */ 95 private int mode; 96 /** The button, which when clicked, adds metadata to the selected records. */ 97 private JButton add; 98 /** The button, which when clicked, removes the selected metadata from the selected records. */ 99 private JButton remove; 100 /** The button, which when clicked, changes the currently shown GTable view. */ 101 //private JButton table_view; 102 /** The button, which when clicked, updates the selected metadata from the selected records. */ 103 private JButton update; 104 /** The label at the top of the collection tree, which shows the collection name. */ 105 private JLabel collection_label; 106 /** The panel in which the metadata value card layout resides. */ 107 private JPanel control_pane; 108 /** The panel in which the metadata table card layout resides. */ 109 private JPanel table_card_pane; 110 /** The panel the table is added to. */ 111 private JPanel table_pane; 111 112 /** An icon showing the current state of the table build. */ 112 private JProgressBar activity_bar;113 /** The splitpane dividing the collection tree and the metadata based controls. */114 private JSplitPane external_split;115 /** Divides the metadata table and the value tree controls. */116 private JSplitPane main_split_pane;117 /** A reference to the metadata table, via its superclass. */118 private JTable table;119 /** The label shown at the top of the metadata table detailing the current selection statistics. */120 private JTextField table_label;113 //private JProgressBar activity_bar; 114 /** The splitpane dividing the collection tree and the metadata based controls. */ 115 private JSplitPane external_split; 116 /** Divides the metadata table and the value tree controls. */ 117 private JSplitPane main_split_pane; 118 /** A reference to the metadata table, via its superclass. */ 119 private JTable table; 120 /** The label shown at the top of the metadata table detailing the current selection statistics. */ 121 private JTextField table_label; 121 122 /** The button to control whether assigned metadata is shown. */ 122 private JToggleButton assigned_metadata_view;123 //private JToggleButton assigned_metadata_view; 123 124 /** The button to control whether unassigned metadata is shown. */ 124 private JToggleButton unassigned_metadata_view;125 /** A reference to the collection tree. */126 public DragTree collection_tree;127 /** The currently selected metadata determined by listening to every second list selection event from the metadata table. */128 private Metadata selected_metadata;129 /** Listens for right clicks over the collection tree. */130 private RightButtonListener right_button_listener = null;131 /** A temporary storage array from Strings passed to the dictionary to be inserted in the phrase returned. */132 private String args[];133 /** Provide synchronization between the collection trees in this view and the collection pane view. */134 private TreeSynchronizer tree_sync = null;135 136 125 //private JToggleButton unassigned_metadata_view; 126 /** A reference to the collection tree. */ 127 public DragTree collection_tree; 128 /** The currently selected metadata determined by listening to every second list selection event from the metadata table. */ 129 private Metadata selected_metadata; 130 /** Listens for right clicks over the collection tree. */ 131 private RightButtonListener right_button_listener = null; 132 /** A temporary storage array from Strings passed to the dictionary to be inserted in the phrase returned. */ 133 private String args[]; 134 /** Provide synchronization between the collection trees in this view and the collection pane view. */ 135 private TreeSynchronizer tree_sync = null; 136 static public Dimension BUTTON_SIZE = new Dimension(190, 25); 137 static private Dimension CONTROL_SIZE = new Dimension(560, 240); 137 138 static private Dimension LABEL_SIZE = new Dimension(75, 25); 138 static private Dimension MINIMUM_SIZE = new Dimension(100, 100);139 static private Dimension TABLE_SIZE = new Dimension(560, 25);140 static private Dimension TREE_SIZE = new Dimension(250, 500);141 /** An element of the Mode type enumeration, indicating we are adding metadata (ie no metadata rows are selected in the metadata table). */142 static private int ADD = 0;143 /** An element of the Mode type enumeration, indicating we are editing existing metadata (ie some row is selected in the metadata table). */144 static private int EDIT = 1;145 /** The name of the panel containing the metadata table. */146 static final private String CARD_ONE = "Card One";147 /** The name of the panel containing the placeholder for the metadata table. */148 static final private String CARD_ZERO = "Card Zero";149 /** The name of the panel containing the placeholder for the value tree. */150 static final private String TOOLS_OFF = "Tools Off";151 /** The name of the panel containing the value tree. */152 static final private String TOOLS_ON = "Tools On";153 /** Constructor.154 * @param tree_sync The <strong>TreeSynchronizer</strong> to be used on the collection tree.155 * @see org.greenstone.gatherer.Configuration156 * @see org.greenstone.gatherer.gui.table.GTable157 * @see org.greenstone.gatherer.valuetree.GValueTree158 */159 public MetaEditPane(TreeSynchronizer tree_sync) {160 this.current_table_view = GTableModel.SHOW_FILE;139 static private Dimension MINIMUM_SIZE = new Dimension(100, 100); 140 static private Dimension TABLE_SIZE = new Dimension(560, 25); 141 static private Dimension TREE_SIZE = new Dimension(250, 500); 142 /** An element of the Mode type enumeration, indicating we are adding metadata (ie no metadata rows are selected in the metadata table). */ 143 static private int ADD = 0; 144 /** An element of the Mode type enumeration, indicating we are editing existing metadata (ie some row is selected in the metadata table). */ 145 static private int EDIT = 1; 146 /** The name of the panel containing the metadata table. */ 147 static final private String CARD_ONE = "Card One"; 148 /** The name of the panel containing the placeholder for the metadata table. */ 149 static final private String CARD_ZERO = "Card Zero"; 150 /** The name of the panel containing the placeholder for the value tree. */ 151 static final private String TOOLS_OFF = "Tools Off"; 152 /** The name of the panel containing the value tree. */ 153 static final private String TOOLS_ON = "Tools On"; 154 /** Constructor. 155 * @param tree_sync The <strong>TreeSynchronizer</strong> to be used on the collection tree. 156 * @see org.greenstone.gatherer.Configuration 157 * @see org.greenstone.gatherer.gui.table.GTable 158 * @see org.greenstone.gatherer.valuetree.GValueTree 159 */ 160 public MetaEditPane(TreeSynchronizer tree_sync) { 161 //this.current_table_view = GTableModel.SHOW_FILE; 161 162 this.tree = null; 162 163 this.tree_sync = tree_sync; 163 164 add = new JButton(get(" Add"));164 165 add = new JButton(get("MetaEditPrompt.Accumulate")); 165 166 add.addActionListener(this); 166 167 add.setEnabled(false); 167 168 add.setMnemonic(KeyEvent.VK_A); 168 169 update = new JButton(get("Update")); 169 add.setPreferredSize(BUTTON_SIZE); 170 171 update = new JButton(get("MetaEditPrompt.Overwrite")); 170 172 update.addActionListener(this); 171 173 update.setEnabled(false); 172 update.setMnemonic(KeyEvent.VK_U); 173 174 remove = new JButton(get("Remove")); 174 update.setMnemonic(KeyEvent.VK_P); 175 update.setPreferredSize(BUTTON_SIZE); 176 177 remove = new JButton(get("MetaEditPrompt.Remove")); 175 178 remove.addActionListener(this); 176 179 remove.setEnabled(false); 177 180 remove.setMnemonic(KeyEvent.VK_R); 181 remove.setPreferredSize(BUTTON_SIZE); 178 182 179 183 tree = new GValueTree(this, CONTROL_SIZE.width, CONTROL_SIZE.height, add, update, remove); … … 235 239 } 236 240 } 237 else if(esrc == assigned_metadata_view || esrc == unassigned_metadata_view) {238 239 }241 //else if(esrc == assigned_metadata_view || esrc == unassigned_metadata_view) { 242 // model.changeView(); 243 //} 240 244 validateControls(); 241 245 } … … 295 299 collection_tree.setModel(new DefaultTreeModel(new DefaultMutableTreeNode(get("Collection.No_Collection")))); 296 300 } 297 collection_tree.setRootVisible(ready);298 301 299 302 filter.setEnabled(ready); … … 346 349 collection_tree.addTreeExpansionListener(Gatherer.g_man.foa_listener); 347 350 collection_tree.setLargeModel(true); 348 collection_tree.setRootVisible( true);351 collection_tree.setRootVisible(false); 349 352 350 353 JScrollPane collection_scroll = new JScrollPane(collection_tree); … … 416 419 table_label.setEditable(false); 417 420 418 activity_bar = new JProgressBar();419 activity_bar.setPreferredSize(LABEL_SIZE);420 activity_bar.setString(get("Ready"));421 activity_bar.setStringPainted(true);422 activity_bar.setValue(activity_bar.getMaximum());421 //activity_bar = new JProgressBar(); 422 //activity_bar.setPreferredSize(LABEL_SIZE); 423 //activity_bar.setString(get("Ready")); 424 //activity_bar.setStringPainted(true); 425 //activity_bar.setValue(activity_bar.getMaximum()); 423 426 424 427 card_layout = new CardLayout(); … … 436 439 JPanel table_pane_one = new JPanel(); 437 440 438 JPanel view_pane = new JPanel();439 440 JLabel view_label = new JLabel(get("View"));441 view_label.setPreferredSize(LABEL_SIZE);442 443 JPanel view_button_pane = new JPanel();444 445 assigned_metadata_view = new JToggleButton(get("View_Assigned"), Utility.OFF_ICON);446 assigned_metadata_view.setSelectedIcon(Utility.ON_ICON);447 assigned_metadata_view.setSelected(true);448 assigned_metadata_view.addActionListener(this);449 unassigned_metadata_view = new JToggleButton(get("View_Unassigned"), Utility.OFF_ICON);450 unassigned_metadata_view.setSelectedIcon(Utility.ON_ICON);451 unassigned_metadata_view.setSelected(true);452 unassigned_metadata_view.addActionListener(this);453 XORToggleButtonGroup view_group = new XORToggleButtonGroup();454 view_group.add(assigned_metadata_view);455 view_group.add(unassigned_metadata_view);441 //JPanel view_pane = new JPanel(); 442 443 //JLabel view_label = new JLabel(get("View")); 444 //view_label.setPreferredSize(LABEL_SIZE); 445 446 //JPanel view_button_pane = new JPanel(); 447 448 //assigned_metadata_view = new JToggleButton(get("View_Assigned"), Utility.OFF_ICON); 449 //assigned_metadata_view.setSelectedIcon(Utility.ON_ICON); 450 //assigned_metadata_view.setSelected(true); 451 //assigned_metadata_view.addActionListener(this); 452 //unassigned_metadata_view = new JToggleButton(get("View_Unassigned"), Utility.OFF_ICON); 453 //unassigned_metadata_view.setSelectedIcon(Utility.ON_ICON); 454 //unassigned_metadata_view.setSelected(true); 455 //unassigned_metadata_view.addActionListener(this); 456 //XORToggleButtonGroup view_group = new XORToggleButtonGroup(); 457 //view_group.add(assigned_metadata_view); 458 //view_group.add(unassigned_metadata_view); 456 459 457 460 ///atherer.println("\tCreating metadata_table"); 458 461 table = new JTable(); 459 model = new GTableModel(table, assigned_metadata_view, unassigned_metadata_view, activity_bar); 462 //model = new GTableModel(table, assigned_metadata_view, unassigned_metadata_view, activity_bar); 463 model = new GTableModel(table); 460 464 table.setModel(model); 461 465 table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); … … 520 524 table_card_pane.add(table_pane_one, CARD_ONE); 521 525 522 view_button_pane.setLayout(new GridLayout(1,2,5,0));523 view_button_pane.add(assigned_metadata_view);524 view_button_pane.add(unassigned_metadata_view);525 526 view_pane.setBorder(BorderFactory.createEmptyBorder(5,0,0,0));527 view_pane.setLayout(new BorderLayout());528 view_pane.add(view_label, BorderLayout.WEST);529 view_pane.add(view_button_pane, BorderLayout.CENTER);526 //view_button_pane.setLayout(new GridLayout(1,2,5,0)); 527 //view_button_pane.add(assigned_metadata_view); 528 //view_button_pane.add(unassigned_metadata_view); 529 530 //view_pane.setBorder(BorderFactory.createEmptyBorder(5,0,0,0)); 531 //view_pane.setLayout(new BorderLayout()); 532 //view_pane.add(view_label, BorderLayout.WEST); 533 //view_pane.add(view_button_pane, BorderLayout.CENTER); 530 534 531 535 table_pane.setLayout(new BorderLayout()); 532 536 table_pane.add(table_title_pane, BorderLayout.NORTH); 533 537 table_pane.add(table_card_pane, BorderLayout.CENTER); 534 table_pane.add(view_pane, BorderLayout.SOUTH);538 //table_pane.add(view_pane, BorderLayout.SOUTH); 535 539 536 540 //main_split_pane.add(control_pane, JSplitPane.TOP); … … 538 542 main_split_pane.add(table_pane, JSplitPane.TOP); 539 543 main_split_pane.add(control_pane, JSplitPane.BOTTOM); 540 main_split_pane.setDividerLocation(2 00);544 main_split_pane.setDividerLocation(250); 541 545 542 546 external_split.add(collection_pane, JSplitPane.LEFT);//BorderLayout.WEST); … … 646 650 */ 647 651 public void validateControls() { 652 validateControls(true); 653 } 654 public void validateControls(boolean and_tree) { 648 655 validateMetadataTable(); 649 656 // Validate card_layout_2 … … 654 661 card_layout2.show(control_pane, TOOLS_OFF); 655 662 } 656 657 tree.validateControls(); 663 if(and_tree) { 664 tree.validateControls(); 665 } 658 666 } 659 667 … … 686 694 tree.setFileLevel(selected_metadata.isFileLevel()); 687 695 tree.setSelectedMetadataElement(selected_metadata.getElement()); 688 tree.setSelectedValue(selected_metadata.getValue()); 696 GValueNode value_node = selected_metadata.getValueNode(); 697 if(value_node != null) { 698 tree.setSelectedValue(value_node.getFullPath()); 699 } 700 else { 701 tree.setSelectedValue(""); 702 } 689 703 } 690 704 } … … 721 735 Gatherer.c_man.getCollection().msm.removeMSMListener(model); 722 736 // Create new model (which will add itself to msm). 723 model = new GTableModel(table, assigned_metadata_view, unassigned_metadata_view, activity_bar, records); 737 //model = new GTableModel(table, assigned_metadata_view, unassigned_metadata_view, activity_bar, records); 738 model = new GTableModel(table, records); 724 739 table.setModel(model); 725 740 } … … 732 747 } 733 748 // Create new model (which will add itself to msm). 734 model = new GTableModel(table, assigned_metadata_view, unassigned_metadata_view, activity_bar); 749 //model = new GTableModel(table, assigned_metadata_view, unassigned_metadata_view, activity_bar); 750 model = new GTableModel(table); 735 751 table.setModel(model); 736 752 }
Note:
See TracChangeset
for help on using the changeset viewer.