Changeset 1419 in josm for trunk/src/org
- Timestamp:
- 2009-02-17T16:52:39+01:00 (16 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/gui/dialogs
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/dialogs/ConflictDialog.java
r1228 r1419 40 40 import org.openstreetmap.josm.data.osm.visitor.Visitor; 41 41 import org.openstreetmap.josm.gui.ConflictResolver; 42 import org.openstreetmap.josm.gui.ExtendedDialog; 42 43 import org.openstreetmap.josm.gui.NavigatableComponent; 43 44 import org.openstreetmap.josm.gui.OsmPrimitivRenderer; … … 50 51 private final DefaultListModel model = new DefaultListModel(); 51 52 private final JList displaylist = new JList(model); 53 54 private final SideButton sbSelect = new SideButton(marktr("Select"), "select", "Conflict", 55 tr("Set the selected elements on the map to the selected items in the list above."), new ActionListener(){ 56 public void actionPerformed(ActionEvent e) { 57 Collection<OsmPrimitive> sel = new LinkedList<OsmPrimitive>(); 58 for (Object o : displaylist.getSelectedValues()) 59 sel.add((OsmPrimitive)o); 60 Main.ds.setSelected(sel); 61 } 62 }); 63 private final SideButton sbResolve = new SideButton(marktr("Resolve"), "conflict", "Conflict", 64 tr("Open a merge dialog of all selected items in the list above."), new ActionListener(){ 65 public void actionPerformed(ActionEvent e) { 66 resolve(); 67 } 68 }); 52 69 53 70 public ConflictDialog() { … … 65 82 66 83 JPanel buttonPanel = new JPanel(new GridLayout(1,2)); 67 buttonPanel.add(new SideButton(marktr("Resolve"), "conflict", "Conflict", 68 tr("Open a merge dialog of all selected items in the list above."), new ActionListener(){ 69 public void actionPerformed(ActionEvent e) { 70 resolve(); 71 } 72 })); 73 74 buttonPanel.add(new SideButton(marktr("Select"), "select", "Conflict", 75 tr("Set the selected elements on the map to the selected items in the list above."), new ActionListener(){ 76 public void actionPerformed(ActionEvent e) { 77 Collection<OsmPrimitive> sel = new LinkedList<OsmPrimitive>(); 78 for (Object o : displaylist.getSelectedValues()) 79 sel.add((OsmPrimitive)o); 80 Main.ds.setSelected(sel); 81 } 82 })); 84 buttonPanel.add(sbResolve); 85 buttonPanel.add(sbSelect); 83 86 add(buttonPanel, BorderLayout.SOUTH); 84 87 … … 99 102 } 100 103 }); 104 105 rebuildList(); 101 106 } 102 107 103 108 private final void resolve() { 104 if (displaylist.getSelectedIndex() == -1) { 105 JOptionPane.showMessageDialog(Main.parent,tr("Please select something from the conflict list.")); 109 if(model.size() == 1) 110 displaylist.setSelectedIndex(0); 111 112 if (displaylist.getSelectedIndex() == -1) 106 113 return; 107 }108 114 Map<OsmPrimitive, OsmPrimitive> sel = new HashMap<OsmPrimitive, OsmPrimitive>(); 109 115 for (int i : displaylist.getSelectedIndices()) { … … 112 118 } 113 119 ConflictResolver resolver = new ConflictResolver(sel); 114 int answer = JOptionPane.showConfirmDialog(Main.parent, resolver, tr("Resolve Conflicts"), JOptionPane.OK_CANCEL_OPTION); 115 if (answer != JOptionPane.OK_OPTION) 120 int answer = new ExtendedDialog(Main.parent, 121 tr("Resolve Conflicts"), 122 resolver, 123 new String[] { tr("Solve Conflict"), tr("Cancel") }, 124 new String[] { "dialogs/conflict.png", "cancel.png"} 125 ).getValue(); 126 127 if (answer != 1) 116 128 return; 117 129 Main.main.undoRedo.add(new ConflictResolveCommand(resolver.conflicts, sel)); … … 136 148 setTitle(tr("Conflicts"), false); 137 149 } 150 151 sbSelect.setEnabled(model.size() > 0); 152 sbResolve.setEnabled(model.size() > 0); 138 153 } 139 154 -
trunk/src/org/openstreetmap/josm/gui/dialogs/RelationListDialog.java
r1415 r1419 18 18 import javax.swing.JScrollPane; 19 19 import javax.swing.ListSelectionModel; 20 import javax.swing.event.ListSelectionEvent; 20 21 import javax.swing.event.ListSelectionListener; 21 22 import org.openstreetmap.josm.Main; … … 53 54 */ 54 55 private JList displaylist = new JList(list); 56 57 private SideButton sbEdit = new SideButton(marktr("Edit"), "edit", "Selection", tr( "Open an editor for the selected relation"), new ActionListener() { 58 public void actionPerformed(ActionEvent e) { 59 Relation toEdit = getSelected(); 60 if (toEdit == null) 61 return; 62 63 new RelationEditor(toEdit).setVisible(true); 64 } 65 }); 66 67 private SideButton sbDel = new SideButton(marktr("Delete"), "delete", "Selection", tr("Delete the selected relation"), new ActionListener() { 68 public void actionPerformed(ActionEvent e) { 69 Relation toDelete = getSelected(); 70 if (toDelete == null) 71 return; 72 73 Main.main.undoRedo.add( 74 new DeleteCommand(Collections.singleton(toDelete))); 75 } 76 }); 55 77 56 78 public RelationListDialog() { … … 77 99 }), GBC.std()); 78 100 79 buttonPanel.add(new SideButton(marktr("Edit"), "edit", "Selection", tr( "Open an editor for the selected relation"), new ActionListener() { 80 public void actionPerformed(ActionEvent e) { 81 Relation toEdit = (Relation) displaylist.getSelectedValue(); 82 if (toEdit != null) 83 new RelationEditor(toEdit).setVisible(true); 84 } 85 }), GBC.std()); 101 buttonPanel.add(sbEdit, GBC.std()); 86 102 87 buttonPanel.add(new SideButton(marktr("Delete"), "delete", "Selection", tr("Delete the selected relation"), new ActionListener() { 88 public void actionPerformed(ActionEvent e) { 89 Relation toDelete = (Relation) displaylist.getSelectedValue(); 90 if (toDelete != null) { 91 Main.main.undoRedo.add( 92 new DeleteCommand(Collections.singleton(toDelete))); 93 } 94 } 95 }), GBC.eol()); 103 buttonPanel.add(sbDel, GBC.eol()); 96 104 Layer.listeners.add(this); 97 105 add(buttonPanel, BorderLayout.SOUTH); 106 107 displaylist.addListSelectionListener(new ListSelectionListener() { 108 public void valueChanged(ListSelectionEvent e) { 109 sbEdit.setEnabled(getSelected() != null); 110 sbDel.setEnabled(getSelected() != null); 111 } 112 }); 98 113 } 99 114 … … 117 132 setTitle(tr("Relations"), false); 118 133 } 134 135 sbEdit.setEnabled(list.size() > 0); 136 sbDel.setEnabled(list.size() > 0); 119 137 } 120 138 … … 169 187 displaylist.removeListSelectionListener(listener); 170 188 } 189 190 /** 191 * @return The selected relation in the list 192 */ 193 private Relation getSelected() { 194 if(list.size() == 1) 195 displaylist.setSelectedIndex(0); 196 return (Relation) displaylist.getSelectedValue(); 197 } 171 198 }
Note:
See TracChangeset
for help on using the changeset viewer.