Changeset 11945 in josm


Ignore:
Timestamp:
2017-04-17T14:47:28+02:00 (5 weeks ago)
Author:
Don-vip
Message:

sonar - fb-contrib:SCII_SPOILED_CHILD_INTERFACE_IMPLEMENTOR - Style - Class implements interface by relying on unknowing superclass methods

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

Legend:

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

    r11747 r11945  
    7373 * </pre>
    7474 */
    75 public class ExtendedDialog extends JDialog {
     75public class ExtendedDialog extends JDialog implements IExtendedDialog {
    7676    private final boolean disposeOnClose;
    7777    private volatile int result;
     
    173173    }
    174174
    175     /**
    176      * Allows decorating the buttons with icons.
    177      * @param buttonIcons The button icons
    178      * @return {@code this}
    179      */
     175    @Override
    180176    public ExtendedDialog setButtonIcons(Icon... buttonIcons) {
    181177        this.bIcons = Utils.copyArray(buttonIcons);
     
    183179    }
    184180
    185     /**
    186      * Convenience method to provide image names instead of images.
    187      * @param buttonIcons The button icon names
    188      * @return {@code this}
    189      */
     181    @Override
    190182    public ExtendedDialog setButtonIcons(String... buttonIcons) {
    191183        bIcons = new Icon[buttonIcons.length];
     
    196188    }
    197189
    198     /**
    199      * Allows decorating the buttons with tooltips. Expects a String array with
    200      * translated tooltip texts.
    201      *
    202      * @param toolTipTexts the tool tip texts. Ignored, if null.
    203      * @return {@code this}
    204      */
     190    @Override
    205191    public ExtendedDialog setToolTipTexts(String... toolTipTexts) {
    206192        this.bToolTipTexts = Utils.copyArray(toolTipTexts);
     
    208194    }
    209195
    210     /**
    211      * Sets the content that will be displayed in the message dialog.
    212      *
    213      * Note that depending on your other settings more UI elements may appear.
    214      * The content is played on top of the other elements though.
    215      *
    216      * @param content Any element that can be displayed in the message dialog
    217      * @return {@code this}
    218      */
     196    @Override
    219197    public ExtendedDialog setContent(Component content) {
    220198        return setContent(content, true);
    221199    }
    222200
    223     /**
    224      * Sets the content that will be displayed in the message dialog.
    225      *
    226      * Note that depending on your other settings more UI elements may appear.
    227      * The content is played on top of the other elements though.
    228      *
    229      * @param content Any element that can be displayed in the message dialog
    230      * @param placeContentInScrollPane if true, places the content in a JScrollPane
    231      * @return {@code this}
    232      */
     201    @Override
    233202    public ExtendedDialog setContent(Component content, boolean placeContentInScrollPane) {
    234203        this.content = content;
     
    237206    }
    238207
    239     /**
    240      * Sets the message that will be displayed. The String will be automatically
    241      * wrapped if it is too long.
    242      *
    243      * Note that depending on your other settings more UI elements may appear.
    244      * The content is played on top of the other elements though.
    245      *
    246      * @param message The text that should be shown to the user
    247      * @return {@code this}
    248      */
     208    @Override
    249209    public ExtendedDialog setContent(String message) {
    250210        return setContent(string2label(message), false);
    251211    }
    252212
    253     /**
    254      * Decorate the dialog with an icon that is shown on the left part of
    255      * the window area. (Similar to how it is done in {@link JOptionPane})
    256      * @param icon The icon to display
    257      * @return {@code this}
    258      */
     213    @Override
    259214    public ExtendedDialog setIcon(Icon icon) {
    260215        this.icon = icon;
     
    262217    }
    263218
    264     /**
    265      * Convenience method to allow values that would be accepted by {@link JOptionPane} as messageType.
    266      * @param messageType The {@link JOptionPane} messageType
    267      * @return {@code this}
    268      */
     219    @Override
    269220    public ExtendedDialog setIcon(int messageType) {
    270221        switch (messageType) {
     
    284235    }
    285236
    286     /**
    287      * Show the dialog to the user. Call this after you have set all options
    288      * for the dialog. You can retrieve the result using {@link #getValue()}.
    289      * @return {@code this}
    290      */
     237    @Override
    291238    public ExtendedDialog showDialog() {
    292239        // Check if the user has set the dialog to not be shown again
     
    309256    }
    310257
    311     /**
    312      * Retrieve the user choice after the dialog has been closed.
    313      *
    314      * @return <ul> <li>The selected button. The count starts with 1.</li>
    315      *              <li>A return value of {@link #DialogClosedOtherwise} means the dialog has been closed otherwise.</li>
    316      *         </ul>
    317      */
     258    @Override
    318259    public int getValue() {
    319260        return result;
     
    322263    private boolean setupDone;
    323264
    324     /**
    325      * This is called by {@link #showDialog()}.
    326      * Only invoke from outside if you need to modify the contentPane
    327      */
     265    @Override
    328266    public void setupDialog() {
    329267        if (setupDone)
     
    523461    }
    524462
    525     /**
    526      * Call this if you want the dialog to remember the geometry (size and position) set by the user.
    527      * Set the pref to <code>null</code> or to an empty string to disable again.
    528      * By default, it's disabled.
    529      *
    530      * Note: If you want to set the width of this dialog directly use the usual
    531      * setSize, setPreferredSize, setMaxSize, setMinSize
    532      *
    533      * @param pref  The preference to save the dimension to
    534      * @param wg    The default window geometry that should be used if no
    535      *              existing preference is found (only takes effect if
    536      *              <code>pref</code> is not null or empty
    537      * @return {@code this}
    538      */
     463    @Override
    539464    public ExtendedDialog setRememberWindowGeometry(String pref, WindowGeometry wg) {
    540465        rememberSizePref = pref == null ? "" : pref;
     
    543468    }
    544469
    545     /**
    546      * Calling this will offer the user a "Do not show again" checkbox for the
    547      * dialog. Default is to not offer the choice; the dialog will be shown
    548      * every time.
    549      * Currently, this is not supported for non-modal dialogs.
    550      * @param togglePref  The preference to save the checkbox state to
    551      * @return {@code this}
    552      */
     470    @Override
    553471    public ExtendedDialog toggleEnable(String togglePref) {
    554472        if (!modal) {
     
    560478    }
    561479
    562     /**
    563      * Sets the button that will react to ENTER.
    564      * @param defaultButtonIdx The button index (starts to 1)
    565      * @return {@code this}
    566      */
     480    @Override
    567481    public ExtendedDialog setDefaultButton(int defaultButtonIdx) {
    568482        this.defaultButtonIdx = defaultButtonIdx;
     
    570484    }
    571485
    572     /**
    573      * Used in combination with toggle:
    574      * If the user presses 'cancel' the toggle settings are ignored and not saved to the pref
    575      * @param cancelButtonIdx index of the button that stands for cancel, accepts multiple values
    576      * @return {@code this}
    577      */
     486    @Override
    578487    public ExtendedDialog setCancelButton(Integer... cancelButtonIdx) {
    579488        this.cancelButtonIdx = new HashSet<>(Arrays.<Integer>asList(cancelButtonIdx));
     
    581490    }
    582491
    583     /**
    584      * Makes default button request initial focus or not.
    585      * @param focus {@code true} to make default button request initial focus
    586      * @since 7407
    587      */
     492    @Override
    588493    public void setFocusOnDefaultButton(boolean focus) {
    589494        focusOnDefaultButton = focus;
     
    596501    }
    597502
    598     /**
    599      * This function returns true if the dialog has been set to "do not show again"
    600      * @return true if dialog should not be shown again
    601      */
     503    @Override
    602504    public final boolean toggleCheckState() {
    603505        toggleable = togglePref != null && !togglePref.isEmpty();
     
    634536    }
    635537
    636     /**
    637      * Configures how this dialog support for context sensitive help.
    638      * <ul>
    639      *  <li>if helpTopic is null, the dialog doesn't provide context sensitive help</li>
    640      *  <li>if helpTopic != null, the dialog redirect user to the help page for this helpTopic when
    641      *  the user clicks F1 in the dialog</li>
    642      *  <li>if showHelpButton is true, the dialog displays "Help" button (rightmost button in
    643      *  the button row)</li>
    644      * </ul>
    645      *
    646      * @param helpTopic the help topic
    647      * @param showHelpButton true, if the dialog displays a help button
    648      * @return {@code this}
    649      */
     538    @Override
    650539    public ExtendedDialog configureContextsensitiveHelp(String helpTopic, boolean showHelpButton) {
    651540        this.helpTopic = helpTopic;
  • trunk/src/org/openstreetmap/josm/gui/SelectionManager.java

    r10716 r11945  
    1616import java.util.LinkedList;
    1717
     18import javax.swing.Action;
     19
    1820import org.openstreetmap.josm.Main;
    1921import org.openstreetmap.josm.actions.SelectByInternalPointAction;
     
    6062     * @author imi
    6163     */
    62     public interface SelectionEnded {
     64    public interface SelectionEnded extends Action {
    6365        /**
    6466         * Called, when the left mouse button was released.
     
    6971         */
    7072        void selectionEnded(Rectangle r, MouseEvent e);
    71 
    72         /**
    73          * Called to register the selection manager for "active" property.
    74          * @param listener The listener to register
    75          */
    76         void addPropertyChangeListener(PropertyChangeListener listener);
    77 
    78         /**
    79          * Called to remove the selection manager from the listener list
    80          * for "active" property.
    81          * @param listener The listener to register
    82          */
    83         void removePropertyChangeListener(PropertyChangeListener listener);
    8473    }
    8574
  • trunk/src/org/openstreetmap/josm/gui/dialogs/properties/TagEditHelper.java

    r11804 r11945  
    7676import org.openstreetmap.josm.data.preferences.StringProperty;
    7777import org.openstreetmap.josm.gui.ExtendedDialog;
     78import org.openstreetmap.josm.gui.IExtendedDialog;
    7879import org.openstreetmap.josm.gui.datatransfer.ClipboardUtils;
    7980import org.openstreetmap.josm.gui.mappaint.MapPaintStyles;
     
    241242    }
    242243
     244    /**
     245     * Returns a new {@code AddTagsDialog}.
     246     * @return a new {@code AddTagsDialog}
     247     */
    243248    protected AddTagsDialog getAddTagsDialog() {
    244249        return new AddTagsDialog();
     
    267272    }
    268273
    269     protected interface IEditTagDialog {
    270         ExtendedDialog showDialog();
    271 
    272         int getValue();
    273 
     274    /**
     275     * Extracted interface of {@link EditTagDialog}.
     276     */
     277    protected interface IEditTagDialog extends IExtendedDialog {
     278        /**
     279         * Edit tags of multiple selected objects according to selected ComboBox values
     280         * If value == "", tag will be deleted
     281         * Confirmations may be needed.
     282         */
    274283        void performTagEdit();
    275284    }
     
    483492        }
    484493
    485         /**
    486          * Edit tags of multiple selected objects according to selected ComboBox values
    487          * If value == "", tag will be deleted
    488          * Confirmations may be needed.
    489          */
    490494        @Override
    491495        public void performTagEdit() {
Note: See TracChangeset for help on using the changeset viewer.