Statistics
| Revision:

gvsig-tools / org.gvsig.tools / library / trunk / org.gvsig.tools / org.gvsig.tools.main / src / main / java / org / gvsig / tools / main / usability / UsabilityAction.java @ 501

History | View | Annotate | Download (5.16 KB)

1
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Government (CIT)
5
 * 
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 * 
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 * 
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
19
 * MA  02110-1301, USA.
20
 * 
21
 */
22

    
23
/*
24
 * AUTHORS (In addition to CIT):
25
 * 2010 {}  {{Task}}
26
 */
27
package org.gvsig.tools.main.usability;
28

    
29
import java.awt.Component;
30

    
31
import javax.swing.BoxLayout;
32
import javax.swing.JButton;
33
import javax.swing.JComponent;
34
import javax.swing.JPanel;
35
import javax.swing.JSpinner;
36
import javax.swing.JTabbedPane;
37
import javax.swing.JTextArea;
38

    
39
import org.gvsig.tools.dataTypes.DataTypes;
40
import org.gvsig.tools.main.MainAction;
41
import org.gvsig.tools.swing.api.ToolsSwingLocator;
42
import org.gvsig.tools.swing.api.usability.UsabilitySwingManager;
43

    
44
/**
45
 * Shows the panel of usability components.
46
 * 
47
 * @author 2010- C?sar Ordi?ana - gvSIG team 
48
 */
49
public class UsabilityAction extends MainAction {
50

    
51
    private static final long serialVersionUID = 6471916708466720365L;
52

    
53
    private static final UsabilitySwingManager manager =
54
        ToolsSwingLocator.getUsabilitySwingManager();
55

    
56
    /**
57
     * @see MainAction#MainAction(JTabbedPane)
58
     */
59
    public UsabilityAction(JTabbedPane tabbedPane) {
60
        super("Usability", tabbedPane);
61
        putValue(SHORT_DESCRIPTION, "Usability components");
62
    }
63

    
64
    @Override
65
    protected JComponent createComponent() {
66
        JTabbedPane tabbedPane = new JTabbedPane();
67
        tabbedPane.setTabPlacement(JTabbedPane.RIGHT);
68

    
69
        tabbedPane.addTab("JButton", createJButtonComponent());
70
        tabbedPane.addTab("JTextArea", createJTextAreaComponent());
71
        tabbedPane.addTab("JNullSpinner", createJNullSpinnerComponent());
72
        return tabbedPane;
73
    }
74

    
75
    @Override
76
    protected String getComponentTitle() {
77
        return "Usability";
78
    }
79

    
80
    private Component createJButtonComponent() {
81
        // Create the container panel
82
        JPanel panel = new JPanel();
83
        panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
84
        // panel.setLayout(new GridLayout(18, 1));
85
        // panel.setLayout(new );
86
        JButton button = manager.createJButton("+");
87
        panel.add(button); 
88
        button = manager.createJButton("-");
89
        panel.add(button);
90
        button = manager.createJToolButton("+");
91
        panel.add(button); 
92
        button = manager.createJToolButton("-");
93
        panel.add(button);
94
        // Create buttons with different sizes
95
        StringBuffer text = new StringBuffer("012");
96
        for (int i = 4; i < 22; i++) {
97
            text.append(String.valueOf(i % 10));
98
            button = manager.createJButton(text.toString());
99
            panel.add(button);
100
        }
101

    
102
        return panel;
103
    }
104

    
105
    private Component createJTextAreaComponent() {
106
        // Create the container panel
107
        JPanel panel = new JPanel();
108
        panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
109
        // panel.setLayout(new GridLayout(18, 1));
110
        // panel.setLayout(new );
111
        JTextArea ta = manager.createJTextArea("");       
112
        ta = manager.createJTextArea("test");
113
        panel.add(ta); 
114
        ta = manager.createJTextArea("test longer");
115
        panel.add(ta);
116
        ta = manager.createJTextArea("test much longer");
117
        panel.add(ta); 
118
        ta = manager.createJTextArea("test");
119
        panel.add(ta); 
120
        ta = manager.createJTextArea("test size = 150", 150);
121
        panel.add(ta); 
122
        ta = manager.createJTextArea("test too long", -1);
123
        panel.add(ta);
124
        // Create buttons with different sizes
125
        StringBuffer text = new StringBuffer("012");
126
        for (int i = 4; i < 22; i++) {
127
            text.append(String.valueOf(i % 10));
128
            ta = manager.createJTextArea(text.toString());
129
            panel.add(ta);
130
        }
131
   
132
        
133
        return panel;
134
    }
135

    
136
    private Component createJNullSpinnerComponent() {
137
        // Create the container panel
138
        JPanel panel = new JPanel();
139
        panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
140
        // panel.setLayout(new GridLayout(18, 1));
141
        // panel.setLayout(new );
142
        JSpinner spinner = manager.createJNullSpinner(DataTypes.FLOAT, "1.05", -1);
143
        panel.add(spinner);
144
        // Create buttons with different sizes
145
        StringBuffer text = new StringBuffer("01287.");
146
        for (int i = 4; i < 22; i++) {
147
            text.append(String.valueOf(i % 10));
148
            spinner = manager.createJNullSpinner(DataTypes.FLOAT, text.toString(), -1);
149
            panel.add(spinner);
150
        }
151

    
152
        return panel;
153
    }
154

    
155
}