42 |
42 |
import org.eclipse.jface.viewers.StructuredSelection;
|
43 |
43 |
import org.eclipse.jface.window.Window;
|
44 |
44 |
import org.eclipse.nebula.widgets.nattable.NatTable;
|
|
45 |
import org.eclipse.nebula.widgets.nattable.command.StructuralRefreshCommand;
|
45 |
46 |
import org.eclipse.nebula.widgets.nattable.config.AbstractRegistryConfiguration;
|
46 |
47 |
import org.eclipse.nebula.widgets.nattable.config.CellConfigAttributes;
|
47 |
48 |
import org.eclipse.nebula.widgets.nattable.config.ConfigRegistry;
|
... | ... | |
55 |
56 |
import org.eclipse.nebula.widgets.nattable.export.command.ExportCommand;
|
56 |
57 |
import org.eclipse.nebula.widgets.nattable.export.command.ExportCommandHandler;
|
57 |
58 |
import org.eclipse.nebula.widgets.nattable.extension.glazedlists.GlazedListsEventLayer;
|
|
59 |
import org.eclipse.nebula.widgets.nattable.extension.glazedlists.GlazedListsSortModel;
|
58 |
60 |
import org.eclipse.nebula.widgets.nattable.extension.glazedlists.tree.GlazedListTreeData;
|
59 |
61 |
import org.eclipse.nebula.widgets.nattable.extension.glazedlists.tree.GlazedListTreeRowModel;
|
60 |
62 |
import org.eclipse.nebula.widgets.nattable.grid.GridRegion;
|
... | ... | |
85 |
87 |
import org.eclipse.nebula.widgets.nattable.reorder.RowReorderLayer;
|
86 |
88 |
import org.eclipse.nebula.widgets.nattable.selection.SelectionLayer;
|
87 |
89 |
import org.eclipse.nebula.widgets.nattable.selection.event.CellSelectionEvent;
|
|
90 |
import org.eclipse.nebula.widgets.nattable.sort.SortHeaderLayer;
|
|
91 |
import org.eclipse.nebula.widgets.nattable.sort.config.SingleClickSortConfiguration;
|
88 |
92 |
import org.eclipse.nebula.widgets.nattable.style.DisplayMode;
|
89 |
93 |
import org.eclipse.nebula.widgets.nattable.summaryrow.FixedSummaryRowLayer;
|
90 |
94 |
import org.eclipse.nebula.widgets.nattable.summaryrow.SummaryRowLayer;
|
... | ... | |
165 |
169 |
|
166 |
170 |
private WorkingSet workingSet;
|
167 |
171 |
|
168 |
|
private Composite parent;
|
169 |
|
|
170 |
172 |
private ConversationHolder conversation;
|
171 |
173 |
|
172 |
174 |
private ICdmEntitySession cdmEntitySession;
|
... | ... | |
194 |
196 |
|
195 |
197 |
private ListDataProvider<Object> bodyDataProvider;
|
196 |
198 |
|
|
199 |
private Label wsLabel;
|
|
200 |
|
|
201 |
private Button btnToggleTree;
|
|
202 |
|
|
203 |
private Button btnToggleFlat;
|
|
204 |
|
|
205 |
private Button btnCollapseAll;
|
|
206 |
|
|
207 |
private Button btnExpandAll;
|
|
208 |
|
|
209 |
private ComboViewer comboStates;
|
|
210 |
|
|
211 |
private Button btnManageState;
|
|
212 |
|
|
213 |
private Button btnExcelExport;
|
|
214 |
|
|
215 |
private Composite buttonPanel;
|
|
216 |
|
|
217 |
private Composite parent;
|
|
218 |
|
|
219 |
private List<Feature> features;
|
|
220 |
|
197 |
221 |
@PostConstruct
|
198 |
222 |
public void create(Composite parent) {
|
199 |
223 |
if(CdmStore.isActive() && conversation==null){
|
... | ... | |
205 |
229 |
else{
|
206 |
230 |
return;
|
207 |
231 |
}
|
208 |
|
parent.setLayout(new GridLayout());
|
209 |
232 |
this.parent = parent;
|
210 |
|
}
|
|
233 |
parent.setLayout(new GridLayout());
|
211 |
234 |
|
|
235 |
Composite toolbarComposite = new Composite(parent, SWT.NONE);
|
|
236 |
toolbarComposite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
|
|
237 |
toolbarComposite.setLayout(new GridLayout(8, false));
|
|
238 |
natTable = new NatTable(parent, false);
|
212 |
239 |
|
213 |
|
public void init(UUID workingSetUuid) {
|
214 |
|
this.workingSet = CdmStore.getService(IWorkingSetService.class).load(workingSetUuid, WS_PROPERTY_PATH);
|
215 |
|
if(workingSet.getDescriptiveSystem()==null){
|
216 |
|
MessagingUtils.informationDialog("Editor could not be opened", "The working set has no feature tree selected.");
|
217 |
|
return;
|
|
240 |
wsLabel = new Label(toolbarComposite, SWT.NONE);
|
|
241 |
|
|
242 |
btnToggleTree = new Button(toolbarComposite, SWT.PUSH);
|
|
243 |
btnToggleFlat = new Button(toolbarComposite, SWT.PUSH);
|
|
244 |
btnCollapseAll = new Button(toolbarComposite, SWT.PUSH);
|
|
245 |
btnExpandAll = new Button(toolbarComposite, SWT.PUSH);
|
|
246 |
comboStates = new ComboViewer(toolbarComposite, SWT.DROP_DOWN);
|
|
247 |
btnManageState = new Button(toolbarComposite, SWT.PUSH);
|
|
248 |
btnExcelExport = new Button(toolbarComposite, SWT.PUSH);
|
|
249 |
|
|
250 |
/**
|
|
251 |
* Toogle tree button
|
|
252 |
*/
|
|
253 |
btnToggleTree.setImage(ImageResources.getImage(ImageResources.HIERARCHICAL));
|
|
254 |
btnToggleTree.setToolTipText("Show taxon hierarchy");
|
|
255 |
btnToggleTree.setSelection(true);
|
|
256 |
btnToggleTree.setEnabled(false);
|
|
257 |
btnToggleTree.addSelectionListener(new SelectionAdapter() {
|
|
258 |
@Override
|
|
259 |
public void widgetSelected(SelectionEvent e) {
|
|
260 |
toggleTreeFlat(true);
|
|
261 |
}
|
|
262 |
});
|
|
263 |
|
|
264 |
/**
|
|
265 |
* Toogle flat button
|
|
266 |
*/
|
|
267 |
btnToggleFlat.setImage(ImageResources.getImage(ImageResources.FLAT));
|
|
268 |
btnToggleFlat.setToolTipText("Show flat list");
|
|
269 |
btnToggleFlat.addSelectionListener(new SelectionAdapter() {
|
|
270 |
@Override
|
|
271 |
public void widgetSelected(SelectionEvent e) {
|
|
272 |
toggleTreeFlat(false);
|
|
273 |
}
|
|
274 |
});
|
|
275 |
|
|
276 |
/**
|
|
277 |
*
|
|
278 |
* Collapse button
|
|
279 |
*/
|
|
280 |
btnCollapseAll.setImage(ImageResources.getImage(ImageResources.COLLAPSE_ALL));
|
|
281 |
btnCollapseAll.setToolTipText("Collapse all");
|
|
282 |
btnCollapseAll.addSelectionListener(new SelectionAdapter() {
|
|
283 |
@Override
|
|
284 |
public void widgetSelected(SelectionEvent e) {
|
|
285 |
natTable.doCommand(new TreeCollapseAllCommand());
|
|
286 |
}
|
|
287 |
});
|
|
288 |
|
|
289 |
/**
|
|
290 |
* Expand button
|
|
291 |
*/
|
|
292 |
btnExpandAll.setImage(ImageResources.getImage(ImageResources.EXPAND_ALL));
|
|
293 |
btnExpandAll.setToolTipText("Expand all");
|
|
294 |
btnExpandAll.addSelectionListener(new SelectionAdapter() {
|
|
295 |
@Override
|
|
296 |
public void widgetSelected(SelectionEvent e) {
|
|
297 |
natTable.doCommand(new TreeExpandAllCommand());
|
|
298 |
}
|
|
299 |
});
|
|
300 |
|
|
301 |
/**
|
|
302 |
* Table state persistence
|
|
303 |
*/
|
|
304 |
natTableState = new Properties();
|
|
305 |
//load persisted state
|
|
306 |
File statePropertiesFile = getStatePropertiesFile();
|
|
307 |
FileInputStream inputStream;
|
|
308 |
try {
|
|
309 |
inputStream = new FileInputStream(statePropertiesFile);
|
|
310 |
natTableState.load(inputStream);
|
|
311 |
} catch (IOException e) {
|
|
312 |
MessagingUtils.info("No initial state properties file found for character matrix");
|
218 |
313 |
}
|
219 |
|
thisPart.setLabel(workingSet.getLabel());
|
220 |
314 |
|
221 |
|
Composite toolbarComposite = new Composite(parent, SWT.NONE);
|
222 |
|
toolbarComposite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
|
223 |
|
toolbarComposite.setLayout(new GridLayout(6, false));
|
|
315 |
DisplayPersistenceDialogCommandHandler handler =
|
|
316 |
new DisplayPersistenceDialogCommandHandler(natTableState, natTable);
|
|
317 |
natTable.registerCommandHandler(handler);
|
|
318 |
// create a combobox for showing the available view states
|
|
319 |
Collection<String> availableStates = PersistenceHelper.getAvailableStates(natTableState);
|
|
320 |
comboStates.setLabelProvider(new LabelProvider(){
|
|
321 |
@Override
|
|
322 |
public String getText(Object element) {
|
|
323 |
if(element instanceof String && ((String) element).isEmpty()){
|
|
324 |
return "-default-";
|
|
325 |
}
|
|
326 |
return super.getText(element);
|
|
327 |
}
|
|
328 |
});
|
|
329 |
comboStates.setContentProvider(new ArrayContentProvider());
|
|
330 |
comboStates.addSelectionChangedListener(e->
|
|
331 |
{
|
|
332 |
int index = comboStates.getCombo().getSelectionIndex();
|
|
333 |
if (index >= 0) {
|
|
334 |
String selected = comboStates.getCombo().getItem(index);
|
|
335 |
// load the state
|
|
336 |
natTable.loadState(selected, natTableState);
|
|
337 |
natTableState.setProperty(PersistenceDialog.ACTIVE_VIEW_CONFIGURATION_KEY, selected);
|
|
338 |
}
|
|
339 |
});
|
|
340 |
comboStates.setInput(availableStates);
|
|
341 |
if(comboStates.getCombo().getItemCount()>0){
|
|
342 |
comboStates.getCombo().select(0);
|
|
343 |
}
|
|
344 |
|
|
345 |
// add listener to update the combo on view state management changes
|
|
346 |
handler.addStateChangeListener(new IStateChangedListener() {
|
|
347 |
@Override
|
|
348 |
public void handleStateChange(StateChangeEvent event) {
|
|
349 |
comboStates.setInput(PersistenceHelper.getAvailableStates(natTableState));
|
|
350 |
selectStateItem(comboStates, event.getViewConfigName());
|
|
351 |
}
|
|
352 |
});
|
|
353 |
|
|
354 |
// add button to show dialog
|
|
355 |
btnManageState.setImage(ImageResources.getImage(ImageResources.SETTINGS));
|
|
356 |
btnManageState.setToolTipText("View configuration");
|
|
357 |
btnManageState.addSelectionListener(new SelectionAdapter() {
|
|
358 |
@Override
|
|
359 |
public void widgetSelected(SelectionEvent e) {
|
|
360 |
natTable.doCommand(new DisplayPersistenceDialogCommand(natTable));
|
|
361 |
selectStateItem(comboStates, natTableState.get(PersistenceDialog.ACTIVE_VIEW_CONFIGURATION_KEY).toString());
|
|
362 |
}
|
|
363 |
});
|
|
364 |
|
|
365 |
/**
|
|
366 |
* excel export
|
|
367 |
*/
|
|
368 |
btnExcelExport.setToolTipText("Export to Excel");
|
|
369 |
btnExcelExport.setImage(ImageResources.getImage(ImageResources.EXPORT));
|
|
370 |
btnExcelExport.addSelectionListener(new SelectionAdapter() {
|
|
371 |
@Override
|
|
372 |
public void widgetSelected(SelectionEvent e) {
|
|
373 |
natTable.doCommand(
|
|
374 |
new ExportCommand(
|
|
375 |
natTable.getConfigRegistry(),
|
|
376 |
natTable.getShell()));
|
|
377 |
}
|
|
378 |
});
|
|
379 |
|
|
380 |
buttonPanel = new Composite(parent, SWT.NONE);
|
|
381 |
}
|
|
382 |
|
|
383 |
private void toggleTreeFlat(boolean isTree) {
|
|
384 |
init(workingSet.getUuid(), isTree);
|
|
385 |
btnToggleFlat.setEnabled(isTree);
|
|
386 |
btnToggleTree.setEnabled(!isTree);
|
|
387 |
btnCollapseAll.setEnabled(isTree);
|
|
388 |
btnExpandAll.setEnabled(isTree);
|
|
389 |
natTable.doCommand(new StructuralRefreshCommand());
|
|
390 |
}
|
|
391 |
|
|
392 |
public void init(UUID workingSetUuid, boolean treeView) {
|
|
393 |
if(workingSet==null){
|
|
394 |
this.workingSet = CdmStore.getService(IWorkingSetService.class).load(workingSetUuid, WS_PROPERTY_PATH);
|
|
395 |
if(workingSet.getDescriptiveSystem()==null){
|
|
396 |
MessagingUtils.informationDialog("Editor could not be opened", "The working set has no feature tree selected.");
|
|
397 |
return;
|
|
398 |
}
|
|
399 |
thisPart.setLabel(workingSet.getLabel());
|
224 |
400 |
|
225 |
|
//get features/columns stored in working set
|
226 |
|
FeatureTree tree = workingSet.getDescriptiveSystem();
|
227 |
|
List<Feature> features = new ArrayList<>(tree.getDistinctFeatures());
|
228 |
|
Collections.sort(features);
|
|
401 |
//get features/columns stored in working set
|
|
402 |
FeatureTree tree = workingSet.getDescriptiveSystem();
|
|
403 |
features = new ArrayList<>(tree.getDistinctFeatures());
|
|
404 |
Collections.sort(features);
|
229 |
405 |
|
230 |
|
descriptions = GlazedLists.eventList(getDescriptions(workingSet));
|
|
406 |
descriptions = GlazedLists.eventList(getDescriptions(workingSet));
|
|
407 |
}
|
231 |
408 |
// use the SortedList constructor with 'null' for the Comparator
|
232 |
409 |
// because the Comparator will be set by configuration
|
233 |
410 |
SortedList<Object> sortedList = new SortedList<>(descriptions, null);
|
234 |
411 |
// wrap the SortedList with the TreeList
|
235 |
|
TreeList treeList = new TreeList(sortedList, new DescriptionTreeFormat(workingSet.getMaxRank()), TreeList.NODES_START_EXPANDED);
|
236 |
|
|
237 |
|
ConfigRegistry configRegistry = new ConfigRegistry();
|
238 |
|
|
|
412 |
TreeList<Object> treeList = new TreeList(sortedList, new DescriptionTreeFormat(workingSet.getMaxRank()), TreeList.NODES_START_EXPANDED);
|
239 |
413 |
/**
|
240 |
414 |
* data provider
|
241 |
415 |
*/
|
242 |
416 |
SpecimenColumnPropertyAccessor columnPropertyAccessor = new SpecimenColumnPropertyAccessor(this);
|
243 |
|
bodyDataProvider = new ListDataProvider<Object>(treeList, columnPropertyAccessor);
|
|
417 |
bodyDataProvider = treeView?new ListDataProvider<>(treeList, columnPropertyAccessor):new ListDataProvider<>(sortedList, columnPropertyAccessor);
|
|
418 |
|
|
419 |
ConfigRegistry configRegistry = new ConfigRegistry();
|
|
420 |
|
244 |
421 |
|
245 |
422 |
/**
|
246 |
423 |
* BODY layer
|
... | ... | |
255 |
432 |
ViewportLayer
|
256 |
433 |
|
257 |
434 |
^
|
258 |
|
TreeLayer
|
|
435 |
TreeLayer (default visible)
|
259 |
436 |
|
260 |
437 |
^
|
261 |
438 |
SelectionLayer
|
... | ... | |
307 |
484 |
RowHideShowLayer rowHideShowLayer = new RowHideShowLayer(columnHideShowLayer);
|
308 |
485 |
SelectionLayer selectionLayer = new SelectionLayer(rowHideShowLayer);
|
309 |
486 |
TreeLayer treeLayer = new TreeLayer(selectionLayer, treeRowModel);
|
310 |
|
ViewportLayer viewportLayer = new ViewportLayer(treeLayer);
|
|
487 |
ViewportLayer viewportLayer = treeView?new ViewportLayer(treeLayer):new ViewportLayer(selectionLayer);
|
311 |
488 |
|
312 |
489 |
// create a standalone FixedSummaryRowLayer
|
313 |
490 |
// since the summary row should be fixed at the top of the body
|
... | ... | |
344 |
521 |
// add the SortHeaderLayer to the column header layer stack
|
345 |
522 |
// as we use GlazedLists, we use the GlazedListsSortModel which
|
346 |
523 |
// delegates the sorting to the SortedList
|
347 |
|
//TODO currently disabled sorting because of tree list
|
348 |
|
// final SortHeaderLayer<SpecimenDescription> sortHeaderLayer = new SortHeaderLayer<>(
|
349 |
|
// columnHeaderLayer,
|
350 |
|
// new GlazedListsSortModel<>(
|
351 |
|
// sortedList,
|
352 |
|
// columnPropertyAccessor,
|
353 |
|
// configRegistry,
|
354 |
|
// columnHeaderDataLayer));
|
|
524 |
final SortHeaderLayer<SpecimenDescription> sortHeaderLayer = new SortHeaderLayer<>(
|
|
525 |
columnHeaderLayer,
|
|
526 |
new GlazedListsSortModel<>(
|
|
527 |
sortedList,
|
|
528 |
columnPropertyAccessor,
|
|
529 |
configRegistry,
|
|
530 |
columnHeaderDataLayer));
|
355 |
531 |
|
356 |
532 |
|
357 |
533 |
/**
|
... | ... | |
369 |
545 |
*/
|
370 |
546 |
ILayer cornerLayer = new CornerLayer(
|
371 |
547 |
new DataLayer(new DefaultCornerDataProvider(columnHeaderDataProvider, rowHeaderDataProvider)),
|
372 |
|
fixedSummaryRowHeaderLayer, columnHeaderLayer);
|
|
548 |
fixedSummaryRowHeaderLayer, sortHeaderLayer);
|
373 |
549 |
|
374 |
550 |
|
375 |
551 |
/**
|
376 |
552 |
* GRID layer (composition of all other layers)
|
377 |
553 |
*/
|
378 |
|
GridLayer gridLayer = new GridLayer(composite, columnHeaderLayer, fixedSummaryRowHeaderLayer, cornerLayer);
|
379 |
|
|
380 |
|
|
381 |
|
|
382 |
|
natTable = new NatTable(parent, gridLayer, false);
|
|
554 |
GridLayer gridLayer = new GridLayer(composite, sortHeaderLayer, fixedSummaryRowHeaderLayer, cornerLayer);
|
383 |
555 |
|
|
556 |
natTable.setLayer(gridLayer);
|
384 |
557 |
|
385 |
558 |
/**
|
386 |
559 |
* CONFIGURATION
|
387 |
560 |
*/
|
388 |
561 |
natTable.setConfigRegistry(configRegistry);
|
389 |
562 |
|
390 |
|
|
391 |
563 |
//add default configuration because autoconfigure is set to false in constructor
|
392 |
564 |
natTable.addConfiguration(new DefaultNatTableStyleConfiguration());
|
393 |
565 |
|
... | ... | |
397 |
569 |
// override the default sort configuration and change the mouse bindings
|
398 |
570 |
// to sort on a single click
|
399 |
571 |
//currently removed sorting because of using the TreeConfiguration
|
400 |
|
// natTable.addConfiguration(new SingleClickSortConfiguration());
|
401 |
|
|
|
572 |
natTable.addConfiguration(new SingleClickSortConfiguration());
|
402 |
573 |
|
403 |
574 |
// add the header menu configuration for adding the column header menu
|
404 |
575 |
// with hide/show actions
|
... | ... | |
487 |
658 |
|
488 |
659 |
GridDataFactory.fillDefaults().grab(true, true).applyTo(natTable);
|
489 |
660 |
|
490 |
|
/**
|
491 |
|
* Info label
|
492 |
|
*/
|
493 |
|
Label wsLabel = new Label(toolbarComposite, SWT.NONE);
|
|
661 |
|
494 |
662 |
wsLabel.setText(workingSet.getLabel());
|
495 |
663 |
wsLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
|
|
664 |
wsLabel.getParent().layout();
|
496 |
665 |
|
497 |
|
|
498 |
|
/**
|
499 |
|
* Expand/Collapse button
|
500 |
|
*/
|
501 |
|
Button collapseAllButton = new Button(toolbarComposite, SWT.PUSH);
|
502 |
|
collapseAllButton.setImage(ImageResources.getImage(ImageResources.COLLAPSE_ALL));
|
503 |
|
collapseAllButton.setToolTipText("Collapse all");
|
504 |
|
collapseAllButton.addSelectionListener(new SelectionAdapter() {
|
505 |
|
@Override
|
506 |
|
public void widgetSelected(SelectionEvent e) {
|
507 |
|
natTable.doCommand(new TreeCollapseAllCommand());
|
508 |
|
}
|
509 |
|
});
|
510 |
|
Button expandAllButton = new Button(toolbarComposite, SWT.PUSH);
|
511 |
|
expandAllButton.setImage(ImageResources.getImage(ImageResources.EXPAND_ALL));
|
512 |
|
expandAllButton.setToolTipText("Expand all");
|
513 |
|
expandAllButton.addSelectionListener(new SelectionAdapter() {
|
514 |
|
@Override
|
515 |
|
public void widgetSelected(SelectionEvent e) {
|
516 |
|
natTable.doCommand(new TreeExpandAllCommand());
|
517 |
|
}
|
518 |
|
});
|
519 |
|
|
520 |
|
/**
|
521 |
|
* Table state persistence
|
522 |
|
*/
|
523 |
|
natTableState = new Properties();
|
524 |
|
//load persisted state
|
525 |
|
File statePropertiesFile = getStatePropertiesFile();
|
526 |
|
FileInputStream inputStream;
|
527 |
|
try {
|
528 |
|
inputStream = new FileInputStream(statePropertiesFile);
|
529 |
|
natTableState.load(inputStream);
|
530 |
|
} catch (IOException e) {
|
531 |
|
MessagingUtils.info("No initial state properties file found for character matrix");
|
532 |
|
}
|
533 |
|
|
534 |
|
DisplayPersistenceDialogCommandHandler handler =
|
535 |
|
new DisplayPersistenceDialogCommandHandler(natTableState, natTable);
|
536 |
|
gridLayer.registerCommandHandler(handler);
|
537 |
|
// create a combobox for showing the available view states
|
538 |
|
ComboViewer comboStates= new ComboViewer(toolbarComposite, SWT.DROP_DOWN) ;
|
539 |
|
Collection<String> availableStates = PersistenceHelper.getAvailableStates(natTableState);
|
540 |
|
comboStates.setLabelProvider(new LabelProvider(){
|
541 |
|
@Override
|
542 |
|
public String getText(Object element) {
|
543 |
|
if(element instanceof String && ((String) element).isEmpty()){
|
544 |
|
return "-default-";
|
545 |
|
}
|
546 |
|
return super.getText(element);
|
547 |
|
}
|
548 |
|
});
|
549 |
|
comboStates.setContentProvider(new ArrayContentProvider());
|
550 |
|
comboStates.addSelectionChangedListener(e->
|
551 |
|
{
|
552 |
|
int index = comboStates.getCombo().getSelectionIndex();
|
553 |
|
if (index >= 0) {
|
554 |
|
String selected = comboStates.getCombo().getItem(index);
|
555 |
|
// load the state
|
556 |
|
natTable.loadState(selected, natTableState);
|
557 |
|
natTableState.setProperty(PersistenceDialog.ACTIVE_VIEW_CONFIGURATION_KEY, selected);
|
558 |
|
}
|
559 |
|
});
|
560 |
|
comboStates.setInput(availableStates);
|
561 |
|
if(comboStates.getCombo().getItemCount()>0){
|
562 |
|
comboStates.getCombo().select(0);
|
563 |
|
}
|
564 |
|
|
565 |
|
// add listener to update the combo on view state management changes
|
566 |
|
handler.addStateChangeListener(new IStateChangedListener() {
|
567 |
|
@Override
|
568 |
|
public void handleStateChange(StateChangeEvent event) {
|
569 |
|
comboStates.setInput(PersistenceHelper.getAvailableStates(natTableState));
|
570 |
|
selectStateItem(comboStates, event.getViewConfigName());
|
571 |
|
}
|
572 |
|
});
|
573 |
|
|
574 |
|
// add button to show dialog
|
575 |
|
Button btnManageState = new Button(toolbarComposite, SWT.PUSH);
|
576 |
|
btnManageState.setImage(ImageResources.getImage(ImageResources.SETTINGS));
|
577 |
|
btnManageState.setToolTipText("View configuration");
|
578 |
|
btnManageState.addSelectionListener(new SelectionAdapter() {
|
579 |
|
@Override
|
580 |
|
public void widgetSelected(SelectionEvent e) {
|
581 |
|
natTable.doCommand(new DisplayPersistenceDialogCommand(natTable));
|
582 |
|
selectStateItem(comboStates, natTableState.get(PersistenceDialog.ACTIVE_VIEW_CONFIGURATION_KEY).toString());
|
583 |
|
}
|
584 |
|
});
|
585 |
|
|
586 |
|
/**
|
587 |
|
* excel export
|
588 |
|
*/
|
589 |
|
Button btnExcelExport = new Button(toolbarComposite, SWT.PUSH);
|
590 |
|
btnExcelExport.setToolTipText("Export to Excel");
|
591 |
|
btnExcelExport.setImage(ImageResources.getImage(ImageResources.EXPORT));
|
592 |
|
btnExcelExport.addSelectionListener(new SelectionAdapter() {
|
593 |
|
@Override
|
594 |
|
public void widgetSelected(SelectionEvent e) {
|
595 |
|
natTable.doCommand(
|
596 |
|
new ExportCommand(
|
597 |
|
natTable.getConfigRegistry(),
|
598 |
|
natTable.getShell()));
|
599 |
|
}
|
600 |
|
});
|
601 |
|
|
602 |
|
/**
|
603 |
|
* bottom button toolbar
|
604 |
|
*/
|
605 |
|
Composite buttonPanel = new Composite(parent, SWT.NONE);
|
606 |
666 |
buttonPanel.setLayout(new RowLayout());
|
607 |
667 |
GridDataFactory.fillDefaults().grab(true, false).applyTo(buttonPanel);
|
608 |
668 |
|
ref #7095 Add functionality to toggle between tree and flat list