1 |
edb456d4
|
Katja Luther
|
/**
|
2 |
|
|
* Copyright (C) 2007 EDIT
|
3 |
|
|
* European Distributed Institute of Taxonomy
|
4 |
|
|
* http://www.e-taxonomy.eu
|
5 |
|
|
*
|
6 |
|
|
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
7 |
|
|
* See LICENSE.TXT at the top of this package for the full license terms.
|
8 |
|
|
*/
|
9 |
|
|
|
10 |
|
|
package eu.etaxonomy.taxeditor.editor.view.checklist.e4;
|
11 |
|
|
|
12 |
6a534f27
|
Katja Luther
|
|
13 |
edb456d4
|
Katja Luther
|
import java.util.ArrayList;
|
14 |
|
|
import java.util.Arrays;
|
15 |
|
|
import java.util.Collections;
|
16 |
|
|
import java.util.HashMap;
|
17 |
|
|
import java.util.List;
|
18 |
|
|
import java.util.Map;
|
19 |
|
|
import java.util.SortedSet;
|
20 |
4f25e642
|
Katja Luther
|
import java.util.UUID;
|
21 |
edb456d4
|
Katja Luther
|
|
22 |
|
|
import javax.annotation.PostConstruct;
|
23 |
|
|
import javax.annotation.PreDestroy;
|
24 |
|
|
import javax.inject.Inject;
|
25 |
|
|
|
26 |
|
|
import org.apache.log4j.Logger;
|
27 |
|
|
import org.eclipse.core.runtime.IProgressMonitor;
|
28 |
|
|
import org.eclipse.e4.ui.di.Focus;
|
29 |
|
|
import org.eclipse.e4.ui.di.Persist;
|
30 |
|
|
import org.eclipse.e4.ui.model.application.ui.MDirtyable;
|
31 |
|
|
import org.eclipse.e4.ui.model.application.ui.basic.MPart;
|
32 |
|
|
import org.eclipse.e4.ui.workbench.modeling.ESelectionService;
|
33 |
9a1539bb
|
Katja Luther
|
import org.eclipse.jface.viewers.ColumnViewerEditorActivationStrategy;
|
34 |
|
|
import org.eclipse.jface.viewers.FocusCellOwnerDrawHighlighter;
|
35 |
edb456d4
|
Katja Luther
|
import org.eclipse.jface.viewers.ISelectionChangedListener;
|
36 |
|
|
import org.eclipse.jface.viewers.StructuredViewer;
|
37 |
|
|
import org.eclipse.jface.viewers.TableViewer;
|
38 |
|
|
import org.eclipse.jface.viewers.TableViewerColumn;
|
39 |
9a1539bb
|
Katja Luther
|
import org.eclipse.jface.viewers.TableViewerEditor;
|
40 |
|
|
import org.eclipse.jface.viewers.TableViewerFocusCellManager;
|
41 |
4f25e642
|
Katja Luther
|
import org.eclipse.jface.wizard.WizardDialog;
|
42 |
edb456d4
|
Katja Luther
|
import org.eclipse.swt.SWT;
|
43 |
|
|
import org.eclipse.swt.events.ModifyListener;
|
44 |
|
|
import org.eclipse.swt.events.SelectionAdapter;
|
45 |
|
|
import org.eclipse.swt.events.SelectionEvent;
|
46 |
|
|
import org.eclipse.swt.layout.GridData;
|
47 |
|
|
import org.eclipse.swt.layout.GridLayout;
|
48 |
6a534f27
|
Katja Luther
|
import org.eclipse.swt.widgets.Button;
|
49 |
edb456d4
|
Katja Luther
|
import org.eclipse.swt.widgets.Composite;
|
50 |
6a534f27
|
Katja Luther
|
import org.eclipse.swt.widgets.Display;
|
51 |
edb456d4
|
Katja Luther
|
import org.eclipse.swt.widgets.Label;
|
52 |
|
|
import org.eclipse.swt.widgets.Table;
|
53 |
|
|
import org.eclipse.swt.widgets.TableColumn;
|
54 |
|
|
import org.eclipse.swt.widgets.Text;
|
55 |
|
|
import org.eclipse.swt.widgets.ToolBar;
|
56 |
|
|
import org.eclipse.swt.widgets.ToolItem;
|
57 |
|
|
import org.eclipse.ui.progress.IWorkbenchSiteProgressService;
|
58 |
|
|
|
59 |
|
|
import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
|
60 |
|
|
import eu.etaxonomy.cdm.api.conversation.IConversationEnabled;
|
61 |
|
|
import eu.etaxonomy.cdm.api.service.ITaxonNodeService;
|
62 |
|
|
import eu.etaxonomy.cdm.model.common.DefinedTermBase;
|
63 |
6a534f27
|
Katja Luther
|
import eu.etaxonomy.cdm.model.common.Representation;
|
64 |
|
|
import eu.etaxonomy.cdm.model.reference.Reference;
|
65 |
edb456d4
|
Katja Luther
|
import eu.etaxonomy.cdm.model.taxon.Classification;
|
66 |
75902572
|
Katja Luther
|
import eu.etaxonomy.cdm.model.taxon.Taxon;
|
67 |
edb456d4
|
Katja Luther
|
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
|
68 |
|
|
import eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap;
|
69 |
|
|
import eu.etaxonomy.taxeditor.editor.EditorUtil;
|
70 |
8e68b46a
|
Katja Luther
|
import eu.etaxonomy.taxeditor.editor.IDistributionEditor;
|
71 |
edb456d4
|
Katja Luther
|
import eu.etaxonomy.taxeditor.editor.internal.TaxeditorEditorPlugin;
|
72 |
|
|
import eu.etaxonomy.taxeditor.editor.l10n.Messages;
|
73 |
|
|
import eu.etaxonomy.taxeditor.editor.view.checklist.ChecklistContentProvider;
|
74 |
|
|
import eu.etaxonomy.taxeditor.editor.view.checklist.ChecklistEditorComparator;
|
75 |
|
|
import eu.etaxonomy.taxeditor.editor.view.checklist.ChecklistEditorInput;
|
76 |
|
|
import eu.etaxonomy.taxeditor.editor.view.checklist.ChecklistLabelProvider;
|
77 |
|
|
import eu.etaxonomy.taxeditor.editor.view.checklist.filter.ChecklistEditorFilter;
|
78 |
|
|
import eu.etaxonomy.taxeditor.editor.view.checklist.listener.ChecklistFocusListener;
|
79 |
|
|
import eu.etaxonomy.taxeditor.editor.view.checklist.listener.ChecklistModifyListener;
|
80 |
6a534f27
|
Katja Luther
|
import eu.etaxonomy.taxeditor.model.AbstractUtility;
|
81 |
edb456d4
|
Katja Luther
|
import eu.etaxonomy.taxeditor.model.IDirtyMarkable;
|
82 |
|
|
import eu.etaxonomy.taxeditor.model.IPartContentHasDetails;
|
83 |
2a4b0092
|
Katja Luther
|
import eu.etaxonomy.taxeditor.model.IPartContentHasSupplementalData;
|
84 |
edb456d4
|
Katja Luther
|
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
|
85 |
|
|
import eu.etaxonomy.taxeditor.preference.Resources;
|
86 |
4f25e642
|
Katja Luther
|
import eu.etaxonomy.taxeditor.preference.wizard.AvailableDistributionWizard;
|
87 |
edb456d4
|
Katja Luther
|
import eu.etaxonomy.taxeditor.store.CdmStore;
|
88 |
4f25e642
|
Katja Luther
|
import eu.etaxonomy.taxeditor.store.StoreUtil;
|
89 |
6a534f27
|
Katja Luther
|
import eu.etaxonomy.taxeditor.ui.dialog.selection.ReferenceSelectionDialog;
|
90 |
|
|
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
|
91 |
|
|
import eu.etaxonomy.taxeditor.ui.selection.EntitySelectionElement;
|
92 |
9a1539bb
|
Katja Luther
|
import eu.etaxonomy.taxeditor.workbench.part.IE4SavablePart;
|
93 |
edb456d4
|
Katja Luther
|
|
94 |
|
|
/**
|
95 |
deffae8c
|
Patrick Plitzner
|
*
|
96 |
edb456d4
|
Katja Luther
|
* @author k.luther
|
97 |
|
|
*
|
98 |
|
|
*/
|
99 |
cc4e78d1
|
Katja Luther
|
public class ChecklistEditorE4 implements IConversationEnabled,
|
100 |
2a4b0092
|
Katja Luther
|
IDirtyMarkable, IPartContentHasDetails, IE4SavablePart, IDistributionEditor, IPartContentHasSupplementalData{
|
101 |
edb456d4
|
Katja Luther
|
|
102 |
|
|
private static final String DISTRIBUTION_EDITOR = "Distribution Editor";
|
103 |
|
|
private static final String LOADING_TAXA = Messages.ChecklistEditor_LOAD_TAXA;
|
104 |
|
|
private static final String UNKNOWN = Messages.ChecklistEditor_UNKNOWN;
|
105 |
|
|
private static final String ELEMENT_COUNT = Messages.ChecklistEditor_ELEMENT_COUNT;
|
106 |
|
|
public static final String TYPE_FILTER_TEXT = "type filter text"; //$NON-NLS-1$
|
107 |
|
|
|
108 |
|
|
private static final Logger logger = Logger.getLogger(ChecklistEditorE4.class);
|
109 |
|
|
|
110 |
|
|
/**
|
111 |
|
|
* Constant
|
112 |
|
|
* <code>ID="eu.etaxonomy.taxeditor.store.datasource"{trunked}</code>
|
113 |
|
|
*/
|
114 |
|
|
public static String ID = "eu.etaxonomy.taxeditor.editor.view.checklist.ChecklistEditor"; //$NON-NLS-1$
|
115 |
|
|
|
116 |
|
|
private TableViewer viewer;
|
117 |
|
|
|
118 |
|
|
private ITaxonNodeService taxonNodeService;
|
119 |
|
|
|
120 |
|
|
private ChecklistEditorComparator comparator;
|
121 |
|
|
|
122 |
|
|
private ChecklistEditorInput checklistEditorInput;
|
123 |
|
|
|
124 |
|
|
private ConversationHolder conversation;
|
125 |
|
|
|
126 |
|
|
private Integer countNodes;
|
127 |
|
|
|
128 |
|
|
private List<TaxonNode> selectedTaxonNodes;
|
129 |
|
|
|
130 |
|
|
@Inject
|
131 |
|
|
private MPart thisPart;
|
132 |
deffae8c
|
Patrick Plitzner
|
|
133 |
edb456d4
|
Katja Luther
|
@Inject
|
134 |
|
|
private MDirtyable dirty;
|
135 |
deffae8c
|
Patrick Plitzner
|
|
136 |
edb456d4
|
Katja Luther
|
@Inject
|
137 |
|
|
private ESelectionService selService;
|
138 |
|
|
|
139 |
|
|
private ISelectionChangedListener selectionChangedListener;
|
140 |
|
|
|
141 |
|
|
private ChecklistEditorFilter filter;
|
142 |
|
|
|
143 |
|
|
private Label statusLabel;
|
144 |
566e18a2
|
Katja Luther
|
private Label statusLabelSourceReference;
|
145 |
edb456d4
|
Katja Luther
|
|
146 |
|
|
private ChecklistLabelProvider labelProvider;
|
147 |
321b9521
|
Katja Luther
|
|
148 |
4f25e642
|
Katja Luther
|
private Map<UUID, Integer> areaPosition= new HashMap();
|
149 |
|
|
|
150 |
|
|
private ToolItem toolItem;
|
151 |
6a534f27
|
Katja Luther
|
private ToolItem toolItem2;
|
152 |
edb456d4
|
Katja Luther
|
private ChecklistDropdownSelectionListenerE4 dropListener;
|
153 |
c2578872
|
Katja Luther
|
private Text searchText;
|
154 |
6a534f27
|
Katja Luther
|
private EntitySelectionElement<Reference> defaultReferenceSelection;
|
155 |
|
|
|
156 |
|
|
private Reference defaultSource = null;
|
157 |
c2578872
|
Katja Luther
|
|
158 |
6a534f27
|
Katja Luther
|
public Reference getDefaultSource() {
|
159 |
|
|
return defaultSource;
|
160 |
|
|
}
|
161 |
|
|
public Map<UUID, Integer> getAreaPosition() {
|
162 |
4f25e642
|
Katja Luther
|
return areaPosition;
|
163 |
|
|
}
|
164 |
edb456d4
|
Katja Luther
|
/**
|
165 |
|
|
* @return the selectedTaxonNodes
|
166 |
|
|
*/
|
167 |
|
|
public List<TaxonNode> getSelectedTaxonNodes() {
|
168 |
|
|
return selectedTaxonNodes;
|
169 |
|
|
}
|
170 |
|
|
|
171 |
|
|
/**
|
172 |
|
|
* @param selectedTaxonNodes
|
173 |
|
|
* the selectedTaxonNodes to set
|
174 |
|
|
*/
|
175 |
|
|
public void setSelectedTaxonNodes(List<TaxonNode> selectedTaxonNodes) {
|
176 |
|
|
this.selectedTaxonNodes = selectedTaxonNodes;
|
177 |
|
|
}
|
178 |
|
|
|
179 |
|
|
@Inject
|
180 |
|
|
public ChecklistEditorE4() {
|
181 |
|
|
}
|
182 |
|
|
|
183 |
|
|
/** {@inheritDoc} */
|
184 |
|
|
@PostConstruct
|
185 |
|
|
public void createPartControl(Composite parent) {
|
186 |
|
|
if (!CdmStore.isActive()){
|
187 |
|
|
return;
|
188 |
|
|
}
|
189 |
|
|
taxonNodeService = CdmStore.getService(ITaxonNodeService.class);
|
190 |
c2578872
|
Katja Luther
|
filter = new ChecklistEditorFilter();
|
191 |
|
|
createTopComposite(parent);
|
192 |
6a534f27
|
Katja Luther
|
// createToolbar(parent);
|
193 |
edb456d4
|
Katja Luther
|
viewer = new TableViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION);
|
194 |
deffae8c
|
Patrick Plitzner
|
|
195 |
9a1539bb
|
Katja Luther
|
//the focuzsCellManager should return the distribution!!!
|
196 |
|
|
TableViewerFocusCellManager focusCellManager = new TableViewerFocusCellManager(viewer, new FocusCellOwnerDrawHighlighter (viewer));
|
197 |
6a534f27
|
Katja Luther
|
TableViewerEditor.create(viewer, focusCellManager, new ColumnViewerEditorActivationStrategy(viewer), TableViewerEditor.DEFAULT);
|
198 |
9a1539bb
|
Katja Luther
|
|
199 |
321b9521
|
Katja Luther
|
labelProvider = new ChecklistLabelProvider(this);
|
200 |
c2578872
|
Katja Luther
|
|
201 |
|
|
viewer.addFilter(filter);
|
202 |
|
|
createTable();
|
203 |
|
|
|
204 |
|
|
viewer.setContentProvider(new ChecklistContentProvider());
|
205 |
|
|
viewer.setLabelProvider(this.labelProvider);
|
206 |
6a534f27
|
Katja Luther
|
|
207 |
c2578872
|
Katja Luther
|
comparator = new ChecklistEditorComparator();
|
208 |
|
|
viewer.setComparator(comparator);
|
209 |
|
|
final ModifyListener modifyListener = new ChecklistModifyListener(viewer, filter, searchText);
|
210 |
|
|
|
211 |
|
|
searchText.addFocusListener(new ChecklistFocusListener(searchText, modifyListener));
|
212 |
|
|
searchText.addModifyListener(modifyListener);
|
213 |
|
|
createGridDataForViewerLayout();
|
214 |
|
|
createStatusBar(parent);
|
215 |
6a534f27
|
Katja Luther
|
|
216 |
edb456d4
|
Katja Luther
|
}
|
217 |
|
|
|
218 |
|
|
/**
|
219 |
|
|
* @param parent
|
220 |
|
|
*/
|
221 |
|
|
private void createTopComposite(Composite parent) {
|
222 |
|
|
GridLayout gridLayout = new GridLayout(3, false);
|
223 |
|
|
gridLayout.marginWidth = 0;
|
224 |
|
|
gridLayout.marginHeight = 0;
|
225 |
|
|
parent.setLayout(gridLayout);
|
226 |
|
|
|
227 |
c2578872
|
Katja Luther
|
searchText = createSearchBar(parent);
|
228 |
edb456d4
|
Katja Luther
|
|
229 |
|
|
|
230 |
6a534f27
|
Katja Luther
|
}
|
231 |
edb456d4
|
Katja Luther
|
|
232 |
|
|
|
233 |
6a534f27
|
Katja Luther
|
/**
|
234 |
|
|
* @param parent
|
235 |
|
|
* @return
|
236 |
|
|
*/
|
237 |
|
|
private void createSetDefaultReferenceButton(Composite parent) {
|
238 |
|
|
CdmFormFactory cdmFormFactory = new CdmFormFactory(Display.getCurrent());
|
239 |
|
|
defaultReferenceSelection = cdmFormFactory.createSelectionElement(Reference.class,
|
240 |
|
|
null, "Default Source Reference", null,
|
241 |
|
|
EntitySelectionElement.DELETABLE, SWT.NULL);
|
242 |
|
|
|
243 |
edb456d4
|
Katja Luther
|
|
244 |
|
|
|
245 |
|
|
|
246 |
6a534f27
|
Katja Luther
|
|
247 |
|
|
return;
|
248 |
|
|
}
|
249 |
|
|
private void createGridDataForViewerLayout() {
|
250 |
edb456d4
|
Katja Luther
|
GridData gridData = new GridData();
|
251 |
|
|
gridData.verticalAlignment = GridData.FILL;
|
252 |
|
|
gridData.horizontalSpan = 3;
|
253 |
|
|
gridData.grabExcessHorizontalSpace = true;
|
254 |
|
|
gridData.grabExcessVerticalSpace = true;
|
255 |
|
|
gridData.horizontalAlignment = GridData.FILL;
|
256 |
|
|
viewer.getControl().setLayoutData(gridData);
|
257 |
|
|
}
|
258 |
|
|
|
259 |
|
|
/**
|
260 |
|
|
* @param parent
|
261 |
|
|
* @return
|
262 |
|
|
*/
|
263 |
|
|
private Text createSearchBar(Composite parent) {
|
264 |
6a534f27
|
Katja Luther
|
|
265 |
edb456d4
|
Katja Luther
|
final Text searchText = new Text(parent, SWT.BORDER | SWT.SEARCH | SWT.ICON_SEARCH | SWT.CANCEL);
|
266 |
6a534f27
|
Katja Luther
|
GridData gridData = new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL);
|
267 |
|
|
|
268 |
|
|
searchText.setLayoutData(gridData);
|
269 |
edb456d4
|
Katja Luther
|
searchText.setForeground(EditorUtil.getColor(Resources.SEARCH_VIEW_FOREGROUND));
|
270 |
|
|
searchText.setText(TYPE_FILTER_TEXT);
|
271 |
6a534f27
|
Katja Luther
|
searchText.setToolTipText(Messages.ChecklistEditor_SEARCH_TOOLTIP);
|
272 |
|
|
|
273 |
|
|
Button button1 = new Button(parent, SWT.PUSH );
|
274 |
|
|
GridData gridData2 = new GridData();
|
275 |
|
|
gridData2.horizontalSpan = 1;
|
276 |
566e18a2
|
Katja Luther
|
gridData2.horizontalAlignment = SWT.RIGHT;
|
277 |
6a534f27
|
Katja Luther
|
button1.setLayoutData(gridData2);
|
278 |
|
|
|
279 |
|
|
|
280 |
|
|
button1.setText(Messages.ChecklistEditor_DIST_STATUS);
|
281 |
|
|
button1.setToolTipText(Messages.ChecklistEditor_DIST_STATUS_TOOLTIP);
|
282 |
|
|
button1.addSelectionListener(new SelectionAdapter() {
|
283 |
|
|
@Override
|
284 |
|
|
public void widgetSelected(SelectionEvent event) {
|
285 |
|
|
AvailableDistributionWizard availableDistributionWizard = new AvailableDistributionWizard();
|
286 |
|
|
WizardDialog dialog = new WizardDialog(StoreUtil.getShell(),
|
287 |
|
|
availableDistributionWizard);
|
288 |
|
|
|
289 |
|
|
int open = dialog.open();
|
290 |
|
|
if(open == 0){
|
291 |
|
|
reload();
|
292 |
|
|
}
|
293 |
|
|
}
|
294 |
|
|
});
|
295 |
|
|
|
296 |
|
|
Button button2 = new Button(parent, SWT.PUSH );
|
297 |
|
|
GridData gridData3 = new GridData();
|
298 |
|
|
gridData2.horizontalSpan = 1;
|
299 |
|
|
button2.setLayoutData(gridData3);
|
300 |
|
|
|
301 |
|
|
|
302 |
|
|
button2.setText(Messages.ChecklistEditor_DEFAULT_SOURCE);
|
303 |
|
|
button2.setToolTipText(Messages.ChecklistEditor_DEFAULT_SOURCE_TOOLTIP);
|
304 |
|
|
button2.addSelectionListener(new SelectionAdapter() {
|
305 |
|
|
|
306 |
|
|
@Override
|
307 |
|
|
public void widgetSelected(SelectionEvent event) {
|
308 |
|
|
defaultSource = ReferenceSelectionDialog.select(AbstractUtility.getShell(), null);
|
309 |
b40f38ec
|
Katja Luther
|
|
310 |
45c989af
|
Andreas Müller
|
String defaultSourceStr = (defaultSource == null) ? "" : "Default Source Reference: " + defaultSource.getTitleCache();
|
311 |
|
|
if (defaultSourceStr.length()> 100){
|
312 |
|
|
defaultSourceStr = defaultSourceStr.substring(0, 98) + "...";
|
313 |
|
|
}
|
314 |
|
|
statusLabelSourceReference.setText(defaultSourceStr);
|
315 |
b40f38ec
|
Katja Luther
|
|
316 |
566e18a2
|
Katja Luther
|
button2.setBackground(EditorUtil.getColor(Resources.COLOR_CONTROL_SELECTED));
|
317 |
6a534f27
|
Katja Luther
|
}
|
318 |
|
|
|
319 |
|
|
});
|
320 |
|
|
|
321 |
|
|
parent.pack();
|
322 |
edb456d4
|
Katja Luther
|
return searchText;
|
323 |
|
|
}
|
324 |
|
|
|
325 |
|
|
/**
|
326 |
|
|
* @param parent
|
327 |
|
|
*/
|
328 |
|
|
private void createToolbar(Composite parent) {
|
329 |
6a534f27
|
Katja Luther
|
ToolBar toolBar = new ToolBar(parent, SWT.BORDER);
|
330 |
4f25e642
|
Katja Luther
|
// toolItem = new ToolItem(toolBar, SWT.DROP_DOWN | SWT.BORDER);
|
331 |
6a534f27
|
Katja Luther
|
|
332 |
|
|
toolItem = new ToolItem(toolBar, SWT.PUSH| SWT.BORDER);
|
333 |
|
|
|
334 |
4f25e642
|
Katja Luther
|
|
335 |
edb456d4
|
Katja Luther
|
toolItem.setText(Messages.ChecklistEditor_DIST_STATUS);
|
336 |
|
|
toolItem.setToolTipText(Messages.ChecklistEditor_DIST_STATUS_TOOLTIP);
|
337 |
4f25e642
|
Katja Luther
|
//createToolbarItems();
|
338 |
|
|
// toolItem.addSelectionListener(dropListener);
|
339 |
|
|
toolItem.addSelectionListener(new SelectionAdapter() {
|
340 |
|
|
@Override
|
341 |
|
|
public void widgetSelected(SelectionEvent event) {
|
342 |
|
|
AvailableDistributionWizard availableDistributionWizard = new AvailableDistributionWizard();
|
343 |
|
|
WizardDialog dialog = new WizardDialog(StoreUtil.getShell(),
|
344 |
|
|
availableDistributionWizard);
|
345 |
|
|
|
346 |
|
|
int open = dialog.open();
|
347 |
|
|
if(open == 0){
|
348 |
|
|
reload();
|
349 |
|
|
}
|
350 |
|
|
}
|
351 |
|
|
});
|
352 |
6a534f27
|
Katja Luther
|
toolItem2 = new ToolItem(toolBar, SWT.PUSH | SWT.BORDER);
|
353 |
|
|
|
354 |
|
|
|
355 |
|
|
toolItem2.setText(Messages.ChecklistEditor_DEFAULT_SOURCE);
|
356 |
|
|
toolItem2.setToolTipText(Messages.ChecklistEditor_DEFAULT_SOURCE_TOOLTIP);
|
357 |
|
|
//createToolbarItems();
|
358 |
|
|
// toolItem.addSelectionListener(dropListener);
|
359 |
|
|
toolItem2.addSelectionListener(new SelectionAdapter() {
|
360 |
|
|
@Override
|
361 |
|
|
public void widgetSelected(SelectionEvent event) {
|
362 |
|
|
defaultSource = ReferenceSelectionDialog.select(AbstractUtility.getShell(), null);
|
363 |
566e18a2
|
Katja Luther
|
|
364 |
6a534f27
|
Katja Luther
|
}
|
365 |
|
|
});
|
366 |
|
|
|
367 |
edb456d4
|
Katja Luther
|
toolBar.pack();
|
368 |
|
|
}
|
369 |
|
|
|
370 |
|
|
|
371 |
|
|
|
372 |
|
|
private void createStatusBar(Composite composite) {
|
373 |
|
|
GridData gridData = new GridData();
|
374 |
566e18a2
|
Katja Luther
|
gridData.horizontalSpan = 1;
|
375 |
edb456d4
|
Katja Luther
|
gridData.grabExcessHorizontalSpace = true;
|
376 |
|
|
gridData.horizontalAlignment = GridData.FILL;
|
377 |
|
|
|
378 |
|
|
statusLabel = new Label(composite, SWT.LEFT);
|
379 |
|
|
statusLabel.setText(ELEMENT_COUNT + (countNodes != null ? countNodes : UNKNOWN));
|
380 |
|
|
statusLabel.setLayoutData(gridData);
|
381 |
566e18a2
|
Katja Luther
|
|
382 |
|
|
statusLabelSourceReference = new Label(composite, SWT.RIGHT);
|
383 |
b40f38ec
|
Katja Luther
|
// GridData sourceGrid = new GridData();
|
384 |
|
|
// sourceGrid.horizontalAlignment = GridData.HORIZONTAL_ALIGN_END;
|
385 |
|
|
// //sourceGrid.grabExcessHorizontalSpace = false;
|
386 |
|
|
// sourceGrid.horizontalSpan = 1;
|
387 |
|
|
statusLabelSourceReference.setLayoutData(gridData);
|
388 |
|
|
|
389 |
566e18a2
|
Katja Luther
|
if (defaultSource != null){
|
390 |
|
|
statusLabelSourceReference.setText("Default Source Reference: " + defaultSource.getAbbrevTitle() != null? defaultSource.getAbbrevTitle() : defaultSource.getAbbrevTitleCache());
|
391 |
|
|
|
392 |
|
|
}
|
393 |
edb456d4
|
Katja Luther
|
}
|
394 |
|
|
|
395 |
|
|
private void createTable() {
|
396 |
|
|
Table table = viewer.getTable();//new Table(parent, viewer.getTable().getStyle());
|
397 |
|
|
List<String> titles = new ArrayList<String>();
|
398 |
|
|
List<Integer> bounds = new ArrayList<Integer>();
|
399 |
|
|
if (PreferencesUtil.isShowRankInChecklistEditor()){
|
400 |
|
|
Collections.addAll(titles, Messages.ChecklistEditor_TAXON, Messages.ChecklistEditor_RANK);
|
401 |
|
|
Collections.addAll(bounds, 300, 200);
|
402 |
|
|
} else{
|
403 |
|
|
Collections.addAll(titles, Messages.ChecklistEditor_TAXON);
|
404 |
|
|
Collections.addAll(bounds, 300);
|
405 |
|
|
}
|
406 |
|
|
|
407 |
|
|
|
408 |
fc9c0563
|
Katja Luther
|
// Map<Integer, Boolean> restoreValuesForColumnWidth =
|
409 |
|
|
restoreValuesForColumnWidth(titles, bounds);
|
410 |
|
|
createInitalDistributionColumns(table, titles, bounds);
|
411 |
edb456d4
|
Katja Luther
|
table.setSortDirection(SWT.DOWN);
|
412 |
|
|
table.setHeaderVisible(true);
|
413 |
|
|
table.setLinesVisible(true);
|
414 |
|
|
}
|
415 |
|
|
/**
|
416 |
|
|
* This method creates initially the distribution columns for a table. It should only be called for creation.<br>
|
417 |
|
|
*<p>
|
418 |
|
|
*
|
419 |
|
|
*<b>Notice:</b> If you want to add additional columns later please use <b>addTableViewerColumn()</b>
|
420 |
|
|
*
|
421 |
|
|
* @param table
|
422 |
|
|
* @param titles
|
423 |
|
|
* @param bounds
|
424 |
|
|
* @param restoreValuesForColumnWidth
|
425 |
|
|
*/
|
426 |
|
|
private void createInitalDistributionColumns(Table table,
|
427 |
fc9c0563
|
Katja Luther
|
List<String> titles, List<Integer> bounds) {
|
428 |
edb456d4
|
Katja Luther
|
for (int columnIndex = 0; columnIndex < titles.size(); columnIndex++) {
|
429 |
|
|
TableViewerColumn column = new TableViewerColumn(viewer, SWT.NONE);
|
430 |
|
|
column.getColumn().setText(titles.get(columnIndex));
|
431 |
|
|
column.getColumn().setWidth(bounds.get(columnIndex));
|
432 |
|
|
column.getColumn().setResizable(true);
|
433 |
|
|
column.getColumn().setMoveable(true);
|
434 |
|
|
column.getColumn().addSelectionListener(getSelectionAdapter(column.getColumn(), columnIndex));
|
435 |
|
|
if (columnIndex == 0) {
|
436 |
|
|
table.setSortColumn(column.getColumn());
|
437 |
|
|
}
|
438 |
|
|
if (columnIndex == 1 && PreferencesUtil.isShowRankInChecklistEditor()) {
|
439 |
|
|
/** uncommented it for now because no rank editing is wanted **/
|
440 |
fecf5fd5
|
Katja Luther
|
|
441 |
edb456d4
|
Katja Luther
|
}
|
442 |
|
|
if ((columnIndex == 1 && !PreferencesUtil.isShowRankInChecklistEditor()) || columnIndex >= 2 ) {
|
443 |
fecf5fd5
|
Katja Luther
|
column.getColumn().setWidth(50);
|
444 |
edb456d4
|
Katja Luther
|
column.setEditingSupport(new DistributionEditingSupportE4(viewer, this, columnIndex));
|
445 |
9a1539bb
|
Katja Luther
|
|
446 |
edb456d4
|
Katja Luther
|
}
|
447 |
|
|
}
|
448 |
|
|
}
|
449 |
|
|
|
450 |
|
|
/**
|
451 |
|
|
* This methods loads the last opened distribution columns for the table viewer from the prefrence store.<br>
|
452 |
|
|
*<p>
|
453 |
|
|
* <b>Notice:</b> It adds also the TitleCache to the titles list for the header of each column.<p>
|
454 |
|
|
*
|
455 |
|
|
* @param titles
|
456 |
|
|
* @param bounds
|
457 |
|
|
* @return Map<Integer, Boolean>
|
458 |
|
|
*/
|
459 |
fc9c0563
|
Katja Luther
|
private void restoreValuesForColumnWidth(List<String> titles,
|
460 |
edb456d4
|
Katja Luther
|
List<Integer> bounds) {
|
461 |
fc9c0563
|
Katja Luther
|
// Map<Integer, Boolean> restoreColumnWidth = new HashMap<Integer, Boolean>();
|
462 |
4f25e642
|
Katja Luther
|
if (labelProvider.getNamedAreas(true) != null) {
|
463 |
edb456d4
|
Katja Luther
|
int columnIndex;
|
464 |
|
|
if (PreferencesUtil.isShowRankInChecklistEditor()){
|
465 |
|
|
columnIndex = 2;
|
466 |
|
|
} else{
|
467 |
|
|
columnIndex = 1;
|
468 |
|
|
}
|
469 |
3319e347
|
Katja Luther
|
for (DefinedTermBase<DefinedTermBase> term : getLabelProvider().getNamedAreas(false)) {
|
470 |
edb456d4
|
Katja Luther
|
if(term != null){
|
471 |
fc9c0563
|
Katja Luther
|
// restoreColumnWidth.put(columnIndex, PreferencesUtil.getPreferenceStore().getBoolean(term.getUuid().toString()));
|
472 |
4f25e642
|
Katja Luther
|
areaPosition.put(term.getUuid(), columnIndex);
|
473 |
6a534f27
|
Katja Luther
|
Representation rep = term.getPreferredRepresentation(CdmStore.getDefaultLanguage());
|
474 |
b40f38ec
|
Katja Luther
|
String label = rep.getLabel();
|
475 |
6a534f27
|
Katja Luther
|
if (label == null){
|
476 |
|
|
term.getTitleCache();
|
477 |
|
|
}
|
478 |
edb456d4
|
Katja Luther
|
if (PreferencesUtil.isShowIdInVocabularyInChecklistEditor()){
|
479 |
|
|
if (term.getIdInVocabulary() != null){
|
480 |
|
|
titles.add(term.getIdInVocabulary());
|
481 |
|
|
} else{
|
482 |
6a534f27
|
Katja Luther
|
titles.add(label);
|
483 |
edb456d4
|
Katja Luther
|
}
|
484 |
321b9521
|
Katja Luther
|
}else if (PreferencesUtil.isShowSymbol1InChecklistEditor()){
|
485 |
|
|
if (term.getSymbol() != null){
|
486 |
|
|
titles.add(term.getSymbol());
|
487 |
|
|
} else{
|
488 |
6a534f27
|
Katja Luther
|
titles.add(label);
|
489 |
321b9521
|
Katja Luther
|
}
|
490 |
|
|
}else if (PreferencesUtil.isShowSymbol2InChecklistEditor()){
|
491 |
|
|
if (term.getSymbol2() != null){
|
492 |
|
|
titles.add(term.getSymbol2());
|
493 |
|
|
} else{
|
494 |
6a534f27
|
Katja Luther
|
titles.add(label);
|
495 |
321b9521
|
Katja Luther
|
}
|
496 |
6a534f27
|
Katja Luther
|
}else{
|
497 |
|
|
titles.add(label);
|
498 |
edb456d4
|
Katja Luther
|
}
|
499 |
|
|
bounds.add(200);
|
500 |
|
|
columnIndex++;
|
501 |
|
|
}
|
502 |
|
|
}
|
503 |
|
|
}
|
504 |
fecf5fd5
|
Katja Luther
|
|
505 |
edb456d4
|
Katja Luther
|
}
|
506 |
|
|
|
507 |
|
|
/**
|
508 |
|
|
* This method adds new DistributionColumns to an existing table.
|
509 |
|
|
*
|
510 |
|
|
* @param title
|
511 |
|
|
* @param bound
|
512 |
|
|
* @param colNumber
|
513 |
|
|
* @return
|
514 |
|
|
*/
|
515 |
4f25e642
|
Katja Luther
|
private TableViewerColumn addTableViewerColumn(String title, int bound, final int colNumber, DefinedTermBase term) {
|
516 |
3319e347
|
Katja Luther
|
|
517 |
04f83f13
|
Katja Luther
|
final TableViewerColumn viewerColumn = new TableViewerColumn(viewer, SWT.FULL_SELECTION);
|
518 |
edb456d4
|
Katja Luther
|
final TableColumn column = viewerColumn.getColumn();
|
519 |
|
|
column.setText(title);
|
520 |
4f25e642
|
Katja Luther
|
String[] UuidAndLable = new String[2];
|
521 |
|
|
UuidAndLable[0] = term.getUuid().toString();
|
522 |
|
|
UuidAndLable[1] = title;
|
523 |
|
|
column.setData(UuidAndLable);
|
524 |
edb456d4
|
Katja Luther
|
column.setWidth(200);
|
525 |
04f83f13
|
Katja Luther
|
|
526 |
edb456d4
|
Katja Luther
|
viewerColumn.setEditingSupport(new DistributionEditingSupportE4(viewer, this, colNumber));
|
527 |
|
|
column.setResizable(true);
|
528 |
|
|
column.setMoveable(true);
|
529 |
|
|
return viewerColumn;
|
530 |
|
|
}
|
531 |
|
|
|
532 |
|
|
|
533 |
|
|
|
534 |
|
|
/**
|
535 |
|
|
*
|
536 |
|
|
* pull data from database and set input for view
|
537 |
|
|
*
|
538 |
|
|
*/
|
539 |
|
|
private void loadDataInput() {
|
540 |
|
|
Classification classification = checklistEditorInput.getClassification();
|
541 |
|
|
TaxonNode taxonNode = checklistEditorInput.getTaxonNode();
|
542 |
|
|
if (classification != null && taxonNode == null) {
|
543 |
|
|
countNodes = taxonNodeService.countAllNodesForClassification(classification);
|
544 |
|
|
// statusLabel.setText(ELEMENT_COUNT + (countNodes != null ? countNodes : UNKNOWN));
|
545 |
|
|
// This should not kill the view nor the editor if something goes
|
546 |
|
|
// wrong
|
547 |
|
|
// TODO: don't load the whole taxonNode Object but rather a small
|
548 |
|
|
// and simple Solution
|
549 |
|
|
// FIXME: May be don't open classification which are greater than
|
550 |
|
|
// 3000 Taxa
|
551 |
|
|
selectedTaxonNodes = taxonNodeService.listAllNodesForClassification(classification, 0, countNodes);
|
552 |
|
|
countNodes = selectedTaxonNodes.size();
|
553 |
|
|
statusLabel.setText(ELEMENT_COUNT + (countNodes != null ? countNodes : UNKNOWN));
|
554 |
|
|
viewer.setInput(checklistEditorInput.getTaxa());
|
555 |
|
|
// Job checkListJob = new ChecklistJob(LOADING_TAXA, selectedTaxonNodes);
|
556 |
|
|
// checkListJob.schedule(Job.LONG);
|
557 |
deffae8c
|
Patrick Plitzner
|
|
558 |
edb456d4
|
Katja Luther
|
}
|
559 |
|
|
if (taxonNode != null) {
|
560 |
acebcf17
|
Andreas Müller
|
boolean includeUnpublished = true;
|
561 |
|
|
selectedTaxonNodes = taxonNodeService.loadChildNodesOfTaxonNode(taxonNode, NODE_INIT_STRATEGY, true, includeUnpublished, null);
|
562 |
edb456d4
|
Katja Luther
|
countNodes = selectedTaxonNodes.size();
|
563 |
|
|
viewer.setInput(checklistEditorInput.getTaxa());
|
564 |
|
|
statusLabel.setText(ELEMENT_COUNT + (countNodes != null ? countNodes : UNKNOWN));
|
565 |
b40f38ec
|
Katja Luther
|
|
566 |
edb456d4
|
Katja Luther
|
}
|
567 |
|
|
}
|
568 |
|
|
|
569 |
75902572
|
Katja Luther
|
|
570 |
edb456d4
|
Katja Luther
|
@PreDestroy
|
571 |
|
|
public void dispose() {
|
572 |
|
|
if(conversation!=null){
|
573 |
|
|
conversation.unregisterForDataStoreChanges(this);
|
574 |
76a8b44f
|
Patrick Plitzner
|
conversation.close();
|
575 |
|
|
}
|
576 |
|
|
conversation = null;
|
577 |
|
|
if(checklistEditorInput!=null){
|
578 |
|
|
checklistEditorInput.dispose();
|
579 |
edb456d4
|
Katja Luther
|
}
|
580 |
c6997339
|
Patrick Plitzner
|
dirty.setDirty(false);
|
581 |
b40f38ec
|
Katja Luther
|
|
582 |
edb456d4
|
Katja Luther
|
}
|
583 |
|
|
|
584 |
|
|
/** {@inheritDoc} */
|
585 |
|
|
@Focus
|
586 |
|
|
public void setFocus() {
|
587 |
deffae8c
|
Patrick Plitzner
|
if(viewer!=null && viewer.getControl()!=null && !viewer.getControl().isDisposed()) {
|
588 |
|
|
viewer.getControl().setFocus();
|
589 |
|
|
}
|
590 |
edb456d4
|
Katja Luther
|
}
|
591 |
|
|
|
592 |
|
|
//FIXME E4 migrate
|
593 |
|
|
// /*
|
594 |
|
|
// * (non-Javadoc)
|
595 |
|
|
// *
|
596 |
|
|
// * @see org.eclipse.ui.part.WorkbenchPart#showBusy(boolean)
|
597 |
|
|
// */
|
598 |
|
|
// /** {@inheritDoc} */
|
599 |
|
|
// @Override
|
600 |
|
|
// public void showBusy(boolean busy) {
|
601 |
|
|
// super.showBusy(busy);
|
602 |
|
|
// // viewer.getTable().setEnabled(!busy);
|
603 |
|
|
// if (busy) {
|
604 |
|
|
// partNameCache = getPartName();
|
605 |
|
|
// setPartName(String.format(Messages.ChecklistEditor_LOAD_CNT_TAXA, countNodes));
|
606 |
|
|
// } else {
|
607 |
|
|
// if (partNameCache != null) {
|
608 |
|
|
// setPartName(partNameCache);
|
609 |
|
|
// }
|
610 |
|
|
// }
|
611 |
|
|
// }
|
612 |
|
|
|
613 |
|
|
/**
|
614 |
|
|
* <p>
|
615 |
|
|
* Getter for the field <code>viewer</code>.
|
616 |
|
|
* </p>
|
617 |
|
|
*
|
618 |
|
|
* @return a {@link org.eclipse.jface.viewers.StructuredViewer} object.
|
619 |
|
|
*/
|
620 |
|
|
public StructuredViewer getViewer() {
|
621 |
|
|
return viewer;
|
622 |
|
|
}
|
623 |
|
|
|
624 |
|
|
public void refresh() {
|
625 |
|
|
viewer.refresh();
|
626 |
|
|
}
|
627 |
|
|
|
628 |
|
|
/**
|
629 |
|
|
* This method should only be called for adding new Distribution columns and reloading the table.<br>
|
630 |
|
|
* It will hide the old distribution column and load the newly added columns.<br>
|
631 |
|
|
* <p>
|
632 |
|
|
* <b>Notice:</b> for data update please use <b>refresh()</b>
|
633 |
|
|
*
|
634 |
|
|
*/
|
635 |
|
|
@SuppressWarnings({ "unchecked", "rawtypes" })
|
636 |
|
|
public void reload(){
|
637 |
fecf5fd5
|
Katja Luther
|
//create new Items for Dropdown menue
|
638 |
|
|
Table table = viewer.getTable();
|
639 |
|
|
table.setRedraw(false);
|
640 |
|
|
SortedSet<DefinedTermBase> newTerms = labelProvider.getNamedAreas(true);
|
641 |
|
|
|
642 |
|
|
|
643 |
|
|
//check which terms are deleted and which are new.
|
644 |
|
|
TableColumn[] columns = viewer.getTable().getColumns() ;
|
645 |
|
|
int index = 0;
|
646 |
4f25e642
|
Katja Luther
|
|
647 |
|
|
for (TableColumn column: columns){
|
648 |
|
|
if ((!PreferencesUtil.isShowRankInChecklistEditor() && index > 0) || (index > 1)) {
|
649 |
3423aff4
|
Katja Luther
|
column.dispose();
|
650 |
|
|
}
|
651 |
4f25e642
|
Katja Luther
|
index++;
|
652 |
|
|
}
|
653 |
|
|
|
654 |
fecf5fd5
|
Katja Luther
|
areaPosition.clear();
|
655 |
|
|
int columnIndex;
|
656 |
|
|
if (PreferencesUtil.isShowRankInChecklistEditor()){
|
657 |
|
|
columnIndex = 2;
|
658 |
|
|
} else{
|
659 |
|
|
columnIndex = 1;
|
660 |
|
|
}
|
661 |
|
|
for (DefinedTermBase term:newTerms){
|
662 |
|
|
areaPosition.put(term.getUuid(), Integer.valueOf(columnIndex));
|
663 |
|
|
columnIndex++;
|
664 |
be7068cc
|
Katja Luther
|
}
|
665 |
4f25e642
|
Katja Luther
|
|
666 |
fecf5fd5
|
Katja Luther
|
for (DefinedTermBase term: newTerms){
|
667 |
|
|
Representation rep = term.getPreferredRepresentation(CdmStore.getDefaultLanguage());
|
668 |
|
|
|
669 |
|
|
String termLable = rep.getAbbreviatedLabel();
|
670 |
|
|
if (termLable == null){
|
671 |
|
|
termLable = rep.getLabel();
|
672 |
|
|
}
|
673 |
|
|
if (PreferencesUtil.isShowIdInVocabularyInChecklistEditor()){
|
674 |
|
|
if (term.getIdInVocabulary() != null){
|
675 |
|
|
termLable = term.getIdInVocabulary();
|
676 |
|
|
}
|
677 |
|
|
}
|
678 |
|
|
TableViewerColumn column= addTableViewerColumn(termLable, 200, areaPosition.get(term.getUuid()), term);
|
679 |
278a5e0a
|
Katja Luther
|
|
680 |
3319e347
|
Katja Luther
|
|
681 |
fecf5fd5
|
Katja Luther
|
}
|
682 |
6a534f27
|
Katja Luther
|
|
683 |
fecf5fd5
|
Katja Luther
|
viewer.setLabelProvider(labelProvider);
|
684 |
|
|
table.setRedraw(true);
|
685 |
|
|
viewer.refresh();
|
686 |
edb456d4
|
Katja Luther
|
}
|
687 |
|
|
|
688 |
4f25e642
|
Katja Luther
|
/**
|
689 |
|
|
*
|
690 |
|
|
*/
|
691 |
|
|
private void updateColumnIndex() {
|
692 |
|
|
int columnIndex;
|
693 |
|
|
if (PreferencesUtil.isShowRankInChecklistEditor()){
|
694 |
|
|
columnIndex = 2;
|
695 |
|
|
} else{
|
696 |
|
|
columnIndex = 1;
|
697 |
|
|
}
|
698 |
|
|
for (UUID uuid:areaPosition.keySet()){
|
699 |
|
|
areaPosition.put(uuid, columnIndex);
|
700 |
|
|
columnIndex++;
|
701 |
|
|
}
|
702 |
|
|
|
703 |
|
|
}
|
704 |
edb456d4
|
Katja Luther
|
|
705 |
6a534f27
|
Katja Luther
|
|
706 |
|
|
|
707 |
edb456d4
|
Katja Luther
|
|
708 |
|
|
/**
|
709 |
|
|
* <p>
|
710 |
|
|
* Getter for the field <code>service</code>.
|
711 |
|
|
* </p>
|
712 |
|
|
*
|
713 |
|
|
* @return the service
|
714 |
|
|
*/
|
715 |
|
|
public IWorkbenchSiteProgressService getService() {
|
716 |
|
|
return TaxeditorEditorPlugin.getDefault().getWorkbench().getService(IWorkbenchSiteProgressService.class);
|
717 |
|
|
}
|
718 |
|
|
|
719 |
|
|
private SelectionAdapter getSelectionAdapter(final TableColumn column, final int index) {
|
720 |
|
|
SelectionAdapter selectionAdapter = new SelectionAdapter() {
|
721 |
|
|
@Override
|
722 |
|
|
public void widgetSelected(SelectionEvent e) {
|
723 |
|
|
comparator.setColumn(index);
|
724 |
|
|
int dir = viewer.getTable().getSortDirection();
|
725 |
|
|
if (viewer.getTable().getSortColumn() == column) {
|
726 |
|
|
dir = dir == SWT.UP ? SWT.DOWN : SWT.UP;
|
727 |
|
|
} else {
|
728 |
|
|
dir = SWT.DOWN;
|
729 |
|
|
}
|
730 |
|
|
viewer.getTable().setSortDirection(dir);
|
731 |
|
|
viewer.getTable().setSortColumn(column);
|
732 |
|
|
viewer.refresh();
|
733 |
|
|
}
|
734 |
|
|
};
|
735 |
|
|
return selectionAdapter;
|
736 |
|
|
}
|
737 |
|
|
|
738 |
|
|
public void doSave(IProgressMonitor monitor) {
|
739 |
|
|
try {
|
740 |
321b9521
|
Katja Luther
|
// monitor.beginTask(Messages.ChecklistEditor_SAVE_EDITOR, 1);
|
741 |
|
|
// if (!conversation.isBound()) {
|
742 |
|
|
// conversation.bind();
|
743 |
|
|
// }
|
744 |
75902572
|
Katja Luther
|
|
745 |
|
|
this.checklistEditorInput.merge();
|
746 |
|
|
|
747 |
321b9521
|
Katja Luther
|
//conversation.commit(true);
|
748 |
edb456d4
|
Katja Luther
|
setDirty(false);
|
749 |
321b9521
|
Katja Luther
|
// monitor.worked(1);
|
750 |
edb456d4
|
Katja Luther
|
} finally {
|
751 |
321b9521
|
Katja Luther
|
// monitor.done();
|
752 |
edb456d4
|
Katja Luther
|
}
|
753 |
|
|
|
754 |
|
|
}
|
755 |
|
|
|
756 |
1d892040
|
Patrick Plitzner
|
public void init(ChecklistEditorInput input) {
|
757 |
|
|
checklistEditorInput = input;
|
758 |
|
|
thisPart.setLabel(DISTRIBUTION_EDITOR+": " + checklistEditorInput.getName());
|
759 |
|
|
conversation = checklistEditorInput.getConversation();
|
760 |
|
|
conversation.registerForDataStoreChanges(this);
|
761 |
|
|
|
762 |
edb456d4
|
Katja Luther
|
//propagate selection
|
763 |
9a1539bb
|
Katja Luther
|
selectionChangedListener = (event -> selService.setSelection(
|
764 |
04f83f13
|
Katja Luther
|
DistributionEditorHelper.getDistributionForColumn(event, areaPosition)));
|
765 |
9a1539bb
|
Katja Luther
|
|
766 |
edb456d4
|
Katja Luther
|
viewer.addSelectionChangedListener(selectionChangedListener);
|
767 |
deffae8c
|
Patrick Plitzner
|
|
768 |
edb456d4
|
Katja Luther
|
|
769 |
|
|
loadDataInput();
|
770 |
|
|
}
|
771 |
|
|
private static final List<String> NODE_INIT_STRATEGY = Arrays.asList(new String[] { "descriptions", //$NON-NLS-1$
|
772 |
|
|
"descriptions.*", "description.state", "feature", "feature.*", "childNodes", "childNodes.taxon", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
|
773 |
|
|
"childNodes.taxon.name", "taxonNodes", "taxonNodes.*", "taxonNodes.taxon.*", "taxon.*", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
|
774 |
|
|
"taxon.descriptions", "taxon.sec", "taxon.name.*", "terms", "name.*", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
|
775 |
|
|
"name.rank.representations", "name.status.type.representations", "stateData.$" }); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
776 |
|
|
|
777 |
|
|
/*
|
778 |
|
|
* (non-Javadoc)
|
779 |
|
|
*
|
780 |
|
|
* @see
|
781 |
|
|
* eu.etaxonomy.taxeditor.model.IDirtyMarkableSelectionProvider#changed(
|
782 |
|
|
* java.lang.Object)
|
783 |
|
|
*/
|
784 |
|
|
@Override
|
785 |
|
|
public void changed(Object element) {
|
786 |
|
|
if (element != null) {
|
787 |
|
|
viewer.update(element, null);
|
788 |
6a534f27
|
Katja Luther
|
|
789 |
75902572
|
Katja Luther
|
if (element instanceof Taxon){
|
790 |
|
|
checklistEditorInput.addTaxonToSave((Taxon)element);
|
791 |
|
|
}
|
792 |
edb456d4
|
Katja Luther
|
setDirty(true);
|
793 |
|
|
}
|
794 |
|
|
}
|
795 |
|
|
|
796 |
|
|
/* (non-Javadoc)
|
797 |
|
|
* @see eu.etaxonomy.taxeditor.model.IDirtyMarkableSelectionProvider#forceDirty()
|
798 |
|
|
*/
|
799 |
|
|
@Override
|
800 |
|
|
public void forceDirty() {
|
801 |
|
|
changed(null);
|
802 |
|
|
}
|
803 |
|
|
|
804 |
|
|
public void setDirty(boolean dirty) {
|
805 |
|
|
this.dirty.setDirty(dirty);
|
806 |
|
|
}
|
807 |
|
|
|
808 |
|
|
/*
|
809 |
|
|
* (non-Javadoc)
|
810 |
|
|
*
|
811 |
|
|
* @see org.eclipse.ui.forms.editor.FormEditor#isDirty()
|
812 |
|
|
*/
|
813 |
278a5e0a
|
Katja Luther
|
@Override
|
814 |
edb456d4
|
Katja Luther
|
public boolean isDirty() {
|
815 |
|
|
return dirty.isDirty();
|
816 |
|
|
}
|
817 |
|
|
|
818 |
|
|
|
819 |
|
|
/**
|
820 |
|
|
* @return the labelProvider
|
821 |
|
|
*/
|
822 |
|
|
public ChecklistLabelProvider getLabelProvider() {
|
823 |
|
|
return labelProvider;
|
824 |
|
|
}
|
825 |
|
|
|
826 |
|
|
/* (non-Javadoc)
|
827 |
|
|
* @see eu.etaxonomy.cdm.persistence.hibernate.ICdmPostDataChangeObserver#update(eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap)
|
828 |
|
|
*/
|
829 |
|
|
@Override
|
830 |
|
|
public void update(CdmDataChangeMap arg0) {
|
831 |
|
|
// TODO Auto-generated method stub
|
832 |
|
|
|
833 |
|
|
}
|
834 |
|
|
|
835 |
|
|
/* (non-Javadoc)
|
836 |
|
|
* @see eu.etaxonomy.cdm.api.conversation.IConversationEnabled#getConversationHolder()
|
837 |
|
|
*/
|
838 |
|
|
@Override
|
839 |
|
|
public ConversationHolder getConversationHolder() {
|
840 |
|
|
return conversation;
|
841 |
|
|
}
|
842 |
|
|
|
843 |
9a1539bb
|
Katja Luther
|
/* (non-Javadoc)
|
844 |
|
|
* @see eu.etaxonomy.taxeditor.workbench.part.IE4SavablePart#save(org.eclipse.core.runtime.IProgressMonitor)
|
845 |
|
|
*/
|
846 |
|
|
@Override
|
847 |
|
|
@Persist
|
848 |
|
|
public void save(IProgressMonitor monitor) {
|
849 |
|
|
doSave(monitor);
|
850 |
|
|
}
|
851 |
|
|
|
852 |
edb456d4
|
Katja Luther
|
|
853 |
|
|
}
|