Ignore:
Timestamp:
2013-10-27T05:35:41+01:00 (11 years ago)
Author:
Don-vip
Message:

code cleanup / robustness in edit layer handling

Location:
trunk/src/org/openstreetmap/josm/actions
Files:
24 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/actions/AutoScaleAction.java

    r6333 r6336  
    6262     */
    6363    public static void zoomToSelection() {
    64         if (Main.main == null || Main.main.getEditLayer() == null) return;
    65         if (Main.map == null || Main.map.mapView == null) return;
     64        if (Main.main == null || !Main.main.hasEditLayer()) return;
    6665        Collection<OsmPrimitive> sel = Main.main.getEditLayer().data.getSelected();
    6766        if (sel.isEmpty()) {
  • trunk/src/org/openstreetmap/josm/actions/CreateMultipolygonAction.java

    r6258 r6336  
    6767    @Override
    6868    public void actionPerformed(ActionEvent e) {
    69         if (Main.main.getEditLayer() == null) {
     69        if (!Main.main.hasEditLayer()) {
    7070            new Notification(
    7171                    tr("No data loaded."))
  • trunk/src/org/openstreetmap/josm/actions/DownloadReferrersAction.java

    r6084 r6336  
    8181    @Override
    8282    public void actionPerformed(ActionEvent e) {
    83         if (!isEnabled() || ! Main.isDisplayingMapView())
     83        if (!isEnabled())
    8484            return;
    85         OsmDataLayer layer = Main.map.mapView.getEditLayer();
     85        OsmDataLayer layer = Main.main.getEditLayer();
    8686        if (layer == null)
    8787            return;
  • trunk/src/org/openstreetmap/josm/actions/InfoAction.java

    r5925 r6336  
    1 //License: GPL. Copyright 2007 by Immanuel Scholz and others
     1// License: GPL. For details, see LICENSE file.
    22package org.openstreetmap.josm.actions;
    33
     
    1717public class InfoAction extends JosmAction {
    1818
     19    /**
     20     * Constructs a new {@code InfoAction}.
     21     */
    1922    public InfoAction() {
    2023        super(tr("Advanced info"), "about",
     
    3033        DataSet set = getCurrentDataSet();
    3134        if (set != null) {
    32             new InspectPrimitiveDialog(set.getAllSelected(), Main.map.mapView.getEditLayer()).showDialog();
     35            new InspectPrimitiveDialog(set.getAllSelected(), Main.main.getEditLayer()).showDialog();
    3336        }
    3437    }
  • trunk/src/org/openstreetmap/josm/actions/JoinAreasAction.java

    r6316 r6336  
    519519        // Delete the discarded inner ways
    520520        if (!discardedWays.isEmpty()) {
    521             Command deleteCmd = DeleteCommand.delete(Main.map.mapView.getEditLayer(), discardedWays, true);
     521            Command deleteCmd = DeleteCommand.delete(Main.main.getEditLayer(), discardedWays, true);
    522522            if (deleteCmd != null) {
    523523                cmds.add(deleteCmd);
     
    835835
    836836        if (chunks.size() > 1) {
    837             SplitWayResult split = SplitWayAction.splitWay(Main.map.mapView.getEditLayer(), way, chunks, Collections.<OsmPrimitive>emptyList());
     837            SplitWayResult split = SplitWayAction.splitWay(Main.main.getEditLayer(), way, chunks, Collections.<OsmPrimitive>emptyList());
    838838
    839839            //execute the command, we need the results
  • trunk/src/org/openstreetmap/josm/actions/PasteAction.java

    r6227 r6336  
    131131            if (data instanceof NodeData) {
    132132                NodeData nodeData = (NodeData)data;
    133                 if (Main.map.mapView.getEditLayer() == source) {
     133                if (Main.main.getEditLayer() == source) {
    134134                    nodeData.setEastNorth(nodeData.getEastNorth().add(offsetEast, offsetNorth));
    135135                }
  • trunk/src/org/openstreetmap/josm/actions/PurgeAction.java

    r6084 r6336  
    9090
    9191        Collection<OsmPrimitive> sel = getCurrentDataSet().getAllSelected();
    92         layer = Main.map.mapView.getEditLayer();
     92        layer = Main.main.getEditLayer();
    9393
    9494        toPurge = new HashSet<OsmPrimitive>(sel);
     
    209209        Main.pref.put("purge.clear_undo_redo", cbClearUndoRedo.isSelected());
    210210
    211         Main.main.undoRedo.add(new PurgeCommand(Main.map.mapView.getEditLayer(), toPurgeChecked, makeIncomplete));
     211        Main.main.undoRedo.add(new PurgeCommand(Main.main.getEditLayer(), toPurgeChecked, makeIncomplete));
    212212
    213213        if (cbClearUndoRedo.isSelected()) {
  • trunk/src/org/openstreetmap/josm/actions/SimplifyWayAction.java

    r6296 r6336  
    4848
    4949    protected boolean confirmWayWithNodesOutsideBoundingBox(List<? extends OsmPrimitive> primitives) {
    50         return DeleteCommand.checkAndConfirmOutlyingDelete(Main.map.mapView.getEditLayer(), primitives, null);
     50        return DeleteCommand.checkAndConfirmOutlyingDelete(Main.main.getEditLayer(), primitives, null);
    5151    }
    5252
  • trunk/src/org/openstreetmap/josm/actions/UpdateSelectionAction.java

    r6046 r6336  
    4040        try {
    4141            DataSet ds = reader.parseOsm(NullProgressMonitor.INSTANCE);
    42             Main.map.mapView.getEditLayer().mergeFrom(ds);
     42            Main.main.getEditLayer().mergeFrom(ds);
    4343        } catch(Exception e) {
    4444            ExceptionDialogUtil.explainException(e);
  • trunk/src/org/openstreetmap/josm/actions/UploadAction.java

    r6316 r6336  
    269269        }
    270270        APIDataSet apiData = new APIDataSet(Main.main.getCurrentDataSet());
    271         uploadData(Main.map.mapView.getEditLayer(), apiData);
     271        uploadData(Main.main.getEditLayer(), apiData);
    272272    }
    273273}
  • trunk/src/org/openstreetmap/josm/actions/ViewportFollowToggleAction.java

    r6327 r6336  
    4242    @Override
    4343    protected void updateEnabledState() {
    44         setEnabled(Main.isDisplayingMapView() && Main.main.getEditLayer() != null);
     44        setEnabled(Main.main.hasEditLayer());
    4545    }
    4646}
  • trunk/src/org/openstreetmap/josm/actions/WireframeToggleAction.java

    r6327 r6336  
    3737    @Override
    3838    protected void updateEnabledState() {
    39         setEnabled(Main.isDisplayingMapView() && Main.main.getEditLayer() != null);
     39        setEnabled(Main.main.hasEditLayer());
    4040    }
    4141
  • trunk/src/org/openstreetmap/josm/actions/downloadtasks/DownloadOsmTask.java

    r6272 r6336  
    223223        protected OsmDataLayer getEditLayer() {
    224224            if (!Main.isDisplayingMapView()) return null;
    225             return Main.map.mapView.getEditLayer();
     225            return Main.main.getEditLayer();
    226226        }
    227227
  • trunk/src/org/openstreetmap/josm/actions/downloadtasks/DownloadTaskList.java

    r6316 r6336  
    291291                }
    292292            }
    293             final OsmDataLayer editLayer = Main.map.mapView.getEditLayer();
     293            final OsmDataLayer editLayer = Main.main.getEditLayer();
    294294            if (editLayer != null && osmData) {
    295295                final Set<OsmPrimitive> myPrimitives = getCompletePrimitives(editLayer.data);
  • trunk/src/org/openstreetmap/josm/actions/mapmode/DrawAction.java

    r6317 r6336  
    283283    @Override
    284284    public void eventDispatched(AWTEvent event) {
    285         if(Main.map == null || Main.map.mapView == null || !Main.map.mapView.isActiveLayerDrawable())
     285        if (!Main.isDisplayingMapView() || !Main.map.mapView.isActiveLayerDrawable())
    286286            return;
    287287        if (event instanceof KeyEvent) {
  • trunk/src/org/openstreetmap/josm/actions/mapmode/ExtrudeAction.java

    r6310 r6336  
    156156        @Override
    157157        public void eventDispatched(AWTEvent e) {
    158             if(Main.map == null || Main.map.mapView == null || !Main.map.mapView.isActiveLayerDrawable())
     158            if (!Main.isDisplayingMapView() || !Main.map.mapView.isActiveLayerDrawable())
    159159                return;
    160160            InputEvent ie = (InputEvent) e;
  • trunk/src/org/openstreetmap/josm/actions/mapmode/ImproveWayAccuracyAction.java

    r6316 r6336  
    323323    @Override
    324324    public void eventDispatched(AWTEvent event) {
    325         if (Main.map == null || Main.map.mapView == null
    326                 || !Main.map.mapView.isActiveLayerDrawable()) {
     325        if (!Main.isDisplayingMapView() || !Main.map.mapView.isActiveLayerDrawable()) {
    327326            return;
    328327        }
  • trunk/src/org/openstreetmap/josm/actions/relation/DeleteRelationsAction.java

    r5799 r6336  
    3939    @Override
    4040    public void actionPerformed(ActionEvent e) {
    41         if (!isEnabled() || Main.main.getEditLayer() == null)
     41        if (!isEnabled() || !Main.main.hasEditLayer())
    4242            return;
    4343        for (Relation r : relations) {
  • trunk/src/org/openstreetmap/josm/actions/relation/DownloadMembersAction.java

    r5821 r6336  
    3434    @Override
    3535    public void actionPerformed(ActionEvent e) {
    36         if (!isEnabled() || relations.isEmpty() || Main.map==null || Main.map.mapView==null) return;
    37         Main.worker.submit(new DownloadRelationTask(relations, Main.map.mapView.getEditLayer()));
     36        if (!isEnabled() || relations.isEmpty() || !Main.isDisplayingMapView()) return;
     37        Main.worker.submit(new DownloadRelationTask(relations, Main.main.getEditLayer()));
    3838    }
    3939
  • trunk/src/org/openstreetmap/josm/actions/relation/DownloadSelectedIncompleteMembersAction.java

    r5821 r6336  
    4747    @Override
    4848    public void actionPerformed(ActionEvent e) {
    49         if (!isEnabled() || relations.isEmpty() || Main.map==null || Main.map.mapView==null) return;
     49        if (!isEnabled() || relations.isEmpty() || !Main.isDisplayingMapView()) return;
    5050        Main.worker.submit(new DownloadRelationMemberTask(
    5151                relations,
    5252                buildSetOfIncompleteMembers(relations),
    53                 Main.map.mapView.getEditLayer()));
     53                Main.main.getEditLayer()));
    5454    }
    5555
  • trunk/src/org/openstreetmap/josm/actions/relation/EditRelationAction.java

    r6333 r6336  
    4040        Set<RelationMember> members = new HashSet<RelationMember>();
    4141        if (Main.isDisplayingMapView()) {
    42             OsmDataLayer editLayer = Main.map.mapView.getEditLayer();
     42            OsmDataLayer editLayer = Main.main.getEditLayer();
    4343            if (editLayer != null && editLayer.data != null) {
    4444                Collection<OsmPrimitive> selection = editLayer.data.getSelected();
     
    5858     */
    5959    public static void launchEditor(Relation toEdit) {
    60         if (toEdit == null || Main.map==null || Main.map.mapView==null) return;
    61         RelationEditor.getEditor(Main.map.mapView.getEditLayer(), toEdit,
     60        if (toEdit == null || !Main.isDisplayingMapView()) return;
     61        RelationEditor.getEditor(Main.main.getEditLayer(), toEdit,
    6262                getMembersForCurrentSelection(toEdit)).setVisible(true);
    6363    }
  • trunk/src/org/openstreetmap/josm/actions/relation/SelectMembersAction.java

    r5794 r6336  
    3434    @Override
    3535    public void actionPerformed(ActionEvent e) {
    36         if (!isEnabled() || relations.isEmpty() || Main.map==null || Main.map.mapView==null) return;
     36        if (!isEnabled() || relations.isEmpty() || !Main.isDisplayingMapView()) return;
    3737       
    3838        HashSet<OsmPrimitive> members = new HashSet<OsmPrimitive>();
     
    4141        }
    4242        if (add) {
    43             Main.map.mapView.getEditLayer().data.addSelected(members);
     43            Main.main.getEditLayer().data.addSelected(members);
    4444        } else {
    45             Main.map.mapView.getEditLayer().data.setSelected(members);
     45            Main.main.getEditLayer().data.setSelected(members);
    4646        }
    4747    }
  • trunk/src/org/openstreetmap/josm/actions/relation/SelectRelationAction.java

    r6069 r6336  
    3131    @Override
    3232    public void actionPerformed(ActionEvent e) {
    33         if (!isEnabled() || relations.isEmpty() || Main.map==null || Main.map.mapView==null) return;
    34         OsmDataLayer editLayer = Main.map.mapView.getEditLayer();
     33        if (!isEnabled() || relations.isEmpty()) return;
     34        OsmDataLayer editLayer = Main.main.getEditLayer();
    3535        if (editLayer==null || editLayer.data==null) return;
    3636        if (add) {
  • trunk/src/org/openstreetmap/josm/actions/search/SearchCompiler.java

    r6265 r6336  
    11341134        @Override
    11351135        protected Bounds getBounds() {
    1136             if (Main.map == null || Main.map.mapView == null) {
     1136            if (!Main.isDisplayingMapView()) {
    11371137                return null;
    11381138            }
     
    11501150    }
    11511151
    1152     public static Match compile(String searchStr, boolean caseSensitive, boolean regexSearch)
    1153             throws ParseError {
     1152    public static Match compile(String searchStr, boolean caseSensitive, boolean regexSearch) throws ParseError {
    11541153        return new SearchCompiler(caseSensitive, regexSearch,
    11551154                new PushbackTokenizer(
Note: See TracChangeset for help on using the changeset viewer.