Revision ab153e3d
Added by Patrick Plitzner about 6 years ago
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/datasource/e4/handler/AbstractDataSourceHandlerE4.java | ||
---|---|---|
12 | 12 |
import javax.inject.Named; |
13 | 13 |
|
14 | 14 |
import org.eclipse.e4.core.di.annotations.Execute; |
15 |
import org.eclipse.e4.ui.di.UISynchronize; |
|
15 | 16 |
import org.eclipse.e4.ui.model.application.ui.basic.MPart; |
16 | 17 |
import org.eclipse.e4.ui.services.IServiceConstants; |
17 | 18 |
import org.eclipse.e4.ui.workbench.modeling.EPartService; |
... | ... | |
29 | 30 |
*/ |
30 | 31 |
public abstract class AbstractDataSourceHandlerE4 { |
31 | 32 |
|
33 |
protected UISynchronize sync; |
|
34 |
|
|
32 | 35 |
@Execute |
33 | 36 |
public void execute(EPartService partService, |
34 | 37 |
@Named(IServiceConstants.ACTIVE_SHELL)Shell shell, |
35 |
@Named(IServiceConstants.ACTIVE_SELECTION)CdmMetaDataAwareDataSourceContainer container) { |
|
38 |
@Named(IServiceConstants.ACTIVE_SELECTION)CdmMetaDataAwareDataSourceContainer container, |
|
39 |
UISynchronize sync) { |
|
40 |
|
|
41 |
this.sync = sync; |
|
36 | 42 |
|
37 | 43 |
MPart dataSourceView = partService.showPart( |
38 | 44 |
"eu.etaxonomy.taxeditor.view.datasource", |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/datasource/e4/handler/UpdateDataSourceHandlerE4.java | ||
---|---|---|
19 | 19 |
import org.eclipse.e4.ui.services.IServiceConstants; |
20 | 20 |
import org.eclipse.jface.dialogs.MessageDialog; |
21 | 21 |
import org.eclipse.swt.SWT; |
22 |
import org.eclipse.swt.widgets.Display; |
|
23 | 22 |
import org.eclipse.swt.widgets.Shell; |
24 | 23 |
import org.eclipse.ui.progress.IProgressConstants; |
25 | 24 |
|
... | ... | |
43 | 42 |
|
44 | 43 |
/** {@inheritDoc} */ |
45 | 44 |
@Override |
46 |
public boolean specificExecute(CdmDataSourceViewPartE4 dataSourceViewPart, CdmMetaDataAwareDataSourceContainer container, Shell shell) {
|
|
47 |
final Display display = Display.getCurrent();
|
|
45 |
public boolean specificExecute(CdmDataSourceViewPartE4 dataSourceViewPart, |
|
46 |
CdmMetaDataAwareDataSourceContainer container, Shell shell) {
|
|
48 | 47 |
if(! MessageDialog.open(MessageDialog.CONFIRM, shell, "Update Datasource", "WARNING!\n\n" + |
49 | 48 |
"This will change your data base structure! Be sure you have an up-to-date backup of your data before running the update! \n\n " + |
50 | 49 |
"Are you sure you want to update the datasource?", SWT.NONE)){ |
... | ... | |
63 | 62 |
SchemaUpdateResult result = updater.updateToCurrentVersion( |
64 | 63 |
(ICdmDataSource)cdmSource, CdmProgressMonitorAdapter.CreateMonitor(monitor)); |
65 | 64 |
if(result.isSuccess()){ |
66 |
display.asyncExec(new Runnable(){ |
|
67 |
|
|
68 |
@Override |
|
69 |
public void run() { |
|
65 |
sync.asyncExec(()->{ |
|
70 | 66 |
if(dataSourceViewPart!= null){ |
71 | 67 |
container.getMetaDataFromDataSource(); |
72 | 68 |
dataSourceViewPart.getViewer().update(new CdmMetaDataAwareDataSourceContainer[]{container}, null); |
73 | 69 |
} |
74 |
|
|
75 | 70 |
} |
76 |
});
|
|
71 |
); |
|
77 | 72 |
status = Status.OK_STATUS; |
78 | 73 |
}else{ |
79 | 74 |
throw new RuntimeException("An error occurred during the update."); |
... | ... | |
93 | 88 |
job.setProperty(IProgressConstants.KEEP_PROPERTY, true); |
94 | 89 |
job.schedule(); |
95 | 90 |
|
96 |
return false;
|
|
91 |
return true;
|
|
97 | 92 |
} |
98 | 93 |
|
99 | 94 |
|
Also available in: Unified diff
ref #6912 Use e4 UISynchronize for UI refresh