Ejemplo n.º 1
0
  /**
   * Base constructor for this widget
   *
   * @param elements The number of elements (bars) to show on the progress bar
   * @param options The display options for the progress bar
   */
  public ProgressBar(int elements, int options) {
    // Read the options and set convenience variables
    if ((options & SHOW_TIME_REMAINING) == SHOW_TIME_REMAINING) showRemaining = true;
    if ((options & SHOW_TEXT) == SHOW_TEXT) showText = true;

    // Set element count
    this.elements = elements;

    // Styling
    remainLabel.setStyleName("progressbar-remaining");
    textLabel.setStyleName("progressbar-text");

    // Initialize the progress elements
    elementGrid = new Grid(1, elements);
    elementGrid.setStyleName("progressbar-inner");
    elementGrid.setCellPadding(0);
    elementGrid.setCellSpacing(0);

    for (int loop = 0; loop < elements; loop++) {
      Grid elm = new Grid(1, 1);
      // elm.setHTML(0, 0, "&nbsp;");
      elm.setHTML(0, 0, "");
      elm.setStyleName("progressbar-blankbar");
      elm.addStyleName("progressbar-bar");
      elementGrid.setWidget(0, loop, elm);
    }

    // Create the container around the elements
    Grid containerGrid = new Grid(1, 1);
    containerGrid.setCellPadding(0);
    containerGrid.setCellSpacing(0);
    containerGrid.setWidget(0, 0, elementGrid);
    containerGrid.setStyleName("progressbar-outer");
    // containerGrid.setBorderWidth(1);

    // Set up the surrounding flex table based on the options
    int row = 0;
    if (showText) barFrame.setWidget(row++, 0, textLabel);
    barFrame.setWidget(row++, 0, containerGrid);
    if (showRemaining) barFrame.setWidget(row++, 0, remainLabel);

    barFrame.setWidth("100%");

    // Add the frame to the panel
    this.add(barFrame);

    // Initialize progress bar
    setProgress(0);
  }
Ejemplo n.º 2
0
  /** Creates a new ProjectList */
  public ProjectList() {
    projects = new ArrayList<Project>();
    selectedProjects = new ArrayList<Project>();
    projectWidgets = new HashMap<Project, ProjectWidgets>();

    sortField = SortField.DATE_MODIFIED;
    sortOrder = SortOrder.DESCENDING;

    // Initialize UI
    table = new Grid(1, 4); // The table initially contains just the header row.
    table.addStyleName("ode-ProjectTable");
    table.setWidth("100%");
    table.setCellSpacing(0);
    nameSortIndicator = new Label("");
    dateCreatedSortIndicator = new Label("");
    dateModifiedSortIndicator = new Label("");
    refreshSortIndicators();
    setHeaderRow();

    VerticalPanel panel = new VerticalPanel();
    panel.setWidth("100%");

    panel.add(table);
    initWidget(panel);

    // It is important to listen to project manager events as soon as possible.
    Ode.getInstance().getProjectManager().addProjectManagerEventListener(this);
  }
Ejemplo n.º 3
0
  /**
   * Skeleton of toolbar creation
   *
   * @return
   */
  protected Widget buildStepBar() {
    HorizontalPanel uiToolbar = new HorizontalPanel();
    uiToolbar.setStylePrimaryName("blockSteps");
    uiToolbar.setWidth("100%");
    uiToolbar.setHorizontalAlignment(ALIGN_RIGHT);
    uiToolbar.setVerticalAlignment(ALIGN_MIDDLE);

    // Build stepBar
    int nbSteps = controller.getNbViews();

    Grid table = new Grid(1, nbSteps);
    table.setCellSpacing(3);
    Image currentImg = null;
    for (int i = 0; i < nbSteps; i++) {
      if (i == stepNumber) {
        currentImg = new Image("img/red_round_button.jpg");
      } else if (i < stepNumber) {
        currentImg = new Image("img/green_round_tick.jpg");
      } else {
        currentImg = new Image("img/green_round_button.jpg");
      }
      table.setWidget(0, i, currentImg);
    }

    uiToolbar.add(table);
    return uiToolbar;
  }
Ejemplo n.º 4
0
  /** Initialize this example. */
  @ShowcaseSource
  @Override
  public Widget onInitialize() {
    // Use a Grid to layout the content
    Grid layout = new Grid(4, 2);
    layout.setCellSpacing(5);

    // Add a field to select the pattern
    patternList = new ListBox();
    patternList.setWidth("17em");
    String[] patterns = constants.cwNumberFormatPatterns();
    for (String pattern : patterns) {
      patternList.addItem(pattern);
    }
    patternList.addChangeHandler(
        new ChangeHandler() {
          public void onChange(ChangeEvent event) {
            updatePattern();
          }
        });
    layout.setHTML(0, 0, constants.cwNumberFormatPatternLabel());
    layout.setWidget(0, 1, patternList);

    // Add a field to display the pattern
    patternBox = new TextBox();
    patternBox.setWidth("17em");
    patternBox.addKeyUpHandler(
        new KeyUpHandler() {
          public void onKeyUp(KeyUpEvent event) {
            updatePattern();
          }
        });
    layout.setWidget(1, 1, patternBox);

    // Add a field to set the value
    valueBox = new TextBox();
    valueBox.setWidth("17em");
    valueBox.setText("31415926535.897932");
    valueBox.addKeyUpHandler(
        new KeyUpHandler() {
          public void onKeyUp(KeyUpEvent event) {
            updateFormattedValue();
          }
        });
    layout.setHTML(2, 0, constants.cwNumberFormatValueLabel());
    layout.setWidget(2, 1, valueBox);

    // Add a field to display the formatted value
    formattedBox = new Label();
    formattedBox.setWidth("17em");
    layout.setHTML(3, 0, constants.cwNumberFormatFormattedLabel());
    layout.setWidget(3, 1, formattedBox);

    // Return the layout Widget
    updatePattern();
    return layout;
  }
Ejemplo n.º 5
0
  @Override
  protected Widget createContents(int start, int count, List<T> list) {
    int limit = list.size();
    int cells = padToFullPage() ? Math.max(count, limit) : limit;
    Grid grid = new Grid((int) Math.ceil(cells / (float) _cols), Math.min(_cols, cells));
    grid.setStyleName("Grid");
    grid.setCellPadding(0);
    grid.setCellSpacing(0);
    grid.setWidth("100%");

    for (int ii = 0; ii < limit; ii++) {
      int row = (ii / _cols), col = (ii % _cols);
      T item = ii >= list.size() ? null : list.get(ii);
      Widget widget = createWidget(item);
      if (widget != null) {
        grid.setWidget(row, col, widget);
      }
      formatCell(grid.getCellFormatter(), row, col, limit);
      formatCell(grid.getCellFormatter(), row, col, item);
    }

    return grid;
  }
  public ResizableDialogBox(
      final String headerText,
      String okText,
      String cancelText,
      final Widget content,
      final boolean modal) {
    this.content = content;
    boundaryPanel =
        new AbsolutePanel() {
          public void onBrowserEvent(Event event) {
            super.onBrowserEvent(event);
            if (!modal && event.getTypeInt() == Event.ONCLICK) {
              hide();
            }
          }
        };
    boundaryPanel.setSize(
        "100%",
        Window.getClientHeight() + Window.getScrollTop() + "px"); // $NON-NLS-1$ //$NON-NLS-2$
    boundaryPanel.setVisible(true);
    RootPanel.get().add(boundaryPanel, 0, 0);
    boundaryPanel.sinkEvents(Event.ONCLICK);
    boundaryPanel
        .getElement()
        .getStyle()
        .setProperty("cursor", "wait"); // $NON-NLS-1$ //$NON-NLS-2$

    // initialize window controller which provides drag and resize windows
    WindowController windowController = new WindowController(boundaryPanel);

    // content wrapper
    Button ok = new Button(okText);
    ok.setStylePrimaryName("pentaho-button");
    ok.getElement().setAttribute("id", "okButton"); // $NON-NLS-1$ //$NON-NLS-2$
    ok.addClickHandler(
        new ClickHandler() {

          @Override
          public void onClick(ClickEvent event) {
            if (validatorCallback == null
                || (validatorCallback != null && validatorCallback.validate())) {
              try {
                if (callback != null) {
                  callback.okPressed();
                }
              } catch (Throwable dontCare) {
              }
              hide();
            }
          }
        });
    final HorizontalPanel dialogButtonPanel = new HorizontalPanel();
    dialogButtonPanel.setSpacing(2);
    dialogButtonPanel.add(ok);
    if (cancelText != null) {
      Button cancel = new Button(cancelText);
      cancel.setStylePrimaryName("pentaho-button");
      cancel.getElement().setAttribute("id", "cancelButton"); // $NON-NLS-1$ //$NON-NLS-2$
      cancel.addClickHandler(
          new ClickHandler() {

            public void onClick(ClickEvent event) {
              try {
                if (callback != null) {
                  callback.cancelPressed();
                }
              } catch (Throwable dontCare) {
              }
              hide();
            }
          });
      dialogButtonPanel.add(cancel);
    }
    HorizontalPanel dialogButtonPanelWrapper = new HorizontalPanel();
    if (okText != null && cancelText != null) {
      dialogButtonPanelWrapper.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_RIGHT);
    } else {
      dialogButtonPanelWrapper.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
    }
    dialogButtonPanelWrapper.setStyleName("dialogButtonPanel"); // $NON-NLS-1$
    dialogButtonPanelWrapper.setWidth("100%"); // $NON-NLS-1$
    dialogButtonPanelWrapper.add(dialogButtonPanel);

    Grid dialogContent = new Grid(2, 1);
    dialogContent.setCellPadding(0);
    dialogContent.setCellSpacing(0);
    dialogContent.getCellFormatter().setVerticalAlignment(1, 0, HasVerticalAlignment.ALIGN_TOP);
    dialogContent
        .getCellFormatter()
        .setHorizontalAlignment(1, 0, HasHorizontalAlignment.ALIGN_LEFT);
    // add content
    dialogContent.setWidget(0, 0, content);
    dialogContent.getCellFormatter().setVerticalAlignment(0, 0, HasVerticalAlignment.ALIGN_TOP);
    // add button panel
    dialogContent.setWidget(1, 0, dialogButtonPanelWrapper);
    dialogContent.getCellFormatter().setVerticalAlignment(1, 0, HasVerticalAlignment.ALIGN_BOTTOM);
    dialogContent.setWidth("100%"); // $NON-NLS-1$
    dialogContent.setHeight("100%"); // $NON-NLS-1$

    windowPanel = new WindowPanel(windowController, headerText, dialogContent, true);
  }
Ejemplo n.º 7
0
  private void updateRecords() {
    records.clear();

    if (displayFields.isEmpty()) {
      records.setWidget(new HTML(""));
      return;
    }

    List<StructureHolder> holders = oneToMany.getSelected();
    if (holders.isEmpty()) {
      records.setWidget(new HTML(""));
      return;
    }

    List<String> descs = holders.get(0).getStructure().extractDescriptions();

    Grid grid = new Grid(holders.size() + 1, displayFields.size());
    grid.setCellSpacing(0);
    grid.setCellPadding(8);
    grid.addStyleName("page_assessment_classScheme_grid");

    int row = 0;
    int column = 0;
    for (Integer value : displayFields) {
      try {
        grid.setHTML(
            row,
            column,
            "<span class=\"page_assessment_classScheme_grid_th\">" + descs.get(value) + "</span>");
      } catch (IndexOutOfBoundsException e) {
        grid.setHTML(row, column, "<span class=\"page_assessment_classScheme_grid_th\">-</span>");
      } finally {
        column++;
      }
    }

    row++;

    for (StructureHolder holder : holders) {
      final ArrayList<String> raw = new ArrayList<String>(), pretty = new ArrayList<String>();

      final Structure<Object> structure = holder.getStructure();

      final Map<String, String> map = new LinkedHashMap<String, String>();

      for (Object obj : structure.getClassificationInfo()) {
        ClassificationInfo info = (ClassificationInfo) obj;
        map.put(info.getDescription(), info.getData());
        raw.add(info.getData());
      }

      try {
        structure.getDisplayableData(raw, pretty, 0);
      } catch (Exception e) {
        continue;
      }

      column = 0;
      for (Integer value : displayFields) {
        try {
          grid.setHTML(
              row,
              column,
              "<span class=\"page_assessment_classScheme_content\">"
                  + pretty.get(value)
                  + "</span>");
        } catch (IndexOutOfBoundsException e) {
          grid.setHTML(row, column, "<span class=\"page_assessment_classScheme_content\">-</span>");
        } finally {
          column++;
        }
      }

      row++;
    }

    for (int i = 0; i < grid.getColumnCount(); i++) grid.getColumnFormatter().setWidth(i, "150px");

    records.setWidget(grid);
  }
  public OperatorCreation(IAdminView parent) {

    VerticalPanel formPnl = new VerticalPanel();

    parentView = parent;
    setText(RESOURCES.m_newOperatorCreation_text());

    closeBtn.addClickHandler(
        new ClickHandler() {

          @Override
          public void onClick(ClickEvent event) {
            hide();
            clearDialog();
          }
        });

    createBtn.addClickHandler(
        new ClickHandler() {

          @Override
          public void onClick(ClickEvent event) {

            ValidationProcessor validator = new DefaultValidationProcessor();

            NotEmptyValidator notEmptyUsername = new NotEmptyValidator(usernameTxt);
            validator.addValidators("Validation", notEmptyUsername);
            if (validator.validate("Validation") == false) {
              Messages.showError(RESOURCES.m_usrnameCannotBeEmpty_text());
              return;
            }
            validator.removeAllValidators();

            EmailValidator emailMatchUsername = new EmailValidator(usernameTxt);
            validator.addValidators("Validation", emailMatchUsername);
            if (validator.validate("Validation") == false) {
              Messages.showError(RESOURCES.m_usrnameMustBeEmail_text());
              return;
            }
            validator.removeAllValidators();

            NotEmptyValidator notEmptyPassword = new NotEmptyValidator(passwordPwd);
            validator.addValidators("Validation", notEmptyPassword);
            if (validator.validate("Validation") == false) {
              Messages.showError(RESOURCES.m_pwdCannotBeEmpty_text());
              return;
            }
            validator.removeAllValidators();

            StringLengthValidator rangePasswordCharacter =
                new StringLengthValidator(passwordPwd, 8, 16);
            validator.addValidators("Validation", rangePasswordCharacter);
            if (validator.validate("Validation") == false) {
              Messages.showError(RESOURCES.m_pwdBetween8_16_text());
              return;
            }
            validator.removeAllValidators();

            if (passwordPwd.getText().equals(confirmPasswordPwd.getText())) {
              OperatorBO newOperator = new OperatorBO();
              newOperator.setAuthority(parentView.getCurrentUser().getAuthority());
              newOperator.setCanEditNew(canEditNewCkb.getValue());
              newOperator.setPassword(passwordPwd.getText());
              newOperator.setUsername(usernameTxt.getText());
              parentView.getPresenter().addOperator(newOperator);
              hide();
              clearDialog();
            } else {
              Messages.showError(RESOURCES.m_wrongConfirmPwd_text());
            }
          }
        });

    grid.setWidget(0, 0, fieldUsernameLbl);
    grid.setWidget(0, 1, usernameTxt);
    grid.setWidget(1, 0, fieldPasswordLbl);
    grid.setWidget(1, 1, passwordPwd);
    grid.setWidget(2, 0, fieldConfirmPasswordLbl);
    grid.setWidget(2, 1, confirmPasswordPwd);
    grid.setWidget(3, 0, fieldCanEditNewLbl);
    grid.setWidget(3, 1, canEditNewCkb);

    formPnl.add(grid);

    HorizontalPanel buttonPnl = new HorizontalPanel();
    buttonPnl.add(closeBtn);
    buttonPnl.add(createBtn);
    buttonPnl.setCellWidth(closeBtn, "200px");
    buttonPnl.setCellHorizontalAlignment(closeBtn, HorizontalPanel.ALIGN_CENTER);
    buttonPnl.setHeight("30px");

    formPnl.add(buttonPnl);

    setWidget(formPnl);
    grid.setCellSpacing(10);
    show();
    center();
  }