Changeset 8510 in josm for trunk/src/org/openstreetmap/josm/gui/dialogs/properties
- Timestamp:
- 2015-06-20T23:42:21+02:00 (9 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/gui/dialogs/properties
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/dialogs/properties/PropertiesCellRenderer.java
r8390 r8510 60 60 otherCount = v.size(); 61 61 } else { 62 blankCount = (Integer) v.get("");62 blankCount = (Integer) v.get(""); 63 63 otherCount = v.size()-1; 64 64 } … … 75 75 sb.append(trn("{0} different", "{0} different", otherCount, otherCount)); 76 76 } 77 if (blankCount > 0) {77 if (blankCount > 0) { 78 78 /* I18n: properties display partial string joined with comma */ 79 79 sb.append(trn(", {0} unset", ", {0} unset", blankCount, blankCount)); … … 88 88 } 89 89 } 90 ((JLabel) c).putClientProperty("html.disable", Boolean.TRUE); // Fix #873091 ((JLabel) c).setText(str);90 ((JLabel) c).putClientProperty("html.disable", Boolean.TRUE); // Fix #8730 91 ((JLabel) c).setText(str); 92 92 if (Main.pref.getBoolean("display.discardable-keys", false)) { 93 93 String key = null; -
trunk/src/org/openstreetmap/josm/gui/dialogs/properties/PropertiesDialog.java
r8509 r8510 188 188 private final SelectMembersAction addMembersToSelectionAction = new SelectMembersAction(true); 189 189 190 private final transient HighlightHelper highlightHelper = new HighlightHelper();190 private final transient HighlightHelper highlightHelper = new HighlightHelper(); 191 191 192 192 /** … … 225 225 }; 226 226 227 // <editor-fold defaultstate="collapsed" desc="Dialog construction and helper methods">228 229 227 /** 230 228 * Create a new PropertiesDialog … … 246 244 boolean top = Main.pref.getBoolean("properties.presets.top", true); 247 245 bothTables.setLayout(new GridBagLayout()); 248 if (top) {246 if (top) { 249 247 bothTables.add(presets, GBC.std().fill(GBC.HORIZONTAL).insets(5, 2, 5, 2).anchor(GBC.NORTHWEST)); 250 248 double epsilon = Double.MIN_VALUE; // need to set a weight or else anchor value is ignored 251 bothTables.add(pluginHook, GBC.eol().insets(0, 1,1,1).anchor(GBC.NORTHEAST).weight(epsilon, epsilon));249 bothTables.add(pluginHook, GBC.eol().insets(0, 1, 1, 1).anchor(GBC.NORTHEAST).weight(epsilon, epsilon)); 252 250 } 253 251 bothTables.add(selectSth, GBC.eol().fill().insets(10, 10, 10, 10)); … … 256 254 bothTables.add(membershipTable.getTableHeader(), GBC.eol().fill(GBC.HORIZONTAL)); 257 255 bothTables.add(membershipTable, GBC.eol().fill(GBC.BOTH)); 258 if (!top) {256 if (!top) { 259 257 bothTables.add(presets, GBC.eol().fill(GBC.HORIZONTAL).insets(5, 2, 5, 2)); 260 258 } … … 287 285 private void buildTagsTable() { 288 286 // setting up the tags table 289 tagData.setColumnIdentifiers(new String[]{tr("Key"), tr("Value")});287 tagData.setColumnIdentifiers(new String[]{tr("Key"), tr("Value")}); 290 288 tagTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); 291 289 tagTable.getTableHeader().setReorderingAllowed(false); … … 297 295 298 296 private void buildMembershipTable() { 299 membershipData.setColumnIdentifiers(new String[]{tr("Member Of"), tr("Role"),tr("Position")});297 membershipData.setColumnIdentifiers(new String[]{tr("Member Of"), tr("Role"), tr("Position")}); 300 298 membershipTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); 301 299 … … 309 307 return this; 310 308 if (c instanceof JLabel) { 311 JLabel label = (JLabel) c;312 Relation r = (Relation) value;309 JLabel label = (JLabel) c; 310 Relation r = (Relation) value; 313 311 label.setText(r.getDisplayName(DefaultNameFormatter.getInstance())); 314 312 if (r.isDisabledAndHidden()) { … … 326 324 return this; 327 325 Component c = super.getTableCellRendererComponent(table, value, isSelected, false, row, column); 328 boolean isDisabledAndHidden = ((Relation) table.getValueAt(row, 0)).isDisabledAndHidden();326 boolean isDisabledAndHidden = ((Relation) table.getValueAt(row, 0)).isDisabledAndHidden(); 329 327 if (c instanceof JLabel) { 330 328 JLabel label = (JLabel) c; … … 342 340 boolean isSelected, boolean hasFocus, int row, int column) { 343 341 Component c = super.getTableCellRendererComponent(table, value, isSelected, false, row, column); 344 boolean isDisabledAndHidden = ((Relation) table.getValueAt(row, 0)).isDisabledAndHidden();342 boolean isDisabledAndHidden = ((Relation) table.getValueAt(row, 0)).isDisabledAndHidden(); 345 343 if (c instanceof JLabel) { 346 JLabel label = (JLabel) c;344 JLabel label = (JLabel) c; 347 345 label.setText(((MemberInfo) table.getValueAt(row, 1)).getPositionString()); 348 346 if (isDisabledAndHidden) { … … 416 414 if (Main.isDisplayingMapView()) { 417 415 int row = membershipTable.rowAtPoint(e.getPoint()); 418 if (row >=0) {416 if (row >= 0) { 419 417 if (highlightHelper.highlightOnly((Relation) membershipTable.getValueAt(row, 0))) { 420 418 Main.map.mapView.repaint(); … … 462 460 tagTable.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT) 463 461 .put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "onTableEnter"); 464 tagTable.getActionMap().put("onTableEnter", editAction);462 tagTable.getActionMap().put("onTableEnter", editAction); 465 463 membershipTable.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT) 466 .put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "onTableEnter");467 membershipTable.getActionMap().put("onTableEnter", editAction);464 .put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "onTableEnter"); 465 membershipTable.getActionMap().put("onTableEnter", editAction); 468 466 469 467 // INSERT button = addAction, open "add tag" dialog 470 468 tagTable.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT) 471 .put(KeyStroke.getKeyStroke(KeyEvent.VK_INSERT, 0), "onTableInsert");472 tagTable.getActionMap().put("onTableInsert", addAction);469 .put(KeyStroke.getKeyStroke(KeyEvent.VK_INSERT, 0), "onTableInsert"); 470 tagTable.getActionMap().put("onTableInsert", addAction); 473 471 474 472 // unassign some standard shortcuts for JTable to allow upload / download / image browsing … … 480 478 481 479 tagTable.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT) 482 .put(KeyStroke.getKeyStroke(KeyEvent.VK_C, InputEvent.CTRL_MASK), "onCopy");483 tagTable.getActionMap().put("onCopy", copyKeyValueAction);480 .put(KeyStroke.getKeyStroke(KeyEvent.VK_C, InputEvent.CTRL_MASK), "onCopy"); 481 tagTable.getActionMap().put("onCopy", copyKeyValueAction); 484 482 485 483 // allow using enter to add tags for all look&feel configurations … … 488 486 // DEL button = deleteAction 489 487 getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put( 490 KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0), "delete"488 KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0), "delete" 491 489 ); 492 490 getActionMap().put("delete", deleteAction); … … 505 503 */ 506 504 private void editMembership(int row) { 507 Relation relation = (Relation) membershipData.getValueAt(row, 0);505 Relation relation = (Relation) membershipData.getValueAt(row, 0); 508 506 Main.map.relationListDialog.selectRelation(relation); 509 507 RelationEditor.getEditor( … … 515 513 516 514 private int findRow(TableModel model, Object value) { 517 for (int i =0; i<model.getRowCount(); i++) {515 for (int i = 0; i < model.getRowCount(); i++) { 518 516 if (model.getValueAt(i, 0).equals(value)) 519 517 return i; … … 529 527 selectionChanged(null); 530 528 } 531 532 // </editor-fold>533 534 // <editor-fold defaultstate="collapsed" desc="Event listeners methods">535 529 536 530 @Override … … 596 590 selectedTag = editHelper.getChangedKey(); // select last added or last edited key by default 597 591 if (selectedTag == null && tagTable.getSelectedRowCount() == 1) { 598 selectedTag = (String) tagData.getValueAt(tagTable.getSelectedRow(), 0);592 selectedTag = (String) tagData.getValueAt(tagTable.getSelectedRow(), 0); 599 593 } 600 594 if (membershipTable.getSelectedRowCount() == 1) { 601 selectedRelation = (Relation) membershipData.getValueAt(membershipTable.getSelectedRow(), 0);595 selectedRelation = (Relation) membershipData.getValueAt(membershipTable.getSelectedRow(), 0); 602 596 } 603 597 … … 648 642 Relation r = (Relation) ref; 649 643 MemberInfo mi = roles.get(r); 650 if (mi == null) {644 if (mi == null) { 651 645 mi = new MemberInfo(newSel); 652 646 } … … 696 690 } else if (selectedRelation != null && (selectedIndex = findRow(membershipData, selectedRelation)) != -1) { 697 691 membershipTable.changeSelection(selectedIndex, 0, false, false); 698 } else if (hasTags) {692 } else if (hasTags) { 699 693 tagTable.changeSelection(0, 0, false, false); 700 } else if (hasMemberships) {694 } else if (hasMemberships) { 701 695 membershipTable.changeSelection(0, 0, false, false); 702 696 } 703 697 704 if (tagData.getRowCount() != 0 || membershipData.getRowCount() != 0) {705 if (newSel.size() > 1) {698 if (tagData.getRowCount() != 0 || membershipData.getRowCount() != 0) { 699 if (newSel.size() > 1) { 706 700 setTitle(tr("Objects: {2} / Tags: {0} / Memberships: {1}", 707 701 tagData.getRowCount(), membershipData.getRowCount(), newSel.size())); … … 734 728 } 735 729 736 // </editor-fold>737 738 // <editor-fold defaultstate="collapsed" desc="Methods that are called by plugins to extend fuctionality ">739 740 730 /** 741 731 * Replies the tag popup menu handler. … … 777 767 } 778 768 779 // </editor-fold> 780 781 /** 769 /** 782 770 * Class that watches for mouse clicks 783 771 * @author imi 784 772 */ 785 773 public class MouseClickWatch extends MouseAdapter { 786 @Override public void mouseClicked(MouseEvent e) { 774 @Override 775 public void mouseClicked(MouseEvent e) { 787 776 if (e.getClickCount() < 2) { 788 777 // single click, clear selection in other table not clicked in … … 812 801 } 813 802 } 814 @Override public void mousePressed(MouseEvent e) { 803 804 @Override 805 public void mousePressed(MouseEvent e) { 815 806 if (e.getSource() == tagTable) { 816 807 membershipTable.clearSelection(); … … 880 871 */ 881 872 public static class ReadOnlyTableModel extends DefaultTableModel { 882 @Override public boolean isCellEditable(int row, int column) { 873 @Override 874 public boolean isCellEditable(int row, int column) { 883 875 return false; 884 876 } 885 @Override public Class<?> getColumnClass(int columnIndex) { 877 878 @Override 879 public Class<?> getColumnClass(int columnIndex) { 886 880 return String.class; 887 881 } … … 902 896 } 903 897 904 protected void deleteTags(int[] rows) {898 protected void deleteTags(int[] rows) { 905 899 // convert list of rows to HashMap (and find gap for nextKey) 906 900 Map<String, String> tags = new HashMap<>(rows.length); … … 925 919 nextKeyIndex++; 926 920 } 927 nextKey = (String) tagData.getValueAt(nextKeyIndex, 0);921 nextKey = (String) tagData.getValueAt(nextKeyIndex, 0); 928 922 } 929 923 … … 938 932 939 933 protected void deleteFromRelation(int row) { 940 Relation cur = (Relation) membershipData.getValueAt(row, 0);934 Relation cur = (Relation) membershipData.getValueAt(row, 0); 941 935 942 936 Relation nextRelation = null; 943 937 int rowCount = membershipTable.getRowCount(); 944 938 if (rowCount > 1) { 945 nextRelation = (Relation) membershipData.getValueAt(row + 1 < rowCount ? row + 1 : row - 1, 0);939 nextRelation = (Relation) membershipData.getValueAt(row + 1 < rowCount ? row + 1 : row - 1, 0); 946 940 } 947 941 … … 954 948 ed.showDialog(); 955 949 956 if (ed.getValue() != 1)950 if (ed.getValue() != 1) 957 951 return; 958 952 … … 978 972 int[] rows = membershipTable.getSelectedRows(); 979 973 // delete from last relation to conserve row numbers in the table 980 for (int i =rows.length-1; i>=0; i--) {974 for (int i = rows.length-1; i >= 0; i--) { 981 975 deleteFromRelation(rows[i]); 982 976 } … … 1083 1077 } else if (membershipTable.getSelectedRowCount() == 1) { 1084 1078 row = membershipTable.getSelectedRow(); 1085 String type = ((Relation) membershipData.getValueAt(row, 0)).get("type");1079 String type = ((Relation) membershipData.getValueAt(row, 0)).get("type"); 1086 1080 if (type != null) { 1087 1081 type = Utils.encodeUrl(type); … … 1101 1095 } 1102 1096 1103 Main.worker.execute(new Runnable() {1097 Main.worker.execute(new Runnable() { 1104 1098 @Override public void run() { 1105 1099 try { … … 1108 1102 for (URI u : uris) { 1109 1103 conn = Utils.openHttpConnection(u.toURL()); 1110 conn.setConnectTimeout(Main.pref.getInteger("socket.timeout.connect", 15)*1000);1104 conn.setConnectTimeout(Main.pref.getInteger("socket.timeout.connect", 15)*1000); 1111 1105 1112 1106 if (conn.getResponseCode() != 200) { … … 1122 1116 .replaceFirst("/wiki/", "/w/index.php?redirect=no&title=") 1123 1117 ).toURL()); 1124 conn.setConnectTimeout(Main.pref.getInteger("socket.timeout.connect", 15)*1000);1118 conn.setConnectTimeout(Main.pref.getInteger("socket.timeout.connect", 15)*1000); 1125 1119 } 1126 1120 … … 1187 1181 return; 1188 1182 for (OsmPrimitive p : sel) { 1189 Collection<String> s = getString(p, key);1183 Collection<String> s = getString(p, key); 1190 1184 if (s != null) { 1191 1185 values.addAll(s); … … 1201 1195 class CopyValueAction extends AbstractCopyAction { 1202 1196 1197 /** 1198 * Constructs a new {@code CopyValueAction}. 1199 */ 1203 1200 public CopyValueAction() { 1204 1201 putValue(NAME, tr("Copy Value")); -
trunk/src/org/openstreetmap/josm/gui/dialogs/properties/TagEditHelper.java
r8509 r8510 153 153 154 154 String key = tagData.getValueAt(row, 0).toString(); 155 objKey =key;155 objKey = key; 156 156 157 157 @SuppressWarnings("unchecked") … … 262 262 @Override 263 263 public Component getListCellRendererComponent(JList<? extends AutoCompletionListItem> list, 264 AutoCompletionListItem value, int index, boolean isSelected, boolean cellHasFocus) {264 AutoCompletionListItem value, int index, boolean isSelected, boolean cellHasFocus) { 265 265 Component c = def.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); 266 266 if (c instanceof JLabel) { … … 280 280 281 281 private EditTagDialog(String key, Map<String, Integer> map, final boolean initialFocusOnKey) { 282 super(Main.parent, trn("Change value?", "Change values?", map.size()), new String[] {tr("OK"), tr("Cancel")});283 setButtonIcons(new String[] {"ok", "cancel"});282 super(Main.parent, trn("Change value?", "Change values?", map.size()), new String[] {tr("OK"), tr("Cancel")}); 283 setButtonIcons(new String[] {"ok", "cancel"}); 284 284 setCancelButton(2); 285 285 configureContextsensitiveHelp("/Dialog/EditValue", true /* show help button */); … … 307 307 keys.setSelectedItem(key); 308 308 309 p.add(Box.createVerticalStrut(5), GBC.eol());309 p.add(Box.createVerticalStrut(5), GBC.eol()); 310 310 p.add(new JLabel(tr("Key")), GBC.std()); 311 311 p.add(Box.createHorizontalStrut(10), GBC.std()); … … 315 315 Collections.sort(valueList, usedValuesAwareComparator); 316 316 317 final String selection = m.size()!=1?tr("<different>"):m.entrySet().iterator().next().getKey();317 final String selection = m.size() != 1 ? tr("<different>") : m.entrySet().iterator().next().getKey(); 318 318 319 319 values = new AutoCompletingComboBox(selection); … … 324 324 values.setSelectedItem(selection); 325 325 values.getEditor().setItem(selection); 326 p.add(Box.createVerticalStrut(5), GBC.eol());326 p.add(Box.createVerticalStrut(5), GBC.eol()); 327 327 p.add(new JLabel(tr("Value")), GBC.std()); 328 328 p.add(Box.createHorizontalStrut(10), GBC.std()); … … 496 496 protected FocusAdapter addFocusAdapter(final AutoCompletionManager autocomplete, final Comparator<AutoCompletionListItem> comparator) { 497 497 // get the combo box' editor component 498 JTextComponent editor = (JTextComponent) values.getEditor().getEditorComponent();498 JTextComponent editor = (JTextComponent) values.getEditor().getEditorComponent(); 499 499 // Refresh the values model when focus is gained 500 500 FocusAdapter focus = new FocusAdapter() { … … 508 508 values.setPossibleACItems(valueList); 509 509 values.getEditor().selectAll(); 510 objKey =key;510 objKey = key; 511 511 } 512 512 }; … … 517 517 protected JPopupMenu popupMenu = new JPopupMenu() { 518 518 private JCheckBoxMenuItem fixTagLanguageCb = new JCheckBoxMenuItem( 519 new AbstractAction(tr("Use English language for tag by default")) {519 new AbstractAction(tr("Use English language for tag by default")) { 520 520 @Override 521 521 public void actionPerformed(ActionEvent e) { 522 boolean use =((JCheckBoxMenuItem) e.getSource()).getState();522 boolean use = ((JCheckBoxMenuItem) e.getSource()).getState(); 523 523 PROPERTY_FIX_TAG_LOCALE.put(use); 524 524 keys.setFixedLocale(use); … … 539 539 540 540 public AddTagsDialog() { 541 super(Main.parent, tr("Add value?"), new String[] {tr("OK"), tr("Cancel")});542 setButtonIcons(new String[] {"ok", "cancel"});541 super(Main.parent, tr("Add value?"), new String[] {tr("OK"), tr("Cancel")}); 542 setButtonIcons(new String[] {"ok", "cancel"}); 543 543 setCancelButton(2); 544 544 configureContextsensitiveHelp("/Dialog/AddValue", true /* show help button */); … … 549 549 550 550 mainPanel.add(new JLabel("<html>"+trn("This will change up to {0} object.", 551 "This will change up to {0} objects.", sel.size(), sel.size())551 "This will change up to {0} objects.", sel.size(), sel.size()) 552 552 +"<br><br>"+tr("Please select a key")), GBC.eol().fill(GBC.HORIZONTAL)); 553 553 … … 624 624 }); 625 625 JCheckBoxMenuItem rememberLastTags = new JCheckBoxMenuItem( 626 new AbstractAction(tr("Remember last used tags after a restart")) {626 new AbstractAction(tr("Remember last used tags after a restart")) { 627 627 @Override 628 628 public void actionPerformed(ActionEvent e) { 629 boolean sel =((JCheckBoxMenuItem) e.getSource()).getState();629 boolean sel = ((JCheckBoxMenuItem) e.getSource()).getState(); 630 630 PROPERTY_REMEMBER_TAGS.put(sel); 631 631 if (sel) saveTagsIfNeeded(); … … 650 650 lines.add(code(KeyEvent.getKeyModifiersText(KeyEvent.SHIFT_MASK)+"+"+KeyEvent.getKeyText(KeyEvent.VK_ENTER)) 651 651 +tr("to add without closing the dialog")); 652 sc = Shortcut.findShortcut(KeyEvent.VK_1, commandDownMask |KeyEvent.SHIFT_DOWN_MASK);652 sc = Shortcut.findShortcut(KeyEvent.VK_1, commandDownMask | KeyEvent.SHIFT_DOWN_MASK); 653 653 if (sc != null) { 654 654 lines.add(code(sc.getKeyText()) + tr("to add first suggestion without closing the dialog")); … … 667 667 try { 668 668 int v = Integer.parseInt(s); 669 if (v >=0 && v<=MAX_LRU_TAGS_NUMBER) {669 if (v >= 0 && v <= MAX_LRU_TAGS_NUMBER) { 670 670 PROPERTY_RECENT_TAGS_NUMBER.put(v); 671 671 return; … … 762 762 action.actionPerformed(null); 763 763 // add tags and close window on double-click 764 if (e.getClickCount() >1) {764 if (e.getClickCount() > 1) { 765 765 buttonAction(0, null); // emulate OK click and close the dialog 766 766 }
Note:
See TracChangeset
for help on using the changeset viewer.