コード例 #1
0
  /**
   * Selects the attachment.
   *
   * @param parent the parent shell.
   * @param currentAttachment the original attachment.
   * @param basicNode the node.
   * @return the selected attachment.
   * @see
   *     net.dependableos.dcase.diagram.ui.AttributeDialog.IAttachmentSelector#selectAttachment(java.lang.String)
   */
  public String selectAttachment(Shell parent, String currentAttachment, BasicNode basicNode) {

    SelectFromWebDialog dialog = new SelectFromWebDialog(parent);
    dialog.setUrl(basicNode.getAttachment());
    // displays the dialog.
    if (dialog.open() == Dialog.OK) {

      return dialog.getUrl();
    }
    return null;
  }
コード例 #2
0
  /**
   * Shows a dialog to select the attachment from web.
   *
   * @param event An event
   * @return the result of the execution.
   * @throws ExecutionException if an exception occurred during execution.
   * @see
   *     org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent)
   */
  public Object execute(ExecutionEvent event) throws ExecutionException {

    // gets the GraphicalEditPart of selected node.
    GraphicalEditPart selectedElement = getSelectedElement(event);

    if (selectedElement != null) {
      // gets the BasicNode object from the GraphicalEditPart.
      BasicNode basicNode = getBasicNode(selectedElement);
      if (basicNode != null) {

        IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindowChecked(event);

        SelectFromWebDialog dialog = new SelectFromWebDialog(window.getShell());
        dialog.setUrl(basicNode.getAttachment());
        // displays the dialog.
        if (dialog.open() == Dialog.OK) {

          String selectedUrl = dialog.getUrl();

          // create the attribute map.
          Map<AttributeType, Object> attributeMap = new HashMap<AttributeType, Object>();
          // sets the attachment to attribute map.
          attributeMap.put(AttributeType.ATTACHMENT, selectedUrl);

          // creates the command to change the attribute.
          TransactionalEditingDomain currentDomain =
              DcaseEditorUtil.getCurrentArgumentEditPart().getEditingDomain();
          ICommand changeCommand =
              new ChangeBasicNodePropertyTransactionCommand(
                  currentDomain, Menus.SelectAttachmentHandler_0, null, basicNode, attributeMap);

          // executes the command to change the attribute.
          selectedElement
              .getDiagramEditDomain()
              .getDiagramCommandStack()
              .execute(new ICommandProxy(changeCommand));
        }
      }
    }
    return null;
  }