Changeset 4765 in josm for trunk


Ignore:
Timestamp:
2012-01-04T13:34:49+01:00 (12 years ago)
Author:
stoecker
Message:

allow individual disabled dynamic buttons

Location:
trunk
Files:
2 added
1 edited

Legend:

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

    r4609 r4765  
    8383     */
    8484    protected boolean isCollapsed;
     85    /**
     86     * Indicates whether dynamic button hiding is active or not.
     87     */
     88    protected boolean isButtonHiding;
    8589
    8690    /** the preferred height if the toggle dialog is expanded */
     
    8993    /** the label in the title bar which shows whether the toggle dialog is expanded or collapsed */
    9094    private JLabel lblMinimized;
     95
     96    /** the label in the title bar which shows whether buttons are dynamic or not */
     97    private JButton buttonsHide = null;
    9198
    9299    /** the JDialog displaying the toggle dialog as undocked dialog */
     
    132139        toggleAction.putValue("help", helpId.substring(0, helpId.length()-6));
    133140
    134         /** show the minimize button */
    135         lblMinimized = new JLabel(ImageProvider.get("misc", "normal"));
    136         titleBar = new TitleBar(name, iconName);
    137         add(titleBar, BorderLayout.NORTH);
    138 
    139         setBorder(BorderFactory.createEtchedBorder());
    140 
    141141        isShowing = Main.pref.getBoolean(preferencePrefix+".visible", defShow);
    142142        isDocked = Main.pref.getBoolean(preferencePrefix+".docked", true);
    143143        isCollapsed = Main.pref.getBoolean(preferencePrefix+".minimized", false);
     144        isButtonHiding = Main.pref.getBoolean(preferencePrefix+".buttonhiding", true);
     145
     146        /** show the minimize button */
     147        titleBar = new TitleBar(name, iconName);
     148        add(titleBar, BorderLayout.NORTH);
     149
     150        setBorder(BorderFactory.createEtchedBorder());
    144151
    145152        RedirectInputMap.redirectToMainContentPane(this);
     
    222229            dialogsPanel.reconstruct(Action.COLLAPSED_TO_DEFAULT, this);
    223230        } else if (!isDialogShowing()) {
    224 //            if (isButtonHidden()) {
    225 //                showButtonImpl();
    226 //            }
    227231            showDialog();
    228232            if (isDocked && isCollapsed) {
     
    289293     */
    290294    public void collapse() {
    291         //        if (isShowing && isDocked && !isCollapsed) {
    292295        if (isDialogInDefaultView()) {
    293296            setContentVisible(false);
     
    305308     */
    306309    protected void expand() {
    307         //        if (isShowing && isDocked && isCollapsed) {
    308310        if (isDialogInCollapsedView()) {
    309311            setContentVisible(true);
     
    375377        public TitleBar(String toggleDialogName, String iconName) {
    376378            setLayout(new GridBagLayout());
     379
    377380            lblMinimized = new JLabel(ImageProvider.get("misc", "normal"));
    378381            add(lblMinimized);
     
    404407                        @Override
    405408                        public void mouseClicked(MouseEvent e) {
    406                             // toggleExpandedState
    407409                            if (isCollapsed) {
    408410                                expand();
     
    415417                    }
    416418            );
     419
     420            if(Main.pref.getBoolean("dialog.dynamic.buttons", true)) {
     421                buttonsHide = new JButton(ImageProvider.get("misc", isButtonHiding ? "buttonhide" : "buttonshow"));
     422                buttonsHide.setToolTipText(tr("Toggle dynamic buttons"));
     423                buttonsHide.setBorder(BorderFactory.createEmptyBorder());
     424                buttonsHide.addActionListener(
     425                    new ActionListener(){
     426                        public void actionPerformed(ActionEvent e) {
     427                            setIsButtonHiding(!isButtonHiding);
     428                        }
     429                    }
     430                );
     431                add(buttonsHide);
     432            }
    417433
    418434            // show the sticky button
     
    574590    }
    575591
     592    protected void setIsButtonHiding(boolean val) {
     593        isButtonHiding = val;
     594        Main.pref.put(preferencePrefix+".buttonhiding", val);
     595        buttonsHide.setIcon(ImageProvider.get("misc", val ? "buttonhide" : "buttonshow"));
     596        stateChanged();
     597    }
     598
    576599    public int getPreferredHeight() {
    577600        return preferredHeight;
     
    652675     */
    653676    protected void stateChanged() {
    654     }
    655 
    656     /* use createLayout() instead of self-constructed dialogs */
    657     @Deprecated
    658     protected JPanel getButtonPanel(int columns) {
    659         JPanel pnl = new JPanel();
    660         pnl.setLayout(Main.pref.getBoolean("dialog.align.left", false)
    661                 ? new FlowLayout(FlowLayout.LEFT) : new GridLayout(1,columns));
    662         return pnl;
    663677    }
    664678
     
    677691                buttonsPanel.setVisible(false);
    678692            }
     693        } else if(buttonsHide != null) {
     694            buttonsHide.setVisible(false);
    679695        }
    680696        return data;
     
    683699    @Override
    684700    public void eventDispatched(AWTEvent event) {
    685         if(isShowing() && !isCollapsed) {
     701        if(isShowing() && !isCollapsed && isButtonHiding) {
    686702            Rectangle b = this.getBounds();
    687703            b.setLocation(getLocationOnScreen());
Note: See TracChangeset for help on using the changeset viewer.