Revision 12154 trunk/extensions/extRasterTools-SE/src/org/gvsig/rastertools/properties/dialog/RegistrableTabPanel.java
RegistrableTabPanel.java | ||
---|---|---|
18 | 18 |
*/ |
19 | 19 |
package org.gvsig.rastertools.properties.dialog; |
20 | 20 |
|
21 |
import java.util.Hashtable; |
|
21 | 22 |
import java.util.Iterator; |
22 | 23 |
|
23 | 24 |
import javax.swing.JPanel; |
... | ... | |
27 | 28 |
import com.iver.utiles.extensionPoints.ExtensionPoint; |
28 | 29 |
import com.iver.utiles.extensionPoints.ExtensionPoints; |
29 | 30 |
import com.iver.utiles.extensionPoints.ExtensionPointsSingleton; |
30 |
|
|
31 |
|
|
32 | 31 |
/** |
33 | 32 |
* Panel que contiene todos los paneles de los tabs del cuadro de dialogo |
34 | 33 |
* de bandas y transparencias |
35 | 34 |
* |
36 | 35 |
* @author Nacho Brodin (brodin_ign@gva.es) |
37 | 36 |
*/ |
38 |
public class RegistrableTabPanel extends DefaultTabPanel implements ChangeListener{ |
|
39 |
final private static long serialVersionUID = 0;
|
|
37 |
public class RegistrableTabPanel extends DefaultTabPanel implements ChangeListener {
|
|
38 |
final private static long serialVersionUID = 0;
|
|
40 | 39 |
|
41 |
private ExtensionPoints extensionPoints = null; |
|
42 |
private ExtensionPoint extensionPoint = null; |
|
43 |
/** |
|
44 |
* Tama?o en X del panel |
|
45 |
*/ |
|
46 |
protected int sizePanelX = 0; |
|
47 |
/** |
|
48 |
* Tama?o en Y del panel |
|
49 |
*/ |
|
50 |
protected int sizePanelY = 0; |
|
51 |
|
|
52 |
/** |
|
53 |
* Constructor. Inicializa los paneles y propiedades |
|
54 |
* @param props Propiedades |
|
55 |
*/ |
|
56 |
public RegistrableTabPanel(int sizex, int sizey) { |
|
57 |
super(sizex, sizey); |
|
40 |
private ExtensionPoints extensionPoints = null; |
|
41 |
private ExtensionPoint extensionPoint = null; |
|
42 |
|
|
43 |
static public Hashtable initialProperties = new Hashtable(); |
|
44 |
/** |
|
45 |
* Tama?o en X del panel |
|
46 |
*/ |
|
47 |
protected int sizePanelX = 0; |
|
48 |
|
|
49 |
/** |
|
50 |
* Tama?o en Y del panel |
|
51 |
*/ |
|
52 |
protected int sizePanelY = 0; |
|
53 |
|
|
54 |
/** |
|
55 |
* Constructor. Inicializa los paneles y propiedades |
|
56 |
* @param props Propiedades |
|
57 |
*/ |
|
58 |
public RegistrableTabPanel() { |
|
58 | 59 |
this.loadTabsFromExtensionPoints(); |
59 |
getTabPane().addChangeListener(this);
|
|
60 |
}
|
|
61 |
|
|
62 |
/**
|
|
63 |
* Load register tabs inside the panel, reading these from extension points.
|
|
64 |
*/
|
|
65 |
private void loadTabsFromExtensionPoints(){
|
|
66 |
extensionPoints = ExtensionPointsSingleton.getInstance();
|
|
67 |
extensionPoint = (ExtensionPoint)extensionPoints.get("RasterSEPropertiesDialog"); |
|
68 |
if(extensionPoint == null) |
|
60 |
getTabPane().addChangeListener(this);
|
|
61 |
}
|
|
62 |
|
|
63 |
/**
|
|
64 |
* Load register tabs inside the panel, reading these from extension points.
|
|
65 |
*/
|
|
66 |
private void loadTabsFromExtensionPoints() {
|
|
67 |
extensionPoints = ExtensionPointsSingleton.getInstance();
|
|
68 |
extensionPoint = (ExtensionPoint) extensionPoints.get("RasterSEPropertiesDialog");
|
|
69 |
if (extensionPoint == null)
|
|
69 | 70 |
return; |
70 | 71 |
Iterator iterator = extensionPoint.keySet().iterator(); |
71 | 72 |
while (iterator.hasNext()) { |
72 | 73 |
try { |
73 |
String key = (String)iterator.next(); |
|
74 |
JPanel panel = (JPanel)extensionPoint.get(key); |
|
74 |
String key = (String) iterator.next();
|
|
75 |
JPanel panel = (JPanel) extensionPoint.get(key);
|
|
75 | 76 |
super.addTab(key, panel); |
76 | 77 |
} catch (ClassCastException e) { |
77 |
//No se a?ade el panel y se sigue con el siguiente |
|
78 |
// No se a?ade el panel y se sigue con el siguiente
|
|
78 | 79 |
continue; |
79 | 80 |
} |
80 | 81 |
} |
81 |
}
|
|
82 |
}
|
|
82 | 83 |
|
83 |
/**
|
|
84 |
* Obtiene el indice del tab seleccionado
|
|
85 |
* @return N?mero de tab seleccionado
|
|
86 |
*/
|
|
87 |
public int getSelectedTab(){
|
|
88 |
return super.getTab().getSelectedIndex();
|
|
89 |
}
|
|
90 |
|
|
91 |
/**
|
|
92 |
* Ejecuta la acci?n de aceptar en el panel seleccionado
|
|
93 |
*/
|
|
94 |
public void acceptSelectedTab(){
|
|
95 |
execAction(0);
|
|
96 |
}
|
|
97 |
|
|
98 |
/**
|
|
99 |
* Ejecuta la acci?n de aplicar en el panel seleccionado
|
|
100 |
*/
|
|
101 |
public void applySelectedTab(){
|
|
102 |
execAction(1);
|
|
103 |
}
|
|
104 |
|
|
105 |
/**
|
|
106 |
* Ejecuta la acci?n de cancelar en el panel seleccionado
|
|
107 |
*/
|
|
108 |
public void cancelSelectedTab(){
|
|
109 |
execAction(2);
|
|
110 |
}
|
|
111 |
|
|
112 |
/**
|
|
113 |
* Ejecuta la acci?n en el panel seleccionado que se le indica en el
|
|
114 |
* par?metro
|
|
115 |
* @param action indicador de la acci?n a realizar
|
|
116 |
*/
|
|
117 |
private void execAction(int action){
|
|
118 |
if(extensionPoint == null)
|
|
84 |
/**
|
|
85 |
* Obtiene el indice del tab seleccionado
|
|
86 |
* @return N?mero de tab seleccionado
|
|
87 |
*/
|
|
88 |
public int getSelectedTab() {
|
|
89 |
return super.getTab().getSelectedIndex();
|
|
90 |
}
|
|
91 |
|
|
92 |
/**
|
|
93 |
* Ejecuta la acci?n de aceptar en el panel seleccionado
|
|
94 |
*/
|
|
95 |
public void acceptSelectedTab() {
|
|
96 |
execAction(0);
|
|
97 |
}
|
|
98 |
|
|
99 |
/**
|
|
100 |
* Ejecuta la acci?n de aplicar en el panel seleccionado
|
|
101 |
*/
|
|
102 |
public void applySelectedTab() {
|
|
103 |
execAction(1);
|
|
104 |
}
|
|
105 |
|
|
106 |
/**
|
|
107 |
* Ejecuta la acci?n de cancelar en el panel seleccionado
|
|
108 |
*/
|
|
109 |
public void cancelSelectedTab() {
|
|
110 |
execAction(2);
|
|
111 |
}
|
|
112 |
|
|
113 |
/**
|
|
114 |
* Ejecuta la acci?n en el panel seleccionado que se le indica en el
|
|
115 |
* par?metro
|
|
116 |
* @param action indicador de la acci?n a realizar
|
|
117 |
*/
|
|
118 |
private void execAction(int action) {
|
|
119 |
if (extensionPoint == null)
|
|
119 | 120 |
return; |
120 |
if(getTab().getSelectedIndex() == -1)
|
|
121 |
return;
|
|
122 |
String title = getTab().getTitleAt(getTab().getSelectedIndex());
|
|
123 |
|
|
124 |
Iterator iterator = extensionPoint.keySet().iterator();
|
|
121 |
if (getTab().getSelectedIndex() == -1)
|
|
122 |
return;
|
|
123 |
String title = getTab().getTitleAt(getTab().getSelectedIndex());
|
|
124 |
|
|
125 |
Iterator iterator = extensionPoint.keySet().iterator();
|
|
125 | 126 |
while (iterator.hasNext()) { |
126 | 127 |
try { |
127 |
String key = (String)iterator.next(); |
|
128 |
if(key.equals(title)){ |
|
129 |
IRegistrablePanel panel = (IRegistrablePanel)extensionPoint.get(key); |
|
130 |
switch(action){ |
|
131 |
case 0: panel.accept(); break; |
|
132 |
case 1: panel.apply(); break; |
|
133 |
case 2: panel.cancel(); break; |
|
128 |
String key = (String) iterator.next(); |
|
129 |
IRegistrablePanel panel = (IRegistrablePanel) extensionPoint.get(key); |
|
130 |
if (key.equals(title)) { |
|
131 |
switch (action) { |
|
132 |
case 0: |
|
133 |
panel.accept(); |
|
134 |
break; |
|
135 |
case 1: |
|
136 |
panel.apply(); |
|
137 |
break; |
|
134 | 138 |
} |
135 | 139 |
} |
140 |
if (action == 2) |
|
141 |
panel.cancel(); |
|
136 | 142 |
} catch (ClassCastException e) { |
137 |
//No se ejecuta |
|
143 |
// No se ejecuta
|
|
138 | 144 |
continue; |
139 | 145 |
} |
140 | 146 |
} |
141 |
} |
|
142 |
|
|
143 |
/** |
|
144 |
* Asigna la visibilidad de un tab a verdadero o falso. La |
|
145 |
* selecci?n del tab se hace por el identificador. |
|
146 |
* @param tab Identificador del tab. Variable nom del mismo |
|
147 |
* @param active True o false para visible o invisible. |
|
148 |
*/ |
|
149 |
public void setTabVisible(String tab, boolean active){ |
|
150 |
|
|
151 |
} |
|
152 |
|
|
153 |
/** |
|
154 |
* Selecciona el panel indicado por index |
|
155 |
* @param index panel seleccionado |
|
156 |
*/ |
|
157 |
public void setSelectedIndex(int index) { |
|
158 |
tabbedPane.setSelectedIndex(index); |
|
159 |
} |
|
147 |
} |
|
160 | 148 |
|
161 |
/** |
|
162 |
* Propagamos el evento de cambiar de pesta?a a todos los paneles. |
|
163 |
*/ |
|
149 |
/** |
|
150 |
* Asigna la visibilidad de un tab a verdadero o falso. La |
|
151 |
* selecci?n del tab se hace por el identificador. |
|
152 |
* @param tab Identificador del tab. Variable nom del mismo |
|
153 |
* @param active True o false para visible o invisible. |
|
154 |
*/ |
|
155 |
public void setTabVisible(String tab, boolean active){ |
|
156 |
|
|
157 |
} |
|
158 |
|
|
159 |
/** |
|
160 |
* Selecciona el panel indicado por index |
|
161 |
* @param index panel seleccionado |
|
162 |
*/ |
|
163 |
public void setSelectedIndex(int index) { |
|
164 |
tabbedPane.setSelectedIndex(index); |
|
165 |
} |
|
166 |
|
|
167 |
/** |
|
168 |
* Propagamos el evento de cambiar de pesta?a a todos los paneles. |
|
169 |
*/ |
|
164 | 170 |
public void stateChanged(ChangeEvent e) { |
165 |
if(extensionPoint == null)
|
|
171 |
if(extensionPoint == null)
|
|
166 | 172 |
return; |
167 |
if(getTab().getSelectedIndex() == -1)
|
|
168 |
return;
|
|
169 |
String title = getTab().getTitleAt(getTab().getSelectedIndex());
|
|
170 |
|
|
171 |
Iterator iterator = extensionPoint.keySet().iterator();
|
|
173 |
if(getTab().getSelectedIndex() == -1)
|
|
174 |
return;
|
|
175 |
String title = getTab().getTitleAt(getTab().getSelectedIndex());
|
|
176 |
|
|
177 |
Iterator iterator = extensionPoint.keySet().iterator();
|
|
172 | 178 |
while (iterator.hasNext()) { |
173 | 179 |
try { |
174 | 180 |
String key = (String)iterator.next(); |
... | ... | |
182 | 188 |
} |
183 | 189 |
} |
184 | 190 |
} |
185 |
|
|
186 |
} |
|
191 |
} |
Also available in: Unified diff