Пример #1
0
  /**
   * Returns a 2-valued array of Lines: 0: col, 1:row ; non-null lines if the parameter cells are
   * all contained on the same col/row. So don't be flippant in assessing the array as there are
   * likely null values.
   *
   * @param cells
   * @param g
   * @return
   */
  public static Line[] getCommonLines(ArrayList<Cell> cells, Grid g) {
    Line[] out = new Line[2];
    if (cells.isEmpty()) {
      return new Line[2];
    }

    int x = cells.get(0).x;
    int outlength = 0;
    boolean yes1 = true;
    for (Cell c : cells) {
      if (c.x != x) {
        yes1 = false;
        break;
      }
    }
    if (yes1) {
      out[0] = g.getColumn(x);
      outlength++;
    }
    int y = cells.get(0).y;
    boolean yes2 = true;
    for (Cell c : cells) {
      if (c.y != y) {
        yes2 = false;
        break;
      }
    }
    if (yes2) {
      out[1] = g.getRow(y);
    }
    return out;
  }
Пример #2
0
  public SubsEditViewImpl() {
    ButtonRenderer deleteButton = createDeleteButton();
    Slider percentSlider = createPercentSlider();
    MultiFileUpload uploader = createUploader();

    // need to update the grid a first time for initialization.
    updateGrid(null);
    grid.getColumn("delete").setRenderer(deleteButton);
    fileDownloader = new FileDownloader(generateResource());
    fileDownloader.extend(downloadButton);

    // create the main layout
    VerticalLayout content = new VerticalLayout();

    // layout which contains the uploader and the percentage - in other words : all the
    // configuration information
    HorizontalLayout configHorizontalLayout = new HorizontalLayout();
    configHorizontalLayout.addComponent(uploader);

    // Configure the layout which contains the percentage slider
    AbsoluteLayout sliderLayout = new AbsoluteLayout();
    sliderLayout.setWidth("100px");
    sliderLayout.setHeight("35px");
    sliderLayout.addComponent(percentSlider);

    // Configure the layout which contains the percentage slider layout and the labels linked to the
    // percentage
    HorizontalLayout percentageLayout = new HorizontalLayout();
    percentageLayout.addComponent(percentSliderTitle);
    percentageLayout.addComponent(sliderLayout);
    percentageLayout.addComponent(percentLabel);
    percentageLayout.setComponentAlignment(percentSliderTitle, Alignment.MIDDLE_LEFT);
    percentageLayout.setComponentAlignment(percentLabel, Alignment.MIDDLE_LEFT);

    // add the percentage Layout to the layout which contains the uploader
    configHorizontalLayout.addComponent(percentageLayout);
    configHorizontalLayout.setComponentAlignment(percentageLayout, Alignment.BOTTOM_LEFT);

    // add every layouts to the principal one
    content.addComponent(configHorizontalLayout);
    content.addComponent(new Label("&nbsp;", Label.CONTENT_XHTML));
    content.addComponents(grid);
    content.addComponent(downloadButton);
    setCompositionRoot(content);
  }