Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » Figures not visible
Figures not visible [message #541354] Sun, 20 June 2010 08:10 Go to next message
tei is currently offline tei
Messages: 13
Registered: April 2010
Junior Member
Hi,

I am trying to create an graphical editor with a simple model, a single class stores the type of figure to be displayed. In the createFigure() I return a figure depending on the type in the model. When I open a file with the editoe though, nothing is displayed, there are no error messages logged either.

public class ContentModel {

List _shapes = new ArrayList();

public List getShapes() {
return _shapes;
}

public void setShapes(List shapes) {
_shapes = shapes;
}


public class ShapeModel implements Serializable{

private static final long serialVersionUID = -7303239549506441257L;
private String _type;

public String getType() {
return _type;
}

public void setType(String type) {
_type = type;
}


}


public class ShapesEditPart extends AbstractGraphicalEditPart implements
NodeEditPart {

String RECT_TYPE = "RECTANGLE";
String CIRC_TYPE = "CIRCLE";

/* (non-Javadoc)
* @see org.eclipse.gef.editparts.AbstractGraphicalEditPart#createFi gure()
*/
@Override
protected IFigure createFigure() {
ShapeModel model = (ShapeModel)getModel();
IFigure figure;

if(RECT_TYPE.equals(model.getType())){
figure = new RectangleFigure();
} else {
figure = new Ellipse();
}
figure.setOpaque(true);
return figure;
}
...
}


Thanks in advance for your help


Re: Figures not visible [message #543496 is a reply to message #541354] Tue, 29 June 2010 11:09 Go to previous messageGo to next message
Chris  is currently offline Chris
Messages: 44
Registered: April 2010
Member
Do you have a factory in place to create the EditPart from your model and is it registered with your Editor?
Re: Figures not visible [message #544003 is a reply to message #543496] Thu, 01 July 2010 06:17 Go to previous messageGo to next message
tei is currently offline tei
Messages: 13
Registered: April 2010
Junior Member
yes, I do have a factory for creating the editparts with the following methods


public EditPart createEditPart(EditPart arg0, Object arg1) {


System.out.println("createEditPartinvoked...");

EditPart editPart = getEditPart(arg1);

editPart.setModel(arg1);
return editPart;
}

private EditPart getEditPart(Object model) {
if(model instanceof ContentModel){
return new ContentsEditPart();
}
return new ShapesEditPart();
}


This factory is also registered in the Editor using


@Override
protected void configureGraphicalViewer() {
super.configureGraphicalViewer();
getGraphicalViewer().setEditPartFactory(new SandboxEditPartFactory());
getGraphicalViewer().setRootEditPart(new FreeformGraphicalRootEditPart());
}
Re: Figures not visible [message #544276 is a reply to message #544003] Fri, 02 July 2010 04:25 Go to previous messageGo to next message
Madhu Samuel is currently offline Madhu Samuel
Messages: 199
Registered: July 2009
Senior Member
On 01-07-2010 15:47, tei wrote:
> yes, I do have a factory for creating the editparts with the following
> methods
>
>
> public EditPart createEditPart(EditPart arg0, Object arg1) {
>
>
> System.out.println("createEditPartinvoked...");
>
> EditPart editPart = getEditPart(arg1);
>
> editPart.setModel(arg1);
> return editPart;
> }
>
> private EditPart getEditPart(Object model) {
> if(model instanceof ContentModel){
> return new ContentsEditPart();
> }
> return new ShapesEditPart();
> }
>
>
> This factory is also registered in the Editor using
>
>
> @Override
> protected void configureGraphicalViewer() {
> super.configureGraphicalViewer();
> getGraphicalViewer().setEditPartFactory(new SandboxEditPartFactory());
> getGraphicalViewer().setRootEditPart(new FreeformGraphicalRootEditPart());
> }
>
where do you set the model to the graphicalViewer? Could you please post
the entire code?


Re: Figures not visible [message #638697 is a reply to message #544276] Fri, 12 November 2010 04:17 Go to previous message
Girish is currently offline Girish
Messages: 4
Registered: June 2010
Junior Member
I think you need to just set some size for it

figure.setPreferredSize(100,100);
also set the some background color

hope it will work

Previous Topic:How/when to show popup menu on connection creation?
Next Topic:Implementing Connections in Gef without having a Palette
Goto Forum:
  


Current Time: Wed Aug 20 14:41:18 EDT 2014

Powered by FUDForum. Page generated in 0.03975 seconds