本文整理汇总了Java中org.eclipse.swt.widgets.Control.setMenu方法的典型用法代码示例。如果您正苦于以下问题:Java Control.setMenu方法的具体用法?Java Control.setMenu怎么用?Java Control.setMenu使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.swt.widgets.Control
的用法示例。
在下文中一共展示了Control.setMenu方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: hookContextMenu
import org.eclipse.swt.widgets.Control; //导入方法依赖的package包/类
protected void hookContextMenu ( final Control control, final ISelectionProvider selectionProvider, final IViewSite viewSite )
{
final MenuManager menuMgr = new MenuManager ( "#PopupMenu" ); //$NON-NLS-1$
menuMgr.setRemoveAllWhenShown ( true );
menuMgr.addMenuListener ( new IMenuListener () {
@Override
public void menuAboutToShow ( final IMenuManager manager )
{
fillContextMenu ( manager );
}
} );
final Menu menu = menuMgr.createContextMenu ( control );
control.setMenu ( menu );
viewSite.registerContextMenu ( menuMgr, selectionProvider );
}
示例2: registerContextMenu
import org.eclipse.swt.widgets.Control; //导入方法依赖的package包/类
private void registerContextMenu() {
final MenuManager contextMenu = new MenuManager();
contextMenu.setRemoveAllWhenShown(true);
this.getSite().registerContextMenu(contextMenu, ContextualView.treeViewer);
// Add in the entries for all markers views if this has a different if
if (!this.getSite().getId().equals(ContextualView.MARKERS_ID)) {
this.getSite().registerContextMenu(ContextualView.MARKERS_ID, contextMenu, ContextualView.treeViewer);
}
final Control control = ContextualView.treeViewer.getControl();
final Menu menu = contextMenu.createContextMenu(control);
control.setMenu(menu);
}
示例3: registerContextMenu
import org.eclipse.swt.widgets.Control; //导入方法依赖的package包/类
private void registerContextMenu() {
final MenuManager contextMenu = new MenuManager();
contextMenu.setRemoveAllWhenShown(true);
this.getSite().registerContextMenu(contextMenu, this.treeViewer);
// Add in the entries for all markers views if this has a different if
if (!this.getSite().getId().equals(MARKERS_ID)) {
this.getSite().registerContextMenu(MARKERS_ID, contextMenu, this.treeViewer);
}
final Control control = this.treeViewer.getControl();
final Menu menu = contextMenu.createContextMenu(control);
control.setMenu(menu);
}
示例4: createPartControl
import org.eclipse.swt.widgets.Control; //导入方法依赖的package包/类
@Override
public void createPartControl(Composite parent) {
FillLayout fillLayout = new FillLayout(SWT.VERTICAL);
fillLayout.marginHeight = 5;
fillLayout.marginWidth = 5;
parent.setLayout(fillLayout);
// main container
container = new Composite(parent, SWT.BORDER);
container.setLayout(new FillLayout());
// create container for stack trace data
Composite stacktraceDataContainer = new Composite(parent, SWT.BORDER);
FormLayout formLayout = new FormLayout();
formLayout.marginHeight = 5;
formLayout.marginWidth = 5;
formLayout.spacing = 5;
stacktraceDataContainer.setLayout(formLayout);
Composite stackLabelContainer = new Composite(stacktraceDataContainer, SWT.NO_SCROLL | SWT.SHADOW_NONE);
stackLabelContainer.setLayout(new GridLayout());
FormData stackLabelFormData = new FormData();
stackLabelFormData.top = new FormAttachment(0);
stackLabelFormData.left = new FormAttachment(0);
stackLabelFormData.right = new FormAttachment(100);
stackLabelFormData.bottom = new FormAttachment(20);
stackLabelContainer.setLayoutData(stackLabelFormData);
Composite stackTraceContainer = new Composite(stacktraceDataContainer, SWT.NO_SCROLL | SWT.SHADOW_NONE);
stackTraceContainer.setLayout(new FillLayout());
FormData stackTraceFormData = new FormData();
stackTraceFormData.top = new FormAttachment(stackLabelContainer);
stackTraceFormData.left = new FormAttachment(0);
stackTraceFormData.right = new FormAttachment(100);
stackTraceFormData.bottom = new FormAttachment(100);
stackTraceContainer.setLayoutData(stackTraceFormData);
// Create viewer for test tree in main container
testTreeViewer = new TreeViewer(container);
testTreeViewer.setContentProvider(new XpectContentProvider());
testTreeViewer.setLabelProvider(new XpectLabelProvider(this.testsExecutionStatus));
testTreeViewer.setInput(null);
// create stack trace label
stacktraceLabel = new Label(stackLabelContainer, SWT.SHADOW_OUT);
FontData fontData = stacktraceLabel.getFont().getFontData()[0];
Display display = Display.getCurrent();
// may be null if outside the UI thread
if (display == null)
display = Display.getDefault();
Font font = new Font(display, new FontData(fontData.getName(), fontData
.getHeight(), SWT.BOLD));
// Make stack trace label bold
stacktraceLabel.setFont(font);
stacktraceLabel.setText(NO_TRACE_MSG);
// create stack trace console
MessageConsole messageConsole = new MessageConsole("trace", null);
stacktraceConsole = new TraceConsole(messageConsole);
stacktraceConsoleViewer = new TextConsoleViewer(stackTraceContainer, messageConsole);
// context menu
getSite().setSelectionProvider(testTreeViewer);
MenuManager contextMenu = new MenuManager();
contextMenu.setRemoveAllWhenShown(true);
getSite().registerContextMenu(contextMenu, testTreeViewer);
Control control = testTreeViewer.getControl();
Menu menu = contextMenu.createContextMenu(control);
control.setMenu(menu);
activateContext();
createSelectionActions();
}