import java.util.UUID;
import java.util.stream.Collectors;
+import javax.inject.Inject;
+
import org.apache.commons.collections4.map.LinkedMap;
import org.apache.commons.math3.stat.descriptive.DescriptiveStatistics;
import org.eclipse.core.runtime.ICoreRunnable;
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.jobs.IJobChangeEvent;
import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.core.runtime.jobs.JobChangeAdapter;
+import org.eclipse.e4.ui.di.UISynchronize;
import org.eclipse.jface.layout.GridDataFactory;
import org.eclipse.jface.viewers.ComboViewer;
import org.eclipse.nebula.widgets.nattable.NatTable;
static final String LABEL_TAXON_ROW = "TAXON_ROW"; //$NON-NLS-1$
+ @Inject
+ private UISynchronize sync;
+
private DescriptiveDataSet descriptiveDataSet;
private NatTable natTable;
UUID monitorUuid = CdmStore.getService(IDescriptiveDataSetService.class).monitGetRowWrapper(descriptiveDataSet);
IProgressMonitorService progressMonitorService = CdmApplicationState.getCurrentAppConfig().getProgressMonitorService();
-
+ final Collection<RowWrapperDTO> wrappers = new ArrayList<>();
String jobLabel = "Load character data";
Job job = Job.create(jobLabel, (ICoreRunnable) monitor -> {
monitor.beginTask(jobLabel, IProgressMonitor.UNKNOWN);
IRemotingProgressMonitor remotingMonitor = progressMonitorService.getRemotingMonitor(monitorUuid);
Object result = remotingMonitor.getResult();
if(result instanceof Collection){
- Collection<RowWrapperDTO> wrappers = (Collection<RowWrapperDTO>) result;
- wrappers.forEach(wrapper->CharacterMatrix.this.descriptions.add(wrapper));
+ wrappers.addAll((Collection<RowWrapperDTO>) result);
}
monitor.done();
});
+ job.addJobChangeListener(new JobChangeAdapter(){
+ @Override
+ public void done(IJobChangeEvent event) {
+ sync.syncExec(()->{
+ wrappers.forEach(wrapper->CharacterMatrix.this.descriptions.add(wrapper));
+ loadingDone();
+ });
+ }
+ });
job.schedule(1000);
}
+ private void loadingDone() {
+ this.part.loadingDone();
+ }
+
public List<State> getSupportedStatesForCategoricalFeature(Feature feature){
return categoricalFeatureToStateMap.get(feature);
}
import javax.inject.Inject;
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.e4.core.contexts.ContextInjectionFactory;
+import org.eclipse.e4.core.contexts.IEclipseContext;
import org.eclipse.e4.ui.di.Focus;
import org.eclipse.e4.ui.di.Persist;
import org.eclipse.e4.ui.model.application.ui.MDirtyable;
import org.eclipse.e4.ui.model.application.ui.basic.MPart;
import org.eclipse.e4.ui.workbench.modeling.ESelectionService;
import org.eclipse.nebula.widgets.nattable.NatTable;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.StackLayout;
import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
import eu.etaxonomy.cdm.api.conversation.IConversationEnabled;
private CharacterMatrix matrix;
+ private StackLayout stackLayout;
+
@PostConstruct
- public void create(Composite parent) {
+ public void create(Composite parent, IEclipseContext context) {
if(CdmStore.isActive() && conversation==null){
conversation = CdmStore.createConversation();
}
else{
return;
}
+ stackLayout = new StackLayout();
+ parent.setLayout(stackLayout);
matrix = new CharacterMatrix(parent, this);
+ Label label = new Label(parent, SWT.NONE);
+ label.setText("Loading matrix...");
+ stackLayout.topControl = label;
+ ContextInjectionFactory.inject(matrix, context);
}
public void init(UUID descriptiveDataSetUuid, boolean treeView) {
updateResults.add(result);
}
+ public void loadingDone() {
+ stackLayout.topControl = matrix;
+ matrix.getParent().layout();
+ }
+
}