Search in sources :

Example 41 with Cell

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

the class TaskTreeView method removeTask.

/**
 * Remove a task
 *
 * @param task the task to remove
 */
@SuppressWarnings("unchecked")
private void removeTask(Task<?> task) {
    DefaultTreeNode node = taskNodes.get(task);
    if (node != null) {
        // remove task from model
        MapTreeNode<ResolvedTask<?>, TreeNode> parent = (MapTreeNode<ResolvedTask<?>, TreeNode>) node.getParent();
        if (parent != null) {
            parent.removeChildNode(node);
            taskNodes.remove(task);
            // remove empty nodes
            if (!parent.hasChildren()) {
                MapTreeNode<Cell, MapTreeNode<ResolvedTask<?>, TreeNode>> root = (MapTreeNode<Cell, MapTreeNode<ResolvedTask<?>, TreeNode>>) parent.getParent();
                root.removeChildNode(parent);
                tree.refresh(root, true);
            } else {
                tree.refresh(parent, true);
                // update icons
                TreeNode updateNode = parent.getParent();
                while (updateNode != null) {
                    tree.update(updateNode, null);
                    updateNode = updateNode.getParent();
                }
            }
        }
    }
}
Also used : DefaultTreeNode(eu.esdihumboldt.hale.ui.util.tree.DefaultTreeNode) ResolvedTask(eu.esdihumboldt.hale.common.tasks.ResolvedTask) DefaultTreeNode(eu.esdihumboldt.hale.ui.util.tree.DefaultTreeNode) MapTreeNode(eu.esdihumboldt.hale.ui.util.tree.MapTreeNode) TreeNode(org.eclipse.jface.viewers.TreeNode) SortedMapTreeNode(eu.esdihumboldt.hale.ui.util.tree.SortedMapTreeNode) MapTreeNode(eu.esdihumboldt.hale.ui.util.tree.MapTreeNode) SortedMapTreeNode(eu.esdihumboldt.hale.ui.util.tree.SortedMapTreeNode) Cell(eu.esdihumboldt.hale.common.align.model.Cell)

Example 42 with Cell

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

the class TaskTreeView method update.

/**
 * Update the view with the given selection
 *
 * @param selection the selection
 */
public void update(ISelection selection) {
    if (selection instanceof IStructuredSelection) {
        Object element = ((IStructuredSelection) selection).getFirstElement();
        if (element instanceof Cell) {
            Collection<Task<Cell>> tasks = taskService.getTasks((Cell) element);
            if (!tasks.isEmpty()) {
                ResolvedTask<Cell> rt = taskService.resolveTask(tasks.iterator().next());
                MapTreeNode<?, TreeNode> cellNode = getParentNode(rt, false);
                tree.setSelection(new StructuredSelection(cellNode));
                tree.expandToLevel(cellNode, TreeViewer.ALL_LEVELS);
            }
        }
    } else {
        tree.setInput(null);
    }
}
Also used : ResolvedTask(eu.esdihumboldt.hale.common.tasks.ResolvedTask) Task(eu.esdihumboldt.hale.common.tasks.Task) DefaultTreeNode(eu.esdihumboldt.hale.ui.util.tree.DefaultTreeNode) MapTreeNode(eu.esdihumboldt.hale.ui.util.tree.MapTreeNode) TreeNode(org.eclipse.jface.viewers.TreeNode) SortedMapTreeNode(eu.esdihumboldt.hale.ui.util.tree.SortedMapTreeNode) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) Cell(eu.esdihumboldt.hale.common.align.model.Cell)

Example 43 with Cell

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

the class TaskTreeView method onDoubleClick.

/**
 * React on a double click on an item that represents the given identifier
 *
 * @param context the context object of the double-clicked node
 */
protected void onDoubleClick(Object context) {
    String cellId;
    if (context instanceof Cell) {
        cellId = ((Cell) context).getId();
    } else {
        return;
    }
    IWorkbenchWindow activeWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
    try {
        IViewPart part = activeWindow.getActivePage().showView(MappingView.ID);
        if (part instanceof MappingView) {
            ((MappingView) part).selectCell(cellId);
        }
    } catch (PartInitException e) {
    // ignore
    }
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) IViewPart(org.eclipse.ui.IViewPart) MappingView(eu.esdihumboldt.hale.ui.views.mapping.MappingView) PartInitException(org.eclipse.ui.PartInitException) Cell(eu.esdihumboldt.hale.common.align.model.Cell)

Example 44 with Cell

use of eu.esdihumboldt.hale.common.align.model.Cell 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 45 with Cell

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

the class NetworkExpansionExplanation method getExplanation.

@Override
protected String getExplanation(Cell cell, boolean html, ServiceProvider services, Locale locale) {
    Entity target = CellUtil.getFirstEntity(cell.getTarget());
    String expression = CellUtil.getFirstParameter(cell, PARAMETER_BUFFER_WIDTH).as(String.class);
    List<? extends Entity> variables = cell.getSource().get(ENTITY_VARIABLE);
    List<? extends Entity> geom = cell.getSource().get(null);
    if (target != null && expression != null) {
        if (html)
            expression = "<pre>" + expression + "</pre>";
        String explanation = MessageFormat.format(getMessage("main", locale), formatEntity(geom.get(0), html, true, locale), formatEntity(target, html, true, locale), expression);
        if (html)
            explanation = explanation.replaceAll("\n", "<br />");
        if (html) {
            Map<String, String> varToProperty = variables.stream().collect(Collectors.toMap(entity -> {
                return getEntityNameWithoutCondition(entity);
            }, entity -> {
                return formatEntity(entity, true, false, locale);
            }));
            explanation += buildReplacementTable(varToProperty, locale);
        }
        return explanation;
    }
    return null;
}
Also used : List(java.util.List) Cell(eu.esdihumboldt.hale.common.align.model.Cell) Locale(java.util.Locale) Map(java.util.Map) ServiceProvider(eu.esdihumboldt.hale.common.core.service.ServiceProvider) Entity(eu.esdihumboldt.hale.common.align.model.Entity) AbstractCellExplanation(eu.esdihumboldt.hale.common.align.model.impl.AbstractCellExplanation) Collectors(java.util.stream.Collectors) CellUtil(eu.esdihumboldt.hale.common.align.model.CellUtil) MessageFormat(java.text.MessageFormat) Entity(eu.esdihumboldt.hale.common.align.model.Entity)

Aggregations

Cell (eu.esdihumboldt.hale.common.align.model.Cell)123 ArrayList (java.util.ArrayList)33 MutableCell (eu.esdihumboldt.hale.common.align.model.MutableCell)28 ParameterValue (eu.esdihumboldt.hale.common.align.model.ParameterValue)28 Test (org.junit.Test)27 Entity (eu.esdihumboldt.hale.common.align.model.Entity)24 DefaultCell (eu.esdihumboldt.hale.common.align.model.impl.DefaultCell)24 EntityDefinition (eu.esdihumboldt.hale.common.align.model.EntityDefinition)18 BaseAlignmentCell (eu.esdihumboldt.hale.common.align.model.BaseAlignmentCell)16 TypeEntityDefinition (eu.esdihumboldt.hale.common.align.model.impl.TypeEntityDefinition)16 AlignmentService (eu.esdihumboldt.hale.ui.service.align.AlignmentService)16 TypeDefinition (eu.esdihumboldt.hale.common.schema.model.TypeDefinition)15 Alignment (eu.esdihumboldt.hale.common.align.model.Alignment)13 HashSet (java.util.HashSet)13 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)12 Type (eu.esdihumboldt.hale.common.align.model.Type)11 List (java.util.List)11 ModifiableCell (eu.esdihumboldt.hale.common.align.model.ModifiableCell)9 PropertyEntityDefinition (eu.esdihumboldt.hale.common.align.model.impl.PropertyEntityDefinition)9 Property (eu.esdihumboldt.hale.common.align.model.Property)8