- Timestamp:
- 2003-05-27T15:57:37+12:00 (21 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gli/src/org/greenstone/gatherer/gui/metaaudit/MetaAuditFrame.java
r4293 r4366 78 78 */ 79 79 public class MetaAuditFrame 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 80 extends JDialog 81 implements TreeSelectionListener { 82 public AutofilterDialog autofilter_dialog; 83 /** Whether the selection has changed since the last time we built the model (because it has been hidden and theres no point refreshing a model you can't see!). */ 84 private boolean invalid = true; 85 /** An array holding the most recent list of paths selected (plus some nulls for those paths removed). */ 86 private FileNode records[]; 87 /** A reference to ourselves so that inner classes can interact with us. */ 88 private MetaAuditFrame self; 89 /** The table in which the metadata is shown. */ 90 private MetaAuditTable table; 91 /** The default size for the metaaudit dialog. */ 92 static final private Dimension SIZE = new Dimension(640,480); 93 /** The tolerance used to determine between a column resize, and a request for an AutoFilterDialog. */ 94 static final private int TOLERANCE = 3; 95 /** Constructor.*/ 96 public MetaAuditFrame(TreeSynchronizer tree_sync, FileNode records[]) { 97 super(); 98 // Arguments 99 this.autofilter_dialog = new AutofilterDialog(this); 100 this.records = records; 101 this.self = this; 102 this.table = new MetaAuditTable(this); 103 // Creation 104 setDefaultCloseOperation(JDialog.HIDE_ON_CLOSE); 105 setSize(SIZE); 106 setTitle(get("Title")); 107 108 JPanel content_pane = (JPanel) getContentPane(); 109 JPanel button_pane = new JPanel(); 110 111 JButton close_button = new JButton(get("Close")); 112 close_button.setMnemonic(KeyEvent.VK_C); 113 // Connection 114 close_button.addActionListener(new CloseListener()); 115 tree_sync.addTreeSelectionListener(this); 116 // Layout 117 button_pane.setBorder(BorderFactory.createEmptyBorder(5,5,5,5)); 118 button_pane.setLayout(new BorderLayout()); 119 button_pane.add(close_button, BorderLayout.CENTER); 120 120 121 122 123 124 121 content_pane.setBorder(BorderFactory.createEmptyBorder(5,5,5,5)); 122 content_pane.setLayout(new BorderLayout()); 123 content_pane.add(new JScrollPane(table), BorderLayout.CENTER); 124 content_pane.add(button_pane, BorderLayout.SOUTH); 125 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 126 Dimension screen_size = Gatherer.config.screen_size; 127 setLocation((screen_size.width - SIZE.width) / 2, (screen_size.height - SIZE.height) / 2); 128 screen_size = null; 129 close_button = null; 130 button_pane = null; 131 content_pane = null; 132 } 133 /** Destructor. */ 134 public void destroy() { 135 records = null; 136 self = null; 137 table = null; 138 } 139 /** Display the dialog on screen. */ 140 public void display() { 141 if(invalid) { 142 rebuildModel(); 143 } 144 show(); 145 } 146 /** This method is called whenever the selection within the collection tree changes. This causes the table to be rebuilt with a new model. 147 * @param event A <strong>TreeSelectionEvent</strong> containing information about the event. 148 */ 149 public void valueChanged(TreeSelectionEvent event) { 150 if(event.getSource() instanceof JTree) { 151 TreePath paths[] = Gatherer.g_man.metaedit_pane.collection_tree.getSelectionPaths(); 152 if(paths != null) { 153 records = new FileNode[paths.length]; 154 for(int i = 0; i < paths.length; i++) { 155 records[i] = (FileNode) paths[i].getLastPathComponent(); 156 } 157 if(isVisible()) { 158 rebuildModel(); 159 } 160 else { 161 invalid = true; 162 } 163 } 164 } 165 } 166 167 public void wait(boolean waiting) { 168 Component glass_pane = getGlassPane(); 169 if(waiting) { 170 170 // Show wait cursor. 171 172 173 174 171 glass_pane.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); 172 glass_pane.setVisible(true); 173 } 174 else { 175 175 // Hide wait cursor. 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 176 glass_pane.setVisible(false); 177 glass_pane.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); 178 } 179 glass_pane = null; 180 } 181 182 /** Retrieve a phrase from the Dictionary. 183 * @param key A <strong>String</strong> which uniquely maps to a phrase. 184 * @return The desired phrase as a </strong>String</strong>. 185 * @see org.greenstone.gatherer.Dictionary 186 */ 187 private String get(String key) { 188 return Gatherer.dictionary.get("MetaAudit." + key); 189 } 190 /** Rebuild the metaaudit table model using the current collection tree selection. 191 */ 192 private void rebuildModel() { 193 // Build and set model 194 table.newModel(records); 195 // Done. 196 invalid = false; 197 } 198 /** Listens for actions apon the close button, and if detected closes the dialog (storing its current size first). */ 199 private class CloseListener 200 implements ActionListener { 201 /** Any implementation of ActionListener must include this method so that we can be informed when an action has been performed on our target control(s). 202 * @param event An <strong>ActionEvent</strong> containing information about the event. 203 */ 204 public void actionPerformed(ActionEvent event) { 205 self.hide(); 206 } 207 } 208 208 } 209 209
Note:
See TracChangeset
for help on using the changeset viewer.