Changeset 30742 in osm for applications/editors/josm/plugins
- Timestamp:
- 2014-10-19T02:45:29+02:00 (10 years ago)
- Location:
- applications/editors/josm/plugins/trustosm/src
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/trustosm/src/org/openstreetmap/josm/plugins/trustosm/data/TrustSignatures.java
r30738 r30742 135 135 136 136 try (BCPGOutputStream bOut = new BCPGOutputStream(aOut)) { 137 138 139 137 for (PGPSignature sig : l) { 138 sig.encode(bOut); 139 } 140 140 } 141 141 … … 159 159 160 160 try (BCPGOutputStream bOut = new BCPGOutputStream(aOut)) { 161 161 sig.encode(bOut); 162 162 } 163 163 -
applications/editors/josm/plugins/trustosm/src/org/openstreetmap/josm/plugins/trustosm/gui/dialogs/TrustDialog.java
r30724 r30742 1 1 package org.openstreetmap.josm.plugins.trustosm.gui.dialogs; 2 2 3 import static org.openstreetmap.josm.tools.I18n.marktr;4 3 import static org.openstreetmap.josm.tools.I18n.tr; 5 4 6 5 import java.awt.BasicStroke; 7 import java.awt.BorderLayout;8 6 import java.awt.Color; 9 7 import java.awt.Component; 10 8 import java.awt.Font; 11 9 import java.awt.Graphics2D; 12 import java.awt.GridLayout;13 10 import java.awt.Point; 14 11 import java.awt.event.ActionEvent; 15 import java.awt.event.ActionListener;16 12 import java.awt.event.FocusEvent; 17 13 import java.awt.event.FocusListener; 18 14 import java.awt.event.KeyEvent; 19 15 import java.awt.geom.GeneralPath; 16 import java.util.ArrayList; 20 17 import java.util.Arrays; 21 import java.util.ArrayList;22 18 import java.util.Collection; 23 19 import java.util.HashMap; 24 20 import java.util.List; 25 21 import java.util.Map; 22 import java.util.Map.Entry; 26 23 import java.util.TreeMap; 27 import java.util.Map.Entry;28 24 29 25 import javax.swing.BoxLayout; 30 26 import javax.swing.JLabel; 31 27 import javax.swing.JPanel; 32 import javax.swing.JScrollPane;33 28 import javax.swing.JTable; 34 29 import javax.swing.JTree; … … 44 39 45 40 import org.openstreetmap.josm.Main; 41 import org.openstreetmap.josm.actions.JosmAction; 46 42 import org.openstreetmap.josm.data.Bounds; 47 43 import org.openstreetmap.josm.data.SelectionChangedListener; … … 68 64 import org.openstreetmap.josm.tools.Shortcut; 69 65 70 public class TrustDialog extends ToggleDialog implements ActionListener, SelectionChangedListener, MapViewPaintable { 71 72 /** 73 * 74 */ 75 private static final long serialVersionUID = -3324984194315776740L; 76 66 public class TrustDialog extends ToggleDialog implements SelectionChangedListener, MapViewPaintable { 77 67 78 68 public final static Color BGCOLOR_NO_SIG = new Color(234, 234, 234); … … 83 73 public final static Color BGCOLOR_UPDATED_ITEM = new Color(249,221,95); 84 74 85 86 75 /** Use a TrustGPGPreparer to sign or validate signatures */ 87 76 //private final TrustGPGPreparer gpg; … … 101 90 private Collection<? extends OsmPrimitive> osmData; 102 91 103 104 92 private final List<WaySegment> selectedSegments = new ArrayList<>(); 105 93 private final List<OsmPrimitive> selectedPrimitives = new ArrayList<>(); … … 107 95 /** The JTree for showing the geometry */ 108 96 private final JTree geomTree; 109 110 97 111 98 /** … … 113 100 */ 114 101 private final DefaultTableModel propertyData = new DefaultTableModel() { 115 /**116 *117 */118 private static final long serialVersionUID = -1252801283184909691L;119 102 @Override public boolean isCellEditable(int row, int column) { 120 103 return false; … … 125 108 }; 126 109 private final JTable propertyTable = new JTable(propertyData) { 127 /**128 *129 */130 private static final long serialVersionUID = 1L;131 110 132 111 @Override … … 146 125 147 126 /** The JTable for members of a relation */ 148 private final DefaultTableModel memberData = new DefaultTableModel() { 149 150 /** 151 * 152 */ 153 private static final long serialVersionUID = 1L; 127 /*private final DefaultTableModel memberData = new DefaultTableModel() { 128 154 129 @Override public boolean isCellEditable(int row, int column) { 155 130 return false; … … 160 135 }; 161 136 private final JTable memberTable = new JTable(memberData) { 162 /**163 *164 */165 private static final long serialVersionUID = 1L;166 137 167 138 @Override … … 178 149 return c; 179 150 } 180 }; 181 151 };*/ 182 152 183 153 /** … … 198 168 propertyTable.getColumnModel().getColumn(1).setCellRenderer(new DefaultTableCellRenderer(){ 199 169 /** 200 * 170 * 201 171 */ 202 172 private static final long serialVersionUID = 8003207668070727861L; … … 232 202 geomTree.setCellRenderer(new DefaultTreeCellRenderer(){ 233 203 234 /**235 *236 */237 private static final long serialVersionUID = -3070210847060314196L;238 239 204 @Override 240 205 public Component getTreeCellRendererComponent(JTree tree, Object value, … … 253 218 setText(osm.getDisplayName(DefaultNameFormatter.getInstance())); 254 219 255 256 220 if (osm instanceof Node) { 257 Node osmNode = (Node) osm;258 221 TrustSignatures sigs; 259 222 String id = TrustOsmPrimitive.createUniqueObjectIdentifier(osm); … … 289 252 return this; 290 253 } 291 292 293 254 }); 294 255 295 256 geomTree.addTreeSelectionListener(new TreeSelectionListener() { 257 @Override 296 258 public void valueChanged(TreeSelectionEvent e) { 297 259 // unhighlight everything … … 328 290 329 291 } 330 331 292 }); 332 293 … … 343 304 344 305 } 345 346 306 }); 347 307 … … 353 313 dataPanel.add(geomTree); 354 314 355 checkButton = new SideButton(marktr("Check"), "checksignatures", "TrustOSM", 356 tr("Check all available signatures for selected object."), this); 357 signButton = new SideButton(marktr("Sign"), "sign", "TrustOSM", 358 tr("Digital sign selected Tags, if you believe they are correct."), this); 359 showButton = new SideButton(marktr("Show"), "showsig", "TrustOSM", 360 tr("Show all available signatures for selected attribute."), this); 315 checkButton = new SideButton(new CheckAction()); 316 signButton = new SideButton(new SignAction()); 317 showButton = new SideButton(new ShowAction()); 361 318 362 319 createLayout(dataPanel, true, Arrays.asList(new SideButton[] { … … 366 323 } 367 324 368 @Override 369 public void actionPerformed(ActionEvent e) { 370 String actionCommand = e.getActionCommand(); 371 if (actionCommand.equals("Check")) { 325 private class CheckAction extends JosmAction { 326 327 public CheckAction() { 328 super(tr("Check"), "checksignatures", tr("Check all available signatures for selected object."), null, false); 329 } 330 331 @Override 332 public void actionPerformed(ActionEvent e) { 372 333 for (OsmPrimitive osm : osmData) { 373 334 String id = TrustOsmPrimitive.createUniqueObjectIdentifier(osm); … … 378 339 updateTable(); 379 340 geomTree.repaint(); 380 } else if (actionCommand.equals("Sign")) { 341 } 342 } 343 344 private class SignAction extends JosmAction { 345 346 public SignAction() { 347 super(tr("Sign"), "sign", tr("Digital sign selected Tags, if you believe they are correct."), null, false); 348 } 349 350 @Override 351 public void actionPerformed(ActionEvent e) { 381 352 for (int i : propertyTable.getSelectedRows()) { 382 353 String key = (String)propertyTable.getValueAt(i, 0); … … 439 410 updateTable(); 440 411 geomTree.repaint(); 441 } else if (actionCommand.equals("Show")) { 412 } 413 } 414 415 private class ShowAction extends JosmAction { 416 417 public ShowAction() { 418 super(tr("Show"), "showsig", tr("Show all available signatures for selected attribute."), null, false); 419 } 420 421 @Override 422 public void actionPerformed(ActionEvent e) { 442 423 for (int i : propertyTable.getSelectedRows()) { 443 424 String key = (String)propertyTable.getValueAt(i, 0); … … 449 430 } 450 431 } 451 if (geomTree.getSelectionPaths()!=null) 432 if (geomTree.getSelectionPaths()!=null) { 452 433 for (TreePath tp : geomTree.getSelectionPaths()) { 453 434 Object o = ((DefaultMutableTreeNode) tp.getLastPathComponent()).getUserObject(); … … 473 454 } 474 455 } 475 476 } 477 } 456 } 457 } 458 } 459 478 460 /* 479 461 public void showSignaturesDialog(TrustOSMItem trust, String key) { … … 557 539 558 540 } 559 560 541 } 561 542 562 543 return new DefaultTreeModel(root); 563 564 544 } 565 545 … … 663 643 if (Main.map.mapView == null) return; 664 644 665 666 645 Graphics2D g2 = g; 667 646 g2.setColor(PaintColors.HIGHLIGHT.get()); … … 680 659 g2.setStroke(new BasicStroke(1)); 681 660 } 682 683 661 } -
applications/editors/josm/plugins/trustosm/src/org/openstreetmap/josm/plugins/trustosm/gui/dialogs/TrustPreferenceEditor.java
r30724 r30742 16 16 17 17 import org.openstreetmap.josm.Main; 18 import org.openstreetmap.josm.gui.preferences. PreferenceSetting;18 import org.openstreetmap.josm.gui.preferences.DefaultTabPreferenceSetting; 19 19 import org.openstreetmap.josm.gui.preferences.PreferenceTabbedPane; 20 20 import org.openstreetmap.josm.plugins.trustosm.TrustOSMplugin; 21 21 import org.openstreetmap.josm.tools.GBC; 22 22 23 public class TrustPreferenceEditor implementsPreferenceSetting {23 public class TrustPreferenceEditor extends DefaultTabPreferenceSetting { 24 24 25 25 private final JCheckBox showSignedDeleted = new JCheckBox(tr("Show deleted tags and notes if they were signed before")); … … 27 27 private final JRadioButton separateHomedir = new JRadioButton(tr("Use separate GnuPG directory ({0}) to store new keys and configs.", TrustOSMplugin.getGpgPath())); 28 28 29 public TrustPreferenceEditor() { 30 super("trustosm", tr("Trust OSM Settings"), tr("Change GPG and privacy settings of the trustosm plugin.")); 31 } 32 29 33 @Override 30 34 public void addGui(final PreferenceTabbedPane gui) { 31 // TODO Auto-generated method stub 32 JPanel p = gui.createPreferenceTab("trustosm", tr("Trust OSM Settings"), tr("Change GPG and privacy settings of the trustosm plugin.")); 35 JPanel p = gui.createPreferenceTab(this); 33 36 JTabbedPane tabs = new JTabbedPane(); 34 37 p.add(tabs, GBC.eol().fill(GBC.BOTH)); 35 36 38 37 39 JPanel gpgsettings = new JPanel(new GridBagLayout()); … … 52 54 gpgsettings.add(defaultHomedir, GBC.eol().insets(40,0,0,0)); 53 55 54 55 56 gpgsettings.add(Box.createVerticalGlue(), GBC.eol().fill(GBC.BOTH)); 56 57 JScrollPane scrollpane = new JScrollPane(gpgsettings); … … 58 59 tabs.add(tr("GnuPG"), scrollpane); 59 60 60 61 61 JPanel dialogsettings = new JPanel(new GridBagLayout()); 62 62 tabs.add(tr("Dialog"), dialogsettings); 63 63 dialogsettings.add(showSignedDeleted, GBC.eol().fill(GBC.HORIZONTAL).insets(20,0,0,5)); 64 65 64 } 66 65 … … 72 71 return false; 73 72 } 74 75 76 73 } -
applications/editors/josm/plugins/trustosm/src/org/openstreetmap/josm/plugins/trustosm/util/NameGenerator.java
r30738 r30742 85 85 */ 86 86 public void refresh() throws IOException{ 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 87 try ( 88 FileReader input = new FileReader(fileName); 89 BufferedReader bufRead = new BufferedReader(input); 90 ) { 91 String line=""; 92 while (line != null){ 93 line = bufRead.readLine(); 94 if (line != null && !line.equals("")) { 95 if(line.charAt(0) == '-') { 96 pre.add(line.substring(1).toLowerCase()); 97 } else if (line.charAt(0) == '+') { 98 sur.add(line.substring(1).toLowerCase()); 99 } else { 100 mid.add(line.toLowerCase()); 101 } 102 } 103 } 104 } 105 105 } 106 106 -
applications/editors/josm/plugins/trustosm/src/org/openstreetmap/josm/plugins/trustosm/util/TrustGPG.java
r30724 r30742 281 281 282 282 public void writeGpgFiles() throws FileNotFoundException, IOException { 283 283 String path = Main.pref.getPluginsDirectory().getPath(); 284 284 try (FileOutputStream pubOut = new FileOutputStream(path + "/trustosm/gnupg/pubring.gpg"); 285 285 FileOutputStream secOut = new FileOutputStream(path + "/trustosm/gnupg/secring.gpg")) { 286 287 288 289 286 pgpSec.encode(secOut); 287 pgpPub.encode(pubOut); 288 pubOut.flush(); 289 secOut.flush(); 290 290 } 291 291 } -
applications/editors/josm/plugins/trustosm/src/tools/NameGenerator.java
r30738 r30742 86 86 public void refresh() throws IOException{ 87 87 try ( 88 89 88 FileReader input = new FileReader(fileName); 89 BufferedReader bufRead = new BufferedReader(input); 90 90 ) { 91 92 93 94 95 96 97 98 99 100 101 102 103 104 91 String line=""; 92 93 while (line != null) { 94 line = bufRead.readLine(); 95 if (line != null && !line.equals("")) { 96 if (line.charAt(0) == '-') { 97 pre.add(line.substring(1).toLowerCase()); 98 } else if (line.charAt(0) == '+') { 99 sur.add(line.substring(1).toLowerCase()); 100 } else{ 101 mid.add(line.toLowerCase()); 102 } 103 } 104 } 105 105 } 106 106 }
Note:
See TracChangeset
for help on using the changeset viewer.