eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/campanula/basicFields/ToggleableTextFieldController.java -text
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/campanula/compatibility/ICdmFormElement.java -text
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/campanula/compatibility/IEntitySelectionElement.java -text
+eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/campanula/derivatesearch/DerivateSearchComposite.java -text
+eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/campanula/derivatesearch/DerivateSearchCompositeController.java -text
+eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/campanula/derivatesearch/DerivateSearchResultsLabelProvider.java -text
+eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/campanula/derivatesearch/DerivateSearchView.java -text
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/campanula/detailViews/fieldObservation/FieldObservationDetailsElement.java -text
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/campanula/detailViews/fieldObservation/FieldObservationDetailsElementController.java -text
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/campanula/detailViews/fieldObservation/FieldObservationDetailsSection.java -text
if(activePart instanceof DerivateView){
DerivateView derivateView = (DerivateView)activePart;
derivateView.viewer.refresh();
- derivateView.getEditor().doSave(new NullProgressMonitor());
+ derivateView.doSave(new NullProgressMonitor());
}
}
package eu.etaxonomy.taxeditor.editor.view.derivate;
+import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.action.MenuManager;
-import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.jface.viewers.Viewer;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Menu;
import org.eclipse.swt.widgets.Tree;
-import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IEditorSite;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.part.EditorPart;
-import eu.etaxonomy.cdm.model.common.CdmBase;
-import eu.etaxonomy.taxeditor.bulkeditor.BulkEditor;
-import eu.etaxonomy.taxeditor.model.AbstractUtility;
import eu.etaxonomy.taxeditor.model.IPartContentHasDetails;
import eu.etaxonomy.taxeditor.model.IPartContentHasSupplementalData;
-import eu.etaxonomy.taxeditor.view.AbstractCdmEditorViewPart;
/**
* Displays the derivate hierarchy of all derivates belonging to a taxon.
*
*/
-public class DerivateView extends AbstractCdmEditorViewPart implements IPartContentHasDetails, IPartContentHasSupplementalData {
+public class DerivateView extends EditorPart implements IPartContentHasDetails, IPartContentHasSupplementalData {
/** Constant <code>ID="eu.etaxonomy.taxeditor.editor.view.desc"{trunked}</code> */
public static final String ID = "eu.etaxonomy.taxeditor.editor.view.derivate.DerivateView";
protected TreeViewer viewer;
- @Override
- public void createViewer(Composite parent) {
- viewer = new TreeViewer(new Tree(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION));
- viewer.setContentProvider(new DerivateContentProvider());
- viewer.setLabelProvider(new DerivateLabelProvider());
- viewer.setAutoExpandLevel(2);
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
+ */
+ @Override
+ public void createPartControl(Composite parent) {
+ viewer = new TreeViewer(new Tree(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION));
+ viewer.setContentProvider(new DerivateContentProvider());
+ viewer.setLabelProvider(new DerivateLabelProvider());
+ viewer.setAutoExpandLevel(2);
// Propagate selection from viewer
getSite().setSelectionProvider(viewer);
Menu menu = menuManager.createContextMenu(control);
control.setMenu(menu);
- }
-
- @Override
- public void selectionChanged(IWorkbenchPart part, ISelection selection) {
- if(AbstractUtility.getActiveEditor()==null || !(AbstractUtility.getActiveEditor() instanceof BulkEditor)){
- showEmptyPage();
- return;
- }
- else if(part instanceof BulkEditor){
- this.part = part;
-
- getViewer().setInput(selection);
-
- showViewer();
- return;
- }
- }
-
- @Override
- public boolean onComplete() {
- // TODO Auto-generated method stub
- return false;
- }
-
- @Override
- public Viewer getViewer() {
- return viewer;
- }
-
-
- @Override
- public boolean postOperation(CdmBase objectAffectedByOperation) {
- return super.postOperation(objectAffectedByOperation);
- }
+
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.part.EditorPart#doSave(org.eclipse.core.runtime.IProgressMonitor)
+ */
+ @Override
+ public void doSave(IProgressMonitor monitor) {
+ // TODO Auto-generated method stub
+
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.part.EditorPart#doSaveAs()
+ */
+ @Override
+ public void doSaveAs() {
+ // TODO Auto-generated method stub
+
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.part.EditorPart#init(org.eclipse.ui.IEditorSite, org.eclipse.ui.IEditorInput)
+ */
+ @Override
+ public void init(IEditorSite site, IEditorInput input) throws PartInitException {
+ // TODO Auto-generated method stub
+
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.part.EditorPart#isDirty()
+ */
+ @Override
+ public boolean isDirty() {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.part.EditorPart#isSaveAsAllowed()
+ */
+ @Override
+ public boolean isSaveAsAllowed() {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.part.WorkbenchPart#setFocus()
+ */
+ @Override
+ public void setFocus() {
+ // TODO Auto-generated method stub
+
+ }
+
+// @Override
+// public void createViewer(Composite parent) {
+// viewer = new TreeViewer(new Tree(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION));
+// viewer.setContentProvider(new DerivateContentProvider());
+// viewer.setLabelProvider(new DerivateLabelProvider());
+// viewer.setAutoExpandLevel(2);
+// // Propagate selection from viewer
+// getSite().setSelectionProvider(viewer);
+//
+// //create context menu
+// MenuManager menuManager = new MenuManager();
+//
+// getSite().registerContextMenu(menuManager, viewer);
+//
+// Control control = viewer.getControl();
+// Menu menu = menuManager.createContextMenu(control);
+//
+// control.setMenu(menu);
+// }
+//
+// @Override
+// public void selectionChanged(IWorkbenchPart part, ISelection selection) {
+// if(AbstractUtility.getActiveEditor()==null || !(AbstractUtility.getActiveEditor() instanceof BulkEditor)){
+// showEmptyPage();
+// return;
+// }
+// else if(part instanceof BulkEditor){
+// this.part = part;
+//
+// getViewer().setInput(selection);
+//
+// showViewer();
+// return;
+// }
+// }
+//
+// @Override
+// public boolean onComplete() {
+// // TODO Auto-generated method stub
+// return false;
+// }
+//
+// @Override
+// public Viewer getViewer() {
+// return viewer;
+// }
+//
+//
+// @Override
+// public boolean postOperation(CdmBase objectAffectedByOperation) {
+// return super.postOperation(objectAffectedByOperation);
+// }
}
id="eu.etaxonomy.taxeditor.view.userecords"
name="Use Records"
restorable="true">
+ </view>
+ <view
+ class="eu.etaxonomy.taxeditor.ui.campanula.derivatesearch.DerivateSearchView"
+ id="eu.etaxonomy.taxeditor.ui.campanula.derivatesearch.DerivateSearchView"
+ name="Derivate Search"
+ restorable="true">
</view>
</extension>
<extension
--- /dev/null
+// $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.
+*/
+package eu.etaxonomy.taxeditor.ui.campanula.derivatesearch;
+
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+
+/**
+ * @author pplitzner
+ * @date 25.11.2013
+ *
+ */
+public class DerivateSearchComposite extends Composite {
+ private final FormToolkit formToolkit = new FormToolkit(Display.getDefault());
+ private Text searchField;
+ private Table table;
+ private TableViewer resultViewer;
+
+ /**
+ * Create the composite.
+ * @param parent
+ * @param style
+ */
+ public DerivateSearchComposite(Composite parent, int style) {
+ super(parent, style);
+ setLayout(new GridLayout(2, false));
+
+ Label lblDerivateType = new Label(this, SWT.NULL);
+ lblDerivateType.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
+ lblDerivateType.setText("Derivate Type");
+
+ Combo combo = new Combo(this, SWT.NONE);
+ combo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
+ formToolkit.paintBordersFor(combo);
+
+ searchField = formToolkit.createText(this, "New Text", SWT.NONE);
+ searchField.setText("");
+ searchField.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1));
+
+ resultViewer = new TableViewer(this, SWT.BORDER | SWT.FULL_SELECTION);
+ table = resultViewer.getTable();
+ table.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1));
+
+ }
+
+ @Override
+ protected void checkSubclass() {
+ // Disable the check that prevents subclassing of SWT components
+ }
+ public Text getSearchField() {
+ return searchField;
+ }
+ public TableViewer getResultViewer() {
+ return resultViewer;
+ }
+}
--- /dev/null
+// $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.
+*/
+package eu.etaxonomy.taxeditor.ui.campanula.derivatesearch;
+
+import java.util.List;
+
+import org.eclipse.jface.viewers.ArrayContentProvider;
+import org.eclipse.jface.viewers.DoubleClickEvent;
+import org.eclipse.jface.viewers.IDoubleClickListener;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.KeyAdapter;
+import org.eclipse.swt.events.KeyEvent;
+
+import eu.etaxonomy.cdm.api.service.config.IIdentifiableEntityServiceConfigurator;
+import eu.etaxonomy.cdm.api.service.config.IdentifiableServiceConfiguratorImpl;
+import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase;
+import eu.etaxonomy.taxeditor.store.CdmStore;
+
+/**
+ * @author pplitzner
+ * @date 25.11.2013
+ *
+ */
+public class DerivateSearchCompositeController {
+
+ private DerivateSearchComposite derivateSearchComposite;
+ private IIdentifiableEntityServiceConfigurator<SpecimenOrObservationBase<?>> configurator;
+
+ /**
+ * @param derivateSearchComposite
+ */
+ public DerivateSearchCompositeController(DerivateSearchComposite derivateSearchComposite) {
+ this.derivateSearchComposite = derivateSearchComposite;
+ init();
+ }
+
+ private void init(){
+ derivateSearchComposite.getSearchField().addKeyListener(new KeyAdapter() {
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.swt.events.KeyAdapter#keyPressed(org.eclipse.swt.events.KeyEvent)
+ */
+ @Override
+ public void keyPressed(KeyEvent e) {
+ if (e.keyCode == SWT.CR) {
+ String searchString = derivateSearchComposite.getSearchField().getText();
+ searchDerivates(searchString);
+ }
+ }
+ });
+
+ TableViewer resultViewer = derivateSearchComposite.getResultViewer();
+ resultViewer.setContentProvider(new ArrayContentProvider());
+ resultViewer.setLabelProvider(new DerivateSearchResultsLabelProvider());
+ resultViewer.addDoubleClickListener(new IDoubleClickListener() {
+ @Override
+ public void doubleClick(DoubleClickEvent event) {
+// PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().openEditor(input, editorId);
+ }
+ });
+
+ configurator = new IdentifiableServiceConfiguratorImpl<SpecimenOrObservationBase<?>>();
+ }
+
+ private void searchDerivates(String searchString){
+ configurator.setTitleSearchString(searchString);
+ List<SpecimenOrObservationBase> results = CdmStore.getSearchManager().findOccurrences(configurator);
+ derivateSearchComposite.getResultViewer().setInput(results);
+ }
+
+}
--- /dev/null
+// $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.
+*/
+package eu.etaxonomy.taxeditor.ui.campanula.derivatesearch;
+
+import org.eclipse.jface.viewers.ColumnLabelProvider;
+import org.eclipse.swt.graphics.Color;
+
+import eu.etaxonomy.cdm.model.common.UuidAndTitleCache;
+
+/**
+ * @author pplitzner
+ * @date 25.11.2013
+ *
+ */
+public class DerivateSearchResultsLabelProvider extends ColumnLabelProvider {
+
+ /** {@inheritDoc} */
+ @Override
+ public String getText(Object element) {
+ if(element instanceof UuidAndTitleCache){
+ return ((UuidAndTitleCache) element).getTitleCache();
+ }
+ return element.toString();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.ColumnLabelProvider#getBackground(java.lang.Object)
+ */
+ /** {@inheritDoc} */
+ @Override
+ public Color getBackground(Object element) {
+ return super.getBackground(element);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.CellLabelProvider#getToolTipText(java.lang.Object)
+ *
+ * does not seem t work right now
+ */
+ /** {@inheritDoc} */
+ @Override
+ public String getToolTipText(Object element) {
+ return "Name: " + element.toString();
+ }
+
+}
--- /dev/null
+// $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.
+*/
+package eu.etaxonomy.taxeditor.ui.campanula.derivatesearch;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.part.ViewPart;
+
+/**
+ * @author pplitzner
+ * @date 25.11.2013
+ *
+ */
+public class DerivateSearchView extends ViewPart {
+ public DerivateSearchView() {
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
+ */
+ @Override
+ public void createPartControl(Composite parent) {
+ new DerivateSearchCompositeController(new DerivateSearchComposite(parent, SWT.NONE));
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.part.WorkbenchPart#setFocus()
+ */
+ @Override
+ public void setFocus() {
+ // TODO Auto-generated method stub
+
+ }
+
+}