Changeset 25711 in osm for applications


Ignore:
Timestamp:
2011-03-25T16:40:33+01:00 (14 years ago)
Author:
zverik
Message:

context menu for relations, selected relations in relation list (reltoolbox plugin)

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

Legend:

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

    r25692 r25711  
    1919 */
    2020public class ChosenRelation implements EditLayerChangeListener, MapViewPaintable, DataSetListener {
    21     private Relation chosenRelation = null;
     21    protected Relation chosenRelation = null;
    2222    private Set<ChosenRelationListener> chosenRelationListeners = new HashSet<ChosenRelationListener>();
    2323
     
    7373    }
    7474
    75     private void analyse() {
     75    protected void analyse() {
    7676        // todo
    7777    }
  • applications/editors/josm/plugins/relcontext/src/relcontext/RelContextDialog.java

    r25709 r25711  
    11package relcontext;
    22
     3import org.openstreetmap.josm.gui.widgets.PopupMenuLauncher;
    34import org.openstreetmap.josm.command.SequenceCommand;
    45import org.openstreetmap.josm.command.Command;
     
    7475        MapView.addEditLayerChangeListener(chosenRelation);
    7576
    76         popupMenu = new ChosenRelationPopupMenu();
     77        popupMenu = new ChosenRelationPopupMenu(chosenRelation);
    7778        multiPopupMenu = new MultipolygonSettingsPopup();
    7879
     
    178179        relationsTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    179180        relationsTable.setTableHeader(null);
     181        relationsTable.addMouseListener(new PopupMenuLauncher() {
     182            @Override
     183            public void launch(MouseEvent evt) {
     184                Point p = evt.getPoint();
     185                int row = relationsTable.rowAtPoint(p);
     186                if (row > -1) {
     187                    Relation relation = (Relation)relationsData.getValueAt(row, 0);
     188                    JPopupMenu menu = new ChosenRelationPopupMenu(new StaticChosenRelation(relation));
     189                    menu.show(relationsTable, p.x, p.y-5);
     190                }
     191            }
     192        });
     193
    180194        TableColumnModel columns = relationsTable.getColumnModel();
    181195        columns.getColumn(0).setCellRenderer(new OsmPrimitivRenderer() {
     
    293307            relationsData.addRow(new Object[] {rel, role == null ? "" : role});
    294308        }
     309        for( OsmPrimitive element : newSelection )
     310            if( element instanceof Relation && (chosenRelation.get() == null || !chosenRelation.get().equals(element) ) )
     311                relationsData.addRow(new Object[] {element, ""});
    295312    }
    296313
     
    406423
    407424    private class ChosenRelationPopupMenu extends JPopupMenu {
    408         public ChosenRelationPopupMenu() {
     425        public ChosenRelationPopupMenu( ChosenRelation chosenRelation ) {
    409426            add(new SelectMembersAction(chosenRelation));
    410427            add(new SelectRelationAction(chosenRelation));
  • applications/editors/josm/plugins/relcontext/src/relcontext/actions/DeleteChosenRelationAction.java

    r25696 r25711  
    1919        this.rel = rel;
    2020        rel.addChosenRelationListener(this);
    21         setEnabled(false);
     21        setEnabled(rel.get() != null);
    2222    }
    2323
  • applications/editors/josm/plugins/relcontext/src/relcontext/actions/DownloadParentsAction.java

    r25695 r25711  
    3434        this.rel = rel;
    3535        rel.addChosenRelationListener(this);
    36         setEnabled(false);
     36        setEnabled(rel.get() != null && Main.map.mapView.getEditLayer() != null);
    3737    }
    3838
  • applications/editors/josm/plugins/relcontext/src/relcontext/actions/EditChosenRelationAction.java

    r25695 r25711  
    2626        this.rel = rel;
    2727        rel.addChosenRelationListener(this);
    28         setEnabled(false);
     28        setEnabled(rel.get() != null);
    2929    }
    3030
  • applications/editors/josm/plugins/relcontext/src/relcontext/actions/RelationHelpAction.java

    r25695 r25711  
    2727        this.rel = rel;
    2828        rel.addChosenRelationListener(this);
    29         setEnabled(false);
     29        setEnabled(rel.get() != null);
    3030    }
    3131
  • applications/editors/josm/plugins/relcontext/src/relcontext/actions/SelectInRelationPanelAction.java

    r25680 r25711  
    2020        this.rel = rel;
    2121        rel.addChosenRelationListener(this);
    22         setEnabled(false);
     22        setEnabled(rel.get() != null);
    2323    }
    2424
  • applications/editors/josm/plugins/relcontext/src/relcontext/actions/SelectMembersAction.java

    r25670 r25711  
    1818        this.rel = rel;
    1919        rel.addChosenRelationListener(this);
    20         setEnabled(false);
     20        setEnabled(rel.get() != null);
    2121    }
    2222
  • applications/editors/josm/plugins/relcontext/src/relcontext/actions/SelectRelationAction.java

    r25709 r25711  
    1919        this.rel = rel;
    2020        rel.addChosenRelationListener(this);
    21         setEnabled(false);
     21        setEnabled(rel.get() != null);
    2222    }
    2323
Note: See TracChangeset for help on using the changeset viewer.