Search in sources :

Example 56 with EntityDefinition

use of eu.esdihumboldt.hale.common.align.model.EntityDefinition 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)

Example 57 with EntityDefinition

use of eu.esdihumboldt.hale.common.align.model.EntityDefinition in project hale by halestudio.

the class MergeParameterPage method createContent.

@Override
protected void createContent(Composite page) {
    // set layout of page
    page.setLayout(new GridLayout());
    Label name = new Label(page, SWT.NONE);
    name.setText(parameter.getDisplayName());
    // create checkbox tree viewer
    viewer = new CheckboxTreeViewer(page, SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
    viewer.getControl().setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());
    // comparator
    viewer.setComparator(new DefinitionComparator());
    // label provider
    viewer.setLabelProvider(labelProvider);
    // content provider
    viewer.setContentProvider(new PropertyPathContentProvider(SchemaSpaceID.SOURCE));
    // check state listener
    viewer.addCheckStateListener(new ICheckStateListener() {

        @Override
        public void checkStateChanged(CheckStateChangedEvent event) {
            // add/remove it from/to set of selected properties
            EntityDefinition eventSource = (EntityDefinition) event.getElement();
            if (event.getChecked())
                selection.add(eventSource);
            else
                selection.remove(eventSource);
        }
    });
    // for now filter everything after first level
    viewer.addFilter(new ViewerFilter() {

        @Override
        public boolean select(Viewer viewer, Object parentElement, Object element) {
            return parentElement == sourceType;
        }
    });
    if (parameter.getName().equals(PARAMETER_ADDITIONAL_PROPERTY))
        viewer.addFilter(new ViewerFilter() {

            @Override
            public boolean select(Viewer viewer, Object parentElement, Object element) {
                return !filtered.contains(element);
            }
        });
    Cell unfinishedCell = getWizard().getUnfinishedCell();
    if (unfinishedCell.getSource() != null) {
        sourceType = (TypeDefinition) unfinishedCell.getSource().values().iterator().next().getDefinition().getDefinition();
    }
    viewer.setInput(sourceType);
    // add initial selection
    if (sourceType != null && initialSelection != null) {
        for (String propertyPath : initialSelection) {
            EntityDefinition entity = getEntityDefinition(propertyPath, sourceType);
            if (entity != null) {
                selection.add(entity);
            } else {
                log.warn("Could not find child for property path " + propertyPath);
            }
        }
        viewer.setCheckedElements(selection.toArray());
    }
}
Also used : ViewerFilter(org.eclipse.jface.viewers.ViewerFilter) PropertyPathContentProvider(eu.esdihumboldt.hale.ui.common.definition.viewer.PropertyPathContentProvider) DefinitionComparator(eu.esdihumboldt.hale.ui.common.definition.viewer.DefinitionComparator) ICheckStateListener(org.eclipse.jface.viewers.ICheckStateListener) Label(org.eclipse.swt.widgets.Label) Viewer(org.eclipse.jface.viewers.Viewer) CheckboxTreeViewer(org.eclipse.jface.viewers.CheckboxTreeViewer) CheckboxTreeViewer(org.eclipse.jface.viewers.CheckboxTreeViewer) EntityDefinition(eu.esdihumboldt.hale.common.align.model.EntityDefinition) GridLayout(org.eclipse.swt.layout.GridLayout) CheckStateChangedEvent(org.eclipse.jface.viewers.CheckStateChangedEvent) Cell(eu.esdihumboldt.hale.common.align.model.Cell)

Example 58 with EntityDefinition

use of eu.esdihumboldt.hale.common.align.model.EntityDefinition in project hale by halestudio.

the class MergeParameterPage method onShowPage.

/**
 * @see eu.esdihumboldt.hale.ui.HaleWizardPage#onShowPage(boolean)
 */
@Override
protected void onShowPage(boolean firstShow) {
    super.onShowPage(firstShow);
    setPageComplete(true);
    Cell unfinishedCell = getWizard().getUnfinishedCell();
    // selected target could've changed!
    TypeDefinition newSourceType = (TypeDefinition) unfinishedCell.getSource().values().iterator().next().getDefinition().getDefinition();
    if (!newSourceType.equals(sourceType)) {
        selection = new HashSet<EntityDefinition>();
        sourceType = newSourceType;
        viewer.setInput(sourceType);
    }
    // for additional_property: selected properties can change!
    if (parameter.getName().equals(PARAMETER_ADDITIONAL_PROPERTY)) {
        filtered = new HashSet<EntityDefinition>();
        List<ParameterValue> properties = unfinishedCell.getTransformationParameters().get(PARAMETER_PROPERTY);
        boolean oldSelectionChanged = false;
        for (ParameterValue propertyPath : properties) {
            EntityDefinition def = getEntityDefinition(propertyPath.as(String.class), sourceType);
            filtered.add(def);
            if (selection.remove(def))
                oldSelectionChanged = true;
        }
        if (oldSelectionChanged) {
            viewer.setCheckedElements(selection.toArray());
        }
        viewer.refresh();
    }
}
Also used : EntityDefinition(eu.esdihumboldt.hale.common.align.model.EntityDefinition) ParameterValue(eu.esdihumboldt.hale.common.align.model.ParameterValue) Cell(eu.esdihumboldt.hale.common.align.model.Cell) TypeDefinition(eu.esdihumboldt.hale.common.schema.model.TypeDefinition)

Example 59 with EntityDefinition

use of eu.esdihumboldt.hale.common.align.model.EntityDefinition in project hale by halestudio.

the class MergeParameterPage method getConfiguration.

/**
 * @see eu.esdihumboldt.hale.ui.function.generic.pages.ParameterPage#getConfiguration()
 */
@Override
public ListMultimap<String, ParameterValue> getConfiguration() {
    ListMultimap<String, ParameterValue> configuration = ArrayListMultimap.create();
    for (EntityDefinition selected : selection) {
        // build property path (QNames separated by .)
        /*
			 * FIXME this is problematic with property names that contain dots
			 * and only works out because only top level properties are allowed.
			 * If multiple levels are needed, properties should be stored as
			 * Lists of QNames (Complex values) or EntityDefinitions.
			 */
        // FIXME use MergeUtil helper function instead
        String propertyPath = Joiner.on('.').join(Collections2.transform(selected.getPropertyPath(), new Function<ChildContext, String>() {

            @Override
            public String apply(ChildContext input) {
                return input.getChild().getName().toString();
            }
        }));
        // add it to configuration
        configuration.put(parameter.getName(), new ParameterValue(propertyPath));
    }
    return configuration;
}
Also used : EntityDefinition(eu.esdihumboldt.hale.common.align.model.EntityDefinition) Function(com.google.common.base.Function) ParameterValue(eu.esdihumboldt.hale.common.align.model.ParameterValue) ChildContext(eu.esdihumboldt.hale.common.align.model.ChildContext)

Example 60 with EntityDefinition

use of eu.esdihumboldt.hale.common.align.model.EntityDefinition in project hale by halestudio.

the class DefinitionInstanceLabelProvider method getToolTipText.

/**
 * @see org.eclipse.jface.viewers.CellLabelProvider#getToolTipText(java.lang.Object)
 */
@Override
public String getToolTipText(Object element) {
    if (element instanceof EntityDefinition) {
        InstanceValidationReport report = validator.validate(instance);
        Collection<InstanceValidationMessage> warnings = report.getWarnings();
        if (warnings.isEmpty())
            return null;
        StringBuilder toolTip = new StringBuilder();
        for (Message m : warnings) toolTip.append(m.getFormattedMessage()).append('\n');
        return toolTip.substring(0, toolTip.length() - 1);
    } else
        return null;
}
Also used : EntityDefinition(eu.esdihumboldt.hale.common.align.model.EntityDefinition) InstanceValidationReport(eu.esdihumboldt.hale.common.instance.extension.validation.report.InstanceValidationReport) InstanceValidationMessage(eu.esdihumboldt.hale.common.instance.extension.validation.report.InstanceValidationMessage) Message(eu.esdihumboldt.hale.common.core.report.Message) InstanceValidationMessage(eu.esdihumboldt.hale.common.instance.extension.validation.report.InstanceValidationMessage)

Aggregations

EntityDefinition (eu.esdihumboldt.hale.common.align.model.EntityDefinition)99 TypeEntityDefinition (eu.esdihumboldt.hale.common.align.model.impl.TypeEntityDefinition)39 PropertyEntityDefinition (eu.esdihumboldt.hale.common.align.model.impl.PropertyEntityDefinition)37 ChildContext (eu.esdihumboldt.hale.common.align.model.ChildContext)23 ArrayList (java.util.ArrayList)22 Entity (eu.esdihumboldt.hale.common.align.model.Entity)21 TypeDefinition (eu.esdihumboldt.hale.common.schema.model.TypeDefinition)20 Cell (eu.esdihumboldt.hale.common.align.model.Cell)18 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)13 PropertyDefinition (eu.esdihumboldt.hale.common.schema.model.PropertyDefinition)11 MutableCell (eu.esdihumboldt.hale.common.align.model.MutableCell)10 HashSet (java.util.HashSet)10 QName (javax.xml.namespace.QName)10 HashMap (java.util.HashMap)9 Condition (eu.esdihumboldt.hale.common.align.model.Condition)8 SimpleLog (eu.esdihumboldt.hale.common.core.report.SimpleLog)7 ISelection (org.eclipse.jface.viewers.ISelection)7 List (java.util.List)6 TreePath (org.eclipse.jface.viewers.TreePath)6 AlignmentMigration (eu.esdihumboldt.hale.common.align.migrate.AlignmentMigration)5