eclipse plugin - Calling a ViewPart(SWT) from void main -
i new eclipse plugin , swt. designing view part functionalities. problem have launch eclipse plugin check. there way can call main(string[] args) method?
i posting sample viewpart code
public class view extends viewpart { public static display display=new display(); public static final string id = "test.view"; //$non-nls-1$ private final formtoolkit toolkit = new formtoolkit(display.getcurrent()); public view() { } /** * create contents of view part. * @param parent */ @override public void createpartcontrol(composite parent) { composite container = toolkit.createcomposite(parent, swt.none); toolkit.paintbordersfor(container); { label lblnewlabel = new label(container, swt.none); lblnewlabel.setbounds(25, 46, 49, 13); toolkit.adapt(lblnewlabel, true, true); lblnewlabel.settext("new label"); } spinner spinner = new spinner(container, swt.border); spinner.setbounds(88, 105, 47, 21); toolkit.adapt(spinner); toolkit.paintbordersfor(spinner); dragsource dragsource = new dragsource(container, dnd.drop_move); droptarget droptarget = new droptarget(container, dnd.drop_move); canvas canvas = new canvas(container, swt.none); canvas.setbounds(94, 161, 174, 148); toolkit.adapt(canvas); toolkit.paintbordersfor(canvas); createactions(); initializetoolbar(); initializemenu(); } public void dispose() { toolkit.dispose(); super.dispose(); } /** * create actions. */ private void createactions() { // create actions } /** * initialize toolbar. */ private void initializetoolbar() { itoolbarmanager tbm = getviewsite().getactionbars().gettoolbarmanager(); } /** * initialize menu. */ private void initializemenu() { imenumanager manager = getviewsite().getactionbars().getmenumanager(); } @override public void setfocus() { // set focus }
can write like
public static void main(string[] args){ view v=new view(); shell shell=new shell(display); v.createpartcontrol(shell); }
not really, eclipse views part of rcp , depend on infrastructure. can create small rcp application shows view instead.
having
public static display display=new display();
in view wrong! theredisplay
time code runs, can accesseddisplay.getdefault()
(on thread) ordisplay.getcurrent()
(on gui thread).
Comments
Post a Comment