use of org.openlca.core.model.DQSystem in project olca-modules by GreenDelta.
the class DQSystemImport method create.
private void create(DQSystemDescriptor descriptor) {
DQSystem src = srcDao.getForId(descriptor.id);
DQSystem dest = src.copy();
dest.refId = src.refId;
dest.category = refs.switchRef(src.category);
dest.source = refs.switchRef(src.source);
dest = destDao.insert(dest);
seq.put(seq.DQ_SYSTEM, src.refId, dest.id);
}
use of org.openlca.core.model.DQSystem in project olca-app by GreenDelta.
the class ProcessFigure method drawDqBar.
private void drawDqBar(Graphics g) {
DQResult dqResult = node.parent.editor.dqResult;
if (!DQUI.displayProcessQuality(dqResult))
return;
Point loc = getLocation();
Dimension size = getSize();
Color fColor = g.getForegroundColor();
Color bColor = g.getBackgroundColor();
g.setForegroundColor(Colors.white());
g.setBackgroundColor(Colors.white());
int x = loc.x + size.width - 30;
int y = loc.y + 10;
int w = 20;
DQSystem system = dqResult.setup.processSystem;
int h = (size.height - 20) / system.indicators.size();
int[] values = dqResult.get(node.product);
for (int value : values) {
Color color = DQUI.getColor(value, system.getScoreCount());
g.setBackgroundColor(color);
g.drawRectangle(x, y, w, h);
g.fillRectangle(x + 1, y + 1, w - 1, h - 1);
y += h;
}
g.setForegroundColor(fColor);
g.setBackgroundColor(bColor);
}
use of org.openlca.core.model.DQSystem in project olca-app by GreenDelta.
the class InfoPage method createDqEntryRow.
private Hyperlink createDqEntryRow(Composite parent, FormToolkit tk) {
UI.formLabel(parent, tk, M.DataQualityEntry);
Supplier<String> dqLabel = () -> {
Process p = getModel();
return p.dqSystem == null || Strings.nullOrEmpty(p.dqEntry) ? "(not specified)" : p.dqSystem.applyScoreLabels(p.dqEntry);
};
Hyperlink link = UI.formLink(parent, tk, dqLabel.get());
Controls.onClick(link, e -> {
if (getModel().dqSystem == null) {
MsgBox.info("No data quality system is selected");
return;
}
String oldVal = getModel().dqEntry;
DQSystem system = getModel().dqSystem;
String entry = getModel().dqEntry;
DataQualityShell shell = DataQualityShell.withoutUncertainty(parent.getShell(), system, entry);
shell.onOk = (_shell) -> {
getModel().dqEntry = _shell.getSelection();
};
shell.onDelete = (_shell) -> {
getModel().dqEntry = null;
};
shell.addDisposeListener(_e -> {
if (Objects.equals(oldVal, getModel().dqEntry))
return;
link.setText(dqLabel.get());
link.pack();
getEditor().setDirty(true);
});
shell.open();
});
link.setEnabled(isEditable());
new CommentControl(parent, getToolkit(), "dqEntry", getComments());
return link;
}
use of org.openlca.core.model.DQSystem in project olca-app by GreenDelta.
the class DataQualityCellEditor method openDialogBox.
@Override
protected Object openDialogBox(Control control) {
if (exchange == null || editor.getModel().exchangeDqSystem == null) {
MsgBox.error("Please select a data quality system first");
return null;
}
DQSystem system = editor.getModel().exchangeDqSystem;
String dqEntry = exchange.dqEntry;
Double uncertainty = exchange.baseUncertainty;
DataQualityShell shell = DataQualityShell.withUncertainty(control.getShell(), system, dqEntry, uncertainty);
shell.onOk = this::onOk;
shell.onDelete = this::onDelete;
shell.onUseUncertainties = this::onUseUncertainties;
shell.addDisposeListener(e -> {
if (valuesChanged()) {
updateContents(exchange.dqEntry);
viewer.refresh();
editor.setDirty(true);
}
});
shell.open();
return null;
}
Aggregations