Search in sources :

Example 1 with URLSourceURIFieldEditor

use of eu.esdihumboldt.hale.ui.io.source.URLSourceURIFieldEditor in project hale by halestudio.

the class AbstractWFSSource method createControls.

/**
 * @see ImportSource#createControls(Composite)
 */
@Override
public void createControls(Composite parent) {
    parent.setLayout(new GridLayout(4, false));
    // caption
    // placeholder
    new Label(parent, SWT.NONE);
    Label caption = new Label(parent, SWT.NONE);
    caption.setText(getCaption());
    caption.setLayoutData(new GridData(SWT.BEGINNING, SWT.BEGINNING, true, false, 3, 1));
    // source file
    // target URL field
    sourceURL = new URLSourceURIFieldEditor("sourceURL", "URL:", parent) {

        // the following methods are overridden so the capabilities button
        // may appear on the same line
        @Override
        public int getNumberOfControls() {
            return super.getNumberOfControls() + 1;
        }

        @Override
        protected void doFillIntoGrid(Composite parent, int numColumns) {
            super.doFillIntoGrid(parent, numColumns - 1);
        }
    };
    sourceURL.setPage(getPage());
    // set custom URI filter
    sourceURL.setURIFilter(createHistoryURIFilter());
    // set content types for URI field
    Collection<IOProviderDescriptor> factories = getConfiguration().getFactories();
    HashSet<IContentType> supportedTypes = new HashSet<IContentType>();
    for (IOProviderDescriptor factory : factories) {
        supportedTypes.addAll(factory.getSupportedTypes());
    }
    sourceURL.setContentTypes(supportedTypes);
    sourceURL.setPropertyChangeListener(new IPropertyChangeListener() {

        @Override
        public void propertyChange(PropertyChangeEvent event) {
            if (event.getProperty().equals(FieldEditor.IS_VALID)) {
                getPage().setMessage(null);
                updateState(true);
            } else if (event.getProperty().equals(FieldEditor.VALUE)) {
                getPage().setMessage(null);
                updateState(true);
            }
        }
    });
    // button to determine from capabilities
    Button capButton = new Button(parent, SWT.PUSH);
    capButton.setText("...");
    capButton.setToolTipText("Determine based on WFS Capabilities");
    capButton.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            determineSource(sourceURL);
        }
    });
    // provider selection
    // label
    Label providerLabel = new Label(parent, SWT.NONE);
    providerLabel.setText("Import as");
    // create provider combo
    ComboViewer providers = createProviders(parent);
    providers.getControl().setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, false, 3, 1));
    // initial state update
    updateState(true);
}
Also used : URLSourceURIFieldEditor(eu.esdihumboldt.hale.ui.io.source.URLSourceURIFieldEditor) IPropertyChangeListener(org.eclipse.jface.util.IPropertyChangeListener) PropertyChangeEvent(org.eclipse.jface.util.PropertyChangeEvent) Composite(org.eclipse.swt.widgets.Composite) IOProviderDescriptor(eu.esdihumboldt.hale.common.core.io.extension.IOProviderDescriptor) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Label(org.eclipse.swt.widgets.Label) IContentType(org.eclipse.core.runtime.content.IContentType) GridLayout(org.eclipse.swt.layout.GridLayout) Button(org.eclipse.swt.widgets.Button) ComboViewer(org.eclipse.jface.viewers.ComboViewer) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) HashSet(java.util.HashSet)

Aggregations

IOProviderDescriptor (eu.esdihumboldt.hale.common.core.io.extension.IOProviderDescriptor)1 URLSourceURIFieldEditor (eu.esdihumboldt.hale.ui.io.source.URLSourceURIFieldEditor)1 HashSet (java.util.HashSet)1 IContentType (org.eclipse.core.runtime.content.IContentType)1 IPropertyChangeListener (org.eclipse.jface.util.IPropertyChangeListener)1 PropertyChangeEvent (org.eclipse.jface.util.PropertyChangeEvent)1 ComboViewer (org.eclipse.jface.viewers.ComboViewer)1 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)1 SelectionEvent (org.eclipse.swt.events.SelectionEvent)1 GridData (org.eclipse.swt.layout.GridData)1 GridLayout (org.eclipse.swt.layout.GridLayout)1 Button (org.eclipse.swt.widgets.Button)1 Composite (org.eclipse.swt.widgets.Composite)1 Label (org.eclipse.swt.widgets.Label)1