use of eu.esdihumboldt.hale.ui.function.common.PropertyEntitySelector in project hale by halestudio.
the class GeoJSONConfigurationPage method createContent.
/**
* @see HaleWizardPage#createContent(Composite)
*/
@Override
protected void createContent(final Composite page) {
page.setLayout(new GridLayout(1, false));
Label explanation = new Label(page, SWT.NONE);
explanation.setText("If a geometry is set to \"none\", instances will still be included as GeoJSON features,\nbut without default geometries.");
final DynamicScrolledComposite sc = new DynamicScrolledComposite(page, SWT.V_SCROLL);
sc.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
Composite parent = new Composite(sc, SWT.NONE);
sc.setExpandHorizontal(true);
GridLayoutFactory.swtDefaults().numColumns(2).equalWidth(false).spacing(6, 12).applyTo(parent);
InstanceService is = PlatformUI.getWorkbench().getService(InstanceService.class);
GeometrySchemaService gss = PlatformUI.getWorkbench().getService(GeometrySchemaService.class);
Set<TypeDefinition> types = is.getInstanceTypes(DataSet.TRANSFORMED);
for (final TypeDefinition type : types) {
Label label = new Label(parent, SWT.NONE);
label.setText(type.getDisplayName() + ":");
PropertyCondition condition = new PropertyOrChildrenTypeCondition(new GeometryCondition());
PropertyParameterDefinition param = new PropertyParameter("", 0, 1, "Geometry", null, Collections.singletonList(condition), false);
PropertyEntitySelector selector = new PropertyEntitySelector(SchemaSpaceID.TARGET, param, parent, new TypeEntityDefinition(type, SchemaSpaceID.TARGET, null));
selector.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
if (!event.getSelection().isEmpty() && event.getSelection() instanceof IStructuredSelection) {
IStructuredSelection selection = (IStructuredSelection) event.getSelection();
PropertyEntityDefinition property = (PropertyEntityDefinition) selection.getFirstElement();
config.addDefaultGeometry(type, property);
} else {
config.addDefaultGeometry(type, null);
}
}
});
selector.getControl().setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, false));
// initial selection
List<QName> path = gss.getDefaultGeometry(type);
if (path != null) {
EntityDefinition entityDef = new TypeEntityDefinition(type, SchemaSpaceID.TARGET, null);
for (QName child : path) entityDef = AlignmentUtil.getChild(entityDef, child);
selector.setSelection(new StructuredSelection(entityDef));
}
}
sc.setContent(parent);
}
Aggregations