Search in sources :

Example 16 with AlignmentService

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

the class EditCustomFunctionContribution method fill.

@Override
public void fill(Menu menu, int index) {
    AlignmentService alignmentService = PlatformUI.getWorkbench().getService(AlignmentService.class);
    Collection<CustomPropertyFunction> functions = alignmentService.getAlignment().getCustomPropertyFunctions().values();
    for (CustomPropertyFunction function : functions) {
        if (function instanceof DefaultCustomPropertyFunction) {
            // XXX currently only these functions editable
            DefaultCustomPropertyFunction cf = (DefaultCustomPropertyFunction) function;
            EditWizardAction action = new EditWizardAction(cf, alignmentService);
            IContributionItem item = new ActionContributionItem(action);
            item.fill(menu, index++);
        }
    }
// TODO add base alignment functions (disabled, with separator)?
}
Also used : DefaultCustomPropertyFunction(eu.esdihumboldt.hale.common.align.custom.DefaultCustomPropertyFunction) ActionContributionItem(org.eclipse.jface.action.ActionContributionItem) AlignmentService(eu.esdihumboldt.hale.ui.service.align.AlignmentService) IContributionItem(org.eclipse.jface.action.IContributionItem) CustomPropertyFunction(eu.esdihumboldt.hale.common.align.extension.function.custom.CustomPropertyFunction) DefaultCustomPropertyFunction(eu.esdihumboldt.hale.common.align.custom.DefaultCustomPropertyFunction)

Example 17 with AlignmentService

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

the class NewCustomPropertyFunctionHandler method onComplete.

@Override
protected void onComplete(CustomPropertyFunctionWizard wizard) {
    AlignmentService as = PlatformUI.getWorkbench().getService(AlignmentService.class);
    as.addCustomPropertyFunction(wizard.getResultFunction());
}
Also used : AlignmentService(eu.esdihumboldt.hale.ui.service.align.AlignmentService)

Example 18 with AlignmentService

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

the class RemoveCustomFunctionContribution method fill.

@Override
public void fill(Menu menu, int index) {
    AlignmentService alignmentService = PlatformUI.getWorkbench().getService(AlignmentService.class);
    Collection<CustomPropertyFunction> functions = alignmentService.getAlignment().getCustomPropertyFunctions().values();
    for (CustomPropertyFunction function : functions) {
        if (function instanceof DefaultCustomPropertyFunction) {
            // XXX currently only these functions editable
            DefaultCustomPropertyFunction cf = (DefaultCustomPropertyFunction) function;
            RemoveCustomFunctionAction action = new RemoveCustomFunctionAction(cf, alignmentService);
            IContributionItem item = new ActionContributionItem(action);
            item.fill(menu, index++);
        }
    }
// TODO add base alignment functions (disabled, with separator)?
}
Also used : DefaultCustomPropertyFunction(eu.esdihumboldt.hale.common.align.custom.DefaultCustomPropertyFunction) ActionContributionItem(org.eclipse.jface.action.ActionContributionItem) AlignmentService(eu.esdihumboldt.hale.ui.service.align.AlignmentService) IContributionItem(org.eclipse.jface.action.IContributionItem) CustomPropertyFunction(eu.esdihumboldt.hale.common.align.extension.function.custom.CustomPropertyFunction) DefaultCustomPropertyFunction(eu.esdihumboldt.hale.common.align.custom.DefaultCustomPropertyFunction)

Example 19 with AlignmentService

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

the class CellPrioritySection method selectionChanged.

/**
 * @see org.eclipse.jface.viewers.ISelectionChangedListener#selectionChanged(org.eclipse.jface.viewers.SelectionChangedEvent)
 */
@Override
public void selectionChanged(SelectionChangedEvent event) {
    ISelection selection = event.getSelection();
    if (selection instanceof IStructuredSelection) {
        IStructuredSelection structuredSelection = (IStructuredSelection) selection;
        Object firstElement = structuredSelection.getFirstElement();
        if (firstElement instanceof Priority) {
            Priority priority = (Priority) firstElement;
            Cell cell = getCell();
            if (cell.getPriority() != priority) {
                AlignmentService alignmentService = PlatformUI.getWorkbench().getService(AlignmentService.class);
                alignmentService.setCellProperty(cell.getId(), Cell.PROPERTY_PRIORITY, priority);
            }
        }
    }
}
Also used : Priority(eu.esdihumboldt.hale.common.align.model.Priority) AlignmentService(eu.esdihumboldt.hale.ui.service.align.AlignmentService) ISelection(org.eclipse.jface.viewers.ISelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) Cell(eu.esdihumboldt.hale.common.align.model.Cell)

Example 20 with AlignmentService

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

the class AlignmentView method createViewControl.

/**
 * @see eu.esdihumboldt.hale.ui.views.mapping.AbstractMappingView#createViewControl(org.eclipse.swt.widgets.Composite)
 */
@Override
public void createViewControl(Composite parent) {
    Composite page = new Composite(parent, SWT.NONE);
    page.setLayout(GridLayoutFactory.fillDefaults().create());
    // create type relation selection control
    sourceTargetSelector = new SourceTargetTypeSelector(page);
    sourceTargetSelector.getControl().setLayoutData(GridDataFactory.swtDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).create());
    sourceTargetSelector.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            getViewer().setInput(sourceTargetSelector.getSelectedCell());
            if (deactivatedCellFilterAction != null) {
                deactivatedCellFilterAction.setEnabled(sourceTargetSelector.isCellSelected());
                if (!sourceTargetSelector.isCellSelected())
                    deactivatedCellFilterAction.setChecked(true);
            }
            refreshGraph();
        }
    });
    // typeRelations = new ComboViewer(page, SWT.DROP_DOWN | SWT.READ_ONLY);
    // typeRelations.setContentProvider(ArrayContentProvider.getInstance());
    // typeRelations.setLabelProvider(new LabelProvider() {
    // 
    // @Override
    // public Image getImage(Object element) {
    // if (element instanceof Cell) {
    // // use function image if possible
    // Cell cell = (Cell) element;
    // String functionId = cell.getTransformationIdentifier();
    // AbstractFunction<?> function = FunctionUtil.getFunction(functionId);
    // if (function != null) {
    // return functionLabels.getImage(function);
    // }
    // return null;
    // }
    // 
    // return super.getImage(element);
    // }
    // 
    // @Override
    // public String getText(Object element) {
    // if (element instanceof Cell) {
    // Cell cell = (Cell) element;
    // 
    // return CellUtil.getCellDescription(cell);
    // }
    // 
    // return super.getText(element);
    // }
    // 
    // });
    // typeRelations.addSelectionChangedListener(new ISelectionChangedListener() {
    // 
    // @Override
    // public void selectionChanged(SelectionChangedEvent event) {
    // updateGraph();
    // }
    // });
    // typeRelations.getControl().setLayoutData(
    // GridDataFactory.swtDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false)
    // .create());
    // create viewer
    Composite viewerContainer = new Composite(page, SWT.NONE);
    viewerContainer.setLayout(new FillLayout());
    viewerContainer.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());
    super.createViewControl(viewerContainer);
    updateLayout(false);
    AlignmentService as = PlatformUI.getWorkbench().getService(AlignmentService.class);
    // update();
    as.addListener(alignmentListener = new AlignmentServiceAdapter() {

        @Override
        public void alignmentCleared() {
            PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() {

                @Override
                public void run() {
                    sourceTargetSelector.setSelection(StructuredSelection.EMPTY);
                }
            });
        }

        @Override
        public void cellsRemoved(Iterable<Cell> cells) {
            if (sourceTargetSelector.isCellSelected() && Iterables.contains(cells, sourceTargetSelector.getSelectedCell()))
                sourceTargetSelector.setSelection(StructuredSelection.EMPTY);
            refreshGraph();
        }

        @Override
        public void cellsReplaced(Map<? extends Cell, ? extends Cell> cells) {
            if (sourceTargetSelector.isCellSelected() && cells.keySet().contains(sourceTargetSelector.getSelectedCell()))
                sourceTargetSelector.setSelection(StructuredSelection.EMPTY);
            refreshGraph();
        }

        @Override
        public void cellsAdded(Iterable<Cell> cells) {
            refreshGraph();
        }

        @Override
        public void alignmentChanged() {
            PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() {

                @Override
                public void run() {
                    sourceTargetSelector.setSelection(StructuredSelection.EMPTY);
                }
            });
        }

        @Override
        public void cellsPropertyChanged(Iterable<Cell> cells, String propertyName) {
            refreshGraph();
        }

        @Override
        public void customFunctionsChanged() {
            refreshGraph();
        }
    });
    TaskService taskService = PlatformUI.getWorkbench().getService(TaskService.class);
    taskService.addListener(tasksListener = new TaskServiceListener() {

        @Override
        public void tasksRemoved(Iterable<Task<?>> tasks) {
            refreshGraph();
        }

        @Override
        public void tasksAdded(Iterable<Task<?>> tasks) {
            refreshGraph();
        }

        @Override
        public void taskUserDataChanged(ResolvedTask<?> task) {
            refreshGraph();
        }
    });
    // initialize compatibility checkup and display
    CompatibilityService cs = PlatformUI.getWorkbench().getService(CompatibilityService.class);
    cs.addListener(compListener = new ExclusiveExtensionListener<CompatibilityMode, CompatibilityModeFactory>() {

        @Override
        public void currentObjectChanged(final CompatibilityMode arg0, final CompatibilityModeFactory arg1) {
            refreshGraph();
        }
    });
    // listen on SchemaSelections
    getSite().getWorkbenchWindow().getSelectionService().addPostSelectionListener(selectionListener = new ISelectionListener() {

        @Override
        public void selectionChanged(IWorkbenchPart part, ISelection selection) {
            if (!(selection instanceof SchemaSelection)) {
                // only react on schema selections
                return;
            }
            if (part != AlignmentView.this) {
                updateRelation((SchemaSelection) selection);
            }
        }
    });
    // select type cell, if it is double clicked
    getViewer().addDoubleClickListener(new IDoubleClickListener() {

        @Override
        public void doubleClick(DoubleClickEvent event) {
            IStructuredSelection selection = (IStructuredSelection) event.getSelection();
            if (selection.size() == 1) {
                Object selected = selection.getFirstElement();
                if (selected instanceof Cell && AlignmentUtil.isTypeCell((Cell) selected))
                    sourceTargetSelector.setSelection(selection);
            }
        }
    });
    // listen on size changes
    getViewer().getControl().addControlListener(new ControlAdapter() {

        @Override
        public void controlResized(ControlEvent e) {
            updateLayout(true);
        }
    });
    getViewer().setInput(new DefaultCell());
}
Also used : CompatibilityModeFactory(eu.esdihumboldt.hale.ui.common.service.compatibility.CompatibilityModeFactory) ControlAdapter(org.eclipse.swt.events.ControlAdapter) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) SourceTargetTypeSelector(eu.esdihumboldt.hale.ui.function.common.SourceTargetTypeSelector) ISelectionListener(org.eclipse.ui.ISelectionListener) IWorkbenchPart(org.eclipse.ui.IWorkbenchPart) AlignmentService(eu.esdihumboldt.hale.ui.service.align.AlignmentService) ResolvedTask(eu.esdihumboldt.hale.common.tasks.ResolvedTask) IDoubleClickListener(org.eclipse.jface.viewers.IDoubleClickListener) ISelection(org.eclipse.jface.viewers.ISelection) CompatibilityService(eu.esdihumboldt.hale.ui.common.service.compatibility.CompatibilityService) SchemaSelection(eu.esdihumboldt.hale.ui.selection.SchemaSelection) DefaultCell(eu.esdihumboldt.hale.common.align.model.impl.DefaultCell) BaseAlignmentCell(eu.esdihumboldt.hale.common.align.model.BaseAlignmentCell) Cell(eu.esdihumboldt.hale.common.align.model.Cell) Composite(org.eclipse.swt.widgets.Composite) CompatibilityMode(eu.esdihumboldt.hale.common.align.compatibility.CompatibilityMode) TaskService(eu.esdihumboldt.hale.common.tasks.TaskService) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) ExclusiveExtensionListener(de.fhg.igd.eclipse.util.extension.exclusive.ExclusiveExtension.ExclusiveExtensionListener) DoubleClickEvent(org.eclipse.jface.viewers.DoubleClickEvent) FillLayout(org.eclipse.swt.layout.FillLayout) DefaultCell(eu.esdihumboldt.hale.common.align.model.impl.DefaultCell) TaskServiceListener(eu.esdihumboldt.hale.common.tasks.TaskServiceListener) ControlEvent(org.eclipse.swt.events.ControlEvent) AlignmentServiceAdapter(eu.esdihumboldt.hale.ui.service.align.AlignmentServiceAdapter) Map(java.util.Map)

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