import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.jface.layout.GridDataFactory;
import org.eclipse.jface.viewers.ComboViewer;
-import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.nebula.widgets.nattable.NatTable;
-import org.eclipse.nebula.widgets.nattable.config.AbstractRegistryConfiguration;
-import org.eclipse.nebula.widgets.nattable.config.CellConfigAttributes;
import org.eclipse.nebula.widgets.nattable.config.ConfigRegistry;
import org.eclipse.nebula.widgets.nattable.config.DefaultNatTableStyleConfiguration;
-import org.eclipse.nebula.widgets.nattable.config.IConfigRegistry;
-import org.eclipse.nebula.widgets.nattable.config.IEditableRule;
import org.eclipse.nebula.widgets.nattable.coordinate.PositionCoordinate;
import org.eclipse.nebula.widgets.nattable.data.IDataProvider;
import org.eclipse.nebula.widgets.nattable.data.ListDataProvider;
-import org.eclipse.nebula.widgets.nattable.edit.EditConfigAttributes;
import org.eclipse.nebula.widgets.nattable.export.command.ExportCommandHandler;
import org.eclipse.nebula.widgets.nattable.extension.glazedlists.GlazedListsEventLayer;
import org.eclipse.nebula.widgets.nattable.extension.glazedlists.GlazedListsSortModel;
import org.eclipse.nebula.widgets.nattable.layer.CompositeLayer;
import org.eclipse.nebula.widgets.nattable.layer.DataLayer;
import org.eclipse.nebula.widgets.nattable.layer.ILayer;
-import org.eclipse.nebula.widgets.nattable.layer.ILayerListener;
import org.eclipse.nebula.widgets.nattable.layer.cell.ColumnOverrideLabelAccumulator;
-import org.eclipse.nebula.widgets.nattable.layer.cell.ILayerCell;
-import org.eclipse.nebula.widgets.nattable.layer.event.ILayerEvent;
import org.eclipse.nebula.widgets.nattable.layer.stack.DefaultBodyLayerStack;
import org.eclipse.nebula.widgets.nattable.selection.SelectionLayer;
-import org.eclipse.nebula.widgets.nattable.selection.event.CellSelectionEvent;
import org.eclipse.nebula.widgets.nattable.sort.SortHeaderLayer;
import org.eclipse.nebula.widgets.nattable.sort.config.SingleClickSortConfiguration;
-import org.eclipse.nebula.widgets.nattable.style.DisplayMode;
import org.eclipse.nebula.widgets.nattable.style.HorizontalAlignmentEnum;
import org.eclipse.nebula.widgets.nattable.style.theme.ModernNatTableThemeConfiguration;
-import org.eclipse.nebula.widgets.nattable.summaryrow.DefaultSummaryRowConfiguration;
import org.eclipse.nebula.widgets.nattable.summaryrow.FixedSummaryRowLayer;
-import org.eclipse.nebula.widgets.nattable.summaryrow.ISummaryProvider;
-import org.eclipse.nebula.widgets.nattable.summaryrow.SummaryRowConfigAttributes;
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.menu.AbstractHeaderMenuConfiguration;
-import org.eclipse.nebula.widgets.nattable.ui.menu.PopupMenuBuilder;
import org.eclipse.nebula.widgets.nattable.util.GUIHelper;
import org.eclipse.nebula.widgets.nattable.viewport.ViewportLayer;
import org.eclipse.swt.SWT;
import eu.etaxonomy.cdm.model.description.SpecimenDescription;
import eu.etaxonomy.cdm.model.description.State;
import eu.etaxonomy.cdm.persistence.dto.SpecimenNodeWrapper;
-import eu.etaxonomy.taxeditor.editor.descriptiveDataSet.matrix.categorical.CategoricalDataCellEditor;
-import eu.etaxonomy.taxeditor.editor.descriptiveDataSet.matrix.categorical.CategoricalDataDisplayConverter;
-import eu.etaxonomy.taxeditor.editor.descriptiveDataSet.matrix.quantitative.QuantitativeDataCellEditor;
-import eu.etaxonomy.taxeditor.editor.descriptiveDataSet.matrix.quantitative.QuantitativeDataDisplayConverter;
-import eu.etaxonomy.taxeditor.editor.descriptiveDataSet.matrix.supplementalInfo.SupplementalInfoDisplayConverter;
import eu.etaxonomy.taxeditor.editor.l10n.Messages;
import eu.etaxonomy.taxeditor.model.MessagingUtils;
import eu.etaxonomy.taxeditor.store.CdmStore;
private void applyStyles(){
ModernNatTableThemeConfiguration configuration = new ModernNatTableThemeConfiguration();
configuration.summaryRowHAlign = HorizontalAlignmentEnum.CENTER;
+ // NOTE: Getting the colors and fonts from the GUIHelper ensures that
+ // they are disposed properly (required by SWT)
configuration.summaryRowBgColor = GUIHelper.getColor(255, 255, 153);
configuration.cHeaderBgColor = GUIHelper.getColor(211, 211, 211);
configuration.rHeaderBgColor = GUIHelper.getColor(211, 211, 211);
natTable.addConfiguration(configuration);
-// // NOTE: Getting the colors and fonts from the GUIHelper ensures that
-// // they are disposed properly (required by SWT)
-// DefaultNatTableStyleConfiguration natTableConfiguration = new DefaultNatTableStyleConfiguration();
-// natTableConfiguration.bgColor = GUIHelper.getColor(249, 172, 7);
-// natTableConfiguration.fgColor = GUIHelper.getColor(30, 76, 19);
-// natTableConfiguration.hAlign = HorizontalAlignmentEnum.LEFT;
-// natTableConfiguration.vAlign = VerticalAlignmentEnum.TOP;
-//// natTableConfiguration.borderStyle = new BorderStyle(1, GUIHelper.getColor(249, 172, 7), LineStyleEnum.SOLID);
-//
-// // Setup even odd row colors - row colors override the NatTable default
-// // colors
-// DefaultRowStyleConfiguration rowStyleConfiguration = new DefaultRowStyleConfiguration();
-// rowStyleConfiguration.oddRowBgColor = ColorResources.getColor(Resources.COLOR_LIST_ODD);
-// rowStyleConfiguration.evenRowBgColor = ColorResources.getColor(Resources.COLOR_LIST_EVEN);
-//
-// // Setup selection styling
-// DefaultSelectionStyleConfiguration selectionStyle = new DefaultSelectionStyleConfiguration();
-//// selectionStyle.selectionFont = GUIHelper.getFont(new FontData("Verdana", 8, SWT.NORMAL));
-//// selectionStyle.selectionBgColor = GUIHelper.getColor(217, 232, 251);
-//// selectionStyle.selectionFgColor = GUIHelper.COLOR_BLACK;
-//// selectionStyle.anchorBorderStyle = new BorderStyle(1, GUIHelper.COLOR_DARK_GRAY, LineStyleEnum.SOLID);
-//// selectionStyle.anchorBgColor = GUIHelper.getColor(65, 113, 43);
-// selectionStyle.selectedHeaderBgColor = GUIHelper.getColor(156, 209, 103);
-//
-// // Add all style configurations to NatTable
-// natTable.addConfiguration(natTableConfiguration);
-// natTable.addConfiguration(rowStyleConfiguration);
-// natTable.addConfiguration(selectionStyle);
-//
-// // Column/Row header style and custom painters
-// DefaultRowHeaderStyleConfiguration rowHeaderConfig = new DefaultRowHeaderStyleConfiguration();
-// Color rowColumnColor = GUIHelper.getColor(230, 255, 255);
-// rowHeaderConfig.bgColor = rowColumnColor;
-// natTable.addConfiguration(rowHeaderConfig);
-// DefaultColumnHeaderStyleConfiguration columnHeaderStyle = new DefaultColumnHeaderStyleConfiguration();
-// columnHeaderStyle.bgColor = rowColumnColor;
-// columnHeaderStyle.font = GUIHelper.getFont(new FontData("Verdana", 9, SWT.BOLD)); //$NON-NLS-1$
-// natTable.addConfiguration(columnHeaderStyle);
}
*/
registerHandlersAndListeners(topMostLayer);
+ //grab all space
GridDataFactory.fillDefaults().grab(true, true).applyTo(natTable);
+ //update label to current data set
toolbar.getWsLabel().setText(descriptiveDataSet.getLabel());
toolbar.getWsLabel().setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
toolbar.getWsLabel().getParent().layout();
+ //initial freeze of supplemental columns
freezeSupplementalColumns(true);
this.layout();
topMostLayer.registerCommandHandler(new ExportCommandHandler(topMostLayer));
//propagate single cell selection
- natTable.addLayerListener(new ILayerListener() {
- @Override
- public void handleLayerEvent(ILayerEvent event) {
- if(event instanceof CellSelectionEvent){
- CellSelectionEvent cellSelectionEvent = (CellSelectionEvent)event;
- int columnPosition = cellSelectionEvent.getColumnPosition();
- if(columnPosition>LEADING_COLUMN_COUNT){
- Collection<ILayerCell> selectedCells = cellSelectionEvent.getSelectionLayer().getSelectedCells();
- StructuredSelection selection = new StructuredSelection();
- if(selectedCells.size()==1){
- ILayerCell cell = selectedCells.iterator().next();
- Object dataValue = cell.getDataValue();
- if(dataValue!=null){
- selection = new StructuredSelection(dataValue);
- }
- }
- part.getSelectionService().setSelection(selection);
- }
- }
- }
- });
+ natTable.addLayerListener(new CellSelectionListener(part));
//register handler for view configuration menu
natTable.registerCommandHandler(toolbar.getDisplayPersistenceDialogCommandHandler());
}
- private void configureNatTable(boolean treeView, ConfigRegistry configRegistry, AbstractLayer topMostLayer,
+ private void configureNatTable(boolean treeView,
+ ConfigRegistry configRegistry,
+ AbstractLayer topMostLayer,
FixedSummaryRowLayer summaryRowLayer) {
/**
* CONFIGURATION
// add the header menu configuration for adding the column header menu
// with hide/show actions
- natTable.addConfiguration(new AbstractHeaderMenuConfiguration(natTable) {
-
- @Override
- protected PopupMenuBuilder createColumnHeaderMenu(NatTable natTable) {
- return super.createColumnHeaderMenu(natTable)
- .withHideColumnMenuItem()
- .withShowAllColumnsMenuItem();
- }
-
- });
+ natTable.addConfiguration(new CharacterMatrixHeaderMenuConfiguration(natTable));
// add custom configuration for data conversion and add column labels to viewport layer
- topMostLayer.addConfiguration(new AbstractRegistryConfiguration() {
- @Override
- public void configureRegistry(IConfigRegistry configRegistry) {
-
- //add display converter for string representation
- configRegistry.registerConfigAttribute(
- CellConfigAttributes.DISPLAY_CONVERTER,
- new SupplementalInfoDisplayConverter(),
- DisplayMode.NORMAL,
- TAXON_COLUMN);
- configRegistry.registerConfigAttribute(
- CellConfigAttributes.DISPLAY_CONVERTER,
- new SupplementalInfoDisplayConverter(),
- DisplayMode.NORMAL,
- COLLECTOR_COLUMN);
- configRegistry.registerConfigAttribute(
- CellConfigAttributes.DISPLAY_CONVERTER,
- new SupplementalInfoDisplayConverter(),
- DisplayMode.NORMAL,
- IDENTIFIER_COLUMN);
- configRegistry.registerConfigAttribute(
- CellConfigAttributes.DISPLAY_CONVERTER,
- new SupplementalInfoDisplayConverter(),
- DisplayMode.NORMAL,
- COUNTRY_COLUMN);
- features.forEach(feature->registerColumnConfiguration(feature, configRegistry));
- }
-
- });
+ topMostLayer.addConfiguration(new DataConversionConfiguration(this));
- //no summary for the supplemental columns
- for(int i=0;i<LEADING_COLUMN_COUNT;i++){
- int index = i;
- summaryRowLayer.addConfiguration(new DefaultSummaryRowConfiguration() {
- @Override
- public void addSummaryProviderConfig(IConfigRegistry configRegistry) {
- configRegistry.registerConfigAttribute(
- SummaryRowConfigAttributes.SUMMARY_PROVIDER,
- new ISummaryProvider() {
-
- @Override
- public Object summarize(int columnIndex) {
- return "";
- }
- },
- DisplayMode.NORMAL,
- SummaryRowLayer.DEFAULT_SUMMARY_COLUMN_CONFIG_LABEL_PREFIX+index);
- }
- });
- }
- //register aggregation configuration for each feature
- features.forEach(feature->summaryRowLayer.addConfiguration(new AggregationConfiguration(bodyDataProvider, feature)));
+ //register aggregation configuration
+ summaryRowLayer.addConfiguration(new AggregationConfiguration(this));
natTable.configure();
}
propertyToLabelMap.put(property, featureLabel);
}
- private void registerColumnConfiguration(Feature feature, IConfigRegistry configRegistry) {
- //make cell editable
- configRegistry.registerConfigAttribute(
- EditConfigAttributes.CELL_EDITABLE_RULE,
- IEditableRule.ALWAYS_EDITABLE,
- DisplayMode.EDIT,
- MatrixUtility.getProperty(feature)
- );
- if(feature.isSupportsQuantitativeData()){
- //add display converter for string representation
- configRegistry.registerConfigAttribute(
- CellConfigAttributes.DISPLAY_CONVERTER,
- new QuantitativeDataDisplayConverter(),
- DisplayMode.NORMAL,
- MatrixUtility.getProperty(feature));
- //register quantitative editor
- configRegistry.registerConfigAttribute(
- EditConfigAttributes.CELL_EDITOR,
- new QuantitativeDataCellEditor(feature, this),
- DisplayMode.EDIT,
- MatrixUtility.getProperty(feature));
- }
- else if(feature.isSupportsCategoricalData()){
- //add display converter for string representation
- configRegistry.registerConfigAttribute(
- CellConfigAttributes.DISPLAY_CONVERTER,
- new CategoricalDataDisplayConverter(),
- DisplayMode.NORMAL,
- MatrixUtility.getProperty(feature));
-
- //add combo box cell editor
- //register editor
- configRegistry.registerConfigAttribute(EditConfigAttributes.CELL_EDITOR,
- new CategoricalDataCellEditor(getSupportedStatesForCategoricalFeature(feature), this, feature),
- DisplayMode.EDIT,
- MatrixUtility.getProperty(feature));
-
- }
-
- }
-
-
public void loadDescriptions(DescriptiveDataSet descriptiveDataSet) {
UUID monitorUuid = CdmStore.getService(IDescriptiveDataSetService.class).monitGetRowWrapper(descriptiveDataSet);
IProgressMonitorService progressMonitorService = CdmApplicationState.getCurrentAppConfig().getProgressMonitorService();
}
monitor.done();
});
- job.schedule();
+ job.schedule(1000);
}
public List<State> getSupportedStatesForCategoricalFeature(Feature feature){