private void showAddNewComment() {
    newCommentLayout.clear();
    final TextArea comment = new TextArea();
    comment.setWidth("100%");
    newCommentLayout.add(comment);

    Button ok = new Button(constants.OK());
    Button cancel = new Button(constants.Cancel());

    ok.addClickHandler(
        new ClickHandler() {
          public void onClick(ClickEvent sender) {
            sendNewComment(comment.getText());
          }
        });

    cancel.addClickHandler(
        new ClickHandler() {
          public void onClick(ClickEvent sender) {
            showNewCommentButton();
          }
        });

    HorizontalPanel hp = new HorizontalPanel();
    hp.add(ok);
    hp.add(cancel);

    newCommentLayout.add(hp);

    comment.setFocus(true);
  }
  public WorkspaceManager() {
    PrettyFormLayout form = new PrettyFormLayout();
    form.addHeader(
        GuvnorImages.INSTANCE.WorkspaceManager(),
        new HTML("<b>" + constants.ManageWorkspaces() + "</b>"));
    form.startSection(constants.Workspaces());

    form.addAttribute("", buildDoubleList());

    HorizontalPanel hPanel = new HorizontalPanel();
    Button create = new Button(constants.AddWorkspace());
    create.addClickHandler(
        new ClickHandler() {
          public void onClick(ClickEvent w) {
            WorkspaceEditor newCat =
                new WorkspaceEditor(
                    new Command() {
                      public void execute() {
                        refreshWorkspaceList();
                      }
                    });

            newCat.show();
          }
        });

    Button remove = new Button(constants.DeleteSelectedWorkspace());
    remove.addClickHandler(
        new ClickHandler() {
          public void onClick(ClickEvent w) {
            if (availableWorkspacesListBox.getSelectedIndex() == -1) {
              Window.alert(constants.PleaseSelectAWorkspaceToRemove());
              return;
            }
            removeWorkspace();
          }
        });

    Button updateWorkspace = new Button(constants.UpdateSelectedWorkspace());
    updateWorkspace.addClickHandler(
        new ClickHandler() {
          public void onClick(ClickEvent w) {
            if (availableWorkspacesListBox.getSelectedIndex() == -1) {
              Window.alert(constants.PleaseSelectAWorkspaceToUpdate());
              return;
            }

            updateWorkspace();
          }
        });
    hPanel.add(create);
    hPanel.add(remove);
    hPanel.add(updateWorkspace);

    form.addAttribute("", hPanel);

    form.endSection();
    initWidget(form);
  }
  private void showNewCommentButton() {
    newCommentLayout.clear();

    HorizontalPanel hp = new HorizontalPanel();

    Button createNewComment = new Button(constants.AddADiscussionComment());
    createNewComment.setEnabled(!this.readOnly);
    hp.add(createNewComment);

    if (UserCapabilities.INSTANCE.hasCapability(Capability.SHOW_ADMIN)) {
      Button adminClearAll = new Button(constants.EraseAllComments());
      adminClearAll.setEnabled(!readOnly);
      hp.add(adminClearAll);
      adminClearAll.addClickHandler(
          new ClickHandler() {
            public void onClick(ClickEvent sender) {
              if (Window.confirm(constants.EraseAllCommentsWarning())) {
                assetService.clearAllDiscussionsForAsset(
                    artifact.getUuid(),
                    new GenericCallback<java.lang.Void>() {
                      public void onSuccess(Void v) {
                        updateCommentList(new ArrayList<DiscussionRecord>());
                      }
                    });
              }
            }
          });
    }

    final String feedURL =
        GWT.getModuleBaseURL()
            + "feed/discussion?package="
            + ((Asset) artifact).getMetaData().getModuleName()
            + "&assetName="
            + URL.encode(artifact.getName())
            + "&viewUrl="
            + Util.getSelfURL();
    Image image = new Image(images.feed());
    image.addClickHandler(
        new ClickHandler() {
          public void onClick(ClickEvent arg0) {
            Window.open(feedURL, "_blank", null);
          }
        });
    hp.add(image);

    newCommentLayout.add(hp);

    newCommentLayout.setCellHorizontalAlignment(hp, HasHorizontalAlignment.ALIGN_RIGHT);
    createNewComment.addClickHandler(
        new ClickHandler() {
          public void onClick(ClickEvent sender) {
            showAddNewComment();
          }
        });
  }
Beispiel #4
0
  public VersionBrowser(
      ClientFactory clientFactory, EventBus eventBus, String uuid, boolean isPackage) {
    this.clientFactory = clientFactory;
    this.eventBus = eventBus;
    this.uuid = uuid;
    this.isPackage = isPackage;

    HorizontalPanel wrapper = new HorizontalPanel();

    ClickHandler clickHandler =
        new ClickHandler() {

          public void onClick(ClickEvent event) {
            clickLoadHistory();
          }
        };
    layout = new FlexTable();
    ClickableLabel vh = new ClickableLabel(constants.VersionHistory1(), clickHandler);
    layout.setWidget(0, 0, vh);
    layout.getCellFormatter().setStyleName(0, 0, "metadata-Widget"); // NON-NLS
    FlexCellFormatter formatter = layout.getFlexCellFormatter();
    formatter.setHorizontalAlignment(0, 0, HasHorizontalAlignment.ALIGN_LEFT);

    refresh = new ImageButton(images.refresh());

    refresh.addClickHandler(clickHandler);

    layout.setWidget(0, 1, refresh);
    formatter.setHorizontalAlignment(0, 1, HasHorizontalAlignment.ALIGN_RIGHT);

    wrapper.setStyleName("version-browser-Border");

    wrapper.add(layout);

    layout.setWidth("100%");
    wrapper.setWidth("100%");

    initWidget(wrapper);
  }