use of org.openlca.app.M in project olca-app by GreenDelta.
the class ImpactPage method createFormContent.
@Override
protected void createFormContent(IManagedForm mform) {
ScrolledForm form = UI.formHeader(this);
FormToolkit tk = mform.getToolkit();
Composite body = UI.formBody(form, tk);
Composite comp = tk.createComposite(body);
UI.gridLayout(comp, 4);
UI.formLabel(comp, tk, M.ImpactAssessmentMethod);
combo = new ImpactMethodViewer(comp);
List<ImpactMethodDescriptor> list = new ImpactMethodDao(Database.get()).getDescriptors().stream().sorted((m1, m2) -> Strings.compare(m1.name, m2.name)).collect(Collectors.toList());
combo.setInput(list);
combo.addSelectionChangedListener(this::setTreeInput);
zeroCheck = tk.createButton(comp, M.ExcludeZeroValues, SWT.CHECK);
zeroCheck.setSelection(true);
Controls.onSelect(zeroCheck, e -> setTreeInput(combo.getSelected()));
Button reload = tk.createButton(comp, M.Reload, SWT.NONE);
reload.setImage(Icon.REFRESH.get());
Controls.onSelect(reload, _e -> {
result = null;
setTreeInput(combo.getSelected());
});
tree = Trees.createViewer(body, M.Name, M.Category, M.Amount, M.Result);
UI.gridData(tree.getControl(), true, true);
tree.setContentProvider(new Content());
tree.setLabelProvider(new Label());
Trees.bindColumnWidths(tree.getTree(), 0.35, 0.35, 0.15, 0.15);
tree.getTree().getColumns()[2].setAlignment(SWT.RIGHT);
tree.getTree().getColumns()[3].setAlignment(SWT.RIGHT);
Action onOpen = Actions.onOpen(() -> {
Contribution<?> c = Viewers.getFirstSelected(tree);
if (c == null)
return;
if (c.item instanceof EnviFlow) {
App.open(((EnviFlow) c.item).flow());
}
if (c.item instanceof ImpactDescriptor) {
App.open((ImpactDescriptor) c.item);
}
});
Actions.bind(tree, onOpen);
Trees.onDoubleClick(tree, e -> onOpen.run());
if (!list.isEmpty()) {
ImpactMethodDescriptor m = list.get(0);
combo.select(m);
setTreeInput(m);
}
form.reflow(true);
}
use of org.openlca.app.M in project olca-app by GreenDelta.
the class JsonImportDialog method createDialogArea.
@Override
protected Control createDialogArea(Composite parent) {
Composite root = (Composite) super.createDialogArea(parent);
UI.gridLayout(root, 1, 10, 10);
Composite comp = new Composite(root, SWT.NONE);
UI.gridLayout(comp, 2, 10, 0);
UI.formLabel(comp, M.File);
String fileText = Strings.cut(provider.file().getParent(), 50) + File.separator + Strings.cut(provider.file().getName(), 50);
Label label = UI.formLabel(comp, fileText);
label.setForeground(Colors.linkBlue());
Button openCheck = new Button(root, SWT.RADIO);
openCheck.setText("Open mapping definition");
Combo combo = new Combo(root, SWT.READ_ONLY);
Controls.onSelect(combo, e -> {
selectedMap = flowMaps.get(combo.getSelectionIndex());
});
UI.gridData(combo, true, false);
Controls.onSelect(openCheck, e -> {
selectedMap = flowMaps.get(combo.getSelectionIndex());
combo.setEnabled(true);
});
Button genCheck = new Button(root, SWT.RADIO);
genCheck.setText("Generate mapping based on flow attributes");
Controls.onSelect(genCheck, e -> {
selectedMap = null;
combo.setEnabled(false);
});
if (flowMaps.isEmpty()) {
genCheck.setSelection(true);
openCheck.setSelection(false);
combo.setEnabled(false);
openCheck.setEnabled(false);
} else {
openCheck.setSelection(true);
genCheck.setSelection(false);
String[] items = this.flowMaps.stream().map(m -> m.name).toArray(len -> new String[len]);
combo.setItems(items);
combo.select(0);
selectedMap = flowMaps.get(0);
}
return root;
}
Aggregations