use of org.openlca.core.model.Parameter in project olca-app by GreenDelta.
the class Clipboard method readAsCalculatedParams.
static List<Parameter> readAsCalculatedParams(String text, ParameterScope scope) {
ClipboardText ct = ClipboardText.split(text);
List<Parameter> params = readParams(ct);
for (Parameter param : params) {
param.scope = scope;
param.isInputParameter = false;
if (param.formula == null) {
param.formula = Double.toString(param.value);
}
param.uncertainty = null;
}
return params;
}
use of org.openlca.core.model.Parameter in project olca-app by GreenDelta.
the class Formulas method evalGlobal.
private List<String> evalGlobal(List<Parameter> params) {
try {
FormulaInterpreter interpreter = new FormulaInterpreter();
Scope scope = interpreter.getGlobalScope();
for (Parameter p : params) bind(p, scope);
evalParams(params, scope);
} catch (Exception e) {
log.warn("unexpected error in formula evaluation", e);
}
return errors;
}
use of org.openlca.core.model.Parameter in project olca-app by GreenDelta.
the class ParameterPage method bindGlobalParamActions.
private void bindGlobalParamActions(Section section, TableViewer table) {
var copy = TableClipboard.onCopySelected(table);
var refresh = Actions.create(M.Reload, Icon.REFRESH.descriptor(), () -> {
setGlobalTableInput();
support.evaluate();
editor.setDirty(true);
});
var usage = Actions.create(M.Usage, Icon.LINK.descriptor(), () -> {
Parameter p = Viewers.getFirstSelected(table);
if (p != null) {
ParameterUsagePage.show(p.name);
}
});
Actions.bind(table, copy, refresh, usage);
Actions.bind(section, refresh);
}
use of org.openlca.core.model.Parameter in project olca-app by GreenDelta.
the class ParameterSection method onPaste.
private void onPaste(String text) {
var scope = entity().parameterScope();
var params = forInputParameters ? Clipboard.readAsInputParams(text, scope) : Clipboard.readAsCalculatedParams(text, scope);
boolean skipped = false;
for (Parameter param : params) {
String name = param.name;
if (!Parameters.isValidName(name) || exists(name)) {
skipped = true;
continue;
}
entity().parameters.add(param);
}
if (skipped) {
MsgBox.warning(M.SomeParametersWereNotAdded);
}
setInput();
editor.setDirty(true);
support.evaluate();
}
Aggregations