Changeset 30738 in osm for applications/editors/josm/plugins/roadsigns
- Timestamp:
- 2014-10-19T01:27:04+02:00 (10 years ago)
- Location:
- applications/editors/josm/plugins/roadsigns/src/org/openstreetmap/josm/plugins/roadsigns
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/roadsigns/src/org/openstreetmap/josm/plugins/roadsigns/RoadSignInputDialog.java
r30737 r30738 68 68 import org.openstreetmap.josm.gui.ExtendedDialog; 69 69 import org.openstreetmap.josm.gui.widgets.MultiSplitLayout; 70 import org.openstreetmap.josm.gui.widgets.MultiSplitLayout.Node; 70 71 import org.openstreetmap.josm.gui.widgets.MultiSplitPane; 71 import org.openstreetmap.josm.gui.widgets.MultiSplitLayout.Node;72 72 import org.openstreetmap.josm.plugins.roadsigns.RoadSignsPlugin.PresetMetaData; 73 73 import org.openstreetmap.josm.plugins.roadsigns.Sign.SignParameter; … … 103 103 protected JEditorPane info; 104 104 protected JScrollPane scrollInfo; 105 105 106 106 private MultiSplitPane multiSplitPane; 107 107 … … 150 150 Node model = multiSplitPane.getMultiSplitLayout().getModel(); 151 151 File f = new File(RoadSignsPlugin.pluginDir(), "roadsigns-layout.xml"); 152 try {152 try ( 153 153 XMLEncoder xmlenc = new XMLEncoder( 154 154 new BufferedOutputStream(new FileOutputStream(f)) 155 ) ;155 )) { 156 156 xmlenc.writeObject(model); 157 xmlenc.close();158 157 } catch (FileNotFoundException ex) { 159 158 Main.warn("unable to write dialog layout: "+ex); … … 163 162 super.setVisible(visible); 164 163 } 165 166 164 167 165 private Command createCommand(Collection<OsmPrimitive> selPrim) { … … 198 196 199 197 multiSplitPane = new MultiSplitPane(); 200 try { 201 File f = new File(RoadSignsPlugin.pluginDir(), "roadsigns-layout.xml"); 202 XMLDecoder decoder = new XMLDecoder(new BufferedInputStream(new FileInputStream(f))); 198 File f = new File(RoadSignsPlugin.pluginDir(), "roadsigns-layout.xml"); 199 try (XMLDecoder decoder = new XMLDecoder(new BufferedInputStream(new FileInputStream(f)))) { 203 200 Node model = (Node) decoder.readObject(); 204 decoder.close();205 201 multiSplitPane.getMultiSplitLayout().setModel(model); 206 202 multiSplitPane.getMultiSplitLayout().setFloatingDividers(false); 207 } 208 catch (Exception ex) { 203 } catch (Exception ex) { 209 204 Node modelRoot = MultiSplitLayout.parseModel(layoutDef); 210 205 multiSplitPane.getMultiSplitLayout().setModel(modelRoot); … … 225 220 info.setBackground(this.getBackground()); 226 221 info.addHyperlinkListener(new HyperlinkListener() { 227 public void hyperlinkUpdate(HyperlinkEvent e) { 222 @Override 223 public void hyperlinkUpdate(HyperlinkEvent e) { 228 224 if (e == null || e.getURL() == null) 229 225 return; 230 System.out.println(e.getURL());231 226 if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { 232 227 OpenBrowser.displayUrl(e.getURL().toString()); … … 472 467 } 473 468 class TFDocumentListener implements DocumentListener { 474 public void insertUpdate(DocumentEvent e) { 469 @Override 470 public void insertUpdate(DocumentEvent e) { 475 471 update(); 476 472 } 477 473 478 public void removeUpdate(DocumentEvent e) { 474 @Override 475 public void removeUpdate(DocumentEvent e) { 479 476 update(); 480 477 } 481 478 482 public void changedUpdate(DocumentEvent e) { 479 @Override 480 public void changedUpdate(DocumentEvent e) { 483 481 update(); 484 482 } … … 540 538 String[][] data = {{}}; 541 539 previewTable = new JTable(data, columnNames) { 542 public String getToolTipText(MouseEvent e) { 540 @Override 541 public String getToolTipText(MouseEvent e) { 543 542 int rowIndex = rowAtPoint(e.getPoint()); 544 543 int colIndex = columnAtPoint(e.getPoint()); … … 564 563 addTrafficSignTag.setSelected(Main.pref.getBoolean("plugin.roadsigns.addTrafficSignTag")); 565 564 addTrafficSignTag.addActionListener(new ActionListener() { 566 public void actionPerformed(ActionEvent e) { 565 @Override 566 public void actionPerformed(ActionEvent e) { 567 567 previewModel.update(); 568 568 } … … 581 581 String[] header = {tr("Key"), tr("Value")}; 582 582 583 public int getRowCount() { 583 @Override 584 public int getRowCount() { 584 585 return keys.size(); 585 586 } 586 587 587 public int getColumnCount() { 588 @Override 589 public int getColumnCount() { 588 590 return 2; 589 591 } 590 592 591 public Object getValueAt(int rowIndex, int columnIndex) { 593 @Override 594 public Object getValueAt(int rowIndex, int columnIndex) { 592 595 if (columnIndex == 0) { 593 596 return keys.get(rowIndex); … … 758 761 /* scroll up again */ 759 762 SwingUtilities.invokeLater(new Runnable(){ 760 public void run() { 763 @Override 764 public void run() { 761 765 scrollInfo.getVerticalScrollBar().setValue(0); 762 766 } … … 818 822 } 819 823 820 public Dimension getPreferredScrollableViewportSize() { 824 @Override 825 public Dimension getPreferredScrollableViewportSize() { 821 826 return super.getPreferredSize(); 822 827 } 823 828 824 public int getScrollableUnitIncrement( Rectangle visibleRect, int orientation, int direction ) { 829 @Override 830 public int getScrollableUnitIncrement( Rectangle visibleRect, int orientation, int direction ) { 825 831 final int FRAC = 20; 826 832 int inc = (orientation == SwingConstants.VERTICAL ? getParent().getHeight() : getParent().getWidth()) / FRAC; … … 828 834 } 829 835 830 public int getScrollableBlockIncrement( Rectangle visibleRect, int orientation, int direction ) { 836 @Override 837 public int getScrollableBlockIncrement( Rectangle visibleRect, int orientation, int direction ) { 831 838 return orientation == SwingConstants.VERTICAL ? getParent().getHeight() : getParent().getWidth(); 832 839 } 833 840 834 public boolean getScrollableTracksViewportWidth() { 841 @Override 842 public boolean getScrollableTracksViewportWidth() { 835 843 return true; 836 844 } 837 845 838 public boolean getScrollableTracksViewportHeight() { 846 @Override 847 public boolean getScrollableTracksViewportHeight() { 839 848 return false; 840 849 } -
applications/editors/josm/plugins/roadsigns/src/org/openstreetmap/josm/plugins/roadsigns/RoadSignsPlugin.java
r30737 r30738 24 24 import javax.swing.JOptionPane; 25 25 26 import org.xml.sax.SAXException;27 26 import org.openstreetmap.josm.Main; 28 27 import org.openstreetmap.josm.actions.JosmAction; … … 36 35 import org.openstreetmap.josm.tools.Shortcut; 37 36 import org.openstreetmap.josm.tools.Utils; 37 import org.xml.sax.SAXException; 38 38 39 39 public class RoadSignsPlugin extends Plugin { … … 79 79 } 80 80 81 public void actionPerformed(ActionEvent e) { 81 @Override 82 public void actionPerformed(ActionEvent e) { 82 83 String code = Main.pref.get("plugin.roadsigns.preset.selection", null); 83 84 if (code == null) { … … 241 242 * Returns an inputstream from urls, files and classloaders, depending on the name. 242 243 */ 243 public static InputStream getInputStream(String source) throws IOException { 244 @SuppressWarnings("resource") 245 public static InputStream getInputStream(String source) throws IOException { 244 246 InputStream in = null; 245 247 if (source.startsWith("http://") || source.startsWith("https://") || source.startsWith("ftp://")) {
Note:
See TracChangeset
for help on using the changeset viewer.