use of eu.esdihumboldt.hale.ui.util.components.DynamicScrolledComposite in project hale by halestudio.
the class CustomPropertyFunctionEntitiesPage method createEntityGroup.
/**
* Create an entity group
*
* @param ssid the schema space id
* @param parent the parent composite
* @return the main group control
*/
protected Control createEntityGroup(SchemaSpaceID ssid, Composite parent) {
// return another Composite, since the returned Control's layoutData are
// overwritten.
Composite holder = new Composite(parent, SWT.NONE);
holder.setLayout(GridLayoutFactory.fillDefaults().create());
// Important: Field does rely on DynamicScrolledComposite to be the
// parent of its parent,
// because sadly layout(true, true) on the Shell does not seem to
// propagate to this place.
ScrolledComposite sc = new DynamicScrolledComposite(holder, SWT.V_SCROLL);
sc.setExpandHorizontal(true);
sc.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).hint(300, 400).create());
Group main = new Group(sc, SWT.NONE);
sc.setContent(main);
main.setLayout(GridLayoutFactory.swtDefaults().numColumns(1).margins(10, 5).create());
// load from initial function
DefaultCustomPropertyFunction cf = getWizard().getResultFunction();
// set group title
switch(ssid) {
case SOURCE:
main.setText("Input variables");
sources = new CustomPropertyFunctionEntityList(null, null, main, cf.getSources());
break;
case TARGET:
main.setText("Output");
target = new BindingOrTypeEditor(main, SchemaSpaceID.TARGET);
GridDataFactory.fillDefaults().grab(true, false).applyTo(target.getControl());
if (cf.getTarget() != null) {
BindingOrType bot = new BindingOrType();
bot.setType(cf.getTarget().getBindingType());
bot.setBinding(cf.getTarget().getBindingClass());
bot.setUseBinding(cf.getTarget().getBindingType() == null);
target.setValue(bot);
}
break;
}
return holder;
}
use of eu.esdihumboldt.hale.ui.util.components.DynamicScrolledComposite 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());
}
use of eu.esdihumboldt.hale.ui.util.components.DynamicScrolledComposite in project hale by halestudio.
the class GeoJSONConfigurationPage method createContent.
/**
* @see HaleWizardPage#createContent(Composite)
*/
@Override
protected void createContent(final Composite page) {
page.setLayout(new GridLayout(1, false));
Label explanation = new Label(page, SWT.NONE);
explanation.setText("If a geometry is set to \"none\", instances will still be included as GeoJSON features,\nbut without default geometries.");
final DynamicScrolledComposite sc = new DynamicScrolledComposite(page, SWT.V_SCROLL);
sc.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
Composite parent = new Composite(sc, SWT.NONE);
sc.setExpandHorizontal(true);
GridLayoutFactory.swtDefaults().numColumns(2).equalWidth(false).spacing(6, 12).applyTo(parent);
InstanceService is = PlatformUI.getWorkbench().getService(InstanceService.class);
GeometrySchemaService gss = PlatformUI.getWorkbench().getService(GeometrySchemaService.class);
Set<TypeDefinition> types = is.getInstanceTypes(DataSet.TRANSFORMED);
for (final TypeDefinition type : types) {
Label label = new Label(parent, SWT.NONE);
label.setText(type.getDisplayName() + ":");
PropertyCondition condition = new PropertyOrChildrenTypeCondition(new GeometryCondition());
PropertyParameterDefinition param = new PropertyParameter("", 0, 1, "Geometry", null, Collections.singletonList(condition), false);
PropertyEntitySelector selector = new PropertyEntitySelector(SchemaSpaceID.TARGET, param, parent, new TypeEntityDefinition(type, SchemaSpaceID.TARGET, null));
selector.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
if (!event.getSelection().isEmpty() && event.getSelection() instanceof IStructuredSelection) {
IStructuredSelection selection = (IStructuredSelection) event.getSelection();
PropertyEntityDefinition property = (PropertyEntityDefinition) selection.getFirstElement();
config.addDefaultGeometry(type, property);
} else {
config.addDefaultGeometry(type, null);
}
}
});
selector.getControl().setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, false));
// initial selection
List<QName> path = gss.getDefaultGeometry(type);
if (path != null) {
EntityDefinition entityDef = new TypeEntityDefinition(type, SchemaSpaceID.TARGET, null);
for (QName child : path) entityDef = AlignmentUtil.getChild(entityDef, child);
selector.setSelection(new StructuredSelection(entityDef));
}
}
sc.setContent(parent);
}
use of eu.esdihumboldt.hale.ui.util.components.DynamicScrolledComposite in project hale by halestudio.
the class EntitiesPage method createEntityGroup.
/**
* Create an entity group
*
* @param ssid the schema space id
* @param parent the parent composite
* @return the main group control
*/
protected Control createEntityGroup(SchemaSpaceID ssid, Composite parent) {
// return another Composite, since the returned Control's layoutData are
// overwritten.
Composite holder = new Composite(parent, SWT.NONE);
holder.setLayout(GridLayoutFactory.fillDefaults().create());
// Important: Field does rely on DynamicScrolledComposite to be the
// parent of its parent,
// because sadly layout(true, true) on the Shell does not seem to
// propagate to this place.
ScrolledComposite sc = new DynamicScrolledComposite(holder, SWT.V_SCROLL);
sc.setExpandHorizontal(true);
sc.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).hint(200, 200).create());
Group main = new Group(sc, SWT.NONE);
sc.setContent(main);
main.setLayout(GridLayoutFactory.swtDefaults().numColumns(1).margins(10, 5).create());
// set group title
switch(ssid) {
case SOURCE:
main.setText("Source");
break;
case TARGET:
main.setText("Target");
break;
}
// determine fields
T function = getWizard().getFunction();
final Set<? extends D> fields;
switch(ssid) {
case SOURCE:
fields = function.getSource();
break;
case TARGET:
fields = function.getTarget();
break;
default:
fields = new HashSet<D>();
}
// create fields
for (D field : fields) {
F functionField = createField(ssid, field, main);
if (functionField != null) {
functionFields.add(functionField);
functionField.addObserver(fieldObserver);
}
}
return holder;
}
use of eu.esdihumboldt.hale.ui.util.components.DynamicScrolledComposite in project hale by halestudio.
the class ProjectVariablesPreferencePage method createContents.
@Override
protected Control createContents(Composite parent) {
ProjectService ps = PlatformUI.getWorkbench().getService(ProjectService.class);
Value value = ps.getConfigurationService().getProperty(ProjectVariables.PROJECT_PROPERTY_VARIABLES);
variables = value.as(ValueProperties.class);
if (variables == null) {
variables = new ValueProperties();
if (value.getValue() != null) {
log.error("Unknown representation of project variables encountered");
}
}
sc = new DynamicScrolledComposite(parent, SWT.V_SCROLL);
sc.setExpandHorizontal(true);
sc.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).hint(SWT.DEFAULT, 200).create());
page = new Composite(sc, SWT.NONE);
GridLayoutFactory.swtDefaults().numColumns(1).applyTo(page);
GridDataFactory.fillDefaults().grab(true, true).applyTo(page);
varList = new Composite(page, SWT.NONE);
GridLayoutFactory.fillDefaults().numColumns(3).equalWidth(false).applyTo(varList);
GridDataFactory.fillDefaults().grab(true, false).applyTo(varList);
Map<String, Value> sorted = new TreeMap<>(variables);
for (String varName : sorted.keySet()) {
addEditor(varName, false);
}
// add Add button
Button add = new Button(page, SWT.PUSH);
GridDataFactory.swtDefaults().align(SWT.END, SWT.BEGINNING).applyTo(add);
add.setImage(CommonSharedImages.getImageRegistry().get(CommonSharedImagesConstants.IMG_ADD));
add.setToolTipText("Add variable");
add.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
final Display display = Display.getCurrent();
InputDialog dialog = new InputDialog(display.getActiveShell(), "Add new variable", "Please enter the name of the variable to add", "", new IInputValidator() {
@Override
public String isValid(String newText) {
if (newText == null || newText.isEmpty()) {
return "Variable name must not be empty";
} else if (variables.containsKey(newText)) {
return "Variable already exists";
}
return null;
}
});
if (dialog.open() == InputDialog.OK) {
String varName = dialog.getValue();
if (varName != null) {
variables.put(varName, Value.of(""));
addEditor(varName, true);
changed = true;
}
}
}
});
sc.setContent(page);
return page;
}
Aggregations