Changeset 11343 in josm for trunk/src/org/openstreetmap
- Timestamp:
- 2016-11-29T02:22:12+01:00 (8 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/actions
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/AddImageryLayerAction.java
r11257 r11343 45 45 public class AddImageryLayerAction extends JosmAction implements AdaptableAction { 46 46 private final transient ImageryInfo info; 47 48 static class SelectWmsLayersDialog extends ExtendedDialog { 49 SelectWmsLayersDialog(WMSLayerTree tree, JComboBox<String> formats) { 50 super(Main.parent, tr("Select WMS layers"), new String[]{tr("Add layers"), tr("Cancel")}); 51 final JScrollPane scrollPane = new JScrollPane(tree.getLayerTree()); 52 scrollPane.setPreferredSize(new Dimension(400, 400)); 53 final JPanel panel = new JPanel(new GridBagLayout()); 54 panel.add(scrollPane, GBC.eol().fill()); 55 panel.add(formats, GBC.eol().fill(GBC.HORIZONTAL)); 56 setContent(panel); 57 } 58 } 47 59 48 60 /** … … 151 163 formats.setToolTipText(tr("Select image format for WMS layer")); 152 164 153 if (!GraphicsEnvironment.isHeadless()) { 154 if (1 != new ExtendedDialog(Main.parent, tr("Select WMS layers"), new String[]{tr("Add layers"), tr("Cancel")}) { { 155 final JScrollPane scrollPane = new JScrollPane(tree.getLayerTree()); 156 scrollPane.setPreferredSize(new Dimension(400, 400)); 157 final JPanel panel = new JPanel(new GridBagLayout()); 158 panel.add(scrollPane, GBC.eol().fill()); 159 panel.add(formats, GBC.eol().fill(GBC.HORIZONTAL)); 160 setContent(panel); 161 } }.showDialog().getValue()) { 162 return null; 163 } 165 if (!GraphicsEnvironment.isHeadless() && 1 != new SelectWmsLayersDialog(tree, formats).showDialog().getValue()) { 166 return null; 164 167 } 165 168 -
trunk/src/org/openstreetmap/josm/actions/JumpToAction.java
r11301 r11343 36 36 public class JumpToAction extends JosmAction { 37 37 38 private final JosmTextField url = new JosmTextField(); 39 private final JosmTextField lat = new JosmTextField(); 40 private final JosmTextField lon = new JosmTextField(); 41 private final JosmTextField zm = new JosmTextField(); 42 38 43 /** 39 44 * Constructs a new {@code JumpToAction}. … … 46 51 } 47 52 48 private final JosmTextField url = new JosmTextField(); 49 private final JosmTextField lat = new JosmTextField(); 50 private final JosmTextField lon = new JosmTextField(); 51 private final JosmTextField zm = new JosmTextField(); 53 static class JumpToPositionDialog extends ExtendedDialog { 54 JumpToPositionDialog(String[] buttons, JPanel panel) { 55 super(Main.parent, tr("Jump to Position"), buttons); 56 setContent(panel); 57 setCancelButton(2); 58 } 59 } 52 60 53 61 class OsmURLListener implements DocumentListener { … … 143 151 double zoomLvl = 100; 144 152 while (ll == null) { 145 final int option = new ExtendedDialog(Main.parent, tr("Jump to Position"), buttons) {{ 146 setContent(panel); 147 setCancelButton(2); 148 }}.showDialog().getValue(); 153 final int option = new JumpToPositionDialog(buttons, panel).showDialog().getValue(); 149 154 150 155 if (option != 1) return; -
trunk/src/org/openstreetmap/josm/actions/OpenLocationAction.java
r11329 r11343 59 59 protected final transient List<Class<? extends DownloadTask>> downloadTasks; 60 60 61 static class WhichTasksToPerformDialog extends ExtendedDialog { 62 WhichTasksToPerformDialog(JList<DownloadTask> list) { 63 super(Main.parent, tr("Which tasks to perform?"), new String[]{tr("Ok"), tr("Cancel")}, true); 64 setButtonIcons(new String[]{"ok", "cancel"}); 65 final JPanel pane = new JPanel(new GridLayout(2, 1)); 66 pane.add(new JLabel(tr("Which tasks to perform?"))); 67 pane.add(list); 68 setContent(pane); 69 } 70 } 71 61 72 /** 62 73 * Create an open action. The name is "Open a file". … … 237 248 final JList<DownloadTask> list = new JList<>(tasks.toArray(new DownloadTask[tasks.size()])); 238 249 list.addSelectionInterval(0, tasks.size() - 1); 239 final ExtendedDialog dialog = new ExtendedDialog(Main.parent, 240 tr("Which tasks to perform?"), new String[]{tr("Ok"), tr("Cancel")}, true) { { 241 setButtonIcons(new String[]{"ok", "cancel"}); 242 final JPanel pane = new JPanel(new GridLayout(2, 1)); 243 pane.add(new JLabel(tr("Which tasks to perform?"))); 244 pane.add(list); 245 setContent(pane); 246 } }; 250 final ExtendedDialog dialog = new WhichTasksToPerformDialog(list); 247 251 dialog.showDialog(); 248 252 return dialog.getValue() == 1 ? list.getSelectedValuesList() : Collections.<DownloadTask>emptyList(); -
trunk/src/org/openstreetmap/josm/actions/PurgeAction.java
r11277 r11343 89 89 } 90 90 91 /** force selection to be active for all entries */ 92 static class SelectionForcedOsmPrimitivRenderer extends OsmPrimitivRenderer { 93 @Override 94 public Component getListCellRendererComponent(JList<? extends OsmPrimitive> list, 95 OsmPrimitive value, int index, boolean isSelected, boolean cellHasFocus) { 96 return super.getListCellRendererComponent(list, value, index, true, false); 97 } 98 } 99 91 100 @Override 92 101 public void actionPerformed(ActionEvent e) { … … 128 137 toPurgeChecked = new HashSet<>(); 129 138 130 // Add referrer, unless the object to purge is not new 131 // and the parent is a relation 139 // Add referrer, unless the object to purge is not new and the parent is a relation 132 140 Set<OsmPrimitive> toPurgeRecursive = new HashSet<>(); 133 141 while (!toPurge.isEmpty()) { … … 169 177 } 170 178 171 // Add untagged way nodes. Do not add nodes that have other 172 // referrers not yet to-be-purged. 179 // Add untagged way nodes. Do not add nodes that have other referrers not yet to-be-purged. 173 180 if (Main.pref.getBoolean("purge.add_untagged_waynodes", true)) { 174 181 Set<OsmPrimitive> wayNodes = new HashSet<>(); … … 206 213 } 207 214 208 /** 209 * Add higher level relations (list gets extended while looping over it) 210 */ 215 // Add higher level relations (list gets extended while looping over it) 211 216 List<Relation> relLst = new ArrayList<>(relSet); 212 217 for (int i = 0; i < relLst.size(); ++i) { // foreach loop not applicable since list gets extended while looping over it … … 262 267 JList<OsmPrimitive> list = new JList<>(toPurgeAdditionally.toArray(new OsmPrimitive[toPurgeAdditionally.size()])); 263 268 /* force selection to be active for all entries */ 264 list.setCellRenderer(new OsmPrimitivRenderer() { 265 @Override 266 public Component getListCellRendererComponent(JList<? extends OsmPrimitive> list, 267 OsmPrimitive value, 268 int index, 269 boolean isSelected, 270 boolean cellHasFocus) { 271 return super.getListCellRendererComponent(list, value, index, true, false); 272 } 273 }); 269 list.setCellRenderer(new SelectionForcedOsmPrimitivRenderer()); 274 270 JScrollPane scroll = new JScrollPane(list); 275 271 scroll.setPreferredSize(new Dimension(250, 300)); -
trunk/src/org/openstreetmap/josm/actions/RenameLayerAction.java
r9591 r11343 44 44 } 45 45 46 static class InitialValueOptionPane extends JOptionPane { 47 InitialValueOptionPane(Box panel, JosmTextField initial) { 48 super(panel, JOptionPane.QUESTION_MESSAGE, JOptionPane.OK_CANCEL_OPTION, null, null, initial); 49 } 50 51 @Override 52 public void selectInitialValue() { 53 JosmTextField initial = (JosmTextField) getInitialValue(); 54 initial.requestFocusInWindow(); 55 initial.selectAll(); 56 } 57 } 58 46 59 @Override 47 60 public void actionPerformed(ActionEvent e) { … … 56 69 } 57 70 58 final JOptionPane optionPane = new JOptionPane(panel, JOptionPane.QUESTION_MESSAGE, JOptionPane.OK_CANCEL_OPTION) { 59 @Override public void selectInitialValue() { 60 name.requestFocusInWindow(); 61 name.selectAll(); 62 } 63 }; 71 final JOptionPane optionPane = new InitialValueOptionPane(panel, name); 64 72 final JDialog dlg = optionPane.createDialog(Main.parent, tr("Rename layer")); 65 73 dlg.setModalityType(ModalityType.DOCUMENT_MODAL); -
trunk/src/org/openstreetmap/josm/actions/SplitWayAction.java
r11240 r11343 264 264 } 265 265 }); 266 list.setCellRenderer(new DefaultListCellRenderer() { 267 @Override 268 public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) { 269 final Component c = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); 270 final String name = DefaultNameFormatter.getInstance().format((Way) value); 271 // get rid of id from DefaultNameFormatter.decorateNameWithId() 272 final String nameWithoutId = name 273 .replace(tr(" [id: {0}]", ((Way) value).getId()), "") 274 .replace(tr(" [id: {0}]", ((Way) value).getUniqueId()), ""); 275 ((JLabel) c).setText(tr("Segment {0}: {1}", index + 1, nameWithoutId)); 276 return c; 277 } 278 }); 266 list.setCellRenderer(new SegmentListCellRenderer()); 279 267 } 280 268 … … 306 294 Main.getLayerManager().getEditDataSet().setSelected(result.getNewSelection()); 307 295 } 296 } 297 } 298 299 static class SegmentListCellRenderer extends DefaultListCellRenderer { 300 @Override 301 public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) { 302 final Component c = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); 303 final String name = DefaultNameFormatter.getInstance().format((Way) value); 304 // get rid of id from DefaultNameFormatter.decorateNameWithId() 305 final String nameWithoutId = name 306 .replace(tr(" [id: {0}]", ((Way) value).getId()), "") 307 .replace(tr(" [id: {0}]", ((Way) value).getUniqueId()), ""); 308 ((JLabel) c).setText(tr("Segment {0}: {1}", index + 1, nameWithoutId)); 309 return c; 308 310 } 309 311 }
Note:
See TracChangeset
for help on using the changeset viewer.