Methods Summary |
---|
private void | contributeToActionBars()
IActionBars bars = getViewSite().getActionBars();
fillLocalPullDown(bars.getMenuManager());
fillLocalToolBar(bars.getToolBarManager());
|
public void | createPartControl(org.eclipse.swt.widgets.Composite parent)This is a callback that will allow us
to create the viewer and initialize it.
viewer = new TreeViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
drillDownAdapter = new DrillDownAdapter(viewer);
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());
drillDownAdapter.addNavigationActions(manager);
// Other plug-ins can contribute there actions here
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);
manager.add(new Separator());
drillDownAdapter.addNavigationActions(manager);
|
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() {
showMessage("You selected Action 1");
}
};
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("You selected Action 2");
}
};
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()Passing the focus request to the viewer's control.
viewer.getControl().setFocus();
|
private void | showMessage(java.lang.String message)
MessageDialog.openInformation(
viewer.getControl().getShell(),
"Item View",
message);
|