Methods Summary |
---|
private void | contributeToActionBars()
IActionBars bars = getViewSite().getActionBars();
fillLocalPullDown(bars.getMenuManager());
fillLocalToolBar(bars.getToolBarManager());
|
public void | createPartControl(org.eclipse.swt.widgets.Composite parent)
viewer = new TableViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
viewer.setContentProvider(new ViewContentProvider());
viewer.setLabelProvider(new ViewLabelProvider());
viewer.setSorter(new NameSorter());
viewer.setInput(ResourcesPlugin.getWorkspace());
makeActions();
hookContextMenu();
hookDoubleClickAction();
contributeToActionBars();
|
private void | fillContextMenu(IMenuManager manager)
manager.add(action1);
manager.add(action2);
manager.add(new Separator("Additions"));
|
private void | fillLocalPullDown(IMenuManager manager)
manager.add(action1);
manager.add(new Separator());
manager.add(action2);
|
private void | fillLocalToolBar(IToolBarManager manager)
manager.add(action1);
manager.add(action2);
|
private void | hookContextMenu()
MenuManager menuMgr = new MenuManager("#PopupMenu");
menuMgr.setRemoveAllWhenShown(true);
menuMgr.addMenuListener(new IMenuListener() {
public void menuAboutToShow(IMenuManager manager) {
SampleView.this.fillContextMenu(manager);
}
});
Menu menu = menuMgr.createContextMenu(viewer.getControl());
viewer.getControl().setMenu(menu);
getSite().registerContextMenu(menuMgr, viewer);
|
private void | hookDoubleClickAction()
viewer.addDoubleClickListener(new IDoubleClickListener() {
public void doubleClick(DoubleClickEvent event) {
doubleClickAction.run();
}
});
|
private void | makeActions()
action1 = new Action() {
public void run() {
ISelection selection = viewer.getSelection();
Object obj = ((IStructuredSelection)selection).getFirstElement();
showMessage("You selected " + obj.toString());
}
};
action1.setText("Action 1");
action1.setToolTipText("Action 1 tooltip");
action1.setImageDescriptor(PlatformUI.getWorkbench().getSharedImages().
getImageDescriptor(ISharedImages.IMG_OBJS_INFO_TSK));
action2 = new Action() {
public void run() {
showMessage("Action 2 executed");
}
};
action2.setText("Action 2");
action2.setToolTipText("Action 2 tooltip");
action2.setImageDescriptor(PlatformUI.getWorkbench().getSharedImages().
getImageDescriptor(ISharedImages.IMG_OBJS_TASK_TSK));
doubleClickAction = new Action() {
public void run() {
ISelection selection = viewer.getSelection();
Object obj = ((IStructuredSelection)selection).getFirstElement();
showMessage("You double-clicked " + obj.toString());
}
};
|
public void | setFocus()
viewer.getControl().setFocus();
|
private void | showMessage(java.lang.String message)
MessageDialog.openInformation(
viewer.getControl().getShell(),
"Sample View",
message);
|