@Override
  public AbsPage zTreeItem(Action action, Button option, IItem folder) throws HarnessException {

    tracer.trace("Click " + action + " then " + option + " on folder " + folder.getName());

    // Validate the arguments
    if ((action == null) || (option == null) || (folder == null)) {
      throw new HarnessException("Must define an action, option, and addressbook");
    }

    if (folder instanceof FolderMountpointItem) {
      return (zTreeItem(action, option, (FolderMountpointItem) folder));
    } else if (folder instanceof SavedSearchFolderItem) {
      return (zTreeItem(action, option, (SavedSearchFolderItem) folder));
      // } else if ( folder instanceof ZimletItem ) {
      //	return (zTreeItem(action, option, (ZimletItem)folder));
    } else if (folder instanceof TagItem) {
      return (zTreeItem(action, option, (TagItem) folder));
    } else if (folder instanceof FolderItem) { // FolderItem needs to go last
      return (zTreeItem(action, option, (FolderItem) folder));
    }

    throw new HarnessException(
        "Must use TagItem FolderItem or SavedSearchFolderItem or ZimletItem as argument, but was "
            + folder.getClass());
  }
Beispiel #2
0
 public IItem findById(int itemId) {
   for (IItem item : inventory.values()) {
     if (item.getItemId() == itemId) {
       return item;
     }
   }
   return null;
 }
Beispiel #3
0
 public int countById(int itemId) {
   int possesed = 0;
   for (IItem item : inventory.values()) {
     if (item.getItemId() == itemId) {
       possesed += item.getQuantity();
     }
   }
   return possesed;
 }
Beispiel #4
0
 @Override
 public int compareTo(IItem other) {
   if (this.id < other.getItemId()) {
     return -1;
   } else if (this.id > other.getItemId()) {
     return 1;
   }
   return 0;
 }
Beispiel #5
0
 public List<IItem> listById(int itemId) {
   List<IItem> ret = new ArrayList<IItem>();
   for (IItem item : inventory.values()) {
     if (item.getItemId() == itemId) {
       ret.add(item);
     }
   }
   if (ret.size() > 1) {
     Collections.sort(ret);
   }
   return ret;
 }
Beispiel #6
0
 private void swap(IItem source, IItem target) {
   inventory.remove(source.getPosition());
   inventory.remove(target.getPosition());
   byte swapPos = source.getPosition();
   source.setPosition(target.getPosition());
   target.setPosition(swapPos);
   inventory.put(source.getPosition(), source);
   inventory.put(target.getPosition(), target);
 }
Beispiel #7
0
 public byte addItem(IItem item) {
   byte slotId = getNextFreeSlot();
   if (slotId < 0) {
     return -1;
   }
   inventory.put(slotId, item);
   item.setPosition(slotId);
   return slotId;
 }
  public AbsPage zTreeItem(Action action, IItem item, boolean isRowAdded) throws HarnessException {

    tracer.trace("Click " + action + " on folder " + item.getName());

    String treeItemLocator = Locators.briefcaseTreeView + "]";

    AbsPage page = zTreeItem(action, item);

    zWaitForElementPresent(treeItemLocator);

    String listItemLocator = "css=div[id^=zl__BDLV][class=DwtListView-Rows]";

    if (isRowAdded) listItemLocator += ">div[id^=zli__BDLV][class^=Row]";

    zWaitForElementPresent(listItemLocator);

    return page;
  }
Beispiel #9
0
 public void removeItem(byte slot, short quantity, boolean allowZero) {
   IItem item = inventory.get(slot);
   if (item == null) { // TODO is it ok not to throw an exception here?
     return;
   }
   item.setQuantity((short) (item.getQuantity() - quantity));
   if (item.getQuantity() < 0) {
     item.setQuantity((short) 0);
   }
   if (item.getQuantity() == 0 && !allowZero) {
     removeSlot(slot);
   }
 }
Beispiel #10
0
 public void addFromDB(IItem item) {
   if (item.getPosition() < 0 && !type.equals(MapleInventoryType.EQUIPPED)) {
     throw new RuntimeException("Item with negative position in non-equipped IV wtf?");
   }
   inventory.put(item.getPosition(), item);
 }
  @Override
  public AbsPage zTreeItem(Action action, Button option, IItem item) throws HarnessException {
    // Validate the arguments
    if ((action == null) || (option == null) || (item == null)) {
      throw new HarnessException(
          "zTreeItem(Action, Button, IItem): Must define an action, option, and item");
    }

    logger.info(
        myPageName() + " zTreeItem(" + action + ", " + option + ", " + item.getName() + ")");

    tracer.trace("Click " + action + " then " + option + " on item " + item.getName());

    AbsPage page = null;
    String actionLocator = null;
    String optionLocator = null;

    if (item instanceof TagItem) {
      actionLocator =
          "css=td[id^=zti__main_Briefcase__]:contains(" + ((TagItem) item).getName() + ")";
    } else if (item instanceof FolderItem) {
      actionLocator =
          "css=td[id^=zti__main_Briefcase__" + ((FolderItem) item).getId() + "_textCell]";
    } else {
      throw new HarnessException("Must use IItem as argument, but was " + item.getClass());
    }

    zWaitForElementVisible(actionLocator);

    if (action == Action.A_RIGHTCLICK) {
      this.zRightClickAt(actionLocator, "0,0");
    } else {
      throw new HarnessException("implement me! " + action + ": not implemented");
    }

    if (option == Button.B_TREE_NEWTAG) {

      optionLocator = Locators.zNewTagTreeMenuItem;

      page = new DialogTag(MyApplication, ((AppAjaxClient) MyApplication).zPageBriefcase);

    } else if (option == Button.B_TREE_RENAMETAG) {

      optionLocator = Locators.zRenameTagTreeMenuItem;

      page = new DialogRenameTag(MyApplication, ((AppAjaxClient) MyApplication).zPageBriefcase);
    } else if (option == Button.B_TREE_DELETE) {

      optionLocator = Locators.zDeleteTreeMenuItem;

      if (item instanceof TagItem) {
        page =
            new DialogWarning(
                DialogWarning.DialogWarningID.DeleteTagWarningMessage,
                MyApplication,
                ((AppAjaxClient) MyApplication).zPageBriefcase);
      }
    } else if (option == Button.B_TREE_NEWFOLDER) {

      optionLocator = Locators.zNewFolderTreeMenuItem;

      page =
          new DialogCreateBriefcaseFolder(
              MyApplication, ((AppAjaxClient) MyApplication).zPageBriefcase);

    } else if (option == Button.B_TREE_EDIT_PROPERTIES) {

      optionLocator = Locators.zEditPropertiesTreeMenuItem;

      page =
          new DialogEditProperties(MyApplication, ((AppAjaxClient) MyApplication).zPageBriefcase);

    } else {
      throw new HarnessException("button " + option + " not yet implemented");
    }

    this.zWaitForBusyOverlay();

    zWaitForElementVisible(optionLocator);

    // Default behavior. Click the locator
    zClickAt(optionLocator, "");

    // If there is a busy overlay, wait for that to finish
    this.zWaitForBusyOverlay();

    if (page != null) {
      // Wait for the page to become active, if it was specified
      page.zWaitForActive();
    }
    return (page);
  }
  @Override
  public AbsPage zTreeItem(Action action, IItem item) throws HarnessException {
    // Validate the arguments
    if ((action == null) || (item == null)) {
      throw new HarnessException("zTreeItem(Action, IItem): Must define an action, and item");
    }
    logger.info(myPageName() + " zTreeItem(" + action + ", " + item.getName() + ")");

    tracer.trace("Click " + action + " on item " + item.getName());

    AbsPage page = null;
    String locator = null;

    if (item instanceof TagItem) {
      locator = "css=td[id^=zti__main_Briefcase__]:contains(" + ((TagItem) item).getName() + ")";
    } else if (item instanceof FolderItem) {
      locator = Locators.briefcaseTreeView + ((FolderItem) item).getId() + "_imageCell]";

    } else if (item instanceof LinkItem) {
      page = new DialogFindShares(MyApplication, ((AppAjaxClient) MyApplication).zPageBriefcase);
      if (ZimbraSeleniumProperties.isWebDriver()) {
        clickBy(By.id("ztih__main_Briefcase__BRIEFCASE"), By.linkText("Find Shares..."));
        return page;
      } else {
        locator = "css=div[id=ztih__main_Briefcase__BRIEFCASE] a[id$=_addshare_link]";
        page = new DialogFindShares(MyApplication, ((AppAjaxClient) MyApplication).zPageBriefcase);
      }

      if (!this.sIsElementPresent(locator)) {
        throw new HarnessException("Unable to locate link in the tree " + locator);
      }

      this.sClickAt(locator, "0,0");

      zWaitForBusyOverlay();

      return page;

    } else {
      throw new HarnessException("Must use IItem as argument, but was " + item.getClass());
    }

    if (action == Action.A_LEFTCLICK) {

      zWaitForBusyOverlay();

      // FALL THROUGH
    } else if (action == Action.A_RIGHTCLICK) {

      if (!this.sIsElementPresent(locator))
        throw new HarnessException("Unable to locate folder in the tree " + locator);

      // Select the folder
      this.zRightClickAt(locator, "0,0");

      // return a context menu
      return (new ContextMenu(MyApplication));
    } else {
      throw new HarnessException("Action " + action + " not yet implemented");
    }

    if (!this.sIsElementPresent(locator))
      throw new HarnessException("Unable to locate folder in the tree " + locator);

    // Default behavior. Click the locator
    zClickAt(locator, "0,0");

    // If there is a busy overlay, wait for that to finish
    zWaitForBusyOverlay();

    return (page);
  }