-// $Id$
/**
* Copyright (C) 2007 EDIT
-* European Distributed Institute of Taxonomy
+* 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.
*/
import java.util.Arrays;
import java.util.Collection;
+import java.util.Comparator;
import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.IAction;
import org.eclipse.jface.action.ToolBarManager;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.swt.SWT;
import eu.etaxonomy.cdm.api.facade.DerivedUnitFacade;
import eu.etaxonomy.cdm.model.occurrence.DeterminationEvent;
import eu.etaxonomy.taxeditor.model.ImageResources;
-import eu.etaxonomy.taxeditor.ui.campanula.compatibility.ICdmFormElement;
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
+import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
+import eu.etaxonomy.taxeditor.ui.section.DefaultCdmBaseComparator;
/**
* @author n.hoffmann
int style) {
super(formFactory, conversation, parentElement, "Current Determination", style);
}
-
+
@Override
protected Control createToolbar() {
ToolBarManager toolBarManager = new ToolBarManager(SWT.FLAT);
-
- Action addAction = new Action("add", Action.AS_PUSH_BUTTON){
+
+ Action addAction = new Action("add", IAction.AS_PUSH_BUTTON){
/* (non-Javadoc)
* @see org.eclipse.jface.action.Action#run()
*/
@Override
public void run() {
DeterminationEvent element = createNewElement();
-
+
// set as preferred determination
getEntity().setPreferredDetermination(element);
-
+
if(element != null){
- if(! getSection().isExpanded())
- getSection().setExpanded(true);
- internalUpdateSection(true);
+ if(! getSection().isExpanded()) {
+ getSection().setExpanded(true);
+ }
+ internalUpdateSection(true);
}
}
};
addAction.setImageDescriptor(new ImageDescriptor() {
-
+
@Override
public ImageData getImageData() {
return ImageResources.getImage(ImageResources.ADD_ICON).getImageData();
}
});
addAction.setToolTipText(getTooltipString());
-
+
toolBarManager.add(addAction);
-
+
return toolBarManager.createControl(this);
}
-
+
@Override
public void refresh() {
internalUpdateSection(false);
DeterminationEvent preferredDetermination = entity.getPreferredDetermination();
return preferredDetermination != null ? Arrays.asList(new DeterminationEvent[]{preferredDetermination}) : null;
}
-
+
+ @Override
+ public Comparator<DeterminationEvent> getComparator() {
+ return new DefaultCdmBaseComparator<>();
+ }
+
/* (non-Javadoc)
* @see eu.etaxonomy.taxeditor.ui.section.occurrence.AbstractDeterminationEventDetailSection#createNewElement()
*/
newElement.setPreferredFlag(true);
return newElement;
}
-
+
/* (non-Javadoc)
* @see eu.etaxonomy.taxeditor.section.AbstractEntityCollectionSection#getTooltipString()
return "Create new current determination event";
}
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public DeterminationEvent addExisting() {
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean allowAddExisting() {
+ return false;
+ }
+
}