// $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.
*/
package eu.etaxonomy.taxeditor.ui.section.name;
import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.IAction;
import org.eclipse.jface.action.ToolBarManager;
import org.eclipse.jface.viewers.ISelectionProvider;
import org.eclipse.swt.SWT;
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
import eu.etaxonomy.cdm.model.name.NonViralName;
import eu.etaxonomy.cdm.model.taxon.TaxonBase;
-import eu.etaxonomy.taxeditor.store.StoreUtil;
+import eu.etaxonomy.taxeditor.model.AbstractUtility;
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
+import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory.DetailType;
import eu.etaxonomy.taxeditor.ui.element.CdmPropertyChangeEvent;
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
-import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory.DetailType;
import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailSection;
import eu.etaxonomy.taxeditor.ui.section.ITaxonBaseDetailSection;
ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style) {
super(formFactory, conversation, parentElement, selectionProvider, style);
}
-
+
/* (non-Javadoc)
* @see eu.etaxonomy.taxeditor.section.AbstractCdmDetailSection#createToolbar()
*/
@Override
protected Control createToolbar() {
ToolBarManager toolBarManager = new ToolBarManager(SWT.FLAT);
-
+
if(getEntity() != null && checkForMultipleNameUsages(getEntity())){
-
- Action cloneAction = new Action("Clone", Action.AS_PUSH_BUTTON){
- public void run() {
- boolean confirm = StoreUtil.confirmDialog("Confirm cloning", "Do you really want to clone the name?");
-
+
+ Action cloneAction = new Action("Clone", IAction.AS_PUSH_BUTTON){
+ @Override
+ public void run() {
+ boolean confirm = AbstractUtility.confirmDialog("Confirm cloning", "Do you really want to clone the name?");
+
if(confirm){
NonViralName clonedName;
clonedName = (NonViralName) getEntity().clone();
// EditorUtil.getActiveMultiPageTaxonEditor().r
firePropertyChangeEvent(new CdmPropertyChangeEvent(NonViralNameDetailSection.this, null));
}
-
+
};
};
-
+
cloneAction.setToolTipText("Clone the name if you do not want to edit the shared instance");
-
+
toolBarManager.add(cloneAction);
-
+
}
return toolBarManager.createControl(this);
}
-
+
/**
- * @param nonViralName
- *
+ * @param nonViralName
+ *
*/
private boolean checkForMultipleNameUsages(NonViralName nonViralName) {
return nonViralName.getTaxonBases().size() != 1;
}
-
+
/* (non-Javadoc)
* @see eu.etaxonomy.taxeditor.section.AbstractCdmDetailSection#getDetailType()
*/
* @see eu.etaxonomy.taxeditor.section.ITaxonDetailSection#setTaxon(eu.etaxonomy.cdm.model.taxon.TaxonBase)
*/
/** {@inheritDoc} */
- public void setTaxonBase(TaxonBase taxon) {
+ @Override
+ public void setTaxonBase(TaxonBase taxon) {
taxonBase = taxon;
NonViralName name = (NonViralName) HibernateProxyHelper.deproxy(taxon.getName());
setEntity(name);