Search in sources :

Example 1 with NewRelationWizard

use of eu.esdihumboldt.hale.ui.function.internal.NewRelationWizard in project hale by halestudio.

the class FunctionWizardUtil method addRelationForTarget.

/**
 * Launches a wizard for mapping to a specific target entity.
 *
 * @param target the target entity
 * @param source the source entities the target should be mapped from, or
 *            <code>null</code>
 * @return the created cell or <code>null</code>
 */
public static Cell addRelationForTarget(EntityDefinition target, Iterable<EntityDefinition> source) {
    DefaultSchemaSelection initialSelection = new DefaultSchemaSelection();
    initialSelection.addTargetItem(target);
    if (source != null) {
        for (EntityDefinition sourceEntity : source) {
            initialSelection.addSourceItem(sourceEntity);
        }
    }
    SchemaSelectionFunctionMatcher selectionMatcher;
    if (source == null) {
        // ignore source
        selectionMatcher = new SchemaSelectionFunctionMatcher(true, false);
    } else {
        // respect source
        selectionMatcher = new SchemaSelectionFunctionMatcher(false, false);
    }
    NewRelationWizard wizard = new NewRelationWizard(initialSelection, selectionMatcher);
    wizard.setWindowTitle("Map to " + target.getDefinition().getDisplayName());
    Shell shell = Display.getCurrent().getActiveShell();
    HaleWizardDialog dialog = new HaleWizardDialog(shell, wizard);
    if (dialog.open() == Window.OK) {
        return wizard.getCreatedCell();
    } else {
        return null;
    }
}
Also used : EntityDefinition(eu.esdihumboldt.hale.common.align.model.EntityDefinition) Shell(org.eclipse.swt.widgets.Shell) DefaultSchemaSelection(eu.esdihumboldt.hale.ui.selection.impl.DefaultSchemaSelection) NewRelationWizard(eu.esdihumboldt.hale.ui.function.internal.NewRelationWizard) SchemaSelectionFunctionMatcher(eu.esdihumboldt.hale.ui.function.contribution.SchemaSelectionFunctionMatcher) HaleWizardDialog(eu.esdihumboldt.hale.ui.util.wizard.HaleWizardDialog)

Aggregations

EntityDefinition (eu.esdihumboldt.hale.common.align.model.EntityDefinition)1 SchemaSelectionFunctionMatcher (eu.esdihumboldt.hale.ui.function.contribution.SchemaSelectionFunctionMatcher)1 NewRelationWizard (eu.esdihumboldt.hale.ui.function.internal.NewRelationWizard)1 DefaultSchemaSelection (eu.esdihumboldt.hale.ui.selection.impl.DefaultSchemaSelection)1 HaleWizardDialog (eu.esdihumboldt.hale.ui.util.wizard.HaleWizardDialog)1 Shell (org.eclipse.swt.widgets.Shell)1