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();
}
}
}
}
}
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);
}
}
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
}
}
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++);
}
}
}
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;
}
Aggregations