svn-gvsig-desktop / trunk / applications / appgvSIG / src / com / iver / cit / gvsig / project / documents / view / legend / gui / AbstractThemeManagerPage.java @ 28407
History | View | Annotate | Download (3.29 KB)
1 | 10679 | jaume | 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 | 11558 | jaume | import com.iver.cit.gvsig.fmap.rendering.ILegend; |
12 | 13870 | jaume | import com.iver.cit.gvsig.fmap.rendering.IVectorLegend; |
13 | 10679 | jaume | |
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 | 11558 | jaume | ILegend theLegend = auxC.getLegend(); |
44 | 10679 | jaume | |
45 | 13870 | jaume | if (theLegend instanceof IVectorLegend) { |
46 | 10679 | jaume | lyr = (FLayer) auxC; |
47 | } |
||
48 | } |
||
49 | } |
||
50 | |||
51 | if (lyr == null) { |
||
52 | JOptionPane.showMessageDialog(null, |
||
53 | 13729 | jaume | Messages.getString( |
54 | PluginServices.getText(this, "necesita_una_capa_vectorial_activa") + |
||
55 | "\n\n"+
|
||
56 | PluginServices.getText(this, "Por_favor_active_la_capa") + "."), |
||
57 | "",
|
||
58 | 10679 | jaume | JOptionPane.ERROR_MESSAGE);
|
59 | return null; |
||
60 | } |
||
61 | |||
62 | return lyr;
|
||
63 | } |
||
64 | |||
65 | 12805 | jaume | /**
|
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 | 10679 | jaume | public abstract String getName(); |
70 | 13513 | caballero | |
71 | 12805 | jaume | /**
|
72 | * <p>
|
||
73 | 13513 | caballero | * Method invoked when the Ok button is pressed from the ThemeManagerWindow.
|
74 | 12805 | jaume | * 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 | 10679 | jaume | public abstract void acceptAction(); |
88 | 13513 | caballero | |
89 | 12805 | jaume | /**
|
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 | 10679 | jaume | public abstract void cancelAction(); |
96 | 13513 | caballero | |
97 | 12805 | jaume | /**
|
98 | 13513 | caballero | * Method invoked when the Apply button is pressed from the ThemeManagerWindow.
|
99 | 12805 | jaume | * It will cause the changes performed by the user to take effect inmediately
|
100 | * into the the layer.
|
||
101 | */
|
||
102 | 10679 | jaume | public abstract void applyAction(); |
103 | 13513 | caballero | |
104 | 12805 | jaume | /**
|
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 | 10679 | jaume | public abstract void setModel(FLayer layer); |
111 | } |