use of eu.esdihumboldt.hale.ui.util.viewer.EnumContentProvider in project hale by halestudio.
the class AbstractWFSCapabilitiesPage method createContent.
@Override
protected void createContent(Composite parent) {
Composite page = new Composite(parent, SWT.NONE);
page.setLayout(new GridLayout(2, false));
// capabilities field
location = new WFSCapabilitiesFieldEditor("location", "GetCapabilities URL", page) {
@Override
protected WFSVersion getWFSVersion() {
if (versionSelect != null) {
ISelection sel = versionSelect.getSelection();
if (!sel.isEmpty() && sel instanceof IStructuredSelection) {
Object selected = ((IStructuredSelection) sel).getFirstElement();
if (NoObject.NONE.equals(selected)) {
return null;
}
return (WFSVersion) selected;
}
}
return super.getWFSVersion();
}
};
location.setPage(this);
location.setPropertyChangeListener(new IPropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent event) {
if (event.getProperty().equals(FieldEditor.IS_VALID)) {
update();
}
}
});
String currentValue = getCapabilitiesURL(getWizard().getConfiguration());
if (currentValue != null) {
location.setValue(currentValue);
}
// version field
Label vLabel = new Label(page, SWT.NONE);
vLabel.setText("WFS version");
versionSelect = new ComboViewer(page, SWT.READ_ONLY);
GridDataFactory.fillDefaults().grab(true, false).applyTo(versionSelect.getControl());
versionSelect.setContentProvider(new EnumContentProvider() {
@Override
public Object[] getElements(Object inputElement) {
Object[] values = super.getElements(inputElement);
// add a NoObject
values = Arrays.copyOf(values, values.length + 1, Object[].class);
values[values.length - 1] = NoObject.NONE;
return values;
}
});
versionSelect.setLabelProvider(new LabelProvider() {
@Override
public String getText(Object element) {
if (element instanceof NoObject) {
return "Based on URL / server default";
}
return super.getText(element);
}
});
versionSelect.setInput(WFSVersion.class);
versionSelect.setSelection(new StructuredSelection(NoObject.NONE));
versionSelect.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
location.revalidate();
}
});
setControl(page);
update();
}
Aggregations