eu.etaxonomy.taxeditor.cdmlib/lib/opencsv-2.3.jar -text
eu.etaxonomy.taxeditor.cdmlib/lib/org.apache.commons.codec-1.3.0.jar -text
eu.etaxonomy.taxeditor.cdmlib/lib/org.eclipse.equinox.common-3.6.0.v20110523.jar -text
+eu.etaxonomy.taxeditor.cdmlib/lib/org.eclipse.osgi-3.7.2.v20120110-1415.jar -text
eu.etaxonomy.taxeditor.cdmlib/lib/org.osgi.core-1.0.0.jar -text
eu.etaxonomy.taxeditor.cdmlib/lib/org.springframework.aop-3.2.2.RELEASE-sources.jar -text
eu.etaxonomy.taxeditor.cdmlib/lib/org.springframework.aop-3.2.2.RELEASE.jar -text
<classpathentry exported="true" kind="lib" path="lib/cdmlib-io-3.2.0-SNAPSHOT-sources.jar"/>
<classpathentry exported="true" kind="lib" path="lib/cdmlib-io-3.2.0-SNAPSHOT.jar"/>
<classpathentry exported="true" kind="lib" path="lib/cdmlib-model-3.2.0-SNAPSHOT-sources.jar"/>
- <classpathentry exported="true" kind="lib" path="lib/cdmlib-model-3.2.0-SNAPSHOT.jar"/>
+ <classpathentry exported="true" kind="lib" path="lib/cdmlib-model-3.2.0-SNAPSHOT.jar" sourcepath="lib/cdmlib-model-3.2.0-SNAPSHOT-sources.jar"/>
<classpathentry exported="true" kind="lib" path="lib/cdmlib-persistence-3.2.0-SNAPSHOT-sources.jar"/>
<classpathentry exported="true" kind="lib" path="lib/cdmlib-persistence-3.2.0-SNAPSHOT.jar"/>
<classpathentry exported="true" kind="lib" path="lib/cdmlib-print-3.2.0-SNAPSHOT-sources.jar"/>
<classpathentry exported="true" kind="lib" path="lib/cdmlib-remote-3.2.0-SNAPSHOT-sources.jar"/>
<classpathentry exported="true" kind="lib" path="lib/cdmlib-remote-3.2.0-SNAPSHOT.jar"/>
<classpathentry exported="true" kind="lib" path="lib/cdmlib-services-3.2.0-SNAPSHOT-sources.jar"/>
- <classpathentry exported="true" kind="lib" path="lib/cdmlib-services-3.2.0-SNAPSHOT.jar"/>
+ <classpathentry exported="true" kind="lib" path="lib/cdmlib-services-3.2.0-SNAPSHOT.jar" sourcepath="lib/cdmlib-services-3.2.0-SNAPSHOT-sources.jar"/>
<classpathentry exported="true" kind="lib" path="lib/cglib-2.1.3.jar"/>
<classpathentry exported="true" kind="lib" path="lib/cglib-nodep-2.2.2.jar"/>
<classpathentry exported="true" kind="lib" path="lib/com.springsource.org.aopalliance-1.0.0.jar"/>
/**
* 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 eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap;
import eu.etaxonomy.taxeditor.editor.name.TaxonNameEditor;
import eu.etaxonomy.taxeditor.editor.name.container.AbstractGroupedContainer;
+import eu.etaxonomy.taxeditor.model.AbstractUtility;
import eu.etaxonomy.taxeditor.model.DataChangeBridge;
import eu.etaxonomy.taxeditor.model.IDataChangeBehavior;
import eu.etaxonomy.taxeditor.model.IDirtyMarkableSelectionProvider;
import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
/**
- *
+ *
* Generates the tabbed editor with <code>TaxonNameEditor</code> on top and tabs
* for "Descriptions", "Concepts", "Geography", etc.
- *
+ *
* @author p.ciardelli
* @author n.hoffmann
* @created 15.05.2008
/*
* (non-Javadoc)
- *
+ *
* @see org.eclipse.ui.forms.editor.FormEditor#addPages()
*/
/** {@inheritDoc} */
// EditorUtil.showPropertySheet();
} catch (PartInitException e) {
- EditorUtil.error(getClass(), e);
+ AbstractUtility.error(getClass(), e);
}
}
}
monitor.worked(1);
- for (IEditorPart editorPage : getPages()) {
- if (editorPage instanceof TaxonNameEditor) {
- if (((TaxonNameEditor) editorPage).checkForEmptyNames()) {
- MessageDialog
- .openWarning(
- EditorUtil.getShell(),
- "No Name Specified",
- "An attempt was made to save a taxon or synonym with "
- + "an empty name. Operation was cancelled.");
- return;
- }
- }
-
- editorPage.doSave(monitor);
- monitor.worked(1);
- }
+ for (IEditorPart editorPage : getPages()) {
+ if (editorPage instanceof TaxonNameEditor) {
+ if (((TaxonNameEditor) editorPage).checkForEmptyNames()) {
+ MessageDialog.openWarning(AbstractUtility.getShell(), "No Name Specified",
+ "An attempt was made to save a taxon or synonym with "
+ + "an empty name. Operation was cancelled.");
+ return;
+ }
+ }
+
+ editorPage.doSave(monitor);
+ monitor.worked(1);
+ }
// commit the conversation and start a new transaction immediately
conversation.commit(true);
monitor.worked(1);
- this.setDirty(false);
- monitor.worked(1);
- } catch (Exception e) {
- setFocus();
- EditorUtil
- .errorDialog(
- "An error occurred while saving",
- getClass(),
- "An error occurred while saving the editor. Please close and reopen the taxon again.",
- e);
- disableEditor(true);
- } finally {
- monitor.done();
- }
+ this.setDirty(false);
+ monitor.worked(1);
+ } catch (Exception e) {
+ setFocus();
+ AbstractUtility.errorDialog("An error occurred while saving", getClass(),
+ "An error occurred while saving the editor. Please close and reopen the taxon again.", e);
+ disableEditor(true);
+ } finally {
+ monitor.done();
+ }
}
private void disableEditor(boolean isOnError) {
if(isOnError){
editorPage.setOnError();
}else {
- editorPage.setDisabled();
+ editorPage.setDisabled();
}
}
conversation.unregisterForDataStoreChanges(this);
/*
* (non-Javadoc)
- *
+ *
* @see org.eclipse.ui.part.MultiPageEditorPart#isDirty()
*/
/**
* <p>
* isDirty
* </p>
- *
+ *
* @return a boolean.
*/
- public boolean isDirty() {
+ @Override
+ public boolean isDirty() {
return dirty;
}
/*
* (non-Javadoc)
- *
+ *
* @see org.eclipse.ui.forms.editor.FormEditor#editorDirtyStateChanged()
*/
/** {@inheritDoc} */
/**
* {@inheritDoc}
- *
+ *
* Checks whether nested editors are calling
* <code>firePropertyChange(PROP_DIRTY)</code> to signal an edit has taken
* place before passing property change along to
*/
/*
* (non-Javadoc)
- *
+ *
* @see org.eclipse.ui.part.MultiPageEditorPart#handlePropertyChange(int)
*/
- protected void handlePropertyChange(int propertyId) {
+ @Override
+ protected void handlePropertyChange(int propertyId) {
if (propertyId == PROP_DIRTY) {
setDirty(true);
}
public void init(IEditorSite site, IEditorInput input)
throws PartInitException {
- if (!(input instanceof TaxonEditorInput))
- throw new PartInitException(
+ if (!(input instanceof TaxonEditorInput)) {
+ throw new PartInitException(
"Invalid Input: Must be TaxonEditorInput");
+ }
this.input = (TaxonEditorInput) input;
setPartName(partName);
}
- /**
- * {@inheritDoc}
- *
- * Editor pages call this in their postOperation to notify the
- * MultiPageTaxonEditor of unsaved changes
- */
- public void changed(Object element) {
- // setDirty(true);
- dirty = true;
- super.editorDirtyStateChanged();
- if (element instanceof TaxonBase) {
- TaxonNameEditor page = (TaxonNameEditor) getPage(Page.NAME);
- AbstractGroupedContainer container = page
- .getContainer((TaxonBase) element);
- if (container != null) {
- container.refresh();
- }
- }
- }
+ /**
+ * {@inheritDoc}
+ *
+ * Editor pages call this in their postOperation to notify the
+ * MultiPageTaxonEditor of unsaved changes
+ */
+ @Override
+ public void changed(Object element) {
+ // setDirty(true);
+ dirty = true;
+ super.editorDirtyStateChanged();
+ if (element instanceof TaxonBase) {
+ TaxonNameEditor page = (TaxonNameEditor) getPage(Page.NAME);
+ AbstractGroupedContainer container = page.getContainer((TaxonBase) element);
+ if (container != null) {
+ container.refresh();
+ }
+ }
+ }
/**
* The accepted taxon that is the input for this editor
- *
+ *
* @return the accepted taxon
*/
public Taxon getTaxon() {
/*
* (non-Javadoc)
- *
+ *
* @see
* eu.etaxonomy.cdm.api.conversation.IConversationEnabled#getConversationHolder
* ()
* <p>
* getConversationHolder
* </p>
- *
+ *
* @return a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder}
* object.
*/
- public ConversationHolder getConversationHolder() {
+ @Override
+ public ConversationHolder getConversationHolder() {
return conversation;
}
* <p>
* setConversationHolder
* </p>
- *
+ *
* @param conversation
* a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder}
* object.
* <p>
* Getter for the field <code>undoContext</code>.
* </p>
- *
+ *
* @return a {@link org.eclipse.core.commands.operations.IUndoContext}
* object.
*/
* <p>
* Setter for the field <code>undoContext</code>.
* </p>
- *
+ *
* @param undoContext
* a {@link org.eclipse.core.commands.operations.IUndoContext}
* object.
getActiveEditor().setFocus();
}
- /*
- * (non-Javadoc)
- *
- * @see
- * eu.etaxonomy.cdm.persistence.hibernate.ICdmPostCrudObserver#update(eu
- * .etaxonomy.cdm.persistence.hibernate.CdmCrudEvent)
- */
- /** {@inheritDoc} */
- public void update(CdmDataChangeMap events) {
- if (dataChangeBehavior == null) {
- dataChangeBehavior = new MultiPageTaxonEditorDataChangeBehaviour(
- this);
- }
-
- DataChangeBridge.handleDataChange(events, dataChangeBehavior);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * eu.etaxonomy.taxeditor.store.operations.IPostOperationEnabled#postOperation
- * ()
- */
- /** {@inheritDoc} */
- public boolean postOperation(CdmBase objectAffectedByOperation) {
- setDirty(true);
-
- for (IEditorPart editor : this.getPages()) {
- if (editor instanceof IPostOperationEnabled) {
- ((IPostOperationEnabled) editor)
- .postOperation(objectAffectedByOperation);
- } else {
- EditorUtil.warn(getClass(),
- "postOperation not enabled for editor " + editor);
- }
- }
- EditorUtil
- .warn(getClass(),
- "postOperation called on MultiPageTaxonEditor. Can you make it more specific?");
-
- return false;
- }
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * eu.etaxonomy.cdm.persistence.hibernate.ICdmPostCrudObserver#update(eu
+ * .etaxonomy.cdm.persistence.hibernate.CdmCrudEvent)
+ */
+ /** {@inheritDoc} */
+ @Override
+ public void update(CdmDataChangeMap events) {
+ if (dataChangeBehavior == null) {
+ dataChangeBehavior = new MultiPageTaxonEditorDataChangeBehaviour(this);
+ }
+
+ DataChangeBridge.handleDataChange(events, dataChangeBehavior);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * eu.etaxonomy.taxeditor.store.operations.IPostOperationEnabled#postOperation
+ * ()
+ */
+ /** {@inheritDoc} */
+ @Override
+ public boolean postOperation(CdmBase objectAffectedByOperation) {
+ setDirty(true);
+
+ for (IEditorPart editor : this.getPages()) {
+ if (editor instanceof IPostOperationEnabled) {
+ ((IPostOperationEnabled) editor).postOperation(objectAffectedByOperation);
+ } else {
+ AbstractUtility.warn(getClass(), "postOperation not enabled for editor " + editor);
+ }
+ }
+ AbstractUtility.warn(getClass(), "postOperation called on MultiPageTaxonEditor. Can you make it more specific?");
+
+ return false;
+ }
/**
* Returns an <code>IEditorPart</code> implementation by type
- *
+ *
* @param page
* the page type
* @return a {@link eu.etaxonomy.taxeditor.editor.IMultiPageTaxonEditorPage}
/**
* Return a list of <code>AbstractTaxonEditor</code>s registered with this
* <code>MultiPageTaxonEditor</code>.
- *
+ *
* @return a {@link java.util.List} object.
*/
public List<IMultiPageTaxonEditorPage> getPages() {
/**
* Refreshes a certain page of the MultipageTaxonEditor
- *
+ *
* @param page
* a {@link eu.etaxonomy.taxeditor.editor.Page} object.
* @return a boolean.
/**
* Refreshes a certain page of the MultipageTaxonEditor and sets focus to
* that page
- *
+ *
* @param page
* a {@link eu.etaxonomy.taxeditor.editor.Page} object.
* @param focus
* <p>
* onComplete
* </p>
- *
+ *
* @return a boolean.
*/
- public boolean onComplete() {
+ @Override
+ public boolean onComplete() {
return false;
}
- /**
- * Reloads the data for this
- */
- public void reload() {
- if (isDirty()) {
- EditorUtil
- .warningDialog(
- "Editor has unsaved data",
- getClass(),
- "This editor can not be "
- + "refreshed because it contains unsaved data. Refreshing "
- + "this editor would discard the changes. Please save this editor, "
- + "close and reopen it manually in order to get the latest content");
- } else {
- TaxonEditorInput input = (TaxonEditorInput) getEditorInput();
-
- UUID uuid = input.getTaxonNode().getUuid();
-
- conversation.clear();
-
- try {
- TaxonEditorInput newInput = TaxonEditorInput.NewInstance(uuid);
- setInput(newInput);
- for (IMultiPageTaxonEditorPage editorPart : getPages()) {
- editorPart.redraw();
- }
- } catch (Exception e) {
- EditorUtil.errorDialog("Error refreshing editor", getClass(),
- "Could not refresh this editor", e);
- }
- }
- }
-
+ /**
+ * Reloads the data for this
+ */
+ public void reload() {
+ if (isDirty()) {
+ AbstractUtility.warningDialog("Editor has unsaved data", getClass(), "This editor can not be "
+ + "refreshed because it contains unsaved data. Refreshing "
+ + "this editor would discard the changes. Please save this editor, "
+ + "close and reopen it manually in order to get the latest content");
+ } else {
+ TaxonEditorInput input = (TaxonEditorInput) getEditorInput();
+
+ UUID uuid = input.getTaxonNode().getUuid();
+
+ conversation.clear();
+
+ try {
+ TaxonEditorInput newInput = TaxonEditorInput.NewInstance(uuid);
+ setInput(newInput);
+ for (IMultiPageTaxonEditorPage editorPart : getPages()) {
+ editorPart.redraw();
+ }
+ } catch (Exception e) {
+ AbstractUtility.errorDialog("Error refreshing editor", getClass(), "Could not refresh this editor", e);
+ }
+ }
+ }
+
@Override
public String toString() {
return String.format("%s[%s]", this.getClass().getSimpleName(), getEditorInput());
/**\r
* Copyright (C) 2011 EDIT\r
- * European Distributed Institute of Taxonomy \r
+ * European Distributed Institute of Taxonomy\r
* http://www.e-taxonomy.eu\r
- * \r
+ *\r
* The contents of this file are subject to the Mozilla Public License Version 1.1\r
* See LICENSE.TXT at the top of this package for the full license terms.\r
*/\r
import eu.etaxonomy.taxeditor.editor.view.descriptive.DescriptionElementDropAdapter;\r
import eu.etaxonomy.taxeditor.editor.view.descriptive.DescriptionElementTransfer;\r
import eu.etaxonomy.taxeditor.editor.view.descriptive.DescriptiveViewPart;\r
-import eu.etaxonomy.taxeditor.model.IPartContentHasDetails;\r
-import eu.etaxonomy.taxeditor.model.IPartContentHasSupplementalData;\r
\r
\r
/**\r
- * The Class create a speific Use View to keep the taxonomic view clean\r
- * @author a.theys \r
+ * The Class create a specific Use View to keep the taxonomic view clean\r
+ * @author a.theys\r
* @created mar 13, 2012\r
* @version 1.0\r
*/\r
-public class UsesViewPart extends DescriptiveViewPart implements IPartContentHasDetails, IPartContentHasSupplementalData {\r
+public class UsesViewPart extends DescriptiveViewPart {\r
\r
/** Constant <code>ID="eu.etaxonomy.taxeditor.editor.view.uses"</code> */\r
public static final String ID = "eu.etaxonomy.taxeditor.editor.view.uses";\r
/** {@inheritDoc} */\r
@Override\r
public void createViewer(Composite parent) {\r
- \r
+\r
viewer = new TreeViewer(new Tree(parent, SWT.MULTI | SWT.H_SCROLL\r
| SWT.V_SCROLL | SWT.FULL_SELECTION));\r
viewer.setContentProvider(new UsesContentProvider(featureNodeContainerCache));\r
viewer.setLabelProvider(new UsesLabelProvider());\r
viewer.setAutoExpandLevel(2);\r
- \r
- \r
- \r
+\r
+\r
+\r
Transfer[] transfers = new Transfer[] { DescriptionElementTransfer.getInstance() };\r
viewer.addDragSupport(dndOperations, transfers, new DescriptionElementDragListener(\r
this));\r
viewer.addDropSupport(dndOperations, transfers,\r
new DescriptionElementDropAdapter(viewer));\r
- \r
+\r
// Propagate selection from viewer\r
getSite().setSelectionProvider(viewer);\r
- \r
- showAllElementsAction = new ToggleDescriptionAction(false); \r
+\r
+ showAllElementsAction = new ToggleDescriptionAction(false);\r
hideAllElementsAction = new ToggleDescriptionAction(true);\r
- \r
+\r
// Add context menu to tree\r
createMenu();\r
- \r
+\r
createToolbar();\r
\r
}\r
- \r
+\r
/** {@inheritDoc} */\r
@Override\r
public boolean postOperation(CdmBase objectAffectedByOperation) {\r
viewer.refresh();\r
return super.postOperation(objectAffectedByOperation);\r
}\r
- \r
+\r
\r
\r
}\r
/**
* 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 eu.etaxonomy.cdm.model.taxon.TaxonBase;
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
import eu.etaxonomy.taxeditor.editor.EditorUtil;
-import eu.etaxonomy.taxeditor.editor.OpenEditorConfiguration;
import eu.etaxonomy.taxeditor.editor.TaxonEditorInput;
import eu.etaxonomy.taxeditor.editor.internal.TaxeditorEditorPlugin;
import eu.etaxonomy.taxeditor.model.AbstractUtility;
*/
public class NavigationUtil extends AbstractUtility{
private static IUndoContext defaultUndoContext;
-
+
/**
* <p>executeEditHandler</p>
*/
public static void executeEditHandler(){
String commandId = "eu.etaxonomy.taxeditor.navigation.command.editSelection";
-
- IHandlerService handlerService = (IHandlerService) NavigationUtil.getService(IHandlerService.class);
+
+ IHandlerService handlerService = (IHandlerService) AbstractUtility.getService(IHandlerService.class);
try {
handlerService.executeCommand(commandId, null);
} catch (ExecutionException e) {
- NavigationUtil.error(NavigationUtil.class, e);
+ AbstractUtility.error(NavigationUtil.class, e);
} catch (NotDefinedException e) {
- NavigationUtil.error(NavigationUtil.class, e);
+ AbstractUtility.error(NavigationUtil.class, e);
} catch (NotEnabledException e) {
- NavigationUtil.error(NavigationUtil.class, e);
+ AbstractUtility.error(NavigationUtil.class, e);
} catch (NotHandledException e) {
- NavigationUtil.error(NavigationUtil.class, e);
+ AbstractUtility.error(NavigationUtil.class, e);
}
}
-
+
/**
* <p>openEditor</p>
*
* @param selectedObject a {@link eu.etaxonomy.cdm.model.common.CdmBase} object.
*/
public static void openEditor(ICdmBase selectedObject){
- UUID entityUuid = selectedObject.getUuid();
- try {
+ UUID entityUuid = selectedObject.getUuid();
+ try {
if(selectedObject instanceof TaxonNode){
EditorUtil.openTaxonNode(entityUuid);
}else if(selectedObject instanceof TaxonBase){
warningDialog("Unsupported Type", NavigationUtil.class, "No editor exists for the current selection: " + selectedObject);
}
} catch (PartInitException e) {
- NavigationUtil.error(NavigationUtil.class, "Error opening the editor", e);
+ AbstractUtility.error(NavigationUtil.class, "Error opening the editor", e);
} catch (Exception e) {
- EditorUtil.warningDialog("Could not create Taxon", NavigationUtil.class, e.getMessage());
+ AbstractUtility.warningDialog("Could not create Taxon", NavigationUtil.class, e.getMessage());
}
}
-
+
public static void openEditor(Object selectedObject){
if (selectedObject instanceof UuidAndTitleCache){
Class type = ((UuidAndTitleCache) selectedObject).getType();
try {
EditorUtil.openTaxonBase(((UuidAndTitleCache) selectedObject).getUuid());
} catch (PartInitException e) {
- NavigationUtil.error(NavigationUtil.class, "Error opening the editor", e);
+ AbstractUtility.error(NavigationUtil.class, "Error opening the editor", e);
}
}
}else if(selectedObject instanceof ICdmBase){
- openEditor((ICdmBase) selectedObject);
+ openEditor((ICdmBase) selectedObject);
}else{
- NavigationUtil.error(NavigationUtil.class, new IllegalArgumentException("Selected object is not supported: " + selectedObject));
+ AbstractUtility.error(NavigationUtil.class, new IllegalArgumentException("Selected object is not supported: " + selectedObject));
}
}
-
+
/**
* <p>openEmpty</p>
*
try {
EditorUtil.openEmpty(parentNodeUuid);
} catch (PartInitException e) {
- NavigationUtil.error(NavigationUtil.class, "Error opening the editor", e);
+ AbstractUtility.error(NavigationUtil.class, "Error opening the editor", e);
}
}
-
+
/**
* <p>getShell</p>
*
return TaxeditorNavigationPlugin.getDefault().getWorkbench().
getActiveWorkbenchWindow();
}
-
+
/**
* <p>getWorkbenchUndoContext</p>
*
public static IUndoContext getUndoContext() {
// FIXME this has to be more specific. Every widget has to have its own undo context
// return IOperationHistory.GLOBAL_UNDO_CONTEXT;
-
- // Plug-ins that wish their operations to be undoable from workbench views
- // such as the Navigator or Package Explorer should assign the workbench
- // undo context to their operations.
+
+ // Plug-ins that wish their operations to be undoable from workbench views
+ // such as the Navigator or Package Explorer should assign the workbench
+ // undo context to their operations.
if (defaultUndoContext == null) {
defaultUndoContext = new UndoContext();
}
* @return a boolean.
*/
public static boolean isDirty(TaxonNode taxonNode){
-
+
for (IEditorReference reference : getActivePage().getEditorReferences()) {
-
+
try {
if (reference.getEditorInput() instanceof TaxonEditorInput) {
TaxonEditorInput editorInput = (TaxonEditorInput) reference.getEditorInput();
}
}
} catch (PartInitException e) {
- NavigationUtil.error(NavigationUtil.class, e.getMessage(), e);
+ AbstractUtility.error(NavigationUtil.class, e.getMessage(), e);
throw new RuntimeException(e);
}
-
+
}
return false;
}
public static void selectInNavigator(final Object element, final Object parentElement) {
Display.getDefault().asyncExec(new Runnable(){
- public void run() {
+ @Override
+ public void run() {
TaxonNavigator navigator = showNavigator();
if (navigator != null) {
if (parentElement != null) {
viewer.setExpandedState(parentElement, true);
}
- viewer.setSelection(new StructuredSelection((TaxonNode) element));
+ viewer.setSelection(new StructuredSelection(element));
}
}
}
-
+
});
}
public static void openSearch(Object selection) {
if(selection instanceof Taxon){
Taxon taxon = (Taxon) selection;
-
+
handleOpeningOfMultipleTaxonNodes(taxon.getTaxonNodes());
-
+
}else if(selection instanceof Synonym){
Synonym synonym = (Synonym) selection;
-
+
handleOpeningOfMultipleTaxa(synonym.getAcceptedTaxa());
-
+
}else{
warningDialog("Not implemented yet", NavigationUtil.class, "You chose to open a name that has no connection to a taxon. The Editor does not support editing of such a content type at the moment.");
}
-
+
}
private static void handleOpeningOfMultipleTaxa(Set<Taxon> acceptedTaxa) {
*/
private static void handleOpeningOfMultipleTaxonNodes(
Set<TaxonNode> taxonNodes) {
-
+
if(taxonNodes.size() == 1){
openEditor(taxonNodes.iterator().next());
}else if(taxonNodes.size() > 1){
// $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.Set;
import java.util.UUID;
-import org.eclipse.core.commands.Command;
-import org.eclipse.core.commands.common.NotDefinedException;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.viewers.DoubleClickEvent;
import org.eclipse.ui.IMemento;
import org.eclipse.ui.IViewSite;
import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.commands.ICommandService;
-import org.eclipse.ui.handlers.IHandlerService;
import org.eclipse.ui.navigator.CommonNavigator;
import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
/**
* Taxonomic tree implementation using Common Navigator Framework.
- *
+ *
* @author p.ciardelli
* @author n.hoffmann
* @created 02.06.2009
*/
public static final String ID = "eu.etaxonomy.taxeditor.navigation.navigator"; //$NON-NLS-1$
- /**
- * Constant
- * <code>OPEN_COMMAND_ID="eu.etaxonomy.taxeditor.navigation.comma"{trunked}</code>
- */
- public static final String OPEN_COMMAND_ID = "eu.etaxonomy.taxeditor.navigation.command.editSelection";
-
private static final String TREE_PATH = "treepath";
private static final String TREE_PATHS = "treepaths";
/*
* (non-Javadoc)
- *
+ *
* @see org.eclipse.ui.navigator.CommonNavigator#getInitialInput()
*/
/** {@inheritDoc} */
*/
public void refresh() {
if(getConversationHolder() != null){
- getConversationHolder().bind();
+ getConversationHolder().bind();
}
getCommonViewer().refresh();
}
* <p>
* restore
* </p>
- *
+ *
* @param memento
* a {@link org.eclipse.ui.IMemento} object.
* @param monitor
List<CdmBase> pathList = new ArrayList<CdmBase>();
- if (string.length() == 0)
- return null;
+ if (string.length() == 0) {
+ return null;
+ }
for (String uuid : string.split(" ")) {
CdmBase cdmBaseObject = CdmStore.getService(
IClassificationService.class).load(
UUID.fromString(uuid));
- if (cdmBaseObject == null)
- return null;
+ if (cdmBaseObject == null) {
+ return null;
+ }
}
pathList.add(cdmBaseObject);
}
* <p>
* saveTreeState
* </p>
- *
+ *
* @param memento
* a {@link org.eclipse.ui.IMemento} object.
* @param progressMonitor
/*
* (non-Javadoc)
- *
+ *
* @see
* eu.etaxonomy.cdm.api.conversation.IConversationEnabled#getConversationHolder
* ()
* <p>
* getConversationHolder
* </p>
- *
+ *
* @return a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder}
* object.
*/
/*
* (non-Javadoc)
- *
+ *
* @see
* eu.etaxonomy.cdm.persistence.hibernate.ICdmPostDataChangeObserver#update
* (eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap)
/*
* (non-Javadoc)
- *
+ *
* @see org.eclipse.ui.part.WorkbenchPart#dispose()
*/
/** {@inheritDoc} */
/*
* (non-Javadoc)
- *
+ *
* @see org.eclipse.ui.navigator.CommonNavigator#setFocus()
*/
/** {@inheritDoc} */
/*
* (non-Javadoc)
- *
+ *
* @see
* eu.etaxonomy.taxeditor.operations.IPostOperationEnabled#postOperation
* (eu.etaxonomy.cdm.model.common.CdmBase)
* <p>
* save
* </p>
- *
+ *
* @param memento
* a {@link org.eclipse.ui.IMemento} object.
* @param monitor
/** {@inheritDoc} */
@Override
protected void handleDoubleClick(DoubleClickEvent anEvent) {
-
- ICommandService commandService = (ICommandService) getSite()
- .getService(ICommandService.class);
-
- Command command = commandService.getCommand(OPEN_COMMAND_ID);
- if (command.isEnabled()) {
- IHandlerService handlerService = (IHandlerService) getSite()
- .getService(IHandlerService.class);
- try {
- handlerService.executeCommand(OPEN_COMMAND_ID, null);
- } catch (NotDefinedException e) {
- throw new RuntimeException("Could not find open command: "
- + OPEN_COMMAND_ID);
- } catch (Exception e) {
- NavigationUtil
- .error(getClass(),
- "An exception occured while trying to open a selection",
- e);
- }
- }
+ NavigationUtil.executeEditHandler();
// If the double click is passed up to the super-class it will
// expand/collapse trees.
// We do not want that
* <p>
* onComplete
* </p>
- *
+ *
* @return a boolean.
*/
@Override
/*
* (non-Javadoc)
- *
+ *
* @see org.eclipse.ui.part.WorkbenchPart#showBusy(boolean)
*/
/** {@inheritDoc} */
if(o instanceof LoginManager){
refresh();
}
-
+
}
}
// $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.
*/
* @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent)
*/
/** {@inheritDoc} */
- public Object execute(ExecutionEvent event) throws ExecutionException {
-
+ @Override
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+
ISelection selection = HandlerUtil.getCurrentSelection(event);
-
+
if(selection instanceof StructuredSelection){
final StructuredSelection structuredSelection = (StructuredSelection) selection;
-
+
if(structuredSelection.size() == 1 && structuredSelection.getFirstElement() instanceof Classification){
Classification classification = (Classification) structuredSelection.getFirstElement();
-
+
NewClassificationWizard classificationWizard = new NewClassificationWizard();
classificationWizard.init(null, null);
classificationWizard.setEntity(classification);
WizardDialog dialog = new WizardDialog(HandlerUtil.getActiveShell(event), classificationWizard);
dialog.open();
-
+
}
else{
Job job = new Job("Opening editor") {
-
+
@Override
protected IStatus run(IProgressMonitor monitor) {
for(final Object selectedObject : structuredSelection.toArray()){
-
+
Display.getDefault().asyncExec(new Runnable(){
-
- public void run() {
+
+ @Override
+ public void run() {
NavigationUtil.openEditor(selectedObject);
}
-
+
});
}
return Status.OK_STATUS;
}
};
-
+
job.schedule();
}
}
-
+
return null;
}
}
/**
* 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 eu.etaxonomy.cdm.model.common.UuidAndTitleCache;
import eu.etaxonomy.cdm.model.taxon.TaxonBase;
import eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap;
+import eu.etaxonomy.taxeditor.model.AbstractUtility;
import eu.etaxonomy.taxeditor.model.ContextListenerAdapter;
import eu.etaxonomy.taxeditor.model.IContextListener;
import eu.etaxonomy.taxeditor.navigation.NavigationUtil;
* @version 1.0
*/
public class SearchResultView extends ViewPart implements IConversationEnabled{
-
+
private static Object[] EMPTY = new Object[0];
-
+
private class ContextListener extends ContextListenerAdapter{
/* (non-Javadoc)
* @see eu.etaxonomy.taxeditor.model.IContextListener#contextStop(org.eclipse.ui.IMemento, org.eclipse.core.runtime.IProgressMonitor)
@Override
public void contextStop(IMemento memento, IProgressMonitor monitor) {
monitor.subTask("Getting rid of search results");
- NavigationUtil.hideView(SearchResultView.this);
+ AbstractUtility.hideView(SearchResultView.this);
}
}
-
+
/** Constant <code>ID="eu.etaxonomy.taxeditor.navigation.searc"{trunked}</code> */
- public static final String ID =
+ public static final String ID =
"eu.etaxonomy.taxeditor.navigation.search.searchResultView"; //$NON-NLS-1$
private TableViewer resultViewer;
private Text status;
private SearchJob searchJob;
-
+
private IContextListener contextListener;
-
+
/* (non-Javadoc)
* @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
*/
/** {@inheritDoc} */
@Override
public void createPartControl(Composite parent) {
-
+
conversation = CdmStore.createConversation();
contextListener = new ContextListener();
CdmStore.getContextManager().addContextListener(contextListener);
-
+
GridLayout layout = new GridLayout();
layout.marginWidth = 0;
layout.marginHeight = 0;
-
+
parent.setLayout(layout);
-
+
Composite infoComposite = createInfoComposite(parent);
infoComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
-
+
resultViewer = new TableViewer(parent, SWT.NONE);
resultViewer.setContentProvider(new ArrayContentProvider());
resultViewer.setLabelProvider(new SearchResultLabelProvider());
resultViewer.addDoubleClickListener(new IDoubleClickListener() {
- public void doubleClick(DoubleClickEvent event) {
+ @Override
+ public void doubleClick(DoubleClickEvent event) {
NavigationUtil.executeEditHandler();
}
});
-
+
resultViewer.getControl().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
-
+
getSite().setSelectionProvider(resultViewer);
-
+
// register context menu
MenuManager menuMgr = new MenuManager();
menuMgr.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS));
Control control = resultViewer.getControl();
Menu menu = menuMgr.createContextMenu(control);
- control.setMenu(menu);
+ control.setMenu(menu);
}
-
+
private Composite createInfoComposite(Composite parent){
Composite composite = new Composite(parent, SWT.NULL);
-
+
composite.setLayout(new GridLayout(2, false));
-
+
Label searchStringLabel = new Label(composite, SWT.NULL);
searchStringLabel.setText("Search String:");
-
+
searchString = new Text(composite, SWT.NULL);
searchString.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
searchString.setEditable(false);
// searchString.setText(" ");
-
+
Label configurationDescriptionLabel = new Label(composite, SWT.NULL);
configurationDescriptionLabel.setText("Search for:");
-
+
configurationLabel = new Text(composite, SWT.WRAP);
configurationLabel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
configurationLabel.setEditable(false);
-
+
Label statusLabel = new Label(composite, SWT.NULL);
statusLabel.setText("Status:");
-
+
status = new Text(composite, SWT.NULL);
status.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
status.setEditable(false);
-
+
return composite;
}
-
+
/**
* <p>performSearch</p>
*
*/
public void performSearch(IFindTaxaAndNamesConfigurator configurator){
setPartName("Search: '" + configurator.getTitleSearchString() + "'");
-
+
searchString.setText(configurator.getTitleSearchString());
-
+
List<String> includedEntities = new ArrayList<String>();
- if(configurator.isDoTaxa())
- includedEntities.add(SearchOption.TAXON.getLabel());
- if(configurator.isDoSynonyms())
- includedEntities.add(SearchOption.SYNONYM.getLabel());
- if(configurator.isDoNamesWithoutTaxa())
- includedEntities.add(SearchOption.NAME.getLabel());
+ if(configurator.isDoTaxa()) {
+ includedEntities.add(SearchOption.TAXON.getLabel());
+ }
+ if(configurator.isDoSynonyms()) {
+ includedEntities.add(SearchOption.SYNONYM.getLabel());
+ }
+ if(configurator.isDoNamesWithoutTaxa()) {
+ includedEntities.add(SearchOption.NAME.getLabel());
+ }
if(configurator.isDoTaxaByCommonNames()){
includedEntities.add(SearchOption.COMMON_NAME.getLabel());
}
-
+
String includedEntitiesString = "";
for (int i = 0; i < includedEntities.size(); i++){
includedEntitiesString += includedEntities.get(i);
includedEntitiesString += ", ";
}
}
-
+
configurationLabel.setText(includedEntitiesString);
-
+
status.setText("Searching...");
-
+
searchJob = new SearchJob(Display.getCurrent(), configurator);
searchJob.schedule();
-
+
}
-
+
/**
* <p>displaySearchResult</p>
*
*/
protected void displaySearchResult(List<UuidAndTitleCache<TaxonBase>> result) {
if(result.size() > 0){
- resultViewer.setInput(result);
+ resultViewer.setInput(result);
status.setText(result.size() + " entities found");
}else{
- resultViewer.setInput(EMPTY);
+ resultViewer.setInput(EMPTY);
status.setText("Search returned no results");
}
}
*
* @return a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder} object.
*/
- public ConversationHolder getConversationHolder() {
+ @Override
+ public ConversationHolder getConversationHolder() {
return this.conversation;
}
* @see eu.etaxonomy.cdm.persistence.hibernate.ICdmPostDataChangeObserver#update(eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap)
*/
/** {@inheritDoc} */
- public void update(CdmDataChangeMap changeEvents) {
+ @Override
+ public void update(CdmDataChangeMap changeEvents) {
// TODO Auto-generated method stub
-
+
}
-
+
/* (non-Javadoc)
* @see org.eclipse.ui.part.WorkbenchPart#dispose()
*/
public void dispose() {
super.dispose();
conversation.close();
- if(searchJob != null)
- searchJob.cancel();
+ if(searchJob != null) {
+ searchJob.cancel();
+ }
CdmStore.getContextManager().removeContextListener(contextListener);
}
-
+
/**
- *
+ *
* @author n.hoffmann
* @created Feb 2, 2010
* @version 1.0
*/
class SearchJob extends Job{
- private IFindTaxaAndNamesConfigurator configurator;
-
- private Display display;
-
+ private final IFindTaxaAndNamesConfigurator configurator;
+
+ private final Display display;
+
/**
* @param name
*/
protected IStatus run(IProgressMonitor monitor) {
monitor.beginTask("", 100);
monitor.worked(20);
-
+
final List<UuidAndTitleCache<TaxonBase>> searchResult = CdmStore.getSearchManager().findTaxaAndNames(configurator);
monitor.worked(40);
-
+
if(! monitor.isCanceled()){
display.asyncExec(new Runnable() {
- public void run() {
+ @Override
+ public void run() {
displaySearchResult(searchResult);
}
});
}else{
display.asyncExec(new Runnable() {
- public void run() {
+ @Override
+ public void run() {
status.setText("Cancelled");
}
});
monitor.done();
return Status.OK_STATUS;
}
-
- }
+
+ }
}
/**
- *
+ *
*/
package eu.etaxonomy.taxeditor.ui.element;
import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
import eu.etaxonomy.cdm.api.conversation.IConversationEnabled;
import eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap;
-import eu.etaxonomy.taxeditor.store.StoreUtil;
+import eu.etaxonomy.taxeditor.model.AbstractUtility;
/**
* <p>
- * Abstract AbstractFormSection class.
+ * Abstract super class for a {@link Section} GUI element that visualizes a CDM
+ * entity, manages a conversation and listens to selections
* </p>
- *
+ *
+ * @param <ENTITY> A CDM entity which should be visualized by this section.
+ *
* @author n.hoffmann
* @created Feb 22, 2010
* @version 1.0
* @param <T>
*/
+//TODO shouldn't ENTITY be bound with super class ICdmBase for example (AbstractFormSection<ENTITY extends ICdmBase>)?
public abstract class AbstractFormSection<ENTITY> extends Section implements
- ISelectionChangedListener, ICdmFormElement, IEntityElement<ENTITY>,
+ ISelectionChangedListener, IEntityElement<ENTITY>,
IConversationEnabled {
private ISelectionProvider selectionProvider;
private ENTITY entity;
- private Set<ICdmFormElement> elements = new HashSet<ICdmFormElement>();
+ private final Set<ICdmFormElement> elements = new HashSet<ICdmFormElement>();
protected CdmFormFactory formFactory;
* <p>
* Constructor for AbstractFormSection.
* </p>
- *
+ *
* @param conversation
* TODO
* @param style
* @param <ENTITY>
* a ENTITY object.
*/
- protected AbstractFormSection(CdmFormFactory formFactory, ICdmFormElement parentElement,
- int style) {
+ protected AbstractFormSection(CdmFormFactory formFactory, ICdmFormElement parentElement, int style) {
super(parentElement.getLayoutComposite(), style);
this.parentElement = parentElement;
this.setClient(client);
}
- /**
- * <p>
- * Constructor for AbstractFormSection.
- * </p>
- *
- * @param formFactory
- * a {@link eu.etaxonomy.taxeditor.ui.element.CdmFormFactory}
- * object.
- * @param conversation
- * a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder}
- * object.
- * @param parentElement
- * a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
- * object.
- * @param selectionProvider
- * a {@link org.eclipse.jface.viewers.ISelectionProvider} object.
- * @param style
- * a int.
- */
- protected AbstractFormSection(CdmFormFactory formFactory,
- ICdmFormElement parentElement,
- ISelectionProvider selectionProvider, int style) {
- this(formFactory, parentElement, style);
- this.selectionProvider = selectionProvider;
- }
+ /**
+ * <p>
+ * Constructor for AbstractFormSection.
+ * </p>
+ *
+ * @param formFactory
+ * a {@link eu.etaxonomy.taxeditor.ui.element.CdmFormFactory}
+ * object.
+ * @param conversation
+ * a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder}
+ * object.
+ * @param parentElement
+ * a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
+ * object.
+ * @param selectionProvider
+ * a {@link org.eclipse.jface.viewers.ISelectionProvider} object.
+ * @param style
+ * a int.
+ */
+ protected AbstractFormSection(CdmFormFactory formFactory, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style) {
+ this(formFactory, parentElement, style);
+ this.selectionProvider = selectionProvider;
+ }
/**
* <p>
* Getter for the field <code>propertyChangeListeners</code>.
* </p>
- *
+ *
* @return a {@link java.util.Set} object.
*/
- public List<IPropertyChangeListener> getPropertyChangeListeners() {
+ @Override
+ public List<IPropertyChangeListener> getPropertyChangeListeners() {
return propertyChangeListeners;
}
/** {@inheritDoc} */
- public void setPropertyChangeListeners(
+ @Override
+ public void setPropertyChangeListeners(
List<IPropertyChangeListener> propertyChangeListeners) {
this.propertyChangeListeners = propertyChangeListeners;
}
* <p>
* Setter for the field <code>entity</code>.
* </p>
- *
+ *
* @param entity
* a ENTITY object.
*/
/*
* (non-Javadoc)
- *
+ *
* @see eu.etaxonomy.taxeditor.forms.IEntityElement#getEntity()
*/
/**
* <p>
* Getter for the field <code>entity</code>.
* </p>
- *
+ *
* @return a ENTITY object.
*/
- public ENTITY getEntity() {
+ @Override
+ public ENTITY getEntity() {
return entity;
}
* <p>
* getToggle
* </p>
- *
+ *
* @return a {@link org.eclipse.ui.forms.widgets.ToggleHyperlink} object.
*/
public ToggleHyperlink getToggle() {
* <p>
* getSection
* </p>
- *
+ *
* @return a {@link eu.etaxonomy.taxeditor.ui.element.AbstractFormSection}
* object.
*/
/*
* (non-Javadoc)
- *
+ *
* @see
* eu.etaxonomy.taxeditor.forms.IPropertyChangeEmitter#firePropertyChangeEvent
* ()
*/
/** {@inheritDoc} */
- public void firePropertyChangeEvent(CdmPropertyChangeEvent event) {
- Assert.isNotNull(propertyChangeListeners,
- "No property change listeners.");
- try {
- for (Object listener : propertyChangeListeners) {
- ((IPropertyChangeListener) listener).propertyChange(event);
- }
- } catch (ConcurrentModificationException e) {
- StoreUtil.warn(getClass(),
- "ConcurrentModificationException while handling PropertyChangeEvents."
- + " It seems like this is not critical");
- }
+ @Override
+ public void firePropertyChangeEvent(CdmPropertyChangeEvent event) {
+ Assert.isNotNull(propertyChangeListeners, "No property change listeners.");
+ try {
+ for (Object listener : propertyChangeListeners) {
+ ((IPropertyChangeListener) listener).propertyChange(event);
+ }
+ } catch (ConcurrentModificationException e) {
+ AbstractUtility.warn(getClass(), "ConcurrentModificationException while handling PropertyChangeEvents."
+ + " It seems like this is not critical");
+ }
}
/**
* Fires a {@link CdmPropertyChangeEvent} with the given object as source.
- *
+ *
* @param object
* the object on which the property changed
*/
/**
* Fires a {@link CdmPropertyChangeEvent} with the given object as source
* also containing the originating event
- *
+ *
* @param object
* the object on which the property changed
* @param originatingEvent
/*
* (non-Javadoc)
- *
+ *
* @see org.eclipse.swt.widgets.Composite#setFocus()
*/
/** {@inheritDoc} */
/*
* (non-Javadoc)
- *
+ *
* @see
* org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse
* .jface.util.PropertyChangeEvent)
*/
/** {@inheritDoc} */
- public void propertyChange(PropertyChangeEvent event) {
+ @Override
+ public void propertyChange(PropertyChangeEvent event) {
firePropertyChangeEvent(new CdmPropertyChangeEvent(this, event));
}
/*
* (non-Javadoc)
- *
+ *
* @see
* org.eclipse.swt.widgets.Control#setBackground(org.eclipse.swt.graphics
* .Color)
getLayoutComposite().setBackground(color);
super.setBackground(color);
}
-
+
@Override
public void setPersistentBackground(Color color) {
persistentBackgroundColor = color;
setBackground(color);
}
-
+
@Override
public Color getPersistentBackground() {
return persistentBackgroundColor;
}
-
+
/**
* <p>
* widgetSelected
* </p>
- *
+ *
* @param e
* a {@link org.eclipse.swt.events.SelectionEvent} object.
*/
public void widgetSelected(SelectionEvent e) {
- Widget widget = e.widget;
-
- if (widget instanceof Control) {
- Control control = (Control) widget;
- if (checkControlAncestryForWidget(control)) {
- if (getEntity() != null) {
- IStructuredSelection selection = new StructuredSelection(
- getEntity());
- if (selectionProvider != null) {
- selectionProvider.setSelection(selection);
- }
- }
- }
- }
+ Widget widget = e.widget;
+
+ if (widget instanceof Control) {
+ Control control = (Control) widget;
+ if (checkControlAncestryForWidget(control)) {
+ if (getEntity() != null) {
+ IStructuredSelection selection = new StructuredSelection(getEntity());
+ if (selectionProvider != null) {
+ selectionProvider.setSelection(selection);
+ }
+ }
+ }
+ }
}
private boolean checkControlAncestryForWidget(Control control) {
}
/** {@inheritDoc} */
- public void setSelected(boolean selected) {
+ @Override
+ public void setSelected(boolean selected) {
if (selected) {
setBackground(Display.getCurrent().getSystemColor(
SWT.COLOR_LIST_SELECTION));
}
/** {@inheritDoc} */
- public void selectionChanged(SelectionChangedEvent event) {
+ @Override
+ public void selectionChanged(SelectionChangedEvent event) {
if (event.getSelection() == CdmFormFactory.EMPTY_SELECTION) {
return;
}
* <p>
* addSelectionListener
* </p>
- *
+ *
* @param listener
* a {@link org.eclipse.swt.events.SelectionListener} object.
*/
* <p>
* removeSelectionListener
* </p>
- *
+ *
* @param listener
* a {@link org.eclipse.swt.events.SelectionListener} object.
*/
}
/** {@inheritDoc} */
- public void addElement(ICdmFormElement element) {
+ @Override
+ public void addElement(ICdmFormElement element) {
elements.add(element);
}
* <p>
* removeElement
* </p>
- *
+ *
* @param element
* a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
* object.
* removeElements
* </p>
*/
- public void removeElements() {
+ @Override
+ public void removeElements() {
for (ICdmFormElement childElement : getElements()) {
// recursion
childElement.removeElements();
// unregister selection arbitrator
if (childElement instanceof ISelectableElement) {
ISelectableElement selectableElement = (ISelectableElement) childElement;
- if (selectableElement != null
- && selectableElement.getSelectionArbitrator() != null) {
+ if (selectableElement.getSelectionArbitrator() != null) {
formFactory.destroySelectionArbitrator(selectableElement
.getSelectionArbitrator());
}
* <p>
* Getter for the field <code>parentElement</code>.
* </p>
- *
+ *
* @return a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement} object.
*/
- public ICdmFormElement getParentElement() {
+ @Override
+ public ICdmFormElement getParentElement() {
return parentElement;
}
* <p>
* Getter for the field <code>elements</code>.
* </p>
- *
+ *
* @return a {@link java.util.Set} object.
*/
- public Set<ICdmFormElement> getElements() {
+ @Override
+ public Set<ICdmFormElement> getElements() {
return elements;
}
* <p>
* getControls
* </p>
- *
+ *
* @return a {@link java.util.Set} object.
*/
- public Set<Control> getControls() {
+ @Override
+ public Set<Control> getControls() {
Set<Control> controls = new HashSet<Control>();
for (Control control : getChildren()) {
* <p>
* getLayoutComposite
* </p>
- *
+ *
* @return a {@link org.eclipse.swt.widgets.Composite} object.
*/
- public Composite getLayoutComposite() {
+ @Override
+ public Composite getLayoutComposite() {
return (Composite) getClient();
}
/** {@inheritDoc} */
- public boolean containsFormElement(ICdmFormElement formElement) {
+ @Override
+ public boolean containsFormElement(ICdmFormElement formElement) {
if (formElement == this) {
return true;
} else {
* <p>
* Getter for the field <code>formFactory</code>.
* </p>
- *
+ *
* @return a {@link eu.etaxonomy.taxeditor.ui.element.CdmFormFactory} object.
*/
public CdmFormFactory getFormFactory() {
/*
* (non-Javadoc)
- *
+ *
* @see eu.etaxonomy.taxeditor.forms.ICdmFormElement#refresh()
*/
/**
* refresh
* </p>
*/
- public void refresh() {
+ @Override
+ public void refresh() {
// empty default implementation
}
* <p>
* getConversationHolder
* </p>
- *
+ *
* @return a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder}
* object.
*/
- public ConversationHolder getConversationHolder() {
+ @Override
+ public ConversationHolder getConversationHolder() {
if(getParentElement() instanceof RootElement || getParentElement() == null){
-
- IEditorPart activeEditor = StoreUtil.getActiveEditor();
+
+ IEditorPart activeEditor = AbstractUtility.getActiveEditor();
if(activeEditor instanceof IConversationEnabled){
- ConversationHolder conversation = ((IConversationEnabled) StoreUtil.getActiveEditor()).getConversationHolder();
+ ConversationHolder conversation = ((IConversationEnabled) AbstractUtility.getActiveEditor()).getConversationHolder();
return conversation;
}
}else if(getParentElement() instanceof IConversationEnabled){
return ((IConversationEnabled) getParentElement()).getConversationHolder();
}
- StoreUtil.errorDialog("Could not get conversation for AbstractFormSection",
- getClass(), "There is an error in the implementation. There should have been an active editor but it wasn't",
+ AbstractUtility.errorDialog("Could not get conversation for AbstractFormSection",
+ getClass(), "There is an error in the implementation. There should have been an active editor but it wasn't",
new IllegalArgumentException());
return null;
-
+
}
/** {@inheritDoc} */
- public void update(CdmDataChangeMap changeEvents) {
+ @Override
+ public void update(CdmDataChangeMap changeEvents) {
}
/**
- *
+ *
*/
package eu.etaxonomy.taxeditor.ui.element;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Label;
import org.eclipse.ui.forms.IFormColors;
+import org.eclipse.ui.forms.widgets.ExpandableComposite;
import org.eclipse.ui.forms.widgets.FormToolkit;
import org.eclipse.ui.forms.widgets.Section;
import org.eclipse.ui.internal.forms.widgets.FormFonts;
import eu.etaxonomy.cdm.model.taxon.Taxon;
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
import eu.etaxonomy.cdm.strategy.parser.ParserProblem;
-import eu.etaxonomy.taxeditor.store.StoreUtil;
+import eu.etaxonomy.taxeditor.model.AbstractUtility;
import eu.etaxonomy.taxeditor.ui.combo.EnumComboElement;
import eu.etaxonomy.taxeditor.ui.combo.TermComboElement;
import eu.etaxonomy.taxeditor.ui.openurl.IOpenUrlEnabled;
import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailElement;
import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailSection;
import eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionElement;
+import eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionSection;
import eu.etaxonomy.taxeditor.ui.section.EmptyElement;
import eu.etaxonomy.taxeditor.ui.section.agent.InstitutionDetailElement;
import eu.etaxonomy.taxeditor.ui.section.agent.InstitutionDetailSection;
* <p>
* CdmFormFactory class.
* </p>
- *
+ *
* @author n.hoffmann
* @created Feb 24, 2010
* @version 1.0
*/
public class CdmFormFactory extends FormToolkit {
- private BoldFontHolder2 boldFontHolder2;
- private MouseListener selectionMouseHandler;
- private FocusListener selectionFocusHandler;
-
- private final Set selectionListenerList = new HashSet();
-
- private final List<IPropertyChangeListener> propertyChangeListeners = new ArrayList<IPropertyChangeListener>();
-
- private final int orientation = Window.getDefaultOrientation();
- private ISelectionProvider selectionProvider;
-
- /** Constant <code>EMPTY_SELECTION</code> */
- public static ISelection EMPTY_SELECTION = new ISelection() {
- @Override
- public boolean isEmpty() {
- return true;
- }
- };
-
- /**
- *
- * @author n.hoffmann
- * @date Jan 25, 2010
+ private BoldFontHolder2 boldFontHolder2;
+ private MouseListener selectionMouseHandler;
+ private FocusListener selectionFocusHandler;
+
+ private final Set selectionListenerList = new HashSet();
+
+ private final List<IPropertyChangeListener> propertyChangeListeners = new ArrayList<IPropertyChangeListener>();
+
+ private final int orientation = Window.getDefaultOrientation();
+ private ISelectionProvider selectionProvider;
+
+ /** Constant <code>EMPTY_SELECTION</code> */
+ public static ISelection EMPTY_SELECTION = new ISelection() {
+ @Override
+ public boolean isEmpty() {
+ return true;
+ }
+ };
+
+ /**
+ *
+ * @author n.hoffmann
+ * @date Jan 25, 2010
+ *
+ */
+ private class SelectionMouseHandler extends MouseAdapter {
+ @Override
+ public void mouseDown(MouseEvent e) {
+ notifySelectionListeners(e);
+ }
+ }
+
+ /**
+ *
+ * @author n.hoffmann
+ * @date Jan 25, 2010
+ *
+ */
+ private class SelectionFocusHandler extends FocusAdapter {
+ @Override
+ public void focusGained(FocusEvent e) {
+ notifySelectionListeners(e);
+ }
+ }
+
+ private void notifySelectionListeners(TypedEvent e) {
+ Event event = new Event();
+ event.widget = e.widget;
+ SelectionEvent selectionEvent = new SelectionEvent(event);
+
+ for (Object listener : selectionListenerList) {
+ ((SelectionListener) listener).widgetSelected(selectionEvent);
+ }
+ }
+
+ /**
+ * <p>
+ * Constructor for CdmFormFactory.
+ * </p>
+ *
+ * @param display
+ * a {@link org.eclipse.swt.widgets.Display} object.
+ * @param selectionProvider
+ * a {@link org.eclipse.jface.viewers.ISelectionProvider} object.
+ */
+ public CdmFormFactory(Display display, ISelectionProvider selectionProvider) {
+ super(display);
+ this.selectionProvider = selectionProvider;
+ init();
+ }
+
+ /**
+ * <p>
+ * Constructor for CdmFormFactory.
+ * </p>
+ *
+ * @param display
+ * a {@link org.eclipse.swt.widgets.Display} object.
+ */
+ public CdmFormFactory(Display display) {
+ super(display);
+ init();
+ }
+
+ /**
*
*/
- private class SelectionMouseHandler extends MouseAdapter {
- @Override
- public void mouseDown(MouseEvent e) {
- notifySelectionListeners(e);
- }
- }
-
- /**
- *
- * @author n.hoffmann
- * @date Jan 25, 2010
- *
- */
- private class SelectionFocusHandler extends FocusAdapter {
- @Override
- public void focusGained(FocusEvent e) {
- notifySelectionListeners(e);
- }
- }
-
- private void notifySelectionListeners(TypedEvent e) {
- Event event = new Event();
- event.widget = e.widget;
- SelectionEvent selectionEvent = new SelectionEvent(event);
-
- for (Object listener : selectionListenerList) {
- ((SelectionListener) listener).widgetSelected(selectionEvent);
- }
- }
-
- /**
- * <p>
- * Constructor for CdmFormFactory.
- * </p>
- *
- * @param display
- * a {@link org.eclipse.swt.widgets.Display} object.
- * @param selectionProvider
- * a {@link org.eclipse.jface.viewers.ISelectionProvider} object.
- */
- public CdmFormFactory(Display display, ISelectionProvider selectionProvider) {
- super(display);
- this.selectionProvider = selectionProvider;
- init();
- }
-
- /**
- * <p>
- * Constructor for CdmFormFactory.
- * </p>
- *
- * @param display
- * a {@link org.eclipse.swt.widgets.Display} object.
- */
- public CdmFormFactory(Display display) {
- super(display);
- init();
- }
-
- /**
- *
- */
- private void init() {
- boldFontHolder2 = new BoldFontHolder2();
- selectionMouseHandler = new SelectionMouseHandler();
- selectionFocusHandler = new SelectionFocusHandler();
- }
-
- /**
- * Creates an instance initialized with the correct selectionProvider
- *
- * Make sure to remove the instance when the entityComposite disposes via
- * destroySelectionArbitrator(..)
- *
- * @param entityElement
- * a {@link eu.etaxonomy.taxeditor.ui.element.IEntityElement}
- * object.
- * @return a {@link eu.etaxonomy.taxeditor.ui.element.SelectionArbitrator}
- * object.
- */
- public SelectionArbitrator createSelectionArbitrator(
- IEntityElement entityElement) {
- SelectionArbitrator selectionArbitrator = new SelectionArbitrator(
- entityElement);
- selectionArbitrator.addSelectionProvider(selectionProvider);
- selectionProvider.addSelectionChangedListener(selectionArbitrator);
- addSelectionListener(selectionArbitrator);
- return selectionArbitrator;
- }
-
- /**
- * <p>
- * destroySelectionArbitrator
- * </p>
- *
- * @param selectionArbitrator
- * a {@link eu.etaxonomy.taxeditor.ui.element.SelectionArbitrator}
- * object.
- */
- public void destroySelectionArbitrator(
- SelectionArbitrator selectionArbitrator) {
- removeSelectionListener(selectionArbitrator);
- if (selectionProvider != null) {
- selectionProvider
- .removeSelectionChangedListener(selectionArbitrator);
- } else {
- StoreUtil
- .error(this.getClass(),
- "Tried to destroy a selection listener from this factories listeners but was null",
- null);
- }
- }
-
- /** {@inheritDoc} */
- @Override
- public void adapt(Composite composite) {
- composite.addMouseListener(selectionMouseHandler);
- super.adapt(composite);
- }
-
- /**
- * <p>
- * adapt
- * </p>
- *
- * @param formElement
- * a
- * {@link eu.etaxonomy.taxeditor.ui.element.AbstractCdmFormElement}
- * object.
- */
- public void adapt(AbstractCdmFormElement formElement) {
- formElement.setPropertyChangeListeners(propertyChangeListeners);
- }
-
- /** {@inheritDoc} */
- @Override
- public void adapt(Control control, boolean trackFocus, boolean trackKeyboard) {
- if (trackFocus) {
- control.addFocusListener(selectionFocusHandler);
- }
- super.adapt(control, trackFocus, trackKeyboard);
- }
-
- /**
- * <p>
- * destroyElement
- * </p>
- *
- * @param formElement
- * a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
- * object.
- */
- public void destroyElement(ICdmFormElement formElement) {
- // return if element was not initialized
- if (formElement == null) {
- return;
- }
- // destroy selection arbitrator, if any
- if (formElement instanceof ISelectableElement) {
- destroySelectionArbitrator(((ISelectableElement) formElement)
- .getSelectionArbitrator());
- }
- // remove this element form its parents list of elements
- // ICdmFormElement parentElement = formElement.getParentElement();
- // if(parentElement != null){
- // parentElement.removeElement(formElement);
- // }
- // call destroy on child elements recursively
- for (ICdmFormElement childElement : formElement.getElements()) {
- destroyElement(childElement);
- }
- // dispose of the controls
- for (Control control : formElement.getControls()) {
- // we added the layoutComposite of the parental element as the
- // layout composite to this formElement
- // but we do not want to destroy it.
- if (control.equals(formElement.getLayoutComposite())) {
- continue;
- } else {
- control.dispose();
- control = null;
- }
- }
- }
-
- /**
- * <p>
- * createEmptyCell
- * </p>
- *
- * @param parent
- * a {@link org.eclipse.swt.widgets.Composite} object.
- * @return a {@link org.eclipse.swt.widgets.Label} object.
- */
- public Label createEmptyCell(Composite parent) {
- return this.createLabel(parent, null);
- }
-
- /**
- * <p>
- * createMultilineTextWithLabel
- * </p>
- *
- * @param labelString
- * a {@link java.lang.String} object.
- * @param textHeight
- * a int.
- * @param style
- * a int.
- * @param parentElement
- * a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
- * object.
- * @return a {@link eu.etaxonomy.taxeditor.ui.element.TextWithLabelElement}
- * object.
- */
- public TextWithLabelElement createMultilineTextWithLabel(
- ICdmFormElement parentElement, String labelString, int textHeight,
- int style) {
- TextWithLabelElement element = new TextWithLabelElement(this,
- parentElement, labelString, "", textHeight, style);
- adapt(element);
- parentElement.addElement(element);
- return element;
- }
-
- /**
- * <p>
- * createMultiLanguageTextElement
- * </p>
- *
- * @param parentElement
- * a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
- * object.
- * @param labelString
- * a {@link java.lang.String} object.
- * @param multilanguageText
- * a {@link java.util.Map} object.
- * @param textHeight
- * a int.
- * @param style
- * a int.
- * @return a
- * {@link eu.etaxonomy.taxeditor.ui.element.MultilanguageTextElement}
- * object.
- */
- public MultilanguageTextElement createMultiLanguageTextElement(
- ICdmFormElement parentElement, String labelString,
- Map<Language, LanguageString> multilanguageText, int textHeight,
- int style) {
- MultilanguageTextElement element = new MultilanguageTextElement(this,
- parentElement, labelString, multilanguageText, textHeight,
- style);
- adapt(element);
- parentElement.addElement(element);
- return element;
- }
-
- public KeyStatementElement createKeyStatementElement(
- ICdmFormElement parentElement, String labelString,
- KeyStatement keyStatement, int textHeight, int style) {
- KeyStatementElement element = new KeyStatementElement(this,
- parentElement, labelString, keyStatement, textHeight, style);
- adapt(element);
- parentElement.addElement(element);
- return element;
- }
-
- /**
- * <p>
- * createTextWithLabelElement
- * </p>
- *
- * @param labelString
- * a {@link java.lang.String} object.
- * @param initialText
- * a {@link java.lang.String} object.
- * @param style
- * a int.
- * @param parentElement
- * a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
- * object.
- * @return a {@link eu.etaxonomy.taxeditor.ui.element.TextWithLabelElement}
- * object.
- */
- public TextWithLabelElement createTextWithLabelElement(
- ICdmFormElement parentElement, String labelString,
- String initialText, int style) {
- TextWithLabelElement element = new TextWithLabelElement(this,
- parentElement, labelString, initialText, null, style);
- adapt(element);
- parentElement.addElement(element);
- return element;
- }
-
- public UriWithLabelElement createUriWithLabelElement(
- ICdmFormElement parentElement, String labelString, URI initialUri,
- int style) {
- UriWithLabelElement element = new UriWithLabelElement(this,
- parentElement, labelString, initialUri, null, style);
- adapt(element);
- parentElement.addElement(element);
- return element;
- }
-
- /**
- * @param element
- * @param string
- * @param uri
- * @param style
- * @return
- */
- public OpenUrlSelectorElement createOpenUrlSelectorElement(
- ICdmFormElement parentElement, String labelString,
- IOpenUrlEnabled openUrlEnabled, int style) {
- OpenUrlSelectorElement element = new OpenUrlSelectorElement(this,
- parentElement, labelString, openUrlEnabled, style);
- adapt(element);
- parentElement.addElement(element);
- return element;
- }
-
- /**
- *
- * @param parentElement
- * @param labelString
- * @param conversationEnabled
- * @param user
- * @param style
- * @return
- */
- public EditPasswordElement createEditPasswordElement(
- ICdmFormElement parentElement, String labelString,
- ConversationHolder conversation, User user, int style) {
- EditPasswordElement element = new EditPasswordElement(this,
- parentElement, labelString, user, conversation);
- adapt(element);
- parentElement.addElement(element);
- return element;
- }
-
- /**
- * <p>
- * createIntegerTextWithLabelElement
- * </p>
- *
- * @param parentElement
- * a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
- * object.
- * @param labelString
- * a {@link java.lang.String} object.
- * @param initialInteger
- * a {@link java.lang.Integer} object.
- * @param style
- * a int.
- * @return a {@link eu.etaxonomy.taxeditor.ui.element.NumberWithLabelElement}
- * object.
- */
- public NumberWithLabelElement createIntegerTextWithLabelElement(
- ICdmFormElement parentElement, String labelString,
- Integer initialInteger, int style) {
- NumberWithLabelElement element = new NumberWithLabelElement(this,
- parentElement, labelString, initialInteger, style);
- adapt(element);
- parentElement.addElement(element);
- return element;
- }
-
- /**
- * <p>
- * createFloatTextWithLabelElement
- * </p>
- *
- * @param parentElement
- * a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
- * object.
- * @param labelString
- * a {@link java.lang.String} object.
- * @param initialFloat
- * a float.
- * @param style
- * a int.
- * @return a {@link eu.etaxonomy.taxeditor.ui.element.NumberWithLabelElement}
- * object.
- */
- public NumberWithLabelElement createFloatTextWithLabelElement(
- ICdmFormElement parentElement, String labelString,
- float initialFloat, int style) {
- NumberWithLabelElement element = new NumberWithLabelElement(this,
- parentElement, labelString, initialFloat, style);
- adapt(element);
- parentElement.addElement(element);
- return element;
- }
-
- /**
- * <p>
- * createLanguageStringWithLabelElement
- * </p>
- *
- * @param parentElement
- * a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
- * object.
- * @param labelString
- * a {@link java.lang.String} object.
- * @param languageString
- * a {@link eu.etaxonomy.cdm.model.common.LanguageString} object.
- * @param style
- * a int.
- * @return a
- * {@link eu.etaxonomy.taxeditor.ui.element.LanguageStringWithLabelElement}
- * object.
- */
- public LanguageStringWithLabelElement createLanguageStringWithLabelElement(
- ICdmFormElement parentElement, String labelString,
- LanguageString languageString, int style) {
- LanguageStringWithLabelElement element = new LanguageStringWithLabelElement(
- this, parentElement, labelString, languageString, style);
- adapt(element);
- parentElement.addElement(element);
- return element;
- }
-
- /**
- * <p>
- * createLanguageStringWithLabelElement
- * </p>
- *
- * @param parentElement
- * a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
- * object.
- * @param labelString
- * a {@link java.lang.String} object.
- * @param languageString
- * a {@link eu.etaxonomy.cdm.model.common.LanguageString} object.
- * @param height
- * a int.
- * @param style
- * a int.
- * @return a
- * {@link eu.etaxonomy.taxeditor.ui.element.LanguageStringWithLabelElement}
- * object.
- */
- public LanguageStringWithLabelElement createLanguageStringWithLabelElement(
- ICdmFormElement parentElement, String labelString,
- LanguageString languageString, int height, int style) {
- LanguageStringWithLabelElement element = new LanguageStringWithLabelElement(
- this, parentElement, labelString, languageString, height, style);
- adapt(element);
- parentElement.addElement(element);
- return element;
- }
-
- /**
- * <p>
- * createTextElement
- * </p>
- *
- * @param parentElement
- * a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
- * object.
- * @param initialText
- * a {@link java.lang.String} object.
- * @param style
- * a int.
- * @return a {@link eu.etaxonomy.taxeditor.ui.element.TextWithLabelElement}
- * object.
- */
- public TextWithLabelElement createTextElement(
- ICdmFormElement parentElement, String initialText, int style) {
- TextWithLabelElement element = new TextWithLabelElement(this,
- parentElement, null, initialText, null, style);
- adapt(element);
- parentElement.addElement(element);
- return element;
- }
-
- /**
- * <p>
- * createKeyValueViewerElement
- * </p>
- *
- * @param parentElement
- * a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
- * object.
- * @param keyHeading
- * a {@link java.lang.String} object.
- * @param valueHeading
- * a {@link java.lang.String} object.
- * @param map
- * a {@link java.util.Map} object.
- * @return a {@link eu.etaxonomy.taxeditor.ui.element.KeyValueViewerElement}
- * object.
- */
- public KeyValueViewerElement createKeyValueViewerElement(
- ICdmFormElement parentElement, String keyHeading,
- String valueHeading, Map<Object, Object> map) {
- KeyValueViewerElement element = new KeyValueViewerElement(this,
- parentElement, keyHeading, valueHeading, map);
- adapt(element);
- parentElement.addElement(element);
- return element;
- }
-
- /**
- * <p>
- * createTermComboElement
- * </p>
- *
- * @param termComboType
- * a
- * {@link eu.eu.etaxonomy.taxeditor.ui.element.CdmFormFactory.TermComboType}
- * object.
- * @param parentElement
- * a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
- * object.
- * @param labelString
- * a {@link java.lang.String} object.
- * @param selection
- * a {@link eu.etaxonomy.cdm.model.common.DefinedTermBase}
- * object.
- * @param style
- * a int.
- * @return a {@link eu.etaxonomy.taxeditor.ui.combo.TermComboElement}
- * object.
- */
-
- public <T extends DefinedTermBase> TermComboElement<T> createTermComboElement(
- Class<T> termComboType, ICdmFormElement parentElement,
- String labelString, T selection, int style) {
- TermComboElement<T> element = new TermComboElement<T>(this, parentElement, termComboType, labelString, selection, style);
- adapt(element);
- parentElement.addElement(element);
- return element;
- }
-
- /**
- * <p>
- * createEnumComboElement
- * </p>
- *
- * @param enumComboType
- * a
- * {@link eu.eu.etaxonomy.taxeditor.ui.element.CdmFormFactory.EnumComboType}
- * object.
- * @param parentElement
- * a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
- * object.
- * @param style
- * a int.
- * @return a {@link eu.etaxonomy.taxeditor.ui.term.AbstractEnumComboElement}
- * object.
- */
- public <T extends IDefinedTerm> EnumComboElement<T> createEnumComboElement(
- Class<T> enumComboType, ICdmFormElement parentElement,
- int style) {
- EnumComboElement<T> element = new EnumComboElement<T>(this, parentElement, enumComboType, style);
- adapt(element);
- parentElement.addElement(element);
- return element;
- }
-
- /**
- * <p>
- * createBrowserElement
- * </p>
- *
- * @param imageUri
- * a {@link java.net.URI} object.
- * @param style
- * a int.
- * @param parentElement
- * a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
- * object.
- * @return a {@link eu.etaxonomy.taxeditor.ui.element.BrowserElement} object.
- */
- public BrowserElement createBrowserElement(ICdmFormElement parentElement,
- URI imageUri, int style) {
- BrowserElement element = new BrowserElement(this, parentElement,
- imageUri, style);
- adapt(element);
- parentElement.addElement(element);
- return element;
- }
-
- /**
- * <p>
- * createImageElement
- * </p>
- *
- * @param parentElement
- * a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
- * object.
- * @param imageUri
- * a {@link java.net.URI} object.
- * @param style
- * a int.
- * @return a {@link eu.etaxonomy.taxeditor.ui.element.ImageElement} object.
- */
- public ImageElement createImageElement(ICdmFormElement parentElement,
- URI imageUri, int style) {
- ImageElement element = new ImageElement(this, parentElement, imageUri,
- style);
- adapt(element);
- parentElement.addElement(element);
- return element;
- }
-
- /**
- * <p>
- * createTextActionElement
- * </p>
- *
- * @param labelString
- * a {@link java.lang.String} object.
- * @param initialText
- * a {@link java.lang.String} object.
- * @param style
- * a int.
- * @param parentElement
- * a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
- * object.
- * @param buttonLabel
- * a {@link java.lang.String} object.
- * @return a {@link eu.etaxonomy.taxeditor.ui.element.TextActionElement}
- * object.
- */
- public TextActionElement createTextActionElement(
- ICdmFormElement parentElement, String labelString,
- String buttonLabel, String initialText, int style) {
- TextActionElement element = new TextActionElement(this, parentElement,
- labelString, buttonLabel, initialText, style);
- adapt(element);
- parentElement.addElement(element);
- return element;
- }
-
- /**
- * <p>
- * createCheckbox
- * </p>
- *
- * @param parentElement
- * a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
- * object.
- * @param label
- * a {@link java.lang.String} object.
- * @param initialState
- * a boolean.
- * @param style
- * a int.
- * @return a {@link eu.etaxonomy.taxeditor.ui.element.CheckboxElement} object.
- */
- public CheckboxElement createCheckbox(ICdmFormElement parentElement,
- String label, boolean initialState, int style) {
- CheckboxElement element = new CheckboxElement(this, parentElement,
- label, initialState, style | orientation);
- adapt(element);
- parentElement.addElement(element);
- return element;
- }
-
- /**
- * Creates a section as a part of the form.
- *
- * @return the section widget
- * @param section
- * a {@link eu.etaxonomy.taxeditor.ui.element.AbstractFormSection}
- * object.
- */
- public Section adapt(AbstractFormSection section) {
- section.setMenu(section.getLayoutComposite().getMenu());
- adapt(section, true, true);
-
- // handle focus and property change events for cdm use
- section.addFocusListener(selectionFocusHandler);
- section.setPropertyChangeListeners(propertyChangeListeners);
-
- if (section.getToggle() != null) {
- section.getToggle().setHoverDecorationColor(
- getColors().getColor(IFormColors.TB_TOGGLE_HOVER));
- section.getToggle().setDecorationColor(
- getColors().getColor(IFormColors.TB_TOGGLE));
- }
-
- section.setFont(boldFontHolder2.getBoldFont(section
- .getLayoutComposite().getFont()));
-
- if ((section.getStyle() & Section.TITLE_BAR) != 0
- || (section.getStyle() & Section.SHORT_TITLE_BAR) != 0) {
- getColors().initializeSectionToolBarColors();
- section.setTitleBarBackground(getColors().getColor(
- IFormColors.TB_BG));
- section.setTitleBarBorderColor(getColors().getColor(
- IFormColors.TB_BORDER));
- }
- // call setTitleBarForeground regardless as it also sets the label color
- section.setTitleBarForeground(getColors().getColor(
- IFormColors.TB_TOGGLE));
- return section;
- }
-
- private class BoldFontHolder2 {
- private Font normalFont;
-
- private Font boldFont;
-
- public BoldFontHolder2() {
- }
-
- public Font getBoldFont(Font font) {
- createBoldFont(font);
- return boldFont;
- }
-
- private void createBoldFont(Font font) {
- if (normalFont == null || !normalFont.equals(font)) {
- normalFont = font;
- dispose();
- }
- if (boldFont == null) {
- boldFont = FormFonts.getInstance().getBoldFont(
- getColors().getDisplay(), normalFont);
- }
- }
-
- public void dispose() {
- if (boldFont != null) {
- FormFonts.getInstance().markFinished(boldFont,
- getColors().getDisplay());
- boldFont = null;
- }
- }
- }
-
- /**
- * <p>
- * createToggleableTextField
- * </p>
- *
- * @param parentElement
- * a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
- * object.
- * @param labelString
- * a {@link java.lang.String} object.
- * @param initialText
- * a {@link java.lang.String} object.
- * @param initialState
- * a boolean.
- * @param style
- * a int.
- * @return a {@link eu.etaxonomy.taxeditor.ui.element.ToggleableTextElement}
- * object.
- */
- public ToggleableTextElement createToggleableTextField(
- ICdmFormElement parentElement, String labelString,
- String initialText, boolean initialState, int style) {
- ToggleableTextElement element = new ToggleableTextElement(this,
- parentElement, labelString, initialText, initialState, style
- | orientation);
- adapt(element);
- parentElement.addElement(element);
- return element;
- }
-
- /**
- * <p>
- * createTimePeriodElement
- * </p>
- *
- * @param parentElement
- * a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
- * object.
- * @param labelString
- * a {@link java.lang.String} object.
- * @param timePeriod
- * a {@link eu.etaxonomy.cdm.model.common.TimePeriod} object.
- * @param style
- * a int.
- * @return a {@link eu.etaxonomy.taxeditor.ui.element.TimePeriodElement}
- * object.
- */
- public TimePeriodElement createTimePeriodElement(
- ICdmFormElement parentElement, String labelString,
- TimePeriod timePeriod, int style) {
- TimePeriodElement element = new TimePeriodElement(this, parentElement,
- labelString, timePeriod, style);
- adapt(element);
- parentElement.addElement(element);
- return element;
- }
-
- /**
- * <p>
- * createPointElement
- * </p>
- *
- * @param style
- * a int.
- * @param parentElement
- * a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
- * object.
- * @param point
- * a {@link eu.etaxonomy.cdm.model.location.Point} object.
- * @return a {@link eu.etaxonomy.taxeditor.ui.element.PointElement} object.
- */
- public PointElement createPointElement(ICdmFormElement parentElement,
- Point point, int style) {
- PointElement element = new PointElement(this, parentElement, point,
- style);
- adapt(element);
- parentElement.addElement(element);
- return element;
- }
-
- /**
- * <p>
- * createDateDetailSection
- * </p>
- *
- * @param parentElement
- * a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
- * object.
- * @param style
- * a int.
- * @return a {@link eu.etaxonomy.taxeditor.ui.element.DateDetailSection}
- * object.
- */
- public DateDetailSection createDateDetailSection(
- ICdmFormElement parentElement, int style) {
- DateDetailSection section = new DateDetailSection(this, parentElement,
- style);
- parentElement.addElement(section);
- adapt(section);
- return section;
- }
-
- /**
- * <p>
- * createPartialElement
- * </p>
- *
- * @param parentElement
- * a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
- * object.
- * @param labelString
- * a {@link java.lang.String} object.
- * @param partial
- * a {@link org.joda.time.Partial} object.
- * @param style
- * a int.
- * @return a {@link eu.etaxonomy.taxeditor.ui.element.PartialElement} object.
- */
- public PartialElement createPartialElement(ICdmFormElement parentElement,
- String labelString, Partial partial, int style) {
- PartialElement element = new PartialElement(this, parentElement,
- labelString, style);
- adapt(element);
- parentElement.addElement(element);
- return element;
- }
-
- /**
- * <p>
- * addSelectionListener
- * </p>
- *
- * @param listener
- * a {@link org.eclipse.swt.events.SelectionListener} object.
- */
- public void addSelectionListener(SelectionListener listener) {
- selectionListenerList.add(listener);
- }
-
- /**
- * <p>
- * removeSelectionListener
- * </p>
- *
- * @param listener
- * a {@link org.eclipse.swt.events.SelectionListener} object.
- */
- public void removeSelectionListener(SelectionListener listener) {
- if (listener == null) {
- StoreUtil
- .error(this.getClass(),
- "Tried to remove a selection listener from this factories listeners but was null",
- null);
- } else {
- selectionListenerList.remove(listener);
- }
- }
-
- /**
- * <p>
- * addPropertyChangeListener
- * </p>
- *
- * @param listener
- * a {@link org.eclipse.jface.util.IPropertyChangeListener}
- * object.
- */
- public void addPropertyChangeListener(IPropertyChangeListener listener) {
- if(propertyChangeListeners.contains(listener)){
- return;
- }
- propertyChangeListeners.add(0, listener);
- }
-
- /**
- * <p>
- * removePropertyChangeListener
- * </p>
- *
- * @param listener
- * a {@link org.eclipse.jface.util.IPropertyChangeListener}
- * object.
- */
- public void removePropertyChangeListener(IPropertyChangeListener listener) {
- propertyChangeListeners.remove(listener);
- }
-
- /**
- * <p>
- * createHorizontalSeparator
- * </p>
- *
- * @param parentElement
- * a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
- * object.
- * @param style
- * a int.
- * @return a {@link org.eclipse.swt.widgets.Label} object.
- */
- public Label createHorizontalSeparator(ICdmFormElement parentElement,
- int style) {
- Label separator = this.createSeparator(
- parentElement.getLayoutComposite(), SWT.HORIZONTAL | style);
- separator.setLayoutData(LayoutConstants.FILL_HORIZONTALLY());
- return separator;
- }
-
- /**
- * <p>
- * createVersionElement
- * </p>
- *
- * @param parentElement
- * a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
- * object.
- * @param entity
- * a {@link eu.etaxonomy.cdm.model.common.VersionableEntity}
- * object.
- * @param style
- * a int.
- * @return a
- * {@link eu.etaxonomy.taxeditor.ui.section.supplemental.VersionElement}
- * object.
- */
- public VersionElement createVersionElement(ICdmFormElement parentElement,
- VersionableEntity entity, int style) {
- VersionElement element = new VersionElement(this, parentElement,
- entity, style);
- adapt(element);
- parentElement.addElement(element);
- return element;
- }
-
- /**
- * @param cdmBaseSection
- * @param object
- * @param style
- * @return
- */
- public CdmBaseElement createCdmBaseElement(ICdmFormElement parentElement,
- CdmBase entity, int style) {
- CdmBaseElement element = new CdmBaseElement(this, parentElement,
- entity, style);
- adapt(element);
- parentElement.addElement(element);
- return element;
- }
-
-
- /**
- * <p>
- * createVersionSection
- * </p>
- *
- * @param parentElement
- * a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
- * object.
- * @param style
- * a int.
- * @return a
- * {@link eu.etaxonomy.taxeditor.ui.section.supplemental.VersionSection}
- * object.
- */
- public VersionSection createVersionSection(ICdmFormElement parentElement,
- int style) {
- VersionSection section = new VersionSection(this, parentElement, style);
- parentElement.addElement(section);
- adapt(section);
- return section;
- }
-
- /**
- * @param parent
- * @param i
- * @return
- */
- public CdmBaseSection createCdmBaseSection(ICdmFormElement parentElement, int style) {
- CdmBaseSection section = new CdmBaseSection(this, parentElement, style);
- parentElement.addElement(section);
- adapt(section);
- return section;
- }
-
- /**
- * <p>
- * createEmptyElement
- * </p>
- *
- * @param parentElement
- * a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
- * object.
- * @return a {@link eu.etaxonomy.taxeditor.ui.section.EmptyElement} object.
- */
- public EmptyElement createEmptyElement(ICdmFormElement parentElement) {
- EmptyElement element = new EmptyElement(this, parentElement, null,
- SWT.NULL);
- adapt(element);
- parentElement.addElement(element);
- return element;
- }
-
- /**
- * <p>
- * createHeadlineSection
- * </p>
- *
- * @param parentElement
- * a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
- * object.
- * @return a
- * {@link eu.etaxonomy.taxeditor.ui.section.supplemental.HeadlineSection}
- * object.
- */
- public HeadlineSection createHeadlineSection(ICdmFormElement parentElement) {
- HeadlineSection section = new HeadlineSection(this, parentElement,
- SWT.NULL);
- parentElement.addElement(section);
- adapt(section);
- return section;
- }
-
- /**
- * <p>
- * createParsingMessageElement
- * </p>
- *
- * @param parentElement
- * a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
- * object.
- * @param parserProblem
- * a {@link eu.etaxonomy.cdm.strategy.parser.ParserProblem}
- * object.
- * @param style
- * a int.
- * @return a
- * {@link eu.etaxonomy.taxeditor.ui.section.taxon.ParsingMessageElement}
- * object.
- */
- public ParsingMessageElement createParsingMessageElement(
- ICdmFormElement parentElement, ParserProblem parserProblem,
- int style) {
- ParsingMessageElement element = new ParsingMessageElement(this,
- parentElement, parserProblem, style);
- adapt(element);
- parentElement.addElement(element);
- return element;
- }
-
- // SIMPLIFY
-
- /**
- *
- */
- public static enum DetailType {
- AUTHORSHIP,
- CLASSIFICATION,
- COLLECTION,
- DERIVED_UNIT,
- DERIVED_UNIT_FACADE,
- DERIVED_UNIT_GENERAL,
- DESCRIPTION,
- DESCRIPTIONELEMENT,
- DETERMINATION,
- FEATURE_DISTRIBUTION,
- FIELD_OBSERVATION,
- GATHERING_EVENT,
- GRANTEDAUTHORITY,
- GROUP,
- HYBRID,
- INSTITUTION,
- MEDIA,
- NAMED_AREA,
- NAMED_AREA_LEVEL,
- NAMERELATIONSHIP,
- NATURAL_LANGUAGE,
- NOMENCLATURALREFERENCE,
- NONVIRALNAME,
- PARSINGMESSAGE,
- PERSON,
- POLYTOMOUS_KEY,
- POLYTOMOUS_KEY_NODE,
- REFERENCEBASE,
- REFERENCED_ENTITY,
- SCIENTIFICNAME,
- TAXON_NODE,
- TAXON_RELATIONSHIP,
- TAXONBASE,
- TEAM,
- TEAMORPERSONBASE,
- TERM_VOCABULARY,
- USE_RECORD,
- USER
- }
-
- public AbstractFormSection createDefinedTermDetailSection(Class definedTermClass,
- ConversationHolder conversation, ICdmFormElement parentElement,
- ISelectionProvider selectionProvider, int style) {
-
- AbstractFormSection section = new DefinedTermDetailSection(this, definedTermClass, conversation, parentElement, selectionProvider, style);
-
- parentElement.addElement(section);
- adapt(section);
- return section;
-
- }
-
- /**
- * @param definedTermClass
- * @param formElement
- * @param style
- * @return
- */
- public AbstractCdmDetailElement createDefinedTermDetailElement(
- Class definedTermClass, AbstractCdmDetailSection parentElement,
- int style) {
- AbstractCdmDetailElement element = null;
-
- if (NamedArea.class.isAssignableFrom(definedTermClass)){
- element = new eu.etaxonomy.taxeditor.ui.section.vocabulary.NamedAreaDetailElement(this, parentElement);
- }
- else {
- element = new DefinedTermDetailElement(this, parentElement);
- }
-
- adapt(element);
- parentElement.addElement(element);
- return element;
- }
-
- /**
- * <p>
- * createCdmDetailSection
- * </p>
- *
- * @param detailType
- * a
- * {@link eu.etaxonomy.taxeditor.ui.element.CdmFormFactory.DetailType}
- * object.
- * @param parentElement
- * a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
- * object.
- * @param selectionProvider
- * a {@link org.eclipse.jface.viewers.ISelectionProvider} object.
- * @param style
- * a int.
- * @param conversation
- * a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder}
- * object.
- * @return a {@link eu.etaxonomy.taxeditor.ui.element.AbstractFormSection}
- * object.
- */
- public AbstractFormSection createCdmDetailSection(DetailType detailType,
- ConversationHolder conversation, ICdmFormElement parentElement,
- ISelectionProvider selectionProvider, int style) {
- AbstractFormSection section = null;
-
- switch (detailType) {
- case SCIENTIFICNAME:
- section = new NameDetailSection(this, conversation, parentElement,
- selectionProvider, style);
- break;
- case REFERENCEBASE:
- section = new ReferenceDetailSection(this, conversation,
- parentElement, selectionProvider, style);
- break;
- case NOMENCLATURALREFERENCE:
- section = new NomenclaturalReferenceDetailSection(this,
- conversation, parentElement, selectionProvider, style);
- break;
- case TAXONBASE:
- section = new TaxonBaseDetailSection(this, conversation,
- parentElement, selectionProvider, style);
- break;
- case AUTHORSHIP:
- section = new AuthorshipDetailSection(this, conversation,
- parentElement, selectionProvider, style);
- break;
- case TEAMORPERSONBASE:
- section = new TeamOrPersonBaseDetailSection(this, conversation,
- parentElement, selectionProvider, style);
- break;
- case TEAM:
- section = new TeamDetailSection(this, conversation, parentElement,
- null, style);
- break;
- case PERSON:
- section = new PersonDetailSection(this, conversation,
- parentElement, null, style);
- break;
- case DESCRIPTION:
- section = new DescriptionDetailSection(this, conversation,
- parentElement, selectionProvider, style);
- break;
- case DESCRIPTIONELEMENT:
- section = new DescriptionElementDetailSection(this, conversation,
- parentElement, selectionProvider, style);
- break;
- case PARSINGMESSAGE:
- section = new ParsingMessagesSection(this, conversation,
- parentElement, selectionProvider, style);
- break;
- case NONVIRALNAME:
- section = new NonViralNameDetailSection(this, conversation,
- parentElement, selectionProvider, style);
- break;
- case MEDIA:
- section = new eu.etaxonomy.taxeditor.ui.section.description.MediaDetailsSection(
- this, conversation, parentElement, selectionProvider, style);
- break;
- case DERIVED_UNIT_FACADE:
- section = new DerivedUnitFacadeDetailSection(this, conversation,
- parentElement, selectionProvider, style);
- break;
- case FIELD_OBSERVATION:
- section = new FieldObservationDetailSection(this, conversation,
- parentElement, selectionProvider, style);
- break;
- case GATHERING_EVENT:
- section = new GatheringEventDetailSection(this, conversation,
- parentElement, selectionProvider, style);
- break;
- case DERIVED_UNIT:
- section = new DerivedUnitBaseDetailSection(this, conversation,
- parentElement, selectionProvider, style);
- break;
- case NATURAL_LANGUAGE:
- section = new NaturalLanguageSection(this, conversation,
- parentElement, selectionProvider, style);
- break;
- case FEATURE_DISTRIBUTION:
- section = new FeatureDistributionDetailSection(this, conversation,
- parentElement, selectionProvider, style);
- break;
- case CLASSIFICATION:
- section = new ClassificationDetailSection(this, conversation,
- parentElement, selectionProvider, style);
- break;
- case TAXON_NODE:
- section = new TaxonNodeDetailSection(this, conversation,
- parentElement, selectionProvider, style);
- break;
- case POLYTOMOUS_KEY:
- section = new PolytomousKeyDetailSection(this, conversation,
- parentElement, selectionProvider, style);
- break;
- case POLYTOMOUS_KEY_NODE:
- section = new PolytomousKeyNodeDetailSection(this, conversation,
- parentElement, selectionProvider, style);
- break;
- case INSTITUTION:
- section = new InstitutionDetailSection(this, conversation,
- parentElement, selectionProvider, style);
- break;
- case DERIVED_UNIT_GENERAL:
- section = new GeneralDetailSection(this, conversation,
- parentElement, selectionProvider, style);
- break;
- case HYBRID:
- section = new HybridDetailSection(this, conversation,
- parentElement, selectionProvider, style);
- break;
- case USER:
- section = new UserDetailSection(this, conversation, parentElement,
- selectionProvider, style);
- break;
- case GROUP:
- section = new GroupDetailSection(this, conversation, parentElement,
- selectionProvider, style);
- break;
- case DETERMINATION:
- section = new DeterminationDetailSection(this, conversation, parentElement,
- selectionProvider, style);
- break;
- case TAXON_RELATIONSHIP:
- section = new TaxonRelationshipDetailSection(this, conversation, parentElement,
- selectionProvider, style);
- break;
- case REFERENCED_ENTITY:
- section = new ReferencedEntityDetailSection(this, conversation, parentElement,
- selectionProvider, style);
- break;
- case TERM_VOCABULARY:
- section = new TermVocabularyDetailSection(this, conversation, parentElement,
- selectionProvider, style);
- break;
- case NAMED_AREA:
- section = new NamedAreaDetailSection(this, conversation, parentElement,
- selectionProvider, style);
- break;
- case USE_RECORD:
- section = new UseRecordDetailSection(this, conversation, parentElement,
- selectionProvider, style);
- break;
- }
-
-
- if (section == null) {
- throw new RuntimeException(
- "You tried to create a cdm detail section that is not implemented yet.");
- }
-
- parentElement.addElement(section);
- adapt(section);
- return section;
- }
-
-
-
- /**
- * <p>
- * createCdmDetailElement
- * </p>
- *
- * @param detailType
- * a
- * {@link eu.etaxonomy.taxeditor.ui.element.CdmFormFactory.DetailType}
- * object.
- * @param style
- * a int.
- * @param parentElement
- * a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
- * object.
- * @return a
- * {@link eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailElement}
- * object.
- */
- public AbstractCdmDetailElement createCdmDetailElement(
- DetailType detailType, ICdmFormElement parentElement, int style) {
- AbstractCdmDetailElement element = null;
-
- switch (detailType) {
- case SCIENTIFICNAME:
- element = new NameDetailElement(this, parentElement, style);
- break;
- case REFERENCEBASE:
- element = new ReferenceDetailElement(this, parentElement, style);
- break;
- case NOMENCLATURALREFERENCE:
- element = new NomenclaturalReferenceDetailElement(this,
- parentElement, style);
- break;
- case TAXONBASE:
- element = new TaxonBaseDetailElement(this, parentElement, style);
- break;
- case AUTHORSHIP:
- element = new AuthorshipDetailElement(this, parentElement, style);
- break;
- case TEAM:
- element = new TeamDetailElement(this, parentElement, style);
- break;
- case PERSON:
- element = new PersonDetailElement(this, parentElement, style);
- break;
- case DESCRIPTION:
- element = new DescriptionDetailElement(this, parentElement, style);
- break;
- case DESCRIPTIONELEMENT:
- element = new DescriptionElementDetailElement(this, parentElement,
- style);
- break;
- case NONVIRALNAME:
- element = new NonViralNameDetailElement(this, parentElement);
- break;
- case DERIVED_UNIT_FACADE:
- element = new DerivedUnitFacadeDetailElement(this, parentElement);
- break;
- case FIELD_OBSERVATION:
- element = new FieldObservationDetailElement(this, parentElement);
- break;
- case GATHERING_EVENT:
- element = new GatheringEventDetailElement(this, parentElement);
- break;
- case DERIVED_UNIT:
- element = new DerivedUnitBaseDetailElement(this, parentElement);
- break;
- case NATURAL_LANGUAGE:
- element = new NaturalLanguageDetailElement(this, parentElement);
- break;
- case FEATURE_DISTRIBUTION:
- element = new FeatureDistributionDetailElement(this, parentElement);
- break;
- case CLASSIFICATION:
- element = new ClassificationDetailElement(this, parentElement);
- break;
- case TAXON_NODE:
- element = new TaxonNodeDetailElement(this, parentElement);
- break;
- case COLLECTION:
- element = new CollectionDetailElement(this, parentElement);
- break;
- case POLYTOMOUS_KEY:
- element = new PolytomousKeyDetailElement(this, parentElement);
- break;
- case POLYTOMOUS_KEY_NODE:
- element = new PolytomousKeyNodeDetailElement(this, parentElement);
- break;
- case INSTITUTION:
- element = new InstitutionDetailElement(this, parentElement);
- break;
- case DERIVED_UNIT_GENERAL:
- element = new GeneralDetailElement(this, parentElement);
- break;
- case HYBRID:
- element = new HybridDetailElement(this, parentElement);
- break;
- case USER:
- element = new UserDetailElement(this, parentElement);
- break;
- case GROUP:
- element = new GroupDetailElement(this, parentElement);
- break;
- case GRANTEDAUTHORITY:
- element = new GrantedAuthorityDetailElement(this, parentElement);
- break;
- case DETERMINATION:
- element = new DeterminationDetailElement(this, parentElement);
- break;
- case TAXON_RELATIONSHIP:
- element = new TaxonRelationshipDetailElement(this, parentElement);
- break;
- case REFERENCED_ENTITY:
- element = new RefereneEntityDetailElement(this, parentElement);
- break;
- case TERM_VOCABULARY:
- element = new TermVocabularyDetailElement(this, parentElement);
- break;
- case NAMED_AREA:
- element = new eu.etaxonomy.taxeditor.ui.section.vocabulary.NamedAreaDetailElement(this, parentElement);
- break;
- case NAMED_AREA_LEVEL:
- element = new DefinedTermDetailElement<NamedAreaLevel>(this, parentElement);
- break;
- case USE_RECORD:
- //element = new UseRecordDetailElement(this, parentElement, style);
- element = new UseRecordDetailElement(this, parentElement);
- break;
- }
-
- if (element == null) {
- StoreUtil
- .error(this.getClass(),
- "Detail element was not created. Seems like the case was not implemented for the requested detail type: "
- + detailType, null);
- }
-
- adapt(element);
- parentElement.addElement(element);
- return element;
- }
-
- /**
- *
- * @author n.hoffmann
- * @created Mar 5, 2010
- * @version 1.0
- */
- public static enum EntityDetailType {
- TEAM,
- TEAMMEMBER,
- ANNOTATION,
- CREDIT,
- DESCRIPTIONELEMENTSOURCE,
- EXTENSION,
- MARKER,
- MEDIA,
- DESCRIPTIONELEMENTMEDIA,
- MEDIAREPRESENTATION,
- MEDIAREPRESENTATIONPART,
- MODIFIER,
- NOMENCLATURALSTATUS,
- NAME_RELATIONSHIP,
- PROTOLOG,
- RIGHTS,
- SOURCE,
- SCOPE,
- DESCRIPTIONSOURCE,
- TYPEDESIGNATION,
- STATE_DATA,
- STATISTICAL_MEASUREMENT_VALUE,
- DESCRIBED_SPECIMEN,
- COLLECTING_AREA,
- DETERMINATION_EVENT,
- SPECIMEN_COLLECTION,
- IDENTIFIABLE_SOURCE_COLLECTION,
- GEOGRAPHICAL_SCOPE,
- SCOPE_RESTRICTION,
- MEMBER,
- GRANTED_AUTHORITY,
- GROUPS_BY_USER,
- TAXONOMIC_SCOPE,
- DETERMINATION_CURRENT,
- DETERMINATION_HISTORY
- }
-
- /**
- * <p>
- * createEntityDetailSection
- * </p>
- *
- * @param entityDetailType
- * a
- * {@link eu.etaxonomy.taxeditor.ui.element.CdmFormFactory.EntityDetailType}
- * object.
- * @param style
- * a int.
- * @param conversation
- * a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder}
- * object.
- * @param parentElement
- * a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
- * object.
- * @return a {@link eu.etaxonomy.taxeditor.ui.element.AbstractFormSection}
- * object.
- */
- public AbstractFormSection createEntityDetailSection(
- EntityDetailType entityDetailType, ConversationHolder conversation,
- ICdmFormElement parentElement, int style) {
- AbstractFormSection section = null;
-
- switch (entityDetailType) {
- case TEAM:
- section = new TeamDetailSection(this, conversation, parentElement,
- null, style);
- break;
- case TEAMMEMBER:
- section = new TeamMemberSection(this, conversation, parentElement,
- style);
- break;
- case ANNOTATION:
- section = new AnnotationSection(this, conversation, parentElement,
- style);
- break;
- case CREDIT:
- section = new CreditSection(this, conversation, parentElement,
- style);
- break;
- case DESCRIPTIONELEMENTSOURCE:
- section = new DescriptionElementSourceSection(this, conversation,
- parentElement, style);
- break;
- case EXTENSION:
- section = new ExtensionSection(this, conversation, parentElement,
- style);
- break;
- case MARKER:
- section = new MarkerSection(this, conversation, parentElement,
- style);
- break;
- case MEDIA:
- section = new MediaSection(this, conversation, parentElement, style);
- break;
- case DESCRIPTIONELEMENTMEDIA:
- section = new DescriptionElementMediaSection(this, conversation,
- parentElement, style);
- break;
- case MEDIAREPRESENTATION:
- section = new MediaRepresentationSection(this, conversation,
- parentElement, style);
- break;
- case MEDIAREPRESENTATIONPART:
- section = new MediaRepresentationPartSection(this, conversation,
- parentElement, style);
- break;
- case MODIFIER:
- section = new ModifierSection(this, conversation, parentElement,
- style);
- break;
- case NOMENCLATURALSTATUS:
- section = new NomenclaturalStatusSection(this, conversation,
- parentElement, style);
- break;
- case NAME_RELATIONSHIP:
- section = new NameRelationshipDetailSection(this, conversation,
- parentElement, style);
- break;
- case PROTOLOG:
- section = new ProtologueSection(this, conversation, parentElement,
- style);
- break;
- case RIGHTS:
- section = new RightsSection(this, conversation, parentElement,
- style);
- break;
- case SOURCE:
- section = new SourceSection(this, conversation, parentElement,
- style);
- break;
- case SCOPE:
- section = new ScopeSection(this, conversation, parentElement, style);
- break;
- case DESCRIPTIONSOURCE:
- section = new DescriptionSourceSection(this, conversation,
- parentElement, style);
- break;
- case TYPEDESIGNATION:
- section = new TypeDesignationSection(this, conversation,
- parentElement, style);
- break;
- case STATE_DATA:
- section = new StateDataSection(this, conversation, parentElement,
- style);
- break;
- case STATISTICAL_MEASUREMENT_VALUE:
- section = new StatisticalMeasurementValueSection(this,
- conversation, parentElement, style);
- break;
- case DESCRIBED_SPECIMEN:
- section = new DescribedSpecimenSection(this, conversation,
- parentElement, style);
- break;
- case COLLECTING_AREA:
- section = new CollectingAreasDetailSection(this, conversation,
- parentElement, style);
- break;
- case DETERMINATION_CURRENT:
- section = new CurrentDeterminationDetailSection(this, conversation,
- parentElement, style);
- break;
- case DETERMINATION_HISTORY:
- section = new DeterminationHistoryDetailSection(this, conversation,
- parentElement, style);
- break;
- case SPECIMEN_COLLECTION:
- section = new SpecimenCollectionDetailSection(this, conversation,
- parentElement, style);
- break;
- case IDENTIFIABLE_SOURCE_COLLECTION:
- section = new SourceCollectionDetailSection(this, conversation,
- parentElement, style);
- break;
- case GEOGRAPHICAL_SCOPE:
- section = new GeographicalScopeDetailSection(this, conversation,
- parentElement, style);
- break;
- case SCOPE_RESTRICTION:
- section = new ScopeRestrictionSection(this, conversation,
- parentElement, style);
- break;
- case MEMBER:
- section = new MemberDetailSection(this, conversation,
- parentElement, style);
- break;
- case GRANTED_AUTHORITY:
- section = new GrantedAuthorityDetailSection(this, conversation,
- parentElement, style);
- break;
- case GROUPS_BY_USER:
- section = new GroupsByUserDetailSection(this, conversation,
- parentElement, style);
- break;
- case TAXONOMIC_SCOPE:
- section = new TaxonomicScopeSection(this, conversation,
- parentElement, style);
- break;
- }
- parentElement.addElement(section);
- adapt(section);
- return section;
- }
-
- /**
- * <p>
- * createEntityCollectionElement
- * </p>
- *
- * @param removeListener
- * a {@link org.eclipse.swt.events.SelectionListener} object.
- * @param style
- * a int.
- * @param parentElement
- * a {@link eu.etaxonomy.taxeditor.ui.element.AbstractFormSection}
- * object.
- * @param versionableEntity
- * a {@link eu.etaxonomy.cdm.model.common.IVersionableEntity}
- * object.
- * @param backgroundColor
- * a {@link org.eclipse.swt.graphics.Color} object.
- * @return a
- * {@link eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionElement}
- * object.
- */
- public AbstractEntityCollectionElement createEntityCollectionElement(
- AbstractFormSection parentElement, Object versionableEntity,
- SelectionListener removeListener, Color backgroundColor, int style) {
- AbstractEntityCollectionElement element = null;
-
- Object entity = HibernateProxyHelper.deproxy(versionableEntity);
-
- if (entity instanceof Annotation) {
- element = new AnnotationElement(this, parentElement,
- (Annotation) entity, removeListener, style);
- } else if (entity instanceof Person) {
- element = new TeamMemberElement(this, parentElement,
- (Person) entity, removeListener, style);
- } else if (entity instanceof Credit) {
- element = new CreditElement(this, parentElement, (Credit) entity,
- removeListener, style);
- } else if (entity instanceof Extension) {
- element = new ExtensionElement(this, parentElement,
- (Extension) entity, removeListener, style);
- } else if (entity instanceof Marker) {
- element = new MarkerElement(this, parentElement, (Marker) entity,
- removeListener, style);
- } else if (entity instanceof Media) {
- element = new MediaElement(this, parentElement, (Media) entity,
- removeListener, style);
- } else if (entity instanceof MediaRepresentation) {
- element = new MediaRepresentationElement(this, parentElement,
- (MediaRepresentation) entity, removeListener, style);
- } else if (entity instanceof ImageFile) {
- element = new ImageFileElement(this, parentElement,
- (ImageFile) entity, removeListener, style);
- } else if (entity instanceof MediaRepresentationPart){
- element = new MediaRepresentationPartElement(this, parentElement,
- (MediaRepresentationPart) entity, removeListener, style);
- } else if (entity instanceof NomenclaturalStatus) {
- element = new NomenclaturalStatusElement(this, parentElement,
- (NomenclaturalStatus) entity, removeListener, style);
- } else if (entity instanceof Rights) {
- element = new RightsElement(this, parentElement, (Rights) entity,
- removeListener, style);
- } else if (entity instanceof DescriptionElementSource) {
- element = new DescriptionElementSourceElement(this, parentElement,
- (DescriptionElementSource) entity, removeListener, style);
- } else if (entity instanceof IdentifiableSource) {
- element = new IdentifiableSourceElement(this, parentElement,
- (IdentifiableSource) entity, removeListener, style);
- } else if (entity instanceof Scope) {
- element = new ScopeElement(this, parentElement, (Scope) entity,
- removeListener, style);
- } else if (entity instanceof Modifier) {
- element = new ModifierElement(this, parentElement,
- (Modifier) entity, removeListener, style);
- } else if (entity instanceof Reference) {
- element = new DescriptionSourceElement(this, parentElement,
- (Reference) entity, removeListener, style);
- } else if (entity instanceof NameTypeDesignation) {
- element = new NameTypeDesignationElement(this, parentElement,
- (NameTypeDesignation) entity, removeListener, style);
- } else if (entity instanceof NameRelationship) {
- element = new NameRelationshipDetailElement(this, parentElement,
- (NameRelationship) entity, removeListener, style);
- } else if (entity instanceof SpecimenTypeDesignation) {
- element = new SpecimenTypeDesignationElement(this, parentElement,
- (SpecimenTypeDesignation) entity, removeListener, style);
- } else if (entity instanceof StateData) {
- element = new StateDataElement(this, parentElement,
- (StateData) entity, removeListener, style);
- } else if (entity instanceof StatisticalMeasurementValue) {
- element = new StatisticalMeasurementValueElement(this,
- parentElement, (StatisticalMeasurementValue) entity,
- removeListener, style);
- } else if (entity instanceof DerivedUnit) {
- element = new DerivedUnitElement(this, parentElement,
- (DerivedUnit) entity, removeListener, style);
- } else if (entity instanceof NamedArea) {
- element = new NamedAreaDetailElement(this, parentElement,
- (NamedArea) entity, removeListener, style);
- } else if (entity instanceof DeterminationEvent) {
- element = new DeterminationEventDetailElement(this, parentElement,
- (DeterminationEvent) entity, removeListener, style);
- } else if (entity instanceof Specimen) {
- element = new SpecimenCollectionDetailElement(this, parentElement,
- (Specimen) entity, removeListener, style);
- } else if (entity instanceof User) {
- element = new MemberDetailElement(this, parentElement,
- (User) entity, removeListener, style);
- } else if (entity instanceof GrantedAuthority) {
- element = new GrantedAuthorityCollectionElement(this, parentElement,
- (GrantedAuthorityImpl) entity, removeListener, style);
- } else if (entity instanceof Group) {
- element = new GroupsByUserDetailElement(this, parentElement,
- (Group) entity, removeListener, style);
- } else if (entity instanceof Taxon) {
- element = new TaxonDetailElement(this, parentElement,
- (Taxon) entity, removeListener, style);
- } else if (entity instanceof DescriptionElementBase) {
- // this is the special case for protologs, maybe we can do this
- // differently when API improves
- DescriptionElementBase descriptionElement = (DescriptionElementBase) entity;
- if (descriptionElement.getFeature().equals(Feature.PROTOLOGUE())) {
- element = new ProtologueElement(this, parentElement,
- descriptionElement, removeListener, style);
- }
- }
-
- if (element == null) {
- StoreUtil
- .errorDialog(
- "No element for entity",
- this,
- "Could not generate element for entity. "
- + "Looks like the case is not handled already. Check implementation. Entity: "
- + entity, null);
-
- }
-
- if (backgroundColor != null && !backgroundColor.isDisposed()) {
- element.setPersistentBackground(backgroundColor);
- }
-
- adapt(element);
- parentElement.addElement(element);
- return element;
- }
-
- /**
- * <p>
- * Creates a selection element for the given type T.
- * </p>
- * <p>
- * <strong>Selection elements not handled by this method:</strong>
- * <ul>
- * <li>{@link TaxonNodeSelectionElement} see {@link #createTaxonNodeSelectionElement(ConversationHolder, ICdmFormElement, String, TaxonNode, int, int)}</li>
- * <li>{@link NomenclaturalAuthorTeamSelectionElement} see {@link #createNomenclaturalAuthorTeamSelectionElement(ConversationHolder, ICdmFormElement, String, Team, int, int)}</li>
- * </ul>
- * </p>
- *
- * @param clazz
- * a {@link Class} object of the type that you want the selection element to handle
- * @param parentElement
- * a {@link ICdmFormElement}
- * object.
- * @param labelString
- * a {@link String} object.
- * @param selectionType
- * @param selection
- * a {@link ICdmBase} object.
- * @param style
- * a int.
- * @param conversation
- * a {@link ConversationHolder} object.
- * @return a
- * {@link EntitySelectionElement}
- * object.
- */
- public <T extends ICdmBase> EntitySelectionElement<T> createSelectionElement(
- Class<T> clazz, ConversationHolder conversation,
- ICdmFormElement parentElement, String labelString,
- T selection, int mode, int style) {
- EntitySelectionElement<T> element = new EntitySelectionElement<T>(this, conversation, parentElement, clazz, labelString, selection, mode, style);
- adapt(element);
- parentElement.addElement(element);
- return element;
- }
-
- public TaxonNodeSelectionElement createTaxonNodeSelectionElement(
- ConversationHolder conversation,
- ICdmFormElement parentElement, String labelString,
- TaxonNode selection, int mode, int style) {
- TaxonNodeSelectionElement element = new TaxonNodeSelectionElement(this, conversation, parentElement, labelString, selection, mode, style);
- adapt(element);
- parentElement.addElement(element);
- return element;
- }
-
- public NomenclaturalAuthorTeamSelectionElement createNomenclaturalAuthorTeamSelectionElement(
- ConversationHolder conversation,
- ICdmFormElement parentElement, String labelString,
- Team selection, int mode, int style) {
- NomenclaturalAuthorTeamSelectionElement element = new NomenclaturalAuthorTeamSelectionElement(this, conversation, parentElement, labelString, selection, mode, style);
- adapt(element);
- parentElement.addElement(element);
- return element;
- }
-
-
- /** {@inheritDoc} */
- public LabelElement createLabel(ICdmFormElement parentElement, String text) {
- LabelElement labelElement = new LabelElement(this, parentElement, text);
- adapt(labelElement);
- parentElement.addElement(labelElement);
- return labelElement;
- }
-
- /**
- * <p>
- * Getter for the field <code>selectionProvider</code>.
- * </p>
- *
- * @return a {@link org.eclipse.jface.viewers.ISelectionProvider} object.
- */
- public ISelectionProvider getSelectionProvider() {
- return selectionProvider;
- }
-
- /**
- * <p>
- * createDetailedDescriptionDetailElement
- * </p>
- *
- * @param parentElement
- * a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
- * object.
- * @param entity
- * a
- * {@link eu.etaxonomy.cdm.model.description.DescriptionElementBase}
- * object.
- * @param style
- * a int.
- * @return a
- * {@link eu.etaxonomy.taxeditor.ui.section.description.detail.AbstractDetailedDescriptionDetailElement}
- * object.
- */
- public AbstractDetailedDescriptionDetailElement createDetailedDescriptionDetailElement(
- ICdmFormElement parentElement, DescriptionElementBase entity,
- int style) {
- AbstractDetailedDescriptionDetailElement detailedDescriptionElement = null;
-
- if (entity instanceof CategoricalData) {
- detailedDescriptionElement = new CategoricalDataDetailElement(this,
- parentElement, (CategoricalData) entity, style);
- } else if (entity instanceof CommonTaxonName) {
- detailedDescriptionElement = new CommonNameDetailElement(this,
- parentElement, (CommonTaxonName) entity, style);
- } else if (entity instanceof Distribution) {
- detailedDescriptionElement = new DistributionDetailElement(this,
- parentElement, (Distribution) entity, style);
- } else if (entity instanceof IndividualsAssociation) {
- detailedDescriptionElement = new IndividualsAssociationDetailElement(
- this, parentElement, (IndividualsAssociation) entity, style);
- } else if (entity instanceof QuantitativeData) {
- detailedDescriptionElement = new QuantitativeDataDetailElement(
- this, parentElement, (QuantitativeData) entity, style);
- } else if (entity instanceof TaxonInteraction) {
- detailedDescriptionElement = new TaxonInteractionDetailElement(
- this, parentElement, (TaxonInteraction) entity, style);
- } else if (entity instanceof TextData) {
- detailedDescriptionElement = new TextDataDetailElement(this,
- parentElement, (TextData) entity, style);
- } else {
- throw new IllegalStateException(
- "There is no interface for the given description element");
- }
- adapt(detailedDescriptionElement);
- parentElement.addElement(detailedDescriptionElement);
- return detailedDescriptionElement;
-
- }
-
- /**
- * Creates a styled text as a part of the form.
- *
- * @param parent
- * the text parent
- * @param value
- * the text initial value
- * @param style
- * the text style
- * @return the text widget
- */
- public StyledText createStyledText(Composite parent, String value, int style) {
- StyledText text = new StyledText(parent, getBorderStyle() | style
- | getOrientation());
- if (value != null)
- text.setText(value);
- text.setForeground(getColors().getForeground());
- text.setBackground(getColors().getBackground());
- // text.addFocusListener(visibilityHandler);
- return text;
- }
-
-
-
-
-
+ private void init() {
+ boldFontHolder2 = new BoldFontHolder2();
+ selectionMouseHandler = new SelectionMouseHandler();
+ selectionFocusHandler = new SelectionFocusHandler();
+ }
+
+ /**
+ * Creates an instance initialized with the correct selectionProvider
+ *
+ * Make sure to remove the instance when the entityComposite disposes via
+ * destroySelectionArbitrator(..)
+ *
+ * @param entityElement
+ * a {@link eu.etaxonomy.taxeditor.ui.element.IEntityElement}
+ * object.
+ * @return a {@link eu.etaxonomy.taxeditor.ui.element.SelectionArbitrator}
+ * object.
+ */
+ public SelectionArbitrator createSelectionArbitrator(IEntityElement entityElement) {
+ SelectionArbitrator selectionArbitrator = new SelectionArbitrator(entityElement);
+ selectionArbitrator.addSelectionProvider(selectionProvider);
+ selectionProvider.addSelectionChangedListener(selectionArbitrator);
+ addSelectionListener(selectionArbitrator);
+ return selectionArbitrator;
+ }
+
+ /**
+ * <p>
+ * destroySelectionArbitrator
+ * </p>
+ *
+ * @param selectionArbitrator
+ * a
+ * {@link eu.etaxonomy.taxeditor.ui.element.SelectionArbitrator}
+ * object.
+ */
+ public void destroySelectionArbitrator(SelectionArbitrator selectionArbitrator) {
+ removeSelectionListener(selectionArbitrator);
+ if (selectionProvider != null) {
+ selectionProvider.removeSelectionChangedListener(selectionArbitrator);
+ } else {
+ AbstractUtility.error(this.getClass(),
+ "Tried to destroy a selection listener from this factories listeners but was null", null);
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public void adapt(Composite composite) {
+ composite.addMouseListener(selectionMouseHandler);
+ super.adapt(composite);
+ }
+
+ /**
+ * <p>
+ * Adapts the {@link AbstractCdmFormElement}:<br>
+ * - sets the {@link IPropertyChangeListener}s handled by this class
+ * </p>
+ *
+ * @param formElement
+ * a
+ * {@link eu.etaxonomy.taxeditor.ui.element.AbstractCdmFormElement}
+ * object.
+ */
+ public void adapt(AbstractCdmFormElement formElement) {
+ formElement.setPropertyChangeListeners(propertyChangeListeners);
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public void adapt(Control control, boolean trackFocus, boolean trackKeyboard) {
+ if (trackFocus) {
+ control.addFocusListener(selectionFocusHandler);
+ }
+ super.adapt(control, trackFocus, trackKeyboard);
+ }
+
+ /**
+ * <p>
+ * destroyElement
+ * </p>
+ *
+ * @param formElement
+ * a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
+ * object.
+ */
+ public void destroyElement(ICdmFormElement formElement) {
+ // return if element was not initialized
+ if (formElement == null) {
+ return;
+ }
+ // destroy selection arbitrator, if any
+ if (formElement instanceof ISelectableElement) {
+ destroySelectionArbitrator(((ISelectableElement) formElement).getSelectionArbitrator());
+ }
+ // remove this element form its parents list of elements
+ // ICdmFormElement parentElement = formElement.getParentElement();
+ // if(parentElement != null){
+ // parentElement.removeElement(formElement);
+ // }
+ // call destroy on child elements recursively
+ for (ICdmFormElement childElement : formElement.getElements()) {
+ destroyElement(childElement);
+ }
+ // dispose of the controls
+ for (Control control : formElement.getControls()) {
+ // we added the layoutComposite of the parental element as the
+ // layout composite to this formElement
+ // but we do not want to destroy it.
+ if (control.equals(formElement.getLayoutComposite())) {
+ continue;
+ } else {
+ control.dispose();
+ control = null;
+ }
+ }
+ }
+
+ /**
+ * <p>
+ * createEmptyCell
+ * </p>
+ *
+ * @param parent
+ * a {@link org.eclipse.swt.widgets.Composite} object.
+ * @return a {@link org.eclipse.swt.widgets.Label} object.
+ */
+ public Label createEmptyCell(Composite parent) {
+ return this.createLabel(parent, null);
+ }
+
+ /**
+ * <p>
+ * createMultilineTextWithLabel
+ * </p>
+ *
+ * @param labelString
+ * a {@link java.lang.String} object.
+ * @param textHeight
+ * a int.
+ * @param style
+ * a int.
+ * @param parentElement
+ * a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
+ * object.
+ * @return a {@link eu.etaxonomy.taxeditor.ui.element.TextWithLabelElement}
+ * object.
+ */
+ public TextWithLabelElement createMultilineTextWithLabel(ICdmFormElement parentElement, String labelString,
+ int textHeight, int style) {
+ TextWithLabelElement element = new TextWithLabelElement(this, parentElement, labelString, "", textHeight, style);
+ adapt(element);
+ parentElement.addElement(element);
+ return element;
+ }
+
+ /**
+ * <p>
+ * createMultiLanguageTextElement
+ * </p>
+ *
+ * @param parentElement
+ * a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
+ * object.
+ * @param labelString
+ * a {@link java.lang.String} object.
+ * @param multilanguageText
+ * a {@link java.util.Map} object.
+ * @param textHeight
+ * a int.
+ * @param style
+ * a int.
+ * @return a
+ * {@link eu.etaxonomy.taxeditor.ui.element.MultilanguageTextElement}
+ * object.
+ */
+ public MultilanguageTextElement createMultiLanguageTextElement(ICdmFormElement parentElement, String labelString,
+ Map<Language, LanguageString> multilanguageText, int textHeight, int style) {
+ MultilanguageTextElement element = new MultilanguageTextElement(this, parentElement, labelString,
+ multilanguageText, textHeight, style);
+ adapt(element);
+ parentElement.addElement(element);
+ return element;
+ }
+
+ public KeyStatementElement createKeyStatementElement(ICdmFormElement parentElement, String labelString,
+ KeyStatement keyStatement, int textHeight, int style) {
+ KeyStatementElement element = new KeyStatementElement(this, parentElement, labelString, keyStatement,
+ textHeight, style);
+ adapt(element);
+ parentElement.addElement(element);
+ return element;
+ }
+
+ /**
+ * <p>
+ * createTextWithLabelElement
+ * </p>
+ *
+ * @param labelString
+ * a {@link java.lang.String} object.
+ * @param initialText
+ * a {@link java.lang.String} object.
+ * @param style
+ * a int.
+ * @param parentElement
+ * a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
+ * object.
+ * @return a {@link eu.etaxonomy.taxeditor.ui.element.TextWithLabelElement}
+ * object.
+ */
+ public TextWithLabelElement createTextWithLabelElement(ICdmFormElement parentElement, String labelString,
+ String initialText, int style) {
+ TextWithLabelElement element = new TextWithLabelElement(this, parentElement, labelString, initialText, null,
+ style);
+ adapt(element);
+ parentElement.addElement(element);
+ return element;
+ }
+
+ public UriWithLabelElement createUriWithLabelElement(ICdmFormElement parentElement, String labelString,
+ URI initialUri, int style) {
+ UriWithLabelElement element = new UriWithLabelElement(this, parentElement, labelString, initialUri, null, style);
+ adapt(element);
+ parentElement.addElement(element);
+ return element;
+ }
+
+ /**
+ * @param element
+ * @param string
+ * @param uri
+ * @param style
+ * @return
+ */
+ public OpenUrlSelectorElement createOpenUrlSelectorElement(ICdmFormElement parentElement, String labelString,
+ IOpenUrlEnabled openUrlEnabled, int style) {
+ OpenUrlSelectorElement element = new OpenUrlSelectorElement(this, parentElement, labelString, openUrlEnabled,
+ style);
+ adapt(element);
+ parentElement.addElement(element);
+ return element;
+ }
+
+ /**
+ *
+ * @param parentElement
+ * @param labelString
+ * @param conversationEnabled
+ * @param user
+ * @param style
+ * @return
+ */
+ public EditPasswordElement createEditPasswordElement(ICdmFormElement parentElement, String labelString,
+ ConversationHolder conversation, User user, int style) {
+ EditPasswordElement element = new EditPasswordElement(this, parentElement, labelString, user, conversation);
+ adapt(element);
+ parentElement.addElement(element);
+ return element;
+ }
+
+ /**
+ * <p>
+ * createIntegerTextWithLabelElement
+ * </p>
+ *
+ * @param parentElement
+ * a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
+ * object.
+ * @param labelString
+ * a {@link java.lang.String} object.
+ * @param initialInteger
+ * a {@link java.lang.Integer} object.
+ * @param style
+ * a int.
+ * @return a
+ * {@link eu.etaxonomy.taxeditor.ui.element.NumberWithLabelElement}
+ * object.
+ */
+ public NumberWithLabelElement createIntegerTextWithLabelElement(ICdmFormElement parentElement, String labelString,
+ Integer initialInteger, int style) {
+ NumberWithLabelElement element = new NumberWithLabelElement(this, parentElement, labelString, initialInteger,
+ style);
+ adapt(element);
+ parentElement.addElement(element);
+ return element;
+ }
+
+ /**
+ * <p>
+ * createFloatTextWithLabelElement
+ * </p>
+ *
+ * @param parentElement
+ * a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
+ * object.
+ * @param labelString
+ * a {@link java.lang.String} object.
+ * @param initialFloat
+ * a float.
+ * @param style
+ * a int.
+ * @return a
+ * {@link eu.etaxonomy.taxeditor.ui.element.NumberWithLabelElement}
+ * object.
+ */
+ public NumberWithLabelElement createFloatTextWithLabelElement(ICdmFormElement parentElement, String labelString,
+ float initialFloat, int style) {
+ NumberWithLabelElement element = new NumberWithLabelElement(this, parentElement, labelString, initialFloat,
+ style);
+ adapt(element);
+ parentElement.addElement(element);
+ return element;
+ }
+
+ /**
+ * <p>
+ * createLanguageStringWithLabelElement
+ * </p>
+ *
+ * @param parentElement
+ * a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
+ * object.
+ * @param labelString
+ * a {@link java.lang.String} object.
+ * @param languageString
+ * a {@link eu.etaxonomy.cdm.model.common.LanguageString} object.
+ * @param style
+ * a int.
+ * @return a
+ * {@link eu.etaxonomy.taxeditor.ui.element.LanguageStringWithLabelElement}
+ * object.
+ */
+ public LanguageStringWithLabelElement createLanguageStringWithLabelElement(ICdmFormElement parentElement,
+ String labelString, LanguageString languageString, int style) {
+ LanguageStringWithLabelElement element = new LanguageStringWithLabelElement(this, parentElement, labelString,
+ languageString, style);
+ adapt(element);
+ parentElement.addElement(element);
+ return element;
+ }
+
+ /**
+ * <p>
+ * createLanguageStringWithLabelElement
+ * </p>
+ *
+ * @param parentElement
+ * a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
+ * object.
+ * @param labelString
+ * a {@link java.lang.String} object.
+ * @param languageString
+ * a {@link eu.etaxonomy.cdm.model.common.LanguageString} object.
+ * @param height
+ * a int.
+ * @param style
+ * a int.
+ * @return a
+ * {@link eu.etaxonomy.taxeditor.ui.element.LanguageStringWithLabelElement}
+ * object.
+ */
+ public LanguageStringWithLabelElement createLanguageStringWithLabelElement(ICdmFormElement parentElement,
+ String labelString, LanguageString languageString, int height, int style) {
+ LanguageStringWithLabelElement element = new LanguageStringWithLabelElement(this, parentElement, labelString,
+ languageString, height, style);
+ adapt(element);
+ parentElement.addElement(element);
+ return element;
+ }
+
+ /**
+ * <p>
+ * createTextElement
+ * </p>
+ *
+ * @param parentElement
+ * a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
+ * object.
+ * @param initialText
+ * a {@link java.lang.String} object.
+ * @param style
+ * a int.
+ * @return a {@link eu.etaxonomy.taxeditor.ui.element.TextWithLabelElement}
+ * object.
+ */
+ public TextWithLabelElement createTextElement(ICdmFormElement parentElement, String initialText, int style) {
+ TextWithLabelElement element = new TextWithLabelElement(this, parentElement, null, initialText, null, style);
+ adapt(element);
+ parentElement.addElement(element);
+ return element;
+ }
+
+ /**
+ * <p>
+ * createKeyValueViewerElement
+ * </p>
+ *
+ * @param parentElement
+ * a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
+ * object.
+ * @param keyHeading
+ * a {@link java.lang.String} object.
+ * @param valueHeading
+ * a {@link java.lang.String} object.
+ * @param map
+ * a {@link java.util.Map} object.
+ * @return a {@link eu.etaxonomy.taxeditor.ui.element.KeyValueViewerElement}
+ * object.
+ */
+ public KeyValueViewerElement createKeyValueViewerElement(ICdmFormElement parentElement, String keyHeading,
+ String valueHeading, Map<Object, Object> map) {
+ KeyValueViewerElement element = new KeyValueViewerElement(this, parentElement, keyHeading, valueHeading, map);
+ adapt(element);
+ parentElement.addElement(element);
+ return element;
+ }
+
+ /**
+ * <p>
+ * createTermComboElement
+ * </p>
+ *
+ * @param termComboType
+ * a
+ * {@link eu.eu.etaxonomy.taxeditor.ui.element.CdmFormFactory.TermComboType}
+ * object.
+ * @param parentElement
+ * a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
+ * object.
+ * @param labelString
+ * a {@link java.lang.String} object.
+ * @param selection
+ * a {@link eu.etaxonomy.cdm.model.common.DefinedTermBase}
+ * object.
+ * @param style
+ * a int.
+ * @return a {@link eu.etaxonomy.taxeditor.ui.combo.TermComboElement}
+ * object.
+ */
+
+ public <T extends DefinedTermBase> TermComboElement<T> createTermComboElement(Class<T> termComboType,
+ ICdmFormElement parentElement, String labelString, T selection, int style) {
+ TermComboElement<T> element = new TermComboElement<T>(this, parentElement, termComboType, labelString,
+ selection, style);
+ adapt(element);
+ parentElement.addElement(element);
+ return element;
+ }
+
+ /**
+ * <p>
+ * createEnumComboElement
+ * </p>
+ *
+ * @param enumComboType
+ * a
+ * {@link eu.eu.etaxonomy.taxeditor.ui.element.CdmFormFactory.EnumComboType}
+ * object.
+ * @param parentElement
+ * a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
+ * object.
+ * @param style
+ * a int.
+ * @return a {@link eu.etaxonomy.taxeditor.ui.term.AbstractEnumComboElement}
+ * object.
+ */
+ public <T extends IDefinedTerm> EnumComboElement<T> createEnumComboElement(Class<T> enumComboType,
+ ICdmFormElement parentElement, int style) {
+ EnumComboElement<T> element = new EnumComboElement<T>(this, parentElement, enumComboType, style);
+ adapt(element);
+ parentElement.addElement(element);
+ return element;
+ }
+
+ /**
+ * <p>
+ * createBrowserElement
+ * </p>
+ *
+ * @param imageUri
+ * a {@link java.net.URI} object.
+ * @param style
+ * a int.
+ * @param parentElement
+ * a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
+ * object.
+ * @return a {@link eu.etaxonomy.taxeditor.ui.element.BrowserElement}
+ * object.
+ */
+ public BrowserElement createBrowserElement(ICdmFormElement parentElement, URI imageUri, int style) {
+ BrowserElement element = new BrowserElement(this, parentElement, imageUri, style);
+ adapt(element);
+ parentElement.addElement(element);
+ return element;
+ }
+
+ /**
+ * <p>
+ * createImageElement
+ * </p>
+ *
+ * @param parentElement
+ * a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
+ * object.
+ * @param imageUri
+ * a {@link java.net.URI} object.
+ * @param style
+ * a int.
+ * @return a {@link eu.etaxonomy.taxeditor.ui.element.ImageElement} object.
+ */
+ public ImageElement createImageElement(ICdmFormElement parentElement, URI imageUri, int style) {
+ ImageElement element = new ImageElement(this, parentElement, imageUri, style);
+ adapt(element);
+ parentElement.addElement(element);
+ return element;
+ }
+
+ /**
+ * <p>
+ * createTextActionElement
+ * </p>
+ *
+ * @param labelString
+ * a {@link java.lang.String} object.
+ * @param initialText
+ * a {@link java.lang.String} object.
+ * @param style
+ * a int.
+ * @param parentElement
+ * a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
+ * object.
+ * @param buttonLabel
+ * a {@link java.lang.String} object.
+ * @return a {@link eu.etaxonomy.taxeditor.ui.element.TextActionElement}
+ * object.
+ */
+ public TextActionElement createTextActionElement(ICdmFormElement parentElement, String labelString,
+ String buttonLabel, String initialText, int style) {
+ TextActionElement element = new TextActionElement(this, parentElement, labelString, buttonLabel, initialText,
+ style);
+ adapt(element);
+ parentElement.addElement(element);
+ return element;
+ }
+
+ /**
+ * <p>
+ * createCheckbox
+ * </p>
+ *
+ * @param parentElement
+ * a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
+ * object.
+ * @param label
+ * a {@link java.lang.String} object.
+ * @param initialState
+ * a boolean.
+ * @param style
+ * a int.
+ * @return a {@link eu.etaxonomy.taxeditor.ui.element.CheckboxElement}
+ * object.
+ */
+ public CheckboxElement createCheckbox(ICdmFormElement parentElement, String label, boolean initialState, int style) {
+ CheckboxElement element = new CheckboxElement(this, parentElement, label, initialState, style | orientation);
+ adapt(element);
+ parentElement.addElement(element);
+ return element;
+ }
+
+ /**
+ * Creates a section as a part of the form.
+ *
+ * @return the section widget
+ * @param section
+ * a
+ * {@link eu.etaxonomy.taxeditor.ui.element.AbstractFormSection}
+ * object.
+ */
+ public Section adapt(AbstractFormSection section) {
+ section.setMenu(section.getLayoutComposite().getMenu());
+ adapt(section, true, true);
+
+ // handle focus and property change events for cdm use
+ section.addFocusListener(selectionFocusHandler);
+ section.setPropertyChangeListeners(propertyChangeListeners);
+
+ if (section.getToggle() != null) {
+ section.getToggle().setHoverDecorationColor(getColors().getColor(IFormColors.TB_TOGGLE_HOVER));
+ section.getToggle().setDecorationColor(getColors().getColor(IFormColors.TB_TOGGLE));
+ }
+
+ section.setFont(boldFontHolder2.getBoldFont(section.getLayoutComposite().getFont()));
+
+ if ((section.getStyle() & ExpandableComposite.TITLE_BAR) != 0
+ || (section.getStyle() & ExpandableComposite.SHORT_TITLE_BAR) != 0) {
+ getColors().initializeSectionToolBarColors();
+ section.setTitleBarBackground(getColors().getColor(IFormColors.TB_BG));
+ section.setTitleBarBorderColor(getColors().getColor(IFormColors.TB_BORDER));
+ }
+ // call setTitleBarForeground regardless as it also sets the label color
+ section.setTitleBarForeground(getColors().getColor(IFormColors.TB_TOGGLE));
+ return section;
+ }
+
+ private class BoldFontHolder2 {
+ private Font normalFont;
+
+ private Font boldFont;
+
+ public BoldFontHolder2() {
+ }
+
+ public Font getBoldFont(Font font) {
+ createBoldFont(font);
+ return boldFont;
+ }
+
+ private void createBoldFont(Font font) {
+ if (normalFont == null || !normalFont.equals(font)) {
+ normalFont = font;
+ dispose();
+ }
+ if (boldFont == null) {
+ boldFont = FormFonts.getInstance().getBoldFont(getColors().getDisplay(), normalFont);
+ }
+ }
+
+ public void dispose() {
+ if (boldFont != null) {
+ FormFonts.getInstance().markFinished(boldFont, getColors().getDisplay());
+ boldFont = null;
+ }
+ }
+ }
+
+ /**
+ * <p>
+ * createToggleableTextField
+ * </p>
+ *
+ * @param parentElement
+ * a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
+ * object.
+ * @param labelString
+ * a {@link java.lang.String} object.
+ * @param initialText
+ * a {@link java.lang.String} object.
+ * @param initialState
+ * a boolean.
+ * @param style
+ * a int.
+ * @return a {@link eu.etaxonomy.taxeditor.ui.element.ToggleableTextElement}
+ * object.
+ */
+ public ToggleableTextElement createToggleableTextField(ICdmFormElement parentElement, String labelString,
+ String initialText, boolean initialState, int style) {
+ ToggleableTextElement element = new ToggleableTextElement(this, parentElement, labelString, initialText,
+ initialState, style | orientation);
+ adapt(element);
+ parentElement.addElement(element);
+ return element;
+ }
+
+ /**
+ * <p>
+ * createTimePeriodElement
+ * </p>
+ *
+ * @param parentElement
+ * a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
+ * object.
+ * @param labelString
+ * a {@link java.lang.String} object.
+ * @param timePeriod
+ * a {@link eu.etaxonomy.cdm.model.common.TimePeriod} object.
+ * @param style
+ * a int.
+ * @return a {@link eu.etaxonomy.taxeditor.ui.element.TimePeriodElement}
+ * object.
+ */
+ public TimePeriodElement createTimePeriodElement(ICdmFormElement parentElement, String labelString,
+ TimePeriod timePeriod, int style) {
+ TimePeriodElement element = new TimePeriodElement(this, parentElement, labelString, timePeriod, style);
+ adapt(element);
+ parentElement.addElement(element);
+ return element;
+ }
+
+ /**
+ * <p>
+ * createPointElement
+ * </p>
+ *
+ * @param style
+ * a int.
+ * @param parentElement
+ * a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
+ * object.
+ * @param point
+ * a {@link eu.etaxonomy.cdm.model.location.Point} object.
+ * @return a {@link eu.etaxonomy.taxeditor.ui.element.PointElement} object.
+ */
+ public PointElement createPointElement(ICdmFormElement parentElement, Point point, int style) {
+ PointElement element = new PointElement(this, parentElement, point, style);
+ adapt(element);
+ parentElement.addElement(element);
+ return element;
+ }
+
+ /**
+ * <p>
+ * createDateDetailSection
+ * </p>
+ *
+ * @param parentElement
+ * a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
+ * object.
+ * @param style
+ * a int.
+ * @return a {@link eu.etaxonomy.taxeditor.ui.element.DateDetailSection}
+ * object.
+ */
+ public DateDetailSection createDateDetailSection(ICdmFormElement parentElement, int style) {
+ DateDetailSection section = new DateDetailSection(this, parentElement, style);
+ parentElement.addElement(section);
+ adapt(section);
+ return section;
+ }
+
+ /**
+ * <p>
+ * createPartialElement
+ * </p>
+ *
+ * @param parentElement
+ * a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
+ * object.
+ * @param labelString
+ * a {@link java.lang.String} object.
+ * @param partial
+ * a {@link org.joda.time.Partial} object.
+ * @param style
+ * a int.
+ * @return a {@link eu.etaxonomy.taxeditor.ui.element.PartialElement}
+ * object.
+ */
+ public PartialElement createPartialElement(ICdmFormElement parentElement, String labelString, Partial partial,
+ int style) {
+ PartialElement element = new PartialElement(this, parentElement, labelString, style);
+ adapt(element);
+ parentElement.addElement(element);
+ return element;
+ }
+
+ /**
+ * <p>
+ * addSelectionListener
+ * </p>
+ *
+ * @param listener
+ * a {@link org.eclipse.swt.events.SelectionListener} object.
+ */
+ public void addSelectionListener(SelectionListener listener) {
+ selectionListenerList.add(listener);
+ }
+
+ /**
+ * <p>
+ * removeSelectionListener
+ * </p>
+ *
+ * @param listener
+ * a {@link org.eclipse.swt.events.SelectionListener} object.
+ */
+ public void removeSelectionListener(SelectionListener listener) {
+ if (listener == null) {
+ AbstractUtility.error(this.getClass(),
+ "Tried to remove a selection listener from this factories listeners but was null", null);
+ } else {
+ selectionListenerList.remove(listener);
+ }
+ }
+
+ /**
+ * <p>
+ * addPropertyChangeListener
+ * </p>
+ *
+ * @param listener
+ * a {@link org.eclipse.jface.util.IPropertyChangeListener}
+ * object.
+ */
+ public void addPropertyChangeListener(IPropertyChangeListener listener) {
+ if (propertyChangeListeners.contains(listener)) {
+ return;
+ }
+ propertyChangeListeners.add(0, listener);
+ }
+
+ /**
+ * <p>
+ * removePropertyChangeListener
+ * </p>
+ *
+ * @param listener
+ * a {@link org.eclipse.jface.util.IPropertyChangeListener}
+ * object.
+ */
+ public void removePropertyChangeListener(IPropertyChangeListener listener) {
+ propertyChangeListeners.remove(listener);
+ }
+
+ /**
+ * <p>
+ * createHorizontalSeparator
+ * </p>
+ *
+ * @param parentElement
+ * a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
+ * object.
+ * @param style
+ * a int.
+ * @return a {@link org.eclipse.swt.widgets.Label} object.
+ */
+ public Label createHorizontalSeparator(ICdmFormElement parentElement, int style) {
+ Label separator = this.createSeparator(parentElement.getLayoutComposite(), SWT.HORIZONTAL | style);
+ separator.setLayoutData(LayoutConstants.FILL_HORIZONTALLY());
+ return separator;
+ }
+
+ /**
+ * <p>
+ * createVersionElement
+ * </p>
+ *
+ * @param parentElement
+ * a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
+ * object.
+ * @param entity
+ * a {@link eu.etaxonomy.cdm.model.common.VersionableEntity}
+ * object.
+ * @param style
+ * a int.
+ * @return a
+ * {@link eu.etaxonomy.taxeditor.ui.section.supplemental.VersionElement}
+ * object.
+ */
+ public VersionElement createVersionElement(ICdmFormElement parentElement, VersionableEntity entity, int style) {
+ VersionElement element = new VersionElement(this, parentElement, entity, style);
+ adapt(element);
+ parentElement.addElement(element);
+ return element;
+ }
+
+ /**
+ * @param cdmBaseSection
+ * @param object
+ * @param style
+ * @return
+ */
+ public CdmBaseElement createCdmBaseElement(ICdmFormElement parentElement, CdmBase entity, int style) {
+ CdmBaseElement element = new CdmBaseElement(this, parentElement, entity, style);
+ adapt(element);
+ parentElement.addElement(element);
+ return element;
+ }
+
+ /**
+ * <p>
+ * createVersionSection
+ * </p>
+ *
+ * @param parentElement
+ * a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
+ * object.
+ * @param style
+ * a int.
+ * @return a
+ * {@link eu.etaxonomy.taxeditor.ui.section.supplemental.VersionSection}
+ * object.
+ */
+ public VersionSection createVersionSection(ICdmFormElement parentElement, int style) {
+ VersionSection section = new VersionSection(this, parentElement, style);
+ parentElement.addElement(section);
+ adapt(section);
+ return section;
+ }
+
+ /**
+ * @param parent
+ * @param i
+ * @return
+ */
+ public CdmBaseSection createCdmBaseSection(ICdmFormElement parentElement, int style) {
+ CdmBaseSection section = new CdmBaseSection(this, parentElement, style);
+ parentElement.addElement(section);
+ adapt(section);
+ return section;
+ }
+
+ /**
+ * <p>
+ * createEmptyElement
+ * </p>
+ *
+ * @param parentElement
+ * a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
+ * object.
+ * @return a {@link eu.etaxonomy.taxeditor.ui.section.EmptyElement} object.
+ */
+ public EmptyElement createEmptyElement(ICdmFormElement parentElement) {
+ EmptyElement element = new EmptyElement(this, parentElement, null, SWT.NULL);
+ adapt(element);
+ parentElement.addElement(element);
+ return element;
+ }
+
+ /**
+ * <p>
+ * createHeadlineSection
+ * </p>
+ *
+ * @param parentElement
+ * a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
+ * object.
+ * @return a
+ * {@link eu.etaxonomy.taxeditor.ui.section.supplemental.HeadlineSection}
+ * object.
+ */
+ public HeadlineSection createHeadlineSection(ICdmFormElement parentElement) {
+ HeadlineSection section = new HeadlineSection(this, parentElement, SWT.NULL);
+ parentElement.addElement(section);
+ adapt(section);
+ return section;
+ }
+
+ /**
+ * <p>
+ * createParsingMessageElement
+ * </p>
+ *
+ * @param parentElement
+ * a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
+ * object.
+ * @param parserProblem
+ * a {@link eu.etaxonomy.cdm.strategy.parser.ParserProblem}
+ * object.
+ * @param style
+ * a int.
+ * @return a
+ * {@link eu.etaxonomy.taxeditor.ui.section.taxon.ParsingMessageElement}
+ * object.
+ */
+ public ParsingMessageElement createParsingMessageElement(ICdmFormElement parentElement,
+ ParserProblem parserProblem, int style) {
+ ParsingMessageElement element = new ParsingMessageElement(this, parentElement, parserProblem, style);
+ adapt(element);
+ parentElement.addElement(element);
+ return element;
+ }
+
+ // SIMPLIFY
+
+ /**
+ * Used to define which {@link AbstractCdmDetailSection} or
+ * {@link AbstractCdmDetailElement} should be created with
+ * {@link CdmFormFactory#createCdmDetailSection(DetailType, ConversationHolder, ICdmFormElement, ISelectionProvider, int)}
+ * or
+ * {@link CdmFormFactory#createCdmDetailElement(DetailType, ICdmFormElement, int)}
+ */
+ public static enum DetailType {
+ AUTHORSHIP,
+ CLASSIFICATION,
+ COLLECTION,
+ DERIVED_UNIT,
+ DERIVED_UNIT_FACADE,
+ DERIVED_UNIT_GENERAL,
+ DESCRIPTION,
+ DESCRIPTIONELEMENT,
+ DETERMINATION,
+ FEATURE_DISTRIBUTION,
+ FIELD_OBSERVATION,
+ GATHERING_EVENT,
+ GRANTEDAUTHORITY,
+ GROUP,
+ HYBRID,
+ INSTITUTION,
+ MEDIA,
+ NAMED_AREA,
+ NAMED_AREA_LEVEL,
+ NAMERELATIONSHIP,//never used
+ NATURAL_LANGUAGE,
+ NOMENCLATURALREFERENCE,
+ NONVIRALNAME,
+ PARSINGMESSAGE,
+ PERSON,
+ POLYTOMOUS_KEY,
+ POLYTOMOUS_KEY_NODE,
+ REFERENCEBASE,
+ REFERENCED_ENTITY,
+ SCIENTIFICNAME,
+ TAXON_NODE,
+ TAXON_RELATIONSHIP,
+ TAXONBASE,
+ TEAM,
+ TEAMORPERSONBASE,
+ TERM_VOCABULARY,
+ USE_RECORD,
+ USER
+ }
+
+ public AbstractFormSection createDefinedTermDetailSection(Class definedTermClass, ConversationHolder conversation,
+ ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style) {
+
+ AbstractFormSection section = new DefinedTermDetailSection(this, definedTermClass, conversation, parentElement,
+ selectionProvider, style);
+
+ parentElement.addElement(section);
+ adapt(section);
+ return section;
+
+ }
+
+ /**
+ * @param definedTermClass
+ * @param formElement
+ * @param style
+ * @return
+ */
+ public AbstractCdmDetailElement createDefinedTermDetailElement(Class definedTermClass,
+ AbstractCdmDetailSection parentElement, int style) {
+ AbstractCdmDetailElement element = null;
+
+ if (NamedArea.class.isAssignableFrom(definedTermClass)) {
+ element = new eu.etaxonomy.taxeditor.ui.section.vocabulary.NamedAreaDetailElement(this, parentElement);
+ } else {
+ element = new DefinedTermDetailElement(this, parentElement);
+ }
+
+ adapt(element);
+ parentElement.addElement(element);
+ return element;
+ }
+
+ public GeneralDetailSection createFOSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
+ GeneralDetailSection generalSection = new GeneralDetailSection(this, conversation, parentElement, selectionProvider, style);
+ parentElement.addElement(generalSection);
+ adapt(generalSection);
+ return generalSection;
+ }
+
+ public GatheringEventDetailSection createGatheringSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
+ GatheringEventDetailSection gatheringSection = new GatheringEventDetailSection(this, conversation, parentElement, selectionProvider, style);
+ parentElement.addElement(gatheringSection);
+ adapt(gatheringSection);
+ return gatheringSection;
+ }
+
+ public FieldObservationDetailSection createFODetailsSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
+ FieldObservationDetailSection foDetailsSection = new FieldObservationDetailSection(this, conversation, parentElement, selectionProvider, style);
+ parentElement.addElement(foDetailsSection);
+ adapt(foDetailsSection);
+ return foDetailsSection;
+ }
+
+ /**
+ * <p>
+ * createCdmDetailSection
+ * </p>
+ *
+ * @param detailType
+ * a
+ * {@link eu.etaxonomy.taxeditor.ui.element.CdmFormFactory.DetailType}
+ * object.
+ * @param parentElement
+ * a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
+ * object.
+ * @param selectionProvider
+ * a {@link org.eclipse.jface.viewers.ISelectionProvider} object.
+ * @param style
+ * a int.
+ * @param conversation
+ * a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder}
+ * object.
+ * @return a {@link eu.etaxonomy.taxeditor.ui.element.AbstractFormSection}
+ * object.
+ */
+ public AbstractFormSection createCdmDetailSection(DetailType detailType, ConversationHolder conversation,
+ ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style) {
+ AbstractFormSection section = null;
+
+// System.out.println("DetailSection: " + detailType);
+ switch (detailType) {
+ case SCIENTIFICNAME:
+ section = new NameDetailSection(this, conversation, parentElement, selectionProvider, style);
+ break;
+ case REFERENCEBASE:
+ section = new ReferenceDetailSection(this, conversation, parentElement, selectionProvider, style);
+ break;
+ case NOMENCLATURALREFERENCE:
+ section = new NomenclaturalReferenceDetailSection(this, conversation, parentElement, selectionProvider,
+ style);
+ break;
+ case TAXONBASE:
+ section = new TaxonBaseDetailSection(this, conversation, parentElement, selectionProvider, style);
+ break;
+ case AUTHORSHIP:
+ section = new AuthorshipDetailSection(this, conversation, parentElement, selectionProvider, style);
+ break;
+ case TEAMORPERSONBASE:
+ section = new TeamOrPersonBaseDetailSection(this, conversation, parentElement, selectionProvider, style);
+ break;
+ case TEAM:
+ section = new TeamDetailSection(this, conversation, parentElement, null, style);
+ break;
+ case PERSON:
+ section = new PersonDetailSection(this, conversation, parentElement, null, style);
+ break;
+ case DESCRIPTION:
+ section = new DescriptionDetailSection(this, conversation, parentElement, selectionProvider, style);
+ break;
+ case DESCRIPTIONELEMENT:
+ section = new DescriptionElementDetailSection(this, conversation, parentElement, selectionProvider, style);
+ break;
+ case PARSINGMESSAGE:
+ section = new ParsingMessagesSection(this, conversation, parentElement, selectionProvider, style);
+ break;
+ case NONVIRALNAME:
+ section = new NonViralNameDetailSection(this, conversation, parentElement, selectionProvider, style);
+ break;
+ case MEDIA:
+ section = new eu.etaxonomy.taxeditor.ui.section.description.MediaDetailsSection(this, conversation,
+ parentElement, selectionProvider, style);
+ break;
+ case DERIVED_UNIT_FACADE:
+ section = new DerivedUnitFacadeDetailSection(this, conversation, parentElement, selectionProvider, style);
+ break;
+ case FIELD_OBSERVATION:
+ section = new FieldObservationDetailSection(this, conversation, parentElement, selectionProvider, style);
+ break;
+ case GATHERING_EVENT:
+ section = new GatheringEventDetailSection(this, conversation, parentElement, selectionProvider, style);
+ break;
+ case DERIVED_UNIT:
+ section = new DerivedUnitBaseDetailSection(this, conversation, parentElement, selectionProvider, style);
+ break;
+ case NATURAL_LANGUAGE:
+ section = new NaturalLanguageSection(this, conversation, parentElement, selectionProvider, style);
+ break;
+ case FEATURE_DISTRIBUTION:
+ section = new FeatureDistributionDetailSection(this, conversation, parentElement, selectionProvider, style);
+ break;
+ case CLASSIFICATION:
+ section = new ClassificationDetailSection(this, conversation, parentElement, selectionProvider, style);
+ break;
+ case TAXON_NODE:
+ section = new TaxonNodeDetailSection(this, conversation, parentElement, selectionProvider, style);
+ break;
+ case POLYTOMOUS_KEY:
+ section = new PolytomousKeyDetailSection(this, conversation, parentElement, selectionProvider, style);
+ break;
+ case POLYTOMOUS_KEY_NODE:
+ section = new PolytomousKeyNodeDetailSection(this, conversation, parentElement, selectionProvider, style);
+ break;
+ case INSTITUTION:
+ section = new InstitutionDetailSection(this, conversation, parentElement, selectionProvider, style);
+ break;
+ case DERIVED_UNIT_GENERAL:
+ section = new GeneralDetailSection(this, conversation, parentElement, selectionProvider, style);
+ break;
+ case HYBRID:
+ section = new HybridDetailSection(this, conversation, parentElement, selectionProvider, style);
+ break;
+ case USER:
+ section = new UserDetailSection(this, conversation, parentElement, selectionProvider, style);
+ break;
+ case GROUP:
+ section = new GroupDetailSection(this, conversation, parentElement, selectionProvider, style);
+ break;
+ case DETERMINATION:
+ section = new DeterminationDetailSection(this, conversation, parentElement, selectionProvider, style);
+ break;
+ case TAXON_RELATIONSHIP:
+ section = new TaxonRelationshipDetailSection(this, conversation, parentElement, selectionProvider, style);
+ break;
+ case REFERENCED_ENTITY:
+ section = new ReferencedEntityDetailSection(this, conversation, parentElement, selectionProvider, style);
+ break;
+ case TERM_VOCABULARY:
+ section = new TermVocabularyDetailSection(this, conversation, parentElement, selectionProvider, style);
+ break;
+ case NAMED_AREA:
+ section = new NamedAreaDetailSection(this, conversation, parentElement, selectionProvider, style);
+ break;
+ case USE_RECORD:
+ section = new UseRecordDetailSection(this, conversation, parentElement, selectionProvider, style);
+ break;
+ }
+
+ if (section == null) {
+ throw new RuntimeException("You tried to create a cdm detail section that is not implemented yet.");
+ }
+
+ parentElement.addElement(section);
+ adapt(section);
+ return section;
+ }
+
+ /**
+ * <p>
+ * createCdmDetailElement
+ * </p>
+ *
+ * @param detailType
+ * a
+ * {@link eu.etaxonomy.taxeditor.ui.element.CdmFormFactory.DetailType}
+ * object.
+ * @param style
+ * a int.
+ * @param parentElement
+ * a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
+ * object.
+ * @return a
+ * {@link eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailElement}
+ * object.
+ */
+ public AbstractCdmDetailElement createCdmDetailElement(DetailType detailType, ICdmFormElement parentElement, int style) {
+ AbstractCdmDetailElement element = null;
+
+ switch (detailType) {
+ case SCIENTIFICNAME:
+ element = new NameDetailElement(this, parentElement, style);
+ break;
+ case REFERENCEBASE:
+ element = new ReferenceDetailElement(this, parentElement, style);
+ break;
+ case NOMENCLATURALREFERENCE:
+ element = new NomenclaturalReferenceDetailElement(this, parentElement, style);
+ break;
+ case TAXONBASE:
+ element = new TaxonBaseDetailElement(this, parentElement, style);
+ break;
+ case AUTHORSHIP:
+ element = new AuthorshipDetailElement(this, parentElement, style);
+ break;
+ case TEAM:
+ element = new TeamDetailElement(this, parentElement, style);
+ break;
+ case PERSON:
+ element = new PersonDetailElement(this, parentElement, style);
+ break;
+ case DESCRIPTION:
+ element = new DescriptionDetailElement(this, parentElement, style);
+ break;
+ case DESCRIPTIONELEMENT:
+ element = new DescriptionElementDetailElement(this, parentElement, style);
+ break;
+ case NONVIRALNAME:
+ element = new NonViralNameDetailElement(this, parentElement);
+ break;
+ case DERIVED_UNIT_FACADE:
+ element = new DerivedUnitFacadeDetailElement(this, parentElement);
+ break;
+ case FIELD_OBSERVATION:
+ element = new FieldObservationDetailElement(this, parentElement);
+ break;
+ case GATHERING_EVENT:
+ element = new GatheringEventDetailElement(this, parentElement);
+ break;
+ case DERIVED_UNIT:
+ element = new DerivedUnitBaseDetailElement(this, parentElement);
+ break;
+ case NATURAL_LANGUAGE:
+ element = new NaturalLanguageDetailElement(this, parentElement);
+ break;
+ case FEATURE_DISTRIBUTION:
+ element = new FeatureDistributionDetailElement(this, parentElement);
+ break;
+ case CLASSIFICATION:
+ element = new ClassificationDetailElement(this, parentElement);
+ break;
+ case TAXON_NODE:
+ element = new TaxonNodeDetailElement(this, parentElement);
+ break;
+ case COLLECTION:
+ element = new CollectionDetailElement(this, parentElement);
+ break;
+ case POLYTOMOUS_KEY:
+ element = new PolytomousKeyDetailElement(this, parentElement);
+ break;
+ case POLYTOMOUS_KEY_NODE:
+ element = new PolytomousKeyNodeDetailElement(this, parentElement);
+ break;
+ case INSTITUTION:
+ element = new InstitutionDetailElement(this, parentElement);
+ break;
+ case DERIVED_UNIT_GENERAL:
+ element = new GeneralDetailElement(this, parentElement);
+ break;
+ case HYBRID:
+ element = new HybridDetailElement(this, parentElement);
+ break;
+ case USER:
+ element = new UserDetailElement(this, parentElement);
+ break;
+ case GROUP:
+ element = new GroupDetailElement(this, parentElement);
+ break;
+ case GRANTEDAUTHORITY:
+ element = new GrantedAuthorityDetailElement(this, parentElement);
+ break;
+ case DETERMINATION:
+ element = new DeterminationDetailElement(this, parentElement);
+ break;
+ case TAXON_RELATIONSHIP:
+ element = new TaxonRelationshipDetailElement(this, parentElement);
+ break;
+ case REFERENCED_ENTITY:
+ element = new RefereneEntityDetailElement(this, parentElement);
+ break;
+ case TERM_VOCABULARY:
+ element = new TermVocabularyDetailElement(this, parentElement);
+ break;
+ case NAMED_AREA:
+ element = new eu.etaxonomy.taxeditor.ui.section.vocabulary.NamedAreaDetailElement(this, parentElement);
+ break;
+ case NAMED_AREA_LEVEL:
+ element = new DefinedTermDetailElement<NamedAreaLevel>(this, parentElement);
+ break;
+ case USE_RECORD:
+ // element = new UseRecordDetailElement(this, parentElement, style);
+ element = new UseRecordDetailElement(this, parentElement);
+ break;
+ }
+
+ if (element == null) {
+ AbstractUtility.error(this.getClass(),
+ "Detail element was not created. Seems like the case was not implemented for the requested detail type: "
+ + detailType, null);
+ }
+
+ adapt(element);
+ parentElement.addElement(element);
+ return element;
+ }
+
+ /**
+ *
+ * Used to define which {@link AbstractEntityCollectionSection} should be
+ * created in
+ * {@link CdmFormFactory#createEntityDetailSection(EntityDetailType, ConversationHolder, ICdmFormElement, int)}
+ *
+ * @author n.hoffmann
+ * @created Mar 5, 2010
+ * @version 1.0
+ */
+ public static enum EntityDetailType {
+ TEAM, // never used
+ TEAMMEMBER,
+ ANNOTATION,
+ CREDIT,
+ DESCRIPTIONELEMENTSOURCE,
+ EXTENSION,
+ MARKER,
+ MEDIA,
+ DESCRIPTIONELEMENTMEDIA,
+ MEDIAREPRESENTATION,
+ MEDIAREPRESENTATIONPART,
+ MODIFIER,
+ NOMENCLATURALSTATUS,
+ NAME_RELATIONSHIP,
+ PROTOLOG,
+ RIGHTS,
+ SOURCE,
+ SCOPE,
+ DESCRIPTIONSOURCE,
+ TYPEDESIGNATION,
+ STATE_DATA,
+ STATISTICAL_MEASUREMENT_VALUE,
+ DESCRIBED_SPECIMEN,
+ COLLECTING_AREA, DETERMINATION_EVENT, // never used
+ SPECIMEN_COLLECTION,
+ IDENTIFIABLE_SOURCE_COLLECTION,
+ GEOGRAPHICAL_SCOPE, // never used
+ SCOPE_RESTRICTION,
+ MEMBER,
+ GRANTED_AUTHORITY,
+ GROUPS_BY_USER,
+ TAXONOMIC_SCOPE,
+ DETERMINATION_CURRENT,
+ DETERMINATION_HISTORY
+ }
+
+ /**
+ * <p>
+ * createEntityDetailSection
+ * </p>
+ *
+ * @param entityDetailType
+ * a
+ * {@link eu.etaxonomy.taxeditor.ui.element.CdmFormFactory.EntityDetailType}
+ * object.
+ * @param style
+ * a int.
+ * @param conversation
+ * a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder}
+ * object.
+ * @param parentElement
+ * a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
+ * object.
+ * @return a {@link eu.etaxonomy.taxeditor.ui.element.AbstractFormSection}
+ * object.
+ */
+ public AbstractFormSection createEntityDetailSection(EntityDetailType entityDetailType,
+ ConversationHolder conversation, ICdmFormElement parentElement, int style) {
+ AbstractFormSection section = null;
+
+// System.out.println("EntityDetailSection: " + entityDetailType);
+ switch (entityDetailType) {
+ case TEAM:
+ // TODO this is not an AbstractEntityCollectionSection
+ section = new TeamDetailSection(this, conversation, parentElement, null, style);
+ break;
+ case TEAMMEMBER:
+ section = new TeamMemberSection(this, conversation, parentElement, style);
+ break;
+ case ANNOTATION:
+ section = new AnnotationSection(this, conversation, parentElement, style);
+ break;
+ case CREDIT:
+ section = new CreditSection(this, conversation, parentElement, style);
+ break;
+ case DESCRIPTIONELEMENTSOURCE:
+ section = new DescriptionElementSourceSection(this, conversation, parentElement, style);
+ break;
+ case EXTENSION:
+ section = new ExtensionSection(this, conversation, parentElement, style);
+ break;
+ case MARKER:
+ section = new MarkerSection(this, conversation, parentElement, style);
+ break;
+ case MEDIA:
+ section = new MediaSection(this, conversation, parentElement, style);
+ break;
+ case DESCRIPTIONELEMENTMEDIA:
+ section = new DescriptionElementMediaSection(this, conversation, parentElement, style);
+ break;
+ case MEDIAREPRESENTATION:
+ section = new MediaRepresentationSection(this, conversation, parentElement, style);
+ break;
+ case MEDIAREPRESENTATIONPART:
+ section = new MediaRepresentationPartSection(this, conversation, parentElement, style);
+ break;
+ case MODIFIER:
+ section = new ModifierSection(this, conversation, parentElement, style);
+ break;
+ case NOMENCLATURALSTATUS:
+ section = new NomenclaturalStatusSection(this, conversation, parentElement, style);
+ break;
+ case NAME_RELATIONSHIP:
+ section = new NameRelationshipDetailSection(this, conversation, parentElement, style);
+ break;
+ case PROTOLOG:
+ section = new ProtologueSection(this, conversation, parentElement, style);
+ break;
+ case RIGHTS:
+ section = new RightsSection(this, conversation, parentElement, style);
+ break;
+ case SOURCE:
+ section = new SourceSection(this, conversation, parentElement, style);
+ break;
+ case SCOPE:
+ section = new ScopeSection(this, conversation, parentElement, style);
+ break;
+ case DESCRIPTIONSOURCE:
+ section = new DescriptionSourceSection(this, conversation, parentElement, style);
+ break;
+ case TYPEDESIGNATION:
+ section = new TypeDesignationSection(this, conversation, parentElement, style);
+ break;
+ case STATE_DATA:
+ section = new StateDataSection(this, conversation, parentElement, style);
+ break;
+ case STATISTICAL_MEASUREMENT_VALUE:
+ section = new StatisticalMeasurementValueSection(this, conversation, parentElement, style);
+ break;
+ case DESCRIBED_SPECIMEN:
+ section = new DescribedSpecimenSection(this, conversation, parentElement, style);
+ break;
+ case COLLECTING_AREA:
+ section = new CollectingAreasDetailSection(this, conversation, parentElement, style);
+ break;
+ case DETERMINATION_CURRENT:
+ section = new CurrentDeterminationDetailSection(this, conversation, parentElement, style);
+ break;
+ case DETERMINATION_HISTORY:
+ section = new DeterminationHistoryDetailSection(this, conversation, parentElement, style);
+ break;
+ case SPECIMEN_COLLECTION:
+ section = new SpecimenCollectionDetailSection(this, conversation, parentElement, style);
+ break;
+ case IDENTIFIABLE_SOURCE_COLLECTION:
+ section = new SourceCollectionDetailSection(this, conversation, parentElement, style);
+ break;
+ case GEOGRAPHICAL_SCOPE:
+ section = new GeographicalScopeDetailSection(this, conversation, parentElement, style);
+ break;
+ case SCOPE_RESTRICTION:
+ section = new ScopeRestrictionSection(this, conversation, parentElement, style);
+ break;
+ case MEMBER:
+ section = new MemberDetailSection(this, conversation, parentElement, style);
+ break;
+ case GRANTED_AUTHORITY:
+ section = new GrantedAuthorityDetailSection(this, conversation, parentElement, style);
+ break;
+ case GROUPS_BY_USER:
+ section = new GroupsByUserDetailSection(this, conversation, parentElement, style);
+ break;
+ case TAXONOMIC_SCOPE:
+ section = new TaxonomicScopeSection(this, conversation, parentElement, style);
+ break;
+ }
+ parentElement.addElement(section);
+ adapt(section);
+ return section;
+ }
+
+ /**
+ * <p>
+ * createEntityCollectionElement
+ * </p>
+ *
+ * @param removeListener
+ * a {@link org.eclipse.swt.events.SelectionListener} object.
+ * @param style
+ * a int.
+ * @param parentElement
+ * a
+ * {@link eu.etaxonomy.taxeditor.ui.element.AbstractFormSection}
+ * object.
+ * @param versionableEntity
+ * a {@link eu.etaxonomy.cdm.model.common.IVersionableEntity}
+ * object.
+ * @param backgroundColor
+ * a {@link org.eclipse.swt.graphics.Color} object.
+ * @return a
+ * {@link eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionElement}
+ * object.
+ */
+ public AbstractEntityCollectionElement createEntityCollectionElement(AbstractFormSection parentElement,
+ Object versionableEntity, SelectionListener removeListener, Color backgroundColor, int style) {
+ AbstractEntityCollectionElement element = null;
+
+ Object entity = HibernateProxyHelper.deproxy(versionableEntity);
+
+ if (entity instanceof Annotation) {
+ element = new AnnotationElement(this, parentElement, (Annotation) entity, removeListener, style);
+ } else if (entity instanceof Person) {
+ element = new TeamMemberElement(this, parentElement, (Person) entity, removeListener, style);
+ } else if (entity instanceof Credit) {
+ element = new CreditElement(this, parentElement, (Credit) entity, removeListener, style);
+ } else if (entity instanceof Extension) {
+ element = new ExtensionElement(this, parentElement, (Extension) entity, removeListener, style);
+ } else if (entity instanceof Marker) {
+ element = new MarkerElement(this, parentElement, (Marker) entity, removeListener, style);
+ } else if (entity instanceof Media) {
+ element = new MediaElement(this, parentElement, (Media) entity, removeListener, style);
+ } else if (entity instanceof MediaRepresentation) {
+ element = new MediaRepresentationElement(this, parentElement, (MediaRepresentation) entity, removeListener,
+ style);
+ } else if (entity instanceof ImageFile) {
+ element = new ImageFileElement(this, parentElement, (ImageFile) entity, removeListener, style);
+ } else if (entity instanceof MediaRepresentationPart) {
+ element = new MediaRepresentationPartElement(this, parentElement, (MediaRepresentationPart) entity,
+ removeListener, style);
+ } else if (entity instanceof NomenclaturalStatus) {
+ element = new NomenclaturalStatusElement(this, parentElement, (NomenclaturalStatus) entity, removeListener,
+ style);
+ } else if (entity instanceof Rights) {
+ element = new RightsElement(this, parentElement, (Rights) entity, removeListener, style);
+ } else if (entity instanceof DescriptionElementSource) {
+ element = new DescriptionElementSourceElement(this, parentElement, (DescriptionElementSource) entity,
+ removeListener, style);
+ } else if (entity instanceof IdentifiableSource) {
+ element = new IdentifiableSourceElement(this, parentElement, (IdentifiableSource) entity, removeListener,
+ style);
+ } else if (entity instanceof Scope) {
+ element = new ScopeElement(this, parentElement, (Scope) entity, removeListener, style);
+ } else if (entity instanceof Modifier) {
+ element = new ModifierElement(this, parentElement, (Modifier) entity, removeListener, style);
+ } else if (entity instanceof Reference) {
+ element = new DescriptionSourceElement(this, parentElement, (Reference) entity, removeListener, style);
+ } else if (entity instanceof NameTypeDesignation) {
+ element = new NameTypeDesignationElement(this, parentElement, (NameTypeDesignation) entity, removeListener,
+ style);
+ } else if (entity instanceof NameRelationship) {
+ element = new NameRelationshipDetailElement(this, parentElement, (NameRelationship) entity, removeListener,
+ style);
+ } else if (entity instanceof SpecimenTypeDesignation) {
+ element = new SpecimenTypeDesignationElement(this, parentElement, (SpecimenTypeDesignation) entity,
+ removeListener, style);
+ } else if (entity instanceof StateData) {
+ element = new StateDataElement(this, parentElement, (StateData) entity, removeListener, style);
+ } else if (entity instanceof StatisticalMeasurementValue) {
+ element = new StatisticalMeasurementValueElement(this, parentElement, (StatisticalMeasurementValue) entity,
+ removeListener, style);
+ } else if (entity instanceof DerivedUnit) {
+ element = new DerivedUnitElement(this, parentElement, (DerivedUnit) entity, removeListener, style);
+ } else if (entity instanceof NamedArea) {
+ element = new NamedAreaDetailElement(this, parentElement, (NamedArea) entity, removeListener, style);
+ } else if (entity instanceof DeterminationEvent) {
+ element = new DeterminationEventDetailElement(this, parentElement, (DeterminationEvent) entity,
+ removeListener, style);
+ } else if (entity instanceof Specimen) {
+ element = new SpecimenCollectionDetailElement(this, parentElement, (Specimen) entity, removeListener, style);
+ } else if (entity instanceof User) {
+ element = new MemberDetailElement(this, parentElement, (User) entity, removeListener, style);
+ } else if (entity instanceof GrantedAuthority) {
+ element = new GrantedAuthorityCollectionElement(this, parentElement, (GrantedAuthorityImpl) entity,
+ removeListener, style);
+ } else if (entity instanceof Group) {
+ element = new GroupsByUserDetailElement(this, parentElement, (Group) entity, removeListener, style);
+ } else if (entity instanceof Taxon) {
+ element = new TaxonDetailElement(this, parentElement, (Taxon) entity, removeListener, style);
+ } else if (entity instanceof DescriptionElementBase) {
+ // this is the special case for protologs, maybe we can do this
+ // differently when API improves
+ DescriptionElementBase descriptionElement = (DescriptionElementBase) entity;
+ if (descriptionElement.getFeature().equals(Feature.PROTOLOGUE())) {
+ element = new ProtologueElement(this, parentElement, descriptionElement, removeListener, style);
+ }
+ }
+
+ if (element == null) {
+ AbstractUtility.errorDialog("No element for entity", this,
+ "Could not generate element for entity. Looks like the case is not handled already. Check implementation. Entity: "
+ + entity, null);
+ }
+
+ else if (backgroundColor != null && !backgroundColor.isDisposed()) {
+ element.setPersistentBackground(backgroundColor);
+ }
+
+ adapt(element);
+ parentElement.addElement(element);
+ return element;
+ }
+
+ /**
+ * <p>
+ * Creates a selection element for the given type T.
+ * </p>
+ * <p>
+ * <strong>Selection elements not handled by this method:</strong>
+ * <ul>
+ * <li>{@link TaxonNodeSelectionElement} see
+ * {@link #createTaxonNodeSelectionElement(ConversationHolder, ICdmFormElement, String, TaxonNode, int, int)}
+ * </li>
+ * <li>{@link NomenclaturalAuthorTeamSelectionElement} see
+ * {@link #createNomenclaturalAuthorTeamSelectionElement(ConversationHolder, ICdmFormElement, String, Team, int, int)}
+ * </li>
+ * </ul>
+ * </p>
+ *
+ * @param clazz
+ * a {@link Class} object of the type that you want the selection
+ * element to handle
+ * @param parentElement
+ * a {@link ICdmFormElement} object.
+ * @param labelString
+ * a {@link String} object.
+ * @param selectionType
+ * @param selection
+ * a {@link ICdmBase} object.
+ * @param style
+ * a int.
+ * @param conversation
+ * a {@link ConversationHolder} object.
+ * @return a {@link EntitySelectionElement} object.
+ */
+ public <T extends ICdmBase> EntitySelectionElement<T> createSelectionElement(Class<T> clazz,
+ ConversationHolder conversation, ICdmFormElement parentElement, String labelString, T selection, int mode,
+ int style) {
+ EntitySelectionElement<T> element = new EntitySelectionElement<T>(this, conversation, parentElement, clazz,
+ labelString, selection, mode, style);
+ adapt(element);
+ parentElement.addElement(element);
+ return element;
+ }
+
+ public TaxonNodeSelectionElement createTaxonNodeSelectionElement(ConversationHolder conversation,
+ ICdmFormElement parentElement, String labelString, TaxonNode selection, int mode, int style) {
+ TaxonNodeSelectionElement element = new TaxonNodeSelectionElement(this, conversation, parentElement,
+ labelString, selection, mode, style);
+ adapt(element);
+ parentElement.addElement(element);
+ return element;
+ }
+
+ public NomenclaturalAuthorTeamSelectionElement createNomenclaturalAuthorTeamSelectionElement(
+ ConversationHolder conversation, ICdmFormElement parentElement, String labelString, Team selection,
+ int mode, int style) {
+ NomenclaturalAuthorTeamSelectionElement element = new NomenclaturalAuthorTeamSelectionElement(this,
+ conversation, parentElement, labelString, selection, mode, style);
+ adapt(element);
+ parentElement.addElement(element);
+ return element;
+ }
+
+ /** {@inheritDoc} */
+ public LabelElement createLabel(ICdmFormElement parentElement, String text) {
+ LabelElement labelElement = new LabelElement(this, parentElement, text);
+ adapt(labelElement);
+ parentElement.addElement(labelElement);
+ return labelElement;
+ }
+
+ /**
+ * <p>
+ * Getter for the field <code>selectionProvider</code>.
+ * </p>
+ *
+ * @return a {@link org.eclipse.jface.viewers.ISelectionProvider} object.
+ */
+ public ISelectionProvider getSelectionProvider() {
+ return selectionProvider;
+ }
+
+ /**
+ * <p>
+ * createDetailedDescriptionDetailElement
+ * </p>
+ *
+ * @param parentElement
+ * a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
+ * object.
+ * @param entity
+ * a
+ * {@link eu.etaxonomy.cdm.model.description.DescriptionElementBase}
+ * object.
+ * @param style
+ * a int.
+ * @return a
+ * {@link eu.etaxonomy.taxeditor.ui.section.description.detail.AbstractDetailedDescriptionDetailElement}
+ * object.
+ */
+ public AbstractDetailedDescriptionDetailElement createDetailedDescriptionDetailElement(
+ ICdmFormElement parentElement, DescriptionElementBase entity, int style) {
+ AbstractDetailedDescriptionDetailElement detailedDescriptionElement = null;
+
+ if (entity instanceof CategoricalData) {
+ detailedDescriptionElement = new CategoricalDataDetailElement(this, parentElement,
+ (CategoricalData) entity, style);
+ } else if (entity instanceof CommonTaxonName) {
+ detailedDescriptionElement = new CommonNameDetailElement(this, parentElement, (CommonTaxonName) entity,
+ style);
+ } else if (entity instanceof Distribution) {
+ detailedDescriptionElement = new DistributionDetailElement(this, parentElement, (Distribution) entity,
+ style);
+ } else if (entity instanceof IndividualsAssociation) {
+ detailedDescriptionElement = new IndividualsAssociationDetailElement(this, parentElement,
+ (IndividualsAssociation) entity, style);
+ } else if (entity instanceof QuantitativeData) {
+ detailedDescriptionElement = new QuantitativeDataDetailElement(this, parentElement,
+ (QuantitativeData) entity, style);
+ } else if (entity instanceof TaxonInteraction) {
+ detailedDescriptionElement = new TaxonInteractionDetailElement(this, parentElement,
+ (TaxonInteraction) entity, style);
+ } else if (entity instanceof TextData) {
+ detailedDescriptionElement = new TextDataDetailElement(this, parentElement, (TextData) entity, style);
+ } else {
+ throw new IllegalStateException("There is no interface for the given description element");
+ }
+ adapt(detailedDescriptionElement);
+ parentElement.addElement(detailedDescriptionElement);
+ return detailedDescriptionElement;
+
+ }
+
+ /**
+ * Creates a styled text as a part of the form.
+ *
+ * @param parent
+ * the text parent
+ * @param value
+ * the text initial value
+ * @param style
+ * the text style
+ * @return the text widget
+ */
+ public StyledText createStyledText(Composite parent, String value, int style) {
+ StyledText text = new StyledText(parent, getBorderStyle() | style | getOrientation());
+ if (value != null) {
+ text.setText(value);
+ }
+ text.setForeground(getColors().getForeground());
+ text.setBackground(getColors().getBackground());
+ // text.addFocusListener(visibilityHandler);
+ return text;
+ }
}
/**
- *
+ *
*/
package eu.etaxonomy.taxeditor.ui.element;
* <p>
* TextWithLabelElement class.
* </p>
- *
+ *
* @author n.hoffmann
* @version $Id: $
*/
-public class TextWithLabelElement extends AbstractCdmFormElement implements
- ModifyListener, IEnableableFormElement, ISelectable {
-
- protected Text text;
- private Label label;
-
- /** Constant <code>MAX_HEIGHT=0</code> */
- public static final int MAX_HEIGHT = 0;
- /** Constant <code>SINGLE=-1</code> */
- public static final int SINGLE = -1;
-
- /**
- * <p>
- * Constructor for TextWithLabelElement.
- * </p>
- *
- * @param formFactory
- * a {@link eu.etaxonomy.taxeditor.ui.element.CdmFormFactory}
- * object.
- * @param parentElement
- * a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
- * object.
- * @param labelString
- * a {@link java.lang.String} object.
- * @param initialText
- * a {@link java.lang.String} object.
- * @param textHeight
- * a {@link java.lang.Integer} object.
- * @param style
- * a int.
- */
- protected TextWithLabelElement(CdmFormFactory formFactory,
- ICdmFormElement parentElement, String labelString,
- String initialText, Integer textHeight, int style) {
- super(formFactory, parentElement);
-
- if (labelString != null) {
- label = formFactory.createLabel(getLayoutComposite(),
- CdmUtils.Nz(labelString), SWT.NULL);
- addControl(label);
- label.setLayoutData(LayoutConstants.LEFT());
- }
-
- int scrollStyle = textHeight == null ? SWT.NULL
- : (SWT.V_SCROLL | SWT.MULTI);
-
- int combinedStyle = style | SWT.BORDER | scrollStyle;
-
- //SWT.PASSWORD does not work when SWT.WRAP is set.
- if(style != SWT.PASSWORD){
- combinedStyle = combinedStyle | SWT.WRAP;
- }
-
- text = formFactory.createText(getLayoutComposite(), "", combinedStyle);
-
- addControl(text);
-
- // text.setWO
-
- if (textHeight == null) {
- text.addKeyListener(new KeyAdapter() {
- @Override
- public void keyPressed(KeyEvent e) {
- if (e.character == SWT.CR) {
- // Don't accept carriage returns as input when in single
- // line mode
- e.doit = false;
- } else if (e.character == SWT.TAB) {
- // traverse is not working for wrapped text widgets so
- // we reintroduce it here
- e.doit = false;
- TextWithLabelElement.this.text
- .traverse(SWT.TRAVERSE_TAB_NEXT);
- }
- }
- });
- }
-
- TableWrapData layoutData = LayoutConstants.FILL();
- if (textHeight != null && textHeight > 0) {
- (layoutData).heightHint = textHeight;
- }
-
- text.setLayoutData(layoutData);
-
- text.addModifyListener(this);
-
- setText(initialText);
- }
-
- /**
- * Get the text of this composites text composite
- *
- * @return a {@link java.lang.String} object.
- */
- public String getText() {
- return text.getText();
- }
-
- /**
- * Set the text of this composites text composite
- *
- * @param string
- * a {@link java.lang.String} object.
- */
- public void setText(String string) {
- Listener[] listeners = text.getListeners(SWT.Modify);
-
- for (Listener listener : listeners) {
- text.removeListener(SWT.Modify, listener);
- }
-
- text.setText(CdmUtils.Nz(string));
-
- for (Listener listener : listeners) {
- text.addListener(SWT.Modify, listener);
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.eclipse.swt.events.ModifyListener#modifyText(org.eclipse.swt.events
- * .ModifyEvent)
- */
- /** {@inheritDoc} */
- public void modifyText(ModifyEvent e) {
- firePropertyChangeEvent(new CdmPropertyChangeEvent(this, e));
- }
-
- /** {@inheritDoc} */
- public void setEnabled(boolean enabled) {
- text.setEnabled(enabled);
- String symbolicName = enabled ? Resources.COLOR_FONT_DEFAULT
- : Resources.COLOR_TEXT_DISABLED;
- text.setForeground(getColor(symbolicName));
- }
-
- /** {@inheritDoc} */
- public void setIrrelevant(boolean irrelevant) {
- String colorId = irrelevant ? Resources.COLOR_COMPOSITE_IRRELEVANT
- : Resources.COLOR_COMPOSITE_BACKGROUND;
-
- Color color = getColor(colorId);
- text.setBackground(color);
- }
-
- /** {@inheritDoc} */
- @Override
- public void setBackground(Color color) {
- if (label != null)
- label.setBackground(color);
- }
-
- @Override
- public void setSelected(boolean selected) {
- setBackground(selected ? SELECTED : getPersistentBackground());
- }
-
- /*
- * (non-Javadoc)
- *
- * @see eu.etaxonomy.taxeditor.forms.AbstractCdmFormElement#setFocus()
- */
- /** {@inheritDoc} */
- @Override
- public void setFocus() {
- text.setFocus();
- }
-
- /**
- * <p>
- * getMainControl
- * </p>
- *
- * @return a {@link org.eclipse.swt.widgets.Control} object.
- */
- public Control getMainControl() {
- return text;
- }
-
- /**
- * <p>
- * setTextLimit
- * </p>
- *
- * @param limit
- * a int.
- */
- public void setTextLimit(int limit) {
- text.setTextLimit(limit);
- }
+public class TextWithLabelElement extends AbstractCdmFormElement implements ModifyListener, IEnableableFormElement,
+ ISelectable {
+
+ protected Text text;
+ private Label label;
+
+ /** Constant <code>MAX_HEIGHT=0</code> */
+ public static final int MAX_HEIGHT = 0;
+ /** Constant <code>SINGLE=-1</code> */
+ public static final int SINGLE = -1;
+
+ /**
+ * <p>
+ * Constructor for TextWithLabelElement.
+ * </p>
+ *
+ * @param formFactory
+ * a {@link eu.etaxonomy.taxeditor.ui.element.CdmFormFactory}
+ * object.
+ * @param parentElement
+ * a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
+ * object.
+ * @param labelString
+ * a {@link java.lang.String} object.
+ * @param initialText
+ * a {@link java.lang.String} object.
+ * @param textHeight
+ * a {@link java.lang.Integer} object.
+ * @param style
+ * a int.
+ * @wbp.parser.entryPoint
+ */
+ protected TextWithLabelElement(CdmFormFactory formFactory, ICdmFormElement parentElement, String labelString,
+ String initialText, Integer textHeight, int style) {
+ super(formFactory, parentElement);
+
+ if (labelString != null) {
+ label = formFactory.createLabel(getLayoutComposite(), CdmUtils.Nz(labelString), SWT.NULL);
+ addControl(label);
+ label.setLayoutData(LayoutConstants.LEFT());
+ }
+
+ int scrollStyle = textHeight == null ? SWT.NULL : (SWT.V_SCROLL | SWT.MULTI);
+
+ int combinedStyle = style | SWT.BORDER | scrollStyle;
+
+ // SWT.PASSWORD does not work when SWT.WRAP is set.
+ if (style != SWT.PASSWORD) {
+ combinedStyle = combinedStyle | SWT.WRAP;
+ }
+
+ text = formFactory.createText(getLayoutComposite(), "", combinedStyle);
+
+ addControl(text);
+
+ // text.setWO
+
+ if (textHeight == null) {
+ text.addKeyListener(new KeyAdapter() {
+ @Override
+ public void keyPressed(KeyEvent e) {
+ if (e.character == SWT.CR) {
+ // Don't accept carriage returns as input when in single
+ // line mode
+ e.doit = false;
+ } else if (e.character == SWT.TAB) {
+ // traverse is not working for wrapped text widgets so
+ // we reintroduce it here
+ e.doit = false;
+ TextWithLabelElement.this.text.traverse(SWT.TRAVERSE_TAB_NEXT);
+ }
+ }
+ });
+ }
+
+ TableWrapData layoutData = LayoutConstants.FILL();
+ if (textHeight != null && textHeight > 0) {
+ (layoutData).heightHint = textHeight;
+ }
+
+ text.setLayoutData(layoutData);
+
+ text.addModifyListener(this);
+
+ setText(initialText);
+ }
+
+ /**
+ * Get the text of this composites text composite
+ *
+ * @return a {@link java.lang.String} object.
+ */
+ public String getText() {
+ return text.getText();
+ }
+
+ /**
+ * Set the text of this composites text composite
+ *
+ * @param string
+ * a {@link java.lang.String} object.
+ */
+ public void setText(String string) {
+ Listener[] listeners = text.getListeners(SWT.Modify);
+
+ for (Listener listener : listeners) {
+ text.removeListener(SWT.Modify, listener);
+ }
+
+ text.setText(CdmUtils.Nz(string));
+
+ for (Listener listener : listeners) {
+ text.addListener(SWT.Modify, listener);
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.swt.events.ModifyListener#modifyText(org.eclipse.swt.events
+ * .ModifyEvent)
+ */
+ /** {@inheritDoc} */
+ @Override
+ public void modifyText(ModifyEvent e) {
+ firePropertyChangeEvent(new CdmPropertyChangeEvent(this, e));
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public void setEnabled(boolean enabled) {
+ text.setEnabled(enabled);
+ String symbolicName = enabled ? Resources.COLOR_FONT_DEFAULT : Resources.COLOR_TEXT_DISABLED;
+ text.setForeground(getColor(symbolicName));
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public void setIrrelevant(boolean irrelevant) {
+ String colorId = irrelevant ? Resources.COLOR_COMPOSITE_IRRELEVANT : Resources.COLOR_COMPOSITE_BACKGROUND;
+
+ Color color = getColor(colorId);
+ text.setBackground(color);
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public void setBackground(Color color) {
+ if (label != null) {
+ label.setBackground(color);
+ }
+ }
+
+ @Override
+ public void setSelected(boolean selected) {
+ setBackground(selected ? SELECTED : getPersistentBackground());
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see eu.etaxonomy.taxeditor.forms.AbstractCdmFormElement#setFocus()
+ */
+ /** {@inheritDoc} */
+ @Override
+ public void setFocus() {
+ text.setFocus();
+ }
+
+ /**
+ * <p>
+ * getMainControl
+ * </p>
+ *
+ * @return a {@link org.eclipse.swt.widgets.Control} object.
+ */
+ public Control getMainControl() {
+ return text;
+ }
+
+ /**
+ * <p>
+ * setTextLimit
+ * </p>
+ *
+ * @param limit
+ * a int.
+ */
+ public void setTextLimit(int limit) {
+ text.setTextLimit(limit);
+ }
}
// $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 org.eclipse.swt.widgets.Control;
import org.eclipse.ui.forms.events.ExpansionEvent;
import org.eclipse.ui.forms.events.IExpansionListener;
-import org.eclipse.ui.forms.widgets.Section;
+import org.eclipse.ui.forms.widgets.ExpandableComposite;
import org.eclipse.ui.forms.widgets.TableWrapLayout;
import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
import eu.etaxonomy.cdm.model.common.IdentifiableEntity;
import eu.etaxonomy.taxeditor.ui.element.AbstractFormSection;
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
+import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory.DetailType;
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
import eu.etaxonomy.taxeditor.ui.element.IEnableableFormElement;
import eu.etaxonomy.taxeditor.ui.element.ISelectableElement;
-import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory.DetailType;
/**
- * <p>
- * Abstract AbstractCdmDetailSection class.
- * </p>
- *
+ * This class visualizes an CDM entity of type ENTITY.
+ *
+ * @param <ENTITY> A CDM entity which should be visualized by this section.
+ *
* @author n.hoffmann
* @created Feb 26, 2010
* @version 1.0
*/
-public abstract class AbstractCdmDetailSection<ENTITY> extends
- AbstractFormSection<ENTITY> implements IEnableableFormElement,
- IExpansionListener {
+public abstract class AbstractCdmDetailSection<ENTITY> extends AbstractFormSection<ENTITY> implements IEnableableFormElement, IExpansionListener {
protected AbstractCdmDetailElement<ENTITY> detailElement;
* <p>
* Constructor for AbstractCdmDetailSection.
* </p>
- *
+ *
* @param formFactory
* a {@link eu.etaxonomy.taxeditor.ui.element.CdmFormFactory}
* object.
ConversationHolder conversation, ICdmFormElement parentElement,
ISelectionProvider selectionProvider, int style) {
super(formFactory, parentElement, selectionProvider,
- Section.CLIENT_INDENT | style);
+ ExpandableComposite.CLIENT_INDENT | style);
setText(getHeading());
createControls(this, SWT.NULL);
}
-
+
public AbstractCdmDetailSection(CdmFormFactory formFactory, Class<ENTITY> clazz,
ConversationHolder conversation, ICdmFormElement parentElement,
ISelectionProvider selectionProvider, int style) {
super(formFactory, parentElement, selectionProvider,
- Section.CLIENT_INDENT | style);
-
+ ExpandableComposite.CLIENT_INDENT | style);
+
setText(getHeading());
addExpansionListener(this);
* @param definedTermClass
* @param null1
*/
- protected void createControlsByType(
- AbstractCdmDetailSection<ENTITY> abstractCdmDetailSection,
- Class<ENTITY> entityClass, int style) {
+ protected void createControlsByType(AbstractCdmDetailSection<ENTITY> abstractCdmDetailSection, Class<ENTITY> entityClass, int style) {
}
* <p>
* createControls
* </p>
- *
+ *
* @param formElement
* a
* {@link eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailSection}
layout.numColumns = 2;
getLayoutComposite().setLayout(layout);
- detailElement = formFactory.createCdmDetailElement(getDetailType(),
- formElement, style);
+ detailElement = formFactory.createCdmDetailElement(getDetailType(), formElement, style);
}
/**
* <p>
* getDetailType
* </p>
- *
+ *
* @return a
* {@link eu.etaxonomy.taxeditor.ui.element.CdmFormFactory.DetailType}
* object.
* <p>
* getHeading
* </p>
- *
+ *
* @return the heading for this section
*/
public abstract String getHeading();
/*
* (non-Javadoc)
- *
+ *
* @see
* eu.etaxonomy.taxeditor.forms.section.AbstractEditorFormSection#setBackground
* (org.eclipse.swt.graphics.Color)
* <p>
* setEntity
* </p>
- *
+ *
* @param entity
* a ENTITY object.
*/
}
/** {@inheritDoc} */
- public void setIrrelevant(boolean irrelevant) {
+ @Override
+ public void setIrrelevant(boolean irrelevant) {
if (detailElement != null) {
detailElement.setIrrelevant(irrelevant);
}
}
/** {@inheritDoc} */
- public void expansionStateChanging(ExpansionEvent e) {
+ @Override
+ public void expansionStateChanging(ExpansionEvent e) {
// logger.warn("Expansion State Changing");
}
/** {@inheritDoc} */
- public void expansionStateChanged(ExpansionEvent e) {
+ @Override
+ public void expansionStateChanged(ExpansionEvent e) {
// logger.warn("Expansion State Changed");
}
}
/**
- *
+ *
*/
package eu.etaxonomy.taxeditor.ui.section;
import java.util.Collection;
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 org.eclipse.swt.widgets.Label;
import org.eclipse.ui.forms.events.ExpansionEvent;
import org.eclipse.ui.forms.events.IExpansionListener;
-import org.eclipse.ui.forms.widgets.Section;
+import org.eclipse.ui.forms.widgets.ExpandableComposite;
import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
import eu.etaxonomy.cdm.common.CdmUtils;
+import eu.etaxonomy.taxeditor.model.AbstractUtility;
import eu.etaxonomy.taxeditor.model.ImageResources;
import eu.etaxonomy.taxeditor.preference.IPreferenceKeys;
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
import eu.etaxonomy.taxeditor.preference.Resources;
-import eu.etaxonomy.taxeditor.store.StoreUtil;
import eu.etaxonomy.taxeditor.ui.element.AbstractFormSection;
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
/**
- * <p>Abstract AbstractEntityCollectionSection class.</p>
+ * This class visualizes an CDM entity of type ENTITY and additionally provides the functionality to add
+ * other elements of type ELEMENT to them.
+ *
+ * @param <ENTITY> A CDM entity which should be visualized by this section.
+ * @param <ELEMENT> An element that can be added (multiple times) to this entity.
*
* @author n.hoffmann
* @version $Id: $
*/
+
public abstract class AbstractEntityCollectionSection<ENTITY, ELEMENT> extends AbstractFormSection<ENTITY> implements IExpansionListener{
-
+
protected Composite container;
-
+
private Label label_empty;
private String title;
-
+
/**
* <p>Constructor for AbstractEntityCollectionSection.</p>
*
- * @param conversation
+ * @param conversation
* @param parentElement a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement} object.
* @param style a int.
* @param formFactory a {@link eu.etaxonomy.taxeditor.ui.element.CdmFormFactory} object.
* @param <ELEMENT> a ELEMENT object.
*/
public AbstractEntityCollectionSection(CdmFormFactory formFactory, ConversationHolder conversation, ICdmFormElement parentElement, String title, int style) {
- super(formFactory, parentElement, Section.CLIENT_INDENT | style);
+ super(formFactory, parentElement, ExpandableComposite.CLIENT_INDENT | style);
this.title = title;
this.setText(getTitleString());
showToolbar();
-
+
addExpansionListener(this);
}
-
+
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()
*/
ELEMENT element = createNewElement();
if(element != null){
addElement(element);
- if(! getSection().isExpanded())
- getSection().setExpanded(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);
}
-
+
public void showToolbar(){
setTextClient(createToolbar());
}
-
+
public void removeToolbar(){
setTextClient(null);
}
-
+
/**
* <p>setEntity</p>
*
}
setSectionTitle();
layout();
- };
-
+ }
+
/**
* Sets the title for the section. Adds a "+" sign if the collection is not empty for this section.
* Override in subclasses if you want to have a different behaviour.
this.setText(getTitleString());
}
}
-
+
/**
* Removes all content from the container
*/
}
removeElements();
}
-
+
/**
* Call this method after dynamically changing the client area.
* If the options changed is set to true, will also fire a state changed
*/
protected void internalUpdateSection(boolean changed){
destroyDynamicContent();
- if(isExpanded() || expandSectionWhenContentAvailable())
- renderContent(isExpanded());
- if(changed)
- firePropertyChangeEvent(this);
+ if(isExpanded() || expandSectionWhenContentAvailable()) {
+ renderContent(isExpanded());
+ }
+ if(changed) {
+ firePropertyChangeEvent(this);
+ }
}
/**
- * Create the elements to be shown in this seciton client area
+ * Create the elements to be shown in this section client area
*/
private void renderContent(boolean forceExpansion)
{
Collection<ELEMENT> elements = getCollection(getEntity());
-
+
if(elements == null || elements.isEmpty()){
createEmptyContent();
}else{
createDynamicContents(elements);
forceExpansion = true;
}
-
+
this.setExpanded(forceExpansion);
-
+
reflow();
}
-
+
/**
* <p>createEmptyContent</p>
*/
protected void createEmptyContent(){
label_empty = formFactory.createLabel(getLayoutComposite(), getEmptyString());
}
-
+
/**
* Creates the widgets for the collection
*
* @param elements a {@link java.util.Collection} object.
*/
protected void createDynamicContents(Collection<ELEMENT> elements)
- {
+ {
int i = 0;
for(final ELEMENT element : elements){
SelectionAdapter removeListener = new SelectionAdapter(){
@Override
public void widgetSelected(SelectionEvent e) {
- removeElement(element);
+ removeElement(element);
internalUpdateSection(true);
}
};
boolean modulo = i++%2 == 0;
String colorResource = modulo ? Resources.COLOR_LIST_EVEN : Resources.COLOR_LIST_ODD;
- createElementComposite(element, removeListener, StoreUtil.getColor(colorResource));
+ createElementComposite(element, removeListener, AbstractUtility.getColor(colorResource));
}
}
protected void createElementComposite(ELEMENT element, SelectionListener removeListener, Color backgroundColor){
formFactory.createEntityCollectionElement(this, element, removeListener, backgroundColor, SWT.NULL);
}
-
+
/* (non-Javadoc)
* @see eu.etaxonomy.taxeditor.forms.section.AbstractEditorFormSection#setBackground(org.eclipse.swt.graphics.Color)
*/
public String getTitleString() {
return CdmUtils.Nz(title);
}
-
+
/**
* <p>setTitleString</p>
*
setSectionTitle();
layout();
}
-
+
/** {@inheritDoc} */
- public void expansionStateChanging(ExpansionEvent e) {
+ @Override
+ public void expansionStateChanging(ExpansionEvent e) {
// logger.warn("Expansion State Changing");
}
-
+
/** {@inheritDoc} */
- public void expansionStateChanged(ExpansionEvent e) {
+ @Override
+ public void expansionStateChanged(ExpansionEvent e) {
if(isExpanded()){
renderContent(isExpanded());
}else{
destroyDynamicContent();
}
}
-
+
private boolean expandSectionWhenContentAvailable(){
return PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOULD_EXPAND_SECTION_WHEN_DATA_AVAILABLE);
}
-
+
/**
* Get the specific collection of this entity
*
* @return a {@link java.util.Collection} object.
*/
public abstract Collection<ELEMENT> getCollection(ENTITY entity);
-
+
/**
* Create a new Element for this collection
*
* @return a ELEMENT object.
*/
public abstract ELEMENT createNewElement();
-
+
/**
* Add an element to the entities collection
*
* @param element a ELEMENT object.
*/
public abstract void addElement(ELEMENT element);
-
+
/**
* Remove an element from the entities collection
*
* @param element a ELEMENT object.
*/
public abstract void removeElement(ELEMENT element);
-
+
/**
* String to display when the collection is empty
*
* @return a {@link java.lang.String} object.
*/
public abstract String getEmptyString();
-
+
/**
* <p>getTooltipString</p>
*
* @return String to display when hovering the add button
*/
- protected abstract String getTooltipString();
+ protected abstract String getTooltipString();
}
// $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.
*/
* @version 1.0
*/
public class DerivedUnitFacadeDetailElement extends AbstractCdmDetailElement<DerivedUnitBase> {
-
+
private DerivedUnitFacade facade;
private DerivedUnitFacadeConfigurator configurator;
configurator.setMoveDerivedUnitMediaToGallery(true);
configurator.setMoveFieldObjectMediaToGallery(true);
}
-
+
/** {@inheritDoc} */
@Override
public void setEntity(DerivedUnitBase entity) {
super.setEntity(entity);
try {
facade = DerivedUnitFacade.NewInstance(entity, configurator);
-
+
section_general.setEntity(facade);
section_derivedUnitBase.setEntity(facade);
section_gatheringEvent.setEntity(facade);
section_fieldObservation.setEntity(facade);
-
+
} catch (DerivedUnitFacadeNotSupportedException e) {
StoreUtil.errorDialog("Error", this, "SpecimenFacadeNotSupportedException while inititating SpecimenFacade", e);
}
}
-
+
/** {@inheritDoc} */
@Override
public void removeElements() {
section_fieldObservation = null;
}
}
-
+
/** {@inheritDoc} */
@Override
public DerivedUnitBase getEntity() {
throw new IllegalArgumentException("Should not be called");
}
-
+
/**
* <p>Getter for the field <code>facade</code>.</p>
*
public DerivedUnitFacade getFacade(){
return facade;
}
-
+
/** {@inheritDoc} */
@Override
protected void createControls(ICdmFormElement formElement,
DerivedUnitBase entity, int style) {
-
+
section_general = (GeneralDetailSection) formFactory.createCdmDetailSection(DetailType.DERIVED_UNIT_GENERAL, getConversationHolder(), formElement, null, Section.TWISTIE | Section.EXPANDED);
section_general.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
addControl(section_general);
addElement(section_general);
-
+
section_gatheringEvent = (GatheringEventDetailSection) formFactory.createCdmDetailSection(DetailType.GATHERING_EVENT, getConversationHolder(), formElement, null, Section.TWISTIE);
section_gatheringEvent.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
addControl(section_gatheringEvent);
addElement(section_gatheringEvent);
-
+
section_fieldObservation = (FieldObservationDetailSection) formFactory.createCdmDetailSection(DetailType.FIELD_OBSERVATION, getConversationHolder(), formElement, null, Section.TWISTIE);
section_fieldObservation.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
addControl(section_fieldObservation);
addElement(section_fieldObservation);
-
+
section_derivedUnitBase = (DerivedUnitBaseDetailSection) formFactory.createCdmDetailSection(DetailType.DERIVED_UNIT, getConversationHolder(), formElement, null, Section.TWISTIE);
section_derivedUnitBase.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
addControl(section_derivedUnitBase);
@Override
public void handleEvent(Object eventSource) {
if(eventSource == section_derivedUnitBase || eventSource == section_gatheringEvent || eventSource == section_fieldObservation){
- if(getParentElement() instanceof AbstractCdmDetailSection)
- ((AbstractCdmDetailSection) getParentElement()).updateTitle();
+ if(getParentElement() instanceof AbstractCdmDetailSection) {
+ ((AbstractCdmDetailSection) getParentElement()).updateTitle();
+ }
}
}
}
// $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.occurrence;
import eu.etaxonomy.cdm.api.facade.DerivedUnitFacade;
-import eu.etaxonomy.cdm.model.description.Sex;
-import eu.etaxonomy.cdm.model.description.Stage;
import eu.etaxonomy.taxeditor.store.CdmStore;
-import eu.etaxonomy.taxeditor.ui.combo.TermComboElement;
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
import eu.etaxonomy.taxeditor.ui.element.NumberWithLabelElement;
* @version 1.0
*/
public class FieldObservationDetailElement extends AbstractCdmDetailElement<DerivedUnitFacade> {
-
+
private TextWithLabelElement text_ecology;
private TextWithLabelElement text_plantDescription;
private NumberWithLabelElement number_individualCount;
- private TermComboElement<Sex> combo_sex;
+// private TermComboElement<Sex> combo_sex;
+//
+// private TermComboElement<Stage> combo_lifeStage;
- private TermComboElement<Stage> combo_lifeStage;
-
/**
* <p>Constructor for FieldObservationDetailElement.</p>
*
ICdmFormElement formElement) {
super(formFactory, formElement);
}
-
+
/** {@inheritDoc} */
@Override
protected void createControls(ICdmFormElement formElement,
// Disable for now
// text_fieldObjectDefinition = formFactory.createTextWithLabelElement(formElement, "Field Object Definition", entity.getFieldObjectDefinition(CdmStore.getDefaultLanguage()), style);
text_fieldNotes = formFactory.createTextWithLabelElement(formElement, "Field Notes", entity.getFieldNotes(), style);
-
+
number_individualCount = formFactory.createIntegerTextWithLabelElement(formElement, "Individual Count", entity.getIndividualCount(), style);
- combo_lifeStage = formFactory.createTermComboElement(Stage.class, formElement, "Life Stage", entity.getLifeStage(), style);
- combo_sex = formFactory.createTermComboElement(Sex.class, formElement, "Sex", entity.getSex(), style);
+// combo_lifeStage = formFactory.createTermComboElement(Stage.class, formElement, "Life Stage", entity.getLifeStage(), style);
+// combo_sex = formFactory.createTermComboElement(Sex.class, formElement, "Sex", entity.getSex(), style);
}
/** {@inheritDoc} */
else if(eventSource == number_individualCount){
getEntity().setIndividualCount(number_individualCount.getInteger());
}
- else if(eventSource == combo_lifeStage){
- getEntity().setLifeStage(combo_lifeStage.getSelection());
- }
- else if(eventSource == combo_sex){
- getEntity().setSex(combo_sex.getSelection());
- }
+// else if(eventSource == combo_lifeStage){
+// getEntity().setLifeStage(combo_lifeStage.getSelection());
+// }
+// else if(eventSource == combo_sex){
+// getEntity().setSex(combo_sex.getSelection());
+// }
}
}
// $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.occurrence;
-import org.eclipse.ui.forms.widgets.Section;
+import org.eclipse.ui.forms.widgets.ExpandableComposite;
import eu.etaxonomy.cdm.api.facade.DerivedUnitFacade;
+import eu.etaxonomy.taxeditor.model.AbstractUtility;
import eu.etaxonomy.taxeditor.preference.Resources;
-import eu.etaxonomy.taxeditor.store.StoreUtil;
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory.EntityDetailType;
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
* <p>
* GatheringEventDetailElement class.
* </p>
- *
+ *
* @author n.hoffmann
* @created Jun 24, 2010
* @version 1.0
* <p>
* Constructor for GatheringEventDetailElement.
* </p>
- *
+ *
* @param formFactory
* a {@link eu.etaxonomy.taxeditor.ui.element.CdmFormFactory}
* object.
super(formFactory, formElement);
}
- /** {@inheritDoc} */
- @Override
- protected void createControls(ICdmFormElement formElement,
- DerivedUnitFacade entity, int style) {
- // collectingArea
- number_absoluteElevationError = formFactory
- .createIntegerTextWithLabelElement(formElement,
- "Elevation Error", entity.getAbsoluteElevationError(),
- style);
- number_absoluteElevationMinimum = formFactory
- .createIntegerTextWithLabelElement(formElement,
- "Elevation Minimum (m)",
- entity.getAbsoluteElevationMinimum(), style);
- number_absoluteElevationMaximum = formFactory
- .createIntegerTextWithLabelElement(formElement,
- "Elevation Maximum (m)",
- entity.getAbsoluteElevationMaximum(), style);
-
- text_collectingMethod = formFactory.createTextWithLabelElement(
- formElement, "Collecting Method", entity.getCollectingMethod(),
- style);
-
- number_distanceToGround = formFactory
- .createIntegerTextWithLabelElement(formElement,
- "Distance To Ground (m)", entity.getDistanceToGround(),
- style);
- number_distanceToWaterSurface = formFactory
- .createIntegerTextWithLabelElement(formElement,
- "Distance To Water Surface (m)",
- entity.getDistanceToWaterSurface(), style);
- // exactLocation
- text_gatheringEventDescription = formFactory
- .createTextWithLabelElement(formElement,
- "Gathering Event Description",
- entity.getGatheringEventDescription(), style);
-
- section_collectingAreas = (CollectingAreasDetailSection) formFactory
- .createEntityDetailSection(EntityDetailType.COLLECTING_AREA,
- getConversationHolder(), formElement, Section.TWISTIE);
- section_collectingAreas.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(
- 2, 1));
- section_collectingAreas.setEntity(entity);
- }
+ /** {@inheritDoc} */
+ @Override
+ protected void createControls(ICdmFormElement formElement, DerivedUnitFacade entity, int style) {
+ // collectingArea
+ number_absoluteElevationError = formFactory.createIntegerTextWithLabelElement(
+ formElement, "Elevation Error", entity.getAbsoluteElevationError(), style);
+ number_absoluteElevationMinimum = formFactory.createIntegerTextWithLabelElement(
+ formElement, "Elevation Minimum (m)", entity.getAbsoluteElevationMinimum(), style);
+ number_absoluteElevationMaximum = formFactory.createIntegerTextWithLabelElement(
+ formElement, "Elevation Maximum (m)", entity.getAbsoluteElevationMaximum(), style);
+
+ text_collectingMethod = formFactory.createTextWithLabelElement(
+ formElement, "Collecting Method", entity.getCollectingMethod(), style);
+
+ number_distanceToGround = formFactory.createIntegerTextWithLabelElement(
+ formElement, "Distance To Ground (m)", entity.getDistanceToGround(), style);
+ number_distanceToWaterSurface = formFactory.createIntegerTextWithLabelElement(
+ formElement, "Distance To Water Surface (m)", entity.getDistanceToWaterSurface(), style);
+ // exactLocation
+ text_gatheringEventDescription = formFactory.createTextWithLabelElement(
+ formElement, "Gathering Event Description", entity.getGatheringEventDescription(), style);
+
+ section_collectingAreas = (CollectingAreasDetailSection) formFactory.createEntityDetailSection(
+ EntityDetailType.COLLECTING_AREA, getConversationHolder(), formElement, ExpandableComposite.TWISTIE);
+ section_collectingAreas.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
+ section_collectingAreas.setEntity(entity);
+ }
/** {@inheritDoc} */
@Override
} catch (IllegalArgumentException e) {
number_absoluteElevationMinimum
.setBackground(getColor(Resources.COLOR_PARSE_ERROR));
- StoreUtil.warn(getClass(), e.getLocalizedMessage());
+ AbstractUtility.warn(getClass(), e.getLocalizedMessage());
}
} else if (eventSource == number_absoluteElevationMaximum) {
try {
} catch (IllegalArgumentException e) {
number_absoluteElevationMaximum
.setBackground(getColor(Resources.COLOR_PARSE_ERROR));
- StoreUtil.warn(getClass(), e.getLocalizedMessage());
+ AbstractUtility.warn(getClass(), e.getLocalizedMessage());
}
} else if (eventSource == text_collectingMethod) {
getEntity().setCollectingMethod(text_collectingMethod.getText());
// $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 eu.etaxonomy.cdm.model.agent.AgentBase;
import eu.etaxonomy.cdm.model.common.LanguageString;
import eu.etaxonomy.cdm.model.location.NamedArea;
-import eu.etaxonomy.cdm.model.occurrence.Collection;
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
import eu.etaxonomy.taxeditor.ui.element.LanguageStringWithLabelElement;
private TimePeriodElement element_date;
private EntitySelectionElement<AgentBase> selection_collector;
private TextWithLabelElement text_collectingNumber;
- private EntitySelectionElement<Collection> selection_collection;
- private TextWithLabelElement text_accessionNumber;
+// private EntitySelectionElement<Collection> selection_collection;
+// private TextWithLabelElement text_accessionNumber;
/**
* @param formFactory
/*
* (non-Javadoc)
- *
+ *
* @see
* eu.etaxonomy.taxeditor.section.AbstractCdmDetailElement#createControls
* (eu.etaxonomy.taxeditor.forms.ICdmFormElement, java.lang.Object, int)
entity.getCountry(), EntitySelectionElement.NOTHING, style);
languageText_locality = formFactory
.createLanguageStringWithLabelElement(formElement, "Locality",
- entity.getLocality(), style);
+ entity.getLocality(), style);
element_point = formFactory.createPointElement(formElement,
entity.getExactLocation(), style);
number_elevation = formFactory.createIntegerTextWithLabelElement(
style);
text_collectingNumber = formFactory.createTextWithLabelElement(formElement,
"Collecting number", entity.getFieldNumber(), style);
- selection_collection = formFactory
- .createSelectionElement(Collection.class,
- getConversationHolder(), formElement, "Collection",
- entity.getCollection(),
- EntitySelectionElement.ALL, style);
- text_accessionNumber = formFactory.createTextWithLabelElement(
- formElement, "Accession Number", entity.getAccessionNumber(),
- style);
-
+// selection_collection = formFactory
+// .createSelectionElement(Collection.class,
+// getConversationHolder(), formElement, "Collection",
+// entity.getCollection(),
+// EntitySelectionElement.ALL, style);
+// text_accessionNumber = formFactory.createTextWithLabelElement(
+// formElement, "Accession Number", entity.getAccessionNumber(),
+// style);
+
}
/*
* (non-Javadoc)
- *
+ *
* @see
* eu.etaxonomy.taxeditor.section.AbstractCdmDetailElement#handleEvent(java
* .lang.Object)
getEntity().setCollector(selection_collector.getSelection());
} else if (eventSource == text_collectingNumber) {
getEntity().setFieldNumber(text_collectingNumber.getText());
- } else if (eventSource == selection_collection) {
- getEntity().setCollection(selection_collection.getSelection());
- } else if (eventSource == text_accessionNumber) {
- getEntity().setAccessionNumber(text_accessionNumber.getText());
}
+// else if (eventSource == selection_collection) {
+// getEntity().setCollection(selection_collection.getSelection());
+// } else if (eventSource == text_accessionNumber) {
+// getEntity().setAccessionNumber(text_accessionNumber.getText());
+// }
if (eventSource != toggleableText_titleCache) {
toggleableText_titleCache.setText(getEntity().getTitleCache());
// $Id$\r
/**\r
* Copyright (C) 2009 EDIT\r
-* European Distributed Institute of Taxonomy \r
+* European Distributed Institute of Taxonomy\r
* http://www.e-taxonomy.eu\r
-* \r
+*\r
* The contents of this file are subject to the Mozilla Public License Version 1.1\r
* See LICENSE.TXT at the top of this package for the full license terms.\r
*/\r
import eu.etaxonomy.cdm.api.conversation.ConversationHolder;\r
import eu.etaxonomy.cdm.model.common.DefinedTermBase;\r
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;\r
-import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;\r
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory.DetailType;\r
+import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;\r
import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailSection;\r
\r
/**\r
\r
/**\r
* @param formFactory\r
- * @param definedTermClass \r
+ * @param definedTermClass\r
* @param conversation\r
* @param parentElement\r
* @param selectionProvider\r
protected DetailType getDetailType() {\r
return null;\r
}\r
- \r
- @Override\r
- protected void createControlsByType(\r
- AbstractCdmDetailSection<T> abstractCdmDetailSection,\r
- Class<T> clazz, int style) {\r
- TableWrapLayout layout = (TableWrapLayout) getLayoutComposite()\r
- .getLayout();\r
- layout.topMargin = 10;\r
- layout.numColumns = 2;\r
\r
- getLayoutComposite().setLayout(layout);\r
- detailElement = formFactory.createDefinedTermDetailElement(clazz,\r
- abstractCdmDetailSection, style);\r
- }\r
+ @Override\r
+ protected void createControlsByType(AbstractCdmDetailSection<T> abstractCdmDetailSection, Class<T> clazz, int style) {\r
+ TableWrapLayout layout = (TableWrapLayout) getLayoutComposite().getLayout();\r
+ layout.topMargin = 10;\r
+ layout.numColumns = 2;\r
+\r
+ getLayoutComposite().setLayout(layout);\r
+ detailElement = formFactory.createDefinedTermDetailElement(clazz, abstractCdmDetailSection, style);\r
+ }\r
\r
/* (non-Javadoc)\r
* @see eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailSection#getHeading()\r
// $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.view;
-import org.eclipse.jface.viewers.ISelectionProvider;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.swt.widgets.Composite;
* @created Feb 9, 2010
* @version 1.0
*/
-public abstract class AbstractCdmDataViewer extends Viewer implements ISelectionProvider, IConversationEnabled{
-
+public abstract class AbstractCdmDataViewer extends Viewer implements IConversationEnabled{
+
protected ManagedForm managedForm;
protected CdmFormFactory formFactory;
protected ScrolledForm scrolledForm;
-
- private Composite body;
-
+
+ private final Composite body;
+
protected RootElement rootElement;
+ //TODO: create a super class for this?
private Object input;
- private AbstractCdmViewPart viewPart;
+ private final AbstractCdmViewPart viewPart;
+
-
/**
* <p>Constructor for AbstractCdmDataViewer.</p>
*
*/
public AbstractCdmDataViewer(Composite parent, AbstractCdmViewPart viewPart) {
this.viewPart = viewPart;
-
+
managedForm = new ManagedForm(parent){
-
+
/* (non-Javadoc)
* @see org.eclipse.ui.forms.ManagedForm#dirtyStateChanged()
*/
markViewPartDirty();
}
};
-
+
createFormFactory();
-
+
scrolledForm = managedForm.getForm();
-
+
body = scrolledForm.getBody();
-
+
body.setLayout(LayoutConstants.LAYOUT());
-
+
rootElement = new RootElement(formFactory, body);
}
-
+
/**
* <p>createFormFactory</p>
*/
protected void markViewPartDirty(){
viewPart.changed(input);
}
-
-
+
+
/**
* @return
*/
for(Control child : body.getChildren()){
return child;
}
-
+
return body;
}
-
+
/* (non-Javadoc)
* @see org.eclipse.jface.viewers.Viewer#setInput(java.lang.Object)
*/
/** {@inheritDoc} */
@Override
public void setInput(Object input) {
- this.input = input;
+ this.input = input;
// reset selection
setSelection(new StructuredSelection(input));
refresh();
}
-
+
/* (non-Javadoc)
* @see org.eclipse.jface.viewers.Viewer#getInput()
*/
public Object getInput() {
return input;
}
-
+
/* (non-Javadoc)
* @see org.eclipse.jface.viewers.Viewer#refresh()
*/
@Override
public void refresh() {
showParts();
-
+
managedForm.setInput(input);
-
+
managedForm.refresh();
-
+
managedForm.reflow(true);
}
-
+
/**
* <p>layout</p>
*/
public void layout(){
body.layout();
}
-
+
/**
* <p>showParts</p>
*/
protected abstract void showParts();
-
-
+
+
/**
* <p>destroySections</p>
*/
- protected void destroySections() {
+ protected void destroySections() {
for (IFormPart formPart : managedForm.getParts()){
removePart((CdmSectionPart) formPart);
- }
-
+ }
+
managedForm.setInput(null);
-
+
formFactory.destroyElement(rootElement);
-
+
createFormFactory();
-
+
rootElement = new RootElement(formFactory, body);
-
+
for(Control control : body.getChildren()){
control.dispose();
control = null;
}
}
-
-
+
+
/**
* <p>setFocus</p>
*/
break;
}
}
-
+
/**
* <p>reflow</p>
*/
public void reflow(){
managedForm.reflow(true);
}
-
+
/**
* <p>removePart</p>
*
managedForm.removePart(sectionPart);
formFactory.removePropertyChangeListener(sectionPart);
}
-
+
/**
* <p>addPart</p>
*
managedForm.addPart(sectionPart);
formFactory.addPropertyChangeListener(sectionPart);
}
-
+
/**
* <p>getConversationHolder</p>
*
* @return a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder} object.
*/
- public ConversationHolder getConversationHolder() {
+ @Override
+ public ConversationHolder getConversationHolder() {
return viewPart.getConversationHolder();
}
-
+
/** {@inheritDoc} */
- public void update(CdmDataChangeMap changeEvents) {}
+ @Override
+ public void update(CdmDataChangeMap changeEvents) {}
}
/**
- *
+ *
*/
package eu.etaxonomy.taxeditor.view;
import org.eclipse.ui.IEditorPart;
import eu.etaxonomy.taxeditor.editor.ISecuredEditor;
+import eu.etaxonomy.taxeditor.model.AbstractUtility;
import eu.etaxonomy.taxeditor.model.IDirtyMarkableSelectionProvider;
-import eu.etaxonomy.taxeditor.store.StoreUtil;
/**
* <p>
* Abstract AbstractCdmEditorViewPart class.
* </p>
- *
+ *
* @author n.hoffmann
* @created Sep 21, 2010
* @version 1.0
/*
* (non-Javadoc)
- *
+ *
* @see
* eu.etaxonomy.taxeditor.model.AbstractCdmViewPart#createPartControl(org
* .eclipse.swt.widgets.Composite)
/** {@inheritDoc} */
@Override
public void createPartControl(Composite parent) {
-
super.createPartControl(parent);
-
}
/**
* <p>
* getEditor
* </p>
- *
+ *
* @return the currently active editor
*/
public IEditorPart getEditor() {
- return StoreUtil.getActiveEditor();
+ return AbstractUtility.getActiveEditor();
}
-
+
/** {@inheritDoc} */
@Override
public void setFocus() {
super.setFocus();
-
- if(getEditor() != null && ISecuredEditor.class.isAssignableFrom(getEditor().getClass())){
+
+ if(getEditor() != null && ISecuredEditor.class.isAssignableFrom(getEditor().getClass())){
boolean doEnable = ((ISecuredEditor)getEditor()).permissionsSatisfied();
setEnabled(doEnable);
}
- }
+ }
- /** {@inheritDoc} */
- @Override
- public void changed(Object object) {
- if (part instanceof AbstractCdmViewPart) {
- ((AbstractCdmViewPart) part).changed(object);
- } else {
- IEditorPart editor = getEditor();
- if (editor != null
- && editor instanceof IDirtyMarkableSelectionProvider) {
-
- ((IDirtyMarkableSelectionProvider) editor).changed(object);
-
- }
- }
- }
+ /** {@inheritDoc} */
+ @Override
+ public void changed(Object object) {
+ if (part instanceof AbstractCdmViewPart) {
+ ((AbstractCdmViewPart) part).changed(object);
+ } else {
+ IEditorPart editor = getEditor();
+ if (editor != null && editor instanceof IDirtyMarkableSelectionProvider) {
+ ((IDirtyMarkableSelectionProvider) editor).changed(object);
+ }
+ }
+ }
}
// $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 eu.etaxonomy.cdm.api.conversation.IConversationEnabled;
import eu.etaxonomy.cdm.model.common.CdmBase;
import eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap;
+import eu.etaxonomy.taxeditor.model.AbstractUtility;
import eu.etaxonomy.taxeditor.model.IDirtyMarkableSelectionProvider;
import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
-import eu.etaxonomy.taxeditor.store.StoreUtil;
/**
* <p>Abstract AbstractCdmViewPart class.</p>
* @version 1.0
*/
public abstract class AbstractCdmViewPart extends ViewPart implements ISelectionListener, IPostOperationEnabled, IConversationEnabled, IDirtyMarkableSelectionProvider{
-
+
protected ISelectionService selectionService;
public static IStructuredSelection EMPTY_SELECTION = new StructuredSelection();
-
+
protected IWorkbenchPart part;
-
+
private PageBook pageBook;
private Label emptySelectionLabel;
private Composite viewerComposite;
-
+
/** {@inheritDoc} */
@Override
public void createPartControl(Composite parent) {
selectionService = getSite().getWorkbenchWindow().getSelectionService();
selectionService.addSelectionListener(this);
-
+
pageBook = new PageBook(parent, SWT.NULL);
createViewerComposite(pageBook);
createViewer(viewerComposite);
-
+
// Page 2: Nothing selected
emptySelectionLabel = new Label(pageBook, SWT.TOP + SWT.LEFT + SWT.WRAP);
-
+
setInitialSelection();
}
-
+
/**
- *
+ *
*/
private void setInitialSelection() {
- selectionChanged(StoreUtil.getActivePart(), getInitialSelection());
+ selectionChanged(AbstractUtility.getActivePart(), getInitialSelection());
}
/**
protected ISelection getInitialSelection() {
return selectionService.getSelection();
}
-
+
private void createViewerComposite(Composite parent) {
viewerComposite = new SashForm(parent, SWT.HORIZONTAL);
}
-
+
/**
* <p>showEmptyPage</p>
*/
public void showEmptyPage(){
pageBook.showPage(emptySelectionLabel);
}
-
+
/**
* <p>showViewer</p>
*
* @param selection a {@link org.eclipse.jface.viewers.ISelection} object.
*/
public void showViewer(IWorkbenchPart part, IStructuredSelection selection){
- this.part = part;
-
+ this.part = part;
+
Object element = selection.getFirstElement();
-
+
getViewer().setInput(element);
-
+
showViewer();
}
-
+
/**
* <p>getViewer</p>
*
public void showViewer(){
pageBook.showPage(viewerComposite);
}
-
+
public void setEnabled(boolean enabled){
pageBook.setEnabled(enabled);
}
-
+
/** {@inheritDoc} */
@Override
public void setFocus() {
if(getConversationHolder() != null){
getConversationHolder().bind();
- }
- getViewer().getControl().setFocus();
+ }
+ getViewer().getControl().setFocus();
}
-
+
/**
* <p>createViewer</p>
*
* @param parent a {@link org.eclipse.swt.widgets.Composite} object.
*/
public abstract void createViewer(Composite parent);
-
+
/** {@inheritDoc} */
- public boolean postOperation(CdmBase objectAffectedByOperation) {
+ @Override
+ public boolean postOperation(CdmBase objectAffectedByOperation) {
changed(objectAffectedByOperation);
return true;
}
-
+
/** {@inheritDoc} */
- public abstract void changed(Object object);
-
+ @Override
+ public abstract void changed(Object object);
+
/**
* <p>getConversationHolder</p>
*
* @return a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder} object.
*/
- public ConversationHolder getConversationHolder() {
- if(part != null)
- return ((IConversationEnabled) part).getConversationHolder();
-
+ @Override
+ public ConversationHolder getConversationHolder() {
+ if(part != null) {
+ return ((IConversationEnabled) part).getConversationHolder();
+ }
+
return null;
}
-
+
/** {@inheritDoc} */
- public void update(CdmDataChangeMap changeEvents) {
-
+ @Override
+ public void update(CdmDataChangeMap changeEvents) {
+
}
-
+
/** {@inheritDoc} */
@Override
public void dispose() {
// $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 eu.etaxonomy.cdm.model.common.CdmBase;
import eu.etaxonomy.cdm.model.description.Feature;
+import eu.etaxonomy.taxeditor.model.AbstractUtility;
import eu.etaxonomy.taxeditor.model.FeatureNodeContainer;
+import eu.etaxonomy.taxeditor.model.IPartContentHasDetails;
import eu.etaxonomy.taxeditor.model.IPartContentHasSupplementalData;
-import eu.etaxonomy.taxeditor.store.StoreUtil;
import eu.etaxonomy.taxeditor.view.AbstractCdmEditorViewPart;
-import eu.etaxonomy.taxeditor.view.AbstractCdmViewPart;
/**
* <p>DetailsViewPart class.</p>
* @version 1.0
*/
public class DetailsViewPart extends AbstractCdmEditorViewPart implements IPartContentHasSupplementalData{
-
+
/** Constant <code>ID="eu.etaxonomy.taxeditor.editor.forms.det"{trunked}</code> */
public static String ID = "eu.etaxonomy.taxeditor.view.detail";
@Override
public void createViewer(Composite parent) {
//selectionService.addPostSelectionListener(this);
-
+
viewer = new DetailsViewer(parent, this);
getSite().setSelectionProvider(viewer);
}
/** {@inheritDoc} */
- public void selectionChanged(IWorkbenchPart part, ISelection selection) {
- if(StoreUtil.getActiveEditor() == null){
+ @Override
+ public void selectionChanged(IWorkbenchPart part, ISelection selection) {
+ if(AbstractUtility.getActiveEditor() == null){
showEmptyPage();
return;
}
-
+
if(part == this){
return;
}
-
+
if(!(selection instanceof IStructuredSelection)){
return;
}
-
+
IStructuredSelection structuredSelection = (IStructuredSelection) selection;
-
- if((part instanceof IEditorPart) || (part instanceof AbstractCdmViewPart)) {
+
+ if((part instanceof IEditorPart) || (part instanceof IPartContentHasDetails)) {
if(structuredSelection.size() != 1){
showEmptyPage();
return;
}
-
- // do not show details for feature nodes TODO really?
+
+ // do not show details for feature nodes TODO really?
if(structuredSelection.getFirstElement() instanceof FeatureNodeContainer){
// do show the map for distributions
Feature feature = ((FeatureNodeContainer) ((IStructuredSelection) selection).getFirstElement()).getFeature();
return;
}
}
-
+
showViewer(part, structuredSelection);
}else{
- showEmptyPage();
- }
+ showEmptyPage();
+ }
}
-
+
/** {@inheritDoc} */
@Override
public boolean postOperation(CdmBase objectAffectedByOperation) {
-
+
viewer.setInput(objectAffectedByOperation);
-
+
return super.postOperation(objectAffectedByOperation);
}
-
-
+
+
/** {@inheritDoc} */
@Override
public Viewer getViewer() {
return viewer;
}
-
+
/** {@inheritDoc} */
@Override
public void dispose() {
*
* @return a boolean.
*/
- public boolean onComplete() {
+ @Override
+ public boolean onComplete() {
return true;
}
}
-
// $Id$
/**
* Copyright (C) 2011 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 org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Composite;
-import org.eclipse.ui.forms.widgets.Section;
+import org.eclipse.ui.forms.widgets.ExpandableComposite;
import eu.etaxonomy.cdm.api.facade.DerivedUnitFacade;
import eu.etaxonomy.cdm.api.facade.DerivedUnitFacadeNotSupportedException;
import eu.etaxonomy.cdm.model.reference.Reference;
import eu.etaxonomy.cdm.model.taxon.TaxonBase;
import eu.etaxonomy.cdm.model.taxon.TaxonRelationship;
-
import eu.etaxonomy.taxeditor.editor.UsageTermCollection;
+import eu.etaxonomy.taxeditor.model.AbstractUtility;
import eu.etaxonomy.taxeditor.model.FeatureNodeContainer;
import eu.etaxonomy.taxeditor.model.PolytomousKeyRelationship;
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
import eu.etaxonomy.taxeditor.store.CdmStore;
-import eu.etaxonomy.taxeditor.store.StoreUtil;
import eu.etaxonomy.taxeditor.ui.element.AbstractFormSection;
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory.DetailType;
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory.EntityDetailType;
import eu.etaxonomy.taxeditor.ui.section.grantedAuthority.GrantedAuthorityDetailSection;
import eu.etaxonomy.taxeditor.ui.section.group.GroupDetailSection;
import eu.etaxonomy.taxeditor.ui.section.group.MemberDetailSection;
-import eu.etaxonomy.taxeditor.ui.section.key.GeographicalScopeDetailSection;
import eu.etaxonomy.taxeditor.ui.section.key.PolytomousKeyDetailSection;
import eu.etaxonomy.taxeditor.ui.section.key.PolytomousKeyNodeDetailSection;
-import eu.etaxonomy.taxeditor.ui.section.key.ScopeRestrictionSection;
import eu.etaxonomy.taxeditor.ui.section.key.TaxonomicScopeSection;
import eu.etaxonomy.taxeditor.ui.section.name.NameRelationshipDetailSection;
import eu.etaxonomy.taxeditor.ui.section.name.NomenclaturalStatusSection;
import eu.etaxonomy.taxeditor.view.AbstractCdmViewPart;
/**
- * <p>
- * DetailsViewer class.
- * </p>
- *
+ *
+ * The DetailsViewer handles the content of the details view (
+ * {@link DetailsViewPart}).<br>
+ * Depending on the type of the selected element the section of the details view
+ * are created.
+ *
* @author n.hoffmann
* @created Feb 12, 2010
* @version 1.0
*/
public class DetailsViewer extends AbstractCdmDataViewer {
- private ISelection selection;
-
- /**
- * <p>
- * Constructor for DetailsViewer.
- * </p>
- *
- * @param parent
- * a {@link org.eclipse.swt.widgets.Composite} object.
- * @param viewPart
- * a {@link eu.etaxonomy.taxeditor.view.AbstractCdmViewPart}
- * object.
- */
- public DetailsViewer(Composite parent, AbstractCdmViewPart viewPart) {
- super(parent, viewPart);
- }
-
- // START HACK TO MAKE THE DERIVED UNIT FACADE WORK
- // since we are getting implementations of DerivedUnitBase from the bulk
- // editor
- // and not derived unit facade objects,
-
- /*
- * (non-Javadoc)
- *
- * @see
- * eu.etaxonomy.taxeditor.editor.view.AbstractCdmDataViewer#setInput(java
- * .lang.Object)
- */
- @Override
- public void setInput(Object input) {
- if (input instanceof DerivedUnitBase) {
- try {
- input = DerivedUnitFacade.NewInstance((DerivedUnitBase) input,
- PreferencesUtil.getDerivedUnitConfigurator());
- } catch (DerivedUnitFacadeNotSupportedException e) {
- StoreUtil.error(getClass(), e);
- }
- }
- super.setInput(input);
- }
-
- @Override
- protected void markViewPartDirty() {
- if (getInput() instanceof DerivedUnitFacade) {
- getViewPart().changed(
- ((DerivedUnitFacade) getInput()).innerDerivedUnit());
- }
-
- super.markViewPartDirty();
- }
-
- // END HACK TO MAKE THE DERIVED UNIT FACADE WORK
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.viewers.Viewer#refresh()
- */
- /** {@inheritDoc} */
- @Override
- protected void showParts() {
- // FIXME (CM) : Need to clean out this code.
- // Too much type checking to decide which detail view to display.
- // Need to build in a mechanism where navigators / editors are 'aware'
- // of the corresponding detail viewer.
- if (getInput() instanceof TaxonBase) {
- createTaxonSections(rootElement);
-
- } else if (getInput() instanceof NonViralName) {
- createNameSections(rootElement);
-
- } else if (getInput() instanceof Reference) {
- createReferenceSections(rootElement);
-
- } else if (getInput() instanceof Team) {
- createTeamDetailSection(rootElement);
-
- } else if (getInput() instanceof Person) {
- createPersonDetailSection(rootElement);
-
- } else if (getInput() instanceof TeamOrPersonBase) {
- createTeamOrPersonBaseDetailSection(rootElement);
-
- } else if (getInput() instanceof DescriptionBase) {
- Set<Marker> descriptionMarkers = ((DescriptionBase) getInput()).getMarkers();
- MarkerType useMarkertype = (MarkerType) CdmStore.getService(ITermService.class).find(UsageTermCollection.uuidUseMarkerType);
- Boolean isUseDescription = false;
- for (Marker marker : descriptionMarkers) {
- if (marker.getMarkerType().equals(useMarkertype)) {
- isUseDescription = true;
- }
- }
- if (((DescriptionBase) getInput()).isImageGallery()) {
- createImageGallerySection(rootElement);
-
- } else if (isUseDescription) {
- createUseDescriptionSection(rootElement);
- } else {
- createDescriptionSection(rootElement);
-
- }
- } else if (getInput() instanceof DescriptionElementBase) {
- Set<Marker> descriptionMarkers = ((DescriptionElementBase) getInput()).getInDescription().getMarkers();
- MarkerType useMarkertype = (MarkerType) CdmStore.getService(ITermService.class).find(UsageTermCollection.uuidUseMarkerType);
- Boolean isUseDescription = false;
- for (Marker marker : descriptionMarkers) {
- if (marker.getMarkerType().equals(useMarkertype)) {
- isUseDescription = true;
- }
- }
-
- if (isUseDescription == true && getInput() instanceof CategoricalData ) {
- createUseRecordSection(rootElement);
- }
- else {
- createDescriptionElementSection(rootElement);
- }
-
- } else if (getInput() instanceof Media) {
- createMediaElementSection(rootElement);
-
- } else if (getInput() instanceof DerivedUnitFacade) {
- createDerivedUnitBaseElementSection(rootElement);
-
- } else if (getInput() instanceof FeatureNodeContainer) {
- createFeatureDistributionSection(rootElement);
-
- } else if (getInput() instanceof PolytomousKey) {
- //createPolytomousKeySection(rootElement);
-
- } else if ((getInput() instanceof PolytomousKeyNode)
- || (getInput() instanceof PolytomousKeyRelationship)) {
- createPolytomousKeyNodeSection(rootElement);
-
- } else if (getInput() instanceof User) {
- createUserSection(rootElement);
-
- } else if (getInput() instanceof Group) {
- createGroupSection(rootElement);
-
- } else if (getInput() instanceof TaxonRelationship) {
- createTaxonRelationshipSection(rootElement);
-
- } else if (getInput() instanceof TermVocabulary) {
- createTermVocabularySection(rootElement);
-
- } else if (getInput() instanceof DefinedTermBase) {
- createDefinedTermSection(rootElement);
- } else {
- destroySections();
- }
- layout();
- }
-
-
- /**
- * @param rootElement
- */
- private void createGroupSection(RootElement parent) {
- destroySections();
-
- GroupDetailSection groupDetailSection = (GroupDetailSection) formFactory
- .createCdmDetailSection(DetailType.GROUP,
- getConversationHolder(), parent, this, Section.TWISTIE
- | Section.EXPANDED);
- MemberDetailSection memberDetailSection = (MemberDetailSection) formFactory
- .createEntityDetailSection(EntityDetailType.MEMBER,
- getConversationHolder(), parent, Section.TWISTIE
- | Section.EXPANDED);
- GrantedAuthorityDetailSection grantedAuthorityDetailSection = (GrantedAuthorityDetailSection) formFactory
- .createEntityDetailSection(EntityDetailType.GRANTED_AUTHORITY,
- getConversationHolder(), parent, Section.TWISTIE
- | Section.EXPANDED);
-
- addPart(groupDetailSection);
- addPart(memberDetailSection);
- addPart(grantedAuthorityDetailSection);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.viewers.Viewer#getSelection()
- */
- /** {@inheritDoc} */
- @Override
- public ISelection getSelection() {
- return selection;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.eclipse.jface.viewers.Viewer#setSelection(org.eclipse.jface.viewers
- * .ISelection, boolean)
- */
- /** {@inheritDoc} */
- @Override
- public void setSelection(ISelection selection, boolean reveal) {
- this.selection = selection;
- SelectionChangedEvent selectionChangedEvent = new SelectionChangedEvent(
- this, selection);
- fireSelectionChanged(selectionChangedEvent);
- }
-
- /**
- * createTaxonSections(RootElement parent)
- * @param parent
- */
- private void createTaxonSections(RootElement parent) {
- destroySections();
-
- TaxonBaseDetailSection taxonBaseDetailSection = (TaxonBaseDetailSection) formFactory
- .createCdmDetailSection(DetailType.TAXONBASE,
- getConversationHolder(), parent, this, Section.TWISTIE);
-
- formFactory.createHorizontalSeparator(parent, SWT.BORDER);
-
- NonViralNameDetailSection nonViralNameSection = (NonViralNameDetailSection) formFactory
- .createCdmDetailSection(DetailType.NONVIRALNAME,
- getConversationHolder(), parent, this, Section.TWISTIE
- | Section.EXPANDED);
-
- formFactory.createHorizontalSeparator(parent, SWT.BORDER);
-
- NomenclaturalReferenceDetailSection referenceDetailSection = (NomenclaturalReferenceDetailSection) formFactory
- .createCdmDetailSection(DetailType.NOMENCLATURALREFERENCE,
- getConversationHolder(), parent, this, Section.TWISTIE);
-
- formFactory.createHorizontalSeparator(parent, SWT.BORDER);
-
- NomenclaturalStatusSection nomenclaturalStatusSection = (NomenclaturalStatusSection) formFactory
- .createEntityDetailSection(
- EntityDetailType.NOMENCLATURALSTATUS,
- getConversationHolder(), parent, Section.TWISTIE);
-
- formFactory.createHorizontalSeparator(parent, SWT.BORDER);
-
- ProtologueSection protologSection = (ProtologueSection) formFactory
- .createEntityDetailSection(EntityDetailType.PROTOLOG,
- getConversationHolder(), parent, Section.TWISTIE);
-
- formFactory.createHorizontalSeparator(parent, SWT.BORDER);
-
- TypeDesignationSection typeDesignationSection = (TypeDesignationSection) formFactory
- .createEntityDetailSection(EntityDetailType.TYPEDESIGNATION,
- getConversationHolder(), parent, Section.TWISTIE);
-
- formFactory.createHorizontalSeparator(parent, SWT.BORDER);
-
- NameRelationshipDetailSection nameRelationshipSection = (NameRelationshipDetailSection) formFactory
- .createEntityDetailSection(EntityDetailType.NAME_RELATIONSHIP,
- getConversationHolder(), parent, Section.TWISTIE);
-
- formFactory.createHorizontalSeparator(parent, SWT.BORDER);
-
- ParsingMessagesSection parsingMessagesSection = (ParsingMessagesSection) formFactory
- .createCdmDetailSection(DetailType.PARSINGMESSAGE,
- getConversationHolder(), parent, this, Section.EXPANDED);
-
- addPart(taxonBaseDetailSection);
- addPart(nonViralNameSection);
- addPart(nomenclaturalStatusSection);
- addPart(protologSection);
- addPart(referenceDetailSection);
- addPart(typeDesignationSection);
- addPart(nameRelationshipSection);
- addPart(parsingMessagesSection);
- }
-
- /**
- * createNameSections
- * @param parent
- */
- private void createNameSections(RootElement parent) {
- destroySections();
- NonViralNameDetailSection nonViralNameSection = (NonViralNameDetailSection) formFactory
- .createCdmDetailSection(DetailType.NONVIRALNAME,
- getConversationHolder(), parent, this, Section.TWISTIE
- | Section.EXPANDED);
-
- formFactory.createHorizontalSeparator(parent, SWT.BORDER);
-
- NomenclaturalReferenceDetailSection referenceDetailSection = (NomenclaturalReferenceDetailSection) formFactory
- .createCdmDetailSection(DetailType.NOMENCLATURALREFERENCE,
- getConversationHolder(), parent, this, Section.TWISTIE);
-
- formFactory.createHorizontalSeparator(parent, SWT.BORDER);
-
- NomenclaturalStatusSection nomenclaturalStatusSection = (NomenclaturalStatusSection) formFactory
- .createEntityDetailSection(
- EntityDetailType.NOMENCLATURALSTATUS,
- getConversationHolder(), parent, Section.TWISTIE);
-
- formFactory.createHorizontalSeparator(parent, SWT.BORDER);
-
- ProtologueSection protologSection = (ProtologueSection) formFactory
- .createEntityDetailSection(EntityDetailType.PROTOLOG,
- getConversationHolder(), parent, Section.TWISTIE);
-
- formFactory.createHorizontalSeparator(parent, SWT.BORDER);
-
- TypeDesignationSection typeDesignationSection = (TypeDesignationSection) formFactory
- .createEntityDetailSection(EntityDetailType.TYPEDESIGNATION,
- getConversationHolder(), parent, Section.TWISTIE);
-
- formFactory.createHorizontalSeparator(parent, SWT.BORDER);
-
- NameRelationshipDetailSection nameRelationshipSection = (NameRelationshipDetailSection) formFactory
- .createEntityDetailSection(EntityDetailType.NAME_RELATIONSHIP,
- getConversationHolder(), parent, Section.TWISTIE);
-
- formFactory.createHorizontalSeparator(parent, SWT.BORDER);
-
- addPart(nonViralNameSection);
- addPart(nomenclaturalStatusSection);
- addPart(protologSection);
- addPart(referenceDetailSection);
- addPart(typeDesignationSection);
- addPart(nameRelationshipSection);
- }
-
- /**
- * createReferenceSections
- * @param parent
- */
- private void createReferenceSections(RootElement parent) {
- destroySections();
-
- ReferenceDetailSection referenceDetailSection = (ReferenceDetailSection) formFactory
- .createCdmDetailSection(DetailType.REFERENCEBASE,
- getConversationHolder(), parent, this, Section.TWISTIE
- | Section.EXPANDED);
-
- addPart(referenceDetailSection);
- }
-
- /**
- * createTeamOrPersonBaseDetailSection
- * @param parent
- */
- private void createTeamOrPersonBaseDetailSection(RootElement parent) {
- destroySections();
- TeamOrPersonBaseDetailSection teamOrPersonBaseDetailSection = (TeamOrPersonBaseDetailSection) formFactory
- .createCdmDetailSection(DetailType.TEAMORPERSONBASE,
- getConversationHolder(), parent, this, Section.TWISTIE
- | Section.EXPANDED);
-
- addPart(teamOrPersonBaseDetailSection);
- }
-
- /**
- * createTeamDetailSection
- * @param parent
- */
- private void createTeamDetailSection(RootElement parent) {
- destroySections();
- TeamDetailSection teamDetailSection = (TeamDetailSection) formFactory
- .createCdmDetailSection(DetailType.TEAM,
- getConversationHolder(), parent, this, Section.TWISTIE
- | Section.EXPANDED);
-
- addPart(teamDetailSection);
- }
-
- /**
- * createPersonDetailSection
- * @param parent
- */
- private void createPersonDetailSection(RootElement parent) {
- destroySections();
- PersonDetailSection personDetailSection = (PersonDetailSection) formFactory
- .createCdmDetailSection(DetailType.PERSON,
- getConversationHolder(), parent, this, Section.TWISTIE
- | Section.EXPANDED);
- addPart(personDetailSection);
- }
-
- /**
- * createDescriptionElementSection
- * @param parent
- */
- private void createDescriptionElementSection(RootElement parent) {
- destroySections();
-
- DescriptionElementDetailSection descriptionElementDetailSection = (DescriptionElementDetailSection) formFactory
- .createCdmDetailSection(DetailType.DESCRIPTIONELEMENT,
- getConversationHolder(), parent, this, Section.TWISTIE
- | Section.EXPANDED);
-
- formFactory.createHorizontalSeparator(parent, SWT.BORDER);
-
- DescriptionElementSourceSection descriptionElementSourceSection = (DescriptionElementSourceSection) formFactory
- .createEntityDetailSection(
- EntityDetailType.DESCRIPTIONELEMENTSOURCE,
- getConversationHolder(), parent, Section.TWISTIE);
-
- formFactory.createHorizontalSeparator(parent, SWT.BORDER);
-
- DescriptionElementMediaSection descriptionElementMediaSection = (DescriptionElementMediaSection) formFactory
- .createEntityDetailSection(
- EntityDetailType.DESCRIPTIONELEMENTMEDIA,
- getConversationHolder(), parent, Section.TWISTIE);
-
- formFactory.createHorizontalSeparator(parent, SWT.BORDER);
-
- addPart(descriptionElementDetailSection);
- addPart(descriptionElementSourceSection);
- addPart(descriptionElementMediaSection);
- }
-
- /**
- * createDescriptionSection
- * @param parent
- */
- private void createDescriptionSection(RootElement parent) {
- destroySections();
- DescriptionDetailSection descriptionDetailSection = (DescriptionDetailSection) formFactory
- .createCdmDetailSection(DetailType.DESCRIPTION,
- getConversationHolder(), parent, this, Section.TWISTIE
- | Section.EXPANDED);
-
- formFactory.createHorizontalSeparator(parent, SWT.BORDER);
-
- NaturalLanguageSection naturalLanguageSection = (NaturalLanguageSection) formFactory
- .createCdmDetailSection(DetailType.NATURAL_LANGUAGE,
- getConversationHolder(), parent, this, Section.TWISTIE
- | Section.EXPANDED);
-
- formFactory.createHorizontalSeparator(parent, SWT.BORDER);
-
- DescribedSpecimenSection describedSpecimenSection = (DescribedSpecimenSection) formFactory
- .createEntityDetailSection(EntityDetailType.DESCRIBED_SPECIMEN,
- getConversationHolder(), parent, Section.TWISTIE);
-
- formFactory.createHorizontalSeparator(parent, SWT.BORDER);
-
- DescriptionSourceSection descriptionSourceSection = (DescriptionSourceSection) formFactory
- .createEntityDetailSection(EntityDetailType.DESCRIPTIONSOURCE,
- getConversationHolder(), parent, Section.TWISTIE);
-
- formFactory.createHorizontalSeparator(parent, SWT.BORDER);
-
- ScopeSection scopeSection = (ScopeSection) formFactory
- .createEntityDetailSection(EntityDetailType.SCOPE,
- getConversationHolder(), parent, Section.TWISTIE);
-
- formFactory.createHorizontalSeparator(parent, SWT.BORDER);
-
- addPart(descriptionDetailSection);
- addPart(naturalLanguageSection);
- addPart(describedSpecimenSection);
- addPart(descriptionSourceSection);
- addPart(scopeSection);
- }
-
- /**
- * Creates the use Description section
- * @param parent
- */
- private void createUseDescriptionSection(RootElement parent) {
- destroySections();
- DescriptionDetailSection descriptionDetailSection = (DescriptionDetailSection) formFactory
- .createCdmDetailSection(DetailType.DESCRIPTION,
- getConversationHolder(), parent, this, Section.TWISTIE
- | Section.EXPANDED);
-
- formFactory.createHorizontalSeparator(parent, SWT.BORDER);
-
- DescriptionSourceSection descriptionSourceSection = (DescriptionSourceSection) formFactory
- .createEntityDetailSection(EntityDetailType.DESCRIPTIONSOURCE,
- getConversationHolder(), parent, Section.TWISTIE
- | Section.EXPANDED);
-
- formFactory.createHorizontalSeparator(parent, SWT.BORDER);
-
- addPart(descriptionDetailSection);
- addPart(descriptionSourceSection);
-
- }
-
-
- /**
- * @param rootElement
- */
- private void createImageGallerySection(RootElement parent) {
- destroySections();
- DescriptionDetailSection descriptionDetailSection = (DescriptionDetailSection) formFactory
- .createCdmDetailSection(DetailType.DESCRIPTION,
- getConversationHolder(), parent, this, Section.TWISTIE
- | Section.EXPANDED);
-
- addPart(descriptionDetailSection);
- }
-
- /**
- * createMediaElementSection
- * @param parent
- */
-
- private void createMediaElementSection(RootElement parent) {
- destroySections();
- MediaDetailsSection mediaDetailSection = (MediaDetailsSection) formFactory
- .createCdmDetailSection(DetailType.MEDIA,
- getConversationHolder(), parent, this, Section.TWISTIE
- | Section.EXPANDED);
-
- addPart(mediaDetailSection);
- }
-
- /**
- * createDerivedUnitBaseElementSection
- * @param parent
- */
- private void createDerivedUnitBaseElementSection(RootElement parent) {
- destroySections();
-
- GeneralDetailSection generalDetailSection = (GeneralDetailSection) formFactory
- .createCdmDetailSection(DetailType.DERIVED_UNIT_GENERAL,
- getConversationHolder(), parent, this, Section.TWISTIE
- | Section.EXPANDED);
-
- formFactory.createHorizontalSeparator(parent, SWT.BORDER);
-
- GatheringEventDetailSection gatheringEventDetailSection = (GatheringEventDetailSection) formFactory
- .createCdmDetailSection(DetailType.GATHERING_EVENT,
- getConversationHolder(), parent, this, Section.TWISTIE);
-
- formFactory.createHorizontalSeparator(parent, SWT.BORDER);
-
- FieldObservationDetailSection fieldObservationDetailSection = (FieldObservationDetailSection) formFactory
- .createCdmDetailSection(DetailType.FIELD_OBSERVATION,
- getConversationHolder(), parent, this, Section.TWISTIE);
-
- formFactory.createHorizontalSeparator(parent, SWT.BORDER);
-
- DerivedUnitBaseDetailSection derivedUnitBaseDetailSection = (DerivedUnitBaseDetailSection) formFactory
- .createCdmDetailSection(DetailType.DERIVED_UNIT,
- getConversationHolder(), parent, this, Section.TWISTIE);
-
- formFactory.createHorizontalSeparator(parent, SWT.BORDER);
-
- DeterminationDetailSection determinationDetailSection = (DeterminationDetailSection) formFactory
- .createCdmDetailSection(DetailType.DETERMINATION,
- getConversationHolder(), parent, this, Section.TWISTIE);
-
- addPart(generalDetailSection);
- addPart(gatheringEventDetailSection);
- addPart(fieldObservationDetailSection);
- addPart(derivedUnitBaseDetailSection);
- addPart(determinationDetailSection);
-
- }
-
- /**
- * @param rootElement
- */
- private void createFeatureDistributionSection(RootElement parent) {
- destroySections();
-
- FeatureDistributionDetailSection featureDistributionSection = (FeatureDistributionDetailSection) formFactory
- .createCdmDetailSection(DetailType.FEATURE_DISTRIBUTION,
- getConversationHolder(), parent, this, Section.TWISTIE
- | Section.EXPANDED);
+ private ISelection selection;
+
+ /**
+ * <p>
+ * Constructor for DetailsViewer.
+ * </p>
+ *
+ * @param parent
+ * a {@link org.eclipse.swt.widgets.Composite} object.
+ * @param viewPart
+ * a {@link eu.etaxonomy.taxeditor.view.AbstractCdmViewPart}
+ * object.
+ */
+ public DetailsViewer(Composite parent, AbstractCdmViewPart viewPart) {
+ super(parent, viewPart);
+ }
+
+ // START HACK TO MAKE THE DERIVED UNIT FACADE WORK
+ // since we are getting implementations of DerivedUnitBase from the bulk
+ // editor
+ // and not derived unit facade objects,
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * eu.etaxonomy.taxeditor.editor.view.AbstractCdmDataViewer#setInput(java
+ * .lang.Object)
+ */
+ @Override
+ public void setInput(Object input) {
+ if (input instanceof DerivedUnitBase) {
+ try {
+ input = DerivedUnitFacade.NewInstance((DerivedUnitBase) input,
+ PreferencesUtil.getDerivedUnitConfigurator());
+ } catch (DerivedUnitFacadeNotSupportedException e) {
+ AbstractUtility.error(getClass(), e);
+ }
+ }
+ super.setInput(input);
+ }
+
+ @Override
+ protected void markViewPartDirty() {
+ if (getInput() instanceof DerivedUnitFacade) {
+ getViewPart().changed(((DerivedUnitFacade) getInput()).innerDerivedUnit());
+ }
+
+ super.markViewPartDirty();
+ }
+
+ // END HACK TO MAKE THE DERIVED UNIT FACADE WORK
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.viewers.Viewer#refresh()
+ */
+ /** {@inheritDoc} */
+ @Override
+ protected void showParts() {
+ // FIXME (CM) : Need to clean out this code.
+ // Too much type checking to decide which detail view to display.
+ // Need to build in a mechanism where navigators / editors are 'aware'
+ // of the corresponding detail viewer.
+ Object input = getInput();
+ if (input instanceof TaxonBase) {
+ createTaxonSections(rootElement);
+
+ } else if (input instanceof NonViralName) {
+ createNameSections(rootElement);
+
+ } else if (input instanceof Reference) {
+ createReferenceSections(rootElement);
+
+ } else if (input instanceof Team) {
+ createTeamDetailSection(rootElement);
+
+ } else if (input instanceof Person) {
+ createPersonDetailSection(rootElement);
+
+ } else if (input instanceof TeamOrPersonBase) {
+ createTeamOrPersonBaseDetailSection(rootElement);
+
+ } else if (input instanceof DescriptionBase) {
+ Set<Marker> descriptionMarkers = ((DescriptionBase) input).getMarkers();
+ MarkerType useMarkertype = (MarkerType) CdmStore.getService(ITermService.class).find(
+ UsageTermCollection.uuidUseMarkerType);
+ Boolean isUseDescription = false;
+ for (Marker marker : descriptionMarkers) {
+ if (marker.getMarkerType().equals(useMarkertype)) {
+ isUseDescription = true;
+ }
+ }
+ if (((DescriptionBase) input).isImageGallery()) {
+ createImageGallerySection(rootElement);
+
+ } else if (isUseDescription) {
+ createUseDescriptionSection(rootElement);
+ } else {
+ createDescriptionSection(rootElement);
+
+ }
+ } else if (input instanceof DescriptionElementBase) {
+ Set<Marker> descriptionMarkers = ((DescriptionElementBase) input).getInDescription().getMarkers();
+ MarkerType useMarkertype = (MarkerType) CdmStore.getService(ITermService.class).find(
+ UsageTermCollection.uuidUseMarkerType);
+ Boolean isUseDescription = false;
+ for (Marker marker : descriptionMarkers) {
+ if (marker.getMarkerType().equals(useMarkertype)) {
+ isUseDescription = true;
+ }
+ }
+
+ if (isUseDescription == true && input instanceof CategoricalData) {
+ createUseRecordSection(rootElement);
+ } else {
+ createDescriptionElementSection(rootElement);
+ }
+
+ } else if (input instanceof Media) {
+ createMediaElementSection(rootElement);
+
+ } else if (input instanceof DerivedUnitFacade) {
+ createDerivedUnitBaseElementSection(rootElement);
+
+ } else if (input instanceof FeatureNodeContainer) {
+ createFeatureDistributionSection(rootElement);
+
+ } else if (input instanceof PolytomousKey) {
+ // createPolytomousKeySection(rootElement);
+
+ } else if ((input instanceof PolytomousKeyNode) || (input instanceof PolytomousKeyRelationship)) {
+ createPolytomousKeyNodeSection(rootElement);
+ } else if (input instanceof User) {
+ createUserSection(rootElement);
+ } else if (input instanceof Group) {
+ createGroupSection(rootElement);
+ } else if (input instanceof TaxonRelationship) {
+ createTaxonRelationshipSection(rootElement);
+ } else if (input instanceof TermVocabulary) {
+ createTermVocabularySection(rootElement);
+ } else if (input instanceof DefinedTermBase) {
+ createDefinedTermSection(rootElement);
+ } else {
+ destroySections();
+ }
+ layout();
+ }
+
+ /**
+ * @param rootElement
+ */
+ private void createGroupSection(RootElement parent) {
+ destroySections();
+
+ GroupDetailSection groupDetailSection = (GroupDetailSection) formFactory.createCdmDetailSection(
+ DetailType.GROUP, getConversationHolder(), parent, this, ExpandableComposite.TWISTIE
+ | ExpandableComposite.EXPANDED);
+ MemberDetailSection memberDetailSection = (MemberDetailSection) formFactory.createEntityDetailSection(
+ EntityDetailType.MEMBER, getConversationHolder(), parent, ExpandableComposite.TWISTIE
+ | ExpandableComposite.EXPANDED);
+ GrantedAuthorityDetailSection grantedAuthorityDetailSection = (GrantedAuthorityDetailSection) formFactory
+ .createEntityDetailSection(EntityDetailType.GRANTED_AUTHORITY, getConversationHolder(), parent,
+ ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
+
+ addPart(groupDetailSection);
+ addPart(memberDetailSection);
+ addPart(grantedAuthorityDetailSection);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.viewers.Viewer#getSelection()
+ */
+ /** {@inheritDoc} */
+ @Override
+ public ISelection getSelection() {
+ return selection;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.jface.viewers.Viewer#setSelection(org.eclipse.jface.viewers
+ * .ISelection, boolean)
+ */
+ /** {@inheritDoc} */
+ @Override
+ public void setSelection(ISelection selection, boolean reveal) {
+ this.selection = selection;
+ SelectionChangedEvent selectionChangedEvent = new SelectionChangedEvent(this, selection);
+ fireSelectionChanged(selectionChangedEvent);
+ }
+
+ /**
+ * createTaxonSections(RootElement parent)
+ *
+ * @param parent
+ */
+ private void createTaxonSections(RootElement parent) {
+ destroySections();
+
+ TaxonBaseDetailSection taxonBaseDetailSection = (TaxonBaseDetailSection) formFactory.createCdmDetailSection(
+ DetailType.TAXONBASE, getConversationHolder(), parent, this, ExpandableComposite.TWISTIE);
+
+ formFactory.createHorizontalSeparator(parent, SWT.BORDER);
+
+ NonViralNameDetailSection nonViralNameSection = (NonViralNameDetailSection) formFactory.createCdmDetailSection(
+ DetailType.NONVIRALNAME, getConversationHolder(), parent, this, ExpandableComposite.TWISTIE
+ | ExpandableComposite.EXPANDED);
+
+ formFactory.createHorizontalSeparator(parent, SWT.BORDER);
+
+ NomenclaturalReferenceDetailSection referenceDetailSection = (NomenclaturalReferenceDetailSection) formFactory
+ .createCdmDetailSection(DetailType.NOMENCLATURALREFERENCE, getConversationHolder(), parent, this,
+ ExpandableComposite.TWISTIE);
+
+ formFactory.createHorizontalSeparator(parent, SWT.BORDER);
+
+ NomenclaturalStatusSection nomenclaturalStatusSection = (NomenclaturalStatusSection) formFactory
+ .createEntityDetailSection(EntityDetailType.NOMENCLATURALSTATUS, getConversationHolder(), parent,
+ ExpandableComposite.TWISTIE);
+
+ formFactory.createHorizontalSeparator(parent, SWT.BORDER);
+
+ ProtologueSection protologSection = (ProtologueSection) formFactory.createEntityDetailSection(
+ EntityDetailType.PROTOLOG, getConversationHolder(), parent, ExpandableComposite.TWISTIE);
+
+ formFactory.createHorizontalSeparator(parent, SWT.BORDER);
+
+ TypeDesignationSection typeDesignationSection = (TypeDesignationSection) formFactory.createEntityDetailSection(
+ EntityDetailType.TYPEDESIGNATION, getConversationHolder(), parent, ExpandableComposite.TWISTIE);
+
+ formFactory.createHorizontalSeparator(parent, SWT.BORDER);
+
+ NameRelationshipDetailSection nameRelationshipSection = (NameRelationshipDetailSection) formFactory
+ .createEntityDetailSection(EntityDetailType.NAME_RELATIONSHIP, getConversationHolder(), parent,
+ ExpandableComposite.TWISTIE);
+
+ formFactory.createHorizontalSeparator(parent, SWT.BORDER);
+
+ ParsingMessagesSection parsingMessagesSection = (ParsingMessagesSection) formFactory.createCdmDetailSection(
+ DetailType.PARSINGMESSAGE, getConversationHolder(), parent, this, ExpandableComposite.EXPANDED);
+
+ addPart(taxonBaseDetailSection);
+ addPart(nonViralNameSection);
+ addPart(nomenclaturalStatusSection);
+ addPart(protologSection);
+ addPart(referenceDetailSection);
+ addPart(typeDesignationSection);
+ addPart(nameRelationshipSection);
+ addPart(parsingMessagesSection);
+ }
+
+ /**
+ * createNameSections
+ *
+ * @param parent
+ */
+ private void createNameSections(RootElement parent) {
+ destroySections();
+ NonViralNameDetailSection nonViralNameSection = (NonViralNameDetailSection) formFactory.createCdmDetailSection(
+ DetailType.NONVIRALNAME, getConversationHolder(), parent, this, ExpandableComposite.TWISTIE
+ | ExpandableComposite.EXPANDED);
+
+ formFactory.createHorizontalSeparator(parent, SWT.BORDER);
+
+ NomenclaturalReferenceDetailSection referenceDetailSection = (NomenclaturalReferenceDetailSection) formFactory
+ .createCdmDetailSection(DetailType.NOMENCLATURALREFERENCE, getConversationHolder(), parent, this,
+ ExpandableComposite.TWISTIE);
+
+ formFactory.createHorizontalSeparator(parent, SWT.BORDER);
+
+ NomenclaturalStatusSection nomenclaturalStatusSection = (NomenclaturalStatusSection) formFactory
+ .createEntityDetailSection(EntityDetailType.NOMENCLATURALSTATUS, getConversationHolder(), parent,
+ ExpandableComposite.TWISTIE);
+
+ formFactory.createHorizontalSeparator(parent, SWT.BORDER);
+
+ ProtologueSection protologSection = (ProtologueSection) formFactory.createEntityDetailSection(
+ EntityDetailType.PROTOLOG, getConversationHolder(), parent, ExpandableComposite.TWISTIE);
+
+ formFactory.createHorizontalSeparator(parent, SWT.BORDER);
+
+ TypeDesignationSection typeDesignationSection = (TypeDesignationSection) formFactory.createEntityDetailSection(
+ EntityDetailType.TYPEDESIGNATION, getConversationHolder(), parent, ExpandableComposite.TWISTIE);
+
+ formFactory.createHorizontalSeparator(parent, SWT.BORDER);
+
+ NameRelationshipDetailSection nameRelationshipSection = (NameRelationshipDetailSection) formFactory
+ .createEntityDetailSection(EntityDetailType.NAME_RELATIONSHIP, getConversationHolder(), parent,
+ ExpandableComposite.TWISTIE);
+
+ formFactory.createHorizontalSeparator(parent, SWT.BORDER);
+
+ addPart(nonViralNameSection);
+ addPart(nomenclaturalStatusSection);
+ addPart(protologSection);
+ addPart(referenceDetailSection);
+ addPart(typeDesignationSection);
+ addPart(nameRelationshipSection);
+ }
+
+ /**
+ * createReferenceSections
+ *
+ * @param parent
+ */
+ private void createReferenceSections(RootElement parent) {
+ destroySections();
+
+ ReferenceDetailSection referenceDetailSection = (ReferenceDetailSection) formFactory.createCdmDetailSection(
+ DetailType.REFERENCEBASE, getConversationHolder(), parent, this, ExpandableComposite.TWISTIE
+ | ExpandableComposite.EXPANDED);
+
+ addPart(referenceDetailSection);
+ }
+
+ /**
+ * createTeamOrPersonBaseDetailSection
+ *
+ * @param parent
+ */
+ private void createTeamOrPersonBaseDetailSection(RootElement parent) {
+ destroySections();
+ TeamOrPersonBaseDetailSection teamOrPersonBaseDetailSection = (TeamOrPersonBaseDetailSection) formFactory
+ .createCdmDetailSection(DetailType.TEAMORPERSONBASE, getConversationHolder(), parent, this,
+ ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
+
+ addPart(teamOrPersonBaseDetailSection);
+ }
+
+ /**
+ * createTeamDetailSection
+ *
+ * @param parent
+ */
+ private void createTeamDetailSection(RootElement parent) {
+ destroySections();
+ TeamDetailSection teamDetailSection = (TeamDetailSection) formFactory.createCdmDetailSection(DetailType.TEAM,
+ getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
+
+ addPart(teamDetailSection);
+ }
+
+ /**
+ * createPersonDetailSection
+ *
+ * @param parent
+ */
+ private void createPersonDetailSection(RootElement parent) {
+ destroySections();
+ PersonDetailSection personDetailSection = (PersonDetailSection) formFactory.createCdmDetailSection(
+ DetailType.PERSON, getConversationHolder(), parent, this, ExpandableComposite.TWISTIE
+ | ExpandableComposite.EXPANDED);
+ addPart(personDetailSection);
+ }
+
+ /**
+ * createDescriptionElementSection
+ *
+ * @param parent
+ */
+ private void createDescriptionElementSection(RootElement parent) {
+ destroySections();
+
+ DescriptionElementDetailSection descriptionElementDetailSection = (DescriptionElementDetailSection) formFactory
+ .createCdmDetailSection(DetailType.DESCRIPTIONELEMENT, getConversationHolder(), parent, this,
+ ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
+
+ formFactory.createHorizontalSeparator(parent, SWT.BORDER);
+
+ DescriptionElementSourceSection descriptionElementSourceSection = (DescriptionElementSourceSection) formFactory
+ .createEntityDetailSection(EntityDetailType.DESCRIPTIONELEMENTSOURCE, getConversationHolder(), parent,
+ ExpandableComposite.TWISTIE);
+
+ formFactory.createHorizontalSeparator(parent, SWT.BORDER);
+
+ DescriptionElementMediaSection descriptionElementMediaSection = (DescriptionElementMediaSection) formFactory
+ .createEntityDetailSection(EntityDetailType.DESCRIPTIONELEMENTMEDIA, getConversationHolder(), parent,
+ ExpandableComposite.TWISTIE);
+
+ formFactory.createHorizontalSeparator(parent, SWT.BORDER);
+
+ addPart(descriptionElementDetailSection);
+ addPart(descriptionElementSourceSection);
+ addPart(descriptionElementMediaSection);
+ }
+
+ /**
+ * createDescriptionSection
+ *
+ * @param parent
+ */
+ private void createDescriptionSection(RootElement parent) {
+ destroySections();
+ DescriptionDetailSection descriptionDetailSection = (DescriptionDetailSection) formFactory
+ .createCdmDetailSection(DetailType.DESCRIPTION, getConversationHolder(), parent, this,
+ ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
+
+ formFactory.createHorizontalSeparator(parent, SWT.BORDER);
+
+ NaturalLanguageSection naturalLanguageSection = (NaturalLanguageSection) formFactory.createCdmDetailSection(
+ DetailType.NATURAL_LANGUAGE, getConversationHolder(), parent, this, ExpandableComposite.TWISTIE
+ | ExpandableComposite.EXPANDED);
+
+ formFactory.createHorizontalSeparator(parent, SWT.BORDER);
+
+ DescribedSpecimenSection describedSpecimenSection = (DescribedSpecimenSection) formFactory
+ .createEntityDetailSection(EntityDetailType.DESCRIBED_SPECIMEN, getConversationHolder(), parent,
+ ExpandableComposite.TWISTIE);
+
+ formFactory.createHorizontalSeparator(parent, SWT.BORDER);
+
+ DescriptionSourceSection descriptionSourceSection = (DescriptionSourceSection) formFactory
+ .createEntityDetailSection(EntityDetailType.DESCRIPTIONSOURCE, getConversationHolder(), parent,
+ ExpandableComposite.TWISTIE);
+
+ formFactory.createHorizontalSeparator(parent, SWT.BORDER);
+
+ ScopeSection scopeSection = (ScopeSection) formFactory.createEntityDetailSection(EntityDetailType.SCOPE,
+ getConversationHolder(), parent, ExpandableComposite.TWISTIE);
+
+ formFactory.createHorizontalSeparator(parent, SWT.BORDER);
+
+ addPart(descriptionDetailSection);
+ addPart(naturalLanguageSection);
+ addPart(describedSpecimenSection);
+ addPart(descriptionSourceSection);
+ addPart(scopeSection);
+ }
+
+ /**
+ * Creates the use Description section
+ *
+ * @param parent
+ */
+ private void createUseDescriptionSection(RootElement parent) {
+ destroySections();
+ DescriptionDetailSection descriptionDetailSection = (DescriptionDetailSection) formFactory
+ .createCdmDetailSection(DetailType.DESCRIPTION, getConversationHolder(), parent, this,
+ ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
+
+ formFactory.createHorizontalSeparator(parent, SWT.BORDER);
+
+ DescriptionSourceSection descriptionSourceSection = (DescriptionSourceSection) formFactory
+ .createEntityDetailSection(EntityDetailType.DESCRIPTIONSOURCE, getConversationHolder(), parent,
+ ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
+
+ formFactory.createHorizontalSeparator(parent, SWT.BORDER);
+
+ addPart(descriptionDetailSection);
+ addPart(descriptionSourceSection);
+
+ }
+
+ /**
+ * @param rootElement
+ */
+ private void createImageGallerySection(RootElement parent) {
+ destroySections();
+ DescriptionDetailSection descriptionDetailSection = (DescriptionDetailSection) formFactory
+ .createCdmDetailSection(DetailType.DESCRIPTION, getConversationHolder(), parent, this,
+ ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
+
+ addPart(descriptionDetailSection);
+ }
+
+ /**
+ * createMediaElementSection
+ *
+ * @param parent
+ */
+
+ private void createMediaElementSection(RootElement parent) {
+ destroySections();
+ MediaDetailsSection mediaDetailSection = (MediaDetailsSection) formFactory.createCdmDetailSection(
+ DetailType.MEDIA, getConversationHolder(), parent, this, ExpandableComposite.TWISTIE
+ | ExpandableComposite.EXPANDED);
+
+ addPart(mediaDetailSection);
+ }
+
+ /**
+ * createDerivedUnitBaseElementSection
+ *
+ * @param parent
+ */
+ private void createDerivedUnitBaseElementSection(RootElement parent) {
+ destroySections();
+
+ GeneralDetailSection generalDetailSection = (GeneralDetailSection) formFactory.createCdmDetailSection(
+ DetailType.DERIVED_UNIT_GENERAL, getConversationHolder(), parent, this, ExpandableComposite.TWISTIE
+ | ExpandableComposite.EXPANDED);
+
+ formFactory.createHorizontalSeparator(parent, SWT.BORDER);
+
+ GatheringEventDetailSection gatheringEventDetailSection = (GatheringEventDetailSection) formFactory
+ .createCdmDetailSection(DetailType.GATHERING_EVENT, getConversationHolder(), parent, this,
+ ExpandableComposite.TWISTIE);
+
+ formFactory.createHorizontalSeparator(parent, SWT.BORDER);
+
+ FieldObservationDetailSection fieldObservationDetailSection = (FieldObservationDetailSection) formFactory
+ .createCdmDetailSection(DetailType.FIELD_OBSERVATION, getConversationHolder(), parent, this,
+ ExpandableComposite.TWISTIE);
+
+ formFactory.createHorizontalSeparator(parent, SWT.BORDER);
+
+ DerivedUnitBaseDetailSection derivedUnitBaseDetailSection = (DerivedUnitBaseDetailSection) formFactory
+ .createCdmDetailSection(DetailType.DERIVED_UNIT, getConversationHolder(), parent, this,
+ ExpandableComposite.TWISTIE);
+
+ formFactory.createHorizontalSeparator(parent, SWT.BORDER);
+
+ DeterminationDetailSection determinationDetailSection = (DeterminationDetailSection) formFactory
+ .createCdmDetailSection(DetailType.DETERMINATION, getConversationHolder(), parent, this,
+ ExpandableComposite.TWISTIE);
+
+ addPart(generalDetailSection);
+ addPart(gatheringEventDetailSection);
+ addPart(fieldObservationDetailSection);
+ addPart(derivedUnitBaseDetailSection);
+ addPart(determinationDetailSection);
+
+ }
- addPart(featureDistributionSection);
- }
-
- private void createPolytomousKeySection(RootElement parent) {
- destroySections();
-
- PolytomousKeyDetailSection polytomousKeyDetailSection = (PolytomousKeyDetailSection) formFactory
- .createCdmDetailSection(DetailType.POLYTOMOUS_KEY,
- getConversationHolder(), parent, this, Section.TWISTIE
- | Section.EXPANDED);
-
- formFactory.createHorizontalSeparator(parent, SWT.BORDER);
-
- GeographicalScopeDetailSection geographicalScopeDetailSection = (GeographicalScopeDetailSection) formFactory
- .createEntityDetailSection(EntityDetailType.GEOGRAPHICAL_SCOPE,
- getConversationHolder(), parent, Section.TWISTIE);
-
- formFactory.createHorizontalSeparator(parent, SWT.BORDER);
-
- ScopeRestrictionSection scopeRestrictionSection = (ScopeRestrictionSection) formFactory
- .createEntityDetailSection(EntityDetailType.SCOPE_RESTRICTION,
- getConversationHolder(), parent, Section.TWISTIE);
-
- formFactory.createHorizontalSeparator(parent, SWT.BORDER);
+ /**
+ * @param rootElement
+ */
+ private void createFeatureDistributionSection(RootElement parent) {
+ destroySections();
- TaxonomicScopeSection taxonomicScopeSection = (TaxonomicScopeSection) formFactory
- .createEntityDetailSection(EntityDetailType.TAXONOMIC_SCOPE,
- getConversationHolder(), parent, Section.TWISTIE);
+ FeatureDistributionDetailSection featureDistributionSection = (FeatureDistributionDetailSection) formFactory
+ .createCdmDetailSection(DetailType.FEATURE_DISTRIBUTION, getConversationHolder(), parent, this,
+ ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
- addPart(polytomousKeyDetailSection);
- addPart(geographicalScopeDetailSection);
- addPart(scopeRestrictionSection);
- addPart(taxonomicScopeSection);
- }
+ addPart(featureDistributionSection);
+ }
- /**
- * createPolytomousKeyNodeSection
- * @param parent
- */
- private void createPolytomousKeyNodeSection(RootElement parent) {
- destroySections();
+ /**
+ * createPolytomousKeyNodeSection
+ *
+ * @param parent
+ */
+ private void createPolytomousKeyNodeSection(RootElement parent) {
+ destroySections();
PolytomousKeyDetailSection polytomousKeyDetailSection = (PolytomousKeyDetailSection) formFactory
- .createCdmDetailSection(DetailType.POLYTOMOUS_KEY,
- getConversationHolder(), parent, this, Section.TWISTIE
- | Section.COMPACT);
-
+ .createCdmDetailSection(DetailType.POLYTOMOUS_KEY, getConversationHolder(), parent, this,
+ ExpandableComposite.TWISTIE | ExpandableComposite.COMPACT);
+
formFactory.createHorizontalSeparator(parent, SWT.BORDER);
-
+
PolytomousKeyNodeDetailSection polytomousKeyNodeDetailSection = (PolytomousKeyNodeDetailSection) formFactory
- .createCdmDetailSection(DetailType.POLYTOMOUS_KEY_NODE,
- getConversationHolder(), parent, this, Section.TWISTIE
- | Section.EXPANDED);
-
-// formFactory.createHorizontalSeparator(parent, SWT.BORDER);
-//
-// GeographicalScopeDetailSection geographicalScopeDetailSection = (GeographicalScopeDetailSection) formFactory
-// .createEntityDetailSection(EntityDetailType.GEOGRAPHICAL_SCOPE,
-// getConversationHolder(), parent, Section.TWISTIE | Section.COMPACT);
-//
-// formFactory.createHorizontalSeparator(parent, SWT.BORDER);
-//
-// ScopeRestrictionSection scopeRestrictionSection = (ScopeRestrictionSection) formFactory
-// .createEntityDetailSection(EntityDetailType.SCOPE_RESTRICTION,
-// getConversationHolder(), parent, Section.TWISTIE | Section.COMPACT);
-//
- formFactory.createHorizontalSeparator(parent, SWT.BORDER);
-
- TaxonomicScopeSection taxonomicScopeSection = (TaxonomicScopeSection) formFactory
- .createEntityDetailSection(EntityDetailType.TAXONOMIC_SCOPE,
- getConversationHolder(), parent, Section.TWISTIE | Section.COMPACT);
-
- addPart(polytomousKeyDetailSection);
- addPart(polytomousKeyNodeDetailSection);
-// addPart(geographicalScopeDetailSection);
-// addPart(scopeRestrictionSection);
- addPart(taxonomicScopeSection);
-
- }
-
- /**
- * create the UseRecordSection
- * @param parent
- */
- private void createUseRecordSection(RootElement parent) {
- destroySections();
-
- UseRecordDetailSection descriptionUseRecordSection = (UseRecordDetailSection) formFactory
- .createCdmDetailSection(DetailType.USE_RECORD,
- getConversationHolder(), parent, this, Section.TWISTIE
- | Section.EXPANDED);
-
- formFactory.createHorizontalSeparator(parent, SWT.BORDER);
-
- addPart(descriptionUseRecordSection);
-
-
- }
-
- /**
- * createUserSection
- * @param parent
- */
- private void createUserSection(RootElement parent) {
- destroySections();
-
- UserDetailSection userDetailSection = (UserDetailSection) formFactory
- .createCdmDetailSection(DetailType.USER,
- getConversationHolder(), parent, this, Section.TWISTIE
- | Section.EXPANDED);
-
- GroupsByUserDetailSection groupByUserDetailSection = (GroupsByUserDetailSection) formFactory
- .createEntityDetailSection(EntityDetailType.GROUPS_BY_USER,
- getConversationHolder(), parent, Section.TWISTIE
- | Section.EXPANDED);
-
- addPart(userDetailSection);
- addPart(groupByUserDetailSection);
- }
-
- /**
- * createTaxonRelationshipSection
- * @param parent
- */
- private void createTaxonRelationshipSection(RootElement parent) {
- destroySections();
-
- TaxonRelationshipDetailSection taxonRelationshipDetailSection = (TaxonRelationshipDetailSection) formFactory
- .createCdmDetailSection(DetailType.TAXON_RELATIONSHIP,
- getConversationHolder(), parent, this, Section.TWISTIE
- | Section.EXPANDED);
-
- ReferencedEntityDetailSection referencedEntityBaseDetailSection = (ReferencedEntityDetailSection) formFactory
- .createCdmDetailSection(DetailType.REFERENCED_ENTITY,
- getConversationHolder(), parent, this, Section.TWISTIE
- | Section.EXPANDED);
- addPart(taxonRelationshipDetailSection);
- addPart(referencedEntityBaseDetailSection);
- }
-
- /**
- * @param rootElement
- */
- private void createTermVocabularySection(RootElement parent) {
- destroySections();
-
- TermVocabularyDetailSection termVocabularyDetailSection = (TermVocabularyDetailSection) formFactory
- .createCdmDetailSection(DetailType.TERM_VOCABULARY,
- getConversationHolder(), parent, this, Section.TWISTIE
- | Section.EXPANDED);
- addPart(termVocabularyDetailSection);
- }
-
- /**
- * createDefinedTermSection
- * @param parent
- */
- private void createDefinedTermSection(RootElement parent) {
- destroySections();
-
- AbstractFormSection definedTermDetailSection = formFactory
- .createDefinedTermDetailSection(getInput().getClass(),
- getConversationHolder(), parent, this, Section.TWISTIE
- | Section.EXPANDED);
- addPart(definedTermDetailSection);
- }
+ .createCdmDetailSection(DetailType.POLYTOMOUS_KEY_NODE, getConversationHolder(), parent, this,
+ ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
+
+ formFactory.createHorizontalSeparator(parent, SWT.BORDER);
+
+ TaxonomicScopeSection taxonomicScopeSection = (TaxonomicScopeSection) formFactory.createEntityDetailSection(
+ EntityDetailType.TAXONOMIC_SCOPE, getConversationHolder(), parent, ExpandableComposite.TWISTIE
+ | ExpandableComposite.COMPACT);
+
+ addPart(polytomousKeyDetailSection);
+ addPart(polytomousKeyNodeDetailSection);
+ addPart(taxonomicScopeSection);
+
+ }
+
+ /**
+ * create the UseRecordSection
+ *
+ * @param parent
+ */
+ private void createUseRecordSection(RootElement parent) {
+ destroySections();
+
+ UseRecordDetailSection descriptionUseRecordSection = (UseRecordDetailSection) formFactory
+ .createCdmDetailSection(DetailType.USE_RECORD, getConversationHolder(), parent, this,
+ ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
+
+ formFactory.createHorizontalSeparator(parent, SWT.BORDER);
+
+ addPart(descriptionUseRecordSection);
+
+ }
+
+ /**
+ * createUserSection
+ *
+ * @param parent
+ */
+ private void createUserSection(RootElement parent) {
+ destroySections();
+
+ UserDetailSection userDetailSection = (UserDetailSection) formFactory.createCdmDetailSection(DetailType.USER,
+ getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
+
+ GroupsByUserDetailSection groupByUserDetailSection = (GroupsByUserDetailSection) formFactory
+ .createEntityDetailSection(EntityDetailType.GROUPS_BY_USER, getConversationHolder(), parent,
+ ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
+
+ addPart(userDetailSection);
+ addPart(groupByUserDetailSection);
+ }
+
+ /**
+ * createTaxonRelationshipSection
+ *
+ * @param parent
+ */
+ private void createTaxonRelationshipSection(RootElement parent) {
+ destroySections();
+
+ TaxonRelationshipDetailSection taxonRelationshipDetailSection = (TaxonRelationshipDetailSection) formFactory
+ .createCdmDetailSection(DetailType.TAXON_RELATIONSHIP, getConversationHolder(), parent, this,
+ ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
+
+ ReferencedEntityDetailSection referencedEntityBaseDetailSection = (ReferencedEntityDetailSection) formFactory
+ .createCdmDetailSection(DetailType.REFERENCED_ENTITY, getConversationHolder(), parent, this,
+ ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
+ addPart(taxonRelationshipDetailSection);
+ addPart(referencedEntityBaseDetailSection);
+ }
+
+ /**
+ * @param rootElement
+ */
+ private void createTermVocabularySection(RootElement parent) {
+ destroySections();
+
+ TermVocabularyDetailSection termVocabularyDetailSection = (TermVocabularyDetailSection) formFactory
+ .createCdmDetailSection(DetailType.TERM_VOCABULARY, getConversationHolder(), parent, this,
+ ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
+ addPart(termVocabularyDetailSection);
+ }
+
+ /**
+ * createDefinedTermSection
+ *
+ * @param parent
+ */
+ private void createDefinedTermSection(RootElement parent) {
+ destroySections();
+
+ AbstractFormSection definedTermDetailSection = formFactory.createDefinedTermDetailSection(
+ getInput().getClass(), getConversationHolder(), parent, this, ExpandableComposite.TWISTIE
+ | ExpandableComposite.EXPANDED);
+ addPart(definedTermDetailSection);
+ }
+
+ private void createFOSection(RootElement parent){
+ destroySections();
+
+ GeneralDetailSection generalDetailSection = formFactory.createFOSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
+
+ formFactory.createHorizontalSeparator(parent, SWT.BORDER);
+
+ GatheringEventDetailSection gatheringEventDetailSection = formFactory.createGatheringSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE);
+
+ formFactory.createHorizontalSeparator(parent, SWT.BORDER);
+
+ FieldObservationDetailSection fieldObservationDetailSection =formFactory.createFODetailsSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE);
+
+ addPart(generalDetailSection);
+ addPart(gatheringEventDetailSection);
+ addPart(fieldObservationDetailSection);
+ }
}
// $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 eu.etaxonomy.cdm.api.facade.DerivedUnitFacade;
import eu.etaxonomy.cdm.model.description.PolytomousKeyNode;
+import eu.etaxonomy.taxeditor.model.AbstractUtility;
import eu.etaxonomy.taxeditor.model.FeatureNodeContainer;
-import eu.etaxonomy.taxeditor.store.StoreUtil;
+import eu.etaxonomy.taxeditor.model.IPartContentHasSupplementalData;
import eu.etaxonomy.taxeditor.view.AbstractCdmEditorViewPart;
-import eu.etaxonomy.taxeditor.view.AbstractCdmViewPart;
-import eu.etaxonomy.taxeditor.view.detail.CdmSectionPart;
/**
public static final String ID = "eu.etaxonomy.taxeditor.view.supplementalData";
private SupplementalDataViewer viewer;
-
+
/* (non-Javadoc)
* @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
*/
/** {@inheritDoc} */
- public void selectionChanged(IWorkbenchPart part, ISelection selection) {
- if(StoreUtil.getActiveEditor() == null){
+ @Override
+ public void selectionChanged(IWorkbenchPart part, ISelection selection) {
+ if(AbstractUtility.getActiveEditor() == null){
showEmptyPage();
return;
}
-
- if(((part instanceof EditorPart) || (part instanceof AbstractCdmViewPart)) && selection instanceof IStructuredSelection) {
- IStructuredSelection structuredSelection = (IStructuredSelection) selection;
+
+ if(!(selection instanceof IStructuredSelection)){
+ return;
+ }
+
+ IStructuredSelection structuredSelection = (IStructuredSelection) selection;
+
+ if((part instanceof EditorPart || part instanceof IPartContentHasSupplementalData)) {
if(structuredSelection.size() != 1){
showEmptyPage();
return;
}
-
+
// do not show supplemental data for feature nodes
if(structuredSelection.getFirstElement() instanceof FeatureNodeContainer){
showEmptyPage();
return;
}
- if(structuredSelection.getFirstElement() instanceof DerivedUnitFacade){
+ else if(structuredSelection.getFirstElement() instanceof DerivedUnitFacade){
return;
}
- if(structuredSelection.getFirstElement() instanceof PolytomousKeyNode){
+ else if(structuredSelection.getFirstElement() instanceof PolytomousKeyNode){
structuredSelection = new StructuredSelection(((PolytomousKeyNode)structuredSelection.getFirstElement()).getKey());
}
showViewer(part, structuredSelection);
}else{
- showEmptyPage();
+ showEmptyPage();
}
}
-
+
/** {@inheritDoc} */
@Override
public void dispose() {
*
* @return a boolean.
*/
- public boolean onComplete() {
+ @Override
+ public boolean onComplete() {
// TODO Auto-generated method stub
return false;
}
-
-
+
+
}