Search in sources :

Example 6 with SchemaSpace

use of eu.esdihumboldt.hale.common.schema.model.SchemaSpace 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();
}
Also used : IPropertyChangeListener(org.eclipse.jface.util.IPropertyChangeListener) PropertyChangeEvent(org.eclipse.jface.util.PropertyChangeEvent) DefinitionLabelFactory(eu.esdihumboldt.hale.ui.common.definition.DefinitionLabelFactory) Composite(org.eclipse.swt.widgets.Composite) SchemaSpace(eu.esdihumboldt.hale.common.schema.model.SchemaSpace) Definition(eu.esdihumboldt.hale.common.schema.model.Definition) PropertyDefinition(eu.esdihumboldt.hale.common.schema.model.PropertyDefinition) TypeDefinition(eu.esdihumboldt.hale.common.schema.model.TypeDefinition) Label(org.eclipse.swt.widgets.Label) XmlIndex(eu.esdihumboldt.hale.io.xsd.model.XmlIndex) AttributeEditorFactory(eu.esdihumboldt.hale.ui.common.definition.AttributeEditorFactory) PropertyDefinition(eu.esdihumboldt.hale.common.schema.model.PropertyDefinition) SchemaSpaceID(eu.esdihumboldt.hale.common.schema.SchemaSpaceID) TypeDefinition(eu.esdihumboldt.hale.common.schema.model.TypeDefinition) OpenFileFieldEditor(eu.esdihumboldt.hale.ui.util.io.OpenFileFieldEditor) SchemaService(eu.esdihumboldt.hale.ui.service.schema.SchemaService) DefinitionAccessor(eu.esdihumboldt.hale.common.schema.groovy.DefinitionAccessor) GridData(org.eclipse.swt.layout.GridData) XmlElement(eu.esdihumboldt.hale.io.xsd.model.XmlElement)

Example 7 with SchemaSpace

use of eu.esdihumboldt.hale.common.schema.model.SchemaSpace in project hale by halestudio.

the class RootElementPage method loadPreSelection.

/**
 * @see eu.esdihumboldt.hale.ui.io.IOWizardPage#loadPreSelection(eu.esdihumboldt.hale.common.core.io.project.model.IOConfiguration)
 */
@Override
public void loadPreSelection(IOConfiguration conf) {
    String name = conf.getProviderConfiguration().get(StreamGmlWriter.PARAM_ROOT_ELEMENT_NAME).getStringRepresentation();
    String namespace = conf.getProviderConfiguration().get(StreamGmlWriter.PARAM_ROOT_ELEMENT_NAMESPACE).getStringRepresentation();
    String elementName = namespace + "/" + name;
    SchemaSpace schemas = getWizard().getProvider().getTargetSchema();
    XmlIndex index = StreamGmlWriter.getXMLIndex(schemas);
    for (XmlElement element : index.getElements().values()) {
        if (element.getIdentifier().equals(elementName)) {
            list.setSelection(new StructuredSelection(element), true);
        }
    }
}
Also used : SchemaSpace(eu.esdihumboldt.hale.common.schema.model.SchemaSpace) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) XmlIndex(eu.esdihumboldt.hale.io.xsd.model.XmlIndex) XmlElement(eu.esdihumboldt.hale.io.xsd.model.XmlElement)

Aggregations

SchemaSpace (eu.esdihumboldt.hale.common.schema.model.SchemaSpace)7 TypeDefinition (eu.esdihumboldt.hale.common.schema.model.TypeDefinition)5 XmlElement (eu.esdihumboldt.hale.io.xsd.model.XmlElement)4 XmlIndex (eu.esdihumboldt.hale.io.xsd.model.XmlIndex)4 SchemaService (eu.esdihumboldt.hale.ui.service.schema.SchemaService)3 QName (javax.xml.namespace.QName)3 XmlElements (eu.esdihumboldt.hale.io.xsd.constraint.XmlElements)2 EntityAccessor (eu.esdihumboldt.hale.common.align.groovy.accessor.EntityAccessor)1 EntityDefinition (eu.esdihumboldt.hale.common.align.model.EntityDefinition)1 TypeEntityDefinition (eu.esdihumboldt.hale.common.align.model.impl.TypeEntityDefinition)1 SchemaSpaceID (eu.esdihumboldt.hale.common.schema.SchemaSpaceID)1 DefinitionAccessor (eu.esdihumboldt.hale.common.schema.groovy.DefinitionAccessor)1 Definition (eu.esdihumboldt.hale.common.schema.model.Definition)1 PropertyDefinition (eu.esdihumboldt.hale.common.schema.model.PropertyDefinition)1 Schema (eu.esdihumboldt.hale.common.schema.model.Schema)1 WFSCapabilities (eu.esdihumboldt.hale.io.wfs.capabilities.WFSCapabilities)1 WFSOperation (eu.esdihumboldt.hale.io.wfs.capabilities.WFSOperation)1 AbstractWFSCapabilitiesPage (eu.esdihumboldt.hale.io.wfs.ui.capabilities.AbstractWFSCapabilitiesPage)1 AttributeEditorFactory (eu.esdihumboldt.hale.ui.common.definition.AttributeEditorFactory)1 DefinitionLabelFactory (eu.esdihumboldt.hale.ui.common.definition.DefinitionLabelFactory)1