Search in sources :

Example 11 with DQSystem

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);
}
Also used : DQSystem(org.openlca.core.model.DQSystem)

Example 12 with DQSystem

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);
}
Also used : DQResult(org.openlca.core.math.data_quality.DQResult) DQSystem(org.openlca.core.model.DQSystem) Color(org.eclipse.swt.graphics.Color) Point(org.eclipse.draw2d.geometry.Point) Dimension(org.eclipse.draw2d.geometry.Dimension) Point(org.eclipse.draw2d.geometry.Point)

Example 13 with DQSystem

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;
}
Also used : DataQualityShell(org.openlca.app.editors.processes.data_quality.DataQualityShell) DQSystem(org.openlca.core.model.DQSystem) CommentControl(org.openlca.app.editors.comments.CommentControl) Process(org.openlca.core.model.Process) Hyperlink(org.eclipse.ui.forms.widgets.Hyperlink) ImageHyperlink(org.eclipse.ui.forms.widgets.ImageHyperlink)

Example 14 with DQSystem

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;
}
Also used : DataQualityShell(org.openlca.app.editors.processes.data_quality.DataQualityShell) DQSystem(org.openlca.core.model.DQSystem)

Aggregations

DQSystem (org.openlca.core.model.DQSystem)14 Process (org.openlca.core.model.Process)4 DQSystemDao (org.openlca.core.database.DQSystemDao)3 Source (org.openlca.core.model.Source)3 DataQualityShell (org.openlca.app.editors.processes.data_quality.DataQualityShell)2 Category (org.openlca.core.model.Category)2 DQIndicator (org.openlca.core.model.DQIndicator)2 DQScore (org.openlca.core.model.DQScore)2 Location (org.openlca.core.model.Location)2 Parameter (org.openlca.core.model.Parameter)2 ProcessDocumentation (org.openlca.core.model.ProcessDocumentation)2 Dimension (org.eclipse.draw2d.geometry.Dimension)1 Point (org.eclipse.draw2d.geometry.Point)1 ArrayContentProvider (org.eclipse.jface.viewers.ArrayContentProvider)1 BaseLabelProvider (org.eclipse.jface.viewers.BaseLabelProvider)1 ITableLabelProvider (org.eclipse.jface.viewers.ITableLabelProvider)1 ITreeContentProvider (org.eclipse.jface.viewers.ITreeContentProvider)1 TreeViewer (org.eclipse.jface.viewers.TreeViewer)1 Color (org.eclipse.swt.graphics.Color)1 Hyperlink (org.eclipse.ui.forms.widgets.Hyperlink)1