Statistics
| Revision:

root / branches / v2_0_0_prep / frameworks / _fwAndami / src / org / gvsig / andami / ui / mdiFrame / SelectableToolBar.java @ 38608

History | View | Annotate | Download (3.5 KB)

1 1104 fjp
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
4
 *
5
 * This program is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU General Public License
7
 * as published by the Free Software Foundation; either version 2
8
 * of the License, or (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program; if not, write to the Free Software
17
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
18
 *
19
 * For more information, contact:
20
 *
21
 *  Generalitat Valenciana
22
 *   Conselleria d'Infraestructures i Transport
23
 *   Av. Blasco Ib??ez, 50
24
 *   46010 VALENCIA
25
 *   SPAIN
26
 *
27
 *      +34 963862235
28
 *   gvsig@gva.es
29
 *      www.gvsig.gva.es
30
 *
31
 *    or
32
 *
33
 *   IVER T.I. S.A
34
 *   Salamanca 50
35
 *   46005 Valencia
36
 *   Spain
37
 *
38
 *   +34 963163400
39
 *   dac@iver.es
40
 */
41 29593 jpiera
package org.gvsig.andami.ui.mdiFrame;
42 598 fernando
43
import javax.swing.ButtonGroup;
44
import javax.swing.JToggleButton;
45
import javax.swing.JToolBar;
46
47
48
/**
49
 * Caja de herramientas seleccionables
50
 */
51
public class SelectableToolBar extends JToolBar {
52 10582 cesar
        private static final long serialVersionUID = 1L;
53
        /**
54 9822 cesar
     * Andami visibility: determines whether this toolbar should
55
     * be shown by Andami. If it's false, the toolbar will be
56
     * hidden even if its associated extension is visible.
57
     */
58
    private boolean _visible;
59 598 fernando
60
    /**
61
     * Creates a new SelectableToolBar object.
62
     *
63
     * @param titulo T?tulo de la barra
64
     */
65
    public SelectableToolBar(String titulo) {
66
        super(titulo);
67
    }
68
69
    /**
70
     * A?ade un boton a la caja
71
     *
72
     * @param btn bot?n a a?adir.
73
     */
74 3196 caballero
    public void addButton(ButtonGroup group, JToggleButton btn) {
75
            group.add(btn);
76
        add(btn);
77
    }
78 3897 caballero
79 2684 fjp
    /**
80
     * Selects a toggleButton in this toolBar by ActionCommand
81
     * @param actionCommand
82
     */
83 3897 caballero
    public void setSelectedTool(String actionCommand){
84 2684 fjp
        for (int i = 0; i < getComponentCount(); i++) {
85
            if (getComponent(i) instanceof JToggleButton)
86
            {
87
                JToggleButton toggleButton = (JToggleButton) getComponent(i);
88
                String aux = toggleButton.getActionCommand();
89 3897 caballero
                if (aux != null)
90
                  if (aux.equals(actionCommand)){
91 2684 fjp
                        toggleButton.setSelected(true);
92
                      }
93
            }
94
        }
95 3897 caballero
96 2684 fjp
    }
97 9822 cesar
98
    /**
99
     * Sets whether or not this toolbar should
100
     * be shown by Andami. If it's false, the toolbar will be
101
     * hidden even if its associated extension is visible.
102
     *
103
     * @param visible
104
     */
105
    public void setAndamiVisibility(boolean visible) {
106
            _visible = visible;
107
    }
108
109
    /**
110
     * Gets whether this toolbar should
111
     * be shown by Andami. If it's false, the toolbar will be
112
     * hidden even if its associated extension is visible.
113
     *
114
     * @return <code>true</code> if the toolbar should be shown
115
     * when it has some visible button, <code>false</code> if
116
     * the toolbar should be hidden even it it contains some
117
     * buttons that should be visible according to its associated
118
     * extension.
119
     */
120
    public boolean getAndamiVisibility() {
121
            return _visible;
122
    }
123 598 fernando
}