Statistics
| Revision:

svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.library / org.gvsig.ui / src / main / java / org / gvsig / gui / beans / panelGroup / exceptions / PanelWithNoPreferredSizeDefinedException.java @ 40561

History | View | Annotate | Download (3.76 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.gui.beans.panelGroup.exceptions;
25

    
26
import java.util.HashMap;
27
import java.util.Map;
28

    
29
import org.gvsig.gui.beans.Messages;
30
import org.gvsig.gui.beans.panelGroup.IPanelGroup;
31
import org.gvsig.tools.exception.BaseException;
32

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

    
46
        /**
47
         * <p>Creates an initializes a new instance of <code>PanelWithNoPreferredSizedDefinedException</code>.</p>
48
         */
49
        public PanelWithNoPreferredSizeDefinedException() {
50
                super();
51

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

    
63
                initialize();
64

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

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

    
87
                setTranslator(new Messages());
88
        }
89

    
90
        protected Map<String, String> values() {
91
                return values;
92
        }
93

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

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