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 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 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 AbstractProjectDetailsPage method createContent.
/**
* @see HaleWizardPage#createContent(Composite)
*/
@Override
protected void createContent(Composite page) {
page.setLayout(new GridLayout(2, false));
// name
name = new StringFieldEditor("name", "Project name:", page);
name.setEmptyStringAllowed(false);
name.setValidateStrategy(StringFieldEditor.VALIDATE_ON_KEY_STROKE);
name.setErrorMessage("The project name must be specified.");
name.setPage(this);
// author
author = new StringFieldEditor("author", "Project author:", page);
author.setEmptyStringAllowed(false);
author.setValidateStrategy(StringFieldEditor.VALIDATE_ON_KEY_STROKE);
author.setPage(this);
// description
Label descLabel = new Label(page, SWT.NONE);
descLabel.setText("Description:");
descLabel.setLayoutData(GridDataFactory.swtDefaults().align(SWT.BEGINNING, SWT.BEGINNING).create());
description = new Text(page, SWT.MULTI | SWT.WRAP | SWT.V_SCROLL | SWT.BORDER);
description.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).hint(500, SWT.DEFAULT).create());
// listen for state changes on field editors
IPropertyChangeListener stateListener = new IPropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent event) {
if (event.getProperty().equals(StringFieldEditor.IS_VALID)) {
updateState();
}
}
};
name.setPropertyChangeListener(stateListener);
author.setPropertyChangeListener(stateListener);
// listen for provider changes
getWizard().addIOWizardListener(new IOWizardListener<P, E>() {
@Override
public void providerDescriptorChanged(IOProviderDescriptor providerFactory) {
// update fields as the provider will have changed
updateFields();
}
@Override
public void contentTypeChanged(IContentType contentType) {
// ignore
}
});
updateState();
updateFields();
}
use of org.eclipse.jface.util.IPropertyChangeListener in project hale by halestudio.
the class DefaultSchemaTypePage method createContent.
/**
* @see HaleWizardPage#createContent(org.eclipse.swt.widgets.Composite)
*/
@Override
protected void createContent(Composite parent) {
Composite holder = new Composite(parent, SWT.NONE);
holder.setLayout(GridLayoutFactory.fillDefaults().create());
sc = new DynamicScrolledComposite(holder, SWT.V_SCROLL);
sc.setExpandHorizontal(true);
sc.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).hint(SWT.DEFAULT, 200).create());
Composite page = new Composite(sc, SWT.NONE);
page.setLayout(new GridLayout(2, false));
sfe = new TypeNameField("typename", "Typename", page);
sfe.setEmptyStringAllowed(false);
// sfe.setErrorMessage("Please enter a valid Type Name");
sfe.setPropertyChangeListener(new IPropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent event) {
if (event.getProperty().equals(StringFieldEditor.IS_VALID)) {
setPageComplete(isValid());
}
}
});
sfe.setStringValue(defaultString);
// sfe.setPage(this);
group = new Group(page, SWT.NONE);
group.setText("Properties");
group.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).span(2, 1).create());
group.setLayout(GridLayoutFactory.swtDefaults().numColumns(3).equalWidth(false).margins(5, 5).create());
sc.setContent(page);
sc.layout();
// setPageComplete(sfe.isValid());
}
Aggregations