Changeset 10849 in josm
- Timestamp:
- 2016-08-19T00:07:48+02:00 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/tagging/presets/TaggingPreset.java
r10714 r10849 50 50 import org.openstreetmap.josm.gui.preferences.ToolbarPreferences; 51 51 import org.openstreetmap.josm.gui.tagging.presets.items.Key; 52 import org.openstreetmap.josm.gui.tagging.presets.items.Label;53 52 import org.openstreetmap.josm.gui.tagging.presets.items.Link; 54 53 import org.openstreetmap.josm.gui.tagging.presets.items.Optional; … … 174 173 175 174 /** 176 * Returns the preset icon .175 * Returns the preset icon (16px). 177 176 * @return The preset icon, or {@code null} if none defined 178 177 * @since 6403 179 178 */ 180 179 public final ImageIcon getIcon() { 181 Object icon = getValue(Action.SMALL_ICON); 180 return getIcon(Action.SMALL_ICON); 181 } 182 183 /** 184 * Returns the preset icon (16 or 24px). 185 * @param key Key determining icon size: {@code Action.SMALL_ICON} for 16x, {@code Action.LARGE_ICON_KEY} for 24px 186 * @return The preset icon, or {@code null} if none defined 187 * @since 10849 188 */ 189 public final ImageIcon getIcon(String key) { 190 Object icon = getValue(key); 182 191 if (icon instanceof ImageIcon) { 183 192 return (ImageIcon) icon; … … 289 298 pp.add(label); 290 299 } 291 if (pp.getComponentCount() > 0) { 292 p.add(pp, GBC.eol()); 293 } 300 final int count = pp.getComponentCount(); 294 301 if (preset_name_label) { 295 Label.addLabel(p, getIcon(), getName()); 302 p.add(new JLabel(getIcon(Action.LARGE_ICON_KEY)), GBC.std(0, 0).span(1, count > 0 ? 2 : 1).insets(0, 0, 5, 0)); 303 } 304 if (count > 0) { 305 p.add(pp, GBC.std(1, 0).span(GBC.REMAINDER)); 306 } 307 if (preset_name_label) { 308 p.add(new JLabel(getName()), GBC.std(1, count > 0 ? 1 : 0).insets(5, 0, 0, 0).span(GBC.REMAINDER).fill(GBC.HORIZONTAL)); 296 309 } 297 310 … … 331 344 JToggleButton tb = new JToggleButton(new ToolbarButtonAction()); 332 345 tb.setFocusable(false); 333 p.add(tb, GBC.std( 0, 0).anchor(GBC.LINE_END));346 p.add(tb, GBC.std(1, 0).anchor(GBC.LINE_END)); 334 347 return p; 335 348 } … … 402 415 403 416 private static class PresetDialog extends ExtendedDialog { 417 418 /** 419 * Constructs a new {@code PresetDialog}. 420 * @param content the content that will be displayed in this dialog 421 * @param title the text that will be shown in the window titlebar 422 * @param icon the image to be displayed as the icon for this window 423 * @param disableApply whether to disable "Apply" button 424 * @param showNewRelation whether to display "New relation" button 425 */ 404 426 PresetDialog(Component content, String title, ImageIcon icon, boolean disableApply, boolean showNewRelation) { 405 427 super(Main.parent, title, 406 428 showNewRelation ? 407 new String[] {tr("Apply Preset"), tr("New relation"), tr("Cancel")}:408 new String[] {tr("Apply Preset"), tr("Cancel")},409 429 (new String[] {tr("Apply Preset"), tr("New relation"), tr("Cancel")}) : 430 (new String[] {tr("Apply Preset"), tr("Cancel")}), 431 true); 410 432 if (icon != null) 411 433 setIconImage(icon.getImage()); … … 427 449 setSize(d); 428 450 } 429 showDialog(); 430 } 431 } 432 451 super.showDialog(); 452 } 453 } 454 455 /** 456 * Shows the preset dialog. 457 * @param sel selection 458 * @param showNewRelation whether to display "New relation" button 459 * @return the user choice after the dialog has been closed 460 */ 433 461 public int showDialog(Collection<OsmPrimitive> sel, boolean showNewRelation) { 434 462 PresetPanel p = createPanel(sel); 435 if (p == null)436 return DIALOG_ANSWER_CANCEL;437 463 438 464 int answer = 1;
Note:
See TracChangeset
for help on using the changeset viewer.