Revision 44011
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app.document.table.app/org.gvsig.app.document.table.app.mainplugin/src/main/resources-plugin/i18n/text.properties | ||
---|---|---|
54 | 54 |
locale=Idioma |
55 | 55 |
locale_XcolonX=Idioma\: |
56 | 56 |
_Select_by_attributes=Selecci\u00f3n por atributos |
57 |
_Select_by_attributes_old=Selecci\u00f3n por atributos (antig\u00fco) |
|
57 | 58 |
_Column_information_XcolonX=Informaci\u00f3n de columna\: |
58 | 59 |
_Select_table_duplicates=Seleccionar duplicados tabla |
59 | 60 |
_Select_all_duplicates=Seleccionar todos los duplicados |
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app.document.table.app/org.gvsig.app.document.table.app.mainplugin/src/main/resources-plugin/i18n/text_en.properties | ||
---|---|---|
54 | 54 |
locale=Locale |
55 | 55 |
locale_XcolonX=Locale\: |
56 | 56 |
_Select_by_attributes=Select by attributes |
57 |
_Select_by_attributes_old=Select by attributes (old) |
|
57 | 58 |
_Column_information_XcolonX=Column information\: |
58 | 59 |
_Select_table_duplicates=Select table duplicates |
59 | 60 |
_Select_all_duplicates=Select all duplicates |
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app.document.table.app/org.gvsig.app.document.table.app.mainplugin/src/main/resources-plugin/config.xml | ||
---|---|---|
694 | 694 |
accelerator="" |
695 | 695 |
/> |
696 | 696 |
<action |
697 |
name="selection2-by-attributes-table"
|
|
698 |
label="_Select_by_attributes" |
|
697 |
name="selection-by-attributes-table-old"
|
|
698 |
label="_Select_by_attributes_old"
|
|
699 | 699 |
tooltip="_Select_by_attributes" |
700 | 700 |
position="300400001" |
701 |
action-command="selection2-by-attributes-table"
|
|
701 |
action-command="selection-by-attributes-table-old"
|
|
702 | 702 |
icon="selection-by-attributes" |
703 | 703 |
accelerator="" |
704 | 704 |
/> |
705 | 705 |
<menu |
706 |
name="selection-by-attributes-table-old" |
|
707 |
text="Selection/_Select_by_attributes_old" |
|
708 |
/> |
|
709 |
<menu |
|
706 | 710 |
name="selection-by-attributes-table" |
707 | 711 |
text="Selection/_Select_by_attributes" |
708 | 712 |
/> |
709 |
<menu |
|
710 |
name="selection2-by-attributes-table" |
|
711 |
text="Selection/_Select_by_attributes_new" |
|
712 |
/> |
|
713 | 713 |
|
714 | 714 |
<tool-bar name="table"> |
715 | 715 |
<action-tool |
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/SelectByAttributesInTableExtension.java | ||
---|---|---|
23 | 23 |
*/ |
24 | 24 |
package org.gvsig.app.extension; |
25 | 25 |
|
26 |
import java.awt.event.ActionEvent; |
|
27 |
import java.awt.event.ActionListener; |
|
28 |
import java.util.Iterator; |
|
29 | 26 |
|
30 | 27 |
import javax.swing.JOptionPane; |
31 | 28 |
|
... | ... | |
38 | 35 |
import org.gvsig.app.gui.filter.ExpressionListener; |
39 | 36 |
import org.gvsig.app.gui.filter.FilterDialog; |
40 | 37 |
import org.gvsig.app.project.documents.table.gui.FeatureTableDocumentPanel; |
41 |
import org.gvsig.expressionevaluator.ExpressionEvaluatorLocator; |
|
42 |
import org.gvsig.expressionevaluator.ExpressionEvaluatorManager; |
|
43 |
import org.gvsig.expressionevaluator.swing.Element; |
|
44 |
import org.gvsig.expressionevaluator.swing.ExpressionEvaluatorSwingLocator; |
|
45 |
import org.gvsig.expressionevaluator.swing.ExpressionEvaluatorSwingManager; |
|
46 |
import org.gvsig.expressionevaluator.swing.JExpressionBuilder; |
|
47 | 38 |
import org.gvsig.fmap.dal.DALLocator; |
48 | 39 |
import org.gvsig.fmap.dal.DataManager; |
49 | 40 |
import org.gvsig.fmap.dal.exception.DataException; |
... | ... | |
54 | 45 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
55 | 46 |
import org.gvsig.i18n.Messages; |
56 | 47 |
import org.gvsig.tools.dispose.DisposeUtils; |
57 |
import org.gvsig.tools.swing.api.ToolsSwingLocator; |
|
58 |
import org.gvsig.tools.swing.api.windowmanager.Dialog; |
|
59 | 48 |
import org.gvsig.tools.swing.api.windowmanager.WindowManager; |
60 |
import org.gvsig.tools.swing.api.windowmanager.WindowManager_v2; |
|
61 | 49 |
import org.gvsig.utils.exceptionHandling.ExceptionListener; |
62 | 50 |
|
63 | 51 |
/** |
... | ... | |
65 | 53 |
* |
66 | 54 |
* @author Vicente Caballero Navarro |
67 | 55 |
*/ |
56 |
@SuppressWarnings("UseSpecificCatch") |
|
68 | 57 |
public class SelectByAttributesInTableExtension extends Extension implements ExpressionListener { |
69 | 58 |
|
70 | 59 |
protected FeatureStore featureStore = null; |
71 | 60 |
protected FeatureTableDocumentPanel table; |
72 | 61 |
private String filterTitle; |
73 | 62 |
|
63 |
@Override |
|
74 | 64 |
public void initialize() { |
75 | 65 |
registerIcons(); |
76 | 66 |
} |
... | ... | |
79 | 69 |
IconThemeHelper.registerIcon("action", "selection-by-attributes", this); |
80 | 70 |
} |
81 | 71 |
|
72 |
@Override |
|
82 | 73 |
public void execute(String actionCommand) { |
83 | 74 |
IWindow v = PluginServices.getMDIManager().getActiveWindow(); |
84 | 75 |
|
85 | 76 |
if (!(v instanceof FeatureTableDocumentPanel)) { |
86 | 77 |
return; |
87 | 78 |
} |
88 |
if ("selection-by-attributes-table2".equals(actionCommand)) {
|
|
79 |
if ("selection-by-attributes-table".equals(actionCommand)) { |
|
89 | 80 |
table = (FeatureTableDocumentPanel) v; |
90 | 81 |
|
91 | 82 |
featureStore = table.getModel().getStore(); |
92 | 83 |
filterTitle = table.getModel().getName(); |
93 | 84 |
table.getModel().setModified(true); |
94 |
|
|
95 |
doSelectByAttributes2(filterTitle, featureStore);
|
|
85 |
SelectByAttributes selector = new SelectByAttributes(); |
|
86 |
selector.showWindow(filterTitle, featureStore, WindowManager.MODE.TOOL);
|
|
96 | 87 |
|
97 |
} else if ("selection-by-attributes-table".equals(actionCommand)) { |
|
88 |
} else if ("selection-by-attributes-table-old".equals(actionCommand)) {
|
|
98 | 89 |
table = (FeatureTableDocumentPanel) v; |
99 | 90 |
|
100 | 91 |
featureStore = table.getModel().getStore(); |
... | ... | |
110 | 101 |
dlg.addExpressionListener(this); |
111 | 102 |
dlg.addExceptionListener(new ExceptionListener() { |
112 | 103 |
|
104 |
@Override |
|
113 | 105 |
public void exceptionThrown(Throwable t) { |
114 | 106 |
NotificationManager.addError(t.getMessage(), t); |
115 | 107 |
} |
... | ... | |
118 | 110 |
PluginServices.getMDIManager().addWindow(dlg); |
119 | 111 |
} |
120 | 112 |
|
113 |
@Override |
|
121 | 114 |
public boolean isEnabled() { |
122 | 115 |
return isVisible(); |
123 | 116 |
} |
124 | 117 |
|
118 |
@Override |
|
125 | 119 |
public boolean isVisible() { |
126 | 120 |
IWindow v = PluginServices.getMDIManager().getActiveWindow(); |
127 | 121 |
return (v instanceof FeatureTableDocumentPanel); |
128 | 122 |
} |
129 | 123 |
|
130 | 124 |
// if no filter expression -> no element selected |
125 |
@Override |
|
131 | 126 |
public void newSet(String expression) throws DataException { |
132 | 127 |
if (!this.filterExpressionFromWhereIsEmpty(expression)) { |
133 | 128 |
FeatureSet set = null; |
... | ... | |
199 | 194 |
} |
200 | 195 |
FeatureSelection oldSelection = featureStore.getFeatureSelection(); |
201 | 196 |
FeatureSelection newSelection = featureStore.createFeatureSelection(); |
202 |
Iterator iterator = set.iterator(); |
|
203 |
while (iterator.hasNext()) { |
|
204 |
Feature feature = (Feature) iterator.next(); |
|
197 |
for (Feature feature : set) { |
|
205 | 198 |
if (oldSelection.isSelected(feature)) { |
206 | 199 |
newSelection.select(feature); |
207 | 200 |
} |
... | ... | |
279 | 272 |
} |
280 | 273 |
return p.getMessage(); |
281 | 274 |
} |
282 |
|
|
283 |
private void doSelectByAttributes2(String title, final FeatureStore store) { |
|
284 |
WindowManager_v2 windowManager = (WindowManager_v2) ToolsSwingLocator.getWindowManager(); |
|
285 |
ExpressionEvaluatorManager manager = ExpressionEvaluatorLocator.getManager(); |
|
286 |
ExpressionEvaluatorSwingManager swingManager = ExpressionEvaluatorSwingLocator.getManager(); |
|
287 |
|
|
288 |
final JExpressionBuilder panel = swingManager.createJExpressionBuilder(); |
|
289 |
Element element = swingManager.createElement("DAL.FeatureStoreElement", panel, store); |
|
290 |
if (element != null) { |
|
291 |
panel.getElements().add(element); |
|
292 |
} |
|
293 |
final Dialog dialog = windowManager.createDialog( |
|
294 |
panel.asJComponent(), |
|
295 |
title, |
|
296 |
null, |
|
297 |
WindowManager_v2.BUTTONS_OK_CANCEL |
|
298 |
); |
|
299 |
dialog.addActionListener(new ActionListener() { |
|
300 |
@Override |
|
301 |
public void actionPerformed(ActionEvent e) { |
|
302 |
if (dialog.getAction() == WindowManager_v2.BUTTON_OK) { |
|
303 |
try { |
|
304 |
DataManager manager = DALLocator.getDataManager(); |
|
305 |
|
|
306 |
FeatureQuery query = store.createFeatureQuery(); |
|
307 |
query.setFilter(manager.createExpresion(panel.getExpression())); |
|
308 |
FeatureSet selection = store.getFeatureSet(query); |
|
309 |
store.getFeatureSelection().select(selection); |
|
310 |
} catch (Exception ex) { |
|
311 |
logger.warn("Can't build selecction from filter expression.", ex); |
|
312 |
} |
|
313 |
} |
|
314 |
} |
|
315 |
}); |
|
316 |
dialog.show(WindowManager.MODE.WINDOW); |
|
317 |
|
|
318 |
} |
|
319 | 275 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app/org.gvsig.app.mainplugin/src/main/java/org/gvsig/app/project/documents/view/expressionevaluator/ViewElement.java | ||
---|---|---|
7 | 7 |
import org.gvsig.expressionevaluator.swing.Element; |
8 | 8 |
import org.gvsig.expressionevaluator.swing.Element.GroupElement; |
9 | 9 |
import org.gvsig.expressionevaluator.swing.spi.AbstractElement; |
10 |
import org.gvsig.tools.ToolsLocator; |
|
10 | 11 |
|
11 | 12 |
/** |
12 | 13 |
* |
... | ... | |
20 | 21 |
private final List<Element> childs; |
21 | 22 |
|
22 | 23 |
public ViewElement() { |
23 |
super("View", null, "expressionbuilder-element-view");
|
|
24 |
super(ToolsLocator.getI18nManager().getTranslation("View"), null, "expressionbuilder-element-view");
|
|
24 | 25 |
this.childs = new ArrayList<>(); |
25 | 26 |
this.childs.add(new ViewCaptureRectangleElement()); |
26 | 27 |
this.childs.add(new ViewCapturePointElement()); |
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app/org.gvsig.app.mainplugin/src/main/java/org/gvsig/app/project/documents/view/expressionevaluator/ViewElementFactory.java | ||
---|---|---|
1 | 1 |
package org.gvsig.app.project.documents.view.expressionevaluator; |
2 | 2 |
|
3 |
import java.net.URL; |
|
4 | 3 |
import org.gvsig.andami.IconThemeHelper; |
5 | 4 |
import org.gvsig.expressionevaluator.swing.Element; |
6 | 5 |
import org.gvsig.expressionevaluator.swing.ExpressionEvaluatorSwingLocator; |
7 | 6 |
import org.gvsig.expressionevaluator.swing.ExpressionEvaluatorSwingManager; |
8 | 7 |
import org.gvsig.expressionevaluator.swing.spi.AbstractElementFactory; |
9 |
import org.gvsig.tools.swing.api.ToolsSwingLocator; |
|
10 |
import org.gvsig.tools.swing.icontheme.IconTheme; |
|
11 | 8 |
|
12 | 9 |
/** |
13 | 10 |
* |
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app/org.gvsig.app.mainplugin/src/main/java/org/gvsig/app/extension/SelectByAttributes.java | ||
---|---|---|
1 |
package org.gvsig.app.extension; |
|
2 |
|
|
3 |
import java.awt.BorderLayout; |
|
4 |
import java.awt.FlowLayout; |
|
5 |
import java.awt.event.ActionEvent; |
|
6 |
import javax.swing.AbstractAction; |
|
7 |
import javax.swing.JButton; |
|
8 |
import javax.swing.JPanel; |
|
9 |
import org.gvsig.expressionevaluator.Expression; |
|
10 |
import org.gvsig.expressionevaluator.swing.Element; |
|
11 |
import org.gvsig.expressionevaluator.swing.ExpressionEvaluatorSwingLocator; |
|
12 |
import org.gvsig.expressionevaluator.swing.ExpressionEvaluatorSwingManager; |
|
13 |
import org.gvsig.expressionevaluator.swing.JExpressionBuilder; |
|
14 |
import org.gvsig.fmap.dal.DALLocator; |
|
15 |
import org.gvsig.fmap.dal.DataManager; |
|
16 |
import org.gvsig.fmap.dal.feature.Feature; |
|
17 |
import org.gvsig.fmap.dal.feature.FeatureQuery; |
|
18 |
import org.gvsig.fmap.dal.feature.FeatureSelection; |
|
19 |
import org.gvsig.fmap.dal.feature.FeatureSet; |
|
20 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
|
21 |
import org.gvsig.fmap.dal.swing.DataSwingManager; |
|
22 |
import org.gvsig.tools.ToolsLocator; |
|
23 |
import org.gvsig.tools.i18n.I18nManager; |
|
24 |
import org.gvsig.tools.swing.api.ToolsSwingLocator; |
|
25 |
import org.gvsig.tools.swing.api.windowmanager.WindowManager; |
|
26 |
import org.slf4j.Logger; |
|
27 |
import org.slf4j.LoggerFactory; |
|
28 |
|
|
29 |
/** |
|
30 |
* |
|
31 |
* @author jjdelcerro |
|
32 |
*/ |
|
33 |
@SuppressWarnings("UseSpecificCatch") |
|
34 |
public class SelectByAttributes { |
|
35 |
|
|
36 |
private static final Logger LOGGER = LoggerFactory.getLogger(SelectByAttributes.class); |
|
37 |
|
|
38 |
public SelectByAttributes() { |
|
39 |
|
|
40 |
} |
|
41 |
|
|
42 |
public void showWindow(String title, final FeatureStore store, WindowManager.MODE mode) { |
|
43 |
I18nManager i18n = ToolsLocator.getI18nManager(); |
|
44 |
WindowManager windowManager = ToolsSwingLocator.getWindowManager(); |
|
45 |
ExpressionEvaluatorSwingManager swingManager = ExpressionEvaluatorSwingLocator.getManager(); |
|
46 |
|
|
47 |
final JPanel panel = new JPanel(); |
|
48 |
panel.setLayout(new BorderLayout()); |
|
49 |
|
|
50 |
final JExpressionBuilder builder = swingManager.createJExpressionBuilder(); |
|
51 |
builder.addSymbolTable(DataManager.FEATURE_SYMBOL_TABLE); |
|
52 |
Element element = swingManager.createElement("View"); |
|
53 |
if (element != null) { |
|
54 |
builder.getElements().add(element); |
|
55 |
} |
|
56 |
element = swingManager.createElement( |
|
57 |
DataSwingManager.FEATURE_STORE_EXPRESSION_ELEMENT, |
|
58 |
builder, |
|
59 |
store |
|
60 |
); |
|
61 |
if (element != null) { |
|
62 |
builder.getElements().add(element); |
|
63 |
} |
|
64 |
panel.add(builder.asJComponent(), BorderLayout.CENTER); |
|
65 |
JPanel buttons = new JPanel(); |
|
66 |
buttons.setLayout(new FlowLayout(FlowLayout.RIGHT, 4, 4)); |
|
67 |
buttons.add(new JButton(new AbstractAction(i18n.getTranslation("_Set_selection")) { |
|
68 |
@Override |
|
69 |
public void actionPerformed(ActionEvent e) { |
|
70 |
setSelection(store, builder.getExpression()); |
|
71 |
} |
|
72 |
})); |
|
73 |
buttons.add(new JButton(new AbstractAction(i18n.getTranslation("_Add_to_selection")) { |
|
74 |
@Override |
|
75 |
public void actionPerformed(ActionEvent e) { |
|
76 |
addToSelection(store, builder.getExpression()); |
|
77 |
} |
|
78 |
})); |
|
79 |
buttons.add(new JButton(new AbstractAction(i18n.getTranslation("_Filter_selection")) { |
|
80 |
@Override |
|
81 |
public void actionPerformed(ActionEvent e) { |
|
82 |
filterSelection(store, builder.getExpression()); |
|
83 |
} |
|
84 |
})); |
|
85 |
buttons.add(new JButton(new AbstractAction(i18n.getTranslation("_Close")) { |
|
86 |
@Override |
|
87 |
public void actionPerformed(ActionEvent e) { |
|
88 |
panel.setVisible(false); |
|
89 |
} |
|
90 |
})); |
|
91 |
panel.add(buttons, BorderLayout.SOUTH); |
|
92 |
|
|
93 |
windowManager.showWindow( |
|
94 |
panel, |
|
95 |
title, |
|
96 |
mode |
|
97 |
); |
|
98 |
|
|
99 |
} |
|
100 |
|
|
101 |
public void setSelection(FeatureStore store, Expression expression) { |
|
102 |
try { |
|
103 |
DataManager manager = DALLocator.getDataManager(); |
|
104 |
|
|
105 |
FeatureSelection currentSelection = store.getFeatureSelection(); |
|
106 |
FeatureQuery query = store.createFeatureQuery(); |
|
107 |
query.setFilter(manager.createExpresion(expression)); |
|
108 |
FeatureSet selection = store.getFeatureSet(query); |
|
109 |
currentSelection.deselectAll(); |
|
110 |
currentSelection.select(selection); |
|
111 |
} catch (Exception ex) { |
|
112 |
LOGGER.warn("Can't build selecction from filter expression.", ex); |
|
113 |
} |
|
114 |
} |
|
115 |
|
|
116 |
public void addToSelection(FeatureStore store, Expression expression) { |
|
117 |
try { |
|
118 |
DataManager manager = DALLocator.getDataManager(); |
|
119 |
|
|
120 |
FeatureSelection currentSelection = store.getFeatureSelection(); |
|
121 |
FeatureQuery query = store.createFeatureQuery(); |
|
122 |
query.setFilter(manager.createExpresion(expression)); |
|
123 |
FeatureSet selection = store.getFeatureSet(query); |
|
124 |
currentSelection.select(selection); |
|
125 |
} catch (Exception ex) { |
|
126 |
LOGGER.warn("Can't build selecction from filter expression.", ex); |
|
127 |
} |
|
128 |
} |
|
129 |
|
|
130 |
public void filterSelection(FeatureStore store, Expression expression) { |
|
131 |
try { |
|
132 |
DataManager manager = DALLocator.getDataManager(); |
|
133 |
|
|
134 |
FeatureSelection currentSelection = store.getFeatureSelection(); |
|
135 |
FeatureQuery query = store.createFeatureQuery(); |
|
136 |
query.setFilter(manager.createExpresion(expression)); |
|
137 |
FeatureSet set = store.getFeatureSet(query); |
|
138 |
FeatureSelection newSelection = store.createFeatureSelection(); |
|
139 |
for (Feature feature : set) { |
|
140 |
if( currentSelection.isSelected(feature) ) { |
|
141 |
newSelection.select(feature); |
|
142 |
} |
|
143 |
} |
|
144 |
store.setSelection(newSelection); |
|
145 |
} catch (Exception ex) { |
|
146 |
LOGGER.warn("Can't build selecction from filter expression.", ex); |
|
147 |
} |
|
148 |
} |
|
149 |
|
|
150 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app/org.gvsig.app.mainplugin/src/main/java/org/gvsig/app/extension/SelectByAttributesExtension.java | ||
---|---|---|
22 | 22 |
*/ |
23 | 23 |
package org.gvsig.app.extension; |
24 | 24 |
|
25 |
import java.awt.BorderLayout; |
|
26 |
import java.awt.FlowLayout; |
|
27 |
import java.awt.event.ActionEvent; |
|
28 | 25 |
import java.util.Iterator; |
29 |
import javax.swing.AbstractAction; |
|
30 |
import javax.swing.JButton; |
|
31 | 26 |
|
32 | 27 |
import javax.swing.JOptionPane; |
33 |
import javax.swing.JPanel; |
|
34 | 28 |
|
35 | 29 |
import org.gvsig.andami.IconThemeHelper; |
36 | 30 |
import org.gvsig.andami.PluginServices; |
... | ... | |
42 | 36 |
import org.gvsig.app.gui.filter.FilterDialog; |
43 | 37 |
import org.gvsig.app.project.documents.view.ViewDocument; |
44 | 38 |
import org.gvsig.app.project.documents.view.gui.IView; |
45 |
import org.gvsig.expressionevaluator.Expression; |
|
46 |
import org.gvsig.expressionevaluator.swing.ExpressionEvaluatorSwingLocator; |
|
47 |
import org.gvsig.expressionevaluator.swing.ExpressionEvaluatorSwingManager; |
|
48 |
import org.gvsig.expressionevaluator.swing.JExpressionBuilder; |
|
49 |
import org.gvsig.expressionevaluator.swing.Element; |
|
50 | 39 |
import org.gvsig.fmap.dal.DALLocator; |
51 | 40 |
import org.gvsig.fmap.dal.DataManager; |
52 | 41 |
import org.gvsig.fmap.dal.exception.DataException; |
... | ... | |
55 | 44 |
import org.gvsig.fmap.dal.feature.FeatureSelection; |
56 | 45 |
import org.gvsig.fmap.dal.feature.FeatureSet; |
57 | 46 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
58 |
import org.gvsig.fmap.dal.swing.DataSwingManager; |
|
59 | 47 |
import org.gvsig.fmap.mapcontext.layers.FLayer; |
60 | 48 |
import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect; |
61 | 49 |
import org.gvsig.i18n.Messages; |
62 |
import org.gvsig.tools.ToolsLocator; |
|
63 |
import org.gvsig.tools.i18n.I18nManager; |
|
64 |
import org.gvsig.tools.swing.api.ToolsSwingLocator; |
|
65 | 50 |
import org.gvsig.tools.swing.api.windowmanager.WindowManager; |
66 | 51 |
import org.gvsig.utils.exceptionHandling.ExceptionListener; |
67 | 52 |
|
... | ... | |
89 | 74 |
if (view == null) { |
90 | 75 |
return; |
91 | 76 |
} |
92 |
if ("selection-by-attributes-layer2".equals(actionCommand)) {
|
|
77 |
if ("selection-by-attributes-layer".equals(actionCommand)) { |
|
93 | 78 |
ViewDocument document = view.getViewDocument(); |
94 | 79 |
|
95 | 80 |
FLayer layer = document.getMapContext().getLayers().getActives()[0]; |
96 | 81 |
filterTitle = layer.getName(); |
97 | 82 |
featureStore = ((FLyrVect) layer).getFeatureStore(); |
98 | 83 |
document.setModified(true); |
99 |
doSelectByAttributes2(filterTitle, featureStore); |
|
84 |
SelectByAttributes selector = new SelectByAttributes(); |
|
85 |
selector.showWindow(filterTitle, featureStore, WindowManager.MODE.TOOL); |
|
100 | 86 |
|
101 |
} else if ("selection-by-attributes-layer".equals(actionCommand)) { |
|
87 |
|
|
88 |
} else if ("selection-by-attributes-layer-old".equals(actionCommand)) { |
|
102 | 89 |
ViewDocument document = view.getViewDocument(); |
103 | 90 |
|
104 | 91 |
FLayer layer = document.getMapContext().getLayers().getActives()[0]; |
... | ... | |
296 | 283 |
} |
297 | 284 |
return p.getMessage(); |
298 | 285 |
} |
299 |
|
|
300 |
private void doSelectByAttributes2(String title, final FeatureStore store) { |
|
301 |
I18nManager i18n = ToolsLocator.getI18nManager(); |
|
302 |
WindowManager windowManager = ToolsSwingLocator.getWindowManager(); |
|
303 |
ExpressionEvaluatorSwingManager swingManager = ExpressionEvaluatorSwingLocator.getManager(); |
|
304 |
|
|
305 |
final JPanel panel = new JPanel(); |
|
306 |
panel.setLayout(new BorderLayout()); |
|
307 |
|
|
308 |
final JExpressionBuilder builder = swingManager.createJExpressionBuilder(); |
|
309 |
builder.addSymbolTable(DataManager.FEATURE_SYMBOL_TABLE); |
|
310 |
Element element = swingManager.createElement("View"); |
|
311 |
if (element != null) { |
|
312 |
builder.getElements().add(element); |
|
313 |
} |
|
314 |
element = swingManager.createElement( |
|
315 |
DataSwingManager.FEATURE_STORE_EXPRESSION_ELEMENT, |
|
316 |
builder, |
|
317 |
store |
|
318 |
); |
|
319 |
if (element != null) { |
|
320 |
builder.getElements().add(element); |
|
321 |
} |
|
322 |
panel.add(builder.asJComponent(), BorderLayout.CENTER); |
|
323 |
JPanel buttons = new JPanel(); |
|
324 |
buttons.setLayout(new FlowLayout(FlowLayout.RIGHT, 4, 4)); |
|
325 |
buttons.add(new JButton(new AbstractAction(i18n.getTranslation("_Set_selection")) { |
|
326 |
@Override |
|
327 |
public void actionPerformed(ActionEvent e) { |
|
328 |
doSetSelection(store, builder.getExpression()); |
|
329 |
} |
|
330 |
})); |
|
331 |
buttons.add(new JButton(new AbstractAction(i18n.getTranslation("_Add_to_selection")) { |
|
332 |
@Override |
|
333 |
public void actionPerformed(ActionEvent e) { |
|
334 |
doAddToSelection(store, builder.getExpression()); |
|
335 |
} |
|
336 |
})); |
|
337 |
buttons.add(new JButton(new AbstractAction(i18n.getTranslation("_Filter_selection")) { |
|
338 |
@Override |
|
339 |
public void actionPerformed(ActionEvent e) { |
|
340 |
doFilterSelection(store, builder.getExpression()); |
|
341 |
} |
|
342 |
})); |
|
343 |
buttons.add(new JButton(new AbstractAction(i18n.getTranslation("_Close")) { |
|
344 |
@Override |
|
345 |
public void actionPerformed(ActionEvent e) { |
|
346 |
panel.setVisible(false); |
|
347 |
} |
|
348 |
})); |
|
349 |
panel.add(buttons, BorderLayout.SOUTH); |
|
350 |
|
|
351 |
windowManager.showWindow( |
|
352 |
panel, |
|
353 |
title, |
|
354 |
WindowManager.MODE.TOOL |
|
355 |
); |
|
356 |
|
|
357 |
} |
|
358 |
|
|
359 |
private void doSetSelection(FeatureStore store, Expression expression) { |
|
360 |
try { |
|
361 |
DataManager manager = DALLocator.getDataManager(); |
|
362 |
|
|
363 |
FeatureSelection currentSelection = store.getFeatureSelection(); |
|
364 |
FeatureQuery query = store.createFeatureQuery(); |
|
365 |
query.setFilter(manager.createExpresion(expression)); |
|
366 |
FeatureSet selection = store.getFeatureSet(query); |
|
367 |
currentSelection.deselectAll(); |
|
368 |
currentSelection.select(selection); |
|
369 |
} catch (Exception ex) { |
|
370 |
logger.warn("Can't build selecction from filter expression.", ex); |
|
371 |
} |
|
372 |
} |
|
373 |
|
|
374 |
private void doAddToSelection(FeatureStore store, Expression expression) { |
|
375 |
try { |
|
376 |
DataManager manager = DALLocator.getDataManager(); |
|
377 |
|
|
378 |
FeatureSelection currentSelection = store.getFeatureSelection(); |
|
379 |
FeatureQuery query = store.createFeatureQuery(); |
|
380 |
query.setFilter(manager.createExpresion(expression)); |
|
381 |
FeatureSet selection = store.getFeatureSet(query); |
|
382 |
currentSelection.select(selection); |
|
383 |
} catch (Exception ex) { |
|
384 |
logger.warn("Can't build selecction from filter expression.", ex); |
|
385 |
} |
|
386 |
} |
|
387 |
|
|
388 |
private void doFilterSelection(FeatureStore store, Expression expression) { |
|
389 |
try { |
|
390 |
DataManager manager = DALLocator.getDataManager(); |
|
391 |
|
|
392 |
FeatureSelection currentSelection = store.getFeatureSelection(); |
|
393 |
FeatureQuery query = store.createFeatureQuery(); |
|
394 |
query.setFilter(manager.createExpresion(expression)); |
|
395 |
FeatureSet set = store.getFeatureSet(query); |
|
396 |
FeatureSelection newSelection = store.createFeatureSelection(); |
|
397 |
for (Feature feature : set) { |
|
398 |
if( currentSelection.isSelected(feature) ) { |
|
399 |
newSelection.select(feature); |
|
400 |
} |
|
401 |
} |
|
402 |
store.setSelection(newSelection); |
|
403 |
} catch (Exception ex) { |
|
404 |
logger.warn("Can't build selecction from filter expression.", ex); |
|
405 |
} |
|
406 |
} |
|
407 |
|
|
408 | 286 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app/org.gvsig.app.mainplugin/src/main/resources-plugin/config.xml | ||
---|---|---|
815 | 815 |
active="true"> |
816 | 816 |
|
817 | 817 |
<action |
818 |
name="selection-by-attributes-layer" |
|
819 |
label="_Select_by_attributes" |
|
818 |
name="selection-by-attributes-layer-old"
|
|
819 |
label="_Select_by_attributes_old"
|
|
820 | 820 |
position="300080000" |
821 | 821 |
icon="selection-by-attributes" |
822 |
tooltip="_Select_by_attributes" |
|
823 |
action-command="selection-by-attributes-layer" |
|
822 |
tooltip="_Select_by_attributes_old"
|
|
823 |
action-command="selection-by-attributes-layer-old"
|
|
824 | 824 |
accelerator="" |
825 | 825 |
/> |
826 | 826 |
|
827 | 827 |
<action |
828 |
name="selection-by-attributes-layer2"
|
|
828 |
name="selection-by-attributes-layer" |
|
829 | 829 |
label="_Select_by_attributes" |
830 | 830 |
position="300080001" |
831 | 831 |
icon="selection-by-attributes" |
832 | 832 |
tooltip="_Select_by_attributes" |
833 |
action-command="selection-by-attributes-layer2"
|
|
833 |
action-command="selection-by-attributes-layer" |
|
834 | 834 |
accelerator="" |
835 | 835 |
/> |
836 | 836 |
|
837 | 837 |
<menu |
838 |
name="selection-by-attributes-layer" |
|
838 |
name="selection-by-attributes-layer-old"
|
|
839 | 839 |
text="Selection/_Select_by_attributes_old" |
840 | 840 |
/> |
841 | 841 |
|
842 | 842 |
<menu |
843 |
name="selection-by-attributes-layer2"
|
|
843 |
name="selection-by-attributes-layer" |
|
844 | 844 |
text="Selection/_Select_by_attributes" |
845 | 845 |
/> |
846 | 846 |
|
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app/org.gvsig.app.mainplugin/src/main/resources-plugin/i18n/text.properties | ||
---|---|---|
1228 | 1228 |
_Undo_redo_history=Historial de hacer/deshacer |
1229 | 1229 |
|
1230 | 1230 |
_Selection_by_attributes=Selecci\u00f3n por atributos |
1231 |
_Select_by_attributes_old=Selecci\u00f3n por atributos (antig\u00fco) |
|
1232 |
_Set_selection=Asignar a la selecci\u00f3n |
|
1233 |
_Add_to_selection=A\u00f1adir a la selecci\u00f3n |
|
1234 |
_Filter_selection=Filtrar la selecci\u00f3n |
|
1231 | 1235 |
text_editor=Editor de texto |
1232 | 1236 |
first=Primero |
1233 | 1237 |
last=Ultimo |
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app/org.gvsig.app.mainplugin/src/main/resources-plugin/i18n/text_en.properties | ||
---|---|---|
1150 | 1150 |
_Undo_redo_history=Undo/redo history |
1151 | 1151 |
|
1152 | 1152 |
_Selection_by_attributes=Selecci\u00f3n por atributos |
1153 |
_Select_by_attributes_old=Select by attributes )old) |
|
1154 |
_Set_selection=Set selection |
|
1155 |
_Add_to_selection=Add to selection |
|
1156 |
_Filter_selection=Filter selection |
|
1153 | 1157 |
text_editor=Text editor |
1154 | 1158 |
first=First |
1155 | 1159 |
last=Last |
trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.expressionevaluator/org.gvsig.expressionevaluator.swing/org.gvsig.expressionevaluator.swing.api/src/main/java/org/gvsig/expressionevaluator/swing/spi/AbstractElementFactory.java | ||
---|---|---|
1 | 1 |
package org.gvsig.expressionevaluator.swing.spi; |
2 | 2 |
|
3 |
import java.util.HashMap; |
|
4 |
import java.util.Map; |
|
5 |
import org.gvsig.expressionevaluator.swing.Element; |
|
6 | 3 |
import org.gvsig.expressionevaluator.swing.ElementFactory; |
7 | 4 |
import org.gvsig.tools.ToolsLocator; |
8 | 5 |
import org.gvsig.tools.i18n.I18nManager; |
Also available in: Unified diff