Ignore:
Timestamp:
2011-03-23T07:57:47+01:00 (14 years ago)
Author:
zverik
Message:

sort and fix relation, some listener updates (relcontext plugin)

Location:
applications/editors/josm/plugins/relcontext/src/relcontext
Files:
1 added
2 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/relcontext/src/relcontext/ChosenRelation.java

    r25669 r25671  
    4444    public void clear() {
    4545        set(null);
     46    }
     47   
     48    private final static String[] MULTIPOLYGON_TYPES = new String[] {
     49        "multipolygon", "boundary", "natural_reserve"
     50    };
     51
     52    /**
     53     * Check if the relation type assumes all ways inside it form a multipolygon.
     54     */
     55    public boolean isMultipolygon() {
     56        if( chosenRelation == null )
     57            return false;
     58        String type = chosenRelation.get("type");
     59        if( type == null )
     60            return false;
     61        for( String t : MULTIPOLYGON_TYPES )
     62            if( t.equals(type) )
     63                return true;
     64        return false;
    4665    }
    4766
     
    127146    }
    128147
     148    public void primtivesRemoved( PrimitivesRemovedEvent event ) {
     149        if( chosenRelation != null && event.getPrimitives().contains(chosenRelation) )
     150            clear();
     151    }
     152
    129153    public void nodeMoved( NodeMovedEvent event ) {}
    130154    public void otherDatasetChange( AbstractDatasetChangedEvent event ) {}
    131155    public void primtivesAdded( PrimitivesAddedEvent event ) {}
    132     public void primtivesRemoved( PrimitivesRemovedEvent event ) {}
    133156    public void wayNodesChanged( WayNodesChangedEvent event ) {}
    134157}
  • applications/editors/josm/plugins/relcontext/src/relcontext/RelContextDialog.java

    r25670 r25671  
    8484        topLine.add(chosenRelationComponent, BorderLayout.CENTER);
    8585        JPanel topRightButtons = new JPanel(new FlowLayout(FlowLayout.RIGHT));
     86        final Action sortAndFixAction = new SortAndFixAction(chosenRelation);
     87        final JButton sortAndFixButton = new JButton(sortAndFixAction);
     88        topRightButtons.add(sortAndFixButton);
    8689        final Action downloadChosenRelationAction = new DownloadChosenRelationAction(chosenRelation);
    8790        final JButton downloadButton = new JButton(downloadChosenRelationAction);
     
    9194        rcPanel.add(topLine, BorderLayout.NORTH);
    9295
     96        sortAndFixAction.addPropertyChangeListener(new PropertyChangeListener() {
     97            public void propertyChange( PropertyChangeEvent evt ) {
     98                sortAndFixButton.setVisible(sortAndFixAction.isEnabled());
     99            }
     100        });
     101        sortAndFixButton.setVisible(false);
     102
    93103        downloadChosenRelationAction.addPropertyChangeListener(new PropertyChangeListener() {
    94104            public void propertyChange( PropertyChangeEvent evt ) {
     
    131141        if( topLine != null )
    132142            topLine.setVisible(newRelation != null);
     143        if( oldRelation != newRelation && Main.main.getCurrentDataSet() != null )
     144            selectionChanged(Main.main.getCurrentDataSet().getSelected());
    133145        // ?
    134146    }
Note: See TracChangeset for help on using the changeset viewer.