Changeset 5297 in josm for trunk/src/org/openstreetmap
- Timestamp:
- 2012-06-24T19:14:38+02:00 (12 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 5 added
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/MergeLayerAction.java
r5233 r5297 82 82 @Override 83 83 protected void updateEnabledState() { 84 if (getEditLayer() == null) { 85 setEnabled(false); 86 return; 87 } 88 setEnabled(!LayerListDialog.getInstance().getModel().getPossibleMergeTargets(getEditLayer()).isEmpty()); 84 GuiHelper.runInEDT(new Runnable() { 85 @Override 86 public void run() { 87 if (getEditLayer() == null) { 88 setEnabled(false); 89 return; 90 } 91 setEnabled(!LayerListDialog.getInstance().getModel().getPossibleMergeTargets(getEditLayer()).isEmpty()); 92 } 93 }); 89 94 } 90 95 -
trunk/src/org/openstreetmap/josm/gui/MapStatus.java
r5137 r5297 47 47 import org.openstreetmap.josm.gui.progress.PleaseWaitProgressMonitor; 48 48 import org.openstreetmap.josm.gui.progress.PleaseWaitProgressMonitor.ProgressMonitorDialog; 49 import org.openstreetmap.josm.gui.util.GuiHelper; 49 50 import org.openstreetmap.josm.tools.GBC; 50 51 import org.openstreetmap.josm.tools.ImageProvider; … … 757 758 setHelpText(null, t); 758 759 } 759 public void setHelpText(Object id, String text) {760 public void setHelpText(Object id, final String text) { 760 761 761 762 StatusTextHistory entry = new StatusTextHistory(id, text); … … 764 765 statusText.add(entry); 765 766 766 helpText.setText(text); 767 helpText.setToolTipText(text); 767 GuiHelper.runInEDT(new Runnable() { 768 @Override 769 public void run() { 770 helpText.setText(text); 771 helpText.setToolTipText(text); 772 } 773 }); 768 774 } 769 775 public void resetHelpText(Object id) { -
trunk/src/org/openstreetmap/josm/gui/conflict/pair/ConflictResolver.java
r5288 r5297 338 338 return resolvedCompletely; 339 339 } 340 341 public void unregisterListeners() { 342 nodeListMerger.unlinkAsListener(); 343 relationMemberMerger.unlinkAsListener(); 344 } 340 345 } -
trunk/src/org/openstreetmap/josm/gui/conflict/pair/ListMergeModel.java
r5266 r5297 29 29 import org.openstreetmap.josm.gui.HelpAwareOptionPane; 30 30 import org.openstreetmap.josm.gui.help.HelpUtil; 31 import org.openstreetmap.josm.gui.widgets.OsmPrimitivesTableModel; 31 32 32 33 /** … … 69 70 protected HashMap<ListRole, ArrayList<T>> entries; 70 71 71 protected DefaultTableModel myEntriesTableModel;72 protected DefaultTableModel theirEntriesTableModel;73 protected DefaultTableModel mergedEntriesTableModel;72 protected EntriesTableModel myEntriesTableModel; 73 protected EntriesTableModel theirEntriesTableModel; 74 protected EntriesTableModel mergedEntriesTableModel; 74 75 75 76 protected EntriesSelectionModel myEntriesSelectionModel; … … 210 211 } 211 212 212 public TableModel getMyTableModel() {213 public OsmPrimitivesTableModel getMyTableModel() { 213 214 return myEntriesTableModel; 214 215 } 215 216 216 public TableModel getTheirTableModel() {217 public OsmPrimitivesTableModel getTheirTableModel() { 217 218 return theirEntriesTableModel; 218 219 } 219 220 220 public TableModel getMergedTableModel() {221 public OsmPrimitivesTableModel getMergedTableModel() { 221 222 return mergedEntriesTableModel; 222 223 } … … 535 536 protected boolean myAndTheirEntriesEqual() { 536 537 537 if (getMyEntries ().size() != getTheirEntries().size())538 if (getMyEntriesSize() != getTheirEntriesSize()) 538 539 return false; 539 for (int i=0; i < getMyEntries ().size(); i++) {540 for (int i=0; i < getMyEntriesSize(); i++) { 540 541 if (! isEqualEntry(getMyEntries().get(i), getTheirEntries().get(i))) 541 542 return false; … … 555 556 * @see ListMergeModel#getMergedTableModel() 556 557 */ 557 public class EntriesTableModel extends DefaultTableModel {558 public class EntriesTableModel extends DefaultTableModel implements OsmPrimitivesTableModel { 558 559 private final ListRole role; 559 560 … … 675 676 return role; 676 677 } 678 679 @Override 680 public OsmPrimitive getReferredPrimitive(int idx) { 681 return (OsmPrimitive) getValueAt(idx, 1); 682 } 677 683 } 678 684 -
trunk/src/org/openstreetmap/josm/gui/conflict/pair/ListMerger.java
r5266 r5297 36 36 import javax.swing.event.ListSelectionListener; 37 37 38 import org.openstreetmap.josm.gui.widgets.OsmPrimitivesTable; 38 39 import org.openstreetmap.josm.tools.CheckParameterUtil; 39 40 import org.openstreetmap.josm.tools.ImageProvider; … … 46 47 */ 47 48 public abstract class ListMerger<T> extends JPanel implements PropertyChangeListener, Observer { 48 protected JTable myEntriesTable;49 protected JTable mergedEntriesTable;50 protected JTable theirEntriesTable;49 protected OsmPrimitivesTable myEntriesTable; 50 protected OsmPrimitivesTable mergedEntriesTable; 51 protected OsmPrimitivesTable theirEntriesTable; 51 52 52 53 protected ListMergeModel<T> model; … … 878 879 trn("Their version ({0} entry)", "Their version ({0} entries)", model.getTheirEntriesSize(), model.getTheirEntriesSize()) 879 880 ); 881 } 882 883 public void unlinkAsListener() { 884 myEntriesTable.unlinkAsListener(); 885 mergedEntriesTable.unlinkAsListener(); 886 theirEntriesTable.unlinkAsListener(); 880 887 } 881 888 -
trunk/src/org/openstreetmap/josm/gui/conflict/pair/nodes/NodeListMerger.java
r5266 r5297 2 2 package org.openstreetmap.josm.gui.conflict.pair.nodes; 3 3 4 import java.util.List; 5 4 6 import javax.swing.JScrollPane; 5 import javax.swing.JTable;6 7 8 import org.openstreetmap.josm.Main; 7 9 import org.openstreetmap.josm.data.conflict.Conflict; 8 10 import org.openstreetmap.josm.data.osm.Node; … … 11 13 import org.openstreetmap.josm.gui.conflict.pair.IConflictResolver; 12 14 import org.openstreetmap.josm.gui.conflict.pair.ListMerger; 15 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 13 16 14 17 /** … … 23 26 @Override 24 27 protected JScrollPane buildMyElementsTable() { 25 myEntriesTable = new JTable( 28 myEntriesTable = new NodeListTable( 29 "table.mynodes", 26 30 model.getMyTableModel(), 27 new NodeListColumnModel(28 new NodeListTableCellRenderer()29 ),30 31 model.getMySelectionModel() 31 32 ); 32 myEntriesTable.setName("table.mynodes");33 myEntriesTable.setAutoResizeMode(JTable.AUTO_RESIZE_LAST_COLUMN);34 33 return embeddInScrollPane(myEntriesTable); 35 34 } … … 37 36 @Override 38 37 protected JScrollPane buildMergedElementsTable() { 39 mergedEntriesTable = new JTable( 38 mergedEntriesTable = new NodeListTable( 39 "table.mergednodes", 40 40 model.getMergedTableModel(), 41 new NodeListColumnModel(42 new NodeListTableCellRenderer()43 ),44 41 model.getMergedSelectionModel() 45 42 ); 46 mergedEntriesTable.setName("table.mergednodes");47 mergedEntriesTable.setAutoResizeMode(JTable.AUTO_RESIZE_LAST_COLUMN);48 43 return embeddInScrollPane(mergedEntriesTable); 49 44 } … … 51 46 @Override 52 47 protected JScrollPane buildTheirElementsTable() { 53 theirEntriesTable = new JTable( 48 theirEntriesTable = new NodeListTable( 49 "table.theirnodes", 54 50 model.getTheirTableModel(), 55 new NodeListColumnModel(56 new NodeListTableCellRenderer()57 ),58 51 model.getTheirSelectionModel() 59 52 ); 60 theirEntriesTable.setName("table.theirnodes");61 theirEntriesTable.setAutoResizeMode(JTable.AUTO_RESIZE_LAST_COLUMN);62 53 return embeddInScrollPane(theirEntriesTable); 63 54 } 64 55 65 56 public void populate(Conflict<? extends OsmPrimitive> conflict) { 66 ((NodeListMergeModel)model).populate((Way)conflict.getMy(), (Way)conflict.getTheir()); 57 Way myWay = (Way)conflict.getMy(); 58 Way theirWay = (Way)conflict.getTheir(); 59 ((NodeListMergeModel)model).populate(myWay, theirWay); 60 myEntriesTable.setLayer(findLayerFor(myWay)); 61 theirEntriesTable.setLayer(findLayerFor(theirWay)); 62 } 63 64 protected OsmDataLayer findLayerFor(Way w) { 65 List<OsmDataLayer> layers = Main.map.mapView.getLayersOfType(OsmDataLayer.class); 66 // Find layer with same dataset 67 for (OsmDataLayer layer : layers) { 68 if (layer.data == w.getDataSet()) { 69 return layer; 70 } 71 } 72 // Conflict after merging layers: a dataset could be no more in any layer, try to find another layer with same primitive 73 for (OsmDataLayer layer : layers) { 74 for (Way way : layer.data.getWays()) { 75 if (way.getPrimitiveId().equals(w.getPrimitiveId())) { 76 return layer; 77 } 78 } 79 } 80 return null; 67 81 } 68 82 -
trunk/src/org/openstreetmap/josm/gui/conflict/pair/relation/RelationMemberMerger.java
r5266 r5297 3 3 4 4 import javax.swing.JScrollPane; 5 import javax.swing.JTable;6 5 7 6 import org.openstreetmap.josm.data.conflict.Conflict; … … 18 17 @Override 19 18 protected JScrollPane buildMyElementsTable() { 20 myEntriesTable = new JTable( 19 myEntriesTable = new RelationMemberTable( 20 "table.mymembers", 21 21 model.getMyTableModel(), 22 new RelationMemberListColumnModel(),23 22 model.getMySelectionModel() 24 23 ); 25 myEntriesTable.setName("table.mynodes");26 myEntriesTable.setAutoResizeMode(JTable.AUTO_RESIZE_LAST_COLUMN);27 24 return embeddInScrollPane(myEntriesTable); 28 25 } … … 30 27 @Override 31 28 protected JScrollPane buildMergedElementsTable() { 32 mergedEntriesTable = new JTable( 29 mergedEntriesTable = new RelationMemberTable( 30 "table.mergedmembers", 33 31 model.getMergedTableModel(), 34 new RelationMemberListColumnModel(),35 32 model.getMergedSelectionModel() 36 33 ); 37 34 mergedEntriesTable.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE); 38 mergedEntriesTable.setName("table.mergednodes");39 mergedEntriesTable.setAutoResizeMode(JTable.AUTO_RESIZE_LAST_COLUMN);40 35 return embeddInScrollPane(mergedEntriesTable); 41 36 } … … 43 38 @Override 44 39 protected JScrollPane buildTheirElementsTable() { 45 theirEntriesTable = new JTable( 40 theirEntriesTable = new RelationMemberTable( 41 "table.theirmembers", 46 42 model.getTheirTableModel(), 47 new RelationMemberListColumnModel(),48 43 model.getTheirSelectionModel() 49 44 ); 50 theirEntriesTable.setName("table.theirnodes");51 theirEntriesTable.setAutoResizeMode(JTable.AUTO_RESIZE_LAST_COLUMN);52 45 return embeddInScrollPane(theirEntriesTable); 53 46 } -
trunk/src/org/openstreetmap/josm/gui/dialogs/ConflictDialog.java
r5266 r5297 46 46 import org.openstreetmap.josm.gui.SideButton; 47 47 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 48 import org.openstreetmap.josm.gui.util.GuiHelper; 48 49 import org.openstreetmap.josm.tools.ImageProvider; 49 50 import org.openstreetmap.josm.tools.Shortcut; … … 156 157 public final void refreshView() { 157 158 OsmDataLayer editLayer = Main.main.getEditLayer(); 158 conflicts = editLayer == null?new ConflictCollection():editLayer.getConflicts(); 159 model.fireContentChanged(); 160 updateTitle(conflicts.size()); 159 conflicts = (editLayer == null ? new ConflictCollection() : editLayer.getConflicts()); 160 GuiHelper.runInEDT(new Runnable() { 161 @Override 162 public void run() { 163 model.fireContentChanged(); 164 updateTitle(conflicts.size()); 165 } 166 }); 161 167 } 162 168 -
trunk/src/org/openstreetmap/josm/gui/dialogs/ConflictResolutionDialog.java
r5266 r5297 9 9 import java.awt.Dimension; 10 10 import java.awt.FlowLayout; 11 import java.awt.Point;12 11 import java.awt.event.ActionEvent; 13 12 import java.beans.PropertyChangeEvent; … … 100 99 private void unregisterListeners() { 101 100 resolver.removePropertyChangeListener(applyResolutionAction); 101 resolver.unregisterListeners(); 102 102 } 103 103 -
trunk/src/org/openstreetmap/josm/gui/dialogs/LayerListDialog.java
r5275 r5297 63 63 import org.openstreetmap.josm.gui.layer.Layer.LayerAction; 64 64 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 65 import org.openstreetmap.josm.gui.util.GuiHelper; 65 66 import org.openstreetmap.josm.gui.widgets.PopupMenuLauncher; 66 67 import org.openstreetmap.josm.tools.CheckParameterUtil; … … 704 705 @Override 705 706 public void updateEnabledState() { 706 if (layer == null) { 707 if (getModel().getSelectedLayers().size() != 1) { 708 setEnabled(false); 709 return; 710 } 711 Layer selectedLayer = getModel().getSelectedLayers().get(0); 712 setEnabled(!isActiveLayer(selectedLayer)); 713 } else { 714 setEnabled(!isActiveLayer(layer)); 715 } 707 GuiHelper.runInEDT(new Runnable() { 708 @Override 709 public void run() { 710 if (layer == null) { 711 if (getModel().getSelectedLayers().size() != 1) { 712 setEnabled(false); 713 return; 714 } 715 Layer selectedLayer = getModel().getSelectedLayers().get(0); 716 setEnabled(!isActiveLayer(selectedLayer)); 717 } else { 718 setEnabled(!isActiveLayer(layer)); 719 } 720 } 721 }); 716 722 } 717 723 … … 1255 1261 return; 1256 1262 layer.removePropertyChangeListener(this); 1257 int size = getRowCount(); 1258 List<Integer> rows = getSelectedRows(); 1259 if (rows.isEmpty() && size > 0) { 1260 selectionModel.setSelectionInterval(size-1, size-1); 1261 } 1262 fireTableDataChanged(); 1263 fireRefresh(); 1264 ensureActiveSelected(); 1263 final int size = getRowCount(); 1264 final List<Integer> rows = getSelectedRows(); 1265 GuiHelper.runInEDTAndWait(new Runnable() { 1266 @Override 1267 public void run() { 1268 if (rows.isEmpty() && size > 0) { 1269 selectionModel.setSelectionInterval(size-1, size-1); 1270 } 1271 fireTableDataChanged(); 1272 fireRefresh(); 1273 ensureActiveSelected(); 1274 } 1275 }); 1265 1276 } 1266 1277 … … 1426 1437 if (getLayers().isEmpty()) 1427 1438 return; 1428 if (getActiveLayer() != null) { 1439 final Layer activeLayer = getActiveLayer(); 1440 if (activeLayer != null) { 1429 1441 // there's an active layer - select it and make it 1430 1442 // visible 1431 int idx = getLayers().indexOf( getActiveLayer());1443 int idx = getLayers().indexOf(activeLayer); 1432 1444 selectionModel.setSelectionInterval(idx, idx); 1433 1445 ensureSelectedIsVisible(); … … 1506 1518 /* ------------------------------------------------------------------------------ */ 1507 1519 @Override 1508 public void activeLayerChange(Layer oldLayer, Layer newLayer) { 1509 if (oldLayer != null) { 1510 int idx = getLayers().indexOf(oldLayer); 1511 if (idx >= 0) { 1512 fireTableRowsUpdated(idx,idx); 1513 } 1514 } 1515 1516 if (newLayer != null) { 1517 int idx = getLayers().indexOf(newLayer); 1518 if (idx >= 0) { 1519 fireTableRowsUpdated(idx,idx); 1520 } 1521 } 1522 ensureActiveSelected(); 1520 public void activeLayerChange(final Layer oldLayer, final Layer newLayer) { 1521 GuiHelper.runInEDTAndWait(new Runnable() { 1522 @Override 1523 public void run() { 1524 if (oldLayer != null) { 1525 int idx = getLayers().indexOf(oldLayer); 1526 if (idx >= 0) { 1527 fireTableRowsUpdated(idx,idx); 1528 } 1529 } 1530 1531 if (newLayer != null) { 1532 int idx = getLayers().indexOf(newLayer); 1533 if (idx >= 0) { 1534 fireTableRowsUpdated(idx,idx); 1535 } 1536 } 1537 ensureActiveSelected(); 1538 } 1539 }); 1523 1540 } 1524 1541 -
trunk/src/org/openstreetmap/josm/gui/dialogs/relation/MemberTable.java
r5081 r5297 8 8 import java.awt.event.ActionEvent; 9 9 import java.awt.event.KeyEvent; 10 import java.awt.event.MouseAdapter;11 import java.awt.event.MouseEvent;12 10 import java.util.Arrays; 13 11 import java.util.Collection; … … 20 18 import javax.swing.KeyStroke; 21 19 import javax.swing.ListSelectionModel; 22 import javax.swing.SwingUtilities;23 20 import javax.swing.event.ListSelectionEvent; 24 21 import javax.swing.event.ListSelectionListener; … … 26 23 import org.openstreetmap.josm.Main; 27 24 import org.openstreetmap.josm.actions.AutoScaleAction; 28 import org.openstreetmap.josm. data.osm.OsmPrimitive;25 import org.openstreetmap.josm.actions.ZoomToAction; 29 26 import org.openstreetmap.josm.data.osm.Way; 30 27 import org.openstreetmap.josm.gui.MapView; … … 33 30 import org.openstreetmap.josm.gui.layer.Layer; 34 31 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 35 36 public class MemberTable extends JTable implements IMemberModelListener { 37 38 /** 39 * the data layer in whose context relation members are edited in this table 40 */ 41 protected OsmDataLayer layer; 42 43 /** the popup menu */ 44 protected JPopupMenu popupMenu; 45 private ZoomToAction zoomToAction; 32 import org.openstreetmap.josm.gui.widgets.OsmPrimitivesTable; 33 34 public class MemberTable extends OsmPrimitivesTable implements IMemberModelListener { 35 36 /** the additional actions in popup menu */ 46 37 private ZoomToGapAction zoomToGap; 47 38 … … 54 45 public MemberTable(OsmDataLayer layer, MemberTableModel model) { 55 46 super(model, new MemberTableColumnModel(layer.data), model.getSelectionModel()); 56 this.layer = layer;47 setLayer(layer); 57 48 model.addMemberModelListener(this); 58 49 init(); 59 60 50 } 61 51 … … 79 69 getActionMap().put("selectNextColumnCell", new SelectNextColumnCellAction()); 80 70 getActionMap().put("selectPreviousColumnCell", new SelectPreviousColumnCellAction()); 81 82 addMouseListener(new PopupListener()); 83 addMouseListener(new DblClickHandler()); 71 } 72 73 @Override 74 protected ZoomToAction buildZoomToAction() { 75 return new ZoomToAction(this); 76 } 77 78 @Override 79 protected JPopupMenu buildPopupMenu() { 80 JPopupMenu menu = super.buildPopupMenu(); 81 zoomToGap = new ZoomToGapAction(); 82 MapView.addLayerChangeListener(zoomToGap); 83 getSelectionModel().addListSelectionListener(zoomToGap); 84 menu.add(zoomToGap); 85 menu.addSeparator(); 86 menu.add(new SelectPreviousGapAction()); 87 menu.add(new SelectNextGapAction()); 88 return menu; 84 89 } 85 90 … … 156 161 } 157 162 158 /** 159 * Replies the popup menu for this table 160 * 161 * @return the popup menu 162 */ 163 protected JPopupMenu getPopUpMenu() { 164 if (popupMenu == null) { 165 popupMenu = new JPopupMenu(); 166 zoomToAction = new ZoomToAction(); 167 MapView.addLayerChangeListener(zoomToAction); 168 getSelectionModel().addListSelectionListener(zoomToAction); 169 popupMenu.add(zoomToAction); 170 zoomToGap = new ZoomToGapAction(); 171 MapView.addLayerChangeListener(zoomToGap); 172 getSelectionModel().addListSelectionListener(zoomToGap); 173 popupMenu.add(zoomToGap); 174 popupMenu.addSeparator(); 175 popupMenu.add(new SelectPreviousGapAction()); 176 popupMenu.add(new SelectNextGapAction()); 177 } 178 return popupMenu; 179 } 180 163 @Override 181 164 public void unlinkAsListener() { 182 MapView.removeLayerChangeListener(zoomToAction);165 super.unlinkAsListener(); 183 166 MapView.removeLayerChangeListener(zoomToGap); 184 }185 186 class PopupListener extends MouseAdapter {187 @Override188 public void mousePressed(MouseEvent e) {189 showPopup(e);190 }191 192 @Override193 public void mouseReleased(MouseEvent e) {194 showPopup(e);195 }196 197 private void showPopup(MouseEvent e) {198 if (e.isPopupTrigger()) {199 getPopUpMenu().show(e.getComponent(), e.getX(), e.getY());200 }201 }202 }203 204 private class ZoomToAction extends AbstractAction implements LayerChangeListener, ListSelectionListener {205 public ZoomToAction() {206 putValue(NAME, tr("Zoom to"));207 putValue(SHORT_DESCRIPTION, tr("Zoom to the object the first selected member refers to"));208 updateEnabledState();209 }210 211 public void actionPerformed(ActionEvent e) {212 if (! isEnabled())213 return;214 int rows[] = getSelectedRows();215 if (rows == null || rows.length == 0)216 return;217 int row = rows[0];218 OsmPrimitive primitive = getMemberTableModel().getReferredPrimitive(row);219 layer.data.setSelected(primitive);220 AutoScaleAction.autoScale("selection");221 }222 223 protected void updateEnabledState() {224 if (Main.main == null || Main.main.getEditLayer() != layer) {225 setEnabled(false);226 putValue(SHORT_DESCRIPTION, tr("Zooming disabled because layer of this relation is not active"));227 return;228 }229 if (getSelectedRowCount() == 0) {230 setEnabled(false);231 putValue(SHORT_DESCRIPTION, tr("Zooming disabled because there is no selected member"));232 return;233 }234 setEnabled(true);235 putValue(SHORT_DESCRIPTION, tr("Zoom to the object the first selected member refers to"));236 }237 238 public void valueChanged(ListSelectionEvent e) {239 updateEnabledState();240 }241 242 public void activeLayerChange(Layer oldLayer, Layer newLayer) {243 updateEnabledState();244 }245 246 public void layerAdded(Layer newLayer) {247 updateEnabledState();248 }249 250 public void layerRemoved(Layer oldLayer) {251 updateEnabledState();252 }253 167 } 254 168 … … 316 230 Way way = (Way) getMemberTableModel().getReferredPrimitive(getSelectedRows()[0]); 317 231 if (!connectionType.linkPrev) { 318 layer.data.setSelected(WayConnectionType.Direction.FORWARD.equals(connectionType.direction)232 getLayer().data.setSelected(WayConnectionType.Direction.FORWARD.equals(connectionType.direction) 319 233 ? way.firstNode() : way.lastNode()); 320 234 AutoScaleAction.autoScale("selection"); 321 235 } else if (!connectionType.linkNext) { 322 layer.data.setSelected(WayConnectionType.Direction.FORWARD.equals(connectionType.direction)236 getLayer().data.setSelected(WayConnectionType.Direction.FORWARD.equals(connectionType.direction) 323 237 ? way.lastNode() : way.firstNode()); 324 238 AutoScaleAction.autoScale("selection"); … … 328 242 private void updateEnabledState() { 329 243 setEnabled(Main.main != null 330 && Main.main.getEditLayer() == layer244 && Main.main.getEditLayer() == getLayer() 331 245 && getSelectedRowCount() == 1 332 246 && hasGap()); … … 357 271 return (MemberTableModel) getModel(); 358 272 } 359 360 private class DblClickHandler extends MouseAdapter {361 362 protected void setSelection(MouseEvent e) {363 int row = rowAtPoint(e.getPoint());364 if (row < 0) return;365 OsmPrimitive primitive = getMemberTableModel().getReferredPrimitive(row);366 getMemberTableModel().getLayer().data.setSelected(primitive.getPrimitiveId());367 }368 369 protected void addSelection(MouseEvent e) {370 int row = rowAtPoint(e.getPoint());371 if (row < 0) return;372 OsmPrimitive primitive = getMemberTableModel().getReferredPrimitive(row);373 getMemberTableModel().getSelectionModel().addSelectionInterval(row, row);374 getMemberTableModel().getLayer().data.addSelected(primitive.getPrimitiveId());375 376 }377 378 @Override379 public void mouseClicked(MouseEvent e) {380 if (SwingUtilities.isLeftMouseButton(e) && e.getClickCount() > 1) {381 if (e.isControlDown()) {382 addSelection(e);383 } else {384 setSelection(e);385 }386 }387 }388 }389 273 } -
trunk/src/org/openstreetmap/josm/gui/dialogs/relation/MemberTableModel.java
r5266 r5297 45 45 import org.openstreetmap.josm.gui.dialogs.relation.WayConnectionType.Direction; 46 46 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 47 48 public class MemberTableModel extends AbstractTableModel implements TableModelListener, SelectionChangedListener, DataSetListener { 47 import org.openstreetmap.josm.gui.widgets.OsmPrimitivesTableModel; 48 49 public class MemberTableModel extends AbstractTableModel implements TableModelListener, SelectionChangedListener, DataSetListener, OsmPrimitivesTableModel { 49 50 50 51 /** … … 198 199 } 199 200 201 @Override 200 202 public OsmPrimitive getReferredPrimitive(int idx) { 201 203 return members.get(idx).getMember(); … … 650 652 * @return the unlinked node if element is a way, the node itself if element is a node, null otherwise 651 653 */ 652 private static Node getUnusedNode(RelationMember element, RelationMember linked_element)654 /*private static Node getUnusedNode(RelationMember element, RelationMember linked_element) 653 655 { 654 656 Node result = null; … … 677 679 678 680 return result; 679 } 681 }*/ 680 682 681 683 /* -
trunk/src/org/openstreetmap/josm/gui/layer/OsmDataLayer.java
r5275 r5297 78 78 import org.openstreetmap.josm.gui.progress.PleaseWaitProgressMonitor; 79 79 import org.openstreetmap.josm.gui.progress.ProgressMonitor; 80 import org.openstreetmap.josm.gui.util.GuiHelper; 80 81 import org.openstreetmap.josm.tools.DateUtils; 81 82 import org.openstreetmap.josm.tools.FilteredCollection; … … 386 387 ); 387 388 388 StringBuffer sb = new StringBuffer();389 final StringBuffer sb = new StringBuffer(); 389 390 sb.append("<html>").append(msg1).append("</html>"); 390 391 if (numNewConflicts > 0) { 391 ButtonSpec[] options = new ButtonSpec[] {392 final ButtonSpec[] options = new ButtonSpec[] { 392 393 new ButtonSpec( 393 394 tr("OK"), … … 397 398 ) 398 399 }; 399 HelpAwareOptionPane.showOptionDialog( 400 Main.parent, 401 sb.toString(), 402 tr("Conflicts detected"), 403 JOptionPane.WARNING_MESSAGE, 404 null, /* no icon */ 405 options, 406 options[0], 407 ht("/Concepts/Conflict#WarningAboutDetectedConflicts") 408 ); 409 Main.map.conflictDialog.unfurlDialog(); 410 Main.map.repaint(); 400 GuiHelper.runInEDT(new Runnable() { 401 @Override 402 public void run() { 403 HelpAwareOptionPane.showOptionDialog( 404 Main.parent, 405 sb.toString(), 406 tr("Conflicts detected"), 407 JOptionPane.WARNING_MESSAGE, 408 null, /* no icon */ 409 options, 410 options[0], 411 ht("/Concepts/Conflict#WarningAboutDetectedConflicts") 412 ); 413 Main.map.conflictDialog.unfurlDialog(); 414 Main.map.repaint(); 415 } 416 }); 411 417 } 412 418 } -
trunk/src/org/openstreetmap/josm/gui/util/GuiHelper.java
r5233 r5297 7 7 import java.awt.Container; 8 8 import java.awt.Image; 9 import java.lang.reflect.InvocationTargetException; 9 10 10 11 import javax.swing.Icon; … … 43 44 } 44 45 } 46 47 public static void runInEDTAndWait(Runnable task) { 48 if (SwingUtilities.isEventDispatchThread()) { 49 task.run(); 50 } else { 51 try { 52 SwingUtilities.invokeAndWait(task); 53 } catch (InterruptedException e) { 54 e.printStackTrace(); 55 } catch (InvocationTargetException e) { 56 e.printStackTrace(); 57 } 58 } 59 } 45 60 46 61 /**
Note:
See TracChangeset
for help on using the changeset viewer.