import org.eclipse.nebula.widgets.nattable.persistence.command.DisplayPersistenceDialogCommandHandler;
import org.eclipse.nebula.widgets.nattable.persistence.command.IStateChangedListener;
import org.eclipse.nebula.widgets.nattable.persistence.command.StateChangeEvent;
+import org.eclipse.nebula.widgets.nattable.persistence.gui.PersistenceDialog;
import org.eclipse.nebula.widgets.nattable.reorder.ColumnReorderLayer;
import org.eclipse.nebula.widgets.nattable.reorder.RowReorderLayer;
import org.eclipse.nebula.widgets.nattable.selection.SelectionLayer;
import org.eclipse.nebula.widgets.nattable.summaryrow.FixedSummaryRowLayer;
import org.eclipse.nebula.widgets.nattable.summaryrow.SummaryRowLayer;
import org.eclipse.nebula.widgets.nattable.ui.menu.AbstractHeaderMenuConfiguration;
-import org.eclipse.nebula.widgets.nattable.ui.menu.DebugMenuConfiguration;
import org.eclipse.nebula.widgets.nattable.ui.menu.PopupMenuBuilder;
import org.eclipse.nebula.widgets.nattable.viewport.ViewportLayer;
import org.eclipse.swt.SWT;
//add default configuration because autoconfigure is set to false in constructor
natTable.addConfiguration(new DefaultNatTableStyleConfiguration());
+ //FIXME: this is for DEBUG ONLY
+// natTable.addConfiguration(new DebugMenuConfiguration(natTable));
+
// override the default sort configuration and change the mouse bindings
// to sort on a single click
natTable.addConfiguration(new SingleClickSortConfiguration());
- //FIXME: this is for DEBUG ONLY
- natTable.addConfiguration(new DebugMenuConfiguration(natTable));
// add the header menu configuration for adding the column header menu
// with hide/show actions
gridLayer.registerCommandHandler(handler);
// create a combobox for showing the available view states
Combo comboStates = new Combo(toolbarComposite, SWT.DROP_DOWN);
- comboStates.setItems(PersistenceHelper
- .getAvailableStates(natTableState)
- .toArray(new String[] {}));
- comboStates.addSelectionListener(new SelectionAdapter() {
+ Collection<String> availableStates = PersistenceHelper.getAvailableStates(natTableState);
+ comboStates.setItems(availableStates.toArray(new String[] {}));
+ comboStates.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
int index = comboStates.getSelectionIndex();
String selected = comboStates.getItem(index);
// load the state
natTable.loadState(selected, natTableState);
+ natTableState.setProperty(PersistenceDialog.ACTIVE_VIEW_CONFIGURATION_KEY, selected);
}
}
});
// add listener to update the combo on view state management changes
handler.addStateChangeListener(new IStateChangedListener() {
-
@Override
public void handleStateChange(StateChangeEvent event) {
- comboStates.setItems(PersistenceHelper
- .getAvailableStates(natTableState)
+ comboStates.setItems(PersistenceHelper.getAvailableStates(natTableState)
.toArray(new String[] {}));
+ selectStateItem(comboStates, event.getViewConfigName());
}
});
@Override
public void widgetSelected(SelectionEvent e) {
natTable.doCommand(new DisplayPersistenceDialogCommand(natTable));
+ selectStateItem(comboStates, natTableState.get(PersistenceDialog.ACTIVE_VIEW_CONFIGURATION_KEY).toString());
}
});
parent.layout();
}
+ private void selectStateItem(Combo comboStates, String stateName){
+ String[] items = comboStates.getItems();
+ for(int i=0;i<items.length;i++){
+ if(items[i].equals(stateName)){
+ comboStates.select(i);
+ break;
+ }
+ }
+ }
+
private SpecimenDescription getDescriptionForWorkingSet(SpecimenOrObservationBase specimen){
Set<SpecimenDescription> descriptions = specimen.getDescriptions();
if(descriptions!=null){