コード例 #1
0
 /**
  * Constructor for use within the package so this handler can be used by other handlers.
  *
  * @param editor
  * @param editingDomain
  * @param resource
  * @param softPkg
  */
 public RemovePortsHandler(
     final EditingDomain editingDomain, final Resource resource, final SoftPkg softPkg) {
   this.editingDomain = editingDomain;
   this.resource = resource;
   this.softPkg = softPkg;
   this.interfaceMap = PortsHandlerUtil.getInterfaceMap(this.softPkg);
 }
コード例 #2
0
  /** {@inheritDoc} */
  @Override
  public Object execute(final ExecutionEvent event) throws ExecutionException {
    final ISelection selection =
        HandlerUtil.getActiveWorkbenchWindow(event).getSelectionService().getSelection();
    final ComponentEditor editor = (ComponentEditor) HandlerUtil.getActiveEditor(event);
    this.editingDomain = editor.getEditingDomain();
    this.resource = editor.getMainResource();
    this.softPkg = ModelUtil.getSoftPkg(this.resource);
    this.interfaceMap = PortsHandlerUtil.getInterfaceMap(this.softPkg);
    final List<Object> ports = Arrays.asList(((IStructuredSelection) selection).toArray());

    Command command = this.createRemovePortCommand(ports, new HashSet<String>());
    this.editingDomain.getCommandStack().execute(command);

    return null;
  }