Changeset 6939 in josm
- Timestamp:
- 2014-03-28T21:34:47+01:00 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/dialogs/properties/PropertiesDialog.java
r6890 r6939 143 143 private final JTable membershipTable = new JTable(membershipData); 144 144 145 /** JPanel containing both previous tables */ 146 private final JPanel bothTables = new JPanel(); 147 145 148 // Popup menus 146 149 private final JPopupMenu tagMenu = new JPopupMenu(); 147 150 private final JPopupMenu membershipMenu = new JPopupMenu(); 151 private final JPopupMenu blankSpaceMenu = new JPopupMenu(); 148 152 149 153 // Popup menu handlers 150 154 private final PopupMenuHandler tagMenuHandler = new PopupMenuHandler(tagMenu); 151 155 private final PopupMenuHandler membershipMenuHandler = new PopupMenuHandler(membershipMenu); 156 private final PopupMenuHandler blankSpaceMenuHandler = new PopupMenuHandler(blankSpaceMenu); 152 157 153 158 private final Map<String, Map<String, Integer>> valueCount = new TreeMap<String, Map<String, Integer>>(); … … 235 240 236 241 // combine both tables and wrap them in a scrollPane 237 JPanel bothTables = new JPanel();238 242 boolean top = Main.pref.getBoolean("properties.presets.top", true); 239 243 bothTables.setLayout(new GridBagLayout()); … … 251 255 bothTables.add(presets, GBC.eol().fill(GBC.HORIZONTAL).insets(5, 2, 5, 2)); 252 256 } 253 257 258 setupBlankSpaceMenu(); 254 259 setupKeyboardShortcuts(); 255 260 256 // Let the action know when selection in the tables change 261 // Let the actions know when selection in the tables change 257 262 tagTable.getSelectionModel().addListSelectionListener(editAction); 258 263 membershipTable.getSelectionModel().addListSelectionListener(editAction); … … 260 265 membershipTable.getSelectionModel().addListSelectionListener(deleteAction); 261 266 262 263 267 JScrollPane scrollPane = (JScrollPane) createLayout(bothTables, true, Arrays.asList(new SideButton[] { 264 268 this.btnAdd, this.btnEdit, this.btnDel … … 280 284 private void buildTagsTable() { 281 285 // setting up the tags table 282 283 286 tagData.setColumnIdentifiers(new String[]{tr("Key"),tr("Value")}); 284 287 tagTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); … … 353 356 354 357 /** 355 * creates the popup menu @field membershipMenu and its launcher on membership table 358 * Creates the popup menu @field blankSpaceMenu and its launcher on main panel. 359 */ 360 private void setupBlankSpaceMenu() { 361 if (Main.pref.getBoolean("properties.menu.add_edit_delete", true)) { 362 blankSpaceMenuHandler.addAction(addAction); 363 PopupMenuLauncher launcher = new PopupMenuLauncher(blankSpaceMenu) { 364 @Override 365 protected boolean checkSelection(Component component, Point p) { 366 if (component instanceof JTable) { 367 return ((JTable) component).rowAtPoint(p) == -1; 368 } 369 return true; 370 } 371 }; 372 bothTables.addMouseListener(launcher); 373 tagTable.addMouseListener(launcher); 374 } 375 } 376 377 /** 378 * Creates the popup menu @field membershipMenu and its launcher on membership table. 356 379 */ 357 380 private void setupMembershipMenu() { 358 381 // setting up the membership table 382 if (Main.pref.getBoolean("properties.menu.add_edit_delete", true)) { 383 membershipMenuHandler.addAction(editAction); 384 membershipMenuHandler.addAction(deleteAction); 385 membershipMenu.addSeparator(); 386 } 359 387 membershipMenuHandler.addAction(setRelationSelectionAction); 360 388 membershipMenuHandler.addAction(selectRelationAction); … … 402 430 403 431 /** 404 * creates the popup menu @field tagMenu and its launcher on tag table432 * Creates the popup menu @field tagMenu and its launcher on tag table. 405 433 */ 406 434 private void setupTagsMenu() { 435 if (Main.pref.getBoolean("properties.menu.add_edit_delete", true)) { 436 tagMenu.add(addAction); 437 tagMenu.add(editAction); 438 tagMenu.add(deleteAction); 439 tagMenu.addSeparator(); 440 } 407 441 tagMenu.add(pasteValueAction); 408 442 tagMenu.add(copyValueAction); … … 418 452 419 453 /** 420 * Assign as all needed keys like Enter and Spacebar to most important actions454 * Assigns all needed keys like Enter and Spacebar to most important actions. 421 455 */ 422 456 private void setupKeyboardShortcuts() { … … 649 683 boolean hasTags = hasSelection && tagData.getRowCount() > 0; 650 684 boolean hasMemberships = hasSelection && membershipData.getRowCount() > 0; 651 btnAdd.setEnabled(hasSelection);652 btnEdit.setEnabled(hasTags || hasMemberships);653 btnDel.setEnabled(hasTags || hasMemberships);685 addAction.setEnabled(hasSelection); 686 editAction.setEnabled(hasTags || hasMemberships); 687 deleteAction.setEnabled(hasTags || hasMemberships); 654 688 tagTable.setVisible(hasTags); 655 689 tagTable.getTableHeader().setVisible(hasTags); … … 707 741 } 708 742 743 /** 744 * Returns the selected tag. 745 * @return The current selected tag 746 */ 709 747 @SuppressWarnings("unchecked") 710 748 public Tag getSelectedProperty() { … … 725 763 } 726 764 765 /** 766 * Returns the selected relation membership. 767 * @return The current selected relation membership 768 */ 727 769 public IRelation getSelectedMembershipRelation() { 728 770 int row = membershipTable.getSelectedRow(); … … 774 816 } 775 817 } 776 777 818 } 778 819
Note:
See TracChangeset
for help on using the changeset viewer.