Package com.google.gwt.user.client.ui

Examples of com.google.gwt.user.client.ui.DisclosurePanel$ClickableHeader


            SafeHtmlBuilder safeHtmlBuilder = new SafeHtmlBuilder();
            safeHtmlBuilder.appendHtmlConstant("<pre>")
                    .appendEscaped(stackTrace).appendHtmlConstant("</pre>");
            Label stackTraceLabel =
                    new Label(safeHtmlBuilder.toSafeHtml().asString());
            DisclosurePanel stackTracePanel =
                    new DisclosurePanel("More detail:");
            stackTracePanel.getElement().addClassName(APP_LOAD_ERROR_CSS_CLASS);
            stackTracePanel.add(stackTraceLabel);
            layoutPanel.add(stackTracePanel);
        }

        RootPanel.get(CONTENT_DIV_ID).add(layoutPanel);
    }
View Full Code Here


  private void loadCommentWidget(final boolean forceOpen) {
    clear();
    if (permissibleObject.isAllowComments()) {

      String fileName = permissibleObject.getName();
      final DisclosurePanel commentDisclosurePanel = new DisclosurePanel("View comments (" + numComments + ") for " + fileName);

      VerticalPanel commentsPanel = new VerticalPanel();
      commentsPanel.setSpacing(0);
      if (numComments > 0) {
        commentsPanel.setStyleName("commentsPanel");
      }
      commentsPanel.setWidth("100%");

      int renderedComments = 0;
      boolean userCanManage = AuthenticationHandler.getInstance().getUser() != null
          && (AuthenticationHandler.getInstance().getUser().isAdministrator() || AuthenticationHandler.getInstance().getUser()
              .equals(permissibleObject.getOwner()));
      List<PermissibleObject> sortedComments = new ArrayList<PermissibleObject>();
      if (comments != null) {
        sortedComments.addAll(comments);
      }
      if (!flatten) {
        sortedComments = sortComments(sortedComments);
      }

      for (PermissibleObject obj : sortedComments) {
        final Comment comment = (Comment) obj;
        int commentDepth = getCommentDepth(comment);

        int maxDepth = Integer.parseInt(maxCommentDepthListBox.getValue(maxCommentDepthListBox.getSelectedIndex()));
        if (commentDepth >= maxDepth) {
          continue;
        }

        boolean userIsAuthorOfComment = AuthenticationHandler.getInstance().getUser() != null && comment.getAuthor() != null
            && comment.getAuthor().equals(AuthenticationHandler.getInstance().getUser());

        if (userCanManage || userIsAuthorOfComment || comment.isApproved()) {

          FlexTable commentHeaderPanel = new FlexTable();
          commentHeaderPanel.setCellPadding(0);
          commentHeaderPanel.setCellSpacing(0);
          commentHeaderPanel.setStyleName("commentHeader");
          commentHeaderPanel.setWidth("100%");

          String authorLabelString = comment.getAuthor() == null ? comment.getEmail() : comment.getAuthor().getUsername();
          if (comment.getAuthor() != null && comment.getAuthor().getFirstname() != null && !"".equals(comment.getAuthor().getFirstname())) {
            authorLabelString += " (" + comment.getAuthor().getFirstname();
            if (comment.getAuthor() != null && comment.getAuthor().getLastname() != null && !"".equals(comment.getAuthor().getLastname())) {
              authorLabelString += " " + comment.getAuthor().getLastname() + ")";
            } else {
              authorLabelString += ")";
            }
          }

          Image replyCommentImage = new Image();
          replyCommentImage.setResource(BaseImageBundle.images.reply());
          replyCommentImage.setStyleName("commentActionButton");
          replyCommentImage.setTitle("Reply to this comment");
          replyCommentImage.addClickHandler(new ClickHandler() {

            public void onClick(ClickEvent event) {
              replyToComment(comment);
            }
          });
          int columnIndex = 0;
          commentHeaderPanel.setWidget(0, columnIndex, replyCommentImage);
          commentHeaderPanel.getFlexCellFormatter().setHorizontalAlignment(0, columnIndex, HasHorizontalAlignment.ALIGN_LEFT);
          columnIndex++;

          Label authorLabel = new Label(authorLabelString, false);
          commentHeaderPanel.setWidget(0, columnIndex, authorLabel);
          commentHeaderPanel.getFlexCellFormatter().setHorizontalAlignment(0, columnIndex, HasHorizontalAlignment.ALIGN_LEFT);
          columnIndex++;
          commentHeaderPanel.setWidget(0, columnIndex, new Label());
          commentHeaderPanel.getFlexCellFormatter().setWidth(0, columnIndex, "100%");
          commentHeaderPanel.getFlexCellFormatter().setHorizontalAlignment(0, columnIndex, HasHorizontalAlignment.ALIGN_RIGHT);
          columnIndex++;
          Label dateLabel = new Label(new Date(comment.getCommentDate()).toLocaleString(), false);
          commentHeaderPanel.setWidget(0, columnIndex, dateLabel);
          if (!userCanManage && !userIsAuthorOfComment) {
            DOM.setStyleAttribute(dateLabel.getElement(), "padding", "0 5px 0 0");
          }
          commentHeaderPanel.getFlexCellFormatter().setHorizontalAlignment(0, columnIndex, HasHorizontalAlignment.ALIGN_RIGHT);

          columnIndex++;
          if (userCanManage || userIsAuthorOfComment) {
            if (userCanManage && !comment.isApproved()) {
              final Image approveCommentImage = new Image();
              approveCommentImage.setResource(BaseImageBundle.images.approve());
              approveCommentImage.setStyleName("commentActionButton");
              approveCommentImage.setTitle("Approve comment");
              approveCommentImage.addClickHandler(new ClickHandler() {

                public void onClick(ClickEvent event) {
                  workingOnComment = comment;
                  approveComment(comment);
                }
              });
              commentHeaderPanel.setWidget(0, columnIndex, approveCommentImage);
              commentHeaderPanel.getFlexCellFormatter().setHorizontalAlignment(0, columnIndex, HasHorizontalAlignment.ALIGN_RIGHT);
              columnIndex++;
            } else {
              // put 16x16 spacer here for alignment
              final Image approveSpacerImage = new Image();
              approveSpacerImage.setResource(BaseImageBundle.images.empty16x16());
              approveSpacerImage.setStyleName("commentActionButton");
              commentHeaderPanel.setWidget(0, columnIndex, approveSpacerImage);
              commentHeaderPanel.getFlexCellFormatter().setHorizontalAlignment(0, columnIndex, HasHorizontalAlignment.ALIGN_RIGHT);
              columnIndex++;
            }
            Image deleteCommentImage = new Image();
            deleteCommentImage.setResource(BaseImageBundle.images.delete());
            deleteCommentImage.setStyleName("commentActionButton");
            deleteCommentImage.setTitle("Remove comment");
            deleteCommentImage.addClickHandler(new ClickHandler() {

              public void onClick(ClickEvent event) {
                IDialogCallback callback = new IDialogCallback() {

                  public void cancelPressed() {
                  }

                  public void okPressed() {
                    deleteComment(comment);
                  }
                };
                PromptDialogBox dialogBox = new PromptDialogBox("Question", "Yes", null, "No", false, true);
                dialogBox.setContent(new Label("Delete comment by " + (comment.getAuthor() == null ? comment.getEmail() : comment.getAuthor().getUsername())
                    + "?"));
                dialogBox.setCallback(callback);
                dialogBox.center();
              }
            });
            commentHeaderPanel.setWidget(0, columnIndex, deleteCommentImage);
            commentHeaderPanel.getFlexCellFormatter().setHorizontalAlignment(0, columnIndex, HasHorizontalAlignment.ALIGN_RIGHT);
            columnIndex++;
          }

          if (commentDepth > 0) {
            HorizontalPanel commentHeaderPanelWrapper = new HorizontalPanel();
            commentHeaderPanelWrapper.setWidth("100%");
            Label spacerLabel = new Label();
            commentHeaderPanelWrapper.add(spacerLabel);
            if (!flatten) {
              commentHeaderPanelWrapper.setCellWidth(spacerLabel, (commentDepth * 20) + "px");
            }
            commentHeaderPanelWrapper.add(commentHeaderPanel);
            commentsPanel.add(commentHeaderPanelWrapper);
          } else {
            commentsPanel.add(commentHeaderPanel);
          }

          // Label commentLabel = new Label(comment.getId() + " " + comment.getComment(), true);
          Label commentLabel = new Label(comment.getComment(), true);
          if (comment.isApproved()) {
            commentLabel.setStyleName("comment");
          } else if (userCanManage || userIsAuthorOfComment) {
            commentLabel.setStyleName("commentAwaitingApproval");
          }

          if (commentDepth > 0) {
            HorizontalPanel commentHeaderPanelWrapper = new HorizontalPanel();
            commentHeaderPanelWrapper.setWidth("100%");
            Label spacerLabel = new Label();
            commentHeaderPanelWrapper.add(spacerLabel);
            if (!flatten) {
              commentHeaderPanelWrapper.setCellWidth(spacerLabel, (commentDepth * 20) + "px");
            }
            commentHeaderPanelWrapper.add(commentLabel);
            commentsPanel.add(commentHeaderPanelWrapper);
          } else {
            commentsPanel.add(commentLabel);
          }
          renderedComments++;
        }
      }

      final FlexTable mainPanel = new FlexTable();
      mainPanel.setWidth("100%");
      int row = 0;
      if (paginate) {
        mainPanel.setWidget(row, 0, createButtonPanel(mainPanel, forceOpen));
        mainPanel.getCellFormatter().setHorizontalAlignment(row++, 0, HasHorizontalAlignment.ALIGN_LEFT);
      }
      mainPanel.setWidget(row, 0, commentsPanel);
      mainPanel.getCellFormatter().setWidth(row++, 0, "100%");

      commentDisclosurePanel.setContent(mainPanel);
      commentDisclosurePanel.setOpen(renderedComments == 0 || forceOpen);
      commentDisclosurePanel.setWidth("100%");
      add(createCommentPostPanel());
      add(commentDisclosurePanel);
    }
    if (layoutCallback != null) {
      layoutCallback.layoutComplete();
View Full Code Here

    buttonPanel.add(maxCommentDepthListBox);
    return buttonPanel;
  }

  private DisclosurePanel createCommentPostPanel() {
    DisclosurePanel postCommentDisclosurePanel = new DisclosurePanel("Post Comment");
    postCommentDisclosurePanel.setWidth("100%");
    postCommentDisclosurePanel.setOpen(true);
    VerticalPanel postCommentPanel = new VerticalPanel();
    postCommentPanel.setWidth("100%");
    // create text area for comment
    final TextArea commentTextArea = new TextArea();
    commentTextArea.setVisibleLines(3);
    commentTextArea.setWidth("500px");
    // create textfield for email address (if not logged in)
    final TextBox emailTextField = new TextBox();
    emailTextField.setVisibleLength(60);
    // create button panel
    HorizontalPanel buttonPanelWrapper = new HorizontalPanel();
    buttonPanelWrapper.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
    buttonPanelWrapper.setWidth("500px");
    HorizontalPanel buttonPanel = new HorizontalPanel();
    // create buttons
    final Button submitButton = new Button("Submit");
    submitButton.addClickHandler(new ClickHandler() {
      public void onClick(ClickEvent event) {
        String commentStr = commentTextArea.getText();
        if (commentStr == null || "".equals(commentStr.trim())) {
          return;
        }
        Comment comment = new Comment();
        comment.setGlobalRead(true);
        comment.setOwner(permissibleObject.getOwner());
        comment.setAuthor(AuthenticationHandler.getInstance().getUser());
        comment.setComment(commentStr);
        comment.setParent(permissibleObject);
        comment.setEmail(emailTextField.getText());
        submitButton.setEnabled(false);
        submitComment(comment);
      }
    });
    final Button clearButton = new Button("Clear");
    clearButton.addClickHandler(new ClickHandler() {
      public void onClick(ClickEvent event) {
        commentTextArea.setText("");
        submitButton.setEnabled(true);
      }
    });
    // add buttons
    buttonPanel.add(clearButton);
    buttonPanel.add(submitButton);
    buttonPanelWrapper.add(buttonPanel);
    // add panels
    if (AuthenticationHandler.getInstance().getUser() == null) {
      postCommentPanel.add(new Label("Email:"));
      postCommentPanel.add(emailTextField);
    }
    postCommentPanel.add(new Label("Comment:"));
    postCommentPanel.add(commentTextArea);
    postCommentPanel.add(buttonPanelWrapper);
    postCommentDisclosurePanel.setContent(postCommentPanel);
    return postCommentDisclosurePanel;
  }
View Full Code Here

public class DisclosurePanelTest extends GwtTestTest {

   @Test
   public void style() {
      // Arrange
      DisclosurePanel dp = new DisclosurePanel();
      // Pre-Assert
      assertEquals("gwt-DisclosurePanel gwt-DisclosurePanel-closed", dp.getStyleName());

      // Act
      dp.setOpen(true);

      // Assert
      assertEquals("gwt-DisclosurePanel gwt-DisclosurePanel-open", dp.getStyleName());
   }
View Full Code Here

   }

   @Test
   public void title() {
      // Arrange
      DisclosurePanel dp = new DisclosurePanel();

      // Act
      dp.setTitle("title");

      // Assert
      assertEquals("title", dp.getTitle());
   }
View Full Code Here

   }

   @Test
   public void visible() {
      // Arrange
      DisclosurePanel dp = new DisclosurePanel();
      // Pre-Assert
      assertEquals(true, dp.isVisible());

      // Act
      dp.setVisible(false);

      // Assert
      assertEquals(false, dp.isVisible());
   }
View Full Code Here

        mapping.put(NameTokens.MessagingPresenter, jmsQueues);
        mapping.put(NameTokens.WebPresenter, web);
        mapping.put(NameTokens.TransactionPresenter, tx);


        DisclosurePanel serverPanel  = new DisclosureStackPanel("Status", true).asWidget();
        serverPanel.setContent(statusTree);

        // open by default
        serverContents.setState(true);


        stack.add(serverPanel);

        // ----------------------------------------------------

        Tree deploymentTree = new LHSNavTree("standalone-runtime");
        DisclosurePanel deploymentPanel  = new DisclosureStackPanel("Deployments").asWidget();
        deploymentPanel.setContent(deploymentTree);

        deploymentTree.addItem(new LHSNavTreeItem("Manage Deployments", NameTokens.DeploymentListPresenter));

        stack.add(deploymentPanel);


        // ----

        Tree runtimeOpsTree = new LHSNavTree("standalone-runtime");
        DisclosurePanel runtimePanel  = new DisclosureStackPanel("Runtime Operations").asWidget();
        runtimePanel.setContent(runtimeOpsTree);

        LHSNavTreeItem osgi = new LHSNavTreeItem("OSGi", NameTokens.OSGiRuntimePresenter);
        runtimeOpsTree.addItem(osgi);

        stack.add(runtimePanel);
View Full Code Here

        // ----------------------------------------------------


        subsysTree = new LHSNavTree("profiles");

        DisclosurePanel subsysPanel  = new DisclosureStackPanel("Profile", true).asWidget();
        subsysPanel.setContent(subsysTree);
        stack.add(subsysPanel);

        // ----------------------------------------------------

        Tree commonTree = new LHSNavTree("profiles");
        DisclosurePanel commonPanel  = new DisclosureStackPanel("General Configuration").asWidget();
        commonPanel.setContent(commonTree);

        LHSNavTreeItem[] commonItems = new LHSNavTreeItem[] {
                /*new LHSNavTreeItem("Server", NameTokens.StandaloneServerPresenter),*/
                new LHSNavTreeItem("Interfaces", NameTokens.InterfacePresenter),
                new LHSNavTreeItem("Socket Binding Groups", NameTokens.SocketBindingPresenter),
View Full Code Here

    }

    public Widget asWidget()
    {
        ImageResource helpIcon = Icons.INSTANCE.help();
        helpPanel = new DisclosurePanel(helpIcon, helpIcon, "");

        helpPanel.addStyleName("help-panel");
        helpPanel.getHeader().getElement().setAttribute("style", "float:right");
        helpPanel.addOpenHandler(new OpenHandler<DisclosurePanel>() {
View Full Code Here

        // ----------------------------------------------------


        subsysTree = new LHSNavTree("profiles");

        DisclosurePanel subsysPanel  = new DisclosureStackPanel("Profile").asWidget();
        subsysPanel.setContent(subsysTree);
        stack.add(subsysPanel);

        // ----------------------------------------------------

        Tree deploymentTree = new LHSNavTree("profiles");
        deploymentTree.addItem(new LHSNavTreeItem("Manage Deployments", NameTokens.DeploymentListPresenter));
        DisclosurePanel deplPanel  = new DisclosureStackPanel("Deployments").asWidget();
        deplPanel.setContent(deploymentTree);

        stack.add(deplPanel);

        // ----------------------------------------------------

        Tree commonTree = new LHSNavTree("profiles");
        DisclosurePanel commonPanel  = new DisclosureStackPanel("General Configuration").asWidget();
        commonPanel.setContent(commonTree);

        LHSNavTreeItem[] commonItems = new LHSNavTreeItem[] {
                /*new LHSNavTreeItem("Server", NameTokens.StandaloneServerPresenter),*/
                new LHSNavTreeItem("Interfaces", NameTokens.InterfacePresenter),
                new LHSNavTreeItem("Socket Binding Groups", NameTokens.SocketBindingPresenter),
View Full Code Here

TOP

Related Classes of com.google.gwt.user.client.ui.DisclosurePanel$ClickableHeader

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.