Changeset 8510 in josm for trunk/src/org/openstreetmap/josm/gui/preferences/advanced/AdvancedPreference.java
- Timestamp:
- 2015-06-20T23:42:21+02:00 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/preferences/advanced/AdvancedPreference.java
r8469 r8510 90 90 p.add(lbFilter); 91 91 p.add(txtFilter, GBC.eol().fill(GBC.HORIZONTAL)); 92 txtFilter.getDocument().addDocumentListener(new DocumentListener(){ 93 @Override public void changedUpdate(DocumentEvent e) { 92 txtFilter.getDocument().addDocumentListener(new DocumentListener() { 93 @Override 94 public void changedUpdate(DocumentEvent e) { 94 95 action(); 95 96 } 96 @Override public void insertUpdate(DocumentEvent e) { 97 98 @Override 99 public void insertUpdate(DocumentEvent e) { 97 100 action(); 98 101 } 99 @Override public void removeUpdate(DocumentEvent e) { 102 103 @Override 104 public void removeUpdate(DocumentEvent e) { 100 105 action(); 101 106 } 107 102 108 private void action() { 103 109 applyFilter(); … … 110 116 JScrollPane scroll = new JScrollPane(table); 111 117 p.add(scroll, GBC.eol().fill(GBC.BOTH)); 112 scroll.setPreferredSize(new Dimension(400, 200));118 scroll.setPreferredSize(new Dimension(400, 200)); 113 119 114 120 JButton add = new JButton(tr("Add")); 115 121 p.add(Box.createHorizontalGlue(), GBC.std().fill(GBC.HORIZONTAL)); 116 p.add(add, GBC.std().insets(0, 5,0,0));117 add.addActionListener(new ActionListener() {122 p.add(add, GBC.std().insets(0, 5, 0, 0)); 123 add.addActionListener(new ActionListener() { 118 124 @Override public void actionPerformed(ActionEvent e) { 119 125 PrefEntry pe = table.addPreference(gui); 120 if (pe !=null) {126 if (pe != null) { 121 127 allData.add(pe); 122 128 Collections.sort(allData); … … 127 133 128 134 JButton edit = new JButton(tr("Edit")); 129 p.add(edit, GBC.std().insets(5, 5,5,0));130 edit.addActionListener(new ActionListener() {135 p.add(edit, GBC.std().insets(5, 5, 5, 0)); 136 edit.addActionListener(new ActionListener() { 131 137 @Override public void actionPerformed(ActionEvent e) { 132 138 boolean ok = table.editPreference(gui); … … 136 142 137 143 JButton reset = new JButton(tr("Reset")); 138 p.add(reset, GBC.std().insets(0, 5,0,0));139 reset.addActionListener(new ActionListener() {144 p.add(reset, GBC.std().insets(0, 5, 0, 0)); 145 reset.addActionListener(new ActionListener() { 140 146 @Override public void actionPerformed(ActionEvent e) { 141 147 table.resetPreferences(gui); … … 144 150 145 151 JButton read = new JButton(tr("Read from file")); 146 p.add(read, GBC.std().insets(5, 5,0,0));147 read.addActionListener(new ActionListener() {152 p.add(read, GBC.std().insets(5, 5, 0, 0)); 153 read.addActionListener(new ActionListener() { 148 154 @Override public void actionPerformed(ActionEvent e) { 149 155 readPreferencesFromXML(); … … 152 158 153 159 JButton export = new JButton(tr("Export selected items")); 154 p.add(export, GBC.std().insets(5, 5,0,0));155 export.addActionListener(new ActionListener() {160 p.add(export, GBC.std().insets(5, 5, 0, 0)); 161 export.addActionListener(new ActionListener() { 156 162 @Override public void actionPerformed(ActionEvent e) { 157 163 exportSelectedToXML(); … … 160 166 161 167 final JButton more = new JButton(tr("More...")); 162 p.add(more, GBC.std().insets(5, 5,0,0));168 p.add(more, GBC.std().insets(5, 5, 0, 0)); 163 169 more.addActionListener(new ActionListener() { 164 170 private JPopupMenu menu = buildPopupMenu(); … … 180 186 // so we do not want to show it in the table as "changed" now 181 187 Setting<?> pluginSetting = orig.get("plugins"); 182 if (pluginSetting !=null) {188 if (pluginSetting != null) { 183 189 loaded.put("plugins", pluginSetting); 184 190 } … … 195 201 return f.isDirectory() || Utils.hasExtension(f, "xml"); 196 202 } 203 197 204 @Override 198 205 public String getDescription() { … … 204 211 if (fc != null) { 205 212 File[] sel = fc.isMultiSelectionEnabled() ? fc.getSelectedFiles() : (new File[]{fc.getSelectedFile()}); 206 if (sel.length ==1 && !sel[0].getName().contains(".")) sel[0]=new File(sel[0].getAbsolutePath()+".xml");213 if (sel.length == 1 && !sel[0].getName().contains(".")) sel[0] = new File(sel[0].getAbsolutePath()+".xml"); 207 214 return sel; 208 215 } … … 314 321 } 315 322 316 private Map<String, String> profileTypes = new LinkedHashMap<>();323 private Map<String, String> profileTypes = new LinkedHashMap<>(); 317 324 318 325 private JPopupMenu buildPopupMenu() { … … 323 330 profileTypes.put(marktr("imagery"), "imagery.*"); 324 331 325 for (Entry<String, String> e: profileTypes.entrySet()) {332 for (Entry<String, String> e: profileTypes.entrySet()) { 326 333 menu.add(new ExportProfileAction(Main.pref, e.getKey(), e.getValue())); 327 334 } … … 354 361 355 362 private JMenu getProfileMenu() { 356 final JMenu p = new JMenu(tr("Load profile"));363 final JMenu p = new JMenu(tr("Load profile")); 357 364 p.addMenuListener(new MenuListener() { 358 365 @Override … … 364 371 String s = f.getName(); 365 372 int idx = s.indexOf('_'); 366 if (idx >=0) {367 String t =s.substring(0,idx);373 if (idx >= 0) { 374 String t = s.substring(0, idx); 368 375 if (profileTypes.containsKey(t)) { 369 376 p.add(new ImportProfileAction(s, f, t)); … … 377 384 String s = f.getName(); 378 385 int idx = s.indexOf('_'); 379 if (idx >=0) {380 String t =s.substring(0,idx);386 if (idx >= 0) { 387 String t = s.substring(0, idx); 381 388 if (profileTypes.containsKey(t)) { 382 389 p.add(new ImportProfileAction(s, f, t)); … … 386 393 } 387 394 } 395 388 396 @Override 389 397 public void menuDeselected(MenuEvent me) { 390 398 // Not implemented 391 399 } 400 392 401 @Override 393 402 public void menuCanceled(MenuEvent me) { … … 450 459 } 451 460 } 452 if (table !=null) table.fireDataChanged();461 if (table != null) table.fireDataChanged(); 453 462 } 454 463
Note:
See TracChangeset
for help on using the changeset viewer.