use of eu.esdihumboldt.hale.ui.service.schema.SchemaService in project hale by halestudio.
the class SpatialDataSetConfigurationPage method createContent.
/**
* @see HaleWizardPage#createContent(Composite)
*/
@Override
protected void createContent(Composite page) {
GridLayoutFactory.swtDefaults().numColumns(2).equalWidth(false).spacing(6, 12).applyTo(page);
// Get the property definitions of localId and namespace.
String action = getWizard().getActionId();
SchemaService ss = PlatformUI.getWorkbench().getService(SchemaService.class);
SchemaSpaceID ssid = SchemaSpaceID.TARGET;
if (InstanceIO.ACTION_SAVE_SOURCE_DATA.equals(action)) {
ssid = SchemaSpaceID.SOURCE;
}
SchemaSpace target = ss.getSchemas(ssid);
XmlIndex index = StreamGmlWriter.getXMLIndex(target);
XmlElement sdsElement = InspireUtil.findSpatialDataSet(index);
TypeDefinition sdsType = null;
if (sdsElement != null) {
sdsType = sdsElement.getType();
}
// applicable.
if (sdsType == null)
return;
// find localId and namespace definitions
Path<Definition<?>> localIdPath = new DefinitionAccessor(sdsType).findChildren("identifier").findChildren("Identifier").findChildren("localId").eval(false);
List<Definition<?>> localIdDefs = localIdPath.getElements();
PropertyDefinition localIdDef = (PropertyDefinition) localIdDefs.get(localIdDefs.size() - 1);
Path<Definition<?>> namespacePath = new DefinitionAccessor(sdsType).findChildren("identifier").findChildren("Identifier").findChildren("namespace").eval(false);
List<Definition<?>> namespaceDefs = namespacePath.getElements();
PropertyDefinition nsDef = (PropertyDefinition) namespaceDefs.get(namespaceDefs.size() - 1);
IPropertyChangeListener changeListener = new IPropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent event) {
if (event.getProperty().equals(AttributeEditor.IS_VALID) || event.getProperty().equals(FileFieldEditor.IS_VALID))
updateState();
}
};
// inspire identifier
Label inspireId = new Label(page, SWT.NONE);
inspireId.setText("Please specify the local ID and the namespace as part of the INSPIRE identifier of the Spatial Data Set:");
GridDataFactory.fillDefaults().span(2, 1).applyTo(inspireId);
AttributeEditorFactory aef = PlatformUI.getWorkbench().getService(AttributeEditorFactory.class);
Composite localIdtitle = new Composite(page, SWT.NONE);
localIdtitle.setLayout(GridLayoutFactory.swtDefaults().numColumns(2).margins(0, 0).create());
DefinitionLabelFactory dlf = PlatformUI.getWorkbench().getService(DefinitionLabelFactory.class);
dlf.createLabel(localIdtitle, localIdDef, false);
Label label = new Label(localIdtitle, SWT.NONE);
label.setText(" = ");
localIdEditor = aef.createEditor(page, localIdDef, null, false);
localIdEditor.getControl().setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, false));
localIdEditor.setPropertyChangeListener(changeListener);
Composite namespacetitle = new Composite(page, SWT.NONE);
namespacetitle.setLayout(GridLayoutFactory.swtDefaults().numColumns(2).margins(0, 0).create());
dlf.createLabel(namespacetitle, nsDef, false);
label = new Label(namespacetitle, SWT.NONE);
label.setText(" = ");
namespaceEditor = aef.createEditor(page, nsDef, null, false);
namespaceEditor.getControl().setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, false));
namespaceEditor.setPropertyChangeListener(changeListener);
// spacer
Composite spacer = new Composite(page, SWT.NONE);
GridDataFactory.fillDefaults().hint(0, 8).applyTo(spacer);
// metadata file
Label metadataLabel = new Label(page, SWT.NONE);
metadataLabel.setText("You can include metadata in the Spatial Data Set from a XML file with a MD_Metadata element:");
GridDataFactory.fillDefaults().span(2, 1).applyTo(metadataLabel);
// source file
Composite fileFieldComposite = new Composite(page, SWT.NONE);
fileFieldComposite.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, false, 2, 1));
metadataFile = new OpenFileFieldEditor("metadataFile", "ISO Geographic MetaData XML", true, FileFieldEditor.VALIDATE_ON_KEY_STROKE, fileFieldComposite);
metadataFile.setPage(this);
metadataFile.setEmptyStringAllowed(true);
metadataFile.setFileExtensions(new String[] { "*.xml" });
metadataFile.setPropertyChangeListener(changeListener);
// isValid starts with false even if emptyStringAllowed is true.
// -> force validation hack
metadataFile.setStringValue(" ");
metadataFile.setStringValue("");
updateState();
}
use of eu.esdihumboldt.hale.ui.service.schema.SchemaService in project hale by halestudio.
the class TypeSelectionPage method createContent.
/**
* @see eu.esdihumboldt.hale.ui.HaleWizardPage#createContent(org.eclipse.swt.widgets.Composite)
*/
@Override
protected void createContent(Composite page) {
page.setLayout(new GridLayout(2, false));
// XXX needed?
GridData layoutData = new GridData();
layoutData.widthHint = 200;
label = new Label(page, SWT.NONE);
label.setText("Choose your Type:");
SchemaService ss = PlatformUI.getWorkbench().getService(SchemaService.class);
sel = new TypeDefinitionSelector(page, "Select the corresponding schema type", ss.getSchemas(SchemaSpaceID.SOURCE), null);
sel.getControl().setLayoutData(GridDataFactory.fillDefaults().grab(true, false).span(1, 1).create());
sel.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
setPageComplete(!(event.getSelection().isEmpty()));
if (sel.getSelectedObject() != null) {
TypeDefinition type = sel.getSelectedObject();
CSVConfiguration conf = type.getConstraint(CSVConfiguration.class);
Boolean skip = conf.skipFirst();
button.setSelection(skip);
label.getParent().layout();
}
}
});
button = new Button(page, SWT.CHECK);
button.setText("Skip first line");
button.setSelection(true);
page.pack();
setPageComplete(false);
}
use of eu.esdihumboldt.hale.ui.service.schema.SchemaService in project hale by halestudio.
the class PropertyEntityDialog method setupViewer.
/**
* @see EntityDialog#setupViewer(TreeViewer, EntityDefinition)
*/
@Override
protected void setupViewer(TreeViewer viewer, EntityDefinition initialSelection) {
viewer.setLabelProvider(new StyledDefinitionLabelProvider(viewer));
EntityDefinitionService entityDefinitionService = PlatformUI.getWorkbench().getService(EntityDefinitionService.class);
if (parentType != null) {
viewer.setContentProvider(new TreePathProviderAdapter(new EntityTypePropertyContentProvider(entityDefinitionService, ssid)));
viewer.setInput(parentType);
} else {
flatRelevantProvider = new TreePathProviderAdapter(new EntityTypeIndexContentProvider(entityDefinitionService, ssid, true, false));
hierarchicalRelevantProvider = new TreePathProviderAdapter(new EntityTypeIndexHierarchy(entityDefinitionService, ssid, true, false));
flatAllProvider = new TreePathProviderAdapter(new EntityTypeIndexContentProvider(entityDefinitionService, ssid, false, false));
hierarchicalAllProvider = new TreePathProviderAdapter(new EntityTypeIndexHierarchy(entityDefinitionService, ssid, false, false));
viewer.setContentProvider(flatRelevantProvider);
SchemaService ss = PlatformUI.getWorkbench().getService(SchemaService.class);
viewer.setInput(ss.getSchemas(ssid));
}
if (initialSelection != null) {
viewer.setSelection(new StructuredSelection(initialSelection));
}
}
use of eu.esdihumboldt.hale.ui.service.schema.SchemaService in project hale by halestudio.
the class TypeEntityDialog method setupViewer.
/**
* @see EntityDialog#setupViewer(TreeViewer, EntityDefinition)
*/
@Override
protected void setupViewer(TreeViewer viewer, EntityDefinition initialSelection) {
viewer.setLabelProvider(new StyledDefinitionLabelProvider(viewer));
EntityDefinitionService entityDefinitionService = PlatformUI.getWorkbench().getService(EntityDefinitionService.class);
flatRelevantProvider = new TreePathProviderAdapter(new EntityTypeIndexContentProvider(entityDefinitionService, ssid, true, true));
if (!onlyMappingRelevant) {
hierarchicalRelevantProvider = new TreePathProviderAdapter(new EntityTypeIndexHierarchy(entityDefinitionService, ssid, true, true));
flatAllProvider = new TreePathProviderAdapter(new EntityTypeIndexContentProvider(entityDefinitionService, ssid, false, true));
hierarchicalAllProvider = new TreePathProviderAdapter(new EntityTypeIndexHierarchy(entityDefinitionService, ssid, false, true));
viewer.setContentProvider(flatAllProvider);
} else {
viewer.setContentProvider(flatRelevantProvider);
}
SchemaService ss = PlatformUI.getWorkbench().getService(SchemaService.class);
viewer.setInput(ss.getSchemas(ssid));
if (initialSelection instanceof TypeEntityDefinition) {
viewer.setSelection(new StructuredSelection(initialSelection));
}
}
use of eu.esdihumboldt.hale.ui.service.schema.SchemaService in project hale by halestudio.
the class AlignmentImportAdvisor method prepareProvider.
/**
* @see AbstractIOAdvisor#prepareProvider(IOProvider)
*/
@Override
public void prepareProvider(AlignmentReader provider) {
super.prepareProvider(provider);
SchemaService ss = getService(SchemaService.class);
provider.setSourceSchema(ss.getSchemas(SchemaSpaceID.SOURCE));
provider.setTargetSchema(ss.getSchemas(SchemaSpaceID.TARGET));
ProjectService ps = getService(ProjectService.class);
// XXX uses the same path updater as the project
// If someone edited the project file and referenced an alignment file,
// which isn't in the project directory this won't work.
provider.setPathUpdater(ps.getLocationUpdater());
}
Aggregations