Changeset 30145 in osm


Ignore:
Timestamp:
2013-12-22T12:27:11+01:00 (11 years ago)
Author:
donvip
Message:

[josm-plugins] global replacement of Main.map.mapview.getEditLayer() by Main.main.getEditLayer() (avoids NPEs)

Location:
applications/editors/josm/plugins
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/CommandLine/src/CommandLine/OsmToCmd.java

    r29505 r30145  
    250250                else if (currentPrimitive.isModified()) {
    251251                    //System.out.println(String.valueOf(currentPrimitive.getUniqueId()) + " IS MODIFIED BY SCRIPT");
    252                     cmds.add(new ChangeCommand(Main.map.mapView.getEditLayer(), targetDataSet.getPrimitiveById(currentPrimitive.getPrimitiveId()), currentPrimitive));
     252                    cmds.add(new ChangeCommand(Main.main.getEditLayer(), targetDataSet.getPrimitiveById(currentPrimitive.getPrimitiveId()), currentPrimitive));
    253253                }
    254254                else if (currentPrimitive.isNew()) {
     
    262262                }
    263263                else if (currentPrimitive.isModified()) {
    264                     cmds.add(new ChangeCommand(Main.map.mapView.getEditLayer(), targetDataSet.getPrimitiveById(currentPrimitive.getPrimitiveId()), currentPrimitive));
     264                    cmds.add(new ChangeCommand(Main.main.getEditLayer(), targetDataSet.getPrimitiveById(currentPrimitive.getPrimitiveId()), currentPrimitive));
    265265                }
    266266                else if (currentPrimitive.isNew()) {
     
    274274                }
    275275                else if (currentPrimitive.isModified()) {
    276                     cmds.add(new ChangeCommand(Main.map.mapView.getEditLayer(), targetDataSet.getPrimitiveById(currentPrimitive.getPrimitiveId()), currentPrimitive));
     276                    cmds.add(new ChangeCommand(Main.main.getEditLayer(), targetDataSet.getPrimitiveById(currentPrimitive.getPrimitiveId()), currentPrimitive));
    277277                }
    278278                else if (currentPrimitive.isNew()) {
  • applications/editors/josm/plugins/graphview/src/org/openstreetmap/josm/plugins/graphview/plugin/GraphViewPlugin.java

    r29525 r30145  
    250250        if (oldLayer == graphViewLayer) {
    251251            graphViewLayer = null;
    252         } else if (oldLayer == Main.map.mapView.getEditLayer()) { //data layer removed
     252        } else if (oldLayer == Main.main.getEditLayer()) { //data layer removed
    253253            if (graphViewLayer != null) {
    254254                Main.main.removeLayer(graphViewLayer);
  • applications/editors/josm/plugins/reltoolbox/src/relcontext/RelContextDialog.java

    r29535 r30145  
    243243                    Relation relation = (Relation)relationsData.getValueAt(row, 0);
    244244                    if( e.getClickCount() > 1 ) {
    245                         Main.map.mapView.getEditLayer().data.setSelected(relation);
     245                        Main.main.getEditLayer().data.setSelected(relation);
    246246                    }
    247247                }
     
    487487        public void mouseClicked( MouseEvent e ) {
    488488            if( e.isControlDown() || !(e.getComponent() instanceof JComboBox ) ) // do not use left click handler on combo box
    489             if( SwingUtilities.isLeftMouseButton(e) && chosenRelation.get() != null && Main.map.mapView.getEditLayer() != null ) {
    490                 Main.map.mapView.getEditLayer().data.setSelected(chosenRelation.get());
     489            if( SwingUtilities.isLeftMouseButton(e) && chosenRelation.get() != null && Main.main.getEditLayer() != null ) {
     490                Main.main.getEditLayer().data.setSelected(chosenRelation.get());
    491491            }
    492492        }
  • applications/editors/josm/plugins/reltoolbox/src/relcontext/actions/DownloadChosenRelationAction.java

    r25695 r30145  
    6262    protected void downloadMembers( Relation rel ) {
    6363        if( !rel.isNew() ) {
    64             Main.worker.submit(new DownloadRelationTask(Collections.singletonList(rel), Main.map.mapView.getEditLayer()));
     64            Main.worker.submit(new DownloadRelationTask(Collections.singletonList(rel), Main.main.getEditLayer()));
    6565        }
    6666    }
     
    7171        ret.addAll(rel.getIncompleteMembers());
    7272        if( ret.isEmpty() ) return;
    73         Main.worker.submit(new DownloadRelationMemberTask(Collections.singletonList(rel), ret, Main.map.mapView.getEditLayer()));
     73        Main.worker.submit(new DownloadRelationMemberTask(Collections.singletonList(rel), ret, Main.main.getEditLayer()));
    7474    }
    7575}
  • applications/editors/josm/plugins/reltoolbox/src/relcontext/actions/DownloadParentsAction.java

    r29535 r30145  
    3737        this.rel = rel;
    3838        rel.addChosenRelationListener(this);
    39         setEnabled(rel.get() != null && Main.map.mapView.getEditLayer() != null);
     39        setEnabled(rel.get() != null && Main.main.getEditLayer() != null);
    4040    }
    4141
     
    4646        objects.add(relation);
    4747        objects.addAll(relation.getMemberPrimitives());
    48         Main.worker.submit(new DownloadReferrersTask(Main.map.mapView.getEditLayer(), objects));
     48        Main.worker.submit(new DownloadReferrersTask(Main.main.getEditLayer(), objects));
    4949    }
    5050
    5151    public void chosenRelationChanged( Relation oldRelation, Relation newRelation ) {
    52         setEnabled(newRelation != null && Main.map.mapView.getEditLayer() != null);
     52        setEnabled(newRelation != null && Main.main.getEditLayer() != null);
    5353    }
    5454
    5555    protected void downloadMembers( Relation rel ) {
    5656        if( !rel.isNew() ) {
    57             Main.worker.submit(new DownloadRelationTask(Collections.singletonList(rel), Main.map.mapView.getEditLayer()));
     57            Main.worker.submit(new DownloadRelationTask(Collections.singletonList(rel), Main.main.getEditLayer()));
    5858        }
    5959    }
     
    6464        ret.addAll(rel.getIncompleteMembers());
    6565        if( ret.isEmpty() ) return;
    66         Main.worker.submit(new DownloadRelationMemberTask(Collections.singletonList(rel), ret, Main.map.mapView.getEditLayer()));
     66        Main.worker.submit(new DownloadRelationMemberTask(Collections.singletonList(rel), ret, Main.main.getEditLayer()));
    6767    }
    6868}
  • applications/editors/josm/plugins/reltoolbox/src/relcontext/actions/EditChosenRelationAction.java

    r25711 r30145  
    3232        Relation relation = rel.get();
    3333        if( relation == null ) return;
    34         RelationEditor.getEditor(Main.map.mapView.getEditLayer(), relation, null).setVisible(true);
     34        RelationEditor.getEditor(Main.main.getEditLayer(), relation, null).setVisible(true);
    3535    }
    3636
  • applications/editors/josm/plugins/reltoolbox/src/relcontext/actions/SelectMembersAction.java

    r25711 r30145  
    2222
    2323    public void actionPerformed( ActionEvent e ) {
    24         Main.map.mapView.getEditLayer().data.setSelected(rel.get() == null ? null : rel.get().getMemberPrimitives());
     24        Main.main.getEditLayer().data.setSelected(rel.get() == null ? null : rel.get().getMemberPrimitives());
    2525    }
    2626
  • applications/editors/josm/plugins/reltoolbox/src/relcontext/actions/SelectRelationAction.java

    r25711 r30145  
    2323
    2424    public void actionPerformed( ActionEvent e ) {
    25         Main.map.mapView.getEditLayer().data.setSelected(rel.get() == null ? null : rel.get());
     25        Main.main.getEditLayer().data.setSelected(rel.get() == null ? null : rel.get());
    2626    }
    2727
  • applications/editors/josm/plugins/routing/src/com/innovant/josm/plugin/routing/RoutingPlugin.java

    r29586 r30145  
    174174
    175175        public void addLayer() {
    176                 OsmDataLayer osmLayer = Main.map.mapView.getEditLayer();
     176                OsmDataLayer osmLayer = Main.main.getEditLayer();
    177177                if (osmLayer != null) {
    178178                        RoutingLayer layer = new RoutingLayer(tr("Routing") + " [" + osmLayer.getName() + "]", osmLayer);
  • applications/editors/josm/plugins/simplifyarea/src/sk/zdila/josm/plugin/simplify/SimplifyAreaAction.java

    r30133 r30145  
    5050
    5151    private List<Bounds> getCurrentEditBounds() {
    52         return Main.map.mapView.getEditLayer().data.getDataSourceBounds();
     52        return Main.main.getEditLayer().data.getDataSourceBounds();
    5353    }
    5454
  • applications/editors/josm/plugins/surveyor/src/at/dallermassl/josm/plugin/surveyor/AutoSaveEditLayerTimerTask.java

    r27243 r30145  
    3232    }
    3333
    34     /* (non-Javadoc)
    35      * @see java.util.TimerTask#run()
    36      */
    3734    @Override
    3835    public void run() {
    39         if(Main.map == null || Main.map.mapView == null || Main.map.mapView.getEditLayer() == null) {
     36        OsmDataLayer layer = Main.main.getEditLayer();
     37        if (layer == null) {
    4038            return;
    4139        }
    42         OsmDataLayer layer = Main.map.mapView.getEditLayer();
    4340        try {
    4441            DataSet dataset = layer.data;
    45 
    46 //            File outFile = layer.associatedFile;
    47 //            if(outFile == null) {
    48 //                outFile = file;
    49 //            }
    5042
    5143            // write to temporary file, on success, rename tmp file to target file:
     
    6961        }
    7062    }
    71 
    72 
    7363}
  • applications/editors/josm/plugins/turnrestrictions/src/org/openstreetmap/josm/plugins/turnrestrictions/list/TurnRestrictionsInDatasetListModel.java

    r29854 r30145  
    7777    /* --------------------------------------------------------------------------- */   
    7878    public void dataChanged(DataChangedEvent event) {       
    79         OsmDataLayer layer = Main.map.mapView.getEditLayer();
     79        OsmDataLayer layer = Main.main.getEditLayer();
    8080        if (layer == null) {
    8181            setTurnRestrictions(null);
  • applications/editors/josm/plugins/turnrestrictions/src/org/openstreetmap/josm/plugins/turnrestrictions/list/TurnRestrictionsListDialog.java

    r30034 r30145  
    205205        protected Collection<RelationMember> getMembersForCurrentSelection(Relation r) {
    206206            Collection<RelationMember> members = new HashSet<RelationMember>();
    207             Collection<OsmPrimitive> selection = Main.map.mapView.getEditLayer().data.getSelected();
     207            Collection<OsmPrimitive> selection = Main.main.getEditLayer().data.getSelected();
    208208            for (RelationMember member: r.getMembers()) {
    209209                if (selection.contains(member.getMember())) {
Note: See TracChangeset for help on using the changeset viewer.