Statistics
| Revision:

root / trunk / libraries / libUIComponent / src / org / gvsig / gui / beans / panelGroup / exceptions / PanelWithNoPreferredSizeDefinedException.java @ 17543

History | View | Annotate | Download (3.66 KB)

1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2007 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

    
20
package org.gvsig.gui.beans.panelGroup.exceptions;
21

    
22
import java.util.HashMap;
23
import java.util.Map;
24

    
25
import org.gvsig.exceptions.BaseException;
26
import org.gvsig.gui.beans.panelGroup.IPanelGroup;
27

    
28
/**
29
 * <p>If an object of type {@link IPanelGroup IPanelGroup} tries to load a panel that its preferred sized
30
 *  hasn't been initialized, (not the default preferred size), then an exception of this kind will be
31
 *  launched.</p>
32
 * 
33
 * @version 28/11/2007
34
 * @author Pablo Piqueras Bartolom? (pablo.piqueras@iver.es) 
35
 */
36
public class PanelWithNoPreferredSizeDefinedException extends BaseException {
37
        private static final long serialVersionUID = 3953831724578904518L;
38
        protected HashMap<String, String> values;
39
        public static final String PANEL_LABEL = "PANEL_LABEL";
40

    
41
        /**
42
         * <p>Creates an initializes a new instance of <code>PanelWithNoPreferredSizedDefinedException</code>.</p>
43
         */
44
        public PanelWithNoPreferredSizeDefinedException() {
45
                super();
46

    
47
                initialize();
48
        }
49
        
50
        /**
51
         * <p>Creates an initializes a new instance of <code>PanelWithNoPreferredSizedDefinedException</code>.</p>
52
         * 
53
         * @param panelLabel label of the panel which is the source of this exception
54
         */
55
        public PanelWithNoPreferredSizeDefinedException(String panelLabel) {
56
                super();
57

    
58
                initialize();
59

    
60
                // Sets the needed information
61
                setPanelLabel(panelLabel);
62
        }
63
        
64
        /**
65
         * <p>Initializes a <code>PanelBaseException</code> with the needed information.</p>
66
         */
67
        protected void initialize() {
68
                // Identifier of this kind of exception
69
                this.code = serialVersionUID;
70
                
71
                // Default text that explains this kind of exception. If there is no translation associated to the
72
                // "messageKey" of this exception, then the value shown will be the value of "formatString".
73
                this.formatString = "Panel with label \"%(" + PANEL_LABEL + ")\" without preferred size defined.";
74

    
75
                 // Key to the sentence that explains this exception. That key will be use for multilingual purposes.
76
                this.messageKey = "panel_without_preferred_size_defined_exception";
77
                
78
                // Map with the label of the panel
79
                values = new HashMap<String, String>();
80
                values.put(PANEL_LABEL, "");
81
        }
82

    
83
        /*
84
         * (non-Javadoc)
85
         * @see org.gvsig.exceptions.BaseException#values()
86
         */
87
        protected Map<String, String> values() {
88
                return values;
89
        }
90

    
91
        /**
92
         * <p>Gets the label of the panel which is the source of this exception, or
93
         *  <code>null</code> if hasn't been defined.</p>
94
         * 
95
         * @return label of the panel which is the source of this exception
96
         */
97
        public String getPanelLabel() {
98
                return values.get(PANEL_LABEL);
99
        }
100

    
101
        /**
102
         * <p>Sets the label of the panel which is the source of this exception.</p>
103
         * 
104
         * @param panelLabel label of the panel which is the source of this exception
105
         */
106
        public void setPanelLabel(String panelLabel) {
107
                if (panelLabel == null)
108
                        values.put(PANEL_LABEL, "");
109
                else
110
                        values.put(PANEL_LABEL, panelLabel);
111
        }
112
}