svn-gvsig-desktop / trunk / applications / appgvSIG / src / com / iver / cit / gvsig / project / documents / view / legend / gui / AbstractThemeManagerPage.java @ 12805
History | View | Annotate | Download (3.89 KB)
1 |
package com.iver.cit.gvsig.project.documents.view.legend.gui; |
---|---|
2 |
|
3 |
import javax.swing.JOptionPane; |
4 |
import javax.swing.JPanel; |
5 |
|
6 |
import com.iver.andami.PluginServices; |
7 |
import com.iver.andami.messages.Messages; |
8 |
import com.iver.cit.gvsig.fmap.layers.FLayer; |
9 |
import com.iver.cit.gvsig.fmap.layers.FLayers; |
10 |
import com.iver.cit.gvsig.fmap.layers.layerOperations.Classifiable; |
11 |
import com.iver.cit.gvsig.fmap.rendering.ILegend; |
12 |
import com.iver.cit.gvsig.fmap.rendering.IVectorialLegend; |
13 |
|
14 |
public abstract class AbstractThemeManagerPage extends JPanel { |
15 |
/**
|
16 |
* Cuando hay varios capas vectoriales seleccionados, devolver? el ?ltimo.
|
17 |
*
|
18 |
* @param layers Grupo de layers.
|
19 |
*
|
20 |
* @return la primera flayer seleccionada.
|
21 |
*/
|
22 |
protected FLayer getFirstActiveLayerVect(FLayers layers) {
|
23 |
// Comprobar en openLegendManager que hay alg?n capa activo!
|
24 |
FLayer[] activeLyrs = layers.getActives();
|
25 |
|
26 |
if (activeLyrs.length == 0) { |
27 |
JOptionPane.showMessageDialog(null, |
28 |
Messages.getString("necesita_una_capa_activa"), "", |
29 |
JOptionPane.ERROR_MESSAGE);
|
30 |
|
31 |
return null; |
32 |
} |
33 |
|
34 |
FLayer lyr = null;
|
35 |
|
36 |
for (int i = 0; i < activeLyrs.length; i++) { |
37 |
if (activeLyrs[i] instanceof FLayers) { |
38 |
lyr = getFirstActiveLayerVect((FLayers) activeLyrs[i]); |
39 |
} |
40 |
|
41 |
if (activeLyrs[i] instanceof Classifiable) { |
42 |
Classifiable auxC = (Classifiable) activeLyrs[i]; |
43 |
ILegend theLegend = auxC.getLegend(); |
44 |
|
45 |
if (theLegend instanceof IVectorialLegend) { |
46 |
lyr = (FLayer) auxC; |
47 |
} |
48 |
} |
49 |
} |
50 |
|
51 |
if (lyr == null) { |
52 |
System.out.println(PluginServices.getText(this, |
53 |
"Por_favor_active_la_capa") + "."); |
54 |
JOptionPane.showMessageDialog(null, |
55 |
Messages.getString(PluginServices.getText(this,
|
56 |
"necesita_una_capa_vectorial_activa")), "", |
57 |
JOptionPane.ERROR_MESSAGE);
|
58 |
|
59 |
return null; |
60 |
} |
61 |
|
62 |
return lyr;
|
63 |
} |
64 |
|
65 |
/**
|
66 |
* Returns the name of this ThemeManagerPage's tab, the text returned by this
|
67 |
* method will be shown in the text of this panel's tab.
|
68 |
*/
|
69 |
public abstract String getName(); |
70 |
|
71 |
/**
|
72 |
* <p>
|
73 |
* Method invoked when the Ok button is pressed from the ThemeManagerWindow.
|
74 |
* It will cause the changes performed by the user to take effect into the
|
75 |
* layer if the Apply button wasn't pressed yet. In case Apply button was
|
76 |
* pressed, then the programmer can choose between apply the changes again or
|
77 |
* not.<br>
|
78 |
* </p>
|
79 |
* <p>
|
80 |
* It shouldn't be a problem rather than the potential consumption of time
|
81 |
* required in when applying such changes.<br>
|
82 |
* </p>
|
83 |
* <p>
|
84 |
* <b>Notice</b> that after the call of this method the ThemeManagerWindow will be closed.
|
85 |
* </p>
|
86 |
*/
|
87 |
public abstract void acceptAction(); |
88 |
|
89 |
/**
|
90 |
* <p>
|
91 |
* Method invoked when the Cancel button is pressed from the ThemeManagerWindow.
|
92 |
* It will cause that the changes performed will be discarded.
|
93 |
* </p>
|
94 |
*/
|
95 |
public abstract void cancelAction(); |
96 |
|
97 |
/**
|
98 |
* Method invoked when the Apply button is pressed from the ThemeManagerWindow.
|
99 |
* It will cause the changes performed by the user to take effect inmediately
|
100 |
* into the the layer.
|
101 |
*/
|
102 |
public abstract void applyAction(); |
103 |
|
104 |
/**
|
105 |
* This method is invoked during the initialization of the ThemeManagerWindow
|
106 |
* and causes the dialog to be updated to reflect the current settings of
|
107 |
* the layer in the context that this panel was designed for.
|
108 |
* @param layer, the target FLayer
|
109 |
*/
|
110 |
public abstract void setModel(FLayer layer); |
111 |
|
112 |
/**
|
113 |
* Method used to hide or show this panel depending of it was designed for
|
114 |
* this layer. Use it to avoid errors setting values for layers that are
|
115 |
* not the type of layer this panel handles, or even to avoid errors if
|
116 |
* the layer is not ready to take the changes, (for example: maybe you
|
117 |
* want to ensure that some properties are not changed if this layer is being
|
118 |
* edited).
|
119 |
* @param layer, the target FLayer
|
120 |
* @return <b>true</b> if this panel has sense for the layer passed as parameter,
|
121 |
* or <b>false</b> otherwise.
|
122 |
*/
|
123 |
public abstract boolean isSuitableFor(FLayer layer); |
124 |
|
125 |
} |