svn-gvsig-desktop / trunk / extensions / extMetadata / src / org / gvsig / metadata / extension / gui / MDGUITab.java @ 24124
History | View | Annotate | Download (4.36 KB)
1 |
/* gvSIG. Geographic Information System of the Valencian Government
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department
|
4 |
* of the Valencian Government (CIT)
|
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 2
|
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 |
*/
|
22 |
|
23 |
/*
|
24 |
* AUTHORS (In addition to CIT):
|
25 |
* 2008 Geographic Information research group: http://www.geoinfo.uji.es
|
26 |
* Departamento de Lenguajes y Sistemas Inform?ticos (LSI)
|
27 |
* Universitat Jaume I
|
28 |
* {{Task}}
|
29 |
*/
|
30 |
|
31 |
package org.gvsig.metadata.extension.gui; |
32 |
|
33 |
import java.awt.BorderLayout; |
34 |
import java.awt.event.ItemEvent; |
35 |
import java.awt.event.ItemListener; |
36 |
|
37 |
import javax.swing.JCheckBox; |
38 |
import javax.swing.JPanel; |
39 |
|
40 |
import net.miginfocom.swing.MigLayout; |
41 |
|
42 |
import org.gvsig.gui.beans.swing.JBlank; |
43 |
|
44 |
import com.iver.andami.PluginServices; |
45 |
import com.iver.andami.ui.mdiManager.IWindow; |
46 |
import com.iver.cit.gvsig.fmap.layers.FLayer; |
47 |
import com.iver.cit.gvsig.fmap.layers.FLayers; |
48 |
import com.iver.cit.gvsig.project.documents.view.gui.View; |
49 |
import com.iver.cit.gvsig.project.documents.view.legend.gui.AbstractThemeManagerPage; |
50 |
|
51 |
|
52 |
|
53 |
public class MDGUITab extends AbstractThemeManagerPage { |
54 |
|
55 |
private static final long serialVersionUID = 1L; |
56 |
|
57 |
private FLayer layer;
|
58 |
private MDBasicGUIPanel mdPanel;
|
59 |
private JCheckBox editCB; |
60 |
private boolean edited; |
61 |
|
62 |
|
63 |
|
64 |
/**
|
65 |
* This is the default constructor.
|
66 |
*/
|
67 |
public MDGUITab() {
|
68 |
super();
|
69 |
|
70 |
// GET ACTIVE LAYER --------------------------------
|
71 |
FLayers al = this.getFLayers();
|
72 |
FLayer[] ll = al.getActives();
|
73 |
|
74 |
layer = al.getLayer(0);
|
75 |
if(ll.length > 0) |
76 |
layer = ll[0];
|
77 |
// -------------------------------------------------
|
78 |
|
79 |
mdPanel = new MDBasicGUIPanel(layer);
|
80 |
|
81 |
setLayout(new BorderLayout()); |
82 |
add(mdPanel, BorderLayout.CENTER);
|
83 |
add(new JBlank(5, 10), BorderLayout.WEST); |
84 |
add(new JBlank(5, 10), BorderLayout.EAST); |
85 |
add(getSouthPanel(), BorderLayout.SOUTH);
|
86 |
} |
87 |
|
88 |
private JPanel getSouthPanel() { |
89 |
|
90 |
editCB = new JCheckBox(PluginServices.getText(this, "edit_checkbox"), false); |
91 |
editCB.addItemListener( new ItemListener() { |
92 |
public void itemStateChanged(ItemEvent e) { |
93 |
if(e.getStateChange() == ItemEvent.SELECTED) { |
94 |
mdPanel.allowEdition(); |
95 |
edited = true;
|
96 |
} else
|
97 |
mdPanel.closeEdition(); |
98 |
} |
99 |
} |
100 |
); |
101 |
edited = false;
|
102 |
|
103 |
JPanel auxPanel = new JPanel(); |
104 |
auxPanel.setLayout(new MigLayout());
|
105 |
auxPanel.add(editCB); |
106 |
return auxPanel;
|
107 |
} |
108 |
|
109 |
/**
|
110 |
* (non-Javadoc)
|
111 |
* @see java.awt.Component#getName()
|
112 |
*/
|
113 |
public String getName() { |
114 |
return PluginServices.getText(this, "Metadata"); |
115 |
} |
116 |
|
117 |
/**
|
118 |
* Sets the necessary properties in the panel.
|
119 |
* @param FLayer layer
|
120 |
*/
|
121 |
public void setModel(FLayer layer) { |
122 |
this.layer = layer;
|
123 |
} |
124 |
|
125 |
public void acceptAction() { |
126 |
if(edited)
|
127 |
mdPanel.saveChanges(); |
128 |
} |
129 |
|
130 |
public void cancelAction() { |
131 |
//if(edited) -> Lanzar alert sobre guardar posibles cambios?
|
132 |
} |
133 |
|
134 |
public void applyAction() { |
135 |
if(edited) {
|
136 |
mdPanel.closeEdition(); |
137 |
mdPanel.saveChanges(); |
138 |
} |
139 |
} |
140 |
|
141 |
private FLayers getFLayers () {
|
142 |
FLayers flyrs = null;
|
143 |
IWindow window = PluginServices.getMDIManager().getActiveWindow(); |
144 |
|
145 |
if( !(window instanceof View) ) { |
146 |
IWindow[] windowList = PluginServices.getMDIManager().getAllWindows();
|
147 |
for (int i = 0; i < windowList.length; i++) { |
148 |
if(windowList[i] instanceof View) { |
149 |
window = windowList[i]; |
150 |
break;
|
151 |
} |
152 |
} |
153 |
} |
154 |
|
155 |
if ( window != null && window instanceof View ) |
156 |
if ( ((View) window).getMapControl() != null ) |
157 |
if ( ((View) window).getMapControl().getMapContext() != null ) |
158 |
flyrs = ((View) window).getMapControl().getMapContext().getLayers();
|
159 |
return flyrs;
|
160 |
} |
161 |
|
162 |
} |