Changeset 10611 in josm for trunk/src/org/openstreetmap/josm/gui/preferences
- Timestamp:
- 2016-07-23T18:46:45+02:00 (8 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/gui/preferences
- Files:
-
- 26 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/preferences/PreferenceDialog.java
r10369 r10611 12 12 import java.awt.Insets; 13 13 import java.awt.event.ActionEvent; 14 import java.awt.event.ActionListener;15 14 import java.awt.event.KeyEvent; 16 15 import java.awt.event.WindowAdapter; … … 19 18 import javax.swing.AbstractAction; 20 19 import javax.swing.BorderFactory; 20 import javax.swing.JButton; 21 21 import javax.swing.JCheckBox; 22 22 import javax.swing.JComponent; 23 import javax.swing.JButton;24 23 import javax.swing.JDialog; 25 24 import javax.swing.JPanel; … … 58 57 JCheckBox expert = new JCheckBox(tr("Expert mode")); 59 58 expert.setSelected(ExpertToggleAction.isExpert()); 60 expert.addActionListener(new ActionListener() { 61 @Override 62 public void actionPerformed(ActionEvent e) { 63 ExpertToggleAction.getInstance().actionPerformed(null); 64 } 65 }); 59 expert.addActionListener(e -> ExpertToggleAction.getInstance().actionPerformed(null)); 66 60 67 61 JPanel btns = new JPanel(new FlowLayout(FlowLayout.CENTER)); -
trunk/src/org/openstreetmap/josm/gui/preferences/PreferenceTabbedPane.java
r10600 r10611 322 322 323 323 public void selectTabByName(String name) { 324 selectTabBy(new TabIdentifier() { 325 @Override 326 public boolean identify(TabPreferenceSetting tps, Object name) { 327 return name != null && tps != null && tps.getIconName() != null && name.equals(tps.getIconName()); 328 } 329 }, name); 324 selectTabBy((tps, name1) -> name1 != null && tps != null && tps.getIconName() != null && name1.equals(tps.getIconName()), name); 330 325 } 331 326 332 327 public void selectTabByPref(Class<? extends TabPreferenceSetting> clazz) { 333 selectTabBy(new TabIdentifier() { 334 @Override 335 public boolean identify(TabPreferenceSetting tps, Object clazz) { 336 return tps.getClass().isAssignableFrom((Class<?>) clazz); 337 } 338 }, clazz); 328 selectTabBy((tps, clazz1) -> tps.getClass().isAssignableFrom((Class<?>) clazz1), clazz); 339 329 } 340 330 … … 344 334 final SubPreferenceSetting sub = (SubPreferenceSetting) setting; 345 335 final TabPreferenceSetting tab = sub.getTabPreferenceSetting(this); 346 selectTabBy(new TabIdentifier() { 347 @Override 348 public boolean identify(TabPreferenceSetting tps, Object unused) { 349 return tps.equals(tab); 350 } 351 }, null); 336 selectTabBy((tps, unused) -> tps.equals(tab), null); 352 337 return tab.selectSubTab(sub); 353 338 } … … 419 404 public void savePreferences() { 420 405 // create a task for downloading plugins if the user has activated, yet not downloaded, new plugins 421 //422 406 final PluginPreference preference = getPluginPreference(); 423 407 final Set<PluginInformation> toDownload = preference.getPluginsScheduledForUpdateOrDownload(); … … 430 414 431 415 // this is the task which will run *after* the plugins are downloaded 432 //433 416 final Runnable continuation = new PluginDownloadAfterTask(preference, task, toDownload); 434 417 … … 436 419 // if we have to launch a plugin download task we do it asynchronously, followed 437 420 // by the remaining "save preferences" activites run on the Swing EDT. 438 //439 421 Main.worker.submit(task); 440 Main.worker.submit( 441 new Runnable() { 442 @Override 443 public void run() { 444 SwingUtilities.invokeLater(continuation); 445 } 446 } 447 ); 422 Main.worker.submit(() -> SwingUtilities.invokeLater(continuation)); 448 423 } else { 449 424 // no need for asynchronous activities. Simply run the remaining "save preference" 450 425 // activities on this thread (we are already on the Swing EDT 451 //452 426 continuation.run(); 453 427 } -
trunk/src/org/openstreetmap/josm/gui/preferences/SourceEditor.java
r10482 r10611 18 18 import java.awt.event.MouseAdapter; 19 19 import java.awt.event.MouseEvent; 20 import java.beans.PropertyChangeEvent;21 import java.beans.PropertyChangeListener;22 20 import java.io.BufferedReader; 23 21 import java.io.File; … … 29 27 import java.util.Collection; 30 28 import java.util.Collections; 31 import java.util.Comparator;32 29 import java.util.EventObject; 33 30 import java.util.HashMap; … … 66 63 import javax.swing.event.CellEditorListener; 67 64 import javax.swing.event.ChangeEvent; 68 import javax.swing.event.ChangeListener;69 65 import javax.swing.event.DocumentEvent; 70 66 import javax.swing.event.DocumentListener; … … 165 161 } 166 162 167 activeSourcesModel.addTableModelListener(new TableModelListener() { 168 @Override 169 public void tableChanged(TableModelEvent e) { 170 listCellRenderer.updateSources(activeSourcesModel.getSources()); 171 lstAvailableSources.repaint(); 172 } 163 activeSourcesModel.addTableModelListener(e -> { 164 listCellRenderer.updateSources(activeSourcesModel.getSources()); 165 lstAvailableSources.repaint(); 173 166 }); 174 tblActiveSources.addPropertyChangeListener(new PropertyChangeListener() { 175 @Override 176 public void propertyChange(PropertyChangeEvent evt) { 177 listCellRenderer.updateSources(activeSourcesModel.getSources()); 178 lstAvailableSources.repaint(); 179 } 167 tblActiveSources.addPropertyChangeListener(evt -> { 168 listCellRenderer.updateSources(activeSourcesModel.getSources()); 169 lstAvailableSources.repaint(); 180 170 }); 181 activeSourcesModel.addTableModelListener(new TableModelListener() { 182 // Force swing to show horizontal scrollbars for the JTable 183 // Yes, this is a little ugly, but should work 184 @Override 185 public void tableChanged(TableModelEvent e) { 186 TableHelper.adjustColumnWidth(tblActiveSources, canEnable ? 1 : 0, 800); 187 } 188 }); 171 // Force Swing to show horizontal scrollbars for the JTable 172 // Yes, this is a little ugly, but should work 173 activeSourcesModel.addTableModelListener(e -> TableHelper.adjustColumnWidth(tblActiveSources, canEnable ? 1 : 0, 800)); 189 174 activeSourcesModel.setActiveSources(getInitialSourcesList()); 190 175 … … 1238 1223 1239 1224 protected void sort() { 1240 Collections.sort( 1241 data, 1242 new Comparator<String>() { 1243 @Override 1244 public int compare(String o1, String o2) { 1245 if (o1.isEmpty() && o2.isEmpty()) 1246 return 0; 1247 if (o1.isEmpty()) return 1; 1248 if (o2.isEmpty()) return -1; 1249 return o1.compareTo(o2); 1250 } 1251 } 1252 ); 1225 Collections.sort(data, 1226 (o1, o2) -> { 1227 if (o1.isEmpty() && o2.isEmpty()) 1228 return 0; 1229 if (o1.isEmpty()) return 1; 1230 if (o2.isEmpty()) return -1; 1231 return o1.compareTo(o2); 1232 }); 1253 1233 } 1254 1234 … … 1380 1360 final String msg = tr(getStr(I18nString.FAILED_TO_LOAD_SOURCES_FROM), url, emsg); 1381 1361 1382 GuiHelper.runInEDT(new Runnable() { 1383 @Override 1384 public void run() { 1385 HelpAwareOptionPane.showOptionDialog( 1386 Main.parent, 1387 msg, 1388 tr("Error"), 1389 JOptionPane.ERROR_MESSAGE, 1390 ht(getStr(I18nString.FAILED_TO_LOAD_SOURCES_FROM_HELP_TOPIC)) 1391 ); 1392 } 1393 }); 1362 GuiHelper.runInEDT(() -> HelpAwareOptionPane.showOptionDialog( 1363 Main.parent, 1364 msg, 1365 tr("Error"), 1366 JOptionPane.ERROR_MESSAGE, 1367 ht(getStr(I18nString.FAILED_TO_LOAD_SOURCES_FROM_HELP_TOPIC)) 1368 )); 1394 1369 } 1395 1370 … … 1746 1721 */ 1747 1722 public final void deferLoading(final DefaultTabPreferenceSetting tab, final Component component) { 1748 tab.getTabPane().addChangeListener( 1749 new ChangeListener() { 1750 @Override 1751 public void stateChanged(ChangeEvent e) { 1752 if (tab.getTabPane().getSelectedComponent() == component) { 1753 SourceEditor.this.initiallyLoadAvailableSources(); 1754 } 1755 } 1756 } 1757 ); 1723 tab.getTabPane().addChangeListener(e -> { 1724 if (tab.getTabPane().getSelectedComponent() == component) { 1725 SourceEditor.this.initiallyLoadAvailableSources(); 1726 } 1727 }); 1758 1728 } 1759 1729 -
trunk/src/org/openstreetmap/josm/gui/preferences/ToolbarPreferences.java
r10378 r10611 18 18 import java.awt.event.InputEvent; 19 19 import java.awt.event.KeyEvent; 20 import java.beans.PropertyChangeEvent;21 import java.beans.PropertyChangeListener;22 20 import java.io.IOException; 23 21 import java.util.ArrayList; … … 51 49 import javax.swing.MenuElement; 52 50 import javax.swing.TransferHandler; 53 import javax.swing.event.ListSelectionEvent;54 import javax.swing.event.ListSelectionListener;55 51 import javax.swing.event.PopupMenuEvent; 56 52 import javax.swing.event.PopupMenuListener; 57 import javax.swing.event.TreeSelectionEvent;58 import javax.swing.event.TreeSelectionListener;59 53 import javax.swing.table.AbstractTableModel; 60 54 import javax.swing.tree.DefaultMutableTreeNode; … … 69 63 import org.openstreetmap.josm.actions.ParameterizedAction; 70 64 import org.openstreetmap.josm.actions.ParameterizedActionDecorator; 71 import org.openstreetmap.josm.data.Preferences.PreferenceChangeEvent;72 import org.openstreetmap.josm.data.Preferences.PreferenceChangedListener;73 65 import org.openstreetmap.josm.gui.tagging.presets.TaggingPreset; 74 66 import org.openstreetmap.josm.tools.GBC; … … 762 754 }; 763 755 selectedList.setCellRenderer(renderer); 764 selectedList.addListSelectionListener(new ListSelectionListener() { 765 @Override 766 public void valueChanged(ListSelectionEvent e) { 767 boolean sel = selectedList.getSelectedIndex() != -1; 768 if (sel) { 769 actionsTree.clearSelection(); 770 ActionDefinition action = selected.get(selectedList.getSelectedIndex()); 771 actionParametersModel.setCurrentAction(action); 772 actionParametersPanel.setVisible(actionParametersModel.getRowCount() > 0); 773 } 774 updateEnabledState(); 775 } 756 selectedList.addListSelectionListener(e -> { 757 boolean sel = selectedList.getSelectedIndex() != -1; 758 if (sel) { 759 actionsTree.clearSelection(); 760 ActionDefinition action = selected.get(selectedList.getSelectedIndex()); 761 actionParametersModel.setCurrentAction(action); 762 actionParametersPanel.setVisible(actionParametersModel.getRowCount() > 0); 763 } 764 updateEnabledState(); 776 765 }); 777 766 … … 804 793 }); 805 794 actionsTree.setDragEnabled(true); 806 actionsTree.getSelectionModel().addTreeSelectionListener(new TreeSelectionListener() { 807 @Override public void valueChanged(TreeSelectionEvent e) { 808 updateEnabledState(); 809 } 810 }); 795 actionsTree.getSelectionModel().addTreeSelectionListener(e -> updateEnabledState()); 811 796 812 797 final JPanel left = new JPanel(new GridBagLayout()); … … 914 899 control.setFloatable(false); 915 900 control.setComponentPopupMenu(popupMenu); 916 Main.pref.addPreferenceChangeListener(new PreferenceChangedListener() { 917 @Override 918 public void preferenceChanged(PreferenceChangeEvent e) { 919 if ("toolbar.visible".equals(e.getKey())) { 920 refreshToolbarControl(); 921 } 901 Main.pref.addPreferenceChangeListener(e -> { 902 if ("toolbar.visible".equals(e.getKey())) { 903 refreshToolbarControl(); 922 904 } 923 905 }); … … 1078 1060 } else { 1079 1061 // hide action text if an icon is set later (necessary for delayed/background image loading) 1080 action.getParametrizedAction().addPropertyChangeListener(new PropertyChangeListener() { 1081 1082 @Override 1083 public void propertyChange(PropertyChangeEvent evt) { 1084 if (Action.SMALL_ICON.equals(evt.getPropertyName())) { 1085 b.setHideActionText(evt.getNewValue() != null); 1086 } 1062 action.getParametrizedAction().addPropertyChangeListener(evt -> { 1063 if (Action.SMALL_ICON.equals(evt.getPropertyName())) { 1064 b.setHideActionText(evt.getNewValue() != null); 1087 1065 } 1088 1066 }); -
trunk/src/org/openstreetmap/josm/gui/preferences/advanced/AdvancedPreference.java
r9759 r10611 75 75 private final Map<String, String> profileTypes = new LinkedHashMap<>(); 76 76 77 private final Comparator<PrefEntry> customComparator = new Comparator<PrefEntry>() { 78 @Override 79 public int compare(PrefEntry o1, PrefEntry o2) { 80 if (o1.isChanged() && !o2.isChanged()) 81 return -1; 82 if (o2.isChanged() && !o1.isChanged()) 83 return 1; 84 if (!(o1.isDefault()) && o2.isDefault()) 85 return -1; 86 if (!(o2.isDefault()) && o1.isDefault()) 87 return 1; 88 return o1.compareTo(o2); 89 } 77 private final Comparator<PrefEntry> customComparator = (o1, o2) -> { 78 if (o1.isChanged() && !o2.isChanged()) 79 return -1; 80 if (o2.isChanged() && !o1.isChanged()) 81 return 1; 82 if (!(o1.isDefault()) && o2.isDefault()) 83 return -1; 84 if (!(o2.isDefault()) && o1.isDefault()) 85 return 1; 86 return o1.compareTo(o2); 90 87 }; 91 88 … … 139 136 p.add(Box.createHorizontalGlue(), GBC.std().fill(GBC.HORIZONTAL)); 140 137 p.add(add, GBC.std().insets(0, 5, 0, 0)); 141 add.addActionListener(new ActionListener() { 142 @Override public void actionPerformed(ActionEvent e) { 143 PrefEntry pe = table.addPreference(gui); 144 if (pe != null) { 145 allData.add(pe); 146 Collections.sort(allData); 147 applyFilter(); 148 } 138 add.addActionListener(e -> { 139 PrefEntry pe = table.addPreference(gui); 140 if (pe != null) { 141 allData.add(pe); 142 Collections.sort(allData); 143 applyFilter(); 149 144 } 150 145 }); … … 152 147 JButton edit = new JButton(tr("Edit")); 153 148 p.add(edit, GBC.std().insets(5, 5, 5, 0)); 154 edit.addActionListener(new ActionListener() { 155 @Override public void actionPerformed(ActionEvent e) { 156 if (table.editPreference(gui)) 157 applyFilter(); 158 } 149 edit.addActionListener(e -> { 150 if (table.editPreference(gui)) 151 applyFilter(); 159 152 }); 160 153 161 154 JButton reset = new JButton(tr("Reset")); 162 155 p.add(reset, GBC.std().insets(0, 5, 0, 0)); 163 reset.addActionListener(new ActionListener() { 164 @Override public void actionPerformed(ActionEvent e) { 165 table.resetPreferences(gui); 166 } 167 }); 156 reset.addActionListener(e -> table.resetPreferences(gui)); 168 157 169 158 JButton read = new JButton(tr("Read from file")); 170 159 p.add(read, GBC.std().insets(5, 5, 0, 0)); 171 read.addActionListener(new ActionListener() { 172 @Override public void actionPerformed(ActionEvent e) { 173 readPreferencesFromXML(); 174 } 175 }); 160 read.addActionListener(e -> readPreferencesFromXML()); 176 161 177 162 JButton export = new JButton(tr("Export selected items")); 178 163 p.add(export, GBC.std().insets(5, 5, 0, 0)); 179 export.addActionListener(new ActionListener() { 180 @Override public void actionPerformed(ActionEvent e) { 181 exportSelectedToXML(); 182 } 183 }); 164 export.addActionListener(e -> exportSelectedToXML()); 184 165 185 166 final JButton more = new JButton(tr("More...")); -
trunk/src/org/openstreetmap/josm/gui/preferences/advanced/ListEditor.java
r10047 r10611 19 19 import org.openstreetmap.josm.gui.widgets.JosmTextField; 20 20 import org.openstreetmap.josm.tools.GBC; 21 import org.openstreetmap.josm.tools.Predicate;22 21 import org.openstreetmap.josm.tools.Utils; 23 22 … … 44 43 @Override 45 44 public List<String> getData() { 46 return new ArrayList<>(Utils.filter(model.getData(), new Predicate<String>() { 47 @Override 48 public boolean evaluate(String object) { 49 return object != null && !object.isEmpty(); 50 } 51 })); 45 return new ArrayList<>(Utils.filter(model.getData(), object -> object != null && !object.isEmpty())); 52 46 } 53 47 -
trunk/src/org/openstreetmap/josm/gui/preferences/display/ColorPreference.java
r10001 r10611 5 5 6 6 import java.awt.Color; 7 import java.awt.Component;8 7 import java.awt.Dimension; 9 8 import java.awt.GridBagLayout; 10 import java.awt.event.ActionEvent;11 import java.awt.event.ActionListener;12 9 import java.awt.event.MouseAdapter; 13 10 import java.awt.event.MouseEvent; … … 156 153 157 154 colorEdit = new JButton(tr("Choose")); 158 colorEdit.addActionListener(new ActionListener() { 159 @Override 160 public void actionPerformed(ActionEvent e) { 161 int sel = colors.getSelectedRow(); 162 JColorChooser chooser = new JColorChooser((Color) colors.getValueAt(sel, 1)); 163 int answer = JOptionPane.showConfirmDialog( 164 gui, chooser, 165 tr("Choose a color for {0}", getName((String) colors.getValueAt(sel, 0))), 166 JOptionPane.OK_CANCEL_OPTION, 167 JOptionPane.PLAIN_MESSAGE); 168 if (answer == JOptionPane.OK_OPTION) { 169 colors.setValueAt(chooser.getColor(), sel, 1); 170 } 155 colorEdit.addActionListener(e -> { 156 int sel = colors.getSelectedRow(); 157 JColorChooser chooser = new JColorChooser((Color) colors.getValueAt(sel, 1)); 158 int answer = JOptionPane.showConfirmDialog( 159 gui, chooser, 160 tr("Choose a color for {0}", getName((String) colors.getValueAt(sel, 0))), 161 JOptionPane.OK_CANCEL_OPTION, 162 JOptionPane.PLAIN_MESSAGE); 163 if (answer == JOptionPane.OK_OPTION) { 164 colors.setValueAt(chooser.getColor(), sel, 1); 171 165 } 172 166 }); 173 167 defaultSet = new JButton(tr("Set to default")); 174 defaultSet.addActionListener(new ActionListener() { 175 @Override 176 public void actionPerformed(ActionEvent e) { 177 int sel = colors.getSelectedRow(); 178 String name = (String) colors.getValueAt(sel, 0); 168 defaultSet.addActionListener(e -> { 169 int sel = colors.getSelectedRow(); 170 String name = (String) colors.getValueAt(sel, 0); 171 Color c = Main.pref.getDefaultColor(name); 172 if (c != null) { 173 colors.setValueAt(c, sel, 1); 174 } 175 }); 176 JButton defaultAll = new JButton(tr("Set all to default")); 177 defaultAll.addActionListener(e -> { 178 for (int i = 0; i < colors.getRowCount(); ++i) { 179 String name = (String) colors.getValueAt(i, 0); 179 180 Color c = Main.pref.getDefaultColor(name); 180 181 if (c != null) { 181 colors.setValueAt(c, sel, 1);182 colors.setValueAt(c, i, 1); 182 183 } 183 184 } 184 185 }); 185 JButton defaultAll = new JButton(tr("Set all to default"));186 defaultAll.addActionListener(new ActionListener() {187 @Override188 public void actionPerformed(ActionEvent e) {189 for (int i = 0; i < colors.getRowCount(); ++i) {190 String name = (String) colors.getValueAt(i, 0);191 Color c = Main.pref.getDefaultColor(name);192 if (c != null) {193 colors.setValueAt(c, i, 1);194 }195 }196 }197 });198 186 remove = new JButton(tr("Remove")); 199 remove.addActionListener(new ActionListener() { 200 @Override 201 public void actionPerformed(ActionEvent e) { 202 int sel = colors.getSelectedRow(); 203 del.add((String) colors.getValueAt(sel, 0)); 204 tableModel.removeRow(sel); 205 } 187 remove.addActionListener(e -> { 188 int sel = colors.getSelectedRow(); 189 del.add((String) colors.getValueAt(sel, 0)); 190 tableModel.removeRow(sel); 206 191 }); 207 192 remove.setEnabled(false); … … 233 218 colors.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); 234 219 final TableCellRenderer oldColorsRenderer = colors.getDefaultRenderer(Object.class); 235 colors.setDefaultRenderer(Object.class, new TableCellRenderer() { 236 @Override 237 public Component getTableCellRendererComponent(JTable t, Object o, boolean selected, boolean focus, int row, int column) { 238 if (o == null) 239 return new JLabel(); 240 if (column == 1) { 241 Color c = (Color) o; 242 JLabel l = new JLabel(ColorHelper.color2html(c)); 243 GuiHelper.setBackgroundReadable(l, c); 244 l.setOpaque(true); 245 return l; 246 } 247 return oldColorsRenderer.getTableCellRendererComponent(t, getName(o.toString()), selected, focus, row, column); 248 } 220 colors.setDefaultRenderer(Object.class, (t, o, selected, focus, row, column) -> { 221 if (o == null) 222 return new JLabel(); 223 if (column == 1) { 224 Color c = (Color) o; 225 JLabel l = new JLabel(ColorHelper.color2html(c)); 226 GuiHelper.setBackgroundReadable(l, c); 227 l.setOpaque(true); 228 return l; 229 } 230 return oldColorsRenderer.getTableCellRendererComponent(t, getName(o.toString()), selected, focus, row, column); 249 231 }); 250 232 colors.getColumnModel().getColumn(1).setWidth(100); -
trunk/src/org/openstreetmap/josm/gui/preferences/display/DrawingPreference.java
r9778 r10611 5 5 6 6 import java.awt.GridBagLayout; 7 import java.awt.event.ActionEvent;8 import java.awt.event.ActionListener;9 7 10 8 import javax.swing.BorderFactory; … … 71 69 72 70 // directionHint 73 directionHint.addActionListener(new ActionListener() { 74 @Override 75 public void actionPerformed(ActionEvent e) { 76 if (directionHint.isSelected()) { 77 headArrow.setSelected(Main.pref.getBoolean("draw.segment.head_only", false)); 78 } else { 79 headArrow.setSelected(false); 80 } 81 headArrow.setEnabled(directionHint.isSelected()); 71 directionHint.addActionListener(e -> { 72 if (directionHint.isSelected()) { 73 headArrow.setSelected(Main.pref.getBoolean("draw.segment.head_only", false)); 74 } else { 75 headArrow.setSelected(false); 82 76 } 77 headArrow.setEnabled(directionHint.isSelected()); 83 78 }); 84 79 directionHint.setToolTipText(tr("Draw direction hints for way segments.")); -
trunk/src/org/openstreetmap/josm/gui/preferences/display/GPXSettingsPanel.java
r10378 r10611 7 7 import java.awt.Component; 8 8 import java.awt.GridBagLayout; 9 import java.awt.event.ActionEvent;10 9 import java.awt.event.ActionListener; 11 10 … … 18 17 import javax.swing.JPanel; 19 18 import javax.swing.JRadioButton; 20 import javax.swing.event.ChangeEvent;21 import javax.swing.event.ChangeListener;22 19 23 20 import org.openstreetmap.josm.Main; … … 140 137 ExpertToggleAction.addVisibilitySwitcher(drawRawGpsLinesAll); 141 138 142 drawRawGpsLinesActionListener = new ActionListener() { 143 @Override 144 public void actionPerformed(ActionEvent e) { 145 boolean f = drawRawGpsLinesNone.isSelected() || drawRawGpsLinesGlobal.isSelected(); 146 forceRawGpsLines.setEnabled(!f); 147 drawRawGpsMaxLineLength.setEnabled(!(f || drawRawGpsLinesLocal.isSelected())); 148 drawRawGpsMaxLineLengthLocal.setEnabled(!f); 149 drawGpsArrows.setEnabled(!f); 150 drawGpsArrowsFast.setEnabled(drawGpsArrows.isSelected() && drawGpsArrows.isEnabled()); 151 drawGpsArrowsMinDist.setEnabled(drawGpsArrows.isSelected() && drawGpsArrows.isEnabled()); 152 } 139 drawRawGpsLinesActionListener = e -> { 140 boolean f = drawRawGpsLinesNone.isSelected() || drawRawGpsLinesGlobal.isSelected(); 141 forceRawGpsLines.setEnabled(!f); 142 drawRawGpsMaxLineLength.setEnabled(!(f || drawRawGpsLinesLocal.isSelected())); 143 drawRawGpsMaxLineLengthLocal.setEnabled(!f); 144 drawGpsArrows.setEnabled(!f); 145 drawGpsArrowsFast.setEnabled(drawGpsArrows.isSelected() && drawGpsArrows.isEnabled()); 146 drawGpsArrowsMinDist.setEnabled(drawGpsArrows.isSelected() && drawGpsArrows.isEnabled()); 153 147 }; 154 148 … … 181 175 182 176 // drawGpsArrows 183 drawGpsArrows.addActionListener(new ActionListener() { 184 @Override 185 public void actionPerformed(ActionEvent e) { 186 drawGpsArrowsFast.setEnabled(drawGpsArrows.isSelected() && drawGpsArrows.isEnabled()); 187 drawGpsArrowsMinDist.setEnabled(drawGpsArrows.isSelected() && drawGpsArrows.isEnabled()); 188 } 177 drawGpsArrows.addActionListener(e -> { 178 drawGpsArrowsFast.setEnabled(drawGpsArrows.isSelected() && drawGpsArrows.isEnabled()); 179 drawGpsArrowsMinDist.setEnabled(drawGpsArrows.isSelected() && drawGpsArrows.isEnabled()); 189 180 }); 190 181 drawGpsArrows.setToolTipText(tr("Draw direction arrows for lines, connecting GPS points.")); … … 231 222 colorGroup.add(colorTypeTime); 232 223 233 colorTypeVelocity.addChangeListener(new ChangeListener() { 234 @Override 235 public void stateChanged(ChangeEvent e) { 236 colorTypeVelocityTune.setEnabled(colorTypeVelocity.isSelected()); 237 colorDynamic.setEnabled(colorTypeVelocity.isSelected() || colorTypeDilution.isSelected()); 238 } 224 colorTypeVelocity.addChangeListener(e -> { 225 colorTypeVelocityTune.setEnabled(colorTypeVelocity.isSelected()); 226 colorDynamic.setEnabled(colorTypeVelocity.isSelected() || colorTypeDilution.isSelected()); 239 227 }); 240 colorTypeDilution.addChangeListener(new ChangeListener() { 241 @Override 242 public void stateChanged(ChangeEvent e) { 243 colorDynamic.setEnabled(colorTypeVelocity.isSelected() || colorTypeDilution.isSelected()); 244 } 245 }); 228 colorTypeDilution.addChangeListener(e -> colorDynamic.setEnabled(colorTypeVelocity.isSelected() || colorTypeDilution.isSelected())); 246 229 247 230 colorTypeNone.setToolTipText(tr("All points and track segments will have the same color. Can be customized in Layer Manager.")); … … 283 266 label.setLabelFor(waypointLabel); 284 267 add(waypointLabel, GBC.eol().fill(GBC.HORIZONTAL).insets(5, 0, 0, 5)); 285 waypointLabel.addActionListener(new ActionListener() { 286 @Override 287 public void actionPerformed(ActionEvent e) { 288 updateWaypointPattern(waypointLabel, waypointLabelPattern); 289 } 290 }); 268 waypointLabel.addActionListener(e -> updateWaypointPattern(waypointLabel, waypointLabelPattern)); 291 269 updateWaypointLabelCombobox(waypointLabel, waypointLabelPattern, TemplateEntryProperty.forMarker(layerName)); 292 270 add(waypointLabelPattern, GBC.eol().fill(GBC.HORIZONTAL).insets(20, 0, 0, 5)); … … 304 282 label.setLabelFor(audioWaypointLabel); 305 283 add(audioWaypointLabel, GBC.eol().fill(GBC.HORIZONTAL).insets(5, 0, 0, 5)); 306 audioWaypointLabel.addActionListener(new ActionListener() { 307 @Override 308 public void actionPerformed(ActionEvent e) { 309 updateWaypointPattern(audioWaypointLabel, audioWaypointLabelPattern); 310 } 311 }); 284 audioWaypointLabel.addActionListener(e -> updateWaypointPattern(audioWaypointLabel, audioWaypointLabelPattern)); 312 285 updateWaypointLabelCombobox(audioWaypointLabel, audioWaypointLabelPattern, TemplateEntryProperty.forAudioMarker(layerName)); 313 286 add(audioWaypointLabelPattern, GBC.eol().fill(GBC.HORIZONTAL).insets(20, 0, 0, 5)); -
trunk/src/org/openstreetmap/josm/gui/preferences/imagery/AddImageryPanel.java
r10600 r10611 9 9 import javax.swing.AbstractButton; 10 10 import javax.swing.JPanel; 11 import javax.swing.event.ChangeEvent;12 import javax.swing.event.ChangeListener;13 11 import javax.swing.event.DocumentEvent; 14 12 import javax.swing.event.DocumentListener; … … 56 54 57 55 protected final void registerValidableComponent(AbstractButton component) { 58 component.addChangeListener(new ChangeListener() { 59 @Override 60 public void stateChanged(ChangeEvent e) { 61 notifyListeners(); 62 } 63 }); 56 component.addChangeListener(e -> notifyListeners()); 64 57 } 65 58 -
trunk/src/org/openstreetmap/josm/gui/preferences/imagery/AddWMSLayerPanel.java
r10520 r10611 4 4 import static org.openstreetmap.josm.tools.I18n.tr; 5 5 6 import java.awt.event.ActionEvent;7 import java.awt.event.ActionListener;8 import java.awt.event.ItemEvent;9 import java.awt.event.ItemListener;10 import java.beans.PropertyChangeEvent;11 import java.beans.PropertyChangeListener;12 6 import java.io.IOException; 13 7 import java.net.MalformedURLException; … … 75 69 add(name, GBC.eop().fill()); 76 70 77 getLayers.addActionListener(new ActionListener() { 78 @Override 79 public void actionPerformed(ActionEvent e) { 80 try { 81 wms.attemptGetCapabilities(rawUrl.getText()); 82 tree.updateTree(wms); 83 formats.setModel(new DefaultComboBoxModel<>(wms.getFormats().toArray(new String[0]))); 84 formats.setSelectedItem(wms.getPreferredFormats()); 85 } catch (MalformedURLException ex) { 86 Main.error(ex, false); 87 JOptionPane.showMessageDialog(getParent(), tr("Invalid service URL."), 88 tr("WMS Error"), JOptionPane.ERROR_MESSAGE); 89 } catch (IOException ex) { 90 Main.error(ex, false); 91 JOptionPane.showMessageDialog(getParent(), tr("Could not retrieve WMS layer list."), 92 tr("WMS Error"), JOptionPane.ERROR_MESSAGE); 93 } catch (WMSImagery.WMSGetCapabilitiesException ex) { 94 String incomingData = ex.getIncomingData().trim(); 95 String title = tr("WMS Error"); 96 String message = tr("Could not parse WMS layer list."); 97 Main.error(ex, "Could not parse WMS layer list. Incoming data:\n"+incomingData); 98 if ((incomingData.startsWith("<html>") || incomingData.startsWith("<HTML>")) 99 && (incomingData.endsWith("</html>") || incomingData.endsWith("</HTML>"))) { 100 GuiHelper.notifyUserHtmlError(AddWMSLayerPanel.this, title, message, incomingData); 101 } else { 102 if (ex.getMessage() != null) { 103 message += '\n' + ex.getMessage(); 104 } 105 JOptionPane.showMessageDialog(getParent(), message, title, JOptionPane.ERROR_MESSAGE); 71 getLayers.addActionListener(e -> { 72 try { 73 wms.attemptGetCapabilities(rawUrl.getText()); 74 tree.updateTree(wms); 75 formats.setModel(new DefaultComboBoxModel<>(wms.getFormats().toArray(new String[0]))); 76 formats.setSelectedItem(wms.getPreferredFormats()); 77 } catch (MalformedURLException ex1) { 78 Main.error(ex1, false); 79 JOptionPane.showMessageDialog(getParent(), tr("Invalid service URL."), 80 tr("WMS Error"), JOptionPane.ERROR_MESSAGE); 81 } catch (IOException ex2) { 82 Main.error(ex2, false); 83 JOptionPane.showMessageDialog(getParent(), tr("Could not retrieve WMS layer list."), 84 tr("WMS Error"), JOptionPane.ERROR_MESSAGE); 85 } catch (WMSImagery.WMSGetCapabilitiesException ex3) { 86 String incomingData = ex3.getIncomingData().trim(); 87 String title = tr("WMS Error"); 88 String message = tr("Could not parse WMS layer list."); 89 Main.error(ex3, "Could not parse WMS layer list. Incoming data:\n"+incomingData); 90 if ((incomingData.startsWith("<html>") || incomingData.startsWith("<HTML>")) 91 && (incomingData.endsWith("</html>") || incomingData.endsWith("</HTML>"))) { 92 GuiHelper.notifyUserHtmlError(AddWMSLayerPanel.this, title, message, incomingData); 93 } else { 94 if (ex3.getMessage() != null) { 95 message += '\n' + ex3.getMessage(); 106 96 } 97 JOptionPane.showMessageDialog(getParent(), message, title, JOptionPane.ERROR_MESSAGE); 107 98 } 108 99 } 109 100 }); 110 101 111 endpoint.addItemListener(new ItemListener() { 112 @Override 113 public void itemStateChanged(ItemEvent e) { 114 tree.getLayerTree().setEnabled(!endpoint.isSelected()); 115 showBounds.setEnabled(!endpoint.isSelected()); 116 wmsInstruction.setEnabled(!endpoint.isSelected()); 117 formats.setEnabled(!endpoint.isSelected()); 118 wmsUrl.setEnabled(!endpoint.isSelected()); 119 if (endpoint.isSelected()) { 120 URL url = wms.getServiceUrl(); 121 if (url != null) { 122 name.setText(url.getHost()); 123 } 124 } else { 125 onLayerSelectionChanged(); 102 endpoint.addItemListener(e -> { 103 tree.getLayerTree().setEnabled(!endpoint.isSelected()); 104 showBounds.setEnabled(!endpoint.isSelected()); 105 wmsInstruction.setEnabled(!endpoint.isSelected()); 106 formats.setEnabled(!endpoint.isSelected()); 107 wmsUrl.setEnabled(!endpoint.isSelected()); 108 if (endpoint.isSelected()) { 109 URL url = wms.getServiceUrl(); 110 if (url != null) { 111 name.setText(url.getHost()); 126 112 } 127 } 128 }); 129 130 tree.getLayerTree().addPropertyChangeListener("selectedLayers", new PropertyChangeListener() { 131 @Override 132 public void propertyChange(PropertyChangeEvent evt) { 113 } else { 133 114 onLayerSelectionChanged(); 134 115 } 135 116 }); 136 117 137 formats.addActionListener(new ActionListener() { 138 @Override 139 public void actionPerformed(ActionEvent e) { 140 onLayerSelectionChanged(); 141 } 142 }); 118 tree.getLayerTree().addPropertyChangeListener("selectedLayers", evt -> onLayerSelectionChanged()); 143 119 144 showBounds.addActionListener(new ActionListener() { 145 @Override 146 public void actionPerformed(ActionEvent e) { 147 if (tree.getSelectedLayers().get(0).bounds != null) { 148 SlippyMapBBoxChooser mapPanel = new SlippyMapBBoxChooser(); 149 mapPanel.setBoundingBox(tree.getSelectedLayers().get(0).bounds); 150 JOptionPane.showMessageDialog(null, mapPanel, tr("Show Bounds"), JOptionPane.PLAIN_MESSAGE); 151 } else { 152 JOptionPane.showMessageDialog(null, tr("No bounding box was found for this layer."), 153 tr("WMS Error"), JOptionPane.ERROR_MESSAGE); 154 } 120 formats.addActionListener(e -> onLayerSelectionChanged()); 121 122 showBounds.addActionListener(e -> { 123 if (tree.getSelectedLayers().get(0).bounds != null) { 124 SlippyMapBBoxChooser mapPanel = new SlippyMapBBoxChooser(); 125 mapPanel.setBoundingBox(tree.getSelectedLayers().get(0).bounds); 126 JOptionPane.showMessageDialog(null, mapPanel, tr("Show Bounds"), JOptionPane.PLAIN_MESSAGE); 127 } else { 128 JOptionPane.showMessageDialog(null, tr("No bounding box was found for this layer."), 129 tr("WMS Error"), JOptionPane.ERROR_MESSAGE); 155 130 } 156 131 }); -
trunk/src/org/openstreetmap/josm/gui/preferences/imagery/CacheContentsPanel.java
r10541 r10611 8 8 import java.util.ArrayList; 9 9 import java.util.Collections; 10 import java.util.Comparator;11 10 import java.util.List; 12 11 import java.util.Map; … … 51 50 public CacheContentsPanel() { 52 51 super(new GridBagLayout()); 53 Main.worker.submit(new Runnable() { 54 @Override 55 public void run() { 56 addToPanel(TMSLayer.getCache(), "TMS"); 57 addToPanel(WMSLayer.getCache(), "WMS"); 58 addToPanel(WMTSLayer.getCache(), "WMTS"); 59 } 52 Main.worker.submit(() -> { 53 addToPanel(TMSLayer.getCache(), "TMS"); 54 addToPanel(WMSLayer.getCache(), "WMS"); 55 addToPanel(WMTSLayer.getCache(), "WMTS"); 60 56 }); 61 57 } … … 65 61 final TableModel tableModel = getTableModel(cache); 66 62 67 GuiHelper.runInEDT(new Runnable() { 68 @Override 69 public void run() { 70 add( 71 new JLabel(tr("{0} cache, total cache size: {1} bytes", name, cacheSize)), 72 GBC.eol().insets(5, 5, 0, 0)); 73 74 add( 75 new JScrollPane(getTableForCache(cache, tableModel)), 76 GBC.eol().fill(GBC.BOTH)); 77 } 63 GuiHelper.runInEDT(() -> { 64 add(new JLabel(tr("{0} cache, total cache size: {1} bytes", name, cacheSize)), 65 GBC.eol().insets(5, 5, 0, 0)); 66 add(new JScrollPane(getTableForCache(cache, tableModel)), 67 GBC.eol().fill(GBC.BOTH)); 78 68 }); 79 69 } … … 88 78 return (Long) val; 89 79 } 90 91 80 } 92 81 } … … 116 105 sortedStats.add(new Pair<>(e.getKey(), e.getValue()[0])); 117 106 } 118 Collections.sort(sortedStats, new Comparator<Pair<String, Integer>>() { 119 @Override 120 public int compare(Pair<String, Integer> o1, Pair<String, Integer> o2) { 121 return -1 * o1.b.compareTo(o2.b); 122 } 123 }); 107 Collections.sort(sortedStats, (o1, o2) -> -1 * o1.b.compareTo(o2.b)); 124 108 String[][] ret = new String[sortedStats.size()][3]; 125 109 int index = 0; -
trunk/src/org/openstreetmap/josm/gui/preferences/imagery/CommonSettingsPanel.java
r10418 r10611 6 6 import java.awt.Color; 7 7 import java.awt.GridBagLayout; 8 import java.awt.event.ActionEvent;9 import java.awt.event.ActionListener;10 8 import java.io.File; 11 9 import java.io.FilenameFilter; … … 55 53 AbstractCachedTileSourceLayer.MAX_DISK_CACHE_SIZE.get().intValue(), 0, Integer.MAX_VALUE, 1)); 56 54 57 58 55 this.btnFadeColor = new JButton(); 59 60 this.btnFadeColor.addActionListener(new ActionListener() { 61 @Override 62 public void actionPerformed(ActionEvent e) { 63 JColorChooser chooser = new JColorChooser(btnFadeColor.getBackground()); 64 int answer = JOptionPane.showConfirmDialog( 65 CommonSettingsPanel.this, chooser, 66 tr("Choose a color for {0}", tr("imagery fade")), 67 JOptionPane.OK_CANCEL_OPTION, 68 JOptionPane.PLAIN_MESSAGE); 69 if (answer == JOptionPane.OK_OPTION) { 70 Color colFadeColor = chooser.getColor(); 71 btnFadeColor.setBackground(colFadeColor); 72 btnFadeColor.setText(ColorHelper.color2html(colFadeColor)); 73 } 56 this.btnFadeColor.addActionListener(e -> { 57 JColorChooser chooser = new JColorChooser(btnFadeColor.getBackground()); 58 int answer = JOptionPane.showConfirmDialog( 59 CommonSettingsPanel.this, chooser, 60 tr("Choose a color for {0}", tr("imagery fade")), 61 JOptionPane.OK_CANCEL_OPTION, 62 JOptionPane.PLAIN_MESSAGE); 63 if (answer == JOptionPane.OK_OPTION) { 64 Color colFadeColor = chooser.getColor(); 65 btnFadeColor.setBackground(colFadeColor); 66 btnFadeColor.setText(ColorHelper.color2html(colFadeColor)); 74 67 } 75 68 }); … … 159 152 private void removeCacheFiles(String path) { 160 153 File directory = new File(path); 161 File[] cacheFiles = directory.listFiles(new FilenameFilter() { 162 @Override 163 public boolean accept(File dir, String name) { 164 return name.endsWith(".data") || name.endsWith(".key"); 165 } 166 167 }); 154 File[] cacheFiles = directory.listFiles((FilenameFilter) (dir, name) -> name.endsWith(".data") || name.endsWith(".key")); 168 155 JCSCacheManager.shutdown(); // shutdown Cache - so files can by safely deleted 169 156 for (File cacheFile: cacheFiles) { -
trunk/src/org/openstreetmap/josm/gui/preferences/imagery/ImageryPreference.java
r10179 r10611 14 14 import java.awt.GridBagLayout; 15 15 import java.awt.event.ActionEvent; 16 import java.awt.event.ActionListener;17 16 import java.awt.event.MouseEvent; 18 17 import java.io.IOException; … … 41 40 import javax.swing.event.ListSelectionEvent; 42 41 import javax.swing.event.ListSelectionListener; 43 import javax.swing.event.TableModelEvent;44 import javax.swing.event.TableModelListener;45 42 import javax.swing.table.DefaultTableCellRenderer; 46 43 import javax.swing.table.DefaultTableModel; … … 312 309 defaultTable = new JTable(defaultModel); 313 310 314 defaultModel.addTableModelListener( 315 new TableModelListener() { 316 @Override 317 public void tableChanged(TableModelEvent e) { 318 activeTable.repaint(); 319 } 320 } 321 ); 322 323 activeModel.addTableModelListener( 324 new TableModelListener() { 325 @Override 326 public void tableChanged(TableModelEvent e) { 327 defaultTable.repaint(); 328 } 329 } 330 ); 311 defaultModel.addTableModelListener(e -> activeTable.repaint()); 312 activeModel.addTableModelListener(e -> defaultTable.repaint()); 331 313 332 314 TableColumnModel mod = defaultTable.getColumnModel(); … … 839 821 JButton add = new JButton(tr("Add")); 840 822 buttonPanel.add(add, GBC.std().insets(0, 5, 0, 0)); 841 add.addActionListener(new ActionListener() { 842 @Override 843 public void actionPerformed(ActionEvent e) { 844 OffsetBookmark b = new OffsetBookmark(Main.getProjection().toCode(), "", "", 0, 0); 845 model.addRow(b); 846 } 847 }); 823 add.addActionListener(e -> model.addRow(new OffsetBookmark(Main.getProjection().toCode(), "", "", 0, 0))); 848 824 849 825 JButton delete = new JButton(tr("Delete")); 850 826 buttonPanel.add(delete, GBC.std().insets(0, 5, 0, 0)); 851 delete.addActionListener(new ActionListener() { 852 @Override 853 public void actionPerformed(ActionEvent e) { 854 if (list.getSelectedRow() == -1) { 855 JOptionPane.showMessageDialog(gui, tr("Please select the row to delete.")); 856 } else { 857 Integer i; 858 while ((i = list.getSelectedRow()) != -1) { 859 model.removeRow(i); 860 } 827 delete.addActionListener(e -> { 828 if (list.getSelectedRow() == -1) { 829 JOptionPane.showMessageDialog(gui, tr("Please select the row to delete.")); 830 } else { 831 Integer i; 832 while ((i = list.getSelectedRow()) != -1) { 833 model.removeRow(i); 861 834 } 862 835 } -
trunk/src/org/openstreetmap/josm/gui/preferences/map/BackupPreference.java
r9543 r10611 5 5 6 6 import java.awt.GridBagLayout; 7 import java.awt.event.ActionEvent;8 7 import java.awt.event.ActionListener; 9 8 … … 101 100 panel.add(notification, GBC.eop()); 102 101 103 ActionListener autosaveEnabled = new ActionListener() { 104 @Override 105 public void actionPerformed(ActionEvent e) { 106 boolean enabled = autosave.isSelected(); 107 autosaveIntervalLabel.setEnabled(enabled); 108 autosaveInterval.setEnabled(enabled); 109 backupPerLayerLabel.setEnabled(enabled); 110 backupPerLayer.setEnabled(enabled); 111 } 102 ActionListener autosaveEnabled = e -> { 103 boolean enabled = autosave.isSelected(); 104 autosaveIntervalLabel.setEnabled(enabled); 105 autosaveInterval.setEnabled(enabled); 106 backupPerLayerLabel.setEnabled(enabled); 107 backupPerLayer.setEnabled(enabled); 112 108 }; 113 109 autosave.addActionListener(autosaveEnabled); -
trunk/src/org/openstreetmap/josm/gui/preferences/map/MapPaintPreference.java
r10420 r10611 33 33 import org.openstreetmap.josm.gui.preferences.TabPreferenceSetting; 34 34 import org.openstreetmap.josm.tools.GBC; 35 import org.openstreetmap.josm.tools.Predicate;36 35 import org.openstreetmap.josm.tools.Utils; 37 36 … … 233 232 int insertionIdx = 0; 234 233 for (final SourceEntry def : defaults) { 235 int i = Utils.indexOf(list, 236 new Predicate<SourceEntry>() { 237 @Override 238 public boolean evaluate(SourceEntry se) { 239 return Objects.equals(def.url, se.url); 240 } 241 }); 234 int i = Utils.indexOf(list, se -> Objects.equals(def.url, se.url)); 242 235 if (i == -1 && !knownDefaults.contains(def.url)) { 243 236 def.active = false; … … 255 248 256 249 // XML style is not bundled anymore 257 list.remove(Utils.find(list, new Predicate<SourceEntry>() { 258 @Override 259 public boolean evaluate(SourceEntry se) { 260 return "resource://styles/standard/elemstyles.xml".equals(se.url); 261 } 262 })); 250 list.remove(Utils.find(list, se -> "resource://styles/standard/elemstyles.xml".equals(se.url))); 263 251 264 252 return changed; -
trunk/src/org/openstreetmap/josm/gui/preferences/plugin/PluginListPanel.java
r10228 r10611 15 15 import javax.swing.SwingConstants; 16 16 import javax.swing.SwingUtilities; 17 import javax.swing.event.HyperlinkEvent;18 17 import javax.swing.event.HyperlinkEvent.EventType; 19 import javax.swing.event.HyperlinkListener;20 18 21 19 import org.openstreetmap.josm.gui.widgets.HtmlPanel; … … 151 149 HtmlPanel description = new HtmlPanel(); 152 150 description.setText(pi.getDescriptionAsHtml()); 153 description.getEditorPane().addHyperlinkListener(new HyperlinkListener() { 154 @Override 155 public void hyperlinkUpdate(HyperlinkEvent e) { 156 if (e.getEventType() == EventType.ACTIVATED) { 157 OpenBrowser.displayUrl(e.getURL().toString()); 158 } 151 description.getEditorPane().addHyperlinkListener(e -> { 152 if (e.getEventType() == EventType.ACTIVATED) { 153 OpenBrowser.displayUrl(e.getURL().toString()); 159 154 } 160 155 }); … … 170 165 repaint(); 171 166 if (visibleRect != null && visibleRect.width > 0 && visibleRect.height > 0) { 172 SwingUtilities.invokeLater(new Runnable() { 173 @Override 174 public void run() { 175 scrollRectToVisible(visibleRect); 176 } 177 }); 167 SwingUtilities.invokeLater(() -> scrollRectToVisible(visibleRect)); 178 168 } 179 169 } -
trunk/src/org/openstreetmap/josm/gui/preferences/plugin/PluginPreference.java
r10482 r10611 150 150 sb.append("</html>"); 151 151 if (!GraphicsEnvironment.isHeadless()) { 152 GuiHelper.runInEDTAndWait(new Runnable() { 153 @Override 154 public void run() { 155 HelpAwareOptionPane.showOptionDialog( 156 parent, 157 sb.toString(), 158 tr("Update plugins"), 159 !failed.isEmpty() ? JOptionPane.WARNING_MESSAGE : JOptionPane.INFORMATION_MESSAGE, 160 HelpUtil.ht("/Preferences/Plugins") 161 ); 162 } 163 }); 152 GuiHelper.runInEDTAndWait(() -> HelpAwareOptionPane.showOptionDialog( 153 parent, 154 sb.toString(), 155 tr("Update plugins"), 156 !failed.isEmpty() ? JOptionPane.WARNING_MESSAGE : JOptionPane.INFORMATION_MESSAGE, 157 HelpUtil.ht("/Preferences/Plugins") 158 )); 164 159 } 165 160 } … … 318 313 public void readLocalPluginInformation() { 319 314 final ReadLocalPluginInformationTask task = new ReadLocalPluginInformationTask(); 320 Runnable r = new Runnable() { 321 @Override 322 public void run() { 323 if (!task.isCanceled()) { 324 SwingUtilities.invokeLater(new Runnable() { 325 @Override 326 public void run() { 327 model.setAvailablePlugins(task.getAvailablePlugins()); 328 pnlPluginPreferences.refreshView(); 329 } 330 }); 331 } 315 Runnable r = () -> { 316 if (!task.isCanceled()) { 317 SwingUtilities.invokeLater(() -> { 318 model.setAvailablePlugins(task.getAvailablePlugins()); 319 pnlPluginPreferences.refreshView(); 320 }); 332 321 } 333 322 }; … … 357 346 } 358 347 final ReadRemotePluginInformationTask task = new ReadRemotePluginInformationTask(pluginSites); 359 Runnable continuation = new Runnable() { 360 @Override 361 public void run() { 362 if (!task.isCanceled()) { 363 SwingUtilities.invokeLater(new Runnable() { 364 @Override 365 public void run() { 366 model.updateAvailablePlugins(task.getAvailablePlugins()); 367 pnlPluginPreferences.refreshView(); 368 Main.pref.putInteger("pluginmanager.version", Version.getInstance().getVersion()); // fix #7030 369 } 370 }); 371 } 348 Runnable continuation = () -> { 349 if (!task.isCanceled()) { 350 SwingUtilities.invokeLater(() -> { 351 model.updateAvailablePlugins(task.getAvailablePlugins()); 352 pnlPluginPreferences.refreshView(); 353 Main.pref.putInteger("pluginmanager.version", Version.getInstance().getVersion()); // fix #7030 354 }); 372 355 } 373 356 }; … … 389 372 protected void alertNothingToUpdate() { 390 373 try { 391 SwingUtilities.invokeAndWait(new Runnable() { 392 @Override 393 public void run() { 394 HelpAwareOptionPane.showOptionDialog( 395 pnlPluginPreferences, 396 tr("All installed plugins are up to date. JOSM does not have to download newer versions."), 397 tr("Plugins up to date"), 398 JOptionPane.INFORMATION_MESSAGE, 399 null // FIXME: provide help context 400 ); 401 } 402 }); 374 SwingUtilities.invokeAndWait(() -> HelpAwareOptionPane.showOptionDialog( 375 pnlPluginPreferences, 376 tr("All installed plugins are up to date. JOSM does not have to download newer versions."), 377 tr("Plugins up to date"), 378 JOptionPane.INFORMATION_MESSAGE, 379 null // FIXME: provide help context 380 )); 403 381 } catch (InterruptedException | InvocationTargetException e) { 404 382 Main.error(e); … … 421 399 // to be run asynchronously after the plugin download 422 400 // 423 final Runnable pluginDownloadContinuation = new Runnable() { 424 @Override 425 public void run() { 426 if (pluginDownloadTask.isCanceled()) 427 return; 428 boolean restartRequired = false; 429 for (PluginInformation pi : pluginDownloadTask.getDownloadedPlugins()) { 430 if (!model.getNewlyActivatedPlugins().contains(pi) || !pi.canloadatruntime) { 431 restartRequired = true; 432 break; 433 } 434 } 435 notifyDownloadResults(pnlPluginPreferences, pluginDownloadTask, restartRequired); 436 model.refreshLocalPluginVersion(pluginDownloadTask.getDownloadedPlugins()); 437 model.clearPendingPlugins(pluginDownloadTask.getDownloadedPlugins()); 438 GuiHelper.runInEDT(new Runnable() { 439 @Override 440 public void run() { 441 pnlPluginPreferences.refreshView(); 442 } 443 }); 444 } 401 final Runnable pluginDownloadContinuation = () -> { 402 if (pluginDownloadTask.isCanceled()) 403 return; 404 boolean restartRequired = false; 405 for (PluginInformation pi : pluginDownloadTask.getDownloadedPlugins()) { 406 if (!model.getNewlyActivatedPlugins().contains(pi) || !pi.canloadatruntime) { 407 restartRequired = true; 408 break; 409 } 410 } 411 notifyDownloadResults(pnlPluginPreferences, pluginDownloadTask, restartRequired); 412 model.refreshLocalPluginVersion(pluginDownloadTask.getDownloadedPlugins()); 413 model.clearPendingPlugins(pluginDownloadTask.getDownloadedPlugins()); 414 GuiHelper.runInEDT(pnlPluginPreferences::refreshView); 445 415 }; 446 416 447 417 // to be run asynchronously after the plugin list download 448 418 // 449 final Runnable pluginInfoDownloadContinuation = new Runnable() { 450 @Override 451 public void run() { 452 if (pluginInfoDownloadTask.isCanceled()) 453 return; 454 model.updateAvailablePlugins(pluginInfoDownloadTask.getAvailablePlugins()); 455 // select plugins which actually have to be updated 456 // 457 Iterator<PluginInformation> it = toUpdate.iterator(); 458 while (it.hasNext()) { 459 PluginInformation pi = it.next(); 460 if (!pi.isUpdateRequired()) { 461 it.remove(); 462 } 463 } 464 if (toUpdate.isEmpty()) { 465 alertNothingToUpdate(); 466 return; 467 } 468 pluginDownloadTask.setPluginsToDownload(toUpdate); 469 Main.worker.submit(pluginDownloadTask); 470 Main.worker.submit(pluginDownloadContinuation); 471 } 419 final Runnable pluginInfoDownloadContinuation = () -> { 420 if (pluginInfoDownloadTask.isCanceled()) 421 return; 422 model.updateAvailablePlugins(pluginInfoDownloadTask.getAvailablePlugins()); 423 // select plugins which actually have to be updated 424 // 425 Iterator<PluginInformation> it = toUpdate.iterator(); 426 while (it.hasNext()) { 427 PluginInformation pi = it.next(); 428 if (!pi.isUpdateRequired()) { 429 it.remove(); 430 } 431 } 432 if (toUpdate.isEmpty()) { 433 alertNothingToUpdate(); 434 return; 435 } 436 pluginDownloadTask.setPluginsToDownload(toUpdate); 437 Main.worker.submit(pluginDownloadTask); 438 Main.worker.submit(pluginDownloadContinuation); 472 439 }; 473 440 … … 476 443 } 477 444 } 478 479 445 480 446 /** … … 509 475 510 476 @Override 511 public void changedUpdate(DocumentEvent arg0) {477 public void changedUpdate(DocumentEvent evt) { 512 478 filter(); 513 479 } 514 480 515 481 @Override 516 public void insertUpdate(DocumentEvent arg0) {482 public void insertUpdate(DocumentEvent evt) { 517 483 filter(); 518 484 } 519 485 520 486 @Override 521 public void removeUpdate(DocumentEvent arg0) {487 public void removeUpdate(DocumentEvent evt) { 522 488 filter(); 523 489 } -
trunk/src/org/openstreetmap/josm/gui/preferences/plugin/PluginPreferencesModel.java
r10210 r10611 6 6 import java.util.Collection; 7 7 import java.util.Collections; 8 import java.util.Comparator;9 8 import java.util.HashMap; 10 9 import java.util.HashSet; … … 150 149 Collections.sort( 151 150 availablePlugins, 152 new Comparator<PluginInformation>() { 153 @Override 154 public int compare(PluginInformation o1, PluginInformation o2) { 155 String n1 = o1.getName() == null ? "" : o1.getName().toLowerCase(Locale.ENGLISH); 156 String n2 = o2.getName() == null ? "" : o2.getName().toLowerCase(Locale.ENGLISH); 157 return n1.compareTo(n2); 158 } 151 (o1, o2) -> { 152 String n1 = o1.getName() == null ? "" : o1.getName().toLowerCase(Locale.ENGLISH); 153 String n2 = o2.getName() == null ? "" : o2.getName().toLowerCase(Locale.ENGLISH); 154 return n1.compareTo(n2); 159 155 } 160 156 ); -
trunk/src/org/openstreetmap/josm/gui/preferences/projection/CustomProjectionChoice.java
r10242 r10611 7 7 import java.awt.GridBagLayout; 8 8 import java.awt.Insets; 9 import java.awt.event.ActionEvent;10 9 import java.awt.event.ActionListener; 11 10 import java.util.Arrays; … … 113 112 114 113 JButton btnCheck = new JButton(tr("Validate")); 115 btnCheck.addActionListener(new ActionListener() { 116 @Override 117 public void actionPerformed(ActionEvent e) { 118 val.validate(); 119 } 120 }); 114 btnCheck.addActionListener(e -> val.validate()); 121 115 btnCheck.setLayout(new BorderLayout()); 122 116 btnCheck.setMargin(new Insets(-1, 0, -1, 0)); 123 117 124 118 JButton btnInfo = new JButton(tr("Parameter information...")); 125 btnInfo.addActionListener(new ActionListener() { 126 @Override 127 public void actionPerformed(ActionEvent e) { 128 CustomProjectionChoice.ParameterInfoDialog dlg = new CustomProjectionChoice.ParameterInfoDialog(); 129 dlg.showDialog(); 130 dlg.toFront(); 131 } 119 btnInfo.addActionListener(e -> { 120 CustomProjectionChoice.ParameterInfoDialog dlg = new CustomProjectionChoice.ParameterInfoDialog(); 121 dlg.showDialog(); 122 dlg.toFront(); 132 123 }); 133 124 -
trunk/src/org/openstreetmap/josm/gui/preferences/projection/ProjectionPreference.java
r10310 r10611 6 6 import java.awt.Component; 7 7 import java.awt.GridBagLayout; 8 import java.awt.event.ActionEvent;9 8 import java.awt.event.ActionListener; 10 9 import java.util.ArrayList; … … 449 448 return; 450 449 451 final ActionListener listener = new ActionListener() { 452 @Override 453 public void actionPerformed(ActionEvent e) { 454 updateMeta(pc); 455 } 456 }; 450 final ActionListener listener = e -> updateMeta(pc); 457 451 458 452 // Replace old panel with new one … … 485 479 throw new RuntimeException("Couldn't find the current projection in the list of available projections!"); 486 480 487 projectionCombo.addActionListener(new ActionListener() { 488 @Override 489 public void actionPerformed(ActionEvent e) { 490 ProjectionChoice pc = (ProjectionChoice) projectionCombo.getSelectedItem(); 491 selectedProjectionChanged(pc); 492 } 481 projectionCombo.addActionListener(e -> { 482 ProjectionChoice pc1 = (ProjectionChoice) projectionCombo.getSelectedItem(); 483 selectedProjectionChanged(pc1); 493 484 }); 494 485 return pc; -
trunk/src/org/openstreetmap/josm/gui/preferences/remotecontrol/RemoteControlPreference.java
r9778 r10611 7 7 import java.awt.Font; 8 8 import java.awt.GridBagLayout; 9 import java.awt.event.ActionEvent;10 9 import java.awt.event.ActionListener; 11 10 import java.io.IOException; … … 120 119 wrapper.add(installCertificate, GBC.std().insets(5, 5, 0, 0)); 121 120 wrapper.add(uninstallCertificate, GBC.eol().insets(5, 5, 0, 0)); 122 enableHttpsSupport.addActionListener(new ActionListener() { 123 @Override 124 public void actionPerformed(ActionEvent e) { 125 installCertificate.setEnabled(enableHttpsSupport.isSelected()); 121 enableHttpsSupport.addActionListener(e -> installCertificate.setEnabled(enableHttpsSupport.isSelected())); 122 installCertificate.addActionListener(e -> { 123 try { 124 boolean changed = RemoteControlHttpsServer.setupPlatform( 125 RemoteControlHttpsServer.loadJosmKeystore()); 126 String msg = changed ? 127 tr("Certificate has been successfully installed.") : 128 tr("Certificate is already installed. Nothing to do."); 129 Main.info(msg); 130 JOptionPane.showMessageDialog(wrapper, msg); 131 } catch (IOException | GeneralSecurityException ex) { 132 Main.error(ex); 126 133 } 127 134 }); 128 installCertificate.addActionListener(new ActionListener() { 129 @Override 130 public void actionPerformed(ActionEvent e) { 131 try { 132 boolean changed = RemoteControlHttpsServer.setupPlatform( 133 RemoteControlHttpsServer.loadJosmKeystore()); 134 String msg = changed ? 135 tr("Certificate has been successfully installed.") : 136 tr("Certificate is already installed. Nothing to do."); 137 Main.info(msg); 138 JOptionPane.showMessageDialog(wrapper, msg); 139 } catch (IOException | GeneralSecurityException ex) { 140 Main.error(ex); 135 uninstallCertificate.addActionListener(e -> { 136 try { 137 String msg; 138 KeyStore ks = PlatformHookWindows.getRootKeystore(); 139 if (ks.containsAlias(RemoteControlHttpsServer.ENTRY_ALIAS)) { 140 Main.info(tr("Removing certificate {0} from root keystore.", RemoteControlHttpsServer.ENTRY_ALIAS)); 141 ks.deleteEntry(RemoteControlHttpsServer.ENTRY_ALIAS); 142 msg = tr("Certificate has been successfully uninstalled."); 143 } else { 144 msg = tr("Certificate is not installed. Nothing to do."); 141 145 } 142 } 143 }); 144 uninstallCertificate.addActionListener(new ActionListener() { 145 @Override 146 public void actionPerformed(ActionEvent e) { 147 try { 148 String msg; 149 KeyStore ks = PlatformHookWindows.getRootKeystore(); 150 if (ks.containsAlias(RemoteControlHttpsServer.ENTRY_ALIAS)) { 151 Main.info(tr("Removing certificate {0} from root keystore.", RemoteControlHttpsServer.ENTRY_ALIAS)); 152 ks.deleteEntry(RemoteControlHttpsServer.ENTRY_ALIAS); 153 msg = tr("Certificate has been successfully uninstalled."); 154 } else { 155 msg = tr("Certificate is not installed. Nothing to do."); 156 } 157 Main.info(msg); 158 JOptionPane.showMessageDialog(wrapper, msg); 159 } catch (KeyStoreException | NoSuchAlgorithmException | CertificateException | IOException ex) { 160 Main.error(ex); 161 } 146 Main.info(msg); 147 JOptionPane.showMessageDialog(wrapper, msg); 148 } catch (KeyStoreException | NoSuchAlgorithmException | CertificateException | IOException ex) { 149 Main.error(ex); 162 150 } 163 151 }); … … 181 169 alwaysAskUserConfirm.setSelected(Main.pref.getBoolean(RequestHandler.globalConfirmationKey, RequestHandler.globalConfirmationDefault)); 182 170 183 ActionListener remoteControlEnabled = new ActionListener() { 184 185 @Override 186 public void actionPerformed(ActionEvent e) { 187 GuiHelper.setEnabledRec(wrapper, enableRemoteControl.isSelected()); 188 // 'setEnabled(false)' does not work for JLabel with html text, so do it manually 189 // FIXME: use QuadStateCheckBox to make checkboxes unset when disabled 190 if (installCertificate != null && uninstallCertificate != null) { 191 // Install certificate button is enabled if HTTPS is also enabled 192 installCertificate.setEnabled(enableRemoteControl.isSelected() && enableHttpsSupport.isSelected()); 193 // Uninstall certificate button is always enabled 194 uninstallCertificate.setEnabled(true); 195 } 171 ActionListener remoteControlEnabled = e -> { 172 GuiHelper.setEnabledRec(wrapper, enableRemoteControl.isSelected()); 173 // 'setEnabled(false)' does not work for JLabel with html text, so do it manually 174 // FIXME: use QuadStateCheckBox to make checkboxes unset when disabled 175 if (installCertificate != null && uninstallCertificate != null) { 176 // Install certificate button is enabled if HTTPS is also enabled 177 installCertificate.setEnabled(enableRemoteControl.isSelected() && enableHttpsSupport.isSelected()); 178 // Uninstall certificate button is always enabled 179 uninstallCertificate.setEnabled(true); 196 180 } 197 181 }; -
trunk/src/org/openstreetmap/josm/gui/preferences/server/FeaturesPanel.java
r9073 r10611 10 10 import javax.swing.JLabel; 11 11 import javax.swing.JPanel; 12 import javax.swing.event.ChangeEvent;13 import javax.swing.event.ChangeListener;14 12 15 13 import org.openstreetmap.josm.actions.downloadtasks.DownloadNotesTask; … … 44 42 notifier = new JCheckBox(tr("Periodically check for new messages")); 45 43 add(notifier, GBC.eol()); 46 notifier.addChangeListener(new ChangeListener() { 47 @Override 48 public void stateChanged(ChangeEvent e) { 49 updateEnabledState(); 50 } 51 }); 44 notifier.addChangeListener(e -> updateEnabledState()); 52 45 53 46 intervalLabel = new JLabel(tr("Check interval (minutes):")); -
trunk/src/org/openstreetmap/josm/gui/preferences/server/OAuthAuthenticationPreferencesPanel.java
r10424 r10611 13 13 import java.awt.event.ActionEvent; 14 14 import java.awt.event.ItemEvent; 15 import java.awt.event.ItemListener;16 15 import java.beans.PropertyChangeEvent; 17 16 import java.beans.PropertyChangeListener; … … 78 77 cbShowAdvancedParameters.setSelected(false); 79 78 cbShowAdvancedParameters.addItemListener( 80 new ItemListener() { 81 @Override 82 public void itemStateChanged(ItemEvent evt) { 83 pnlAdvancedProperties.setVisible(evt.getStateChange() == ItemEvent.SELECTED); 84 } 85 } 79 evt -> pnlAdvancedProperties.setVisible(evt.getStateChange() == ItemEvent.SELECTED) 86 80 ); 87 81 -
trunk/src/org/openstreetmap/josm/gui/preferences/server/OsmApiUrlInputPanel.java
r10424 r10611 186 186 final ApiUrlTestTask task = new ApiUrlTestTask(OsmApiUrlInputPanel.this, url); 187 187 Main.worker.submit(task); 188 Runnable r = new Runnable() { 189 @Override 190 public void run() { 191 if (task.isCanceled()) 192 return; 193 Runnable r = new Runnable() { 194 @Override 195 public void run() { 196 if (task.isSuccess()) { 197 lblValid.setIcon(ImageProvider.get("dialogs", "valid")); 198 lblValid.setToolTipText(tr("The API URL is valid.")); 199 lastTestedUrl = url; 200 updateEnabledState(); 201 } else { 202 lblValid.setIcon(ImageProvider.get("warning-small")); 203 lblValid.setToolTipText(tr("Validation failed. The API URL seems to be invalid.")); 204 } 205 } 206 }; 207 SwingUtilities.invokeLater(r); 208 } 188 Runnable r = () -> { 189 if (task.isCanceled()) 190 return; 191 Runnable r1 = () -> { 192 if (task.isSuccess()) { 193 lblValid.setIcon(ImageProvider.get("dialogs", "valid")); 194 lblValid.setToolTipText(tr("The API URL is valid.")); 195 lastTestedUrl = url; 196 updateEnabledState(); 197 } else { 198 lblValid.setIcon(ImageProvider.get("warning-small")); 199 lblValid.setToolTipText(tr("Validation failed. The API URL seems to be invalid.")); 200 } 201 }; 202 SwingUtilities.invokeLater(r1); 209 203 }; 210 204 Main.worker.submit(r); -
trunk/src/org/openstreetmap/josm/gui/preferences/validator/ValidatorTestsPreference.java
r9778 r10611 5 5 6 6 import java.awt.GridBagLayout; 7 import java.awt.event.ActionEvent;8 7 import java.awt.event.ActionListener; 9 8 import java.util.ArrayList; … … 76 75 testPanel.add(prefOtherUpload, GBC.eol()); 77 76 78 ActionListener otherUploadEnabled = new ActionListener() { 79 @Override 80 public void actionPerformed(ActionEvent e) { 81 prefOtherUpload.setEnabled(prefOther.isSelected()); 82 } 83 }; 77 ActionListener otherUploadEnabled = e -> prefOtherUpload.setEnabled(prefOther.isSelected()); 84 78 prefOther.addActionListener(otherUploadEnabled); 85 79 otherUploadEnabled.actionPerformed(null);
Note:
See TracChangeset
for help on using the changeset viewer.