use of name.abuchen.portfolio.model.TaxonomyTemplate in project portfolio by buchen.
the class OpenSampleHandler method applyTaxonomyLabels.
private void applyTaxonomyLabels(TaxonomyTemplate template, Taxonomy taxonomy) {
Taxonomy original = template.buildOriginal();
taxonomy.setName(original.getName());
taxonomy.setDimensions(original.getDimensions());
Map<String, Classification> translated = //
original.getAllClassifications().stream().collect(Collectors.toMap(c -> c.getId(), c -> c));
taxonomy.foreach(new Visitor() {
@Override
public void visit(Classification classification) {
Classification t = translated.get(classification.getId());
if (t != null) {
classification.setName(t.getName());
classification.setNote(t.getNote());
}
}
});
}
use of name.abuchen.portfolio.model.TaxonomyTemplate in project portfolio by buchen.
the class AddTaxonomyPage method createControl.
@Override
public void createControl(Composite parent) {
Composite container = new Composite(parent, SWT.NONE);
setControl(container);
TableColumnLayout layout = new TableColumnLayout();
container.setLayout(layout);
final TableViewer viewer = new TableViewer(container);
TableViewerColumn column = new TableViewerColumn(viewer, SWT.NONE);
layout.setColumnData(column.getColumn(), new ColumnWeightData(90));
column.getColumn().setText(Messages.ColumnTaxonomy);
column.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
return ((TaxonomyTemplate) element).getName();
}
});
column = new TableViewerColumn(viewer, SWT.NONE);
layout.setColumnData(column.getColumn(), new ColumnWeightData(10));
column.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
return null;
}
@Override
public Image getImage(Object element) {
TaxonomyTemplate t = (TaxonomyTemplate) element;
if (taxonomiesAdded.contains(t.getId()))
return Images.CHECK.image();
else
return null;
}
});
viewer.addDoubleClickListener(new IDoubleClickListener() {
@Override
public void doubleClick(DoubleClickEvent event) {
TaxonomyTemplate template = (TaxonomyTemplate) ((IStructuredSelection) event.getSelection()).getFirstElement();
if (template != null && !taxonomiesAdded.contains(template.getId())) {
taxonomiesAdded.add(template.getId());
client.addTaxonomy(template.build());
viewer.refresh(template);
}
}
});
viewer.getTable().setHeaderVisible(true);
viewer.setContentProvider(ArrayContentProvider.getInstance());
viewer.setInput(TaxonomyTemplate.list());
setPageComplete(true);
}
use of name.abuchen.portfolio.model.TaxonomyTemplate in project portfolio by buchen.
the class ClientEditorSidebar method taxonomyCreateMenuAboutToShow.
private void taxonomyCreateMenuAboutToShow(IMenuManager manager) {
manager.add(new Action(Messages.MenuTaxonomyCreate) {
@Override
public void run() {
String name = askTaxonomyName(Messages.LabelNewTaxonomy);
if (name == null)
return;
Taxonomy taxonomy = new Taxonomy(name);
taxonomy.setRootNode(new Classification(UUID.randomUUID().toString(), name));
addAndOpenTaxonomy(taxonomy);
}
});
manager.add(new Separator());
manager.add(new LabelOnly(Messages.LabelTaxonomyTemplates));
for (final TaxonomyTemplate template : TaxonomyTemplate.list()) {
manager.add(new Action(template.getName()) {
@Override
public void run() {
addAndOpenTaxonomy(template.build());
}
});
}
}
Aggregations