Changeset 15457 in josm for trunk/src/org/openstreetmap
- Timestamp:
- 2019-10-15T20:40:50+02:00 (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/dialogs/LayerListDialog.java
r15390 r15457 39 39 import javax.swing.table.TableModel; 40 40 41 import org.openstreetmap.josm.actions.ExpertToggleAction; 41 42 import org.openstreetmap.josm.actions.MergeLayerAction; 42 43 import org.openstreetmap.josm.data.coor.EastNorth; 43 44 import org.openstreetmap.josm.data.imagery.OffsetBookmark; 44 45 import org.openstreetmap.josm.data.preferences.AbstractProperty; 46 import org.openstreetmap.josm.data.preferences.AbstractProperty.ValueChangeListener; 47 import org.openstreetmap.josm.data.preferences.BooleanProperty; 45 48 import org.openstreetmap.josm.gui.MainApplication; 46 49 import org.openstreetmap.josm.gui.MapFrame; … … 97 100 private static volatile LayerListDialog instance; 98 101 102 private static final BooleanProperty DISPLAY_NUMBERS = new BooleanProperty("layerlist.display.numbers", true); 103 99 104 /** 100 105 * Creates the instance of the dialog. It's connected to the layer manager … … 127 132 /** the list of layers (technically its a JTable, but appears like a list) */ 128 133 private final LayerList layerList; 134 private final ValueChangeListener<? super Boolean> displayNumbersPrefListener; 129 135 130 136 private final ActivateLayerAction activateLayerAction; … … 219 225 layerList.getColumnModel().getColumn(2).setResizable(false); 220 226 227 int width = getLayerNumberWidth(); 221 228 layerList.getColumnModel().getColumn(3).setCellRenderer(new LayerVisibleCellRenderer()); 222 229 layerList.getColumnModel().getColumn(3).setCellEditor(new LayerVisibleCellEditor(new LayerVisibleCheckBox())); 223 layerList.getColumnModel().getColumn(3).setMaxWidth( 48);224 layerList.getColumnModel().getColumn(3).setPreferredWidth( 48);230 layerList.getColumnModel().getColumn(3).setMaxWidth(width); 231 layerList.getColumnModel().getColumn(3).setPreferredWidth(width); 225 232 layerList.getColumnModel().getColumn(3).setResizable(false); 226 233 … … 247 254 } 248 255 256 displayNumbersPrefListener = change -> { 257 int numberWidth = getLayerNumberWidth(); 258 layerList.getColumnModel().getColumn(3).setMaxWidth(numberWidth); 259 layerList.getColumnModel().getColumn(3).setPreferredWidth(numberWidth); 260 repaint(); 261 }; 262 DISPLAY_NUMBERS.addListener(displayNumbersPrefListener); 263 249 264 // init the model 250 265 // … … 326 341 } 327 342 343 private static boolean displayLayerNumbers() { 344 return ExpertToggleAction.isExpert() && DISPLAY_NUMBERS.get(); 345 } 346 347 private static int getLayerNumberWidth() { 348 return displayLayerNumbers() ? 48 : 16; 349 } 350 328 351 /** 329 352 * Gets the layer manager this dialog is for. … … 367 390 JumpToMarkerActions.unregisterActions(); 368 391 layerList.setTransferHandler(null); 392 DISPLAY_NUMBERS.removeListener(displayNumbersPrefListener); 369 393 super.destroy(); 370 394 instance = null; … … 419 443 boolean visible = layer.isVisible(); 420 444 setSelected(visible); 421 List<Layer> layers = MainApplication.getLayerManager().getLayers(); 422 int num = layers.size() - layers.indexOf(layer); 423 setText(String.format("%s[%d]", num < 10 ? " " : "", num)); 445 if (displayLayerNumbers()) { 446 List<Layer> layers = MainApplication.getLayerManager().getLayers(); 447 int num = layers.size() - layers.indexOf(layer); 448 setText(String.format("%s[%d]", num < 10 ? " " : "", num)); 449 } else { 450 setText(null); 451 } 424 452 setTranslucent(layer.getOpacity() < 1.0); 425 453 setToolTipText(visible ?
Note:
See TracChangeset
for help on using the changeset viewer.