Changeset 1868 in josm
- Timestamp:
- 2009-07-28T21:43:34+02:00 (16 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/AutoScaleAction.java
r1854 r1868 59 59 } 60 60 61 public void a ctionPerformed(ActionEvent e){61 public void autoScale() { 62 62 if (Main.map != null) { 63 63 BoundingXYVisitor bbox = getBoundingBox(); … … 67 67 } 68 68 putValue("active", true); 69 } 70 71 public void actionPerformed(ActionEvent e) { 72 autoScale(); 69 73 } 70 74 -
trunk/src/org/openstreetmap/josm/gui/dialogs/RelationListDialog.java
r1866 r1868 1 1 package org.openstreetmap.josm.gui.dialogs; 2 2 3 import static org.openstreetmap.josm.tools.I18n.marktr;4 3 import static org.openstreetmap.josm.tools.I18n.tr; 5 4 … … 7 6 import java.awt.GridLayout; 8 7 import java.awt.event.ActionEvent; 9 import java.awt.event.ActionListener;10 8 import java.awt.event.KeyEvent; 11 9 import java.awt.event.MouseAdapter; 12 10 import java.awt.event.MouseEvent; 13 import java.util.ArrayList;14 import java.util.Collections;15 import java.util.List;16 11 17 12 import javax.swing.AbstractAction; 18 13 import javax.swing.DefaultListModel; 19 14 import javax.swing.JList; 20 import javax.swing.JOptionPane;21 15 import javax.swing.JPanel; 22 16 import javax.swing.JScrollPane; … … 26 20 27 21 import org.openstreetmap.josm.Main; 28 import org.openstreetmap.josm.command.ChangeCommand;29 import org.openstreetmap.josm.command.Command;30 import org.openstreetmap.josm.command.DeleteCommand;31 import org.openstreetmap.josm.command.SequenceCommand;32 22 import org.openstreetmap.josm.data.osm.DataSet; 33 23 import org.openstreetmap.josm.data.osm.OsmPrimitive; 34 24 import org.openstreetmap.josm.data.osm.Relation; 35 import org.openstreetmap.josm.gui.ConditionalOptionPaneUtil;36 import org.openstreetmap.josm.gui.OptionPaneUtil;37 25 import org.openstreetmap.josm.gui.OsmPrimitivRenderer; 38 26 import org.openstreetmap.josm.gui.PrimitiveNameFormatter; 39 27 import org.openstreetmap.josm.gui.SideButton; 40 import org.openstreetmap.josm.gui.dialogs.relation.ParentRelationLoadingTask;41 import org.openstreetmap.josm.gui.dialogs.relation.RelationDialogManager;42 28 import org.openstreetmap.josm.gui.dialogs.relation.RelationEditor; 43 29 import org.openstreetmap.josm.gui.layer.DataChangeListener; … … 45 31 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 46 32 import org.openstreetmap.josm.gui.layer.Layer.LayerChangeListener; 47 import org.openstreetmap.josm.gui.progress.PleaseWaitProgressMonitor;48 33 import org.openstreetmap.josm.tools.GBC; 49 34 import org.openstreetmap.josm.tools.ImageProvider; 50 35 import org.openstreetmap.josm.tools.Shortcut; 51 52 import com.sun.corba.se.spi.legacy.connection.GetEndPointInfoAgainException;53 36 54 37 /** -
trunk/src/org/openstreetmap/josm/gui/dialogs/relation/GenericRelationEditor.java
r1857 r1868 327 327 pnl.setLayout(new GridBagLayout()); 328 328 // setting up the member table 329 memberTable = new MemberTable(memberTableModel); 329 memberTable = new MemberTable(getLayer(),memberTableModel); 330 330 331 331 memberTable.getSelectionModel().addListSelectionListener(new SelectionSynchronizer()); … … 666 666 ); 667 667 switch(ret) { 668 case ConditionalOptionPaneUtil.DIALOG_DISABLED_OPTION: return; 669 case JOptionPane.CLOSED_OPTION: return; 670 case JOptionPane.NO_OPTION: return; 671 case JOptionPane.YES_OPTION: 672 memberTableModel.removeMembersReferringTo(toCheck); 673 break; 668 case ConditionalOptionPaneUtil.DIALOG_DISABLED_OPTION: return; 669 case JOptionPane.CLOSED_OPTION: return; 670 case JOptionPane.NO_OPTION: return; 671 case JOptionPane.YES_OPTION: 672 memberTableModel.removeMembersReferringTo(toCheck); 673 break; 674 674 } 675 675 } … … 704 704 ); 705 705 switch(ret) { 706 case ConditionalOptionPaneUtil.DIALOG_DISABLED_OPTION : return true; 707 case JOptionPane.YES_OPTION: return true; 708 case JOptionPane.NO_OPTION: return false; 709 case JOptionPane.CLOSED_OPTION: return false; 710 case JOptionPane.CANCEL_OPTION: throw new AddAbortException(); 706 case ConditionalOptionPaneUtil.DIALOG_DISABLED_OPTION : return true; 707 case JOptionPane.YES_OPTION: return true; 708 case JOptionPane.NO_OPTION: return false; 709 case JOptionPane.CLOSED_OPTION: return false; 710 case JOptionPane.CANCEL_OPTION: throw new AddAbortException(); 711 711 } 712 712 // should not happen … … 1079 1079 ); 1080 1080 switch(ret) { 1081 case JOptionPane.CANCEL_OPTION: return false; 1082 case JOptionPane.YES_OPTION: return true; 1083 case JOptionPane.NO_OPTION: return false; 1081 case JOptionPane.CANCEL_OPTION: return false; 1082 case JOptionPane.YES_OPTION: return true; 1083 case JOptionPane.NO_OPTION: return false; 1084 1084 } 1085 1085 return false; -
trunk/src/org/openstreetmap/josm/gui/dialogs/relation/MemberTable.java
r1804 r1868 2 2 package org.openstreetmap.josm.gui.dialogs.relation; 3 3 4 import java.awt.Dimension;5 import java.awt.Rectangle;6 4 import java.awt.event.ActionEvent; 7 5 import java.awt.event.KeyEvent; 6 import java.awt.event.MouseAdapter; 7 import java.awt.event.MouseEvent; 8 8 9 9 import javax.swing.AbstractAction; 10 10 import javax.swing.JComponent; 11 import javax.swing.JPopupMenu; 11 12 import javax.swing.JTable; 12 13 import javax.swing.KeyStroke; 13 14 import javax.swing.ListSelectionModel; 15 import javax.swing.event.ListSelectionEvent; 16 import javax.swing.event.ListSelectionListener; 14 17 import javax.swing.table.TableColumnModel; 15 18 19 import org.openstreetmap.josm.Main; 20 import org.openstreetmap.josm.actions.AutoScaleAction; 21 import org.openstreetmap.josm.data.osm.DataSet; 22 import org.openstreetmap.josm.data.osm.OsmPrimitive; 23 import org.openstreetmap.josm.gui.layer.Layer; 24 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 25 import org.openstreetmap.josm.gui.layer.Layer.LayerChangeListener; 26 27 import static org.openstreetmap.josm.tools.I18n.tr; 28 16 29 public class MemberTable extends JTable implements IMemberModelListener { 30 31 /** 32 * the data layer in whose context relation members are edited in this table 33 */ 34 protected OsmDataLayer layer; 35 36 /** the popup menu */ 37 protected JPopupMenu popupMenu; 17 38 18 39 /** … … 22 43 * @param columnModel 23 44 */ 24 public MemberTable(MemberTableModel model) { 45 public MemberTable(OsmDataLayer layer, MemberTableModel model) { 25 46 super(model, new MemberTableColumnModel(), model.getSelectionModel()); 47 this.layer = layer; 26 48 model.addMemberModelListener(this); 27 49 init(); 50 28 51 } 29 52 … … 38 61 // make ENTER behave like TAB 39 62 // 40 getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT) 41 .put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0, false), "selectNextColumnCell");63 getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put( 64 KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0, false), "selectNextColumnCell"); 42 65 43 66 // install custom navigation actions … … 45 68 getActionMap().put("selectNextColumnCell", new SelectNextColumnCellAction()); 46 69 getActionMap().put("selectPreviousColumnCell", new SelectPreviousColumnCellAction()); 47 } 48 49 /** 50 * adjusts the width of the columns for the tag name and the tag value 51 * to the width of the scroll panes viewport. 70 71 addMouseListener(new PopupListener()); 72 } 73 74 /** 75 * adjusts the width of the columns for the tag name and the tag value to the width of the 76 * scroll panes viewport. 52 77 * 53 78 * Note: {@see #getPreferredScrollableViewportSize()} did not work as expected … … 71 96 72 97 public void makeMemberVisible(int index) { 73 scrollRectToVisible( 74 getCellRect(index, 0, true) 75 ); 76 } 77 78 /** 79 * Action to be run when the user navigates to the next cell in the table, 80 * for instance by pressing TAB or ENTER. The action alters the standard 81 * navigation path from cell to cell: 82 * <ul> 83 * <li>it jumps over cells in the first column</li> 84 * <li>it automatically add a new empty row when the user leaves the 85 * last cell in the table</li> 86 * <ul> 87 * 88 * 89 */ 90 class SelectNextColumnCellAction extends AbstractAction { 98 scrollRectToVisible(getCellRect(index, 0, true)); 99 } 100 101 /** 102 * Action to be run when the user navigates to the next cell in the table, for instance by 103 * pressing TAB or ENTER. The action alters the standard navigation path from cell to cell: <ul> 104 * <li>it jumps over cells in the first column</li> <li>it automatically add a new empty row 105 * when the user leaves the last cell in the table</li> <ul> 106 * 107 * 108 */ 109 class SelectNextColumnCellAction extends AbstractAction { 91 110 public void actionPerformed(ActionEvent e) { 92 111 run(); … … 102 121 if (col == 0 && row < getRowCount() - 1) { 103 122 row++; 104 } else if (row < getRowCount() -1) {105 col =0;123 } else if (row < getRowCount() - 1) { 124 col = 0; 106 125 row++; 107 126 } … … 110 129 } 111 130 112 113 /** 114 * Action to be run when the user navigates to the previous cell in the table, 115 * for instance by pressing Shift-TAB 116 * 117 */ 118 class SelectPreviousColumnCellAction extends AbstractAction { 131 /** 132 * Action to be run when the user navigates to the previous cell in the table, for instance by 133 * pressing Shift-TAB 134 * 135 */ 136 class SelectPreviousColumnCellAction extends AbstractAction { 119 137 120 138 public void actionPerformed(ActionEvent e) { … … 125 143 } 126 144 127 128 145 if (col == 0 && row == 0) { 129 146 // change nothing … … 135 152 } 136 153 } 154 155 /** 156 * creates the popup men 157 */ 158 protected void createPopupMenu() { 159 popupMenu = new JPopupMenu(); 160 ZoomToAction zoomToAction = new ZoomToAction(); 161 Layer.listeners.add(zoomToAction); 162 getSelectionModel().addListSelectionListener(zoomToAction); 163 popupMenu.add(zoomToAction); 164 } 165 166 /** 167 * Replies the popup menu for this table 168 * 169 * @return the popup menu 170 */ 171 protected JPopupMenu getPopUpMenu() { 172 if (popupMenu == null) { 173 createPopupMenu(); 174 } 175 return popupMenu; 176 } 177 178 class PopupListener extends MouseAdapter { 179 @Override 180 public void mousePressed(MouseEvent e) { 181 showPopup(e); 182 } 183 184 @Override 185 public void mouseReleased(MouseEvent e) { 186 showPopup(e); 187 } 188 189 private void showPopup(MouseEvent e) { 190 if (e.isPopupTrigger()) { 191 getPopUpMenu().show(e.getComponent(), e.getX(), e.getY()); 192 } 193 } 194 } 195 196 class ZoomToAction extends AbstractAction implements LayerChangeListener, ListSelectionListener { 197 public ZoomToAction() { 198 putValue(NAME, tr("Zoom to")); 199 putValue(SHORT_DESCRIPTION, tr("Zoom to primitive the first selected member refers to")); 200 updateEnabledState(); 201 } 202 203 public void actionPerformed(ActionEvent e) { 204 if (! isEnabled()) 205 return; 206 int rows[] = getSelectedRows(); 207 if (rows == null || rows.length == 0) 208 return; 209 int row = rows[0]; 210 OsmPrimitive primitive = getMemberTableModel().getReferredPrimitive(row); 211 layer.data.setSelected(primitive); 212 DataSet.fireSelectionChanged(layer.data.getSelected()); 213 AutoScaleAction action = new AutoScaleAction("selection"); 214 action.autoScale(); 215 } 216 217 protected void updateEnabledState() { 218 if (Main.main == null || Main.main.getEditLayer() != layer) { 219 setEnabled(false); 220 putValue(SHORT_DESCRIPTION, tr("Zooming disabled because layer of this relation is not active")); 221 return; 222 } 223 if (getSelectedRowCount() == 0) { 224 setEnabled(false); 225 putValue(SHORT_DESCRIPTION, tr("Zooming disabled because there is no selected member")); 226 return; 227 } 228 setEnabled(true); 229 putValue(SHORT_DESCRIPTION, tr("Zoom to primitive the first selected member refers to")); 230 } 231 232 public void valueChanged(ListSelectionEvent e) { 233 updateEnabledState(); 234 } 235 236 public void activeLayerChange(Layer oldLayer, Layer newLayer) { 237 updateEnabledState(); 238 } 239 240 public void layerAdded(Layer newLayer) { 241 updateEnabledState(); 242 } 243 244 public void layerRemoved(Layer oldLayer) { 245 updateEnabledState(); 246 } 247 } 248 249 protected MemberTableModel getMemberTableModel() { 250 return (MemberTableModel) getModel(); 251 } 137 252 } -
trunk/src/org/openstreetmap/josm/io/OsmApi.java
r1867 r1868 24 24 import java.util.Properties; 25 25 26 import javax.swing.JPopupMenu; 26 27 import javax.xml.parsers.SAXParserFactory; 27 28 … … 502 503 return capabilities; 503 504 } 505 504 506 }
Note:
See TracChangeset
for help on using the changeset viewer.