Changeset 8503
- Timestamp:
- 2004-11-10T11:06:50+13:00 (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gli/src/org/greenstone/gatherer/gui/EnrichPane.java
r8501 r8503 951 951 private class MetadataValueTree 952 952 extends JPanel 953 implements TreeSelectionListener954 953 { 955 954 private boolean ignore_tree_selection_event = false; … … 984 983 metadata_value_text_field.setPreferredSize(new Dimension(413, 24)); 985 984 metadata_value_text_field.getDocument().addDocumentListener(new DocumentListenerImpl()); 986 metadata_value_text_field.addKeyListener(new Metadata FieldListener());985 metadata_value_text_field.addKeyListener(new MetadataValueTextFieldKeyListener()); 987 986 metadata_value_text_field.setFocusTraversalKeysEnabled(false); 988 987 Dictionary.setTooltip(metadata_value_text_field, "MetaEdit.Value_Field_Tooltip"); … … 995 994 996 995 tree = new JTree(); 997 tree.addTreeSelectionListener(this); 996 tree.addMouseListener(new MetadataValueTreeMouseListener()); 997 tree.addTreeSelectionListener(new MetadataValueTreeSelectionListener()); 998 998 tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); 999 999 tree.setRootVisible(false); … … 1217 1217 1218 1218 1219 /** Handles TreeSelectionEvents. */ 1220 public void valueChanged(TreeSelectionEvent event) 1221 { 1222 if (tree.getSelectionCount() != 0 && !ignore_tree_selection_event) { 1223 TreePath path = tree.getSelectionPath(); 1224 MetadataValueTreeNode node = (MetadataValueTreeNode) path.getLastPathComponent(); 1225 setSelectedValue(node.getFullValue()); 1226 } 1227 } 1228 1229 1230 private class MetadataFieldListener 1231 implements KeyListener { 1232 1219 private class MetadataValueTextFieldKeyListener 1220 extends KeyAdapter 1221 { 1233 1222 /** Gives notification of key events on the text field */ 1234 1223 public void keyPressed(KeyEvent e) … … 1260 1249 } 1261 1250 } 1262 1263 public void keyReleased(KeyEvent e) { } 1264 1265 public void keyTyped(KeyEvent e) { } 1251 } 1252 1253 1254 private class MetadataValueTreeMouseListener 1255 extends MouseAdapter 1256 { 1257 public void mouseClicked(MouseEvent e) 1258 { 1259 // Double click: assign the selected value tree node immediately (if possible) 1260 if (e.getClickCount() == 2 && tree.getSelectionCount() != 0) { 1261 TreePath path = tree.getSelectionPath(); 1262 MetadataValueTreeNode node = (MetadataValueTreeNode) path.getLastPathComponent(); 1263 1264 // Leaf nodes only (folder nodes will expand/contract) 1265 if (node.getChildCount() == 0 && add.isEnabled()) { 1266 add.doClick(); 1267 } 1268 } 1269 } 1270 } 1271 1272 1273 private class MetadataValueTreeSelectionListener 1274 implements TreeSelectionListener 1275 { 1276 public void valueChanged(TreeSelectionEvent event) 1277 { 1278 // Select a node in the tree: fill the metadata value text field with the selected node's value 1279 if (tree.getSelectionCount() != 0 && !ignore_tree_selection_event) { 1280 TreePath path = tree.getSelectionPath(); 1281 MetadataValueTreeNode node = (MetadataValueTreeNode) path.getLastPathComponent(); 1282 setSelectedValue(node.getFullValue()); 1283 } 1284 } 1266 1285 } 1267 1286 … … 1344 1363 } 1345 1364 tree.setImmediate(false); 1346 } else if (event.getKeyCode() == KeyEvent.VK_LEFT) { 1365 } 1366 else if (event.getKeyCode() == KeyEvent.VK_LEFT) { 1347 1367 // left key on a file shifts the selection to the parent folder 1348 1368 DragTree tree = (DragTree)event.getSource();
Note:
See TracChangeset
for help on using the changeset viewer.