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();
}
Aggregations