// $Id$
/**
-* Copyright (C) 2013 EDIT
-* European Distributed Institute of Taxonomy
-* http://www.e-taxonomy.eu
-*
-* The contents of this file are subject to the Mozilla Public License Version 1.1
-* See LICENSE.TXT at the top of this package for the full license terms.
-*/
+ * Copyright (C) 2013 EDIT
+ * European Distributed Institute of Taxonomy
+ * http://www.e-taxonomy.eu
+ *
+ * The contents of this file are subject to the Mozilla Public License Version 1.1
+ * See LICENSE.TXT at the top of this package for the full license terms.
+ */
package eu.etaxonomy.taxeditor.view.derivateSearch;
import org.eclipse.jface.viewers.TableViewer;
private final TableViewer resultViewer;
private final Combo comboDerivateType;
private final Button buttonSearch;
+ private final Button btnFilterUndeterminedSpecimen;
/**
* Create the composite.
*/
public DerivateSearchComposite(Composite parent, int style) {
super(parent, style);
- setLayout(new GridLayout(2, false));
+ setLayout(new GridLayout(6, false));
- comboDerivateType = new Combo(this, SWT.READ_ONLY);
- comboDerivateType.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
- formToolkit.paintBordersFor(comboDerivateType);
+ Label lblDerivateType = new Label(this, SWT.NULL);
+ lblDerivateType.setText("Derivate Filter");
- Label lblDerivateType = new Label(this, SWT.NULL);
- lblDerivateType.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
- lblDerivateType.setText("Derivate Filter");
+ comboDerivateType = new Combo(this, SWT.READ_ONLY);
+ comboDerivateType.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
+ formToolkit.paintBordersFor(comboDerivateType);
- searchField = formToolkit.createText(this, "New Text", SWT.NONE);
- searchField.setText("");
- searchField.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
+ btnFilterUndeterminedSpecimen = new Button(this, SWT.CHECK);
+ btnFilterUndeterminedSpecimen.setText("Only undetermined specimen");
+ btnFilterUndeterminedSpecimen.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
+ new Label(this, SWT.NONE);
+ new Label(this, SWT.NONE);
+ new Label(this, SWT.NONE);
+
+ searchField = formToolkit.createText(this, "New Text", SWT.NONE);
+ searchField.setText("");
+ searchField.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1));
buttonSearch = new Button(this, SWT.NONE);
buttonSearch.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
formToolkit.adapt(buttonSearch, true, true);
buttonSearch.setText("Search");
+ new Label(this, SWT.NONE);
+ new Label(this, SWT.NONE);
+ new Label(this, SWT.NONE);
resultViewer = new TableViewer(this, SWT.BORDER | SWT.FULL_SELECTION);
table = resultViewer.getTable();
- table.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1));
+ table.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 6, 4));
}
comboDerivateType.setEnabled(enabled);
buttonSearch.setEnabled(enabled);
}
+ public Button getBtnFilterUndeterminedSpecimen() {
+ return btnFilterUndeterminedSpecimen;
+ }
}
*/
package eu.etaxonomy.taxeditor.view.derivateSearch;
+import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedHashMap;
import java.util.List;
import org.eclipse.ui.handlers.IHandlerService;
import eu.etaxonomy.cdm.api.facade.DerivedUnitFacadeCacheStrategy;
+import eu.etaxonomy.cdm.api.service.IOccurrenceService;
import eu.etaxonomy.cdm.api.service.config.IIdentifiableEntityServiceConfigurator;
import eu.etaxonomy.cdm.api.service.config.IdentifiableServiceConfiguratorImpl;
import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase;
private void searchDerivates(){
configurator.setTitleSearchString(derivateSearchComposite.getSearchField().getText());
SpecimenOrObservationType type = enumTermComboController.getSelection();
+ //filter by specimen type
List<SpecimenOrObservationBase> results = CdmStore.getSearchManager().findOccurrencesByType(configurator, type);
+ //filter out assigned specimens
+ if(derivateSearchComposite.getBtnFilterUndeterminedSpecimen().getSelection()){
+ List<SpecimenOrObservationBase> specimensWithNoDetermination = new ArrayList<SpecimenOrObservationBase>();
+ for(SpecimenOrObservationBase<?> result:results){
+ if(CdmStore.getService(IOccurrenceService.class).countDeterminations(result, null)==0){
+ specimensWithNoDetermination.add(result);
+ }
+ }
+ results = specimensWithNoDetermination;
+ }
derivateSearchComposite.getResultViewer().setInput(results);
}