Revision 7c6f4a67
Added by Patrick Plitzner over 8 years ago
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/derivative/OccurrenceView.java | ||
---|---|---|
11 | 11 |
|
12 | 12 |
import java.util.Collection; |
13 | 13 |
|
14 |
import org.eclipse.core.runtime.IProgressMonitor; |
|
15 |
import org.eclipse.core.runtime.NullProgressMonitor; |
|
14 | 16 |
import org.eclipse.jface.action.MenuManager; |
15 | 17 |
import org.eclipse.jface.viewers.AbstractTreeViewer; |
16 | 18 |
import org.eclipse.jface.viewers.ISelection; |
17 | 19 |
import org.eclipse.jface.viewers.IStructuredSelection; |
18 | 20 |
import org.eclipse.jface.viewers.TreeViewer; |
21 |
import org.eclipse.jface.viewers.Viewer; |
|
19 | 22 |
import org.eclipse.swt.SWT; |
20 | 23 |
import org.eclipse.swt.layout.GridData; |
21 | 24 |
import org.eclipse.swt.widgets.Composite; |
22 | 25 |
import org.eclipse.swt.widgets.Control; |
23 | 26 |
import org.eclipse.swt.widgets.Menu; |
24 | 27 |
import org.eclipse.swt.widgets.Tree; |
25 |
import org.eclipse.ui.ISelectionListener;
|
|
28 |
import org.eclipse.ui.ISaveablePart2;
|
|
26 | 29 |
import org.eclipse.ui.ISelectionService; |
27 | 30 |
import org.eclipse.ui.IWorkbenchPart; |
28 |
import org.eclipse.ui.part.ViewPart; |
|
29 | 31 |
|
32 |
import eu.etaxonomy.cdm.api.conversation.ConversationHolder; |
|
30 | 33 |
import eu.etaxonomy.cdm.api.service.IOccurrenceService; |
31 | 34 |
import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase; |
32 | 35 |
import eu.etaxonomy.cdm.model.taxon.Taxon; |
33 | 36 |
import eu.etaxonomy.taxeditor.model.IPartContentHasDetails; |
34 | 37 |
import eu.etaxonomy.taxeditor.store.CdmStore; |
38 |
import eu.etaxonomy.taxeditor.view.AbstractCdmViewPart; |
|
35 | 39 |
import eu.etaxonomy.taxeditor.view.derivateSearch.DerivateContentProvider; |
36 | 40 |
import eu.etaxonomy.taxeditor.view.derivateSearch.DerivateLabelProvider; |
37 | 41 |
|
... | ... | |
40 | 44 |
* @date Oct 7, 2015 |
41 | 45 |
* |
42 | 46 |
*/ |
43 |
public class OccurrenceView extends ViewPart implements ISelectionListener, IPartContentHasDetails{
|
|
47 |
public class OccurrenceView extends AbstractCdmViewPart implements IPartContentHasDetails, ISaveablePart2{
|
|
44 | 48 |
|
45 | 49 |
public static String ID = "eu.etaxonomy.taxeditor.view.derivative.OccurrenceView"; |
46 | 50 |
|
... | ... | |
50 | 54 |
|
51 | 55 |
private ISelectionService selectionService; |
52 | 56 |
|
57 |
private ConversationHolder conversation; |
|
58 |
|
|
59 |
private boolean dirty; |
|
60 |
|
|
61 |
|
|
62 |
public OccurrenceView() { |
|
63 |
if(conversation==null && CdmStore.isActive()){ |
|
64 |
conversation = CdmStore.createConversation(); |
|
65 |
} |
|
66 |
} |
|
67 |
|
|
53 | 68 |
/** |
54 | 69 |
* {@inheritDoc} |
55 | 70 |
*/ |
... | ... | |
90 | 105 |
*/ |
91 | 106 |
@Override |
92 | 107 |
public void setFocus() { |
108 |
if(!conversation.isBound()){ |
|
109 |
conversation.bind(); |
|
110 |
} |
|
93 | 111 |
} |
94 | 112 |
|
95 | 113 |
/** |
... | ... | |
98 | 116 |
@Override |
99 | 117 |
public void dispose() { |
100 | 118 |
selectionService.removeSelectionListener(this); |
119 |
if(conversation!=null){ |
|
120 |
conversation.close(); |
|
121 |
} |
|
101 | 122 |
} |
102 | 123 |
|
103 | 124 |
/** |
... | ... | |
113 | 134 |
} |
114 | 135 |
} |
115 | 136 |
} |
137 |
|
|
138 |
@Override |
|
139 |
public boolean onComplete() { |
|
140 |
return false; |
|
141 |
} |
|
142 |
|
|
143 |
@Override |
|
144 |
public Viewer getViewer() { |
|
145 |
return viewer; |
|
146 |
} |
|
147 |
|
|
148 |
@Override |
|
149 |
public void createViewer(Composite parent) { |
|
150 |
} |
|
151 |
|
|
152 |
@Override |
|
153 |
public void changed(Object object) { |
|
154 |
this.dirty = true; |
|
155 |
firePropertyChange(PROP_DIRTY); |
|
156 |
} |
|
157 |
|
|
158 |
@Override |
|
159 |
public void doSave(IProgressMonitor monitor) { |
|
160 |
if(conversation.isBound()){ |
|
161 |
// input.merge(); TODO remote merging |
|
162 |
conversation.commit(true); |
|
163 |
} |
|
164 |
this.dirty = false; |
|
165 |
firePropertyChange(PROP_DIRTY); |
|
166 |
} |
|
167 |
|
|
168 |
@Override |
|
169 |
public void doSaveAs() { |
|
170 |
doSave(new NullProgressMonitor()); |
|
171 |
} |
|
172 |
|
|
173 |
@Override |
|
174 |
public boolean isDirty() { |
|
175 |
return this.dirty; |
|
176 |
} |
|
177 |
|
|
178 |
@Override |
|
179 |
public boolean isSaveAsAllowed() { |
|
180 |
return false; |
|
181 |
} |
|
182 |
|
|
183 |
@Override |
|
184 |
public boolean isSaveOnCloseNeeded() { |
|
185 |
return isDirty(); |
|
186 |
} |
|
187 |
|
|
188 |
@Override |
|
189 |
public int promptToSaveOnClose() { |
|
190 |
return ISaveablePart2.DEFAULT; |
|
191 |
} |
|
116 | 192 |
} |
Also available in: Unified diff
Add conversation/session support to OccurenceView