eu.etaxonomy.taxeditor.application/icons/256color_32x32.gif -text
eu.etaxonomy.taxeditor.application/icons/256color_48x48.gif -text
eu.etaxonomy.taxeditor.application/icons/256color_48x48.ico -text
+eu.etaxonomy.taxeditor.application/icons/check.png -text
eu.etaxonomy.taxeditor.application/icons/edit_16x16.gif -text
eu.etaxonomy.taxeditor.application/icons/specimen_derivate-16x16-32.png -text
eu.etaxonomy.taxeditor.application/plugin.xml -text
eu.etaxonomy.taxeditor.application/src/main/java/eu/etaxonomy/taxeditor/SaveHandler.java -text
eu.etaxonomy.taxeditor.application/src/main/java/eu/etaxonomy/taxeditor/TaxonomicEditorPlugin.java -text
eu.etaxonomy.taxeditor.application/src/main/java/eu/etaxonomy/taxeditor/perspective/BulkEditing.java -text
+eu.etaxonomy.taxeditor.application/src/main/java/eu/etaxonomy/taxeditor/perspective/ChecklistPerspective.java -text
eu.etaxonomy.taxeditor.application/src/main/java/eu/etaxonomy/taxeditor/perspective/Default.java -text
eu.etaxonomy.taxeditor.application/src/main/java/eu/etaxonomy/taxeditor/perspective/DerivatePerspective.java -text
eu.etaxonomy.taxeditor.application/src/main/java/eu/etaxonomy/taxeditor/perspective/PolytomousKey.java -text
eu.etaxonomy.taxeditor.editor/build.properties -text
eu.etaxonomy.taxeditor.editor/icons/address-book-new.png -text
eu.etaxonomy.taxeditor.editor/icons/camera-photo.png -text
+eu.etaxonomy.taxeditor.editor/icons/check.png -text
eu.etaxonomy.taxeditor.editor/icons/derivate_view-16x16-32.png -text
eu.etaxonomy.taxeditor.editor/icons/edit_16x16.gif -text
eu.etaxonomy.taxeditor.editor/icons/emblem-photos.png -text
eu.etaxonomy.taxeditor.navigation/OSGI-INF/l10n/messages_de.properties -text
eu.etaxonomy.taxeditor.navigation/OSGI-INF/l10n/messages_en.properties -text
eu.etaxonomy.taxeditor.navigation/build.properties -text
+eu.etaxonomy.taxeditor.navigation/icons/check.png -text
eu.etaxonomy.taxeditor.navigation/icons/edit_16x16.gif -text
eu.etaxonomy.taxeditor.navigation/icons/preferences-system-windows.png -text
eu.etaxonomy.taxeditor.navigation/icons/system-search.png -text
plugin_customization.ini,\
icons/,\
OSGI-INF/l10n/plugin.properties,\
- splash.bmp,\
OSGI-INF/l10n/plugin_de.properties,\
- OSGI-INF/l10n/plugin_en.properties
+ OSGI-INF/l10n/plugin_en.properties,\
+ splash.bmp,\
id="eu.etaxonomy.taxeditor.application.perspective.derivates"\r
name="%perspective.name.2">\r
</perspective>\r
+ <perspective\r
+ class="eu.etaxonomy.taxeditor.perspective.ChecklistPerspective"\r
+ icon="icons/check.png"\r
+ id="eu.etaxonomy.taxeditor.perspective.checklistperspective"\r
+ name="Checklist">\r
+ </perspective>\r
\r
</extension>\r
<!--extension\r
/**
* Prefix to declare the version as beta
*/
- private static final String BETA_PREFIX = "[BETA]";
+ private static final String BETA_PREFIX = "[Beta]";
/**
* @return
--- /dev/null
+// $Id$
+/**
+ * Copyright (C) 2007 EDIT
+ * European Distributed Institute of Taxonomy
+ * http://www.e-taxonomy.eu
+ *
+ * The contents of this file are subject to the Mozilla Public License Version 1.1
+ * See LICENSE.TXT at the top of this package for the full license terms.
+ */
+
+package eu.etaxonomy.taxeditor.perspective;
+
+import org.eclipse.ui.IFolderLayout;
+import org.eclipse.ui.IPageLayout;
+
+import eu.etaxonomy.taxeditor.editor.view.descriptive.DescriptiveViewPart;
+import eu.etaxonomy.taxeditor.editor.view.media.MediaViewPart;
+import eu.etaxonomy.taxeditor.navigation.navigator.TaxonNavigator;
+import eu.etaxonomy.taxeditor.navigation.search.SearchResultView;
+import eu.etaxonomy.taxeditor.view.datasource.CdmDataSourceViewPart;
+import eu.etaxonomy.taxeditor.view.detail.DetailsViewPart;
+import eu.etaxonomy.taxeditor.editor.view.concept.ConceptViewPart;
+
+/**
+ * @author a.oppermann
+ * @created Nov 18, 2014
+ * @version 1.0
+ */
+public class ChecklistPerspective extends Default {
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.ui.IPerspectiveFactory#createInitialLayout(org.eclipse.ui
+ * .IPageLayout)
+ */
+ @Override
+ public void createInitialLayout(IPageLayout layout) {
+ IFolderLayout navigationFolder = layout.createFolder("navigation",
+ IPageLayout.LEFT, 0.25f, layout.getEditorArea());
+
+ navigationFolder.addView(TaxonNavigator.ID);
+ navigationFolder.addPlaceholder(SearchResultView.ID + ":*");
+
+ layout.addView(CdmDataSourceViewPart.ID, IPageLayout.BOTTOM, 0.6f, TaxonNavigator.ID);
+ IFolderLayout folder = layout.createFolder("Folder", IPageLayout.BOTTOM, 0.6f, layout.getEditorArea());
+ folder.addView(DescriptiveViewPart.ID);
+ folder.addView(DetailsViewPart.ID);
+ folder.addView(ConceptViewPart.ID);
+// folder.addView(MediaViewPart.ID);
+
+// createAdditionalFolder(layout, layout.getEditorArea());
+ }
+}
// $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 eu.etaxonomy.taxeditor.bulkeditor.IEntityCreator#createEntity(java.lang.String)
*/
/** {@inheritDoc} */
- public Reference createEntity(String text) {
+ @Override
+ public Reference createEntity(String text) {
return createEntity(Reference.class, text);
}
* @see eu.etaxonomy.taxeditor.annotatedlineeditor.IEntityCreator#createEntity(java.lang.Class, java.lang.String)
*/
/** {@inheritDoc} */
- public Reference createEntity(Object key, String text) {
+ @Override
+ public Reference createEntity(Object key, String text) {
Reference reference = null;
-
+
// TODO replace w more generic method when cdmlib matures accordingly
if (ReferenceType.Article.getMessage().equals(key)) {
reference = ReferenceFactory.newArticle();
if (ReferenceType.WebPage.getMessage().equals(key)) {
reference = ReferenceFactory.newWebPage();
}
+ if (ReferenceType.Section.getMessage().equals(key)) {
+ reference = ReferenceFactory.newSection();
+ }
if (reference == null) {
MessagingUtils.warn(getClass(), "Reference type " + key + " not found. Creating reference with default type.");
reference = ReferenceFactory.newGeneric();
*
* @return a {@link java.util.Map} object.
*/
- public Map<Object, String> getKeyLabelPairs() {
+ @Override
+ public Map<Object, String> getKeyLabelPairs() {
Map<Object, String> result = new HashMap<Object, String>();
for (ReferenceType type : ReferenceType.values()) {
result.put(type.getMessage(), type.getMessage());
// $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 org.apache.log4j.Logger;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Table;
import org.eclipse.ui.INullSelectionListener;
-import org.eclipse.ui.ISelectionListener;
import org.eclipse.ui.IWorkbenchPart;
-import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
import eu.etaxonomy.cdm.api.service.IAgentService;
import eu.etaxonomy.cdm.api.service.ICommonService;
-import eu.etaxonomy.cdm.api.service.IIdentifiableEntityService;
-import eu.etaxonomy.cdm.model.agent.AgentBase;
import eu.etaxonomy.cdm.model.agent.TeamOrPersonBase;
import eu.etaxonomy.cdm.model.common.CdmBase;
-import eu.etaxonomy.cdm.model.common.ICdmBase;
import eu.etaxonomy.cdm.model.common.IdentifiableEntity;
-import eu.etaxonomy.cdm.persistence.dao.agent.IAgentDao;
import eu.etaxonomy.taxeditor.bulkeditor.BulkEditor;
import eu.etaxonomy.taxeditor.model.DescriptionHelper;
import eu.etaxonomy.taxeditor.model.LineSelection;
/** Constant <code>ID="eu.etaxonomy.taxeditor.bulkeditor.refer"{trunked}</code> */
public static final String ID = "eu.etaxonomy.taxeditor.bulkeditor.view.referencingobjects";
-
+
private TableViewer viewer;
private CdmBase referencedObject;
-
+
/* (non-Javadoc)
* @see eu.etaxonomy.taxeditor.model.AbstractCdmViewPart#createViewer(org.eclipse.swt.widgets.Composite)
*/
@Override
public void createViewer(Composite parent) {
selectionService.addSelectionListener(this);
-
+
viewer = new TableViewer(parent, SWT.MULTI | SWT.H_SCROLL
| SWT.V_SCROLL | SWT.FULL_SELECTION);
createColumns(viewer);
viewer.setLabelProvider(new ReferencingObjectsLabelProvider());
// viewer.setInput(new ArrayList<CdmBase>());
}
-
+
/**
* Create the columns for the table
* @param viewer
* @param entity a {@link eu.etaxonomy.cdm.model.common.IdentifiableEntity} object.
*/
public void updateReferencingObjects(final IdentifiableEntity entity) {
-
+
final Display display = Display.getCurrent();
-
+
+ //TODO see ticket #4537 (Re-enable asynchronous loading for ReferencingObjectsView)
+ //this is a workaround for #1569
//Job job = new Job("Update Referencing Objects") {
-//
+//
// @Override
// protected IStatus run(IProgressMonitor monitor) {
// monitor.beginTask("Calculating referencing objects", 10);
-//
+//
// monitor.worked(3);
-//
+//
// display.asyncExec(new Runnable() {
-//
+//
// @Override
// public void run() {
// ConversationHolder conversation = CdmStore.createConversation();
// conversation.close();
// }
// });
-//
+//
// monitor.done();
-//
-//
+//
+//
// return Status.OK_STATUS;
// }
// };
-//
+//
// job.setPriority(Job.DECORATE);
// job.schedule();
}
//referencedObject =(CdmBase) CdmStore.getService(IIdentifiableEntityService.class).load(referencedObject.getUuid());
Set<CdmBase> setOfReferencingObjects = CdmStore.getService(ICommonService.class).getReferencingObjects(referencedObject);
if (setOfReferencingObjects != null){
- List<CdmBase> referencingObjects = new ArrayList<CdmBase>(setOfReferencingObjects);
-
+ List<CdmBase> referencingObjects = new ArrayList<CdmBase>(setOfReferencingObjects);
+
Collections.sort(referencingObjects, new ReferencingClassComparator());
-
+
return referencingObjects;
}
}
}
return null;
}
-
+
class ReferencingClassComparator implements Comparator<CdmBase> {
/* (non-Javadoc)
* @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
*/
- public int compare(CdmBase o1, CdmBase o2) {
+ @Override
+ public int compare(CdmBase o1, CdmBase o2) {
String string1 = o1.getClass().getSimpleName();
String string2 = o2.getClass().getSimpleName();
int classCompare = string1.compareToIgnoreCase(string2);
}
}
}
-
+
/**
- *
+ *
*/
private void updateView(List<CdmBase> referencingObjects) {
viewer.setInput(referencingObjects);
}
/** {@inheritDoc} */
- public void selectionChanged(IWorkbenchPart part, ISelection selection) {
+ @Override
+ public void selectionChanged(IWorkbenchPart part, ISelection selection) {
+ if(part==null){
+ return;
+ }
if(! (part instanceof BulkEditor)){
setContentDescription("");
showEmptyPage();
return;
}
-
+
if(! (selection instanceof LineSelection)){
return;
}
LineSelection lineSelection = (LineSelection) selection;
-
+
if(lineSelection.size() != 1){
return;
}
-
+
if(! (lineSelection.getFirstElement() instanceof IdentifiableEntity)){
return;
}
-
+
showViewer(part, lineSelection);
}
-
+
/* (non-Javadoc)
* @see eu.etaxonomy.taxeditor.model.AbstractCdmViewPart#showViewer(org.eclipse.ui.IWorkbenchPart, org.eclipse.jface.viewers.ISelection)
*/
@Override
public void showViewer(IWorkbenchPart part, IStructuredSelection selection) {
this.part = part;
-
+
updateReferencingObjects((IdentifiableEntity) selection.getFirstElement());
}
-
+
/** {@inheritDoc} */
@Override
public void dispose() {
selectionService.removePostSelectionListener(this);
selectionService.removeSelectionListener(this);
super.dispose();
-
+
}
/* (non-Javadoc)
public void changed(Object object) {
// no editing in this view
}
-
+
/* (non-Javadoc)
* @see eu.etaxonomy.taxeditor.operations.IPostOperationEnabled#onComplete()
*/
public boolean onComplete() {
return false;
}
-
+
public void refresh(){
selectionService.removePostSelectionListener(this);
selectionService.removeSelectionListener(this);
selectionService.addPostSelectionListener(this);
selectionService.addSelectionListener(this);
-
+
}
<classpathentry exported="true" kind="lib" path="lib/cdmlib-model-3.4.0-SNAPSHOT-sources.jar"/>
<classpathentry exported="true" kind="lib" path="lib/cdmlib-model-3.4.0-SNAPSHOT.jar"/>
<classpathentry exported="true" kind="lib" path="lib/cdmlib-persistence-3.4.0-SNAPSHOT-sources.jar"/>
- <classpathentry exported="true" kind="lib" path="lib/cdmlib-persistence-3.4.0-SNAPSHOT.jar"/>
+ <classpathentry exported="true" kind="lib" path="lib/cdmlib-persistence-3.4.0-SNAPSHOT.jar" />
<classpathentry exported="true" kind="lib" path="lib/cdmlib-print-3.4.0-SNAPSHOT-sources.jar"/>
<classpathentry exported="true" kind="lib" path="lib/cdmlib-print-3.4.0-SNAPSHOT.jar"/>
<classpathentry exported="true" kind="lib" path="lib/cdmlib-remote-3.4.0-SNAPSHOT-sources.jar"/>
lib/spring-security-remoting-3.1.3.RELEASE.jar,
lib/jena-core-2.11.2.jar,
lib/jena-iri-1.0.2.jar,
- lib/cdmlib-commons-3.4.0-SNAPSHOT-sources.jar,
- lib/cdmlib-commons-3.4.0-SNAPSHOT.jar,
- lib/cdmlib-ext-3.4.0-SNAPSHOT-sources.jar,
- lib/cdmlib-ext-3.4.0-SNAPSHOT.jar,
- lib/cdmlib-io-3.4.0-SNAPSHOT-sources.jar,
- lib/cdmlib-io-3.4.0-SNAPSHOT.jar,
- lib/cdmlib-model-3.4.0-SNAPSHOT-sources.jar,
- lib/cdmlib-model-3.4.0-SNAPSHOT.jar,
- lib/cdmlib-persistence-3.4.0-SNAPSHOT-sources.jar,
- lib/cdmlib-persistence-3.4.0-SNAPSHOT.jar,
- lib/cdmlib-print-3.4.0-SNAPSHOT-sources.jar,
- lib/cdmlib-print-3.4.0-SNAPSHOT.jar,
- lib/cdmlib-remote-3.4.0-SNAPSHOT-sources.jar,
- lib/cdmlib-remote-3.4.0-SNAPSHOT.jar,
- lib/cdmlib-services-3.4.0-SNAPSHOT-sources.jar,
- lib/cdmlib-services-3.4.0-SNAPSHOT.jar
+ lib/cdmlib-commons-3.5.0-SNAPSHOT-sources.jar,
+ lib/cdmlib-commons-3.5.0-SNAPSHOT.jar,
+ lib/cdmlib-ext-3.5.0-SNAPSHOT-sources.jar,
+ lib/cdmlib-ext-3.5.0-SNAPSHOT.jar,
+ lib/cdmlib-io-3.5.0-SNAPSHOT-sources.jar,
+ lib/cdmlib-io-3.5.0-SNAPSHOT.jar,
+ lib/cdmlib-model-3.5.0-SNAPSHOT-sources.jar,
+ lib/cdmlib-model-3.5.0-SNAPSHOT.jar,
+ lib/cdmlib-persistence-3.5.0-SNAPSHOT-sources.jar,
+ lib/cdmlib-persistence-3.5.0-SNAPSHOT.jar,
+ lib/cdmlib-print-3.5.0-SNAPSHOT-sources.jar,
+ lib/cdmlib-print-3.5.0-SNAPSHOT.jar,
+ lib/cdmlib-remote-3.5.0-SNAPSHOT-sources.jar,
+ lib/cdmlib-remote-3.5.0-SNAPSHOT.jar,
+ lib/cdmlib-services-3.5.0-SNAPSHOT-sources.jar,
+ lib/cdmlib-services-3.5.0-SNAPSHOT.jar
lib/odfdom-0.8.jar,\\r
lib/h2mig_pagestore_addon.jar,\\r
lib/spring-security-remoting-3.1.3.RELEASE.jar,\\r
- lib/cdmlib-commons-3.4.0-SNAPSHOT-sources.jar,\\r
- lib/cdmlib-commons-3.4.0-SNAPSHOT.jar,\\r
- lib/cdmlib-ext-3.4.0-SNAPSHOT-sources.jar,\\r
- lib/cdmlib-ext-3.4.0-SNAPSHOT.jar,\\r
- lib/cdmlib-io-3.4.0-SNAPSHOT-sources.jar,\\r
- lib/cdmlib-io-3.4.0-SNAPSHOT.jar,\\r
- lib/cdmlib-model-3.4.0-SNAPSHOT-sources.jar,\\r
- lib/cdmlib-model-3.4.0-SNAPSHOT.jar,\\r
- lib/cdmlib-persistence-3.4.0-SNAPSHOT-sources.jar,\\r
- lib/cdmlib-persistence-3.4.0-SNAPSHOT.jar,\\r
- lib/cdmlib-print-3.4.0-SNAPSHOT-sources.jar,\\r
- lib/cdmlib-print-3.4.0-SNAPSHOT.jar,\\r
- lib/cdmlib-remote-3.4.0-SNAPSHOT-sources.jar,\\r
- lib/cdmlib-remote-3.4.0-SNAPSHOT.jar,\\r
- lib/cdmlib-services-3.4.0-SNAPSHOT-sources.jar,\\r
- lib/cdmlib-services-3.4.0-SNAPSHOT.jar,\\r
lib/spring-security-remoting-3.1.3.RELEASE.jar,\\r
lib/jena-core-2.11.2.jar,\\r
- lib/jena-iri-1.0.2.jar\r
+ lib/jena-iri-1.0.2.jar,\\r
+ lib/cdmlib-commons-3.5.0-SNAPSHOT-sources.jar,\\r
+ lib/cdmlib-commons-3.5.0-SNAPSHOT.jar,\\r
+ lib/cdmlib-ext-3.5.0-SNAPSHOT-sources.jar,\\r
+ lib/cdmlib-ext-3.5.0-SNAPSHOT.jar,\\r
+ lib/cdmlib-io-3.5.0-SNAPSHOT-sources.jar,\\r
+ lib/cdmlib-io-3.5.0-SNAPSHOT.jar,\\r
+ lib/cdmlib-model-3.5.0-SNAPSHOT-sources.jar,\\r
+ lib/cdmlib-model-3.5.0-SNAPSHOT.jar,\\r
+ lib/cdmlib-persistence-3.5.0-SNAPSHOT-sources.jar,\\r
+ lib/cdmlib-persistence-3.5.0-SNAPSHOT.jar,\\r
+ lib/cdmlib-print-3.5.0-SNAPSHOT-sources.jar,\\r
+ lib/cdmlib-print-3.5.0-SNAPSHOT.jar,\\r
+ lib/cdmlib-remote-3.5.0-SNAPSHOT-sources.jar,\\r
+ lib/cdmlib-remote-3.5.0-SNAPSHOT.jar,\\r
+ lib/cdmlib-services-3.5.0-SNAPSHOT-sources.jar,\\r
+ lib/cdmlib-services-3.5.0-SNAPSHOT.jar\r
jars.compile.order = .\r
output.. = bin/\r
source.. = src/main/java/,\\r
eu.etaxonomy.taxeditor.editor.internal,
eu.etaxonomy.taxeditor.editor.name,
eu.etaxonomy.taxeditor.editor.name.handler,
+ eu.etaxonomy.taxeditor.editor.view.concept,
eu.etaxonomy.taxeditor.editor.view.dataimport,
eu.etaxonomy.taxeditor.editor.view.descriptive,
eu.etaxonomy.taxeditor.editor.view.media,
bin.includes = META-INF/,\
.,\
plugin.xml,\
- OSGI-INF/l10n/plugin.properties,\
icons/,\
p2.inf,\
+ OSGI-INF/l10n/plugin.properties,\
OSGI-INF/l10n/plugin_de.properties,\
OSGI-INF/l10n/plugin_en.properties
</editor>
<editor
class="eu.etaxonomy.taxeditor.editor.view.checklist.ChecklistEditor"
- icon="icons/address-book-new.png"
+ icon="icons/check.png"
id="eu.etaxonomy.taxeditor.editor.view.checklist.ChecklistEditor"
name="%editor.name.8">
</editor>
import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
import eu.etaxonomy.cdm.api.conversation.IConversationEnabled;
+import eu.etaxonomy.cdm.api.service.ITaxonService;
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
import eu.etaxonomy.cdm.model.common.CdmBase;
import eu.etaxonomy.cdm.model.name.HomotypicalGroup;
* </p>
*/
public void createOrUpdateNameComposites() {
-
+ this.taxon = (Taxon)CdmStore.getService(ITaxonService.class).load(this.getTaxon().getUuid());
ContainerFactory.createOrUpdateAcceptedTaxonsHomotypicGroup(this);
ContainerFactory.createOrUpdateHeterotypicSynonymyGroups(this);
ContainerFactory.createOrUpdateMisapplicationsGroup(this);
/**
- *
+ *
*/
package eu.etaxonomy.taxeditor.editor.name.dnd;
import org.eclipse.core.runtime.Assert;
+import org.eclipse.swt.SWTException;
import org.eclipse.swt.dnd.DND;
import org.eclipse.swt.dnd.DropTargetAdapter;
import org.eclipse.swt.dnd.DropTargetEvent;
import eu.etaxonomy.cdm.model.common.ICdmBase;
import eu.etaxonomy.cdm.model.name.HomotypicalGroup;
+import eu.etaxonomy.cdm.model.reference.Reference;
import eu.etaxonomy.cdm.model.taxon.Synonym;
+import eu.etaxonomy.cdm.model.taxon.SynonymRelationship;
+import eu.etaxonomy.cdm.model.taxon.SynonymRelationshipType;
import eu.etaxonomy.cdm.model.taxon.Taxon;
import eu.etaxonomy.cdm.model.taxon.TaxonBase;
import eu.etaxonomy.cdm.model.taxon.TaxonRelationshipType;
import eu.etaxonomy.taxeditor.editor.IDropTargetable;
import eu.etaxonomy.taxeditor.editor.name.TaxonNameEditor;
import eu.etaxonomy.taxeditor.editor.name.container.AbstractHomotypicalGroupContainer;
+import eu.etaxonomy.taxeditor.editor.name.container.HomotypicalSynonymGroup;
import eu.etaxonomy.taxeditor.editor.name.container.MisappliedGroup;
import eu.etaxonomy.taxeditor.editor.name.operation.ChangeConceptRelationshipTypeOperation;
import eu.etaxonomy.taxeditor.editor.name.operation.ChangeConceptToSynonymOperation;
import eu.etaxonomy.taxeditor.editor.name.operation.ChangeHomotypicGroupOperation;
import eu.etaxonomy.taxeditor.editor.name.operation.ChangeSynonymToMisapplicationOperation;
+import eu.etaxonomy.taxeditor.editor.name.operation.MoveSynonymToAnotherAcceptedTaxonOperation;
import eu.etaxonomy.taxeditor.model.MessagingUtils;
import eu.etaxonomy.taxeditor.operation.AbstractPostOperation;
* @version $Id: $
*/
public class NameEditorDropTargetListener extends DropTargetAdapter {
-
- private final IDropTargetable target;
-
- /**
- * <p>Constructor for NameEditorDropTargetListener.</p>
- *
- * @param target a {@link eu.etaxonomy.taxeditor.editor.IDropTargetable} object.
- */
- public NameEditorDropTargetListener(IDropTargetable target){
- this.target = target;
- }
-
- /** {@inheritDoc} */
- @Override
- public void dragEnter(DropTargetEvent dropTargetEvent) {
- target.dragEntered();
-
-// if(! EditorUtil.getActiveMultiPageTaxonEditor().equals(editor.getMultiPageTaxonEditor())){
-// editor.getMultiPageTaxonEditor().setFocus();
-// }
- }
-
- /** {@inheritDoc} */
- @Override
- public void dragLeave(DropTargetEvent dropTargetEvent) {
- target.dragLeft();
- }
-
- /** {@inheritDoc} */
- @Override
- public void drop(DropTargetEvent dropTargetEvent) {
-
- TaxonBase taxonBase = getDroppedTaxonBase(dropTargetEvent);
-
- Assert.isNotNull(taxonBase);
-
- if(taxonBase.getHomotypicGroup().equals(getHomotypicalGroup())){
- // do nothing when dragged to the same group
- dropTargetEvent.detail = DND.DROP_NONE;
- return;
- }
-
- // Execute operations at end of drag event
- AbstractPostOperation operation = createOperation(taxonBase);
-
- // Execute operation if it has been initiated
- if (operation == null) {
- MessagingUtils.warn(getClass(), "User unsuccessfully tried to drop: " + taxonBase.getClass() +
- ". Target: " + target);
- dropTargetEvent.detail = DND.DROP_NONE;
- } else {
- EditorUtil.executeOperation(operation);
- }
- }
-
- private AbstractPostOperation createOperation(TaxonBase taxonBase) {
-
- if(taxonBase instanceof Synonym){
- Synonym synonym = (Synonym) taxonBase;
-
- if(target instanceof AbstractHomotypicalGroupContainer){
- HomotypicalGroup homotypicalGroup = ((AbstractHomotypicalGroupContainer) target).getGroup();
-
- return new ChangeHomotypicGroupOperation("Change Homotypical Group", getEditor().getUndoContext(),
- getEditor().getTaxon(), synonym, homotypicalGroup, target);
- }
- else if(target instanceof MisappliedGroup){
- return new ChangeSynonymToMisapplicationOperation("Change Synonym to Misapplication", getEditor().getUndoContext(),
- getEditor().getTaxon(), synonym, target);
- }
- else if(target instanceof TaxonNameEditor){
- return new ChangeHomotypicGroupOperation("Change Homotypical Group", getEditor().getUndoContext(),
- getEditor().getTaxon(), synonym, null, target);
- }
-
- }else if(taxonBase instanceof Taxon){
- Taxon concept = (Taxon) taxonBase;
-
- if(target instanceof AbstractHomotypicalGroupContainer){
- HomotypicalGroup homotypicalGroup = ((AbstractHomotypicalGroupContainer) target).getGroup();
-
- return new ChangeConceptToSynonymOperation("Change to Synonym", getEditor().getUndoContext(),
- getEditor().getTaxon(), concept, homotypicalGroup, target);
- }
- else if(target instanceof MisappliedGroup ){
- return new ChangeConceptRelationshipTypeOperation("Change", getEditor().getUndoContext(),
- getEditor().getTaxon(), concept, TaxonRelationshipType.MISAPPLIED_NAME_FOR(), target);
- }
- }
-
-
- return null;
- }
-
- /** {@inheritDoc} */
- @Override
- public void dropAccept(DropTargetEvent event) {
- // pass
- }
-
-
- private HomotypicalGroup getHomotypicalGroup() {
- if(target instanceof AbstractHomotypicalGroupContainer){
- return ((AbstractHomotypicalGroupContainer) target).getGroup();
- }
- return null;
- }
-
- private TaxonBase getDroppedTaxonBase(DropTargetEvent dropTargetEvent){
- if(dropTargetEvent.data instanceof ICdmBase[]){
-
- ICdmBase[] cdmBaseObjects = (ICdmBase[]) dropTargetEvent.data;
-
- if(cdmBaseObjects[0] instanceof TaxonBase){
- return (TaxonBase) cdmBaseObjects[0];
- }
- }
- return null;
- }
-
- /**
- * @return
- *
- */
- private TaxonNameEditor getEditor() {
- return target.getEditor();
- }
+
+ private IDropTargetable target;
+
+
+ /**
+ * <p>Constructor for NameEditorDropTargetListener.</p>
+ *
+ * @param target a {@link eu.etaxonomy.taxeditor.editor.IDropTargetable} object.
+ */
+ public NameEditorDropTargetListener(IDropTargetable target){
+ this.target = target;
+ }
+
+ /** {@inheritDoc} */
+ public void dragEnter(DropTargetEvent dropTargetEvent) {
+ target.dragEntered();
+
+// if(! EditorUtil.getActiveMultiPageTaxonEditor().equals(editor.getMultiPageTaxonEditor())){
+// editor.getMultiPageTaxonEditor().setFocus();
+// }
+ }
+
+ /** {@inheritDoc} */
+ public void dragLeave(DropTargetEvent dropTargetEvent) {
+ target.dragLeft();
+ }
+
+ /** {@inheritDoc} */
+ public void drop(DropTargetEvent dropTargetEvent) {
+
+ TaxonBase taxonBase = getDroppedTaxonBase(dropTargetEvent);
+
+ Assert.isNotNull(taxonBase);
+
+ if(taxonBase.getHomotypicGroup().equals(getHomotypicalGroup())){
+ // do nothing when dragged to the same group
+ dropTargetEvent.detail = DND.DROP_NONE;
+ return;
+ }
+
+ // Execute operations at end of drag event
+ AbstractPostOperation operation = createOperation(taxonBase);
+
+ // Execute operation if it has been initiated
+ if (operation == null) {
+ MessagingUtils.warn(getClass(), "User unsuccessfully tried to drop: " + taxonBase.getClass() +
+ ". Target: " + target);
+ dropTargetEvent.detail = DND.DROP_NONE;
+ } else {
+ EditorUtil.executeOperation(operation);
+ }
+ target.getEditor().getConversationHolder().commit();
+ if (!target.equals(EditorUtil.getActiveMultiPageTaxonEditor().getActiveEditor())){
+ ((TaxonNameEditor)EditorUtil.getActiveMultiPageTaxonEditor().getActiveEditor()).redraw();
+ ((TaxonNameEditor)EditorUtil.getActiveMultiPageTaxonEditor().getActiveEditor()).getConversationHolder().commit();
+
+ }
+ target.getEditor().redraw();
+
+ }
+
+ private AbstractPostOperation createOperation(TaxonBase taxonBase) {
+
+ if(taxonBase instanceof Synonym){
+ Synonym synonym = (Synonym) taxonBase;
+
+ if(target instanceof AbstractHomotypicalGroupContainer){
+ HomotypicalGroup homotypicalGroup = ((AbstractHomotypicalGroupContainer) target).getGroup();
+
+ return new ChangeHomotypicGroupOperation("Change Homotypical Group", getEditor().getUndoContext(),
+ getEditor().getTaxon(), synonym, homotypicalGroup, target);
+ }
+ else if(target instanceof MisappliedGroup){
+ return new ChangeSynonymToMisapplicationOperation("Change Synonym to Misapplication", getEditor().getUndoContext(),
+ getEditor().getTaxon(), synonym, target);
+ }
+ else if(target instanceof TaxonNameEditor){
+ if (target.equals(getEditor())){
+ return new ChangeHomotypicGroupOperation("Change Homotypical Group", getEditor().getUndoContext(),
+ getEditor().getTaxon(), synonym, null, target);
+ } else{
+ getEditor().getConversationHolder().commit();
+ ((TaxonNameEditor) target).getConversationHolder().commit();
+
+ return new MoveSynonymToAnotherAcceptedTaxonOperation("Change accepted Taxon", getEditor().getUndoContext(), getEditor().getTaxon().getUuid(), synonym.getUuid(), ((TaxonNameEditor) target).getTaxon(), null );
+
+ }
+ }
+
+ }else if(taxonBase instanceof Taxon){
+ Taxon concept = (Taxon) taxonBase;
+
+ if(target instanceof AbstractHomotypicalGroupContainer){
+ HomotypicalGroup homotypicalGroup = ((AbstractHomotypicalGroupContainer) target).getGroup();
+
+ return new ChangeConceptToSynonymOperation("Change to Synonym", getEditor().getUndoContext(),
+ getEditor().getTaxon(), concept, homotypicalGroup, target);
+ }
+ else if(target instanceof MisappliedGroup ){
+ return new ChangeConceptRelationshipTypeOperation("Change", getEditor().getUndoContext(),
+ getEditor().getTaxon(), concept, TaxonRelationshipType.MISAPPLIED_NAME_FOR(), target);
+ }
+ }
+
+
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public void dropAccept(DropTargetEvent event) {
+ // pass
+ }
+
+
+ private HomotypicalGroup getHomotypicalGroup() {
+ if(target instanceof AbstractHomotypicalGroupContainer){
+ return ((AbstractHomotypicalGroupContainer) target).getGroup();
+ }
+ return null;
+ }
+
+ private TaxonBase getDroppedTaxonBase(DropTargetEvent dropTargetEvent){
+ if(dropTargetEvent.data instanceof ICdmBase[]){
+
+ ICdmBase[] cdmBaseObjects = (ICdmBase[]) dropTargetEvent.data;
+
+ if(cdmBaseObjects[0] instanceof TaxonBase){
+ return (TaxonBase) cdmBaseObjects[0];
+ }
+ }
+ return null;
+ }
+
+ /**
+ * @return
+ *
+ */
+ private TaxonNameEditor getEditor() {
+ return (TaxonNameEditor) EditorUtil.getActiveMultiPageTaxonEditor().getActiveEditor();
+ }
}
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Menu;
+import org.eclipse.swt.widgets.MenuItem;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.swt.widgets.Text;
import eu.etaxonomy.taxeditor.editor.EditorUtil;
import eu.etaxonomy.taxeditor.editor.SimpleSelectionProvider;
import eu.etaxonomy.taxeditor.editor.view.checklist.edit.DistributionEditingSupport;
-import eu.etaxonomy.taxeditor.editor.view.checklist.edit.RankEditingSupport;
import eu.etaxonomy.taxeditor.editor.view.checklist.filter.ChecklistEditorFilter;
import eu.etaxonomy.taxeditor.editor.view.checklist.listener.ChecklistDropdownSelectionListener;
import eu.etaxonomy.taxeditor.editor.view.checklist.listener.ChecklistFocusListener;
@Override
public void run() {
- viewer.setInput(taxonList);
+ viewer.setInput(taxonList);
}
});
monitor.worked(1);
private Label statusLabel;
private SortedSet<DefinedTermBase> terms = null;
+ private ToolItem toolItem;
+ private ChecklistDropdownSelectionListener dropListener;
/**
* @return the selectedTaxonNodes
parent.setLayout(gridLayout);
final Text searchText = createSearchBar(parent);
-
-// if (terms != null && !terms.isEmpty()) {
- createToolbar(parent);
-// }
+ createToolbar(parent);
viewer = new TableViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION);
getSite().setSelectionProvider(viewer);
searchText.addFocusListener(new ChecklistFocusListener(searchText, modifyListener));
searchText.addModifyListener(modifyListener);
-
- // Layout the viewer
- GridData gridData = new GridData();
- gridData.verticalAlignment = GridData.FILL;
- gridData.horizontalSpan = 3;
- gridData.grabExcessHorizontalSpace = true;
- gridData.grabExcessVerticalSpace = true;
- gridData.horizontalAlignment = GridData.FILL;
- viewer.getControl().setLayoutData(gridData);
+ createGridDataForViewerLayout();
viewer.addFilter(filter);
- createColumns(viewer);
+ createTable();
viewer.setContentProvider(new ChecklistContentProvider());
- viewer.setLabelProvider(new ChecklistLabelProvider());
+ viewer.setLabelProvider(new ChecklistLabelProvider(viewer));
comparator = new ChecklistEditorComparator();
viewer.setComparator(comparator);
createStatusBar(parent);
}
+ private void createGridDataForViewerLayout() {
+ GridData gridData = new GridData();
+ gridData.verticalAlignment = GridData.FILL;
+ gridData.horizontalSpan = 3;
+ gridData.grabExcessHorizontalSpace = true;
+ gridData.grabExcessVerticalSpace = true;
+ gridData.horizontalAlignment = GridData.FILL;
+ viewer.getControl().setLayoutData(gridData);
+ }
+
/**
* @param parent
* @return
*/
private void createToolbar(Composite parent) {
ToolBar toolBar = new ToolBar(parent, SWT.NONE);
- ToolItem toolItem = new ToolItem(toolBar, SWT.DROP_DOWN | SWT.BORDER);
+ toolItem = new ToolItem(toolBar, SWT.DROP_DOWN | SWT.BORDER);
toolItem.setText("Distribution Status");
toolItem.setToolTipText("Show Distribution Status for selected Areas");
- ChecklistDropdownSelectionListener dropListener = new ChecklistDropdownSelectionListener(toolItem, this, terms);
+ createToolbarItems();
+ toolItem.addSelectionListener(dropListener);
+ toolBar.pack();
+ }
+
+ private void createToolbarItems() {
+ dropListener = new ChecklistDropdownSelectionListener(toolItem, this, terms);
for (DefinedTermBase<DefinedTermBase> term : terms) {
if(term!=null){
dropListener.add(term);
}
}
- toolItem.addSelectionListener(dropListener);
- toolBar.pack();
- }
+ }
private void createStatusBar(Composite composite) {
GridData gridData = new GridData();
statusLabel.setLayoutData(gridData);
}
- // This will create the columns for the table
- private void createColumns(TableViewer viewer) {
- Table table = viewer.getTable();
+ private void createTable() {
+ Table table = viewer.getTable();//new Table(parent, viewer.getTable().getStyle());
List<String> titles = new ArrayList<String>();
Collections.addAll(titles, "Taxon", "Author", "Reference", "Rank");
List<Integer> bounds = new ArrayList<Integer>();
Collections.addAll(bounds, 300, 200, 200, 200);
- Map<Integer, Boolean>restoreColumnWidth = new HashMap<Integer, Boolean>();
- if (terms != null) {
- int i = 4;
- for (DefinedTermBase<DefinedTermBase> term : terms) {
- if(term != null){
- restoreColumnWidth.put(i, PreferencesUtil.getPreferenceStore().getBoolean(term.getUuid().toString()));
- titles.add(term.getTitleCache());
- bounds.add(200);
- i++;
- }
- }
- }
-
- for (int i = 0; i < titles.size(); i++) {
+ Map<Integer, Boolean> restoreValuesForColumnWidth = restoreValuesForColumnWidth(titles, bounds);
+ createInitalDistributionColumns(table, titles, bounds, restoreValuesForColumnWidth);
+ table.setSortDirection(SWT.DOWN);
+ table.setHeaderVisible(true);
+ table.setLinesVisible(true);
+ }
+ /**
+ * This method creates initially the distribution columns for a table. It should only be called for creation.<br>
+ *<p>
+ *
+ *<b>Notice:</b> If you want to add additional columns later please use <b>addTableViewerColumn()</b>
+ *
+ * @param table
+ * @param titles
+ * @param bounds
+ * @param restoreValuesForColumnWidth
+ */
+ private void createInitalDistributionColumns(Table table,
+ List<String> titles, List<Integer> bounds,
+ Map<Integer, Boolean> restoreValuesForColumnWidth) {
+ for (int columnIndex = 0; columnIndex < titles.size(); columnIndex++) {
TableViewerColumn column = new TableViewerColumn(viewer, SWT.NONE);
- column.getColumn().setText(titles.get(i));
- column.getColumn().setWidth(bounds.get(i));
+ column.getColumn().setText(titles.get(columnIndex));
+ column.getColumn().setWidth(bounds.get(columnIndex));
column.getColumn().setResizable(true);
column.getColumn().setMoveable(true);
- column.getColumn().addSelectionListener(getSelectionAdapter(column.getColumn(), i));
- if (i == 1) {
+ column.getColumn().addSelectionListener(getSelectionAdapter(column.getColumn(), columnIndex));
+ if (columnIndex == 1) {
table.setSortColumn(column.getColumn());
}
- if (i == 3) {
- column.setEditingSupport(new RankEditingSupport(viewer, this));
+ if (columnIndex == 3) {
+ /** uncommented it for now because no rank editing is wanted **/
+// column.setEditingSupport(new RankEditingSupport(viewer, this));
}
- if (i >= 4) {
+ if (columnIndex >= 4) {
//read PrefrenceStore to setWidth according to last saved state
- if(restoreColumnWidth.get(i)){
+ if(restoreValuesForColumnWidth.get(columnIndex)){
column.getColumn().setWidth(100);
}else{
column.getColumn().setWidth(0);
}
- column.setEditingSupport(new DistributionEditingSupport(viewer, this, i));
+ column.setEditingSupport(new DistributionEditingSupport(viewer, this, columnIndex));
}
}
- table.setSortDirection(SWT.DOWN);
- table.setHeaderVisible(true);
- table.setLinesVisible(true);
- }
+ }
+
+ /**
+ * This methods loads the last opened distribution columns for the table viewer from the prefrence store.<br>
+ *<p>
+ * <b>Notice:</b> It adds also the TitleCache to the titles list for the header of each column.<p>
+ *
+ * @param titles
+ * @param bounds
+ * @return Map<Integer, Boolean>
+ */
+ private Map<Integer, Boolean> restoreValuesForColumnWidth(List<String> titles,
+ List<Integer> bounds) {
+ Map<Integer, Boolean> restoreColumnWidth = new HashMap<Integer, Boolean>();
+ if (terms != null) {
+ int columnIndex = 4;
+ for (DefinedTermBase<DefinedTermBase> term : terms) {
+ if(term != null){
+ restoreColumnWidth.put(columnIndex, PreferencesUtil.getPreferenceStore().getBoolean(term.getUuid().toString()));
+ titles.add(term.getTitleCache());
+ bounds.add(200);
+ columnIndex++;
+ }
+ }
+ }
+ return restoreColumnWidth;
+ }
+ /**
+ * This method adds new DistributionColumns to an existing table.
+ *
+ * @param title
+ * @param bound
+ * @param colNumber
+ * @return
+ */
+ private TableViewerColumn addTableViewerColumn(String title, int bound, final int colNumber) {
+ final TableViewerColumn viewerColumn = new TableViewerColumn(viewer, SWT.NONE);
+ final TableColumn column = viewerColumn.getColumn();
+ column.setText(title);
+ column.setWidth(200);
+ viewerColumn.setEditingSupport(new DistributionEditingSupport(viewer, this, colNumber));
+ column.setResizable(true);
+ column.setMoveable(true);
+ return viewerColumn;
+ }
+
+
+
/**
*
* pull data from database and set input for view
viewer.refresh();
}
+ /**
+ * This method should only be called for adding new Distribution columns and reloading the table.<br>
+ * It will hide the old distribution column and load the newly added columns.<br>
+ * <p>
+ * <b>Notice:</b> for data update please use <b>refresh()</b>
+ *
+ */
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ public void reload(){
+ //create new Items for Dropdown menue
+ Table table = viewer.getTable();
+ table.setRedraw(false);
+ SortedSet<DefinedTermBase> oldTerms = terms;
+ ChecklistLabelProvider labelProvider = new ChecklistLabelProvider();
+ terms = (SortedSet<DefinedTermBase>) labelProvider.getTermsOrderedByLabels(labelProvider.getNamedAreas(), CdmStore.getDefaultLanguage());
+ SortedSet<DefinedTermBase> newTerms = terms;
+ toolItem.removeSelectionListener(dropListener);
+ hideDistributionColumns(oldTerms);
+ createToolbarItems();
+ toolItem.addSelectionListener(dropListener);
+ for(DefinedTermBase term:newTerms){
+ int count = viewer.getTable().getColumnCount();
+ addTableViewerColumn(term.getTitleCache(), 200, count);
+ acitivateNewColumnInDropDownMenu(term);
+ }
+ viewer.setLabelProvider(new ChecklistLabelProvider(viewer));
+ getService().schedule(new ChecklistJob("loading Taxa", selectedTaxonNodes), Job.LONG);
+ table.setRedraw(true);
+ viewer.refresh();
+ }
+
+ private void acitivateNewColumnInDropDownMenu(DefinedTermBase term) {
+ Menu menu = dropListener.getMenu();
+ MenuItem[] items = menu.getItems();
+ for(MenuItem item: items){
+ if(item.getText().equalsIgnoreCase(term.getTitleCache())){
+ item.setSelection(true);
+ PreferencesUtil.getPreferenceStore().setValue(term.getUuid().toString(), true);
+ }
+ }
+ }
+
+ private void hideDistributionColumns(SortedSet<DefinedTermBase> oldTerms) {
+ TableColumn[] columns = viewer.getTable().getColumns();
+ for(int i=4; i<columns.length; i++){
+ //remove all columns
+ columns[i].dispose();
+ Menu menu = dropListener.getMenu();
+ int itemCount = menu.getItemCount();
+ MenuItem item = menu.getItem(i-3);
+ item.setSelection(false);
+ }
+ if(oldTerms != null){
+ for(DefinedTermBase term : oldTerms){
+ PreferencesUtil.getPreferenceStore().setValue(term.getUuid().toString(), false);
+ }
+ }
+ }
+
/**
* <p>
* Getter for the field <code>service</code>.
@Override
public void doSaveAs() {
- // TODO Auto-generated method stub
-
}
@Override
@Override
public boolean isSaveAsAllowed() {
- // TODO Auto-generated method stub
return false;
}
*/
@Override
public void selectionChanged(IWorkbenchPart part, ISelection selection) {
- // TODO Auto-generated method stub
-
}
/*
*/
@Override
public void contextStop(IMemento memento, IProgressMonitor monitor) {
- // TODO Auto-generated method stub
// IStructuredSelection sel = (IStructuredSelection) this.viewer.getSelection();
// if (sel.isEmpty()) {
// return;
*/
@Override
public void contextRefresh(IProgressMonitor monitor) {
- // TODO Auto-generated method stub
-
}
/*
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.viewers.ITableLabelProvider;
import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.TableColumn;
import eu.etaxonomy.cdm.api.service.IDescriptionService;
import eu.etaxonomy.cdm.api.service.ITermService;
*/
public class ChecklistLabelProvider extends LabelProvider implements ITableLabelProvider {
- public static final String DEFAULT_ENTRY = "-";
+ public static final String DEFAULT_ENTRY = "";
private IDescriptionService descriptionService;
private final List<DefinedTermBase<?>> namedAreas;
-
-
+ TableViewer viewer = null;
/**
*
namedAreas = loadNamedAreas();
}
+ public ChecklistLabelProvider(TableViewer viewer) {
+ namedAreas = loadNamedAreas();
+ this.viewer = viewer;
+ }
+
/*
* (non-Javadoc)
*
* .Object, int)
*/
/** {@inheritDoc} */
- @Override
+ @Override
public String getColumnText(Object element, int columnIndex) {
descriptionService = CdmStore.getService(IDescriptionService.class);
Taxon taxon = (Taxon) element;
//TODO load areas by this list
- SortedSet<DefinedTermBase<?>> sortedNamedAreas = (SortedSet<DefinedTermBase<?>>) getTermsOrderedByLabels(namedAreas, CdmStore.getDefaultLanguage());
List<TaxonDescription> listTaxonDescriptions = descriptionService.listTaxonDescriptions(taxon, null, null, null, null, null, DESC_INIT_STRATEGY);;
NonViralName<?> nonVirlaName = HibernateProxyHelper.deproxy(taxon.getName(), NonViralName.class);
if (deb instanceof Distribution) {
Distribution distribution = (Distribution) deb;
String area = distribution.toString();
- if(sortedNamedAreas != null){
- Object[] array = sortedNamedAreas.toArray();
- DefinedTermBase<DefinedTermBase> term = (DefinedTermBase<DefinedTermBase>) array[columnIndex-4];
- if(term != null){
- if (area.equalsIgnoreCase(term.getTitleCache())) {
- return (distribution.getStatus().getTitleCache() != null)?distribution.getStatus().getTitleCache():DEFAULT_ENTRY;
- }
- }
+ if(viewer != null){
+ TableColumn column = viewer.getTable().getColumn(columnIndex);
+ if (area.equalsIgnoreCase(column.getText())) {
+ return (distribution.getStatus().getTitleCache() != null)?distribution.getStatus().getTitleCache():DEFAULT_ENTRY;
+ }
}
}
}
import eu.etaxonomy.cdm.api.service.IDescriptionService;
import eu.etaxonomy.cdm.model.common.DefinedTermBase;
+import eu.etaxonomy.cdm.model.common.TermType;
import eu.etaxonomy.cdm.model.description.DescriptionElementBase;
import eu.etaxonomy.cdm.model.description.Distribution;
import eu.etaxonomy.cdm.model.description.PresenceAbsenceTermBase;
cellEditor.setLabelProvider(new LabelProvider());
cellEditor.setContentProvider(new ArrayContentProvider());
// TODO set input
- List<PresenceAbsenceTermBase> input = CdmStore.getTermManager()
- .getPreferredTerms(PresenceAbsenceTermBase.class);
+// List<PresenceAbsenceTermBase> input = CdmStore.getTermManager()
+// .getPreferredTerms(PresenceAbsenceTermBase.class);
+ List<DefinedTermBase<?>> input = CdmStore.getTermManager().getPreferredTerms(TermType.PresenceAbsenceTerm);
cellEditor.setInput(input);
}
@Override
protected void setValue(Object element, Object value) {
- if (element instanceof Taxon && value instanceof PresenceAbsenceTermBase) {
+ if (element instanceof Taxon && value instanceof PresenceAbsenceTermBase) {
Taxon taxon = (Taxon) element;
PresenceAbsenceTermBase occurenceStatus = (PresenceAbsenceTermBase) value;
Distribution distribution = getDistributionForColumn(taxon);
import java.util.SortedSet;
+import org.apache.log4j.Logger;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.jface.wizard.WizardDialog;
import org.eclipse.swt.SWT;
public class ChecklistDropdownSelectionListener extends SelectionAdapter {
private final Menu menu;
- private final ToolItem dropdown;
private final ChecklistEditor editor;
private final SortedSet<DefinedTermBase> termSet;
-
+ private Logger logger = Logger.getLogger(ChecklistDropdownSelectionListener.class);
+
public ChecklistDropdownSelectionListener(ToolItem dropdown, ChecklistEditor editor,
SortedSet<DefinedTermBase> termSet) {
- this.dropdown = dropdown;
this.editor = editor;
this.termSet = termSet;
menu = new Menu(dropdown.getParent().getShell());
TableColumn column = null;
DefinedTermBase<DefinedTermBase> selectedTerm = null;
if (termSet != null) {
- int i = 0;
- for (DefinedTermBase<DefinedTermBase> term : termSet) {
- if (term != null) {
- if (selected.getText().equalsIgnoreCase(term.getTitleCache())) {
- selectedTerm = term;
- column = table.getColumn(4 + i);
- }
- i++;
- }
- }
+ TableColumn[] columns = viewer.getTable().getColumns();
+ for(int i=0; i<columns.length; i++){
+ if(selected.getText().equalsIgnoreCase(columns[i].getText())){
+ column = columns[i];
+ logger.info("Column no " +i +" Column Header "+ column.getText() );
+ for (DefinedTermBase<DefinedTermBase> term : termSet) {
+ if(column.getText().equalsIgnoreCase(term.getTitleCache())){
+ selectedTerm = term;
+ break;
+ }
+ }
+ }
+ }
}
if (column != null && column.getWidth() == 0) {
// save column status if shown or not
}
column.setWidth(0);
}
- viewer.refresh();
}
});
}
WizardDialog dialog = new WizardDialog(StoreUtil.getShell(),
availableDistributionWizard);
- dialog.open();
+ int open = dialog.open();
+ if(open == 0){
+ editor.reload();
+ }
}
});
new MenuItem(menu, SWT.SEPARATOR);
menu.setVisible(true);
}
}
+
+ public Menu getMenu(){
+ return menu;
+ }
}
\ No newline at end of file
// $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.ui.IWorkbenchPart;
import org.eclipse.ui.handlers.HandlerUtil;
+import eu.etaxonomy.cdm.model.description.DescriptionBase;
import eu.etaxonomy.cdm.model.description.DescriptionElementBase;
import eu.etaxonomy.cdm.model.description.TaxonDescription;
import eu.etaxonomy.cdm.model.media.Media;
import eu.etaxonomy.taxeditor.editor.view.descriptive.operation.DeleteDescriptionElementOperation;
import eu.etaxonomy.taxeditor.editor.view.descriptive.operation.DeleteTaxonDescriptionOperation;
import eu.etaxonomy.taxeditor.editor.view.media.operation.DeleteMediaOperation;
+import eu.etaxonomy.taxeditor.model.AbstractUtility;
import eu.etaxonomy.taxeditor.model.FeatureNodeContainer;
import eu.etaxonomy.taxeditor.model.MessagingUtils;
-import eu.etaxonomy.taxeditor.operation.AbstractPostTaxonOperation;
import eu.etaxonomy.taxeditor.operation.AbstractPostOperation;
+import eu.etaxonomy.taxeditor.operation.AbstractPostTaxonOperation;
import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
/**
* @version 1.0
*/
public class DeleteHandler extends AbstractHandler {
-
+
/* (non-Javadoc)
* @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 {
IStructuredSelection selection = (IStructuredSelection) HandlerUtil.getActiveSite(event).getSelectionProvider().getSelection();
IWorkbenchPart part = HandlerUtil.getActivePart(event);
IPostOperationEnabled postOperationEnabled = (part instanceof IPostOperationEnabled) ? (IPostOperationEnabled) part : null;
-
+
try {
String label = event.getCommand().getName();
-
+
IUndoContext undoContext = EditorUtil.getUndoContext();
-
+
List<AbstractPostTaxonOperation> operations = new ArrayList<AbstractPostTaxonOperation>();
-
+
for(Object object : selection.toArray()){
-
+
AbstractPostOperation operation = null;
-
+
// TaxonDescription
if(object instanceof TaxonDescription){
operations.add(new DeleteTaxonDescriptionOperation(label, undoContext, (TaxonDescription) object, postOperationEnabled));
}
else if(object instanceof FeatureNodeContainer){
List<DescriptionElementBase> descriptions = ((FeatureNodeContainer) object).getDescriptionElementsForEntireBranch();
-
+
for(DescriptionElementBase description : descriptions){
- operations.add(new DeleteDescriptionElementOperation(label, undoContext, description, postOperationEnabled));
+ operations.add(new DeleteDescriptionElementOperation(label, undoContext, description, postOperationEnabled));
}
}
// Media
else if(object instanceof Media){
TreeSelection treeSelection = (TreeSelection) selection;
-
+
TreePath[] path = treeSelection.getPathsFor(object);
-
- TaxonDescription imageGallery = (TaxonDescription) path[0].getFirstSegment();
-
+
+ DescriptionBase<?> imageGallery = (DescriptionBase<?>) path[0].getFirstSegment();
+
operations.add(new DeleteMediaOperation(label, undoContext, imageGallery, (Media) object, postOperationEnabled));
}
else{
MessagingUtils.error(getClass(), "Selection is not valid for this delete handler", null);
- }
+ }
}
-
+
// execute all cumulated operations
- for(AbstractPostOperation operation : operations){
- EditorUtil.executeOperation(operation);
+ for(AbstractPostOperation<?> operation : operations){
+ AbstractUtility.executeOperation(operation);
}
-
+
} catch (NotDefinedException e) {
MessagingUtils.warn(getClass(), "Command name not set.");
}
-
-
+
+
return null;
}
}
// $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.
*/
* @created 31.03.2009
* @version 1.0
*/
-@Deprecated // I don't think this is really used anymore
public class DeleteMediaOperation extends AbstractPostTaxonOperation {
-
- private Media media;
- private DescriptionBase<?> description;
+ private final Media media;
+
+ private final DescriptionBase<?> description;
/**
* <p>Constructor for DeleteMediaOperation.</p>
public DeleteMediaOperation(String label, IUndoContext undoContext,
DescriptionBase<?> description, Media media, IPostOperationEnabled postOperationEnabled) {
super(label, undoContext, postOperationEnabled);
-
+
this.media = media;
this.description = description;
}
@Override
public IStatus undo(IProgressMonitor monitor, IAdaptable info)
throws ExecutionException {
-
+
ImagesUtility.addMediaToGallery(description, media);
-
+
return postExecute(null);
}
plugin.xml,\
icons/,\
p2.inf,\
- OSGI-INF/
+ OSGI-INF/l10n/bundle.properties,\
+ OSGI-INF/l10n/bundle_en.properties,\
+ OSGI-INF/l10n/bundle_de.properties,\
+ OSGI-INF/l10n/messages.properties,\
+ OSGI-INF/l10n/messages_en.properties,\
+ OSGI-INF/l10n/messages_de.properties
+
+
</menu>
<command
commandId="eu.etaxonomy.taxeditor.editor.handler.OpenChecklistViewHandler"
- icon="icons/edit_16x16.gif"
+ icon="icons/check.png"
label="%command.label.4"
style="push">
<visibleWhen
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.viewers.DoubleClickEvent;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.viewers.TreePath;
import org.eclipse.ui.IMemento;
import org.eclipse.ui.IViewSite;
import eu.etaxonomy.cdm.api.conversation.IConversationEnabled;
import eu.etaxonomy.cdm.api.service.IClassificationService;
import eu.etaxonomy.cdm.model.common.CdmBase;
-import eu.etaxonomy.cdm.model.taxon.Classification;
import eu.etaxonomy.cdm.model.taxon.TaxonComparatorSearch;
import eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap;
import eu.etaxonomy.taxeditor.model.DataChangeBridge;
/** {@inheritDoc} */
@Override
protected IAdaptable getInitialInput() {
-
+
TaxonComparatorSearch comparator = new TaxonComparatorSearch();
TaxonNodeComparator viewerComparator = new TaxonNodeComparator(comparator);
this.getCommonViewer().setComparator(viewerComparator);
+ setLinkingEnabled(true);
// this.getCommonViewer().addSelectionChangedListener(new ISelectionChangedListener() {
-//
+//
// @Override
// public void selectionChanged(SelectionChangedEvent arg0) {
// IStructuredSelection selection = (IStructuredSelection) getCommonViewer().getSelection();
-//
+//
// Object firstElement = selection.getFirstElement();
// //
// if (!(firstElement instanceof Classification)){
// //NavigationUtil.selectInNavigator(firstElement, null);
// NavigationUtil.openEditor(firstElement);
// }
-//
+//
// }
// } );
-
+
if (CdmStore.isActive()) {
-
+
// TODO when closing and reopening the taxon navigator
// we do not preserve state. Closing the view, in contrary to
// closing the whole application
icons/,\
p2.inf,\
OSGI-INF/,\
- OSGI-INF/l10n/bundle.properties
+ OSGI-INF/l10n/bundle.properties,\
+ OSGI-INF/l10n/bundle_de.properties,\
+ OSGI-INF/l10n/bundle_en.properties,\
+ OSGI-INF/l10n/messages.properties,\
+ OSGI-INF/l10n/messages_de.properties,\
+ OSGI-INF/l10n/messages_en.properties
// $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.
*/
*/
public abstract class CdmDataSourceCredentialsWizardPage extends WizardPage implements ModifyListener {
private ICdmDataSource dataSource;
-
+
protected Text text_password;
protected Text text_databaseName;
protected Text text_dataSourceName;
protected Text text_username;
-
+
protected Group authenticationGroup;
protected Group locationGroup;
protected Group nomenclaturalCodeGroup;
protected String database;
protected String username;
protected String password;
-
+
protected NomenclaturalCode nomenclaturalCode;
-
+
CdmDataSourceWizard.Mode mode;
-
+
/**
* <p>Constructor for CdmDataSourceCredentialsWizardPage.</p>
*
protected CdmDataSourceCredentialsWizardPage(String pageName, ICdmDataSource dataSource) {
super(pageName);
this.setPageComplete(false);
- setDataSource(dataSource);
+ setDataSource(dataSource);
mode = CdmDataSourceWizard.Mode.CREATE;
}
-
+
/**
* <p>Constructor for CdmDataSourceCredentialsWizardPage.</p>
*
protected CdmDataSourceCredentialsWizardPage(String pageName, ICdmDataSource dataSource, CdmDataSourceWizard.Mode mode) {
super(pageName);
this.setPageComplete(false);
-
+
this.mode = mode;
if(mode == CdmDataSourceWizard.Mode.CLONE) {
- setDataSource(CdmDataSource.NewInstance(dataSource));
+ setDataSource(CdmDataSource.NewInstance(dataSource));
} else {
- setDataSource(dataSource);
+ setDataSource(dataSource);
}
}
-
+
/* (non-Javadoc)
* @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
*/
/** {@inheritDoc} */
- public void createControl(Composite parent) {
+ @Override
+ public void createControl(Composite parent) {
this.parent = parent;
-
- // Create top-level composite
+
+ // Create top-level composite
parent.setLayout(new GridLayout());
composite = new Composite(parent, SWT.NONE);
composite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false,2,5));
if(getDataSource() == null) {
editDatasourceComposite.setVisible(false);
}
-
+
// create a database specific form
createDatabaseForm();
-
+
// create the authentication input fields
createAuthenticationForm();
-
+
// create nomenclatural code combo
createNomenclaturalCodeForm();
-
+
// Create composite for buttons
Composite buttonComposite = new Composite(composite, SWT.NONE);
buttonComposite.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, true, false));
GridLayout buttonLayout = new GridLayout();
buttonLayout.numColumns = 1;
buttonComposite.setLayout(buttonLayout);
-
+
// Create test connection button
Button testButton = new Button(buttonComposite, SWT.NONE);
testButton.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));
testButton.setText("Test connection");
-
+
// Test connection when button is pressed
testButton.addSelectionListener(new SelectionAdapter() {
/* (non-Javadoc)
testDbConfiguration();
}
});
-
+
setControl(composite);
-
- init();
-
+
+ init();
+
}
/**
GridLayout authenticationLayout = new GridLayout();
authenticationLayout.numColumns = 2;
authenticationGroup.setLayout(authenticationLayout);
-
+
// Create database name label
Label databaseNameLabel = new Label(authenticationGroup, SWT.NONE);
databaseNameLabel.setText("Database Name:");
// Create database name input
text_databaseName = new Text(authenticationGroup, SWT.BORDER);
text_databaseName.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
-
+
// Create username label
Label usernameLabel = new Label(authenticationGroup, SWT.NONE);
usernameLabel.setText("User Name:");
-
+
// Create username input
text_username = new Text(authenticationGroup, SWT.BORDER);
text_username.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
-
-
+
+
// Create password label
Label passwordLabel = new Label(authenticationGroup, SWT.NONE);
passwordLabel.setText("Password:");
// Create password input
text_password = new Text(authenticationGroup, SWT.BORDER | SWT.PASSWORD);
text_password.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
-
+
}
-
+
/**
* Initialize text fields
*/
- public void init() {
+ public void init() {
removeListeners();
- if(getDataSource() != null){
+ if(getDataSource() != null){
text_dataSourceName.setText(getDataSource().getName());
text_databaseName.setText(getDataSource().getDatabase());
text_username.setText(getDataSource().getUsername());
// add listeners after setting text to avoid the modify event being called
// for the initial value
addListeners();
-
+
// in the case of cloning we use the same datasource info
// except for the name
if(mode == CdmDataSourceWizard.Mode.CLONE) {
- getDataSource().setName("");
- text_dataSourceName.setText("");
+ getDataSource().setName("");
+ text_dataSourceName.setText("");
} else {
name = text_dataSourceName.getText();
}
-
+
}
-
+
private void addListeners() {
- text_dataSourceName.addModifyListener(this);
+ text_dataSourceName.addModifyListener(this);
text_databaseName.addModifyListener(this);
text_username.addModifyListener(this);
text_password.addModifyListener(this);
}
-
+
private void removeListeners() {
text_dataSourceName.removeModifyListener(this);
text_databaseName.removeModifyListener(this);
private void createNomenclaturalCodeForm() {
nomenclaturalCodeGroup = new Group(composite , SWT.NONE);
nomenclaturalCodeGroup.setLayout(new GridLayout());
-
+
nomenclaturalCode = dataSource != null ? dataSource.getNomenclaturalCode() : PreferencesUtil.getPreferredNomenclaturalCode();
-
+
for (final NomenclaturalCode code : NomenclaturalCodeHelper.getSupportedCodes()) {
Button button = new Button(nomenclaturalCodeGroup, SWT.RADIO);
button.setText(NomenclaturalCodeHelper.getDescription(code));
button.setSelection(nomenclaturalCode.equals(code));
}
button.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
nomenclaturalCode = (NomenclaturalCode) e.widget.getData();
modifyText(null);
}
});
- }
+ }
}
-
+
public void testDbConfiguration(){
testDbConfiguration(false);
}
-
+
/**
* Tries to open a connection to the given dataSource. Generates a message on either
* failure or success
MessageDialog.openConfirm(parent.getShell(), "Connection Test successful", "Test successful!");
}
} catch(SQLException e){
- MessageDialog.openWarning(parent.getShell(), "Connection Test unsuccessful", "Reason: " + e.getMessage()
+ MessageDialog.openWarning(parent.getShell(), "Connection Test unsuccessful", "Reason: " + e.getMessage()
+ System.getProperty("line.separator") //we may use System.lineSeparator when migrated to Java 1.7
+ System.getProperty("line.separator")
+ "Please double check the connection fields");
- throw new RuntimeException(e);
} catch (ClassNotFoundException e) {
- MessageDialog.openWarning(parent.getShell(), "Connection Test unsuccessful", "Reason: " + e.getMessage()
+ MessageDialog.openWarning(parent.getShell(), "Connection Test unsuccessful", "Reason: " + e.getMessage()
+ System.getProperty("line.separator") //we may use System.lineSeparator when migrated to Java 1.7
+ System.getProperty("line.separator")
+ "Please double check the connection fields");
- throw new RuntimeException(e);
- }
+ }
}
-
+
/**
* Form implementation for the specific database
*/
- public abstract void createDatabaseForm();
-
+ public abstract void createDatabaseForm();
+
/**
* <p>updateLocation</p>
*/
public abstract void updateLocation();
-
+
/**
* <p>updateDataSource</p>
*/
public abstract void updateDataSource();
-
+
/**
* <p>checkPageComplete</p>
*/
boolean complete = false;
if(mode == CdmDataSourceWizard.Mode.CREATE) {
complete = database.length() != 0;
- } else {
+ } else {
complete = name.length() != 0 && database.length() != 0;
- }
+ }
this.setPageComplete(complete);
}
-
-
+
+
/**
* updates the current datasource with form values
*/
- public void updateAuthentication(){
+ public void updateAuthentication(){
database = text_databaseName.getText();
username = text_username.getText();
password = text_password.getText();
*
* @param dataSource the dataSource to set
*/
- public void setDataSource(ICdmDataSource dataSource) {
+ public void setDataSource(ICdmDataSource dataSource) {
this.dataSource = dataSource;
}
updateDataSource();
return dataSource;
}
-
- protected ICdmDataSource getDataSource() {
+
+ protected ICdmDataSource getDataSource() {
return dataSource;
}
-
+
/**
* <p>getDataSourceName</p>
*
public String getDataSourceName() {
return name;
}
-
+
/* (non-Javadoc)
* @see org.eclipse.swto.events.ModifyListener#modifyText(org.eclipse.swt.events.ModifyEvent)
*/
/** {@inheritDoc} */
- public void modifyText(ModifyEvent e) {
-
+ @Override
+ public void modifyText(ModifyEvent e) {
+
name = text_dataSourceName.getText();
database = text_databaseName.getText();
switch(mode) {
case EDIT:
- if(name.length() == 0){
+ if(name.length() == 0){
name = "";
setErrorMessage("DataSource name must not be empty.");
this.setPageComplete(false);
}
break;
case CLONE:
- if(name.length() == 0){
+ if(name.length() == 0){
name = "";
setErrorMessage("DataSource name must not be empty.");
this.setPageComplete(false);
default:
break;
}
-
- if(database.length() == 0){
+
+ if(database.length() == 0){
setErrorMessage("Database name must not be empty.");
this.setPageComplete(false);
- } else {
+ } else {
updateAndCheck();
- setErrorMessage(null);
- }
- }
+ setErrorMessage(null);
+ }
+ }
+
-
private void updateAndCheck() {
updateLocation();
updateAuthentication();
MessagingUtils.warningDialog(title, source, status.getMessage());
}
+ /**
+ * Standard warning dialog for the case when the application is not yet connected to the datasource
+ *
+ * @param source
+ */
+ public static void noDataSourceWarningDialog(Object source) {
+ MessagingUtils
+ .warningDialog(
+ "Application is not connected to a datastore",
+ source,
+ "The requested operation is only available when "
+ + "connected to a datasource. You may choose a datasource to connect to or create a new one in the datasource view.");
+ }
+
/**
* Displays a warning {@link org.eclipse.jface.dialogs.MessageDialog}.
*
// $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.
*/
private boolean isMultilanguageTextEditingCapability;
private Language globalLanguage;
-
+
private Composite createComposite(Composite parent){
Composite composite = new Composite(parent, SWT.NULL);
composite.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false, 2, 1));
composite.setLayout(new RowLayout(SWT.HORIZONTAL));
return composite;
}
-
+
/* (non-Javadoc)
* @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite)
*/
Composite container = new Composite(parent, SWT.NULL);
final GridLayout gridLayout = new GridLayout();
container.setLayout(gridLayout);
-
+
createSetDefaultLanguage(container);
-
+
createSetMultiLanguageTextEditingCapability(container);
-
+
return container;
-
-
+
+
}
/**
*/
private void createSetDefaultLanguage(Composite parent) {
globalLanguage = PreferencesUtil.getGlobalLanguage();
-
+
+ if(globalLanguage == null) {
+ return;
+ }
+
int curentSelectionIndex = 0;
-
+
final Composite composite = createComposite(parent);
composite.setLayout(new RowLayout(1));
-
+
final Label label = new Label(composite, SWT.NONE);
label.setText("Choose the global language that will be used throughout the editor to get representations in.");
-
- final Combo combo_globalLanguage = new Combo(composite, SWT.NONE);
-
+
+ final Combo combo_globalLanguage = new Combo(composite, SWT.NONE);
+
List<Language> preferredLanguages = CdmStore.getTermManager().getPreferredTerms(Language.class);
-
+
for(int i = 0; i < preferredLanguages.size(); i++){
Language language = preferredLanguages.get(i);
combo_globalLanguage.add(language.getLabel(), i);
curentSelectionIndex = i;
}
}
-
+
combo_globalLanguage.select(curentSelectionIndex);
-
+
combo_globalLanguage.addSelectionListener(new SelectionAdapter() {
/* (non-Javadoc)
* @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
int selectionIndex = combo_globalLanguage.getSelectionIndex();
globalLanguage = Language.getLanguageByLabel(combo_globalLanguage.getItem(selectionIndex));
}
- });
+ });
}
/**
- *
+ *
*/
private void createSetMultiLanguageTextEditingCapability(Composite parent) {
isMultilanguageTextEditingCapability = getPreferenceStore().getBoolean(IPreferenceKeys.MULTILANGUAGE_TEXT_EDITING_CAPABILITY);
-
+
final Composite composite = createComposite(parent);
-
- final Button button_toggle = new Button(composite, SWT.CHECK);
-
-
+
+ final Button button_toggle = new Button(composite, SWT.CHECK);
+
+
button_toggle.setText("Enable Multiple Language Editing Capability");
-
+
button_toggle.setSelection(isMultilanguageTextEditingCapability);
-
-
+
+
button_toggle.addSelectionListener(new SelectionAdapter(){
/* (non-Javadoc)
* @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
public boolean performOk() {
getPreferenceStore().setValue(IPreferenceKeys.MULTILANGUAGE_TEXT_EDITING_CAPABILITY, isMultilanguageTextEditingCapability);
PreferencesUtil.setGlobalLanguage(globalLanguage);
-
+
return super.performOk();
}
}
"http://www.biodiversitylibrary.org/openurl");
getPreferenceStore().setDefault(OPENURL_IMAGE_MAX_WIDTH, "1000");
getPreferenceStore().setDefault(OPENURL_IMAGE_MAX_HEIGHT, "1000");
+ getPreferenceStore().setDefault(IPreferenceKeys.DISTRIBUTION_AREA_PREFRENCES_ACTIVE, true);
}
/**
"The following has been set as your preferred nomenclatural code:\n\n\t"
+ NomenclaturalCodeHelper
.getDescription(code)
- + "\n\nYou can change the nomenclatural code at any time in the \"Preferences\" menu.");*/
+ + "\n\nYou iour is not consistent throughout the application. For DescriptionElemts and also PolytomousKeyNode.Question and PolytomousKeyNode.Statement it shows only the languages where text is available whereas for PolytomousKeyNode.modyfingText it shows a strange list of about 10-20 (different for different nodes) most of them starting with can change the nomenclatural code at any time in the \"Preferences\" menu.");*/
}
}
}
public static Language getGlobalLanguage() {
+
+
String languageUuidString = getPreferenceStore().getString(
GLOBAL_LANGUAGE_UUID);
+ if(!CdmStore.isActive()) {
+ MessagingUtils.noDataSourceWarningDialog(languageUuidString);
+ return null;
+ }
+
if (CdmUtils.isBlank(languageUuidString)) {
return Language.getDefaultLanguage();
}
}
public static void setGlobalLanguage(Language language) {
- getPreferenceStore().setValue(GLOBAL_LANGUAGE_UUID,
- language.getUuid().toString());
- CdmStore.setDefaultLanguage(language);
+ if(language != null) {
+ getPreferenceStore().setValue(GLOBAL_LANGUAGE_UUID,language.getUuid().toString());
+ CdmStore.setDefaultLanguage(language);
+ }
+
}
/**
}
protected List<T> getTerms(){
- return TermStore.getTerms(getTermClass());
+ if(!CdmStore.isActive()) {
+ return new ArrayList<T>();
+ } else {
+ return TermStore.getTerms(getTermClass());
+ }
}
/**
/** {@inheritDoc} */
@Override
public void init(IWorkbench workbench) {
- setPreferenceStore(PreferencesUtil.getPreferenceStore());
- getConversationHolder().bind();
+ setPreferenceStore(PreferencesUtil.getPreferenceStore());
+ if(!CdmStore.isActive()) {
+ MessagingUtils.noDataSourceWarningDialog(null);
+
+ } else {
+ getConversationHolder().bind();
+ }
}
/*
/** {@inheritDoc} */
@Override
public boolean performOk() {
+ if(!CdmStore.isActive()) {
+ return true;
+ }
+
if(checkNoneChecked()){
return false;
}
return instance;
} else{// if (instance == null || !instance.isConnected) {
- MessagingUtils
- .warningDialog(
- "Application is not connected to a datastore",
- instance,
- "The requested operation is only available when "
- + "connected to a datasource. You may choose a datasource to connect to or create a new one in the datasource view.");
+ MessagingUtils.noDataSourceWarningDialog(instance);
AbstractUtility.showView(CdmDataSourceViewPart.ID);
return null;
public class DerivedUnitGeneralDetailElement extends
AbstractCdmDetailElement<DerivedUnitFacade> {
+ boolean showOnlyDerivedUnitData = false;
+
private ToggleableTextElement toggleableText_titleCache;
private EnumComboElement<SpecimenOrObservationType> combo_specorobstype;
private EntitySelectionElement<NamedArea> selection_country;
private GatheringEventUnitElement element_elevation;
-
/**
* @param formFactory
* @param formElement
*/
public DerivedUnitGeneralDetailElement(CdmFormFactory formFactory,
ICdmFormElement formElement) {
- super(formFactory, formElement);
+ super(formFactory, formElement);
}
/*
toggleableText_titleCache = formFactory.createToggleableTextField(
formElement, "Title Cache", entity.getTitleCache(),
entity.isProtectedTitleCache(), style);
- if((AbstractUtility.getActivePart() instanceof IDerivedUnitFacadePart)){
+ //TODO for DerivateEditor do not use facade anyore to avoid this special case handling #4539
+ if(showOnlyDerivedUnitData){
+ toggleableText_titleCache.setEnabled(false);
+ }
+ else{
combo_specorobstype = formFactory.createEnumComboElement(SpecimenOrObservationType.class, formElement, style);
combo_specorobstype.setSelection(entity.getType());
selection_country = formFactory.createSelectionElement(NamedArea.class, getConversationHolder(),
text_collectingNumber = formFactory.createTextWithLabelElement(formElement,
"Collecting number", entity.getFieldNumber(), style);
}
- else{
- toggleableText_titleCache.setEnabled(false);
- }
selection_collection = formFactory
.createSelectionElement(Collection.class,
getConversationHolder(), formElement, "Collection",
toggleableText_titleCache.setText(getEntity().getTitleCache());
}
}
+
+ public void setShowOnlyDerivedUnitData(boolean showOnlyDerivedUnitData) {
+ this.showOnlyDerivedUnitData = showOnlyDerivedUnitData;
+ }
}
*/
public class DerivedUnitGeneralDetailSection extends AbstractCdmDetailSection<DerivedUnitFacade> implements IDerivedUnitFacadeDetailSection{
- /**
+ //TODO for DerivateEditor do not use facade anymore to avoid this special case handling #4539
+ private DerivedUnitGeneralDetailElement derivedUnitGeneralDetailElement;
+
+ /**
* @param formFactory
* @param conversation
* @param parentElement
*/
@Override
protected AbstractCdmDetailElement<DerivedUnitFacade> createCdmDetailElement(AbstractCdmDetailSection<DerivedUnitFacade> parentElement, int style) {
- return formFactory.createDerivedUnitGeneralDetailElement(parentElement);
+ derivedUnitGeneralDetailElement = formFactory.createDerivedUnitGeneralDetailElement(parentElement);
+ return derivedUnitGeneralDetailElement;
+ }
+
+ public void setShowOnlyDerivedUnitData(boolean showOnlyDerivedUnitData){
+ derivedUnitGeneralDetailElement.setShowOnlyDerivedUnitData(showOnlyDerivedUnitData);
}
}
}
});
status = Status.OK_STATUS;
+ }else{
+ throw new RuntimeException("An error occurred during the update.");
}
}catch(Exception e){
status = new Status(IStatus.ERROR, TaxeditorStorePlugin.PLUGIN_ID, e.getMessage(), e);
- MessagingUtils.messageDialog("Could not run updater", getClass(), status.getMessage());
+ MessagingUtils.errorDialog("Could not complete updater", updater, status.getMessage(), status.getPlugin(), e, true);
}
}
destroySections();
DerivedUnitGeneralDetailSection derivedUnitGeneralDetailSection = formFactory.createDerivedUnitGeneralDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
+ //TODO for DerivateEditor do not use facade anymore to avoid this special case handling #4539
+ if(!(AbstractUtility.getActivePart() instanceof IDerivedUnitFacadePart)){
+ derivedUnitGeneralDetailSection.setShowOnlyDerivedUnitData(true);
+ }
addPart(derivedUnitGeneralDetailSection);
formFactory.createHorizontalSeparator(parent, SWT.BORDER);