Beispiel #1
0
  private void update() {
    // Update the older/newer buttons & label.
    int count = MailItems.getMailItemCount();
    int max = startIndex + VISIBLE_EMAIL_COUNT;
    if (max > count) {
      max = count;
    }

    // Update the nav bar.
    navBar.update(startIndex, count, max);

    // Show the selected emails.
    int i = 0;
    for (; i < VISIBLE_EMAIL_COUNT; ++i) {
      // Don't read past the end.
      if (startIndex + i >= MailItems.getMailItemCount()) {
        break;
      }

      MailItem item = MailItems.getMailItem(startIndex + i);

      // Add a new row to the table, then set each of its columns to the
      // email's sender and subject values.
      table.setText(i, 0, item.sender);
      table.setText(i, 1, item.email);
      table.setText(i, 2, item.subject);
    }

    // Clear any remaining slots.
    for (; i < VISIBLE_EMAIL_COUNT; ++i) {
      table.removeRow(table.getRowCount() - 1);
    }
  }
  @Test
  public void testFilterAspectsInNavBar() {

    GIVEN("Sam-+->Bob as Work");
    Relation.forUser(Users.Pod2.sam).toUser(Users.Pod2.bob, WORK).doNotLogOut().ensure();

    GIVEN("Work aspect post from Sam is added after setup relation");
    Menu.openStream();
    Feed.ensureNoPost(Users.Pod2.sam, Phrases.POST_FOR_WORK);
    Feed.addAspectPost(WORK, Phrases.POST_FOR_WORK);

    GIVEN("Bob-+->Sam as Friends ");
    Relation.forUser(Users.Pod2.bob).toUser(Users.Pod2.sam, FRIENDS).doNotLogOut().ensure();

    GIVEN("Friends and Family aspects post from Bob are added after setup relation");
    Menu.openStream();
    Feed.ensureNoPost(Users.Pod2.bob, Phrases.POST_FOR_FRIENDS);
    Feed.addAspectPost(FRIENDS, Phrases.POST_FOR_FRIENDS);
    Feed.ensureNoPost(Users.Pod2.bob, Phrases.POST_FOR_FAMILY);
    Feed.addAspectPost(FAMILY, Phrases.POST_FOR_FAMILY);

    WHEN("In NavBar aspects list all aspects is deselected");
    NavBar.openMyAspects();
    Aspects.toggleAll();
    Aspects.assertToggleAllText("Select all");

    THEN("All posts in all aspects is shown");
    Feed.assertPost(Users.Pod2.sam, Phrases.POST_FOR_WORK);
    Feed.assertPost(Users.Pod2.bob, Phrases.POST_FOR_FRIENDS);
    Feed.assertPost(Users.Pod2.bob, Phrases.POST_FOR_FAMILY);

    WHEN("In NavBar aspects list some aspects is selected");
    Aspects.toggleAspect(ACQUAINTANCES);
    Aspects.toggleAspect(FRIENDS);

    THEN("Author's posts limited in these aspects is shown");
    AND("posts of users linked in these aspects is shown");
    Feed.assertPost(Users.Pod2.sam, Phrases.POST_FOR_WORK);
    Feed.assertPost(Users.Pod2.bob, Phrases.POST_FOR_FRIENDS);
    Feed.assertNoPost(Users.Pod2.bob, Phrases.POST_FOR_FAMILY);

    WHEN("In NavBar aspects list some aspect is deselected");
    Aspects.toggleAspect(FRIENDS);

    THEN("Author's posts limited in this aspect is not shown");
    AND("posts of users linked in this aspect is not shown");
    Feed.assertNoPost(Users.Pod2.sam, Phrases.POST_FOR_WORK);
    Feed.assertNoPost(Users.Pod2.bob, Phrases.POST_FOR_FRIENDS);
    Feed.assertNoPost(Users.Pod2.bob, Phrases.POST_FOR_FAMILY);

    WHEN("In NavBar aspects list all aspects is selected");
    Aspects.toggleAll();
    Aspects.assertToggleAllText("Deselect all");

    THEN("All posts in all aspects is shown");
    Feed.assertPost(Users.Pod2.sam, Phrases.POST_FOR_WORK);
    Feed.assertPost(Users.Pod2.bob, Phrases.POST_FOR_FRIENDS);
    Feed.assertPost(Users.Pod2.bob, Phrases.POST_FOR_FAMILY);
  }
  @Test
  public void testAddAspectInNavBar() {

    GIVEN("Aspect " + Phrases.ASPECT1 + " is not used by author");
    Diaspora.ensureSignInAs(Users.Pod2.bob);
    Aspects.ensureNoAspect(Phrases.ASPECT1);

    GIVEN("Post in aspect " + Phrases.ASPECT1 + " does not exist");
    Feed.ensureNoPost(Users.Pod2.bob, Phrases.POST_IN_ASPECT1);

    WHEN("New aspest is added");
    NavBar.openMyAspects();
    Aspects.add(Phrases.ASPECT1);
    Contacts.assertAspect(Phrases.ASPECT1); // this check for wait moment when operation is done

    EXPECT("Added aspect is shown in Nav Bar");
    Menu.openStream();
    waitStreamOpening(); // this wait for wait moment when stream will be loaded
    NavBar.openMyAspects();
    Aspects.assertAspectInNavBar(
        Phrases.ASPECT1); // this check for wait moment when stream will be loaded

    THEN("New aspect can be used for contact setup");
    Menu.search(Users.Pod2.sam.fullName);
    Contact.ensureAspectsForContact(Phrases.ASPECT1);

    EXPECT("New aspect can be used for post setup");
    Menu.openStream();
    Feed.addAspectPost(Phrases.ASPECT1, Phrases.POST_IN_ASPECT1);
    Feed.assertPost(Users.Pod2.bob, Phrases.POST_IN_ASPECT1);

    WHEN("New aspect is selected in NavBar aspects list");
    NavBar.openMyAspects();
    Aspects.toggleAspect(Phrases.ASPECT1);

    THEN("Limited post in this aspect is shown in stream");
    Feed.assertPost(Users.Pod2.bob, Phrases.POST_IN_ASPECT1);

    EXPECT("Limited in aspect post is available for linked in this aspect user");
    Diaspora.ensureSignInAs(Users.Pod2.sam);
    Menu.search(Users.Pod2.bob.fullName);
    Feed.assertPost(Users.Pod2.bob, Phrases.POST_IN_ASPECT1);
    Menu.ensureLogOut();
  }
  @Test
  public void testSwitchToEditModeInNavBar() {

    WHEN("Aspect is in edit mode");
    Diaspora.ensureSignInAs(Users.Pod2.bob);
    NavBar.openMyAspects();
    Aspects.switchToEditMode(FRIENDS);

    THEN("Contact site with this aspect is loaded");
    Contacts.assertAspect(FRIENDS);
  }
Beispiel #5
0
  public void toggleView(NavBar menu) {
    menu.tab.setVisibility(View.VISIBLE);
    if (menu.tabContent.isShown()) {
      collapse(menu.tabContent);
      toggleTabIndicator(menu.tab, 0);

    } else {
      expand(menu.tabContent);
      toggleTabIndicator(menu.tab, 2500);
      if (lastMenu != null) {
        if (!lastMenu.equals(menu)) {
          collapse(lastMenu.tabContent);
          toggleTabIndicator(lastMenu.tab, 0);
        }
      }
    }
    lastMenu = menu;
  }
Beispiel #6
0
  /** Registers av given view to the navigator and adds it to the NavBar */
  private void addView(Class<? extends View> viewClass) {
    ViewConfig viewConfig = viewClass.getAnnotation(ViewConfig.class);

    switch (viewConfig.createMode()) {
      case ALWAYS_NEW:
        navigator.addView(viewConfig.uri(), viewClass);
        break;
      case LAZY_INIT:
        navigator.addProvider(new LazyProvider(viewConfig.uri(), viewClass));
        break;
      case EAGER_INIT:
        try {
          navigator.addView(viewConfig.uri(), viewClass.newInstance());
        } catch (Exception e) {
          e.printStackTrace();
        }
    }
    navBar.addView(viewConfig.uri(), viewConfig.displayName());
  }
Beispiel #7
0
 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);
 }
Beispiel #8
0
 public int getStartIndex() {
   return navBar.getStartIndex();
 }
Beispiel #9
0
  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);
      }
    }
  }