Changeset 198 in josm
- Timestamp:
- 2007-01-14T09:41:24+01:00 (18 years ago)
- Files:
-
- 1 added
- 3 deleted
- 17 edited
Legend:
- Unmodified
- Added
- Removed
-
src/org/openstreetmap/josm/actions/mapmode/AddNodeAction.java
r184 r198 25 25 import org.openstreetmap.josm.data.osm.Way; 26 26 import org.openstreetmap.josm.gui.MapFrame; 27 import org.openstreetmap.josm.tools.ImageProvider;28 27 29 28 /** … … 54 53 55 54 public AddNodeAction(MapFrame mapFrame, String name, Mode mode, String desc) { 56 super(name, "node/"+mode, desc, mapFrame, ImageProvider.getCursor("crosshair", "node"));55 super(name, "node/"+mode, desc, mapFrame, Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR)); 57 56 this.mode = mode; 58 57 putValue("help", "Action/AddNode/"+Character.toUpperCase(mode.toString().charAt(0))+mode.toString().substring(1)); … … 62 61 super.enterMode(); 63 62 Main.map.mapView.addMouseListener(this); 64 Main.map.mapView.setCursor(Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR));65 63 } 66 64 … … 68 66 super.exitMode(); 69 67 Main.map.mapView.removeMouseListener(this); 70 Main.map.mapView.setCursor(Cursor.getDefaultCursor());71 68 } 72 69 -
src/org/openstreetmap/josm/actions/mapmode/MapMode.java
r178 r198 21 21 */ 22 22 abstract public class MapMode extends JosmAction implements MouseListener, MouseMotionListener { 23 //private final Cursor cursor;24 //private Cursor oldCursor;23 private final Cursor cursor; 24 private Cursor oldCursor; 25 25 26 26 /** … … 29 29 public MapMode(String name, String iconName, String tooltip, int keystroke, MapFrame mapFrame, Cursor cursor) { 30 30 super(name, "mapmode/"+iconName, tooltip, keystroke, 0, false); 31 //this.cursor = cursor;31 this.cursor = cursor; 32 32 putValue("active", false); 33 33 } … … 40 40 putValue(SMALL_ICON, ImageProvider.get("mapmode", iconName)); 41 41 putValue(SHORT_DESCRIPTION, tooltip); 42 //this.cursor = cursor;42 this.cursor = cursor; 43 43 } 44 44 45 45 public void enterMode() { 46 46 putValue("active", true); 47 //oldCursor = Main.map.mapView.getCursor();48 //Main.map.mapView.setCursor(cursor);47 oldCursor = Main.map.mapView.getCursor(); 48 Main.map.mapView.setCursor(cursor); 49 49 50 50 } 51 51 public void exitMode() { 52 52 putValue("active", false); 53 //Main.map.mapView.setCursor(oldCursor);53 Main.map.mapView.setCursor(oldCursor); 54 54 } 55 55 -
src/org/openstreetmap/josm/command/SequenceCommand.java
r104 r198 3 3 import static org.openstreetmap.josm.tools.I18n.tr; 4 4 5 import java.util.Arrays; 5 6 import java.util.Collection; 6 7 … … 32 33 this.sequence = sequenz.toArray(this.sequence); 33 34 } 35 36 /** 37 * Convinient constructor, if the commands are known at compile time. 38 */ 39 public SequenceCommand(String name, Command... sequenz) { 40 this(name, Arrays.asList(sequenz)); 41 } 34 42 35 43 @Override public void executeCommand() { -
src/org/openstreetmap/josm/gui/MainApplication.java
r192 r198 4 4 import static org.openstreetmap.josm.tools.I18n.tr; 5 5 6 import java.awt.EventQueue; 6 7 import java.awt.Toolkit; 7 8 import java.awt.event.WindowAdapter; … … 67 68 // construct argument table 68 69 List<String> argList = Arrays.asList(argArray); 69 Map<String, Collection<String>> args = new HashMap<String, Collection<String>>();70 final Map<String, Collection<String>> args = new HashMap<String, Collection<String>>(); 70 71 for (String arg : argArray) { 71 72 if (!arg.startsWith("--")) … … 157 158 JFrame mainFrame = new JFrame(tr("Java Open Street Map - Editor")); 158 159 Main.parent = mainFrame; 159 Main main = new MainApplication(mainFrame);160 final Main main = new MainApplication(mainFrame); 160 161 main.loadPlugins(); 161 162 … … 165 166 mainFrame.setExtendedState(JFrame.MAXIMIZED_BOTH); 166 167 167 main.postConstructorProcessCmdLine(args); 168 EventQueue.invokeLater(new Runnable(){ 169 public void run() { 170 main.postConstructorProcessCmdLine(args); 171 } 172 }); 168 173 } 169 174 } -
src/org/openstreetmap/josm/gui/MapFrame.java
r172 r198 150 150 IconToggleButton button = new IconToggleButton(dlg.action); 151 151 dlg.action.button = button; 152 dlg.parent = toggleDialogs; 152 153 toolBarActions.add(button); 153 154 toggleDialogs.add(dlg); -
src/org/openstreetmap/josm/gui/MapView.java
r178 r198 153 153 Main.ds.clearSelection(); 154 154 } 155 layer.destroy(); 155 156 } 156 157 -
src/org/openstreetmap/josm/gui/dialogs/PropertiesDialog.java
r180 r198 23 23 import java.util.Map.Entry; 24 24 25 import javax.swing.Box; 25 26 import javax.swing.DefaultComboBoxModel; 26 27 import javax.swing.JButton; … … 39 40 import org.openstreetmap.josm.Main; 40 41 import org.openstreetmap.josm.command.ChangePropertyCommand; 42 import org.openstreetmap.josm.command.SequenceCommand; 41 43 import org.openstreetmap.josm.data.SelectionChangedListener; 42 44 import org.openstreetmap.josm.data.osm.OsmPrimitive; … … 97 99 return; 98 100 } 99 String msg = "<html>"+trn("This will change {0} object.", "This will change {0} objects.", sel.size(), sel.size())+"<br><br> "+tr("Please select a new value for \"{0}\".<br>(Empty string deletes the key.)", key)+"</html>"; 101 String msg = "<html>"+trn("This will change {0} object.", "This will change {0} objects.", sel.size(), sel.size())+"<br><br>("+tr("An empty value deletes the key.", key)+")</html>"; 102 103 JPanel panel = new JPanel(new BorderLayout()); 104 panel.add(new JLabel(msg), BorderLayout.NORTH); 105 106 JPanel p = new JPanel(new GridBagLayout()); 107 panel.add(p, BorderLayout.CENTER); 108 109 final JTextField keyField = new JTextField(key); 110 p.add(new JLabel(tr("Key")), GBC.std()); 111 p.add(Box.createHorizontalStrut(10), GBC.std()); 112 p.add(keyField, GBC.eol().fill(GBC.HORIZONTAL)); 113 100 114 final JComboBox combo = (JComboBox)data.getValueAt(row, 1); 101 JPanel p = new JPanel(new BorderLayout());102 p.add( new JLabel(msg), BorderLayout.NORTH);103 p.add(combo, BorderLayout.CENTER);104 105 final JOptionPane optionPane = new JOptionPane(p , JOptionPane.QUESTION_MESSAGE, JOptionPane.OK_CANCEL_OPTION){115 p.add(new JLabel(tr("Value")), GBC.std()); 116 p.add(Box.createHorizontalStrut(10), GBC.std()); 117 p.add(combo, GBC.eol().fill(GBC.HORIZONTAL)); 118 119 final JOptionPane optionPane = new JOptionPane(panel, JOptionPane.QUESTION_MESSAGE, JOptionPane.OK_CANCEL_OPTION){ 106 120 @Override public void selectInitialValue() { 107 121 combo.requestFocusInWindow(); … … 131 145 if (value.equals("")) 132 146 value = null; // delete the key 133 Main.main.editLayer().add(new ChangePropertyCommand(sel, key, value)); 134 135 if (value == null) 147 String newkey = keyField.getText(); 148 if (newkey.equals("")) { 149 newkey = key; 150 value = null; // delete the key instead 151 } 152 if (key.equals(newkey) || value == null) 153 Main.main.editLayer().add(new ChangePropertyCommand(sel, newkey, value)); 154 else { 155 Main.main.editLayer().add(new SequenceCommand(trn("Change properties of {0} object", "Change properties of {0} objects", sel.size(), sel.size()), 156 new ChangePropertyCommand(sel, key, null), 157 new ChangePropertyCommand(sel, newkey, value))); 158 } 159 160 if (!key.equals(newkey) || value == null) 136 161 selectionChanged(sel); // update whole table 137 162 -
src/org/openstreetmap/josm/gui/dialogs/ToggleDialog.java
r178 r198 3 3 import java.awt.BorderLayout; 4 4 import java.awt.Dimension; 5 import java.awt.EventQueue; 6 import java.awt.GridBagLayout; 5 7 import java.awt.event.ActionEvent; 8 import java.awt.event.ActionListener; 9 import java.awt.event.ComponentAdapter; 10 import java.awt.event.ComponentEvent; 6 11 import java.awt.event.KeyEvent; 12 import java.awt.event.WindowAdapter; 13 import java.awt.event.WindowEvent; 7 14 8 15 import javax.swing.AbstractButton; 9 16 import javax.swing.BorderFactory; 17 import javax.swing.Box; 18 import javax.swing.JButton; 19 import javax.swing.JFrame; 10 20 import javax.swing.JLabel; 11 21 import javax.swing.JPanel; … … 14 24 import org.openstreetmap.josm.actions.JosmAction; 15 25 import org.openstreetmap.josm.actions.HelpAction.Helpful; 26 import org.openstreetmap.josm.tools.GBC; 27 import org.openstreetmap.josm.tools.ImageProvider; 16 28 17 29 /** … … 46 58 public final String prefName; 47 59 48 public ToggleDialog(String name, String iconName, String tooltip, int shortCut, int preferredHeight) { 60 public JPanel parent; 61 private final JPanel titleBar = new JPanel(new GridBagLayout()); 62 63 public ToggleDialog(final String name, String iconName, String tooltip, int shortCut, int preferredHeight) { 64 super(new BorderLayout()); 49 65 this.prefName = iconName; 50 66 setPreferredSize(new Dimension(330,preferredHeight)); … … 53 69 action.putValue("help", helpId.substring(0, helpId.length()-6)); 54 70 setLayout(new BorderLayout()); 55 add(new JLabel(name), BorderLayout.NORTH); 71 72 titleBar.add(new JLabel(name), GBC.std()); 73 titleBar.add(Box.createHorizontalGlue(),GBC.std().fill(GBC.HORIZONTAL)); 74 75 JButton sticky = new JButton(ImageProvider.get("misc", "sticky")); 76 sticky.setBorder(BorderFactory.createEmptyBorder()); 77 final ActionListener stickyActionListener = new ActionListener(){ 78 public void actionPerformed(ActionEvent e) { 79 final JFrame f = new JFrame(name); 80 f.setAlwaysOnTop(true); 81 parent.remove(ToggleDialog.this); 82 f.getContentPane().add(ToggleDialog.this); 83 f.addWindowListener(new WindowAdapter(){ 84 @Override public void windowClosing(WindowEvent e) { 85 titleBar.setVisible(true); 86 f.getContentPane().removeAll(); 87 parent.add(ToggleDialog.this); 88 f.dispose(); 89 90 // doLayout() - workaround 91 setVisible(false); 92 setVisible(true); 93 94 Main.pref.put(action.prefname+".docked", true); 95 } 96 }); 97 f.addComponentListener(new ComponentAdapter(){ 98 @Override public void componentMoved(ComponentEvent e) { 99 Main.pref.put(action.prefname+".bounds", f.getX()+","+f.getY()+","+f.getWidth()+","+f.getHeight()); 100 } 101 }); 102 String bounds = Main.pref.get(action.prefname+".bounds",null); 103 if (bounds != null) { 104 String[] b = bounds.split(","); 105 f.setBounds(Integer.parseInt(b[0]),Integer.parseInt(b[1]),Integer.parseInt(b[2]),Integer.parseInt(b[3])); 106 } else 107 f.pack(); 108 Main.pref.put(action.prefname+".docked", false); 109 f.setVisible(true); 110 titleBar.setVisible(false); 111 112 // doLayout() - workaround 113 parent.setVisible(false); 114 parent.setVisible(true); 115 } 116 }; 117 sticky.addActionListener(stickyActionListener); 118 119 titleBar.add(sticky); 120 add(titleBar, BorderLayout.NORTH); 121 56 122 setVisible(false); 57 123 setBorder(BorderFactory.createEtchedBorder()); 124 125 if (!Main.pref.getBoolean(action.prefname+".docked", true)) { 126 EventQueue.invokeLater(new Runnable(){ 127 public void run() { 128 stickyActionListener.actionPerformed(null); 129 } 130 }); 131 } 58 132 } 59 133 -
src/org/openstreetmap/josm/gui/layer/Layer.java
r138 r198 88 88 89 89 abstract public Component[] getMenuEntries(); 90 91 /** 92 * Called, when the layer is removed from the mapview and is going to be 93 * destroyed. 94 * 95 * This is because the Layer constructor can not add itself safely as listener 96 * to the layerlist dialog, because there may be no such dialog yet (loaded 97 * via command line parameter). 98 */ 99 public void destroy() {} 90 100 } -
src/org/openstreetmap/josm/gui/layer/RawGpsLayer.java
r180 r198 27 27 import javax.swing.JRadioButton; 28 28 import javax.swing.JSeparator; 29 import javax.swing.SwingUtilities;30 29 import javax.swing.filechooser.FileFilter; 31 30 … … 42 41 import org.openstreetmap.josm.data.osm.visitor.BoundingXYVisitor; 43 42 import org.openstreetmap.josm.gui.MapView; 44 import org.openstreetmap.josm.gui.MapView.LayerChangeListener;45 43 import org.openstreetmap.josm.gui.dialogs.LayerListDialog; 46 44 import org.openstreetmap.josm.gui.dialogs.LayerListPopup; … … 111 109 this.data = data; 112 110 Main.pref.listener.add(this); 113 SwingUtilities.invokeLater(new Runnable(){114 public void run() {115 Main.map.mapView.addLayerChangeListener(new LayerChangeListener(){116 public void activeLayerChange(Layer oldLayer, Layer newLayer) {}117 public void layerAdded(Layer newLayer) {}118 public void layerRemoved(Layer oldLayer) {119 Main.pref.listener.remove(RawGpsLayer.this);120 }121 });122 }123 });124 111 } 125 112 … … 318 305 Main.map.repaint(); 319 306 } 307 308 @Override public void destroy() { 309 Main.pref.listener.remove(RawGpsLayer.this); 310 } 320 311 } -
test/org/openstreetmap/josm/data/osm/visitor/MergeVisitorTest.java
r197 r198 1 1 package org.openstreetmap.josm.data.osm.visitor; 2 2 3 import java.util.Arrays;4 3 import java.util.Date; 5 4 … … 41 40 return s; 42 41 } 43 44 private Way createWay(long id, Date timestamp, Segment... segments) {45 Way w = new Way();46 w.id = id;47 w.segments.addAll(Arrays.asList(segments));48 w.timestamp = timestamp;49 return w;50 }51 42 52 43 /**
Note:
See TracChangeset
for help on using the changeset viewer.