Search in sources :

Example 1 with Priority

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

the class SetPriorityContribution method fill.

/**
 * @see AbstractFunctionWizardContribution#fill(Menu, int)
 */
@Override
public void fill(Menu menu, int index) {
    if (getOriginalCell() == null)
        return;
    AlignmentService alignmentService = PlatformUI.getWorkbench().getService(AlignmentService.class);
    Cell cell = getOriginalCell();
    Priority oldPriority = cell.getPriority();
    for (Priority priority : Priority.values()) {
        if (priority != oldPriority) {
            SetPriorityAction setPriorityAction = new SetPriorityAction(priority, cell.getId(), alignmentService);
            IContributionItem item = new ActionContributionItem(setPriorityAction);
            item.fill(menu, index++);
        }
    }
}
Also used : SetPriorityAction(eu.esdihumboldt.hale.ui.function.contribution.internal.SetPriorityAction) ActionContributionItem(org.eclipse.jface.action.ActionContributionItem) AlignmentService(eu.esdihumboldt.hale.ui.service.align.AlignmentService) Priority(eu.esdihumboldt.hale.common.align.model.Priority) IContributionItem(org.eclipse.jface.action.IContributionItem) Cell(eu.esdihumboldt.hale.common.align.model.Cell)

Example 2 with Priority

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

the class AlignmentServiceImpl method setCellProperty.

/**
 * @see eu.esdihumboldt.hale.ui.service.align.AlignmentService#setCellProperty(java.lang.String,
 *      java.lang.String, java.lang.Object)
 */
@Override
public void setCellProperty(String cellId, String propertyName, Object property) {
    if (propertyName == null || property == null) {
        throw new IllegalArgumentException("Mandatory parameter is null");
    }
    Cell cell = getAlignment().getCell(cellId);
    if (cell instanceof ModifiableCell && (Cell.PROPERTY_DISABLE_FOR.equals(propertyName) || Cell.PROPERTY_ENABLE_FOR.equals(propertyName))) {
        boolean disable = Cell.PROPERTY_DISABLE_FOR.equals(propertyName);
        if (property instanceof Cell) {
            Cell other = (Cell) property;
            if (!AlignmentUtil.isTypeCell(other))
                throw new IllegalArgumentException();
            // This call may fail, if the cell was disabled in a base
            // alignment and someone tries to enable it again.
            ((ModifiableCell) cell).setDisabledFor(other, disable);
        } else
            throw new IllegalArgumentException();
        notifyCellsPropertyChanged(Arrays.asList(cell), propertyName);
    } else if (Cell.PROPERTY_TRANSFORMATION_MODE.equals(propertyName)) {
        // set the transformation mode
        if (cell instanceof ModifiableCell && property instanceof TransformationMode) {
            ModifiableCell modCell = (ModifiableCell) cell;
            modCell.setTransformationMode((TransformationMode) property);
            notifyCellsPropertyChanged(Arrays.asList(cell), propertyName);
        }
    } else if (cell instanceof MutableCell) {
        MutableCell mutableCell = (MutableCell) cell;
        if (Cell.PROPERTY_PRIORITY.equals(propertyName)) {
            if (property instanceof Priority) {
                Priority priority = (Priority) property;
                mutableCell.setPriority(priority);
            }
            if (property instanceof String) {
                String priorityStr = (String) property;
                Priority priority = Priority.valueOf(priorityStr);
                if (priority != null) {
                    mutableCell.setPriority(priority);
                } else {
                    throw new IllegalArgumentException();
                }
            }
            notifyCellsPropertyChanged(Arrays.asList(cell), propertyName);
        }
    } else {
        throw new IllegalArgumentException("No mutable cell by the given id found: " + cellId);
    }
}
Also used : MutableCell(eu.esdihumboldt.hale.common.align.model.MutableCell) TransformationMode(eu.esdihumboldt.hale.common.align.model.TransformationMode) Priority(eu.esdihumboldt.hale.common.align.model.Priority) Cell(eu.esdihumboldt.hale.common.align.model.Cell) ModifiableCell(eu.esdihumboldt.hale.common.align.model.ModifiableCell) MutableCell(eu.esdihumboldt.hale.common.align.model.MutableCell) BaseAlignmentCell(eu.esdihumboldt.hale.common.align.model.BaseAlignmentCell) ModifiableCell(eu.esdihumboldt.hale.common.align.model.ModifiableCell)

Example 3 with Priority

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

the class AlignmentServiceUndoSupport method setCellProperty.

/**
 * @see eu.esdihumboldt.hale.ui.service.align.AlignmentService#setCellProperty(java.lang.String,
 *      java.lang.String, java.lang.Object)
 */
@Override
public void setCellProperty(String cellId, String propertyName, Object property) {
    if (Cell.PROPERTY_DISABLE_FOR.equals(propertyName) || Cell.PROPERTY_ENABLE_FOR.equals(propertyName)) {
        IUndoableOperation operation = new DisableCellOperation(Cell.PROPERTY_DISABLE_FOR.equals(propertyName), cellId, (Cell) property);
        executeOperation(operation);
    } else if (Cell.PROPERTY_PRIORITY.equals(propertyName)) {
        if (property instanceof Priority) {
            Priority newPriority = (Priority) property;
            Cell cell = getAlignment().getCell(cellId);
            Priority oldPriority = cell.getPriority();
            IUndoableOperation operation = new SetCellPropertyOperation(cellId, propertyName, oldPriority, newPriority);
            executeOperation(operation);
        }
    } else if (Cell.PROPERTY_TRANSFORMATION_MODE.equals(propertyName)) {
        Cell cell = getAlignment().getCell(cellId);
        Object oldValue = cell.getTransformationMode();
        IUndoableOperation operation = new SetCellPropertyOperation(cellId, propertyName, oldValue, property);
        executeOperation(operation);
    } else {
        log.warn("An unknown cell property is set. No undo support.");
        alignmentService.setCellProperty(cellId, propertyName, property);
    }
}
Also used : IUndoableOperation(org.eclipse.core.commands.operations.IUndoableOperation) Priority(eu.esdihumboldt.hale.common.align.model.Priority) Cell(eu.esdihumboldt.hale.common.align.model.Cell) MutableCell(eu.esdihumboldt.hale.common.align.model.MutableCell)

Example 4 with Priority

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

the class CellPrioritySection method setFromCell.

private void setFromCell() {
    Cell cell = getCell();
    Priority currentPriority = cell.getPriority();
    comboViewer.setSelection(new StructuredSelection(currentPriority));
}
Also used : Priority(eu.esdihumboldt.hale.common.align.model.Priority) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) Cell(eu.esdihumboldt.hale.common.align.model.Cell)

Example 5 with Priority

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

Aggregations

Priority (eu.esdihumboldt.hale.common.align.model.Priority)6 Cell (eu.esdihumboldt.hale.common.align.model.Cell)5 MutableCell (eu.esdihumboldt.hale.common.align.model.MutableCell)3 TransformationMode (eu.esdihumboldt.hale.common.align.model.TransformationMode)2 AlignmentService (eu.esdihumboldt.hale.ui.service.align.AlignmentService)2 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)2 Function (com.google.common.base.Function)1 ArrayListMultimap (com.google.common.collect.ArrayListMultimap)1 Collections2 (com.google.common.collect.Collections2)1 ListMultimap (com.google.common.collect.ListMultimap)1 Multimaps (com.google.common.collect.Multimaps)1 AnnotationExtension (eu.esdihumboldt.hale.common.align.extension.annotation.AnnotationExtension)1 FunctionDefinition (eu.esdihumboldt.hale.common.align.extension.function.FunctionDefinition)1 FunctionUtil (eu.esdihumboldt.hale.common.align.extension.function.FunctionUtil)1 CustomPropertyFunction (eu.esdihumboldt.hale.common.align.extension.function.custom.CustomPropertyFunction)1 EntityResolver (eu.esdihumboldt.hale.common.align.io.EntityResolver)1 LoadAlignmentContext (eu.esdihumboldt.hale.common.align.io.LoadAlignmentContext)1 DefaultEntityResolver (eu.esdihumboldt.hale.common.align.io.impl.DefaultEntityResolver)1 JaxbAlignmentIO (eu.esdihumboldt.hale.common.align.io.impl.JaxbAlignmentIO)1 DummyEntityResolver (eu.esdihumboldt.hale.common.align.io.impl.dummy.DummyEntityResolver)1