Statistics
| Revision:

root / trunk / extensions / extAnimationGUI / src / com / iver / ai2 / animationgui / gui / document / AnimationProperties.java @ 20095

History | View | Annotate | Download (7.14 KB)

1
/* gvSIG. Sistema de Informaci�n Geogr�fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2004 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
 * For more information, contact:
20
 *
21
 *  Generalitat Valenciana
22
 *   Conselleria d'Infraestructures i Transport
23
 *   Av. Blasco Ib��ez, 50
24
 *   46010 VALENCIA
25
 *   SPAIN
26
 *
27
 *      +34 963862235
28
 *   gvsig@gva.es
29
 *      www.gvsig.gva.es
30
 *
31
 *    or
32
 *
33
 *   IVER T.I. S.A
34
 *   Salamanca 50
35
 *   46005 Valencia
36
 *   Spain
37
 *
38
 *   +34 963163400
39
 *   dac@iver.es
40
 */
41
package com.iver.ai2.animationgui.gui.document;
42

    
43
import java.awt.Dimension;
44
import java.awt.Insets;
45
import java.awt.event.ActionListener;
46

    
47
import javax.swing.BorderFactory;
48
import javax.swing.JLabel;
49
import javax.swing.JScrollPane;
50
import javax.swing.JTextArea;
51
import javax.swing.JTextField;
52

    
53
import org.gvsig.gui.beans.swing.GridBagLayoutPanel;
54
import org.gvsig.gui.beans.swing.JButton;
55

    
56
import com.iver.andami.PluginServices;
57
import com.iver.andami.ui.mdiManager.SingletonWindow;
58
import com.iver.andami.ui.mdiManager.WindowInfo;
59
import com.iver.cit.gvsig.project.documents.ProjectDocument;
60

    
61
/**
62
 * Dialogo donde se muestran las propiedades de una vista
63
 * 
64
 * @author Fernando Gonz�lez Cort�s
65
 */
66
public class AnimationProperties extends GridBagLayoutPanel implements
67
                SingletonWindow {
68

    
69
        private JTextField txtName;
70

    
71
        private JTextField txtDate;
72

    
73
        private JTextField txtOwner;
74

    
75
        private int width = 390;
76

    
77
        private int height = 250;
78

    
79
        private GridBagLayoutPanel panelColor;
80

    
81
        private JScrollPane jScrollPane;
82

    
83
        private JTextArea txtComments;
84
        
85
        private GridBagLayoutPanel okCancelPanel;
86
        
87
        private boolean editable;
88

    
89
        private JButton okButton;
90

    
91
        private JButton cancelButton;
92

    
93
        private ProjectDocument projectDocument;
94

    
95
        /**
96
         * This is the default constructor
97
         * 
98
         * @param f
99
         *            Frame padre del dialogo
100
         * @param v
101
         *            Vista que se representa
102
         */
103
        public AnimationProperties(ProjectDocument p, boolean edit) {
104
                projectDocument = p;
105
                setEditable(edit);
106
                initialize();
107
        }
108

    
109
        /**
110
         * This method initializes this
111
         */
112
        private void initialize() {
113
                // Inicialize component
114
                setName("Animation properties");
115
                // Introducing the margin 
116
                setBorder(BorderFactory.createEmptyBorder(6, 6, 6, 6));
117
                // Dimension of the panel
118
//                setSize(new Dimension(width, height));
119
                this.setPreferredSize(new Dimension(width, height));
120
                
121
                // ADDING COMPONENTS
122
                
123
                // Name Component
124
                this.addComponent(PluginServices.getText(this, "Name"), getTxtName(), new Insets(0,10,2,10));
125
                // Date component
126
                this.addComponent(PluginServices.getText(this, "Creation_Date"), getTxtDate(), new Insets(2,10,2,10));
127
                // Owner component
128
                this.addComponent(PluginServices.getText(this, "Owner"), getTxtOwner(), new Insets(2,10,2,10));
129
                // Description component
130
                GridBagLayoutPanel aux = new GridBagLayoutPanel();
131
                aux.add(getJScrollPane());
132
                addComponent(new JLabel(PluginServices.getText(this, "Commentaries")),new Insets(2,6,2,6));
133
                addComponent(aux,new Insets(2,6,2,6));
134
                
135
                
136
                // Accept buton
137
                this.addComponent(getOkCancelPanel(),new Insets(2,150,2,0));
138
                
139
                // Inicialicing default values
140
                this.txtName.setText(PluginServices.getText(this, "Creation_Date"));
141
                txtName.setText(projectDocument.getName());
142
                txtDate.setText(projectDocument.getCreationDate());
143
                txtOwner.setText(projectDocument.getOwner());
144
                txtComments.setText(projectDocument.getComment());
145
                
146
        }
147
        
148
        
149
        private javax.swing.JTextField getTxtName() {
150
                if (txtName == null) {
151
                        txtName = new javax.swing.JTextField();
152
                        txtName.setPreferredSize(new java.awt.Dimension(150, 23));
153
                }
154

    
155
                return txtName;
156
        }
157

    
158
        private javax.swing.JTextField getTxtDate() {
159
                if (txtDate == null) {
160
                        txtDate = new javax.swing.JTextField();
161
                        txtDate.setPreferredSize(new java.awt.Dimension(150, 23));
162
                        txtDate.setEditable(false);
163
                        txtDate.setBackground(java.awt.Color.white);
164
                }
165

    
166
                return txtDate;
167
        }
168

    
169
        private javax.swing.JTextField getTxtOwner() {
170
                if (txtOwner == null) {
171
                        txtOwner = new javax.swing.JTextField();
172
                        txtOwner.setPreferredSize(new java.awt.Dimension(150, 23));
173
                }
174

    
175
                return txtOwner;
176
        }
177

    
178
        
179
                
180
        private javax.swing.JScrollPane getJScrollPane() {
181
                if (jScrollPane == null) {
182
                        jScrollPane = new javax.swing.JScrollPane();
183
                        //jScrollPane.setSize(new java.awt.Dimension(340, 70));
184
                        jScrollPane.setViewportView(getTxtComments());
185
                        jScrollPane.setPreferredSize(new java.awt.Dimension(340, 70));
186
                }
187

    
188
                return jScrollPane;
189
        }
190
        
191
        private javax.swing.JTextArea getTxtComments() {
192
                if (txtComments == null) {
193
                        txtComments = new javax.swing.JTextArea();
194
                        txtComments.setRows(1);
195
                        txtComments.setColumns(28);
196
                }
197

    
198
                return txtComments;
199
        }
200
        
201
        
202
        private GridBagLayoutPanel getOkCancelPanel() {
203
                if (okCancelPanel == null) {
204
                        ActionListener okAction, cancelAction;
205
                        okAction = new java.awt.event.ActionListener() {
206
                                public void actionPerformed(java.awt.event.ActionEvent e) {
207
                                        projectDocument.setName(txtName.getText());
208
                                        projectDocument.setCreationDate(txtDate.getText());
209
                                        projectDocument.setOwner(txtOwner.getText());
210
                                        projectDocument.setComment(txtComments.getText());
211
                                        PluginServices.getMDIManager().closeWindow(AnimationProperties.this);
212
                                }
213
                        };
214
                        cancelAction = new java.awt.event.ActionListener() {
215
                                public void actionPerformed(java.awt.event.ActionEvent e) {
216
                                        PluginServices.getMDIManager().closeWindow(AnimationProperties.this);
217
                                }
218
                        };
219
                        
220
                        okCancelPanel = new GridBagLayoutPanel();
221
                        okCancelPanel.setAlignmentX(GridBagLayoutPanel.RIGHT_ALIGNMENT);
222
                        okButton = new JButton();
223
                        okButton.setText(PluginServices.getText(this, "Accept"));
224
                        okButton.addActionListener(okAction);
225
                        cancelButton = new JButton();
226
                        cancelButton.setText(PluginServices.getText(this, "Cancel"));
227
                        cancelButton.addActionListener(cancelAction);
228
                        
229
                        okCancelPanel.addComponent(okButton,cancelButton);
230
                }
231
                return okCancelPanel;
232
        }
233
        
234
        
235
        
236

    
237
        public Object getWindowModel() {
238
                // TODO Auto-generated method stub
239
                return projectDocument;
240
        }
241

    
242
        public WindowInfo getWindowInfo() {
243
                WindowInfo m_viewinfo = new WindowInfo();
244
                m_viewinfo.setTitle("Animation Properties");
245
                m_viewinfo.setHeight(height);
246
                m_viewinfo.setWidth(width);
247
                return m_viewinfo;
248
        }
249

    
250
        public boolean isEditable() {
251
                return editable;
252
        }
253

    
254
        public void setEditable(boolean editable) {
255
                this.editable = editable;
256
        }
257
}