root / branches / v2_0_0_prep / applications / appgvSIG / src / org / gvsig / app / extension / TableFieldOperations.java @ 33205
History | View | Annotate | Download (2.59 KB)
1 |
package org.gvsig.app.extension; |
---|---|
2 |
|
3 |
import org.gvsig.andami.PluginServices; |
4 |
import org.gvsig.andami.plugins.Extension; |
5 |
import org.gvsig.andami.ui.mdiManager.IWindow; |
6 |
import org.gvsig.app.project.documents.table.gui.FeatureTableDocumentPanel; |
7 |
import org.gvsig.fmap.dal.exception.DataException; |
8 |
import org.gvsig.fmap.mapcontrol.dal.feature.swing.table.ConfigurableFeatureTableModel; |
9 |
import org.gvsig.tools.exception.BaseException; |
10 |
|
11 |
/**
|
12 |
* Ascending or descending order operations.
|
13 |
*
|
14 |
* @author Vicente Caballero Navarro
|
15 |
*/
|
16 |
public class TableFieldOperations extends Extension{ |
17 |
private FeatureTableDocumentPanel table=null; |
18 |
/**
|
19 |
* @see org.gvsig.andami.plugins.IExtension#initialize()
|
20 |
*/
|
21 |
public void initialize() { |
22 |
registerIcons(); |
23 |
} |
24 |
|
25 |
private void registerIcons(){ |
26 |
PluginServices.getIconTheme().registerDefault( |
27 |
"table-order-asc",
|
28 |
this.getClass().getClassLoader().getResource("images/orderasc.png") |
29 |
); |
30 |
|
31 |
PluginServices.getIconTheme().registerDefault( |
32 |
"table-order-desc",
|
33 |
this.getClass().getClassLoader().getResource("images/orderdesc.png") |
34 |
); |
35 |
} |
36 |
|
37 |
/**
|
38 |
* @see org.gvsig.andami.plugins.IExtension#execute(java.lang.String)
|
39 |
*/
|
40 |
public void execute(String actionCommand) { |
41 |
doExecute(actionCommand,table); |
42 |
table.getModel().setModified(true);
|
43 |
} |
44 |
|
45 |
/**
|
46 |
* "execute" method acction
|
47 |
* @param actionCommand
|
48 |
* The acction command that executes this method
|
49 |
* @param table
|
50 |
* Table to operate
|
51 |
*/
|
52 |
protected void doExecute(String actionCommand,FeatureTableDocumentPanel table){ |
53 |
// FIXME
|
54 |
ConfigurableFeatureTableModel cftm=table.getTablePanel().getTableModel(); |
55 |
try {
|
56 |
if ("ORDERASC".equals(actionCommand)){ |
57 |
cftm.orderByColumn(table.getTablePanel().getTable().getSelectedColumnsAttributeDescriptor()[0].getName(), true); |
58 |
}else if ("ORDERDESC".equals(actionCommand)){ |
59 |
cftm.orderByColumn(table.getTablePanel().getTable().getSelectedColumnsAttributeDescriptor()[0].getName(), false); |
60 |
} |
61 |
} catch (BaseException e) {
|
62 |
e.printStackTrace(); |
63 |
} |
64 |
} |
65 |
|
66 |
/**
|
67 |
* @see org.gvsig.andami.plugins.IExtension#isEnabled()
|
68 |
*/
|
69 |
public boolean isEnabled() { |
70 |
try {
|
71 |
return (table.getTablePanel().getTable().getSelectedColumnCount()==1); |
72 |
} catch (DataException e) {
|
73 |
e.printStackTrace(); |
74 |
} |
75 |
return false; |
76 |
} |
77 |
|
78 |
/**
|
79 |
* @see org.gvsig.andami.plugins.IExtension#isVisible()
|
80 |
*/
|
81 |
public boolean isVisible() { |
82 |
IWindow v = PluginServices.getMDIManager().getActiveWindow(); |
83 |
if (v!=null && v instanceof FeatureTableDocumentPanel) { |
84 |
table=(FeatureTableDocumentPanel)v; |
85 |
return true; |
86 |
} |
87 |
return false; |
88 |
} |
89 |
|
90 |
} |