Search in sources :

Example 1 with DataQualityShell

use of org.openlca.app.editors.processes.data_quality.DataQualityShell 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 2 with DataQualityShell

use of org.openlca.app.editors.processes.data_quality.DataQualityShell 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

DataQualityShell (org.openlca.app.editors.processes.data_quality.DataQualityShell)2 DQSystem (org.openlca.core.model.DQSystem)2 Hyperlink (org.eclipse.ui.forms.widgets.Hyperlink)1 ImageHyperlink (org.eclipse.ui.forms.widgets.ImageHyperlink)1 CommentControl (org.openlca.app.editors.comments.CommentControl)1 Process (org.openlca.core.model.Process)1