Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [gef-dev] delete action

Hi
 
you will have to add an COMPONENT_ROLE edit policy to your editpart in createEditPolicies().
 
    "installEditPolicy(EditPolicy.COMPONENT_ROLE,new IndividualNodeEditPolicy());"
 
public class IndividualNodeEditPolicy extends ComponentEditPolicy {
 
    protected Command createDeleteCommand(GroupRequest deleteRequest) {
        Command deleteCommand = new DeleteElementCommand((BaseDataModel) (getHost().getParent().getModel()), (ElementModel) (getHost().getModel()));
        return deleteCommand;
    }
 
}
public class DeleteElementCommand extends Command {
  private BaseDataModel baseModel;
  private ElementModel nodeModel;
 
  public DeleteElementCommand(BaseDataModel baseModel, ElementModel model){
    super();
    this.nodeModel = model;
    this.baseModel = baseModel;
  }
 
  public void execute() {
    baseModel.deleteChild(nodeModel);
  }
 
  public boolean canUndo() {
    return false;
  }
 
}
The above example demonstrates that.
 
Aditya Bhushan
 
 
----- Original Message -----
From: "jerome lafon" <jerome.lafon@xxxxxxxx>
Sent: Wednesday, June 23, 2004 8:24 PM
Subject: [gef-dev] delete action

Hi,
is somebody knows how to delete an editpart in a graphicalViewer?
I have write:

viewer.setKeyHandler(new GraphicalViewerKeyHandler(viewer)
    .setParent(getCommonKeyHandler()));

protected KeyHandler getCommonKeyHandler() {
  if (sharedKeyHandler == null) {
   sharedKeyHandler = new KeyHandler();
   sharedKeyHandler.put(
    KeyStroke.getPressed(SWT.DEL, 127, 0),
    getActionRegistry().getAction(GEFActionConstants.DELETE));
  }
  return sharedKeyHandler;
 }

but it doesn't work!
thanks


_______________________________________________
gef-dev mailing list
gef-dev@xxxxxxxxxxx
http://dev.eclipse.org/mailman/listinfo/gef-dev


Back to the top