문제

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

도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top