Revision ee1ed5a9
Added by Patrick Plitzner almost 11 years ago
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/MultiPageTaxonEditor.java | ||
---|---|---|
1 | 1 |
/** |
2 | 2 |
* Copyright (C) 2007 EDIT |
3 |
* European Distributed Institute of Taxonomy
|
|
3 |
* European Distributed Institute of Taxonomy |
|
4 | 4 |
* http://www.e-taxonomy.eu |
5 |
*
|
|
5 |
* |
|
6 | 6 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
7 | 7 |
* See LICENSE.TXT at the top of this package for the full license terms. |
8 | 8 |
*/ |
... | ... | |
32 | 32 |
import eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap; |
33 | 33 |
import eu.etaxonomy.taxeditor.editor.name.TaxonNameEditor; |
34 | 34 |
import eu.etaxonomy.taxeditor.editor.name.container.AbstractGroupedContainer; |
35 |
import eu.etaxonomy.taxeditor.model.AbstractUtility; |
|
35 | 36 |
import eu.etaxonomy.taxeditor.model.DataChangeBridge; |
36 | 37 |
import eu.etaxonomy.taxeditor.model.IDataChangeBehavior; |
37 | 38 |
import eu.etaxonomy.taxeditor.model.IDirtyMarkableSelectionProvider; |
... | ... | |
39 | 40 |
import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled; |
40 | 41 |
|
41 | 42 |
/** |
42 |
*
|
|
43 |
* |
|
43 | 44 |
* Generates the tabbed editor with <code>TaxonNameEditor</code> on top and tabs |
44 | 45 |
* for "Descriptions", "Concepts", "Geography", etc. |
45 |
*
|
|
46 |
* |
|
46 | 47 |
* @author p.ciardelli |
47 | 48 |
* @author n.hoffmann |
48 | 49 |
* @created 15.05.2008 |
... | ... | |
83 | 84 |
|
84 | 85 |
/* |
85 | 86 |
* (non-Javadoc) |
86 |
*
|
|
87 |
* |
|
87 | 88 |
* @see org.eclipse.ui.forms.editor.FormEditor#addPages() |
88 | 89 |
*/ |
89 | 90 |
/** {@inheritDoc} */ |
... | ... | |
107 | 108 |
// EditorUtil.showPropertySheet(); |
108 | 109 |
|
109 | 110 |
} catch (PartInitException e) { |
110 |
EditorUtil.error(getClass(), e);
|
|
111 |
AbstractUtility.error(getClass(), e);
|
|
111 | 112 |
} |
112 | 113 |
} |
113 | 114 |
|
... | ... | |
121 | 122 |
} |
122 | 123 |
monitor.worked(1); |
123 | 124 |
|
124 |
for (IEditorPart editorPage : getPages()) { |
|
125 |
if (editorPage instanceof TaxonNameEditor) { |
|
126 |
if (((TaxonNameEditor) editorPage).checkForEmptyNames()) { |
|
127 |
MessageDialog |
|
128 |
.openWarning( |
|
129 |
EditorUtil.getShell(), |
|
130 |
"No Name Specified", |
|
131 |
"An attempt was made to save a taxon or synonym with " |
|
132 |
+ "an empty name. Operation was cancelled."); |
|
133 |
return; |
|
134 |
} |
|
135 |
} |
|
136 |
|
|
137 |
editorPage.doSave(monitor); |
|
138 |
monitor.worked(1); |
|
139 |
} |
|
125 |
for (IEditorPart editorPage : getPages()) { |
|
126 |
if (editorPage instanceof TaxonNameEditor) { |
|
127 |
if (((TaxonNameEditor) editorPage).checkForEmptyNames()) { |
|
128 |
MessageDialog.openWarning(AbstractUtility.getShell(), "No Name Specified", |
|
129 |
"An attempt was made to save a taxon or synonym with " |
|
130 |
+ "an empty name. Operation was cancelled."); |
|
131 |
return; |
|
132 |
} |
|
133 |
} |
|
134 |
|
|
135 |
editorPage.doSave(monitor); |
|
136 |
monitor.worked(1); |
|
137 |
} |
|
140 | 138 |
|
141 | 139 |
// commit the conversation and start a new transaction immediately |
142 | 140 |
conversation.commit(true); |
143 | 141 |
monitor.worked(1); |
144 | 142 |
|
145 |
this.setDirty(false); |
|
146 |
monitor.worked(1); |
|
147 |
} catch (Exception e) { |
|
148 |
setFocus(); |
|
149 |
EditorUtil |
|
150 |
.errorDialog( |
|
151 |
"An error occurred while saving", |
|
152 |
getClass(), |
|
153 |
"An error occurred while saving the editor. Please close and reopen the taxon again.", |
|
154 |
e); |
|
155 |
disableEditor(true); |
|
156 |
} finally { |
|
157 |
monitor.done(); |
|
158 |
} |
|
143 |
this.setDirty(false); |
|
144 |
monitor.worked(1); |
|
145 |
} catch (Exception e) { |
|
146 |
setFocus(); |
|
147 |
AbstractUtility.errorDialog("An error occurred while saving", getClass(), |
|
148 |
"An error occurred while saving the editor. Please close and reopen the taxon again.", e); |
|
149 |
disableEditor(true); |
|
150 |
} finally { |
|
151 |
monitor.done(); |
|
152 |
} |
|
159 | 153 |
} |
160 | 154 |
|
161 | 155 |
private void disableEditor(boolean isOnError) { |
... | ... | |
163 | 157 |
if(isOnError){ |
164 | 158 |
editorPage.setOnError(); |
165 | 159 |
}else { |
166 |
editorPage.setDisabled();
|
|
160 |
editorPage.setDisabled(); |
|
167 | 161 |
} |
168 | 162 |
} |
169 | 163 |
conversation.unregisterForDataStoreChanges(this); |
... | ... | |
178 | 172 |
|
179 | 173 |
/* |
180 | 174 |
* (non-Javadoc) |
181 |
*
|
|
175 |
* |
|
182 | 176 |
* @see org.eclipse.ui.part.MultiPageEditorPart#isDirty() |
183 | 177 |
*/ |
184 | 178 |
/** |
185 | 179 |
* <p> |
186 | 180 |
* isDirty |
187 | 181 |
* </p> |
188 |
*
|
|
182 |
* |
|
189 | 183 |
* @return a boolean. |
190 | 184 |
*/ |
191 |
public boolean isDirty() { |
|
185 |
@Override |
|
186 |
public boolean isDirty() { |
|
192 | 187 |
return dirty; |
193 | 188 |
} |
194 | 189 |
|
195 | 190 |
/* |
196 | 191 |
* (non-Javadoc) |
197 |
*
|
|
192 |
* |
|
198 | 193 |
* @see org.eclipse.ui.forms.editor.FormEditor#editorDirtyStateChanged() |
199 | 194 |
*/ |
200 | 195 |
/** {@inheritDoc} */ |
... | ... | |
206 | 201 |
|
207 | 202 |
/** |
208 | 203 |
* {@inheritDoc} |
209 |
*
|
|
204 |
* |
|
210 | 205 |
* Checks whether nested editors are calling |
211 | 206 |
* <code>firePropertyChange(PROP_DIRTY)</code> to signal an edit has taken |
212 | 207 |
* place before passing property change along to |
... | ... | |
214 | 209 |
*/ |
215 | 210 |
/* |
216 | 211 |
* (non-Javadoc) |
217 |
*
|
|
212 |
* |
|
218 | 213 |
* @see org.eclipse.ui.part.MultiPageEditorPart#handlePropertyChange(int) |
219 | 214 |
*/ |
220 |
protected void handlePropertyChange(int propertyId) { |
|
215 |
@Override |
|
216 |
protected void handlePropertyChange(int propertyId) { |
|
221 | 217 |
if (propertyId == PROP_DIRTY) { |
222 | 218 |
setDirty(true); |
223 | 219 |
} |
... | ... | |
240 | 236 |
public void init(IEditorSite site, IEditorInput input) |
241 | 237 |
throws PartInitException { |
242 | 238 |
|
243 |
if (!(input instanceof TaxonEditorInput)) |
|
244 |
throw new PartInitException(
|
|
239 |
if (!(input instanceof TaxonEditorInput)) {
|
|
240 |
throw new PartInitException(
|
|
245 | 241 |
"Invalid Input: Must be TaxonEditorInput"); |
242 |
} |
|
246 | 243 |
|
247 | 244 |
this.input = (TaxonEditorInput) input; |
248 | 245 |
|
... | ... | |
289 | 286 |
setPartName(partName); |
290 | 287 |
} |
291 | 288 |
|
292 |
/**
|
|
293 |
* {@inheritDoc}
|
|
294 |
*
|
|
295 |
* Editor pages call this in their postOperation to notify the
|
|
296 |
* MultiPageTaxonEditor of unsaved changes
|
|
297 |
*/
|
|
298 |
public void changed(Object element) {
|
|
299 |
// setDirty(true);
|
|
300 |
dirty = true;
|
|
301 |
super.editorDirtyStateChanged();
|
|
302 |
if (element instanceof TaxonBase) {
|
|
303 |
TaxonNameEditor page = (TaxonNameEditor) getPage(Page.NAME);
|
|
304 |
AbstractGroupedContainer container = page
|
|
305 |
.getContainer((TaxonBase) element);
|
|
306 |
if (container != null) {
|
|
307 |
container.refresh();
|
|
308 |
}
|
|
309 |
}
|
|
310 |
}
|
|
289 |
/**
|
|
290 |
* {@inheritDoc}
|
|
291 |
*
|
|
292 |
* Editor pages call this in their postOperation to notify the
|
|
293 |
* MultiPageTaxonEditor of unsaved changes
|
|
294 |
*/
|
|
295 |
@Override
|
|
296 |
public void changed(Object element) {
|
|
297 |
// setDirty(true);
|
|
298 |
dirty = true;
|
|
299 |
super.editorDirtyStateChanged();
|
|
300 |
if (element instanceof TaxonBase) {
|
|
301 |
TaxonNameEditor page = (TaxonNameEditor) getPage(Page.NAME);
|
|
302 |
AbstractGroupedContainer container = page.getContainer((TaxonBase) element);
|
|
303 |
if (container != null) {
|
|
304 |
container.refresh();
|
|
305 |
}
|
|
306 |
}
|
|
307 |
}
|
|
311 | 308 |
|
312 | 309 |
/** |
313 | 310 |
* The accepted taxon that is the input for this editor |
314 |
*
|
|
311 |
* |
|
315 | 312 |
* @return the accepted taxon |
316 | 313 |
*/ |
317 | 314 |
public Taxon getTaxon() { |
... | ... | |
320 | 317 |
|
321 | 318 |
/* |
322 | 319 |
* (non-Javadoc) |
323 |
*
|
|
320 |
* |
|
324 | 321 |
* @see |
325 | 322 |
* eu.etaxonomy.cdm.api.conversation.IConversationEnabled#getConversationHolder |
326 | 323 |
* () |
... | ... | |
329 | 326 |
* <p> |
330 | 327 |
* getConversationHolder |
331 | 328 |
* </p> |
332 |
*
|
|
329 |
* |
|
333 | 330 |
* @return a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder} |
334 | 331 |
* object. |
335 | 332 |
*/ |
336 |
public ConversationHolder getConversationHolder() { |
|
333 |
@Override |
|
334 |
public ConversationHolder getConversationHolder() { |
|
337 | 335 |
return conversation; |
338 | 336 |
} |
339 | 337 |
|
... | ... | |
341 | 339 |
* <p> |
342 | 340 |
* setConversationHolder |
343 | 341 |
* </p> |
344 |
*
|
|
342 |
* |
|
345 | 343 |
* @param conversation |
346 | 344 |
* a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder} |
347 | 345 |
* object. |
... | ... | |
354 | 352 |
* <p> |
355 | 353 |
* Getter for the field <code>undoContext</code>. |
356 | 354 |
* </p> |
357 |
*
|
|
355 |
* |
|
358 | 356 |
* @return a {@link org.eclipse.core.commands.operations.IUndoContext} |
359 | 357 |
* object. |
360 | 358 |
*/ |
... | ... | |
366 | 364 |
* <p> |
367 | 365 |
* Setter for the field <code>undoContext</code>. |
368 | 366 |
* </p> |
369 |
*
|
|
367 |
* |
|
370 | 368 |
* @param undoContext |
371 | 369 |
* a {@link org.eclipse.core.commands.operations.IUndoContext} |
372 | 370 |
* object. |
... | ... | |
385 | 383 |
getActiveEditor().setFocus(); |
386 | 384 |
} |
387 | 385 |
|
388 |
/* |
|
389 |
* (non-Javadoc) |
|
390 |
* |
|
391 |
* @see |
|
392 |
* eu.etaxonomy.cdm.persistence.hibernate.ICdmPostCrudObserver#update(eu |
|
393 |
* .etaxonomy.cdm.persistence.hibernate.CdmCrudEvent) |
|
394 |
*/ |
|
395 |
/** {@inheritDoc} */ |
|
396 |
public void update(CdmDataChangeMap events) { |
|
397 |
if (dataChangeBehavior == null) { |
|
398 |
dataChangeBehavior = new MultiPageTaxonEditorDataChangeBehaviour( |
|
399 |
this); |
|
400 |
} |
|
401 |
|
|
402 |
DataChangeBridge.handleDataChange(events, dataChangeBehavior); |
|
403 |
} |
|
404 |
|
|
405 |
/* |
|
406 |
* (non-Javadoc) |
|
407 |
* |
|
408 |
* @see |
|
409 |
* eu.etaxonomy.taxeditor.store.operations.IPostOperationEnabled#postOperation |
|
410 |
* () |
|
411 |
*/ |
|
412 |
/** {@inheritDoc} */ |
|
413 |
public boolean postOperation(CdmBase objectAffectedByOperation) { |
|
414 |
setDirty(true); |
|
415 |
|
|
416 |
for (IEditorPart editor : this.getPages()) { |
|
417 |
if (editor instanceof IPostOperationEnabled) { |
|
418 |
((IPostOperationEnabled) editor) |
|
419 |
.postOperation(objectAffectedByOperation); |
|
420 |
} else { |
|
421 |
EditorUtil.warn(getClass(), |
|
422 |
"postOperation not enabled for editor " + editor); |
|
423 |
} |
|
424 |
} |
|
425 |
EditorUtil |
|
426 |
.warn(getClass(), |
|
427 |
"postOperation called on MultiPageTaxonEditor. Can you make it more specific?"); |
|
428 |
|
|
429 |
return false; |
|
430 |
} |
|
386 |
/* |
|
387 |
* (non-Javadoc) |
|
388 |
* |
|
389 |
* @see |
|
390 |
* eu.etaxonomy.cdm.persistence.hibernate.ICdmPostCrudObserver#update(eu |
|
391 |
* .etaxonomy.cdm.persistence.hibernate.CdmCrudEvent) |
|
392 |
*/ |
|
393 |
/** {@inheritDoc} */ |
|
394 |
@Override |
|
395 |
public void update(CdmDataChangeMap events) { |
|
396 |
if (dataChangeBehavior == null) { |
|
397 |
dataChangeBehavior = new MultiPageTaxonEditorDataChangeBehaviour(this); |
|
398 |
} |
|
399 |
|
|
400 |
DataChangeBridge.handleDataChange(events, dataChangeBehavior); |
|
401 |
} |
|
402 |
|
|
403 |
/* |
|
404 |
* (non-Javadoc) |
|
405 |
* |
|
406 |
* @see |
|
407 |
* eu.etaxonomy.taxeditor.store.operations.IPostOperationEnabled#postOperation |
|
408 |
* () |
|
409 |
*/ |
|
410 |
/** {@inheritDoc} */ |
|
411 |
@Override |
|
412 |
public boolean postOperation(CdmBase objectAffectedByOperation) { |
|
413 |
setDirty(true); |
|
414 |
|
|
415 |
for (IEditorPart editor : this.getPages()) { |
|
416 |
if (editor instanceof IPostOperationEnabled) { |
|
417 |
((IPostOperationEnabled) editor).postOperation(objectAffectedByOperation); |
|
418 |
} else { |
|
419 |
AbstractUtility.warn(getClass(), "postOperation not enabled for editor " + editor); |
|
420 |
} |
|
421 |
} |
|
422 |
AbstractUtility.warn(getClass(), "postOperation called on MultiPageTaxonEditor. Can you make it more specific?"); |
|
423 |
|
|
424 |
return false; |
|
425 |
} |
|
431 | 426 |
|
432 | 427 |
/** |
433 | 428 |
* Returns an <code>IEditorPart</code> implementation by type |
434 |
*
|
|
429 |
* |
|
435 | 430 |
* @param page |
436 | 431 |
* the page type |
437 | 432 |
* @return a {@link eu.etaxonomy.taxeditor.editor.IMultiPageTaxonEditorPage} |
... | ... | |
449 | 444 |
/** |
450 | 445 |
* Return a list of <code>AbstractTaxonEditor</code>s registered with this |
451 | 446 |
* <code>MultiPageTaxonEditor</code>. |
452 |
*
|
|
447 |
* |
|
453 | 448 |
* @return a {@link java.util.List} object. |
454 | 449 |
*/ |
455 | 450 |
public List<IMultiPageTaxonEditorPage> getPages() { |
... | ... | |
463 | 458 |
|
464 | 459 |
/** |
465 | 460 |
* Refreshes a certain page of the MultipageTaxonEditor |
466 |
*
|
|
461 |
* |
|
467 | 462 |
* @param page |
468 | 463 |
* a {@link eu.etaxonomy.taxeditor.editor.Page} object. |
469 | 464 |
* @return a boolean. |
... | ... | |
475 | 470 |
/** |
476 | 471 |
* Refreshes a certain page of the MultipageTaxonEditor and sets focus to |
477 | 472 |
* that page |
478 |
*
|
|
473 |
* |
|
479 | 474 |
* @param page |
480 | 475 |
* a {@link eu.etaxonomy.taxeditor.editor.Page} object. |
481 | 476 |
* @param focus |
... | ... | |
491 | 486 |
* <p> |
492 | 487 |
* onComplete |
493 | 488 |
* </p> |
494 |
*
|
|
489 |
* |
|
495 | 490 |
* @return a boolean. |
496 | 491 |
*/ |
497 |
public boolean onComplete() { |
|
492 |
@Override |
|
493 |
public boolean onComplete() { |
|
498 | 494 |
return false; |
499 | 495 |
} |
500 | 496 |
|
501 |
/** |
|
502 |
* Reloads the data for this |
|
503 |
*/ |
|
504 |
public void reload() { |
|
505 |
if (isDirty()) { |
|
506 |
EditorUtil |
|
507 |
.warningDialog( |
|
508 |
"Editor has unsaved data", |
|
509 |
getClass(), |
|
510 |
"This editor can not be " |
|
511 |
+ "refreshed because it contains unsaved data. Refreshing " |
|
512 |
+ "this editor would discard the changes. Please save this editor, " |
|
513 |
+ "close and reopen it manually in order to get the latest content"); |
|
514 |
} else { |
|
515 |
TaxonEditorInput input = (TaxonEditorInput) getEditorInput(); |
|
516 |
|
|
517 |
UUID uuid = input.getTaxonNode().getUuid(); |
|
518 |
|
|
519 |
conversation.clear(); |
|
520 |
|
|
521 |
try { |
|
522 |
TaxonEditorInput newInput = TaxonEditorInput.NewInstance(uuid); |
|
523 |
setInput(newInput); |
|
524 |
for (IMultiPageTaxonEditorPage editorPart : getPages()) { |
|
525 |
editorPart.redraw(); |
|
526 |
} |
|
527 |
} catch (Exception e) { |
|
528 |
EditorUtil.errorDialog("Error refreshing editor", getClass(), |
|
529 |
"Could not refresh this editor", e); |
|
530 |
} |
|
531 |
} |
|
532 |
} |
|
533 |
|
|
497 |
/** |
|
498 |
* Reloads the data for this |
|
499 |
*/ |
|
500 |
public void reload() { |
|
501 |
if (isDirty()) { |
|
502 |
AbstractUtility.warningDialog("Editor has unsaved data", getClass(), "This editor can not be " |
|
503 |
+ "refreshed because it contains unsaved data. Refreshing " |
|
504 |
+ "this editor would discard the changes. Please save this editor, " |
|
505 |
+ "close and reopen it manually in order to get the latest content"); |
|
506 |
} else { |
|
507 |
TaxonEditorInput input = (TaxonEditorInput) getEditorInput(); |
|
508 |
|
|
509 |
UUID uuid = input.getTaxonNode().getUuid(); |
|
510 |
|
|
511 |
conversation.clear(); |
|
512 |
|
|
513 |
try { |
|
514 |
TaxonEditorInput newInput = TaxonEditorInput.NewInstance(uuid); |
|
515 |
setInput(newInput); |
|
516 |
for (IMultiPageTaxonEditorPage editorPart : getPages()) { |
|
517 |
editorPart.redraw(); |
|
518 |
} |
|
519 |
} catch (Exception e) { |
|
520 |
AbstractUtility.errorDialog("Error refreshing editor", getClass(), "Could not refresh this editor", e); |
|
521 |
} |
|
522 |
} |
|
523 |
} |
|
524 |
|
|
534 | 525 |
@Override |
535 | 526 |
public String toString() { |
536 | 527 |
return String.format("%s[%s]", this.getClass().getSimpleName(), getEditorInput()); |
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/uses/UsesViewPart.java | ||
---|---|---|
1 | 1 |
/** |
2 | 2 |
* Copyright (C) 2011 EDIT |
3 |
* European Distributed Institute of Taxonomy
|
|
3 |
* European Distributed Institute of Taxonomy |
|
4 | 4 |
* http://www.e-taxonomy.eu |
5 |
*
|
|
5 |
* |
|
6 | 6 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
7 | 7 |
* See LICENSE.TXT at the top of this package for the full license terms. |
8 | 8 |
*/ |
... | ... | |
19 | 19 |
import eu.etaxonomy.taxeditor.editor.view.descriptive.DescriptionElementDropAdapter; |
20 | 20 |
import eu.etaxonomy.taxeditor.editor.view.descriptive.DescriptionElementTransfer; |
21 | 21 |
import eu.etaxonomy.taxeditor.editor.view.descriptive.DescriptiveViewPart; |
22 |
import eu.etaxonomy.taxeditor.model.IPartContentHasDetails; |
|
23 |
import eu.etaxonomy.taxeditor.model.IPartContentHasSupplementalData; |
|
24 | 22 |
|
25 | 23 |
|
26 | 24 |
/** |
27 |
* The Class create a speific Use View to keep the taxonomic view clean |
|
28 |
* @author a.theys
|
|
25 |
* The Class create a specific Use View to keep the taxonomic view clean
|
|
26 |
* @author a.theys |
|
29 | 27 |
* @created mar 13, 2012 |
30 | 28 |
* @version 1.0 |
31 | 29 |
*/ |
32 |
public class UsesViewPart extends DescriptiveViewPart implements IPartContentHasDetails, IPartContentHasSupplementalData {
|
|
30 |
public class UsesViewPart extends DescriptiveViewPart { |
|
33 | 31 |
|
34 | 32 |
/** Constant <code>ID="eu.etaxonomy.taxeditor.editor.view.uses"</code> */ |
35 | 33 |
public static final String ID = "eu.etaxonomy.taxeditor.editor.view.uses"; |
36 | 34 |
/** {@inheritDoc} */ |
37 | 35 |
@Override |
38 | 36 |
public void createViewer(Composite parent) { |
39 |
|
|
37 |
|
|
40 | 38 |
viewer = new TreeViewer(new Tree(parent, SWT.MULTI | SWT.H_SCROLL |
41 | 39 |
| SWT.V_SCROLL | SWT.FULL_SELECTION)); |
42 | 40 |
viewer.setContentProvider(new UsesContentProvider(featureNodeContainerCache)); |
43 | 41 |
viewer.setLabelProvider(new UsesLabelProvider()); |
44 | 42 |
viewer.setAutoExpandLevel(2); |
45 |
|
|
46 |
|
|
47 |
|
|
43 |
|
|
44 |
|
|
45 |
|
|
48 | 46 |
Transfer[] transfers = new Transfer[] { DescriptionElementTransfer.getInstance() }; |
49 | 47 |
viewer.addDragSupport(dndOperations, transfers, new DescriptionElementDragListener( |
50 | 48 |
this)); |
51 | 49 |
viewer.addDropSupport(dndOperations, transfers, |
52 | 50 |
new DescriptionElementDropAdapter(viewer)); |
53 |
|
|
51 |
|
|
54 | 52 |
// Propagate selection from viewer |
55 | 53 |
getSite().setSelectionProvider(viewer); |
56 |
|
|
57 |
showAllElementsAction = new ToggleDescriptionAction(false);
|
|
54 |
|
|
55 |
showAllElementsAction = new ToggleDescriptionAction(false); |
|
58 | 56 |
hideAllElementsAction = new ToggleDescriptionAction(true); |
59 |
|
|
57 |
|
|
60 | 58 |
// Add context menu to tree |
61 | 59 |
createMenu(); |
62 |
|
|
60 |
|
|
63 | 61 |
createToolbar(); |
64 | 62 |
|
65 | 63 |
} |
66 |
|
|
64 |
|
|
67 | 65 |
/** {@inheritDoc} */ |
68 | 66 |
@Override |
69 | 67 |
public boolean postOperation(CdmBase objectAffectedByOperation) { |
70 | 68 |
viewer.refresh(); |
71 | 69 |
return super.postOperation(objectAffectedByOperation); |
72 | 70 |
} |
73 |
|
|
71 |
|
|
74 | 72 |
|
75 | 73 |
|
76 | 74 |
} |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/AbstractCdmEditorViewPart.java | ||
---|---|---|
1 | 1 |
/** |
2 |
*
|
|
2 |
* |
|
3 | 3 |
*/ |
4 | 4 |
package eu.etaxonomy.taxeditor.view; |
5 | 5 |
|
... | ... | |
7 | 7 |
import org.eclipse.ui.IEditorPart; |
8 | 8 |
|
9 | 9 |
import eu.etaxonomy.taxeditor.editor.ISecuredEditor; |
10 |
import eu.etaxonomy.taxeditor.model.AbstractUtility; |
|
10 | 11 |
import eu.etaxonomy.taxeditor.model.IDirtyMarkableSelectionProvider; |
11 |
import eu.etaxonomy.taxeditor.store.StoreUtil; |
|
12 | 12 |
|
13 | 13 |
/** |
14 | 14 |
* <p> |
15 | 15 |
* Abstract AbstractCdmEditorViewPart class. |
16 | 16 |
* </p> |
17 |
*
|
|
17 |
* |
|
18 | 18 |
* @author n.hoffmann |
19 | 19 |
* @created Sep 21, 2010 |
20 | 20 |
* @version 1.0 |
... | ... | |
23 | 23 |
|
24 | 24 |
/* |
25 | 25 |
* (non-Javadoc) |
26 |
*
|
|
26 |
* |
|
27 | 27 |
* @see |
28 | 28 |
* eu.etaxonomy.taxeditor.model.AbstractCdmViewPart#createPartControl(org |
29 | 29 |
* .eclipse.swt.widgets.Composite) |
... | ... | |
31 | 31 |
/** {@inheritDoc} */ |
32 | 32 |
@Override |
33 | 33 |
public void createPartControl(Composite parent) { |
34 |
|
|
35 | 34 |
super.createPartControl(parent); |
36 |
|
|
37 | 35 |
} |
38 | 36 |
|
39 | 37 |
/** |
40 | 38 |
* <p> |
41 | 39 |
* getEditor |
42 | 40 |
* </p> |
43 |
*
|
|
41 |
* |
|
44 | 42 |
* @return the currently active editor |
45 | 43 |
*/ |
46 | 44 |
public IEditorPart getEditor() { |
47 |
return StoreUtil.getActiveEditor();
|
|
45 |
return AbstractUtility.getActiveEditor();
|
|
48 | 46 |
} |
49 |
|
|
47 |
|
|
50 | 48 |
/** {@inheritDoc} */ |
51 | 49 |
@Override |
52 | 50 |
public void setFocus() { |
53 | 51 |
super.setFocus(); |
54 |
|
|
55 |
if(getEditor() != null && ISecuredEditor.class.isAssignableFrom(getEditor().getClass())){
|
|
52 |
|
|
53 |
if(getEditor() != null && ISecuredEditor.class.isAssignableFrom(getEditor().getClass())){ |
|
56 | 54 |
boolean doEnable = ((ISecuredEditor)getEditor()).permissionsSatisfied(); |
57 | 55 |
setEnabled(doEnable); |
58 | 56 |
} |
59 |
}
|
|
57 |
}
|
|
60 | 58 |
|
61 |
/** {@inheritDoc} */ |
|
62 |
@Override |
|
63 |
public void changed(Object object) { |
|
64 |
if (part instanceof AbstractCdmViewPart) { |
|
65 |
((AbstractCdmViewPart) part).changed(object); |
|
66 |
} else { |
|
67 |
IEditorPart editor = getEditor(); |
|
68 |
if (editor != null |
|
69 |
&& editor instanceof IDirtyMarkableSelectionProvider) { |
|
70 |
|
|
71 |
((IDirtyMarkableSelectionProvider) editor).changed(object); |
|
72 |
|
|
73 |
} |
|
74 |
} |
|
75 |
} |
|
59 |
/** {@inheritDoc} */ |
|
60 |
@Override |
|
61 |
public void changed(Object object) { |
|
62 |
if (part instanceof AbstractCdmViewPart) { |
|
63 |
((AbstractCdmViewPart) part).changed(object); |
|
64 |
} else { |
|
65 |
IEditorPart editor = getEditor(); |
|
66 |
if (editor != null && editor instanceof IDirtyMarkableSelectionProvider) { |
|
67 |
((IDirtyMarkableSelectionProvider) editor).changed(object); |
|
68 |
} |
|
69 |
} |
|
70 |
} |
|
76 | 71 |
|
77 | 72 |
} |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/AbstractCdmViewPart.java | ||
---|---|---|
28 | 28 |
import eu.etaxonomy.cdm.api.conversation.IConversationEnabled; |
29 | 29 |
import eu.etaxonomy.cdm.model.common.CdmBase; |
30 | 30 |
import eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap; |
31 |
import eu.etaxonomy.taxeditor.model.AbstractUtility; |
|
31 | 32 |
import eu.etaxonomy.taxeditor.model.IDirtyMarkableSelectionProvider; |
32 | 33 |
import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled; |
33 |
import eu.etaxonomy.taxeditor.store.StoreUtil; |
|
34 | 34 |
|
35 | 35 |
/** |
36 | 36 |
* <p>Abstract AbstractCdmViewPart class.</p> |
... | ... | |
73 | 73 |
* |
74 | 74 |
*/ |
75 | 75 |
private void setInitialSelection() { |
76 |
selectionChanged(StoreUtil.getActivePart(), getInitialSelection());
|
|
76 |
selectionChanged(AbstractUtility.getActivePart(), getInitialSelection());
|
|
77 | 77 |
} |
78 | 78 |
|
79 | 79 |
/** |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/detail/DetailsViewPart.java | ||
---|---|---|
19 | 19 |
|
20 | 20 |
import eu.etaxonomy.cdm.model.common.CdmBase; |
21 | 21 |
import eu.etaxonomy.cdm.model.description.Feature; |
22 |
import eu.etaxonomy.taxeditor.model.AbstractUtility; |
|
22 | 23 |
import eu.etaxonomy.taxeditor.model.FeatureNodeContainer; |
24 |
import eu.etaxonomy.taxeditor.model.IPartContentHasDetails; |
|
23 | 25 |
import eu.etaxonomy.taxeditor.model.IPartContentHasSupplementalData; |
24 |
import eu.etaxonomy.taxeditor.store.StoreUtil; |
|
25 | 26 |
import eu.etaxonomy.taxeditor.view.AbstractCdmEditorViewPart; |
26 |
import eu.etaxonomy.taxeditor.view.AbstractCdmViewPart; |
|
27 | 27 |
|
28 | 28 |
/** |
29 | 29 |
* <p>DetailsViewPart class.</p> |
... | ... | |
51 | 51 |
/** {@inheritDoc} */ |
52 | 52 |
@Override |
53 | 53 |
public void selectionChanged(IWorkbenchPart part, ISelection selection) { |
54 |
if(StoreUtil.getActiveEditor() == null){
|
|
54 |
if(AbstractUtility.getActiveEditor() == null){
|
|
55 | 55 |
showEmptyPage(); |
56 | 56 |
return; |
57 | 57 |
} |
... | ... | |
66 | 66 |
|
67 | 67 |
IStructuredSelection structuredSelection = (IStructuredSelection) selection; |
68 | 68 |
|
69 |
if((part instanceof IEditorPart) || (part instanceof AbstractCdmViewPart)) {
|
|
69 |
if((part instanceof IEditorPart) || (part instanceof IPartContentHasDetails)) {
|
|
70 | 70 |
if(structuredSelection.size() != 1){ |
71 | 71 |
showEmptyPage(); |
72 | 72 |
return; |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/supplementaldata/SupplementalDataViewPart.java | ||
---|---|---|
1 | 1 |
// $Id$ |
2 | 2 |
/** |
3 | 3 |
* Copyright (C) 2007 EDIT |
4 |
* European Distributed Institute of Taxonomy
|
|
4 |
* European Distributed Institute of Taxonomy |
|
5 | 5 |
* http://www.e-taxonomy.eu |
6 |
*
|
|
6 |
* |
|
7 | 7 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
8 | 8 |
* See LICENSE.TXT at the top of this package for the full license terms. |
9 | 9 |
*/ |
... | ... | |
20 | 20 |
|
21 | 21 |
import eu.etaxonomy.cdm.api.facade.DerivedUnitFacade; |
22 | 22 |
import eu.etaxonomy.cdm.model.description.PolytomousKeyNode; |
23 |
import eu.etaxonomy.taxeditor.model.AbstractUtility; |
|
23 | 24 |
import eu.etaxonomy.taxeditor.model.FeatureNodeContainer; |
24 |
import eu.etaxonomy.taxeditor.store.StoreUtil;
|
|
25 |
import eu.etaxonomy.taxeditor.model.IPartContentHasSupplementalData;
|
|
25 | 26 |
import eu.etaxonomy.taxeditor.view.AbstractCdmEditorViewPart; |
26 |
import eu.etaxonomy.taxeditor.view.AbstractCdmViewPart; |
|
27 |
import eu.etaxonomy.taxeditor.view.detail.CdmSectionPart; |
|
28 | 27 |
|
29 | 28 |
|
30 | 29 |
/** |
... | ... | |
40 | 39 |
public static final String ID = "eu.etaxonomy.taxeditor.view.supplementalData"; |
41 | 40 |
|
42 | 41 |
private SupplementalDataViewer viewer; |
43 |
|
|
42 |
|
|
44 | 43 |
/* (non-Javadoc) |
45 | 44 |
* @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite) |
46 | 45 |
*/ |
... | ... | |
52 | 51 |
|
53 | 52 |
|
54 | 53 |
/** {@inheritDoc} */ |
55 |
public void selectionChanged(IWorkbenchPart part, ISelection selection) { |
|
56 |
if(StoreUtil.getActiveEditor() == null){ |
|
54 |
@Override |
|
55 |
public void selectionChanged(IWorkbenchPart part, ISelection selection) { |
|
56 |
if(AbstractUtility.getActiveEditor() == null){ |
|
57 | 57 |
showEmptyPage(); |
58 | 58 |
return; |
59 | 59 |
} |
60 |
|
|
61 |
if(((part instanceof EditorPart) || (part instanceof AbstractCdmViewPart)) && selection instanceof IStructuredSelection) { |
|
62 |
IStructuredSelection structuredSelection = (IStructuredSelection) selection; |
|
60 |
|
|
61 |
if(!(selection instanceof IStructuredSelection)){ |
|
62 |
return; |
|
63 |
} |
|
64 |
|
|
65 |
IStructuredSelection structuredSelection = (IStructuredSelection) selection; |
|
66 |
|
|
67 |
if((part instanceof EditorPart || part instanceof IPartContentHasSupplementalData)) { |
|
63 | 68 |
if(structuredSelection.size() != 1){ |
64 | 69 |
showEmptyPage(); |
65 | 70 |
return; |
66 | 71 |
} |
67 |
|
|
72 |
|
|
68 | 73 |
// do not show supplemental data for feature nodes |
69 | 74 |
if(structuredSelection.getFirstElement() instanceof FeatureNodeContainer){ |
70 | 75 |
showEmptyPage(); |
71 | 76 |
return; |
72 | 77 |
} |
73 |
if(structuredSelection.getFirstElement() instanceof DerivedUnitFacade){ |
|
78 |
else if(structuredSelection.getFirstElement() instanceof DerivedUnitFacade){
|
|
74 | 79 |
return; |
75 | 80 |
} |
76 |
if(structuredSelection.getFirstElement() instanceof PolytomousKeyNode){ |
|
81 |
else if(structuredSelection.getFirstElement() instanceof PolytomousKeyNode){
|
|
77 | 82 |
structuredSelection = new StructuredSelection(((PolytomousKeyNode)structuredSelection.getFirstElement()).getKey()); |
78 | 83 |
} |
79 | 84 |
showViewer(part, structuredSelection); |
80 | 85 |
}else{ |
81 |
showEmptyPage();
|
|
86 |
showEmptyPage(); |
|
82 | 87 |
} |
83 | 88 |
} |
84 |
|
|
89 |
|
|
85 | 90 |
/** {@inheritDoc} */ |
86 | 91 |
@Override |
87 | 92 |
public void dispose() { |
... | ... | |
101 | 106 |
* |
102 | 107 |
* @return a boolean. |
103 | 108 |
*/ |
104 |
public boolean onComplete() { |
|
109 |
@Override |
|
110 |
public boolean onComplete() { |
|
105 | 111 |
// TODO Auto-generated method stub |
106 | 112 |
return false; |
107 | 113 |
} |
108 |
|
|
109 |
|
|
114 |
|
|
115 |
|
|
110 | 116 |
} |
Also available in: Unified diff
simplified code for opening editor in TaxonNavigator