Project

General

Profile

Revision e08e34dc

IDe08e34dcc806daa84ac388a7b05b328f12ef95f5
Parent ab153e3d
Child b3fe1135

Added by Patrick Plitzner about 1 year ago

ref #6912 Update view when creating a new data base model

View differences:

eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/event/EventUtility.java
15 15
import javax.inject.Named;
16 16

  
17 17
import org.eclipse.e4.core.di.annotations.Optional;
18
import org.eclipse.e4.core.services.events.IEventBroker;
18 19
import org.eclipse.e4.ui.di.UIEventTopic;
19 20
import org.eclipse.e4.ui.model.application.ui.basic.MPart;
20 21
import org.eclipse.e4.ui.services.IServiceConstants;
......
38 39

  
39 40
    private static Shell shell;
40 41

  
42
    @Inject
43
    private static IEventBroker eventBroker;
44

  
41 45
    @PostConstruct
42 46
    public void create(){
43 47
        //nothing
44 48
    }
45 49

  
50
    public static void postEvent(String topic, Object data){
51
        eventBroker.post(topic, data);
52
    }
53

  
46 54
    @Inject
47 55
    @Optional
48 56
    private void updateCurrentActiveShell(@Named(IServiceConstants.ACTIVE_SHELL)Shell shell){
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/event/WorkbenchEventConstants.java
17 17

  
18 18
    public static final String CURRENT_ACTIVE_EDITOR = "CURRENT/ACTIVE_EDITOR";
19 19

  
20
    public static final String REFRESH_DATASOURCE = "REFRESH/DATASOURCE";
21

  
20 22
}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/store/CdmStoreConnector.java
34 34
import eu.etaxonomy.cdm.model.metadata.CdmMetaData;
35 35
import eu.etaxonomy.cdm.model.name.NomenclaturalStatusType;
36 36
import eu.etaxonomy.cdm.model.name.Rank;
37
import eu.etaxonomy.taxeditor.event.EventUtility;
38
import eu.etaxonomy.taxeditor.event.WorkbenchEventConstants;
37 39
import eu.etaxonomy.taxeditor.l10n.Messages;
38 40
import eu.etaxonomy.taxeditor.model.CdmProgressMonitorAdapter;
39 41
import eu.etaxonomy.taxeditor.model.MessagingUtils;
......
116 118
//                if(dataSourceView!=null){
117 119
//                    dataSourceView.refresh();
118 120
//                }
121
                EventUtility.postEvent(WorkbenchEventConstants.REFRESH_DATASOURCE, true);
119 122
                return Status.OK_STATUS;
120 123
            } catch (Exception e) {
121 124
                if(! causeIsCancelationExceptionRecursive(e)){
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/datasource/e4/CdmDataSourceViewPartE4.java
21 21
import org.eclipse.core.runtime.IStatus;
22 22
import org.eclipse.core.runtime.Status;
23 23
import org.eclipse.core.runtime.jobs.Job;
24
import org.eclipse.e4.core.di.annotations.Optional;
24 25
import org.eclipse.e4.ui.di.Focus;
26
import org.eclipse.e4.ui.di.UIEventTopic;
27
import org.eclipse.e4.ui.di.UISynchronize;
25 28
import org.eclipse.e4.ui.services.EMenuService;
26 29
import org.eclipse.e4.ui.workbench.modeling.ESelectionService;
27 30
import org.eclipse.jface.viewers.ISelectionChangedListener;
......
33 36
import org.eclipse.swt.events.SelectionEvent;
34 37
import org.eclipse.swt.layout.FillLayout;
35 38
import org.eclipse.swt.widgets.Composite;
36
import org.eclipse.swt.widgets.Display;
37 39
import org.eclipse.swt.widgets.Table;
38 40
import org.eclipse.swt.widgets.TableColumn;
39 41
import org.eclipse.ui.IMemento;
40 42

  
41 43
import eu.etaxonomy.cdm.config.ICdmSource;
42 44
import eu.etaxonomy.taxeditor.datasource.CdmDataSourceRepository;
45
import eu.etaxonomy.taxeditor.event.WorkbenchEventConstants;
43 46
import eu.etaxonomy.taxeditor.l10n.Messages;
44 47
import eu.etaxonomy.taxeditor.model.AbstractUtility;
45 48
import eu.etaxonomy.taxeditor.model.ContextListenerAdapter;
......
58 61
 */
59 62
public class CdmDataSourceViewPartE4 {
60 63

  
64
    @Inject
65
    private UISynchronize sync;
66

  
61 67
    private static final Logger logger = Logger.getLogger(CdmDataSourceViewPartE4.class);
62 68

  
63 69
	private class ContextListener extends ContextListenerAdapter{
......
104 110
					containers.add(new CdmMetaDataAwareDataSourceContainer(cdmSource));
105 111
				}
106 112

  
107
				Display.getDefault().asyncExec(new Runnable() {
113
				sync.asyncExec(()->viewer.setInput(containers));
108 114

  
109
					@Override
110
					public void run() {
111
						viewer.setInput(containers);
112
					}
113
				});
114 115
				monitor.worked(1);
115 116

  
116 117
				for(final CdmMetaDataAwareDataSourceContainer container : containers){
......
122 123
                     {
123 124
                        logger.debug("  #" + container.hashCode() + " : metadata retrieved, creating new runnable ...");	 //$NON-NLS-1$ //$NON-NLS-2$
124 125
                    }
125
					Display.getDefault().asyncExec(new Runnable() {
126
					sync.asyncExec(new Runnable() {
126 127

  
127 128
						@Override
128 129
						public void run() {
......
227 228

  
228 229
	}
229 230

  
231
    @Inject
232
    @Optional
233
    private void updateView(@UIEventTopic(WorkbenchEventConstants.REFRESH_DATASOURCE)boolean refresh){
234
        if(refresh){
235
            refresh();
236
        }
237
    }
238

  
230 239
	public void refresh(){
231 240
		DataSourceJob dataSourceJob = new DataSourceJob(Messages.CdmDataSourceViewPart_1, CdmDataSourceRepository.getAll());
232 241
		dataSourceJob.schedule();

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)