svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.plugin / org.gvsig.app.document.table.app / org.gvsig.app.document.table.app.mainplugin / src / main / java / org / gvsig / app / extension / SearchByAttributesInTableExtension.java @ 47213
History | View | Annotate | Download (3.22 KB)
1 | 44259 | jjdelcerro | package org.gvsig.app.extension; |
---|---|---|---|
2 | |||
3 | 47212 | jjdelcerro | import java.util.Collections; |
4 | 47213 | jjdelcerro | import java.awt.GridBagConstraints; |
5 | 44474 | jjdelcerro | import org.gvsig.andami.IconThemeHelper; |
6 | 44259 | jjdelcerro | import org.gvsig.andami.plugins.Extension; |
7 | import org.gvsig.app.ApplicationLocator; |
||
8 | import org.gvsig.app.ApplicationManager; |
||
9 | 44262 | jjdelcerro | import org.gvsig.app.project.documents.table.TableDocument; |
10 | import org.gvsig.app.project.documents.table.TableManager; |
||
11 | import org.gvsig.app.project.documents.table.gui.FeatureTableDocumentPanel; |
||
12 | 44259 | jjdelcerro | import org.gvsig.fmap.dal.feature.FeatureStore; |
13 | import org.gvsig.fmap.dal.swing.DALSwingLocator; |
||
14 | import org.gvsig.fmap.dal.swing.DataSwingManager; |
||
15 | import org.gvsig.fmap.dal.swing.searchpanel.FeatureStoreSearchPanel; |
||
16 | 44474 | jjdelcerro | import org.gvsig.tools.ToolsLocator; |
17 | import org.gvsig.tools.i18n.I18nManager; |
||
18 | 44259 | jjdelcerro | import org.gvsig.tools.swing.api.ToolsSwingLocator; |
19 | 47212 | jjdelcerro | import org.gvsig.tools.swing.api.ToolsSwingUtils; |
20 | 44259 | jjdelcerro | import org.gvsig.tools.swing.api.windowmanager.WindowManager; |
21 | 47212 | jjdelcerro | import org.gvsig.tools.swing.api.windowmanager.WindowManager_v2; |
22 | 44259 | jjdelcerro | |
23 | /**
|
||
24 | *
|
||
25 | * @author jjdelcerro
|
||
26 | */
|
||
27 | 44262 | jjdelcerro | public class SearchByAttributesInTableExtension extends Extension { |
28 | 44259 | jjdelcerro | |
29 | @Override
|
||
30 | public void initialize() { |
||
31 | 44474 | jjdelcerro | IconThemeHelper.registerIcon("action", "search-by-attributes-table", this); |
32 | 44259 | jjdelcerro | } |
33 | |||
34 | @Override
|
||
35 | public void execute(String actionCommand) { |
||
36 | ApplicationManager application = ApplicationLocator.getManager(); |
||
37 | |||
38 | 44262 | jjdelcerro | if ("search-by-attributes-table".equals(actionCommand)) { |
39 | 44259 | jjdelcerro | DataSwingManager dataSwingManager = DALSwingLocator.getSwingManager(); |
40 | 47212 | jjdelcerro | WindowManager_v2 winManager = (WindowManager_v2) ToolsSwingLocator.getWindowManager(); |
41 | 44259 | jjdelcerro | |
42 | 44262 | jjdelcerro | TableDocument tabledoc = (TableDocument) application.getActiveDocument(TableManager.TYPENAME); |
43 | if( tabledoc == null ) { |
||
44 | return;
|
||
45 | } |
||
46 | 44474 | jjdelcerro | I18nManager i18n = ToolsLocator.getI18nManager(); |
47 | 44262 | jjdelcerro | final FeatureTableDocumentPanel tablePanel = (FeatureTableDocumentPanel) tabledoc.getMainComponent();
|
48 | final FeatureStore featureStore = tablePanel.getFeatureStore();
|
||
49 | 46793 | jjdelcerro | // String title = i18n.getTranslation("search")+ ": " + featureStore.getName();
|
50 | String title = application.makeTitle("search",tabledoc.getName(), featureStore==null?null:featureStore.getName()); |
||
51 | 47212 | jjdelcerro | |
52 | 44259 | jjdelcerro | FeatureStoreSearchPanel panel = dataSwingManager.createFeatureStoreSearchPanel(featureStore); |
53 | 47212 | jjdelcerro | ToolsSwingUtils.ensureHeightWitdh( |
54 | 47213 | jjdelcerro | panel, |
55 | ToolsSwingUtils.RELATIVE_TO_DESKTOPPANE, |
||
56 | 0.75f, 0.75f, 0.85f, 0.85f |
||
57 | ); |
||
58 | |||
59 | 44259 | jjdelcerro | winManager.showWindow( |
60 | panel.asJComponent(), |
||
61 | title, |
||
62 | 47212 | jjdelcerro | WindowManager.MODE.WINDOW, |
63 | 47213 | jjdelcerro | Collections.singletonMap("align", GridBagConstraints.CENTER) |
64 | 44259 | jjdelcerro | ); |
65 | |||
66 | } |
||
67 | } |
||
68 | |||
69 | @Override
|
||
70 | public boolean isEnabled() { |
||
71 | return true; |
||
72 | } |
||
73 | |||
74 | @Override
|
||
75 | public boolean isVisible() { |
||
76 | ApplicationManager application = ApplicationLocator.getManager(); |
||
77 | |||
78 | 44262 | jjdelcerro | TableDocument tabledoc = (TableDocument) application.getActiveDocument(TableManager.TYPENAME); |
79 | if( tabledoc == null ) { |
||
80 | 44259 | jjdelcerro | return false; |
81 | } |
||
82 | 44262 | jjdelcerro | return true; |
83 | 44259 | jjdelcerro | } |
84 | } |