use of eu.esdihumboldt.hale.common.core.io.Value in project hale by halestudio.
the class SpatiaLiteInstanceWriter method loadConfiguration.
@Override
public void loadConfiguration(Map<String, Value> configuration) {
super.loadConfiguration(configuration);
Value target = configuration.get(PARAM_TARGET);
if (target != null && !target.isEmpty()) {
File file = new File(URI.create(target.as(String.class)));
setTarget(new FileIOSupplier(file));
}
}
use of eu.esdihumboldt.hale.common.core.io.Value in project hale by halestudio.
the class SQLArrayFactory method restore.
@Override
public SQLArray restore(Value value, Definition<?> definition, TypeResolver typeIndex, ClassResolver resolver) throws Exception {
ValueProperties props = value.as(ValueProperties.class);
if (props != null) {
// read element class
Class<?> elementType = null;
String className = props.getSafe(NAME_ELEMENT_CLASS).as(String.class);
if (className != null) {
elementType = resolver.loadClass(className);
}
// read element database type name
String elementTypeName = props.getSafe(NAME_ELEMENT_TYPE_NAME).as(String.class);
// read dimension
int dimension = props.getSafe(NAME_DIMENSION).as(Integer.class, 0);
// read array dimension sizes
int[] sizes = null;
ValueList sizeList = props.getSafe(NAME_SIZES).as(ValueList.class);
if (sizeList != null) {
sizes = new int[sizeList.size()];
int index = 0;
for (Value size : sizeList) {
sizes[index] = size.as(Integer.class, 0);
index++;
}
}
return new SQLArray(elementType, elementTypeName, dimension, sizes);
}
return SQLArray.NO_ARRAY;
}
use of eu.esdihumboldt.hale.common.core.io.Value in project hale by halestudio.
the class CustomFunctionExplanationPage method createMainPart.
private void createMainPart(Composite page, @Nullable Map<Locale, Value> initialContent) {
Composite main = new Composite(page, SWT.NONE);
GridDataFactory.fillDefaults().grab(true, true).applyTo(main);
GridLayoutFactory.fillDefaults().numColumns(2).equalWidth(false).applyTo(main);
// left part - editor tabs
tabFolder = new TabFolder(main, SWT.BORDER);
GridDataFactory.fillDefaults().grab(true, true).applyTo(tabFolder);
if (initialContent != null && !initialContent.isEmpty()) {
for (Entry<Locale, Value> entry : initialContent.entrySet()) {
addTab(entry.getKey(), entry.getValue().as(eu.esdihumboldt.hale.common.core.io.Text.class));
}
} else {
// per default, add an empty explanation for the root locale
addTab(Locale.ROOT, null);
}
// right part - controls
Composite actions = new Composite(main, SWT.NONE);
GridDataFactory.fillDefaults().grab(false, true).applyTo(actions);
GridLayoutFactory.swtDefaults().numColumns(1).applyTo(actions);
// TODO add a language
// Button addLanguage = new Button(actions, SWT.PUSH | SWT.FLAT);
// addLanguage.setImage(CommonSharedImages.getImageRegistry().get(CommonSharedImages.IMG_ADD));
// addLanguage.setToolTipText("Add another explanation language");
// TODO remove a language (prevent removing default)
}
use of eu.esdihumboldt.hale.common.core.io.Value in project hale by halestudio.
the class CustomFunctionExplanationPage method createContent.
@Override
protected void createContent(Composite page) {
DefaultCustomPropertyFunction cf = getWizard().getResultFunction();
DefaultCustomFunctionExplanation expl = cf.getExplanation();
Map<Locale, Value> initialContent = null;
if (expl != null) {
initialContent = expl.getTemplates();
}
GridLayoutFactory.fillDefaults().numColumns(1).applyTo(page);
// top part - editor and locale controls
createMainPart(page, initialContent);
// bottom part - explanation preview
// createPreviewPart(page);
}
use of eu.esdihumboldt.hale.common.core.io.Value in project hale by halestudio.
the class CustomFunctionExplanationPage method apply.
@Override
public void apply() {
DefaultCustomPropertyFunction cf = getWizard().getResultFunction();
if (cf == null)
return;
Map<Locale, Value> templates = new HashMap<>();
tabs.forEach((locale, group) -> {
String text = group.getEditor().getText();
if (text != null && !text.isEmpty()) {
templates.put(locale, Value.of(new eu.esdihumboldt.hale.common.core.io.Text(text)));
}
});
DefaultCustomFunctionExplanation explanation = new DefaultCustomFunctionExplanation(templates);
cf.setExplanation(explanation);
}
Aggregations