Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » Invoking a Direct Edit Action
Invoking a Direct Edit Action [message #647961] Mon, 10 January 2011 15:49 Go to next message
Andy Mising name is currently offline Andy Mising nameFriend
Messages: 4
Registered: August 2010
Location: Minnesota
Junior Member
Having this code put into subclassed Editor's getCommonKeyHandler() method:

sharedKeyHandler.put(KeyStroke.getPressed(SWT.F2, 0),					getActionRegistry().getAction(GEFActionConstants.DIRECT_EDIT));


The F2 key didn't go into my CellEditor for a Label Figure.

I want to be able to edit a label in my editor pressing "Enter" or quickly double clicking twice on the EditPart. While currently an unselected part gets clicked once for selection, and delay a second mouse click.

How would I do this? I was puzzled on how to change certain editing behaviors, which may all lay in the layout policies.

Thankful for any help.
Andy Anfilofieff.
Re: Invoking a Direct Edit Action [message #648978 is a reply to message #647961] Mon, 17 January 2011 03:33 Go to previous messageGo to next message
Andy Mising name is currently offline Andy Mising nameFriend
Messages: 4
Registered: August 2010
Location: Minnesota
Junior Member
I was able to get a double click to edit a cell.

	public void performRequest(Request request) {
		if(request.getType() == RequestConstants.REQ_DIRECT_EDIT)
			performDirectEdit();
		if(request.getType() == RequestConstants.REQ_OPEN)
			performDirectEdit();
	}


But I was unable to use the ENTER key to edit a cell.
Re: Invoking a Direct Edit Action [message #649874 is a reply to message #648978] Thu, 20 January 2011 19:56 Go to previous messageGo to next message
Devi Vara Prasad Bandaru is currently offline Devi Vara Prasad BandaruFriend
Messages: 98
Registered: March 2010
Location: Hyderabad
Member

Hi Andy ,

Try using the below code in your graphical editor

	protected void configureGraphicalViewer() {
		super.configureGraphicalViewer();
		GraphicalViewer viewer = getGraphicalViewer();
		viewer.setKeyHandler(new GraphicalViewerKeyHandler(viewer) {
			@Override
			public boolean keyPressed(KeyEvent event) {

				EditPart editPart = (EditPart) ((IStructuredSelection) getGraphicalViewer().getSelection()).getFirstElement();
				// Open the CPS if enter is pressed
				if (event.keyCode == SWT.KEYPAD_CR || event.character == '\r') {
					editPart.performRequest(new Request(RequestConstants.REQ_DIRECT_EDIT));
				}

				return super.keyPressed(event);
			}
		});
}





Re: Invoking a Direct Edit Action [message #650662 is a reply to message #649874] Tue, 25 January 2011 21:57 Go to previous message
Andy Mising name is currently offline Andy Mising nameFriend
Messages: 4
Registered: August 2010
Location: Minnesota
Junior Member
Yes, everything works the way I wanted it to.

Thank you a bunch and appreciated. Very Happy
Previous Topic:Changing the size of a EditPart without affecting the Figure
Next Topic:Lines in Figure objects are not straight lines but having jerks
Goto Forum:
  


Current Time: Fri Dec 19 08:04:33 GMT 2014

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

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