use of eu.esdihumboldt.hale.ui.io.ImportSource in project hale by halestudio.
the class AbstractMultipleFilesSource 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());
sourceFile = getSourceFile(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)) {
sourceFile.getStringValues().forEach(k -> updateState(true));
} else if (event.getProperty().equals(FieldEditor.VALUE)) {
sourceFile.getStringValues().forEach(k -> updateState(true));
}
}
});
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.FILL, 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);
}
Aggregations