Revision 44705 trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.fmap.control/src/main/java/org/gvsig/fmap/mapcontrol/dal/feature/swing/FeatureTable.java
FeatureTable.java | ||
---|---|---|
223 | 223 |
* Initializes the table GUI. |
224 | 224 |
*/ |
225 | 225 |
private void init() throws DataException { |
226 |
setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
|
|
226 |
setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
|
|
227 | 227 |
|
228 |
featureTableModel.getFeatureStore().addObserver(this);
|
|
229 |
// Change the selection model to link with the FeatureStore selection
|
|
230 |
// through the FeatureTableModel
|
|
231 |
setRowSelectionAllowed(true);
|
|
232 |
setColumnSelectionAllowed(false);
|
|
233 |
setSelectionModel(new FeatureSelectionModel(featureTableModel));
|
|
228 |
featureTableModel.getFeatureStore().addObserver(this); |
|
229 |
// Change the selection model to link with the FeatureStore selection |
|
230 |
// through the FeatureTableModel |
|
231 |
setRowSelectionAllowed(true); |
|
232 |
setColumnSelectionAllowed(false); |
|
233 |
setSelectionModel(new FeatureSelectionModel(featureTableModel));
|
|
234 | 234 |
|
235 |
headerCellRenderer = new JToggleButtonHeaderCellRenderer(this);
|
|
236 |
getTableHeader().setDefaultRenderer(headerCellRenderer);
|
|
235 |
headerCellRenderer = new JToggleButtonHeaderCellRenderer(this);
|
|
236 |
getTableHeader().setDefaultRenderer(headerCellRenderer);
|
|
237 | 237 |
|
238 |
TableColumnModel tcmodel = getColumnModel(); |
|
239 |
for (int i = 0; i < tcmodel.getColumnCount(); i++) { |
|
240 |
TableColumn col = tcmodel.getColumn(i); |
|
241 |
// Get width of column header |
|
242 |
TableCellRenderer renderer = col.getHeaderRenderer(); |
|
243 |
if (renderer == null) { |
|
244 |
renderer = getTableHeader().getDefaultRenderer(); |
|
245 |
} |
|
246 |
Component comp = |
|
247 |
renderer.getTableCellRendererComponent(this, |
|
248 |
col.getHeaderValue(), false, false, 0, i); |
|
249 |
int width = comp.getPreferredSize().width; |
|
250 |
width = |
|
251 |
width < COLUMN_HEADER_MIN_WIDTH ? COLUMN_HEADER_MIN_WIDTH |
|
252 |
: width; |
|
253 |
col.setPreferredWidth(width + 2 * COLUMN_HEADER_MARGIN); |
|
254 |
} |
|
238 |
TableColumnModel tcmodel = getColumnModel(); |
|
239 |
for (int i = 0; i < tcmodel.getColumnCount(); i++) { |
|
240 |
TableColumn col = tcmodel.getColumn(i); |
|
241 |
// Get width of column header |
|
242 |
TableCellRenderer renderer = col.getHeaderRenderer(); |
|
243 |
if (renderer == null) { |
|
244 |
renderer = getTableHeader().getDefaultRenderer(); |
|
245 |
} |
|
246 |
Component comp |
|
247 |
= renderer.getTableCellRendererComponent(this, |
|
248 |
col.getHeaderValue(), false, false, 0, i); |
|
249 |
int width = comp.getPreferredSize().width; |
|
250 |
width |
|
251 |
= width < COLUMN_HEADER_MIN_WIDTH ? COLUMN_HEADER_MIN_WIDTH |
|
252 |
: width; |
|
253 |
col.setPreferredWidth(width + 2 * COLUMN_HEADER_MARGIN); |
|
254 |
} |
|
255 |
try { |
|
256 |
if( !this.featureTableModel.getFeatureStore().getFeatureSelection().isAvailable() ) { |
|
257 |
this.setSelectionBackground(Color.PINK); |
|
258 |
} |
|
259 |
} catch(Exception ex) { |
|
260 |
logger.warn("Can't check if selecction is available.", ex); |
|
261 |
} |
|
255 | 262 |
} |
256 | 263 |
|
257 | 264 |
/** |
Also available in: Unified diff