use of org.eclipse.jface.util.IPropertyChangeListener in project hale by halestudio.
the class FileSource method createControls.
/**
* @see ImportSource#createControls(Composite)
*/
@Override
public void createControls(Composite parent) {
parent.setLayout(new GridLayout(4, false));
ProjectService ps = PlatformUI.getWorkbench().getService(ProjectService.class);
projectLocation = ps.getLoadLocation() == null ? null : ps.getLoadLocation();
boolean projectLocAvailable = projectLocation != null && "file".equals(projectLocation.getScheme());
// source file
sourceFile = new FileSourceFileFieldEditor("sourceFile", "Source file:", FileFieldEditor.VALIDATE_ON_KEY_STROKE, parent, projectLocation);
sourceFile.setEmptyStringAllowed(false);
sourceFile.setPage(getPage());
// set content types for file field
Collection<IOProviderDescriptor> factories = getConfiguration().getFactories();
supportedTypes = new HashSet<IContentType>();
for (IOProviderDescriptor factory : factories) {
supportedTypes.addAll(factory.getSupportedTypes());
}
sourceFile.setContentTypes(supportedTypes);
sourceFile.setPropertyChangeListener(new IPropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent event) {
if (event.getProperty().equals(FieldEditor.IS_VALID)) {
updateState(true);
} else if (event.getProperty().equals(FieldEditor.VALUE)) {
updateState(true);
}
}
});
// 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));
final Button relativeCheck = new Button(parent, SWT.CHECK);
String text = "Use relative paths if possible.";
relativeCheck.setText("Use relative paths if possible.");
relativeCheck.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
sourceFile.setUseRelativeIfPossible(relativeCheck.getSelection());
}
});
if (!projectLocAvailable) {
relativeCheck.setEnabled(false);
text += " Only available once the project is saved to a file.";
}
relativeCheck.setText(text);
relativeCheck.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, false, 4, 1));
// initial state update
updateState(true);
}
use of org.eclipse.jface.util.IPropertyChangeListener in project hale by halestudio.
the class URLSource method createControls.
/**
* @see ImportSource#createControls(Composite)
*/
@Override
public void createControls(Composite parent) {
parent.setLayout(new GridLayout(3, false));
detectImage = HALEUIPlugin.getImageDescriptor("icons/find_obj.gif").createImage();
// source file
sourceURL = new URLSourceURIFieldEditor("sourceURL", "Source URL:", parent) {
@Override
protected void onHistorySelected(URI location, IContentType contentType) {
// select the content type associated with the recent URL
types.setSelection(new StructuredSelection(contentType));
updateState(false);
}
};
sourceURL.setPage(getPage());
// set content types for file field
Collection<IOProviderDescriptor> factories = getConfiguration().getFactories();
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(false);
} else if (event.getProperty().equals(FieldEditor.VALUE)) {
getPage().setMessage(null);
updateState(false);
}
}
});
// content type selection
// label
Label typesLabel = new Label(parent, SWT.NONE);
typesLabel.setText("Content type");
// types combo
Composite group = new Composite(parent, SWT.NONE);
group.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 2, 1));
group.setLayout(GridLayoutFactory.fillDefaults().numColumns(2).create());
types = new ComboViewer(group, SWT.DROP_DOWN | SWT.READ_ONLY);
types.getControl().setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
types.setContentProvider(ArrayContentProvider.getInstance());
types.setLabelProvider(new LabelProvider() {
@Override
public String getText(Object element) {
if (element instanceof IContentType) {
return ((IContentType) element).getName();
}
return super.getText(element);
}
});
types.setInput(supportedTypes);
// process selection changes
types.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
updateState(true);
}
});
// detect button
detect = new Button(group, SWT.PUSH);
detect.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false));
detect.setText("Detect");
detect.setImage(detectImage);
detect.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
runDetectContentType();
}
});
// 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, 2, 1));
// initial state update
updateState(true);
}
use of org.eclipse.jface.util.IPropertyChangeListener in project hale by halestudio.
the class URLTarget method createControls.
/**
* @see eu.esdihumboldt.hale.ui.io.ExportTarget#createControls(org.eclipse.swt.widgets.Composite)
*/
@Override
public void createControls(Composite parent) {
parent.setLayout(new GridLayout(3, false));
// source file
targetURL = new URLTargetURIFieldEditor("targetURL", "Target URL", parent) {
@Override
protected void onHistorySelected(URI location) {
updateState();
}
};
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();
}
}
});
// content type selection
// label
Label typesLabel = new Label(parent, SWT.NONE);
typesLabel.setText("Content type");
// types combo
Composite group = new Composite(parent, SWT.NONE);
group.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 2, 1));
group.setLayout(GridLayoutFactory.fillDefaults().numColumns(2).create());
types = new ComboViewer(group, SWT.DROP_DOWN | SWT.READ_ONLY);
types.getControl().setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
types.setContentProvider(ArrayContentProvider.getInstance());
types.setLabelProvider(new LabelProvider() {
@Override
public String getText(Object element) {
if (element instanceof IContentType) {
return ((IContentType) element).getName();
}
return super.getText(element);
}
});
// process selection changes
types.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
// update content type
ISelection sel = event.getSelection();
if (sel.isEmpty() || !(sel instanceof IStructuredSelection)) {
setContentType(null);
} else {
setContentType((IContentType) ((IStructuredSelection) sel).getFirstElement());
}
}
});
}
use of org.eclipse.jface.util.IPropertyChangeListener 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();
}
use of org.eclipse.jface.util.IPropertyChangeListener 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);
}
Aggregations