- Timestamp:
- 2012-08-11T21:34:13+02:00 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/dialogs/properties/PropertiesDialog.java
r5425 r5427 606 606 @Override 607 607 public void actionPerformed(ActionEvent e) { 608 keys.getEditor().setItem(t.getKey()); 608 //keys.getEditor().setItem(t.getKey()); 609 keys.setSelectedItem(t.getKey()); 609 610 values.getEditor().setItem(t.getValue()); 610 611 // Update list of values (fix #7951) … … 612 613 } 613 614 }; 614 p.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(sc.getKeyStroke(), actionShortcutKey);615 p.getActionMap().put(actionShortcutKey, action);616 615 tagsActions.add(action); 617 // Display clickable tag 616 // Disable action if its key is already set on the object (the key being absent from the keys list for this reason 617 // performing this action leads to autocomplete to the next key (see #7671 comments) 618 for (int j = 0; j < propertyData.getRowCount(); ++j) { 619 System.out.println(propertyData.getValueAt(j, 0)); 620 if (t.getKey().equals(propertyData.getValueAt(j, 0))) { 621 action.setEnabled(false); 622 break; 623 } 624 } 625 // Create tag label 618 626 final JLabel tagLabel = new JLabel("<html>" 619 627 + "<style>td{border:1px solid gray; font-weight:normal;}</style>" 620 628 + "<table><tr><td>" + t.toString() + "</td></tr></table></html>"); 621 tagLabel.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); 622 tagLabel.setToolTipText((String) action.getValue(Action.SHORT_DESCRIPTION)); 623 tagLabel.addMouseListener(new MouseAdapter() { 624 @Override 625 public void mouseClicked(MouseEvent e) { 626 action.actionPerformed(null); 627 } 628 }); 629 if (action.isEnabled()) { 630 // Register action 631 p.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(sc.getKeyStroke(), actionShortcutKey); 632 p.getActionMap().put(actionShortcutKey, action); 633 // Make the tag label clickable and set tooltip to the action description (this displays also the keyboard shortcut) 634 tagLabel.setToolTipText((String) action.getValue(Action.SHORT_DESCRIPTION)); 635 tagLabel.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); 636 tagLabel.addMouseListener(new MouseAdapter() { 637 @Override 638 public void mouseClicked(MouseEvent e) { 639 action.actionPerformed(null); 640 } 641 }); 642 } else { 643 // Disable tag label 644 tagLabel.setEnabled(false); 645 // Explain in the tooltip why 646 tagLabel.setToolTipText(tr("The key ''{0}'' is already used", t.getKey())); 647 } 648 // Finally add label to the resulting panel 629 649 JPanel tagPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0)); 630 650 tagPanel.add(tagLabel);
Note:
See TracChangeset
for help on using the changeset viewer.