Changeset 90 in josm for src/org


Ignore:
Timestamp:
2006-04-21T20:05:14+02:00 (18 years ago)
Author:
imi
Message:
  • fixed that toggle dialog buttons are sync with the dialogs
  • added search for timestamp (e.g. timestamp:06-3-25)
Location:
src/org/openstreetmap/josm
Files:
14 edited

Legend:

Unmodified
Added
Removed
  • src/org/openstreetmap/josm/Main.java

    r89 r90  
    270270                main.setVisible(true);
    271271
    272 
    273                 if (arguments.remove("--show-modifiers")) {
    274                         Point p = main.getLocationOnScreen();
    275                         Dimension s = main.getSize();
    276                         new ShowModifiers(p.x + s.width - 3, p.y + s.height - 32);
    277                         main.setVisible(true);
    278                 }
    279                
    280272                if (!arguments.remove("--no-fullscreen")) {
    281273                        if (Toolkit.getDefaultToolkit().isFrameStateSupported(MAXIMIZED_BOTH))
     
    316308                        }
    317309                }
    318                
     310
     311                if (arguments.remove("--show-modifiers")) {
     312                        Point p = main.getLocationOnScreen();
     313                        Dimension s = main.getSize();
     314                        new ShowModifiers(p.x + s.width - 3, p.y + s.height - 32);
     315                        main.setVisible(true);
     316                }
     317
    319318                for (String s : arguments)
    320319                        main.openAction.openFile(new File(s));
  • src/org/openstreetmap/josm/actions/UploadAction.java

    r86 r90  
    5353                        int cutPos = osmDataServer.endsWith("/0.2") ? 4 : 5;
    5454                        Main.pref.put("osm-server.url", osmDataServer.substring(0, osmDataServer.length()-cutPos));
     55                }
     56               
     57                if (!Main.main.getMapFrame().conflictDialog.conflicts.isEmpty()) {
     58                        JOptionPane.showMessageDialog(Main.main, "There are unresolved conflicts. You have to resolve these first.");
     59                        Main.main.getMapFrame().conflictDialog.action.button.setSelected(true);
     60                        Main.main.getMapFrame().conflictDialog.action.actionPerformed(null);
     61                        return;
    5562                }
    5663
  • src/org/openstreetmap/josm/actions/mapmode/AddWayAction.java

    r86 r90  
    7272               
    7373                if (numberOfSelectedWays > 0) {
    74                         String ways = "way" + (numberOfSelectedWays==1?"":"s");
    75                         int answer = JOptionPane.showConfirmDialog(Main.main, numberOfSelectedWays+" "+ways+" have been selected.\n" +
     74                        String ways = "way" + (numberOfSelectedWays==1?" has":"s have");
     75                        int answer = JOptionPane.showConfirmDialog(Main.main, numberOfSelectedWays+" "+ways+" been selected.\n" +
    7676                                        "Do you wish to select all segments belonging to the "+ways+" instead?");
    7777                        if (answer == JOptionPane.CANCEL_OPTION)
     
    8383                        }
    8484                }
     85               
     86                if (segments.isEmpty())
     87                        return;
    8588               
    8689                // sort the segments in best possible order. This is done by:
  • src/org/openstreetmap/josm/command/ChangePropertyCommand.java

    r86 r90  
    3939                super.executeCommand(); // save old
    4040                if (value == null) {
    41                         for (OsmPrimitive osm : objects)
     41                        for (OsmPrimitive osm : objects) {
     42                                osm.modified = true;
    4243                                osm.remove(key);
     44                        }
    4345                } else {
    44                         for (OsmPrimitive osm : objects)
     46                        for (OsmPrimitive osm : objects) {
     47                                osm.modified = true;
    4548                                osm.put(key, value);
     49                        }
    4650                }
    4751        }
  • src/org/openstreetmap/josm/command/ConflictResolveCommand.java

    r86 r90  
    99import java.util.Map.Entry;
    1010
    11 import javax.swing.DefaultListModel;
    12 
    1311import org.openstreetmap.josm.Main;
    1412import org.openstreetmap.josm.data.conflict.ConflictItem;
    1513import org.openstreetmap.josm.data.osm.OsmPrimitive;
    1614import org.openstreetmap.josm.gui.ConflictResolver;
     15import org.openstreetmap.josm.gui.dialogs.ConflictDialog;
    1716
    1817public class ConflictResolveCommand extends Command {
     
    2120        private final Map<OsmPrimitive, OsmPrimitive> resolved;
    2221        private Map<OsmPrimitive, OsmPrimitive> origAllConflicts;
     22        private final ConflictDialog conflictDialog;
    2323
    2424        public ConflictResolveCommand(List<ConflictItem> conflicts, Map<OsmPrimitive, OsmPrimitive> resolved) {
    2525                this.conflicts = conflicts;
    2626                this.resolved = resolved;
     27                conflictDialog = Main.main.getMapFrame().conflictDialog;
    2728        }
    2829
     
    3031                super.executeCommand();
    3132
    32                 origAllConflicts = new HashMap<OsmPrimitive, OsmPrimitive>(Main.main.getMapFrame().conflictDialog.conflicts);
    33 
     33                origAllConflicts = new HashMap<OsmPrimitive, OsmPrimitive>(conflictDialog.conflicts);
    3434               
    3535                Set<OsmPrimitive> completed = new HashSet<OsmPrimitive>(resolved.keySet());
     
    4444                        }
    4545                }
    46                 for (OsmPrimitive k : completed) {
    47                         Main.main.getMapFrame().conflictDialog.conflicts.remove(k);
    48                         Main.main.getMapFrame().conflictDialog.model.removeElement(k);
    49                 }
     46                for (OsmPrimitive k : completed)
     47                        conflictDialog.conflicts.remove(k);
     48                if (!completed.isEmpty())
     49                        conflictDialog.rebuildList();
    5050        }
    5151
    5252        @Override public void undoCommand() {
    5353                super.undoCommand();
    54                 Map<OsmPrimitive, OsmPrimitive> c = Main.main.getMapFrame().conflictDialog.conflicts;
    55                 DefaultListModel m = Main.main.getMapFrame().conflictDialog.model;
    56 
    57                 c.clear();
    58                 c.putAll(origAllConflicts);
    59                 m.removeAllElements();
    60                 for (Entry<OsmPrimitive, OsmPrimitive> e : c.entrySet())
    61                         m.addElement(e.getKey());
     54                Main.main.getMapFrame().conflictDialog.conflicts.clear();
     55                Main.main.getMapFrame().conflictDialog.conflicts.putAll(origAllConflicts);
     56                Main.main.getMapFrame().conflictDialog.rebuildList();
    6257        }
    6358
  • src/org/openstreetmap/josm/data/osm/OsmPrimitive.java

    r86 r90  
    11package org.openstreetmap.josm.data.osm;
    22
     3import java.text.SimpleDateFormat;
    34import java.util.Collection;
    45import java.util.Collections;
     
    161162                (keys == null ? osm.keys==null : keys.equals(osm.keys));
    162163        }
     164       
     165        public String getTimeStr() {
     166                return timestamp == null ? null : new SimpleDateFormat("y-M-d H:m:s").format(timestamp);
     167        }
    163168}
  • src/org/openstreetmap/josm/gui/IconToggleButton.java

    r80 r90  
    2222                setText(null);
    2323
    24                 // Tooltip
    25                 String toolTipText = "";
    2624                Object o = action.getValue(Action.SHORT_DESCRIPTION);
    2725                if (o != null)
    28                         toolTipText = o.toString();
    29                 setToolTipText(toolTipText);
     26                        setToolTipText(o.toString());
    3027               
    3128                action.addPropertyChangeListener(this);
  • src/org/openstreetmap/josm/gui/MapFrame.java

    r86 r90  
    44import java.awt.Component;
    55import java.awt.Container;
     6import java.awt.event.ActionEvent;
    67import java.beans.PropertyChangeEvent;
    78import java.beans.PropertyChangeListener;
     
    1415import javax.swing.JToolBar;
    1516
     17import org.openstreetmap.josm.Main;
    1618import org.openstreetmap.josm.actions.AutoScaleAction;
    1719import org.openstreetmap.josm.actions.mapmode.AddSegmentAction;
     
    116118
    117119        private void addIconToggle(JPanel toggleDialogs, ToggleDialog dlg) {
    118         toolBarActions.add(new IconToggleButton(dlg.action));
     120        IconToggleButton button = new IconToggleButton(dlg.action);
     121        dlg.action.button = button;
     122                toolBarActions.add(button);
    119123                toggleDialogs.add(dlg);
     124                if (Main.pref.getBoolean(dlg.action.prefname+".visible"))
     125                        dlg.action.actionPerformed(new ActionEvent(this, 0, ""));
    120126        }
    121127
  • src/org/openstreetmap/josm/gui/dialogs/ConflictDialog.java

    r86 r90  
    4444
    4545        public final Map<OsmPrimitive, OsmPrimitive> conflicts = new HashMap<OsmPrimitive, OsmPrimitive>();
    46         public final DefaultListModel model = new DefaultListModel();
     46        private final DefaultListModel model = new DefaultListModel();
    4747        private final JList displaylist = new JList(model);
    4848
     
    120120        }
    121121
     122        public final void rebuildList() {
     123                model.removeAllElements();
     124                for (OsmPrimitive osm : this.conflicts.keySet())
     125                        if (osm instanceof Node)
     126                                model.addElement(osm);
     127                for (OsmPrimitive osm : this.conflicts.keySet())
     128                        if (osm instanceof Segment)
     129                                model.addElement(osm);
     130                for (OsmPrimitive osm : this.conflicts.keySet())
     131                        if (osm instanceof Way)
     132                                model.addElement(osm);
     133        }
     134       
    122135        public final void add(Map<OsmPrimitive, OsmPrimitive> conflicts) {
    123136                this.conflicts.putAll(conflicts);
    124                 model.removeAllElements();
    125                 for (OsmPrimitive osm : this.conflicts.keySet())
    126                         model.addElement(osm);
     137                rebuildList();
    127138        }
    128139
  • src/org/openstreetmap/josm/gui/dialogs/SelectionListDialog.java

    r86 r90  
    117117                                };
    118118                                pane.createDialog(Main.main, "Search").setVisible(true);
    119                                 System.out.println(pane.getValue());
    120119                                if (!Integer.valueOf(JOptionPane.OK_OPTION).equals(pane.getValue()))
    121120                                        return;
  • src/org/openstreetmap/josm/gui/dialogs/ToggleDialog.java

    r86 r90  
    22
    33import java.awt.BorderLayout;
    4 import java.awt.EventQueue;
    54import java.awt.event.ActionEvent;
    65import java.awt.event.KeyEvent;
     
    2322public class ToggleDialog extends JPanel {
    2423
     24        public final class ToggleDialogAction extends JosmAction {
     25            public final String prefname;
     26            public AbstractButton button;
     27
     28            private ToggleDialogAction(String name, String iconName, String tooltip, String shortcut, KeyStroke cut, String prefname) {
     29                    super(name, iconName, tooltip, shortcut, cut);
     30                    this.prefname = prefname;
     31            }
     32
     33            public void actionPerformed(ActionEvent e) {
     34                if (e != null && !(e.getSource() instanceof AbstractButton))
     35                        button.setSelected(!button.isSelected());
     36                setVisible(button.isSelected());
     37                Main.pref.put(prefname+".visible", button.isSelected());
     38            }
     39    }
     40
    2541        /**
    2642         * The action to toggle this dialog.
    2743         */
    28         public JosmAction action;
    29        
     44        public ToggleDialogAction action;
     45
    3046        /**
    3147         * Create a new ToggleDialog.
     
    3450         */
    3551        public ToggleDialog(String title, String name, String iconName, String tooltip, String shortCutName, int shortCut, final String prefName) {
    36                 action = new JosmAction(name, "dialogs/"+iconName, tooltip, "Alt-"+shortCutName, KeyStroke.getKeyStroke(shortCut, KeyEvent.ALT_MASK)){
    37                         public void actionPerformed(ActionEvent e) {
    38                                 boolean show = !isVisible();
    39                                 if (e != null && e.getSource() instanceof AbstractButton)
    40                                         show = ((AbstractButton)e.getSource()).isSelected();
    41                                 setVisible(show);
    42                 Main.pref.put(prefName+".visible", show);
    43                         }
    44                 };
     52                action = new ToggleDialogAction(name, "dialogs/"+iconName, tooltip, "Alt-"+shortCutName, KeyStroke.getKeyStroke(shortCut, KeyEvent.ALT_MASK), prefName);
    4553                setLayout(new BorderLayout());
    4654                add(new JLabel(title), BorderLayout.NORTH);
    4755                setVisible(false);
    4856                setBorder(BorderFactory.createEtchedBorder());
    49                 if (Main.pref.getBoolean(prefName+".visible")) {
    50                     EventQueue.invokeLater(new Runnable(){
    51                         public void run() {
    52                                 action.putValue("active", true);
    53                             action.actionPerformed(null);
    54                         }
    55                     });
    56         }
    5757        }
    5858}
  • src/org/openstreetmap/josm/gui/layer/OsmDataLayer.java

    r86 r90  
    33import java.awt.Graphics;
    44import java.awt.GridBagLayout;
     5import java.awt.event.ActionEvent;
    56import java.util.Collection;
    67import java.util.HashSet;
     
    1314import javax.swing.JLabel;
    1415import javax.swing.JMenuItem;
     16import javax.swing.JOptionPane;
    1517import javax.swing.JPanel;
    1618import javax.swing.JPopupMenu;
     
    3032import org.openstreetmap.josm.data.osm.visitor.Visitor;
    3133import org.openstreetmap.josm.gui.MapView;
     34import org.openstreetmap.josm.gui.dialogs.ConflictDialog;
    3235import org.openstreetmap.josm.gui.dialogs.LayerListPopup;
    3336import org.openstreetmap.josm.tools.GBC;
     
    159162                if (visitor.conflicts.isEmpty())
    160163                        return;
    161                 Main.main.getMapFrame().conflictDialog.add(visitor.conflicts);
     164                ConflictDialog dlg = Main.main.getMapFrame().conflictDialog;
     165                dlg.add(visitor.conflicts);
     166                JOptionPane.showMessageDialog(Main.main, "There were conflicts during import.");
     167                if (!dlg.isVisible())
     168                        dlg.action.actionPerformed(new ActionEvent(this, 0, ""));
    162169        }
    163170
  • src/org/openstreetmap/josm/io/OsmWriter.java

    r86 r90  
    33import java.io.PrintWriter;
    44import java.io.Writer;
    5 import java.text.SimpleDateFormat;
    65import java.util.HashMap;
    76import java.util.Map.Entry;
    87
    98import org.openstreetmap.josm.data.osm.DataSet;
    10 import org.openstreetmap.josm.data.osm.Segment;
    119import org.openstreetmap.josm.data.osm.Node;
    1210import org.openstreetmap.josm.data.osm.OsmPrimitive;
     11import org.openstreetmap.josm.data.osm.Segment;
    1312import org.openstreetmap.josm.data.osm.Way;
    1413import org.openstreetmap.josm.data.osm.visitor.Visitor;
     
    138137                }
    139138                if (osm.timestamp != null) {
    140                         String time = new SimpleDateFormat("y-M-d H:m:s").format(osm.timestamp);
     139                        String time = osm.getTimeStr();
    141140                        out.print(" timestamp='"+time+"'");
    142141                }
  • src/org/openstreetmap/josm/tools/SearchCompiler.java

    r86 r90  
    66import java.util.Map.Entry;
    77
    8 import org.openstreetmap.josm.data.osm.Segment;
    98import org.openstreetmap.josm.data.osm.Node;
    109import org.openstreetmap.josm.data.osm.OsmPrimitive;
     10import org.openstreetmap.josm.data.osm.Segment;
    1111import org.openstreetmap.josm.data.osm.Way;
    1212
     
    7171                public KeyValue(String key, String value, boolean notValue) {this.key = key; this.value = value; this.notValue = notValue;}
    7272                @Override public boolean match(OsmPrimitive osm) {
    73                         String value = osm.get(key);
     73                        String value = null;
     74                        if (key.equals("timestamp"))
     75                                value = osm.getTimeStr();
     76                        else
     77                                value = osm.get(key);
    7478                        if (value == null)
    75                                 return false;
     79                                return notValue;
    7680                        return (value.indexOf(this.value) != -1) != notValue;
    7781                }
    7882                @Override public String toString() {return key+"="+(notValue?"!":"")+value;}
    7983        }
    80        
     84
    8185        private static class Any extends Match {
    8286                private String s;
Note: See TracChangeset for help on using the changeset viewer.