Revision 36411 branches/v2_0_0_prep/applications/appgvSIG/src/org/gvsig/app/project/documents/gui/SymbolCellEditor.java
SymbolCellEditor.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
|
1 |
/* gvSIG. Geographic Information System of the Valencian Government
|
|
2 | 2 |
* |
3 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. |
|
4 |
* |
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
4 |
* of the Valencian Government (CIT) |
|
5 |
* |
|
5 | 6 |
* This program is free software; you can redistribute it and/or |
6 | 7 |
* modify it under the terms of the GNU General Public License |
7 | 8 |
* as published by the Free Software Foundation; either version 2 |
8 | 9 |
* of the License, or (at your option) any later version. |
9 |
* |
|
10 |
*
|
|
10 | 11 |
* This program is distributed in the hope that it will be useful, |
11 | 12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | 13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | 14 |
* GNU General Public License for more details. |
14 |
* |
|
15 |
*
|
|
15 | 16 |
* You should have received a copy of the GNU General Public License |
16 | 17 |
* along with this program; if not, write to the Free Software |
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
18 |
* |
|
19 |
* For more information, contact: |
|
20 |
* |
|
21 |
* Generalitat Valenciana |
|
22 |
* Conselleria d'Infraestructures i Transport |
|
23 |
* Av. Blasco Ib??ez, 50 |
|
24 |
* 46010 VALENCIA |
|
25 |
* SPAIN |
|
26 |
* |
|
27 |
* +34 963862235 |
|
28 |
* gvsig@gva.es |
|
29 |
* www.gvsig.gva.es |
|
30 |
* |
|
31 |
* or |
|
32 |
* |
|
33 |
* IVER T.I. S.A |
|
34 |
* Salamanca 50 |
|
35 |
* 46005 Valencia |
|
36 |
* Spain |
|
37 |
* |
|
38 |
* +34 963163400 |
|
39 |
* dac@iver.es |
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
40 | 21 |
*/ |
41 | 22 |
package org.gvsig.app.project.documents.gui; |
42 | 23 |
|
... | ... | |
58 | 39 |
import org.gvsig.app.project.documents.view.legend.gui.PanelEditSymbol; |
59 | 40 |
import org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol; |
60 | 41 |
|
61 |
|
|
62 |
|
|
63 |
|
|
64 | 42 |
/** |
65 | 43 |
* Cell Editor de ISymbols. Controla los eventos de edici?n que se realicen |
66 | 44 |
* sobre la columna de s?mbolos. |
67 |
* |
|
45 |
*
|
|
68 | 46 |
* @author Vicente Caballero Navarro |
69 | 47 |
*/ |
70 | 48 |
public class SymbolCellEditor extends JButton implements TableCellEditor { |
71 |
private ArrayList listeners = new ArrayList(); |
|
72 |
private ISymbol symbol; |
|
73 |
private int shapeType; |
|
74 |
private PanelEditSymbol symbolPanel; |
|
75 | 49 |
|
76 |
public SymbolCellEditor(int shapeType) { |
|
77 |
this.shapeType = shapeType; |
|
78 |
addMouseListener(new MouseListener(){ |
|
50 |
private static final long serialVersionUID = -913612642474934455L; |
|
51 |
private ArrayList listeners = new ArrayList(); |
|
52 |
private ISymbol symbol; |
|
53 |
private int shapeType; |
|
54 |
private PanelEditSymbol symbolPanel; |
|
79 | 55 |
|
80 |
public void mouseClicked(MouseEvent e) { |
|
81 |
if (e.getClickCount()==2){ |
|
82 |
symbolPanel.setSymbol(symbol); |
|
83 |
// symbolPanel.setShapeType(SymbolCellEditor.this.shapeType); |
|
84 |
symbolPanel.setShapeType(symbol.getSymbolType()); |
|
85 |
PluginServices.getMDIManager().addWindow(symbolPanel); |
|
86 |
if (symbolPanel.isOK()){ |
|
87 |
symbol = (ISymbol) symbolPanel.getSymbol(); |
|
88 |
stopCellEditing(); |
|
89 |
} |
|
90 |
} |
|
91 |
} |
|
56 |
public SymbolCellEditor(int shapeType) { |
|
57 |
this.shapeType = shapeType; |
|
58 |
addMouseListener(new MouseListener() { |
|
92 | 59 |
|
93 |
public void mouseEntered(MouseEvent e) { |
|
94 |
} |
|
60 |
public void mouseClicked(MouseEvent e) { |
|
61 |
if (e.getClickCount() == 2) { |
|
62 |
symbolPanel.setSymbol(symbol); |
|
63 |
// symbolPanel.setShapeType(SymbolCellEditor.this.shapeType); |
|
64 |
symbolPanel.setShapeType(symbol.getSymbolType()); |
|
65 |
PluginServices.getMDIManager().addWindow(symbolPanel); |
|
66 |
if (symbolPanel.isOK()) { |
|
67 |
symbol = (ISymbol) symbolPanel.getSymbol(); |
|
68 |
stopCellEditing(); |
|
69 |
} |
|
70 |
} |
|
71 |
} |
|
95 | 72 |
|
96 |
public void mouseExited(MouseEvent e) {
|
|
97 |
}
|
|
73 |
public void mouseEntered(MouseEvent e) {
|
|
74 |
}
|
|
98 | 75 |
|
99 |
public void mousePressed(MouseEvent e) {
|
|
100 |
}
|
|
76 |
public void mouseExited(MouseEvent e) {
|
|
77 |
}
|
|
101 | 78 |
|
102 |
public void mouseReleased(MouseEvent e) {
|
|
103 |
}
|
|
79 |
public void mousePressed(MouseEvent e) {
|
|
80 |
}
|
|
104 | 81 |
|
105 |
}); |
|
106 |
addKeyListener(new KeyAdapter() { |
|
107 |
public void keyReleased(KeyEvent e) { |
|
108 |
if (e.getKeyCode() == KeyEvent.VK_ENTER) { |
|
109 |
stopCellEditing(); |
|
110 |
} else if (e.getKeyCode() == KeyEvent.VK_ESCAPE) { |
|
111 |
cancelCellEditing(); |
|
112 |
} |
|
113 |
} |
|
114 |
}); |
|
115 |
symbolPanel = new PanelEditSymbol(); |
|
82 |
public void mouseReleased(MouseEvent e) { |
|
83 |
} |
|
116 | 84 |
|
117 |
} |
|
85 |
}); |
|
86 |
addKeyListener(new KeyAdapter() { |
|
118 | 87 |
|
88 |
public void keyReleased(KeyEvent e) { |
|
89 |
if (e.getKeyCode() == KeyEvent.VK_ENTER) { |
|
90 |
stopCellEditing(); |
|
91 |
} else |
|
92 |
if (e.getKeyCode() == KeyEvent.VK_ESCAPE) { |
|
93 |
cancelCellEditing(); |
|
94 |
} |
|
95 |
} |
|
96 |
}); |
|
97 |
symbolPanel = new PanelEditSymbol(); |
|
119 | 98 |
|
120 |
//Implement the one CellEditor method that AbstractCellEditor doesn't. |
|
121 |
public Object getCellEditorValue() { |
|
122 |
return symbol; |
|
123 |
} |
|
99 |
} |
|
124 | 100 |
|
125 |
//Implement the one method defined by TableCellEditor. |
|
126 |
public Component getTableCellEditorComponent(JTable table, Object value, |
|
127 |
boolean isSelected, int row, int column) { |
|
128 |
symbol = (ISymbol) value; |
|
129 |
// setBackground(symbol.getColor()); |
|
101 |
// Implement the one CellEditor method that AbstractCellEditor doesn't. |
|
102 |
public Object getCellEditorValue() { |
|
103 |
return symbol; |
|
104 |
} |
|
130 | 105 |
|
131 |
return this; |
|
132 |
} |
|
106 |
// Implement the one method defined by TableCellEditor. |
|
107 |
public Component getTableCellEditorComponent(JTable table, Object value, |
|
108 |
boolean isSelected, int row, int column) { |
|
109 |
symbol = (ISymbol) value; |
|
110 |
// setBackground(symbol.getColor()); |
|
133 | 111 |
|
134 |
/** |
|
135 |
* DOCUMENT ME! |
|
136 |
*/ |
|
137 |
public void cancelCellEditing() { |
|
138 |
if (symbol != null) { |
|
139 |
// setBackground(symbol.getColor()); |
|
140 |
} |
|
112 |
return this; |
|
113 |
} |
|
141 | 114 |
|
142 |
for (int i = 0; i < listeners.size(); i++) { |
|
143 |
CellEditorListener l = (CellEditorListener) listeners.get(i); |
|
144 |
ChangeEvent evt = new ChangeEvent(this); |
|
145 |
l.editingCanceled(evt); |
|
146 |
} |
|
147 |
} |
|
115 |
/** |
|
116 |
* DOCUMENT ME! |
|
117 |
*/ |
|
118 |
public void cancelCellEditing() { |
|
119 |
if (symbol != null) { |
|
120 |
// setBackground(symbol.getColor()); |
|
121 |
} |
|
148 | 122 |
|
149 |
/** |
|
150 |
* DOCUMENT ME! |
|
151 |
* |
|
152 |
* @return DOCUMENT ME! |
|
153 |
*/ |
|
154 |
public boolean stopCellEditing() { |
|
155 |
for (int i = 0; i < listeners.size(); i++) { |
|
156 |
CellEditorListener l = (CellEditorListener) listeners.get(i); |
|
157 |
ChangeEvent evt = new ChangeEvent(this); |
|
158 |
l.editingStopped(evt); |
|
159 |
} |
|
123 |
for (int i = 0; i < listeners.size(); i++) { |
|
124 |
CellEditorListener l = (CellEditorListener) listeners.get(i); |
|
125 |
ChangeEvent evt = new ChangeEvent(this); |
|
126 |
l.editingCanceled(evt); |
|
127 |
} |
|
128 |
} |
|
160 | 129 |
|
161 |
return true; |
|
162 |
} |
|
130 |
/** |
|
131 |
* DOCUMENT ME! |
|
132 |
* |
|
133 |
* @return DOCUMENT ME! |
|
134 |
*/ |
|
135 |
public boolean stopCellEditing() { |
|
136 |
for (int i = 0; i < listeners.size(); i++) { |
|
137 |
CellEditorListener l = (CellEditorListener) listeners.get(i); |
|
138 |
ChangeEvent evt = new ChangeEvent(this); |
|
139 |
l.editingStopped(evt); |
|
140 |
} |
|
163 | 141 |
|
164 |
/** |
|
165 |
* DOCUMENT ME! |
|
166 |
* |
|
167 |
* @param anEvent DOCUMENT ME! |
|
168 |
* |
|
169 |
* @return DOCUMENT ME! |
|
170 |
*/ |
|
171 |
public boolean isCellEditable(EventObject anEvent) { |
|
172 |
return true; |
|
173 |
} |
|
142 |
return true; |
|
143 |
} |
|
174 | 144 |
|
175 |
/** |
|
176 |
* DOCUMENT ME! |
|
177 |
* |
|
178 |
* @param anEvent DOCUMENT ME! |
|
179 |
* |
|
180 |
* @return DOCUMENT ME! |
|
181 |
*/ |
|
182 |
public boolean shouldSelectCell(EventObject anEvent) { |
|
183 |
return true; |
|
184 |
} |
|
145 |
/** |
|
146 |
* DOCUMENT ME! |
|
147 |
* |
|
148 |
* @param anEvent |
|
149 |
* DOCUMENT ME! |
|
150 |
* |
|
151 |
* @return DOCUMENT ME! |
|
152 |
*/ |
|
153 |
public boolean isCellEditable(EventObject anEvent) { |
|
154 |
return true; |
|
155 |
} |
|
185 | 156 |
|
186 |
/** |
|
187 |
* DOCUMENT ME! |
|
188 |
* |
|
189 |
* @param l DOCUMENT ME! |
|
190 |
*/ |
|
191 |
public void addCellEditorListener(CellEditorListener l) { |
|
192 |
listeners.add(l); |
|
193 |
} |
|
157 |
/** |
|
158 |
* DOCUMENT ME! |
|
159 |
* |
|
160 |
* @param anEvent |
|
161 |
* DOCUMENT ME! |
|
162 |
* |
|
163 |
* @return DOCUMENT ME! |
|
164 |
*/ |
|
165 |
public boolean shouldSelectCell(EventObject anEvent) { |
|
166 |
return true; |
|
167 |
} |
|
194 | 168 |
|
195 |
/** |
|
196 |
* DOCUMENT ME! |
|
197 |
* |
|
198 |
* @param l DOCUMENT ME! |
|
199 |
*/ |
|
200 |
public void removeCellEditorListener(CellEditorListener l) { |
|
201 |
listeners.remove(l); |
|
202 |
} |
|
169 |
/** |
|
170 |
* DOCUMENT ME! |
|
171 |
* |
|
172 |
* @param l |
|
173 |
* DOCUMENT ME! |
|
174 |
*/ |
|
175 |
public void addCellEditorListener(CellEditorListener l) { |
|
176 |
listeners.add(l); |
|
177 |
} |
|
178 |
|
|
179 |
/** |
|
180 |
* DOCUMENT ME! |
|
181 |
* |
|
182 |
* @param l |
|
183 |
* DOCUMENT ME! |
|
184 |
*/ |
|
185 |
public void removeCellEditorListener(CellEditorListener l) { |
|
186 |
listeners.remove(l); |
|
187 |
} |
|
203 | 188 |
} |
Also available in: Unified diff