use of eu.esdihumboldt.hale.ui.function.contribution.SchemaSelectionFunctionMatcher 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;
}
}
Aggregations