Changeset 13135 in osm for applications/editors/josm/plugins
- Timestamp:
- 2009-01-10T20:32:33+01:00 (16 years ago)
- Location:
- applications/editors/josm/plugins/openstreetbugs/src/org/openstreetmap/josm/plugins/osb
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/openstreetbugs/src/org/openstreetmap/josm/plugins/osb/ConfigKeys.java
r12778 r13135 1 1 /* Copyright (c) 2008, Henrik Niehaus 2 2 * All rights reserved. 3 * 3 * 4 4 * Redistribution and use in source and binary forms, with or without 5 5 * modification, are permitted provided that the following conditions are met: 6 * 6 * 7 7 * 1. Redistributions of source code must retain the above copyright notice, 8 8 * this list of conditions and the following disclaimer. 9 * 2. Redistributions in binary form must reproduce the above copyright notice, 10 * this list of conditions and the following disclaimer in the documentation 9 * 2. Redistributions in binary form must reproduce the above copyright notice, 10 * this list of conditions and the following disclaimer in the documentation 11 11 * and/or other materials provided with the distribution. 12 * 3. Neither the name of the project nor the names of its 13 * contributors may be used to endorse or promote products derived from this 12 * 3. Neither the name of the project nor the names of its 13 * contributors may be used to endorse or promote products derived from this 14 14 * software without specific prior written permission. 15 * 15 * 16 16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 17 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE … … 36 36 public static final String OSB_NICKNAME = "osb.nickname"; 37 37 public static final String OSB_AUTO_DOWNLOAD = "osb.auto_download"; 38 public static final String OSB_BUTTON_LABELS = "osb.button_labels"; 38 39 } -
applications/editors/josm/plugins/openstreetbugs/src/org/openstreetmap/josm/plugins/osb/OsbPlugin.java
r12778 r13135 28 28 package org.openstreetmap.josm.plugins.osb; 29 29 30 import static org.openstreetmap.josm.tools.I18n.tr;31 32 30 import java.awt.event.ActionEvent; 33 31 import java.awt.event.ActionListener; -
applications/editors/josm/plugins/openstreetbugs/src/org/openstreetmap/josm/plugins/osb/gui/OsbDialog.java
r12778 r13135 1 1 /* Copyright (c) 2008, Henrik Niehaus 2 2 * All rights reserved. 3 * 3 * 4 4 * Redistribution and use in source and binary forms, with or without 5 5 * modification, are permitted provided that the following conditions are met: 6 * 6 * 7 7 * 1. Redistributions of source code must retain the above copyright notice, 8 8 * this list of conditions and the following disclaimer. 9 * 2. Redistributions in binary form must reproduce the above copyright notice, 10 * this list of conditions and the following disclaimer in the documentation 9 * 2. Redistributions in binary form must reproduce the above copyright notice, 10 * this list of conditions and the following disclaimer in the documentation 11 11 * and/or other materials provided with the distribution. 12 * 3. Neither the name of the project nor the names of its 13 * contributors may be used to endorse or promote products derived from this 12 * 3. Neither the name of the project nor the names of its 13 * contributors may be used to endorse or promote products derived from this 14 14 * software without specific prior written permission. 15 * 15 * 16 16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 17 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE … … 66 66 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 67 67 import org.openstreetmap.josm.gui.layer.Layer.LayerChangeListener; 68 import org.openstreetmap.josm.plugins.osb.ConfigKeys; 68 69 import org.openstreetmap.josm.plugins.osb.OsbObserver; 69 70 import org.openstreetmap.josm.plugins.osb.OsbPlugin; … … 89 90 private JToggleButton newIssue = new JToggleButton(); 90 91 92 private boolean buttonLabels = Main.pref.getBoolean(ConfigKeys.OSB_BUTTON_LABELS); 93 91 94 public OsbDialog(final OsbPlugin plugin) { 92 95 super(tr("Open OpenStreetBugs"), "icon_error22", 93 tr("Opens the OpenStreetBugs window and activates the automatic download"), 94 Shortcut.registerShortcut( 95 "view:openstreetbugs", 96 tr("Toggle: {0}", tr("Open OpenStreetBugs")), 97 KeyEvent.VK_O, Shortcut.GROUP_MENU, Shortcut.SHIFT_DEFAULT), 98 150); 96 tr("Open the OpenStreetBugs window and activates the automatic download"), Shortcut.registerShortcut( 97 "view:openstreetbugs", tr("Toggle: {0}", tr("Open OpenStreetBugs")), KeyEvent.VK_O, 98 Shortcut.GROUP_MENU, Shortcut.SHIFT_DEFAULT), 150); 99 99 100 100 osbPlugin = plugin; … … 109 109 110 110 // create dialog buttons 111 JPanel buttonPanel = new JPanel(new GridLayout(2, 2)); 111 GridLayout layout = buttonLabels ? new GridLayout(2, 2) : new GridLayout(1, 4); 112 JPanel buttonPanel = new JPanel(layout); 112 113 add(buttonPanel, BorderLayout.SOUTH); 113 114 refresh = new JButton(tr("Refresh")); 114 115 refresh.setToolTipText(tr("Refresh")); 115 116 refresh.setIcon(OsbPlugin.loadIcon("view-refresh22.png")); 116 refresh.setHorizontalAlignment(SwingConstants.LEFT);117 117 refresh.addActionListener(new ActionListener() { 118 118 119 119 public void actionPerformed(ActionEvent e) { 120 120 // check zoom level 121 if (Main.map.mapView.zoom() > 15 || Main.map.mapView.zoom() < 9) {121 if (Main.map.mapView.zoom() > 15 || Main.map.mapView.zoom() < 9) { 122 122 JOptionPane.showMessageDialog(Main.parent, 123 123 tr("The visible area is either too small or too big to download data from OpenStreetBugs"), 124 tr("Warning"), 125 JOptionPane.INFORMATION_MESSAGE); 124 tr("Warning"), JOptionPane.INFORMATION_MESSAGE); 126 125 return; 127 126 } … … 134 133 addComment.setToolTipText((String) addComment.getAction().getValue(Action.NAME)); 135 134 addComment.setIcon(OsbPlugin.loadIcon("add_comment22.png")); 136 addComment.setHorizontalAlignment(SwingConstants.LEFT);137 135 closeIssue.setEnabled(false); 138 136 closeIssue.setToolTipText((String) closeIssue.getAction().getValue(Action.NAME)); 139 137 closeIssue.setIcon(OsbPlugin.loadIcon("icon_valid22.png")); 140 closeIssue.setHorizontalAlignment(SwingConstants.LEFT);141 138 NewIssueAction nia = new NewIssueAction(newIssue, osbPlugin); 142 139 newIssue.setAction(nia); 143 140 newIssue.setToolTipText((String) newIssue.getAction().getValue(Action.NAME)); 144 141 newIssue.setIcon(OsbPlugin.loadIcon("icon_error_add22.png")); 145 newIssue.setHorizontalAlignment(SwingConstants.LEFT);146 142 147 143 buttonPanel.add(refresh); … … 149 145 buttonPanel.add(addComment); 150 146 buttonPanel.add(closeIssue); 147 148 if (buttonLabels) { 149 refresh.setHorizontalAlignment(SwingConstants.LEFT); 150 addComment.setHorizontalAlignment(SwingConstants.LEFT); 151 closeIssue.setHorizontalAlignment(SwingConstants.LEFT); 152 newIssue.setHorizontalAlignment(SwingConstants.LEFT); 153 } else { 154 refresh.setText(null); 155 addComment.setText(null); 156 closeIssue.setText(null); 157 newIssue.setText(null); 158 } 151 159 152 160 // add a selection listener to the data … … 158 166 for (int i = 0; i < model.getSize(); i++) { 159 167 OsbListItem item = (OsbListItem) model.get(i); 160 if (item.getNode() == osmPrimitive) {168 if (item.getNode() == osmPrimitive) { 161 169 list.addSelectionInterval(i, i); 162 170 } … … 187 195 188 196 public void valueChanged(ListSelectionEvent e) { 189 if (list.getSelectedValues().length == 0) {197 if (list.getSelectedValues().length == 0) { 190 198 addComment.setEnabled(false); 191 199 closeIssue.setEnabled(false); … … 218 226 219 227 private void scrollToSelected(Node node) { 220 for (int i = 0; i < model.getSize(); i++) {221 Node current = ((OsbListItem) model.get(i)).getNode();222 if (current.id == node.id) {228 for (int i = 0; i < model.getSize(); i++) { 229 Node current = ((OsbListItem) model.get(i)).getNode(); 230 if (current.id == node.id) { 223 231 list.scrollRectToVisible(list.getCellBounds(i, i)); 224 232 list.setSelectedIndex(i); … … 228 236 } 229 237 230 public void activeLayerChange(Layer oldLayer, Layer newLayer) {} 238 public void activeLayerChange(Layer oldLayer, Layer newLayer) { 239 } 231 240 232 241 public void layerAdded(Layer newLayer) { 233 if (newLayer == osbPlugin.getLayer()) {242 if (newLayer == osbPlugin.getLayer()) { 234 243 update(osbPlugin.getDataSet()); 235 244 Main.map.mapView.moveLayer(newLayer, 0); … … 238 247 239 248 public void layerRemoved(Layer oldLayer) { 240 if (oldLayer == osbPlugin.getLayer()) {249 if (oldLayer == osbPlugin.getLayer()) { 241 250 model.removeAllElements(); 242 251 } … … 253 262 254 263 public void mouseClicked(MouseEvent e) { 255 if (e.getButton() == MouseEvent.BUTTON1 && e.getClickCount() == 2) {256 OsbListItem item = (OsbListItem) list.getSelectedValue();264 if (e.getButton() == MouseEvent.BUTTON1 && e.getClickCount() == 2) { 265 OsbListItem item = (OsbListItem) list.getSelectedValue(); 257 266 zoomToNode(item.getNode()); 258 267 } … … 268 277 269 278 private void mayTriggerPopup(MouseEvent e) { 270 if (e.isPopupTrigger()) {279 if (e.isPopupTrigger()) { 271 280 int selectedRow = list.locationToIndex(e.getPoint()); 272 281 list.setSelectedIndex(selectedRow); 273 Node n = ((OsbListItem) list.getSelectedValue()).getNode();282 Node n = ((OsbListItem) list.getSelectedValue()).getNode(); 274 283 OsbAction.setSelectedNode(n); 275 284 PopupFactory.createPopup(n).show(e.getComponent(), e.getX(), e.getY()); … … 277 286 } 278 287 279 public void mouseEntered(MouseEvent e) {} 280 281 public void mouseExited(MouseEvent e) {} 288 public void mouseEntered(MouseEvent e) { 289 } 290 291 public void mouseExited(MouseEvent e) { 292 } 282 293 283 294 public void actionPerformed(OsbAction action) { 284 if (action instanceof AddCommentAction || action instanceof CloseIssueAction) {295 if (action instanceof AddCommentAction || action instanceof CloseIssueAction) { 285 296 update(osbPlugin.getDataSet()); 286 297 } … … 292 303 String state1 = o1.get("state"); 293 304 String state2 = o2.get("state"); 294 if (state1.equals(state2)) {305 if (state1.equals(state2)) { 295 306 return o1.get("note").compareTo(o2.get("note")); 296 307 }
Note:
See TracChangeset
for help on using the changeset viewer.