/**
-* Copyright (C) 2007 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) 2007 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.editor.name;
import org.apache.commons.lang.StringUtils;
import org.eclipse.core.commands.operations.IUndoContext;
-import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.OperationCanceledException;
import org.eclipse.jface.action.MenuManager;
import org.eclipse.swt.dnd.DND;
import org.eclipse.swt.dnd.DropTarget;
import org.eclipse.swt.dnd.Transfer;
+import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Menu;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.IWorkbenchPartReference;
import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.forms.ManagedForm;
import org.eclipse.ui.forms.widgets.FormToolkit;
import org.eclipse.ui.forms.widgets.ScrolledForm;
import eu.etaxonomy.cdm.model.name.HomotypicalGroup;
import eu.etaxonomy.cdm.model.taxon.Taxon;
import eu.etaxonomy.cdm.model.taxon.TaxonBase;
+import eu.etaxonomy.cdm.model.taxon.TaxonNode;
import eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap;
import eu.etaxonomy.taxeditor.editor.CdmDataTransfer;
-import eu.etaxonomy.taxeditor.editor.EditorUtil;
import eu.etaxonomy.taxeditor.editor.IDropTargetable;
import eu.etaxonomy.taxeditor.editor.IMultiPageTaxonEditorPage;
+import eu.etaxonomy.taxeditor.editor.ISecuredEditor;
import eu.etaxonomy.taxeditor.editor.MultiPageTaxonEditor;
import eu.etaxonomy.taxeditor.editor.SimpleSelectionProvider;
import eu.etaxonomy.taxeditor.editor.TaxonEditorInput;
import eu.etaxonomy.taxeditor.editor.name.container.AbstractGroupedContainer;
import eu.etaxonomy.taxeditor.editor.name.container.AcceptedGroup;
import eu.etaxonomy.taxeditor.editor.name.container.AcceptedNameContainer;
-import eu.etaxonomy.taxeditor.editor.name.container.ConceptGroup;
import eu.etaxonomy.taxeditor.editor.name.container.ContainerFactory;
import eu.etaxonomy.taxeditor.editor.name.container.HomotypicalSynonymGroup;
import eu.etaxonomy.taxeditor.editor.name.container.MisappliedGroup;
import eu.etaxonomy.taxeditor.editor.name.dnd.NameEditorDropTargetListener;
+import eu.etaxonomy.taxeditor.model.AbstractUtility;
import eu.etaxonomy.taxeditor.model.IPartChangeListener;
import eu.etaxonomy.taxeditor.model.IPartContentHasDetails;
import eu.etaxonomy.taxeditor.model.TaxeditorPartService;
-import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
import eu.etaxonomy.taxeditor.preference.Resources;
+import eu.etaxonomy.taxeditor.security.RequiredPermissions;
+import eu.etaxonomy.taxeditor.session.ICdmEntitySession;
+import eu.etaxonomy.taxeditor.store.CdmStore;
/**
- * <p>TaxonNameEditor class.</p>
+ * <p>
+ * TaxonNameEditor class.
+ * </p>
*
* @author p.ciardelli
* @author n.hoffmann
* @created 15.05.2008
* @version 1.0
*/
-public class TaxonNameEditor extends EditorPart implements IMultiPageTaxonEditorPage, IAdaptable, IConversationEnabled, IPostOperationEnabled, IPartContentHasDetails, IPartChangeListener
- , ISelectionListener, IDropTargetable {
-
+public class TaxonNameEditor extends EditorPart implements
+ IMultiPageTaxonEditorPage, IConversationEnabled,
+ IPartContentHasDetails, IPartChangeListener,
+ ISelectionListener, IDropTargetable, ISecuredEditor {
+
/** Constant <code>ID="eu.etaxonomy.taxeditor.editor.taxon.name"</code> */
public static final String ID = "eu.etaxonomy.taxeditor.editor.taxon.name";
-
+
private Taxon taxon;
-
+
private ManagedForm managedForm;
- private ScrolledForm scrolledForm;
+ private ScrolledForm scrolledForm;
private Composite parent;
- private ISelectionProvider provider;
-
- private MultiPageTaxonEditor editor;
-
+ private ISelectionProvider simpleSelectionProvider;
+
+ private final MultiPageTaxonEditor editor;
+
private TaxonBase selection;
-
- private ConversationHolder conversation;
- private MenuManager menuManager;
+ private final ConversationHolder conversation;
+ private MenuManager menuManager;
private Menu menu;
+ private AcceptedGroup acceptedGroup;
+ private List<HomotypicalSynonymGroup> heterotypicSynonymGroups = new ArrayList<HomotypicalSynonymGroup>();
private MisappliedGroup misappliedGroup;
- private ConceptGroup conceptGroup;
-
- private List<HomotypicalSynonymGroup> heterotypicSynonymGroups = new ArrayList<HomotypicalSynonymGroup>();
-
private DropTarget target;
-
- private ISelectionService selectionService;
- private AcceptedGroup acceptedGroup;
+ private ISelectionService selectionService;
private TaxonBase objectAffectedByLastOperation;
-
+
+ private ICdmEntitySession cdmEntitySession;
+
/**
- * <p>Constructor for TaxonNameEditor.</p>
+ * <p>
+ * Constructor for TaxonNameEditor.
+ * </p>
*
- * @param editor a {@link eu.etaxonomy.taxeditor.editor.MultiPageTaxonEditor} object.
+ * @param editor
+ * a {@link eu.etaxonomy.taxeditor.editor.MultiPageTaxonEditor}
+ * object.
*/
- public TaxonNameEditor(MultiPageTaxonEditor editor){
+ public TaxonNameEditor(MultiPageTaxonEditor editor) {
this.editor = editor;
conversation = editor.getConversationHolder();
}
-
-
/**
- * <p>getUndoContext</p>
+ * <p>
+ * getUndoContext
+ * </p>
*
- * @return a {@link org.eclipse.core.commands.operations.IUndoContext} object.
+ * @return a {@link org.eclipse.core.commands.operations.IUndoContext}
+ * object.
*/
public IUndoContext getUndoContext() {
return editor.getUndoContext();
}
- /* (non-Javadoc)
- * @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets
+ * .Composite)
*/
/** {@inheritDoc} */
+ @Override
public void createPartControl(Composite composite) {
selectionService = getSite().getWorkbenchWindow().getSelectionService();
selectionService.addSelectionListener(this);
-
+
createManagedForm(composite);
-
- TaxeditorPartService.getInstance().addListener(TaxeditorPartService.PART_ACTIVATED, this);
+
+ TaxeditorPartService.getInstance().addListener(
+ TaxeditorPartService.PART_ACTIVATED, this);
}
-
+
/**
- * <p>createManagedForm</p>
+ * <p>
+ * createManagedForm
+ * </p>
*
- * @param composite a {@link org.eclipse.swt.widgets.Composite} object.
+ * @param composite
+ * a {@link org.eclipse.swt.widgets.Composite} object.
*/
protected void createManagedForm(Composite composite) {
-
+
managedForm = new ManagedForm(composite) {
-
+
+ @Override
public void dirtyStateChanged() {
firePropertyChange(PROP_DIRTY);
}
+
+ @Override
public boolean setInput(Object input) {
if (input instanceof AbstractGroupedContainer) {
selection = ((AbstractGroupedContainer) input).getData();
- provider.setSelection(new StructuredSelection(selection));
+ getSite().getSelectionProvider().setSelection(new StructuredSelection(selection));
+ }else if(input == null){
+ selection = null;
+ getSite().getSelectionProvider().setSelection(new StructuredSelection());
}
- return super.setInput(input);
+
+
+ return super.setInput(input);
}
};
-
-
+
scrolledForm = managedForm.getForm();
parent = scrolledForm.getBody();
-
+
// register the context menu
menuManager = new MenuManager();
ISelectionProvider selectionProvider = getSite().getSelectionProvider();
- getSite().registerContextMenu(TaxonNameEditor.ID, menuManager, selectionProvider);
-
+ getSite().registerContextMenu(TaxonNameEditor.ID, menuManager,
+ selectionProvider);
+
parent.setData(taxon);
-
+
TableWrapLayout layout = new TableWrapLayout();
layout.leftMargin = 0;
layout.rightMargin = 0;
layout.topMargin = 0;
layout.bottomMargin = 0;
-
+
layout.verticalSpacing = 0;
layout.horizontalSpacing = 0;
-
- parent.setLayout(layout);
- parent.setBackground(EditorUtil.getColor(Resources.COLOR_COMPOSITE_BACKGROUND));
-
+
+ parent.setLayout(layout);
+ parent.setBackground(AbstractUtility
+ .getColor(Resources.COLOR_COMPOSITE_BACKGROUND));
+
createOrUpdateNameComposites();
-
+
createDragSupport();
-
+
setFocus();
}
-
+
/**
- * <p>createNameComposites</p>
+ * <p>
+ * createNameComposites
+ * </p>
*/
- public void createOrUpdateNameComposites(){
-
+ public void createOrUpdateNameComposites() {
+// this.taxon = (Taxon)CdmStore.getService(ITaxonService.class).load(this.getTaxon().getUuid());
ContainerFactory.createOrUpdateAcceptedTaxonsHomotypicGroup(this);
ContainerFactory.createOrUpdateHeterotypicSynonymyGroups(this);
ContainerFactory.createOrUpdateMisapplicationsGroup(this);
- ContainerFactory.createOrUpdateConceptGroup(this);
-
+
+
// Redraw composite
managedForm.reflow(true);
}
-
-
-
/**
- * <p>Getter for the field <code>taxon</code>.</p>
+ * <p>
+ * Getter for the field <code>taxon</code>.
+ * </p>
*
* @return a {@link eu.etaxonomy.cdm.model.taxon.Taxon} object.
*/
public Taxon getTaxon() {
return (Taxon) HibernateProxyHelper.deproxy(taxon);
}
-
+
/**
- * <p>setDirty</p>
+ * <p>
+ * setDirty
+ * </p>
*/
public void setDirty() {
managedForm.dirtyStateChanged();
}
-
-
+
/*
* (non-Javadoc)
+ *
* @see org.eclipse.ui.part.WorkbenchPart#setFocus()
*/
/** {@inheritDoc} */
@Override
- public void setFocus(){
- if(getSelectedContainer() == null){
- throw new IllegalStateException("There should always be a selected object.");
+ public void setFocus() {
+ PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell().setFocus();
+ if (getSelectedContainer() == null) {
+ throw new IllegalStateException(
+ "There should always be a selected object.");
}
getSelectedContainer().setSelected();
+
+ // check permissions
+ boolean doEnable = permissionsSatisfied();
+ setEnabled(doEnable);
+ }
+
+ /* (non-Javadoc)
+ * @see eu.etaxonomy.taxeditor.editor.name.ISecuredEditorPart#permissionsSatisfied()
+ */
+ @Override
+ public boolean permissionsSatisfied() {
+ TaxonNode taxonNode = ((TaxonEditorInput)getEditorInput()).getTaxonNode();
+ boolean doEnable = CdmStore.currentAuthentiationHasPermission(taxonNode, RequiredPermissions.TAXONNODE_EDIT);
+ return doEnable;
}
-
+
/** {@inheritDoc} */
- public void setInput(IEditorInput input){
+ @Override
+ public void setInput(IEditorInput input) {
this.setInputWithNotify(input);
}
-
+
/*
* (non-Javadoc)
- * @see eu.etaxonomy.cdm.api.conversation.IConversationEnabled#getConversationHolder()
+ *
+ * @see
+ * eu.etaxonomy.cdm.api.conversation.IConversationEnabled#getConversationHolder
+ * ()
*/
/**
- * <p>getConversationHolder</p>
+ * <p>
+ * getConversationHolder
+ * </p>
*
- * @return a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder} object.
+ * @return a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder}
+ * object.
*/
- public ConversationHolder getConversationHolder(){
+ @Override
+ public ConversationHolder getConversationHolder() {
return conversation;
}
-
+
/*
* (non-Javadoc)
- * @see eu.etaxonomy.cdm.persistence.hibernate.ICdmPostCrudObserver#update(eu.etaxonomy.cdm.persistence.hibernate.CdmCrudEvent)
+ *
+ * @see
+ * eu.etaxonomy.cdm.persistence.hibernate.ICdmPostCrudObserver#update(eu
+ * .etaxonomy.cdm.persistence.hibernate.CdmCrudEvent)
*/
/** {@inheritDoc} */
- public void update(CdmDataChangeMap events) {
- //redraw();
+ @Override
+ public void update(CdmDataChangeMap events) {
+ // redraw();
}
-
+
/**
- * Redraws this editor
- * return true on success
+ * Redraws this editor return true on success
*
* @return a boolean.
*/
- public boolean redraw(){
+ @Override
+ public boolean redraw() {
return redraw(true);
}
-
+
/**
* {@inheritDoc}
*
* Redraws the editor controls
*/
- public boolean redraw(boolean focus) {
-
+ @Override
+ public boolean redraw(boolean focus) {
+
createOrUpdateNameComposites();
-
- if(focus){
+
+ if (focus) {
setFocus();
}
-
- return true;
+
+ return true;
}
-
/**
- * <p>getMultiPageTaxonEditor</p>
+ * <p>
+ * getMultiPageTaxonEditor
+ * </p>
*
- * @return a {@link eu.etaxonomy.taxeditor.editor.MultiPageTaxonEditor} object.
+ * @return a {@link eu.etaxonomy.taxeditor.editor.MultiPageTaxonEditor}
+ * object.
*/
public MultiPageTaxonEditor getMultiPageTaxonEditor() {
return editor;
}
-
/*
* (non-Javadoc)
- * @see eu.etaxonomy.taxeditor.store.operations.IPostOperationEnabled#postOperation()
+ *
+ * @see
+ * eu.etaxonomy.taxeditor.store.operations.IPostOperationEnabled#postOperation
+ * ()
*/
/** {@inheritDoc} */
- public boolean postOperation(CdmBase objectAffectedByOperation) {
-
+ @Override
+ public boolean postOperation(CdmBase objectAffectedByOperation) {
+
editor.changed(objectAffectedByOperation);
-
+
redraw(false);
-
- if(objectAffectedByOperation instanceof TaxonBase){
+
+ if (objectAffectedByOperation instanceof TaxonBase) {
objectAffectedByLastOperation = (TaxonBase) objectAffectedByOperation;
}
-
+
return true;
}
-
+
/**
- * <p>Getter for the field <code>managedForm</code>.</p>
+ * <p>
+ * Getter for the field <code>managedForm</code>.
+ * </p>
*
* @return the managedForm
*/
public ManagedForm getManagedForm() {
return managedForm;
}
-
+
/**
- * <p>getControl</p>
+ * <p>
+ * getControl
+ * </p>
*
* @return a {@link org.eclipse.swt.widgets.Composite} object.
*/
- public Composite getControl() {
+ @Override
+ public Composite getControl() {
return this.getManagedForm().getForm().getBody();
}
-
/**
- * <p>Getter for the field <code>menu</code>.</p>
+ * <p>
+ * Getter for the field <code>menu</code>.
+ * </p>
*
* @return the menu
*/
public Menu getMenu() {
- if(menu == null || menu.isDisposed()){
- // Creating the menu because it was either not initialised or disposed while refreshing the editor
+ if (menu == null || menu.isDisposed()) {
+ // Creating the menu because it was either not initialised or
+ // disposed while refreshing the editor
menu = menuManager.createContextMenu(parent);
}
return menu;
}
/**
- * <p>checkForEmptyNames</p>
+ * <p>
+ * checkForEmptyNames
+ * </p>
*
* @return true if there are empty names
*/
public boolean checkForEmptyNames() {
- for(AbstractGroupedContainer container : getGroupedContainers()){
- if(container.getName() == null || StringUtils.isEmpty(container.getName().getTitleCache())){
+ for (AbstractGroupedContainer container : getGroupedContainers()) {
+ if (container.getName() == null
+ || StringUtils.isEmpty(container.getName().getTitleCache())) {
return true;
}
}
return false;
}
-
- public Set<AbstractGroupedContainer> getEmptyContainers(){
+ public Set<AbstractGroupedContainer> getEmptyContainers() {
Set<AbstractGroupedContainer> containersWithEmptyNames = new HashSet<AbstractGroupedContainer>();
-
- for(AbstractGroupedContainer container : getGroupedContainers()){
- if(container.getName() == null || StringUtils.isEmpty(container.getName().getTitleCache())){
+
+ for (AbstractGroupedContainer container : getGroupedContainers()) {
+ if (container.getName() == null
+ || StringUtils.isEmpty(container.getName().getTitleCache())) {
containersWithEmptyNames.add(container);
}
}
-
+
return containersWithEmptyNames;
}
-
+
/** {@inheritDoc} */
@Override
public void doSave(IProgressMonitor monitor) {
monitor.beginTask("Saving names", getGroupedContainers().size());
- try {
+ try {
// check for empty names
- for(AbstractGroupedContainer container : getGroupedContainers()){
-
- monitor.subTask("Saving composite: " + container.getTaxonBase().getTitleCache());
+ for (AbstractGroupedContainer container : getGroupedContainers()) {
+
+ monitor.subTask("Saving composite: "
+ + container.getTaxonBase().getTitleCache());
container.persistName();
-
+
// In case the progress monitor was canceled throw an exception.
if (monitor.isCanceled()) {
- throw new OperationCanceledException();
- }
-
+ throw new OperationCanceledException();
+ }
+
// Otherwise declare this step as done.
monitor.worked(1);
}
- }
- finally {
-
- // Stop the progress monitor.
- monitor.done();
- }
-
+ } finally {
+
+ // Stop the progress monitor.
+ monitor.done();
+ }
+
}
/** {@inheritDoc} */
@Override
- public void doSaveAs() {}
+ public void doSaveAs() {
+ }
/** {@inheritDoc} */
@Override
public void init(IEditorSite site, IEditorInput input)
throws PartInitException {
-
- if (!(input instanceof IEditorInput))
- throw new PartInitException(
- "Invalid Input: Must be IEditorInput");
-
+
+ if (!(input != null)) {
+ throw new PartInitException("Invalid Input: Must be IEditorInput");
+ }
+
if (input.getAdapter(Taxon.class) != null) {
- taxon = (Taxon) input.getAdapter(Taxon.class);
+ taxon = CdmBase.deproxy(input.getAdapter(Taxon.class), Taxon.class);
} else {
- throw new PartInitException(
- "Invalid Input: Taxon cannot be null");
+ throw new PartInitException("Invalid Input: Taxon cannot be null");
}
setSite(site);
setInput(input);
-
- provider = new SimpleSelectionProvider();
- getSite().setSelectionProvider(provider);
+
+ simpleSelectionProvider = new SimpleSelectionProvider();
+ getSite().setSelectionProvider(simpleSelectionProvider);
}
-
+
+
/**
- *
+ *
*/
private void createDragSupport() {
// Listen for names being dragged outside of existing homotypic groups -
- // user wants to create a new group
- Transfer[] types = new Transfer[] {CdmDataTransfer.getInstance()};
+ // user wants to create a new group
+ Transfer[] types = new Transfer[] { CdmDataTransfer.getInstance() };
int operations = DND.DROP_MOVE;
- if(target == null){
+ if (target == null) {
target = new DropTarget(parent, operations);
target.setTransfer(types);
target.addDropListener(new NameEditorDropTargetListener(this));
- }
+ }
}
/**
- * <p>Getter for the field <code>acceptedNameContainer</code>.</p>
+ * <p>
+ * Getter for the field <code>acceptedNameContainer</code>.
+ * </p>
*
- * @return a {@link eu.etaxonomy.taxeditor.editor.name.container.AcceptedNameContainer} object.
+ * @return a
+ * {@link eu.etaxonomy.taxeditor.editor.name.container.AcceptedNameContainer}
+ * object.
*/
public AcceptedNameContainer getAcceptedNameContainer() {
return getAcceptedGroup().getAcceptedNameContainer();
}
-
+
/**
- * <p>getSynonymGroup</p>
+ * <p>
+ * getSynonymGroup
+ * </p>
*
- * @param homotypicalGroup a {@link eu.etaxonomy.cdm.model.name.HomotypicalGroup} object.
- * @return a {@link eu.etaxonomy.taxeditor.editor.name.container.HomotypicalSynonymGroup} object.
- */
- public HomotypicalSynonymGroup getHomotypicalGroupContainer(HomotypicalGroup homotypicalGroup) {
- for(HomotypicalSynonymGroup group : getHeterotypicSynonymGroups()){
- if(group.getGroup().equals(homotypicalGroup)){
+ * @param homotypicalGroup
+ * a {@link eu.etaxonomy.cdm.model.name.HomotypicalGroup} object.
+ * @return a
+ * {@link eu.etaxonomy.taxeditor.editor.name.container.HomotypicalSynonymGroup}
+ * object.
+ */
+ public HomotypicalSynonymGroup getHomotypicalGroupContainer(
+ HomotypicalGroup homotypicalGroup) {
+ for (HomotypicalSynonymGroup group : getHeterotypicSynonymGroups()) {
+ if (group.getGroup().equals(homotypicalGroup)) {
return group;
}
}
-
+
return null;
}
-
- /**
- * <p>Getter for the field <code>conceptGroup</code>.</p>
- *
- * @return a {@link eu.etaxonomy.taxeditor.editor.name.container.ConceptGroup} object.
- */
- public ConceptGroup getConceptGroup() {
- return conceptGroup;
- }
-
+
/**
- * <p>getDirtyNames</p>
+ * <p>
+ * getDirtyNames
+ * </p>
*
* @return a Set containing all composites that have been edited
*/
- public Set<AbstractGroupedContainer> getDirtyNames(){
+ public Set<AbstractGroupedContainer> getDirtyNames() {
Set<AbstractGroupedContainer> dirtyNames = new HashSet<AbstractGroupedContainer>();
-
- for(AbstractGroupedContainer composite : getGroupedContainers()){
- if(composite.isDirty()){
+
+ for (AbstractGroupedContainer composite : getGroupedContainers()) {
+ if (composite.isDirty()) {
dirtyNames.add(composite);
}
}
-
+
return dirtyNames;
}
-
+
/**
- * <p>getGroupedContainers</p>
+ * <p>
+ * getGroupedContainers
+ * </p>
*
* @return a {@link java.util.List} object.
*/
- public List<AbstractGroupedContainer> getGroupedContainers(){
+ public List<AbstractGroupedContainer> getGroupedContainers() {
List<AbstractGroupedContainer> groupedComposites = new ArrayList<AbstractGroupedContainer>();
-
- for(AbstractGroup group : getAllGroups()){
+
+ for (AbstractGroup group : getAllGroups()) {
groupedComposites.addAll(group.getGroupedContainers());
}
-
+
return groupedComposites;
}
-
+
/**
- * <p>getAllGroups</p>
+ * <p>
+ * getAllGroups
+ * </p>
*
* @return a {@link java.util.List} object.
*/
- public List<AbstractGroup> getAllGroups(){
+ public List<AbstractGroup> getAllGroups() {
List<AbstractGroup> allGroups = new ArrayList<AbstractGroup>();
-
+
allGroups.add(getAcceptedGroup());
-
- allGroups.addAll(getHeterotypicSynonymGroups());
-
- if(misappliedGroup != null){
- allGroups.add(misappliedGroup);
+
+// List<HomotypicalSynonymGroup> grps = getHeterotypicSynonymGroups(); // UNUSED => remove
+
+ heterotypicSynonymGroups = getHeterotypicSynonymGroups();
+
+ if (heterotypicSynonymGroups != null) {
+ allGroups.addAll(heterotypicSynonymGroups);
}
-
- if(conceptGroup != null){
- allGroups.add(conceptGroup);
+
+ if (misappliedGroup != null) {
+ allGroups.add(misappliedGroup);
}
-
+
return allGroups;
}
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
+ *
* @see org.eclipse.ui.part.EditorPart#isDirty()
*/
/** {@inheritDoc} */
public boolean isDirty() {
return editor.isDirty();
}
-
- /* (non-Javadoc)
+
+ /*
+ * (non-Javadoc)
+ *
* @see org.eclipse.ui.part.WorkbenchPart#dispose()
*/
/** {@inheritDoc} */
@Override
public void dispose() {
+ conversation.unregisterForDataStoreChanges(this);
super.dispose();
}
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
+ *
* @see org.eclipse.ui.part.EditorPart#isSaveAsAllowed()
*/
/** {@inheritDoc} */
public boolean isSaveAsAllowed() {
return false;
}
-
+
/*
* (non-Javadoc)
- * @see org.eclipse.ui.ISelectionListener#selectionChanged(org.eclipse.ui.IWorkbenchPart, org.eclipse.jface.viewers.ISelection)
+ *
+ * @see org.eclipse.ui.ISelectionListener#selectionChanged(org.eclipse.ui.
+ * IWorkbenchPart, org.eclipse.jface.viewers.ISelection)
*/
/** {@inheritDoc} */
- public void selectionChanged(IWorkbenchPart part, ISelection selection) {
-
+ @Override
+ public void selectionChanged(IWorkbenchPart part, ISelection selection) {
+
}
/**
- * <p>getNameEditor</p>
+ * <p>
+ * getNameEditor
+ * </p>
*
- * @return a {@link eu.etaxonomy.taxeditor.editor.name.TaxonNameEditor} object.
+ * @return a {@link eu.etaxonomy.taxeditor.editor.name.TaxonNameEditor}
+ * object.
*/
- public TaxonNameEditor getEditor() {
+ @Override
+ public TaxonNameEditor getEditor() {
return this;
}
/**
- * <p>Getter for the field <code>selectedObject</code>.</p>
+ * <p>
+ * Getter for the field <code>selectedObject</code>.
+ * </p>
*
- * @return a {@link eu.etaxonomy.taxeditor.editor.name.container.AbstractGroupedContainer} object.
+ * @return a
+ * {@link eu.etaxonomy.taxeditor.editor.name.container.AbstractGroupedContainer}
+ * object.
*/
- public AbstractGroupedContainer getSelectedContainer(){
-
+ public AbstractGroupedContainer getSelectedContainer() {
+
TaxonBase selectedTaxonBase = null;
-
+
TaxonEditorInput input = (TaxonEditorInput) editor.getEditorInput();
- if(input.getInitiallySelectedTaxonBase() != null){
+ if (input.getInitiallySelectedTaxonBase() != null) {
selectedTaxonBase = input.getInitiallySelectedTaxonBase();
- }else{
- if(selection != null){
+ } else {
+ if (selection != null) {
selectedTaxonBase = selection;
}
}
-
- return (selectedTaxonBase != null) ? getContainer(selectedTaxonBase) : getAcceptedNameContainer();
+
+ return (selectedTaxonBase != null) ? getContainer(selectedTaxonBase)
+ : getAcceptedNameContainer();
}
-
+
/**
- * <p>dragEntered</p>
+ * <p>
+ * dragEntered
+ * </p>
*/
- public void dragEntered() {
+ @Override
+ public void dragEntered() {
// TODO change this
- getControl().setBackground(EditorUtil.getColor(Resources.COLOR_DRAG_ENTER));
+ getControl().setBackground(
+ AbstractUtility.getColor(Resources.COLOR_DRAG_ENTER));
}
/**
- * <p>dragLeft</p>
+ * <p>
+ * dragLeft
+ * </p>
*/
- public void dragLeft() {
- getControl().setBackground(EditorUtil.getColor(Resources.COLOR_COMPOSITE_BACKGROUND));
+ @Override
+ public void dragLeft() {
+ getControl().setBackground(
+ AbstractUtility.getColor(Resources.COLOR_COMPOSITE_BACKGROUND));
}
- /**
- * <p>Setter for the field <code>conceptGroup</code>.</p>
- *
- * @param conceptGroup a {@link eu.etaxonomy.taxeditor.editor.name.container.ConceptGroup} object.
- */
- public void setConceptGroup(ConceptGroup conceptGroup) {
- this.conceptGroup = conceptGroup;
- }
/**
- * <p>setMisapplicationsGroup</p>
+ * <p>
+ * setMisapplicationsGroup
+ * </p>
*
- * @param misappliedGroup a {@link eu.etaxonomy.taxeditor.editor.name.container.MisappliedGroup} object.
+ * @param misappliedGroup
+ * a
+ * {@link eu.etaxonomy.taxeditor.editor.name.container.MisappliedGroup}
+ * object.
*/
public void setMisapplicationsGroup(MisappliedGroup misappliedGroup) {
this.misappliedGroup = misappliedGroup;
/*
* (non-Javadoc)
- * @see eu.etaxonomy.taxeditor.editor.IMultiPageTaxonEditorPage#isRedrawing()
+ *
+ * @see
+ * eu.etaxonomy.taxeditor.editor.IMultiPageTaxonEditorPage#isRedrawing()
*/
/**
- * <p>isRedrawing</p>
+ * <p>
+ * isRedrawing
+ * </p>
*
* @return a boolean.
*/
- public boolean isRedrawing() {
+ @Override
+ public boolean isRedrawing() {
return false;
}
/**
- * <p>getToolkit</p>
+ * <p>
+ * getToolkit
+ * </p>
*
* @return a {@link org.eclipse.ui.forms.widgets.FormToolkit} object.
*/
}
/**
- * <p>getHeterotypicSynonymGroups</p>
+ * <p>
+ * getHeterotypicSynonymGroups
+ * </p>
*
* @return a {@link java.util.List} object.
*/
- public List<HomotypicalSynonymGroup> getHeterotypicSynonymGroups(){
+ public List<HomotypicalSynonymGroup> getHeterotypicSynonymGroups() {
return heterotypicSynonymGroups;
}
-
/**
- * <p>addHeterotypicSynonymGroup</p>
+ * <p>
+ * addHeterotypicSynonymGroup
+ * </p>
*
- * @param group a {@link eu.etaxonomy.taxeditor.editor.name.container.HomotypicalSynonymGroup} object.
+ * @param group
+ * a
+ * {@link eu.etaxonomy.taxeditor.editor.name.container.HomotypicalSynonymGroup}
+ * object.
*/
public void addHeterotypicSynonymGroup(HomotypicalSynonymGroup group) {
heterotypicSynonymGroups.add(group);
}
-
+
/**
- * <p>getHomotypicSynonymGroup</p>
+ * <p>
+ * getHomotypicSynonymGroup
+ * </p>
*
- * @return a {@link eu.etaxonomy.taxeditor.editor.name.container.HomotypicalSynonymGroup} object.
+ * @return a
+ * {@link eu.etaxonomy.taxeditor.editor.name.container.HomotypicalSynonymGroup}
+ * object.
*/
public AcceptedGroup getAcceptedGroup() {
return acceptedGroup;
}
-
-
/**
- *
+ *
* @param acceptedGroup
*/
- public void setAcceptedGroup(
- AcceptedGroup acceptedGroup) {
+ public void setAcceptedGroup(AcceptedGroup acceptedGroup) {
this.acceptedGroup = acceptedGroup;
}
/**
- * <p>Getter for the field <code>misappliedGroup</code>.</p>
+ * <p>
+ * Getter for the field <code>misappliedGroup</code>.
+ * </p>
*
- * @return a {@link eu.etaxonomy.taxeditor.editor.name.container.MisappliedGroup} object.
+ * @return a
+ * {@link eu.etaxonomy.taxeditor.editor.name.container.MisappliedGroup}
+ * object.
*/
public MisappliedGroup getMisappliedGroup() {
return misappliedGroup;
// TODO not very useful at the moment
/**
- * <p>isActive</p>
+ * <p>
+ * isActive
+ * </p>
*
* @return a boolean.
*/
- public boolean isActive(){
- IWorkbenchPart activePart = EditorUtil.getActivePart();
+ public boolean isActive() {
+ IWorkbenchPart activePart = AbstractUtility.getActivePart();
return editor.equals(activePart);
}
/**
- * <p>onComplete</p>
+ * <p>
+ * onComplete
+ * </p>
*
* @return a boolean.
*/
- public boolean onComplete() {
+ @Override
+ public boolean onComplete() {
getContainer(objectAffectedByLastOperation).setSelected();
return true;
}
-
-
/** {@inheritDoc} */
- public void partChanged(Integer eventType, IWorkbenchPartReference partRef) {
- if(! partRef.getPart(false).equals(editor)){
-// getSelectedObject().colorSelected(AbstractGroupedContainer.SELECTED_NO_FOCUS);
+ @Override
+ public void partChanged(Integer eventType, IWorkbenchPartReference partRef) {
+ if (!partRef.getPart(false).equals(editor)) {
+ // getSelectedObject().colorSelected(AbstractGroupedContainer.SELECTED_NO_FOCUS);
}
}
-
-
/**
* @param retainedGroup
*/
public void removeGroup(AbstractGroup group) {
- if(group != null){
+ if (group != null) {
group.dispose();
- getHeterotypicSynonymGroups().remove(group);
+
+ //if (heterotypicSynonymGroups != null) {
+ heterotypicSynonymGroups.remove(group);
+ //}
}
}
*/
public AbstractGroupedContainer getContainer(TaxonBase taxonBase) {
List<AbstractGroupedContainer> groupedContainers = getGroupedContainers();
- for(AbstractGroupedContainer container : groupedContainers){
- if(container.getData().equals(taxonBase) && container.getNameViewer().getTextWidget() != null){
+ for (AbstractGroupedContainer container : groupedContainers) {
+ if (container.getData().equals(taxonBase)
+ && container.getNameViewer().getTextWidget() != null) {
return container;
}
}
return getAcceptedNameContainer();
}
+
+ /* (non-Javadoc)
+ * @see eu.etaxonomy.taxeditor.editor.IMultiPageTaxonEditorPage#setOnError()
+ */
+ @Override
+ public void setOnError() {
+ Color disabledColor = AbstractUtility.getColor(Resources.COLOR_EDITOR_ERROR);
+ setEnabled(false, disabledColor);
+ }
+
+ /* (non-Javadoc)
+ * @see eu.etaxonomy.taxeditor.editor.IMultiPageTaxonEditorPage#setDisabled()
+ */
+ @Override
+ public void setDisabled(){
+ Color disabledColor = AbstractUtility.getColor(Resources.COLOR_TEXT_DISABLED_BACKGROUND);
+ setEnabled(false);
+ }
+
+ protected void setEnabled(boolean enabled, Color background) {
+
+ for(AbstractGroupedContainer groupedContainer : getGroupedContainers()){
+ groupedContainer.setEnabled(enabled);
+ }
+
+ // send an empty selection to the current provider - TODO only on error ???
+ if (!enabled) {
+ getManagedForm().setInput(null);
+
+ for (AbstractGroupedContainer groupedContainer : getGroupedContainers()) {
+ groupedContainer.setBackground(background);
+ }
+ }
+ getControl().setBackground(background);
+ }
+
+ @Override
+ public void setEnabled(boolean enabled) {
+ Color background = AbstractUtility.getColor(enabled ? Resources.COLOR_COMPOSITE_BACKGROUND : Resources.COLOR_TEXT_DISABLED_BACKGROUND);
+ setEnabled(enabled, background);
+ }
+
+
+
}