Revision 0fa0610e
Added by Patrick Plitzner over 6 years ago
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/key/AbstractGraphKeyEditor.java | ||
---|---|---|
93 | 93 |
throws PartInitException { |
94 | 94 |
setSite(site); |
95 | 95 |
setInput(input); |
96 |
formFactory = new CdmFormFactory(site.getShell().getDisplay()); |
|
96 |
// formFactory = new CdmFormFactory(site.getShell().getDisplay());
|
|
97 | 97 |
} |
98 | 98 |
|
99 | 99 |
/* |
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/key/polytomous/PolytomousKeyViewPart.java | ||
---|---|---|
25 | 25 |
import org.eclipse.swt.layout.GridLayout; |
26 | 26 |
import org.eclipse.swt.widgets.Composite; |
27 | 27 |
import org.eclipse.swt.widgets.Control; |
28 |
import org.eclipse.swt.widgets.Display; |
|
29 | 28 |
import org.eclipse.swt.widgets.Event; |
30 | 29 |
import org.eclipse.swt.widgets.Menu; |
31 | 30 |
import org.eclipse.swt.widgets.Text; |
... | ... | |
120 | 119 |
private ListViewer viewer; |
121 | 120 |
private ConversationHolder conversation; |
122 | 121 |
private IContextListener contextListener; |
123 |
private final CdmFormFactory formFactory;
|
|
122 |
private CdmFormFactory formFactory; |
|
124 | 123 |
private Text text_filter; |
125 | 124 |
private ICdmEntitySession cdmEntitySession; |
126 | 125 |
|
127 | 126 |
private PolytomousKeyViewPartDataChangeBehavior dataChangeBehavior; |
128 | 127 |
|
129 | 128 |
public PolytomousKeyViewPart(){ |
130 |
formFactory = new CdmFormFactory(Display.getDefault()); |
|
129 |
// formFactory = new CdmFormFactory(Display.getDefault());
|
|
131 | 130 |
} |
132 | 131 |
|
133 | 132 |
/* (non-Javadoc) |
... | ... | |
171 | 170 |
} |
172 | 171 |
|
173 | 172 |
public void openSelectedKeyNodes() { |
174 |
ICommandService commandService = (ICommandService)getSite().getService(ICommandService.class);
|
|
173 |
ICommandService commandService = getSite().getService(ICommandService.class); |
|
175 | 174 |
|
176 | 175 |
Command command = commandService.getCommand(OPEN_COMMAND_ID); |
177 | 176 |
if(command.isEnabled()) { |
178 |
IHandlerService handlerService = (IHandlerService)getSite().getService(IHandlerService.class);
|
|
177 |
IHandlerService handlerService = getSite().getService(IHandlerService.class); |
|
179 | 178 |
try { |
180 | 179 |
handlerService.executeCommand(OPEN_COMMAND_ID, null); |
181 | 180 |
} catch (NotDefinedException e) { |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/event/EventUtility.java | ||
---|---|---|
37 | 37 |
} |
38 | 38 |
|
39 | 39 |
@Inject |
40 |
@Optional |
|
41 | 40 |
private void updateCurrentActivePart(@Named(IServiceConstants.ACTIVE_PART)MPart activePart){ |
42 |
EventUtility.activePart = activePart; |
|
41 |
if(activePart!=null){ |
|
42 |
EventUtility.activePart = activePart; |
|
43 |
} |
|
43 | 44 |
} |
44 | 45 |
|
45 | 46 |
@Inject |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/model/AbstractUtility.java | ||
---|---|---|
46 | 46 |
import org.eclipse.core.runtime.jobs.ISchedulingRule; |
47 | 47 |
import org.eclipse.core.runtime.jobs.Job; |
48 | 48 |
import org.eclipse.e4.ui.model.application.ui.basic.MPart; |
49 |
import org.eclipse.e4.ui.workbench.modeling.EPartService; |
|
49 | 50 |
import org.eclipse.jface.action.IStatusLineManager; |
50 | 51 |
import org.eclipse.jface.operation.IRunnableWithProgress; |
51 | 52 |
import org.eclipse.jface.resource.ColorRegistry; |
... | ... | |
88 | 89 |
import eu.etaxonomy.taxeditor.store.CdmStore; |
89 | 90 |
import eu.etaxonomy.taxeditor.store.internal.TaxeditorStorePlugin; |
90 | 91 |
import eu.etaxonomy.taxeditor.ui.dialog.ReportTextDialog; |
91 |
import eu.etaxonomy.taxeditor.view.AbstractCdmDataViewer;
|
|
92 |
import eu.etaxonomy.taxeditor.view.detail.DetailsViewPart;
|
|
92 |
import eu.etaxonomy.taxeditor.view.e4.AbstractCdmDataViewerE4;
|
|
93 |
import eu.etaxonomy.taxeditor.view.e4.details.DetailsPartE4;
|
|
93 | 94 |
import eu.etaxonomy.taxeditor.workbench.part.IE4SavablePart; |
94 | 95 |
|
95 | 96 |
/** |
... | ... | |
614 | 615 |
return null; |
615 | 616 |
} |
616 | 617 |
|
617 |
public static DetailsViewPart getDetailsView() { |
|
618 |
return (DetailsViewPart) getView(DetailsViewPart.ID, false); |
|
618 |
public static DetailsPartE4 getDetailsView(EPartService partService) { |
|
619 |
MPart part = partService.findPart("eu.etaxonomy.taxeditor.view.e4.details.DetailsPartE4"); |
|
620 |
if(part!=null){ |
|
621 |
return (DetailsPartE4) part.getObject(); |
|
622 |
} |
|
623 |
return null; |
|
619 | 624 |
} |
620 | 625 |
|
621 |
public static void refreshDetailsViewer() { |
|
622 |
if (getDetailsView() != null) { |
|
623 |
((AbstractCdmDataViewer) getDetailsView().getViewer()).refresh();
|
|
626 |
public static void refreshDetailsViewer(EPartService partService) {
|
|
627 |
if (getDetailsView(partService) != null) {
|
|
628 |
((AbstractCdmDataViewerE4) getDetailsView(partService).getViewer()).refresh();
|
|
624 | 629 |
} |
625 | 630 |
} |
626 | 631 |
|
627 |
public static void reflowDetailsViewer() { |
|
628 |
if (getDetailsView() != null) { |
|
629 |
((AbstractCdmDataViewer) getDetailsView().getViewer()).reflow();
|
|
632 |
public static void reflowDetailsViewer(EPartService partService) {
|
|
633 |
if (getDetailsView(partService) != null) {
|
|
634 |
((AbstractCdmDataViewerE4) getDetailsView(partService).getViewer()).reflow();
|
|
630 | 635 |
} |
631 | 636 |
} |
632 | 637 |
|
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/preference/PreferencesUtil.java | ||
---|---|---|
245 | 245 |
CdmPreference pref = null; |
246 | 246 |
|
247 | 247 |
try{ |
248 |
controller = CdmStore.getCurrentApplicationConfiguration(); |
|
249 |
PrefKey key = CdmPreference.NewKey(PreferenceSubject.NewDatabaseInstance(), predicate); |
|
250 |
pref = controller.getPreferenceService().find(key); |
|
248 |
if(CdmStore.isActive()){ |
|
249 |
controller = CdmStore.getCurrentApplicationConfiguration(); |
|
250 |
PrefKey key = CdmPreference.NewKey(PreferenceSubject.NewDatabaseInstance(), predicate); |
|
251 |
pref = controller.getPreferenceService().find(key); |
|
252 |
} |
|
251 | 253 |
}catch(Exception e){ |
252 | 254 |
e.printStackTrace(); |
253 | 255 |
} |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/store/StoreUtil.java | ||
---|---|---|
14 | 14 |
import org.eclipse.core.commands.operations.IOperationHistory; |
15 | 15 |
import org.eclipse.core.commands.operations.IUndoContext; |
16 | 16 |
import org.eclipse.jface.action.IStatusLineManager; |
17 |
import org.eclipse.swt.widgets.Composite; |
|
17 | 18 |
import org.eclipse.ui.IEditorInput; |
19 |
import org.eclipse.ui.forms.widgets.ScrolledForm; |
|
18 | 20 |
|
19 | 21 |
import eu.etaxonomy.cdm.api.facade.DerivedUnitFacade; |
20 | 22 |
import eu.etaxonomy.cdm.model.common.CdmBase; |
... | ... | |
86 | 88 |
statusLineManager = manager; |
87 | 89 |
} |
88 | 90 |
|
91 |
public static void reflowParentScrolledForm(Composite composite, boolean flushCashes){ |
|
92 |
ScrolledForm scrolledForm = null; |
|
93 |
Composite parent = composite; |
|
94 |
while(parent!=null && !(parent instanceof ScrolledForm)){ |
|
95 |
parent = parent.getParent(); |
|
96 |
} |
|
97 |
scrolledForm = (ScrolledForm)parent; |
|
98 |
if(scrolledForm!=null){ |
|
99 |
scrolledForm.reflow(flushCashes); |
|
100 |
} |
|
101 |
} |
|
102 |
|
|
89 | 103 |
|
90 | 104 |
/** |
91 | 105 |
* <p>getUndoContext</p> |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/element/AbstractCdmFormElement.java | ||
---|---|---|
14 | 14 |
import org.eclipse.swt.graphics.Color; |
15 | 15 |
import org.eclipse.swt.widgets.Composite; |
16 | 16 |
import org.eclipse.swt.widgets.Control; |
17 |
import org.eclipse.ui.forms.widgets.ScrolledForm; |
|
18 | 17 |
import org.eclipse.ui.forms.widgets.Section; |
19 | 18 |
|
20 | 19 |
import eu.etaxonomy.taxeditor.model.AbstractUtility; |
... | ... | |
294 | 293 |
} |
295 | 294 |
} |
296 | 295 |
|
297 |
protected void reflowParentScrolledForm(boolean flushCashes){ |
|
298 |
ScrolledForm scrolledForm = null; |
|
299 |
Composite parent = getLayoutComposite().getParent(); |
|
300 |
while(parent!=null && !(parent instanceof ScrolledForm)){ |
|
301 |
parent = parent.getParent(); |
|
302 |
} |
|
303 |
scrolledForm = (ScrolledForm)parent; |
|
304 |
if(scrolledForm!=null){ |
|
305 |
scrolledForm.reflow(flushCashes); |
|
306 |
} |
|
307 |
} |
|
308 |
|
|
309 | 296 |
@Override |
310 | 297 |
public void refresh() { |
311 | 298 |
// empty default implementation |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/element/CdmFormFactory.java | ||
---|---|---|
13 | 13 |
|
14 | 14 |
import javax.inject.Inject; |
15 | 15 |
|
16 |
import org.eclipse.e4.core.contexts.IEclipseContext; |
|
16 | 17 |
import org.eclipse.jface.util.IPropertyChangeListener; |
17 | 18 |
import org.eclipse.jface.viewers.ISelection; |
18 | 19 |
import org.eclipse.jface.viewers.ISelectionProvider; |
... | ... | |
356 | 357 |
private MouseListener selectionMouseHandler; |
357 | 358 |
private FocusListener selectionFocusHandler; |
358 | 359 |
|
360 |
@Inject |
|
361 |
private IEclipseContext context; |
|
362 |
|
|
359 | 363 |
private final Set<SelectionListener> selectionListenerList = new HashSet<SelectionListener>(); |
360 | 364 |
|
361 | 365 |
private final List<IPropertyChangeListener> propertyChangeListeners = new ArrayList<IPropertyChangeListener>(); |
... | ... | |
407 | 411 |
} |
408 | 412 |
} |
409 | 413 |
|
410 |
/** |
|
411 |
* <p> |
|
412 |
* Constructor for CdmFormFactory. |
|
413 |
* </p> |
|
414 |
* |
|
415 |
* @param display |
|
416 |
* a {@link org.eclipse.swt.widgets.Display} object. |
|
417 |
*/ |
|
418 |
@Inject |
|
419 | 414 |
public CdmFormFactory(Display display) { |
415 |
this(display, null); |
|
416 |
} |
|
417 |
|
|
418 |
public CdmFormFactory(Display display, ISelectionProvider selectionProvider) { |
|
420 | 419 |
super(display); |
420 |
this.selectionProvider = selectionProvider; |
|
421 |
init(); |
|
421 | 422 |
} |
422 | 423 |
|
423 |
public void init(ISelectionProvider selectionProvider) {
|
|
424 |
private void init() {
|
|
424 | 425 |
boldFontHolder2 = new BoldFontHolder2(); |
425 | 426 |
selectionMouseHandler = new SelectionMouseHandler(); |
426 | 427 |
selectionFocusHandler = new SelectionFocusHandler(); |
427 |
this.selectionProvider = selectionProvider; |
|
428 |
} |
|
429 |
|
|
430 |
public IEclipseContext getContext() { |
|
431 |
return context; |
|
428 | 432 |
} |
429 | 433 |
|
430 | 434 |
/** |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/AbstractCdmDetailElement.java | ||
---|---|---|
54 | 54 |
private boolean irrelevant; |
55 | 55 |
|
56 | 56 |
private boolean enabled; |
57 |
|
|
57 |
|
|
58 | 58 |
private LabelElement warnForReferencedObjects; |
59 | 59 |
|
60 | 60 |
private EnumSet<CRUD> requiredCrud = null; |
... | ... | |
105 | 105 |
protected void updateContent() { |
106 | 106 |
removeElements(); |
107 | 107 |
createControls(this, entity, SWT.WRAP); |
108 |
reflowParentScrolledForm(true);
|
|
108 |
StoreUtil.reflowParentScrolledForm(getLayoutComposite(), true);
|
|
109 | 109 |
|
110 | 110 |
updateControlStates(); |
111 | 111 |
} |
... | ... | |
249 | 249 |
if (getParentElement() instanceof AbstractCdmDetailSection) { |
250 | 250 |
((AbstractCdmDetailSection) getParentElement()).updateTitle(); |
251 | 251 |
} |
252 |
reflowParentScrolledForm(true);
|
|
252 |
StoreUtil.reflowParentScrolledForm(getLayoutComposite(), true);
|
|
253 | 253 |
} |
254 | 254 |
|
255 | 255 |
/** |
... | ... | |
310 | 310 |
public void setWarnForReferencedObjects(LabelElement warnForReferencedObjects) { |
311 | 311 |
this.warnForReferencedObjects = warnForReferencedObjects; |
312 | 312 |
} |
313 |
|
|
313 |
|
|
314 | 314 |
public void setWarnForReferencingObjects(ICdmFormElement formElement){ |
315 | 315 |
if (getEntity() instanceof CdmBase){ |
316 | 316 |
CdmBase cdmBase = (CdmBase) getEntity(); |
317 | 317 |
if (cdmBase.getId() != 0){ |
318 | 318 |
Integer referencingObjectsCount = CdmStore.getCommonService().getReferencingObjectsCount(cdmBase); |
319 |
|
|
319 |
|
|
320 | 320 |
if (referencingObjectsCount > 1){ |
321 | 321 |
setWarnForReferencedObjects(formFactory.createLabel(formElement, CdmUtils.Nz("The reference is referenced by " + referencingObjectsCount+ " objects, if you change it, it is changed for all these objects"))); |
322 | 322 |
getWarnForReferencedObjects().setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_RED)); |
323 | 323 |
getWarnForReferencedObjects().setLayout(LayoutConstants.FILL(2, 3)); |
324 | 324 |
getWarnForReferencedObjects().setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_RED)); |
325 |
|
|
325 |
|
|
326 | 326 |
} |
327 | 327 |
} |
328 | 328 |
} |
... | ... | |
333 | 333 |
getWarnForReferencedObjects().setVisible(isVisible); |
334 | 334 |
} |
335 | 335 |
} |
336 |
|
|
336 |
|
|
337 | 337 |
} |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/classification/AbstractEditWizard.java | ||
---|---|---|
11 | 11 |
|
12 | 12 |
import javax.inject.Inject; |
13 | 13 |
|
14 |
import org.eclipse.e4.core.contexts.ContextInjectionFactory; |
|
15 | 14 |
import org.eclipse.e4.core.contexts.IEclipseContext; |
16 | 15 |
import org.eclipse.jface.viewers.IStructuredSelection; |
17 | 16 |
import org.eclipse.jface.wizard.Wizard; |
17 |
import org.eclipse.swt.widgets.Shell; |
|
18 | 18 |
import org.eclipse.ui.INewWizard; |
19 | 19 |
import org.eclipse.ui.IWorkbench; |
20 | 20 |
|
... | ... | |
40 | 40 |
|
41 | 41 |
private IWorkbench workbench; |
42 | 42 |
|
43 |
@Inject |
|
43 | 44 |
private IEclipseContext context; |
44 | 45 |
|
45 | 46 |
/** |
... | ... | |
104 | 105 |
this.workbench = workbench != null ? workbench : AbstractUtility.getWorkbench(); |
105 | 106 |
|
106 | 107 |
|
107 |
formFactory = ContextInjectionFactory.make(CdmFormFactory.class, context);
|
|
108 |
formFactory = new CdmFormFactory(context.get(Shell.class).getDisplay());
|
|
108 | 109 |
conversation = CdmStore.createConversation(); |
109 | 110 |
|
110 | 111 |
|
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/classification/CloneClassificationWizard.java | ||
---|---|---|
11 | 11 |
|
12 | 12 |
import javax.inject.Inject; |
13 | 13 |
|
14 |
import org.eclipse.e4.core.contexts.ContextInjectionFactory; |
|
15 | 14 |
import org.eclipse.e4.core.contexts.IEclipseContext; |
16 | 15 |
import org.eclipse.jface.wizard.Wizard; |
16 |
import org.eclipse.swt.widgets.Shell; |
|
17 | 17 |
|
18 | 18 |
import eu.etaxonomy.cdm.api.conversation.ConversationHolder; |
19 | 19 |
import eu.etaxonomy.cdm.model.reference.Reference; |
... | ... | |
50 | 50 |
public CloneClassificationWizard() { |
51 | 51 |
super(); |
52 | 52 |
conversationHolder = CdmStore.createConversation(); |
53 |
formFactory = ContextInjectionFactory.make(CdmFormFactory.class, context);
|
|
53 |
formFactory = new CdmFormFactory(context.get(Shell.class).getDisplay());
|
|
54 | 54 |
} |
55 | 55 |
|
56 | 56 |
public void init(Classification classification){ |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/description/DescriptionElementDetailSection.java | ||
---|---|---|
9 | 9 |
|
10 | 10 |
package eu.etaxonomy.taxeditor.ui.section.description; |
11 | 11 |
|
12 |
import org.eclipse.e4.ui.workbench.modeling.EPartService; |
|
12 | 13 |
import org.eclipse.jface.action.Action; |
14 |
import org.eclipse.jface.action.IAction; |
|
13 | 15 |
import org.eclipse.jface.action.ToolBarManager; |
14 | 16 |
import org.eclipse.jface.viewers.ISelectionProvider; |
15 | 17 |
import org.eclipse.swt.SWT; |
... | ... | |
19 | 21 |
import eu.etaxonomy.cdm.model.description.DescriptionElementBase; |
20 | 22 |
import eu.etaxonomy.cdm.model.description.Feature; |
21 | 23 |
import eu.etaxonomy.cdm.model.description.TextData; |
24 |
import eu.etaxonomy.taxeditor.model.AbstractUtility; |
|
22 | 25 |
import eu.etaxonomy.taxeditor.model.MessagingUtils; |
23 | 26 |
import eu.etaxonomy.taxeditor.store.CdmStore; |
24 | 27 |
import eu.etaxonomy.taxeditor.store.StoreUtil; |
... | ... | |
27 | 30 |
import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailElement; |
28 | 31 |
import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailSection; |
29 | 32 |
import eu.etaxonomy.taxeditor.ui.section.description.operation.ChangeDescriptionElementType; |
33 |
import eu.etaxonomy.taxeditor.view.e4.details.DetailsPartE4; |
|
30 | 34 |
|
31 | 35 |
/** |
32 | 36 |
* <p>DescriptionElementDetailSection class.</p> |
... | ... | |
62 | 66 |
|
63 | 67 |
final String label = "Change to " + destinationString; |
64 | 68 |
|
65 |
Action addAction = new Action("Change Type", Action.AS_PUSH_BUTTON) { |
|
69 |
Action addAction = new Action("Change Type", IAction.AS_PUSH_BUTTON) {
|
|
66 | 70 |
/* (non-Javadoc) |
67 | 71 |
* @see org.eclipse.jface.action.Action#run() |
68 | 72 |
*/ |
... | ... | |
71 | 75 |
boolean confirmed = MessagingUtils.confirmDialog("Confirmation", "Do you really want to change to " |
72 | 76 |
+ destinationString + "? Current data will be lost."); |
73 | 77 |
if (confirmed) { |
74 |
// FIXME |
|
75 |
ChangeDescriptionElementType operation = new ChangeDescriptionElementType(label, |
|
76 |
getEntity(), StoreUtil.getDetailsView(), StoreUtil.getUndoContext()); |
|
77 |
StoreUtil.executeOperation(operation); |
|
78 |
EPartService partService = formFactory.getContext().get(EPartService.class); |
|
79 |
DetailsPartE4 detailsView = AbstractUtility.getDetailsView(partService); |
|
80 |
ChangeDescriptionElementType operation = new ChangeDescriptionElementType(label, |
|
81 |
getEntity(), detailsView, StoreUtil.getUndoContext()); |
|
82 |
AbstractUtility.executeOperation(operation); |
|
78 | 83 |
} |
79 | 84 |
} |
80 | 85 |
}; |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/description/NaturalLanguageDetailElement.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 |
*/ |
... | ... | |
16 | 16 |
import org.eclipse.core.runtime.IStatus; |
17 | 17 |
import org.eclipse.core.runtime.Status; |
18 | 18 |
import org.eclipse.core.runtime.jobs.Job; |
19 |
import org.eclipse.e4.ui.workbench.modeling.EPartService; |
|
19 | 20 |
import org.eclipse.swt.widgets.Display; |
20 | 21 |
|
21 | 22 |
import eu.etaxonomy.cdm.api.service.NaturalLanguageGenerator; |
22 | 23 |
import eu.etaxonomy.cdm.model.description.FeatureTree; |
23 | 24 |
import eu.etaxonomy.cdm.model.description.TaxonDescription; |
24 | 25 |
import eu.etaxonomy.cdm.model.description.TextData; |
26 |
import eu.etaxonomy.taxeditor.model.AbstractUtility; |
|
25 | 27 |
import eu.etaxonomy.taxeditor.preference.PreferencesUtil; |
26 | 28 |
import eu.etaxonomy.taxeditor.store.CdmStore; |
27 |
import eu.etaxonomy.taxeditor.store.StoreUtil; |
|
28 | 29 |
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory; |
29 | 30 |
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement; |
30 | 31 |
import eu.etaxonomy.taxeditor.ui.element.LabelElement; |
... | ... | |
38 | 39 |
* @version 1.0 |
39 | 40 |
*/ |
40 | 41 |
public class NaturalLanguageDetailElement extends AbstractCdmDetailElement<TaxonDescription> { |
41 |
|
|
42 |
|
|
42 | 43 |
|
43 | 44 |
private static final Logger logger = Logger |
44 | 45 |
.getLogger(NaturalLanguageDetailElement.class); |
... | ... | |
54 | 55 |
ICdmFormElement formElement) { |
55 | 56 |
super(formFactory, formElement); |
56 | 57 |
} |
57 |
|
|
58 |
|
|
58 | 59 |
/** {@inheritDoc} */ |
59 | 60 |
@Override |
60 | 61 |
protected void createControls(ICdmFormElement formElement, |
61 | 62 |
TaxonDescription entity, int style) { |
62 | 63 |
label = formFactory.createLabel(formElement, "Generating Natural Language Description ..."); |
63 |
|
|
64 |
|
|
64 | 65 |
if(entity.hasStructuredData()){ |
65 | 66 |
FetchNaturalLanguageDescriptionJob job = new FetchNaturalLanguageDescriptionJob("Retrieving Natural Language Description", entity); |
66 | 67 |
job.schedule(); |
... | ... | |
68 | 69 |
label.setText("Taxon Description does not contain structured data."); |
69 | 70 |
} |
70 | 71 |
} |
71 |
|
|
72 |
|
|
72 | 73 |
/* (non-Javadoc) |
73 | 74 |
* @see eu.etaxonomy.taxeditor.section.AbstractCdmDetailElement#handleEvent(java.lang.Object) |
74 | 75 |
*/ |
... | ... | |
77 | 78 |
public void handleEvent(Object eventSource) { |
78 | 79 |
// nothing gets edited, nothing gets updated |
79 | 80 |
} |
80 |
|
|
81 |
|
|
81 | 82 |
private class FetchNaturalLanguageDescriptionJob extends Job { |
82 | 83 |
|
83 | 84 |
private TaxonDescription entity; |
84 | 85 |
private NaturalLanguageGenerator generator = new NaturalLanguageGenerator(); |
85 | 86 |
private FeatureTree featureTree = PreferencesUtil.getDefaultFeatureTreeForStructuredDescription(); |
86 | 87 |
private Display display = Display.getCurrent(); |
87 |
|
|
88 |
|
|
88 | 89 |
public FetchNaturalLanguageDescriptionJob(String jobName, TaxonDescription entity){ |
89 | 90 |
super(jobName); |
90 | 91 |
this.entity = entity; |
91 | 92 |
} |
92 |
|
|
93 |
|
|
93 | 94 |
@Override |
94 | 95 |
protected IStatus run(IProgressMonitor monitor) { |
95 | 96 |
String text = ""; |
96 |
|
|
97 |
|
|
97 | 98 |
if(featureTree != null){ |
98 | 99 |
CdmStore.createConversation(); |
99 | 100 |
try{ |
100 | 101 |
List<TextData> naturalLanguageDescription = generator.generateNaturalLanguageDescription(featureTree, entity, CdmStore.getDefaultLanguage()); |
101 |
|
|
102 |
|
|
102 | 103 |
for(TextData element : naturalLanguageDescription){ |
103 | 104 |
text += element.getText(CdmStore.getDefaultLanguage()) + " "; |
104 | 105 |
} |
... | ... | |
109 | 110 |
else{ |
110 | 111 |
text = "Could not generate natural language description, because no Feature Tree was set."; |
111 | 112 |
} |
112 |
|
|
113 |
|
|
113 | 114 |
final String aggregatedText = text; |
114 |
|
|
115 |
|
|
115 | 116 |
display.asyncExec(new Runnable(){ |
116 | 117 |
|
117 | 118 |
@Override |
118 | 119 |
public void run() { |
119 | 120 |
label.setText(aggregatedText); |
120 |
StoreUtil.reflowDetailsViewer();
|
|
121 |
AbstractUtility.reflowDetailsViewer(formFactory.getContext().get(EPartService.class));
|
|
121 | 122 |
} |
122 |
|
|
123 |
|
|
123 | 124 |
}); |
124 |
|
|
125 |
|
|
125 | 126 |
return Status.OK_STATUS; |
126 | 127 |
} |
127 |
|
|
128 |
|
|
128 | 129 |
} |
129 | 130 |
} |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/media/MediaDetailElement.java | ||
---|---|---|
27 | 27 |
import eu.etaxonomy.taxeditor.model.MessagingUtils; |
28 | 28 |
import eu.etaxonomy.taxeditor.preference.IPreferenceKeys; |
29 | 29 |
import eu.etaxonomy.taxeditor.preference.PreferencesUtil; |
30 |
import eu.etaxonomy.taxeditor.store.StoreUtil; |
|
30 | 31 |
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory; |
31 | 32 |
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement; |
32 | 33 |
import eu.etaxonomy.taxeditor.ui.element.ImageElement; |
... | ... | |
144 | 145 |
} |
145 | 146 |
isAdvancedMediaView = !isAdvancedMediaView; |
146 | 147 |
showAdvancedView(); |
147 |
reflowParentScrolledForm(true);
|
|
148 |
StoreUtil.reflowParentScrolledForm(getLayoutComposite(), true);
|
|
148 | 149 |
} |
149 | 150 |
|
150 | 151 |
private void showAdvancedView() { |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/reference/ReferenceDetailSection.java | ||
---|---|---|
9 | 9 |
|
10 | 10 |
package eu.etaxonomy.taxeditor.ui.section.reference; |
11 | 11 |
|
12 |
import org.eclipse.e4.ui.workbench.modeling.EPartService; |
|
12 | 13 |
import org.eclipse.jface.viewers.ISelectionProvider; |
13 | 14 |
|
14 | 15 |
import eu.etaxonomy.cdm.api.conversation.ConversationHolder; |
... | ... | |
69 | 70 |
@Override |
70 | 71 |
public void refresh() { |
71 | 72 |
super.refresh(); |
72 |
AbstractUtility.refreshDetailsViewer(); |
|
73 |
AbstractUtility.refreshDetailsViewer(formFactory.getContext().get(EPartService.class));
|
|
73 | 74 |
} |
74 | 75 |
|
75 | 76 |
@Override |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/e4/AbstractCdmDataViewerE4.java | ||
---|---|---|
18 | 18 |
import org.eclipse.swt.SWT; |
19 | 19 |
import org.eclipse.swt.widgets.Composite; |
20 | 20 |
import org.eclipse.swt.widgets.Control; |
21 |
import org.eclipse.swt.widgets.Display; |
|
21 | 22 |
import org.eclipse.ui.forms.IFormPart; |
22 | 23 |
import org.eclipse.ui.forms.ManagedForm; |
23 | 24 |
import org.eclipse.ui.forms.widgets.ScrolledForm; |
... | ... | |
108 | 109 |
formFactory.dispose(); |
109 | 110 |
formFactory = null; |
110 | 111 |
} |
111 |
formFactory = ContextInjectionFactory.make(CdmFormFactory.class, context);
|
|
112 |
formFactory.init(this);
|
|
112 |
formFactory = new CdmFormFactory(Display.getCurrent(), this);
|
|
113 |
ContextInjectionFactory.inject(formFactory, context);
|
|
113 | 114 |
} |
114 | 115 |
|
115 | 116 |
/** {@inheritDoc} */ |
116 | 117 |
@Override |
117 | 118 |
public Control getControl() { |
118 |
if(body.isDisposed()){ |
|
119 |
return null; |
|
120 |
} |
|
121 |
for(Control child : body.getChildren()){ |
|
122 |
return child; |
|
123 |
} |
|
119 |
if(body!=null){ |
|
120 |
if(body.isDisposed()){ |
|
121 |
return null; |
|
122 |
} |
|
123 |
for(Control child : body.getChildren()){ |
|
124 |
return child; |
|
125 |
} |
|
126 |
} |
|
124 | 127 |
|
125 | 128 |
return body; |
126 | 129 |
} |
... | ... | |
130 | 133 |
public void setInput(Object input) { |
131 | 134 |
this.input = input; |
132 | 135 |
if(input!=null){ |
133 |
// reset selection |
|
134 |
setSelection(new StructuredSelection(input)); |
|
135 | 136 |
refresh(); |
136 | 137 |
} |
137 | 138 |
} |
... | ... | |
145 | 146 |
/** {@inheritDoc} */ |
146 | 147 |
@Override |
147 | 148 |
public void refresh() { |
149 |
setSelection(new StructuredSelection(input)); |
|
150 |
|
|
148 | 151 |
showParts(); |
149 | 152 |
|
150 | 153 |
managedForm.setInput(input); |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/e4/AbstractCdmEditorPartE4.java | ||
---|---|---|
247 | 247 |
@Override |
248 | 248 |
public boolean postOperation(CdmBase objectAffectedByOperation) { |
249 | 249 |
changed(objectAffectedByOperation); |
250 |
viewer.setInput(objectAffectedByOperation); |
|
250 | 251 |
return true; |
251 | 252 |
} |
252 | 253 |
|
Also available in: Unified diff
ref #6913 Remove org.eclipse.ui dependency from AbstractUtility