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