Statistics
| Revision:

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 / SampleInitializingExcetionPanel.java @ 40558

History | View | Annotate | Download (4.55 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.io.Serializable;
28

    
29
import javax.swing.JScrollPane;
30
import javax.swing.JTextArea;
31

    
32
import org.gvsig.gui.beans.panelGroup.panels.AbstractPanel;
33

    
34
/**
35
 * <p>Sample of {@link AbstractPanel AbstractPanel}.</p>
36
 * 
37
 * @version 16/10/2007
38
 * @author Pablo Piqueras Bartolom? (pablo.piqueras@iver.es) 
39
 */
40
public class SampleInitializingExcetionPanel extends AbstractPanel implements Serializable {
41
        private static final long serialVersionUID = -876907003975432865L;
42

    
43
        /**
44
         * <p>Element for the interface.</p>
45
         */
46
        private JTextArea jTextArea = null;
47

    
48
        /**
49
         * @see AbstractPanel#AbstractPanel()
50
         */
51
        public SampleInitializingExcetionPanel() {
52
                super();
53
                initialize();
54
        }
55

    
56
        /**
57
         * @see AbstractPanel#AbstractPanel(String, String, String)
58
         */
59
        public SampleInitializingExcetionPanel(String id, String label, String labelGroup) {
60
                super(id, label, labelGroup);
61
                
62
                initialize();
63
        }
64

    
65
        @Override
66
        protected void initialize() {
67
                add(new JScrollPane(getJTextArea()));
68
                setToolTipText(getID());
69
                
70
                setID(Samples_ExtensionPointsOfIPanels.PANELS1_IDS[0]);
71
                setLabel(Samples_ExtensionPointsOfIPanels.PANELS1_LABELS[0]);
72
                setLabelGroup(Samples_ExtensionPointsOfIPanels.PANELS1_LABELGROUPS[0]);
73
                
74
                // Force to generate an exception
75
                double badValue = 2 / 0;
76

    
77
                resetChangedStatus();
78
        }
79
        
80
        /**
81
         * This method initializes jTextArea
82
         *
83
         * @return JTextArea
84
         */
85
        private JTextArea getJTextArea() {
86
                if (jTextArea == null) {
87
                        jTextArea = new JTextArea(5, 40);
88
                        jTextArea.setText("I\'m a JTextArea object in the \"Panel\" with:\n\nID: " + getID() + "\nLabel: " + getLabel() + "\nLabelGroup: " + getLabelGroup());
89
                        jTextArea.setEditable(false);
90
                        jTextArea.setBackground(Color.GREEN);
91
                }
92

    
93
                return jTextArea;
94
        }
95

    
96
        @Override
97
        public void setID(String id) {
98
                super.setID(id);
99

    
100
                setToolTipText(getID());
101
                getJTextArea().setText("I\'m a JTextArea object in the \"Panel\" with:\n\nID: " + getID() + "\nLabel: " + getLabel() + "\nLabelGroup: " + getLabelGroup());
102
                hasChanged = true;
103
        }
104

    
105
        @Override
106
        public void setLabel(String label) {
107
                super.setLabel(label);
108
                
109
                getJTextArea().setText("I\'m a JTextArea object in the \"Panel\" with:\n\nID: " + getID() + "\nLabel: " + getLabel() + "\nLabelGroup: " + getLabelGroup());
110
                hasChanged = true;
111
        }
112

    
113
        @Override
114
        public void setLabelGroup(String labelGroup) {
115
                super.setLabelGroup(labelGroup);
116
                
117
                getJTextArea().setText("I\'m a JTextArea object in the \"Panel\" with:\n\nID: " + getID() + "\nLabel: " + getLabel() + "\nLabelGroup: " + getLabelGroup());
118
                hasChanged = true;
119
        }
120

    
121
        /*
122
         * (non-Javadoc)
123
         * @see org.gvsig.gui.beans.panelGroup.panels.IPanel#accept()
124
         */
125
        public void accept() {
126
                System.out.println("I'm the IPanel: " + toString() + "\n and I'm executing an 'accept' method.");
127
        }
128

    
129
        /*
130
         * (non-Javadoc)
131
         * @see org.gvsig.gui.beans.panelGroup.panels.IPanel#apply()
132
         */
133
        public void apply() {
134
                System.out.println("I'm the IPanel: " + toString() + "\n and I'm executing an 'apply' method.");
135
        }
136

    
137
        /*
138
         * (non-Javadoc)
139
         * @see org.gvsig.gui.beans.panelGroup.panels.IPanel#cancel()
140
         */
141
        public void cancel() {
142
                System.out.println("I'm the IPanel: " + toString() + "\n and I'm executing a 'cancel' method.");
143
        }
144

    
145
        /*
146
         * (non-Javadoc)
147
         * @see org.gvsig.gui.beans.panelGroup.panels.IPanel#selected()
148
         */
149
        public void selected() {
150
                System.out.println("I'm the IPanel: " + toString() + "\n and I've been selected. My information is: " +
151
                 "\n\tID: " + getID() + "\n\tLABEL_GROUP: " + getLabelGroup() + "\n\tLABEL: " + getLabel() + "\n\tCLASS: " + getClass() +
152
                 "\n\tMy Preferred Size: " + getPreferredSize() + "\n\tAnd My size: " + getSize());
153
        }
154
}