eclipse rcp - Trying to create simple GEF -
i trying create simple automation tool testing.i have followed simple tutorials
on net , created rcp view on eclipse. have tried include simple gef
component on view throws me error saying " not create view: plug-in "geftutorial" unable instantiate class "geftutorial.view"."
here source code
particularly when uncomment creation of
private scrollinggraphicalviewer viewer = new scrollinggraphicalviewer(); private rooteditpart rooteditpart = new scalablefreeformrooteditpart(); private editpartfactory editpartfactory = new simplegefeditpartfactory();
all above statements on view.my view appears back
here source code view.java
package geftutorial; import org.eclipse.jface.viewers.istructuredcontentprovider; import org.eclipse.jface.viewers.itablelabelprovider; import org.eclipse.jface.viewers.labelprovider; import org.eclipse.jface.viewers.tableviewer; import org.eclipse.jface.viewers.viewer; import org.eclipse.swt.swt; import org.eclipse.swt.graphics.color; import org.eclipse.swt.graphics.image; import org.eclipse.swt.widgets.composite; import org.eclipse.ui.isharedimages; import org.eclipse.ui.platformui; import org.eclipse.ui.part.viewpart; import org.eclipse.gef.*; import org.eclipse.gef.editparts.scalablefreeformrooteditpart; import org.eclipse.gef.ui.parts.scrollinggraphicalviewer; public class view extends viewpart { public static final string id = "geftutorial.view"; //use standard viewer draw2d canvas private scrollinggraphicalviewer viewer = new scrollinggraphicalviewer(); //use standard rooteditpart holder other edit parts private rooteditpart rooteditpart = new scalablefreeformrooteditpart(); //custom made editpartfactory, automatically called create //edit // parts model elements private editpartfactory editpartfactory = new simplegefeditpartfactory(); //the model private superwidget model; //private tableviewer viewer; /** * content provider class responsible providing objects * view. can wrap existing objects in adapters or return objects * as-is. these objects may sensitive current input of view, * or ignore , show same content (like task list, * example). */ class viewcontentprovider implements istructuredcontentprovider { public void inputchanged(viewer v, object oldinput, object newinput) { } public void dispose() { } public object[] getelements(object parent) { if (parent instanceof object[]) { return (object[]) parent; } return new object[0]; } } class viewlabelprovider extends labelprovider implements itablelabelprovider { public string getcolumntext(object obj, int index) { return gettext(obj); } public image getcolumnimage(object obj, int index) { return getimage(obj); } public image getimage(object obj) { return platformui.getworkbench().getsharedimages().getimage( isharedimages.img_obj_element); } } /** * callback allow create viewer , initialize * it. */ public void createpartcontrol(composite parent) { /*viewer = new tableviewer(parent, swt.multi | swt.h_scroll | swt.v_scroll); viewer.setcontentprovider(new viewcontentprovider()); viewer.setlabelprovider(new viewlabelprovider()); // provide input contentprovider viewer.setinput(new string[] {"one", "two", "three"}); */ //create dummy model model = new superwidget("model"); model.createdummymodel(); //initialize viewer, 'parent' // enclosing rcp windowframe viewer.createcontrol(parent); viewer.setrooteditpart(rooteditpart); viewer.seteditpartfactory(editpartfactory); //inject model viewer, viewer // traverse model automatically viewer.setcontents(model); //set view's background white viewer.getcontrol().setbackground(new color(null, 255,255,255)); } /** * passing focus request viewer's control. */ public void setfocus() { viewer.getcontrol().setfocus(); } }
can give me clue this? new rcp , gef :(
i'm learning gef, have seen gef editors not viewpart
(views) editors, extending editpart
.
check ongoing gef tutorial here. hope helps.
you can access other gef tutorial eclipse website.
Comments
Post a Comment