Search in sources :

Example 1 with URIFieldEditor

use of eu.esdihumboldt.hale.ui.util.io.URIFieldEditor in project hale by halestudio.

the class WFSTarget method createControls.

@Override
public void createControls(Composite parent) {
    getPage().setMessage("Please specify the WFS Transaction URL");
    GridLayout layout = new GridLayout(3, false);
    parent.setLayout(layout);
    // target URL field
    targetURL = new URIFieldEditor("targetURL", "Transaction 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);
        }
    };
    targetURL.setPage(getPage());
    targetURL.setPropertyChangeListener(new IPropertyChangeListener() {

        @Override
        public void propertyChange(PropertyChangeEvent event) {
            if (event.getProperty().equals(FieldEditor.IS_VALID)) {
                getPage().setMessage(null);
                updateState();
            } else if (event.getProperty().equals(FieldEditor.VALUE)) {
                getPage().setMessage(null);
                updateState();
            }
        }
    });
    // 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) {
            WFSTransactionConfig config = new WFSTransactionConfig();
            ISelection versionSel = selectVersion.getSelection();
            if (!versionSel.isEmpty() && versionSel instanceof IStructuredSelection) {
                WFSVersion version = (WFSVersion) ((IStructuredSelection) versionSel).getFirstElement();
                config.setVersion(version);
            }
            WFSTransactionWizard wizard = new WFSTransactionWizard(config);
            HaleWizardDialog dialog = new HaleWizardDialog(Display.getCurrent().getActiveShell(), wizard);
            if (dialog.open() == WizardDialog.OK) {
                WFSTransactionConfig result = wizard.getConfiguration();
                // apply result
                targetURL.setStringValue(result.getTransactionUri().toString());
                if (result.getVersion() != null) {
                    selectVersion.setSelection(new StructuredSelection(result.getVersion()));
                } else {
                    selectVersion.setSelection(new StructuredSelection());
                }
            }
        }
    });
    // select version
    Label versionLabel = new Label(parent, SWT.NONE);
    versionLabel.setText("WFS Version");
    selectVersion = new ComboViewer(parent);
    GridDataFactory.swtDefaults().span(1, 1).grab(true, false).align(SWT.FILL, SWT.CENTER).applyTo(selectVersion.getControl());
    selectVersion.setContentProvider(EnumContentProvider.getInstance());
    selectVersion.setLabelProvider(new LabelProvider() {

        @Override
        public String getText(Object element) {
            if (element instanceof WFSVersion) {
                return ((WFSVersion) element).versionString;
            }
            return super.getText(element);
        }
    });
    selectVersion.setInput(WFSVersion.class);
    selectVersion.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            updateState();
        }
    });
    // fixed content type
    setContentType(HalePlatform.getContentTypeManager().getContentType(CONTENT_TYPE_ID_WFST));
    // initial state update
    updateState();
}
Also used : IPropertyChangeListener(org.eclipse.jface.util.IPropertyChangeListener) PropertyChangeEvent(org.eclipse.jface.util.PropertyChangeEvent) Composite(org.eclipse.swt.widgets.Composite) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) Label(org.eclipse.swt.widgets.Label) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) WFSVersion(eu.esdihumboldt.hale.io.wfs.WFSVersion) URIFieldEditor(eu.esdihumboldt.hale.ui.util.io.URIFieldEditor) GridLayout(org.eclipse.swt.layout.GridLayout) Button(org.eclipse.swt.widgets.Button) ComboViewer(org.eclipse.jface.viewers.ComboViewer) SelectionEvent(org.eclipse.swt.events.SelectionEvent) ISelection(org.eclipse.jface.viewers.ISelection) LabelProvider(org.eclipse.jface.viewers.LabelProvider) HaleWizardDialog(eu.esdihumboldt.hale.ui.util.wizard.HaleWizardDialog)

Aggregations

WFSVersion (eu.esdihumboldt.hale.io.wfs.WFSVersion)1 URIFieldEditor (eu.esdihumboldt.hale.ui.util.io.URIFieldEditor)1 HaleWizardDialog (eu.esdihumboldt.hale.ui.util.wizard.HaleWizardDialog)1 IPropertyChangeListener (org.eclipse.jface.util.IPropertyChangeListener)1 PropertyChangeEvent (org.eclipse.jface.util.PropertyChangeEvent)1 ComboViewer (org.eclipse.jface.viewers.ComboViewer)1 ISelection (org.eclipse.jface.viewers.ISelection)1 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)1 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)1 LabelProvider (org.eclipse.jface.viewers.LabelProvider)1 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)1 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)1 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)1 SelectionEvent (org.eclipse.swt.events.SelectionEvent)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