Changeset 22684 in osm for applications
- Timestamp:
- 2010-08-18T22:23:10+02:00 (14 years ago)
- Location:
- applications/editors/josm/plugins/openstreetbugs
- Files:
-
- 1 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/openstreetbugs/src/org/openstreetmap/josm/plugins/osb/OsbPlugin.java
r20682 r22684 79 79 newFrame.addToggleDialog(dialog); 80 80 81 MapView.addLayerChangeListener(dialog);82 81 MapView.addLayerChangeListener(this); 83 82 84 83 uploadHook = new OsbUploadHook(); 85 84 UploadAction.registerUploadHook(uploadHook); … … 163 162 // store the current selected node 164 163 Node selectedNode = getDialog().getSelectedNode(); 165 164 166 165 // determine the bounds of the currently visible area 167 166 Bounds bounds = null; … … 179 178 // download the data 180 179 download.execute(dataSet, bounds); 181 180 182 181 // display the parsed data 183 182 if(!dataSet.getNodes().isEmpty() && dialog.isDialogShowing()) { … … 194 193 } 195 194 } 196 195 197 196 // restore node selection 198 197 dialog.setSelectedNode(selectedNode); -
applications/editors/josm/plugins/openstreetbugs/src/org/openstreetmap/josm/plugins/osb/gui/OsbDialog.java
r22466 r22684 71 71 import org.openstreetmap.josm.data.osm.event.TagsChangedEvent; 72 72 import org.openstreetmap.josm.data.osm.event.WayNodesChangedEvent; 73 import org.openstreetmap.josm.gui.MapView; 73 74 import org.openstreetmap.josm.gui.MapView.LayerChangeListener; 74 75 import org.openstreetmap.josm.gui.dialogs.ToggleDialog; … … 88 89 import org.openstreetmap.josm.tools.Shortcut; 89 90 90 public class OsbDialog extends ToggleDialog implements OsbObserver, ListSelectionListener, LayerChangeListener, 91 public class OsbDialog extends ToggleDialog implements OsbObserver, ListSelectionListener, LayerChangeListener, 91 92 DataSetListener, SelectionChangedListener, MouseListener, OsbActionObserver { 92 93 … … 106 107 private JTabbedPane tabbedPane = new JTabbedPane(); 107 108 private boolean queuePanelVisible = false; 109 private final ActionQueue actionQueue = new ActionQueue(); 108 110 109 111 private boolean buttonLabels = Main.pref.getBoolean(ConfigKeys.OSB_BUTTON_LABELS); … … 185 187 queuePanel = new JPanel(new BorderLayout()); 186 188 queuePanel.setName(tr("Queue")); 187 queueList = new JList( ActionQueue.getInstance());189 queueList = new JList(getActionQueue()); 188 190 queueList.setCellRenderer(new OsbQueueListCellRenderer()); 189 191 queuePanel.add(new JScrollPane(queueList), BorderLayout.CENTER); … … 194 196 setConnectionMode(false); 195 197 try { 196 ActionQueue.getInstance().processQueue();198 getActionQueue().processQueue(); 197 199 198 200 // refresh, if the api is enabled … … 225 227 closeIssueAction.addActionObserver(this); 226 228 setConnectionMode(offline); 227 DataSet.selListeners.add(this); 229 230 231 MapView.addLayerChangeListener(this); 232 } 233 234 @Override 235 public void showNotify() { 236 DataSet.addSelectionListener(this); 237 } 238 239 @Override 240 public void hideNotify() { 241 DataSet.removeSelectionListener(this); 242 } 243 244 @Override 245 public void destroy() { 246 super.destroy(); 247 MapView.removeLayerChangeListener(this); 248 228 249 } 229 250 … … 346 367 } 347 368 348 private class BugComparator implements Comparator<Node> {369 private static class BugComparator implements Comparator<Node> { 349 370 350 371 public int compare(Node o1, Node o2) { … … 445 466 if(osbPlugin.getLayer() != null && osbPlugin.getLayer().getDataSet() != null 446 467 && osbPlugin.getLayer().getDataSet().getNodes() != null 447 && osbPlugin.getLayer().getDataSet().getNodes().contains(selectedNode)) 468 && osbPlugin.getLayer().getDataSet().getNodes().contains(selectedNode)) 448 469 { 449 470 setSelectedNode(selectedNode); … … 455 476 } 456 477 } 478 479 public ActionQueue getActionQueue() { 480 return actionQueue; 481 } 457 482 } -
applications/editors/josm/plugins/openstreetbugs/src/org/openstreetmap/josm/plugins/osb/gui/action/ActionQueue.java
r19282 r22684 7 7 public class ActionQueue extends AbstractListModel { 8 8 9 private static ActionQueue instance;10 11 9 private LinkedList<OsbAction> queue = new LinkedList<OsbAction>(); 12 13 private ActionQueue() {}14 15 public static synchronized ActionQueue getInstance() {16 if(instance == null) {17 instance = new ActionQueue();18 }19 return instance;20 }21 10 22 11 public boolean offer(OsbAction e) { … … 51 40 // execute the action 52 41 action.execute(); 53 42 54 43 // notify observers 55 44 for (OsbActionObserver obs : action.getActionObservers()) { -
applications/editors/josm/plugins/openstreetbugs/src/org/openstreetmap/josm/plugins/osb/gui/action/OsbAction.java
r19282 r22684 49 49 50 50 private List<OsbActionObserver> observers = new ArrayList<OsbActionObserver>(); 51 52 protected OsbDialog dialog;53 51 52 protected final OsbDialog dialog; 53 54 54 protected boolean cancelled = false; 55 protected final ActionQueue actionQueue; 55 56 56 57 public OsbAction(String name, OsbDialog osbDialog) { 57 58 super(name); 58 59 this.dialog = osbDialog; 60 this.actionQueue = osbDialog.getActionQueue(); 59 61 } 60 62 … … 71 73 } else { 72 74 OsbAction action = clone(); 73 ActionQueue.getInstance().offer(action);75 actionQueue.offer(action); 74 76 } 75 77 } … … 89 91 observers.remove(obs); 90 92 } 91 93 92 94 protected String addMesgInfo(String msg) { 93 95 // get the user nickname … … 101 103 } 102 104 } 103 105 104 106 // concatenate nickname and date, if date should be included 105 107 String info = nickname; … … 108 110 DateFormat df = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.LONG, Locale.getDefault()); 109 111 String date = df.format(new Date()); 110 112 111 113 // concatenate nickname and date 112 114 info = info.concat(", ").concat(date); 113 115 } 114 116 115 117 // add user and date info to the message 116 msg = msg.concat(" [").concat(info).concat("]"); 117 118 return msg; 118 return msg.concat(" [").concat(info).concat("]"); 119 119 } 120 120 121 121 public List<OsbActionObserver> getActionObservers() { 122 122 return observers; 123 123 } 124 124 125 125 public abstract void execute() throws Exception; 126 126 127 @Override 127 128 public abstract OsbAction clone(); 128 129 } -
applications/editors/josm/plugins/openstreetbugs/src/org/openstreetmap/josm/plugins/osb/gui/action/ToggleConnectionModeAction.java
r19282 r22684 16 16 public class ToggleConnectionModeAction extends AbstractAction { 17 17 18 private OsbPlugin plugin;19 20 private OsbDialog dialog;21 18 private final OsbPlugin plugin; 19 private final OsbDialog dialog; 20 private final ActionQueue actionQueue; 21 22 22 public static final String MSG_ONLINE = tr("Switch to online mode"); 23 23 public static final String MSG_OFFLINE = tr("Switch to offline mode"); 24 24 25 25 public ToggleConnectionModeAction(OsbDialog osbDialog, OsbPlugin osbPlugin) { 26 26 super(MSG_OFFLINE); 27 27 this.dialog = osbDialog; 28 28 this.plugin = osbPlugin; 29 this.actionQueue = osbDialog.getActionQueue(); 29 30 } 30 31 31 32 public void actionPerformed(ActionEvent e) { 32 33 boolean isOffline = !Main.pref.getBoolean(ConfigKeys.OSB_API_OFFLINE); 33 34 34 35 // inform the dialog about the connection mode 35 36 dialog.setConnectionMode(isOffline); 36 37 37 38 // set the new value in the preferences 38 39 Main.pref.put(ConfigKeys.OSB_API_OFFLINE, isOffline); 39 40 40 41 // toggle the tooltip text 41 42 if(e.getSource() != null && e.getSource() instanceof JToggleButton) { … … 53 54 } 54 55 } 55 56 56 57 57 58 if(!isOffline) { 58 if( ActionQueue.getInstance().getSize() == 0) {59 if(actionQueue.getSize() == 0) { 59 60 dialog.hideQueuePanel(); 60 61 return; 61 62 } 62 63 63 64 // if we switch to online mode, ask if the queue should be processed 64 65 int result = JOptionPane.showConfirmDialog(Main.parent, … … 68 69 if(result == JOptionPane.YES_OPTION) { 69 70 try { 70 ActionQueue.getInstance().processQueue();71 71 actionQueue.processQueue(); 72 72 73 // toggle queue panel visibility, if now error occured 73 74 dialog.hideQueuePanel(); 74 75 75 76 // refresh, if the api is enabled 76 77 if(!Main.pref.getBoolean(ConfigKeys.OSB_API_DISABLED)) {
Note:
See TracChangeset
for help on using the changeset viewer.