Tak ja sem taky neco hodim
Jak do promene selection v Commands expressions protlacit vyber ve vasem vlastnim view:
Ukazeme si to na kontextovem menu v nasem view. Jednoduse chceme aby se v menu objevovali polozky na zaklade vybrane polozky v TreeViewer.
public class NaseView extends ViewPart {
public static final String ID = "Ukazka.naseView";
private TreeViewer tree;
public void createPartControl(Composite parent) {
tree = new TreeViewer(parent);
NaseViewContentProvider contentProvider = new NaseViewContentProvider();
tree.setContentProvider(contentProvider);
tree.setLabelProvider(new SystemyViewLabelProvider());
tree.setInput(NasModel.getPolozky());
createContextMenu();
}
private void createContextMenu() {
MenuManager mgr = new MenuManager("NaseMenu");
mgr.setRemoveAllWhenShown(true);
Menu menu = mgr.createContextMenu(tree.getControl());
tree.getControl().setMenu(menu);
getSite().registerContextMenu(mgr, tree);
getSite().setSelectionProvider(tree);
}
public void setFocus() {
tree.getControl().setFocus();
}
}
Dulezita je metoda createContextMenu a obzvlaste jeji posledni radek.
Jeho zavolanim rikame, ze selection tohoto view pochazi z TreeViewer, ktery jsme predali jako parametr metode setSelectionProvider().
Pricemz locationURI vaseho menu pro pouziti v plugin.xml je "popup:Ukazka.naseView"
dekuji za pozornost :-)