use of eu.esdihumboldt.hale.ui.common.graph.figures.CellFigure in project hale by halestudio.
the class CellFigureTaskLabelContribution method contribute.
// private TaskServiceListener taskServiceListener;
@Override
public void contribute(CellFigure figure, Cell cell) {
TaskService taskService = HaleUI.getServiceProvider().getService(TaskService.class);
Collection<ResolvedTask<Cell>> tasks = taskService.getTasks(cell).stream().map(t -> taskService.resolveTask(t)).collect(Collectors.toList());
tasks = tasks.stream().filter(t -> t.isOpen()).collect(Collectors.toList());
if (tasks.isEmpty()) {
return;
}
Label tasksLabel = new Label();
Image tasksImage = null;
tasksImage = CommonSharedImages.getImageRegistry().get(CommonSharedImages.IMG_TASKS);
tasksLabel.setIcon(tasksImage);
tasksLabel.addMouseListener(new MouseListener() {
@Override
public void mouseReleased(MouseEvent me) {
try {
IViewPart part = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView(TaskTreeView.ID);
// the alignment/mapping view
if (part instanceof TaskTreeView) {
((TaskTreeView) part).update(new StructuredSelection(cell));
}
me.consume();
} catch (PartInitException e) {
log.error("Error creating task view", e);
}
}
@Override
public void mousePressed(MouseEvent me) {
// ignore
}
@Override
public void mouseDoubleClicked(MouseEvent me) {
// ignore
}
});
if (tasksImage != null) {
Label priorityTip = new Label(MessageFormat.format("There {0} {1} open tasks for this cell. Please refer to the Tasks view for details.", (tasks.size() == 1) ? "is" : "are", tasks.size()));
tasksLabel.setToolTip(priorityTip);
}
GridData tasksLabelGD = new GridData(GridData.CENTER, GridData.FILL, false, true);
figure.add(tasksLabel, tasksLabelGD);
}
Aggregations