- Timestamp:
- 2018-08-12T14:27:32+02:00 (6 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 28 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/Main.java
r14140 r14143 4 4 import java.awt.Component; 5 5 import java.net.URL; 6 import java.util.Collection;7 import java.util.Collections;8 6 import java.util.Map; 9 7 import java.util.Set; … … 11 9 import org.openstreetmap.josm.data.Preferences; 12 10 import org.openstreetmap.josm.data.UndoRedoHandler; 13 import org.openstreetmap.josm.data.osm.DataSet; 14 import org.openstreetmap.josm.data.osm.IPrimitive; 15 import org.openstreetmap.josm.data.osm.OsmData; 16 import org.openstreetmap.josm.data.osm.OsmPrimitive; 11 import org.openstreetmap.josm.data.osm.IOsmDataManager; 17 12 import org.openstreetmap.josm.data.preferences.JosmBaseDirectories; 18 13 import org.openstreetmap.josm.data.projection.Projection; … … 32 27 * @since 98 33 28 */ 34 public abstract class Main {29 public abstract class Main implements IOsmDataManager { 35 30 36 31 /** … … 41 36 /** 42 37 * Global application. 43 */ 38 * @deprecated Not needed anymore 39 */ 40 @Deprecated 44 41 public static volatile Main main; 45 42 … … 83 80 main = instance; 84 81 } 85 86 /**87 * Replies the current selected OSM primitives, from a end-user point of view.88 * It is not always technically the same collection of primitives than {@link DataSet#getSelected()}.89 * @return The current selected OSM primitives, from a end-user point of view. Can be {@code null}.90 * @since 654691 */92 public Collection<OsmPrimitive> getInProgressSelection() {93 return Collections.emptyList();94 }95 96 /**97 * Replies the current selected primitives, from a end-user point of view.98 * It is not always technically the same collection of primitives than {@link OsmData#getSelected()}.99 * @return The current selected primitives, from a end-user point of view. Can be {@code null}.100 * @since 13926101 */102 public Collection<? extends IPrimitive> getInProgressISelection() {103 return Collections.emptyList();104 }105 106 /**107 * Gets the active edit data set (not read-only).108 * @return That data set, <code>null</code>.109 * @see #getActiveDataSet110 * @since 12691111 */112 public abstract DataSet getEditDataSet();113 114 /**115 * Gets the active data set (can be read-only).116 * @return That data set, <code>null</code>.117 * @see #getEditDataSet118 * @since 13434119 */120 public abstract DataSet getActiveDataSet();121 122 /**123 * Sets the active data set (and also edit data set if not read-only).124 * @param ds New data set, or <code>null</code>125 * @since 13434126 */127 public abstract void setActiveDataSet(DataSet ds);128 129 /**130 * Determines if the list of data sets managed by JOSM contains {@code ds}.131 * @param ds the data set to look for132 * @return {@code true} if the list of data sets managed by JOSM contains {@code ds}133 * @since 12718134 */135 public abstract boolean containsDataSet(DataSet ds);136 82 137 83 /////////////////////////////////////////////////////////////////////////// -
trunk/src/org/openstreetmap/josm/actions/JoinAreasAction.java
r14135 r14143 23 23 import javax.swing.JOptionPane; 24 24 25 import org.openstreetmap.josm.Main;26 25 import org.openstreetmap.josm.actions.ReverseWayAction.ReverseWayResult; 27 26 import org.openstreetmap.josm.command.AddCommand; … … 833 832 834 833 private void commitCommand(Command c) { 835 if ( Main.main != null &&addUndoRedo) {834 if (addUndoRedo) { 836 835 UndoRedoHandler.getInstance().add(c); 837 836 } else { … … 1600 1599 private void makeCommitsOneAction(String message) { 1601 1600 cmds.clear(); 1602 if ( Main.main != null &&addUndoRedo) {1601 if (addUndoRedo) { 1603 1602 UndoRedoHandler ur = UndoRedoHandler.getInstance(); 1604 1603 int i = Math.max(ur.commands.size() - cmdsCount, 0); -
trunk/src/org/openstreetmap/josm/actions/RedoAction.java
r14134 r14143 8 8 import java.awt.event.KeyEvent; 9 9 10 import org.openstreetmap.josm.Main;11 10 import org.openstreetmap.josm.data.UndoRedoHandler; 12 11 import org.openstreetmap.josm.data.UndoRedoHandler.CommandQueueListener; … … 43 42 @Override 44 43 protected void updateEnabledState() { 45 setEnabled( Main.main != null &&!UndoRedoHandler.getInstance().redoCommands.isEmpty());44 setEnabled(!UndoRedoHandler.getInstance().redoCommands.isEmpty()); 46 45 } 47 46 -
trunk/src/org/openstreetmap/josm/actions/ShowStatusReportAction.java
r14138 r14143 181 181 text.append("Program arguments: ").append(Arrays.toString(paramCleanup(commandLineArgs).toArray())).append('\n'); 182 182 } 183 if (Main.main != null) { 184 DataSet dataset = MainApplication.getLayerManager().getActiveDataSet(); 185 if (dataset != null) { 186 String result = DatasetConsistencyTest.runTests(dataset); 187 if (result.isEmpty()) { 188 text.append("Dataset consistency test: No problems found\n"); 189 } else { 190 text.append("\nDataset consistency test:\n").append(result).append('\n'); 191 } 183 DataSet dataset = MainApplication.getLayerManager().getActiveDataSet(); 184 if (dataset != null) { 185 String result = DatasetConsistencyTest.runTests(dataset); 186 if (result.isEmpty()) { 187 text.append("Dataset consistency test: No problems found\n"); 188 } else { 189 text.append("\nDataset consistency test:\n").append(result).append('\n'); 192 190 } 193 191 } -
trunk/src/org/openstreetmap/josm/actions/UndoAction.java
r14134 r14143 8 8 import java.awt.event.KeyEvent; 9 9 10 import org.openstreetmap.josm.Main;11 10 import org.openstreetmap.josm.data.UndoRedoHandler; 12 11 import org.openstreetmap.josm.data.UndoRedoHandler.CommandQueueListener; … … 43 42 @Override 44 43 protected void updateEnabledState() { 45 setEnabled( Main.main != null &&!UndoRedoHandler.getInstance().commands.isEmpty());44 setEnabled(!UndoRedoHandler.getInstance().commands.isEmpty()); 46 45 } 47 46 -
trunk/src/org/openstreetmap/josm/actions/ZoomToAction.java
r13434 r14143 10 10 import javax.swing.event.ListSelectionListener; 11 11 12 import org.openstreetmap.josm.Main;13 12 import org.openstreetmap.josm.data.osm.OsmPrimitive; 14 13 import org.openstreetmap.josm.gui.MainApplication; … … 105 104 106 105 protected final void updateEnabledState() { 107 if (Main .main == null || MainApplication.getLayerManager().getActiveDataLayer() != this.table.getLayer()) {106 if (MainApplication.getLayerManager().getActiveDataLayer() != this.table.getLayer()) { 108 107 setEnabled(false); 109 108 putValue(SHORT_DESCRIPTION, descriptionInactiveLayer); -
trunk/src/org/openstreetmap/josm/actions/mapmode/ParallelWays.java
r14134 r14143 11 11 import java.util.Set; 12 12 13 import org.openstreetmap.josm.Main;14 13 import org.openstreetmap.josm.command.AddCommand; 15 14 import org.openstreetmap.josm.command.Command; … … 20 19 import org.openstreetmap.josm.data.osm.Node; 21 20 import org.openstreetmap.josm.data.osm.NodeGraph; 21 import org.openstreetmap.josm.data.osm.OsmDataManager; 22 22 import org.openstreetmap.josm.data.osm.Way; 23 23 import org.openstreetmap.josm.tools.Geometry; … … 190 190 191 191 private List<Command> makeAddWayAndNodesCommandList() { 192 DataSet ds = Main.main.getEditDataSet();192 DataSet ds = OsmDataManager.getInstance().getEditDataSet(); 193 193 List<Command> commands = new ArrayList<>(sortedNodes.size() + ways.size()); 194 194 for (int i = 0; i < sortedNodes.size() - (isClosedPath() ? 1 : 0); i++) { -
trunk/src/org/openstreetmap/josm/command/SplitWayCommand.java
r13852 r14143 219 219 * 220 220 * Note that changes are not applied to the data yet. You have to 221 * submit the command first, i.e. {@code Main.main.undoredo.add(result)}.221 * submit the command first, i.e. {@code UndoRedoHandler.getInstance().add(result)}. 222 222 * 223 223 * @param way the way to split. Must not be null. … … 237 237 * 238 238 * Note that changes are not applied to the data yet. You have to 239 * submit the command first, i.e. {@code Main.main.undoredo.add(result)}.239 * submit the command first, i.e. {@code UndoRedoHandler.getInstance().add(result)}. 240 240 * 241 241 * @param way the way to split. Must not be null. … … 464 464 * 465 465 * Note that changes are not applied to the data yet. You have to 466 * submit the command first, i.e. {@code Main.main.undoredo.add(result)}.466 * submit the command first, i.e. {@code UndoRedoHandler.getInstance().add(result)}. 467 467 * 468 468 * Replies null if the way couldn't be split at the given nodes. -
trunk/src/org/openstreetmap/josm/command/conflict/ConflictAddCommand.java
r13173 r14143 15 15 import org.openstreetmap.josm.data.osm.DataSet; 16 16 import org.openstreetmap.josm.data.osm.DefaultNameFormatter; 17 import org.openstreetmap.josm.data.osm.OsmDataManager; 17 18 import org.openstreetmap.josm.data.osm.OsmPrimitive; 18 19 import org.openstreetmap.josm.tools.ImageProvider; … … 66 67 public void undoCommand() { 67 68 DataSet ds = getAffectedDataSet(); 68 if ( Main.main != null && !Main.main.containsDataSet(ds)) {69 if (!OsmDataManager.getInstance().containsDataSet(ds)) { 69 70 Logging.warn(tr("Layer ''{0}'' does not exist any more. Cannot remove conflict for object ''{1}''.", 70 71 ds.getName(), -
trunk/src/org/openstreetmap/josm/command/conflict/ConflictResolveCommand.java
r13434 r14143 6 6 import java.util.Objects; 7 7 8 import org.openstreetmap.josm.Main;9 8 import org.openstreetmap.josm.command.Command; 10 9 import org.openstreetmap.josm.data.conflict.Conflict; 11 10 import org.openstreetmap.josm.data.conflict.ConflictCollection; 12 11 import org.openstreetmap.josm.data.osm.DataSet; 12 import org.openstreetmap.josm.data.osm.OsmDataManager; 13 13 import org.openstreetmap.josm.tools.Logging; 14 14 … … 63 63 64 64 DataSet ds = getAffectedDataSet(); 65 if (Main.main != null) { 66 if (!Main.main.containsDataSet(ds)) { 67 Logging.warn(tr("Cannot undo command ''{0}'' because layer ''{1}'' is not present any more", 68 this.toString(), 69 ds.getName() 70 )); 71 return; 72 } 65 if (!OsmDataManager.getInstance().containsDataSet(ds)) { 66 Logging.warn(tr("Cannot undo command ''{0}'' because layer ''{1}'' is not present any more", 67 this.toString(), 68 ds.getName() 69 )); 70 return; 71 } 73 72 74 Main.main.setActiveDataSet(ds); 75 } 73 OsmDataManager.getInstance().setActiveDataSet(ds); 76 74 reconstituteConflicts(); 77 75 } -
trunk/src/org/openstreetmap/josm/command/conflict/RelationMemberConflictResolverCommand.java
r13434 r14143 10 10 import javax.swing.Icon; 11 11 12 import org.openstreetmap.josm.Main;13 12 import org.openstreetmap.josm.data.conflict.Conflict; 14 13 import org.openstreetmap.josm.data.osm.DataSet; 14 import org.openstreetmap.josm.data.osm.OsmDataManager; 15 15 import org.openstreetmap.josm.data.osm.OsmPrimitive; 16 16 import org.openstreetmap.josm.data.osm.Relation; … … 73 73 public void undoCommand() { 74 74 DataSet ds = getAffectedDataSet(); 75 if (! Main.main.containsDataSet(ds)) {75 if (!OsmDataManager.getInstance().containsDataSet(ds)) { 76 76 Logging.warn(tr("Cannot undo command ''{0}'' because layer ''{1}'' is not present any more", 77 77 this.toString(), … … 81 81 } 82 82 83 Main.main.setActiveDataSet(ds);83 OsmDataManager.getInstance().setActiveDataSet(ds); 84 84 85 85 // restore the former state -
trunk/src/org/openstreetmap/josm/data/UndoRedoHandler.java
r14134 r14143 7 7 import java.util.Objects; 8 8 9 import org.openstreetmap.josm.Main;10 9 import org.openstreetmap.josm.command.Command; 11 10 import org.openstreetmap.josm.data.osm.DataSet; 11 import org.openstreetmap.josm.data.osm.OsmDataManager; 12 12 import org.openstreetmap.josm.spi.preferences.Config; 13 13 import org.openstreetmap.josm.tools.CheckParameterUtil; … … 291 291 if (commands.isEmpty()) 292 292 return; 293 DataSet ds = Main.main.getEditDataSet();293 DataSet ds = OsmDataManager.getInstance().getEditDataSet(); 294 294 if (ds != null) { 295 295 ds.beginUpdate(); -
trunk/src/org/openstreetmap/josm/data/osm/FilterModel.java
r13434 r14143 98 98 */ 99 99 public void executeFilters() { 100 DataSet ds = Main.main.getActiveDataSet();100 DataSet ds = OsmDataManager.getInstance().getActiveDataSet(); 101 101 changed = false; 102 102 if (ds == null) { … … 150 150 */ 151 151 public void executeFilters(Collection<? extends OsmPrimitive> primitives) { 152 DataSet ds = Main.main.getEditDataSet();152 DataSet ds = OsmDataManager.getInstance().getEditDataSet(); 153 153 if (ds == null) 154 154 return; … … 209 209 */ 210 210 public void clearFilterFlags() { 211 DataSet ds = Main.main.getEditDataSet();211 DataSet ds = OsmDataManager.getInstance().getEditDataSet(); 212 212 if (ds != null) { 213 213 FilterWorker.clearFilterFlags(ds.allPrimitives()); -
trunk/src/org/openstreetmap/josm/data/validation/tests/UnconnectedWays.java
r13942 r14143 18 18 import java.util.Set; 19 19 20 import org.openstreetmap.josm.Main;21 20 import org.openstreetmap.josm.data.coor.EastNorth; 22 21 import org.openstreetmap.josm.data.coor.LatLon; … … 24 23 import org.openstreetmap.josm.data.osm.DataSet; 25 24 import org.openstreetmap.josm.data.osm.Node; 25 import org.openstreetmap.josm.data.osm.OsmDataManager; 26 26 import org.openstreetmap.josm.data.osm.OsmPrimitive; 27 27 import org.openstreetmap.josm.data.osm.QuadBuckets; … … 169 169 mindist = Config.getPref().getDouble(PREFIX + ".node_way_distance", 10.0); 170 170 minmiddledist = Config.getPref().getDouble(PREFIX + ".way_way_distance", 0.0); 171 DataSet dataSet = Main.main != null ? Main.main.getEditDataSet() : null;171 DataSet dataSet = OsmDataManager.getInstance().getEditDataSet(); 172 172 dsArea = dataSet == null ? null : dataSet.getDataSourceArea(); 173 173 } -
trunk/src/org/openstreetmap/josm/data/validation/tests/UntaggedWay.java
r12691 r14143 9 9 import java.util.Set; 10 10 11 import org.openstreetmap.josm.Main;12 11 import org.openstreetmap.josm.command.Command; 13 12 import org.openstreetmap.josm.data.osm.DataSet; 13 import org.openstreetmap.josm.data.osm.OsmDataManager; 14 14 import org.openstreetmap.josm.data.osm.OsmPrimitive; 15 15 import org.openstreetmap.josm.data.osm.Relation; … … 142 142 public void startTest(ProgressMonitor monitor) { 143 143 super.startTest(monitor); 144 DataSet ds = Main.main.getEditDataSet();144 DataSet ds = OsmDataManager.getInstance().getEditDataSet(); 145 145 if (ds == null) 146 146 return; -
trunk/src/org/openstreetmap/josm/gui/MainApplication.java
r14140 r14143 78 78 import org.openstreetmap.josm.actions.downloadtasks.DownloadTask; 79 79 import org.openstreetmap.josm.actions.downloadtasks.PostDownloadHandler; 80 import org.openstreetmap.josm.actions.mapmode.DrawAction;81 80 import org.openstreetmap.josm.actions.search.SearchAction; 82 81 import org.openstreetmap.josm.cli.CLIModule; … … 90 89 import org.openstreetmap.josm.data.osm.DataSet; 91 90 import org.openstreetmap.josm.data.osm.IPrimitive; 92 import org.openstreetmap.josm.data.osm.OsmData ;91 import org.openstreetmap.josm.data.osm.OsmDataManager; 93 92 import org.openstreetmap.josm.data.osm.OsmPrimitive; 94 93 import org.openstreetmap.josm.data.osm.UserInfo; … … 418 417 } 419 418 419 /** 420 * @deprecated Use {@code OsmDataManager.getInstance().getInProgressSelection()} 421 */ 422 @Deprecated 420 423 @Override 421 424 public Collection<OsmPrimitive> getInProgressSelection() { 422 if (map != null && map.mapMode instanceof DrawAction) { 423 return ((DrawAction) map.mapMode).getInProgressSelection(); 424 } else { 425 DataSet ds = layerManager.getActiveDataSet(); 426 if (ds == null) return Collections.emptyList(); 427 return ds.getSelected(); 428 } 429 } 430 425 return OsmDataManager.getInstance().getInProgressSelection(); 426 } 427 428 /** 429 * @deprecated Use {@code OsmDataManager.getInstance().getInProgressSelection()} 430 */ 431 @Deprecated 431 432 @Override 432 433 public Collection<? extends IPrimitive> getInProgressISelection() { 433 if (map != null && map.mapMode instanceof DrawAction) { 434 return ((DrawAction) map.mapMode).getInProgressSelection(); 435 } else { 436 OsmData<?, ?, ?, ?> ds = layerManager.getActiveData(); 437 if (ds == null) return Collections.emptyList(); 438 return ds.getSelected(); 439 } 440 } 441 434 return OsmDataManager.getInstance().getInProgressSelection(); 435 } 436 437 /** 438 * @deprecated Use {@code OsmDataManager.getInstance().getEditDataSet()} 439 */ 440 @Deprecated 442 441 @Override 443 442 public DataSet getEditDataSet() { 444 return getLayerManager().getEditDataSet(); 445 } 446 443 return OsmDataManager.getInstance().getEditDataSet(); 444 } 445 446 /** 447 * @deprecated Use {@code OsmDataManager.getInstance().getActiveDataSet()} 448 */ 449 @Deprecated 447 450 @Override 448 451 public DataSet getActiveDataSet() { 449 return getLayerManager().getActiveDataSet(); 450 } 451 452 return OsmDataManager.getInstance().getActiveDataSet(); 453 } 454 455 /** 456 * @deprecated Use {@code OsmDataManager.getInstance().setActiveDataSet} 457 */ 458 @Deprecated 452 459 @Override 453 460 public void setActiveDataSet(DataSet ds) { 454 O ptional<OsmDataLayer> layer = getLayerManager().getLayersOfType(OsmDataLayer.class).stream()455 .filter(l -> l.data.equals(ds)).findFirst();456 if (layer.isPresent()) { 457 getLayerManager().setActiveLayer(layer.get());458 459 }460 461 OsmDataManager.getInstance().setActiveDataSet(ds); 462 } 463 464 /** 465 * @deprecated Use {@code OsmDataManager.getInstance().containsDataSet} 466 */ 467 @Deprecated 461 468 @Override 462 469 public boolean containsDataSet(DataSet ds) { … … 488 495 * @return the MapFrame 489 496 * @see MainPanel 490 * @since 12630 (as a replacement to {@code Main.map})497 * @since 12630 491 498 */ 492 499 public static MapFrame getMap() { … … 497 504 * Returns the main panel. 498 505 * @return the main panel 499 * @since 12642 (as a replacement to {@code Main.main.panel})506 * @since 12642 500 507 */ 501 508 public static MainPanel getMainPanel() { … … 515 522 * Returns the toolbar preference control to register new actions. 516 523 * @return the toolbar preference control 517 * @since 12637 (as a replacement to {@code Main.toolbar})524 * @since 12637 518 525 */ 519 526 public static ToolbarPreferences getToolbar() { -
trunk/src/org/openstreetmap/josm/gui/datatransfer/importers/AbstractTagPaster.java
r14134 r14143 14 14 import javax.swing.TransferHandler.TransferSupport; 15 15 16 import org.openstreetmap.josm.Main;17 16 import org.openstreetmap.josm.command.ChangePropertyCommand; 18 17 import org.openstreetmap.josm.command.Command; … … 20 19 import org.openstreetmap.josm.data.UndoRedoHandler; 21 20 import org.openstreetmap.josm.data.coor.EastNorth; 21 import org.openstreetmap.josm.data.osm.OsmDataManager; 22 22 import org.openstreetmap.josm.data.osm.OsmPrimitive; 23 23 import org.openstreetmap.josm.gui.layer.OsmDataLayer; … … 49 49 public boolean importTagsOn(TransferSupport support, Collection<? extends OsmPrimitive> selection) 50 50 throws UnsupportedFlavorException, IOException { 51 ChangePropertyCommand command = new ChangePropertyCommand( Main.main.getEditDataSet(), selection, getTags(support));51 ChangePropertyCommand command = new ChangePropertyCommand(OsmDataManager.getInstance().getEditDataSet(), selection, getTags(support)); 52 52 commitCommands(selection, Collections.singletonList(command)); 53 53 return true; -
trunk/src/org/openstreetmap/josm/gui/datatransfer/importers/PrimitiveTagTransferPaster.java
r12920 r14143 19 19 import org.openstreetmap.josm.data.osm.IPrimitive; 20 20 import org.openstreetmap.josm.data.osm.Node; 21 import org.openstreetmap.josm.data.osm.OsmDataManager; 21 22 import org.openstreetmap.josm.data.osm.OsmPrimitive; 22 23 import org.openstreetmap.josm.data.osm.OsmPrimitiveType; … … 53 54 Map<String, String> tags = new HashMap<>(1); 54 55 tags.put(tag.getKey(), "".equals(tag.getValue()) ? null : tag.getValue()); 55 ChangePropertyCommand cmd = new ChangePropertyCommand( Main.main.getEditDataSet(), selection, tags);56 ChangePropertyCommand cmd = new ChangePropertyCommand(OsmDataManager.getInstance().getEditDataSet(), selection, tags); 56 57 if (cmd.getObjectsNumber() > 0) { 57 58 commands.add(cmd); -
trunk/src/org/openstreetmap/josm/gui/dialogs/ToggleDialog.java
r13649 r14143 268 268 */ 269 269 protected void registerInWindowMenu() { 270 if (Main.main != null) { 271 windowMenuItem = MainMenu.addWithCheckbox(MainApplication.getMenu().windowMenu, 272 (JosmAction) getToggleAction(), 273 MainMenu.WINDOW_MENU_GROUP.TOGGLE_DIALOG); 274 } 270 windowMenuItem = MainMenu.addWithCheckbox(MainApplication.getMenu().windowMenu, 271 (JosmAction) getToggleAction(), 272 MainMenu.WINDOW_MENU_GROUP.TOGGLE_DIALOG); 275 273 } 276 274 … … 465 463 hideNotify(); 466 464 } 467 if (Main.main != null) { 468 MainApplication.getMenu().windowMenu.remove(windowMenuItem); 469 } 465 MainApplication.getMenu().windowMenu.remove(windowMenuItem); 470 466 try { 471 467 Toolkit.getDefaultToolkit().removeAWTEventListener(this); -
trunk/src/org/openstreetmap/josm/gui/dialogs/properties/PropertiesDialog.java
r14134 r14143 17 17 import java.util.Arrays; 18 18 import java.util.Collection; 19 import java.util.Collections;20 19 import java.util.EnumSet; 21 20 import java.util.HashMap; … … 69 68 import org.openstreetmap.josm.data.osm.Node; 70 69 import org.openstreetmap.josm.data.osm.OsmData; 70 import org.openstreetmap.josm.data.osm.OsmDataManager; 71 71 import org.openstreetmap.josm.data.osm.OsmPrimitive; 72 72 import org.openstreetmap.josm.data.osm.Relation; … … 184 184 private final PasteValueAction pasteValueAction = new PasteValueAction(); 185 185 private final CopyValueAction copyValueAction = new CopyValueAction( 186 tagTable, editHelper::getDataKey, Main.main::getInProgressISelection);186 tagTable, editHelper::getDataKey, OsmDataManager.getInstance()::getInProgressISelection); 187 187 private final CopyKeyValueAction copyKeyValueAction = new CopyKeyValueAction( 188 tagTable, editHelper::getDataKey, Main.main::getInProgressISelection);188 tagTable, editHelper::getDataKey, OsmDataManager.getInstance()::getInProgressISelection); 189 189 private final CopyAllKeyValueAction copyAllKeyValueAction = new CopyAllKeyValueAction( 190 tagTable, editHelper::getDataKey, Main.main::getInProgressISelection);190 tagTable, editHelper::getDataKey, OsmDataManager.getInstance()::getInProgressISelection); 191 191 private final SearchAction searchActionSame = new SearchAction(true); 192 192 private final SearchAction searchActionAny = new SearchAction(false); … … 568 568 569 569 // Ignore parameter as we do not want to operate always on real selection here, especially in draw mode 570 Collection<? extends IPrimitive> newSel = Main.main.getInProgressISelection();570 Collection<? extends IPrimitive> newSel = OsmDataManager.getInstance().getInProgressISelection(); 571 571 String selectedTag; 572 572 IRelation<?> selectedRelation = null; … … 851 851 @Override 852 852 public Collection<OsmPrimitive> getSelection() { 853 return Main.main == null ? Collections.<OsmPrimitive>emptyList() : Main.main.getInProgressSelection();853 return OsmDataManager.getInstance().getInProgressSelection(); 854 854 } 855 855 } … … 1011 1011 } 1012 1012 1013 Collection<OsmPrimitive> sel = Main.main.getInProgressSelection();1013 Collection<OsmPrimitive> sel = OsmDataManager.getInstance().getInProgressSelection(); 1014 1014 UndoRedoHandler.getInstance().add(new ChangePropertyCommand(sel, tags)); 1015 1015 … … 1040 1040 1041 1041 Relation rel = new Relation(cur); 1042 for (OsmPrimitive primitive: Main.main.getInProgressSelection()) {1042 for (OsmPrimitive primitive: OsmDataManager.getInstance().getInProgressSelection()) { 1043 1043 rel.removeMembersFor(primitive); 1044 1044 } … … 1069 1069 @Override 1070 1070 protected final void updateEnabledState() { 1071 DataSet ds = Main.main.getActiveDataSet();1071 DataSet ds = OsmDataManager.getInstance().getActiveDataSet(); 1072 1072 setEnabled(ds != null && !ds.isLocked() && 1073 1073 ((tagTable != null && tagTable.getSelectedRowCount() >= 1) … … 1137 1137 @Override 1138 1138 protected void updateEnabledState() { 1139 DataSet ds = Main.main.getActiveDataSet();1139 DataSet ds = OsmDataManager.getInstance().getActiveDataSet(); 1140 1140 setEnabled(ds != null && !ds.isLocked() && 1141 1141 ((tagTable != null && tagTable.getSelectedRowCount() == 1) … … 1161 1161 return; 1162 1162 String key = editHelper.getDataKey(tagTable.getSelectedRow()); 1163 Collection<OsmPrimitive> sel = Main.main.getInProgressSelection();1163 Collection<OsmPrimitive> sel = OsmDataManager.getInstance().getInProgressSelection(); 1164 1164 String clipboard = ClipboardUtils.getClipboardStringContent(); 1165 1165 if (sel.isEmpty() || clipboard == null || sel.iterator().next().getDataSet().isLocked()) … … 1188 1188 return; 1189 1189 String key = editHelper.getDataKey(tagTable.getSelectedRow()); 1190 Collection<? extends IPrimitive> sel = Main.main.getInProgressISelection();1190 Collection<? extends IPrimitive> sel = OsmDataManager.getInstance().getInProgressISelection(); 1191 1191 if (sel.isEmpty()) 1192 1192 return; -
trunk/src/org/openstreetmap/josm/gui/dialogs/properties/TagEditHelper.java
r14138 r14143 69 69 import org.openstreetmap.josm.command.SequenceCommand; 70 70 import org.openstreetmap.josm.data.UndoRedoHandler; 71 import org.openstreetmap.josm.data.osm.OsmDataManager; 71 72 import org.openstreetmap.josm.data.osm.OsmPrimitive; 72 73 import org.openstreetmap.josm.data.osm.Tag; … … 232 233 public void addTag() { 233 234 changedKey = null; 234 sel = Main.main.getInProgressSelection();235 sel = OsmDataManager.getInstance().getInProgressSelection(); 235 236 if (sel == null || sel.isEmpty()) 236 237 return; … … 263 264 public void editTag(final int row, boolean focusOnKey) { 264 265 changedKey = null; 265 sel = Main.main.getInProgressSelection();266 sel = OsmDataManager.getInstance().getInProgressSelection(); 266 267 if (sel == null || sel.isEmpty()) 267 268 return; … … 448 449 mainPanel.add(p, BorderLayout.CENTER); 449 450 450 AutoCompletionManager autocomplete = AutoCompletionManager.of( Main.main.getActiveDataSet());451 AutoCompletionManager autocomplete = AutoCompletionManager.of(OsmDataManager.getInstance().getActiveDataSet()); 451 452 List<AutoCompletionItem> keyList = autocomplete.getTagKeys(DEFAULT_AC_ITEM_COMPARATOR); 452 453 … … 565 566 public void setupDialog() { 566 567 super.setupDialog(); 567 buttons.get(0).setEnabled(! Main.main.getActiveDataSet().isLocked());568 buttons.get(0).setEnabled(!OsmDataManager.getInstance().getActiveDataSet().isLocked()); 568 569 final Dimension size = getSize(); 569 570 // Set resizable only in width … … 701 702 702 703 cacheRecentTags(); 703 AutoCompletionManager autocomplete = AutoCompletionManager.of( Main.main.getActiveDataSet());704 AutoCompletionManager autocomplete = AutoCompletionManager.of(OsmDataManager.getInstance().getActiveDataSet()); 704 705 List<AutoCompletionItem> keyList = autocomplete.getTagKeys(DEFAULT_AC_ITEM_COMPARATOR); 705 706 -
trunk/src/org/openstreetmap/josm/gui/dialogs/relation/MemberTable.java
r13675 r14143 21 21 import javax.swing.event.ListSelectionListener; 22 22 23 import org.openstreetmap.josm.Main;24 23 import org.openstreetmap.josm.actions.AutoScaleAction; 25 24 import org.openstreetmap.josm.actions.ZoomToAction; … … 249 248 250 249 private void updateEnabledState() { 251 setEnabled(Main.main != null 252 && MainApplication.getLayerManager().getEditLayer() == getLayer() 250 setEnabled(MainApplication.getLayerManager().getEditLayer() == getLayer() 253 251 && getSelectedRowCount() == 1 254 252 && hasGap()); -
trunk/src/org/openstreetmap/josm/gui/history/HistoryBrowserModel.java
r13654 r14143 10 10 import javax.swing.table.TableModel; 11 11 12 import org.openstreetmap.josm.Main;13 12 import org.openstreetmap.josm.data.UserIdentityManager; 14 13 import org.openstreetmap.josm.data.osm.DataSet; … … 102 101 referenceRelationMemberTableModel = new DiffTableModel(); 103 102 104 if (Main.main != null) { 105 DataSet ds = MainApplication.getLayerManager().getActiveDataSet(); 106 if (ds != null) { 107 ds.addDataSetListener(this); 108 } 103 DataSet ds = MainApplication.getLayerManager().getActiveDataSet(); 104 if (ds != null) { 105 ds.addDataSetListener(this); 109 106 } 110 107 MainApplication.getLayerManager().addActiveLayerChangeListener(this); -
trunk/src/org/openstreetmap/josm/gui/tagging/presets/TaggingPreset.java
r14134 r14143 41 41 import org.openstreetmap.josm.data.osm.IPrimitive; 42 42 import org.openstreetmap.josm.data.osm.OsmData; 43 import org.openstreetmap.josm.data.osm.OsmDataManager; 43 44 import org.openstreetmap.josm.data.osm.OsmPrimitive; 44 45 import org.openstreetmap.josm.data.osm.Relation; … … 383 384 @Override 384 385 public void actionPerformed(ActionEvent e) { 385 if (Main.main == null) { 386 return; 387 } 388 DataSet ds = Main.main.getEditDataSet(); 386 DataSet ds = OsmDataManager.getInstance().getEditDataSet(); 389 387 Collection<OsmPrimitive> participants = Collections.emptyList(); 390 388 if (ds != null) { … … 565 563 566 564 protected final void updateEnabledState() { 567 setEnabled( Main.main != null && Main.main.getEditDataSet() != null);565 setEnabled(OsmDataManager.getInstance().getEditDataSet() != null); 568 566 } 569 567 -
trunk/src/org/openstreetmap/josm/gui/tagging/presets/TaggingPresetItem.java
r12846 r14143 17 17 import javax.swing.JPanel; 18 18 19 import org.openstreetmap.josm.Main;20 19 import org.openstreetmap.josm.data.osm.DataSet; 20 import org.openstreetmap.josm.data.osm.OsmDataManager; 21 21 import org.openstreetmap.josm.data.osm.OsmPrimitive; 22 22 import org.openstreetmap.josm.data.osm.Tag; … … 43 43 44 44 protected void initAutoCompletionField(AutoCompletingTextField field, List<String> keys) { 45 if (Main.main == null) return; 46 DataSet data = Main.main.getEditDataSet(); 45 DataSet data = OsmDataManager.getInstance().getEditDataSet(); 47 46 if (data == null) { 48 47 return; -
trunk/src/org/openstreetmap/josm/gui/tagging/presets/TaggingPresetSelector.java
r13925 r14143 34 34 import javax.swing.event.ListSelectionListener; 35 35 36 import org.openstreetmap.josm.Main;37 36 import org.openstreetmap.josm.data.osm.DataSelectionListener; 38 37 import org.openstreetmap.josm.data.osm.DataSet; 38 import org.openstreetmap.josm.data.osm.OsmDataManager; 39 39 import org.openstreetmap.josm.data.osm.OsmPrimitive; 40 40 import org.openstreetmap.josm.data.preferences.BooleanProperty; … … 240 240 boolean inTags = ckSearchInTags != null && ckSearchInTags.isSelected(); 241 241 242 DataSet ds = Main.main.getEditDataSet();242 DataSet ds = OsmDataManager.getInstance().getEditDataSet(); 243 243 Collection<OsmPrimitive> selected = (ds == null) ? Collections.<OsmPrimitive>emptyList() : ds.getSelected(); 244 244 final List<PresetClassification> result = classifications.getMatchingPresets( … … 360 360 typesInSelectionDirty = false; 361 361 typesInSelection.clear(); 362 if ( Main.main == null || Main.main.getEditDataSet() == null) return typesInSelection;363 for (OsmPrimitive primitive : Main.main.getEditDataSet().getSelected()) {362 if (OsmDataManager.getInstance().getEditDataSet() == null) return typesInSelection; 363 for (OsmPrimitive primitive : OsmDataManager.getInstance().getEditDataSet().getSelected()) { 364 364 typesInSelection.add(TaggingPresetType.forPrimitive(primitive)); 365 365 } -
trunk/src/org/openstreetmap/josm/io/remotecontrol/handler/AddWayHandler.java
r14134 r14143 13 13 import java.util.Map.Entry; 14 14 15 import org.openstreetmap.josm.Main;16 15 import org.openstreetmap.josm.actions.AutoScaleAction; 17 16 import org.openstreetmap.josm.command.AddCommand; … … 22 21 import org.openstreetmap.josm.data.osm.DataSet; 23 22 import org.openstreetmap.josm.data.osm.Node; 23 import org.openstreetmap.josm.data.osm.OsmDataManager; 24 24 import org.openstreetmap.josm.data.osm.OsmPrimitive; 25 25 import org.openstreetmap.josm.data.osm.Way; … … 151 151 nd = new Node(ll); 152 152 // Now execute the commands to add this node. 153 commands.add(new AddCommand( Main.main.getEditDataSet(), nd));153 commands.add(new AddCommand(OsmDataManager.getInstance().getEditDataSet(), nd)); 154 154 addedNodes.put(ll, nd); 155 155 } -
trunk/test/unit/org/openstreetmap/josm/JOSMFixture.java
r14139 r14143 153 153 } 154 154 155 @SuppressWarnings("deprecation") 155 156 private void setupGUI() { 156 157 JOSMTestRules.cleanLayerEnvironment();
Note:
See TracChangeset
for help on using the changeset viewer.