Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » simple gef example, select figure
simple gef example, select figure [message #214423] Mon, 17 April 2006 18:10 Go to next message
Eclipse UserFriend
Originally posted by: some.trash.mails.gmail.com

Hello,

I've been trying to implement the most basic GEF
example I can think of, but I don't know why the
figure is neither selectable nor moveable.

/*
* @(#)AbstractGraphicalEditor.java
*
*/

import org.eclipse.ui.part.EditorPart;

/**
* Provides basic features for graphical editors, like the
* configuration of an EditDomain and GraphicalViewer.
*
*/
public abstract class AbstractGraphicalEditor extends EditorPart {

// Since this class is just some sort of replacement for
// org.eclipse.gef.GraphicalViewer, I've omitted the
// implementation.
}


/*
* @(#)GraphicalEditor.java
*
*/

public class GraphicalEditor extends AbstractGraphicalEditor {

// Every method not provided in this listing has been
// generated by Eclipse.

protected void inititalizeGraphicalViewer() {
super.inititalizeGraphicalViewer();

getGraphicalViewer().setContents(
new ShapeEditPart());
}
}

/*
* @(#)ShapeEditPart.java
*
*/

import org.eclipse.draw2d.ColorConstants;
import org.eclipse.draw2d.Ellipse;
import org.eclipse.draw2d.IFigure;
import org.eclipse.gef.editparts.AbstractGraphicalEditPart;

public class ShapeEditPart extends AbstractGraphicalEditPart {

// Every method not provided in this listing has been
// generated by Eclipse.

protected IFigure createFigure() {
IFigure figure = new Ellipse();
figure.setBackgroundColor(ColorConstants.green);

return figure;
}
}

Although the Ellipse is shown in the editor, it is not the result I
had expected, since it is stretched across the whole editor and is
as I've already explained neither selectable nor moveable.
Screenshot: http://img118.imageshack.us/my.php?image=eclipse4ki.jpg

I've taken a look at several examples but neither of them is
up-to-date (and therefore can't be compiled) or is too complicated.

greetings
Re: simple gef example, select figure [message #214433 is a reply to message #214423] Mon, 17 April 2006 18:16 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: some.trash.mails.gmail.com

Sorry for the unformatted listing:
http://pastebin.com/665505

greetings
Re: simple gef example, select figure [message #214457 is a reply to message #214423] Mon, 17 April 2006 19:13 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: none.us.ibm.com

There is no free visualization for "selected" in GEF. You need to do
something when the part is selected (which it probably is when clicking on
it).

There is no free mechanism for dragging a part. You must tell GEF how you
are dragging your part around.

"tankian" <some.trash.mails@gmail.com> wrote in message
news:c1a56004a2dc8156cd878d9c2731f6e8$1@www.eclipse.org...
> Hello,
>
> I've been trying to implement the most basic GEF
> example I can think of, but I don't know why the
> figure is neither selectable nor moveable.
>
> /*
> * @(#)AbstractGraphicalEditor.java
> *
> */
>
> import org.eclipse.ui.part.EditorPart;
>
> /**
> * Provides basic features for graphical editors, like the * configuration
> of an EditDomain and GraphicalViewer.
> *
> */
> public abstract class AbstractGraphicalEditor extends EditorPart {
>
> // Since this class is just some sort of replacement for //
> org.eclipse.gef.GraphicalViewer, I've omitted the // implementation. }
>
>
> /*
> * @(#)GraphicalEditor.java
> *
> */
>
> public class GraphicalEditor extends AbstractGraphicalEditor {
>
> // Every method not provided in this listing has been // generated
> by Eclipse.
>
> protected void inititalizeGraphicalViewer() {
> super.inititalizeGraphicalViewer();
> getGraphicalViewer().setContents(
> new ShapeEditPart());
> }
> }
>
> /*
> * @(#)ShapeEditPart.java
> *
> */
>
> import org.eclipse.draw2d.ColorConstants;
> import org.eclipse.draw2d.Ellipse;
> import org.eclipse.draw2d.IFigure;
> import org.eclipse.gef.editparts.AbstractGraphicalEditPart;
>
> public class ShapeEditPart extends AbstractGraphicalEditPart {
> // Every method not provided in this listing has been // generated
> by Eclipse.
>
> protected IFigure createFigure() {
> IFigure figure = new Ellipse();
> figure.setBackgroundColor(ColorConstants.green);
> return figure;
> }
> }
>
> Although the Ellipse is shown in the editor, it is not the result I had
> expected, since it is stretched across the whole editor and is
> as I've already explained neither selectable nor moveable.
> Screenshot: http://img118.imageshack.us/my.php?image=eclipse4ki.jpg
>
> I've taken a look at several examples but neither of them is up-to-date
> (and therefore can't be compiled) or is too complicated.
>
> greetings
>
Re: simple gef example, select figure [message #214465 is a reply to message #214457] Mon, 17 April 2006 20:50 Go to previous message
Eclipse UserFriend
Originally posted by: some.trash.mails.gmail.com

Hello,

The only place I can think of where this "something"
has to be done is in a subclass of Figure, like
that:

public void paintFigure(Graphics graphics) {
if (selected) {
// paint selection border ..
}

// normal paint behaviour
}

The shapes example included in the GEF examples uses
plain Draw2d figures and it works properly, so I've
decided to use them also without success.

I've tried to figure out where this logic has to be
placed but I failed to do so. Although I'm ashamed
to ask newbie questions like this one, but I just
need a hint to start, like the appropiate interface
name ..

greetings
tankian

> There is no free visualization for "selected" in GEF. You need to do
> something when the part is selected (which it probably is when clicking on
> it).
>
> There is no free mechanism for dragging a part. You must tell GEF how you
> are dragging your part around.
Previous Topic:Dispose of an image within a Draw2D Label
Next Topic:How to Create an EditPolicy which handles the RequestConstants.REQ_OPEN request?
Goto Forum:
  


Current Time: Tue Apr 23 17:03:42 GMT 2024

Powered by FUDForum. Page generated in 0.03104 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top