import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.core.runtime.jobs.JobChangeAdapter;
import org.eclipse.e4.ui.di.UISynchronize;
+import org.eclipse.e4.ui.services.EMenuService;
import org.eclipse.jface.layout.GridDataFactory;
import org.eclipse.jface.viewers.ComboViewer;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.nebula.widgets.nattable.NatTable;
+import org.eclipse.nebula.widgets.nattable.config.AbstractUiBindingConfiguration;
import org.eclipse.nebula.widgets.nattable.config.ConfigRegistry;
import org.eclipse.nebula.widgets.nattable.config.DefaultNatTableStyleConfiguration;
import org.eclipse.nebula.widgets.nattable.coordinate.PositionCoordinate;
+import org.eclipse.nebula.widgets.nattable.coordinate.Range;
import org.eclipse.nebula.widgets.nattable.data.IDataProvider;
import org.eclipse.nebula.widgets.nattable.data.ListDataProvider;
import org.eclipse.nebula.widgets.nattable.export.command.ExportCommandHandler;
+import org.eclipse.nebula.widgets.nattable.extension.e4.selection.E4SelectionListener;
import org.eclipse.nebula.widgets.nattable.extension.glazedlists.GlazedListsEventLayer;
import org.eclipse.nebula.widgets.nattable.extension.glazedlists.GlazedListsSortModel;
import org.eclipse.nebula.widgets.nattable.extension.glazedlists.tree.GlazedListTreeData;
import org.eclipse.nebula.widgets.nattable.summaryrow.SummaryRowLayer;
import org.eclipse.nebula.widgets.nattable.tree.ITreeRowModel;
import org.eclipse.nebula.widgets.nattable.tree.TreeLayer;
+import org.eclipse.nebula.widgets.nattable.ui.binding.UiBindingRegistry;
+import org.eclipse.nebula.widgets.nattable.ui.matcher.MouseEventMatcher;
+import org.eclipse.nebula.widgets.nattable.ui.menu.PopupMenuAction;
+import org.eclipse.nebula.widgets.nattable.ui.menu.PopupMenuBuilder;
import org.eclipse.nebula.widgets.nattable.util.GUIHelper;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Menu;
import ca.odell.glazedlists.BasicEventList;
import ca.odell.glazedlists.EventList;
import ca.odell.glazedlists.SortedList;
import ca.odell.glazedlists.TreeList;
-import eu.etaxonomy.cdm.api.service.IDescriptiveDataSetService;
-import eu.etaxonomy.cdm.api.service.UpdateResult;
+import eu.etaxonomy.cdm.api.application.CdmApplicationState;
import eu.etaxonomy.cdm.api.service.dto.RowWrapperDTO;
import eu.etaxonomy.cdm.api.service.dto.SpecimenRowWrapperDTO;
import eu.etaxonomy.cdm.common.monitor.IRemotingProgressMonitor;
+import eu.etaxonomy.cdm.model.description.Character;
import eu.etaxonomy.cdm.model.description.DescriptionBase;
import eu.etaxonomy.cdm.model.description.DescriptiveDataSet;
import eu.etaxonomy.cdm.model.description.Feature;
static final String LABEL_TAXON_ROW = "TAXON_ROW"; //$NON-NLS-1$
static final String LABEL_TAXON_AGGREGATED_DESCRIPTION = "TAXON_AGGREGATED_DESCRIPTION"; //$NON-NLS-1$
+ static final String LABEL_TAXON_AGGREGATED_DESCRIPTION_ICON = "TAXON_AGGREGATED_DESCRIPTION_ICON"; //$NON-NLS-1$
+ static final String LABEL_TAXON_DEFAULT_DESCRIPTION = "TAXON_DEFAULT_DESCRIPTION"; //$NON-NLS-1$
+ static final String LABEL_TAXON_DEFAULT_DESCRIPTION_ICON = "TAXON_DEFAULT_DESCRIPTION_ICON"; //$NON-NLS-1$
+ static final String LABEL_TAXON_LITERATURE_DESCRIPTION = "TAXON_LITERATURE_DESCRIPTION"; //$NON-NLS-1$
+ static final String LABEL_TAXON_LITERATURE_DESCRIPTION_ICON = "TAXON_LITERATURE_DESCRIPTION_ICON"; //$NON-NLS-1$
static final String LABEL_TAXON_DESCRIPTION = "LABEL_TAXON_DESCRIPTION"; //$NON-NLS-1$
+ static final String LABEL_DESCRIPTION_HAS_SUPPLEMENTAL_DATA = "LABEL_DESCRIPTION_HAS_SUPPLEMENTAL_DATA"; //$NON-NLS-1$
@Inject
private UISynchronize sync;
+ @Inject
+ private EMenuService menuService;
+
private DescriptiveDataSet descriptiveDataSet;
private NatTable natTable;
List<Feature> features = new ArrayList<>();
node.getChildNodes().forEach(childNode->
{
- features.add(childNode.getFeature());
+ Feature feature = childNode.getFeature();
+ if(feature.isInstanceOf(Character.class)){
+ features.add(childNode.getFeature());
+ }
features.addAll(initFeatureList(childNode));
});
return features;
// exporting work
topMostLayer.registerCommandHandler(new ExportCommandHandler(topMostLayer));
- //propagate single cell selection
- natTable.addLayerListener(new CellSelectionListener(part));
+ //selection listener
+ E4SelectionListener selectionListener = new CellSelectionListener(part.getSelectionService(),
+ bodyLayer.getSelectionLayer(), bodyDataProvider, part);
+ bodyLayer.getSelectionLayer().addLayerListener(selectionListener);
+ selectionListener.setFullySelectedRowsOnly(false);
//register handler for view configuration menu
natTable.registerCommandHandler(toolbar.getDisplayPersistenceDialogCommandHandler());
//register aggregation configuration
summaryRowLayer.addConfiguration(new AggregationConfiguration(this));
+ //+++CONTEXT MENU+++
+ menuService.registerContextMenu(natTable, "eu.etaxonomy.taxeditor.editor.popupmenu.charactermatrix"); //$NON-NLS-1$
+ // get the menu registered by EMenuService
+ final Menu e4Menu = natTable.getMenu();
+ // remove the menu reference from NatTable instance
+ natTable.setMenu(null);
+ natTable.addConfiguration(
+ new AbstractUiBindingConfiguration() {
+ @Override
+ public void configureUiBindings(
+ UiBindingRegistry uiBindingRegistry) {
+ // add e4 menu to NatTable
+ new PopupMenuBuilder(natTable, e4Menu)
+ .build();
+
+ // register the UI binding for header, corner and body region
+ uiBindingRegistry.registerMouseDownBinding(
+ new MouseEventMatcher(
+ SWT.NONE,
+ null,
+ MouseEventMatcher.RIGHT_BUTTON),
+ new PopupMenuAction(e4Menu));
+ }
+ });
+
natTable.configure();
}
}
public void loadDescriptions(DescriptiveDataSet descriptiveDataSet) {
- UUID monitorUuid = CdmStore.getService(IDescriptiveDataSetService.class).monitGetRowWrapper(descriptiveDataSet);
+ UUID monitorUuid = CdmApplicationState.getLongRunningTasksService().monitGetRowWrapper(descriptiveDataSet);
final Collection<RowWrapperDTO> wrappers = new ArrayList<>();
String jobLabel = Messages.CharacterMatrix_LOAD_CHARACTER_DATA;
job.schedule();
}
+ public IStructuredSelection getSelection(){
+ Set<Range> selectedRowPositions = bodyLayer.getSelectionLayer().getSelectedRowPositions();
+ List<Object> selectedObjects = new ArrayList<>();
+ for (Range range : selectedRowPositions) {
+ for(int i=range.start;i<range.end;i++){
+ selectedObjects.add(bodyDataProvider.getRowObject(i));
+ }
+ }
+ return new StructuredSelection(selectedObjects);
+ }
+
private void loadingDone() {
this.part.loadingDone();
}
return features;
}
- public void addUpdateResult(UpdateResult result){
- part.addUpdateResult(result);
- }
-
public Map<Feature, CategoricalDataHistogram> getFeatureToHistogramMap() {
return featureToHistogramMap;
}