Statistics
| Revision:

svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.library / org.gvsig.ui / src / main / java / org / gvsig / gui / beans / specificcaretposition / JFormattedTextFieldSCP.java @ 40561

History | View | Annotate | Download (4.92 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.specificcaretposition;
25

    
26
import java.io.Serializable;
27
import java.text.Format;
28

    
29
import javax.swing.JFormattedTextField;
30

    
31
import org.gvsig.gui.awt.event.specificCaretPosition.ISpecificCaretPosition;
32
import org.gvsig.gui.awt.event.specificCaretPosition.SpecificCaretPositionListeners;
33

    
34

    
35
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
36
 *
37
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
38
 *
39
 * This program is free software; you can redistribute it and/or
40
 * modify it under the terms of the GNU General Public License
41
 * as published by the Free Software Foundation; either version 2
42
 * of the License, or (at your option) any later version.
43
 *
44
 * This program is distributed in the hope that it will be useful,
45
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
46
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
47
 * GNU General Public License for more details.
48
 *
49
 * You should have received a copy of the GNU General Public License
50
 * along with this program; if not, write to the Free Software
51
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
52
 *
53
 * For more information, contact:
54
 *
55
 *  Generalitat Valenciana
56
 *   Conselleria d'Infraestructures i Transport
57
 *   Av. Blasco Ib??ez, 50
58
 *   46010 VALENCIA
59
 *   SPAIN
60
 *
61
 *      +34 963862235
62
 *   gvsig@gva.es
63
 *      www.gvsig.gva.es
64
 *
65
 *    or
66
 *
67
 *   IVER T.I. S.A
68
 *   Salamanca 50
69
 *   46005 Valencia
70
 *   Spain
71
 *
72
 *   +34 963163400
73
 *   dac@iver.es
74
 */
75

    
76
/**
77
 * This class is a JFormattedTextField with two listeners that allow authomatically reset the caret
78
 *   position of this component to left (LEFT_POSITIONS), right (RIGHT_POSITIONS) or like JFormattedTextField (LIKE_JTEXTCOMPONENT) (do nothing).
79
 *   By default is to left. 
80
 * 
81
 * @author Pablo Piqueras Bartolom? (pablo.piqueras@iver.es)
82
 */
83
public class JFormattedTextFieldSCP extends JFormattedTextField implements ISpecificCaretPosition, Serializable {
84
        private static final long serialVersionUID = -8224060521711689694L;
85

    
86
        private int caretPositionMode;
87

    
88
        /**
89
         * @see JFormattedTextField#JFormattedTextField()
90
         */
91
        public JFormattedTextFieldSCP() {
92
                super();
93
                caretPositionMode = LEFT_POSITIONS;
94
                initialize();
95
        }
96
        
97
        /**
98
         * @see JFormattedTextField#JFormattedTextField(javax.swing.JFormattedTextField.AbstractFormatter)
99
         */
100
        public JFormattedTextFieldSCP(JFormattedTextField.AbstractFormatter formatter) {
101
                super(formatter);
102
                caretPositionMode = LEFT_POSITIONS;
103
                initialize();
104
        }
105
        
106
        /**
107
         * @see JFormattedTextField#JFormattedTextField(javax.swing.JFormattedTextField.AbstractFormatterFactory)
108
         */
109
        public JFormattedTextFieldSCP(JFormattedTextField.AbstractFormatterFactory factory) {
110
                super(factory);
111
                caretPositionMode = LEFT_POSITIONS;
112
                initialize();
113
        }
114
        
115
        /**
116
         * @see JFormattedTextField#JFormattedTextField(javax.swing.JFormattedTextField.AbstractFormatterFactory, java.lang.Object)
117
         */
118
        public JFormattedTextFieldSCP(JFormattedTextField.AbstractFormatterFactory factory, Object currentValue) {
119
                super(factory, currentValue);
120
                caretPositionMode = LEFT_POSITIONS;
121
                initialize();
122
        }
123
        
124
        /**
125
         * @see JFormattedTextField#JFormattedTextField()
126
         */
127
        public JFormattedTextFieldSCP(Format format) {
128
                super(format);
129
                caretPositionMode = LEFT_POSITIONS;
130
                initialize();
131
        }
132
        
133
        /**
134
         * @see JFormattedTextField#JFormattedTextField(java.lang.Object)
135
         */
136
        public JFormattedTextFieldSCP(Object value) {
137
                super(value);
138
                caretPositionMode = LEFT_POSITIONS;
139
                initialize();
140
        }
141
        
142
        /**
143
         * This method adds three listeners to this component:
144
         */
145
        private void initialize() {
146
                SpecificCaretPositionListeners.setListeners(this);
147
        }
148

    
149
        /*
150
         *  (non-Javadoc)
151
         * @see org.gvsig.gui.awt.event.ISpecificCaretPosition#getCaretPositionMode()
152
         */
153
        public int getCaretPositionMode() {
154
                return caretPositionMode;
155
        }
156

    
157
        /*
158
         *  (non-Javadoc)
159
         * @see org.gvsig.gui.awt.event.ISpecificCaretPosition#setCaretPositionMode(int)
160
         */
161
        public void setCaretPositionMode(int caretPositionMode) {
162
                this.caretPositionMode = caretPositionMode;
163
        }
164
}