Package com.google.gdt.eclipse.designer.mobile.device.model

Examples of com.google.gdt.eclipse.designer.mobile.device.model.CategoryInfo


  /**
   * Adds new {@link DeviceInfo}.
   */
  private void onAddDevice() {
    final CategoryInfo targetCategory;
    {
      Object element = getSelectedElements().get(0);
      if (element instanceof CategoryInfo) {
        targetCategory = (CategoryInfo) element;
      } else if (element instanceof DeviceInfo) {
View Full Code Here


  private void onMove(int delta) {
    m_viewer.getTree().setRedraw(false);
    try {
      for (Object element : getSelectedElements()) {
        if (element instanceof CategoryInfo) {
          CategoryInfo category = (CategoryInfo) element;
          List<CategoryInfo> categories = DeviceManager.getCategories();
          int index = categories.indexOf(element);
          int targetIndex = index + delta;
          CategoryInfo nextCategory =
              targetIndex < categories.size() ? (CategoryInfo) categories.get(targetIndex) : null;
          commands_add(new CategoryMoveCommand(category, nextCategory));
        } else if (element instanceof DeviceInfo) {
          DeviceInfo device = (DeviceInfo) element;
          CategoryInfo category = device.getCategory();
          List<DeviceInfo> devices = category.getDevices();
          int index = devices.indexOf(device);
          if (index + delta < devices.size()) {
            commands_add(new DeviceMoveCommand(device, category, devices.get(index + delta)));
          } else {
            commands_add(new DeviceMoveCommand(device, category, null));
View Full Code Here

        int location = getCurrentLocation();
        if (m_dragCategory) {
          Assert.instanceOf(CategoryInfo.class, target);
          Assert.isTrue(location == LOCATION_BEFORE || location == LOCATION_AFTER);
          // prepare next category
          CategoryInfo nextCategory;
          {
            List<CategoryInfo> categories = DeviceManager.getCategories();
            int index = categories.indexOf(target);
            if (location == LOCATION_BEFORE) {
              nextCategory = categories.get(index);
            } else {
              nextCategory = GenericsUtils.getNextOrNull(categories, index);
            }
          }
          // add commands
          for (Object element : m_dragElements) {
            CategoryInfo category = (CategoryInfo) element;
            commands_add(new CategoryMoveCommand(category, nextCategory));
          }
        } else if (target instanceof CategoryInfo) {
          Assert.isTrue(location == LOCATION_ON);
          CategoryInfo targetCategory = (CategoryInfo) target;
          for (Object element : m_dragElements) {
            DeviceInfo device = (DeviceInfo) element;
            commands_add(new DeviceMoveCommand(device, targetCategory, null));
          }
        } else {
          DeviceInfo targetDevice = (DeviceInfo) target;
          CategoryInfo targetCategory = targetDevice.getCategory();
          // prepare next device
          DeviceInfo nextDevice;
          {
            List<DeviceInfo> entries = targetCategory.getDevices();
            int index = entries.indexOf(targetDevice);
            if (location == LOCATION_BEFORE) {
              nextDevice = entries.get(index);
            } else {
              nextDevice = GenericsUtils.getNextOrNull(entries, index);
View Full Code Here

      // work with Bundle
      {
        List<CategoryInfo> categories = DeviceManager.getCategories();
        assertThat(categories.size()).isGreaterThan(1);
        {
          CategoryInfo category = DeviceManager.getCategory("catA");
          assertEquals("catA", category.getId());
          assertEquals("Category A", category.getName());
          {
            List<DeviceInfo> devices = category.getDevices();
            assertThat(devices).hasSize(2);
            // devA
            {
              DeviceInfo device = devices.get(0);
              assertTrue(device.isContributed());
View Full Code Here

  public void test_ElementVisibilityCommand_Category() throws Exception {
    // add Category
    DeviceManager.commandsAdd(new CategoryAddCommand("newCat", "New category"));
    // visible initially
    {
      CategoryInfo category = DeviceManager.getCategory("newCat");
      assertTrue(category.isVisible());
      // show (will be removed by second command)
      DeviceManager.commandsAdd(new ElementVisibilityCommand(category, true));
      // hide
      DeviceManager.commandsAdd(new ElementVisibilityCommand(category, false));
      assertFalse(category.isVisible());
    }
    // reload
    DeviceManager.commandsWrite();
    DeviceManager.forceReload();
    // still hidden
    {
      CategoryInfo category = DeviceManager.getCategory("newCat");
      assertFalse(category.isVisible());
    }
  }
View Full Code Here

      assertFalse(category.isVisible());
    }
  }

  public void test_ElementVisibilityCommand_Device() throws Exception {
    CategoryInfo category = DeviceManager.getCategories().get(0);
    // add Device
    addDevice(category, "dev", "device");
    // visible initially
    {
      DeviceInfo device = DeviceManager.getDevice("dev");
View Full Code Here

  /**
   * Test for {@link DeviceAddCommand}.
   */
  public void test_DeviceAddCommand() throws Exception {
    CategoryInfo category = DeviceManager.getCategories().get(0);
    // add Device
    addDevice(category, "dev", "device");
    // can use new Device
    {
      DeviceInfo device = DeviceManager.getDevice("dev");
View Full Code Here

  /**
   * Test for {@link DeviceMoveCommand}.
   */
  public void test_DeviceMoveCommand() throws Exception {
    {
      CategoryInfo category = DeviceManager.getCategories().get(0);
      List<DeviceInfo> devices = category.getDevices();
      // add Device
      {
        addDevice(category, "devA", "a");
        addDevice(category, "devB", "b");
      }
      // has expected order
      DeviceInfo deviceA = DeviceManager.getDevice("devA");
      DeviceInfo deviceB = DeviceManager.getDevice("devB");
      assertEquals(devices.indexOf(deviceA), devices.indexOf(deviceB) - 1);
      // do move
      DeviceManager.commandsAdd(new DeviceMoveCommand(deviceB, category, deviceA));
      // new order
      assertEquals(devices.indexOf(deviceB), devices.indexOf(deviceA) - 1);
    }
    // reload
    DeviceManager.commandsWrite();
    DeviceManager.forceReload();
    // still has expected order
    {
      CategoryInfo category = DeviceManager.getCategories().get(0);
      List<DeviceInfo> devices = category.getDevices();
      DeviceInfo deviceA = DeviceManager.getDevice("devA");
      DeviceInfo deviceB = DeviceManager.getDevice("devB");
      assertEquals(devices.indexOf(deviceB), devices.indexOf(deviceA) - 1);
    }
  }
View Full Code Here

  /**
   * Test for {@link DeviceMoveCommand}.
   */
  public void test_DeviceMoveCommand_asLast() throws Exception {
    {
      CategoryInfo category = DeviceManager.getCategories().get(0);
      List<DeviceInfo> devices = category.getDevices();
      // add Device
      {
        addDevice(category, "devA", "a");
        addDevice(category, "devB", "b");
      }
      // has expected order
      DeviceInfo deviceA = DeviceManager.getDevice("devA");
      assertEquals(devices.indexOf(deviceA), devices.size() - 2);
      // do move
      DeviceManager.commandsAdd(new DeviceMoveCommand(deviceA, category, null));
      // new order
      assertEquals(devices.indexOf(deviceA), devices.size() - 1);
    }
    // reload
    DeviceManager.commandsWrite();
    DeviceManager.forceReload();
    // still has expected order
    {
      CategoryInfo category = DeviceManager.getCategories().get(0);
      List<DeviceInfo> devices = category.getDevices();
      DeviceInfo deviceA = DeviceManager.getDevice("devA");
      assertEquals(devices.indexOf(deviceA), devices.size() - 1);
    }
  }
View Full Code Here

  /**
   * Test for {@link DeviceMoveCommand}.
   */
  public void test_DeviceMoveCommand_moveBeforeItself() throws Exception {
    CategoryInfo category = DeviceManager.getCategories().get(0);
    List<DeviceInfo> devices = category.getDevices();
    // add Device
    addDevice(category, "devA", "a");
    // has expected order
    DeviceInfo deviceA = DeviceManager.getDevice("devA");
    int index = devices.indexOf(deviceA);
View Full Code Here

TOP

Related Classes of com.google.gdt.eclipse.designer.mobile.device.model.CategoryInfo

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.