Search in sources :

Example 41 with AlignmentService

use of eu.esdihumboldt.hale.ui.service.align.AlignmentService in project hale by halestudio.

the class FunctionWizardUtil method createNewWizard.

/**
 * Open a wizard that creates a new relation with the given ID and adds the
 * result to the alignment.
 *
 * @param functionId the function identifier
 * @param elements the schema selection defining the initial selection or
 *            <code>null</code>
 * @return the created cell or <code>null</code>
 */
public static Cell createNewWizard(String functionId, SchemaSelection elements) {
    FunctionWizardDescriptor<?> desc = FunctionWizardExtension.getInstance().getWizardDescriptor(functionId);
    FunctionWizard wizard = desc.createNewWizard(elements);
    if (wizard != null) {
        // initialize the wizard
        wizard.init();
        HaleWizardDialog dialog = new HaleWizardDialog(Display.getCurrent().getActiveShell(), wizard);
        if (dialog.open() == WizardDialog.OK) {
            MutableCell cell = wizard.getResult();
            AlignmentService as = PlatformUI.getWorkbench().getService(AlignmentService.class);
            as.addCell(cell);
            return cell;
        }
    }
    return null;
}
Also used : MutableCell(eu.esdihumboldt.hale.common.align.model.MutableCell) AlignmentService(eu.esdihumboldt.hale.ui.service.align.AlignmentService) HaleWizardDialog(eu.esdihumboldt.hale.ui.util.wizard.HaleWizardDialog)

Example 42 with AlignmentService

use of eu.esdihumboldt.hale.ui.service.align.AlignmentService in project hale by halestudio.

the class TransformDataWizard method performFinish.

/**
 * @see org.eclipse.jface.wizard.Wizard#performFinish()
 */
@Override
public boolean performFinish() {
    InstanceCollection rawSources = new MultiInstanceCollection(sourceSelectionPage.getSourceInstances());
    // Create a copy of the current alignment to be independent and run
    // everything in a job.
    AlignmentService alignmentService = PlatformUI.getWorkbench().getService(AlignmentService.class);
    Alignment alignment = new DefaultAlignment(alignmentService.getAlignment());
    // schema service for getting source schema
    SchemaService ss = PlatformUI.getWorkbench().getService(SchemaService.class);
    Transformation.transform(rawSources, targetSink, sourceSelectionPage.getExportJob(), sourceSelectionPage.getValidationJob(), alignment, ss.getSchemas(SchemaSpaceID.SOURCE), DefaultReportHandler.getInstance(), HaleUI.getServiceProvider(), null, new DefaultTransformationSettings());
    return true;
}
Also used : MultiInstanceCollection(eu.esdihumboldt.hale.common.instance.model.impl.MultiInstanceCollection) DefaultAlignment(eu.esdihumboldt.hale.common.align.model.impl.DefaultAlignment) Alignment(eu.esdihumboldt.hale.common.align.model.Alignment) SchemaService(eu.esdihumboldt.hale.ui.service.schema.SchemaService) AlignmentService(eu.esdihumboldt.hale.ui.service.align.AlignmentService) MultiInstanceCollection(eu.esdihumboldt.hale.common.instance.model.impl.MultiInstanceCollection) InstanceCollection(eu.esdihumboldt.hale.common.instance.model.InstanceCollection) DefaultTransformationSettings(eu.esdihumboldt.hale.common.headless.transform.DefaultTransformationSettings) DefaultAlignment(eu.esdihumboldt.hale.common.align.model.impl.DefaultAlignment)

Example 43 with AlignmentService

use of eu.esdihumboldt.hale.ui.service.align.AlignmentService in project hale by halestudio.

the class CellMessageTaskProvider method doActivate.

@Override
protected void doActivate(TaskService taskService) {
    alignmentService = HaleUI.getServiceProvider().getService(AlignmentService.class);
    // create tasks from the current schema
    addTasks(generateTasks(), taskService);
    // create tasks when cells have been removed
    alignmentService.addListener(new AlignmentServiceAdapter() {

        @Override
        public void alignmentChanged() {
            addTasks(generateTasks(), taskService);
        }

        @Override
        public void alignmentCleared() {
            taskService.clearTasks();
        }

        @Override
        public void cellsRemoved(Iterable<Cell> cells) {
            taskService.clearTasks();
            addTasks(generateTasks(), taskService);
        }

        @Override
        public void cellsAdded(Iterable<Cell> cells) {
            List<Task<Cell>> tasks = new ArrayList<>();
            for (Cell cell : cells) {
                tasks.addAll(generateTasks(cell));
            }
            addTasks(tasks, taskService);
        }
    });
}
Also used : AlignmentService(eu.esdihumboldt.hale.ui.service.align.AlignmentService) List(java.util.List) ArrayList(java.util.ArrayList) AlignmentServiceAdapter(eu.esdihumboldt.hale.ui.service.align.AlignmentServiceAdapter) Cell(eu.esdihumboldt.hale.common.align.model.Cell)

Aggregations

AlignmentService (eu.esdihumboldt.hale.ui.service.align.AlignmentService)43 Cell (eu.esdihumboldt.hale.common.align.model.Cell)16 Alignment (eu.esdihumboldt.hale.common.align.model.Alignment)11 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)9 ArrayList (java.util.ArrayList)8 DefaultCell (eu.esdihumboldt.hale.common.align.model.impl.DefaultCell)6 ISelection (org.eclipse.jface.viewers.ISelection)6 EntityDefinition (eu.esdihumboldt.hale.common.align.model.EntityDefinition)5 MutableCell (eu.esdihumboldt.hale.common.align.model.MutableCell)5 AlignmentServiceAdapter (eu.esdihumboldt.hale.ui.service.align.AlignmentServiceAdapter)5 ActionContributionItem (org.eclipse.jface.action.ActionContributionItem)5 IContributionItem (org.eclipse.jface.action.IContributionItem)5 TypeEntityDefinition (eu.esdihumboldt.hale.common.align.model.impl.TypeEntityDefinition)4 CompatibilityService (eu.esdihumboldt.hale.ui.common.service.compatibility.CompatibilityService)4 HashSet (java.util.HashSet)4 Display (org.eclipse.swt.widgets.Display)4 BaseAlignmentCell (eu.esdihumboldt.hale.common.align.model.BaseAlignmentCell)3 IAction (org.eclipse.jface.action.IAction)3 ControlAdapter (org.eclipse.swt.events.ControlAdapter)3 ControlEvent (org.eclipse.swt.events.ControlEvent)3