how to invoke viewpart by java code in eclipse plugin -
how can invoke viewpart class on menu command event in eclipse plugin project. want open awt frame inside eclipse plugin using viewpart class that. awt frame should open when user requests it.
i have created menu option , want open awt frame on menu command. have tried make class of viewpart , call did not work. below code of viewpart class
public class labelview extends viewpart { public static composite _parent; private label label; public labelview() { super(); } public void setfocus() { //label.setfocus(); } public void createpartcontrol(composite parent) { _parent=parent; // main composite composite maincomposite = new composite(parent, swt.embedded | swt.no_background); frame awtframe = swt_awt.new_frame(maincomposite); java.awt.panel awtpanel = new java.awt.panel(); awtpanel.setlayout(new java.awt.gridlayout()); awtframe.setlayout(new java.awt.gridlayout()); awtframe.add(awtpanel); } }
to find view use:
iworkbenchpage page = platformui.getworkbench().getactiveworkbenchwindow().getactivepage(); iviewpart view = page.findview("view id");
where "view id" id of view declared in org.eclipse.ui.views
extension point.
if view not open view
findview return null, can open view using:
view = page.showview("view id");
in either case can cast view view class , call method want:
labelview myview = (labelview)view; myview.somemethod(); // todo write method
Comments
Post a Comment