Changeset 14685 in josm


Ignore:
Timestamp:
2019-01-12T21:19:22+01:00 (4 days ago)
Author:
simon04
Message:

fix #14462 - Harmonize relation actions provided in popup menus

Location:
trunk/src/org/openstreetmap/josm/gui/dialogs
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/dialogs/RelationListDialog.java

    r14475 r14685  
    3434
    3535import org.openstreetmap.josm.actions.ExpertToggleAction;
    36 import org.openstreetmap.josm.actions.IPrimitiveAction;
    3736import org.openstreetmap.josm.actions.relation.AddSelectionToRelations;
    3837import org.openstreetmap.josm.actions.relation.DeleteRelationsAction;
    39 import org.openstreetmap.josm.actions.relation.DownloadMembersAction;
    40 import org.openstreetmap.josm.actions.relation.DownloadSelectedIncompleteMembersAction;
    4138import org.openstreetmap.josm.actions.relation.DuplicateRelationAction;
    4239import org.openstreetmap.josm.actions.relation.EditRelationAction;
     
    4441import org.openstreetmap.josm.actions.relation.ExportRelationToGpxAction.Mode;
    4542import org.openstreetmap.josm.actions.relation.RecentRelationsAction;
    46 import org.openstreetmap.josm.actions.relation.SelectMembersAction;
     43import org.openstreetmap.josm.actions.relation.SelectInRelationListAction;
    4744import org.openstreetmap.josm.actions.relation.SelectRelationAction;
    4845import org.openstreetmap.josm.data.osm.DataSet;
     
    7370import org.openstreetmap.josm.gui.SideButton;
    7471import org.openstreetmap.josm.gui.dialogs.relation.RelationEditor;
     72import org.openstreetmap.josm.gui.dialogs.relation.RelationPopupMenus;
    7573import org.openstreetmap.josm.gui.layer.LayerManager.LayerAddEvent;
    7674import org.openstreetmap.josm.gui.layer.LayerManager.LayerChangeListener;
     
    9997 */
    10098public class RelationListDialog extends ToggleDialog
    101         implements DataSetListener, NavigatableComponent.ZoomChangeListener, ExpertToggleAction.ExpertModeChangeListener {
     99        implements DataSetListener, NavigatableComponent.ZoomChangeListener {
    102100    /** The display list. */
    103101    private final JList<IRelation<?>> displaylist;
     
    120118    /** the duplicate action */
    121119    private final DuplicateRelationAction duplicateAction = new DuplicateRelationAction();
    122     private final DownloadMembersAction downloadMembersAction = new DownloadMembersAction();
    123     private final DownloadSelectedIncompleteMembersAction downloadSelectedIncompleteMembersAction =
    124             new DownloadSelectedIncompleteMembersAction();
    125     private final SelectMembersAction selectMembersAction = new SelectMembersAction(false);
    126     private final SelectMembersAction addMembersToSelectionAction = new SelectMembersAction(true);
     120    /** the select relation action */
    127121    private final SelectRelationAction selectRelationAction = new SelectRelationAction(false);
    128     private final SelectRelationAction addRelationToSelectionAction = new SelectRelationAction(true);
    129122    /** add all selected primitives to the given relations */
    130123    private final AddSelectionToRelations addSelectionToRelations = new AddSelectionToRelations();
    131     private transient JMenuItem addSelectionToRelationMenuItem;
    132124
    133125    /** export relation to GPX track action */
     
    245237        SelectionEventManager.getInstance().addSelectionListener(addSelectionToRelations);
    246238        dataChanged(null);
    247         ExpertToggleAction.addExpertModeChangeListener(this);
    248         expertChanged(ExpertToggleAction.isExpert());
    249239    }
    250240
     
    256246        DatasetEventManager.getInstance().removeDatasetListener(this);
    257247        SelectionEventManager.getInstance().removeSelectionListener(addSelectionToRelations);
    258         ExpertToggleAction.removeExpertModeChangeListener(this);
    259248    }
    260249
     
    632621        List<JMenuItem> checkDisabled = new ArrayList<>();
    633622
    634         // -- select action
    635         popupMenuHandler.addAction(selectRelationAction);
    636         popupMenuHandler.addAction(addRelationToSelectionAction);
    637 
    638         // -- select members action
    639         popupMenuHandler.addAction(selectMembersAction);
    640         popupMenuHandler.addAction(addMembersToSelectionAction);
    641 
    642         // -- download members action
    643         popupMenuHandler.addSeparator();
    644         popupMenuHandler.addAction(downloadMembersAction);
    645         popupMenuHandler.addAction(downloadSelectedIncompleteMembersAction);
     623        RelationPopupMenus.setupHandler(popupMenuHandler, SelectInRelationListAction.class);
    646624
    647625        // -- export relation to gpx action
     
    658636        popupMenuHandler.addAction(deleteRelationsAction).setVisible(false);
    659637
    660         addSelectionToRelationMenuItem = popupMenuHandler.addAction(addSelectionToRelations);
     638        ExpertToggleAction.addVisibilitySwitcher(popupMenuHandler.addAction(addSelectionToRelations));
    661639
    662640        popupMenuHandler.addListener(new PopupMenuListener() {
     
    664642            public void popupMenuWillBecomeVisible(PopupMenuEvent e) {
    665643                for (JMenuItem mi: checkDisabled) {
    666                     mi.setVisible(((IPrimitiveAction) mi.getAction()).isEnabled());
    667 
    668                     Component sep = popupMenu.getComponent(
    669                             Math.max(0, popupMenu.getComponentIndex(mi)-1));
     644                    mi.setVisible(mi.getAction().isEnabled());
     645                    Component sep = popupMenu.getComponent(Math.max(0, popupMenu.getComponentIndex(mi) - 1));
    670646                    if (!(sep instanceof JMenuItem)) {
    671647                        sep.setVisible(mi.isVisible());
     
    770746        }
    771747    }
    772 
    773     @Override
    774     public void expertChanged(boolean isExpert) {
    775         addSelectionToRelationMenuItem.setVisible(isExpert);
    776     }
    777748}
  • trunk/src/org/openstreetmap/josm/gui/dialogs/SelectionListDialog.java

    r14609 r14685  
    4040import org.openstreetmap.josm.actions.AutoScaleAction;
    4141import org.openstreetmap.josm.actions.AutoScaleAction.AutoScaleMode;
    42 import org.openstreetmap.josm.actions.relation.DownloadSelectedIncompleteMembersAction;
    4342import org.openstreetmap.josm.actions.relation.EditRelationAction;
    44 import org.openstreetmap.josm.actions.relation.SelectInRelationListAction;
    4543import org.openstreetmap.josm.data.osm.DataSelectionListener;
    4644import org.openstreetmap.josm.data.osm.DataSet;
     
    7270import org.openstreetmap.josm.gui.datatransfer.PrimitiveTransferable;
    7371import org.openstreetmap.josm.gui.datatransfer.data.PrimitiveTransferData;
     72import org.openstreetmap.josm.gui.dialogs.relation.RelationPopupMenus;
    7473import org.openstreetmap.josm.gui.history.HistoryBrowserDialogManager;
    7574import org.openstreetmap.josm.gui.layer.MainLayerManager.ActiveLayerChangeEvent;
     
    10099    private final ZoomToJOSMSelectionAction actZoomToJOSMSelection = new ZoomToJOSMSelectionAction();
    101100    private final ZoomToListSelection actZoomToListSelection = new ZoomToListSelection();
    102     private final SelectInRelationListAction actSetRelationSelection = new SelectInRelationListAction();
    103     private final EditRelationAction actEditRelationSelection = new EditRelationAction();
    104     private final DownloadSelectedIncompleteMembersAction actDownloadSelIncompleteMembers = new DownloadSelectedIncompleteMembersAction();
    105101
    106102    /** the popup menu and its handler */
     
    216212                } else if (osm instanceof Relation) {
    217213                    // else open relation editor if applicable
    218                     actEditRelationSelection.actionPerformed(null);
     214                    EditRelationAction.launchEditor((Relation) osm);
    219215                }
    220216            } else if (highlightEnabled && MainApplication.isDisplayingMapView() && helper.highlightOnly(model.getElementAt(idx))) {
     
    235231        handler.addAction(actZoomToListSelection);
    236232        handler.addSeparator();
    237         handler.addAction(actSetRelationSelection);
    238         handler.addAction(actEditRelationSelection);
    239         handler.addSeparator();
    240         handler.addAction(actDownloadSelIncompleteMembers);
    241         return handler;
     233        return RelationPopupMenus.setupHandler(handler);
    242234    }
    243235
  • trunk/src/org/openstreetmap/josm/gui/dialogs/properties/PropertiesDialog.java

    r14678 r14685  
    5050
    5151import org.openstreetmap.josm.actions.JosmAction;
    52 import org.openstreetmap.josm.actions.relation.DownloadMembersAction;
    53 import org.openstreetmap.josm.actions.relation.DownloadSelectedIncompleteMembersAction;
    54 import org.openstreetmap.josm.actions.relation.SelectInRelationListAction;
    55 import org.openstreetmap.josm.actions.relation.SelectMembersAction;
    56 import org.openstreetmap.josm.actions.relation.SelectRelationAction;
     52import org.openstreetmap.josm.actions.relation.DeleteRelationsAction;
     53import org.openstreetmap.josm.actions.relation.EditRelationAction;
    5754import org.openstreetmap.josm.command.ChangeCommand;
    5855import org.openstreetmap.josm.command.ChangePropertyCommand;
     
    9087import org.openstreetmap.josm.gui.dialogs.ToggleDialog;
    9188import org.openstreetmap.josm.gui.dialogs.relation.RelationEditor;
     89import org.openstreetmap.josm.gui.dialogs.relation.RelationPopupMenus;
    9290import org.openstreetmap.josm.gui.help.HelpUtil;
    9391import org.openstreetmap.josm.gui.layer.MainLayerManager.ActiveLayerChangeEvent;
     
    198196    private final JosmAction[] josmActions = new JosmAction[]{addAction, editAction, deleteAction};
    199197
    200     // relation actions
    201     private final SelectInRelationListAction setRelationSelectionAction = new SelectInRelationListAction();
    202     private final SelectRelationAction selectRelationAction = new SelectRelationAction(false);
    203     private final SelectRelationAction addRelationToSelectionAction = new SelectRelationAction(true);
    204 
    205     private final DownloadMembersAction downloadMembersAction = new DownloadMembersAction();
    206     private final DownloadSelectedIncompleteMembersAction downloadSelectedIncompleteMembersAction =
    207             new DownloadSelectedIncompleteMembersAction();
    208 
    209     private final SelectMembersAction selectMembersAction = new SelectMembersAction(false);
    210     private final SelectMembersAction addMembersToSelectionAction = new SelectMembersAction(true);
    211 
    212198    private final transient HighlightHelper highlightHelper = new HighlightHelper();
    213199
     
    371357            membershipMenu.addSeparator();
    372358        }
    373         membershipMenuHandler.addAction(setRelationSelectionAction);
    374         membershipMenuHandler.addAction(selectRelationAction);
    375         membershipMenuHandler.addAction(addRelationToSelectionAction);
    376         membershipMenuHandler.addAction(selectMembersAction);
    377         membershipMenuHandler.addAction(addMembersToSelectionAction);
    378         membershipMenu.addSeparator();
    379         membershipMenuHandler.addAction(downloadMembersAction);
    380         membershipMenuHandler.addAction(downloadSelectedIncompleteMembersAction);
     359        RelationPopupMenus.setupHandler(membershipMenuHandler, EditRelationAction.class, DeleteRelationsAction.class);
    381360        membershipMenu.addSeparator();
    382361        membershipMenu.add(helpAction);
Note: See TracChangeset for help on using the changeset viewer.