Search in sources :

Example 1 with UpdateMode

use of org.openlca.jsonld.input.UpdateMode in project olca-app by GreenDelta.

the class JsonImportPage method createControl.

@Override
public void createControl(Composite parent) {
    Composite body = new Composite(parent, SWT.NONE);
    UI.gridLayout(body, 1);
    Group group = new Group(body, SWT.NONE);
    group.setText("Update mode");
    UI.gridData(group, true, false);
    UI.gridLayout(group, 1);
    for (UpdateMode mode : mods) {
        Button option = new Button(group, SWT.RADIO);
        option.setText(getText(mode));
        option.setSelection(mode == updateMode);
        Controls.onSelect(option, (e) -> {
            updateMode = mode;
        });
    }
    setControl(body);
}
Also used : Group(org.eclipse.swt.widgets.Group) Composite(org.eclipse.swt.widgets.Composite) Button(org.eclipse.swt.widgets.Button) UpdateMode(org.openlca.jsonld.input.UpdateMode)

Example 2 with UpdateMode

use of org.openlca.jsonld.input.UpdateMode in project olca-app by GreenDelta.

the class JsonImportWizard method doRun.

private void doRun(File zip) throws Exception {
    UpdateMode mode = settingsPage.updateMode;
    var log = LoggerFactory.getLogger(getClass());
    log.info("Import JSON LD package {} with update mode = {}", zip, mode);
    getContainer().run(true, true, (monitor) -> {
        monitor.beginTask(M.Import, IProgressMonitor.UNKNOWN);
        try (ZipStore store = ZipStore.open(zip)) {
            JsonImport importer = new JsonImport(store, Database.get());
            importer.setUpdateMode(mode);
            importer.run();
        } catch (Exception e) {
            throw new InvocationTargetException(e);
        }
    });
}
Also used : JsonImport(org.openlca.jsonld.input.JsonImport) UpdateMode(org.openlca.jsonld.input.UpdateMode) ZipStore(org.openlca.jsonld.ZipStore) InvocationTargetException(java.lang.reflect.InvocationTargetException) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Aggregations

UpdateMode (org.openlca.jsonld.input.UpdateMode)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 Button (org.eclipse.swt.widgets.Button)1 Composite (org.eclipse.swt.widgets.Composite)1 Group (org.eclipse.swt.widgets.Group)1 ZipStore (org.openlca.jsonld.ZipStore)1 JsonImport (org.openlca.jsonld.input.JsonImport)1