Search in sources :

Example 1 with DynamicScrolledComposite

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;
}
Also used : DynamicScrolledComposite(eu.esdihumboldt.hale.ui.util.components.DynamicScrolledComposite) Group(org.eclipse.swt.widgets.Group) DefaultCustomPropertyFunction(eu.esdihumboldt.hale.common.align.custom.DefaultCustomPropertyFunction) DynamicScrolledComposite(eu.esdihumboldt.hale.ui.util.components.DynamicScrolledComposite) Composite(org.eclipse.swt.widgets.Composite) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) CustomPropertyFunctionEntityList(eu.esdihumboldt.hale.ui.functions.custom.pages.internal.CustomPropertyFunctionEntityList) DynamicScrolledComposite(eu.esdihumboldt.hale.ui.util.components.DynamicScrolledComposite) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) BindingOrType(eu.esdihumboldt.hale.ui.functions.custom.pages.internal.BindingOrType) BindingOrTypeEditor(eu.esdihumboldt.hale.ui.functions.custom.pages.internal.BindingOrTypeEditor)

Example 2 with DynamicScrolledComposite

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());
}
Also used : IPropertyChangeListener(org.eclipse.jface.util.IPropertyChangeListener) DynamicScrolledComposite(eu.esdihumboldt.hale.ui.util.components.DynamicScrolledComposite) Group(org.eclipse.swt.widgets.Group) GridLayout(org.eclipse.swt.layout.GridLayout) PropertyChangeEvent(org.eclipse.jface.util.PropertyChangeEvent) Composite(org.eclipse.swt.widgets.Composite) DynamicScrolledComposite(eu.esdihumboldt.hale.ui.util.components.DynamicScrolledComposite) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite)

Example 3 with DynamicScrolledComposite

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);
}
Also used : Label(org.eclipse.swt.widgets.Label) PropertyEntitySelector(eu.esdihumboldt.hale.ui.function.common.PropertyEntitySelector) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) PropertyParameterDefinition(eu.esdihumboldt.hale.common.align.extension.function.PropertyParameterDefinition) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) GeometrySchemaService(eu.esdihumboldt.hale.ui.geometry.service.GeometrySchemaService) TypeDefinition(eu.esdihumboldt.hale.common.schema.model.TypeDefinition) GridLayout(org.eclipse.swt.layout.GridLayout) TypeEntityDefinition(eu.esdihumboldt.hale.common.align.model.impl.TypeEntityDefinition) PropertyCondition(eu.esdihumboldt.hale.common.align.model.condition.PropertyCondition) PropertyOrChildrenTypeCondition(eu.esdihumboldt.hale.common.align.model.condition.PropertyOrChildrenTypeCondition) DynamicScrolledComposite(eu.esdihumboldt.hale.ui.util.components.DynamicScrolledComposite) Composite(org.eclipse.swt.widgets.Composite) DynamicScrolledComposite(eu.esdihumboldt.hale.ui.util.components.DynamicScrolledComposite) QName(javax.xml.namespace.QName) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) PropertyEntityDefinition(eu.esdihumboldt.hale.common.align.model.impl.PropertyEntityDefinition) TypeEntityDefinition(eu.esdihumboldt.hale.common.align.model.impl.TypeEntityDefinition) EntityDefinition(eu.esdihumboldt.hale.common.align.model.EntityDefinition) PropertyEntityDefinition(eu.esdihumboldt.hale.common.align.model.impl.PropertyEntityDefinition) GridData(org.eclipse.swt.layout.GridData) InstanceService(eu.esdihumboldt.hale.ui.service.instance.InstanceService) GeometryCondition(eu.esdihumboldt.hale.common.align.model.condition.impl.GeometryCondition) PropertyParameter(eu.esdihumboldt.hale.common.align.extension.function.PropertyParameter)

Example 4 with DynamicScrolledComposite

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;
}
Also used : DynamicScrolledComposite(eu.esdihumboldt.hale.ui.util.components.DynamicScrolledComposite) Group(org.eclipse.swt.widgets.Group) Composite(org.eclipse.swt.widgets.Composite) DynamicScrolledComposite(eu.esdihumboldt.hale.ui.util.components.DynamicScrolledComposite) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) SWT(org.eclipse.swt.SWT) SchemaSpaceID(eu.esdihumboldt.hale.common.schema.SchemaSpaceID) DynamicScrolledComposite(eu.esdihumboldt.hale.ui.util.components.DynamicScrolledComposite) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite)

Example 5 with DynamicScrolledComposite

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;
}
Also used : DynamicScrolledComposite(eu.esdihumboldt.hale.ui.util.components.DynamicScrolledComposite) InputDialog(org.eclipse.jface.dialogs.InputDialog) Composite(org.eclipse.swt.widgets.Composite) DynamicScrolledComposite(eu.esdihumboldt.hale.ui.util.components.DynamicScrolledComposite) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) ProjectService(eu.esdihumboldt.hale.ui.service.project.ProjectService) TreeMap(java.util.TreeMap) ValueProperties(eu.esdihumboldt.hale.common.core.io.ValueProperties) Button(org.eclipse.swt.widgets.Button) Value(eu.esdihumboldt.hale.common.core.io.Value) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Display(org.eclipse.swt.widgets.Display) IInputValidator(org.eclipse.jface.dialogs.IInputValidator)

Aggregations

DynamicScrolledComposite (eu.esdihumboldt.hale.ui.util.components.DynamicScrolledComposite)5 Composite (org.eclipse.swt.widgets.Composite)5 ScrolledComposite (org.eclipse.swt.custom.ScrolledComposite)3 Group (org.eclipse.swt.widgets.Group)3 GridLayout (org.eclipse.swt.layout.GridLayout)2 DefaultCustomPropertyFunction (eu.esdihumboldt.hale.common.align.custom.DefaultCustomPropertyFunction)1 PropertyParameter (eu.esdihumboldt.hale.common.align.extension.function.PropertyParameter)1 PropertyParameterDefinition (eu.esdihumboldt.hale.common.align.extension.function.PropertyParameterDefinition)1 EntityDefinition (eu.esdihumboldt.hale.common.align.model.EntityDefinition)1 PropertyCondition (eu.esdihumboldt.hale.common.align.model.condition.PropertyCondition)1 PropertyOrChildrenTypeCondition (eu.esdihumboldt.hale.common.align.model.condition.PropertyOrChildrenTypeCondition)1 GeometryCondition (eu.esdihumboldt.hale.common.align.model.condition.impl.GeometryCondition)1 PropertyEntityDefinition (eu.esdihumboldt.hale.common.align.model.impl.PropertyEntityDefinition)1 TypeEntityDefinition (eu.esdihumboldt.hale.common.align.model.impl.TypeEntityDefinition)1 Value (eu.esdihumboldt.hale.common.core.io.Value)1 ValueProperties (eu.esdihumboldt.hale.common.core.io.ValueProperties)1 SchemaSpaceID (eu.esdihumboldt.hale.common.schema.SchemaSpaceID)1 TypeDefinition (eu.esdihumboldt.hale.common.schema.model.TypeDefinition)1 PropertyEntitySelector (eu.esdihumboldt.hale.ui.function.common.PropertyEntitySelector)1 BindingOrType (eu.esdihumboldt.hale.ui.functions.custom.pages.internal.BindingOrType)1