From c92857457dddcad7761ce9dd2644259947360768 Mon Sep 17 00:00:00 2001 From: Cherian Mathew Date: Wed, 20 May 2015 12:24:16 +0000 Subject: [PATCH] InspectSessionsDialog : added filtering CdmStore : clearing caches and session before connecting ParseHandler : using NonViralName instead of TaxonNameBase AbstractPostTaxonOperation, AbstractPostOperation, AbstractPersistentPostOperation : added CdmEntitySessionEnabled object to constructor NewTaxonNodeWizard : explicitly fire changes --- .../newWizard/NewTaxonNodeWizard.java | 8 +- .../AbstractPersistentPostOperation.java | 20 +-- .../operation/AbstractPostOperation.java | 50 +++++- .../operation/AbstractPostTaxonOperation.java | 145 ++++++++++-------- .../taxeditor/parser/ParseHandler.java | 10 +- .../etaxonomy/taxeditor/store/CdmStore.java | 22 ++- .../view/sessions/InspectSessionsDialog.java | 67 +++++--- .../AbstractTaxeditorOperationTestBase.java | 14 +- 8 files changed, 216 insertions(+), 120 deletions(-) diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/newWizard/NewTaxonNodeWizard.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/newWizard/NewTaxonNodeWizard.java index e2dcdb6ff..6c7f7161c 100644 --- a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/newWizard/NewTaxonNodeWizard.java +++ b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/newWizard/NewTaxonNodeWizard.java @@ -3,12 +3,15 @@ */ package eu.etaxonomy.taxeditor.newWizard; +import java.util.HashSet; +import java.util.Set; import java.util.UUID; import org.apache.commons.lang.StringUtils; import eu.etaxonomy.cdm.api.service.IClassificationService; import eu.etaxonomy.cdm.api.service.ITaxonNodeService; +import eu.etaxonomy.cdm.model.common.CdmBase; import eu.etaxonomy.cdm.model.taxon.Classification; import eu.etaxonomy.cdm.model.taxon.ITaxonTreeNode; import eu.etaxonomy.cdm.model.taxon.Taxon; @@ -49,7 +52,10 @@ public class NewTaxonNodeWizard extends AbstractNewEntityWizard{ TaxonNode taxonNode = parent.addChildTaxon(taxon, parent.getReference(), parent.getMicroReference()); taxonNode = CdmStore.getService(ITaxonNodeService.class).merge(taxonNode); generatedTaxonNodeUuid = taxonNode.getUuid(); - CdmStore.getCurrentSessionManager().getActiveSession().addEvent(taxonNode, EventType.INSERT); + Set affectedObjects = new HashSet(); + affectedObjects.add((TaxonNode)parent); + CdmStore.getCurrentSessionManager().getActiveSession().addEvent(taxonNode, affectedObjects, EventType.INSERT); + CdmStore.getCurrentSessionManager().getActiveSession().fireNotifications(); }catch(IllegalArgumentException e){ MessagingUtils.warningDialog("Taxon already exists in classfication", getClass(), e.getMessage()); } diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/operation/AbstractPersistentPostOperation.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/operation/AbstractPersistentPostOperation.java index 09a2a532a..5811603ba 100644 --- a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/operation/AbstractPersistentPostOperation.java +++ b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/operation/AbstractPersistentPostOperation.java @@ -33,7 +33,7 @@ import eu.etaxonomy.taxeditor.session.ICdmEntitySessionEnabled; */ public abstract class AbstractPersistentPostOperation extends AbstractPostTaxonOperation { private final IConversationEnabled conversationEnabled; - private final ICdmEntitySessionEnabled cdmEntitySessionEnabled; + protected ITaxonTreeNode parentNode; /** @@ -48,9 +48,8 @@ public abstract class AbstractPersistentPostOperation extends AbstractPostTaxonO IPostOperationEnabled postOperationEnabled, IConversationEnabled conversationEnabled, ICdmEntitySessionEnabled cdmEntitySessionEnabled) { - super(label, undoContext, postOperationEnabled); + super(label, undoContext, postOperationEnabled, cdmEntitySessionEnabled); this.conversationEnabled = conversationEnabled; - this.cdmEntitySessionEnabled = cdmEntitySessionEnabled; } /** @@ -67,9 +66,9 @@ public abstract class AbstractPersistentPostOperation extends AbstractPostTaxonO IPostOperationEnabled postOperationEnabled, IConversationEnabled conversationEnabled, ICdmEntitySessionEnabled cdmEntitySessionEnabled) { - super(label, undoContext, taxonNode, postOperationEnabled); + super(label, undoContext, taxonNode, postOperationEnabled, cdmEntitySessionEnabled); this.conversationEnabled = conversationEnabled; - this.cdmEntitySessionEnabled = cdmEntitySessionEnabled; + } /** @@ -86,10 +85,10 @@ public abstract class AbstractPersistentPostOperation extends AbstractPostTaxonO IPostOperationEnabled postOperationEnabled, IConversationEnabled conversationEnabled, ICdmEntitySessionEnabled cdmEntitySessionEnabled) { - super(label, undoContext, postOperationEnabled); + super(label, undoContext, postOperationEnabled, cdmEntitySessionEnabled); this.parentNode = parentNode; this.conversationEnabled = conversationEnabled; - this.cdmEntitySessionEnabled = cdmEntitySessionEnabled; + } /* (non-Javadoc) @@ -105,8 +104,8 @@ public abstract class AbstractPersistentPostOperation extends AbstractPostTaxonO conversationEnabled.getConversationHolder().bind(); conversationEnabled.getConversationHolder().commit(true); } - if(cdmEntitySessionEnabled != null) { - cdmEntitySessionEnabled.getCdmEntitySession().fireNotifications(); + if(getCdmEntitySessionEnabled() != null) { + getCdmEntitySessionEnabled().getCdmEntitySession().fireNotifications(); } IStatus status = super.postExecute(objectAffectedByOperation); @@ -118,6 +117,9 @@ public abstract class AbstractPersistentPostOperation extends AbstractPostTaxonO */ public void bind(){ conversationEnabled.getConversationHolder().bind(); + if(getCdmEntitySessionEnabled() != null) { + getCdmEntitySessionEnabled().getCdmEntitySession().bind(); + } } } diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/operation/AbstractPostOperation.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/operation/AbstractPostOperation.java index 5b7c68ec8..c313d1f0f 100644 --- a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/operation/AbstractPostOperation.java +++ b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/operation/AbstractPostOperation.java @@ -16,6 +16,7 @@ import org.eclipse.core.runtime.Status; import eu.etaxonomy.cdm.model.common.CdmBase; import eu.etaxonomy.cdm.model.common.ICdmBase; +import eu.etaxonomy.taxeditor.session.ICdmEntitySessionEnabled; /** * @author pplitzner @@ -35,6 +36,8 @@ public abstract class AbstractPostOperation extends Abstract */ protected IPostOperationEnabled postOperationEnabled; + private ICdmEntitySessionEnabled cdmEntitySessionEnabled; + /** *

Constructor for AbstractPostOperation.

@@ -71,6 +74,15 @@ public abstract class AbstractPostOperation extends Abstract this.postOperationEnabled = postOperationEnabled; } + public AbstractPostOperation(String label, IUndoContext undoContext, + T element, IPostOperationEnabled postOperationEnabled, + ICdmEntitySessionEnabled cdmEntitySessionEnabled) { + this(label, undoContext); + this.element = element; + this.postOperationEnabled = postOperationEnabled; + this.cdmEntitySessionEnabled = cdmEntitySessionEnabled; + } + /** * This method will try to call the post operation on a possibly registered * IPostOperationEnabled implementor. Objects that were affected by the operation @@ -80,10 +92,11 @@ public abstract class AbstractPostOperation extends Abstract * @return a {@link org.eclipse.core.runtime.IStatus} object. */ protected IStatus postExecute(CdmBase objectAffectedByOperation) { - if(postOperationEnabled != null){ - return postOperationEnabled.postOperation(objectAffectedByOperation) ? Status.OK_STATUS : Status.CANCEL_STATUS; - } - return Status.OK_STATUS; + + if(postOperationEnabled != null){ + return postOperationEnabled.postOperation(objectAffectedByOperation) ? Status.OK_STATUS : Status.CANCEL_STATUS; + } + return Status.OK_STATUS; } /** @@ -92,7 +105,34 @@ public abstract class AbstractPostOperation extends Abstract * @return a {@link eu.etaxonomy.taxeditor.operation.IPostOperationEnabled} object. */ public IPostOperationEnabled getPostOperationEnabled() { - return postOperationEnabled; + return postOperationEnabled; + } + +// protected IStatus updateSession(CdmBase clientObjectAffectedByOperation, UpdateResult updateResult) { +// Set affectedObjects; +// if(updateResult == null) { +// affectedObjects = new HashSet(); +// } else { +// affectedObjects = updateResult.getUpdatedObjects(); +// } +// +// if(cdmEntitySessionEnabled != null) { +// cdmEntitySessionEnabled.getCdmEntitySession().update(clientObjectAffectedByOperation, affectedObjects); +// } +// return Status.OK_STATUS; +// } +// +// protected IStatus updateSession(UUID uuid) { +// +// if(cdmEntitySessionEnabled != null) { +// CdmBase cdmBase = cdmEntitySessionEnabled.getCdmEntitySession().remoteLoad(CdmStore.getService(IService.class),uuid); +// cdmEntitySessionEnabled.getCdmEntitySession().update(null, cdmBase); +// } +// return Status.OK_STATUS; +// } + + public ICdmEntitySessionEnabled getCdmEntitySessionEnabled() { + return cdmEntitySessionEnabled; } } \ No newline at end of file diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/operation/AbstractPostTaxonOperation.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/operation/AbstractPostTaxonOperation.java index b37c54010..6604f27bb 100644 --- a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/operation/AbstractPostTaxonOperation.java +++ b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/operation/AbstractPostTaxonOperation.java @@ -1,11 +1,11 @@ /** -* Copyright (C) 2007 EDIT -* European Distributed Institute of Taxonomy -* http://www.e-taxonomy.eu -* -* The contents of this file are subject to the Mozilla Public License Version 1.1 -* See LICENSE.TXT at the top of this package for the full license terms. -*/ + * Copyright (C) 2007 EDIT + * European Distributed Institute of Taxonomy + * http://www.e-taxonomy.eu + * + * The contents of this file are subject to the Mozilla Public License Version 1.1 + * See LICENSE.TXT at the top of this package for the full license terms. + */ package eu.etaxonomy.taxeditor.operation; @@ -16,6 +16,7 @@ import org.eclipse.core.commands.operations.IUndoContext; import eu.etaxonomy.cdm.model.taxon.ITaxonTreeNode; import eu.etaxonomy.cdm.model.taxon.Taxon; import eu.etaxonomy.cdm.model.taxon.TaxonNode; +import eu.etaxonomy.taxeditor.session.ICdmEntitySessionEnabled; /** *

Abstract AbstractPostOperation class.

@@ -27,64 +28,78 @@ import eu.etaxonomy.cdm.model.taxon.TaxonNode; */ public abstract class AbstractPostTaxonOperation extends AbstractPostOperation { - /** - * A reference to the taxons TaxonNode - */ - protected ITaxonTreeNode taxonNode; - - protected UUID parentNodeUuid; - - - /** - *

Constructor for AbstractPostOperation.

- * - * @param label a {@link java.lang.String} object. - * @param undoContext a {@link org.eclipse.core.commands.operations.IUndoContext} object. - * @param taxon a {@link eu.etaxonomy.cdm.model.taxon.Taxon} object. - * @param postOperationEnabled a {@link eu.etaxonomy.taxeditor.operation.IPostOperationEnabled} object. - */ - public AbstractPostTaxonOperation(String label, IUndoContext undoContext, - Taxon taxon, IPostOperationEnabled postOperationEnabled) { - super(label, undoContext, taxon, postOperationEnabled); - } - - /** - *

Constructor for AbstractPostOperation.

- * - * @param label a {@link java.lang.String} object. - * @param undoContext a {@link org.eclipse.core.commands.operations.IUndoContext} object. - * @param taxonNode a {@link eu.etaxonomy.cdm.model.taxon.TaxonNode} object. - * @param postOperationEnabled a {@link eu.etaxonomy.taxeditor.operation.IPostOperationEnabled} object. - */ - public AbstractPostTaxonOperation(String label, IUndoContext undoContext, TaxonNode taxonNode, IPostOperationEnabled postOperationEnabled){ - this(label, undoContext, taxonNode.getTaxon(), postOperationEnabled); - this.taxonNode = taxonNode; - } - - /** - *

Constructor for AbstractPostOperation.

- * - * @param label a {@link java.lang.String} object. - * @param undoContext a {@link org.eclipse.core.commands.operations.IUndoContext} object. - * @param parentNodeUuid a {@link java.util.UUID} object. - * @param postOperationEnabled a {@link eu.etaxonomy.taxeditor.operation.IPostOperationEnabled} object. - */ - public AbstractPostTaxonOperation(String label, IUndoContext undoContext, UUID parentNodeUuid, IPostOperationEnabled postOperationEnabled){ - super(label, undoContext, null, postOperationEnabled); - this.parentNodeUuid = parentNodeUuid; - } - - /** - *

Constructor for AbstractPostOperation.

- * - * @param label a {@link java.lang.String} object. - * @param undoContext a {@link org.eclipse.core.commands.operations.IUndoContext} object. - * @param postOperationEnabled a {@link eu.etaxonomy.taxeditor.operation.IPostOperationEnabled} object. - */ - public AbstractPostTaxonOperation(String label, IUndoContext undoContext, - IPostOperationEnabled postOperationEnabled) { - super(label, undoContext, null, postOperationEnabled); - } + /** + * A reference to the taxons TaxonNode + */ + protected ITaxonTreeNode taxonNode; + + protected UUID parentNodeUuid; + + + /** + *

Constructor for AbstractPostOperation.

+ * + * @param label a {@link java.lang.String} object. + * @param undoContext a {@link org.eclipse.core.commands.operations.IUndoContext} object. + * @param taxon a {@link eu.etaxonomy.cdm.model.taxon.Taxon} object. + * @param postOperationEnabled a {@link eu.etaxonomy.taxeditor.operation.IPostOperationEnabled} object. + */ + public AbstractPostTaxonOperation(String label, IUndoContext undoContext, + Taxon taxon, IPostOperationEnabled postOperationEnabled) { + super(label, undoContext, taxon, postOperationEnabled, null); + } + + public AbstractPostTaxonOperation(String label, IUndoContext undoContext, + Taxon taxon, IPostOperationEnabled postOperationEnabled, ICdmEntitySessionEnabled cdmEntitySessionEnabled) { + super(label, undoContext, taxon, postOperationEnabled, cdmEntitySessionEnabled); + } + + /** + *

Constructor for AbstractPostOperation.

+ * + * @param label a {@link java.lang.String} object. + * @param undoContext a {@link org.eclipse.core.commands.operations.IUndoContext} object. + * @param taxonNode a {@link eu.etaxonomy.cdm.model.taxon.TaxonNode} object. + * @param postOperationEnabled a {@link eu.etaxonomy.taxeditor.operation.IPostOperationEnabled} object. + */ + public AbstractPostTaxonOperation(String label, IUndoContext undoContext, TaxonNode taxonNode, IPostOperationEnabled postOperationEnabled){ + this(label, undoContext, taxonNode, postOperationEnabled, null); + } + + public AbstractPostTaxonOperation(String label, IUndoContext undoContext, TaxonNode taxonNode, IPostOperationEnabled postOperationEnabled, ICdmEntitySessionEnabled cdmEntitySessionEnabled){ + this(label, undoContext, taxonNode.getTaxon(), postOperationEnabled, cdmEntitySessionEnabled); + this.taxonNode = taxonNode; + } + + /** + *

Constructor for AbstractPostOperation.

+ * + * @param label a {@link java.lang.String} object. + * @param undoContext a {@link org.eclipse.core.commands.operations.IUndoContext} object. + * @param parentNodeUuid a {@link java.util.UUID} object. + * @param postOperationEnabled a {@link eu.etaxonomy.taxeditor.operation.IPostOperationEnabled} object. + */ + public AbstractPostTaxonOperation(String label, IUndoContext undoContext, UUID parentNodeUuid, IPostOperationEnabled postOperationEnabled){ + super(label, undoContext, null, postOperationEnabled, null); + this.parentNodeUuid = parentNodeUuid; + } + + /** + *

Constructor for AbstractPostOperation.

+ * + * @param label a {@link java.lang.String} object. + * @param undoContext a {@link org.eclipse.core.commands.operations.IUndoContext} object. + * @param postOperationEnabled a {@link eu.etaxonomy.taxeditor.operation.IPostOperationEnabled} object. + */ + public AbstractPostTaxonOperation(String label, IUndoContext undoContext, + IPostOperationEnabled postOperationEnabled) { + super(label, undoContext, null, postOperationEnabled, null); + } + + public AbstractPostTaxonOperation(String label, IUndoContext undoContext, + IPostOperationEnabled postOperationEnabled, ICdmEntitySessionEnabled cdmEntitySessionEnabled) { + super(label, undoContext, null, postOperationEnabled, cdmEntitySessionEnabled); + } /** * @param text diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/parser/ParseHandler.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/parser/ParseHandler.java index 0bae265df..2059f5d7a 100644 --- a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/parser/ParseHandler.java +++ b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/parser/ParseHandler.java @@ -89,8 +89,8 @@ public class ParseHandler{ * @param unparsedNameString a {@link java.lang.String} object. * @return a {@link eu.etaxonomy.cdm.model.name.TaxonNameBase} object. */ - public static TaxonNameBase parseReferencedName(String unparsedNameString, Rank rank){ - TaxonNameBase name = nonViralNameParser.parseReferencedName(unparsedNameString, + public static NonViralName parseReferencedName(String unparsedNameString, Rank rank){ + NonViralName name = nonViralNameParser.parseReferencedName(unparsedNameString, PreferencesUtil.getPreferredNomenclaturalCode(), rank); // if (name.hasProblem()) { @@ -100,8 +100,8 @@ public class ParseHandler{ return name; } - public static TaxonNameBase parseName(String unparsedNameString, Rank rank){ - TaxonNameBase name = nonViralNameParser.parseFullName(unparsedNameString, + public static NonViralName parseName(String unparsedNameString, Rank rank){ + NonViralName name = nonViralNameParser.parseFullName(unparsedNameString, PreferencesUtil.getPreferredNomenclaturalCode(), rank); return name; @@ -113,7 +113,7 @@ public class ParseHandler{ * * @return a {@link eu.etaxonomy.cdm.model.name.TaxonNameBase} object. */ - public static TaxonNameBase createEmptyName(){ + public static NonViralName createEmptyName(){ return nonViralNameParser.getNonViralNameInstance("", PreferencesUtil.getPreferredNomenclaturalCode()); } diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/store/CdmStore.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/store/CdmStore.java index 89a898b8a..e04649168 100644 --- a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/store/CdmStore.java +++ b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/store/CdmStore.java @@ -25,8 +25,6 @@ import org.springframework.security.core.Authentication; import org.springframework.security.core.context.SecurityContext; import org.springframework.security.core.context.SecurityContextHolder; - -import eu.etaxonomy.cdm.api.application.CdmApplicationRemoteConfiguration; import eu.etaxonomy.cdm.api.application.CdmApplicationRemoteController; import eu.etaxonomy.cdm.api.application.ICdmApplicationConfiguration; import eu.etaxonomy.cdm.api.conversation.ConversationHolder; @@ -45,7 +43,7 @@ import eu.etaxonomy.taxeditor.io.ImportManager; import eu.etaxonomy.taxeditor.model.AbstractUtility; import eu.etaxonomy.taxeditor.model.MessagingUtils; import eu.etaxonomy.taxeditor.preference.PreferencesUtil; - +import eu.etaxonomy.taxeditor.remoting.cache.CdmRemoteCacheManager; import eu.etaxonomy.taxeditor.session.ICdmEntitySessionManager; import eu.etaxonomy.taxeditor.session.mock.MockCdmEntitySessionManager; import eu.etaxonomy.taxeditor.store.internal.TaxeditorStorePlugin; @@ -91,7 +89,7 @@ public class CdmStore { private ICdmSource cdmSource; private boolean isConnected; - + /** @@ -120,6 +118,7 @@ public class CdmStore { ICdmSource cdmSource; try { + cdmSource = CdmDataSourceRepository.getCurrentCdmSource(); connect(cdmSource); } catch (Exception e) { @@ -150,6 +149,13 @@ public class CdmStore { private static void connect(final ICdmSource cdmSource, final DbSchemaValidation dbSchemaValidation, final Resource applicationContextBean) { + if(isActive()) { + // before we connect we clear the caches and the sessions + CdmRemoteCacheManager.getInstance().getDefaultCacheManager().removalAll(); + if(getCurrentSessionManager() != null) { + getCurrentSessionManager().disposeAll(); + } + } MessagingUtils.info("Connecting to datasource: " + cdmSource); job = new CdmStoreConnector(Display.getDefault(), cdmSource, @@ -256,10 +262,10 @@ public class CdmStore { } return conversation; } - + //FIXME:Remoting should be removed after moving completely to remoting private MockCdmEntitySessionManager mockCdmEntitySessionManager; - + private ICdmEntitySessionManager getSessionManager() { //FIXME:Remoting we should only have CdmApplicationRemoteConfiguration after move to remoting // bad hack which should be finally removed @@ -269,10 +275,10 @@ public class CdmStore { if(mockCdmEntitySessionManager == null) { mockCdmEntitySessionManager = new MockCdmEntitySessionManager(); } - return mockCdmEntitySessionManager; + return mockCdmEntitySessionManager; } } - + public static ICdmEntitySessionManager getCurrentSessionManager() { if (getDefault() != null) { return getDefault().getSessionManager(); diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/sessions/InspectSessionsDialog.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/sessions/InspectSessionsDialog.java index 82db7c539..003ecb215 100644 --- a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/sessions/InspectSessionsDialog.java +++ b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/sessions/InspectSessionsDialog.java @@ -1,12 +1,12 @@ // $Id$ /** -* Copyright (C) 2015 EDIT -* European Distributed Institute of Taxonomy -* http://www.e-taxonomy.eu -* -* The contents of this file are subject to the Mozilla Public License Version 1.1 -* See LICENSE.TXT at the top of this package for the full license terms. -*/ + * Copyright (C) 2015 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.view.sessions; import java.util.List; @@ -14,6 +14,7 @@ import java.util.List; import net.sf.ehcache.Cache; import net.sf.ehcache.Element; +import org.eclipse.jface.viewers.ILabelProvider; import org.eclipse.jface.viewers.ITreeContentProvider; import org.eclipse.jface.viewers.StyledCellLabelProvider; import org.eclipse.jface.viewers.StyledString; @@ -24,6 +25,7 @@ import org.eclipse.swt.SWT; import org.eclipse.swt.custom.SashForm; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.graphics.Image; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Button; @@ -33,7 +35,8 @@ import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Text; -import org.eclipse.swt.widgets.Tree; +import org.eclipse.ui.dialogs.FilteredTree; +import org.eclipse.ui.dialogs.PatternFilter; import org.eclipse.wb.swt.SWTResourceManager; import eu.etaxonomy.taxeditor.remoting.cache.CdmModelFieldPropertyFromClass; @@ -111,21 +114,25 @@ public class InspectSessionsDialog extends Dialog { sashForm = new SashForm(shlInspectSessions, SWT.VERTICAL); sashForm.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); - treeViewer = new TreeViewer(sashForm, SWT.BORDER); - Tree tree = treeViewer.getTree(); + PatternFilter filter = new PatternFilter(); + FilteredTree tree = new FilteredTree(sashForm, SWT.MULTI | SWT.H_SCROLL | SWT.BORDER + | SWT.V_SCROLL, filter, true); + treeViewer = tree.getViewer(); + //treeViewer = new TreeViewer(sashForm, SWT.BORDER); + //Tree tree = treeViewer.getTree(); - compositeDebug = new Composite(sashForm, SWT.NONE); - compositeDebug.setLayout(new GridLayout(1, false)); + compositeDebug = new Composite(sashForm, SWT.NONE); + compositeDebug.setLayout(new GridLayout(1, false)); - lblDebugInformation = new Label(compositeDebug, SWT.NONE); - lblDebugInformation.setAlignment(SWT.CENTER); - lblDebugInformation.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, true, false, 1, 1)); - lblDebugInformation.setFont(SWTResourceManager.getFont("Ubuntu", 10, SWT.NORMAL)); - lblDebugInformation.setText("Debug Information"); + lblDebugInformation = new Label(compositeDebug, SWT.NONE); + lblDebugInformation.setAlignment(SWT.CENTER); + lblDebugInformation.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, true, false, 1, 1)); + lblDebugInformation.setFont(SWTResourceManager.getFont("Ubuntu", 10, SWT.NORMAL)); + lblDebugInformation.setText("Debug Information"); - txtDebugInfo = new Text(compositeDebug, SWT.BORDER | SWT.READ_ONLY | SWT.H_SCROLL | SWT.V_SCROLL | SWT.CANCEL | SWT.MULTI); - txtDebugInfo.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); - sashForm.setWeights(new int[] {338, 184}); + txtDebugInfo = new Text(compositeDebug, SWT.BORDER | SWT.READ_ONLY | SWT.H_SCROLL | SWT.V_SCROLL | SWT.CANCEL | SWT.MULTI); + txtDebugInfo.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); + sashForm.setWeights(new int[] {338, 184}); btnClose = new Button(shlInspectSessions, SWT.NONE); btnClose.addSelectionListener(new SelectionAdapter() { @@ -221,7 +228,7 @@ public class InspectSessionsDialog extends Dialog { } - class SessionsTreeLabelProvider extends StyledCellLabelProvider { + class SessionsTreeLabelProvider extends StyledCellLabelProvider implements ILabelProvider { @Override public void update(ViewerCell cell) { @@ -234,6 +241,24 @@ public class InspectSessionsDialog extends Dialog { cell.setStyleRanges(text.getStyleRanges()); super.update(cell); } + + /* (non-Javadoc) + * @see org.eclipse.jface.viewers.ILabelProvider#getImage(java.lang.Object) + */ + @Override + public Image getImage(Object element) { + // TODO Auto-generated method stub + return null; + } + + /* (non-Javadoc) + * @see org.eclipse.jface.viewers.ILabelProvider#getText(java.lang.Object) + */ + @Override + public String getText(Object element) { + CdmEntityInfo cei = (CdmEntityInfo)element; + return cei.getLabel(); + } } } diff --git a/eu.etaxonomy.taxeditor.store/src/test/java/eu/etaxonomy/taxeditor/store/operations/AbstractTaxeditorOperationTestBase.java b/eu.etaxonomy.taxeditor.store/src/test/java/eu/etaxonomy/taxeditor/store/operations/AbstractTaxeditorOperationTestBase.java index 0bef7f3e8..8e6ea3704 100644 --- a/eu.etaxonomy.taxeditor.store/src/test/java/eu/etaxonomy/taxeditor/store/operations/AbstractTaxeditorOperationTestBase.java +++ b/eu.etaxonomy.taxeditor.store/src/test/java/eu/etaxonomy/taxeditor/store/operations/AbstractTaxeditorOperationTestBase.java @@ -1,9 +1,9 @@ // $Id$ /** * Copyright (C) 2007 EDIT -* European Distributed Institute of Taxonomy +* European Distributed Institute of Taxonomy * http://www.e-taxonomy.eu -* +* * The contents of this file are subject to the Mozilla Public License Version 1.1 * See LICENSE.TXT at the top of this package for the full license terms. */ @@ -17,6 +17,7 @@ import org.eclipse.core.runtime.IProgressMonitor; import eu.etaxonomy.cdm.model.taxon.Taxon; import eu.etaxonomy.taxeditor.operation.AbstractPostOperation; import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled; +import eu.etaxonomy.taxeditor.session.ICdmEntitySessionEnabled; /** * @author n.hoffmann @@ -24,13 +25,14 @@ import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled; * @version 1.0 */ public abstract class AbstractTaxeditorOperationTestBase { - + public static final IUndoContext undoContext = null; - + public static final IProgressMonitor monitor = null; - public static final IAdaptable info = null; + public static final IAdaptable info = null; public static final IPostOperationEnabled postOperation = null; - + public static final ICdmEntitySessionEnabled cdmEntitySessionEnabled = null; + protected static AbstractPostOperation operation; protected static Taxon taxon; } -- 2.34.1