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 / view / legend / gui / AbstractThemeManagerPage.java @ 40558
History | View | Annotate | Download (4.24 KB)
1 | 40558 | jjdelcerro | /**
|
---|---|---|---|
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 | 40435 | jjdelcerro | package org.gvsig.app.project.documents.view.legend.gui; |
25 | |||
26 | import javax.swing.JOptionPane; |
||
27 | import javax.swing.JPanel; |
||
28 | |||
29 | import org.gvsig.andami.PluginServices; |
||
30 | import org.gvsig.andami.messages.Messages; |
||
31 | import org.gvsig.fmap.mapcontext.layers.FLayer; |
||
32 | import org.gvsig.fmap.mapcontext.layers.FLayers; |
||
33 | import org.gvsig.fmap.mapcontext.layers.operations.Classifiable; |
||
34 | import org.gvsig.fmap.mapcontext.rendering.legend.ILegend; |
||
35 | import org.gvsig.fmap.mapcontext.rendering.legend.IVectorLegend; |
||
36 | |||
37 | |||
38 | public abstract class AbstractThemeManagerPage extends JPanel { |
||
39 | /**
|
||
40 | * Cuando hay varios capas vectoriales seleccionados, devolver? el ?ltimo.
|
||
41 | *
|
||
42 | * @param layers Grupo de layers.
|
||
43 | *
|
||
44 | * @return la primera flayer seleccionada.
|
||
45 | */
|
||
46 | protected FLayer getFirstActiveLayerVect(FLayers layers) {
|
||
47 | // Comprobar en openLegendManager que hay alg?n capa activo!
|
||
48 | FLayer[] activeLyrs = layers.getActives();
|
||
49 | |||
50 | if (activeLyrs.length == 0) { |
||
51 | JOptionPane.showMessageDialog(null, |
||
52 | Messages.getString("necesita_una_capa_activa"), "", |
||
53 | JOptionPane.ERROR_MESSAGE);
|
||
54 | |||
55 | return null; |
||
56 | } |
||
57 | |||
58 | FLayer lyr = null;
|
||
59 | |||
60 | for (int i = 0; i < activeLyrs.length; i++) { |
||
61 | if (activeLyrs[i] instanceof FLayers) { |
||
62 | lyr = getFirstActiveLayerVect((FLayers) activeLyrs[i]); |
||
63 | } |
||
64 | |||
65 | if (activeLyrs[i] instanceof Classifiable) { |
||
66 | Classifiable auxC = (Classifiable) activeLyrs[i]; |
||
67 | ILegend theLegend = auxC.getLegend(); |
||
68 | |||
69 | if (theLegend instanceof IVectorLegend) { |
||
70 | lyr = (FLayer) auxC; |
||
71 | } |
||
72 | } |
||
73 | } |
||
74 | |||
75 | if (lyr == null) { |
||
76 | JOptionPane.showMessageDialog(null, |
||
77 | Messages.getString( |
||
78 | PluginServices.getText(this, "necesita_una_capa_vectorial_activa") + |
||
79 | "\n\n"+
|
||
80 | PluginServices.getText(this, "Por_favor_active_la_capa") + "."), |
||
81 | "",
|
||
82 | JOptionPane.ERROR_MESSAGE);
|
||
83 | return null; |
||
84 | } |
||
85 | |||
86 | return lyr;
|
||
87 | } |
||
88 | |||
89 | /**
|
||
90 | * Returns the name of this ThemeManagerPage's tab, the text returned by this
|
||
91 | * method will be shown in the text of this panel's tab.
|
||
92 | */
|
||
93 | public abstract String getName(); |
||
94 | |||
95 | /**
|
||
96 | * <p>
|
||
97 | * Method invoked when the Ok button is pressed from the ThemeManagerWindow.
|
||
98 | * It will cause the changes performed by the user to take effect into the
|
||
99 | * layer if the Apply button wasn't pressed yet. In case Apply button was
|
||
100 | * pressed, then the programmer can choose between apply the changes again or
|
||
101 | * not.<br>
|
||
102 | * </p>
|
||
103 | * <p>
|
||
104 | * It shouldn't be a problem rather than the potential consumption of time
|
||
105 | * required in when applying such changes.<br>
|
||
106 | * </p>
|
||
107 | * <p>
|
||
108 | * <b>Notice</b> that after the call of this method the ThemeManagerWindow will be closed.
|
||
109 | * </p>
|
||
110 | */
|
||
111 | public abstract void acceptAction(); |
||
112 | |||
113 | /**
|
||
114 | * <p>
|
||
115 | * Method invoked when the Cancel button is pressed from the ThemeManagerWindow.
|
||
116 | * It will cause that the changes performed will be discarded.
|
||
117 | * </p>
|
||
118 | */
|
||
119 | public abstract void cancelAction(); |
||
120 | |||
121 | /**
|
||
122 | * Method invoked when the Apply button is pressed from the ThemeManagerWindow.
|
||
123 | * It will cause the changes performed by the user to take effect inmediately
|
||
124 | * into the the layer.
|
||
125 | */
|
||
126 | public abstract void applyAction(); |
||
127 | |||
128 | /**
|
||
129 | * This method is invoked during the initialization of the ThemeManagerWindow
|
||
130 | * and causes the dialog to be updated to reflect the current settings of
|
||
131 | * the layer in the context that this panel was designed for.
|
||
132 | * @param layer, the target FLayer
|
||
133 | */
|
||
134 | public abstract void setModel(FLayer layer); |
||
135 | } |