use of org.eclipse.jface.action.GroupMarker in project knime-core by knime.
the class KnimeResourceNavigator method fillContextMenu.
/**
* Fills the context menu with the actions contained in this group and its
* subgroups. Additionally the close project item is removed as not intended
* for the knime projects. Note: Projects which are closed in the default
* navigator are not shown in the knime navigator any more.
*
* @param menu the context menu
*/
@Override
public void fillContextMenu(final IMenuManager menu) {
// fill the menu
super.fillContextMenu(menu);
// remove the close project item
menu.remove(CloseResourceAction.ID);
// items do not have an id
for (IContributionItem item : menu.getItems()) {
if (item instanceof ActionContributionItem) {
ActionContributionItem aItem = (ActionContributionItem) item;
// remove the gointo item
if (aItem.getAction() instanceof GoIntoAction) {
menu.remove(aItem);
} else if (aItem.getAction() instanceof OpenInNewWindowAction) {
menu.remove(aItem);
} else if (aItem.getAction() instanceof CloseUnrelatedProjectsAction) {
menu.remove(aItem);
}
}
}
// move must be our own action (due to workflow locks)
if (menu.find(MoveResourceAction.ID) != null) {
menu.insertBefore(MoveResourceAction.ID, new MoveWorkflowAction(getTreeViewer()));
menu.remove(MoveResourceAction.ID);
}
// remove the default import export actions to store the own one
// that invokes the knime export wizard directly
menu.remove("import");
menu.insertBefore("export", new ImportKnimeWorkflowAction(PlatformUI.getWorkbench().getActiveWorkbenchWindow()));
menu.remove("export");
menu.insertAfter(ImportKnimeWorkflowAction.ID, new ExportKnimeWorkflowAction(PlatformUI.getWorkbench().getActiveWorkbenchWindow()));
String id = ImportKnimeWorkflowAction.ID;
// add an open action which is not listed as the project is normally
// not openable.
menu.insertBefore(id, new Separator());
menu.insertBefore(id, new OpenKnimeProjectAction(this));
menu.insertAfter(ExportKnimeWorkflowAction.ID, new Separator());
menu.insertAfter(ExportKnimeWorkflowAction.ID, new EditMetaInfoAction());
menu.insertAfter(ExportKnimeWorkflowAction.ID, new Separator());
if (NodeExecutionJobManagerPool.getNumberOfJobManagersFactories() > 1) {
menu.insertAfter(ExportKnimeWorkflowAction.ID, new WFShowJobMgrViewAction());
}
menu.insertAfter(ExportKnimeWorkflowAction.ID, new ResetWorkflowAction());
menu.insertAfter(ExportKnimeWorkflowAction.ID, new CancelWorkflowAction());
menu.insertAfter(ExportKnimeWorkflowAction.ID, new ExecuteWorkflowAction());
menu.insertAfter(ExportKnimeWorkflowAction.ID, new ConfigureWorkflowAction());
menu.insertAfter(ExportKnimeWorkflowAction.ID, new Separator());
menu.insertAfter(ExportKnimeWorkflowAction.ID, new OpenCredentialVariablesDialogAction());
menu.insertAfter(ExportKnimeWorkflowAction.ID, new OpenWorkflowVariablesDialogAction());
menu.insertAfter(ExportKnimeWorkflowAction.ID, new Separator());
menu.insertBefore(RefreshAction.ID, new GroupMarker(KNIME_ADDITIONS));
menu.insertBefore(RefreshAction.ID, new Separator());
menu.insertBefore(id, new Separator());
// another bad workaround to replace the first "New" menu manager
// with the "Create New Workflow" action
// store all items, remove all, add the action and then
// add all but the first one
IContributionItem[] items = menu.getItems();
for (IContributionItem item : items) {
menu.remove(item);
}
menu.add(new NewKnimeWorkflowAction(PlatformUI.getWorkbench().getActiveWorkbenchWindow()));
menu.add(new CreateWorkflowGroupAction());
for (int i = 1; i < items.length; i++) {
menu.add(items[i]);
}
}
use of org.eclipse.jface.action.GroupMarker in project org.csstudio.display.builder by kasemir.
the class AxesTableHandler method createContextMenu.
/**
* Add context menu to axes_table
*/
private void createContextMenu() {
final MenuManager menu = new MenuManager();
menu.setRemoveAllWhenShown(true);
menu.addMenuListener(new IMenuListener() {
@Override
public void menuAboutToShow(IMenuManager manager) {
menu.add(new AddAxisAction(operations_manager, model));
if (!axes_table.getSelection().isEmpty())
menu.add(new DeleteAxesAction(operations_manager, axes_table, model));
if (model.getEmptyAxis() != null)
menu.add(new RemoveUnusedAxesAction(operations_manager, model));
menu.add(new Separator());
menu.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS));
}
});
final Table table = axes_table.getTable();
table.setMenu(menu.createContextMenu(table));
}
use of org.eclipse.jface.action.GroupMarker in project webtools.servertools by eclipse.
the class MonitorView method createPartControl.
/**
* @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
*/
public void createPartControl(Composite parent) {
SashForm sashFparent = new SashForm(parent, SWT.VERTICAL);
sashFparent.setBackground(sashFparent.getDisplay().getSystemColor(SWT.COLOR_LIST_BACKGROUND));
GridLayout layout = new GridLayout();
layout.numColumns = 2;
layout.horizontalSpacing = 4;
layout.verticalSpacing = 4;
sashFparent.setLayout(layout);
sashFparent.setLayoutData(new GridData(GridData.FILL_BOTH));
PlatformUI.getWorkbench().getHelpSystem().setHelp(sashFparent, ContextIds.VIEW);
// create tree panel
Composite treePanel = new Composite(sashFparent, SWT.NONE);
layout = new GridLayout();
layout.numColumns = 2;
layout.marginHeight = 0;
layout.marginWidth = 0;
treePanel.setLayout(layout);
GridData data = new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING);
data.heightHint = 110;
data.horizontalSpan = 2;
treePanel.setLayoutData(data);
tree = new Tree(treePanel, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL | SWT.SINGLE);
data = new GridData(GridData.FILL_BOTH);
// data.widthHint = 120;
tree.setLayoutData(data);
treeViewer = new TreeViewer(tree);
contentProvider = new MonitorTreeContentProvider();
treeViewer.setContentProvider(contentProvider);
treeViewer.setInput(MonitorTreeContentProvider.ROOT);
treeViewer.setLabelProvider(new TreeLabelProvider());
PlatformUI.getWorkbench().getHelpSystem().setHelp(tree, ContextIds.VIEW_TREE);
Composite detailsPanel = new Composite(treePanel, SWT.NONE);
layout = new GridLayout();
layout.numColumns = 1;
layout.marginHeight = 2;
layout.marginWidth = 0;
detailsPanel.setLayout(layout);
data = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL);
data.widthHint = 350;
detailsPanel.setLayoutData(data);
final Text detailsTimeText = new Text(detailsPanel, SWT.READ_ONLY);
detailsTimeText.setText(NLS.bind(Messages.viewTime, ""));
detailsTimeText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING));
final Text detailsResponseTimeText = new Text(detailsPanel, SWT.READ_ONLY);
detailsResponseTimeText.setText(NLS.bind(Messages.viewResponseTime, ""));
detailsResponseTimeText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING));
final Text detailsViewTimeText = new Text(detailsPanel, SWT.READ_ONLY);
detailsViewTimeText.setText(NLS.bind(Messages.viewType, ""));
detailsViewTimeText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING));
// create center and right panels
SashForm sashFchild = new SashForm(sashFparent, SWT.HORIZONTAL);
layout = new GridLayout();
layout.numColumns = 2;
layout.horizontalSpacing = 2;
layout.verticalSpacing = 4;
sashFchild.setLayout(layout);
sashFparent.setWeights(new int[] { 30, 70 });
// request panel
Composite request = new Composite(sashFchild, SWT.NONE);
layout = new GridLayout();
layout.marginHeight = 0;
layout.marginWidth = 0;
request.setLayout(layout);
request.setLayoutData(new GridData(GridData.FILL_BOTH));
Composite requestHeader = new Composite(request, SWT.NONE);
layout = new GridLayout();
layout.verticalSpacing = 1;
layout.numColumns = 2;
layout.marginHeight = 0;
layout.marginWidth = 0;
layout.marginLeft = 0;
data = new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING);
requestHeader.setLayout(layout);
requestHeader.setLayoutData(data);
final Label requestViewerComboLabel = new Label(requestHeader, SWT.NONE);
requestViewerComboLabel.setText(NLS.bind(Messages.viewRequestType, ""));
data = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
data.verticalSpan = 1;
data.horizontalIndent = 3;
requestViewerComboLabel.setLayoutData(data);
final Combo requestViewerCombo = new Combo(requestHeader, SWT.DROP_DOWN | SWT.READ_ONLY);
data = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
data.verticalSpan = 1;
requestViewerCombo.setLayoutData(data);
final Text requestLabel = new Text(requestHeader, SWT.READ_ONLY);
requestLabel.setText(NLS.bind(Messages.viewRequest, ""));
data = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
data.verticalSpan = 1;
data.horizontalSpan = 2;
requestLabel.setLayoutData(data);
final Text requestSizeLabel = new Text(requestHeader, SWT.READ_ONLY);
requestSizeLabel.setText(NLS.bind(Messages.viewSize, ""));
data = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
data.verticalSpan = 1;
data.horizontalSpan = 2;
requestSizeLabel.setLayoutData(data);
// response panel
Composite response = new Composite(sashFchild, SWT.NONE);
layout = new GridLayout();
layout.verticalSpacing = 3;
layout.marginHeight = 0;
layout.marginWidth = 0;
response.setLayout(layout);
response.setLayoutData(new GridData(GridData.FILL_BOTH));
Composite responseHeader = new Composite(response, SWT.NONE);
layout = new GridLayout();
layout.verticalSpacing = 1;
layout.numColumns = 2;
layout.marginHeight = 0;
layout.marginWidth = 0;
layout.marginLeft = 0;
data = new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING);
responseHeader.setLayout(layout);
responseHeader.setLayoutData(data);
final Label responseViewerComboLabel = new Label(responseHeader, SWT.NONE);
responseViewerComboLabel.setText(NLS.bind(Messages.viewResponseType, ""));
data = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
data.verticalSpan = 1;
data.horizontalIndent = 3;
responseViewerComboLabel.setLayoutData(data);
final Combo responseViewerCombo = new Combo(responseHeader, SWT.DROP_DOWN | SWT.READ_ONLY);
data = new GridData(GridData.HORIZONTAL_ALIGN_END);
data.verticalSpan = 1;
responseViewerCombo.setLayoutData(data);
final Text responseLabel = new Text(responseHeader, SWT.READ_ONLY);
responseLabel.setText(NLS.bind(Messages.viewResponse, ""));
data = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
data.verticalSpan = 1;
data.horizontalSpan = 2;
requestLabel.setLayoutData(data);
final Text responseSizeLabel = new Text(responseHeader, SWT.READ_ONLY);
responseSizeLabel.setText(NLS.bind(Messages.viewSize, ""));
data = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
data.verticalSpan = 1;
data.horizontalSpan = 2;
responseSizeLabel.setLayoutData(data);
// viewer manager
vm = new ViewerManager(request, response);
requestViewers = vm.getRequestViewers();
responseViewers = vm.getResponseViewers();
// set up the viewer combo boxes
Iterator iterator = requestViewers.iterator();
int ctr = 0;
while (iterator.hasNext()) {
Viewer viewer = (Viewer) iterator.next();
requestViewerCombo.add(viewer.getLabel(), ctr);
if (viewer.getId().equals(DEFAULT_VIEWER)) {
requestViewerCombo.select(ctr);
vm.setRequestViewer(viewer);
}
ctr++;
}
requestViewerCombo.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
Viewer viewer = (Viewer) requestViewers.get(requestViewerCombo.getSelectionIndex());
if (currentRequest != null && viewer != null)
currentRequest.setProperty("request-viewer", viewer.getId());
vm.setRequestViewer(viewer);
}
public void widgetDefaultSelected(SelectionEvent e) {
// ignore
}
});
requestHeader.layout(true);
iterator = responseViewers.iterator();
ctr = 0;
while (iterator.hasNext()) {
Viewer viewer = (Viewer) iterator.next();
responseViewerCombo.add(viewer.getLabel(), ctr);
if (viewer.getId().equals(DEFAULT_VIEWER)) {
responseViewerCombo.select(ctr);
vm.setResponseViewer(viewer);
}
ctr++;
}
responseViewerCombo.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
Viewer viewer = (Viewer) responseViewers.get(responseViewerCombo.getSelectionIndex());
if (currentRequest != null && viewer != null)
currentRequest.setProperty("response-viewer", viewer.getId());
vm.setResponseViewer(viewer);
}
public void widgetDefaultSelected(SelectionEvent e) {
// ignore
}
});
responseHeader.layout(true);
// selection listener
treeViewer.addSelectionChangedListener(new ISelectionChangedListener() {
public void selectionChanged(SelectionChangedEvent event) {
ISelection selection = event.getSelection();
currentRequest = null;
if (selection != null && !selection.isEmpty()) {
StructuredSelection sel = (StructuredSelection) selection;
currentSelection = sel;
Object obj = sel.iterator().next();
if (obj instanceof Request)
currentRequest = (Request) obj;
}
if (currentRequest != null) {
detailsTimeText.setText(NLS.bind(Messages.viewTime, format.format(currentRequest.getDate())));
if (currentRequest.getResponseTime() == -1)
detailsResponseTimeText.setText(NLS.bind(Messages.viewResponseTime, ""));
else {
String time = NLS.bind(Messages.viewResponseTimeFormat, currentRequest.getResponseTime() + "");
detailsResponseTimeText.setText(NLS.bind(Messages.viewResponseTime, time));
}
detailsViewTimeText.setText(NLS.bind(Messages.viewType, currentRequest.getProtocol()));
// request information
requestLabel.setText(NLS.bind(Messages.viewRequest, "localhost:" + currentRequest.getLocalPort()));
requestSizeLabel.setText(getSizeString(currentRequest.getRequest(Request.CONTENT), currentRequest.getRequest(Request.ALL)));
// response information
responseLabel.setText(NLS.bind(Messages.viewResponse, currentRequest.getRemoteHost() + ":" + currentRequest.getRemotePort()));
responseSizeLabel.setText(getSizeString(currentRequest.getResponse(Request.CONTENT), currentRequest.getResponse(Request.ALL)));
vm.setRequest(currentRequest);
Viewer viewer = vm.findViewer((String) currentRequest.getProperty("request-viewer"));
if (viewer == null)
viewer = vm.findViewer(DEFAULT_VIEWER);
if (viewer != null) {
vm.setRequestViewer(viewer);
requestViewerCombo.select(requestViewers.indexOf(viewer));
}
viewer = vm.findViewer((String) currentRequest.getProperty("response-viewer"));
if (viewer == null && currentRequest.getName() != null)
viewer = vm.getDefaultViewer(currentRequest.getName());
if (viewer != null) {
vm.setResponseViewer(viewer);
responseViewerCombo.select(responseViewers.indexOf(viewer));
}
} else {
detailsTimeText.setText(NLS.bind(Messages.viewTime, ""));
detailsResponseTimeText.setText(NLS.bind(Messages.viewResponseTime, ""));
requestLabel.setText(NLS.bind(Messages.viewRequest, ""));
requestSizeLabel.setText(NLS.bind(Messages.viewSize, ""));
responseLabel.setText(NLS.bind(Messages.viewResponse, ""));
responseSizeLabel.setText(NLS.bind(Messages.viewSize, ""));
vm.setRequest(currentRequest);
}
}
});
treeViewer.expandToLevel(2);
// create a menu manager for a context menu
MenuManager menuManager = new MenuManager();
menuManager.setRemoveAllWhenShown(true);
menuManager.addMenuListener(new IMenuListener() {
public void menuAboutToShow(IMenuManager menu) {
menu.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS));
menu.add(preferenceAction);
}
});
// create the menu
Menu menu = menuManager.createContextMenu(treeViewer.getControl());
treeViewer.getControl().setMenu(menu);
// register the menu with the platform
getSite().registerContextMenu(menuManager, treeViewer);
initializeActions();
}
use of org.eclipse.jface.action.GroupMarker in project netxms by netxms.
the class AgentFileManager method fillContextMenu.
/**
* Fill context menu
*
* @param mgr Menu manager
*/
protected void fillContextMenu(final IMenuManager mgr) {
IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
if (selection.isEmpty())
return;
if (selection.size() == 1) {
if (((AgentFile) selection.getFirstElement()).isDirectory()) {
mgr.add(actionUploadFile);
} else {
mgr.add(actionTailFile);
mgr.add(actionShowFile);
}
}
mgr.add(actionDownloadFile);
if (isFolderOnlySelection(selection))
mgr.add(actionCalculateFolderSize);
mgr.add(new Separator());
if (selection.size() == 1) {
if (((AgentFile) selection.getFirstElement()).isDirectory()) {
mgr.add(actionCreateDirectory);
}
mgr.add(actionRename);
}
mgr.add(actionDelete);
mgr.add(new Separator());
if (selection.size() == 1) {
mgr.add(actionCopyFileName);
mgr.add(actionCopyFilePath);
}
mgr.add(new Separator());
mgr.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS));
if ((selection.size() == 1) && ((AgentFile) selection.getFirstElement()).isDirectory()) {
mgr.add(new Separator());
mgr.add(actionRefreshDirectory);
}
}
use of org.eclipse.jface.action.GroupMarker in project netxms by netxms.
the class ServerFileManager method fillContextMenu.
/**
* Fill context menu
*
* @param mgr Menu manager
*/
protected void fillContextMenu(final IMenuManager mgr) {
mgr.add(actionShowFilter);
mgr.add(new Separator());
mgr.add(actionNew);
mgr.add(actionDelete);
mgr.add(new Separator());
mgr.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS));
mgr.add(new Separator());
}
Aggregations