Package org.eclipse.wb.internal.core.model.property.table

Examples of org.eclipse.wb.internal.core.model.property.table.PropertyTable


  //
  // Animate in PropertyTable
  //
  ////////////////////////////////////////////////////////////////////////////
  public void test_withPropertyTable_selectFromDropDown() throws Exception {
    PropertyTable propertyTable = new PropertyTable(TEST_COMBO_SHELL, SWT.NONE);
    try {
      Property property = getStyleProperty("setStyleName('second')");
      PropertyEditor propertyEditor = property.getEditor();
      // activate
      propertyTable.setInput(new Property[]{property});
      propertyTable.setActiveProperty(property);
      propertyTable.activateEditor(property, null);
      CComboBox combo = (CComboBox) getFieldValue(propertyEditor, "m_combo");
      Text comboText = (Text) getFieldValue(combo, "m_text");
      Table comboTable = ((TableViewer) getFieldValue(combo, "m_table")).getTable();
      // has items
      assertEquals(3, combo.getItemCount());
      assertFalse(combo.isDroppedDown());
      // drop-down in async
      waitEventLoop(0);
      assertTrue(combo.isDroppedDown());
      // "second" selected
      assertEquals(1, comboTable.getSelectionIndex());
      // move selection up/down
      {
        EventSender eventSender = new EventSender(comboText);
        // 0
        eventSender.keyDown(SWT.ARROW_UP);
        assertEquals(0, comboTable.getSelectionIndex());
        // 2
        eventSender.keyDown(SWT.ARROW_UP);
        assertEquals(2, comboTable.getSelectionIndex());
        // 0
        eventSender.keyDown(SWT.ARROW_DOWN);
        assertEquals(0, comboTable.getSelectionIndex());
        // done
        eventSender.keyDown('\r');
      }
      // "first" was selected
      assertEditor(getStyleSource("setStyleName('first')"));
    } finally {
      propertyTable.dispose();
    }
  }
View Full Code Here


      propertyTable.dispose();
    }
  }

  public void test_withPropertyTable_useText() throws Exception {
    PropertyTable propertyTable = new PropertyTable(TEST_COMBO_SHELL, SWT.NONE);
    try {
      Property property = getStyleProperty("setStyleName('second')");
      PropertyEditor propertyEditor = property.getEditor();
      // activate
      propertyTable.setInput(new Property[]{property});
      propertyTable.setActiveProperty(property);
      propertyTable.activateEditor(property, null);
      CComboBox combo = (CComboBox) getFieldValue(propertyEditor, "m_combo");
      Text comboText = (Text) getFieldValue(combo, "m_text");
      EventSender eventSender = new EventSender(comboText);
      // has items
      assertEquals(3, combo.getItemCount());
      assertFalse(combo.isDroppedDown());
      // drop-down in async
      waitEventLoop(0);
      assertTrue(combo.isDroppedDown());
      // send ESC, close
      {
        eventSender.keyDown(SWT.ESC);
        assertFalse(combo.isDroppedDown());
      }
      // set text
      combo.setSelectionText("myStyle");
      // apply text
      eventSender.keyDown('\r');
      assertEditor(getStyleSource("setStyleName('myStyle')"));
    } finally {
      propertyTable.dispose();
    }
  }
View Full Code Here

      propertyTable.dispose();
    }
  }

  public void test_withPropertyTable_useEscape() throws Exception {
    PropertyTable propertyTable = new PropertyTable(TEST_COMBO_SHELL, SWT.NONE);
    try {
      Property property = getStyleProperty("setStyleName('second')");
      PropertyEditor propertyEditor = property.getEditor();
      // activate
      propertyTable.setInput(new Property[]{property});
      propertyTable.setActiveProperty(property);
      propertyTable.activateEditor(property, null);
      CComboBox combo = (CComboBox) getFieldValue(propertyEditor, "m_combo");
      Text comboText = (Text) getFieldValue(combo, "m_text");
      EventSender eventSender = new EventSender(comboText);
      // active
      assertSame(propertyEditor, propertyTable.forTests_getActiveEditor());
      // drop-down in async
      waitEventLoop(0);
      assertTrue(combo.isDroppedDown());
      // send ESC, close
      {
        eventSender.keyDown(SWT.ESC);
        assertFalse(combo.isDroppedDown());
      }
      // send ESC, deactivate
      {
        eventSender.keyDown(SWT.ESC);
        assertSame(null, propertyTable.forTests_getActiveEditor());
      }
    } finally {
      propertyTable.dispose();
    }
  }
View Full Code Here

  }

  public void test_withPropertyTable_quickSearch() throws Exception {
    dontUseSharedGWTState();
    setFileContent("war/Module.css", getSource(".aaa {}", ".bb1 {}", ".bb2 {}", ".ccc {}"));
    PropertyTable propertyTable = new PropertyTable(TEST_COMBO_SHELL, SWT.NONE);
    try {
      Property property = getStyleProperty(null);
      PropertyEditor propertyEditor = property.getEditor();
      // activate
      propertyTable.setInput(new Property[]{property});
      propertyTable.setActiveProperty(property);
      // send "b", activate editor
      new EventSender(propertyTable).keyDown(0, 'b');
      // prepare controls
      CComboBox combo = (CComboBox) getFieldValue(propertyEditor, "m_combo");
      Text comboText = (Text) getFieldValue(combo, "m_text");
      Table comboTable = ((TableViewer) getFieldValue(combo, "m_table")).getTable();
      EventSender eventSender = new EventSender(comboText);
      // drop-down in async
      waitEventLoop(0);
      assertTrue(combo.isDroppedDown());
      // state after sending "b"
      assertEquals(2, comboTable.getItemCount());
      assertEquals(-1, comboTable.getSelectionIndex());
      // send DOWN, select "bb2"
      {
        eventSender.keyDown(SWT.ARROW_DOWN);
        assertEquals(0, comboTable.getSelectionIndex());
        eventSender.keyDown(SWT.ARROW_DOWN);
        assertEquals(1, comboTable.getSelectionIndex());
      }
      // apply selection
      eventSender.keyDown('\r');
      assertEditor(getStyleSource("setStyleName('bb2')"));
    } finally {
      propertyTable.dispose();
    }
  }
View Full Code Here

  /**
   * There was bug with entering exact name label of item and pressing Enter.
   */
  public void test_withPropertyTable_quickSearchExact() throws Exception {
    dontUseSharedGWTState();
    PropertyTable propertyTable = new PropertyTable(TEST_COMBO_SHELL, SWT.NONE);
    try {
      Property property = getStyleProperty(null);
      PropertyEditor propertyEditor = property.getEditor();
      // activate
      propertyTable.setInput(new Property[]{property});
      propertyTable.setActiveProperty(property);
      // send "s", activate editor
      new EventSender(propertyTable).keyDown(0, 's');
      // prepare controls
      CComboBox combo = (CComboBox) getFieldValue(propertyEditor, "m_combo");
      Text comboText = (Text) getFieldValue(combo, "m_text");
      Table comboTable = ((TableViewer) getFieldValue(combo, "m_table")).getTable();
      EventSender eventSender = new EventSender(comboText);
      // drop-down in async
      waitEventLoop(0);
      assertTrue(combo.isDroppedDown());
      // use exactly "second"
      comboText.setText("second");
      assertEquals(1, comboTable.getItemCount());
      assertEquals(-1, comboTable.getSelectionIndex());
      // apply selection
      eventSender.keyDown('\r');
      assertEditor(getStyleSource("setStyleName('second')"));
    } finally {
      propertyTable.dispose();
    }
  }
View Full Code Here

  //
  // CSS Style Editor
  //
  ////////////////////////////////////////////////////////////////////////////
  public void test_styleDialog() throws Exception {
    final PropertyTable propertyTable = new PropertyTable(TEST_COMBO_SHELL, SWT.NONE);
    try {
      final Property property = getStyleProperty(null);
      final PropertyEditor propertyEditor = property.getEditor();
      // activate
      propertyTable.setInput(new Property[]{property});
      propertyTable.setActiveProperty(property);
      propertyTable.activateEditor(property, null);
      // open dialog and use "Cancel"
      new UiContext().executeAndCheck(new UIRunnable() {
        public void run(UiContext context) throws Exception {
          openCssStyleEditorDialog(propertyTable, property, propertyEditor);
        }
      }, new UIRunnable() {
        public void run(UiContext context) throws Exception {
          context.useShell("CSS Style Editor");
          context.clickButton("Cancel");
        }
      });
      // open dialog and use "OK"
      new UiContext().executeAndCheck(new UIRunnable() {
        public void run(UiContext context) throws Exception {
          openCssStyleEditorDialog(propertyTable, property, propertyEditor);
        }
      }, new UIRunnable() {
        public void run(UiContext context) throws Exception {
          context.useShell("CSS Style Editor");
          context.clickButton("OK");
        }
      });
      assertEditor(getStyleSource(null));
      // open dialog and use "Apply"
      new UiContext().executeAndCheck(new UIRunnable() {
        public void run(UiContext context) throws Exception {
          openCssStyleEditorDialog(propertyTable, property, propertyEditor);
        }
      }, new UIRunnable() {
        public void run(UiContext context) throws Exception {
          context.useShell("CSS Style Editor");
          // make selection in rules
          org.eclipse.swt.widgets.List rulesList =
              context.findWidgets(org.eclipse.swt.widgets.List.class).get(1);
          rulesList.select(1);
          // apply style
          context.clickButton("Apply");
        }
      });
      // "second" was selected
      assertEditor(getStyleSource("setStyleName('second')"));
    } finally {
      propertyTable.dispose();
    }
  }
View Full Code Here

      }
    });
    assertEquals(getSource(".style {", "  color: cornflowerblue;", "}"), getFileContent(styleFile));
    // animate Text widget
    {
      PropertyTable propertyTable = new PropertyTable(TEST_COMBO_SHELL, SWT.NONE);
      try {
        PropertyEditor propertyEditor = property.getEditor();
        propertyTable.setInput(new Property[]{property});
        propertyTable.setActiveProperty(property);
        // press "b", activate editor
        new EventSender(propertyTable).keyDown(0, 'b');
        // set text and press Enter
        {
          CComboBox combo = (CComboBox) ReflectionUtils.getFieldObject(propertyEditor, "m_combo");
          Text comboText = (Text) ReflectionUtils.getFieldObject(combo, "m_text");
          // drop-down in async
          waitEventLoop(0);
          assertTrue(combo.isDroppedDown());
          // animate
          EventSender eventSender = new EventSender(comboText);
          eventSender.keyDown(SWT.ESC);
          combo.setSelectionText("green");
          eventSender.keyDown(SWT.CR);
        }
      } finally {
        propertyTable.dispose();
      }
      assertEquals(getSource(".style {", "  color: green;", "}"), getFileContent(styleFile));
    }
  }
View Full Code Here

TOP

Related Classes of org.eclipse.wb.internal.core.model.property.table.PropertyTable

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.