Search in sources :

Example 1 with EditorChooserEditor

use of eu.esdihumboldt.hale.ui.common.definition.editors.EditorChooserEditor in project hale by halestudio.

the class AssignParameterPage method createContent.

/**
 * @see eu.esdihumboldt.hale.ui.HaleWizardPage#createContent(org.eclipse.swt.widgets.Composite)
 */
@Override
protected void createContent(Composite page) {
    this.page = page;
    page.setLayout(GridLayoutFactory.swtDefaults().numColumns(2).create());
    // is created)
    if (getWizard().getUnfinishedCell().getTarget() != null) {
        EntityDefinition entityDef = getWizard().getUnfinishedCell().getTarget().values().iterator().next().getDefinition();
        PropertyDefinition propDef = (PropertyDefinition) entityDef.getDefinition();
        title = new Composite(page, SWT.NONE);
        title.setLayout(GridLayoutFactory.swtDefaults().numColumns(2).margins(0, 0).create());
        // title.setLayoutData(GridDataFactory.swtDefaults().align(SWT.END, SWT.END).create());
        DefinitionLabelFactory dlf = PlatformUI.getWorkbench().getService(DefinitionLabelFactory.class);
        dlf.createLabel(title, propDef, false);
        Label label = new Label(title, SWT.NONE);
        label.setText(" = ");
        editor = PlatformUI.getWorkbench().getService(AttributeEditorFactory.class).createEditor(page, propDef, entityDef, false);
        editor.setVariableReplacer(new TransformationVariableReplacer());
        editor.getControl().setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, false));
        editor.setPropertyChangeListener(new IPropertyChangeListener() {

            @Override
            public void propertyChange(PropertyChangeEvent event) {
                if (event.getProperty().equals(AttributeEditor.IS_VALID))
                    setPageComplete((Boolean) event.getNewValue());
            }
        });
    }
    if (editor != null && initialValue != null) {
        editor.setAsText(initialValue.as(String.class));
        if (editor instanceof EditorChooserEditor)
            ((EditorChooserEditor<?>) editor).selectEditor(initialValue.getType());
    }
    if (editor != null)
        setPageComplete(editor.isValid());
}
Also used : TransformationVariableReplacer(eu.esdihumboldt.hale.ui.transformation.TransformationVariableReplacer) IPropertyChangeListener(org.eclipse.jface.util.IPropertyChangeListener) EntityDefinition(eu.esdihumboldt.hale.common.align.model.EntityDefinition) PropertyChangeEvent(org.eclipse.jface.util.PropertyChangeEvent) DefinitionLabelFactory(eu.esdihumboldt.hale.ui.common.definition.DefinitionLabelFactory) Composite(org.eclipse.swt.widgets.Composite) Label(org.eclipse.swt.widgets.Label) GridData(org.eclipse.swt.layout.GridData) EditorChooserEditor(eu.esdihumboldt.hale.ui.common.definition.editors.EditorChooserEditor) PropertyDefinition(eu.esdihumboldt.hale.common.schema.model.PropertyDefinition)

Aggregations

EntityDefinition (eu.esdihumboldt.hale.common.align.model.EntityDefinition)1 PropertyDefinition (eu.esdihumboldt.hale.common.schema.model.PropertyDefinition)1 DefinitionLabelFactory (eu.esdihumboldt.hale.ui.common.definition.DefinitionLabelFactory)1 EditorChooserEditor (eu.esdihumboldt.hale.ui.common.definition.editors.EditorChooserEditor)1 TransformationVariableReplacer (eu.esdihumboldt.hale.ui.transformation.TransformationVariableReplacer)1 IPropertyChangeListener (org.eclipse.jface.util.IPropertyChangeListener)1 PropertyChangeEvent (org.eclipse.jface.util.PropertyChangeEvent)1 GridData (org.eclipse.swt.layout.GridData)1 Composite (org.eclipse.swt.widgets.Composite)1 Label (org.eclipse.swt.widgets.Label)1