3 * Copyright (C) 2013 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
7 * The contents of this file are subject to the Mozilla Public License Version 1.1
8 * See LICENSE.TXT at the top of this package for the full license terms.
10 package eu
.etaxonomy
.taxeditor
.view
.derivateSearch
;
12 import java
.util
.Collection
;
13 import java
.util
.List
;
16 import org
.eclipse
.core
.runtime
.IProgressMonitor
;
17 import org
.eclipse
.jface
.action
.MenuManager
;
18 import org
.eclipse
.swt
.widgets
.Composite
;
19 import org
.eclipse
.swt
.widgets
.Control
;
20 import org
.eclipse
.swt
.widgets
.Menu
;
21 import org
.eclipse
.ui
.IMemento
;
22 import org
.eclipse
.ui
.part
.ViewPart
;
24 import eu
.etaxonomy
.cdm
.api
.conversation
.ConversationHolder
;
25 import eu
.etaxonomy
.cdm
.model
.common
.CdmBase
;
26 import eu
.etaxonomy
.cdm
.model
.occurrence
.SpecimenOrObservationBase
;
27 import eu
.etaxonomy
.taxeditor
.model
.IContextListener
;
28 import eu
.etaxonomy
.taxeditor
.session
.ICdmEntitySession
;
29 import eu
.etaxonomy
.taxeditor
.session
.ICdmEntitySessionEnabled
;
30 import eu
.etaxonomy
.taxeditor
.store
.CdmStore
;
33 * This view allows to search for and filter {@link SpecimenOrObservationBase}s and display
34 * the results in a list. The results can be selected and opened in an editor.
36 public class DerivateSearchView
extends ViewPart
implements IContextListener
, ICdmEntitySessionEnabled
{
38 public static final String ID
= "eu.etaxonomy.taxeditor.view.derivateSearch.DerivateSearchView";
39 private DerivateSearchCompositeController derivateSearchCompositeController
;
40 private ConversationHolder conversationHolder
;
41 private ICdmEntitySession cdmEntitySession
;
44 * Constructs a new DerivateSearchView and registers it to listen to context changes
46 public DerivateSearchView() {
47 CdmStore
.getContextManager().addContextListener(this);
51 public void createPartControl(Composite parent
) {
53 derivateSearchCompositeController
= new DerivateSearchCompositeController(parent
, this);
54 getSite().setSelectionProvider(derivateSearchCompositeController
.getResultViewer());
55 derivateSearchCompositeController
.setEnabled(CdmStore
.isActive());
58 MenuManager menuManager
= new MenuManager();
59 getSite().registerContextMenu(menuManager
, derivateSearchCompositeController
.getResultViewer());
60 Control control
= derivateSearchCompositeController
.getResultViewer().getControl();
61 Menu menu
= menuManager
.createContextMenu(control
);
62 control
.setMenu(menu
);
66 public void setFocus() {
67 derivateSearchCompositeController
.setFocus();
68 //make sure to bind again if maybe in another view the conversation was unbound
69 if(getConversationHolder()!=null && !getConversationHolder().isClosed() && !getConversationHolder().isBound()){
70 getConversationHolder().bind();
72 if(getCdmEntitySession() != null) {
73 getCdmEntitySession().bind();
78 public void contextAboutToStop(IMemento memento
, IProgressMonitor monitor
) {
82 public void contextStop(IMemento memento
, IProgressMonitor monitor
) {
83 derivateSearchCompositeController
.setEnabled(false);
84 derivateSearchCompositeController
.reset();
88 public void contextStart(IMemento memento
, IProgressMonitor monitor
) {
89 derivateSearchCompositeController
.setEnabled(true);
93 public void contextRefresh(IProgressMonitor monitor
) {
98 private void initSession() {
99 if(CdmStore
.isActive() && cdmEntitySession
== null) {
100 cdmEntitySession
= CdmStore
.getCurrentSessionManager().newSession(this, true);
104 private void initConversation(){
105 if(conversationHolder
==null){
106 conversationHolder
= CdmStore
.createConversation();
107 derivateSearchCompositeController
.setConversation(conversationHolder
);
112 public void workbenchShutdown(IMemento memento
, IProgressMonitor monitor
) {
115 public ConversationHolder
getConversationHolder() {
116 if(CdmStore
.isActive() && conversationHolder
==null){
119 return conversationHolder
;
124 public void dispose() {
125 if(conversationHolder
!=null){
126 conversationHolder
.close();
129 cdmEntitySession
.dispose();
135 * @see eu.etaxonomy.taxeditor.session.ICdmEntitySessionEnabled#getCdmEntitySession()
138 public ICdmEntitySession
getCdmEntitySession() {
140 return cdmEntitySession
;
144 * @see eu.etaxonomy.taxeditor.session.ICdmEntitySessionEnabled#getRootEntities()
147 public <T
extends CdmBase
> Collection
<T
> getRootEntities() {
148 // TODO Auto-generated method stub
153 * @see eu.etaxonomy.taxeditor.session.ICdmEntitySessionEnabled#getPropertyPathsMap()
156 public Map
<Object
, List
<String
>> getPropertyPathsMap() {
157 // TODO Auto-generated method stub