Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » use a tool according to the figure selected
use a tool according to the figure selected [message #233071] Tue, 17 April 2007 02:36 Go to next message
Sun Seng David TAN is currently offline Sun Seng David TANFriend
Messages: 12
Registered: July 2009
Junior Member
Hi there
Is there a way to select a tool according to the figure hovered over ?

In my case, i have a palette less editor, and i'd like to use the
selection tool when the child figures are hovered over and the creation
tool when the container figure is hovered over.

Thx for your help :D
Re: use a tool according to the figure selected [message #233082 is a reply to message #233071] Tue, 17 April 2007 06:28 Go to previous messageGo to next message
Sun Seng David TAN is currently offline Sun Seng David TANFriend
Messages: 12
Registered: July 2009
Junior Member
I don't know if it is clean or not, but i managed to do it (editpart of
the child figure ):


protected IFigure createFigure() {
Booking booking = getBookingModel();
BookingFigure fig = (BookingFigure) FigureFactory.createBookingFigure();
fig.setEvent(booking.getStart().equals(booking.getEnd()));
// getViewer().getEditDomain()
fig.addMouseMotionListener(new MouseMotionListener(){
@Override
public void mouseDragged(MouseEvent me) { }
@Override
public void mouseEntered(MouseEvent me) {
System.err.println("mouse entered");
getViewer().getEditDomain().loadDefaultTool();
}
@Override
public void mouseExited(MouseEvent me) {
System.err.println("mouse exit");
getViewer().getEditDomain().setActiveTool(new CreationTool(new
CreationFactory(){
public Object getNewObject() {
return null;
}
public Object getObjectType() {
return null;
}

}));
}
@Override
public void mouseHover(MouseEvent me) { }
@Override
public void mouseMoved(MouseEvent me) { }
});
return fig;

}





Sun Seng David TAN wrote:
> Hi there
> Is there a way to select a tool according to the figure hovered over ?
>
> In my case, i have a palette less editor, and i'd like to use the
> selection tool when the child figures are hovered over and the creation
> tool when the container figure is hovered over.
>
> Thx for your help :D
Re: use a tool according to the figure selected [message #233089 is a reply to message #233082] Tue, 17 April 2007 06:43 Go to previous messageGo to next message
Sun Seng David TAN is currently offline Sun Seng David TANFriend
Messages: 12
Registered: July 2009
Junior Member
Finally im not so happy with: cant resize the child because bounds are
considered out of the figure. If anyone have an idea :S

Sun Seng David TAN wrote:
> I don't know if it is clean or not, but i managed to do it (editpart of
> the child figure ):
>
>
> protected IFigure createFigure() {
> Booking booking = getBookingModel();
> BookingFigure fig = (BookingFigure)
> FigureFactory.createBookingFigure();
> fig.setEvent(booking.getStart().equals(booking.getEnd()));
> // getViewer().getEditDomain()
> fig.addMouseMotionListener(new MouseMotionListener(){
> @Override
> public void mouseDragged(MouseEvent me) { }
> @Override
> public void mouseEntered(MouseEvent me) {
> System.err.println("mouse entered");
> getViewer().getEditDomain().loadDefaultTool();
> }
> @Override
> public void mouseExited(MouseEvent me) {
> System.err.println("mouse exit");
> getViewer().getEditDomain().setActiveTool(new
> CreationTool(new CreationFactory(){
> public Object getNewObject() {
> return null;
> }
> public Object getObjectType() {
> return null;
> }
>
> }));
> }
> @Override
> public void mouseHover(MouseEvent me) { }
> @Override
> public void mouseMoved(MouseEvent me) { }
> });
> return fig;
>
> }
>
>
>
>
>
> Sun Seng David TAN wrote:
>> Hi there
>> Is there a way to select a tool according to the figure hovered over ?
>>
>> In my case, i have a palette less editor, and i'd like to use the
>> selection tool when the child figures are hovered over and the
>> creation tool when the container figure is hovered over.
>>
>> Thx for your help :D
Re: use a tool according to the figure selected [message #233096 is a reply to message #233082] Tue, 17 April 2007 07:13 Go to previous message
Sun Seng David TAN is currently offline Sun Seng David TANFriend
Messages: 12
Registered: July 2009
Junior Member
finally i managed to get it working working :
i added the same kind of listener to the container figure, im still not
sure if it s a clean way to do it. especially the way im creating the
creationtool. Is there something like a bundle or factory to get a
already created Creation tool ?

calendarFigure.addMouseMotionListener(new MouseMotionListener() {
@Override
public void mouseDragged(org.eclipse.draw2d.MouseEvent me) {
}
@Override
public void mouseEntered(org.eclipse.draw2d.MouseEvent me) {
getViewer().getEditDomain().setActiveTool(
new CreationTool(new CreationFactory() {
public Object getNewObject() {
return null;
}
public Object getObjectType() {
return null;
}
}));
}
@Override
public void mouseExited(org.eclipse.draw2d.MouseEvent me) {
}
@Override
public void mouseHover(org.eclipse.draw2d.MouseEvent me) {
}
@Override
public void mouseMoved(org.eclipse.draw2d.MouseEvent me) {
}
});






and





protected IFigure createFigure() {
Booking booking = getBookingModel();
BookingFigure fig = (BookingFigure) FigureFactory.createBookingFigure();
fig.addMouseMotionListener(new MouseMotionListener(){
@Override
public void mouseDragged(MouseEvent me) { }
@Override
public void mouseEntered(MouseEvent me) {
System.err.println("mouse entered");
getViewer().getEditDomain().loadDefaultTool();
}
@Override
public void mouseExited(MouseEvent me) {
System.err.println("mouse exit");
// getViewer().getEditDomain().setActiveTool(new CreationTool(new
CreationFactory(){
// public Object getNewObject() {
// return null;
// }
// public Object getObjectType() {
// return null;
// }
//
// }));
}
@Override
public void mouseHover(MouseEvent me) { }
@Override
public void mouseMoved(MouseEvent me) { }
});
return fig;
}
Previous Topic:Draw2d - Html
Next Topic:EditPart selection feedback
Goto Forum:
  


Current Time: Wed Sep 28 17:19:55 GMT 2022

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

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

Back to the top