use of org.eclipse.mylyn.internal.tasks.ui.actions.CommentActionGroup in project linuxtools by eclipse.
the class OSIOWorkitemLinkAttributeEditor method createControl.
@Override
public void createControl(Composite parent, FormToolkit toolkit) {
initialize();
selectionProvider = new SelectionProviderAdapter();
actionGroup = new CommentActionGroup();
MenuManager menuManager = new MenuManager();
menuManager.setRemoveAllWhenShown(true);
menuManager.addMenuListener(new IMenuListener() {
public void menuAboutToShow(IMenuManager manager) {
// get comment and add reply action as first item in the menu
ISelection selection = selectionProvider.getSelection();
if (selection instanceof IStructuredSelection && !selection.isEmpty()) {
ReplyToCommentAction replyAction = new ReplyToCommentAction(currentViewer);
manager.add(replyAction);
}
actionGroup.setContext(new ActionContext(selectionProvider.getSelection()));
actionGroup.fillContextMenu(manager);
if (currentViewer != null && currentViewer.getEditor() instanceof RichTextAttributeEditor) {
RichTextAttributeEditor editor = (RichTextAttributeEditor) currentViewer.getEditor();
if (editor.getViewSourceAction().isEnabled()) {
// $NON-NLS-1$
manager.add(new Separator("planning"));
manager.add(editor.getViewSourceAction());
}
}
}
});
getTaskEditorPage().getEditorSite().registerContextMenu(ID_POPUP_MENU, menuManager, selectionProvider, false);
commentMenu = menuManager.createContextMenu(parent);
section = createSection(parent, toolkit, hasIncoming);
// $NON-NLS-1$ //$NON-NLS-2$
section.setText(section.getText() + " (" + commentAttributes.size() + ")");
if (commentAttributes.isEmpty()) {
section.setEnabled(false);
} else {
if (hasIncoming) {
expandSection(toolkit, section);
} else {
section.addExpansionListener(new ExpansionAdapter() {
@Override
public void expansionStateChanged(ExpansionEvent event) {
if (section.getClient() == null) {
try {
expandAllInProgress = true;
getTaskEditorPage().setReflow(false);
expandSection(toolkit, section);
} finally {
expandAllInProgress = false;
getTaskEditorPage().setReflow(true);
}
reflow();
}
}
});
}
}
setSection(toolkit, section);
}
Aggregations