Changeset 5180
- Timestamp:
- 2003-08-19T11:19:38+12:00 (21 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gli/src/org/greenstone/gatherer/gui/MetaEditPane.java
r5176 r5180 107 107 /** The currently selected metadata determined by listening to every second list selection event from the metadata table. */ 108 108 private Metadata selected_metadata; 109 /** A temporary storage array from Strings passed to the dictionary to be inserted in the phrase returned. */110 private String args[];111 109 /** Provide synchronization between the collection trees in this view and the collection pane view. */ 112 110 private TreeSynchronizer tree_sync = null; … … 161 159 expand.setPreferredSize(new Dimension(25, 25)); 162 160 163 tree = new GValueTree( this,CONTROL_SIZE.width, CONTROL_SIZE.height);161 tree = new GValueTree(CONTROL_SIZE.width, CONTROL_SIZE.height); 164 162 } 165 163 … … 289 287 if(ready) { 290 288 TreeModel collection_model = Gatherer.c_man.getRecordSet(); 291 args = new String[1];289 String[] args = new String[1]; 292 290 args[0] = Gatherer.c_man.getCollection().getName(); 293 291 collection_label.setText(get("Collection.Collection", args)); … … 342 340 343 341 ///atherer.println("\tCreating collection_label"); 344 args = new String[1];345 args[0] = get("Collection.No_Collection");346 342 collection_label = new JLabel(get("Collection.Collection")); 347 343 collection_label.setOpaque(true); … … 394 390 main_split_pane.setBorder(BorderFactory.createEmptyBorder(5,5,5,5)); 395 391 main_split_pane.setDividerSize(8); 396 397 // Thumbnail - Currently disabled.398 // At least until I figure out how to render thumbnails off screen,399 // which possibly may happen with the discovery of CalpaHTML.400 /*401 thumbnail_pane = new JPanel(new BorderLayout());402 403 Gatherer.println("\tCreating thumbnail_label");404 thumbnail_label = new JLabel(get("Thumbnail"));405 thumbnail_label.setHorizontalAlignment(JLabel.CENTER);406 407 Gatherer.println("\tCreating thumbnail_view_pane");408 thumbnail_view_pane = new JPanel(new FlowLayout(FlowLayout.CENTER));409 thumbnail_scroll = new JScrollPane(thumbnail_view_pane);410 411 thumbnail_pane.add(thumbnail_label, BorderLayout.NORTH);412 thumbnail_pane.add(thumbnail_scroll, BorderLayout.CENTER);413 */414 392 415 393 // Metadata Table. In order to achieve what Ian envisions I'm going … … 519 497 table_title_pane.setBorder(BorderFactory.createEmptyBorder(0,0,5,0)); 520 498 table_title_pane.setLayout(new BorderLayout()); 521 //table_title_pane.setLayout(new GridLayout(1,2,5,0));522 499 table_title_pane.add(table_label, BorderLayout.CENTER); 523 500 … … 645 622 } 646 623 else { 647 // Can append or replace 648 add.setEnabled( true);649 update.setEnabled( true);624 // Can append or replace, if something has been entered 625 add.setEnabled((tree.getSelectedValue().length() > 0)); 626 update.setEnabled((tree.getSelectedValue().length() > 0)); 650 627 } 651 628 … … 976 953 977 954 /** 978 * @author John Thompson, Greenstone Digital Library, University of Waikato 979 * @version 2.2 955 * This class is a little bit complex, a little bit subtle, and a little bit odd. 956 * The strange interaction model is due to the fact that it is very tightly 957 * coupled to the MetaEditPane. 958 * 959 * The interaction is complex because there are three separate controls that the 960 * user may interact with, each of which can affect the other two. The three 961 * controls are: 962 * - The "assigned metadata" table, at the top right of the meta edit pane. 963 * - The "metadata value" text field, where users can type in new values. 964 * - The "metadata value tree", which shows other values that have been 965 * assigned to the selected metadata element. 966 * 967 * The interactions are: 968 * - The "assigned metadata" table 969 * Users may select one (and only one) row in this table. Selecting a row 970 * chooses one metadata element. The text field will be set to the current 971 * value of the metadata element. This value will also be selected in the 972 * metadata value tree. 973 * 974 * - The "metadata value" text field 975 * If the value the user has typed in this is a prefix of an entry in the 976 * value tree, this value will be selected in the value tree. In this case, 977 * pressing "Enter" will complete the value (ie. make the value in the text 978 * field the same as the value in the tree). This is to allow users to 979 * quickly and easily assign existing metadata values to new documents. 980 * 981 * - The "metadata value tree" 982 * Selecting a value in the tree will set the text field to this value. 980 983 */ 981 984 private class GValueTree … … 992 995 private JTextField value; 993 996 private JTree tree; 994 private MetaEditPane metaedit;995 private String args[] = new String[1];996 997 /** Stock standard size for labels. */ 997 998 final private Dimension VALUE_LABEL_SIZE = new Dimension(66, 26); … … 1001 1002 1002 1003 1003 /** 1004 * This class is a little bit complex, a little bit subtle, and a little bit odd. 1005 * The strange interaction model is due to the fact that it is very tightly 1006 * coupled to the MetaEditPane. 1007 * 1008 * The interaction is complex because there are three separate controls that the 1009 * user may interact with, each of which can affect the other two. The three 1010 * controls are: 1011 * - The "assigned metadata" table, at the top right of the meta edit pane. 1012 * - The "metadata value" text field, where users can type in new values. 1013 * - The "metadata value tree", which shows other values that have been 1014 * assigned to the selected metadata element. 1015 * 1016 * The interactions are: 1017 * - The "assigned metadata" table 1018 * Users may select one (and only one) row in this table. Selecting a row 1019 * chooses one metadata element. The text field will be set to the current 1020 * value of the metadata element. This value will also be selected in the 1021 * metadata value tree. 1022 * 1023 * - The "metadata value" text field 1024 * If the value the user has typed in this is a prefix of an entry in the 1025 * value tree, this value will be selected in the value tree. In this case, 1026 * pressing "Enter" will complete the value (ie. make the value in the text 1027 * field the same as the value in the tree). This is to allow users to 1028 * quickly and easily assign existing metadata values to new documents. 1029 * 1030 * - The "metadata value tree" 1031 * Selecting a value in the tree will set the text field to this value. 1032 */ 1033 public GValueTree(MetaEditPane metaedit, int width, int height) { 1004 public GValueTree(int width, int height) { 1034 1005 super(); 1035 1036 this.metaedit = metaedit;1037 1006 1038 1007 setFont(Gatherer.config.getFont("general.font", false)); … … 1051 1020 value.setPreferredSize(new Dimension(413, 24)); 1052 1021 value.getDocument().addDocumentListener(new DocumentListenerImpl()); 1053 value.addActionListener(new MetadataFieldListener()); 1022 value.addKeyListener(new MetadataFieldListener()); 1023 value.setFocusTraversalKeysEnabled(false); 1054 1024 1055 1025 JPanel button_pane = new JPanel(); … … 1158 1128 1159 1129 // Special case the extracted metadata set 1160 if (selected_metadata_element.getNamespace().equals( "")) {1130 if (selected_metadata_element.getNamespace().equals(Utility.EXTRACTED_METADATA_NAMESPACE)) { 1161 1131 // Display the panel showing the "you cannot edit this metadata" message 1132 String[] args = new String[1]; 1162 1133 args[0] = selected_metadata_element.toString(); 1163 1134 extracted_message.setText(get("AutoMessage", args)); … … 1207 1178 key = "MetaEdit." + key; 1208 1179 } 1209 return Gatherer.dictionary.get(key, args);1180 return Gatherer.dictionary.get(key, args); 1210 1181 } 1211 1182 … … 1272 1243 1273 1244 private class MetadataFieldListener 1274 implements ActionListener { 1275 /** Gives notification of the Enter key being pressed on the text field */ 1276 public void actionPerformed(ActionEvent e) { 1277 if (tree.getSelectionCount() != 0 && !value.getText().equals("")) { 1278 TreePath path = tree.getSelectionPath(); 1279 GValueNode node = (GValueNode) path.getLastPathComponent(); 1280 value.setText(Utility.stripNL(node.getFullPath())); 1245 implements KeyListener { 1246 1247 /** Gives notification of key events on the text field */ 1248 public void keyPressed(KeyEvent e) { 1249 if (e.getKeyCode() == KeyEvent.VK_TAB) { 1250 // Tab: Auto-complete 1251 if (tree.getSelectionCount() != 0 && !value.getText().equals("")) { 1252 TreePath path = tree.getSelectionPath(); 1253 GValueNode node = (GValueNode) path.getLastPathComponent(); 1254 value.setText(Utility.stripNL(node.getFullPath())); 1255 } 1281 1256 } 1282 } 1257 if (e.getKeyCode() == KeyEvent.VK_ENTER) { 1258 // Enter: Append the metadata value, if we're allowed to 1259 if (add.isEnabled()) { 1260 add.doClick(); 1261 } 1262 } 1263 } 1264 1265 public void keyReleased(KeyEvent e) { } 1266 1267 public void keyTyped(KeyEvent e) { } 1283 1268 } 1284 1269 … … 1286 1271 private class DocumentListenerImpl 1287 1272 implements DocumentListener { 1288 /** Gives notification that an attribute or set of attributes changed .*/1273 /** Gives notification that an attribute or set of attributes changed */ 1289 1274 public void changedUpdate(DocumentEvent e) { 1290 1275 validate(); 1291 1276 } 1292 1277 1293 /** Gives notification that there was an insert into the document .*/1278 /** Gives notification that there was an insert into the document */ 1294 1279 public void insertUpdate(DocumentEvent e) { 1295 1280 validate(); 1296 1281 } 1297 1282 1298 /** Gives notification that a portion of the document has been removed .*/1283 /** Gives notification that a portion of the document has been removed */ 1299 1284 public void removeUpdate(DocumentEvent e) { 1300 1285 validate(); … … 1302 1287 1303 1288 1304 /** Ensures that the value text field and value tree are synchronized .*/1289 /** Ensures that the value text field and value tree are synchronized */ 1305 1290 private void validate() 1306 1291 { … … 1329 1314 1330 1315 // Update the status of the buttons 1331 metaedit.validateControls();1316 validateControls(); 1332 1317 } 1333 1318 }
Note:
See TracChangeset
for help on using the changeset viewer.