svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.plugin / org.gvsig.app / org.gvsig.app.mainplugin / src / main / java / org / gvsig / app / project / documents / gui / ProjectWindow2_OLD.java @ 47790
History | View | Annotate | Download (39.5 KB)
1 | 40558 | jjdelcerro | /**
|
---|---|---|---|
2 | * gvSIG. Desktop Geographic Information System.
|
||
3 | 40435 | jjdelcerro | *
|
4 | 40558 | jjdelcerro | * Copyright (C) 2007-2013 gvSIG Association.
|
5 | *
|
||
6 | 40435 | jjdelcerro | * This program is free software; you can redistribute it and/or
|
7 | * modify it under the terms of the GNU General Public License
|
||
8 | 40558 | jjdelcerro | * as published by the Free Software Foundation; either version 3
|
9 | 40435 | jjdelcerro | * of the License, or (at your option) any later version.
|
10 | 40558 | jjdelcerro | *
|
11 | 40435 | jjdelcerro | * 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 | 40558 | jjdelcerro | *
|
16 | 40435 | jjdelcerro | * 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 | 40558 | jjdelcerro | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
19 | 40435 | jjdelcerro | * MA 02110-1301, USA.
|
20 | 40558 | jjdelcerro | *
|
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 | 40435 | jjdelcerro | */
|
24 | package org.gvsig.app.project.documents.gui; |
||
25 | |||
26 | import java.awt.Component; |
||
27 | import java.awt.Dimension; |
||
28 | import java.awt.FlowLayout; |
||
29 | import java.awt.GridBagConstraints; |
||
30 | import java.awt.GridBagLayout; |
||
31 | import java.awt.GridLayout; |
||
32 | import java.awt.Insets; |
||
33 | import java.beans.PropertyChangeEvent; |
||
34 | import java.beans.PropertyChangeListener; |
||
35 | import java.io.File; |
||
36 | import java.util.ArrayList; |
||
37 | import java.util.Collections; |
||
38 | import java.util.Comparator; |
||
39 | import java.util.Enumeration; |
||
40 | import java.util.Iterator; |
||
41 | import java.util.List; |
||
42 | 41314 | jjdelcerro | import java.util.Locale; |
43 | 46010 | jjdelcerro | import java.util.Map; |
44 | 40435 | jjdelcerro | |
45 | import javax.swing.AbstractButton; |
||
46 | import javax.swing.BorderFactory; |
||
47 | import javax.swing.ButtonGroup; |
||
48 | import javax.swing.JButton; |
||
49 | import javax.swing.JComponent; |
||
50 | import javax.swing.JDialog; |
||
51 | import javax.swing.JLabel; |
||
52 | import javax.swing.JList; |
||
53 | import javax.swing.JOptionPane; |
||
54 | import javax.swing.JPanel; |
||
55 | import javax.swing.JRadioButton; |
||
56 | import javax.swing.JScrollPane; |
||
57 | import javax.swing.ScrollPaneConstants; |
||
58 | import javax.swing.SwingUtilities; |
||
59 | import javax.swing.border.TitledBorder; |
||
60 | |||
61 | import org.gvsig.andami.PluginServices; |
||
62 | import org.gvsig.andami.help.Help; |
||
63 | import org.gvsig.andami.messages.NotificationManager; |
||
64 | import org.gvsig.andami.ui.mdiManager.IWindow; |
||
65 | import org.gvsig.andami.ui.mdiManager.MDIManager; |
||
66 | import org.gvsig.andami.ui.mdiManager.SingletonWindow; |
||
67 | import org.gvsig.andami.ui.mdiManager.WindowInfo; |
||
68 | 43189 | jjdelcerro | import org.gvsig.app.ApplicationLocator; |
69 | import org.gvsig.app.ApplicationManager; |
||
70 | 40435 | jjdelcerro | import org.gvsig.app.extension.ProjectExtension; |
71 | import org.gvsig.app.project.Project; |
||
72 | import org.gvsig.app.project.ProjectManager; |
||
73 | import org.gvsig.app.project.documents.AbstractDocument; |
||
74 | import org.gvsig.app.project.documents.Document; |
||
75 | import org.gvsig.app.project.documents.DocumentManager; |
||
76 | 41314 | jjdelcerro | import org.gvsig.tools.ToolsLocator; |
77 | import org.gvsig.tools.i18n.I18nManager; |
||
78 | 42873 | jjdelcerro | import org.gvsig.tools.identitymanagement.SimpleIdentityManager; |
79 | 40435 | jjdelcerro | import org.gvsig.tools.observer.Observable; |
80 | import org.gvsig.tools.observer.Observer; |
||
81 | import org.gvsig.tools.swing.api.ToolsSwingLocator; |
||
82 | import org.gvsig.tools.swing.api.usability.UsabilitySwingManager; |
||
83 | 41350 | jjdelcerro | import org.gvsig.tools.swing.api.windowmanager.WindowManager; |
84 | 46010 | jjdelcerro | import org.gvsig.tools.util.PropertiesSupport; |
85 | import org.gvsig.tools.util.PropertiesSupportHelper; |
||
86 | 40435 | jjdelcerro | import org.gvsig.utils.DefaultListModel; |
87 | |||
88 | /**
|
||
89 | * Clase principal del proyecto donde se puede operar para crear cualquier tipo
|
||
90 | * de documento.
|
||
91 | 42037 | fdiaz | *
|
92 | 40435 | jjdelcerro | * @author Vicente Caballero Navarro
|
93 | * @author gvSIG team
|
||
94 | */
|
||
95 | 47790 | fdiaz | public class ProjectWindow2_OLD extends JPanel implements PropertyChangeListener, |
96 | 46010 | jjdelcerro | IWindow, SingletonWindow, Observer, PropertiesSupport {
|
97 | 40435 | jjdelcerro | |
98 | private static final long serialVersionUID = 7315293357719796556L; |
||
99 | |||
100 | public static final String PERSISTENCE_DEFINITION_NAME = "ProjectWindow"; |
||
101 | |||
102 | private JScrollPane documentTypes = null; |
||
103 | private JPanel documentTypesList = null; |
||
104 | private JRadioButton[] btnsDocuments = null; |
||
105 | private ButtonGroup grupo = new ButtonGroup(); |
||
106 | private JPanel documentsPanel = null; |
||
107 | private JList lstDocs = null; |
||
108 | private JPanel jPanel2 = null; |
||
109 | private JButton btnNuevo = null; |
||
110 | private JButton btnPropiedades = null; |
||
111 | private JButton btnAbrir = null; |
||
112 | private JButton btnBorrar = null; |
||
113 | private JButton btnRenombrar = null; |
||
114 | private JPanel propertiesPanel = null; |
||
115 | private JLabel jLabel = null; |
||
116 | private JLabel lblNombreSesion = null; |
||
117 | private JLabel jLabel1 = null; |
||
118 | private JLabel lblGuardado = null; |
||
119 | private JLabel jLabel2 = null; |
||
120 | private JLabel lblFecha = null; |
||
121 | private JButton btnImportar = null; |
||
122 | private JButton btnExportar = null; |
||
123 | private JButton btnEditar = null; |
||
124 | // The properties of the Project Manager window (size, position, etc):
|
||
125 | private WindowInfo m_viewInfo = null; |
||
126 | |||
127 | private Project project;
|
||
128 | private UsabilitySwingManager manager = ToolsSwingLocator
|
||
129 | .getUsabilitySwingManager(); |
||
130 | |||
131 | private JScrollPane documentsScrollPane = null; |
||
132 | private JPanel projectButtonsPanel = null; |
||
133 | 46010 | jjdelcerro | private PropertiesSupportHelper propertiesHelper;
|
134 | 40435 | jjdelcerro | |
135 | /**
|
||
136 | * This is the default constructor
|
||
137 | 42037 | fdiaz | *
|
138 | 40435 | jjdelcerro | * @param project
|
139 | * Extension
|
||
140 | */
|
||
141 | 47790 | fdiaz | public ProjectWindow2_OLD() {
|
142 | 40435 | jjdelcerro | super();
|
143 | 46010 | jjdelcerro | this.propertiesHelper = new PropertiesSupportHelper(); |
144 | this.propertiesHelper.setProperty("ProjectWindow", this); |
||
145 | 40435 | jjdelcerro | initialize(); |
146 | refreshControls(); |
||
147 | Help.getHelp().enableHelp(this, this.getClass().getName()); |
||
148 | // Observe document factory registration changes
|
||
149 | ProjectManager.getInstance().addObserver(this);
|
||
150 | } |
||
151 | |||
152 | /**
|
||
153 | * Asigna el proyecto a la ventana
|
||
154 | 42037 | fdiaz | *
|
155 | 40435 | jjdelcerro | * @param project
|
156 | * Proyecto con el que se operar? a trav?s de este di?logo
|
||
157 | */
|
||
158 | public void setProject(Project project) { |
||
159 | this.project = project;
|
||
160 | 43293 | fdiaz | if(project!=null){ |
161 | project.addPropertyChangeListener(this);
|
||
162 | } |
||
163 | 40435 | jjdelcerro | refreshControls(); |
164 | } |
||
165 | |||
166 | /**
|
||
167 | * Activa los botones de la botonera del medio o los desactiva en funci?n de
|
||
168 | * que est? seleccionado o no un elemento de proyecto en la lista del medio
|
||
169 | */
|
||
170 | private void activarBotones() { |
||
171 | if (lstDocs.getSelectedIndex() != -1) { |
||
172 | btnAbrir.setEnabled(true);
|
||
173 | btnBorrar.setEnabled(true);
|
||
174 | if (lstDocs.getSelectedIndices().length == 1) { |
||
175 | btnRenombrar.setEnabled(true);
|
||
176 | btnPropiedades.setEnabled(true);
|
||
177 | } else {
|
||
178 | btnRenombrar.setEnabled(false);
|
||
179 | btnPropiedades.setEnabled(false);
|
||
180 | } |
||
181 | } else {
|
||
182 | btnAbrir.setEnabled(false);
|
||
183 | btnBorrar.setEnabled(false);
|
||
184 | btnRenombrar.setEnabled(false);
|
||
185 | btnPropiedades.setEnabled(false);
|
||
186 | } |
||
187 | } |
||
188 | |||
189 | /**
|
||
190 | * Refresca la lista de elementos de proyecto con vistas, mapas o tablas,
|
||
191 | * seg?n la opci?n activada
|
||
192 | */
|
||
193 | private void refreshList() { |
||
194 | if (project != null) { |
||
195 | DefaultListModel model = null; |
||
196 | String tituloMarco =
|
||
197 | PluginServices.getText(this, "documentos_existentes"); |
||
198 | |||
199 | String doctype = getDocumentSelected();
|
||
200 | model = new DefaultListModel(project.getDocuments(doctype)); |
||
201 | tituloMarco = getDocumentSelectedName(); |
||
202 | 42093 | cmartinez | Object selectedDoc = lstDocs.getSelectedValue();
|
203 | 40435 | jjdelcerro | lstDocs.setModel(model); |
204 | 42093 | cmartinez | if (selectedDoc!=null) { |
205 | lstDocs.setSelectedValue(selectedDoc, false);
|
||
206 | } |
||
207 | 43293 | fdiaz | |
208 | 40435 | jjdelcerro | ((TitledBorder) getDocumentsPanel().getBorder())
|
209 | .setTitle(tituloMarco); |
||
210 | getDocumentsPanel().repaint(1);
|
||
211 | activarBotones(); |
||
212 | } |
||
213 | } |
||
214 | |||
215 | /**
|
||
216 | * Devuelve el nombre del tipo de documento activo (el mismo que
|
||
217 | * ProjectDocumentFactory.getRegisterName)
|
||
218 | 42037 | fdiaz | *
|
219 | *
|
||
220 | 40435 | jjdelcerro | * @return
|
221 | */
|
||
222 | |||
223 | public String getDocumentSelected() { |
||
224 | JRadioButton btnSelected = null; |
||
225 | for (int i = 0; i < btnsDocuments.length; i++) { |
||
226 | if (btnsDocuments[i].isSelected()) {
|
||
227 | btnSelected = btnsDocuments[i]; |
||
228 | return btnSelected.getName();
|
||
229 | } |
||
230 | } |
||
231 | |||
232 | return null; |
||
233 | } |
||
234 | |||
235 | private String getDocumentSelectedName() { |
||
236 | JRadioButton btnSelected = null; |
||
237 | for (int i = 0; i < btnsDocuments.length; i++) { |
||
238 | if (btnsDocuments[i].isSelected()) {
|
||
239 | btnSelected = btnsDocuments[i]; |
||
240 | return btnSelected.getText();
|
||
241 | } |
||
242 | } |
||
243 | |||
244 | return null; |
||
245 | } |
||
246 | |||
247 | /**
|
||
248 | * Refresca las etiquetas con la informaci?n del proyecto
|
||
249 | */
|
||
250 | private void refreshProperties() { |
||
251 | if (project != null) { |
||
252 | lblNombreSesion.setText(project.getName()); |
||
253 | String path = ProjectExtension.getPath();
|
||
254 | if (path != null) { |
||
255 | File f = new File(path); |
||
256 | lblGuardado.setText(f.toString()); |
||
257 | } else {
|
||
258 | lblGuardado.setText("");
|
||
259 | } |
||
260 | lblFecha.setText(project.getCreationDate()); |
||
261 | } |
||
262 | } |
||
263 | |||
264 | /**
|
||
265 | * Refresca todo el di?logo
|
||
266 | */
|
||
267 | public void refreshControls() { |
||
268 | refreshList(); |
||
269 | refreshProperties(); |
||
270 | } |
||
271 | |||
272 | /**
|
||
273 | * This method initializes this
|
||
274 | */
|
||
275 | private void initialize() { |
||
276 | this.setLayout(new GridBagLayout()); |
||
277 | GridBagConstraints c = new GridBagConstraints(); |
||
278 | c.insets = new Insets(2, 5, 2, 5); |
||
279 | |||
280 | c.fill = GridBagConstraints.HORIZONTAL;
|
||
281 | c.weightx = 1.0d;
|
||
282 | c.weighty = 0.0d;
|
||
283 | c.gridy = 0;
|
||
284 | add(getDocumentTypesPanel(), c); |
||
285 | |||
286 | c.fill = GridBagConstraints.BOTH;
|
||
287 | c.gridy = 1;
|
||
288 | c.weightx = 1.0d;
|
||
289 | c.weighty = 1.0d;
|
||
290 | add(getDocumentsPanel(), c); |
||
291 | |||
292 | c.fill = GridBagConstraints.HORIZONTAL;
|
||
293 | c.weightx = 1.0d;
|
||
294 | c.weighty = 0.0d;
|
||
295 | c.gridy = 2;
|
||
296 | add(getPropertiesPanel(), c); |
||
297 | |||
298 | this.setMinimumSize(this.getPreferredSize()); |
||
299 | refreshDocuments(); |
||
300 | } |
||
301 | |||
302 | private void createDocumentsInProject(String doctype) { |
||
303 | Iterator<? extends Document> documents = |
||
304 | ProjectManager.getInstance().createDocumentsByUser(doctype); |
||
305 | for (; (documents != null) && (documents.hasNext());) { |
||
306 | try {
|
||
307 | Document document = documents.next();
|
||
308 | project.add(document); |
||
309 | int index =
|
||
310 | ((DefaultListModel) lstDocs.getModel()).indexOf(document);
|
||
311 | lstDocs.setSelectedIndex(index); |
||
312 | lstDocs.requestFocus(); |
||
313 | openDocumentWindow(document); |
||
314 | } catch (Exception e) { |
||
315 | NotificationManager.addError(e); |
||
316 | } |
||
317 | } |
||
318 | } |
||
319 | |||
320 | /**
|
||
321 | * Crea un nuevo project element
|
||
322 | 42037 | fdiaz | *
|
323 | 40435 | jjdelcerro | * @throws Exception
|
324 | * DOCUMENT ME!
|
||
325 | */
|
||
326 | private void newProjectDocument() throws Exception { |
||
327 | String doctype = getDocumentSelected();
|
||
328 | createDocumentsInProject(doctype); |
||
329 | 41003 | jjdelcerro | lstDocs.setSelectedIndex(lstDocs.getModel().getSize()-1);
|
330 | 40435 | jjdelcerro | } |
331 | |||
332 | /**
|
||
333 | * Abre la ventana de un nuevo documento
|
||
334 | */
|
||
335 | private void abrir() { |
||
336 | int[] indexes = lstDocs.getSelectedIndices(); |
||
337 | for (int i = indexes.length - 1; i >= 0; i--) { |
||
338 | int index = indexes[i];
|
||
339 | if (index == -1) { |
||
340 | return;
|
||
341 | } |
||
342 | String doctype = getDocumentSelected();
|
||
343 | List<Document> documents = project.getDocuments(doctype); |
||
344 | Document doc = documents.get(index);
|
||
345 | 42088 | fdiaz | if(!doc.isAvailable()){
|
346 | I18nManager i18nManager = ToolsLocator.getI18nManager(); |
||
347 | JOptionPane.showMessageDialog(
|
||
348 | this,
|
||
349 | i18nManager.getTranslation("document_not_available"),
|
||
350 | i18nManager.getTranslation("abrir"),
|
||
351 | JOptionPane.WARNING_MESSAGE);
|
||
352 | return;
|
||
353 | } |
||
354 | 40435 | jjdelcerro | openDocumentWindow(doc); |
355 | } |
||
356 | } |
||
357 | |||
358 | private void openDocumentWindow(Document doc) { |
||
359 | if (doc != null) { |
||
360 | IWindow window = doc.getFactory().getMainWindow(doc); |
||
361 | if (window == null) { |
||
362 | JOptionPane.showMessageDialog(
|
||
363 | (Component) PluginServices.getMainFrame(),
|
||
364 | PluginServices.getText(this, "error_opening_the_document")); |
||
365 | return;
|
||
366 | } |
||
367 | PluginServices.getMDIManager().addWindow(window, |
||
368 | MDIManager.ALIGN_FIRST_LINE_END_CASCADE); |
||
369 | project.setModified(true);
|
||
370 | } |
||
371 | } |
||
372 | |||
373 | /**
|
||
374 | * Cambia el nombre de un project element
|
||
375 | */
|
||
376 | private void renombrar() { |
||
377 | int index = lstDocs.getSelectedIndex();
|
||
378 | |||
379 | if (index == -1) { |
||
380 | return;
|
||
381 | } |
||
382 | String doctype = getDocumentSelected();
|
||
383 | List<Document> documents = project.getDocuments(doctype); |
||
384 | Document doc = documents.get(index);
|
||
385 | |||
386 | JOptionPane pane = new JOptionPane(); |
||
387 | pane.setMessage(PluginServices.getText(this, "introduce_nombre")); |
||
388 | pane.setMessageType(JOptionPane.QUESTION_MESSAGE);
|
||
389 | pane.setWantsInput(true);
|
||
390 | pane.setInitialSelectionValue(doc.getName()); |
||
391 | pane.setInputValue(doc.getName()); |
||
392 | JDialog dlg =
|
||
393 | pane.createDialog((Component) PluginServices.getMainFrame(),
|
||
394 | PluginServices.getText(this, "renombrar")); |
||
395 | dlg.setModal(true);
|
||
396 | dlg.setVisible(true);
|
||
397 | |||
398 | String nuevoNombre = pane.getInputValue().toString().trim();
|
||
399 | |||
400 | if (nuevoNombre.length() == 0) { |
||
401 | return;
|
||
402 | } |
||
403 | |||
404 | for (int i = 0; i < lstDocs.getModel().getSize(); i++) { |
||
405 | if (i == index) {
|
||
406 | continue;
|
||
407 | } |
||
408 | if (((AbstractDocument) lstDocs.getModel().getElementAt(i)) |
||
409 | .getName().equals(nuevoNombre)) { |
||
410 | JOptionPane.showMessageDialog(
|
||
411 | (Component) PluginServices.getMainFrame(),
|
||
412 | PluginServices.getText(this, "elemento_ya_existe")); |
||
413 | return;
|
||
414 | } |
||
415 | |||
416 | } |
||
417 | doc.setName(nuevoNombre); |
||
418 | |||
419 | refreshList(); |
||
420 | project.setModified(true);
|
||
421 | } |
||
422 | |||
423 | /**
|
||
424 | * Borra un project element
|
||
425 | */
|
||
426 | private void borrar() { |
||
427 | 43189 | jjdelcerro | ApplicationManager application = ApplicationLocator.getManager(); |
428 | I18nManager i18n = ToolsLocator.getI18nManager(); |
||
429 | int res = application.confirmDialog(
|
||
430 | i18n.getTranslation("confirmar_borrar"),
|
||
431 | i18n.getTranslation("borrar"),
|
||
432 | 43293 | fdiaz | JOptionPane.YES_NO_OPTION,
|
433 | 43189 | jjdelcerro | JOptionPane.INFORMATION_MESSAGE,
|
434 | "Confirm remove document from project"
|
||
435 | ); |
||
436 | 40435 | jjdelcerro | int lastremoved = 0; |
437 | if (res == JOptionPane.YES_OPTION) { |
||
438 | int[] indexes = lstDocs.getSelectedIndices(); |
||
439 | for (int i = indexes.length - 1; i >= 0; i--) { |
||
440 | int index = indexes[i];
|
||
441 | String s = getDocumentSelected();
|
||
442 | List<Document> documents = project.getDocuments(s); |
||
443 | Document doc = documents.get(index);
|
||
444 | if (doc.isLocked()) {
|
||
445 | 43189 | jjdelcerro | application.messageDialog( |
446 | 43293 | fdiaz | i18n.getTranslation("locked_element_it_cannot_be_deleted"),
|
447 | i18n.getTranslation("Information"),
|
||
448 | 43189 | jjdelcerro | JOptionPane.INFORMATION_MESSAGE
|
449 | ); |
||
450 | 40435 | jjdelcerro | return;
|
451 | } |
||
452 | PluginServices.getMDIManager().closeSingletonWindow(doc); |
||
453 | 43189 | jjdelcerro | project.removeDocument(doc); |
454 | 40435 | jjdelcerro | lastremoved = index; |
455 | } |
||
456 | 43477 | jjdelcerro | if (lastremoved >= lstDocs.getModel().getSize()) {
|
457 | lstDocs.setSelectedIndex(lstDocs.getModel().getSize()-1);
|
||
458 | } else if (lastremoved >= 0) { |
||
459 | 40435 | jjdelcerro | lstDocs.setSelectedIndex(lastremoved); |
460 | } |
||
461 | project.setModified(true);
|
||
462 | } |
||
463 | } |
||
464 | |||
465 | /**
|
||
466 | * Muestra el di?logo de propiedades de un project element
|
||
467 | */
|
||
468 | private void propiedades() { |
||
469 | int index = lstDocs.getSelectedIndex();
|
||
470 | |||
471 | if (index == -1) { |
||
472 | return;
|
||
473 | } |
||
474 | |||
475 | IWindow dlg = null;
|
||
476 | String doctype = getDocumentSelected();
|
||
477 | List<Document> documents = project.getDocuments(doctype); |
||
478 | Document doc = documents.get(index);
|
||
479 | 42088 | fdiaz | if(!doc.isAvailable()){
|
480 | I18nManager i18nManager = ToolsLocator.getI18nManager(); |
||
481 | JOptionPane.showMessageDialog(
|
||
482 | this,
|
||
483 | i18nManager.getTranslation("document_not_available"),
|
||
484 | i18nManager.getTranslation("properties"),
|
||
485 | JOptionPane.WARNING_MESSAGE);
|
||
486 | return;
|
||
487 | } |
||
488 | 40435 | jjdelcerro | dlg = doc.getFactory().getPropertiesWindow(doc); |
489 | PluginServices.getMDIManager().addWindow(dlg); |
||
490 | |||
491 | refreshControls(); |
||
492 | lstDocs.setSelectedIndex(index); |
||
493 | project.setModified(true);
|
||
494 | } |
||
495 | |||
496 | /**
|
||
497 | * This method initializes jPanel
|
||
498 | 42037 | fdiaz | *
|
499 | 40435 | jjdelcerro | * @return JPanel
|
500 | */
|
||
501 | private JComponent getDocumentTypesPanel() { |
||
502 | if (documentTypes == null) { |
||
503 | |||
504 | documentTypesList = |
||
505 | new JPanel(new FlowLayout(FlowLayout.CENTER, 5, 5)); |
||
506 | documentTypesList.setName("tipoDocPanel");
|
||
507 | fillDocumentTypeButtons(); |
||
508 | |||
509 | documentTypes = new JScrollPane(documentTypesList); |
||
510 | Dimension dim = documentTypesList.getPreferredSize();
|
||
511 | 41385 | jjdelcerro | documentTypes.setMinimumSize(new Dimension(dim.width,dim.height + 35)); |
512 | 40435 | jjdelcerro | documentTypes.setBorder(BorderFactory.createTitledBorder(null, |
513 | PluginServices.getText(this, "tipos_de_documentos"), |
||
514 | javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, |
||
515 | javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null)); |
||
516 | 41385 | jjdelcerro | documentTypes.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER);
|
517 | documentTypes.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
|
||
518 | |||
519 | 40435 | jjdelcerro | } |
520 | |||
521 | return documentTypes;
|
||
522 | } |
||
523 | |||
524 | /**
|
||
525 | * Adds a button for each document type
|
||
526 | */
|
||
527 | private void fillDocumentTypeButtons() { |
||
528 | JRadioButton[] btns = getBtnDocumentTypes(); |
||
529 | for (int i = 0; i < btns.length; i++) { |
||
530 | documentTypesList.add(btns[i]); |
||
531 | } |
||
532 | } |
||
533 | |||
534 | /**
|
||
535 | * This method initializes btnVistas
|
||
536 | 42037 | fdiaz | *
|
537 | 40435 | jjdelcerro | * @return JRadioButton
|
538 | */
|
||
539 | private JRadioButton[] getBtnDocumentTypes() { |
||
540 | if (btnsDocuments == null) { |
||
541 | |||
542 | List<JRadioButton> btns = new ArrayList<JRadioButton>(); |
||
543 | List<DocumentManager> factories =
|
||
544 | ProjectManager.getInstance().getDocumentManagers(); |
||
545 | Collections.sort(factories, new Comparator<DocumentManager>() { |
||
546 | |||
547 | public int compare(DocumentManager arg0, DocumentManager arg1) { |
||
548 | return arg0.getPriority() - arg1.getPriority();
|
||
549 | } |
||
550 | |||
551 | }); |
||
552 | 42873 | jjdelcerro | SimpleIdentityManager identityManager = ToolsLocator.getIdentityManager(); |
553 | 40435 | jjdelcerro | for (DocumentManager documentFactory : factories) {
|
554 | 42873 | jjdelcerro | if( ! identityManager.getCurrentIdentity().isAuthorized(Document.ACCESS_DOCUMENT_AUTHORIZATION, documentFactory, documentFactory.getTypeName()) ) { |
555 | // throw new UnauthorizedException(Document.ACCESS_DOCUMENT_AUTHORIZATION, documentFactory, documentFactory.getTypeName());
|
||
556 | continue;
|
||
557 | 43293 | fdiaz | } |
558 | 40435 | jjdelcerro | JRadioButton rb = new JRadioButton(); |
559 | |||
560 | rb.setIcon(documentFactory.getIcon()); |
||
561 | rb.setSelectedIcon(documentFactory.getIconSelected()); |
||
562 | rb.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); |
||
563 | rb.setText(documentFactory.getTitle()); |
||
564 | rb.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); |
||
565 | rb.setName(documentFactory.getTypeName()); |
||
566 | rb.addChangeListener(new javax.swing.event.ChangeListener() {
|
||
567 | |||
568 | public void stateChanged(javax.swing.event.ChangeEvent e) { |
||
569 | refreshList(); |
||
570 | } |
||
571 | }); |
||
572 | btns.add(rb); |
||
573 | } |
||
574 | btnsDocuments = btns.toArray(new JRadioButton[0]); |
||
575 | } |
||
576 | return btnsDocuments;
|
||
577 | } |
||
578 | |||
579 | /**
|
||
580 | * This method initializes jPanel1
|
||
581 | 42037 | fdiaz | *
|
582 | 40435 | jjdelcerro | * @return JPanel
|
583 | */
|
||
584 | private JPanel getDocumentsPanel() { |
||
585 | if (documentsPanel == null) { |
||
586 | documentsPanel = new JPanel(); |
||
587 | |||
588 | GridBagLayout layout2 = new GridBagLayout(); |
||
589 | GridBagConstraints c = new GridBagConstraints(); |
||
590 | |||
591 | documentsPanel.setLayout(layout2); |
||
592 | |||
593 | c.insets = new Insets(2, 5, 2, 5); |
||
594 | c.anchor = GridBagConstraints.WEST;
|
||
595 | c.fill = GridBagConstraints.BOTH;
|
||
596 | c.weightx = 1.0;
|
||
597 | c.weighty = 1.0;
|
||
598 | documentsPanel.add(getDocumentsScrollPane(), c); |
||
599 | |||
600 | c.anchor = GridBagConstraints.EAST;
|
||
601 | c.fill = GridBagConstraints.NONE;
|
||
602 | c.weightx = 0;
|
||
603 | c.weighty = 0;
|
||
604 | documentsPanel.add(getDocumentButtonsPanel(), c); |
||
605 | |||
606 | documentsPanel.setBorder(javax.swing.BorderFactory |
||
607 | .createTitledBorder(null,
|
||
608 | PluginServices.getText(this, "documentos_existentes"), |
||
609 | javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, |
||
610 | javax.swing.border.TitledBorder.DEFAULT_POSITION, null,
|
||
611 | null));
|
||
612 | } |
||
613 | |||
614 | return documentsPanel;
|
||
615 | } |
||
616 | |||
617 | /**
|
||
618 | * This method initializes lstDocs
|
||
619 | 42037 | fdiaz | *
|
620 | 40435 | jjdelcerro | * @return JList
|
621 | */
|
||
622 | private JList getDocumentsList() { |
||
623 | if (lstDocs == null) { |
||
624 | lstDocs = new JList(); |
||
625 | lstDocs.addMouseListener(new java.awt.event.MouseAdapter() {
|
||
626 | |||
627 | public AbstractDocument[] getSelecteds() { |
||
628 | if (lstDocs.getSelectedIndex() < 0) { |
||
629 | return new AbstractDocument[0]; |
||
630 | } |
||
631 | Object[] seleteds = lstDocs.getSelectedValues(); |
||
632 | AbstractDocument[] returnValue = |
||
633 | new AbstractDocument[seleteds.length]; |
||
634 | System.arraycopy(seleteds, 0, returnValue, 0, |
||
635 | seleteds.length); |
||
636 | return returnValue;
|
||
637 | } |
||
638 | |||
639 | public AbstractDocument getItem(java.awt.event.MouseEvent e) { |
||
640 | if (lstDocs.getSelectedIndex() < 0) { |
||
641 | return null; |
||
642 | } |
||
643 | |||
644 | return null; |
||
645 | } |
||
646 | |||
647 | @Override
|
||
648 | public void mouseClicked(java.awt.event.MouseEvent e) { |
||
649 | if (e.getButton() == java.awt.event.MouseEvent.BUTTON3) {
|
||
650 | /*
|
||
651 | * getDocumentSelected();//ProjectView
|
||
652 | * getDocumentSelectedName();//Vista
|
||
653 | */
|
||
654 | String docType = getDocumentSelected();
|
||
655 | AbstractDocument[] selecteds = this.getSelecteds(); |
||
656 | |||
657 | if (selecteds == null) { |
||
658 | return;
|
||
659 | } |
||
660 | DocumentContextMenu menu = |
||
661 | new DocumentContextMenu(docType, this.getItem(e), |
||
662 | selecteds); |
||
663 | if (!menu.hasActions()) {
|
||
664 | return;
|
||
665 | } |
||
666 | lstDocs.add(menu); |
||
667 | menu.show(e.getComponent(), e.getX(), e.getY()); |
||
668 | return;
|
||
669 | } |
||
670 | |||
671 | if (e.getClickCount() == 2) { |
||
672 | abrir(); |
||
673 | } |
||
674 | |||
675 | } |
||
676 | }); |
||
677 | lstDocs |
||
678 | .addListSelectionListener(new javax.swing.event.ListSelectionListener() {
|
||
679 | |||
680 | public void valueChanged( |
||
681 | javax.swing.event.ListSelectionEvent e) { |
||
682 | activarBotones(); |
||
683 | } |
||
684 | }); |
||
685 | } |
||
686 | |||
687 | return lstDocs;
|
||
688 | } |
||
689 | |||
690 | /**
|
||
691 | * This method initializes jPanel2
|
||
692 | 42037 | fdiaz | *
|
693 | 40435 | jjdelcerro | * @return JPanel
|
694 | */
|
||
695 | private JPanel getDocumentButtonsPanel() { |
||
696 | if (jPanel2 == null) { |
||
697 | jPanel2 = new JPanel(); |
||
698 | |||
699 | // FlowLayout layout = new FlowLayout();
|
||
700 | GridLayout layout = new GridLayout(5, 1); |
||
701 | layout.setVgap(7);
|
||
702 | |||
703 | jPanel2.setLayout(layout); |
||
704 | jPanel2.add(getBtnNuevo(), null);
|
||
705 | jPanel2.add(getBtnAbrir(), null);
|
||
706 | jPanel2.add(getBtnRenombrar(), null);
|
||
707 | jPanel2.add(getBtnBorrar(), null);
|
||
708 | jPanel2.add(getBtnPropiedades(), null);
|
||
709 | } |
||
710 | |||
711 | return jPanel2;
|
||
712 | } |
||
713 | |||
714 | /**
|
||
715 | * This method initializes btnNuevo
|
||
716 | 42037 | fdiaz | *
|
717 | 40435 | jjdelcerro | * @return JButton
|
718 | */
|
||
719 | private JButton getBtnNuevo() { |
||
720 | if (btnNuevo == null) { |
||
721 | btnNuevo = manager.createJButton(); |
||
722 | btnNuevo.setName("btnNuevo");
|
||
723 | btnNuevo.setText(PluginServices.getText(this, "nuevo")); |
||
724 | btnNuevo.setMargin(new java.awt.Insets(2, 2, 2, 2)); |
||
725 | btnNuevo.addActionListener(new java.awt.event.ActionListener() {
|
||
726 | |||
727 | public void actionPerformed(java.awt.event.ActionEvent e) { |
||
728 | try {
|
||
729 | newProjectDocument(); |
||
730 | } catch (Exception e1) { |
||
731 | NotificationManager.addError(e1.getLocalizedMessage(), |
||
732 | e1); |
||
733 | } |
||
734 | } |
||
735 | }); |
||
736 | } |
||
737 | |||
738 | return btnNuevo;
|
||
739 | } |
||
740 | |||
741 | /**
|
||
742 | * This method initializes btnPropiedades
|
||
743 | 42037 | fdiaz | *
|
744 | 40435 | jjdelcerro | * @return JButton
|
745 | */
|
||
746 | private JButton getBtnPropiedades() { |
||
747 | if (btnPropiedades == null) { |
||
748 | btnPropiedades = manager.createJButton(); |
||
749 | ; |
||
750 | btnPropiedades.setText(PluginServices.getText(this, "propiedades")); |
||
751 | btnPropiedades.setName("btnPropiedades");
|
||
752 | btnPropiedades.setEnabled(false);
|
||
753 | btnPropiedades.setMargin(new java.awt.Insets(2, 2, 2, 2)); |
||
754 | btnPropiedades |
||
755 | .addActionListener(new java.awt.event.ActionListener() {
|
||
756 | |||
757 | public void actionPerformed(java.awt.event.ActionEvent e) { |
||
758 | propiedades(); |
||
759 | } |
||
760 | }); |
||
761 | } |
||
762 | |||
763 | return btnPropiedades;
|
||
764 | } |
||
765 | |||
766 | /**
|
||
767 | * This method initializes btnAbrir
|
||
768 | 42037 | fdiaz | *
|
769 | 40435 | jjdelcerro | * @return JButton
|
770 | */
|
||
771 | private JButton getBtnAbrir() { |
||
772 | if (btnAbrir == null) { |
||
773 | btnAbrir = manager.createJButton(); |
||
774 | btnAbrir.setName("btnAbrir");
|
||
775 | btnAbrir.setText(PluginServices.getText(this, "abrir")); |
||
776 | btnAbrir.setEnabled(false);
|
||
777 | btnAbrir.setMargin(new java.awt.Insets(2, 2, 2, 2)); |
||
778 | btnAbrir.addActionListener(new java.awt.event.ActionListener() {
|
||
779 | |||
780 | public void actionPerformed(java.awt.event.ActionEvent e) { |
||
781 | abrir(); |
||
782 | } |
||
783 | }); |
||
784 | } |
||
785 | |||
786 | return btnAbrir;
|
||
787 | } |
||
788 | |||
789 | /**
|
||
790 | * This method initializes btnBorrar
|
||
791 | 42037 | fdiaz | *
|
792 | 40435 | jjdelcerro | * @return JButton
|
793 | */
|
||
794 | private JButton getBtnBorrar() { |
||
795 | if (btnBorrar == null) { |
||
796 | btnBorrar = manager.createJButton(); |
||
797 | btnBorrar.setText(PluginServices.getText(this, "borrar")); |
||
798 | btnBorrar.setName("btnBorrar");
|
||
799 | btnBorrar.setEnabled(false);
|
||
800 | btnBorrar.setMargin(new java.awt.Insets(2, 2, 2, 2)); |
||
801 | btnBorrar.addActionListener(new java.awt.event.ActionListener() {
|
||
802 | |||
803 | public void actionPerformed(java.awt.event.ActionEvent e) { |
||
804 | borrar(); |
||
805 | } |
||
806 | }); |
||
807 | } |
||
808 | |||
809 | return btnBorrar;
|
||
810 | } |
||
811 | |||
812 | /**
|
||
813 | * This method initializes btnRenombrar
|
||
814 | 42037 | fdiaz | *
|
815 | 40435 | jjdelcerro | * @return JButton
|
816 | */
|
||
817 | private JButton getBtnRenombrar() { |
||
818 | if (btnRenombrar == null) { |
||
819 | btnRenombrar = manager.createJButton(); |
||
820 | btnRenombrar.setName("btnRenombrar");
|
||
821 | btnRenombrar.setText(PluginServices.getText(this, "renombrar")); |
||
822 | btnRenombrar.setEnabled(false);
|
||
823 | btnRenombrar.setMargin(new java.awt.Insets(2, 2, 2, 2)); |
||
824 | btnRenombrar.addActionListener(new java.awt.event.ActionListener() {
|
||
825 | |||
826 | public void actionPerformed(java.awt.event.ActionEvent e) { |
||
827 | renombrar(); |
||
828 | } |
||
829 | }); |
||
830 | } |
||
831 | |||
832 | return btnRenombrar;
|
||
833 | } |
||
834 | |||
835 | /**
|
||
836 | * This method initializes jPanel3
|
||
837 | 42037 | fdiaz | *
|
838 | 40435 | jjdelcerro | * @return JPanel
|
839 | */
|
||
840 | private JPanel getPropertiesPanel() { |
||
841 | if (propertiesPanel == null) { |
||
842 | propertiesPanel = new JPanel(new GridBagLayout()); |
||
843 | GridBagConstraints c = new GridBagConstraints(); |
||
844 | |||
845 | c.insets = new Insets(2, 5, 0, 5); |
||
846 | c.anchor = GridBagConstraints.WEST;
|
||
847 | c.gridx = 0;
|
||
848 | c.gridy = 0;
|
||
849 | propertiesPanel.add(getJLabel(), c); |
||
850 | |||
851 | c.fill = GridBagConstraints.HORIZONTAL;
|
||
852 | c.weightx = 1.0;
|
||
853 | c.gridx = 1;
|
||
854 | propertiesPanel.add(getLblNombreSesion(), c); |
||
855 | |||
856 | c.gridx = 0;
|
||
857 | c.gridy = 1;
|
||
858 | c.fill = GridBagConstraints.NONE;
|
||
859 | c.weightx = 0.0;
|
||
860 | propertiesPanel.add(getJLabel1(), c); |
||
861 | |||
862 | c.fill = GridBagConstraints.HORIZONTAL;
|
||
863 | c.weightx = 1.0;
|
||
864 | c.gridx = 1;
|
||
865 | propertiesPanel.add(getLblGuardado(), c); |
||
866 | |||
867 | c.gridx = 0;
|
||
868 | c.gridy = 2;
|
||
869 | c.fill = GridBagConstraints.NONE;
|
||
870 | c.weightx = 0.0;
|
||
871 | propertiesPanel.add(getJLabel2(), c); |
||
872 | |||
873 | c.fill = GridBagConstraints.HORIZONTAL;
|
||
874 | c.weightx = 1.0;
|
||
875 | c.gridx = 1;
|
||
876 | propertiesPanel.add(getLblFecha(), c); |
||
877 | |||
878 | c.gridx = 0;
|
||
879 | c.gridwidth = 2;
|
||
880 | c.gridy = 4;
|
||
881 | c.fill = GridBagConstraints.HORIZONTAL;
|
||
882 | c.anchor = GridBagConstraints.EAST;
|
||
883 | propertiesPanel.add(getProjectsButtonPanel(), c); |
||
884 | |||
885 | propertiesPanel.setBorder(javax.swing.BorderFactory |
||
886 | .createTitledBorder(null,
|
||
887 | PluginServices.getText(this, "propiedades_sesion"), |
||
888 | javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, |
||
889 | javax.swing.border.TitledBorder.DEFAULT_POSITION, null,
|
||
890 | null));
|
||
891 | } |
||
892 | |||
893 | return propertiesPanel;
|
||
894 | } |
||
895 | |||
896 | /**
|
||
897 | * This method initializes jLabel
|
||
898 | 42037 | fdiaz | *
|
899 | 40435 | jjdelcerro | * @return JLabel
|
900 | */
|
||
901 | private JLabel getJLabel() { |
||
902 | if (jLabel == null) { |
||
903 | jLabel = new JLabel(); |
||
904 | jLabel.setText(PluginServices.getText(this, "nombre_sesion") + ":"); |
||
905 | } |
||
906 | |||
907 | return jLabel;
|
||
908 | } |
||
909 | |||
910 | /**
|
||
911 | * This method initializes lblNombreSesion
|
||
912 | 42037 | fdiaz | *
|
913 | 40435 | jjdelcerro | * @return JLabel
|
914 | */
|
||
915 | private JLabel getLblNombreSesion() { |
||
916 | if (lblNombreSesion == null) { |
||
917 | lblNombreSesion = new JLabel(); |
||
918 | lblNombreSesion.setText("");
|
||
919 | lblNombreSesion.setName("lblNombreSesion");
|
||
920 | lblNombreSesion.setAutoscrolls(true);
|
||
921 | } |
||
922 | |||
923 | return lblNombreSesion;
|
||
924 | } |
||
925 | |||
926 | /**
|
||
927 | * This method initializes jLabel1
|
||
928 | 42037 | fdiaz | *
|
929 | 40435 | jjdelcerro | * @return JLabel
|
930 | */
|
||
931 | private JLabel getJLabel1() { |
||
932 | if (jLabel1 == null) { |
||
933 | jLabel1 = new JLabel(); |
||
934 | jLabel1.setText(PluginServices.getText(this, "guardado") + ":"); |
||
935 | } |
||
936 | |||
937 | return jLabel1;
|
||
938 | } |
||
939 | |||
940 | /**
|
||
941 | * This method initializes lblGuardado
|
||
942 | 42037 | fdiaz | *
|
943 | 40435 | jjdelcerro | * @return JLabel
|
944 | */
|
||
945 | private JLabel getLblGuardado() { |
||
946 | if (lblGuardado == null) { |
||
947 | lblGuardado = new JLabel(); |
||
948 | lblGuardado.setText("");
|
||
949 | lblGuardado.setAutoscrolls(true);
|
||
950 | } |
||
951 | |||
952 | return lblGuardado;
|
||
953 | } |
||
954 | |||
955 | /**
|
||
956 | * This method initializes jLabel2
|
||
957 | 42037 | fdiaz | *
|
958 | 40435 | jjdelcerro | * @return JLabel
|
959 | */
|
||
960 | private JLabel getJLabel2() { |
||
961 | if (jLabel2 == null) { |
||
962 | jLabel2 = new JLabel(); |
||
963 | jLabel2 |
||
964 | .setText(PluginServices.getText(this, "creation_date") + ":"); |
||
965 | } |
||
966 | |||
967 | return jLabel2;
|
||
968 | } |
||
969 | |||
970 | /**
|
||
971 | * This method initializes lblFecha
|
||
972 | 42037 | fdiaz | *
|
973 | 40435 | jjdelcerro | * @return JLabel
|
974 | */
|
||
975 | private JLabel getLblFecha() { |
||
976 | if (lblFecha == null) { |
||
977 | lblFecha = new JLabel(); |
||
978 | lblFecha.setText("");
|
||
979 | lblFecha.setAutoscrolls(true);
|
||
980 | } |
||
981 | |||
982 | return lblFecha;
|
||
983 | } |
||
984 | |||
985 | /**
|
||
986 | * This method initializes btnImportar
|
||
987 | 42037 | fdiaz | *
|
988 | 40435 | jjdelcerro | * @return JButton
|
989 | */
|
||
990 | private JButton getBtnImportar() { |
||
991 | if (btnImportar == null) { |
||
992 | btnImportar = manager.createJButton(); |
||
993 | btnImportar.setPreferredSize(new java.awt.Dimension(80, 23)); |
||
994 | btnImportar.setText(PluginServices.getText(this, "importar")); |
||
995 | btnImportar.setName("btnImportar");
|
||
996 | btnImportar.setMargin(new java.awt.Insets(2, 2, 2, 2)); |
||
997 | } |
||
998 | |||
999 | return btnImportar;
|
||
1000 | } |
||
1001 | |||
1002 | /**
|
||
1003 | * This method initializes btnExportar
|
||
1004 | 42037 | fdiaz | *
|
1005 | 40435 | jjdelcerro | * @return JButton
|
1006 | */
|
||
1007 | private JButton getBtnExportar() { |
||
1008 | if (btnExportar == null) { |
||
1009 | btnExportar = manager.createJButton(); |
||
1010 | btnExportar.setPreferredSize(new java.awt.Dimension(80, 23)); |
||
1011 | btnExportar.setText(PluginServices.getText(this, "exportar")); |
||
1012 | btnExportar.setName("btnExportar");
|
||
1013 | btnExportar.setMargin(new java.awt.Insets(2, 2, 2, 2)); |
||
1014 | } |
||
1015 | |||
1016 | return btnExportar;
|
||
1017 | } |
||
1018 | |||
1019 | /**
|
||
1020 | * This method initializes btnEditar
|
||
1021 | 42037 | fdiaz | *
|
1022 | 40435 | jjdelcerro | * @return JButton
|
1023 | */
|
||
1024 | private JButton getBtnEditar() { |
||
1025 | if (btnEditar == null) { |
||
1026 | btnEditar = manager.createJButton(); |
||
1027 | btnEditar.setPreferredSize(new java.awt.Dimension(80, 23)); |
||
1028 | btnEditar.setText(PluginServices.getText(this, "propiedades")); |
||
1029 | |||
1030 | btnEditar.setName("btnEditar");
|
||
1031 | btnEditar.setMargin(new java.awt.Insets(2, 2, 2, 2)); |
||
1032 | |||
1033 | btnEditar.addActionListener(new java.awt.event.ActionListener() {
|
||
1034 | |||
1035 | public void actionPerformed(java.awt.event.ActionEvent e) { |
||
1036 | 41350 | jjdelcerro | I18nManager i18nManager = ToolsLocator.getI18nManager(); |
1037 | WindowManager winmgr = ToolsSwingLocator.getWindowManager(); |
||
1038 | winmgr.showWindow( |
||
1039 | 42037 | fdiaz | new ProjectProperties(project),
|
1040 | i18nManager.getTranslation("project_properties"),
|
||
1041 | 41350 | jjdelcerro | WindowManager.MODE.WINDOW |
1042 | ); |
||
1043 | 40435 | jjdelcerro | refreshProperties(); |
1044 | } |
||
1045 | }); |
||
1046 | } |
||
1047 | |||
1048 | return btnEditar;
|
||
1049 | } |
||
1050 | |||
1051 | /**
|
||
1052 | * This method initializes jScrollPane
|
||
1053 | 42037 | fdiaz | *
|
1054 | 40435 | jjdelcerro | * @return JScrollPane
|
1055 | */
|
||
1056 | private JScrollPane getDocumentsScrollPane() { |
||
1057 | if (documentsScrollPane == null) { |
||
1058 | documentsScrollPane = new JScrollPane(); |
||
1059 | documentsScrollPane.setViewportView(getDocumentsList()); |
||
1060 | 41385 | jjdelcerro | documentsScrollPane.setPreferredSize(new java.awt.Dimension(200,100)); |
1061 | documentsScrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
|
||
1062 | 40435 | jjdelcerro | } |
1063 | |||
1064 | return documentsScrollPane;
|
||
1065 | } |
||
1066 | |||
1067 | /**
|
||
1068 | * @see com.iver.mdiApp.ui.MDIManager.SingletonWindow#getWindowModel()
|
||
1069 | */
|
||
1070 | public Object getWindowModel() { |
||
1071 | return project;
|
||
1072 | } |
||
1073 | |||
1074 | public Project getProject() {
|
||
1075 | return project;
|
||
1076 | } |
||
1077 | |||
1078 | /**
|
||
1079 | * This method is used to get <strong>an initial</strong> ViewInfo object
|
||
1080 | * for this Project Manager window. It is not intended to retrieve the
|
||
1081 | * ViewInfo object in a later time. <strong>Use
|
||
1082 | * PluginServices.getMDIManager().getViewInfo(view) to retrieve the ViewInfo
|
||
1083 | * object at any time after the creation of the object.
|
||
1084 | 42037 | fdiaz | *
|
1085 | 40435 | jjdelcerro | * @see com.iver.mdiApp.ui.MDIManager.IWindow#getWindowInfo()
|
1086 | */
|
||
1087 | public WindowInfo getWindowInfo() {
|
||
1088 | if (m_viewInfo == null) { |
||
1089 | m_viewInfo = |
||
1090 | new WindowInfo(WindowInfo.MAXIMIZABLE | WindowInfo.RESIZABLE);
|
||
1091 | m_viewInfo.setWidth(this.getWidth());
|
||
1092 | m_viewInfo.setHeight(this.getHeight());
|
||
1093 | 41164 | jjdelcerro | int w = this.getPreferredSize().width; |
1094 | 41206 | jjdelcerro | if( w < 450 ) { |
1095 | w = 450;
|
||
1096 | 41164 | jjdelcerro | } |
1097 | m_viewInfo.setNormalWidth(w); |
||
1098 | 40435 | jjdelcerro | m_viewInfo.setNormalHeight(this.getPreferredSize().height);
|
1099 | m_viewInfo.setMinimumSize(getPreferredSize()); |
||
1100 | |||
1101 | m_viewInfo.setTitle(PluginServices.getText(this, "_Project_manager")); |
||
1102 | } |
||
1103 | return m_viewInfo;
|
||
1104 | } |
||
1105 | |||
1106 | public void propertyChange(final PropertyChangeEvent evt) { |
||
1107 | if( !SwingUtilities.isEventDispatchThread() ) { |
||
1108 | SwingUtilities.invokeLater( new Runnable() { |
||
1109 | public void run() { |
||
1110 | propertyChange(evt); |
||
1111 | } |
||
1112 | }); |
||
1113 | return;
|
||
1114 | } |
||
1115 | refreshControls(); |
||
1116 | } |
||
1117 | |||
1118 | /**
|
||
1119 | * This method initializes jPanel4
|
||
1120 | 42037 | fdiaz | *
|
1121 | 40435 | jjdelcerro | * @return JPanel
|
1122 | */
|
||
1123 | private JPanel getProjectsButtonPanel() { |
||
1124 | if (projectButtonsPanel == null) { |
||
1125 | projectButtonsPanel = new JPanel(); |
||
1126 | |||
1127 | projectButtonsPanel.setLayout(new FlowLayout(FlowLayout.RIGHT)); |
||
1128 | projectButtonsPanel |
||
1129 | .setComponentOrientation(java.awt.ComponentOrientation.LEFT_TO_RIGHT); |
||
1130 | // TODO: implement export and import functions
|
||
1131 | // projectButtonsPanel.add(getBtnImportar(), null);
|
||
1132 | // projectButtonsPanel.add(getBtnExportar(), null);
|
||
1133 | projectButtonsPanel.add(getBtnEditar(), null);
|
||
1134 | } |
||
1135 | |||
1136 | return projectButtonsPanel;
|
||
1137 | } |
||
1138 | |||
1139 | public Object getWindowProfile() { |
||
1140 | return WindowInfo.PROJECT_PROFILE;
|
||
1141 | } |
||
1142 | |||
1143 | public void update(Observable observable, Object notification) { |
||
1144 | if (observable instanceof ProjectManager) { |
||
1145 | refreshDocuments(); |
||
1146 | } |
||
1147 | } |
||
1148 | |||
1149 | private void refreshDocuments() { |
||
1150 | // Setting it to null will make it recreate in the next
|
||
1151 | // getBtnDocuments() call
|
||
1152 | this.btnsDocuments = null; |
||
1153 | |||
1154 | // Clear previous document type buttons
|
||
1155 | documentTypesList.removeAll(); |
||
1156 | for (Enumeration<AbstractButton> buttons = grupo.getElements(); buttons |
||
1157 | .hasMoreElements();) { |
||
1158 | grupo.remove(buttons.nextElement()); |
||
1159 | } |
||
1160 | |||
1161 | JRadioButton[] btnDocuments = getBtnDocumentTypes(); |
||
1162 | for (int i = 0; i < btnDocuments.length; i++) { |
||
1163 | grupo.add(btnDocuments[i]); |
||
1164 | } |
||
1165 | if (btnDocuments.length > 0) { |
||
1166 | btnDocuments[0].setSelected(true); |
||
1167 | } |
||
1168 | fillDocumentTypeButtons(); |
||
1169 | } |
||
1170 | |||
1171 | 41314 | jjdelcerro | @Override
|
1172 | public void setLocale(Locale locale) { |
||
1173 | super.setLocale(locale);
|
||
1174 | 42037 | fdiaz | |
1175 | 41314 | jjdelcerro | I18nManager i18nManager = ToolsLocator.getI18nManager(); |
1176 | |||
1177 | btnNuevo.setText(i18nManager.getTranslation( "nuevo"));
|
||
1178 | 42037 | fdiaz | btnPropiedades.setText(i18nManager.getTranslation("propiedades"));
|
1179 | 41314 | jjdelcerro | btnAbrir.setText(i18nManager.getTranslation("abrir"));
|
1180 | btnBorrar.setText(i18nManager.getTranslation("borrar"));
|
||
1181 | btnRenombrar.setText(i18nManager.getTranslation("renombrar"));
|
||
1182 | |||
1183 | jLabel.setText(i18nManager.getTranslation("nombre_sesion") + ":"); |
||
1184 | jLabel1.setText(i18nManager.getTranslation("guardado") + ":"); |
||
1185 | jLabel2.setText(i18nManager.getTranslation("creation_date") + ":"); |
||
1186 | 42037 | fdiaz | |
1187 | 41314 | jjdelcerro | // btnImportar.setText(i18nManager.getTranslation("importar"));
|
1188 | // btnExportar.setText(i18nManager.getTranslation("exportar"));
|
||
1189 | btnEditar.setText(i18nManager.getTranslation("propiedades"));
|
||
1190 | 42037 | fdiaz | |
1191 | 41314 | jjdelcerro | m_viewInfo.setTitle(i18nManager.getTranslation("_Project_manager"));
|
1192 | |||
1193 | TitledBorder border = null; |
||
1194 | 42037 | fdiaz | |
1195 | 41314 | jjdelcerro | border = (TitledBorder) propertiesPanel.getBorder();
|
1196 | border.setTitle(i18nManager.getTranslation("propiedades_sesion"));
|
||
1197 | |||
1198 | border = (TitledBorder) documentTypes.getBorder();
|
||
1199 | border.setTitle(i18nManager.getTranslation("tipos_de_documentos"));
|
||
1200 | |||
1201 | border = (TitledBorder) documentsPanel.getBorder();
|
||
1202 | border.setTitle(i18nManager.getTranslation("documentos_existentes"));
|
||
1203 | |||
1204 | 42037 | fdiaz | refreshList(); |
1205 | 41314 | jjdelcerro | } |
1206 | |||
1207 | 46010 | jjdelcerro | @Override
|
1208 | public Object getProperty(String name) { |
||
1209 | return this.propertiesHelper.getProperty(name); |
||
1210 | } |
||
1211 | 42037 | fdiaz | |
1212 | 46010 | jjdelcerro | @Override
|
1213 | public void setProperty(String name, Object value) { |
||
1214 | this.propertiesHelper.setProperty(name, value);
|
||
1215 | } |
||
1216 | |||
1217 | @Override
|
||
1218 | public Map<String, Object> getProperties() { |
||
1219 | return this.propertiesHelper.getProperties(); |
||
1220 | } |
||
1221 | |||
1222 | 40435 | jjdelcerro | } |