Changeset 13545 in josm for trunk/src


Ignore:
Timestamp:
2018-03-19T20:22:42+01:00 (7 years ago)
Author:
Don-vip
Message:

fix #16106 - disable search button arrow when button itself is disabled. Default behaviour of SideButton is not changed (as select button does not have the same logic)

Location:
trunk/src/org/openstreetmap/josm
Files:
3 edited

Legend:

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

    r13434 r13545  
    762762        static SearchTask newSearchTask(SearchSetting setting, SearchReceiver resultReceiver) {
    763763            final DataSet ds = MainApplication.getLayerManager().getActiveDataSet();
     764            if (ds == null) {
     765                throw new IllegalStateException("No active dataset");
     766            }
    764767            return newSearchTask(setting, ds, resultReceiver);
    765768        }
  • trunk/src/org/openstreetmap/josm/gui/SideButton.java

    r13188 r13545  
    2626
    2727    private transient PropertyChangeListener propertyChangeListener;
     28    private BasicArrowButton arrowButton;
     29    private boolean arrowEnabledWithButton;
    2830
    2931    /**
     
    8789     */
    8890    public BasicArrowButton createArrow(ActionListener listener) {
     91        return createArrow(listener, false);
     92    }
     93
     94    /**
     95     * Create the arrow for opening a drop-down menu
     96     * @param listener listener to use for button actions (e.g. pressing)
     97     * @param enabledWithButton determines if the button arrow enabled state is the same as main button
     98     * @return the created button
     99     * @since 13545
     100     */
     101    public BasicArrowButton createArrow(ActionListener listener, boolean enabledWithButton) {
    89102        setMargin(new Insets(0, 0, 0, 0));
    90         BasicArrowButton arrowButton = new BasicArrowButton(SwingConstants.SOUTH, null, null, Color.BLACK, null);
     103        arrowEnabledWithButton = enabledWithButton;
     104        arrowButton = new BasicArrowButton(SwingConstants.SOUTH, null, null, Color.BLACK, null);
    91105        arrowButton.setBorder(BorderFactory.createEmptyBorder());
    92106        add(arrowButton, BorderLayout.EAST);
    93107        arrowButton.addActionListener(listener);
     108        if (arrowEnabledWithButton) {
     109            arrowButton.setEnabled(isEnabled());
     110        }
    94111        return arrowButton;
     112    }
     113
     114    @Override
     115    public void setEnabled(boolean b) {
     116        super.setEnabled(b);
     117        if (arrowButton != null && arrowEnabledWithButton) {
     118            arrowButton.setEnabled(b);
     119        }
    95120    }
    96121
     
    107132            setAction(null);
    108133        }
     134        arrowButton = null;
    109135    }
    110136}
  • trunk/src/org/openstreetmap/josm/gui/dialogs/SelectionListDialog.java

    r13434 r13545  
    128128        // the search button
    129129        final SideButton searchButton = new SideButton(actSearch);
    130         searchButton.createArrow(e -> SearchPopupMenu.launch(searchButton));
     130        searchButton.createArrow(e -> SearchPopupMenu.launch(searchButton), true);
    131131
    132132        createLayout(lstPrimitives, true, Arrays.asList(
Note: See TracChangeset for help on using the changeset viewer.