Revision: 4382 http://sourceforge.net/p/jump-pilot/code/4382 Author: michaudm Date: 2015-04-06 10:13:21 +0000 (Mon, 06 Apr 2015) Log Message: ----------- fix #393 (simple query did not do a deep copy of features) and improve boolean handling
Modified Paths: -------------- core/trunk/src/org/openjump/core/ui/plugin/queries/Condition.java core/trunk/src/org/openjump/core/ui/plugin/queries/QueryDialog.java Modified: core/trunk/src/org/openjump/core/ui/plugin/queries/Condition.java =================================================================== --- core/trunk/src/org/openjump/core/ui/plugin/queries/Condition.java 2015-04-06 09:59:40 UTC (rev 4381) +++ core/trunk/src/org/openjump/core/ui/plugin/queries/Condition.java 2015-04-06 10:13:21 UTC (rev 4382) @@ -31,7 +31,6 @@ */ public class Condition { - //private static final SimpleDateFormat DATE_PARSER = new SimpleDateFormat(); private static final SimpleDateFormat[] DATE_PARSERS = new SimpleDateFormat[]{ new SimpleDateFormat(), new SimpleDateFormat("dd/MM/yy"), @@ -43,6 +42,7 @@ new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss"), new SimpleDateFormat("yyyy") }; + private static final FlexibleDateParser FLEXIBLE_DATE_PARSER = new FlexibleDateParser(); QueryDialog query; @@ -73,10 +73,7 @@ public boolean test(Feature feature) throws Exception { Object o = null; - //System.out.print("Nature de l'attribut : "); if(query.attributeType=='G') { - //System.out.println(" geometrique"); - //System.out.println("Operator = " + op); o = feature.getGeometry(); if(ft.type=='G') return test(gfunction((Geometry)o)); else if(ft.type=='N') return test(nfunction((Geometry)o)); @@ -84,7 +81,6 @@ else return false; } else { - // System.out.println(" semantique"); // attributes which does not exist for this feature must have // been eliminated before the test procedure // (see QueryDialog#executeQuery()) Modified: core/trunk/src/org/openjump/core/ui/plugin/queries/QueryDialog.java =================================================================== --- core/trunk/src/org/openjump/core/ui/plugin/queries/QueryDialog.java 2015-04-06 09:59:40 UTC (rev 4381) +++ core/trunk/src/org/openjump/core/ui/plugin/queries/QueryDialog.java 2015-04-06 10:13:21 UTC (rev 4382) @@ -35,6 +35,7 @@ * version 0.2.1 (10 aug 2007) * version 0.3.0 (04 sept 2010) complete rewrite of functionChenged and operatorChanged methods * version 0.4.0 (28 june 2013) add relate method based on the DE-9IM matrix + * version 0.5.0 (06 avril 2015) clone features in result and improve boolean attribute type */ public class QueryDialog extends BDialog { @@ -66,10 +67,6 @@ static boolean runningQuery = false; static boolean cancelQuery = false; - // if mmpatch is used (mmpatch gives more attribute types), mmaptch must - // be set to true - // boolean mmpatch = false; - // selected features initialized in execute query if "select" option is true Collection selection; @@ -77,6 +74,7 @@ BCheckBox caseSensitive; BCheckBox numFilter; BCheckBox geoFilter; + BCheckBox booFilter; BCheckBox display; BCheckBox select; @@ -96,61 +94,19 @@ BButton refreshButton; BButton cancelButton; BButton stopButton; - - - /** - * Main method : create a Query Dialog. - */ - //public static void main(String[] args) { - //BFrame frame = new BFrame(); - //QueryDialog qd = new QueryDialog(null); - //} + /** - * Overloads createComponent in BDialog, in order to link this BDialog - * to a swing Window (instead of a WindowWidget). - */ - //protected JDialog createComponent(Window parent, String title, boolean modal) { - //return super.createComponent(parent, "", modal); - //} - - /** * Constructor of a QueryDialog * @param context the plugin context */ public QueryDialog(PlugInContext context) { component = super.createComponent(context.getWorkbenchFrame(), "", false); - //component = createComponent(context.getWorkbenchFrame(), "", false); - //initInternal(); - //BDialog dialog = new BDialog(); addEventLink(WindowClosingEvent.class, this, "exit"); - //if (AttributeType.allTypes().size()>6) { - // mmpatch = true; - //} this.context = context; setTitle(I18N.get("org.openjump.core.ui.plugin.queries.SimpleQuery.query-builder")); initUI(context); } - - /** - * Perform internal initialization. - * Copied from BDialog because it is declared as a private method. - * (the method is called in QueryDialog constructor) - */ - /*private void initInternal() { - component.addComponentListener(new ComponentAdapter() { - public void componentResized(ComponentEvent ev) { - if (lastSize == null || !lastSize.equals(component.getSize())) { - lastSize = null; - layoutChildren(); - QueryDialog.this.dispatchEvent(new WindowResizedEvent(QueryDialog.this)); - } - else - lastSize = null; - } - }); - ((JDialog) component).setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); - }*/ /** @@ -217,7 +173,7 @@ BorderFactory.createTitledBorder(border, I18N.get("org.openjump.core.ui.plugin.queries.SimpleQuery.query-manager"))); // ATTRIBUTE FILTER - FormContainer attributeFilterPanel = new FormContainer(2,3); + FormContainer attributeFilterPanel = new FormContainer(2,4); attributeFilterPanel.setDefaultLayout(nwBoth1); BOutline attributeFilterPanelB = new BOutline(attributeFilterPanel, BorderFactory.createTitledBorder(border, @@ -264,6 +220,9 @@ geoFilter = new BCheckBox(I18N.get("org.openjump.core.ui.plugin.queries.SimpleQuery.geometric"), true); geoFilter.addEventLink(ValueChangedEvent.class, this, "geoFilterChanged"); attributeFilterPanel.add(geoFilter, 0, 2); + booFilter = new BCheckBox(I18N.get("org.openjump.core.ui.plugin.queries.SimpleQuery.boolean"), true); + booFilter.addEventLink(ValueChangedEvent.class, this, "booFilterChanged"); + attributeFilterPanel.add(booFilter, 0, 3); // SET THE RESULT OPTIONS display = new BCheckBox(I18N.get("org.openjump.core.ui.plugin.queries.SimpleQuery.display-the-table"), false); @@ -342,7 +301,6 @@ southPanel.add(okButton, 2, 0); southPanel.add(refreshButton, 3, 0); - //southPanel.add(cancelButton, 4, 0); southPanel.add(stopButton, 4, 0); dialogContainer.add(northPanel, dialogContainer.NORTH); @@ -372,7 +330,6 @@ void initVariables() { runningQuery = false; cancelQuery = false; - //comments.setText(""); progressBarTitle.setText(""); progressBar.setIndeterminate(false); progressBar.setValue(0); @@ -394,7 +351,6 @@ List layers = context.getLayerManager().getLayers(); for (int i = 0 ; i < layers.size() ; i++) { Layer layer = (Layer)layers.get(i); - //layerCB.add(layer.getName()); layerCB.add(layer); } ((javax.swing.JComboBox)layerCB.getComponent()).setRenderer(layerListCellRenderer); @@ -452,15 +408,10 @@ if (type==AttributeType.GEOMETRY && geoFilter.getState()) return true; else if (type==AttributeType.STRING && charFilter.getState()) return true; else if (type==AttributeType.INTEGER && numFilter.getState()) return true; + else if (type==AttributeType.LONG && numFilter.getState()) return true; else if (type==AttributeType.DOUBLE && numFilter.getState()) return true; else if (type==AttributeType.DATE && numFilter.getState()) return true; - /* Special MM attributes, to add if mmpatch is added to the core - else if (mmpatch && type==AttributeType.LONG && numFilter.getState()) return true; - else if (mmpatch && type==AttributeType.BOOLEAN && numFilter.getState()) return true; - else if (mmpatch && type instanceof AttributeType.Char && charFilter.getState()) return true; - else if (mmpatch && type instanceof AttributeType.Decimal && numFilter.getState()) return true; - else if (mmpatch && type instanceof AttributeType.Enumeration) return true; - */ + else if (type==AttributeType.BOOLEAN && booFilter.getState()) return true; else return false; } @@ -479,15 +430,7 @@ String att = fs.getAttributeName(j); AttributeType type = fs.getAttributeType(j); if (type!=AttributeType.GEOMETRY && isAttributeAuthorized(fs, att) ) { - /* add this test if mmpatch is added to OpenJUMP core - if(mmpatch && type instanceof AttributeType.Enumeration) { - set.add(att + " (ENUM)"); - enumerations.put(att, ((AttributeType.Enumeration)type).getEnumerationArray()); - } - */ - //else { - set.add(att + " (" + type.toString().split(" ")[0] + ")"); - //} + set.add(att + " (" + type.toString().split(" ")[0] + ")"); } } } @@ -507,6 +450,10 @@ private void geoFilterChanged() { layerChanged(); } + + private void booFilterChanged() { + layerChanged(); + } public void attributeChanged() { String att = (String)attributeCB.getSelectedValue(); @@ -514,16 +461,13 @@ String attType = att.substring(att.lastIndexOf('(')+1, att.lastIndexOf(')')); char newat = 'S'; - //if (mmpatch && attType.equals("BOOLEAN")) newat = 'B'; if (attType.equals("INTEGER")) newat = 'N'; + else if (attType.equals("LONG")) newat = 'N'; else if (attType.equals("DATE")) newat = 'D'; - //else if (mmpatch && attType.equals("LONG")) newat = 'N'; else if (attType.equals("DOUBLE")) newat = 'N'; - //else if (mmpatch && attType.equals("DECIMAL")) newat = 'N'; else if (attType.equals("STRING")) newat = 'S'; - //else if (mmpatch && attType.equals("CHAR")) newat = 'S'; - //else if (mmpatch && attType.equals("ENUM")) newat = 'E'; else if (attType.equals("GEOMETRY")) newat = 'G'; + else if (attType.equals("BOOLEAN")) newat = 'B'; else; // No type change if (newat==attributeType) { @@ -1008,7 +952,7 @@ } Feature f = (BasicFeature)it.next(); if (condition.test(f)) { - okFeatures.add(f); + okFeatures.add(f.clone()); featuresfound++; } Thread.yield(); @@ -1037,14 +981,12 @@ } outputLayerName += (operator + "_" + value); context.getLayerManager().addLayer( - //context.getLayerManager().getCategory(layer).getName(), StandardCategoryNames.RESULT, // modified on 2007-08-22 outputLayerName, dataset ); } if(display.getState()) { info.getModel().add(layer, okFeatures); - //context.getWorkbenchFrame().addInternalFrame(info); } } @@ -1092,9 +1034,7 @@ } private void ok() {executeQuery();} - - //private void cancel() {setVisible(false);} - + private void stop() {if (runningQuery) cancelQuery = true;} private void refresh() {initComboBoxes();} ------------------------------------------------------------------------------ BPM Camp - Free Virtual Workshop May 6th at 10am PDT/1PM EDT Develop your own process in accordance with the BPMN 2 standard Learn Process modeling best practices with Bonita BPM through live exercises http://www.bonitasoft.com/be-part-of-it/events/bpm-camp-virtual- event?utm_ source=Sourceforge_BPM_Camp_5_6_15&utm_medium=email&utm_campaign=VA_SF _______________________________________________ Jump-pilot-devel mailing list Jump-pilot-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel