Revision 1016796d
Added by Patrick Plitzner over 6 years ago
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/workingSet/matrix/CharacterMatrix.java | ||
---|---|---|
45 | 45 |
import org.eclipse.nebula.widgets.nattable.data.ListDataProvider; |
46 | 46 |
import org.eclipse.nebula.widgets.nattable.edit.EditConfigAttributes; |
47 | 47 |
import org.eclipse.nebula.widgets.nattable.edit.editor.IComboBoxDataProvider; |
48 |
import org.eclipse.nebula.widgets.nattable.export.command.ExportCommand; |
|
49 | 48 |
import org.eclipse.nebula.widgets.nattable.export.command.ExportCommandHandler; |
50 | 49 |
import org.eclipse.nebula.widgets.nattable.extension.glazedlists.GlazedListsEventLayer; |
51 | 50 |
import org.eclipse.nebula.widgets.nattable.extension.glazedlists.GlazedListsSortModel; |
... | ... | |
82 | 81 |
import org.eclipse.swt.SWT; |
83 | 82 |
import org.eclipse.swt.events.SelectionAdapter; |
84 | 83 |
import org.eclipse.swt.events.SelectionEvent; |
84 |
import org.eclipse.swt.layout.GridData; |
|
85 | 85 |
import org.eclipse.swt.layout.GridLayout; |
86 | 86 |
import org.eclipse.swt.widgets.Button; |
87 | 87 |
import org.eclipse.swt.widgets.Combo; |
... | ... | |
109 | 109 |
import eu.etaxonomy.taxeditor.editor.workingSet.matrix.supplementalInfo.SupplementalInfoDisplayConverter; |
110 | 110 |
import eu.etaxonomy.taxeditor.model.IDirtyMarkable; |
111 | 111 |
import eu.etaxonomy.taxeditor.model.IPartContentHasDetails; |
112 |
import eu.etaxonomy.taxeditor.model.ImageResources; |
|
112 | 113 |
import eu.etaxonomy.taxeditor.model.MessagingUtils; |
113 | 114 |
import eu.etaxonomy.taxeditor.store.CdmStore; |
114 | 115 |
import eu.etaxonomy.taxeditor.workbench.WorkbenchUtility; |
... | ... | |
169 | 170 |
this.workingSet = CdmStore.getService(IWorkingSetService.class).load(workingSetUuid); |
170 | 171 |
thisPart.setLabel(workingSet.getLabel()); |
171 | 172 |
|
173 |
Composite toolbarComposite = new Composite(parent, SWT.NONE); |
|
174 |
toolbarComposite.setLayout(new GridLayout(2, false)); |
|
175 |
toolbarComposite.setLayoutData(new GridData(SWT.TRAIL, SWT.CENTER, true, false)); |
|
176 |
|
|
172 | 177 |
//get features/columns stored in working set |
173 | 178 |
FeatureTree tree = workingSet.getDescriptiveSystem(); |
174 | 179 |
List<Feature> features = new ArrayList<>(tree.getDistinctFeatures()); |
... | ... | |
358 | 363 |
/** |
359 | 364 |
* Table state persistence |
360 | 365 |
*/ |
361 |
Properties natTableState = new Properties();
|
|
366 |
natTableState = new Properties(); |
|
362 | 367 |
//load persisted state |
363 |
File statePropertiesFile = new File(WorkbenchUtility.getBaseLocation(), CHARACTER_MATRIX_STATE_PROPERTIES);
|
|
368 |
File statePropertiesFile = getStatePropertiesFile();
|
|
364 | 369 |
FileInputStream inputStream; |
365 | 370 |
try { |
366 | 371 |
inputStream = new FileInputStream(statePropertiesFile); |
367 | 372 |
natTableState.load(inputStream); |
368 |
natTable.loadState("", natTableState); |
|
369 | 373 |
} catch (IOException e) { |
370 |
MessagingUtils.error(CharacterMatrix.class, e);;e.printStackTrace();
|
|
374 |
MessagingUtils.info("No initial state properties file found for character matrix");
|
|
371 | 375 |
} |
372 | 376 |
|
373 | 377 |
DisplayPersistenceDialogCommandHandler handler = |
374 | 378 |
new DisplayPersistenceDialogCommandHandler(natTableState, natTable); |
375 | 379 |
gridLayer.registerCommandHandler(handler); |
376 | 380 |
// create a combobox for showing the available view states |
377 |
Combo viewStates = new Combo(parent, SWT.DROP_DOWN);
|
|
378 |
viewStates.setItems(PersistenceHelper
|
|
381 |
Combo comboStates = new Combo(toolbarComposite, SWT.DROP_DOWN);
|
|
382 |
comboStates.setItems(PersistenceHelper
|
|
379 | 383 |
.getAvailableStates(natTableState) |
380 | 384 |
.toArray(new String[] {})); |
381 |
viewStates.addSelectionListener(new SelectionAdapter() {
|
|
385 |
comboStates.addSelectionListener(new SelectionAdapter() {
|
|
382 | 386 |
|
383 | 387 |
@Override |
384 | 388 |
public void widgetSelected(SelectionEvent e) { |
385 |
int index = viewStates.getSelectionIndex();
|
|
389 |
int index = comboStates.getSelectionIndex();
|
|
386 | 390 |
if (index >= 0) { |
387 |
String selected = viewStates.getItem(index);
|
|
391 |
String selected = comboStates.getItem(index);
|
|
388 | 392 |
// load the state |
389 | 393 |
natTable.loadState(selected, natTableState); |
390 | 394 |
} |
... | ... | |
396 | 400 |
|
397 | 401 |
@Override |
398 | 402 |
public void handleStateChange(StateChangeEvent event) { |
399 |
viewStates.setItems(PersistenceHelper
|
|
403 |
comboStates.setItems(PersistenceHelper
|
|
400 | 404 |
.getAvailableStates(natTableState) |
401 | 405 |
.toArray(new String[] {})); |
402 | 406 |
} |
403 | 407 |
}); |
404 | 408 |
|
405 | 409 |
// add button to show dialog |
406 |
Button manage = new Button(parent, SWT.PUSH);
|
|
407 |
manage.setText("View Management");
|
|
408 |
manage.addSelectionListener(new SelectionAdapter() {
|
|
410 |
Button btnManageState = new Button(toolbarComposite, SWT.PUSH);
|
|
411 |
btnManageState.setImage(ImageResources.getImage(ImageResources.SETTINGS));
|
|
412 |
btnManageState.addSelectionListener(new SelectionAdapter() {
|
|
409 | 413 |
@Override |
410 | 414 |
public void widgetSelected(SelectionEvent e) { |
411 | 415 |
natTable.doCommand(new DisplayPersistenceDialogCommand(natTable)); |
412 | 416 |
} |
413 | 417 |
}); |
414 |
Button btnSave = new Button(parent, SWT.PUSH); |
|
415 |
btnSave.setText("Save State"); |
|
416 |
btnSave.addSelectionListener(new SelectionAdapter() { |
|
417 |
@Override |
|
418 |
public void widgetSelected(SelectionEvent e) { |
|
419 |
natTable.saveState("", natTableState); |
|
420 |
try (FileOutputStream tableStateStream = |
|
421 |
new FileOutputStream(new File(WorkbenchUtility.getBaseLocation(), CHARACTER_MATRIX_STATE_PROPERTIES))) { |
|
422 |
natTableState.store(tableStateStream, null); |
|
423 |
} catch (IOException ioe) { |
|
424 |
ioe.printStackTrace(); |
|
425 |
} |
|
426 |
} |
|
427 |
}); |
|
428 | 418 |
|
429 | 419 |
/** |
430 | 420 |
* excel export |
431 | 421 |
*/ |
432 |
Button addColumnButton = new Button(parent, SWT.PUSH);
|
|
433 |
addColumnButton.setText("Export");
|
|
434 |
addColumnButton.addSelectionListener(new SelectionAdapter() { |
|
435 |
@Override |
|
436 |
public void widgetSelected(SelectionEvent e) { |
|
437 |
natTable.doCommand( |
|
438 |
new ExportCommand( |
|
439 |
natTable.getConfigRegistry(), |
|
440 |
natTable.getShell())); |
|
441 |
} |
|
442 |
}); |
|
422 |
// Button addColumnButton = new Button(toolbarComposite, SWT.PUSH);
|
|
423 |
// addColumnButton.setImage(ImageResources.getImage(ImageResources.EXPORT));
|
|
424 |
// addColumnButton.addSelectionListener(new SelectionAdapter() {
|
|
425 |
// @Override
|
|
426 |
// public void widgetSelected(SelectionEvent e) {
|
|
427 |
// natTable.doCommand(
|
|
428 |
// new ExportCommand(
|
|
429 |
// natTable.getConfigRegistry(),
|
|
430 |
// natTable.getShell()));
|
|
431 |
// }
|
|
432 |
// });
|
|
443 | 433 |
|
444 | 434 |
parent.layout(); |
445 | 435 |
} |
... | ... | |
548 | 538 |
this.dirty.setDirty(true); |
549 | 539 |
} |
550 | 540 |
|
541 |
public NatTable getNatTable() { |
|
542 |
return natTable; |
|
543 |
} |
|
544 |
|
|
551 | 545 |
@Persist |
552 | 546 |
@Override |
553 | 547 |
public void save(IProgressMonitor monitor) { |
... | ... | |
569 | 563 |
conversation.close(); |
570 | 564 |
conversation = null; |
571 | 565 |
} |
572 |
natTable.saveState("", natTableState); |
|
573 | 566 |
try (FileOutputStream tableStateStream = |
574 | 567 |
new FileOutputStream(getStatePropertiesFile())) { |
575 | 568 |
natTableState.store(tableStateStream, null); |
... | ... | |
579 | 572 |
} |
580 | 573 |
|
581 | 574 |
|
575 |
private File getStatePropertiesFile() { |
|
576 |
return new File(WorkbenchUtility.getBaseLocation(), CHARACTER_MATRIX_STATE_PROPERTIES); |
|
577 |
} |
|
578 |
|
|
579 |
|
|
582 | 580 |
/** |
583 | 581 |
* {@inheritDoc} |
584 | 582 |
*/ |
Also available in: Unified diff
ref #7095 UI enhancements