use of eu.esdihumboldt.hale.ui.geometry.service.GeometrySchemaService in project hale by halestudio.
the class StyledMapExtra method setMapView.
/**
* @see MapViewExtension#setMapView(MapView)
*/
@Override
public void setMapView(MapView mapView) {
this.mapView = mapView;
layoutController = new PainterLayoutController(mapView.getMapKit());
/*
* Listen for activated/deactivated instance painters
*
* - remove listeners for deactivated painters and clear the waypoints -
* update activated listeners and add the corresponding listeners
*/
ITileOverlayService overlayService = PlatformUI.getWorkbench().getService(ITileOverlayService.class);
overlayService.addListener(new SelectiveExtensionListener<TileOverlayPainter, TileOverlayFactory>() {
@Override
public void deactivated(TileOverlayPainter object, TileOverlayFactory definition) {
if (object instanceof AbstractInstancePainter) {
AbstractInstancePainter painter = (AbstractInstancePainter) object;
// get services
ISelectionService selection = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService();
InstanceService instances = PlatformUI.getWorkbench().getService(InstanceService.class);
StyleService styles = PlatformUI.getWorkbench().getService(StyleService.class);
GeometrySchemaService geometries = PlatformUI.getWorkbench().getService(GeometrySchemaService.class);
// remove listeners
selection.removeSelectionListener(painter);
instances.removeListener(painter);
styles.removeListener(painter.getStyleListener());
geometries.removeListener(painter.getGeometryListener());
// clear way-points
painter.clearWaypoints();
}
}
@Override
public void activated(TileOverlayPainter object, TileOverlayFactory definition) {
if (object instanceof AbstractInstancePainter) {
AbstractInstancePainter painter = (AbstractInstancePainter) object;
// get services
ISelectionService selection = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService();
InstanceService instances = PlatformUI.getWorkbench().getService(InstanceService.class);
StyleService styles = PlatformUI.getWorkbench().getService(StyleService.class);
GeometrySchemaService geometries = PlatformUI.getWorkbench().getService(GeometrySchemaService.class);
// update
painter.update(selection.getSelection());
// add listeners
selection.addSelectionListener(painter);
instances.addListener(painter);
styles.addListener(painter.getStyleListener());
geometries.addListener(painter.getGeometryListener());
}
}
});
IPartService partService = mapView.getSite().getService(IPartService.class);
partService.addPartListener(this);
// map tips
mapView.getMapTips().addMapTip(new InstanceMapTip(mapView.getMapKit()), 5);
}
use of eu.esdihumboldt.hale.ui.geometry.service.GeometrySchemaService 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);
}
use of eu.esdihumboldt.hale.ui.geometry.service.GeometrySchemaService in project hale by halestudio.
the class DefaultGeometryUtil method getDefaultGeometries.
/**
* Get the default geometry of an instance.
*
* @param instance the instance
* @return the default geometries or an empty collection if there is none
*/
public static Collection<GeometryProperty<?>> getDefaultGeometries(Instance instance) {
GeometrySchemaService gss = PlatformUI.getWorkbench().getService(GeometrySchemaService.class);
if (gss == null) {
throw new IllegalStateException("No geometry schema service available");
}
List<QName> path = gss.getDefaultGeometry(instance.getDefinition());
return GeometryUtil.getGeometries(instance, path);
}
use of eu.esdihumboldt.hale.ui.geometry.service.GeometrySchemaService in project hale by halestudio.
the class StyledMapExtra method partOpened.
/**
* @see IPartListener2#partOpened(org.eclipse.ui.IWorkbenchPartReference)
*/
@Override
public void partOpened(IWorkbenchPartReference partRef) {
if (partRef.getPart(false) == mapView) {
mapView.restoreState();
// get services
ISelectionService selection = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService();
InstanceService instances = PlatformUI.getWorkbench().getService(InstanceService.class);
StyleService styles = PlatformUI.getWorkbench().getService(StyleService.class);
GeometrySchemaService geometries = PlatformUI.getWorkbench().getService(GeometrySchemaService.class);
// update
updateScenePainters(selection);
// add listeners
enableScenePainterListeners(selection, instances, styles, geometries);
layoutController.enable();
}
}
Aggregations