Bundle-ManifestVersion: 2
Bundle-Name: Application
Bundle-SymbolicName: eu.etaxonomy.taxeditor.application;singleton:=true
-Bundle-Version: 4.11.4
+Bundle-Version: 4.13.0.qualifier
Bundle-Activator: eu.etaxonomy.taxeditor.TaxonomicEditorPlugin
Bundle-Vendor: EDIT
Bundle-Localization: OSGI-INF/l10n/plugin
org.eclipse.e4.core.contexts,
org.eclipse.e4.core.di,
org.eclipse.e4.core.services,
- org.eclipse.e4.core.di.annotations
+ org.eclipse.e4.core.di.annotations,
+ eu.etaxonomy.taxeditor.cdmlib,
+ org.eclipse.osgi.services
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Bundle-ActivationPolicy: lazy
Import-Package: eu.etaxonomy.cdm.database,
<parent>
<groupId>eu.etaxonomy</groupId>
<artifactId>taxeditor-parent</artifactId>
- <version>4.11.4</version>
+ <version>4.13.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
package eu.etaxonomy.taxeditor;
import java.util.Arrays;
+import java.util.Collection;
import java.util.List;
import javax.inject.Inject;
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.e4.core.contexts.IEclipseContext;
+import org.eclipse.e4.core.di.annotations.Optional;
+import org.eclipse.e4.ui.di.UIEventTopic;
import org.eclipse.e4.ui.model.application.MApplication;
import org.eclipse.e4.ui.model.application.ui.MElementContainer;
import org.eclipse.e4.ui.model.application.ui.MUIElement;
import org.eclipse.e4.ui.model.application.ui.basic.MPart;
+import org.eclipse.e4.ui.workbench.UIEvents;
import org.eclipse.e4.ui.workbench.lifecycle.PostContextCreate;
import org.eclipse.e4.ui.workbench.lifecycle.PreSave;
import org.eclipse.e4.ui.workbench.lifecycle.ProcessAdditions;
import org.eclipse.e4.ui.workbench.lifecycle.ProcessRemovals;
import org.eclipse.e4.ui.workbench.modeling.EModelService;
+import org.eclipse.e4.ui.workbench.modeling.EPartService;
import org.eclipse.ui.IMemento;
+import org.osgi.service.event.Event;
import eu.etaxonomy.taxeditor.model.IContextListener;
import eu.etaxonomy.taxeditor.store.CdmStore;
private void preSave(){
}
+ @Inject
+ @Optional
+ public void subscribeAppShutdownStarted(@UIEventTopic(UIEvents.UILifeCycle.APP_SHUTDOWN_STARTED) Event event,
+ MApplication application) {
+ IEclipseContext context = application.getContext();
+ EPartService partService = context.get(EPartService.class);
+ try {
+ Collection<MPart> dirtyParts = partService.getDirtyParts();
+ if(!dirtyParts.isEmpty()){
+ partService.saveAll(true);
+ }
+ } catch (IllegalStateException e) {
+ //FIXME E4
+ //exception is ignored as this is a temporary fix until full e4 migration
+ }
+ }
+
private void hideParts() {
List<MPart> elements = modelService.findElements(application, null, MPart.class, Arrays.asList(NON_RESTORE));
for (MPart part : elements) {
Bundle-ManifestVersion: 2
Bundle-Name: Bulkeditor Bundle
Bundle-SymbolicName: eu.etaxonomy.taxeditor.bulkeditor;singleton:=true
-Bundle-Version: 4.11.4
+Bundle-Version: 4.13.0.qualifier
Bundle-Activator: eu.etaxonomy.taxeditor.bulkeditor.internal.TaxeditorBulkeditorPlugin
Bundle-Vendor: EDIT
Export-Package: eu.etaxonomy.taxeditor.annotatedlineeditor,
<parent>
<groupId>eu.etaxonomy</groupId>
<artifactId>taxeditor-parent</artifactId>
- <version>4.11.4</version>
+ <version>4.13.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
}
table.setHeaderVisible(true);
table.setLinesVisible(true);
+
viewer.setCellEditors(editors);
viewer.setColumnProperties(titles);
conversation.commit(true);
Object object = viewer.getInput();
- List<CdmBase> cdmBaseList = new ArrayList<>();;
- if(object instanceof List){
- for (Object item: (List)object) {
- CdmBase cdmBase = (CdmBase) item;
- cdmBaseList.add(cdmBase);
+ List<CdmBase> cdmBaseList = new ArrayList<>();
+ List<CdmBase> saveCandidates = getEditorInput().getSaveCandidates();
+ if(saveCandidates != null && !saveCandidates.isEmpty()){
+ for (CdmBase item: saveCandidates) {
+
+ cdmBaseList.add(item);
}
}
- if (!cdmBaseList.isEmpty()){
- CdmStore.getService(cdmBaseList.get(0)).merge(cdmBaseList, true);
+
+ if (!saveCandidates.isEmpty()){
+ CdmStore.getService(saveCandidates.get(0)).merge(saveCandidates, true);
}
dirty.setDirty(false);
+ getEditorInput().resetSaveCandidates();
viewer.refresh();
}
}
}
dirty.setDirty(false);
- getEditorInput().dispose();
- getEditorInput().bind();
+// getEditorInput().dispose();
+// getEditorInput().bind();
getEditorInput().performSearch(query);
viewer.setInput(getEditorInput().getModel());
*/
@Override
public void changed(Object element) {
+ if (element instanceof CdmBase) {
+ getEditorInput().addSaveCandidate((CdmBase)element);
+ }
dirty.setDirty(true);
}
public class SetMergeCandidateHandlerE4 {
@Execute
- public void execute(@Named(IServiceConstants.ACTIVE_SELECTION)CdmBase selection,
+ public void execute(@Named(IServiceConstants.ACTIVE_SELECTION)Object selection,
@Named(IServiceConstants.ACTIVE_PART)MPart activePart) {
BulkEditorE4 editor = (BulkEditorE4) activePart.getObject();
AbstractBulkEditorInput input = editor.getEditorInput();
&& input.getMergeTarget().equals(selection)){
input.setMergeTarget(null);
}
- input.addMergeCandidate(selection);
+ if (selection instanceof Object[]){
+ for(Object object: (Object[])selection){
+ if (object instanceof CdmBase){
+ input.addMergeCandidate((CdmBase)object);
+ }
+ }
+ }else if (selection instanceof CdmBase){
+ input.addMergeCandidate((CdmBase)selection);
+ }
editor.refresh();
}
@CanExecute
- public boolean canExecute(@Named(IServiceConstants.ACTIVE_SELECTION)CdmBase selection,
+ public boolean canExecute(@Named(IServiceConstants.ACTIVE_SELECTION)Object selection,
@Named(IServiceConstants.ACTIVE_PART)MPart activePart,
MHandledMenuItem menuItem) {
boolean canExecute = false;
private List<T> model = new ArrayList<>();
private Map<T, DeleteConfiguratorBase> toDelete = new HashMap<>();
+ private List<T> saveCandidates = new ArrayList<>();
+
private List<T> mergeCandidates = new ArrayList<>();
private T mergeTarget = null;
public void addToDelete(T t, DeleteConfiguratorBase config) {
toDelete.put(t, config);
}
-
+ public void addSaveCandidate(T t){
+ saveCandidates.add(t);
+ }
private void setEntityUuid(UUID entityUuid){
this.entityUuid = entityUuid;
}
public ConversationHolder getConversation() {
return conversation;
}
+
+ public List<T> getSaveCandidates() {
+ return saveCandidates;
+ }
+
+ /**
+ *
+ */
+ public void resetSaveCandidates() {
+ this.saveCandidates.clear();
+
+ }
}
<classpathentry exported="true" kind="lib" path="lib/aspectjrt-1.8.8.jar"/>
<classpathentry exported="true" kind="lib" path="lib/aspectjweaver-1.8.8.jar"/>
<classpathentry exported="true" kind="lib" path="lib/batik-xml-1.7.jar"/>
- <classpathentry exported="true" kind="lib" path="lib/cdmlib-commons-4.11.0.jar"/>
- <classpathentry exported="true" kind="lib" path="lib/cdmlib-ext-4.11.0.jar"/>
- <classpathentry exported="true" kind="lib" path="lib/cdmlib-io-4.11.0.jar"/>
- <classpathentry exported="true" kind="lib" path="lib/cdmlib-model-4.11.0.jar"/>
- <classpathentry exported="true" kind="lib" path="lib/cdmlib-persistence-4.11.0.jar"/>
- <classpathentry exported="true" kind="lib" path="lib/cdmlib-print-4.11.0.jar"/>
- <classpathentry exported="true" kind="lib" path="lib/cdmlib-remote-4.11.0.jar"/>
- <classpathentry exported="true" kind="lib" path="lib/cdmlib-services-4.11.0.jar"/>
- <classpathentry exported="true" kind="lib" path="lib/cdmlib-test-4.11.0.jar"/>
+ <classpathentry exported="true" kind="lib" path="lib/cdmlib-commons-4.13.0-SNAPSHOT.jar"/>
+ <classpathentry exported="true" kind="lib" path="lib/cdmlib-ext-4.13.0-SNAPSHOT.jar"/>
+ <classpathentry exported="true" kind="lib" path="lib/cdmlib-io-4.13.0-SNAPSHOT.jar"/>
+ <classpathentry exported="true" kind="lib" path="lib/cdmlib-model-4.13.0-SNAPSHOT.jar"/>
+ <classpathentry exported="true" kind="lib" path="lib/cdmlib-persistence-4.13.0-SNAPSHOT.jar"/>
+ <classpathentry exported="true" kind="lib" path="lib/cdmlib-print-4.13.0-SNAPSHOT.jar"/>
+ <classpathentry exported="true" kind="lib" path="lib/cdmlib-remote-4.13.0-SNAPSHOT.jar"/>
+ <classpathentry exported="true" kind="lib" path="lib/cdmlib-services-4.13.0-SNAPSHOT.jar"/>
+ <classpathentry exported="true" kind="lib" path="lib/cdmlib-test-4.13.0-SNAPSHOT.jar"/>
<classpathentry exported="true" kind="lib" path="lib/com.springsource.org.aopalliance-1.0.0.jar"/>
<classpathentry exported="true" kind="lib" path="lib/com.springsource.org.apache.commons.logging-1.1.1.jar"/>
<classpathentry exported="true" kind="lib" path="lib/commons-beanutils-1.9.2.jar"/>
Bundle-ManifestVersion: 2
Bundle-Name: CDM Library Dependencies Plugin
Bundle-SymbolicName: eu.etaxonomy.taxeditor.cdmlib;singleton:=true
-Bundle-Version: 4.11.4
+Bundle-Version: 4.13.0.qualifier
Eclipse-BundleShape: dir
Export-Package: com.google.api,
com.google.api.detect,
org.apache.commons.httpclient;bundle-version="3.1.0",
org.eclipse.core.runtime,
org.eclipse.e4.core.di.annotations;bundle-version="1.5.0",
- org.eclipse.e4.ui.services;bundle-version="1.2.100"
+ org.eclipse.e4.ui.services;bundle-version="1.2.100",
+ org.eclipse.swt
Bundle-ClassPath: .,
lib/activation-1.1.1.jar,
lib/apache-log4j-extras-1.2.17.jar,
lib/aspectjrt-1.8.8.jar,
lib/aspectjweaver-1.8.8.jar,
lib/batik-xml-1.7.jar,
- lib/cdmlib-commons-4.11.0.jar,
- lib/cdmlib-ext-4.11.0.jar,
- lib/cdmlib-io-4.11.0.jar,
- lib/cdmlib-model-4.11.0.jar,
- lib/cdmlib-persistence-4.11.0.jar,
- lib/cdmlib-print-4.11.0.jar,
- lib/cdmlib-remote-4.11.0.jar,
- lib/cdmlib-services-4.11.0.jar,
- lib/cdmlib-test-4.11.0.jar,
+ lib/cdmlib-commons-4.13.0-SNAPSHOT.jar,
+ lib/cdmlib-ext-4.13.0-SNAPSHOT.jar,
+ lib/cdmlib-io-4.13.0-SNAPSHOT.jar,
+ lib/cdmlib-model-4.13.0-SNAPSHOT.jar,
+ lib/cdmlib-persistence-4.13.0-SNAPSHOT.jar,
+ lib/cdmlib-print-4.13.0-SNAPSHOT.jar,
+ lib/cdmlib-remote-4.13.0-SNAPSHOT.jar,
+ lib/cdmlib-services-4.13.0-SNAPSHOT.jar,
+ lib/cdmlib-test-4.13.0-SNAPSHOT.jar,
lib/com.springsource.org.aopalliance-1.0.0.jar,
lib/com.springsource.org.apache.commons.logging-1.1.1.jar,
lib/commons-beanutils-1.9.2.jar,
lib/aspectjrt-1.8.8.jar,\
lib/aspectjweaver-1.8.8.jar,\
lib/batik-xml-1.7.jar,\
- lib/cdmlib-commons-4.11.0.jar,\
- lib/cdmlib-ext-4.11.0.jar,\
- lib/cdmlib-io-4.11.0.jar,\
- lib/cdmlib-model-4.11.0.jar,\
- lib/cdmlib-persistence-4.11.0.jar,\
- lib/cdmlib-print-4.11.0.jar,\
- lib/cdmlib-remote-4.11.0.jar,\
- lib/cdmlib-services-4.11.0.jar,\
- lib/cdmlib-test-4.11.0.jar,\
+ lib/cdmlib-commons-4.13.0-SNAPSHOT.jar,\
+ lib/cdmlib-ext-4.13.0-SNAPSHOT.jar,\
+ lib/cdmlib-io-4.13.0-SNAPSHOT.jar,\
+ lib/cdmlib-model-4.13.0-SNAPSHOT.jar,\
+ lib/cdmlib-persistence-4.13.0-SNAPSHOT.jar,\
+ lib/cdmlib-print-4.13.0-SNAPSHOT.jar,\
+ lib/cdmlib-remote-4.13.0-SNAPSHOT.jar,\
+ lib/cdmlib-services-4.13.0-SNAPSHOT.jar,\
+ lib/cdmlib-test-4.13.0-SNAPSHOT.jar,\
lib/com.springsource.org.aopalliance-1.0.0.jar,\
lib/com.springsource.org.apache.commons.logging-1.1.1.jar,\
lib/commons-beanutils-1.9.2.jar,\
<parent>\r
<groupId>eu.etaxonomy</groupId>\r
<artifactId>taxeditor-parent</artifactId>\r
- <version>4.11.4</version>\r
+ <version>4.13.0-SNAPSHOT</version>\r
</parent>\r
<modelVersion>4.0.0</modelVersion>\r
<artifactId>eu.etaxonomy.taxeditor.cdmlib</artifactId>\r
Bundle-ManifestVersion: 2
Bundle-Name: Editor Bundle
Bundle-SymbolicName: eu.etaxonomy.taxeditor.editor;singleton:=true
-Bundle-Version: 4.11.4
+Bundle-Version: 4.13.0.qualifier
Bundle-Activator: eu.etaxonomy.taxeditor.editor.internal.TaxeditorEditorPlugin
Bundle-Vendor: %Bundle-Vendor.0
Bundle-Localization: OSGI-INF/l10n/plugin
command.label.26 = Delete\r
command.label.27 = New Factual Data\r
menu.label.1 = New\r
-command.label.28 = Move Description to Taxon\r
-command.label.29 = Move Elements to Taxon\r
+command.label.28 = Move Factual Data to Other Taxon\r
+command.label.29 = Move Fact to Other Taxon\r
command.label.30 = Delete\r
command.label.31 = Save\r
menu.label.2 = New Derivative\r
category.name.1 = -- Factual\r
command.name.10 = Create Description Element\r
command.name.11 = New Description\r
-command.name.12 = Move Description Elements to Taxon\r
-command.name.13 = Move Description to Taxon\r
+command.name.12 = Move Factual Data to Other Taxon\r
+command.name.13 = Move Fact to Other Taxon\r
category.name.2 = -- New Uses\r
command.name.14 = New Use\r
command.name.15 = New Use Summary\r
command.label.26 = L\u00f6schen
command.label.27 = Neue Faktendaten
menu.label.1 = Neue
-command.label.28 = Verschiebe Eigenschaften zu Taxon
-command.label.29 = Verschiebe Elemente zu Taxon
+command.label.28 = Verschiebe Faktendaten zu anderem Taxon
+command.label.29 = Verschiebe Fakt zu anderem Taxon
command.label.30 = L\u00f6schen
command.label.31 = Speichern
menu.label.2 = Neue Derivate
category.name.1 = -- Fakten
command.name.10 = Erstelle Beschreibungselement
command.name.11 = Neue Beschreibung
-command.name.12 = Bewege Beschreibungselement zu Taxon
-command.name.13 = Bewege Beschreibung zu Taxon
+command.name.12 = Verschiebe Fakt zu anderem Taxon
+command.name.13 = Verschiebe Faktendaten zu anderem Taxon
category.name.2 = -- Neue Nutzung
command.name.14 = Neue Nutzung
command.name.15 = Neue Zusammenfassung
<parent>
<groupId>eu.etaxonomy</groupId>
<artifactId>taxeditor-parent</artifactId>
- <version>4.11.4</version>
+ <version>4.13.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
import eu.etaxonomy.cdm.api.service.IPolytomousKeyNodeService;
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
import eu.etaxonomy.cdm.model.description.PolytomousKeyNode;
-import eu.etaxonomy.taxeditor.bulkeditor.internal.TaxeditorBulkeditorPlugin;
+import eu.etaxonomy.taxeditor.editor.internal.TaxeditorEditorPlugin;
import eu.etaxonomy.taxeditor.editor.l10n.Messages;
import eu.etaxonomy.taxeditor.model.MessagingUtils;
import eu.etaxonomy.taxeditor.operation.AbstractPostOperation;
}else {
t = result.getExceptions().iterator().next();
}
- MessagingUtils.errorDialog(Messages.DeleteNodeOperation_DELETE_FAILED, getClass(),null, TaxeditorBulkeditorPlugin.PLUGIN_ID, t, true);
+ MessagingUtils.errorDialog(Messages.DeleteNodeOperation_DELETE_FAILED, getClass(),null, TaxeditorEditorPlugin.PLUGIN_ID, t, true);
}
return postExecute(null);
}
// Get taxon
Taxon taxon = input.getTaxon();
- TaxonNode newParentNode = TaxonNodeSelectionDialog.select(shell, editor.getConversationHolder(), Messages.ChangeSynonymToAcceptedTaxonHandler_SELECT_PARENT, null, null, input.getTaxonNode().getClassification());
+ TaxonNode newParentNode = TaxonNodeSelectionDialog.select(shell,// editor.getConversationHolder(),
+ Messages.ChangeSynonymToAcceptedTaxonHandler_SELECT_PARENT, null, null, input.getTaxonNode().getClassification());
if(newParentNode != null){
excludeTaxa.add(oldParent.getUuid());
- newParentNode = TaxonNodeSelectionDialog.select(shell, editor.getConversationHolder(), Messages.MoveSynonymToAnotherAcceptedTaxonHandler_SELECT_ACC_TAXON, excludeTaxa, input.getTaxonNode(), input.getTaxonNode().getClassification());
+ newParentNode = TaxonNodeSelectionDialog.select(shell, //editor.getConversationHolder(),
+ Messages.MoveSynonymToAnotherAcceptedTaxonHandler_SELECT_ACC_TAXON, excludeTaxa, input.getTaxonNode(), input.getTaxonNode().getClassification());
if(newParentNode!=null){
MoveSynonymToAnotherAcceptedTaxonOperationE4 operation = new MoveSynonymToAnotherAcceptedTaxonOperationE4(Messages.MoveSynonymToAnotherAcceptedTaxonHandler_CHANGE_ACC_TAXON, EditorUtil.getUndoContext(),
import eu.etaxonomy.cdm.api.conversation.IConversationEnabled;
import eu.etaxonomy.cdm.api.service.ITaxonService;
+import eu.etaxonomy.cdm.api.service.UpdateResult;
import eu.etaxonomy.cdm.api.service.exception.HomotypicalGroupChangeException;
import eu.etaxonomy.cdm.model.taxon.Synonym;
import eu.etaxonomy.cdm.model.taxon.Taxon;
conversationEnabled.getConversationHolder().commit();
try {
- CdmStore.getService(ITaxonService.class).moveSynonymToAnotherTaxon(synonym,
+ UpdateResult result = CdmStore.getService(ITaxonService.class).moveSynonymToAnotherTaxon(synonym,
this.element.getUuid(),
true,
synonym.getType(),
*/
private TaxonNode taxonNode = null;
- private List<Taxon> taxa = new ArrayList<Taxon>();
+ private List<TaxonBase> taxa = new ArrayList();
private Classification classification = null;
- public List<Taxon> getTaxa() {
+ public List<TaxonBase> getTaxa() {
return taxa;
}
@Override
public void merge() {
- for (TaxonBase taxon:this.taxa){
- CdmStore.getService(ITaxonService.class).merge(taxon, true);
- }
-
-
+ CdmStore.getService(ITaxonService.class).merge(taxa, true);
}
/* (non-Javadoc)
}
- public void setTaxa(List<Taxon> taxonList) {
+ public void setTaxa(List<TaxonBase> taxonList) {
this.taxa = taxonList;
}
import eu.etaxonomy.cdm.model.common.DefinedTermBase;
import eu.etaxonomy.taxeditor.editor.l10n.Messages;
-import eu.etaxonomy.taxeditor.editor.view.checklist.ChecklistEditor;
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
import eu.etaxonomy.taxeditor.preference.wizard.AvailableDistributionWizard;
import eu.etaxonomy.taxeditor.store.StoreUtil;
private final ChecklistEditorE4 editor;
private final SortedSet<DefinedTermBase> termSet;
private Logger logger = Logger.getLogger(ChecklistDropdownSelectionListenerE4.class);
-
+
public ChecklistDropdownSelectionListenerE4(ToolItem dropdown, ChecklistEditorE4 editor,
SortedSet<DefinedTermBase> termSet) {
this.editor = editor;
// SearchOption option
public void add(DefinedTermBase<DefinedTermBase> term) {
MenuItem menuItem = new MenuItem(menu, SWT.CHECK);
- menuItem.setText(term.getTitleCache());
+// if (PreferencesUtil) {
+// menuItem.setText(term.getTitleCache());
+// }
if (PreferencesUtil.getPreferenceStore().getBoolean(term.getUuid().toString())) {
menuItem.setSelection(true);
} else {
menu.setVisible(true);
}
}
-
+
public Menu getMenu(){
return menu;
}
private SortedSet<DefinedTermBase> terms = null;
private ToolItem toolItem;
private ChecklistDropdownSelectionListenerE4 dropListener;
+ private Text searchText;
+
/**
* @return the selectedTaxonNodes
return;
}
taxonNodeService = CdmStore.getService(ITaxonNodeService.class);
+ filter = new ChecklistEditorFilter();
+ createTopComposite(parent);
viewer = new TableViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION);
//the focuzsCellManager should return the distribution!!!
this.dispose();
return;
}
- filter = new ChecklistEditorFilter();
- createTopComposite(parent);
+
+
+ viewer.addFilter(filter);
+ createTable();
+
+ viewer.setContentProvider(new ChecklistContentProvider());
+ viewer.setLabelProvider(this.labelProvider);
+ comparator = new ChecklistEditorComparator();
+ viewer.setComparator(comparator);
+ final ModifyListener modifyListener = new ChecklistModifyListener(viewer, filter, searchText);
+
+ searchText.addFocusListener(new ChecklistFocusListener(searchText, modifyListener));
+ searchText.addModifyListener(modifyListener);
+ createGridDataForViewerLayout();
+ createStatusBar(parent);
+ createToolbar(parent);
}
/**
gridLayout.marginHeight = 0;
parent.setLayout(gridLayout);
- final Text searchText = createSearchBar(parent);
- createToolbar(parent);
+ searchText = createSearchBar(parent);
+
// getSite().setSelectionProvider(viewer);
- final ModifyListener modifyListener = new ChecklistModifyListener(viewer, filter, searchText);
- searchText.addFocusListener(new ChecklistFocusListener(searchText, modifyListener));
- searchText.addModifyListener(modifyListener);
- createGridDataForViewerLayout();
- viewer.addFilter(filter);
- createTable();
- viewer.setContentProvider(new ChecklistContentProvider());
- viewer.setLabelProvider(this.labelProvider);
- comparator = new ChecklistEditorComparator();
- viewer.setComparator(comparator);
- createStatusBar(parent);
}
private void createGridDataForViewerLayout() {
return null;
}
ViewerCell cell = editor.getFocusCell();
+ if (cell == null){
+ return null;
+ }
if (cell.getElement() instanceof Taxon){
taxon =(Taxon)cell.getElement();
} else {
// undoContext = bulkEditor.getUndoContext();
// }
- Taxon relatedConcept = TaxonBaseSelectionDialog.selectTaxon(shell, conversationHolder, taxon);
+ Taxon relatedConcept = TaxonBaseSelectionDialog.selectTaxon(shell, //conversationHolder,
+ taxon);
if(relatedConcept == null){
if(conversation == null){
conversation = CdmStore.createConversation();
}
- if(cdmEntitySession!=null){
+ if(cdmEntitySession == null){
cdmEntitySession = CdmStore.getCurrentSessionManager().newSession(this, true);
}
}
protected DerivedUnit createDerivative() {
MediaSpecimen mediaSpecimen = null;
//select media
- Media media = MediaSelectionDialog.select(AbstractUtility.getShell(), null, null);
+ Media media = MediaSelectionDialog.select(AbstractUtility.getShell(), //null,
+ null);
if(media!=null){
//create MediaSpecimen
mediaSpecimen = MediaSpecimen.NewInstance(SpecimenOrObservationType.StillImage);
searchDerivates();
}
else if(eventSource==derivateSearchComposite.getBtnBrowseTaxa()){
- selectedTaxon = SelectionDialogFactory.getSelectionFromDialog(Taxon.class, this.derivateSearchComposite.getShell(), derivativeEditor.getConversationHolder(), null);
+ selectedTaxon = SelectionDialogFactory.getSelectionFromDialog(Taxon.class, this.derivateSearchComposite.getShell(), //derivativeEditor.getConversationHolder(),
+ null);
if(selectedTaxon!=null){
derivateSearchComposite.getTextTaxonName().setText(selectedTaxon.getTitleCache());
}
}
}
TaxonNode newAcceptedTaxonNode = TaxonNodeSelectionDialog.select(shell,
- editor.getConversationHolder(),
+// editor.getConversationHolder(),
Messages.MoveDescriptionElementsHandler_CHOOSE_ACC_TAXON,
excludeTaxa,
null, classification
classification = node.getClassification();
}
TaxonNode newAcceptedTaxonNode = TaxonNodeSelectionDialog.select(shell,
- editor.getConversationHolder(),
+// editor.getConversationHolder(),
Messages.MoveDescriptionToOtherTaxonHandler_CHOOSE_ACC_TAXON,
excludeTaxa,
node,
import eu.etaxonomy.cdm.model.media.Media;
import eu.etaxonomy.cdm.model.media.MediaRepresentation;
import eu.etaxonomy.cdm.model.media.MediaRepresentationPart;
+import eu.etaxonomy.cdm.model.media.MediaUtils;
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
/**
@Override
public Image getImage(Object element) {
Image image = null;
+ int scale = 50;
if (element instanceof Media && PreferencesUtil.isShowMediaPreview()){
Set<MediaRepresentation> representations = ((Media)element).getRepresentations();
if(representations.iterator().hasNext()){
- MediaRepresentation rep = representations.iterator().next();
- List<MediaRepresentationPart> parts = rep.getParts();
+ MediaRepresentation rep = null;
+
MediaRepresentationPart smallestPart = null;
+ rep = MediaUtils.findBestMatchingRepresentation((Media)element, null, null, scale, scale, null);
+ List<MediaRepresentationPart> parts = rep.getParts();
for (MediaRepresentationPart part: parts){
if (smallestPart != null){
if (smallestPart.getSize() != null && part.getSize() != null) {
}
}
- URI uri = parts.get(0).getUri();
+ URI uri = smallestPart.getUri();
if (uri == null){
return null;
}
image = new Image(Display.getCurrent(), imageStream);
int height = image.getBounds().height;
int width = image.getBounds().width;
- int scale = 50;
+
if (height>width){
width = width/(height/scale);
height = scale;
if(description != null){
AbstractPostOperation operation = null;
//select media
- Media media = MediaSelectionDialog.select(AbstractUtility.getShell(), null, null);
+ Media media = MediaSelectionDialog.select(AbstractUtility.getShell(),// null,
+ null);
if(media!=null){
// TODO use undo context specific to editor
operation = new AddExistingMediaToImageGalleryOperation(media, menuItem.getLocalizedLabel(),
@Override
public void widgetSelected(SelectionEvent e) {
- FeatureTree tree = FeatureTreeSelectionDialog.select(featureTreeEditorComposite.getDisplay().getActiveShell(), conversation, null);
+ FeatureTree tree = FeatureTreeSelectionDialog.select(featureTreeEditorComposite.getDisplay().getActiveShell(), //conversation,
+ null);
if(tree!=null){
featureTreeEditorComposite.setSelectedTree(tree, CharacterEditor.this);
featureTreeEditorComposite.getText_title().setEnabled(false);
<feature
id="eu.etaxonomy.taxeditor.feature.platform"
label="Taxeditor Dependencies"
- version="4.11.4"
+ version="4.13.0.qualifier"
os="linux,macosx,win32"
ws="cocoa,gtk,win32"
arch="x86,x86_64">
<parent>
<groupId>eu.etaxonomy</groupId>
<artifactId>taxeditor-parent</artifactId>
- <version>4.11.4</version>
+ <version>4.13.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>eu.etaxonomy.taxeditor.feature.platform</artifactId>
<feature
id="eu.etaxonomy.taxeditor.feature"
label="Taxonomic Editor"
- version="4.11.4"
+ version="4.13.0.qualifier"
provider-name="EDIT"
plugin="eu.etaxonomy.taxeditor.application"
os="linux,macosx,win32"
<parent>
<groupId>eu.etaxonomy</groupId>
<artifactId>taxeditor-parent</artifactId>
- <version>4.11.4</version>
+ <version>4.13.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>eu.etaxonomy.taxeditor.feature</artifactId>
Bundle-ManifestVersion: 2
Bundle-Name: Help
Bundle-SymbolicName: eu.etaxonomy.taxeditor.help; singleton:=true
-Bundle-Version: 4.11.4
+Bundle-Version: 4.13.0.qualifier
Bundle-Activator: eu.etaxonomy.taxeditor.help.Activator
Bundle-Vendor: EDIT
Require-Bundle: org.eclipse.ui,
<parent>
<groupId>eu.etaxonomy</groupId>
<artifactId>taxeditor-parent</artifactId>
- <version>4.11.4</version>
+ <version>4.13.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
Bundle-ManifestVersion: 2
Bundle-Name: eu.etaxonomy.taxeditor.molecular.lib
Bundle-SymbolicName: eu.etaxonomy.taxeditor.molecular.lib;singleton:=true
-Bundle-Version: 4.11.4
+Bundle-Version: 4.13.0.qualifier
Bundle-ClassPath: .,
lib/owlapi-xmlutils-4.1.4.jar,
lib/commons-collections4-4.1.jar,
<parent>
<groupId>eu.etaxonomy</groupId>
<artifactId>taxeditor-parent</artifactId>
- <version>4.11.4</version>
+ <version>4.13.0-SNAPSHOT</version>
</parent>
<name>Molecular Library Dependencies Bundle</name>
Bundle-ManifestVersion: 2
Bundle-Name: Molecular Bundle
Bundle-SymbolicName: eu.etaxonomy.taxeditor.molecular;singleton:=true
-Bundle-Version: 4.11.4
+Bundle-Version: 4.13.0.qualifier
Bundle-Activator: eu.etaxonomy.taxeditor.molecular.TaxeditorMolecularPlugin
Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime,
<parent>
<groupId>eu.etaxonomy</groupId>
<artifactId>taxeditor-parent</artifactId>
- <version>4.11.4</version>
+ <version>4.13.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
Bundle-ManifestVersion: 2
Bundle-Name: Navigation Bundle
Bundle-SymbolicName: eu.etaxonomy.taxeditor.navigation;singleton:=true
-Bundle-Version: 4.11.4
+Bundle-Version: 4.13.0.qualifier
Bundle-Activator: eu.etaxonomy.taxeditor.navigation.internal.TaxeditorNavigationPlugin
Bundle-Vendor: EDIT
Export-Package: eu.etaxonomy.cdm,
<parent>
<groupId>eu.etaxonomy</groupId>
<artifactId>taxeditor-parent</artifactId>
- <version>4.11.4</version>
+ <version>4.13.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
try{
Taxon taxon = HibernateProxyHelper.deproxy(taxonNode.getTaxon());
if(taxon == null){
- String text = taxonNode.getClassification().getName().getText();
+ String text = taxonNode.getClassification().getName() == null ? null : taxonNode.getClassification().getName().getText();
if(text==null){
text = taxonNode.getClassification().getTitleCache();
}
List<UUID> excludeTaxa = new ArrayList<UUID>();
excludeTaxa.add(((TaxonNode)oldAcceptedTaxonNode).getTaxon().getUuid());
TaxonNode newAcceptedTaxonNode = TaxonNodeSelectionDialog.select(shell,
- taxonNavigator.getConversationHolder(),
+// taxonNavigator.getConversationHolder(),
Messages.ChangeAcceptedTaxonToSynonymHandler_CHOOSE_TAXON,
excludeTaxa,
null,
List<UUID> excludeTaxa = new ArrayList<UUID>();
excludeTaxa.add(taxon.getUuid());
TaxonNode dialogTaxonNode = TaxonNodeSelectionDialog.select(shell,
- taxonNavigator.getConversationHolder(),
+// taxonNavigator.getConversationHolder(),
Messages.MoveFactualDataHandler_CHOOSE_TAXON,
excludeTaxa,
sourceTaxonNode,
if(!MessageDialog.openQuestion(null, Messages.MoveTaxonHandler_TARGET_NODE, Messages.MoveTaxonHandler_TARGET_NODE_MESSAGE)){
moveToNewParent = MovingType.BEHIND;
}
- parentTaxonNode = TaxonNodeSelectionDialog.select(shell, taxonNavigator.getConversationHolder(), Messages.MoveTaxonHandler_CHOOSE_ABOVE, excludeTaxa, null, classification);
+ parentTaxonNode = TaxonNodeSelectionDialog.select(shell, //taxonNavigator.getConversationHolder(),
+ Messages.MoveTaxonHandler_CHOOSE_ABOVE, excludeTaxa, null, classification);
}else{
- parentTaxonNode = TaxonNodeSelectionDialog.select(shell, taxonNavigator.getConversationHolder(), Messages.MoveTaxonHandler_CHOOSE_PARENT, excludeTaxa, null, classification);
+ parentTaxonNode = TaxonNodeSelectionDialog.select(shell, //taxonNavigator.getConversationHolder(),
+ Messages.MoveTaxonHandler_CHOOSE_PARENT, excludeTaxa, null, classification);
}
if(parentTaxonNode != null){
if(NavigationUtil.isDirty(parentTaxonNode, partService)){
import org.eclipse.jface.viewers.TreeSelection;
import org.eclipse.swt.widgets.Shell;
-import eu.etaxonomy.cdm.api.conversation.ConversationHolderMock;
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
import eu.etaxonomy.taxeditor.editor.EditorUtil;
import eu.etaxonomy.taxeditor.navigation.l10n.Messages;
List<UUID> excludeTaxa = new ArrayList<UUID>();
excludeTaxa.add(oldTaxonNode.getTaxon().getUuid());
TaxonNode newAcceptedTaxonNode = TaxonNodeSelectionDialog.select(shell,
- new ConversationHolderMock(),
+// new ConversationHolderMock(),
Messages.RemotingChangeAcceptedTaxonToSynonymHandler_CHOOSE_TAXON,
excludeTaxa,
oldTaxonNode,
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
-import eu.etaxonomy.cdm.api.conversation.ConversationHolderMock;
import eu.etaxonomy.cdm.model.taxon.ITaxonTreeNode;
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
import eu.etaxonomy.taxeditor.navigation.NavigationUtil;
excludeTaxa.add(sourceTaxonNode.getTaxon().getUuid());
targetTaxonNode = TaxonNodeSelectionDialog.select(shell,
- new ConversationHolderMock(),
+// new ConversationHolderMock(),
Messages.RemotingMoveFactualDataHandler_CHOOSE_TAXA,
excludeTaxa,
sourceTaxonNode,
import org.eclipse.jface.viewers.TreeSelection;
import org.eclipse.swt.widgets.Shell;
-import eu.etaxonomy.cdm.api.conversation.ConversationHolderMock;
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
import eu.etaxonomy.taxeditor.navigation.NavigationUtil;
import eu.etaxonomy.taxeditor.navigation.l10n.Messages;
parentTaxonNode = TaxonNodeSelectionDialog.select(shell,
- new ConversationHolderMock(),
+// new ConversationHolderMock(),
Messages.RemotingMoveTaxonNodeHandler_CHOOSE_TAXON,
excludeTaxa,
null,
}
} else {
parentTaxonNode = TaxonNodeSelectionDialog.select(shell,
- new ConversationHolderMock(),
+// new ConversationHolderMock(),
Messages.RemotingMoveTaxonNodeHandler_CHOOSE_PARENT,
excludeTaxa,
oldTaxonNode,
Bundle-ManifestVersion: 2
Bundle-Name: Printpublisher Bundle
Bundle-SymbolicName: eu.etaxonomy.taxeditor.printpublisher;singleton:=true
-Bundle-Version: 4.11.4
+Bundle-Version: 4.13.0.qualifier
Require-Bundle: org.eclipse.osgi,
org.eclipse.ui,
eu.etaxonomy.taxeditor.cdmlib,
<parent>
<artifactId>taxeditor-parent</artifactId>
<groupId>eu.etaxonomy</groupId>
- <version>4.11.4</version>
+ <version>4.13.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
Bundle-ManifestVersion: 2
Bundle-Name: DataStore Bundle
Bundle-SymbolicName: eu.etaxonomy.taxeditor.store;singleton:=true
-Bundle-Version: 4.11.4
+Bundle-Version: 4.13.0.qualifier
Bundle-Activator: eu.etaxonomy.taxeditor.store.internal.TaxeditorStorePlugin
Bundle-Vendor: EDIT
Bundle-Localization: OSGI-INF/l10n/bundle
view.name.6 = Derivatsuche
view.name.7 = Specimensuche
view.name.8 = GBIF Specimen Import
+view.name.9 = Auswahl
editor.name = Editor f\u00fcr definierte Begriffe
command.label = Derivatsuche
command.label.0 = Details
<elements xsi:type="basic:PartDescriptor" xmi:id="_N9AMYKkNEeejedk4mZQIGw" elementId="eu.etaxonomy.taxeditor.view.dataimport.e4.GbifResponseImportViewE4" label="%view.name.8" allowMultiple="true" closeable="true" contributionURI="bundleclass://eu.etaxonomy.taxeditor.store/eu.etaxonomy.taxeditor.view.dataimport.e4.GbifResponseImportViewE4">
<tags>nonRestore</tags>
</elements>
+ <elements xsi:type="basic:PartDescriptor" xmi:id="_aT37QM3UEeeznb_sS6rfAQ" elementId="eu.etaxonomy.taxeditor.store.partdescriptor.SearchDialog" label="%view.name.9" contributionURI="bundleclass://eu.etaxonomy.taxeditor.store/eu.etaxonomy.taxeditor.ui.dialog.selection.SearchDialog"/>
</fragments>
<fragments xsi:type="fragment:StringModelFragment" xmi:id="_3rW8wCXaEeex9MwMOgUeWw" featurename="children" parentElementId="eu.etaxonomy.taxeditor.menu.showView" positionInList="after:eu.etaxonomy.taxeditor.workbench.menuseparator.afterConcept">
<elements xsi:type="menu:HandledMenuItem" xmi:id="_TlufMCaGEeeTEd_pKXBflg" elementId="eu.etaxonomy.taxeditor.store.showViewMenu.supplemental" label="%command.label.1" iconURI="platform:/plugin/eu.etaxonomy.taxeditor.store/icons/applications-office.png" tooltip="%command.label.1" command="_bnVKsCZxEeeQLpuomSmVoQ">
<parent>
<groupId>eu.etaxonomy</groupId>
<artifactId>taxeditor-parent</artifactId>
- <version>4.11.4</version>
+ <version>4.13.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
}
}
- FeatureTree tree = FeatureTreeSelectionDialog.select(composite.getDisplay().getActiveShell(), conversation, null);
+ FeatureTree tree = FeatureTreeSelectionDialog.select(composite.getDisplay().getActiveShell(), //conversation,
+ null);
if (tree != null) {
composite.setSelectedTree(tree, FeatureTreeEditor.this);
}
@Override
public void handleEvent(Event event) {
if(event.widget==btnBrowseClassification){
- classification = SelectionDialogFactory.getSelectionFromDialog(Classification.class, getShell(), null, null);
+ classification = SelectionDialogFactory.getSelectionFromDialog(Classification.class, this.getShell(), null, null);
if(classification!=null){
textClassification.setText(classification.getTitleCache());
}
import org.eclipse.e4.core.contexts.IEclipseContext;
import org.eclipse.ui.progress.IProgressConstants;
+import eu.etaxonomy.cdm.io.common.ExportResultType;
import eu.etaxonomy.cdm.io.csv.caryophyllales.out.CsvNameExportConfigurator;
import eu.etaxonomy.taxeditor.io.e4.out.csv.name.CsvNameExportWizardE4;
import eu.etaxonomy.taxeditor.io.wizard.ExportToFileDestinationWizardPage;
+ page.getExportFileName();
configurator.setClassificationUUID(page.getSelectedClassificationUUID());
+ configurator.setResultType(ExportResultType.BYTE_ARRAY);
// create job
Job job = CdmStore.getExportManager().createIOServiceJob(configurator, new File(urlString));
// configure the job
public static String TCSImportWizard_ConfiguratorWizard_label;
+ public static String SearchDialog_patternLabel;
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+ public static String SelectionViewMenu_SET_FLAG;
+ public static String SelectionViewMenu_selectVocabulary;
+ public static String SelectionViewMenu_4_YES;
+ public static String SelectionViewMenu_NO;
SetPublishConfiguration_Title=Configuration for setting the publish flag
SetPublishConfiguration_publish=publish
SetPublishConfiguration_dont_publish=don't publish
+
+SearchDialog_patternLabel=Use * for wildcard
+SearchDialog_listLabel=&Matching items:
+
+SelectionViewMenu_selectVocabulary=choose vocabulary
+SelectionViewMenu_SET_FLAG='%s' set flag
+SelectionViewMenu_4_YES=Yes
+SelectionViewMenu_NO=No
SetPublishConfiguration_Title=Konfiguration zum Setzen des Publish Flags
SetPublishConfiguration_publish=veröffentlichen
SetPublishConfiguration_dont_publish=nicht veröffentlichen
+
+SearchDialog_patternLabel=Nutze * als Platzhalter für eine beliebige Zeichenkette
+SearchDialog_listLabel=&Passende Objekte:
+
+SelectionViewMenu_selectVocabulary=Vokabular wählen
+SelectionViewMenu_SET_FLAG='%s' flag setzen
+SelectionViewMenu_4_YES=Ja
+SelectionViewMenu_NO=Nein
import eu.etaxonomy.cdm.api.application.CdmApplicationState;
import eu.etaxonomy.cdm.api.service.IProgressMonitorService;
+import eu.etaxonomy.cdm.api.service.UpdateResult;
import eu.etaxonomy.cdm.common.monitor.IRemotingProgressMonitor;
import eu.etaxonomy.cdm.io.common.ExportDataWrapper;
import eu.etaxonomy.cdm.io.common.ExportResult;
final StringBuilder reportSb = new StringBuilder();
// collect reports
// for(String report : remotingMonitor.getResult()) {
+ if (remotingMonitor.getResult() instanceof ExportResult) {
reportSb.append(((ExportResult)remotingMonitor.getResult()).createReport());
+ }else if (remotingMonitor.getResult() instanceof UpdateResult){
+ reportSb.append(((UpdateResult)remotingMonitor.getResult()).getExceptions().toString());
+ }
// }
if(!StringUtils.isBlank(reportSb.toString())) {
Display.getDefault().asyncExec(new Runnable() {
import org.eclipse.jface.viewers.CheckStateChangedEvent;
import org.eclipse.jface.viewers.CheckboxTreeViewer;
import org.eclipse.jface.viewers.ICheckStateListener;
-import org.eclipse.jface.viewers.ITreeSelection;
import org.eclipse.jface.viewers.StyledString.Styler;
import org.eclipse.jface.viewers.TreePath;
import org.eclipse.jface.wizard.WizardPage;
ignoreCheckEvent = true;
try {
- TreePath path = ((ITreeSelection) viewer.getSelection()).getPaths()[0];
+
checkChildren(event.getElement(), event.getChecked());
- checkParents(path.getParentPath());
+
+ grayParents(event.getElement());
}
finally {
ignoreCheckEvent = false;
}
List<TermVocabulary<DefinedTermBase>> vocs = CdmStore.getService(IVocabularyService.class).findByTermType(
TermType.NamedArea, null);
+
return vocs;
}
}
}
}
+ /**
+ *
+ * @param path
+ * @param checked
+ */
+ private void grayParents(final Object element) {
+ TermContentProvider tcp = new TermContentProvider();
+
+ if (element == null) {
+ return;
+ }
+ // final Object element = path.getLastSegment();
+ Object parent = tcp.getParent(element);
+ if (parent != null) {
+ boolean allChecked = true;
+ boolean allUnchecked = true;
+ for (final Object fieldElement : tcp.getChildren(parent)) {
+ allChecked = allChecked && this.viewer.getChecked(fieldElement);
+ allUnchecked = allUnchecked && !this.viewer.getChecked(fieldElement);
+ }
+ if (allUnchecked) {
+ this.viewer.setChecked(parent, false);
+ this.viewer.setGrayed(parent, false);
+ } else if (allChecked) {
+ this.viewer.setChecked(parent, true);
+ this.viewer.setGrayed(parent, false);
+ } else if (!allUnchecked && !allChecked) {
+ this.viewer.setChecked(parent, true);
+ this.viewer.setGrayed(parent, true);
+ }
+
+ grayParents(tcp.getParent(parent));
+ }
+ }
@Override
public void dispose() {
import eu.etaxonomy.cdm.api.service.IOccurrenceService;
import eu.etaxonomy.cdm.api.service.IPolytomousKeyNodeService;
import eu.etaxonomy.cdm.api.service.IPolytomousKeyService;
+import eu.etaxonomy.cdm.api.service.IPreferenceService;
import eu.etaxonomy.cdm.api.service.IReferenceService;
import eu.etaxonomy.cdm.api.service.IRegistrationService;
import eu.etaxonomy.cdm.api.service.IRightsService;
import eu.etaxonomy.cdm.model.description.WorkingSet;
import eu.etaxonomy.cdm.model.media.Media;
import eu.etaxonomy.cdm.model.media.Rights;
+<<<<<<< HEAD
+import eu.etaxonomy.cdm.model.metadata.CdmPreference;
+=======
+>>>>>>> master
import eu.etaxonomy.cdm.model.molecular.Amplification;
import eu.etaxonomy.cdm.model.molecular.Primer;
import eu.etaxonomy.cdm.model.name.Registration;
}
else if (cdmBase instanceof Amplification) {
service = (IService<T>) getService(IAmplificationService.class);
- }
+ }
else if (cdmBase instanceof PolytomousKey) {
service = (IService<T>) getService(IPolytomousKeyService.class);
}
else if (cdmBase instanceof Annotation) {
service = (IService<T>) getService(IAnnotationService.class);
}
-// else if (cdmBase instanceof AuditEvent) {
-// service = (IService<T>) getService(IAuditEventService.class);
-// }
else if (cdmBase instanceof Classification) {
service = (IService<T>) getService(IClassificationService.class);
}
else if (cdmBase instanceof Rights) {
service = (IService<T>) getService(IRightsService.class);
}
+<<<<<<< HEAD
+// else if (cdmBase instanceof AuditEvent) {
+// service = (IService<T>) getService(IAuditEventService.class);
+// }
+// else if (cdmBase instanceof CdmPreference) {
+// service = (IService<T>) getService(IPreferenceService.class);
+// }
+=======
+>>>>>>> master
else{
String message = "Service for entity of class %s not yet implemented in TaxEditor";
message = String.format(message, cdmBase.getClass().getSimpleName());
protected void createControls(ICdmFormElement formElement, Classification entity, int style) {
txtClassificationName = formFactory.createTextWithLabelElement(formElement, "Classification name", null, style);
comboRelationType = formFactory.createDefinedTermComboElement(TermType.TaxonRelationshipType, formElement, "Taxon relation", null, style);
- selectReference = formFactory.createSelectionElement(Reference.class, getConversationHolder(), formElement, "Reference", null, EntitySelectionElement.SELECTABLE, style);
+ selectReference = formFactory.createSelectionElement(Reference.class, //getConversationHolder(),
+ formElement, "Reference", null, EntitySelectionElement.SELECTABLE, style);
}
@Override
package eu.etaxonomy.taxeditor.ui.dialog.selection;
import java.text.Collator;
+import java.util.ArrayList;
+import java.util.Collections;
import java.util.Comparator;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
import java.util.UUID;
-import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.OperationCanceledException;
-import org.eclipse.core.runtime.Status;
import org.eclipse.jface.dialogs.IDialogSettings;
import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.window.Window;
import org.eclipse.jface.wizard.WizardDialog;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.graphics.Cursor;
+import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Link;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.IMemento;
-import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
-import eu.etaxonomy.cdm.api.conversation.IConversationEnabled;
import eu.etaxonomy.cdm.model.common.CdmBase;
import eu.etaxonomy.cdm.model.common.ICdmBase;
import eu.etaxonomy.cdm.model.common.IIdentifiableEntity;
import eu.etaxonomy.cdm.persistence.dto.UuidAndTitleCache;
-import eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap;
+import eu.etaxonomy.taxeditor.l10n.Messages;
import eu.etaxonomy.taxeditor.model.MessagingUtils;
import eu.etaxonomy.taxeditor.newWizard.AbstractNewEntityWizard;
import eu.etaxonomy.taxeditor.preference.IPreferenceKeys;
* @version 1.0
*/
public abstract class AbstractFilteredCdmResourceSelectionDialog<T extends ICdmBase> extends
- CdmFilteredItemsSelectionDialog implements IConversationEnabled {
+ SearchDialog {//implements IConversationEnabled {
- private final ConversationHolder conversation;
+// private final ConversationHolder conversation = null;
protected List<UuidAndTitleCache<T>> model;
private final Set<T> transientCdmObjects = new HashSet<T>();
private final String settings;
protected final int limitOfInitialElements = 100;
+ private T selectedObject;
+
protected T cdmBaseToBeFiltered;
* @param cdmObject a T object.
* @param <T> a T object.
*/
- protected AbstractFilteredCdmResourceSelectionDialog(Shell shell, ConversationHolder conversation, String title, boolean multi, String settings, T cdmObject) {
+ protected AbstractFilteredCdmResourceSelectionDialog(Shell shell, //ConversationHolder conversation,
+ String title, boolean multi, String settings, T cdmObject) {
super(shell, multi);
+ setShellStyle(SWT.DIALOG_TRIM);
setTitle(title);
- setMessage("Use * for wildcard, or ? to see all entries");
+ setMessage(Messages.SearchDialog_patternLabel);
this.settings = settings;
- this.conversation = conversation;
+// this.conversation = conversation;
this.cdmBaseToBeFiltered = cdmObject;
Cursor cursor = shell.getCursor();
shell.setCursor(shell.getDisplay().getSystemCursor(SWT.CURSOR_WAIT));
init();
-// initModel();
shell.setCursor(cursor);
- String objectTitle = getTitle(cdmObject);
-// if (objectTitle != null) {
-// setInitialPattern(objectTitle);
-// }
-
setListLabelProvider(createListLabelProvider());
- setDetailsLabelProvider(createDetailsLabelProvider());
- setSelectionHistory(new ResourceSelectionHistory());
}
/**
* @return a TYPE object.
*/
protected static <TYPE extends CdmBase> TYPE getSelectionFromDialog(AbstractFilteredCdmResourceSelectionDialog<TYPE> dialog) {
- //dialog.setInitialPattern("");
int result = dialog.open();
if (result == Window.CANCEL) {
return null;
}
- UUID uuid = dialog.getSelectedUuidAndTitleCache().getUuid();
+ UuidAndTitleCache uuid = dialog.getSelectedUuidAndTitleCache();
if(uuid == null){
return null;
}
- return dialog.getCdmObjectByUuid(uuid);
+ return dialog.getCdmObjectByUuid(uuid.getUuid());
}
/**
*/
abstract protected T getPersistentObject(UUID uuid);
- /**
- * @param cdmObject
- */
-// protected void addObjectToModel(T cdmObject) {
-// model.add(new UuidAndTitleCache(cdmObject.getClass(), cdmObject.getUuid(), getTitle(cdmObject)));
-// transientCdmObjects.add(cdmObject);
-// }
/**
* <p>isObjectTransient</p>
}
- /** {@inheritDoc} */
- @Override
- public void refresh() {
- super.refresh();
- }
-
-
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.dialogs.FilteredItemsSelectionDialog#createFilter()
- */
- /** {@inheritDoc} */
- @Override
- protected ItemsFilter createFilter() {
- return new ItemsFilter() {
-
- /**
- * Always returns false to enforce refiltering even if the pattern is equal
- */
- @Override
- public boolean equalsFilter(ItemsFilter filter) {
- return false;
- }
-
- @Override
- public boolean isConsistentItem(Object item) {
- return false;
- }
-
- @Override
- public boolean matchItem(Object item) {
- String text = null;
- if(item instanceof UuidAndTitleCache){
- text = ((UuidAndTitleCache) item).getTitleCache();
- }else if(item instanceof String){
- text = (String) item;
- }
- return text != null ? matches(text) : false;
- }
-
- };
- }
-
/**
* Set the filter input to the Agent's title cache
* @param cdmObject a T object.
*/
protected void setPattern(T cdmObject) {
- // FilteredSelection does some very tricky caching to make sure it
- // runs with high performance.
- // This works for most use cases, but we want to change the model while the dialog is open
- // and all the clever caching prevents the content provider from knowing that the model has changed
- // I am aware, that this is a hack, but the FilteredSelectionDialog API does not offer a convenient
- // way to solve the problem.
-// try {
-// Field lastCompletedFilter = this.getClass().getSuperclass().getSuperclass().getDeclaredField("lastCompletedFilter");
-// lastCompletedFilter.setAccessible(true);
-// lastCompletedFilter.set(this, null);
-// } catch (SecurityException e) {
-// MessagingUtils.error(getClass(), e);
-// } catch (NoSuchFieldException e) {
-// MessagingUtils.error(getClass(), e);
-// } catch (IllegalArgumentException e) {
-// MessagingUtils.error(getClass(), e);
-// } catch (IllegalAccessException e) {
-// MessagingUtils.error(getClass(), e);
-// }
-
- // this also is not the nicest way to do it.
- // I am still amazed, that FilteredSelectionDialog does not offer any methods to change its data
- // once it was opened. Am I doing it wrong?
String pattern = getTitle(cdmObject);
- ((Text) getPatternControl()).setText(pattern);
+ getSearchField().setText(pattern);
}
* @see org.eclipse.ui.dialogs.FilteredItemsSelectionDialog#fillContentProvider(org.eclipse.ui.dialogs.FilteredItemsSelectionDialog.AbstractContentProvider, org.eclipse.ui.dialogs.FilteredItemsSelectionDialog.ItemsFilter, org.eclipse.core.runtime.IProgressMonitor)
*/
/** {@inheritDoc} */
+
@Override
- protected void fillContentProvider(AbstractContentProvider contentProvider,
- ItemsFilter itemsFilter, IProgressMonitor progressMonitor)
- throws CoreException {
+ protected void fillContentProvider(IProgressMonitor progressMonitor)
+ {
try {
+ if (model == null){
+ model = new ArrayList<UuidAndTitleCache<T>>();
+ }
if(model != null){
- progressMonitor.beginTask("Looking for entities", model.size());
- filterExcludedObjects();
+ if (progressMonitor != null){
+ progressMonitor.beginTask("Looking for entities", model.size());
+ }
+ Collections.sort(model, getItemsComparator());
+ contentProvider.reset();
Iterator<UuidAndTitleCache<T>> iterator = model.iterator();
UuidAndTitleCache<T> element;
while(iterator.hasNext()){
element = iterator.next();
if (!element.equals(cdmBaseToBeFiltered)){
- contentProvider.add(element, itemsFilter);
+ contentProvider.add(element);
+ }
+ if (progressMonitor != null){
+ if (progressMonitor.isCanceled()) {
+ return;
+ }
+ progressMonitor.worked(1);
}
- if (progressMonitor.isCanceled()) {
- throw new OperationCanceledException();
- }
- progressMonitor.worked(1);
}
+ this.refresh();
}else{
+
MessagingUtils.warn(getClass(), "Model for Filtered Selection is null:" + this.getClass().getSimpleName());
}
}
finally {
- progressMonitor.done();
+ if (progressMonitor != null) {
+ progressMonitor.done();
+ }
}
}
* @see org.eclipse.ui.dialogs.FilteredItemsSelectionDialog#getDialogSettings()
*/
/** {@inheritDoc} */
- @Override
+
protected IDialogSettings getDialogSettings() {
IDialogSettings settings = TaxeditorStorePlugin.getDefault().getDialogSettings().getSection(getSettings());
* @see org.eclipse.ui.dialogs.FilteredItemsSelectionDialog#getElementName(java.lang.Object)
*/
/** {@inheritDoc} */
- @Override
+
public String getElementName(Object item) {
return ((UuidAndTitleCache) item).getTitleCache();
}
* @see org.eclipse.ui.dialogs.FilteredItemsSelectionDialog#getItemsComparator()
*/
/** {@inheritDoc} */
+
@Override
- protected Comparator getItemsComparator() {
+ protected Comparator getItemsComparator() {
return new Comparator<UuidAndTitleCache>() {
@Override
public int compare(UuidAndTitleCache entity1,
};
}
- /* (non-Javadoc)
- * @see org.eclipse.ui.dialogs.FilteredItemsSelectionDialog#validateItem(java.lang.Object)
- */
- /** {@inheritDoc} */
- @Override
- protected IStatus validateItem(Object item) {
- return Status.OK_STATUS;
- }
/**
* <p>getSelectedUuidAndTitleCache</p>
* @return a {@link eu.etaxonomy.cdm.model.common.UuidAndTitleCache} object.
*/
protected UuidAndTitleCache getSelectedUuidAndTitleCache() {
- Object[] result = getResult();
- return result[0] == null ? null : (UuidAndTitleCache) result[0];
+ Object result = getResult();
+ if (result instanceof UuidAndTitleCache){
+ return (UuidAndTitleCache) result;
+ }
+ return null;
}
/**
+ * @return
+ */
+ private Object getResult() {
+ StructuredSelection selection = getCurrentSelection();
+ if (selection == null){
+ return null;
+ }
+ return selection.getFirstElement();
+ }
+
+ /**
* <p>Getter for the field <code>settings</code>.</p>
*
* @return a {@link java.lang.String} object.
return settings;
}
- /**
- *
- * @author n.hoffmann
- * @created Oct 19, 2009
- * @version 1.0
- */
- private class ResourceSelectionHistory extends SelectionHistory {
- /*
- * @see org.eclipse.ui.dialogs.FilteredItemsSelectionDialog.SelectionHistory#restoreItemFromMemento(org.eclipse.ui.IMemento)
- */
- @Override
- protected Object restoreItemFromMemento(IMemento element) {
- return element.getString("resource"); //$NON-NLS-1$
- }
- /*
- * @see org.eclipse.ui.dialogs.FilteredItemsSelectionDialog.SelectionHistory#storeItemToMemento(java.lang.Object,
- * org.eclipse.ui.IMemento)
- */
- @Override
- protected void storeItemToMemento(Object item, IMemento element) {
- element.putString("resource", item.toString()); //$NON-NLS-1$
- }
- }
+
/**
* <p>getNewWizardLinkText</p>
*
* @return a {@link java.lang.String} object.
*/
- protected abstract String getNewWizardLinkText();
+ protected abstract String[] getNewWizardText();
/**
* <p>getNewEntityWizard</p>
* @see org.eclipse.ui.dialogs.FilteredItemsSelectionDialog#createExtendedContentArea(org.eclipse.swt.widgets.Composite)
*/
/** {@inheritDoc} */
- @Override
- protected Control createExtendedContentArea(Composite parent) {
- String newWizardLinkText = getNewWizardLinkText();
- if(newWizardLinkText != null){
- Link link = new Link(parent, SWT.NONE);
- link.setText(newWizardLinkText);
- link.addSelectionListener(getNewWizardLinkSelectionListener());
- return link;
- }
- return null;
- }
- protected SelectionListener getNewWizardLinkSelectionListener(){
+// @Override
+// protected Control createExtendedContentArea(Composite parent) {
+// String newWizardLinkText = getNewWizardLinkText();
+//// if(newWizardLinkText != null){
+//// newButton1 = this.createButton(this.getShell(), new_id, newWizardLinkText, false);
+////
+//// newButton1.addSelectionListener(getNewWizardLinkSelectionListener());
+//// return newButton1;
+//// }
+// return null;
+// }
+
+ @Override
+ protected void createButtonsForButtonBar(Composite parent) {
+ String[] newButtonText = getNewWizardText();
+ if (newButtonText!= null){
+ this.newButton1 = createButton(parent, this.new_id, newButtonText[0], false);
+ newButton1.addSelectionListener(getNewWizardButtonSelectionListener());
+ if (newButtonText.length > 1){
+ newButton2 = createButton(parent, this.new_id2, newButtonText[1], false);
+ newButton2.addSelectionListener(getNewWizardButtonSelectionListener());
+ }
+ }
+ //Label label = new Label(parent, SWT.NONE);
+ super.createButtonsForButtonBar(parent);
+ }
+
+ protected SelectionListener getNewWizardButtonSelectionListener(){
return new SelectionAdapter() {
/* (non-Javadoc)
*/
@Override
public void widgetSelected(SelectionEvent e) {
-
- AbstractNewEntityWizard wizard = getNewEntityWizard(e.text);
+ Object source = e.getSource();
+ String text = null;
+ if (source instanceof Button){
+ Button sourceButton = (Button) source;
+ text = sourceButton.getText();
+ }
+ AbstractNewEntityWizard wizard = getNewEntityWizard(text);
if(wizard!=null){
wizard.init(null, null);
if(wizard.getEntity() != null) {
if (status == IStatus.OK) {
T entity = (T) wizard.getEntity();
- // model.add(new UuidAndTitleCache<T>(entity.getUuid(), entity.getId(), getTitle(entity)));
refresh();
setPattern(entity);
- if (getConversationHolder() != null){
- getConversationHolder().bind();
- }
+// if (getConversationHolder() != null){
+// getConversationHolder().bind();
+// }
}
//FIXME : Need to make sure this is a stable fix (ticket 3822)
- if (getConversationHolder() != null){
- getConversationHolder().commit();
- }
+// if (getConversationHolder() != null){
+// getConversationHolder().commit();
+// }
}
}
}
* <p>getConversationHolder</p>
*
* @return a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder} object.
- */
- @Override
- public ConversationHolder getConversationHolder() {
- return conversation;
- }
+// */
+// @Override
+// public ConversationHolder getConversationHolder() {
+// return conversation;
+// }
/** {@inheritDoc} */
- @Override
- public void update(CdmDataChangeMap changeEvents) {}
+// @Override
+// public void update(CdmDataChangeMap changeEvents) {}
/**
* Don't want to add for example a taxon or synonym to itself
model.remove(uuidAndTitleCacheToRemove);
}
}
+ @Override
+ void createFilterButton(Composite searchAndFilter){
+ //as default no filter button available
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ protected void search() {
+ Control control =getSearchField();
+ String pattern = null;
+ if (control != null){
+ pattern = ((Text)control).getText();
+ if (pattern.equals("*")){
+ callService(null);
+ }else if (pattern != null){
+ callService(pattern);
+ }
+ fillContentProvider(null);
+ }
+
+// if (pattern.equals("?")){
+// model = CdmStore.getService(INameService.class).getUuidAndTitleCache(null, null);
+// }else if (pattern != null){
+// model = CdmStore.getService(INameService.class).getUuidAndTitleCache(limitOfInitialElements, pattern);
+// }
+ }
+
+ abstract void callService(String pattern);
+
}
--- /dev/null
+package eu.etaxonomy.taxeditor.ui.dialog.selection;
+
+import java.text.Collator;
+/**
+* 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.
+*/
+import java.util.Comparator;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+import java.util.UUID;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.OperationCanceledException;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.dialogs.IDialogSettings;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.window.Window;
+import org.eclipse.jface.wizard.WizardDialog;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Link;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.IMemento;
+
+import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
+import eu.etaxonomy.cdm.api.conversation.IConversationEnabled;
+import eu.etaxonomy.cdm.api.service.dto.IdentifiedEntityDTO;
+import eu.etaxonomy.cdm.model.common.CdmBase;
+import eu.etaxonomy.cdm.model.common.ICdmBase;
+import eu.etaxonomy.cdm.model.common.IIdentifiableEntity;
+import eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap;
+import eu.etaxonomy.taxeditor.model.MessagingUtils;
+import eu.etaxonomy.taxeditor.newWizard.AbstractNewEntityWizard;
+import eu.etaxonomy.taxeditor.preference.IPreferenceKeys;
+import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
+import eu.etaxonomy.taxeditor.store.internal.TaxeditorStorePlugin;
+
+public abstract class AbstractFilteredIdentifierSelectionDialog<T extends ICdmBase> extends CdmFilteredItemsSelectionDialog implements IConversationEnabled {
+
+ private final ConversationHolder conversation;
+
+ protected List<IdentifiedEntityDTO> model;
+ private final Set<T> transientCdmObjects = new HashSet<T>();
+ private final String settings;
+ protected final int limitOfInitialElements = 100;
+
+ protected T cdmBaseToBeFiltered;
+
+
+ /**
+ * <p>Constructor for AbstractFilteredCdmResourceSelectionDialog.</p>
+ *
+ * @param shell a {@link org.eclipse.swt.widgets.Shell} object.
+ * @param conversation
+ * @param title a {@link java.lang.String} object.
+ * @param multi a boolean.
+ * @param settings a {@link java.lang.String} object.
+ * @param cdmObject a T object.
+ * @param <T> a T object.
+ */
+ protected AbstractFilteredIdentifierSelectionDialog(Shell shell, ConversationHolder conversation, String title, boolean multi, String settings, T cdmObject) {
+ super(shell, multi);
+ setTitle(title);
+ setMessage("Use * for wildcard, or ? to see all entries");
+ this.settings = settings;
+
+ this.conversation = conversation;
+ this.cdmBaseToBeFiltered = cdmObject;
+ org.eclipse.swt.graphics.Cursor cursor = shell.getCursor();
+ shell.setCursor(shell.getDisplay().getSystemCursor(SWT.CURSOR_WAIT));
+ init();
+// initModel();
+ shell.setCursor(cursor);
+ String objectTitle = getTitle(cdmObject);
+// if (objectTitle != null) {
+// setInitialPattern(objectTitle);
+// }
+
+ setListLabelProvider(createListLabelProvider());
+ setDetailsLabelProvider(createDetailsLabelProvider());
+
+ setSelectionHistory(new IdentifierSelectionHistory());
+ }
+
+ /**
+ * By default, we are returning the standard list label provider
+ *
+ * Override in subclasses if you want different behavior
+ *
+ * @return
+ */
+ protected ILabelProvider createDetailsLabelProvider() {
+ return createListLabelProvider();
+ }
+
+ /**
+ *
+ * @return
+ */
+ protected ILabelProvider createListLabelProvider() {
+ return new FilteredIdentifiedEntityLabelProvider();
+ }
+
+ /**
+ * Override in subclasses.
+ * Will run before initModel()
+ */
+ protected void init() {
+
+ }
+
+ /**
+ * <p>getSelectionFromDialog</p>
+ *
+ * @param dialog a {@link eu.etaxonomy.taxeditor.ui.dialog.selection.AbstractFilteredCdmResourceSelectionDialog} object.
+ * @param <TYPE> a TYPE object.
+ * @return a TYPE object.
+ */
+ protected static <TYPE extends CdmBase> TYPE getSelectionFromDialog(AbstractFilteredCdmResourceSelectionDialog<TYPE> dialog) {
+ //dialog.setInitialPattern("");
+ int result = dialog.open();
+
+ if (result == Window.CANCEL) {
+ return null;
+ }
+
+ UUID uuid = dialog.getSelectedUuidAndTitleCache().getUuid();
+ if(uuid == null){
+ return null;
+ }
+ return dialog.getCdmObjectByUuid(uuid);
+ }
+
+ /**
+ * Check if object was created during the life of this dialog. If not,
+ * retrieve it from the CdmStore.
+ *
+ * @param cdmUuid a {@link java.util.UUID} object.
+ * @return a T object.
+ */
+ protected T getCdmObjectByUuid(UUID cdmUuid) {
+ for (T cdmObject : transientCdmObjects) {
+ if (cdmObject.getUuid().equals(cdmUuid)) {
+ return cdmObject;
+ }
+ }
+ return getPersistentObject(cdmUuid);
+ }
+
+ /**
+ * <p>getPersistentObject</p>
+ *
+ * @param uuid a {@link java.util.UUID} object.
+ * @return a T object.
+ */
+ abstract protected T getPersistentObject(UUID uuid);
+
+ /**
+ * @param cdmObject
+ */
+// protected void addObjectToModel(T cdmObject) {
+// model.add(new UuidAndTitleCache(cdmObject.getClass(), cdmObject.getUuid(), getTitle(cdmObject)));
+// transientCdmObjects.add(cdmObject);
+// }
+
+ /**
+ * <p>isObjectTransient</p>
+ *
+ * @param cdmObject a T object.
+ * @return a boolean.
+ */
+ protected boolean isObjectTransient(T cdmObject) {
+ return (getPersistentObject(cdmObject.getUuid()) == null);
+ }
+
+ /**
+ * <p>getTitle</p>
+ *
+ * @param cdmObject a T object.
+ * @return a {@link java.lang.String} object.
+ */
+ protected String getTitle(T cdmObject) {
+ if(cdmObject == null){
+ return "";
+ }
+
+ if (cdmObject instanceof IIdentifiableEntity) {
+ return ((IIdentifiableEntity) cdmObject).getTitleCache();
+ }
+
+ throw new IllegalArgumentException("Generic method only" +
+ " supports cdmObject of type IIdentifiableEntity." +
+ " Please implement specific method in subclass.");
+ }
+
+
+ /** {@inheritDoc} */
+ @Override
+ public void refresh() {
+ super.refresh();
+ }
+
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.dialogs.FilteredItemsSelectionDialog#createFilter()
+ */
+ /** {@inheritDoc} */
+ @Override
+ protected ItemsFilter createFilter() {
+ return new ItemsFilter() {
+
+ /**
+ * Always returns false to enforce refiltering even if the pattern is equal
+ */
+ @Override
+ public boolean equalsFilter(ItemsFilter filter) {
+ return false;
+ }
+
+ @Override
+ public boolean isConsistentItem(Object item) {
+ return false;
+ }
+
+ @Override
+ public boolean matchItem(Object item) {
+ String text = null;
+ if(item instanceof IdentifiedEntityDTO){
+ text = ((IdentifiedEntityDTO) item).getCdmEntity().getTitleCache();
+ }else if(item instanceof String){
+ text = (String) item;
+ }
+ return text != null ? matches(text) : false;
+ }
+
+ };
+ }
+
+
+ /**
+ * Set the filter input to the Agent's title cache
+ *
+ * @param cdmObject a T object.
+ */
+ protected void setPattern(T cdmObject) {
+ // FilteredSelection does some very tricky caching to make sure it
+ // runs with high performance.
+ // This works for most use cases, but we want to change the model while the dialog is open
+ // and all the clever caching prevents the content provider from knowing that the model has changed
+ // I am aware, that this is a hack, but the FilteredSelectionDialog API does not offer a convenient
+ // way to solve the problem.
+// try {
+// Field lastCompletedFilter = this.getClass().getSuperclass().getSuperclass().getDeclaredField("lastCompletedFilter");
+// lastCompletedFilter.setAccessible(true);
+// lastCompletedFilter.set(this, null);
+// } catch (SecurityException e) {
+// MessagingUtils.error(getClass(), e);
+// } catch (NoSuchFieldException e) {
+// MessagingUtils.error(getClass(), e);
+// } catch (IllegalArgumentException e) {
+// MessagingUtils.error(getClass(), e);
+// } catch (IllegalAccessException e) {
+// MessagingUtils.error(getClass(), e);
+// }
+
+ // this also is not the nicest way to do it.
+ // I am still amazed, that FilteredSelectionDialog does not offer any methods to change its data
+ // once it was opened. Am I doing it wrong?
+ String pattern = getTitle(cdmObject);
+ ((Text) getPatternControl()).setText(pattern);
+ }
+
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.dialogs.FilteredItemsSelectionDialog#fillContentProvider(org.eclipse.ui.dialogs.FilteredItemsSelectionDialog.AbstractContentProvider, org.eclipse.ui.dialogs.FilteredItemsSelectionDialog.ItemsFilter, org.eclipse.core.runtime.IProgressMonitor)
+ */
+ /** {@inheritDoc} */
+ @Override
+ protected void fillContentProvider(AbstractContentProvider contentProvider,
+ ItemsFilter itemsFilter, IProgressMonitor progressMonitor)
+ throws CoreException {
+ try {
+ if(model != null){
+ progressMonitor.beginTask("Looking for entities", model.size());
+ filterExcludedObjects();
+ Iterator<IdentifiedEntityDTO> iterator = model.iterator();
+ IdentifiedEntityDTO element;
+ while(iterator.hasNext()){
+ element = iterator.next();
+ if (!element.equals(cdmBaseToBeFiltered)){
+ contentProvider.add(element, itemsFilter);
+ }
+ if (progressMonitor.isCanceled()) {
+ throw new OperationCanceledException();
+ }
+ progressMonitor.worked(1);
+ }
+ }else{
+ MessagingUtils.warn(getClass(), "Model for Filtered Selection is null:" + this.getClass().getSimpleName());
+ }
+ }
+ finally {
+ progressMonitor.done();
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.dialogs.FilteredItemsSelectionDialog#getDialogSettings()
+ */
+ /** {@inheritDoc} */
+ @Override
+ protected IDialogSettings getDialogSettings() {
+ IDialogSettings settings = TaxeditorStorePlugin.getDefault().getDialogSettings().getSection(getSettings());
+
+ if (settings == null) {
+ settings = TaxeditorStorePlugin.getDefault().getDialogSettings().addNewSection(getSettings());
+ }
+ return settings;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.dialogs.FilteredItemsSelectionDialog#getElementName(java.lang.Object)
+ */
+ /** {@inheritDoc} */
+ @Override
+ public String getElementName(Object item) {
+ return ((IdentifiedEntityDTO) item).getCdmEntity().getTitleCache();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.dialogs.FilteredItemsSelectionDialog#getItemsComparator()
+ */
+ /** {@inheritDoc} */
+ @Override
+ protected Comparator getItemsComparator() {
+ return new Comparator<IdentifiedEntityDTO>() {
+ @Override
+ public int compare(IdentifiedEntityDTO entity1,
+ IdentifiedEntityDTO entity2) {
+ Collator collator = Collator.getInstance();
+ if (entity1.getCdmEntity().getCdmUuid().equals(entity2.getCdmEntity().getCdmUuid())){
+ return 0;
+ }
+ int result = collator.compare(entity1.getCdmEntity().getTitleCache(), entity2.getCdmEntity().getTitleCache());
+ if (result == 0){
+ result = entity1.getCdmEntity().getCdmUuid().compareTo(entity2.getCdmEntity().getCdmUuid());
+ }
+ return result;
+ }
+ };
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.dialogs.FilteredItemsSelectionDialog#validateItem(java.lang.Object)
+ */
+ /** {@inheritDoc} */
+ @Override
+ protected IStatus validateItem(Object item) {
+ return Status.OK_STATUS;
+ }
+
+ /**
+ * <p>getSelectedUuidAndTitleCache</p>
+ *
+ * @return a {@link eu.etaxonomy.cdm.model.common.UuidAndTitleCache} object.
+ */
+ protected IdentifiedEntityDTO getSelectedUuidAndTitleCache() {
+ Object[] result = getResult();
+ return result[0] == null ? null : (IdentifiedEntityDTO) result[0];
+ }
+
+ /**
+ * <p>Getter for the field <code>settings</code>.</p>
+ *
+ * @return a {@link java.lang.String} object.
+ */
+ public String getSettings() {
+ if(settings == null){
+ throw new IllegalStateException("No SETTINGS set.");
+ }
+ return settings;
+ }
+
+ /**
+ *
+ * @author n.hoffmann
+ * @created Oct 19, 2009
+ * @version 1.0
+ */
+ private class IdentifierSelectionHistory extends SelectionHistory {
+ /*
+ * @see org.eclipse.ui.dialogs.FilteredItemsSelectionDialog.SelectionHistory#restoreItemFromMemento(org.eclipse.ui.IMemento)
+ */
+ @Override
+ protected Object restoreItemFromMemento(IMemento element) {
+ return element.getString("resource"); //$NON-NLS-1$
+ }
+ /*
+ * @see org.eclipse.ui.dialogs.FilteredItemsSelectionDialog.SelectionHistory#storeItemToMemento(java.lang.Object,
+ * org.eclipse.ui.IMemento)
+ */
+ @Override
+ protected void storeItemToMemento(Object item, IMemento element) {
+ element.putString("resource", item.toString()); //$NON-NLS-1$
+ }
+ }
+
+ /**
+ * <p>getNewWizardLinkText</p>
+ *
+ * @return a {@link java.lang.String} object.
+ */
+ protected abstract String getNewWizardLinkText();
+
+ /**
+ * <p>getNewEntityWizard</p>
+ * @param parameter
+ * @return a {@link eu.etaxonomy.taxeditor.newWizard.AbstractNewEntityWizard} object.
+ */
+ protected abstract AbstractNewEntityWizard getNewEntityWizard(String parameter);
+
+ public class FilteredIdentifiedEntityLabelProvider extends LabelProvider {
+ @Override
+ public String getText(Object element) {
+ if (element == null) {
+ return null;
+ }
+ IdentifiedEntityDTO identifiedEntity = (IdentifiedEntityDTO) element;
+ String titleCache = identifiedEntity.getCdmEntity().getTitleCache();
+ if(PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_ID_IN_ENTITY_SELECTION_DIAOLOG)){
+ titleCache += " ["+identifiedEntity.getCdmEntity().getCdmUuid()+"]";
+ }
+ return titleCache;
+ }
+ };
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.dialogs.FilteredItemsSelectionDialog#createExtendedContentArea(org.eclipse.swt.widgets.Composite)
+ */
+ /** {@inheritDoc} */
+ @Override
+ protected Control createExtendedContentArea(Composite parent) {
+ String newWizardLinkText = getNewWizardLinkText();
+ if(newWizardLinkText != null){
+ Link link = new Link(parent, SWT.NONE);
+ link.setText(newWizardLinkText);
+ link.addSelectionListener(getNewWizardLinkSelectionListener());
+ return link;
+ }
+ return null;
+ }
+
+ protected SelectionListener getNewWizardLinkSelectionListener(){
+ return new SelectionAdapter() {
+
+ /* (non-Javadoc)
+ * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
+ */
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+
+ AbstractNewEntityWizard wizard = getNewEntityWizard(e.text);
+ if(wizard!=null){
+ wizard.init(null, null);
+ if(wizard.getEntity() != null) {
+ WizardDialog dialog = new WizardDialog(getShell(), wizard);
+ int status = dialog.open();
+
+ if (status == IStatus.OK) {
+
+ T entity = (T) wizard.getEntity();
+ // model.add(new UuidAndTitleCache<T>(entity.getUuid(), entity.getId(), getTitle(entity)));
+ refresh();
+ setPattern(entity);
+ if (getConversationHolder() != null){
+ getConversationHolder().bind();
+ }
+ }
+ //FIXME : Need to make sure this is a stable fix (ticket 3822)
+ if (getConversationHolder() != null){
+ getConversationHolder().commit();
+ }
+ }
+ }
+ }
+ };
+ }
+
+ /**
+ * <p>getConversationHolder</p>
+ *
+ * @return a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder} object.
+ */
+ @Override
+ public ConversationHolder getConversationHolder() {
+ return conversation;
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public void update(CdmDataChangeMap changeEvents) {}
+
+ /**
+ * Don't want to add for example a taxon or synonym to itself
+ * so filter the list to remove the taxon in question
+ * (<code>cdmBaseToBeFiltered</code>)
+ * so it is not available in the filtered list.
+ */
+ private void filterExcludedObjects() {
+ if (model != null && cdmBaseToBeFiltered != null) {
+
+ IdentifiedEntityDTO identifiedEntityToRemove = null;
+
+ for (IdentifiedEntityDTO identifiedEntity : model){
+ if ((cdmBaseToBeFiltered.getUuid()).equals(identifiedEntity.getCdmEntity().getCdmUuid())) {
+ identifiedEntityToRemove = identifiedEntity;
+ }
+ }
+ model.remove(identifiedEntityToRemove);
+ }
+ }
+
+
+
+}
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Text;
-import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
import eu.etaxonomy.cdm.api.service.IAgentService;
import eu.etaxonomy.cdm.model.agent.AgentBase;
import eu.etaxonomy.cdm.model.agent.INomenclaturalAuthor;
/**
*
*/
- protected static final String PERSON = "Person";
+ protected static final String PERSON = "New Person";
/**
*
*/
- protected static final String TEAM = "Team";
+ protected static final String TEAM = "New Team";
protected static boolean selectTeamMember;
* @param entity a {@link eu.etaxonomy.cdm.model.agent.AgentBase} object.
* @return a {@link eu.etaxonomy.cdm.model.agent.AgentBase} object.
*/
- public static AgentBase select(Shell shell, ConversationHolder conversation, AgentBase entity, boolean selectTeamMember) {
- AgentSelectionDialog dialog = new AgentSelectionDialog(shell, conversation,
+ public static AgentBase select(Shell shell, //ConversationHolder conversation,
+ AgentBase entity, boolean selectTeamMember) {
+ AgentSelectionDialog dialog = new AgentSelectionDialog(shell, //conversation,
"Choose Agent", false, AgentSelectionDialog.class.getCanonicalName(), entity, selectTeamMember);
return getSelectionFromDialog(dialog);
}
* @param multi a boolean.
* @param settings a {@link java.lang.String} object.
*/
- protected AgentSelectionDialog(Shell shell, ConversationHolder conversation, String title, boolean multi, String settings, AgentBase agent, boolean selectTeamMember) {
- super(shell, conversation, title, multi, settings, agent);
+ protected AgentSelectionDialog(Shell shell, //ConversationHolder conversation,
+ String title, boolean multi, String settings, AgentBase agent, boolean selectTeamMember) {
+ super(shell, //conversation,
+ title, multi, settings, agent);
this.selectTeamMember = selectTeamMember;
}
/** {@inheritDoc} */
@Override
- protected String getNewWizardLinkText() {
+ protected String[] getNewWizardText() {
+ String[] result;
if (this.selectTeamMember){
- return String.format("Create a new <a>%1s</a>", PERSON);
+ result = new String[1];
+ result[0] = PERSON;
+
+ }else{
+ result = new String[2];
+ result[0] = PERSON;
+ result[1] = TEAM;
}
- return String.format("Create a new <a>%1s</a> or <a>%2s</a>", TEAM, PERSON);
+ return result;
}
/* (non-Javadoc)
* @see eu.etaxonomy.taxeditor.dialogs.filteredSelection.AbstractFilteredCdmResourceSelectionDialog#getNewWizardLinkSelectionListener()
*/
@Override
- protected SelectionListener getNewWizardLinkSelectionListener() {
- return super.getNewWizardLinkSelectionListener();
+ protected SelectionListener getNewWizardButtonSelectionListener() {
+ return super.getNewWizardButtonSelectionListener();
}
- /** {@inheritDoc} */
- @Override
- protected void initModel() {
- Control control = getPatternControl();
- String pattern = null;
- if (control != null){
- pattern = ((Text)control).getText();
- }
- if (pattern == null || pattern.equals("?")){
- model = CdmStore.getService(IAgentService.class).getUuidAndTitleCache(null, null);
- }else{
- model = CdmStore.getService(IAgentService.class).getUuidAndTitleCache(limitOfInitialElements, pattern);
- }
- }
+// /** {@inheritDoc} */
+// @Override
+// protected void search() {
+// Control control = getSearchField();
+// String pattern = null;
+// if (control != null){
+// pattern = ((Text)control).getText();
+// }
+//
+// }
+
+ /* (non-Javadoc)
+ * @see eu.etaxonomy.taxeditor.ui.dialog.selection.AbstractFilteredCdmResourceSelectionDialog#callService(java.lang.String)
+ */
+ @Override
+ void callService(String pattern) {
+ model = CdmStore.getService(IAgentService.class).getUuidAndTitleCache(limitOfInitialElements, pattern);
+ }
}
import org.eclipse.swt.widgets.Shell;
-import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
import eu.etaxonomy.cdm.api.service.molecular.IAmplificationService;
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
import eu.etaxonomy.cdm.model.molecular.Amplification;
public class AmplificationSelectionDialog extends
AbstractFilteredCdmResourceSelectionDialog<Amplification> {
- public static Amplification select(Shell shell, ConversationHolder conversation, Amplification amplification){
- AmplificationSelectionDialog dialog = new AmplificationSelectionDialog(shell, conversation,
+ public static Amplification select(Shell shell, //ConversationHolder conversation,
+ Amplification amplification){
+ AmplificationSelectionDialog dialog = new AmplificationSelectionDialog(shell, //conversation,
"Choose Amplification", false, AmplificationSelectionDialog.class.getCanonicalName(), amplification);
return getSelectionFromDialog(dialog);
}
/**
* <p>Constructor for FilteredDerivedUnitSelectionDialog.</p>
*/
- protected AmplificationSelectionDialog(Shell shell, ConversationHolder conversation, String title,
+ protected AmplificationSelectionDialog(Shell shell, //ConversationHolder conversation,
+ String title,
boolean multi, String settings, Amplification cdmObject) {
- super(shell, conversation, title, multi, settings, cdmObject);
+ super(shell, //conversation,
+ title, multi, settings, cdmObject);
}
/** {@inheritDoc} */
/** {@inheritDoc} */
@Override
- protected void initModel() {
- model = CdmStore.getService(IAmplificationService.class).getAmplificationUuidAndLabelCache();
+ protected void callService(String pattern) {
+
+ model = CdmStore.getService(IAmplificationService.class).getAmplificationUuidAndLabelCache(limitOfInitialElements, pattern);
+// model = CdmStore.getService(IAmplificationService.class).getAmplificationUuidAndLabelCache();
+
}
/* (non-Javadoc)
/** {@inheritDoc} */
@Override
- protected String getNewWizardLinkText() {
- return String.format("Create a new <a>%1s</a>", "Amplification ");
+ protected String[] getNewWizardText() {
+ String[] result = new String[1];
+ result[0] = "New Amplification";
+ return result;
}
}
this.refreshCacheJob.cancel();
this.refreshProgressMessageJob.cancel();
if (showViewHandler != null) {
- IHandlerService service = (IHandlerService) PlatformUI
+ IHandlerService service = PlatformUI
.getWorkbench().getService(IHandlerService.class);
service.deactivateHandler(showViewHandler);
showViewHandler.getHandler().dispose();
fillViewMenu(menuManager);
- IHandlerService service = (IHandlerService) PlatformUI.getWorkbench()
+ IHandlerService service = PlatformUI.getWorkbench()
.getService(IHandlerService.class);
IHandler handler = new AbstractHandler() {
@Override
import java.util.UUID;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Text;
-import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
import eu.etaxonomy.cdm.api.service.IClassificationService;
import eu.etaxonomy.cdm.model.taxon.Classification;
import eu.etaxonomy.taxeditor.newWizard.AbstractNewEntityWizard;
* @param curentSelection
* @return a {@link eu.etaxonomy.cdm.model.taxon.TaxonomicTree} object.
*/
- public static Classification select(Shell shell,
- ConversationHolder conversation, Classification curentSelection) {
- ClassificationSelectionDialog dialog = new ClassificationSelectionDialog(
- shell, conversation, "Choose a Classification", false, "", null);
+ public static Classification select(Shell shell,//ConversationHolder conversation,
+ Classification curentSelection) {
+ ClassificationSelectionDialog dialog = new ClassificationSelectionDialog(shell, //conversation,
+ "Choose a Classification", false, "", null);
return getSelectionFromDialog(dialog);
}
* @param classification
* a {@link eu.etaxonomy.cdm.model.taxon.TaxonomicTree} object.
*/
- protected ClassificationSelectionDialog(Shell shell,
- ConversationHolder conversation, String title, boolean multi,
+ protected ClassificationSelectionDialog(Shell shell,//ConversationHolder conversation,
+ String title, boolean multi,
String settings, Classification classification) {
- super(shell, conversation, title, multi, settings, classification);
+ super(shell, //conversation,
+ title, multi, settings, classification);
}
- /*
- * (non-Javadoc)
- *
- * @see
- * org.eclipse.ui.dialogs.FilteredItemsSelectionDialog#createExtendedContentArea
- * (org.eclipse.swt.widgets.Composite)
- */
- /** {@inheritDoc} */
- @Override
- protected Control createExtendedContentArea(Composite parent) {
- return null;
- }
+// /*
+// * (non-Javadoc)
+// *
+// * @see
+// * org.eclipse.ui.dialogs.FilteredItemsSelectionDialog#createExtendedContentArea
+// * (org.eclipse.swt.widgets.Composite)
+// */
+// /** {@inheritDoc} */
+// @Override
+// protected Control createExtendedContentArea(Composite parent) {
+// return null;
+// }
/*
* (non-Javadoc)
*
* @see
* eu.etaxonomy.taxeditor.dialogs.AbstractFilteredCdmResourceSelectionDialog
- * #initModel()
+ * #search
*/
/** {@inheritDoc} */
@Override
- protected void initModel() {
- Control control = getPatternControl();
- String pattern = null;
- if (control != null){
- pattern = ((Text)control).getText();
- }
-
- if (pattern == null || pattern.equals("?")){
- model = CdmStore.getService(IClassificationService.class).getUuidAndTitleCache(null, null);
- }else{
- model = CdmStore.getService(IClassificationService.class).getUuidAndTitleCache(limitOfInitialElements, pattern);
- }
-
- }
+ protected void callService(String pattern) {
+ model = CdmStore.getService(IClassificationService.class).getUuidAndTitleCache(limitOfInitialElements, pattern);
+ }
/** {@inheritDoc} */
@Override
/** {@inheritDoc} */
@Override
- protected String getNewWizardLinkText() {
+ protected String[] getNewWizardText() {
return null;
}
}
import org.eclipse.swt.widgets.Shell;
-import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
import eu.etaxonomy.cdm.api.service.ICollectionService;
import eu.etaxonomy.cdm.model.occurrence.Collection;
import eu.etaxonomy.taxeditor.newWizard.AbstractNewEntityWizard;
* @param collection a {@link eu.etaxonomy.cdm.model.occurrence.Collection} object.
* @return a {@link eu.etaxonomy.cdm.model.occurrence.Collection} object.
*/
- public static Collection select(Shell shell, ConversationHolder conversation, Collection collection){
- CollectionSelectionDialog dialog = new CollectionSelectionDialog(shell, conversation,
+ public static Collection select(Shell shell, //ConversationHolder conversation,
+ Collection collection){
+ CollectionSelectionDialog dialog = new CollectionSelectionDialog(shell, //conversation,
"Choose Collection", false, CollectionSelectionDialog.class.getCanonicalName(), collection);
return getSelectionFromDialog(dialog);
}
* @param settings a {@link java.lang.String} object.
* @param cdmObject a {@link eu.etaxonomy.cdm.model.occurrence.Collection} object.
*/
- protected CollectionSelectionDialog(Shell shell,
- ConversationHolder conversation, String title, boolean multi,
+ protected CollectionSelectionDialog(Shell shell,//ConversationHolder conversation,
+ String title, boolean multi,
String settings, Collection cdmObject) {
- super(shell, conversation, title, multi, settings, cdmObject);
+ super(shell, //conversation,
+ title, multi, settings, cdmObject);
}
/* (non-Javadoc)
}
/* (non-Javadoc)
- * @see eu.etaxonomy.taxeditor.dialogs.filteredSelection.AbstractFilteredCdmResourceSelectionDialog#initModel()
+ * @see eu.etaxonomy.taxeditor.dialogs.filteredSelection.AbstractFilteredCdmResourceSelectionDialog#search
*/
/** {@inheritDoc} */
@Override
- protected void initModel() {
- model = CdmStore.getService(ICollectionService.class).getUuidAndTitleCache(null, null);
- }
+ protected void callService(String pattern) {
+ model = CdmStore.getService(ICollectionService.class).getUuidAndTitleCache(limitOfInitialElements,pattern);
+ }
/* (non-Javadoc)
* @see eu.etaxonomy.taxeditor.dialogs.filteredSelection.AbstractFilteredCdmResourceSelectionDialog#getNewWizardLinkText()
*/
/** {@inheritDoc} */
@Override
- protected String getNewWizardLinkText() {
- return String.format("Create a new <a>%1s</a>", "Collection ");
+ protected String[] getNewWizardText() {
+ return new String[]{ "Collection "};
}
/* (non-Javadoc)
import org.eclipse.swt.widgets.Shell;
-import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
import eu.etaxonomy.cdm.api.service.IOccurrenceService;
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
import eu.etaxonomy.cdm.model.occurrence.DerivedUnit;
* @param unit a {@link eu.etaxonomy.cdm.model.occurrence.DerivedUnitBase} object.
* @return a {@link eu.etaxonomy.cdm.model.occurrence.DerivedUnitBase} object.
*/
- public static DerivedUnit select(Shell shell, ConversationHolder conversation, DerivedUnit unit){
- DerivedUnitSelectionDialog dialog = new DerivedUnitSelectionDialog(shell, conversation,
+ public static DerivedUnit select(Shell shell, //ConversationHolder conversation,
+ DerivedUnit unit){
+ DerivedUnitSelectionDialog dialog = new DerivedUnitSelectionDialog(shell, //conversation,
"Choose Unit", false, DerivedUnitSelectionDialog.class.getCanonicalName(), unit);
return getSelectionFromDialog(dialog);
}
* @param settings a {@link java.lang.String} object.
* @param cdmObject a {@link eu.etaxonomy.cdm.model.occurrence.DerivedUnitBase} object.
*/
- protected DerivedUnitSelectionDialog(Shell shell, ConversationHolder conversation, String title,
+ protected DerivedUnitSelectionDialog(Shell shell, //ConversationHolder conversation,
+ String title,
boolean multi, String settings, DerivedUnit cdmObject) {
- super(shell, conversation, title, multi, settings, cdmObject);
+ super(shell, //conversation,
+ title, multi, settings, cdmObject);
}
/** {@inheritDoc} */
/** {@inheritDoc} */
@Override
- protected void initModel() {
- model = CdmStore.getService(IOccurrenceService.class).getDerivedUnitUuidAndTitleCache();
+ protected void callService(String pattern) {
+ model = CdmStore.getService(IOccurrenceService.class).getDerivedUnitUuidAndTitleCache(limitOfInitialElements,pattern);
}
/** {@inheritDoc} */
/** {@inheritDoc} */
@Override
- protected String getNewWizardLinkText() {
- return String.format("Create a new <a>%1s</a>", "Unit ");
+ protected String[] getNewWizardText() {
+ return new String[]{ "New Unit"};
}
}
--- /dev/null
+/**
+* Copyright (C) 2017 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.ui.dialog.selection;
+
+
+
+
+ import java.util.UUID;
+
+import org.eclipse.swt.widgets.Shell;
+
+import eu.etaxonomy.cdm.api.application.ICdmRepository;
+import eu.etaxonomy.cdm.api.service.IReferenceService;
+import eu.etaxonomy.cdm.model.agent.Person;
+import eu.etaxonomy.cdm.model.agent.Team;
+import eu.etaxonomy.cdm.model.agent.TeamOrPersonBase;
+import eu.etaxonomy.cdm.model.common.OriginalSourceType;
+import eu.etaxonomy.cdm.model.reference.Reference;
+import eu.etaxonomy.cdm.model.reference.ReferenceFactory;
+import eu.etaxonomy.taxeditor.newWizard.AbstractNewEntityWizard;
+import eu.etaxonomy.taxeditor.newWizard.NewReferenceWizard;
+import eu.etaxonomy.taxeditor.remoting.source.CdmServerInfo;
+import eu.etaxonomy.taxeditor.remoting.source.ICdmRemoteSource;
+import eu.etaxonomy.taxeditor.store.CdmStore;
+
+
+/**
+ * @author k.luther
+ * @date 02.05.2017
+ *
+
+ */
+public class ExtReferenceSelectionDialog extends
+ AbstractFilteredCdmResourceSelectionDialog<Reference> {
+
+ protected static boolean isInReference = false;
+ private Reference currentReference;
+ ICdmRepository controller;
+ ICdmRemoteSource remoteSource ;
+ Reference remoteSourceRef;
+ IReferenceService service = null;
+
+
+ /**
+ * <p>select</p>
+ *
+ * @param reference a {@link eu.etaxonomy.cdm.model.reference.ReferenceBase} object.
+ * @param shell a {@link org.eclipse.swt.widgets.Shell} object.
+ * @param conversation a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder} object.
+ * @return a {@link eu.etaxonomy.cdm.model.reference.ReferenceBase} object.
+ */
+ public static Reference select(Shell shell, //ConversationHolder conversation,
+ Reference reference, boolean isInReference) {
+ ExtReferenceSelectionDialog dialog = new ExtReferenceSelectionDialog(shell, //conversation,
+ "Choose a reference", false, reference, isInReference);
+ return getSelectionFromDialog(dialog);
+ }
+
+ /**
+ * <p>select</p>
+ *
+ * @param reference a {@link eu.etaxonomy.cdm.model.reference.ReferenceBase} object.
+ * @param shell a {@link org.eclipse.swt.widgets.Shell} object.
+ * @param conversation a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder} object.
+ * @return a {@link eu.etaxonomy.cdm.model.reference.ReferenceBase} object.
+ */
+ public static Reference select(Shell shell, //ConversationHolder conversation,
+ Reference reference) {
+ ExtReferenceSelectionDialog dialog = new ExtReferenceSelectionDialog(shell, //conversation,
+ "Choose a reference", false, reference);
+ return getSelectionFromDialog(dialog);
+ }
+
+
+
+
+
+
+ /**
+ * <p>Constructor for FilteredReferenceSelectionDialog.</p>
+ *
+ * @param shell a {@link org.eclipse.swt.widgets.Shell} object.
+ * @param title a {@link java.lang.String} object.
+ * @param reference a {@link eu.etaxonomy.cdm.model.reference.ReferenceBase} object.
+ * @param conversation a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder} object.
+ * @param multi a boolean.
+ */
+ protected ExtReferenceSelectionDialog(Shell shell, //ConversationHolder conversation,
+ String title, boolean multi, Reference reference) {
+ super(shell, //conversation,
+ title, multi, ExtReferenceSelectionDialog.class.getCanonicalName(), null);
+ this.currentReference = reference;
+
+// controller = CdmStore.getCurrentApplicationConfiguration();
+// String currentValue = System.getProperty("cdm.server.dev.port");
+ System.setProperty("cdm.server.dev.port", "8080");
+ remoteSource = CdmServerInfo.getDevServerRemoteSource();
+ remoteSourceRef = ReferenceFactory.newDatabase();
+ remoteSourceRef.setTitle(remoteSource.getName());
+ System.setProperty("cdm.server.dev.port", "80");
+ }
+
+
+
+
+ /**
+ * <p>Constructor for FilteredReferenceSelectionDialog.</p>
+ *
+ * @param shell a {@link org.eclipse.swt.widgets.Shell} object.
+ * @param title a {@link java.lang.String} object.
+ * @param reference a {@link eu.etaxonomy.cdm.model.reference.ReferenceBase} object.
+ * @param conversation a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder} object.
+ * @param multi a boolean.
+ */
+ protected ExtReferenceSelectionDialog(Shell shell, //ConversationHolder conversation,
+ String title, boolean multi, Reference reference, boolean isInReference) {
+ super(shell, //conversation,
+ title, multi, ExtReferenceSelectionDialog.class.getCanonicalName(), null);
+ this.isInReference = isInReference;
+ this.currentReference = reference;
+
+// controller = CdmStore.getCurrentApplicationConfiguration();
+// CdmServerInfoConfig parameterObject = new CdmServerInfoConfig("localhost", "localhost", 8080, "cdmserver/", true);
+// CdmServerInfo selectedCsii = new CdmServerInfo(parameterObject);
+// CdmInstanceInfo selectedCdmInstance = selectedCsii.getInstanceFromName("local-cuba") ;
+// Integer port;
+// remoteSource = selectedCsii.getCdmRemoteSource(selectedCdmInstance, 80);
+
+
+ }
+
+
+ /* (non-Javadoc)
+ * @see eu.etaxonomy.taxeditor.dialogs.AbstractFilteredCdmResourceSelectionDialog#getPersistentObject(java.util.UUID)
+ */
+ /** {@inheritDoc} */
+ @Override
+ protected Reference getPersistentObject(UUID cdmUuid) {
+ Reference extRef = service.load(cdmUuid);
+
+ Reference newRef = ReferenceFactory.newReference( extRef.getType());
+ if (extRef.getTitle() != null){
+ newRef.setTitle(extRef.getTitle());
+ }else{
+ newRef.setTitleCache(extRef.getTitleCache(), true);
+ }
+ if (extRef.getAbbrevTitle() != null){
+ newRef.setAbbrevTitle(extRef.getAbbrevTitle());
+ }else{
+ newRef.setAbbrevTitleCache(extRef.getAbbrevTitleCache(), true);
+ }
+
+ if (extRef.getInReference() != null){
+ Reference inRef = extRef.getInReference();
+ Reference newRefInRef = ReferenceFactory.newReference( extRef.getInBook().getType());
+ if (inRef.getTitle() != null){
+ newRefInRef.setTitle(inRef.getTitle());
+ }else{
+ newRefInRef.setTitleCache(inRef.getTitleCache(), true);
+ }
+ if (inRef.getAbbrevTitle() != null){
+ newRefInRef.setAbbrevTitle(inRef.getAbbrevTitle());
+ }else{
+ newRefInRef.setAbbrevTitleCache(inRef.getAbbrevTitleCache(), true);
+ }
+ newRefInRef.addSource(OriginalSourceType.Other, String.valueOf(newRefInRef.getId()), "Reference", remoteSourceRef, null);
+ newRef.setInReference(newRefInRef);
+ newRef.setProtectedTitleCache(false);
+ newRef.setProtectedAbbrevTitleCache(false);
+ newRef.addSource(OriginalSourceType.Other, String.valueOf(newRef.getId()), "Reference", remoteSourceRef, null);
+ }
+ TeamOrPersonBase author;
+ if (extRef.getAuthorship() != null){
+ if (extRef.getAuthorship() instanceof Person){
+ author = Person.NewTitledInstance(extRef.getAuthorship().getTitleCache());
+ author.setProtectedTitleCache(true);
+ }else{
+ author = Team.NewInstance();
+ Person newMember;
+
+ for (Person member:((Team)extRef.getAuthorship()).getTeamMembers()){
+ newMember = Person.NewTitledInstance(member.getTitleCache());
+ ((Team)author).addTeamMember(newMember);
+ }
+
+ }
+ newRef.setAuthorship(author);
+ }
+
+ newRef = CdmStore.getService(IReferenceService.class).save(newRef);
+
+ return newRef;
+ }
+
+ /* (non-Javadoc)
+ * @see eu.etaxonomy.taxeditor.dialogs.AbstractFilteredCdmResourceSelectionDialog#search
+ */
+ /** {@inheritDoc} */
+ @Override
+ protected void callService(String pattern) {
+
+
+ if (remoteSource != null){
+// if (service == null){
+// service = CdmApplicationRemoteConfiguration.getExtReferenceService(remoteSource);
+// }
+ if (pattern.equals("?")){ //$NON-NLS-1$
+ if (isInReference && currentReference != null){
+ model = service.getUuidAndTitleCache(null, null, currentReference.getType());
+ }else{
+ model = service.getUuidAndTitleCache(null, null);
+ }
+ }else{
+ if (isInReference && currentReference != null){
+ model = service.getUuidAndTitleCache(limitOfInitialElements, pattern, currentReference.getType());
+ }else{
+ model = service.getUuidAndTitleCache(limitOfInitialElements,pattern);
+
+ }
+ }
+ }
+ }
+
+
+ /** {@inheritDoc} */
+ @Override
+ protected String getTitle(Reference cdmObject) {
+ if(cdmObject == null){
+ return "";
+ }else{
+ return super.getTitle(cdmObject);
+ }
+// }else{
+// return DefaultReferenceCacheStrategy.putAuthorToEndOfString(cdmObject.getTitleCache(), cdmObject.getAuthorship().getTitleCache());
+// }
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ protected AbstractNewEntityWizard getNewEntityWizard(String parameter) {
+ return new NewReferenceWizard();
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ protected String[] getNewWizardText() {
+ return new String[]{"Reference "};
+ }
+
+ }
+
+
/**
* 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.Shell;
-import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
import eu.etaxonomy.cdm.api.service.ITermService;
import eu.etaxonomy.cdm.model.common.DefinedTermBase;
import eu.etaxonomy.cdm.model.description.Feature;
public class FeatureSelectionDialog extends
AbstractFilteredCdmResourceSelectionDialog<Feature> {
- public static Feature select(Shell shell, ConversationHolder conversation, Feature feature){
- FeatureSelectionDialog dialog = new FeatureSelectionDialog(shell, conversation,
+ public static Feature select(Shell shell, //ConversationHolder conversation,
+ Feature feature){
+ FeatureSelectionDialog dialog = new FeatureSelectionDialog(shell, //conversation,
"Choose Feature", false, FeatureSelectionDialog.class.getCanonicalName(), feature);
return getSelectionFromDialog(dialog);
}
-
+
/**
* @param shell
* @param conversation
* @param settings
* @param cdmObject
*/
- protected FeatureSelectionDialog(Shell shell,
- ConversationHolder conversation, String title, boolean multi,
+ protected FeatureSelectionDialog(Shell shell,//ConversationHolder conversation,
+ String title, boolean multi,
String settings, Feature cdmObject) {
- super(shell, conversation, title, multi, settings, cdmObject);
+ super(shell,//conversation,
+ title, multi, settings, cdmObject);
}
@Override
protected Feature getPersistentObject(UUID uuid) {
-
+
DefinedTermBase<?> term = CdmStore.getService(ITermService.class).load(uuid);
-
+
if(term instanceof Feature){
return (Feature) term;
}
-
+
return null;
}
@Override
- protected void initModel() {
+ protected void callService(String pattern) {
List<Feature> features = CdmStore.getService(ITermService.class).list(Feature.class, null, null, null, null);
-
+
List<UuidAndTitleCache<Feature>> featureUuidAndTitleCache = new ArrayList<UuidAndTitleCache<Feature>>();
-
+
for(Feature feature : features){
UuidAndTitleCache<Feature> uuidAndTitleCache = new UuidAndTitleCache<Feature>(Feature.class, feature.getUuid(), feature.getId(), feature.getTitleCache());
- featureUuidAndTitleCache.add(uuidAndTitleCache);
+ if (uuidAndTitleCache.getTitleCache().matches(pattern)) {
+ featureUuidAndTitleCache.add(uuidAndTitleCache);
+ }
}
-
+
model = featureUuidAndTitleCache;
+
}
/* (non-Javadoc)
* @see eu.etaxonomy.taxeditor.dialogs.filteredSelection.AbstractFilteredCdmResourceSelectionDialog#getNewWizardLinkText()
*/
@Override
- protected String getNewWizardLinkText() {
+ protected String[] getNewWizardText() {
return null;
}
import java.util.List;
import java.util.UUID;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.jface.dialogs.InputDialog;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.Link;
-import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Shell;
-import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
import eu.etaxonomy.cdm.api.service.IFeatureTreeService;
import eu.etaxonomy.cdm.model.description.FeatureTree;
import eu.etaxonomy.cdm.persistence.dto.UuidAndTitleCache;
public class FeatureTreeSelectionDialog extends
AbstractFilteredCdmResourceSelectionDialog<FeatureTree> {
- public static FeatureTree select(Shell shell, ConversationHolder conversation, FeatureTree featureTree) {
- FeatureTreeSelectionDialog dialog = new FeatureTreeSelectionDialog(shell, conversation,
+ public static FeatureTree select(Shell shell, //ConversationHolder conversation,
+ FeatureTree featureTree) {
+ FeatureTreeSelectionDialog dialog = new FeatureTreeSelectionDialog(shell, //conversation,
"Choose a feature tree", false, featureTree);
return getSelectionFromDialog(dialog);
}
- protected FeatureTreeSelectionDialog(Shell shell,
- ConversationHolder conversation, String title, boolean multi,
+ protected FeatureTreeSelectionDialog(Shell shell,//ConversationHolder conversation,
+ String title, boolean multi,
FeatureTree cdmObject) {
- super(shell, conversation, title, multi, FeatureTreeSelectionDialog.class.getCanonicalName(), cdmObject);
+ super(shell, //conversation,
+ title, multi, FeatureTreeSelectionDialog.class.getCanonicalName(), cdmObject);
}
/** {@inheritDoc} */
/** {@inheritDoc} */
@Override
- protected void initModel() {
+ protected void callService(String pattern) {
List<FeatureTree> featureTrees = CdmStore.getService(IFeatureTreeService.class).list(FeatureTree.class, null, null, null, null);
if(model == null){
model.clear();
for(FeatureTree featureTree : featureTrees){
UuidAndTitleCache<FeatureTree> element = new UuidAndTitleCache<FeatureTree>(FeatureTree.class, featureTree.getUuid(),featureTree.getId(), featureTree.getTitleCache());
- model.add(element);
+ if (element.getTitleCache().matches(pattern)) {
+ model.add(element);
+ }
}
- }
- /** {@inheritDoc} */
- @Override
- protected Control createExtendedContentArea(Composite parent) {
- Link link = new Link(parent, SWT.NONE);
- link.setText(getNewWizardLinkText());
- link.addListener (SWT.Selection, new Listener () {
- @Override
- public void handleEvent(Event event) {
-
- InputDialog input = new InputDialog(getShell(), "New feature tree", "Enter label for new feature tree", null, null);
- int status = input.open();
- if (status == IStatus.OK) {
- String label = input.getValue();
- if(label!=null){
- FeatureTree featureTree = FeatureTree.NewInstance();
- featureTree.setTitleCache(label, false);
- CdmStore.getService(IFeatureTreeService.class).save(featureTree);
- UuidAndTitleCache<FeatureTree> uuidAndTitleCache = new UuidAndTitleCache<FeatureTree>(FeatureTree.class, featureTree.getUuid(),featureTree.getId(), featureTree.getTitleCache());
- model.add(uuidAndTitleCache);
- setPattern(featureTree);
- }
- }
- }
- });
- return link;
}
+// /** {@inheritDoc} */
+// @Override
+// protected Control createExtendedContentArea(Composite parent) {
+// Link link = new Link(parent, SWT.NONE);
+// link.setText(getNewWizardLinkText());
+// link.addListener (SWT.Selection, new Listener () {
+// @Override
+// public void handleEvent(Event event) {
+//
+// InputDialog input = new InputDialog(getShell(), "New feature tree", "Enter label for new feature tree", null, null);
+// int status = input.open();
+// if (status == IStatus.OK) {
+// String label = input.getValue();
+// if(label!=null){
+// FeatureTree featureTree = FeatureTree.NewInstance();
+// featureTree.setTitleCache(label, false);
+// CdmStore.getService(IFeatureTreeService.class).save(featureTree);
+// UuidAndTitleCache<FeatureTree> uuidAndTitleCache = new UuidAndTitleCache<FeatureTree>(FeatureTree.class, featureTree.getUuid(),featureTree.getId(), featureTree.getTitleCache());
+// model.add(uuidAndTitleCache);
+// setPattern(featureTree);
+// }
+// }
+// }
+// });
+// return link;
+// }
+
/** {@inheritDoc} */
@Override
- protected String getNewWizardLinkText() {
- return String.format("Create a new <a>%1s</a>" , "Feature tree ");
+ protected String[] getNewWizardText() {
+ return new String[]{ "New Feature tree"};
}
import org.eclipse.swt.widgets.Shell;
-import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
import eu.etaxonomy.cdm.api.service.IOccurrenceService;
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
import eu.etaxonomy.cdm.model.occurrence.FieldUnit;
* @param observation a {@link eu.etaxonomy.cdm.model.occurrence.FieldUnit} object.
* @return a {@link eu.etaxonomy.cdm.model.occurrence.FieldUnit} object.
*/
- public static FieldUnit select(Shell shell, ConversationHolder conversation, FieldUnit observation){
- FieldUnitSelectionDialog dialog = new FieldUnitSelectionDialog(shell, conversation,
+ public static FieldUnit select(Shell shell, //ConversationHolder conversation,
+ FieldUnit observation){
+ FieldUnitSelectionDialog dialog = new FieldUnitSelectionDialog(shell, //conversation,
"Choose Derived Unit", false, FieldUnitSelectionDialog.class.getCanonicalName(), observation);
return getSelectionFromDialog(dialog);
}
* @param settings a {@link java.lang.String} object.
* @param cdmObject a {@link eu.etaxonomy.cdm.model.occurrence.FieldUnit} object.
*/
- protected FieldUnitSelectionDialog(Shell shell, ConversationHolder conversation,
+ protected FieldUnitSelectionDialog(Shell shell, //ConversationHolder conversation,
String title, boolean multi, String settings,
FieldUnit cdmObject) {
- super(shell, conversation, title, multi, settings, cdmObject);
+ super(shell, //conversation,
+ title, multi, settings, cdmObject);
}
/* (non-Javadoc)
}
/* (non-Javadoc)
- * @see eu.etaxonomy.taxeditor.dialogs.filteredSelection.AbstractFilteredCdmResourceSelectionDialog#initModel()
+ * @see eu.etaxonomy.taxeditor.dialogs.filteredSelection.AbstractFilteredCdmResourceSelectionDialog#search
*/
/** {@inheritDoc} */
@Override
- protected void initModel() {
- model = CdmStore.getService(IOccurrenceService.class).getFieldUnitUuidAndTitleCache();
+ protected void callService(String pattern) {
+ model = CdmStore.getService(IOccurrenceService.class).getUuidAndTitleCache(FieldUnit.class, limitOfInitialElements, pattern);
+
}
/** {@inheritDoc} */
/** {@inheritDoc} */
@Override
- protected String getNewWizardLinkText() {
- return String.format("Create a new <a>%1s</a>", "Field Unit ");
+ protected String[] getNewWizardText() {
+ return new String[]{"New Field Unit"};
}
}
--- /dev/null
+// $Id$
+/**
+* Copyright (C) 2017 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.ui.dialog.selection;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Shell;
+
+import eu.etaxonomy.cdm.api.service.IVocabularyService;
+import eu.etaxonomy.cdm.model.common.TermType;
+import eu.etaxonomy.cdm.model.common.TermVocabulary;
+import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
+import eu.etaxonomy.taxeditor.store.CdmStore;
+
+/**
+ * @author k.luther
+ * @date 21.11.2017
+ *
+ */
+public class FilterDialog extends Dialog {
+
+ List<TermVocabulary> vocabularies = new ArrayList<TermVocabulary>();
+
+ List<TermVocabulary> selectedVocabularies = new ArrayList<TermVocabulary>();
+
+ Object preferenceId;
+
+ /**
+ * @param parentShell
+ */
+ protected FilterDialog(Shell parentShell, Object preferenceId, List<TermVocabulary> selectedVocabularies) {
+ super(parentShell);
+ vocabularies = CdmStore.getService(IVocabularyService.class).listByTermType(TermType.NamedArea, true, null, null, null, null);
+ this.preferenceId = preferenceId;
+ List<TermVocabulary> tempSelectedVocabularies = new ArrayList<>();
+ this.selectedVocabularies = selectedVocabularies;
+
+ }
+
+ @Override
+ protected Control createDialogArea(Composite parent) {
+ Composite dialogArea = new Composite(parent, SWT.NULL);
+ dialogArea.setLayout(new GridLayout(1, false));
+ for (TermVocabulary voc: vocabularies){
+ Button btnCheckButton = new Button(dialogArea, SWT.CHECK);
+ btnCheckButton.setText(voc.getLabel());
+ btnCheckButton.setData(voc);
+ if (selectedVocabularies.contains(voc)){
+ btnCheckButton.setSelection(true);
+ }else {
+ btnCheckButton.setSelection(false);
+ }
+
+ btnCheckButton.addSelectionListener(new SelectionListener(){
+
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ if (btnCheckButton.getSelection()){
+ Object obj = btnCheckButton.getData();
+ if (!selectedVocabularies.contains(btnCheckButton.getData())){
+ selectedVocabularies.add((TermVocabulary)btnCheckButton.getData());
+ }
+ }else{
+ if (selectedVocabularies.contains(btnCheckButton.getData())){
+ selectedVocabularies.remove(btnCheckButton.getData());
+ }
+ }
+
+ }
+
+ @Override
+ public void widgetDefaultSelected(SelectionEvent e) {
+ // TODO Auto-generated method stub
+
+ }
+
+ });
+ }
+
+ GridData gd_table = new GridData(SWT.CENTER, SWT.CENTER, true, true, 2, 1);
+ gd_table.heightHint = 231;
+ gd_table.widthHint = 543;
+
+ return dialogArea;
+
+ }
+
+ @Override
+ protected void okPressed(){
+ for (TermVocabulary voc: vocabularies){
+ if (selectedVocabularies.contains(voc)){
+ PreferencesUtil.getPreferenceStore().setValue(getPrefKey(voc), false);
+ } else{
+ PreferencesUtil.getPreferenceStore().setValue(getPrefKey(voc), true);
+ }
+ }
+ super.okPressed();
+ }
+
+ private String getPrefKey(TermVocabulary vocabulary){
+ return "hide_"+NamedAreaSelectionDialog.class.getCanonicalName()+vocabulary.getUuid()+preferenceId;
+ }
+
+}
import org.eclipse.swt.widgets.Shell;
import org.springframework.security.core.GrantedAuthority;
-import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
import eu.etaxonomy.cdm.api.service.IGrantedAuthorityService;
import eu.etaxonomy.cdm.model.common.GrantedAuthorityImpl;
import eu.etaxonomy.cdm.persistence.dto.UuidAndTitleCache;
*/
public class GrantedAuthoritySelectionDialog extends AbstractFilteredCdmResourceSelectionDialog<GrantedAuthorityImpl> {
- public static GrantedAuthority select(Shell shell, ConversationHolder conversation, GrantedAuthorityImpl authority){
+ public static GrantedAuthority select(Shell shell, //ConversationHolder conversation,
+ GrantedAuthorityImpl authority){
- GrantedAuthoritySelectionDialog dialog = new GrantedAuthoritySelectionDialog(shell, conversation,
+ GrantedAuthoritySelectionDialog dialog = new GrantedAuthoritySelectionDialog(shell,//conversation,
"Choose Granted Authority", false, GrantedAuthoritySelectionDialog.class.getCanonicalName(), authority);
return getSelectionFromDialog(dialog);
* @param settings
* @param cdmObject
*/
- protected GrantedAuthoritySelectionDialog(Shell shell,
- ConversationHolder conversation, String title, boolean multi,
+ protected GrantedAuthoritySelectionDialog(Shell shell,//ConversationHolder conversation,
+ String title, boolean multi,
String settings, GrantedAuthorityImpl cdmObject) {
- super(shell, conversation, title, multi, settings, cdmObject);
+ super(shell, //conversation,
+ title, multi, settings, cdmObject);
}
/* (non-Javadoc)
- * @see eu.etaxonomy.taxeditor.ui.dialogs.filteredSelection.AbstractFilteredCdmResourceSelectionDialog#initModel()
+ * @see eu.etaxonomy.taxeditor.ui.dialogs.filteredSelection.AbstractFilteredCdmResourceSelectionDialog#search
*/
@Override
- protected void initModel() {
+ protected void callService(String pattern) {
List<GrantedAuthorityImpl> authorities = CdmStore.getService(IGrantedAuthorityService.class).list(GrantedAuthorityImpl.class, null, null, null, null);
model = new ArrayList<UuidAndTitleCache<GrantedAuthorityImpl>>();
for(GrantedAuthorityImpl authority : authorities){
-
- model.add(new UuidAndTitleCache<GrantedAuthorityImpl>(GrantedAuthorityImpl.class, authority.getUuid(), authority.getId(), String.format("%s", GrantedAuthorityLabelTextProvider.getText(authority))));
+ if (authority.getAuthority().matches(pattern)){
+ model.add(new UuidAndTitleCache<GrantedAuthorityImpl>(GrantedAuthorityImpl.class, authority.getUuid(), authority.getId(), String.format("%s", GrantedAuthorityLabelTextProvider.getText(authority))));
+ }
}
+
}
/* (non-Javadoc)
* @see eu.etaxonomy.taxeditor.ui.dialogs.filteredSelection.AbstractFilteredCdmResourceSelectionDialog#getNewWizardLinkText()
*/
@Override
- protected String getNewWizardLinkText() {
- return String.format("Create a new <a>%1s</a>", "GrantedAuthority ");
+ protected String[] getNewWizardText() {
+ return new String[]{"New GrantedAuthority"};
}
@Override
import org.eclipse.swt.widgets.Shell;
-import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
import eu.etaxonomy.cdm.api.service.IGroupService;
import eu.etaxonomy.cdm.model.common.Group;
import eu.etaxonomy.cdm.persistence.dto.UuidAndTitleCache;
public class GroupSelectionDialog extends
AbstractFilteredCdmResourceSelectionDialog<Group> {
- public static Group select(Shell shell, ConversationHolder conversation, Group group){
- GroupSelectionDialog dialog = new GroupSelectionDialog(shell, conversation,
+ public static Group select(Shell shell, //ConversationHolder conversation,
+ Group group){
+ GroupSelectionDialog dialog = new GroupSelectionDialog(shell, //conversation,
"Choose Group", false, GroupSelectionDialog.class.getCanonicalName(), group);
return getSelectionFromDialog(dialog);
}
* @param settings
* @param cdmObject
*/
- protected GroupSelectionDialog(Shell shell,
- ConversationHolder conversation, String title, boolean multi,
+ protected GroupSelectionDialog(Shell shell,//ConversationHolder conversation,
+ String title, boolean multi,
String settings, Group cdmObject) {
- super(shell, conversation, title, multi, settings, cdmObject);
+ super(shell, //conversation,
+ title, multi, settings, cdmObject);
}
/* (non-Javadoc)
- * @see eu.etaxonomy.taxeditor.ui.dialogs.filteredSelection.AbstractFilteredCdmResourceSelectionDialog#initModel()
+ * @see eu.etaxonomy.taxeditor.ui.dialogs.filteredSelection.AbstractFilteredCdmResourceSelectionDialog#search
*/
@Override
- protected void initModel() {
+ protected void callService(String pattern) {
List<Group> groups = CdmStore.getService(IGroupService.class).list(Group.class, null, null, null, null);
model = new ArrayList<UuidAndTitleCache<Group>>();
for(Group group : groups){
- model.add(new UuidAndTitleCache<Group>(Group.class, group.getUuid(), group.getId(), String.format("%s", group.getName())));
+ if ((pattern != null && group.getName().matches(pattern)) || pattern.equals("*")){
+ model.add(new UuidAndTitleCache<Group>(Group.class, group.getUuid(), group.getId(), String.format("%s", group.getName())));
+ }
}
}
* @see eu.etaxonomy.taxeditor.ui.dialogs.filteredSelection.AbstractFilteredCdmResourceSelectionDialog#getNewWizardLinkText()
*/
@Override
- protected String getNewWizardLinkText() {
- return String.format("Create a new <a>%1s</a>", "Group ");
+ protected String[] getNewWizardText() {
+ return new String[]{"New Group"};
}
/* (non-Javadoc)
import org.eclipse.swt.widgets.Shell;
-import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
import eu.etaxonomy.cdm.api.service.IAgentService;
import eu.etaxonomy.cdm.model.agent.AgentBase;
import eu.etaxonomy.cdm.model.agent.Institution;
public class InstitutionSelectionDialog extends
AbstractFilteredCdmResourceSelectionDialog<Institution> {
- public static Institution select(Shell shell, ConversationHolder conversation, Institution institution){
- InstitutionSelectionDialog dialog = new InstitutionSelectionDialog(shell, conversation,
+ public static Institution select(Shell shell,// ConversationHolder conversation,
+ Institution institution){
+ InstitutionSelectionDialog dialog = new InstitutionSelectionDialog(shell, //conversation,
"Choose Institution", false, TeamSelectionDialog.class.getCanonicalName(), institution);
return getSelectionFromDialog(dialog);
}
* @param settings
* @param cdmObject
*/
- protected InstitutionSelectionDialog(Shell shell,
- ConversationHolder conversation, String title, boolean multi,
+ protected InstitutionSelectionDialog(Shell shell,//ConversationHolder conversation,
+ String title, boolean multi,
String settings, Institution cdmObject) {
- super(shell, conversation, title, multi, settings, cdmObject);
+ super(shell, //conversation,
+ title, multi, settings, cdmObject);
}
/* (non-Javadoc)
}
/* (non-Javadoc)
- * @see eu.etaxonomy.taxeditor.dialogs.filteredSelection.AbstractFilteredCdmResourceSelectionDialog#initModel()
+ * @see eu.etaxonomy.taxeditor.dialogs.filteredSelection.AbstractFilteredCdmResourceSelectionDialog#search
*/
@Override
- protected void initModel() {
- model = CdmStore.getService(IAgentService.class).getInstitutionUuidAndTitleCache();
+ protected void callService(String pattern) {
+
+ model = CdmStore.getService(IAgentService.class).getUuidAndTitleCache(Institution.class, limitOfInitialElements,pattern);
+
+
}
/* (non-Javadoc)
* @see eu.etaxonomy.taxeditor.dialogs.filteredSelection.AbstractFilteredCdmResourceSelectionDialog#getNewWizardLinkText()
*/
@Override
- protected String getNewWizardLinkText() {
- return String.format("Create a new <a>%1s</a>", "Institution ");
+ protected String[] getNewWizardText() {
+ return new String[]{"New Institution"};
}
/* (non-Javadoc)
import org.eclipse.swt.widgets.Shell;
-import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
import eu.etaxonomy.cdm.api.service.IMediaService;
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
import eu.etaxonomy.cdm.model.media.Media;
public class MediaSelectionDialog extends
AbstractFilteredCdmResourceSelectionDialog<Media> {
- public static Media select(Shell shell, ConversationHolder conversation, Media media){
- MediaSelectionDialog dialog = new MediaSelectionDialog(shell, conversation,
+ public static Media select(Shell shell, //ConversationHolder conversation,
+ Media media){
+ MediaSelectionDialog dialog = new MediaSelectionDialog(shell, //conversation,
"Choose Media", false, MediaSelectionDialog.class.getCanonicalName(), media);
return getSelectionFromDialog(dialog);
}
/**
* <p>Constructor for FilteredDerivedUnitSelectionDialog.</p>
*/
- protected MediaSelectionDialog(Shell shell, ConversationHolder conversation, String title,
+ protected MediaSelectionDialog(Shell shell, //ConversationHolder conversation,
+ String title,
boolean multi, String settings, Media cdmObject) {
- super(shell, conversation, title, multi, settings, cdmObject);
+ super(shell, //conversation,
+ title, multi, settings, cdmObject);
}
/** {@inheritDoc} */
/** {@inheritDoc} */
@Override
- protected void initModel() {
- model = CdmStore.getService(IMediaService.class).getUuidAndTitleCache(null, null);
+ protected void callService(String pattern) {
+ model = CdmStore.getService(IMediaService.class).getUuidAndTitleCache(limitOfInitialElements, pattern);
+
}
/* (non-Javadoc)
/** {@inheritDoc} */
@Override
- protected String getNewWizardLinkText() {
- return "";
+ protected String[] getNewWizardText() {
+ return null;
}
}
import java.util.UUID;
-import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Text;
-import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
import eu.etaxonomy.cdm.api.service.INameService;
import eu.etaxonomy.cdm.model.name.TaxonName;
import eu.etaxonomy.taxeditor.newWizard.AbstractNewEntityWizard;
*/
public class NameSelectionDialog extends AbstractFilteredCdmResourceSelectionDialog<TaxonName> {
- public static TaxonName select(Shell shell, ConversationHolder conversation, TaxonName name) {
- NameSelectionDialog dialog = new NameSelectionDialog(shell, conversation,
+ public static TaxonName select(Shell shell, //ConversationHolder conversation,
+ TaxonName name) {
+ NameSelectionDialog dialog = new NameSelectionDialog(shell, //conversation,
"Choose a name", false, name);
return getSelectionFromDialog(dialog);
}
- protected NameSelectionDialog(Shell shell, ConversationHolder conversation, String title, boolean multi, TaxonName name) {
- super(shell, conversation, title, multi, NameSelectionDialog.class.getCanonicalName(), name);
+ protected NameSelectionDialog(Shell shell, //ConversationHolder conversation,
+ String title, boolean multi, TaxonName name) {
+ super(shell, //conversation,
+ title, multi, NameSelectionDialog.class.getCanonicalName(), name);
}
/** {@inheritDoc} */
}
/** {@inheritDoc} */
- @Override
- protected void initModel() {
- Control control = getPatternControl();
- String pattern = null;
- if (control != null){
- pattern = ((Text)control).getText();
- }
-
- if (pattern == null || pattern.equals("?")){
- model = CdmStore.getService(INameService.class).getUuidAndTitleCache(null, null);
- }else{
- model = CdmStore.getService(INameService.class).getUuidAndTitleCache(limitOfInitialElements, pattern);
- }
- }
+// @Override
+// protected void search() {
+// Control control =getSearchField();
+// String pattern = null;
+// if (control != null){
+// pattern = ((Text)control).getText();
+// }
+//
+// if (pattern.equals("?")){
+// model = CdmStore.getService(INameService.class).getUuidAndTitleCache(null, null);
+// }else if (pattern != null){
+// model = CdmStore.getService(INameService.class).getUuidAndTitleCache(limitOfInitialElements, pattern);
+// }
+// }
/** {@inheritDoc} */
@Override
/** {@inheritDoc} */
@Override
- protected String getNewWizardLinkText() {
- return String.format("Create a new <a>%1s</a>", "Name ");
+ protected String[] getNewWizardText() {
+ return new String[]{"New Name"};
}
+
+ /* (non-Javadoc)
+ * @see eu.etaxonomy.taxeditor.ui.dialog.selection.AbstractFilteredCdmResourceSelectionDialog#callService(java.lang.String)
+ */
+ @Override
+ void callService(String pattern) {
+ model = CdmStore.getService(INameService.class).getUuidAndTitleCache(limitOfInitialElements, pattern);
+ }
}
package eu.etaxonomy.taxeditor.ui.dialog.selection;
import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashSet;
import java.util.List;
-import java.util.Set;
import java.util.UUID;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Shell;
+import org.eclipse.wb.swt.ResourceManager;
-import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
+import eu.etaxonomy.cdm.api.service.ITermService;
import eu.etaxonomy.cdm.api.service.IVocabularyService;
-import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
import eu.etaxonomy.cdm.model.common.CdmBase;
import eu.etaxonomy.cdm.model.common.TermType;
import eu.etaxonomy.cdm.model.common.TermVocabulary;
import eu.etaxonomy.cdm.model.location.NamedArea;
-import eu.etaxonomy.cdm.persistence.dto.UuidAndTitleCache;
import eu.etaxonomy.taxeditor.model.MessagingUtils;
import eu.etaxonomy.taxeditor.newWizard.AbstractNewEntityWizard;
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
selectedVocabularies.remove(vocabulary);
}
PreferencesUtil.getPreferenceStore().setValue(getPrefKey(vocabulary), !isChecked());
- initModel();
+ search();
}
}
- protected Collection<TermVocabulary> selectedVocabularies;
+ protected List<TermVocabulary> selectedVocabularies;
protected ArrayList<TermVocabulary> preselectedVocabularies;
- private Object preferenceID;
+
/**
* @param namedArea
* A namedArea that should be selected when the dialog opens
* @param conversation a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder} object.
- * @param preferenceId a class which is used for generating the preference key so that every
+ * @param preferenceId a class which is used for generating the preference key so that every
* dialogs can be grouped to have their own preferences depending on this id
* @param preselectedVocabularyUuids the {@link UUID}s of the pre-selected vocabularies
* @return a {@link eu.etaxonomy.cdm.model.location.NamedArea} object.
*/
- public static NamedArea select(Shell shell, ConversationHolder conversation, NamedArea namedArea, String preferenceId, UUID... preselectedVocabularyUuids) {
- NamedAreaSelectionDialog dialog = new NamedAreaSelectionDialog(shell, conversation,
+ public static NamedArea select(Shell shell, //ConversationHolder conversation,
+ NamedArea namedArea, String preferenceId, UUID... preselectedVocabularyUuids) {
+ NamedAreaSelectionDialog dialog = new NamedAreaSelectionDialog(shell, //conversation,
"Choose an area", false, namedArea, preferenceId, preselectedVocabularyUuids);
return getSelectionFromDialog(dialog);
}
- protected NamedAreaSelectionDialog(Shell shell, ConversationHolder conversation, String title, boolean multi, NamedArea namedArea, Object preferenceId, UUID... preselectedVocabularyUuids) {
- super(shell, conversation, title, multi, NamedAreaSelectionDialog.class.getCanonicalName(), namedArea);
+ protected NamedAreaSelectionDialog(Shell shell, //ConversationHolder conversation,
+ String title, boolean multi, NamedArea namedArea, Object preferenceId, UUID... preselectedVocabularyUuids) {
+ super(shell, //conversation,
+ title, multi, NamedAreaSelectionDialog.class.getCanonicalName(), namedArea);
this.preferenceID = preferenceId;
preselectedVocabularies = new ArrayList<TermVocabulary>();
for(int i=0;i<preselectedVocabularyUuids.length;i++){
TermVocabulary preselectedVocabulary = CdmStore.getService(IVocabularyService.class).find(preselectedVocabularyUuids[i]);
preselectedVocabularies.add(preselectedVocabulary);
}
- Collection<TermVocabulary> tempSelectedVocabularies = new HashSet<>();
- for(TermVocabulary vocabulary:selectedVocabularies){
+
+
+ selectedVocabularies = createSelectedVocabularies();;
+// search;//re-init to consider pre-selected vocabularies
+ }
+
+ private List<TermVocabulary> createSelectedVocabularies() {
+ List<TermVocabulary> tempSelectedVocabularies = new ArrayList<TermVocabulary>();
+ for(TermVocabulary vocabulary:selectedVocabularies){
if(preselectedVocabularies.contains(vocabulary)
|| !PreferencesUtil.getPreferenceStore().getBoolean(getPrefKey(vocabulary))){
tempSelectedVocabularies.add(vocabulary);
}
}
- selectedVocabularies = tempSelectedVocabularies;
- initModel();//re-init to consider pre-selected vocabularies
- }
+ return tempSelectedVocabularies;
+ }
/** {@inheritDoc} */
- @Override
- protected void fillViewMenu(IMenuManager menuManager) {
-
- super.fillViewMenu(menuManager);
+// @Override
+// protected void fillViewMenu(IMenuManager menuManager) {
+//
+//// super.fillViewMenu(menuManager);
+//
+// for(TermVocabulary<NamedArea> vocabulary : getAvailableVocabularies()){
+// IncludeNamedAreaVocabulary action = new IncludeNamedAreaVocabulary(vocabulary);
+// menuManager.add(action);
+// if(preselectedVocabularies.contains(vocabulary)) {
+// action.setChecked(true);
+// }
+// else{
+// action.setChecked(!PreferencesUtil.getPreferenceStore().getBoolean(getPrefKey(vocabulary)));
+// }
+// }
+// }
- for(TermVocabulary<NamedArea> vocabulary : getAvailableVocabularies()){
- IncludeNamedAreaVocabulary action = new IncludeNamedAreaVocabulary(vocabulary);
- menuManager.add(action);
- if(preselectedVocabularies.contains(vocabulary)) {
- action.setChecked(true);
- }
- else{
- action.setChecked(!PreferencesUtil.getPreferenceStore().getBoolean(getPrefKey(vocabulary)));
- }
- }
- }
-
private String getPrefKey(TermVocabulary vocabulary){
return "hide_"+NamedAreaSelectionDialog.class.getCanonicalName()+vocabulary.getUuid()+preferenceID;
}
return vocabularies;
}
- /** {@inheritDoc} */
- @Override
- protected void initModel() {
-
- Set<NamedArea> terms = new HashSet<NamedArea>();
- for(TermVocabulary<NamedArea> vocabulary : selectedVocabularies){
- terms.addAll(vocabulary.getTermsOrderedByLabels(CdmStore.getDefaultLanguage()));
- }
+// /** {@inheritDoc} */
+// @Override
+// protected void search() {
+// Control control =getSearchField();
+// String pattern = null;
+// if (control != null){
+// pattern = ((Text)control).getText();
+// }
+//
+// if (pattern == null || pattern.equals("?")){
+// model = CdmStore.getService(ITermService.class).getUuidAndTitleCache(selectedVocabularies, limitOfInitialElements, null, PreferencesUtil.getGlobalLanguage());
+// }else{
+// model = CdmStore.getService(ITermService.class).getUuidAndTitleCache(selectedVocabularies, limitOfInitialElements, pattern, PreferencesUtil.getGlobalLanguage());
+// }
+// }
- if(model == null){
- model = new ArrayList<UuidAndTitleCache<NamedArea>>();
- }
- model.clear();
- for(Object areaObject : terms){
- NamedArea area = (NamedArea) HibernateProxyHelper.deproxy(areaObject);
- UuidAndTitleCache<NamedArea> element = new UuidAndTitleCache<NamedArea>(NamedArea.class, area.getUuid(), area.getId(), getTitle(area));
- model.add(element);
- }
- }
-
- /** {@inheritDoc} */
- @Override
- protected Control createExtendedContentArea(Composite parent) {
- return null;
- }
+// /** {@inheritDoc} */
+// @Override
+// protected Control createExtendedContentArea(Composite parent) {
+// return null;
+// }
/** {@inheritDoc} */
@Override
/** {@inheritDoc} */
@Override
- protected String getNewWizardLinkText() {
+ protected String[] getNewWizardText() {
return null;
}
+
+ @Override
+ void createFilterButton(Composite searchAndFilter)
+ {
+ filterButton = new Button(searchAndFilter, SWT.NONE);
+// filterButton.setText("Filter");
+ filterButton.setImage(ResourceManager.getPluginImage("eu.etaxonomy.taxeditor.store", "icons/funnel-icon.png"));
+// SelectionListener filterSelectionListener = new FilterSelectionListener(preferenceID, this);
+ filterButton.addSelectionListener(new SelectionListener(){
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+
+ Object source = e.getSource();
+ String text = null;
+ if (source instanceof Button){
+ Shell shell = ((Button)source).getShell();
+ Dialog dialog = new FilterDialog(getShell(), preferenceID, selectedVocabularies);
+ if(dialog!=null){
+ dialog.open();
+ }
+ createSelectedVocabularies();
+ search();
+ }
+
+
+
+
+ }
+
+ @Override
+ public void widgetDefaultSelected(SelectionEvent e) {
+ // TODO Auto-generated method stub
+
+ }
+
+
+ });
+
+ }
+
+ /**
+ *
+ */
+ public void setSelectedVocabularies() {
+ // TODO Auto-generated method stub
+
+ }
+
+ /* (non-Javadoc)
+ * @see eu.etaxonomy.taxeditor.ui.dialog.selection.AbstractFilteredCdmResourceSelectionDialog#callService(java.lang.String)
+ */
+ @Override
+ void callService(String pattern) {
+ model = CdmStore.getService(ITermService.class).getUuidAndTitleCache(selectedVocabularies, limitOfInitialElements, pattern, PreferencesUtil.getGlobalLanguage());
+ }
+
}
import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Text;
-import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
import eu.etaxonomy.cdm.api.service.IAgentService;
import eu.etaxonomy.cdm.model.agent.AgentBase;
import eu.etaxonomy.cdm.model.agent.TeamOrPersonBase;
* @param settings
* @param agent
*/
- protected NomenclaturalAuthorSelectionDialog(Shell shell, ConversationHolder conversation, String title,
+ protected NomenclaturalAuthorSelectionDialog(Shell shell, //ConversationHolder conversation,
+ String title,
boolean multi, String settings, AgentBase agent, boolean teamMemberSelection) {
- super(shell, conversation, title, multi, settings, agent, teamMemberSelection);
+ super(shell, //conversation,
+ title, multi, settings, agent, teamMemberSelection);
// TODO Auto-generated constructor stub
}
@Override
- protected void initModel() {
- Control control = getPatternControl();
- String pattern = null;
- if (control != null){
- pattern = ((Text)control).getText();
- }
- if (pattern == null || pattern.equals("?")){
- model = CdmStore.getService(IAgentService.class).getUuidAndAbbrevTitleCache(null, null, null);
- }else{
- model = CdmStore.getService(IAgentService.class).getUuidAndAbbrevTitleCache(limitOfInitialElements, pattern, null);
- }
+ protected void callService(String pattern) {
+ model = CdmStore.getService(IAgentService.class).getUuidAndAbbrevTitleCache(limitOfInitialElements, pattern, null);
}
/** {@inheritDoc} */
* @param entity a {@link eu.etaxonomy.cdm.model.agent.AgentBase} object.
* @return a {@link eu.etaxonomy.cdm.model.agent.AgentBase} object.
*/
- public static AgentBase select(Shell shell, ConversationHolder conversation, AgentBase entity, boolean teamMemberSelection) {
- NomenclaturalAuthorSelectionDialog dialog = new NomenclaturalAuthorSelectionDialog(shell, conversation,
+ public static AgentBase select(Shell shell, //ConversationHolder conversation,
+ AgentBase entity, boolean teamMemberSelection) {
+ NomenclaturalAuthorSelectionDialog dialog = new NomenclaturalAuthorSelectionDialog(shell, //conversation,
"Choose Agent", false, NomenclaturalAuthorSelectionDialog.class.getCanonicalName(), entity, teamMemberSelection);
return getSelectionFromDialog(dialog);
}
};
/** {@inheritDoc} */
- @Override
- protected ItemsFilter createFilter() {
- return new ItemsFilter() {
-
- /**
- * Always returns false to enforce refiltering even if the pattern is equal
- */
- @Override
- public boolean equalsFilter(ItemsFilter filter) {
- return false;
- }
-
- @Override
- public boolean isConsistentItem(Object item) {
- return false;
- }
-
- @Override
- public boolean matchItem(Object item) {
- String textTitleCache = null;
- String abbrevTitleCache = null;
- if(item instanceof UuidAndTitleCache){
- if (((UuidAndTitleCache) item).getAbbrevTitleCache() != null){
- abbrevTitleCache = ((UuidAndTitleCache) item).getAbbrevTitleCache();
- }
- if (((UuidAndTitleCache) item).getTitleCache() != null ){
- textTitleCache = ((UuidAndTitleCache) item).getTitleCache();
- }
- }else if(item instanceof String){
- textTitleCache = (String) item;
- }
-
- return (matches(textTitleCache) || matches(abbrevTitleCache)) ;
-
- }
-
- };
- }
+// @Override
+// protected ItemsFilter createFilter() {
+// return new ItemsFilter() {
+//
+// /**
+// * Always returns false to enforce refiltering even if the pattern is equal
+// */
+// @Override
+// public boolean equalsFilter(ItemsFilter filter) {
+// return false;
+// }
+//
+// @Override
+// public boolean isConsistentItem(Object item) {
+// return false;
+// }
+//
+// @Override
+// public boolean matchItem(Object item) {
+// String textTitleCache = null;
+// String abbrevTitleCache = null;
+// if(item instanceof UuidAndTitleCache){
+// if (((UuidAndTitleCache) item).getAbbrevTitleCache() != null){
+// abbrevTitleCache = ((UuidAndTitleCache) item).getAbbrevTitleCache();
+// }
+// if (((UuidAndTitleCache) item).getTitleCache() != null ){
+// textTitleCache = ((UuidAndTitleCache) item).getTitleCache();
+// }
+// }else if(item instanceof String){
+// textTitleCache = (String) item;
+// }
+//
+// return (matches(textTitleCache) || matches(abbrevTitleCache)) ;
+//
+// }
+//
+// };
+// }
@Override
protected Comparator getItemsComparator() {
import java.util.UUID;
-import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Text;
-import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
import eu.etaxonomy.cdm.api.service.IAgentService;
import eu.etaxonomy.cdm.model.agent.AgentBase;
import eu.etaxonomy.cdm.model.agent.Team;
* @param team a {@link eu.etaxonomy.cdm.model.agent.Team} object.
* @return a {@link eu.etaxonomy.cdm.model.agent.Team} object.
*/
- public static Team select(Shell shell, ConversationHolder conversation, Team team){
- NomenclaturalAuthorTeamSelectionDialog dialog = new NomenclaturalAuthorTeamSelectionDialog(shell, conversation,
+ public static Team select(Shell shell, //ConversationHolder conversation,
+ Team team){
+ NomenclaturalAuthorTeamSelectionDialog dialog = new NomenclaturalAuthorTeamSelectionDialog(shell, //conversation,
"Choose Author Team", false, NomenclaturalAuthorTeamSelectionDialog.class.getCanonicalName(), team);
return (Team)getSelectionFromDialog(dialog);
}
* @param settings a {@link java.lang.String} object.
* @param agent a {@link eu.etaxonomy.cdm.model.agent.Team} object.
*/
- protected NomenclaturalAuthorTeamSelectionDialog(Shell shell, ConversationHolder conversation, String title,
+ protected NomenclaturalAuthorTeamSelectionDialog(Shell shell, //ConversationHolder conversation,
+ String title,
boolean multi, String settings, Team agent) {
- super(shell, conversation, title, multi, settings, agent);
+ super(shell, //conversation,
+ title, multi, settings, agent);
}
/** {@inheritDoc} */
/** {@inheritDoc} */
@Override
- protected String getNewWizardLinkText() {
- return String.format("Create a new <a>%1s</a>", "Team ");
+ protected String[] getNewWizardText() {
+ return new String[]{"new Team"};
}
- /** {@inheritDoc} */
- @Override
- protected void initModel() {
- Control control = getPatternControl();
- String pattern = null;
- if (control != null){
- pattern = ((Text)control).getText();
- }
-
- model = CdmStore.getService(IAgentService.class).getUuidAndAbbrevTitleCache(limitOfInitialElements, pattern, Team.class);
- }
+// /** {@inheritDoc} */
+// @Override
+// protected void search() {
+// Control control =getSearchField();
+// String pattern = null;
+// if (control != null){
+// pattern = ((Text)control).getText();
+// }
+//
+// model = CdmStore.getService(IAgentService.class).getUuidAndAbbrevTitleCache(limitOfInitialElements, pattern, Team.class);
+// }
/** {@inheritDoc} */
@Override
protected Team getPersistentObject(UUID uuid) {
return CdmBase.deproxy(CdmStore.getService(IAgentService.class).load(uuid), Team.class) ;
}
+
+ /* (non-Javadoc)
+ * @see eu.etaxonomy.taxeditor.ui.dialog.selection.AbstractFilteredCdmResourceSelectionDialog#callService(java.lang.String)
+ */
+ @Override
+ void callService(String pattern) {
+ model = CdmStore.getService(IAgentService.class).getUuidAndAbbrevTitleCache(limitOfInitialElements, pattern, Team.class);
+ }
}
*/
package eu.etaxonomy.taxeditor.ui.dialog.selection;
-import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Text;
-import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
import eu.etaxonomy.cdm.api.service.IAgentService;
import eu.etaxonomy.cdm.model.agent.AgentBase;
import eu.etaxonomy.cdm.model.agent.Person;
* @param settings
* @param agent
*/
- protected NomenclaturalPersonAuthorSelectionDialog(Shell shell, ConversationHolder conversation, String title,
+ protected NomenclaturalPersonAuthorSelectionDialog(Shell shell, //ConversationHolder conversation,
+ String title,
boolean multi, String settings, AgentBase agent, boolean teamMemberSelection) {
- super(shell, conversation, title, multi, settings, agent, teamMemberSelection);
+ super(shell, //conversation,
+ title, multi, settings, agent, teamMemberSelection);
// TODO Auto-generated constructor stub
}
* @param entity a {@link eu.etaxonomy.cdm.model.agent.AgentBase} object.
* @return a {@link eu.etaxonomy.cdm.model.agent.AgentBase} object.
*/
- public static AgentBase select(Shell shell, ConversationHolder conversation, AgentBase entity, boolean teamMemberSelection) {
- NomenclaturalPersonAuthorSelectionDialog dialog = new NomenclaturalPersonAuthorSelectionDialog(shell, conversation,
+ public static AgentBase select(Shell shell, //ConversationHolder conversation,
+ AgentBase entity, boolean teamMemberSelection) {
+ NomenclaturalPersonAuthorSelectionDialog dialog = new NomenclaturalPersonAuthorSelectionDialog(shell, //conversation,
"Choose Agent", false, NomenclaturalAuthorSelectionDialog.class.getCanonicalName(), entity,teamMemberSelection);
return getSelectionFromDialog(dialog);
}
@Override
- protected void initModel() {
- Control control = getPatternControl();
- String pattern = null;
- if (control != null){
- pattern = ((Text)control).getText();
- }
-
+ protected void callService(String pattern) {
model = CdmStore.getService(IAgentService.class).getUuidAndAbbrevTitleCache(limitOfInitialElements, pattern, Person.class);
}
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
-import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
import eu.etaxonomy.cdm.api.service.IReferenceService;
import eu.etaxonomy.cdm.model.agent.TeamOrPersonBase;
import eu.etaxonomy.cdm.model.reference.Reference;
private TeamOrPersonBase author;
private boolean firstCall = true;
- protected NomenclaturalReferenceSelectionDialog(Shell shell,
- ConversationHolder conversation, String title, boolean multi,
+ protected NomenclaturalReferenceSelectionDialog(Shell shell,//ConversationHolder conversation,
+ String title, boolean multi,
Reference reference, boolean inReference, TeamOrPersonBase author) {
- super(shell, conversation, title, multi, reference);
+ super(shell, //conversation,
+ title, multi, reference);
this.author = author;
firstCall = true;
}
/* (non-Javadoc)
- * @see eu.etaxonomy.taxeditor.dialogs.AbstractFilteredCdmResourceSelectionDialog#initModel()
+ * @see eu.etaxonomy.taxeditor.dialogs.AbstractFilteredCdmResourceSelectionDialog#search
*/
/** {@inheritDoc} */
@Override
- protected void initModel() {
- Control control = getPatternControl();
- String pattern = null;
- if (control != null){
- pattern = ((Text)control).getText();
+ protected void callService(String pattern) {
+ Control control =getSearchField();
- }
if (firstCall && author != null){
pattern = author.getNomenclaturalTitle();
if (control!= null){
}
- if (pattern == null || pattern.equals("?")){
- model = CdmStore.getService(IReferenceService.class).getUuidAndAbbrevTitleCache(null, null);
- }else{
- model = CdmStore.getService(IReferenceService.class).getUuidAndAbbrevTitleCache(limitOfInitialElements, pattern);
- }
+ model = CdmStore.getService(IReferenceService.class).getUuidAndAbbrevTitleCache(limitOfInitialElements, pattern);
+
}
/**
* @return a {@link eu.etaxonomy.cdm.model.reference.ReferenceBase} object.
*/
- public static Reference select(Shell shell, ConversationHolder conversation, Reference reference, TeamOrPersonBase author) {
- NomenclaturalReferenceSelectionDialog dialog = new NomenclaturalReferenceSelectionDialog(shell, conversation,
+ public static Reference select(Shell shell, //ConversationHolder conversation,
+ Reference reference, TeamOrPersonBase author) {
+ NomenclaturalReferenceSelectionDialog dialog = new NomenclaturalReferenceSelectionDialog(shell,// conversation,
"Choose a reference", isInReference, reference, false, author);
return getSelectionFromDialog(dialog);
}
* @see org.eclipse.ui.dialogs.FilteredItemsSelectionDialog#createFilter()
*/
/** {@inheritDoc} */
- @Override
- protected ItemsFilter createFilter() {
- return new ItemsFilter() {
-
- /**
- * Always returns false to enforce refiltering even if the pattern is equal
- */
- @Override
- public boolean equalsFilter(ItemsFilter filter) {
- return false;
- }
-
- @Override
- public boolean isConsistentItem(Object item) {
- return false;
- }
-
- @Override
- public boolean matchItem(Object item) {
- return true;
-// String text = null;
-// if(item instanceof UuidAndTitleCache){
-// if (((UuidAndTitleCache) item).getAbbrevTitleCache() != null){
-// text = ((UuidAndTitleCache) item).getAbbrevTitleCache();
-// } else{
-// text = ((UuidAndTitleCache) item).getTitleCache();
-// }
-// }else if(item instanceof String){
-// text = (String) item;
-// }
-// return text != null ? matches(text) : false;
- }
-
- };
- }
+// @Override
+// protected ItemsFilter createFilter() {
+// return new ItemsFilter() {
+//
+// /**
+// * Always returns false to enforce refiltering even if the pattern is equal
+// */
+// @Override
+// public boolean equalsFilter(ItemsFilter filter) {
+// return false;
+// }
+//
+// @Override
+// public boolean isConsistentItem(Object item) {
+// return false;
+// }
+//
+// @Override
+// public boolean matchItem(Object item) {
+// return true;
+//// String text = null;
+//// if(item instanceof UuidAndTitleCache){
+//// if (((UuidAndTitleCache) item).getAbbrevTitleCache() != null){
+//// text = ((UuidAndTitleCache) item).getAbbrevTitleCache();
+//// } else{
+//// text = ((UuidAndTitleCache) item).getTitleCache();
+//// }
+//// }else if(item instanceof String){
+//// text = (String) item;
+//// }
+//// return text != null ? matches(text) : false;
+// }
+//
+// };
+// }
/**
* 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.
*/
* @return a {@link eu.etaxonomy.cdm.model.common.OriginalSourceType} object.
*/
public static OriginalSourceType select(Shell shell, ConversationHolder conversation){
- OriginalSourceTypeSelectionDialog dialog =
- new OriginalSourceTypeSelectionDialog(shell,
+ OriginalSourceTypeSelectionDialog dialog =
+ new OriginalSourceTypeSelectionDialog(shell,
conversation,
- "Choose Original Source Type",
- false,
+ "Choose Original Source Type",
+ false,
OriginalSourceTypeSelectionDialog.class.getCanonicalName());
return getSelectionFromDialog(dialog);
}
-
+
/**
* <p>Constructor for FilteredDerivedUnitSelectionDialog.</p>
*
* @param multi a boolean.
* @param settings a {@link java.lang.String} object.
*/
- protected OriginalSourceTypeSelectionDialog(Shell shell,
- ConversationHolder conversation,
+ protected OriginalSourceTypeSelectionDialog(Shell shell,
+ ConversationHolder conversation,
String title,
- boolean multi,
+ boolean multi,
String settings) {
super(shell, conversation, title, multi, settings, OriginalSourceType.PrimaryTaxonomicSource);
}
@Override
protected void initModel() {
model = new ArrayList<OriginalSourceType>();
- model.addAll(EnumSet.allOf(OriginalSourceType.class));
+ model.addAll(EnumSet.allOf(OriginalSourceType.class));
}
/** {@inheritDoc} */
import org.eclipse.swt.widgets.Shell;
-import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
import eu.etaxonomy.cdm.api.service.IAgentService;
import eu.etaxonomy.cdm.model.agent.Person;
import eu.etaxonomy.taxeditor.newWizard.AbstractNewEntityWizard;
* @param person a {@link eu.etaxonomy.cdm.model.agent.Person} object.
* @return a {@link eu.etaxonomy.cdm.model.agent.Person} object.
*/
- public static Person select(Shell shell, ConversationHolder conversation, Person person){
- PersonSelectionDialog dialog = new PersonSelectionDialog(shell, conversation,
+ public static Person select(Shell shell, //onversationHolder conversation,
+ Person person){
+ PersonSelectionDialog dialog = new PersonSelectionDialog(shell, //conversation,
"Choose a person", false, PersonSelectionDialog.class.getCanonicalName(), person);
return getSelectionFromDialog(dialog);
}
* @param cdmObject a {@link eu.etaxonomy.cdm.model.agent.Person} object.
* @param conversation a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder} object.
*/
- protected PersonSelectionDialog(Shell shell, ConversationHolder conversation, String title,
+ protected PersonSelectionDialog(Shell shell,// ConversationHolder conversation,
+ String title,
boolean multi, String settings, Person cdmObject) {
- super(shell, conversation, title, multi, settings, cdmObject);
+ super(shell, //conversation,
+ title, multi, settings, cdmObject);
}
}
/* (non-Javadoc)
- * @see eu.etaxonomy.taxeditor.dialogs.filteredSelection.AbstractFilteredCdmResourceSelectionDialog#initModel()
+ * @see eu.etaxonomy.taxeditor.dialogs.filteredSelection.AbstractFilteredCdmResourceSelectionDialog#search
*/
/** {@inheritDoc} */
@Override
- protected void initModel() {
- model = CdmStore.getService(IAgentService.class).getPersonUuidAndTitleCache();
+ protected void callService(String pattern) {
+ model = CdmStore.getService(IAgentService.class).getUuidAndTitleCache(Person.class, limitOfInitialElements, pattern);
}
/** {@inheritDoc} */
/** {@inheritDoc} */
@Override
- protected String getNewWizardLinkText() {
- return String.format("Create a new <a>%1s</a>", "Person ");
+ protected String[] getNewWizardText() {
+ return new String[]{"New Person"};
}
}
import org.eclipse.swt.widgets.Shell;
-import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
import eu.etaxonomy.cdm.api.service.IPolytomousKeyService;
import eu.etaxonomy.cdm.model.description.PolytomousKey;
import eu.etaxonomy.taxeditor.newWizard.AbstractNewEntityWizard;
public class PolytomousKeySelectionDialog extends
AbstractFilteredCdmResourceSelectionDialog<PolytomousKey> {
- public static PolytomousKey select(Shell shell, ConversationHolder conversation, PolytomousKey key){
- PolytomousKeySelectionDialog dialog = new PolytomousKeySelectionDialog(shell, conversation,
+ public static PolytomousKey select(Shell shell, //ConversationHolder conversation,
+ PolytomousKey key){
+ PolytomousKeySelectionDialog dialog = new PolytomousKeySelectionDialog(shell, //conversation,
"Choose Polytomous Key", false, PolytomousKeySelectionDialog.class.getCanonicalName(), key);
return getSelectionFromDialog(dialog);
}
* @param settings
* @param cdmObject
*/
- protected PolytomousKeySelectionDialog(Shell shell,
- ConversationHolder conversation, String title, boolean multi,
+ protected PolytomousKeySelectionDialog(Shell shell,//ConversationHolder conversation,
+ String title, boolean multi,
String settings, PolytomousKey cdmObject) {
- super(shell, conversation, title, multi, settings, cdmObject);
+ super(shell, //conversation,
+ title, multi, settings, cdmObject);
}
/* (non-Javadoc)
}
/* (non-Javadoc)
- * @see eu.etaxonomy.taxeditor.dialogs.filteredSelection.AbstractFilteredCdmResourceSelectionDialog#initModel()
+ * @see eu.etaxonomy.taxeditor.dialogs.filteredSelection.AbstractFilteredCdmResourceSelectionDialog#search
*/
@Override
- protected void initModel() {
- model = CdmStore.getService(IPolytomousKeyService.class).getUuidAndTitleCache(null, null);
+ protected void callService(String pattern) {
+ model = CdmStore.getService(IPolytomousKeyService.class).getUuidAndTitleCache(limitOfInitialElements, pattern);
}
/* (non-Javadoc)
* @see eu.etaxonomy.taxeditor.dialogs.filteredSelection.AbstractFilteredCdmResourceSelectionDialog#getNewWizardLinkText()
*/
@Override
- protected String getNewWizardLinkText() {
+ protected String[] getNewWizardText() {
return null;
}
import org.eclipse.swt.widgets.Shell;
-import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
import eu.etaxonomy.cdm.api.service.molecular.IPrimerService;
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
import eu.etaxonomy.cdm.model.molecular.Primer;
public class PrimerSelectionDialog extends
AbstractFilteredCdmResourceSelectionDialog<Primer> {
- public static Primer select(Shell shell, ConversationHolder conversation, Primer primer){
- PrimerSelectionDialog dialog = new PrimerSelectionDialog(shell, conversation,
+ public static Primer select(Shell shell, //ConversationHolder conversation,
+ Primer primer){
+ PrimerSelectionDialog dialog = new PrimerSelectionDialog(shell, //conversation,
"Choose Primer", false, PrimerSelectionDialog.class.getCanonicalName(), primer);
return getSelectionFromDialog(dialog);
}
/**
* <p>Constructor for FilteredDerivedUnitSelectionDialog.</p>
*/
- protected PrimerSelectionDialog(Shell shell, ConversationHolder conversation, String title,
+ protected PrimerSelectionDialog(Shell shell, //ConversationHolder conversation,
+ String title,
boolean multi, String settings, Primer cdmObject) {
- super(shell, conversation, title, multi, settings, cdmObject);
+ super(shell, //conversation,
+ title, multi, settings, cdmObject);
}
/** {@inheritDoc} */
/** {@inheritDoc} */
@Override
- protected void initModel() {
- model = CdmStore.getService(IPrimerService.class).getPrimerUuidAndTitleCache();
+ protected void callService(String pattern) {
+ model = CdmStore.getService(IPrimerService.class).getUuidAndTitleCache(limitOfInitialElements, pattern);
}
/* (non-Javadoc)
/** {@inheritDoc} */
@Override
- protected String getNewWizardLinkText() {
- return String.format("Create a new <a>%1s</a>", "Primer ");
+ protected String[] getNewWizardText() {
+ return new String[]{"New Primer"};
}
}
import java.util.UUID;
-import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Text;
-import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
import eu.etaxonomy.cdm.api.service.IReferenceService;
import eu.etaxonomy.cdm.model.reference.Reference;
import eu.etaxonomy.taxeditor.newWizard.AbstractNewEntityWizard;
* @param conversation a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder} object.
* @return a {@link eu.etaxonomy.cdm.model.reference.ReferenceBase} object.
*/
- public static Reference select(Shell shell, ConversationHolder conversation, Reference reference, boolean isInReference) {
- ReferenceSelectionDialog dialog = new ReferenceSelectionDialog(shell, conversation,
+ public static Reference select(Shell shell, //ConversationHolder conversation,
+ Reference reference, boolean isInReference) {
+ ReferenceSelectionDialog dialog = new ReferenceSelectionDialog(shell, //conversation,
"Choose a reference", false, reference, isInReference);
return getSelectionFromDialog(dialog);
}
* @param conversation a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder} object.
* @return a {@link eu.etaxonomy.cdm.model.reference.ReferenceBase} object.
*/
- public static Reference select(Shell shell, ConversationHolder conversation, Reference reference) {
- ReferenceSelectionDialog dialog = new ReferenceSelectionDialog(shell, conversation,
+ public static Reference select(Shell shell, //ConversationHolder conversation,
+ Reference reference) {
+ ReferenceSelectionDialog dialog = new ReferenceSelectionDialog(shell, //conversation,
"Choose a reference", false, reference);
return getSelectionFromDialog(dialog);
}
* @param conversation a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder} object.
* @param multi a boolean.
*/
- protected ReferenceSelectionDialog(Shell shell, ConversationHolder conversation, String title, boolean multi, Reference reference) {
- super(shell, conversation, title, multi, ReferenceSelectionDialog.class.getCanonicalName(), null);
+ protected ReferenceSelectionDialog(Shell shell, //ConversationHolder conversation,
+ String title, boolean multi, Reference reference) {
+ super(shell, //conversation,
+ title, multi, ReferenceSelectionDialog.class.getCanonicalName(), null);
this.currentReference = reference;
* @param conversation a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder} object.
* @param multi a boolean.
*/
- protected ReferenceSelectionDialog(Shell shell, ConversationHolder conversation, String title, boolean multi, Reference reference, boolean isInReference) {
- super(shell, conversation, title, multi, ReferenceSelectionDialog.class.getCanonicalName(), null);
+ protected ReferenceSelectionDialog(Shell shell, //ConversationHolder conversation,
+ String title, boolean multi, Reference reference, boolean isInReference) {
+ super(shell, //conversation,
+ title, multi, ReferenceSelectionDialog.class.getCanonicalName(), null);
this.isInReference = isInReference;
this.currentReference = reference;
}
/* (non-Javadoc)
- * @see eu.etaxonomy.taxeditor.dialogs.AbstractFilteredCdmResourceSelectionDialog#initModel()
+ * @see eu.etaxonomy.taxeditor.dialogs.AbstractFilteredCdmResourceSelectionDialog#search
*/
/** {@inheritDoc} */
@Override
- protected void initModel() {
- Control control = getPatternControl();
- String pattern = null;
- if (control != null){
- pattern = ((Text)control).getText();
- }
-
- if (pattern == null || pattern.equals("?")){
- if (isInReference && currentReference != null){
- model = CdmStore.getService(IReferenceService.class).getUuidAndTitleCache(null,null,currentReference.getType());
- }else{
- model = CdmStore.getService(IReferenceService.class).getUuidAndTitleCache(null,null);
- }
+ protected void callService(String pattern) {
+ if (isInReference && currentReference != null){
+ model = CdmStore.getService(IReferenceService.class).getUuidAndTitleCache(limitOfInitialElements,pattern, currentReference.getType());
}else{
- if (isInReference && currentReference != null){
- model = CdmStore.getService(IReferenceService.class).getUuidAndTitleCache(limitOfInitialElements,pattern, currentReference.getType());
- }else{
- model = CdmStore.getService(IReferenceService.class).getUuidAndTitleCache(limitOfInitialElements,pattern);
- }
+ model = CdmStore.getService(IReferenceService.class).getUuidAndTitleCache(limitOfInitialElements,pattern);
}
+
}
/** {@inheritDoc} */
@Override
- protected String getNewWizardLinkText() {
- return String.format("Create a new <a>%1s</a>", "Reference ");
+ protected String[] getNewWizardText() {
+ return new String[]{"New Reference"};
}
}
import java.util.UUID;
-import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Text;
-import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
import eu.etaxonomy.cdm.api.service.IRightsService;
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
import eu.etaxonomy.cdm.model.media.Rights;
public class RightsSelectionDialog extends AbstractFilteredCdmResourceSelectionDialog<Rights> {
- public static Rights select(Shell shell, ConversationHolder conversation, Rights rights){
- RightsSelectionDialog dialog = new RightsSelectionDialog(shell, conversation,
+ public static Rights select(Shell shell, //ConversationHolder conversation,
+ Rights rights){
+ RightsSelectionDialog dialog = new RightsSelectionDialog(shell, //conversation,
"Choose Rights", false, RightsSelectionDialog.class.getCanonicalName(), rights);
return getSelectionFromDialog(dialog);
}
/**
* <p>Constructor for FilteredDerivedUnitSelectionDialog.</p>
*/
- protected RightsSelectionDialog(Shell shell, ConversationHolder conversation, String title,
+ protected RightsSelectionDialog(Shell shell, //ConversationHolder conversation,
+ String title,
boolean multi, String settings, Rights rights) {
- super(shell, conversation, title, multi, settings, rights);
+ super(shell, //conversation,
+ title, multi, settings, rights);
}
/**
* {@inheritDoc}
*/
@Override
- protected String getNewWizardLinkText() {
- // TODO Auto-generated method stub
+ protected String[] getNewWizardText() {
return null;
}
* {@inheritDoc}
*/
@Override
- protected void initModel() {
- Control control = getPatternControl();
- String pattern = null;
- if (control != null){
- pattern = ((Text)control).getText();
- }
-
- if (pattern == null || pattern.equals("?")){
- model = CdmStore.getService(IRightsService.class).getUuidAndLabelText(null,null);
-
- }else{
-
- model = CdmStore.getService(IRightsService.class).getUuidAndLabelText(limitOfInitialElements,pattern);
-
- }
-
+ protected void callService(String pattern) {
+ model = CdmStore.getService(IRightsService.class).getUuidAndLabelText(limitOfInitialElements,pattern);
}
}
--- /dev/null
+// $Id$
+/**
+* Copyright (C) 2017 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.ui.dialog.selection;
+
+
+
+import java.text.Collator;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.List;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.ListenerList;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.jface.action.LegacyActionTools;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider.IStyledLabelProvider;
+import org.eclipse.jface.viewers.DoubleClickEvent;
+import org.eclipse.jface.viewers.IColorProvider;
+import org.eclipse.jface.viewers.IDoubleClickListener;
+import org.eclipse.jface.viewers.IFontProvider;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.ILabelProviderListener;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.LabelProviderChangedEvent;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.StyledCellLabelProvider;
+import org.eclipse.jface.viewers.StyledString;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerCell;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.accessibility.AccessibleAdapter;
+import org.eclipse.swt.accessibility.AccessibleEvent;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.TraverseEvent;
+import org.eclipse.swt.events.TraverseListener;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.graphics.GC;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.IWorkbenchPreferenceConstants;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.dialogs.FilteredItemsSelectionDialog;
+import org.eclipse.ui.internal.IWorkbenchGraphicConstants;
+import org.eclipse.ui.internal.WorkbenchImages;
+import org.eclipse.ui.internal.WorkbenchMessages;
+import org.eclipse.ui.internal.WorkbenchPlugin;
+
+import eu.etaxonomy.cdm.model.common.ICdmBase;
+import eu.etaxonomy.cdm.persistence.dto.UuidAndTitleCache;
+import eu.etaxonomy.taxeditor.l10n.Messages;
+import eu.etaxonomy.taxeditor.ui.dialog.selection.CdmFilteredItemsSelectionDialog.ItemsListSeparator;
+
+/**
+ * @author k.luther
+ * @date 15.11.2017
+ *
+ */
+public abstract class SearchDialog<T extends ICdmBase> extends Dialog{// implements IConversationEnabled{
+
+ private TableViewer list;
+ private Text searchField;
+ private String title;
+ protected Button newButton1;
+
+
+ protected Button newButton2;
+ protected Button filterButton;
+ private StructuredSelection currentSelection;
+
+ // message to show user
+ private String message = ""; //$NON-NLS-1$
+
+ protected final ContentProvider contentProvider;
+ ItemsListLabelProvider itemsListLabelProvider;
+
+ private final RefreshCacheJob refreshCacheJob;
+
+ protected Object preferenceID;
+
+ protected final int new_id = 4;
+ protected final int new_id2 = 5;
+ // Need to keep our own list of listeners
+ private final ListenerList listeners = new ListenerList();
+
+
+ private static final String EMPTY_STRING = ""; //$NON-NLS-1$
+ private GridData gd_1;
+
+ public SearchDialog(Shell parent, boolean multi) {
+ super(parent);
+ contentProvider = new ContentProvider();
+ refreshCacheJob = new RefreshCacheJob();
+
+
+ }
+
+
+ @Override
+ protected Control createDialogArea(Composite parent) {
+ Composite container = (Composite) super.createDialogArea(parent);
+
+ GridData gd = new GridData(GridData.FILL_BOTH);
+ container.setLayoutData(gd);
+
+ GridLayout layout = new GridLayout();
+ layout.numColumns = 1;
+ layout.marginWidth = 0;
+ layout.marginHeight = 0;
+ container.setLayout(layout);
+
+ final Label headerLabel = createHeader(container);
+
+ Composite searchAndFilter = new Composite(container, container.getStyle());
+ GridData gd_searchAndFilter =new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL);
+
+ searchAndFilter.setLayoutData(gd_searchAndFilter);
+ GridLayout searchAndFilterLayout = new GridLayout();
+ searchAndFilterLayout.numColumns = 2;
+ searchAndFilter.setLayout(searchAndFilterLayout);
+ searchField = new Text(searchAndFilter, SWT.SINGLE | SWT.BORDER | SWT.SEARCH | SWT.ICON_CANCEL);
+ searchField.getAccessible().addAccessibleListener(new AccessibleAdapter() {
+ @Override
+ public void getName(AccessibleEvent e) {
+ e.result = LegacyActionTools.removeMnemonics(headerLabel
+ .getText());
+ }
+ });
+ searchField.addModifyListener(new ModifyListener() {
+ @Override
+ public void modifyText(ModifyEvent e) {
+ search();
+// fillContentProvider(null);
+
+ }
+ });
+ gd_1 = new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL);
+
+ searchField.setLayoutData(gd_1);
+
+ createFilterButton(searchAndFilter);
+ new Label(searchAndFilter, SWT.NONE);
+ setList(new TableViewer(container, SWT.SINGLE
+ | SWT.BORDER | SWT.V_SCROLL | SWT.VIRTUAL));
+
+ getList().setContentProvider(contentProvider);
+ getList().setLabelProvider(getItemsListLabelProvider());
+ getList().setInput(new Object[0]);
+ getList().setItemCount(contentProvider.getNumberOfElements());
+ getList().addSelectionChangedListener(new ISelectionChangedListener() {
+ @Override
+ public void selectionChanged(SelectionChangedEvent event) {
+ StructuredSelection selection = (StructuredSelection) event
+ .getSelection();
+ currentSelection = selection;
+ }
+ });
+ getList().addDoubleClickListener(new IDoubleClickListener() {
+ @Override
+ public void doubleClick(DoubleClickEvent event) {
+ okPressed();
+ }
+ });
+// createExtendedContentArea(container);
+ new Label(container, SWT.NONE);
+
+ return container;
+ }
+
+
+ abstract void createFilterButton(Composite searchAndFilter) ;
+
+ protected abstract void search();
+
+
+ /**
+ * Sets the title for this dialog.
+ *
+ * @param title
+ * the title
+ */
+ public void setTitle(String title) {
+ this.title = title;
+ }
+
+ /**
+ * Create a new header which is labelled by headerLabel.
+ *
+ * @param parent
+ * @return Label the label of the header
+ */
+ private Label createHeader(Composite parent) {
+ Composite header = new Composite(parent, SWT.NONE);
+ GridData gd_header = new GridData(SWT.CENTER, SWT.CENTER, false, false, 2, 1);
+ gd_header.horizontalIndent = 5;
+ gd_header.widthHint = 575;
+ header.setLayoutData(gd_header);
+
+ GridLayout layout = new GridLayout();
+ layout.marginLeft = 5;
+ layout.horizontalSpacing = 0;
+ layout.verticalSpacing = 1;
+ layout.marginWidth = 0;
+ layout.marginHeight = 0;
+ header.setLayout(layout);
+ new Label(header, SWT.NONE);
+ Label headerLabel = new Label(header, SWT.NONE);
+ headerLabel.setText((getMessage() != null && getMessage().trim()
+ .length() > 0) ? getMessage()
+ : Messages.SearchDialog_patternLabel);
+ headerLabel.addTraverseListener(new TraverseListener() {
+ @Override
+ public void keyTraversed(TraverseEvent e) {
+ if (e.detail == SWT.TRAVERSE_MNEMONIC && e.doit) {
+ e.detail = SWT.TRAVERSE_NONE;
+ searchField.setFocus();
+ }
+ }
+ });
+ GridData gd_headerLabel = new GridData(GridData.FILL_HORIZONTAL);
+ gd_headerLabel.horizontalAlignment = SWT.LEFT;
+ gd_headerLabel.grabExcessHorizontalSpace = false;
+ gd_headerLabel.verticalAlignment = SWT.BOTTOM;
+ gd_headerLabel.minimumHeight = 10;
+ headerLabel.setLayoutData(gd_headerLabel);
+ return headerLabel;
+ }
+
+ protected String getMessage() {
+ return message;
+ }
+
+ protected void setMessage(String message){
+ this.message = message;
+ }
+
+ public Text getSearchField() {
+ return searchField;
+ }
+
+
+ public void setSearchField(Text searchField) {
+ this.searchField = searchField;
+ }
+
+ private ItemsListLabelProvider getItemsListLabelProvider() {
+ if (itemsListLabelProvider == null) {
+ itemsListLabelProvider = new ItemsListLabelProvider(
+ new LabelProvider());
+ }
+ return itemsListLabelProvider;
+ }
+
+
+ public TableViewer getList() {
+ return list;
+ }
+
+ public void setList(TableViewer list) {
+ this.list = list;
+ Table table = list.getTable();
+ GridData gd_table = new GridData(SWT.CENTER, SWT.CENTER, true, true, 2, 1);
+ gd_table.heightHint = 231;
+ gd_table.widthHint = 543;
+ table.setLayoutData(gd_table);
+ }
+
+ public Button getNewButton1() {
+ return newButton1;
+ }
+
+
+ public void setNewButton1(Button newButton1) {
+ this.newButton1 = newButton1;
+ }
+
+
+ public Button getNewButton2() {
+ return newButton2;
+ }
+
+
+ public void setNewButton2(Button newButton2) {
+ this.newButton2 = newButton2;
+ }
+
+
+ public Button getFilterButton() {
+ return filterButton;
+ }
+
+
+ public void setFilterButton(Button filterButton) {
+ this.filterButton = filterButton;
+ }
+
+ /**
+ * Sets a new label provider for items in the list. If the label provider
+ * also implements {@link
+ * org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider
+ * .IStyledLabelProvider}, the style text labels provided by it will be used
+ * provided that the corresponding preference is set.
+ *
+ * @see IWorkbenchPreferenceConstants#USE_COLORED_LABELS
+ *
+ * @param listLabelProvider
+ * the label provider for items in the list
+ */
+ public void setListLabelProvider(ILabelProvider listLabelProvider) {
+ getItemsListLabelProvider().setProvider(listLabelProvider);
+ }
+ protected Comparator getItemsComparator() {
+ return new Comparator<UuidAndTitleCache>() {
+ @Override
+ public int compare(UuidAndTitleCache entity1,
+ UuidAndTitleCache entity2) {
+ Collator collator = Collator.getInstance();
+ if (entity1.getUuid().equals(entity2.getUuid())){
+ return 0;
+ }
+ int result = collator.compare(entity1.getTitleCache(), entity2.getTitleCache());
+ if (result == 0){
+ result = entity1.getUuid().compareTo(entity2.getUuid());
+ }
+ return result;
+ }
+ };
+ }
+
+
+ class ContentProvider implements
+ IStructuredContentProvider {
+
+ private List items;
+
+ /**
+ * Creates new instance of <code>ContentProvider</code>.
+ */
+ public ContentProvider() {
+ this.items = Collections.synchronizedList(new ArrayList(2048));
+ }
+
+ /**
+ * Removes all content items and resets progress message.
+ */
+ public void reset() {
+ this.items.clear();
+
+ }
+
+ public void add(Object item) {
+ this.items.add(item);
+ }
+
+ /**
+ * Refresh dialog.
+ */
+ public void refresh() {
+ scheduleRefresh();
+ }
+
+ /**
+ * Schedule refresh job.
+ */
+ public void scheduleRefresh() {
+ refreshCacheJob.cancelAll();
+ refreshCacheJob.schedule();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object)
+ */
+ @Override
+ public Object[] getElements(Object inputElement) {
+ return items.toArray();
+ }
+
+ public int getNumberOfElements() {
+ return items.size();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.viewers.IContentProvider#dispose()
+ */
+ @Override
+ public void dispose() {
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer,
+ * java.lang.Object, java.lang.Object)
+ */
+ @Override
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ }
+
+
+ }
+
+
+
+ public StructuredSelection getCurrentSelection() {
+ return currentSelection;
+ }
+
+ /**
+ * Fills the content provider with matching items.
+ *
+ * @param progressMonitor
+ * must be used to report search progress. The state of this
+ * progress monitor reflects the state of the filtering process.
+ * @throws CoreException
+ */
+ protected abstract void fillContentProvider(IProgressMonitor progressMonitor) ;
+
+
+ /**
+ * Refreshes the dialog - has to be called in UI thread.
+ */
+ public void refresh() {
+ if (getList() != null && !getList().getTable().isDisposed()) {
+
+ List lastRefreshSelection = ((StructuredSelection) getList()
+ .getSelection()).toList();
+ getList().getTable().deselectAll();
+
+ getList().setItemCount(contentProvider.getNumberOfElements());
+ getList().refresh();
+
+ if (getList().getTable().getItemCount() > 0) {
+ // preserve previous selection
+ if ( lastRefreshSelection != null
+ && lastRefreshSelection.size() > 0) {
+ getList().setSelection(new StructuredSelection(
+ lastRefreshSelection));
+ } else {
+
+ getList().getTable().setSelection(0);
+ getList().getTable().notifyListeners(SWT.Selection, new Event());
+ }
+ } else {
+ getList().setSelection(StructuredSelection.EMPTY);
+ }
+
+ }
+ }
+
+ /**
+ * A job responsible for computing filtered items list presented using
+ * <code>RefreshJob</code>.
+ *
+ * @see FilteredItemsSelectionDialog.RefreshJob
+ *
+ */
+ private class RefreshCacheJob extends Job {
+
+ public RefreshCacheJob() {
+ super(
+ WorkbenchMessages.FilteredItemsSelectionDialog_cacheRefreshJob);
+ setSystem(true);
+ }
+
+ /**
+ * Stops the job and all sub-jobs.
+ */
+ public void cancelAll() {
+ cancel();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.core.runtime.jobs.Job#run(org.eclipse.core.runtime.IProgressMonitor)
+ */
+ @Override
+ protected IStatus run(IProgressMonitor monitor) {
+ if (monitor.isCanceled()) {
+ return new Status(IStatus.CANCEL, WorkbenchPlugin.PI_WORKBENCH,
+ IStatus.CANCEL, EMPTY_STRING, null);
+ }
+
+ if (SearchDialog.this != null) {
+ SearchDialog.this.fillContentProvider(monitor);
+ }
+
+ return new Status(IStatus.OK, PlatformUI.PLUGIN_ID, IStatus.OK,
+ EMPTY_STRING, null);
+
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.core.runtime.jobs.Job#canceling()
+ */
+ @Override
+ protected void canceling() {
+ super.canceling();
+ }
+
+ }
+
+ private class ItemsListLabelProvider extends StyledCellLabelProvider
+ implements ILabelProviderListener {
+ private ILabelProvider provider;
+
+ /**
+ * Creates a new instance of the class.
+ *
+ * @param provider
+ * the label provider for all items, not <code>null</code>
+ * @param selectionDecorator
+ * the decorator for selected items, can be <code>null</code>
+ */
+ public ItemsListLabelProvider(ILabelProvider provider) {
+ Assert.isNotNull(provider);
+ this.provider = provider;
+ this.provider.addListener(this);
+ }
+
+ /**
+ * Sets new label provider.
+ *
+ * @param newProvider
+ * new label provider for items in the list, not
+ * <code>null</code>
+ */
+ public void setProvider(ILabelProvider newProvider) {
+ Assert.isNotNull(newProvider);
+ provider.removeListener(this);
+ provider.dispose();
+ provider = newProvider;
+
+ if (provider != null) {
+ provider.addListener(this);
+ }
+ }
+
+
+
+ private boolean isSelected(Object element) {
+ if (element != null && getCurrentSelection() != null) {
+ if (element.equals(getCurrentSelection())) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.viewers.ILabelProvider#getText(java.lang.Object)
+ */
+ private String getText(Object element) {
+ if (element instanceof ItemsListSeparator) {
+ return getSeparatorLabel(((ItemsListSeparator) element)
+ .getName());
+ }
+ String str = provider.getText(element);
+ return str;
+ }
+
+ private StyledString getStyledText(Object element,
+ IStyledLabelProvider provider) {
+ StyledString string = provider.getStyledText(element);
+
+ return string;
+ }
+
+ @Override
+ public void update(ViewerCell cell) {
+ Object element = cell.getElement();
+
+ if (!(element instanceof ItemsListSeparator)
+ && provider instanceof IStyledLabelProvider) {
+ IStyledLabelProvider styledLabelProvider = (IStyledLabelProvider) provider;
+ StyledString styledString = getStyledText(element,
+ styledLabelProvider);
+
+ cell.setText(styledString.getString());
+ cell.setStyleRanges(styledString.getStyleRanges());
+ cell.setImage(styledLabelProvider.getImage(element));
+ } else {
+ cell.setText(getText(element));
+
+ }
+ cell.setFont(getFont(element));
+ cell.setForeground(getForeground(element));
+ cell.setBackground(getBackground(element));
+
+ super.update(cell);
+ }
+
+ private String getSeparatorLabel(String separatorLabel) {
+ Rectangle rect = getList().getTable().getBounds();
+
+ int borderWidth = getList().getTable().computeTrim(0, 0, 0, 0).width;
+
+ int imageWidth = WorkbenchImages.getImage(
+ IWorkbenchGraphicConstants.IMG_OBJ_SEPARATOR).getBounds().width;
+
+ int width = rect.width - borderWidth - imageWidth;
+
+ GC gc = new GC(getList().getTable());
+ gc.setFont(getList().getTable().getFont());
+
+ int fSeparatorWidth = gc.getAdvanceWidth('-');
+ int fMessageLength = gc.textExtent(separatorLabel).x;
+
+ gc.dispose();
+
+ StringBuffer dashes = new StringBuffer();
+ int chars = (((width - fMessageLength) / fSeparatorWidth) / 2) - 2;
+ for (int i = 0; i < chars; i++) {
+ dashes.append('-');
+ }
+
+ StringBuffer result = new StringBuffer();
+ result.append(dashes);
+ result.append(" " + separatorLabel + " "); //$NON-NLS-1$//$NON-NLS-2$
+ result.append(dashes);
+ return result.toString().trim();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.viewers.IBaseLabelProvider#addListener(org.eclipse.jface.viewers.ILabelProviderListener)
+ */
+ @Override
+ public void addListener(ILabelProviderListener listener) {
+ listeners.add(listener);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.viewers.IBaseLabelProvider#dispose()
+ */
+ @Override
+ public void dispose() {
+ provider.removeListener(this);
+ provider.dispose();
+ super.dispose();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.viewers.IBaseLabelProvider#isLabelProperty(java.lang.Object,
+ * java.lang.String)
+ */
+ @Override
+ public boolean isLabelProperty(Object element, String property) {
+ if (provider.isLabelProperty(element, property)) {
+ return true;
+ }
+ return false;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.viewers.IBaseLabelProvider#removeListener(org.eclipse.jface.viewers.ILabelProviderListener)
+ */
+ @Override
+ public void removeListener(ILabelProviderListener listener) {
+ listeners.remove(listener);
+ }
+
+ private Color getBackground(Object element) {
+ if (element instanceof ItemsListSeparator) {
+ return null;
+ }
+ if (provider instanceof IColorProvider) {
+ return ((IColorProvider) provider).getBackground(element);
+ }
+ return null;
+ }
+
+ private Color getForeground(Object element) {
+ if (element instanceof ItemsListSeparator) {
+ return Display.getCurrent().getSystemColor(
+ SWT.COLOR_WIDGET_NORMAL_SHADOW);
+ }
+ if (provider instanceof IColorProvider) {
+ return ((IColorProvider) provider).getForeground(element);
+ }
+ return null;
+ }
+
+ private Font getFont(Object element) {
+ if (element instanceof ItemsListSeparator) {
+ return null;
+ }
+ if (provider instanceof IFontProvider) {
+ return ((IFontProvider) provider).getFont(element);
+ }
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.viewers.ILabelProviderListener#labelProviderChanged(org.eclipse.jface.viewers.LabelProviderChangedEvent)
+ */
+ @Override
+ public void labelProviderChanged(LabelProviderChangedEvent event) {
+ Object[] l = listeners.getListeners();
+ for (int i = 0; i < listeners.size(); i++) {
+ ((ILabelProviderListener) l[i]).labelProviderChanged(event);
+ }
+ }
+}
+
+ @Override
+ protected Point getInitialSize() {
+ return new Point(593, 399);
+ }
+
+
+
+}
+
+
import org.eclipse.swt.widgets.Shell;
-import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
import eu.etaxonomy.cdm.api.facade.DerivedUnitFacade;
import eu.etaxonomy.cdm.model.agent.AgentBase;
import eu.etaxonomy.cdm.model.agent.Institution;
*/
public class SelectionDialogFactory {
- public static <T extends ICdmBase> T getSelectionFromDialog(Class<T> clazz, Shell shell, ConversationHolder conversation, T currentSelection){
- return getSelectionFromDialog(clazz, shell, conversation, currentSelection, null);
+ public static <T extends ICdmBase> T getSelectionFromDialog(Class<T> clazz, Shell shell, //ConversationHolder conversation,
+ T currentSelection){
+ return getSelectionFromDialog(clazz, shell, //conversation,
+ currentSelection, null);
}
- public static <T extends ICdmBase> T getSelectionFromDialog(Class<T> clazz, Shell shell, ConversationHolder conversation, T currentSelection, ICdmFormElement parentElement){
+ public static <T extends ICdmBase> T getSelectionFromDialog(Class<T> clazz, Shell shell, //ConversationHolder conversation,
+ T currentSelection, ICdmFormElement parentElement){
if(clazz.equals(Taxon.class)){
- return (T) TaxonBaseSelectionDialog.selectTaxon(shell, conversation, (Taxon) currentSelection);
+ return (T) TaxonBaseSelectionDialog.selectTaxon(shell, //conversation,
+ (Taxon) currentSelection);
}
if(clazz.equals(Synonym.class)){
- return (T) TaxonBaseSelectionDialog.selectSynonym(shell, conversation);
+ return (T) TaxonBaseSelectionDialog.selectSynonym(shell );//,conversation);
}
if(clazz.equals(TaxonBase.class)){
- return (T) TaxonBaseSelectionDialog.selectTaxonBase(shell, conversation);
+ return (T) TaxonBaseSelectionDialog.selectTaxonBase(shell);//, conversation);
}
if(clazz.equals(Classification.class)){
- return (T) ClassificationSelectionDialog.select(shell, conversation, (Classification) currentSelection);
+ return (T) ClassificationSelectionDialog.select(shell, //conversation,
+ (Classification) currentSelection);
}
if(clazz.equals(TaxonNode.class)){
- return (T) TaxonNodeSelectionDialog.select(shell, conversation, null, null, (TaxonNode) currentSelection, ((TaxonNode) currentSelection).getClassification());
+ return (T) TaxonNodeSelectionDialog.select(shell, //conversation,
+ null, null, (TaxonNode) currentSelection, ((TaxonNode) currentSelection).getClassification());
}
if(clazz.equals(Reference.class) && parentElement instanceof NomenclaturalReferenceDetailElement){
- return (T) NomenclaturalReferenceSelectionDialog.select(shell, conversation, (Reference) currentSelection, ((NomenclaturalReferenceDetailElement)parentElement).getEntity().getCombinationAuthorship());
+ return (T) NomenclaturalReferenceSelectionDialog.select(shell, //conversation,
+ (Reference) currentSelection, ((NomenclaturalReferenceDetailElement)parentElement).getEntity().getCombinationAuthorship());
}
if(clazz.equals(Reference.class)){
if (parentElement instanceof ReferenceDetailElement){
- return (T) ReferenceSelectionDialog.select(shell, conversation, ((ReferenceDetailElement) parentElement).getEntity(), true);
+ return (T) ReferenceSelectionDialog.select(shell, //conversation,
+ ((ReferenceDetailElement) parentElement).getEntity(), true);
}
- return (T) ReferenceSelectionDialog.select(shell, conversation, (Reference) currentSelection);
+ return (T) ReferenceSelectionDialog.select(shell, //conversation,
+ (Reference) currentSelection);
}
if(clazz.equals(TaxonName.class)){
- return (T) NameSelectionDialog.select(shell, conversation, (TaxonName) currentSelection);
+ return (T) NameSelectionDialog.select(shell, //conversation,
+ (TaxonName) currentSelection);
}
if(clazz.equals(Team.class)){
- return (T) TeamSelectionDialog.select(shell, conversation, (Team) currentSelection);
+ return (T) TeamSelectionDialog.select(shell, //conversation,
+ (Team) currentSelection);
}
if(clazz.equals(TeamOrPersonBase.class) && parentElement instanceof AuthorshipDetailElement){
- return (T) NomenclaturalAuthorSelectionDialog.select(shell, conversation, (AgentBase) currentSelection, false);
+ return (T) NomenclaturalAuthorSelectionDialog.select(shell, //conversation,
+ (AgentBase) currentSelection, false);
}else if(clazz.equals(TeamOrPersonBase.class)){
//TODO: add TeamOrPersonBaseSelectionDialog (see ticket #4545)
- return (T) AgentSelectionDialog.select(shell, conversation, (AgentBase) currentSelection, false);
+ return (T) AgentSelectionDialog.select(shell, //conversation,
+ (AgentBase) currentSelection, false);
}
if(clazz.equals(Person.class) && parentElement instanceof TeamMemberElement){
- return (T) NomenclaturalPersonAuthorSelectionDialog.select(shell, conversation, (AgentBase) currentSelection, true);
+ return (T) NomenclaturalPersonAuthorSelectionDialog.select(shell, //conversation,
+ (AgentBase) currentSelection, true);
}
if(clazz.equals(AgentBase.class)){
- return (T) AgentSelectionDialog.select(shell, conversation, (AgentBase) currentSelection, false);
+ return (T) AgentSelectionDialog.select(shell, //conversation,
+ (AgentBase) currentSelection, false);
}
if(clazz.equals(Feature.class)){
- return (T) FeatureSelectionDialog.select(shell, conversation, (Feature) currentSelection);
+ return (T) FeatureSelectionDialog.select(shell, //conversation,
+ (Feature) currentSelection);
}
if(clazz.equals(FeatureTree.class)){
- return (T) FeatureTreeSelectionDialog.select(shell, conversation, (FeatureTree) currentSelection);
+ return (T) FeatureTreeSelectionDialog.select(shell, //conversation,
+ (FeatureTree) currentSelection);
}
if(clazz.equals(PolytomousKey.class)){
- return (T) PolytomousKeySelectionDialog.select(shell, conversation, (PolytomousKey) currentSelection);
+ return (T) PolytomousKeySelectionDialog.select(shell, //conversation,
+ (PolytomousKey) currentSelection);
}
if(clazz.equals(PolytomousKeyNode.class)){
MessagingUtils.warningDialog("Not implemented yet", SelectionDialogFactory.class,
return null;
}
if(clazz.equals(DerivedUnit.class)){
- return (T) DerivedUnitSelectionDialog.select(shell, conversation, (DerivedUnit) currentSelection);
+ return (T) DerivedUnitSelectionDialog.select(shell, //conversation,
+ (DerivedUnit) currentSelection);
}
if(clazz.equals(FieldUnit.class)){
- return (T) FieldUnitSelectionDialog.select(shell, conversation, (FieldUnit) currentSelection);
+ return (T) FieldUnitSelectionDialog.select(shell, //conversation,
+ (FieldUnit) currentSelection);
}
if(clazz.equals(SpecimenOrObservationBase.class)){
- return (T) SpecimenOrObservationBaseSelectionDialog.select(shell, conversation, (SpecimenOrObservationBase) currentSelection);
+ return (T) SpecimenOrObservationBaseSelectionDialog.select(shell, //conversation,
+ (SpecimenOrObservationBase) currentSelection);
}
if(clazz.equals(NamedArea.class)){
if(parentElement instanceof IEntityElement && ((IEntityElement) parentElement).getEntity() instanceof DerivedUnitFacade){
- return (T) NamedAreaSelectionDialog.select(shell, conversation, (NamedArea) currentSelection, DerivedUnit.class.getCanonicalName(), Country.uuidCountryVocabulary);
+ return (T) NamedAreaSelectionDialog.select(shell, //conversation,
+ (NamedArea) currentSelection, DerivedUnit.class.getCanonicalName(), Country.uuidCountryVocabulary);
}
else{
- return (T) NamedAreaSelectionDialog.select(shell, conversation, (NamedArea) currentSelection, parentElement.getClass().getCanonicalName());
+ return (T) NamedAreaSelectionDialog.select(shell, //conversation,
+ (NamedArea) currentSelection, parentElement.getClass().getCanonicalName());
}
}
if(clazz.equals(Collection.class)){
- return (T) CollectionSelectionDialog.select(shell, conversation, (Collection) currentSelection);
+ return (T) CollectionSelectionDialog.select(shell, //conversation,
+ (Collection) currentSelection);
}
if(clazz.equals(User.class)){
- return (T) UserSelectionDialog.select(shell, conversation, (User) currentSelection);
+ return (T) UserSelectionDialog.select(shell, //conversation,
+ (User) currentSelection);
}
if(clazz.equals(GrantedAuthorityImpl.class)){
- return (T) GrantedAuthoritySelectionDialog.select(shell, conversation, (GrantedAuthorityImpl) currentSelection);
+ return (T) GrantedAuthoritySelectionDialog.select(shell, //conversation,
+ (GrantedAuthorityImpl) currentSelection);
}
if (clazz.equals(Person.class)){
- return (T) PersonSelectionDialog.select(shell, conversation, (Person) currentSelection);
+ return (T) PersonSelectionDialog.select(shell, //conversation,
+ (Person) currentSelection);
}
if(clazz.equals(Group.class)){
- return (T) GroupSelectionDialog.select(shell, conversation, (Group) currentSelection);
+ return (T) GroupSelectionDialog.select(shell, //conversation,
+ (Group) currentSelection);
}
if(clazz.equals(Institution.class)){
- return (T) InstitutionSelectionDialog.select(shell, conversation, (Institution) currentSelection);
+ return (T) InstitutionSelectionDialog.select(shell, //conversation,
+ (Institution) currentSelection);
}
if(clazz.equals(Primer.class)){
- return (T) PrimerSelectionDialog.select(shell, conversation, (Primer) currentSelection);
+ return (T) PrimerSelectionDialog.select(shell, //conversation,
+ (Primer) currentSelection);
}
if(clazz.equals(Amplification.class)){
- return (T) AmplificationSelectionDialog.select(shell, conversation, (Amplification) currentSelection);
+ return (T) AmplificationSelectionDialog.select(shell, //conversation,
+ (Amplification) currentSelection);
}
if(clazz.equals(Media.class)){
- return (T) MediaSelectionDialog.select(shell, conversation, (Media) currentSelection);
+ return (T) MediaSelectionDialog.select(shell, //conversation,
+ (Media) currentSelection);
}
if(clazz.equals(Rights.class)){
- return (T) RightsSelectionDialog.select(shell, conversation, (Rights) currentSelection);
+ return (T) RightsSelectionDialog.select(shell, //conversation,
+ (Rights) currentSelection);
}
return null;
}
+ public static <T extends ICdmBase> T getSelectionFromExtDialog(Class<T> clazz, Shell shell, //ConversationHolder conversation,
+ ICdmFormElement parentElement){
+ return (T) ExtReferenceSelectionDialog.select(shell, //conversation,
+ null);
+ }
+
+
}
import org.eclipse.swt.widgets.Shell;
-import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
import eu.etaxonomy.cdm.api.service.IOccurrenceService;
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase;
public class SpecimenOrObservationBaseSelectionDialog extends
AbstractFilteredCdmResourceSelectionDialog<SpecimenOrObservationBase> {
- public static SpecimenOrObservationBase select(Shell shell, ConversationHolder conversation, SpecimenOrObservationBase observation){
- SpecimenOrObservationBaseSelectionDialog dialog = new SpecimenOrObservationBaseSelectionDialog(shell, conversation,
+ public static SpecimenOrObservationBase select(Shell shell, //ConversationHolder conversation,
+ SpecimenOrObservationBase observation){
+ SpecimenOrObservationBaseSelectionDialog dialog = new SpecimenOrObservationBaseSelectionDialog(shell, //conversation,
"Choose field unit or derived unit", false, SpecimenOrObservationBaseSelectionDialog.class.getCanonicalName(), observation);
return getSelectionFromDialog(dialog);
}
- protected SpecimenOrObservationBaseSelectionDialog(Shell shell, ConversationHolder conversation,
+ protected SpecimenOrObservationBaseSelectionDialog(Shell shell, //ConversationHolder conversation,
String title, boolean multi, String settings,
SpecimenOrObservationBase cdmObject) {
- super(shell, conversation, title, multi, settings, cdmObject);
+ super(shell, //conversation,
+ title, multi, settings, cdmObject);
}
/** {@inheritDoc} */
/** {@inheritDoc} */
@Override
- protected void initModel() {
- model = CdmStore.getService(IOccurrenceService.class).getUuidAndTitleCache(null, null);
- }
+ protected void callService(String pattern) {
+ model =CdmStore.getService(IOccurrenceService.class).getUuidAndTitleCache(limitOfInitialElements,pattern);
+ }
/** {@inheritDoc} */
@Override
/** {@inheritDoc} */
@Override
- protected String getNewWizardLinkText() {
- return String.format("Create a new <a>%1s</a>", "field unit/derived unit");
+ protected String[] getNewWizardText() {
+ return new String[]{"New Field Unit/Derived Unit"};
}
}
* @return a {@link eu.etaxonomy.cdm.model.common.OriginalSourceType} object.
*/
public static SpecimenOrObservationType select(Shell shell, ConversationHolder conversation){
- SpecimenOrObservationTypeSelectionDialog dialog =
- new SpecimenOrObservationTypeSelectionDialog(shell,
+ SpecimenOrObservationTypeSelectionDialog dialog =
+ new SpecimenOrObservationTypeSelectionDialog(shell,
conversation,
- "Choose Specimen / Observation Type",
- false,
+ "Choose Specimen / Observation Type",
+ false,
SpecimenOrObservationTypeSelectionDialog.class.getCanonicalName());
return getSelectionFromDialog(dialog);
}
-
+
/**
* <p>Constructor for FilteredDerivedUnitSelectionDialog.</p>
*
* @param multi a boolean.
* @param settings a {@link java.lang.String} object.
*/
- protected SpecimenOrObservationTypeSelectionDialog(Shell shell,
- ConversationHolder conversation,
+ protected SpecimenOrObservationTypeSelectionDialog(Shell shell,
+ ConversationHolder conversation,
String title,
- boolean multi,
+ boolean multi,
String settings) {
super(shell, conversation, title, multi, settings, SpecimenOrObservationType.Unknown);
}
@Override
protected void initModel() {
model = new ArrayList<SpecimenOrObservationType>();
- model.addAll(EnumSet.allOf(SpecimenOrObservationType.class));
+ model.addAll(EnumSet.allOf(SpecimenOrObservationType.class));
}
/** {@inheritDoc} */
import java.util.List;
import java.util.UUID;
-import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Text;
-import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
import eu.etaxonomy.cdm.api.service.ITaxonService;
import eu.etaxonomy.cdm.model.taxon.Synonym;
import eu.etaxonomy.cdm.model.taxon.Taxon;
public class TaxonBaseSelectionDialog extends AbstractFilteredCdmResourceSelectionDialog<TaxonBase> {
- public static TaxonBase selectTaxonBase(Shell shell, ConversationHolder conversation) {
- AbstractFilteredCdmResourceSelectionDialog<TaxonBase> dialog = new TaxonBaseSelectionDialog(TaxonBase.class, shell, conversation,
+ public static TaxonBase selectTaxonBase(Shell shell){//, ConversationHolder conversation) {
+ AbstractFilteredCdmResourceSelectionDialog<TaxonBase> dialog = new TaxonBaseSelectionDialog(TaxonBase.class, shell, //conversation,
"Choose a taxon/synonym", false, null, null);
return getSelectionFromDialog(dialog);
}
- public static Taxon selectTaxon(Shell shell, ConversationHolder conversation, Taxon taxonToBeFiltered) {
+ public static Taxon selectTaxon(Shell shell, //ConversationHolder conversation,
+ Taxon taxonToBeFiltered) {
- AbstractFilteredCdmResourceSelectionDialog<TaxonBase> dialog = new TaxonBaseSelectionDialog(Taxon.class, shell, conversation,
+ AbstractFilteredCdmResourceSelectionDialog<TaxonBase> dialog = new TaxonBaseSelectionDialog(Taxon.class, shell, //conversation,
"Choose a taxon", false, null, taxonToBeFiltered);
return (Taxon) getSelectionFromDialog(dialog);
}
- public static Synonym selectSynonym(Shell shell, ConversationHolder conversation) {
- AbstractFilteredCdmResourceSelectionDialog<TaxonBase> dialog = new TaxonBaseSelectionDialog(Synonym.class, shell, conversation,
+ public static Synonym selectSynonym(Shell shell){//, ConversationHolder conversation) {
+ AbstractFilteredCdmResourceSelectionDialog<TaxonBase> dialog = new TaxonBaseSelectionDialog(Synonym.class, shell, //conversation,
"Choose a synonym", false, null, null);
return (Synonym) getSelectionFromDialog(dialog);
}
private final Class<? extends TaxonBase> clazz;
- protected TaxonBaseSelectionDialog(Class<? extends TaxonBase> clazz, Shell shell, ConversationHolder conversation, String title, boolean multi, TaxonBase taxon, TaxonBase taxonToBeFiltered) {
- super(shell, conversation, title, multi, TaxonBaseSelectionDialog.class.getCanonicalName(), taxon);
+ protected TaxonBaseSelectionDialog(Class<? extends TaxonBase> clazz, Shell shell, //ConversationHolder conversation,
+ String title, boolean multi, TaxonBase taxon, TaxonBase taxonToBeFiltered) {
+ super(shell, //conversation,
+ title, multi, TaxonBaseSelectionDialog.class.getCanonicalName(), taxon);
this.cdmBaseToBeFiltered = taxonToBeFiltered;
this.clazz = clazz;
- initModel();
+ search();
}
/** {@inheritDoc} */
/** {@inheritDoc} */
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
- protected void initModel() {
- Control control = getPatternControl();
- String pattern = null;
- if (control != null){
- pattern = ((Text)control).getText();
- }
-
- if (pattern == null || pattern.equals("?")){
- model = (List)CdmStore.getService(ITaxonService.class).getUuidAndTitleCache(Taxon.class, null, null);
- }else{
- model = (List)CdmStore.getService(ITaxonService.class).getUuidAndTitleCache(Taxon.class, limitOfInitialElements, pattern);
- }
+ protected void callService(String pattern) {
+ model = (List)CdmStore.getService(ITaxonService.class).getUuidAndTitleCache(Taxon.class, limitOfInitialElements, pattern);
}
/** {@inheritDoc} */
/** {@inheritDoc} */
@Override
- protected String getNewWizardLinkText() {
- return String.format("Create a new <a>%1s</a>", "Taxon ");
+ protected String[] getNewWizardText() {
+ return new String[]{"New Taxon"};
}
}
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Text;
-import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
import eu.etaxonomy.cdm.api.service.IClassificationService;
import eu.etaxonomy.cdm.model.taxon.Classification;
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
*/
public class TaxonNodeSelectionDialog extends AbstractFilteredCdmResourceSelectionDialog<TaxonNode> implements SelectionListener{
- public static TaxonNode select(Shell shell, ConversationHolder conversation, String title, List<UUID> excludeTaxa, TaxonNode node, Classification classification) {
+ public static TaxonNode select(Shell shell, //ConversationHolder conversation,
+ String title, List<UUID> excludeTaxa, TaxonNode node, Classification classification) {
TaxonNodeSelectionDialog dialog = new TaxonNodeSelectionDialog(shell,
- conversation,
+ //conversation,
title,
excludeTaxa,
false,
private Classification selectedClassification;
private final List<UUID> excludeTaxa;
- protected TaxonNodeSelectionDialog(Shell shell, ConversationHolder conversation, String title, List<UUID> excludeTaxa, boolean multi, TaxonNode node, Classification classification) {
- super(shell, conversation, title, multi, TaxonNodeSelectionDialog.class.getCanonicalName(), node);
+ protected TaxonNodeSelectionDialog(Shell shell, //ConversationHolder conversation,
+ String title, List<UUID> excludeTaxa, boolean multi, TaxonNode node, Classification classification) {
+ super(shell, //conversation,
+ title, multi, TaxonNodeSelectionDialog.class.getCanonicalName(), node);
ILabelProvider labelProvider = new FilteredCdmResourceLabelProvider();
setListLabelProvider(labelProvider);
- setDetailsLabelProvider(labelProvider);
+// setDetailsLabelProvider(labelProvider);
this.excludeTaxa = excludeTaxa;
if(classification != null){
selectedClassification = classification;
}
- initModel();
+
+ fillClassifications();
+ createClassificationSelectionCombo(shell);
}
/** {@inheritDoc} */
@Override
- protected Control createExtendedContentArea(Composite parent) {
- return createClassificationSelectionCombo(parent);
+ protected Control createDialogArea(Composite parent) {
+ Composite container = (Composite) super.createDialogArea(parent);
+ return createClassificationSelectionCombo(container);
}
/*
/** {@inheritDoc} */
@Override
- protected void initModel() {
- // default to first tree
- // TODO this will be problematic and can only be seen as workaround
-
- Control control = getPatternControl();
- String pattern = null;
- if (control != null){
- pattern = ((Text)control).getText();
- }
-
+ protected void callService(String pattern) {
+ model = CdmStore.getService(IClassificationService.class).getTaxonNodeUuidAndTitleCacheOfAcceptedTaxaByClassification(selectedClassification.getUuid(), limitOfInitialElements, pattern);
+ }
- if(classifications == null){
+ private void fillClassifications() {
+ if(classifications == null){
classifications = CdmStore.getService(IClassificationService.class).list(null, null, null, null, null);
Collections.sort(classifications, new Comparator<Classification>() {
return result;
}
});
- if (this.cdmBaseToBeFiltered == null){
- selectedClassification = classifications.iterator().next();
- } else {
+ if (selectedClassification == null){
+ if (this.cdmBaseToBeFiltered == null){
+ selectedClassification = classifications.iterator().next();
+ } else {
selectedClassification = this.cdmBaseToBeFiltered.getClassification();
+ }
}
}
- if (pattern == null || pattern.equals("?")){
- model = CdmStore.getService(IClassificationService.class).getTaxonNodeUuidAndTitleCacheOfAcceptedTaxaByClassification(selectedClassification.getUuid(), limitOfInitialElements, pattern);
- }else{
- model = CdmStore.getService(IClassificationService.class).getTaxonNodeUuidAndTitleCacheOfAcceptedTaxaByClassification(selectedClassification.getUuid(), null, null);
- }
- }
+ }
/** {@inheritDoc} */
@Override
/** {@inheritDoc} */
@Override
- protected String getNewWizardLinkText() {
+ protected String[] getNewWizardText() {
return null;
}
selectedClassification = classifications.get(classificationSelectionCombo.getSelectionIndex());
// refresh();
- setPattern(null);
+ if (getSearchField().getText() != null){
+ search();
+ }
}
/** {@inheritDoc} */
\r
import org.eclipse.swt.widgets.Shell;\r
\r
-import eu.etaxonomy.cdm.api.conversation.ConversationHolder;\r
import eu.etaxonomy.cdm.model.taxon.Classification;\r
import eu.etaxonomy.cdm.model.taxon.TaxonNode;\r
\r
public class TaxonNodeSelectionNaturalOrderDialog extends\r
TaxonNodeSelectionDialog {\r
\r
- protected TaxonNodeSelectionNaturalOrderDialog(Shell shell,\r
- ConversationHolder conversation, String title,\r
+ protected TaxonNodeSelectionNaturalOrderDialog(Shell shell,//ConversationHolder conversation,\r
+ String title,\r
List<UUID> excludeTaxa, boolean multi, TaxonNode node,\r
Classification classification) {\r
- super(shell, conversation, title, excludeTaxa, multi, node, classification);\r
+ super(shell, //conversation,\r
+ title, excludeTaxa, multi, node, classification);\r
// TODO Auto-generated constructor stub\r
}\r
- \r
- \r
+\r
+\r
\r
}\r
import org.eclipse.swt.widgets.Shell;
-import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
import eu.etaxonomy.cdm.api.service.IAgentService;
import eu.etaxonomy.cdm.model.agent.Team;
import eu.etaxonomy.cdm.model.common.CdmBase;
* @param team a {@link eu.etaxonomy.cdm.model.agent.Team} object.
* @return a {@link eu.etaxonomy.cdm.model.agent.Team} object.
*/
- public static Team select(Shell shell, ConversationHolder conversation, Team team){
- TeamSelectionDialog dialog = new TeamSelectionDialog(shell, conversation,
+ public static Team select(Shell shell, //ConversationHolder conversation,
+ Team team){
+ TeamSelectionDialog dialog = new TeamSelectionDialog(shell, //conversation,
"Choose Team", false, TeamSelectionDialog.class.getCanonicalName(), team);
return getSelectionFromDialog(dialog);
}
* @param cdmObject a {@link eu.etaxonomy.cdm.model.agent.Team} object.
* @param conversation a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder} object.
*/
- protected TeamSelectionDialog(Shell shell, ConversationHolder conversation,
+ protected TeamSelectionDialog(Shell shell, //ConversationHolder conversation,
String title, boolean multi, String settings,
Team cdmObject) {
- super(shell, conversation, title, multi, settings, cdmObject);
+ super(shell, //conversation,
+ title, multi, settings, cdmObject);
}
/* (non-Javadoc)
- * @see eu.etaxonomy.taxeditor.dialogs.filteredSelection.AbstractFilteredCdmResourceSelectionDialog#initModel()
+ * @see eu.etaxonomy.taxeditor.dialogs.filteredSelection.AbstractFilteredCdmResourceSelectionDialog#search
*/
/** {@inheritDoc} */
@Override
- protected void initModel() {
- model = CdmStore.getService(IAgentService.class).getTeamUuidAndTitleCache();
+ protected void callService(String pattern) {
+ model = CdmStore.getService(IAgentService.class).getUuidAndTitleCache(Team.class, limitOfInitialElements, pattern);
+
}
/** {@inheritDoc} */
/** {@inheritDoc} */
@Override
- protected String getNewWizardLinkText() {
- return String.format("Create a new <a>%1s</a>", "Team ");
+ protected String[] getNewWizardText() {
+ return new String[]{"New Team"};
}
/** {@inheritDoc} */
import org.eclipse.swt.widgets.Shell;
-import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
import eu.etaxonomy.cdm.api.service.IUserService;
import eu.etaxonomy.cdm.model.common.User;
import eu.etaxonomy.cdm.persistence.dto.UuidAndTitleCache;
* @param user
* @return
*/
- public static User select(Shell shell, ConversationHolder conversation, User user){
- UserSelectionDialog dialog = new UserSelectionDialog(shell, conversation,
+ public static User select(Shell shell, //ConversationHolder conversation,
+ User user){
+ UserSelectionDialog dialog = new UserSelectionDialog(shell, //conversation,
"Choose User", false, UserSelectionDialog.class.getCanonicalName(), user);
return getSelectionFromDialog(dialog);
}
* @param settings
* @param cdmObject
*/
- protected UserSelectionDialog(Shell shell, ConversationHolder conversation,
+ protected UserSelectionDialog(Shell shell, //ConversationHolder conversation,
String title, boolean multi, String settings, User cdmObject) {
- super(shell, conversation, title, multi, settings, cdmObject);
+ super(shell, //conversation,
+ title, multi, settings, cdmObject);
}
/* (non-Javadoc)
- * @see eu.etaxonomy.taxeditor.ui.dialogs.filteredSelection.AbstractFilteredCdmResourceSelectionDialog#initModel()
+ * @see eu.etaxonomy.taxeditor.ui.dialogs.filteredSelection.AbstractFilteredCdmResourceSelectionDialog#search
*/
@Override
- protected void initModel() {
+ protected void callService(String pattern) {
List<User> users = CdmStore.getService(IUserService.class).list(User.class, null, null, null, null);
model = new ArrayList<UuidAndTitleCache<User>>();
for(User user : users){
- model.add(new UuidAndTitleCache<User>(User.class, user.getUuid(), user.getId(), String.format("%s, %s", user.getUsername(), user.getPerson())));
+ if (user.getUsername().matches(pattern)) {
+ model.add(new UuidAndTitleCache<User>(User.class, user.getUuid(), user.getId(), String.format("%s, %s", user.getUsername(), user.getPerson())));
+ }
}
}
* @see eu.etaxonomy.taxeditor.ui.dialogs.filteredSelection.AbstractFilteredCdmResourceSelectionDialog#getNewWizardLinkText()
*/
@Override
- protected String getNewWizardLinkText() {
- return String.format("Create a new <a>%1s</a>", "User ");
+ protected String[] getNewWizardText() {
+ return new String[]{"New User"};
}
/* (non-Javadoc)
if (control.equals(formElement.getLayoutComposite())) {
continue;
} else {
- control.dispose();
+ if (control != null && !control.isDisposed()){
+ control.dispose();
+ }
control = null;
}
}
public <T extends CdmBase> EntitySelectionElement<T> createSelectionElement(Class<T> clazz,
ConversationHolder conversation, ICdmFormElement parentElement, String labelString, T selection, int mode,
int style, boolean filterElement) {
- EntitySelectionElement<T> element = new EntitySelectionElement<T>(this, conversation, parentElement, clazz,
+ EntitySelectionElement<T> element = new EntitySelectionElement<T>(this, //conversation,
+ parentElement, clazz,
labelString, selection, mode, style, filterElement);
adapt(element);
parentElement.addElement(element);
}
public <T extends CdmBase> EntitySelectionElement<T> createSelectionElement(Class<T> clazz,
- ConversationHolder conversation, ICdmFormElement parentElement, String labelString, T selection, int mode,
+// ConversationHolder conversation,
+ ICdmFormElement parentElement, String labelString, T selection, int mode,
int style) {
- EntitySelectionElement<T> element = new EntitySelectionElement<T>(this, conversation, parentElement, clazz,
+ EntitySelectionElement<T> element = new EntitySelectionElement<T>(this, //conversation,
+ parentElement, clazz,
labelString, selection, mode, style);
adapt(element);
parentElement.addElement(element);
public <T extends CdmBase> EntitySelectionElementWithAbbreviatedTitle<T> createSelectionElementWithAbbreviatedTitle(
Class<T> clazz, ConversationHolder conversation, ICdmFormElement parentElement, String labelString,
T selection, int mode, int style) {
- EntitySelectionElementWithAbbreviatedTitle<T> element = new EntitySelectionElementWithAbbreviatedTitle<T>(this, conversation, parentElement, clazz,
+ EntitySelectionElementWithAbbreviatedTitle<T> element = new EntitySelectionElementWithAbbreviatedTitle<T>(this, //conversation,
+ parentElement, clazz,
labelString, selection, mode, style);
adapt(element);
parentElement.addElement(element);
public TaxonNodeSelectionElement createTaxonNodeSelectionElement(ConversationHolder conversation,
ICdmFormElement parentElement, String labelString, TaxonNode selection, int mode, int style) {
- TaxonNodeSelectionElement element = new TaxonNodeSelectionElement(this, conversation, parentElement,
+ TaxonNodeSelectionElement element = new TaxonNodeSelectionElement(this, //conversation,
+ parentElement,
labelString, selection, mode, style);
adapt(element);
parentElement.addElement(element);
Integer referencingObjectsCount = CdmStore.getCommonService().getReferencingObjectsCount(cdmBase);
if (referencingObjectsCount > 1){
- setWarnForReferencedObjects(formFactory.createLabel(formElement, CdmUtils.Nz("The reference is referenced by " + referencingObjectsCount+ " objects, if you change it, it is changed for all these objects")));
+ setWarnForReferencedObjects(formFactory.createLabel(formElement, CdmUtils.Nz("The "+ cdmBase.getUserFriendlyTypeName()+" is referenced by " + referencingObjectsCount+ " objects, if you change it, it is changed for all these objects")));
getWarnForReferencedObjects().setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_RED));
getWarnForReferencedObjects().setLayout(LayoutConstants.FILL(2, 3));
getWarnForReferencedObjects().setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_RED));
/**
* 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.
*/
/*
* (non-Javadoc)
- *
+ *
* @see
* eu.etaxonomy.taxeditor.section.AbstractCdmDetailElement#createControls
* (eu.etaxonomy.taxeditor.forms.ICdmFormElement, java.lang.Object, int)
protected void createControls(ICdmFormElement formElement,
Institution entity, int style) {
this.setWarnForReferencingObjects(formElement);
-
+
text_name = formFactory.createTextWithLabelElement(formElement, "Name",
entity.getName(), style);
text_code = formFactory.createTextWithLabelElement(formElement, "Code",
// section_institutionTypes
selection_partOfInstitution = formFactory
.createSelectionElement(Institution.class,
- getConversationHolder(), formElement, "Is Part Of",
+ //getConversationHolder(),
+ formElement, "Is Part Of",
entity.getIsPartOf(),
- EntitySelectionElement.EDITABLE | EntitySelectionElement.SELECTABLE | EntitySelectionElement.DELETABLE,
+ EntitySelectionElement.EDITABLE | EntitySelectionElement.SELECTABLE | EntitySelectionElement.DELETABLE,
style);
}
/*
* (non-Javadoc)
- *
+ *
* @see
* eu.etaxonomy.taxeditor.section.AbstractCdmDetailElement#handleEvent(java
* .lang.Object)
public void createControls(ICdmFormElement element, int style) {
selection_person = formFactory
.createSelectionElement(Person.class,
- getConversationHolder(), this, "Person", null,
+ //getConversationHolder(),
+ this, "Person", null,
EntitySelectionElement.EDITABLE | EntitySelectionElement.SELECTABLE,
style);
}
protected void createControls(ICdmFormElement formElement,
Classification entity, int style) {
text_treeLabel = formFactory.createTextWithLabelElement(formElement, "Label", entity != null ? entity.getName().getText() : null, SWT.NULL);
- selection_reference = formFactory.createSelectionElement(Reference.class, getConversationHolder(), formElement, "Reference",
+ selection_reference = formFactory.createSelectionElement(Reference.class, //getConversationHolder(),
+ formElement, "Reference",
entity != null ? entity.getReference() : null, EntitySelectionElement.ALL, SWT.NULL);
text_microReference = formFactory.createTextWithLabelElement(formElement, "Reference Detail",
entity != null ? entity.getMicroReference() : null, SWT.NULL);
if (entity != null){
selection_toPerson = formFactory
.createSelectionElement(TeamOrPersonBase.class,
- getConversationHolder(), element, "Agent", entity.getAgent(),
+ //getConversationHolder(),
+ element, "Agent", entity.getAgent(),
EntitySelectionElement.ALL, style);
} else{
selection_toPerson = formFactory
.createSelectionElement(TeamOrPersonBase.class,
- getConversationHolder(), element, "Agent", null,
+ //getConversationHolder(),
+ element, "Agent", null,
EntitySelectionElement.ALL, style);
}
label = formFactory.createLabel(element, null);
import eu.etaxonomy.cdm.common.CdmUtils;
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
-import eu.etaxonomy.cdm.model.name.INonViralName;
import eu.etaxonomy.cdm.model.name.TaxonName;
import eu.etaxonomy.cdm.model.reference.Reference;
import eu.etaxonomy.cdm.model.taxon.Classification;
protected void createControls(ICdmFormElement formElement,
ITaxonTreeNode entity, int style) {
selection_classification = formFactory
- .createSelectionElement(Classification.class,
- getConversationHolder(), formElement, "Classification",
+ .createSelectionElement(Classification.class,//getConversationHolder(),
+ formElement, "Classification",
null, EntitySelectionElement.DELETABLE, style);
selection_parentTaxonNode = formFactory
.createTaxonNodeSelectionElement(getConversationHolder(), formElement, "Parent", null,
EntitySelectionElement.DELETABLE, style);
selection_reuseExistingTaxon = formFactory
- .createSelectionElement(Taxon.class,
- getConversationHolder(), formElement,
+ .createSelectionElement(Taxon.class,//getConversationHolder(),
+ formElement,
"Reuse existing taxon", null,
EntitySelectionElement.DELETABLE, style);
selection_reuseExistingName = formFactory
- .createSelectionElement(TaxonName.class,
- getConversationHolder(), formElement,
+ .createSelectionElement(TaxonName.class,//getConversationHolder(),
+ formElement,
"Reuse existing name", null,
EntitySelectionElement.DELETABLE, style);
selection_SecRef = formFactory
- .createSelectionElement(Reference.class,getConversationHolder(), formElement, "Secundum Reference", null,
+ .createSelectionElement(Reference.class,//getConversationHolder(),
+ formElement, "Secundum Reference", null,
EntitySelectionElement.DELETABLE, style);
if (isCreateNew()){
textNewTaxonName = formFactory.createTextWithLabelElement(formElement,"New Taxon", "", style);
/**
* Copyright (C) 2009 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.
*/
protected void createControls(ICdmFormElement formElement,
ReferencedEntityBase entity, int style) {
selection_reference = formFactory
- .createSelectionElement(Reference.class,
- getConversationHolder(), formElement, "Reference",
+ .createSelectionElement(Reference.class,//getConversationHolder(),
+ formElement, "Reference",
entity.getCitation(),
EntitySelectionElement.ALL, style);
text_referenceDetail = formFactory.createTextWithLabelElement(
/**
* 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.
*/
* <p>
* DerivedUnitElement class.
* </p>
- *
+ *
* @author n.hoffmann
* @created Sep 16, 2010
* @version 1.0
* <p>
* Constructor for DerivedUnitElement.
* </p>
- *
+ *
* @param formFactory
* a {@link eu.etaxonomy.taxeditor.ui.element.CdmFormFactory}
* object.
/*
* (non-Javadoc)
- *
+ *
* @see
* eu.etaxonomy.taxeditor.section.AbstractEntityCollectionElement#createControls
* (eu.etaxonomy.taxeditor.forms.ICdmFormElement, int)
@Override
public void createControls(ICdmFormElement element, int style) {
selection_derivedUnit = formFactory.createSelectionElement(
- DerivedUnit.class, getConversationHolder(), element,
- "Specimen", null, EntitySelectionElement.SELECTABLE | EntitySelectionElement.EDITABLE,
+ DerivedUnit.class, //getConversationHolder(),
+ element, "Specimen", null,
+ EntitySelectionElement.SELECTABLE | EntitySelectionElement.EDITABLE,
style);
}
/*
* (non-Javadoc)
- *
+ *
* @see
* eu.etaxonomy.taxeditor.section.AbstractEntityCollectionElement#handleEvent
* (java.lang.Object)
/** {@inheritDoc} */
@Override
public SpecimenOrObservationBase createNewElement() {
- DerivedUnit selection = DerivedUnitSelectionDialog.select(getShell(), getConversationHolder(), null);
+ DerivedUnit selection = DerivedUnitSelectionDialog.select(getShell(), //getConversationHolder(),
+ null);
return selection;
}
public void createControls(ICdmFormElement formElement, int style) {
super.createControls(formElement, style);
selection_name = formFactory
- .createSelectionElement(TaxonName.class,
- getConversationHolder(), formElement, "Name in Source",
+ .createSelectionElement(TaxonName.class,//getConversationHolder(),
+ formElement, "Name in Source",
null, EntitySelectionElement.ALL, SWT.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.
*/
* <p>
* DescriptionSourceElement class.
* </p>
- *
+ *
* @author n.hoffmann
* @created Mar 18, 2010
* @version 1.0
* <p>
* Constructor for DescriptionSourceElement.
* </p>
- *
+ *
* @param cdmFormFactory
* a {@link eu.etaxonomy.taxeditor.ui.element.CdmFormFactory}
* object.
@Override
public void createControls(ICdmFormElement element, int style) {
selection_descriptionSource = formFactory
- .createSelectionElement(Reference.class,
- getConversationHolder(), element, "Description Source",
+ .createSelectionElement(Reference.class,//getConversationHolder(),
+ element, "Description Source",
null, EntitySelectionElement.ALL, style);
}
combo_language = formFactory.createDefinedTermComboElement(TermType.Language, this, "Language", entity.getLanguage(), style);
- selection_namedArea = formFactory.createSelectionElement(NamedArea.class, getConversationHolder(),
+ selection_namedArea = formFactory.createSelectionElement(NamedArea.class, //getConversationHolder(),
formElement, "Area",
entity.getArea(), EntitySelectionElement.NOTHING, style);
}
@Override
protected void createControls(ICdmFormElement formElement,
Distribution entity, int style) {
- selection_namedArea = formFactory.createSelectionElement(NamedArea.class, getConversationHolder(),
+ selection_namedArea = formFactory.createSelectionElement(NamedArea.class, //getConversationHolder(),
formElement, "Area",
entity.getArea(), EntitySelectionElement.NOTHING, style);
ICdmFormElement parent = this.getParentElement();
IndividualsAssociation entity, int style) {
selection_derivedUnit = formFactory
.createSelectionElement(SpecimenOrObservationBase.class,
- getConversationHolder(), formElement, "Occurrence/Unit",
+ //getConversationHolder(),
+ formElement, "Occurrence/Unit",
CdmBase.deproxy(entity.getAssociatedSpecimenOrObservation(),SpecimenOrObservationBase.class),
EntitySelectionElement.ALL, style);
TaxonInteraction entity, int style) {
taxonSelection = formFactory
- .createSelectionElement(Taxon.class,
- getConversationHolder(), formElement, "Taxon",
+ .createSelectionElement(Taxon.class,//getConversationHolder(),
+ formElement, "Taxon",
CdmBase.deproxy(entity.getTaxon2(),Taxon.class),
EntitySelectionElement.ALL, style);
@Override
public void createControls(ICdmFormElement element, int style) {
selection_authority = formFactory.createSelectionElement(
- GrantedAuthorityImpl.class, getConversationHolder(), element, "", getEntity(), EntitySelectionElement.SELECTABLE, style);
+ GrantedAuthorityImpl.class, //getConversationHolder(),
+ element, "", getEntity(), EntitySelectionElement.SELECTABLE, style);
}
/* (non-Javadoc)
// .warningDialog("Not implemented yet", getClass(),
// "This functionality needs to be implemented in CDM Library first.");
- GrantedAuthority selection = GrantedAuthoritySelectionDialog.select(getLayoutComposite().getShell(), getConversationHolder(), null);
+ GrantedAuthority selection = GrantedAuthoritySelectionDialog.select(getLayoutComposite().getShell(), //getConversationHolder(),
+ null);
return selection;
}
*/
@Override
public GrantedAuthority addExisting() {
-
+
return null;
}
/**
* Copyright (C) 2012 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.group;
-import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
import eu.etaxonomy.cdm.model.common.Group;
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
*
*/
public class GroupSelectionElement extends EntitySelectionElement<Group> {
-
- public GroupSelectionElement(CdmFormFactory formFactory,
- ConversationHolder conversation, ICdmFormElement parentElement,
+
+ public GroupSelectionElement(CdmFormFactory formFactory,//ConversationHolder conversation,
+ ICdmFormElement parentElement,
String labelString, Group entity, int mode,
int style) {
- super(formFactory, conversation, parentElement, Group.class, labelString, entity,
+ super(formFactory, //conversation,
+ parentElement, Group.class, labelString, entity,
mode, style);
}
/**
* 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.
*/
/*
* (non-Javadoc)
- *
+ *
* @see
* eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionElement#setEntity
* (java.lang.Object)
/*
* (non-Javadoc)
- *
+ *
* @see eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionElement#
* createControls(eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement, int)
*/
@Override
public void createControls(ICdmFormElement element, int style) {
selection_user = formFactory
- .createSelectionElement(User.class,
- getConversationHolder(), element, "", entity,
+ .createSelectionElement(User.class,//getConversationHolder(),
+ element, "", entity,
EntitySelectionElement.EDITABLE, style);
}
/*
* (non-Javadoc)
- *
+ *
* @see
* eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionElement#handleEvent
* (java.lang.Object)
/**
* 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.
*/
*/
@Override
public User createNewElement() {
- User selection = UserSelectionDialog.select(getLayoutComposite().getShell(), getConversationHolder(), null);
+ User selection = UserSelectionDialog.select(getLayoutComposite().getShell(), //getConversationHolder(),
+ null);
return selection;
}
return false;
}
-
+
}
formElement, "Question", parent.getQuestion(), 50, style);
selection_feature = formFactory
- .createSelectionElement(Feature.class,
- getConversationHolder(), formElement, "Character",
+ .createSelectionElement(Feature.class,//getConversationHolder(),
+ formElement, "Character",
parent.getFeature(),
EntitySelectionElement.EDITABLE | EntitySelectionElement.DELETABLE, style);
}
selection_taxon = formFactory
- .createSelectionElement(Taxon.class,
- getConversationHolder(), formElement, "Taxon",
+ .createSelectionElement(Taxon.class,//getConversationHolder(),
+ formElement, "Taxon",
entity.getTaxon(), EntitySelectionElement.DELETABLE,
style);
selection_subkey = formFactory
- .createSelectionElement(PolytomousKey.class,
- getConversationHolder(), formElement, "Subkey",
+ .createSelectionElement(PolytomousKey.class,//getConversationHolder(),
+ formElement, "Subkey",
entity.getSubkey(),
EntitySelectionElement.EDITABLE | EntitySelectionElement.DELETABLE, style);
selection_otherNode = formFactory
- .createSelectionElement(PolytomousKeyNode.class,
- getConversationHolder(), formElement, "Other Node",
+ .createSelectionElement(PolytomousKeyNode.class,//getConversationHolder(),
+ formElement, "Other Node",
entity.getOtherNode(),
EntitySelectionElement.DELETABLE, style);
/**
* 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.
*/
/*
* (non-Javadoc)
- *
+ *
* @see eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionSection#
* getCollection(java.lang.Object)
*/
/*
* (non-Javadoc)
- *
+ *
* @see eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionSection#
* createNewElement()
*/
@Override
public Taxon createNewElement() {
- Taxon selection = TaxonBaseSelectionDialog.selectTaxon(getShell(),
- getConversationHolder(), null);
+ Taxon selection = TaxonBaseSelectionDialog.selectTaxon(getShell(),//getConversationHolder(),
+ null);
return selection;
}
/*
* (non-Javadoc)
- *
+ *
* @see
* eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionSection#addElement
* (java.lang.Object)
/*
* (non-Javadoc)
- *
+ *
* @see eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionSection#
* removeElement(java.lang.Object)
*/
/*
* (non-Javadoc)
- *
+ *
* @see eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionSection#
* getEmptyString()
*/
/*
* (non-Javadoc)
- *
+ *
* @see eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionSection#
* getTooltipString()
*/
*/
package eu.etaxonomy.taxeditor.ui.section.media;
-import java.time.ZonedDateTime;
import java.util.Map;
import org.eclipse.jface.action.IAction;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
-
import org.eclipse.swt.widgets.Button;
import org.joda.time.DateTime;
-import org.joda.time.DateTimeZone;
import eu.etaxonomy.cdm.common.CdmUtils;
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
import eu.etaxonomy.cdm.model.common.LanguageString;
import eu.etaxonomy.cdm.model.media.Media;
import eu.etaxonomy.taxeditor.model.AbstractUtility;
-import eu.etaxonomy.taxeditor.model.DateConverter;
import eu.etaxonomy.taxeditor.model.ImageResources;
import eu.etaxonomy.taxeditor.store.CdmStore;
import eu.etaxonomy.taxeditor.ui.dialog.selection.MediaSelectionDialog;
}
});
text_title = formFactory.createLanguageStringWithLabelElement(element, "Title", null, style);
- selection_artist = formFactory.createSelectionElement(AgentBase.class, getConversationHolder(), element, "Artist", null, EntitySelectionElement.ALL, style);
+ selection_artist = formFactory.createSelectionElement(AgentBase.class, //getConversationHolder(),
+ element, "Artist", null, EntitySelectionElement.ALL, style);
addElement(selection_artist);
-
+
mediaCreated = formFactory.createDateElement(element, "Media Created", getEntity().getMediaCreated(), style, false);
addElement(mediaCreated.getController());
text_description = formFactory.createLanguageStringWithLabelElement(element, "Description", null, 100, true, style);
-
-
-
-
+
+
+
+
mediaDetailElement = formFactory.createMediaDetailElement(element);
addElement(mediaDetailElement);
}
}
text_title.setLanguageString(title);
-
+
}
@Override
protected Media selectFromDialog() {
- setEntity(MediaSelectionDialog.select(AbstractUtility.getShell(), null, null));
+ setEntity(MediaSelectionDialog.select(AbstractUtility.getShell(), //null,
+ null));
return entity;
}
*/
@Override
public Media addExisting() {
- return MediaSelectionDialog.select(getShell(), getConversationHolder(), null);
+ return MediaSelectionDialog.select(getShell(), //getConversationHolder(),
+ null);
}
/**
checkbox_conservedType = formFactory.createCheckbox(formElement,
"Conserved Type", false, style);
selection_typeName = formFactory
- .createSelectionElement(TaxonName.class,
- getConversationHolder(), formElement, "Name", null,
+ .createSelectionElement(TaxonName.class,//getConversationHolder(),
+ formElement, "Name", null,
EntitySelectionElement.ALL, style);
combo_typeStatus = formFactory.createDefinedTermComboElement(TermType.NameTypeDesignationStatus, formElement,
"Designation Status", null, style);
checkbox_conservedType.setSelection(entity.isConservedType());
checkbox_rejectedType.setSelection(entity.isRejectedType());
- selection_typeName.setEntity((TaxonName) HibernateProxyHelper.deproxy(entity.getTypeName()));
+ selection_typeName.setEntity(HibernateProxyHelper.deproxy(entity.getTypeName()));
combo_typeStatus.setSelection(HibernateProxyHelper.deproxy(entity.getTypeStatus(), NameTypeDesignationStatus.class));
Action chooseNameAction = new Action("Choose Name", IAction.AS_PUSH_BUTTON){
@Override
public void run() {
- TaxonName taxonName = NameSelectionDialog.select(getShell(), getConversationHolder(), getEntity());
+ TaxonName taxonName = NameSelectionDialog.select(getShell(), //getConversationHolder(),
+ getEntity());
if(taxonName!=null){
TaxonName nonViralName = HibernateProxyHelper.deproxy(taxonName);
taxonBase.setName(nonViralName);
public void createControls(ICdmFormElement formElement, int style) {
selection_typeSpecimen = formFactory
.createSelectionElement(DerivedUnit.class,
- getConversationHolder(), formElement, "Specimen", null,
+// getConversationHolder(),
+ formElement, "Specimen", null,
EntitySelectionElement.ALL, style);
combo_typeStatus = formFactory.createDefinedTermComboElement(TermType.SpecimenTypeDesignationStatus,
formElement, "Designation Status", null, style);
/**
* 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.
*/
* <p>
* Abstract AbstractEventDetailElement class.
* </p>
- *
+ *
* @author n.hoffmann
* @created Oct 14, 2010
* @version 1.0
* <p>
* Constructor for AbstractEventDetailElement.
* </p>
- *
+ *
* @param formFactory
* a {@link eu.etaxonomy.taxeditor.ui.element.CdmFormFactory}
* object.
/*
* (non-Javadoc)
- *
+ *
* @see
* eu.etaxonomy.taxeditor.section.AbstractEntityCollectionElement#setEntity
* (java.lang.Object)
/*
* (non-Javadoc)
- *
+ *
* @see
* eu.etaxonomy.taxeditor.section.AbstractEntityCollectionElement#createControls
* (eu.etaxonomy.taxeditor.forms.ICdmFormElement, int)
@Override
public void createControls(ICdmFormElement element, int style) {
selection_agent = formFactory
- .createSelectionElement(AgentBase.class,
- getConversationHolder(), element, "Actor", null,
+ .createSelectionElement(AgentBase.class,//getConversationHolder(),
+ element, "Actor", null,
EntitySelectionElement.ALL, style);
element_timePeriod = formFactory.createTimePeriodElement(element,
"Time Period", null, style);
/** {@inheritDoc} */
@Override
public NamedArea createNewElement() {
- NamedArea selection = NamedAreaSelectionDialog.select(getLayoutComposite().getShell(), getConversationHolder(), null, FieldUnit.class.getCanonicalName());
+ NamedArea selection = NamedAreaSelectionDialog.select(getLayoutComposite().getShell(), //getConversationHolder(),
+ null, FieldUnit.class.getCanonicalName());
return selection;
}
/**
* 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.
*/
* <p>
* CollectionDetailElement class.
* </p>
- *
+ *
* @author n.hoffmann
* @created Oct 13, 2010
* @version 1.0
* <p>
* Constructor for CollectionDetailElement.
* </p>
- *
+ *
* @param formFactory
* a {@link eu.etaxonomy.taxeditor.ui.element.CdmFormFactory}
* object.
/*
* (non-Javadoc)
- *
+ *
* @see
* eu.etaxonomy.taxeditor.section.AbstractCdmDetailElement#createControls
* (eu.etaxonomy.taxeditor.forms.ICdmFormElement,
formElement, "Town Or Location", entity.getTownOrLocation(),
style);
selection_institute = formFactory
- .createSelectionElement(Institution.class,
- getConversationHolder(), formElement, "Institute",
+ .createSelectionElement(Institution.class,//getConversationHolder(),
+ formElement, "Institute",
entity.getInstitute(),
EntitySelectionElement.ALL, style);
selection_superCollection = formFactory
- .createSelectionElement(Collection.class,
- getConversationHolder(), formElement,
+ .createSelectionElement(Collection.class,//getConversationHolder(),
+ formElement,
"Super Collection", entity.getSuperCollection(),
EntitySelectionElement.ALL, style);
}
/*
* (non-Javadoc)
- *
+ *
* @see
* eu.etaxonomy.taxeditor.section.AbstractCdmDetailElement#handleEvent(java
* .lang.Object)
// we ignore this
MessagingUtils.info(e.getMessage());
}
- selection_storedUnder = formFactory.createSelectionElement(TaxonName.class, getConversationHolder(), formElement, "Stored Under", entity.getStoredUnder(), EntitySelectionElement.ALL, style);
+ selection_storedUnder = formFactory.createSelectionElement(TaxonName.class, //getConversationHolder(),
+ formElement, "Stored Under", entity.getStoredUnder(), EntitySelectionElement.ALL, style);
try {
text_exsicatum = formFactory.createTextWithLabelElement(formElement, "Exsiccatum", entity.getExsiccatum(), style);
combo_specorobstype = formFactory.createEnumComboElement(SpecimenOrObservationType.class, formElement, style);
combo_specorobstype.setSelection(entity.getType());
combo_specorobstype.setEnabled(showSpecimenType);
- selection_country = formFactory.createSelectionElement(NamedArea.class, getConversationHolder(),
+ selection_country = formFactory.createSelectionElement(NamedArea.class, //getConversationHolder(),
formElement, "Country",
entity.getCountry(), EntitySelectionElement.NOTHING, style);
element_date = formFactory.createTimePeriodElement(formElement, "Date",
entity.getGatheringPeriod(), style);
selection_collector = formFactory
- .createSelectionElement(AgentBase.class,
- getConversationHolder(), formElement, "Collector",
+ .createSelectionElement(AgentBase.class,//getConversationHolder(),
+ formElement, "Collector",
entity.getCollector(), EntitySelectionElement.ALL,
style);
text_collectingNumber = formFactory.createTextWithLabelElement(formElement,
"Collecting number", entity.getFieldNumber(), style);
}
selection_collection = formFactory
- .createSelectionElement(Collection.class,
- getConversationHolder(), formElement, "Collection",
+ .createSelectionElement(Collection.class,//getConversationHolder(),
+ formElement, "Collection",
entity.getCollection(),
EntitySelectionElement.ALL, style);
text_accessionNumber = formFactory.createTextWithLabelElement(
@Override
public void createControls(ICdmFormElement element, int style) {
selectionTaxonNameBase = formFactory
- .createSelectionElement(TaxonName.class,
- getConversationHolder(), element, "Taxon Name", null,
- EntitySelectionElement.NOTHING, style);
+ .createSelectionElement(TaxonName.class,//getConversationHolder(),
+ element, "Taxon Name", null,
+ EntitySelectionElement.ALL, style);
selection_taxonBase = formFactory
- .createSelectionElement(TaxonBase.class,
- getConversationHolder(), element, "Taxon", null,
- EntitySelectionElement.NOTHING, style);
+ .createSelectionElement(TaxonBase.class,//getConversationHolder(),
+ element, "Taxon", null,
+ EntitySelectionElement.ALL, style);
// TODO set of references
getEntity().setTaxonName(selectionTaxonNameBase.getSelection());
//empty taxon field if name does not belong the taxon
TaxonBase taxonBase = selection_taxonBase.getEntity();
- if(taxonBase!=null && taxonBase.getName()!=null
+ if(taxonBase!=null && taxonBase.getName()!=null
&& !taxonBase.getName().equals(selectionTaxonNameBase.getSelection())){
selection_taxonBase.setEntity(null);
}
combo_specorobstype = formFactory.createEnumComboElement(SpecimenOrObservationType.class, formElement, style);
combo_specorobstype.setSelection(entity.getType());
- selection_country = formFactory.createSelectionElement(NamedArea.class, getConversationHolder(), formElement,
- "Country", entity.getCountry(), EntitySelectionElement.NOTHING, style);
+ selection_country = formFactory.createSelectionElement(NamedArea.class, //getConversationHolder(),
+ formElement, "Country", entity.getCountry(), EntitySelectionElement.NOTHING, style);
if(PreferencesUtil.isCollectingAreaInGeneralSection()){
section_collectingAreas = formFactory.createCollectingAreasDetailSection(getConversationHolder(), formElement, ExpandableComposite.TWISTIE);
section_collectingAreas.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
formElement, "Elevation : ", entity, MinMaxTextSection.UnitType.ELEVATION, style);
element_date = formFactory.createTimePeriodElement(formElement, "Date", entity.getGatheringPeriod(), style);
- selection_collector = formFactory.createSelectionElement(AgentBase.class, getConversationHolder(), formElement,
- "Collector", entity.getCollector(), EntitySelectionElement.ALL, style);
+ selection_collector = formFactory.createSelectionElement(AgentBase.class, //getConversationHolder(),
+ formElement, "Collector", entity.getCollector(), EntitySelectionElement.ALL, style);
text_collectingNumber = formFactory.createTextWithLabelElement(formElement, "Collecting number",
entity.getFieldNumber(), style);
checkIsPublish = formFactory.createCheckbox(formElement, "Publish", entity.isPublish(), style);
/** {@inheritDoc} */
@Override
public NamedArea createNewElement() {
- NamedArea selection = NamedAreaSelectionDialog.select(getLayoutComposite().getShell(), getConversationHolder(), null, Classification.class.getCanonicalName());
+ NamedArea selection = NamedAreaSelectionDialog.select(getLayoutComposite().getShell(), //getConversationHolder(),
+ null, Classification.class.getCanonicalName());
return selection;
}
/** {@inheritDoc} */
@Override
public NamedArea createNewElement() {
- NamedArea selection = NamedAreaSelectionDialog.select(getLayoutComposite().getShell(), getConversationHolder(), null, PolytomousKey.class.getCanonicalName());
+ NamedArea selection = NamedAreaSelectionDialog.select(getLayoutComposite().getShell(), //getConversationHolder(),
+ null, PolytomousKey.class.getCanonicalName());
return selection;
}
/**
* 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.
*/
* <p>
* CollectingAreasDetailElement class.
* </p>
- *
+ *
* @author n.hoffmann
* @created Oct 14, 2010
* @version 1.0
* <p>
* Constructor for CollectingAreasDetailElement.
* </p>
- *
+ *
* @param formFactory
* a {@link eu.etaxonomy.taxeditor.ui.element.CdmFormFactory}
* object.
/*
* (non-Javadoc)
- *
+ *
* @see
* eu.etaxonomy.taxeditor.section.AbstractEntityCollectionElement#setEntity
* (java.lang.Object)
/*
* (non-Javadoc)
- *
+ *
* @see
* eu.etaxonomy.taxeditor.section.AbstractEntityCollectionElement#createControls
* (eu.etaxonomy.taxeditor.forms.ICdmFormElement, int)
/** {@inheritDoc} */
@Override
public void createControls(ICdmFormElement formElement, int style) {
- selection_namedArea = formFactory.createSelectionElement(NamedArea.class, getConversationHolder(),
+ selection_namedArea = formFactory.createSelectionElement(NamedArea.class, //getConversationHolder(),
formElement, "Area",
null, EntitySelectionElement.NOTHING, style);
}
/*
* (non-Javadoc)
- *
+ *
* @see
* eu.etaxonomy.taxeditor.section.AbstractEntityCollectionElement#handleEvent
* (java.lang.Object)
/**
* 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.
*/
* <p>
* SpecimenCollectionDetailElement class.
* </p>
- *
+ *
* @author n.hoffmann
* @created Oct 14, 2010
* @version 1.0
* <p>
* Constructor for SpecimenCollectionDetailElement.
* </p>
- *
+ *
* @param formFactory
* a {@link eu.etaxonomy.taxeditor.ui.element.CdmFormFactory}
* object.
/*
* (non-Javadoc)
- *
+ *
* @see
* eu.etaxonomy.taxeditor.section.AbstractEntityCollectionElement#setEntity
* (java.lang.Object)
/*
* (non-Javadoc)
- *
+ *
* @see
* eu.etaxonomy.taxeditor.section.AbstractEntityCollectionElement#createControls
* (eu.etaxonomy.taxeditor.forms.ICdmFormElement, int)
@Override
public void createControls(ICdmFormElement element, int style) {
selection_derivedUnit = formFactory
- .createSelectionElement(DerivedUnit.class,
- getConversationHolder(), element, "Derived Unit", null,
+ .createSelectionElement(DerivedUnit.class,//getConversationHolder(),
+ element, "Derived Unit", null,
EntitySelectionElement.EDITABLE | EntitySelectionElement.SELECTABLE, style);
}
/*
* (non-Javadoc)
- *
+ *
* @see
* eu.etaxonomy.taxeditor.section.AbstractEntityCollectionElement#handleEvent
* (java.lang.Object)
@Override
public void handleEvent(Object eventSource) {
if (eventSource == selection_derivedUnit) {
- this.setEntity((DerivedUnit) selection_derivedUnit.getSelection());
+ this.setEntity(selection_derivedUnit.getSelection());
}
}
* @author n.hoffmann
* @created May 17, 2010
*/
-public class DerivedUnitTypeDesignationElement
+public class DerivedUnitTypeDesignationElement
extends AbstractTypeDesignationElement<SpecimenTypeDesignation> {
private TermComboElement<SpecimenTypeDesignationStatus> combo_typeStatus;
this.style = style;
selectionTaxonName = formFactory.createSelectionElement(
- TaxonName.class, getConversationHolder(), parentFormElement, "Scientific Name", null,
+ TaxonName.class, //getConversationHolder(),
+ parentFormElement, "Scientific Name", null,
EntitySelectionElement.EDITABLE | EntitySelectionElement.SELECTABLE, style);
combo_typeStatus = formFactory.createDefinedTermComboElement(TermType.SpecimenTypeDesignationStatus,
PreservationMethod preservationMethod = entity.getPreservation();
combo_preservationMethod = formFactory.createDefinedTermComboElement(TermType.MaterialOrMethod, formElement, "Preservation Method", preservationMethod==null?null:preservationMethod.getDefinedMaterialOrMethod(), style);
- selection_storedUnder = formFactory.createSelectionElement(TaxonName.class, getConversationHolder(), formElement, "Stored Under", entity.getStoredUnder(), EntitySelectionElement.ALL, style);
+ selection_storedUnder = formFactory.createSelectionElement(TaxonName.class, //getConversationHolder(),
+ formElement, "Stored Under", entity.getStoredUnder(), EntitySelectionElement.ALL, style);
text_exsicatum = formFactory.createTextWithLabelElement(formElement, "Exsiccatum", entity.getExsiccatum(), style);
formElement, "Title Cache", entity.getTitleCache(),
entity.isProtectedTitleCache(), style);
selection_collection = formFactory
- .createSelectionElement(Collection.class,
- getConversationHolder(), formElement, "Collection",
+ .createSelectionElement(Collection.class,//getConversationHolder(),
+ formElement, "Collection",
entity.getCollection(),
EntitySelectionElement.ALL, style);
text_accessionNumber = formFactory.createTextWithLabelElement(
Cloning cloning = entity.getCloning();
textCloningStrain = formFactory.createTextWithLabelElement(formElement, "Cloning Strain", cloning==null?"":cloning.getStrain(), style);
date = formFactory.createTimePeriodElement(formElement, "Cloning Date", cloning==null?null:cloning.getTimeperiod(), style);
- selectionCloningStaff = formFactory.createSelectionElement(AgentBase.class, getConversationHolder(), formElement, "Cloning Staff", cloning==null?null:cloning.getActor(), EntitySelectionElement.ALL, style);
+ selectionCloningStaff = formFactory.createSelectionElement(AgentBase.class, //getConversationHolder(),
+ formElement, "Cloning Staff", cloning==null?null:cloning.getActor(), EntitySelectionElement.ALL, style);
comboCloningMaterialOrMethod = formFactory.createDefinedTermComboElement(TermType.MaterialOrMethod, formElement, "Cloning Mat. & Meth.", cloning==null?null:cloning.getDefinedMaterialOrMethod(), style);
}
textDesignation = formFactory.createTextWithLabelElement(formElement, "Designation", entity.getLabelCache(), style);
textDesignation.setEnabled(false);
textDesignation.setBackground(getPersistentBackground());
- selectionInstitution = formFactory.createSelectionElement(Institution.class, getConversationHolder(), formElement, "Institution", entity.getInstitution(), EntitySelectionElement.ALL, style);
- selectionAmplificationStaff = formFactory.createSelectionElement(AgentBase.class, getConversationHolder(), formElement, "Amplification staff", entity.getActor(), EntitySelectionElement.ALL, style);
+ selectionInstitution = formFactory.createSelectionElement(Institution.class, //getConversationHolder(),
+ formElement, "Institution", entity.getInstitution(), EntitySelectionElement.ALL, style);
+ selectionAmplificationStaff = formFactory.createSelectionElement(AgentBase.class, //getConversationHolder(),
+ formElement, "Amplification staff", entity.getActor(), EntitySelectionElement.ALL, style);
dateAmplification = formFactory.createTimePeriodElement(formElement, "Date", entity.getTimeperiod(), style);
comboMarker = formFactory.createDefinedTermComboElement(TermType.DnaMarker, formElement, "DNA Marker", entity.getDnaMarker(), style);
- selectionPrimerFW = formFactory.createSelectionElement(Primer.class, getConversationHolder(), formElement, "Primer FW", entity.getForwardPrimer(), EntitySelectionElement.ALL, style);
- selectionPrimerRW = formFactory.createSelectionElement(Primer.class, getConversationHolder(), formElement, "Primer RW", entity.getReversePrimer(), EntitySelectionElement.ALL, style);
+ selectionPrimerFW = formFactory.createSelectionElement(Primer.class,// getConversationHolder(),
+ formElement, "Primer FW", entity.getForwardPrimer(), EntitySelectionElement.ALL, style);
+ selectionPrimerRW = formFactory.createSelectionElement(Primer.class, //getConversationHolder(),
+ formElement, "Primer RW", entity.getReversePrimer(), EntitySelectionElement.ALL, style);
AnnotationSection annotationSection = formFactory.createAnnotationSection(getConversationHolder(), formElement, style);
annotationSection.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
*/
@Override
protected void createControls(ICdmFormElement formElement, Amplification entity, int style) {
- selectionPrimerForward = formFactory.createSelectionElement(Primer.class, getConversationHolder(), formElement, "Forward Primer", entity.getForwardPrimer(), EntitySelectionElement.ALL, style);
- selectionPrimerReverse = formFactory.createSelectionElement(Primer.class, getConversationHolder(), formElement, "Reverse Primer", entity.getReversePrimer(), EntitySelectionElement.ALL, style);
+ selectionPrimerForward = formFactory.createSelectionElement(Primer.class, //getConversationHolder(),
+ formElement, "Forward Primer", entity.getForwardPrimer(), EntitySelectionElement.ALL, style);
+ selectionPrimerReverse = formFactory.createSelectionElement(Primer.class, //getConversationHolder(),
+ formElement, "Reverse Primer", entity.getReversePrimer(), EntitySelectionElement.ALL, style);
}
/*
@Override
protected void createControls(ICdmFormElement formElement, DnaSample entity, int style) {
selection_collection = formFactory
- .createSelectionElement(Collection.class,
- getConversationHolder(), formElement, "Collection",
+ .createSelectionElement(Collection.class,//getConversationHolder(),
+ formElement, "Collection",
entity.getCollection(),
EntitySelectionElement.ALL, style);
textBarcode = formFactory.createTextWithLabelElement(formElement, "Barcode", entity.getBarcode(), style);
* 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.dna;
import eu.etaxonomy.cdm.model.agent.AgentBase;
if(entity.getDerivedFrom()!=null){
materialOrMethodText = entity.getDerivedFrom().getDescription();
}
- selectionInstitution = formFactory.createSelectionElement(Institution.class, getConversationHolder(), formElement, "Institution", institution, EntitySelectionElement.ALL, style);
- selectionStaff = formFactory.createSelectionElement(AgentBase.class, getConversationHolder(), formElement, "Staff", staff, EntitySelectionElement.ALL, style);
+ selectionInstitution = formFactory.createSelectionElement(Institution.class, //getConversationHolder(),
+ formElement, "Institution", institution, EntitySelectionElement.ALL, style);
+ selectionStaff = formFactory.createSelectionElement(AgentBase.class, //getConversationHolder(),
+ formElement, "Staff", staff, EntitySelectionElement.ALL, style);
datePreparationDate = formFactory.createTimePeriodElement(formElement, "Preparation date", preparationDate, style);
numberPreservationTemperature = formFactory.createNumberTextWithLabelElement(formElement, "Preservation Temp. [C°]", temperature, style);
txtMaterialOrMethods = formFactory.createTextWithLabelElement(formElement, "Materials && Methods", materialOrMethodText, style);
comboMarker = formFactory.createDefinedTermComboElement(TermType.DnaMarker, formElement, "DNA Marker", entity.getDnaMarker(), style);
selectionReference = formFactory
- .createSelectionElement(Reference.class,
- getConversationHolder(), formElement, "Reference",
+ .createSelectionElement(Reference.class,//getConversationHolder(),
+ formElement, "Reference",
entity.getPublishedIn(),
EntitySelectionElement.ALL, style);
@Override
public void createControls(ICdmFormElement formElement, int style) {
selection_reference = formFactory
- .createSelectionElement(Reference.class,
- getConversationHolder(), formElement, "Reference",
+ .createSelectionElement(Reference.class,//getConversationHolder(),
+ formElement, "Reference",
null, EntitySelectionElement.SELECTABLE|EntitySelectionElement.EDITABLE, style);
text_referenceDetail = formFactory.createTextWithLabelElement(
formElement, "Reference Detail", null, SWT.NULL);
*/
@Override
protected void createControls(ICdmFormElement formElement, SingleRead entity, int style) {
- selectionPrimer = formFactory.createSelectionElement(Primer.class, getConversationHolder(), formElement, "Primer", entity.getPrimer(), EntitySelectionElement.ALL, style);
+ selectionPrimer = formFactory.createSelectionElement(Primer.class, //getConversationHolder(),
+ formElement, "Primer", entity.getPrimer(), EntitySelectionElement.ALL, style);
AmplificationResult amplificationResult = entity.getAmplificationResult();
if(amplificationResult==null){
amplificationResult = AmplificationResult.NewInstance();
amplificationResult.addSingleRead(entity);
}
- selectionAmplification = formFactory.createSelectionElement(Amplification.class, getConversationHolder(), formElement, "Amplification", amplificationResult.getAmplification(), EntitySelectionElement.ALL, style);
+ selectionAmplification = formFactory.createSelectionElement(Amplification.class, //getConversationHolder(),
+ formElement, "Amplification", amplificationResult.getAmplification(), EntitySelectionElement.ALL, style);
AnnotationSection annotationSection = formFactory.createAnnotationSection(getConversationHolder(), formElement, style);
annotationSection.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
if(entity.getPreservation()!=null){
preservationMedium = entity.getPreservation().getMedium();
}
- selectionInstitution = formFactory.createSelectionElement(Institution.class, getConversationHolder(), formElement, "Institution", institution, EntitySelectionElement.ALL, style);
- selectionStaff = formFactory.createSelectionElement(AgentBase.class, getConversationHolder(), formElement, "Staff", staff, EntitySelectionElement.ALL,style);
+ selectionInstitution = formFactory.createSelectionElement(Institution.class, //getConversationHolder(),
+ formElement, "Institution", institution, EntitySelectionElement.ALL, style);
+ selectionStaff = formFactory.createSelectionElement(AgentBase.class, //getConversationHolder(),
+ formElement, "Staff", staff, EntitySelectionElement.ALL,style);
datePreparation = formFactory.createTimePeriodElement(formElement, "Preparation date", preparationDate, style);
comboPreservationMedium = formFactory.createDefinedTermComboElement(TermType.MaterialOrMethod, formElement, "Preservation medium", preservationMedium, style);
- selectionCollection = formFactory.createSelectionElement(Collection.class, getConversationHolder(), formElement, "Collection", entity.getCollection(), EntitySelectionElement.ALL, style);
+ selectionCollection = formFactory.createSelectionElement(Collection.class, //getConversationHolder(),
+ formElement, "Collection", entity.getCollection(), EntitySelectionElement.ALL, style);
textAccessionNumber = formFactory.createTextWithLabelElement(formElement, "Accession Number", entity.getAccessionNumber(), style);
textBarcode = formFactory.createTextWithLabelElement(formElement, "Barcode", entity.getBarcode(), style);
checkIsPublish = formFactory.createCheckbox(formElement, "Publish", entity.isPublish(), style);
*/
package eu.etaxonomy.taxeditor.ui.section.occurrence.media;
-import java.time.ZonedDateTime;
-
import org.joda.time.DateTime;
import eu.etaxonomy.cdm.api.service.IVocabularyService;
import eu.etaxonomy.cdm.model.occurrence.Collection;
import eu.etaxonomy.cdm.model.occurrence.MediaSpecimen;
import eu.etaxonomy.cdm.model.reference.Reference;
-import eu.etaxonomy.taxeditor.model.DateConverter;
import eu.etaxonomy.taxeditor.store.CdmStore;
import eu.etaxonomy.taxeditor.ui.combo.TermComboElement;
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
else{
comboKindOfUnit = formFactory.createDefinedTermComboElement(mediaSpecimenVocabulary, formElement, "Kind of Media", entity.getKindOfUnit(), style);
textTitleLanguageString = formFactory.createLanguageStringWithLabelElement(formElement, "Motif", media.getTitle(), style);
- selectionArtist = formFactory.createSelectionElement(AgentBase.class, getConversationHolder(), formElement, "Prepared by", media.getArtist(), EntitySelectionElement.ALL, style);
+ selectionArtist = formFactory.createSelectionElement(AgentBase.class, //getConversationHolder(),
+ formElement, "Prepared by", media.getArtist(), EntitySelectionElement.ALL, style);
DateTime mediaCreated = entity.getMediaSpecimen().getMediaCreated();
-
+
date = formFactory.createDateElement(formElement, "Preparation Date", mediaCreated, style, true);
textMethodLanguageString = formFactory.createLanguageStringWithLabelElement(formElement, "Method", media.getDescription(Language.getDefaultLanguage()), style);
- selection_collection = formFactory.createSelectionElement(Collection.class, getConversationHolder(), formElement, "Collection", entity.getCollection(), EntitySelectionElement.ALL, 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);
//the first PrimaryMediaSource is used for storing the reference
break;
}
}
- selection_publishedIn = formFactory.createSelectionElement(Reference.class, getConversationHolder(), formElement, "Published in", publishedIn, EntitySelectionElement.ALL, style);
+ selection_publishedIn = formFactory.createSelectionElement(Reference.class, //getConversationHolder(),
+ formElement, "Published in", publishedIn, EntitySelectionElement.ALL, style);
checkIsPublish = formFactory.createCheckbox(formElement, "Publish", entity.isPublish(), style);
mediaDetailElement = formFactory.createMediaDetailElement(formElement);
import java.util.List;
import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Display;
import org.joda.time.DateTime;
-import eu.etaxonomy.cdm.common.CdmUtils;
import eu.etaxonomy.cdm.model.agent.AgentBase;
import eu.etaxonomy.cdm.model.agent.Institution;
import eu.etaxonomy.cdm.model.agent.TeamOrPersonBase;
import eu.etaxonomy.cdm.model.reference.Reference;
import eu.etaxonomy.cdm.model.reference.ReferenceFactory;
import eu.etaxonomy.cdm.model.reference.ReferenceType;
-import eu.etaxonomy.taxeditor.model.DateConverter;
-import eu.etaxonomy.taxeditor.store.CdmStore;
import eu.etaxonomy.taxeditor.ui.combo.EnumComboElement;
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
import eu.etaxonomy.taxeditor.ui.element.CdmPropertyChangeEvent;
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
import eu.etaxonomy.taxeditor.ui.element.IErrorIntolerableElement;
import eu.etaxonomy.taxeditor.ui.element.IExceptionHandler;
-import eu.etaxonomy.taxeditor.ui.element.LabelElement;
-import eu.etaxonomy.taxeditor.ui.element.LayoutConstants;
import eu.etaxonomy.taxeditor.ui.element.TextWithLabelElement;
import eu.etaxonomy.taxeditor.ui.element.TimePeriodElement;
import eu.etaxonomy.taxeditor.ui.element.ToggleableTextElement;
// author team
selection_authorTeam = formFactory
- .createSelectionElement(AgentBase.class,
- getConversationHolder(), formElement, "Author",
+ .createSelectionElement(AgentBase.class,//getConversationHolder(),
+ formElement, "Author",
entity.getAuthorship(),
EntitySelectionElement.ALL, style);
if (referenceType.equals(ReferenceType.Generic)) {
createGenericControls(this, entity, SWT.NULL);
createPublicationControls(this, referenceType, entity, SWT.NULL);
-
+
} else {
if (referenceType.isPrintedUnit()) {
createPrintedUnitControls(this, referenceType, entity,
if (referenceType.isSection()) {
createSectionControls(this, entity, SWT.NULL);
}
-
+
}
}
private void createWebPageControls(ReferenceDetailElement referenceDetailElement, Reference reference, int style) {
DateTime accessed = reference.getAccessed();
-
+
text_accessed = formFactory.createDateElement(referenceDetailElement, "Accessed", accessed, style, false);
-
+
}
/*
if (createInReferenceWidget) {
selection_inReference = formFactory
- .createSelectionElement(Reference.class,
- getConversationHolder(), element, label,
+ .createSelectionElement(Reference.class,//getConversationHolder(),
+ element, label,
reference.getInReference(),
EntitySelectionElement.ALL, style);
}
// pages
text_pages = formFactory.createTextWithLabelElement(element, "Pages",
reference.getPages(), style);
-
-
+
+
}
/**
if (referenceType.equals(ReferenceType.Report)) {
// institution
selection_institution = formFactory
- .createSelectionElement(Institution.class,
- getConversationHolder(), element, "Institution",
+ .createSelectionElement(Institution.class,//getConversationHolder(),
+ element, "Institution",
reference.getInstitution(),
EntitySelectionElement.ALL, style);
}
if (referenceType.equals(ReferenceType.Thesis)) {
// school
selection_institution = formFactory
- .createSelectionElement(Institution.class,
- getConversationHolder(), element, "School",
+ .createSelectionElement(Institution.class,//getConversationHolder(),
+ element, "School",
reference.getSchool(),
EntitySelectionElement.ALL, style);
}
ReferenceType referenceType, Reference reference, int style) {
// in series
selection_inSeries = formFactory
- .createSelectionElement(Reference.class,
- getConversationHolder(), element, "In Series",
+ .createSelectionElement(Reference.class,//getConversationHolder(),
+ element, "In Series",
(Reference) reference.getInSeries(),
EntitySelectionElement.ALL, style);
setIrrelevant(pushedState, except);
}
-
+
}
@Override
public void createControls(ICdmFormElement formElement, int style) {
selection_reference = formFactory
- .createSelectionElement(Reference.class,
- getConversationHolder(), formElement, "Reference",
+ .createSelectionElement(Reference.class,//getConversationHolder(),
+ formElement, "Reference",
null, EntitySelectionElement.ALL, style);
text_referenceDetail = formFactory.createTextWithLabelElement(
formElement, "Reference Detail", null, SWT.NULL);
/**
- *
+ *
*/
package eu.etaxonomy.taxeditor.ui.section.supplemental;
* <p>
* CreditElement class.
* </p>
- *
+ *
* @author n.hoffmann
* @created Nov 16, 2009
* @version 1.0
* <p>
* Constructor for CreditElement.
* </p>
- *
+ *
* @param formElement
* a {@link eu.etaxonomy.taxeditor.ui.element.AbstractFormSection}
* object.
/*
* (non-Javadoc)
- *
+ *
* @see
* eu.etaxonomy.taxeditor.forms.entitysections.AbstractEntitySetElementComposite
* #createControls(org.eclipse.swt.widgets.Composite, int)
@Override
public void createControls(ICdmFormElement element, int style) {
agentSelection = formFactory
- .createSelectionElement(AgentBase.class,
- getConversationHolder(), this, "Agent", null,
+ .createSelectionElement(AgentBase.class,//getConversationHolder(),
+ this, "Agent", null,
EntitySelectionElement.ALL, style);
text = formFactory.createMultiLineTextWithLabel(this, "Text", 100,
style);
/*
* (non-Javadoc)
- *
+ *
* @see
* eu.etaxonomy.taxeditor.forms.entitysections.AbstractEntitySetElementComposite
* #setElement(eu.etaxonomy.cdm.model.common.AnnotatableEntity)
public void createControls(ICdmFormElement element, int style) {
combo_rightsType = formFactory.createDefinedTermComboElement(TermType.RightsType, this, "Rights Type", null, style);
selection_agent = formFactory.createSelectionElement(
- AgentBase.class, getConversationHolder(), this, "Agent",
+ AgentBase.class, //getConversationHolder(),
+ this, "Agent",
null, EntitySelectionElement.ALL, style);
text = formFactory.createMultiLineTextWithLabel(this, "Text", 100,
style);
*/
@Override
public Rights addExisting() {
- return RightsSelectionDialog.select(getShell(), getConversationHolder(), null);
+ return RightsSelectionDialog.select(getShell(), //getConversationHolder(),
+ null);
}
/**
- selection_secundum = formFactory.createSelectionElement(Reference.class,
- getConversationHolder(), formElement, "Secundum",
+ selection_secundum = formFactory.createSelectionElement(Reference.class,//getConversationHolder(),
+ formElement, "Secundum",
entity.getSec(), EntitySelectionElement.ALL,
style);
/**
* 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.
*/
/*
* (non-Javadoc)
- *
+ *
* @see
* eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionElement#setEntity
* (java.lang.Object)
/*
* (non-Javadoc)
- *
+ *
* @see eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionElement#
* createControls(eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement, int)
*/
public void createControls(ICdmFormElement element, int style) {
selection_taxon = formFactory
.createSelectionElement(Taxon.class,
- getConversationHolder(), element, "Taxon", null,
+// getConversationHolder(),
+ element, "Taxon", null,
EntitySelectionElement.NOTHING, style);
}
/*
* (non-Javadoc)
- *
+ *
* @see
* eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionElement#handleEvent
* (java.lang.Object)
getTaxonRelationshipTypeInverseContainer(), style);
combo_taxonRelationshipType.setEnabled(false);
selection_relatedTaxon = formFactory.createSelectionElement(
- Taxon.class, getConversationHolder(),
+ Taxon.class, //getConversationHolder(),
formElement, "Related Taxon", getRelatedTaxon(),
EntitySelectionElement.SELECTABLE, style);
checkBoxDoubtful = formFactory.createCheckbox(formElement, "Relation is doubtful", entity.isDoubtful(), style);
addControl(taxonElement);
addElement(taxonElement);
- sensuReference = formFactory.createSelectionElement(Reference.class,
- getConversationHolder(), formElement, "Sensu",
+ sensuReference = formFactory.createSelectionElement(Reference.class,//getConversationHolder(),
+ formElement, "Sensu",
taxon.getSec(), EntitySelectionElement.ALL,
style);
taxon.getSecMicroReference(),null,
SWT.WRAP);
- secReference = formFactory.createSelectionElement(Reference.class,
- getConversationHolder(), formElement, "Misappl. Sec.",
+ secReference = formFactory.createSelectionElement(Reference.class,//getConversationHolder(),
+ formElement, "Misappl. Sec.",
entity.getCitation(), EntitySelectionElement.ALL,
style);
import eu.etaxonomy.cdm.model.taxon.TaxonBase;
import eu.etaxonomy.cdm.model.taxon.TaxonRelationship;
import eu.etaxonomy.taxeditor.model.ImageResources;
-import eu.etaxonomy.taxeditor.ui.dialog.selection.NameSelectionDialog;
import eu.etaxonomy.taxeditor.ui.dialog.selection.TaxonBaseSelectionDialog;
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailElement;
import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailSection;
import eu.etaxonomy.taxeditor.ui.section.ITaxonBaseDetailSection;
-import eu.etaxonomy.taxeditor.ui.section.name.NonViralNameDetailSection;
/**
* @author n.hoffmann
@Override
public String getHeading() {
-
+
return getEntity() != null ? StringUtils.replace( getEntity().getType().getLabel(), "for", ""): "Taxon Relation";
}
public TaxonBase getTaxonBase() {
return taxon;
}
-
+
private void setName(TaxonName name){
this.name = name;
}
-
+
@Override
protected Control createToolbar() {
ToolBarManager toolBarManager = new ToolBarManager(SWT.FLAT);
Action chooseTaxonAction = new Action("Choose Taxon", IAction.AS_PUSH_BUTTON){
@Override
public void run() {
- Taxon taxon = TaxonBaseSelectionDialog.selectTaxon(getShell(), getConversationHolder(), getEntity().getFromTaxon());
+ Taxon taxon = TaxonBaseSelectionDialog.selectTaxon(getShell(), //getConversationHolder(),
+ getEntity().getFromTaxon());
if(taxon!=null){
taxon = HibernateProxyHelper.deproxy(taxon);
name = taxon.getName();
rel.setFromTaxon(taxon);
setEntity(rel);
setTaxonBase(taxon);
-
+
firePropertyChangeEvent(TaxonRelationshipDetailSection.this);
}
}
import eu.etaxonomy.taxeditor.ui.selection.EntitySelectionElement;
/**
- *
+ *
* @author n.hoffmann
* @created Mar 10, 2011
* @version 1.0
/*
* (non-Javadoc)
- *
+ *
* @see
* eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionElement#setEntity
* (java.lang.Object)
/*
* (non-Javadoc)
- *
+ *
* @see eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionElement#
* createControls(eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement, int)
*/
@Override
public void createControls(ICdmFormElement element, int style) {
selection_group = formFactory
- .createSelectionElement(Group.class,
- getConversationHolder(), element, "", getEntity(),
+ .createSelectionElement(Group.class,//getConversationHolder(),
+ element, "", getEntity(),
EntitySelectionElement.NOTHING, style);
}
/*
* (non-Javadoc)
- *
+ *
* @see
* eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionElement#handleEvent
* (java.lang.Object)
*/
@Override
public Group createNewElement() {
- Group selectedGroup = GroupSelectionDialog.select(getShell(), getConversationHolder(), null);
+ Group selectedGroup = GroupSelectionDialog.select(getShell(), //getConversationHolder(),
+ null);
return selectedGroup;
}
/**
- *
+ *
*/
package eu.etaxonomy.taxeditor.ui.section.user;
/**
* @author n.hoffmann
- *
+ *
*/
public class UserDetailElement extends AbstractCdmDetailElement<User> {
/*
* (non-Javadoc)
- *
+ *
* @see
* eu.etaxonomy.taxeditor.section.AbstractCdmDetailElement#createControls
* (eu.etaxonomy.taxeditor.forms.ICdmFormElement, java.lang.Object, int)
selection_person = formFactory
.createSelectionElement(Person.class,
- getConversationHolder(),
- formElement,
+ //getConversationHolder(),
+ formElement,
"Person",
- entity.getPerson(),
+ entity.getPerson(),
EntitySelectionElement.EDITABLE | EntitySelectionElement.SELECTABLE,
style);
}
/**
- *
+ *
* @return
*/
private boolean userIsAuthenticated() {
/*
* (non-Javadoc)
- *
+ *
* @see
* eu.etaxonomy.taxeditor.section.AbstractCdmDetailElement#handleEvent(java
* .lang.Object)
package eu.etaxonomy.taxeditor.ui.selection;
-import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
import eu.etaxonomy.cdm.model.taxon.Classification;
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
public class ClassificationSelectionElement extends EntitySelectionElement<Classification> {
- public ClassificationSelectionElement(CdmFormFactory formFactory,
- ConversationHolder conversation, ICdmFormElement parentElement,
+ public ClassificationSelectionElement(CdmFormFactory formFactory,//ConversationHolder conversation, #
+ ICdmFormElement parentElement,
Class<Classification> clazz, String labelString,
Classification entity, int mode, int style) {
- super(formFactory, conversation, parentElement, clazz, labelString, entity,
+ super(formFactory, //conversation,
+ parentElement, clazz, labelString, entity,
mode, style);
-
+
}
}
import eu.etaxonomy.cdm.model.common.User;
import eu.etaxonomy.cdm.model.molecular.Amplification;
import eu.etaxonomy.cdm.model.molecular.Primer;
-import eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap;
+import eu.etaxonomy.cdm.model.reference.Reference;
import eu.etaxonomy.cdm.persistence.hibernate.permission.CRUD;
import eu.etaxonomy.taxeditor.model.ImageResources;
import eu.etaxonomy.taxeditor.preference.Resources;
* @param <T>
*/
public class EntitySelectionElement<T extends CdmBase> extends
- AbstractCdmFormElement implements SelectionListener, IEnableableFormElement, ISelectableElement, IEntityElement<T>, ILabeledElement, IConversationEnabled, Observer {
+ AbstractCdmFormElement implements SelectionListener, IEnableableFormElement, ISelectableElement, IEntityElement<T>, ILabeledElement, //IConversationEnabled,
+ Observer {
private static final EnumSet<CRUD> UPDATE = EnumSet.of(CRUD.UPDATE);
private static final EnumSet<CRUD> DELETE = EnumSet.of(CRUD.DELETE);
/**
* Bitmask for configuring functionality of selection element
*/
- public static final int NOTHING = 0; // 000
- public static final int EDITABLE = 1 << 0; // 001
- public static final int DELETABLE = 1 << 1; // 010
- public static final int SELECTABLE = 1 << 2; // 100
- public static final int ALL = EDITABLE | DELETABLE | SELECTABLE; // 111
-
+ public static final int NOTHING = 0; // 0000
+ public static final int EDITABLE = 1 << 0; // 0001
+ public static final int DELETABLE = 1 << 1; // 0010
+ public static final int SELECTABLE = 1 << 2; // 0100
+ public static final int EXTERNAL = 1 << 3; // 1000
+ public static final int ALL = EDITABLE | DELETABLE | SELECTABLE ; // 0111
+ public static final int ALL_WITH_EXT = EDITABLE | DELETABLE | SELECTABLE | EXTERNAL ; // 1111
protected T entity;
protected T filteredEntity;
protected Text text;
protected Button button_selection;
+ protected Button button_selectionExt;
+
private SelectionArbitrator selectionArbitrator;
protected Button button_edit;
private final boolean isEditable;
private final boolean isDeletable;
+ private final boolean isExternal;
- private final ConversationHolder conversation;
+// private final ConversationHolder conversation;
private Class<T> clazz;
public EntitySelectionElement(CdmFormFactory formFactory,
- ConversationHolder conversation, ICdmFormElement parentElement, Class<T> clazz,
+// ConversationHolder conversation,
+ ICdmFormElement parentElement, Class<T> clazz,
String labelString, T entity, int mode, int style, boolean filterElement) {
super(formFactory, parentElement);
this.clazz = clazz;
this.isEditable = (mode & EDITABLE) == EDITABLE;
this.isDeletable = (mode & DELETABLE) == DELETABLE;
+ this.isExternal= (mode & EXTERNAL) == EXTERNAL;
boolean isSelectable = (mode & SELECTABLE) == SELECTABLE;
this.labelString = (labelString == null || labelString.equals("")) ? "" : labelString;
- this.conversation = conversation;
+// this.conversation = conversation;
if (isSelectable && formFactory.getSelectionProvider() != null) {
selectionArbitrator = formFactory.createSelectionArbitrator(this);
}
- public EntitySelectionElement(CdmFormFactory formFactory,
- ConversationHolder conversation, ICdmFormElement parentElement, Class<T> clazz,
+ public EntitySelectionElement(CdmFormFactory formFactory,//ConversationHolder conversation,
+ ICdmFormElement parentElement, Class<T> clazz,
String labelString, T entity, int mode, int style){
- this(formFactory, conversation, parentElement, clazz, labelString, entity, mode, style, false);
+ this(formFactory, //conversation,
+ parentElement, clazz, labelString, entity, mode, style, false);
}
private void createControls(Composite parent, int style) {
if (isDeletable) {
columns += 1;
}
+ if (isExternal) {
+ columns += 1;
+ }
selectableComposite.setLayout(LayoutConstants.LAYOUT(columns, false));
selectableComposite.setLayoutData(LayoutConstants.FILL_HORIZONTALLY());
addControl(button_selection);
button_selection.addSelectionListener(this);
-
+ if (isExternal){
+ button_selectionExt = formFactory.createButton(selectableComposite, null,
+ SWT.PUSH);
+ button_selectionExt.setImage(ImageResources
+ .getImage(ImageResources.BROWSE_ICON));
+ button_selectionExt.setToolTipText("Browse existing from external cdm store");
+ button_selectionExt.setText("Ext");
+ addControl(button_selectionExt);
+ button_selectionExt.addSelectionListener(this);
+ }
if (isEditable) {
button_edit = formFactory.createButton(selectableComposite, null,
SWT.PUSH);
@Override
public void widgetSelected(SelectionEvent e) {
- T selection = SelectionDialogFactory.getSelectionFromDialog(clazz, getShell(), getConversationHolder(), getFilteredEntity(), getParentElement());
- setSelectionInternal(selection);
+ if (e.getSource().equals(button_selection) ){
+ T selection = SelectionDialogFactory.getSelectionFromDialog(clazz, getShell(), //getConversationHolder(),
+ getFilteredEntity(), getParentElement());
+ setSelectionInternal(selection);
+ }else{
+ Reference selection = SelectionDialogFactory.getSelectionFromExtDialog(Reference.class, getShell(),//null,
+ getParentElement());
+ setSelectionInternal((T)selection);
+ }
+
}
/**
* @return a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder}
* object.
*/
- @Override
+// @Override
public ConversationHolder getConversationHolder() {
- return conversation;
+ if(getParentElement() instanceof IConversationEnabled) {
+ return ((IConversationEnabled)getParentElement()).getConversationHolder();
+ }
+ return null;
}
/** {@inheritDoc} */
}
/** {@inheritDoc} */
- @Override
- public void update(CdmDataChangeMap changeEvents) {
- }
+// @Override
+// public void update(CdmDataChangeMap changeEvents) {
+// }
/* (non-Javadoc)
* @see eu.etaxonomy.taxeditor.ui.element.AbstractCdmFormElement#removeElements()
*/
package eu.etaxonomy.taxeditor.ui.selection;
-import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
import eu.etaxonomy.cdm.model.agent.TeamOrPersonBase;
import eu.etaxonomy.cdm.model.common.CdmBase;
import eu.etaxonomy.cdm.model.reference.Reference;
* @param mode
* @param style
*/
- public EntitySelectionElementWithAbbreviatedTitle(CdmFormFactory formFactory, ConversationHolder conversation,
+ public EntitySelectionElementWithAbbreviatedTitle(CdmFormFactory formFactory,// ConversationHolder conversation,
ICdmFormElement parentElement, Class<T> clazz, String labelString, T entity, int mode, int style) {
- super(formFactory, conversation, parentElement, clazz, labelString, entity, mode, style);
+ super(formFactory, //conversation,
+ parentElement, clazz, labelString, entity, mode, style);
}
@Override
import org.eclipse.swt.events.SelectionEvent;
-import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
import eu.etaxonomy.cdm.model.agent.Team;
import eu.etaxonomy.taxeditor.ui.dialog.selection.NomenclaturalAuthorTeamSelectionDialog;
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
* @param style
* a int.
*/
- public NomenclaturalAuthorTeamSelectionElement(CdmFormFactory formFactory,
- ConversationHolder conversation, ICdmFormElement parentElement,
+ public NomenclaturalAuthorTeamSelectionElement(CdmFormFactory formFactory,//ConversationHolder conversation,
+ ICdmFormElement parentElement,
String labelString, Team entity, int mode, int style) {
- super(formFactory, conversation, parentElement, Team.class, labelString, entity,
+ super(formFactory,// conversation,
+ parentElement, Team.class, labelString, entity,
mode, style);
}
@Override
public void widgetSelected(SelectionEvent e) {
Team newSelection = NomenclaturalAuthorTeamSelectionDialog.select(
- getShell(), getConversationHolder(), entity);
+ getShell(), //getConversationHolder(),
+ entity);
setSelectionInternal(newSelection);
}
}
import org.eclipse.swt.events.SelectionEvent;
-import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
import eu.etaxonomy.cdm.common.CdmUtils;
import eu.etaxonomy.cdm.model.taxon.Classification;
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
private Classification classification;
- public TaxonNodeSelectionElement(CdmFormFactory formFactory,
- ConversationHolder conversation, ICdmFormElement parentElement,
+ public TaxonNodeSelectionElement(CdmFormFactory formFactory,//ConversationHolder conversation,
+ ICdmFormElement parentElement,
String labelString, TaxonNode entity, int mode, int style) {
- super(formFactory, conversation, parentElement, TaxonNode.class, labelString, entity, mode,
+ super(formFactory, //conversation,
+ parentElement, TaxonNode.class, labelString, entity, mode,
style);
}
/** {@inheritDoc} */
@Override
public void widgetSelected(SelectionEvent e) {
- TaxonNode newSelection = TaxonNodeSelectionDialog.select(getShell(),
- getConversationHolder(), "Select parent taxon", null, null, getClassification());
+ TaxonNode newSelection = TaxonNodeSelectionDialog.select(getShell(),//getConversationHolder(),
+ "Select parent taxon", null, null, getClassification());
setSelectionInternal(newSelection);
}
*/
@Override
public void setFocus() {
- tableViewer.getControl().setFocus();
+ if (!tableViewer.getControl().isDisposed()) {
+ tableViewer.getControl().setFocus();
+ }
//make sure to bind again if maybe in another view the conversation was unbound
if(!conversation.isBound()){
conversation.bind();
import javax.inject.Inject;
import javax.inject.Named;
+import org.apache.log4j.Logger;
+import org.apache.lucene.search.similarities.Distribution;
import org.eclipse.e4.core.di.annotations.Optional;
import org.eclipse.e4.ui.di.PersistState;
import org.eclipse.e4.ui.di.UISynchronize;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.swt.SWTException;
+import org.hibernate.proxy.HibernateProxyHelper;
import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
import eu.etaxonomy.cdm.api.conversation.IConversationEnabled;
-import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
import eu.etaxonomy.cdm.model.common.CdmBase;
-import eu.etaxonomy.cdm.model.description.Distribution;
import eu.etaxonomy.cdm.model.taxon.Taxon;
import eu.etaxonomy.cdm.model.taxon.TaxonRelationship;
import eu.etaxonomy.cdm.model.taxon.TaxonRelationshipType;
* If it is <code>true</code> then it is currently delaying a selection.
*/
private boolean isInDelay;
-
+ private static final Logger logger = Logger.getLogger(AbstractCdmEditorPartE4.class);
/**
* This class invokes internal_selectionChanged() in a separate thread.
return;
}
if (viewer != null && viewer.getControl()!= null && viewer.getInput() != null && !viewer.getControl().isDisposed()){
- viewer.getControl().setEnabled(true);
+ try{
+ viewer.getControl().setEnabled(true);
+ }catch(SWTException e){
+ logger.debug("Something went wrong for viewer.getControl().setEnabled(true) in " + this.getClass().getSimpleName(), e);
+ }
+
}
+
+
if(previousSelection==null ||
previousSelection!=selection){//skip redundant rendering of details view
if(delaySelection==null){
Bundle-ManifestVersion: 2
Bundle-Name: eu.etaxonomy.taxeditor.test
Bundle-SymbolicName: eu.etaxonomy.taxeditor.test;singleton:=true
-Bundle-Version: 4.11.4
+Bundle-Version: 4.13.0.qualifier
Bundle-ActivationPolicy: lazy
Bundle-Vendor: EDIT
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
<parent>
<groupId>eu.etaxonomy</groupId>
<artifactId>taxeditor-parent</artifactId>
- <version>4.11.4</version>
+ <version>4.13.0-SNAPSHOT</version>
</parent>
<artifactId>eu.etaxonomy.taxeditor.test</artifactId>
<packaging>eclipse-test-plugin</packaging>
Bundle-ManifestVersion: 2
Bundle-Name: Webapp
Bundle-SymbolicName: eu.etaxonomy.taxeditor.webapp;singleton:=true
-Bundle-Version: 4.11.4
+Bundle-Version: 4.13.0.qualifier
Require-Bundle: org.eclipse.core.runtime
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Bundle-ActivationPolicy: lazy
<parent>
<groupId>eu.etaxonomy</groupId>
<artifactId>taxeditor-parent</artifactId>
- <version>4.11.4</version>
+ <version>4.13.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>eu.etaxonomy.taxeditor.webapp</artifactId>
eu.etaxonomy.taxeditor.workbench,
eu.etaxonomy.taxeditor.workbench.part
Bundle-Name: Workbench Bundle
-Bundle-Version: 4.11.4
+Bundle-Version: 4.13.0.qualifier
Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime,
org.eclipse.e4.ui.workbench,
<parent>
<groupId>eu.etaxonomy</groupId>
<artifactId>taxeditor-parent</artifactId>
- <version>4.11.4</version>
+ <version>4.13.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<?xml version="1.0" encoding="UTF-8"?>
-<?pde version="3.5"?><product application="eu.etaxonomy.taxeditor.application.application" id="eu.etaxonomy.taxeditor.application.eu_etaxonomy_taxeditor_product" includeLaunchers="true" name="EDIT Taxonomic Editor" uid="eu.etaxonomy.taxeditor.product" useFeatures="true" version="4.11.4">
+<?pde version="3.5"?><product application="eu.etaxonomy.taxeditor.application.application" id="eu.etaxonomy.taxeditor.application.eu_etaxonomy_taxeditor_product" includeLaunchers="true" name="EDIT Taxonomic Editor" uid="eu.etaxonomy.taxeditor.product" useFeatures="true" version="4.13.0.qualifier">
<aboutInfo>
<image path="/eu.etaxonomy.taxeditor.application/icons/256color_48x48.gif"/>
<text>
<?xml version="1.0" encoding="UTF-8"?>
<?pde version="3.5"?>
-
-<product name="EDIT Taxonomic Editor" uid="eu.etaxonomy.taxeditor.product.jre" id="eu.etaxonomy.taxeditor.application.eu_etaxonomy_taxeditor_product" application="eu.etaxonomy.taxeditor.application.application" version="4.11.4" useFeatures="true" includeLaunchers="true">
-
+<product name="EDIT Taxonomic Editor" uid="eu.etaxonomy.taxeditor.product.jre" id="eu.etaxonomy.taxeditor.application.eu_etaxonomy_taxeditor_product" application="eu.etaxonomy.taxeditor.application.application" version="4.13.0.qualifier" useFeatures="true" includeLaunchers="true">
<aboutInfo>
<image path="/eu.etaxonomy.taxeditor.application/icons/256color_48x48.gif"/>
<text>
<parent>
<groupId>eu.etaxonomy</groupId>
<artifactId>taxeditor-parent</artifactId>
- <version>4.11.4</version>
+ <version>4.13.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<plugin id="org.eclipse.xtext.xtext.generator.source"/>
<plugin id="org.hamcrest.library"/>
</includeBundles>
-</target>
\ No newline at end of file
+</target>
+
</prerequisites>
<groupId>eu.etaxonomy</groupId>
<artifactId>taxeditor-parent</artifactId>
- <version>4.11.4</version>
+ <version>4.13.0-SNAPSHOT</version>
<name>EDIT Taxonomic Editor</name>
<description>The Taxonomic Editor for EDIT's platform for
cybertaxonomy
<properties>
<java.codelevel>1.8</java.codelevel>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
- <cdmlib.version>4.11.0</cdmlib.version>
+ <cdmlib.version>4.13.0-SNAPSHOT</cdmlib.version>
<!-- TODO can we use project.version ????? -->
<!-- Increasing tycho above 0.22.0 will fail for the macosx build because
for higher version numbers tycho needs to be build against Eclipse Mars or
higher -->
<tycho.version>1.0.0</tycho.version>
- <taxeditor.version>4.11.0</taxeditor.version>
+ <taxeditor.version>4.13.0-SNAPSHOT</taxeditor.version>
<update.dir>snapshot</update.dir>
<unitils.version>3.4.2</unitils.version>
<log4j.version>1.2.17</log4j.version>