Frage

I like to create two figure on a single drag and drop form the palette i.e At a single drag and drop two figures should be created both have separate EditPart and Model class.

Thanks in advance

War es hilfreich?

Lösung

There is multiple ways to make this happen: the easiest is to make you creationFactory return an array or a list of objects. Then, in you

protected Command getCreateCommand(final CreateRequest request) {
   if (request.getNewObject() instanceof List<?>/Object[]) {
     ...
   }
}

or, the other way is to sublcass CreationTool to have a List of creation factories. Then, create a custom request type, for example,

public class MultiCreateRequest extends Request {
    ...    
}

and override getCommand(Request request) dispatching method that it will handle that case:

public Command getCommand(Request request) {
   if (REQ_MULTI_CREATE.equals(request.getType()))
      return getMultiCreateCommand((MultiCreateRequest) request);
}

when subclassing creation tool you should pay you attention to:

Constructor
createTargetRequest() (return MultiCreateRequest)
getCommandName() (return REQ_MULTI_CREATE)
getCreateRequest() (specify)
selectAddedObject(EditPartViewer viewer) (to select all created that way objects)
updateTargetRequest() (specify)

Oh, i've actually came up with the idea, that creation new Tool subclassing TargetingTool is a better idea then subclassing CreationTool. Instead, you can just copy implementation (it's easy actually) and change it as you need.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top