コード例 #1
0
ファイル: MailList.java プロジェクト: KiarashE/timeview
  private void styleRow(int row, boolean selected) {
    if (row != -1) {
      String style = selectionStyle.selectedRow();

      if (selected) {
        table.getRowFormatter().addStyleName(row, style);
      } else {
        table.getRowFormatter().removeStyleName(row, style);
      }
    }
  }
コード例 #2
0
ファイル: Table.java プロジェクト: dematey/ephesoft
 private void setNavigationBar() {
   navBarTable.getCellFormatter().setWidth(0, 1, "30%");
   navBarTable.getCellFormatter().setWidth(0, 2, "10%");
   navBarTable.getCellFormatter().setWidth(0, 3, "10%");
   navBarTable.getCellFormatter().setWidth(0, 4, "22%");
   navBarTable.getCellFormatter().setWidth(0, 5, "23%");
   Label displayText = new Label(navBar.getCountString());
   Label searchPageText =
       new Label(LocaleDictionary.get().getConstantValue(LocaleCommonConstants.TITLE_GO_TO_PAGE));
   Label totalPageCountText = new Label("  /" + navBar.getTotalPageCount());
   HorizontalPanel searchPagePanel = new HorizontalPanel();
   displayText.setStyleName(selectionStyle.boldText());
   searchPageText.setStyleName(selectionStyle.boldText());
   totalPageCountText.setStyleName(selectionStyle.boldText());
   searchPagePanel.add(searchPageText);
   searchPagePanel.add(navBar.getSearchPageTextBox());
   searchPagePanel.add(totalPageCountText);
   searchPagePanel.setCellHorizontalAlignment(searchPageText, HasHorizontalAlignment.ALIGN_RIGHT);
   searchPagePanel.setCellHorizontalAlignment(
       navBar.getSearchPageTextBox(), HasHorizontalAlignment.ALIGN_RIGHT);
   searchPagePanel.setCellHorizontalAlignment(
       totalPageCountText, HasHorizontalAlignment.ALIGN_RIGHT);
   if (this.navBar.getOrderingListner() != null) {
     navBarTable.setWidget(0, 2, navBar.getOrderingPanel());
     navBarTable
         .getCellFormatter()
         .setHorizontalAlignment(0, 2, HasHorizontalAlignment.ALIGN_RIGHT);
   }
   if (this.navBar.getListner() != null) {
     navBarTable.setWidget(0, 3, navBar.getPaginationPanel());
     navBarTable
         .getCellFormatter()
         .setHorizontalAlignment(0, 3, HasHorizontalAlignment.ALIGN_RIGHT);
     navBarTable.setWidget(0, 4, searchPagePanel);
   }
   navBarTable.setWidget(0, 5, displayText);
   navBarTable.getCellFormatter().setHorizontalAlignment(0, 4, HasHorizontalAlignment.ALIGN_RIGHT);
   navBarTable.getCellFormatter().setHorizontalAlignment(0, 5, HasHorizontalAlignment.ALIGN_RIGHT);
 }
コード例 #3
0
ファイル: Table.java プロジェクト: dematey/ephesoft
 @UiHandler("flexTable")
 protected void onFlexTableClicked(ClickEvent event) {
   removeSelectedRowStyleFromTable();
   Cell cell = flexTable.getCellForEvent(event);
   if (cell != null && totalCount != 0) {
     int row = cell.getRowIndex();
     selectedIndex = row;
     flexTable.getRowFormatter().addStyleName(row, selectionStyle.rowHighlighted());
     RadioButtonContainer radioButtonContainer = radioButtons.get(row);
     if (radioButtonContainer != null && radioButtonContainer.getRadioButton() != null) {
       clearRadioButtons();
       radioButtonContainer.getRadioButton().setValue(true);
       selectedRowId = radioButtonContainer.getIdentifier();
       if (listner != null) {
         listner.onRowSelected(selectedRowId);
       }
     }
     if (radioButtonContainer != null
         && radioButtonContainer.getRadioButton() == null
         && radioButtonContainer.getIdentifier() != null) {
       selectedRowId = radioButtonContainer.getIdentifier();
     }
   }
 }
コード例 #4
0
ファイル: Table.java プロジェクト: dematey/ephesoft
 private void removeSelectedRowStyleFromTable() {
   for (int rowId = 0; rowId < flexTable.getRowCount(); rowId++) {
     flexTable.getRowFormatter().removeStyleName(rowId, selectionStyle.rowHighlighted());
   }
 }
コード例 #5
0
ファイル: Table.java プロジェクト: dematey/ephesoft
  private void update(boolean isRadioButton, int startIndex, int selectedIndexlocal) {
    selectedRowId = null;
    flexTable.removeAllRows();
    navBarTable.removeAllRows();
    createTableHeader(isRadioButton);
    int count = totalCount;
    int max = startIndex + visibleRecodrCount;
    if (max > count) {
      max = count;
    }
    navBar.update(startIndex, count, max);
    setNavigationBar();
    TableHeader header = tableData.getHeader();
    HeaderColumn[] columns = header.getHeaderColumns();
    String width = null;
    int rowCounter = 0;
    String radioName = String.valueOf(new Date().getTime());
    final List<Record> recordList = tableData.getRecordList();
    if (recordList != null) {
      if (!recordList.isEmpty()) {
        for (final Record record : recordList) {
          int colCounter = 0;
          for (; colCounter < columns.length; colCounter++) {
            width = columns[colCounter].getWidth() + "%";
            flexTable.getCellFormatter().setWidth(rowCounter, colCounter, width);
            flexTable.setWidget(rowCounter, colCounter, record.getWidget(columns[colCounter]));
            flexTable
                .getCellFormatter()
                .setHorizontalAlignment(rowCounter, colCounter, HasHorizontalAlignment.ALIGN_LEFT);
            flexTable.getCellFormatter().setWordWrap(rowCounter, colCounter, true);
            flexTable.getCellFormatter().addStyleName(rowCounter, colCounter, "wordWrap");
          }
          if (isRadioButton) {
            final RadioButton radioButton = new RadioButton(radioName);
            if (rowCounter == selectedIndexlocal) {
              radioButton.setValue(true);
              selectedRowId = record.getIdentifier();
              selectedIndex = rowCounter;
              if (null != listner && fireEventForFirstRow) {
                listner.onRowSelected(selectedRowId);
              }

              scrollIntoView(
                  flexTable.getWidget(selectedIndexlocal, FIRST_COLUMN_INDEX).getElement());
            }
            radioButton.addClickHandler(
                new ClickHandler() {

                  @Override
                  public void onClick(ClickEvent arg0) {
                    clearRadioButtons();
                    radioButton.setValue(true);
                    selectedRowId = record.getIdentifier();
                    selectedIndex = recordList.indexOf(record);
                  }
                });
            flexTable.setWidget(rowCounter, 0, radioButton);
            RadioButtonContainer radioButtonContainer =
                new RadioButtonContainer(radioButton, record.getIdentifier());
            radioButtons.put(rowCounter, radioButtonContainer);
            flexTable
                .getCellFormatter()
                .setHorizontalAlignment(rowCounter, 0, HasHorizontalAlignment.ALIGN_CENTER);

            radioButton.addFocusHandler(
                new FocusHandler() {

                  @Override
                  public void onFocus(FocusEvent arg0) {
                    removeSelectedRowStyleFromTable();
                    for (Integer rowId : radioButtons.keySet()) {
                      if (radioButtons.get(rowId).getRadioButton().equals(radioButton)) {
                        selectedIndex = recordList.indexOf(record);
                        flexTable
                            .getRowFormatter()
                            .addStyleName(rowId, selectionStyle.rowHighlighted());
                      }
                    }
                  }
                });
          } else {
            RadioButtonContainer radioButtonContainer =
                new RadioButtonContainer(null, record.getIdentifier());
            radioButtons.put(rowCounter, radioButtonContainer);
          }
          if (rowCounter % 2 == 0) {
            flexTable.getRowFormatter().setStyleName(rowCounter, selectionStyle.oddRow());
          } else {
            flexTable.getRowFormatter().setStyleName(rowCounter, selectionStyle.evenRow());
          }
          rowCounter++;
          flexTable
              .getRowFormatter()
              .addStyleName(selectedIndexlocal, selectionStyle.rowHighlighted());
        }
      } else {
        Label label = new Label();
        label.setWidth("100%");
        label.setText("No record found.");
        flexTable.getCellFormatter().setWidth(1, 0, "100%");
        flexTable.getFlexCellFormatter().setColSpan(1, 0, 3);
        // Record record = new Record("1");
        // tableData.getRecordList().add(record);
        flexTable.setWidget(1, 0, label);
      }
    }
  }
コード例 #6
0
ファイル: Table.java プロジェクト: dematey/ephesoft
  private void createTableHeader(boolean isRadioButton) {
    Images images = GWT.create(Images.class);
    final TableHeader header = tableData.getHeader();
    final List<HeaderColumn> columns = header.getHeaderColumns(isRadioButton);
    String width = null;
    int counter = 0;
    for (final HeaderColumn column : columns) {
      width = column.getWidth() + "%";
      headerTable.getCellFormatter().setWidth(0, counter, width);
      headerTable.getCellFormatter().addStyleName(0, counter, "wordWrap");
      HorizontalPanel headerPanel = new HorizontalPanel();
      Label name = new Label(column.getName());
      headerPanel.add(name);
      final Label sortImage = new Label();
      sortImage.setWidth("5px");
      sortImage.setStyleName("alignMiddle");
      if (order != null
          && column.getDomainProperty() != null
          && order
              .getSortProperty()
              .getProperty()
              .equals(column.getDomainProperty().getProperty())) {
        if (column.isPrimaryAsc()) {
          DOM.setInnerHTML(
              sortImage.getElement(), AbstractImagePrototype.create(images.sortUp()).getHTML());
        } else {
          DOM.setInnerHTML(
              sortImage.getElement(), AbstractImagePrototype.create(images.sortDown()).getHTML());
        }
      }
      headerPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
      headerPanel.add(sortImage);

      if (counter == 0 && isRadioButton) {
        name.setText("");
      }
      headerTable.setWidget(0, counter, headerPanel);
      if (column.isSortable()) {
        name.addStyleName("cursorHand");
        name.addClickHandler(
            new ClickHandler() {

              @Override
              public void onClick(ClickEvent arg0) {
                order = new Order(column.getDomainProperty(), !column.isPrimaryAsc());
                navBar.setOrder(order);
                column.setPrimaryAsc(!column.isPrimaryAsc());
                navBar.getListner().onPagination(navBar.getStartIndex(), visibleRecodrCount, order);
              }
            });
      }
      headerTable
          .getFlexCellFormatter()
          .setVerticalAlignment(0, counter, HasVerticalAlignment.ALIGN_TOP);
      headerTable
          .getCellFormatter()
          .setHorizontalAlignment(0, counter, HasHorizontalAlignment.ALIGN_LEFT);
      counter++;
    }
    headerTable.getRowFormatter().setStyleName(0, selectionStyle.header());
  }