Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » Direct Edit with copy/paste
Direct Edit with copy/paste [message #1005764] Mon, 28 January 2013 16:23 Go to next message
ModelGeek Mising name is currently offline ModelGeek Mising nameFriend
Messages: 529
Registered: June 2011
Senior Member
Hi,

There is a GEF editpart having direct edit working on label and direct edit is working fine but cut/copy/paste is not available for direct editing . I would like to have cut/copy/paste actions available for direct editing as well.

any idea?

Cheers,
Re: Direct Edit with copy/paste [message #1005912 is a reply to message #1005764] Tue, 29 January 2013 09:52 Go to previous messageGo to next message
Jan Krakora is currently offline Jan KrakoraFriend
Messages: 477
Registered: December 2009
Location: Prague
Senior Member
Hi, when I use direct edit, I have cut/copy/paste available as with any SWT's Text widget.
Re: Direct Edit with copy/paste [message #1005983 is a reply to message #1005912] Tue, 29 January 2013 13:23 Go to previous messageGo to next message
ModelGeek Mising name is currently offline ModelGeek Mising nameFriend
Messages: 529
Registered: June 2011
Senior Member
Hi,

I have just realized that during direct edit, if i press ctrl + x(cut) then cut operation for widget is called.

i have
register(ActionFactory.CUT.create(window));
register(ActionFactory.COPY.create(window));
register(ActionFactory.PASTE.create(window));

in my ApplicationActionBarAdvisor's makeActions method. If i remoe this piece of code then cut/copy/paste start working for direct edit's text widget.

Do you know how to solve this?

Thanks!

Cheers,

[Updated on: Tue, 29 January 2013 13:27]

Report message to a moderator

Re: Direct Edit with copy/paste [message #1006014 is a reply to message #1005983] Tue, 29 January 2013 14:46 Go to previous messageGo to next message
Jan Krakora is currently offline Jan KrakoraFriend
Messages: 477
Registered: December 2009
Location: Prague
Senior Member
Could you post here your EditPart class of the EditPart that can be directly edited?
Re: Direct Edit with copy/paste [message #1006015 is a reply to message #1006014] Tue, 29 January 2013 14:55 Go to previous messageGo to next message
Jan Krakora is currently offline Jan KrakoraFriend
Messages: 477
Registered: December 2009
Location: Prague
Senior Member
Basically, it means that those shortcuts triggers the registered retarget actions, but you don't have registered any implementations for that.

You have to use org.eclipse.ui.part.CellEditorActionHandler in your org.eclipse.gef.tools.DirectEditManager.
Take a look at org.eclipse.gef.examples.logicdesigner.edit.LogicLabelEditManager how they do that.
Re: Direct Edit with copy/paste [message #1006016 is a reply to message #1006014] Tue, 29 January 2013 14:58 Go to previous messageGo to next message
ModelGeek Mising name is currently offline ModelGeek Mising nameFriend
Messages: 529
Registered: June 2011
Senior Member
public class MyEditPart extends AbstractPart {


public MyEditPart (Canvas cb) {
super(cb);
}

@Override
public void propertyChange(PropertyChangeEvent evt) {

if (evt.getPropertyName().equals(ModelObject.PROPERTY_NAME)) {
refreshVisuals();
}
}

@Override
protected IFigure createFigure() {
ModelObject Figure fig = new ModelObjectFigure(this);
ModelObject inv = (ModelObject) getModel();
fig.setName(inv.getName());
return fig;
}


@Override
protected void createEditPolicies() {
installEditPolicy(EditPolicy.LAYOUT_ROLE, new ClassLayoutPolicy());
installEditPolicy(EditPolicy.COMPONENT_ROLE, new DeletePolicy());
installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, new NameDirectEditPolicy());

}

@Override
public void performRequest(Request request) {
if(request.getType() == RequestConstants.REQ_DIRECT_EDIT || request.getType() == RequestConstants.REQ_OPEN) {
performDirectEditing();
}
}

private void performDirectEditing() {
Canvas cb = (Canvas) getMainCanvas();
if(cb.isClassInvariantsVisible()) {
Label lbl = ((ModelObjectFigure)getFigure()).getNameLabel();
NameEditManager manager = new NameEditManager(this, TextCellEditor.class, new NameEditorLocator(lbl), lbl, ((ModelObject ) getModel()).getName());
manager.show();
}

}


@Override
protected void refreshVisuals() {

}


@Override
public Object getAdapter(Class key) {
return Platform.getAdapterManager().getAdapter(getModel(), key);
}

public void setVisible(boolean visible) {
getFigure().setVisible(visible);
}
}
Re: Direct Edit with copy/paste [message #1006018 is a reply to message #1006016] Tue, 29 January 2013 14:59 Go to previous messageGo to next message
Jan Krakora is currently offline Jan KrakoraFriend
Messages: 477
Registered: December 2009
Location: Prague
Senior Member
See my post above
Re: Direct Edit with copy/paste [message #1006029 is a reply to message #1006015] Tue, 29 January 2013 15:30 Go to previous message
ModelGeek Mising name is currently offline ModelGeek Mising nameFriend
Messages: 529
Registered: June 2011
Senior Member
thanks!
Previous Topic:Troubles with layouts
Next Topic:How initially scroll when editor opens?
Goto Forum:
  


Current Time: Fri Nov 21 20:54:24 GMT 2014

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

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