svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.plugin / org.gvsig.app / org.gvsig.app.mainplugin / src / test / java / org / gvsig / app / panelGroup / samples / SampleScalePanel.java @ 40558
History | View | Annotate | Download (4.3 KB)
1 |
/**
|
---|---|
2 |
* gvSIG. Desktop Geographic Information System.
|
3 |
*
|
4 |
* Copyright (C) 2007-2013 gvSIG Association.
|
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 3
|
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 |
* For any additional information, do not hesitate to contact us
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com.
|
23 |
*/
|
24 |
package org.gvsig.app.panelGroup.samples; |
25 |
|
26 |
import java.awt.Color; |
27 |
import java.awt.Dimension; |
28 |
import java.awt.event.MouseAdapter; |
29 |
import java.awt.event.MouseEvent; |
30 |
import java.io.Serializable; |
31 |
|
32 |
import javax.swing.JScrollPane; |
33 |
import javax.swing.JTextArea; |
34 |
|
35 |
import org.gvsig.gui.beans.panelGroup.panels.AbstractPanel; |
36 |
|
37 |
/**
|
38 |
* <p>Sample of {@link AbstractPanel AbstractPanel}.</p>
|
39 |
*
|
40 |
* @version 16/10/2007
|
41 |
* @author Pablo Piqueras Bartolom? (pablo.piqueras@iver.es)
|
42 |
*/
|
43 |
public class SampleScalePanel extends AbstractPanel implements Serializable { |
44 |
private static final long serialVersionUID = -4160464669737958732L; |
45 |
|
46 |
/**
|
47 |
* <p>Element for the interface.</p>
|
48 |
*/
|
49 |
private JTextArea jTextArea = null; |
50 |
|
51 |
/**
|
52 |
* @see AbstractPanel#AbstractPanel()
|
53 |
*/
|
54 |
public SampleScalePanel() {
|
55 |
super();
|
56 |
initialize(); |
57 |
} |
58 |
|
59 |
/**
|
60 |
* @see AbstractPanel#AbstractPanel(String, String, String)
|
61 |
*/
|
62 |
public SampleScalePanel(String id, String label, String labelGroup) { |
63 |
super(id, label, labelGroup);
|
64 |
initialize(); |
65 |
} |
66 |
|
67 |
@Override
|
68 |
protected void initialize() { |
69 |
add(new JScrollPane(getJTextArea())); |
70 |
setToolTipText(getID()); |
71 |
|
72 |
setID(Samples_ExtensionPointsOfIPanels.PANELS1_IDS[5]);
|
73 |
setLabel(Samples_ExtensionPointsOfIPanels.PANELS1_LABELS[5]);
|
74 |
setLabelGroup(Samples_ExtensionPointsOfIPanels.PANELS1_LABELGROUPS[5]);
|
75 |
setPreferredSize(new Dimension(Samples_ExtensionPointsOfIPanels.PANELS_DEFAULT_WIDTH, Samples_ExtensionPointsOfIPanels.PANELS_DEFAULT_HEIGHT)); |
76 |
resetChangedStatus(); |
77 |
} |
78 |
|
79 |
/**
|
80 |
* This method initializes jTextArea
|
81 |
*
|
82 |
* @return JTextArea
|
83 |
*/
|
84 |
private JTextArea getJTextArea() { |
85 |
if (jTextArea == null) { |
86 |
jTextArea = new JTextArea(5, 40); |
87 |
jTextArea.setText("I\'m a JTextArea object in the \"Panel\" with:\n\nID: " + getID() + "\nLabel: " + getLabel() + "\nLabelGroup: " + getLabelGroup()); |
88 |
jTextArea.setEditable(false);
|
89 |
jTextArea.setBackground(Color.YELLOW);
|
90 |
jTextArea.addMouseListener(new MouseAdapter() { |
91 |
|
92 |
public void mouseClicked(MouseEvent e) { |
93 |
if (getPanelGroup() != null) { |
94 |
getPanelGroup().setEnabledApplyButton(! getPanelGroup().isEnabledApplyButton()); |
95 |
getPanelGroup().setEnabledCancelButton(! getPanelGroup().isEnabledCancelButton()); |
96 |
} |
97 |
} |
98 |
}); |
99 |
} |
100 |
|
101 |
return jTextArea;
|
102 |
} |
103 |
|
104 |
@Override
|
105 |
public void setID(String id) { |
106 |
super.setID(id);
|
107 |
|
108 |
setToolTipText(getID()); |
109 |
getJTextArea().setText("I\'m a JTextArea object in the \"Panel\" with:\n\nID: " + getID() + "\nLabel: " + getLabel() + "\nLabelGroup: " + getLabelGroup()); |
110 |
} |
111 |
|
112 |
@Override
|
113 |
public void setLabel(String label) { |
114 |
super.setLabel(label);
|
115 |
|
116 |
getJTextArea().setText("I\'m a JTextArea object in the \"Panel\" with:\n\nID: " + getID() + "\nLabel: " + getLabel() + "\nLabelGroup: " + getLabelGroup()); |
117 |
} |
118 |
|
119 |
@Override
|
120 |
public void setLabelGroup(String labelGroup) { |
121 |
super.setLabelGroup(labelGroup);
|
122 |
|
123 |
getJTextArea().setText("I\'m a JTextArea object in the \"Panel\" with:\n\nID: " + getID() + "\nLabel: " + getLabel() + "\nLabelGroup: " + getLabelGroup()); |
124 |
} |
125 |
|
126 |
public void accept() { |
127 |
} |
128 |
|
129 |
public void apply() { |
130 |
} |
131 |
|
132 |
public void cancel() { |
133 |
} |
134 |
|
135 |
public void selected() { |
136 |
System.out.println("I'm the IPanel: " + toString() + "\n and I've been selected. My information is: " + |
137 |
"\n\tID: " + getID() + "\n\tLABEL_GROUP: " + getLabelGroup() + "\n\tLABEL: " + getLabel() + "\n\tCLASS: " + getClass() + |
138 |
"\n\tMy Preferred Size: " + getPreferredSize() + "\n\tAnd My size: " + getSize()); |
139 |
} |
140 |
} |