コード例 #1
0
  public void setWave(String wave) {
    this.wave = wave;
    for (Widget w : navigation) {
      if (w instanceof ListItem) {
        w.addStyleName("waves-effect waves-" + wave);
      }
    }

    for (Widget w : mobileNav) {
      if (w instanceof ListItem) {
        ListItem item = (ListItem) w;
        for (Widget child : item) {
          if (!(child instanceof MaterialCollapsible)) {
            w.addStyleName("waves-effect waves-" + wave);
            w.getElement().getStyle().setDisplay(Display.BLOCK);
          } else {
            MaterialCollapsible col = (MaterialCollapsible) child;
            for (Widget colItem : col) {
              if (colItem instanceof MaterialCollapsibleItem) {
                ((MaterialCollapsibleItem) colItem)
                    .getHeader()
                    .addStyleName("waves-effect waves-" + wave);
              }
            }
          }
        }
      }
    }
  }
コード例 #2
0
  @Override
  protected void onAttach() {
    super.onAttach();
    name = String.valueOf(hashCode());
    int col = 12 / tabPanel.getWidgetCount();
    int index = tabPanel.getWidgetCount();
    for (Widget w : tabPanel) {
      if (w instanceof ListItem) {
        if (!waves.isEmpty())
          ((ListItem) w).getWidget(0).getElement().addClassName("waves-effect waves-" + waves);
        if (!color.isEmpty()) w.getElement().addClassName(color);
        if (!textColor.isEmpty())
          ((ListItem) w).getWidget(0).getElement().addClassName(textColor + "-text");
        ((ListItem) w).getWidget(0).getElement().setAttribute("href", "#" + name + index);
        w.addStyleName("tab col s" + col);
        index--;
      }
    }

    int indexC = contentPanel.getWidgetCount();
    for (Widget w : contentPanel) {
      w.getElement().setAttribute("id", name + indexC);
      indexC--;
    }
    initTabs();
    changeIndicator(indicatorColor);
  }
コード例 #3
0
ファイル: SingleUploader.java プロジェクト: rebioma/rebioma
  /**
   * This constructor allows to use an existing form panel.
   *
   * @param type file input to use
   * @param status Customized status widget to use
   * @param submitButton Customized button which submits the form
   * @param form Customized form panel
   */
  public SingleUploader(
      FileInputType type, IUploadStatus status, Widget submitButton, FormPanel form) {
    super(type, form);

    final Uploader thisInstance = this;

    if (status == null) {
      status = new BaseUploadStatus();
      super.add(status.getWidget());
    }
    super.setStatusWidget(status);

    this.button = submitButton;
    if (submitButton != null) {
      submitButton.addStyleName("submit");
      if (submitButton instanceof HasClickHandlers) {
        ((HasClickHandlers) submitButton)
            .addClickHandler(
                new ClickHandler() {
                  public void onClick(ClickEvent event) {
                    thisInstance.submit();
                  }
                });
      }
      if (submitButton instanceof HasText) {
        ((HasText) submitButton).setText(I18N_CONSTANTS.uploaderSend());
      }
      // The user could have attached the button anywhere in the page.
      if (!submitButton.isAttached()) {
        super.add(submitButton);
      }
    }
  }
コード例 #4
0
ファイル: DbFormAdd.java プロジェクト: novaris/novoscan
 private void addColumn(Object columnHeading) {
   Widget widget = createCellWidget(columnHeading);
   int cell = flexTable.getCellCount(HEADER_ROW_INDEX);
   widget.setWidth("100%");
   widget.addStyleName("FlexTable-ColumnLabel");
   flexTable.setWidget(HEADER_ROW_INDEX, cell, widget);
   flexTable.getCellFormatter().addStyleName(HEADER_ROW_INDEX, cell, "FlexTable-ColumnLabelCell");
 }
コード例 #5
0
ファイル: SingleUploader.java プロジェクト: rebioma/rebioma
 /* (non-Javadoc)
  * @see gwtupload.client.Uploader#onChangeInput()
  */
 @Override
 protected void onChangeInput() {
   super.onChangeInput();
   if (button != null) {
     button.addStyleName("changed");
     if (button instanceof Focusable) {
       ((Focusable) button).setFocus(true);
     }
   }
 }
コード例 #6
0
 public Widget getWidgetWithHeading(Widget widget, String heading) {
   FlowPanel vPanel = new FlowPanel();
   Label h = new Label(heading);
   h.addStyleName("myAccountHeader");
   h.addStyleName("leftAligned");
   vPanel.add(h);
   vPanel.add(widget);
   vPanel.addStyleName("myAccountPanel");
   widget.addStyleName("myAccountPanelContent");
   return vPanel;
 }
コード例 #7
0
  /**
   * Sets the content widget which can be opened and closed by this panel. If there is a preexisting
   * content widget, it will be detached.
   *
   * @param content the widget to be used as the content panel
   */
  public void setContent(final Widget content) {
    final Widget currentContent = this.content;

    // Remove existing content widget.
    if (currentContent != null) {
      mainPanel.remove(currentContent);
      currentContent.removeStyleName(STYLENAME_CONTENT);
    }

    // Add new content widget if != null.
    this.content = content;
    if (content != null) {
      mainPanel.add(content);
      content.addStyleName(STYLENAME_CONTENT);
      setContentDisplay();
    }
  }
コード例 #8
0
  /** Activate the control. */
  public void activate() {
    this.clear();
    this.setVisible(true);
    Widget avatar =
        new AvatarWidget(
            Session.getInstance().getCurrentPerson().getId(),
            Session.getInstance().getCurrentPerson().getAvatarId(),
            EntityType.PERSON,
            Size.VerySmall,
            Background.White);
    avatar.addStyleName("avatar");
    this.add(avatar);

    FlowPanel body = new FlowPanel();
    body.addStyleName("body");

    commentBox = new TextArea();
    body.add(commentBox);
    commentBox.setFocus(true);

    countDown = new Label(Integer.toString(MAXLENGTH));
    countDown.addStyleName("characters-remaining");
    body.add(countDown);

    post = new Hyperlink("post", History.getToken());
    post.addStyleName("post-button");
    post.addStyleName("inactive");

    final Label warning = new Label();
    warning.addStyleName("warning hidden");
    body.add(warning);

    Session.getInstance()
        .getEventBus()
        .addObserver(
            GotSystemSettingsResponseEvent.class,
            new Observer<GotSystemSettingsResponseEvent>() {
              public void update(final GotSystemSettingsResponseEvent event) {
                String text = event.getResponse().getContentWarningText();
                if (text != null && !text.isEmpty()) {
                  warning.removeStyleName("hidden");
                  warning.setText(text);
                }
              }
            });

    SystemSettingsModel.getInstance().fetch(null, true);

    post.addClickHandler(
        new ClickHandler() {
          public void onClick(final ClickEvent event) {
            fullCollapse = false;
            if (!inactive) {
              unActivate();
              CommentDTO comment = new CommentDTO();
              comment.setBody(commentBox.getText());
              comment.setActivityId(messageId);
              Session.getInstance()
                  .getActionProcessor()
                  .makeRequest(
                      new ActionRequestImpl<CommentDTO>("postActivityCommentAction", comment),
                      new AsyncCallback<CommentDTO>() {
                        /* implement the async call back methods */
                        public void onFailure(final Throwable caught) {}

                        public void onSuccess(final CommentDTO result) {
                          Session.getInstance()
                              .getEventBus()
                              .notifyObservers(new CommentAddedEvent(result, messageId));
                        }
                      });
            }
          }
        });
    body.add(post);

    this.add(body);
    commentBox.setFocus(true);
    nativeSetFocus(commentBox.getElement());

    commentBox.addBlurHandler(
        new BlurHandler() {
          public void onBlur(final BlurEvent arg0) {
            TimerFactory timerFactory = new TimerFactory();
            timerFactory.runTimer(
                BLUR_DELAY,
                new TimerHandler() {
                  public void run() {
                    if (commentBox.getText().length() == 0) {
                      unActivate();
                    }
                  }
                });
          }
        });

    commentBox.addKeyPressHandler(
        new KeyPressHandler() {
          public void onKeyPress(final KeyPressEvent event) {
            if (event.getCharCode() == KeyCodes.KEY_ESCAPE) {
              unActivate();
            }
          }
        });

    commentBox.addKeyUpHandler(
        new KeyUpHandler() {
          public void onKeyUp(final KeyUpEvent event) {
            onCommentChanges();
          }
        });

    commentBox.addChangeHandler(
        new ChangeHandler() {
          public void onChange(final ChangeEvent event) {
            onCommentChanges();
          }
        });
  }
コード例 #9
0
  /** Activate the control. */
  public void activate() {
    clear();
    this.setVisible(true);
    Widget avatar =
        new AvatarWidget(
            Session.getInstance().getCurrentPerson().getAvatarId(),
            EntityType.PERSON,
            Size.VerySmall);
    avatar.addStyleName(StaticResourceBundle.INSTANCE.coreCss().avatar());
    this.add(avatar);

    FlowPanel body = new FlowPanel();
    body.addStyleName(StaticResourceBundle.INSTANCE.coreCss().body());

    SimplePanel boxWrapper = new SimplePanel();
    boxWrapper.addStyleName(StaticResourceBundle.INSTANCE.coreCss().boxWrapper());
    commentBox = new ExtendedTextArea(true);
    boxWrapper.add(commentBox);
    body.add(boxWrapper);
    commentBox.setFocus(true);

    countDown = new Label(Integer.toString(MAXLENGTH));
    countDown.addStyleName(StaticResourceBundle.INSTANCE.coreCss().charactersRemaining());
    body.add(countDown);

    post = new PushButton("post");
    post.addStyleName(StaticResourceBundle.INSTANCE.coreCss().postButton());
    post.addStyleName(StaticResourceBundle.INSTANCE.coreCss().inactive());
    body.add(post);

    final Label warning = new Label();
    warning.addStyleName(StaticResourceBundle.INSTANCE.coreCss().warning());
    warning.addStyleName(StaticResourceBundle.INSTANCE.coreCss().hidden());
    body.add(warning);

    Session.getInstance()
        .getEventBus()
        .addObserver(
            GotSystemSettingsResponseEvent.class,
            new Observer<GotSystemSettingsResponseEvent>() {
              public void update(final GotSystemSettingsResponseEvent event) {
                String text = event.getResponse().getContentWarningText();
                if (text != null && !text.isEmpty()) {
                  warning.removeStyleName(StaticResourceBundle.INSTANCE.coreCss().hidden());
                  warning.setText(text);
                }
              }
            });

    SystemSettingsModel.getInstance().fetch(null, true);

    post.addClickHandler(
        new ClickHandler() {
          public void onClick(final ClickEvent event) {
            fullCollapse = false;
            if (!inactive) {
              unActivate();
              CommentDTO comment = new CommentDTO();
              comment.setBody(commentBox.getText());
              comment.setActivityId(messageId);
              Session.getInstance()
                  .getActionProcessor()
                  .makeRequest(
                      "postActivityCommentAction",
                      comment,
                      new AsyncCallback<CommentDTO>() {
                        /* implement the async call back methods */
                        public void onFailure(final Throwable caught) {}

                        public void onSuccess(final CommentDTO result) {
                          ActivityModel.getInstance().clearCache();
                          Session.getInstance()
                              .getEventBus()
                              .notifyObservers(new CommentAddedEvent(result, messageId));
                        }
                      });
            }
          }
        });

    this.add(body);
    commentBox.setFocus(true);
    nativeSetFocus(commentBox.getElement());

    commentBox.addBlurHandler(
        new BlurHandler() {
          public void onBlur(final BlurEvent arg0) {
            TimerFactory timerFactory = new TimerFactory();
            timerFactory.runTimer(
                BLUR_DELAY,
                new TimerHandler() {
                  public void run() {
                    if (commentBox.getText().length() == 0) {
                      unActivate();
                    }
                  }
                });
          }
        });

    commentBox.addKeyDownHandler(
        new KeyDownHandler() {
          public void onKeyDown(final KeyDownEvent event) {
            if (event.getNativeKeyCode() == KeyCodes.KEY_ESCAPE) {
              unActivate();
            } else if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER && event.isControlKeyDown()) {
              post.getElement()
                  .dispatchEvent(
                      Document.get().createClickEvent(1, 0, 0, 0, 0, false, false, false, false));
              event.preventDefault();
              event.stopPropagation();
            }
          }
        });

    commentBox.addKeyUpHandler(
        new KeyUpHandler() {
          public void onKeyUp(final KeyUpEvent event) {
            onCommentChanges();
          }
        });

    commentBox.addValueChangeHandler(
        new ValueChangeHandler<String>() {
          public void onValueChange(final ValueChangeEvent<String> inArg0) {
            onCommentChanges();
          }
        });

    commentBox.addChangeHandler(
        new ChangeHandler() {
          public void onChange(final ChangeEvent event) {
            onCommentChanges();
          }
        });
  }
コード例 #10
0
ファイル: Balloon.java プロジェクト: hmiguellima/ugat
 public void setText(String text, String style) {
   setText(text);
   setBalloonBackgroundStyle(widget);
   widget.addStyleName(style);
 }
コード例 #11
0
ファイル: ShellWidget.java プロジェクト: tobywang/rstudio
  public ShellWidget(AceEditor editor) {
    styles_ = ConsoleResources.INSTANCE.consoleStyles();

    SelectInputClickHandler secondaryInputHandler = new SelectInputClickHandler();

    output_ = new PreWidget();
    output_.setStylePrimaryName(styles_.output());
    output_.addClickHandler(secondaryInputHandler);

    pendingInput_ = new PreWidget();
    pendingInput_.setStyleName(styles_.output());
    pendingInput_.addClickHandler(secondaryInputHandler);

    prompt_ = new HTML();
    prompt_.setStylePrimaryName(styles_.prompt());
    prompt_.addStyleName(KEYWORD_CLASS_NAME);

    input_ = editor;
    input_.setShowLineNumbers(false);
    input_.setShowPrintMargin(false);
    if (!Desktop.isDesktop()) input_.setNewLineMode(NewLineMode.Unix);
    input_.setUseWrapMode(true);
    input_.setPadding(0);
    input_.autoHeight();
    final Widget inputWidget = input_.asWidget();
    input_.addClickHandler(secondaryInputHandler);
    inputWidget.addStyleName(styles_.input());
    input_.addCursorChangedHandler(
        new CursorChangedHandler() {
          public void onCursorChanged(CursorChangedEvent event) {
            Scheduler.get()
                .scheduleDeferred(
                    new ScheduledCommand() {
                      @Override
                      public void execute() {
                        input_.scrollToCursor(scrollPanel_, 8, 60);
                      }
                    });
          }
        });
    input_.addCapturingKeyDownHandler(
        new KeyDownHandler() {
          @Override
          public void onKeyDown(KeyDownEvent event) {
            // If the user hits Page-Up from inside the console input, we need
            // to simulate pageup because focus is not contained in the scroll
            // panel (it's in the hidden textarea that Ace uses under the
            // covers).

            int keyCode = event.getNativeKeyCode();
            switch (keyCode) {
              case KeyCodes.KEY_PAGEUP:
                event.stopPropagation();
                event.preventDefault();

                // Can't scroll any further up. Return before we change focus.
                if (scrollPanel_.getVerticalScrollPosition() == 0) return;

                scrollPanel_.focus();
                int newScrollTop =
                    scrollPanel_.getVerticalScrollPosition() - scrollPanel_.getOffsetHeight() + 40;
                scrollPanel_.setVerticalScrollPosition(Math.max(0, newScrollTop));
                break;
            }
          }
        });

    inputLine_ = new DockPanel();
    inputLine_.setHorizontalAlignment(DockPanel.ALIGN_LEFT);
    inputLine_.setVerticalAlignment(DockPanel.ALIGN_TOP);
    inputLine_.add(prompt_, DockPanel.WEST);
    inputLine_.setCellWidth(prompt_, "1");
    inputLine_.add(input_.asWidget(), DockPanel.CENTER);
    inputLine_.setCellWidth(input_.asWidget(), "100%");
    inputLine_.setWidth("100%");

    verticalPanel_ = new VerticalPanel();
    verticalPanel_.setStylePrimaryName(styles_.console());
    verticalPanel_.addStyleName("ace_text-layer");
    verticalPanel_.addStyleName("ace_line");
    FontSizer.applyNormalFontSize(verticalPanel_);
    verticalPanel_.add(output_);
    verticalPanel_.add(pendingInput_);
    verticalPanel_.add(inputLine_);
    verticalPanel_.setWidth("100%");

    scrollPanel_ = new ClickableScrollPanel();
    scrollPanel_.setWidget(verticalPanel_);
    scrollPanel_.addStyleName("ace_editor");
    scrollPanel_.addStyleName("ace_scroller");
    scrollPanel_.addClickHandler(secondaryInputHandler);
    scrollPanel_.addKeyDownHandler(secondaryInputHandler);

    secondaryInputHandler.setInput(editor);

    scrollToBottomCommand_ =
        new TimeBufferedCommand(5) {
          @Override
          protected void performAction(boolean shouldSchedulePassive) {
            if (!DomUtils.selectionExists()) scrollPanel_.scrollToBottom();
          }
        };

    initWidget(scrollPanel_);

    addCopyHook(getElement());
  }
コード例 #12
0
  protected void onUpdate() {
    if (sortColumnIndex == -1) {
      sortColumnIndex = getInitialSortColumnIndex();
      reverseSort = isInitialSortReverse();
    }

    Collection<O> objects;
    try {
      objects = getObjects();
    } catch (Exception ex) {
      throw new RuntimeException(Str.getSimpleName(getClass()) + ".getObjects() failed.", ex);
    }

    log.info("Objects loaded:", objects.size());

    int rowIndex = -1;

    if (isColumnTitlesEnabled()) {
      rowIndex++;
      for (AColumn column : columns) {
        String columnTitle;
        try {
          columnTitle = column.getTitle();
        } catch (Exception ex) {
          log.error(ex);
          columnTitle = "ERROR: " + Str.formatException(ex);
        }

        boolean customSortingEnabled = isCustomSortingEnabled();

        Widget titleWidget = Widgets.textFieldlabel(columnTitle, false);
        if (titleWidget != null && customSortingEnabled && isShowColumnSortingToggleIcon())
          titleWidget.addStyleName("columnTitleWithSortToggle");

        if (titleWidget != null && (sortColumnIndex == column.index)) {
          // Sortierte Spalte hervorheben
          Style style = titleWidget.getElement().getStyle();
          style.setColor("#444");
          style.setFontWeight(FontWeight.BOLD);
          if (reverseSort) style.setFontStyle(FontStyle.ITALIC);
        }

        table.setWidget(
            rowIndex,
            column.index,
            Widgets.frame(
                titleWidget,
                Widgets.defaultSpacing,
                0,
                Widgets.defaultSpacing,
                Widgets.defaultSpacing / 2));

        if (customSortingEnabled) {
          for (int col = 0; col < columns.size(); col++) {
            table.getCellFormatter().setStyleName(rowIndex, col, "clickable");
          }
        }
      }
    }

    if (isColumnFilteringEnabled()) {
      rowIndex++;
      for (AColumn column : columns) {
        TextBox filterTextbox = column.getFilterWidget();
        SimplePanel frame = Widgets.frame(filterTextbox, Widgets.defaultSpacing);
        table.setWidget(rowIndex, column.index, frame);
      }
    }

    try {
      rows = createRows(objects, rowIndex);
    } catch (Exception ex) {
      throw new RuntimeException(Str.getSimpleName(getClass()) + ".createRows() failed.", ex);
    }
    table.setVisible(!rows.isEmpty());

    for (Row row : rows) {
      appendRow(row);
      rowIndex++;
    }

    for (int i = 0; i < getFootRowCount(); i++) {
      rowIndex++;
      for (AColumn column : columns) {
        table.setWidget(rowIndex, column.index, column.getFootCellWidget(i));
      }
    }
  }
コード例 #13
0
ファイル: InputsPanel.java プロジェクト: alexafshar/paco
 private void addErrorHighlight(Widget widget) {
   widget.addStyleName(Main.ERROR_HIGHLIGHT);
 }
コード例 #14
0
 @UiChild(tagname = "content")
 public void addContent(final Widget item) {
   item.addStyleName("col s12");
   contentPanel.add(item);
 }