Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Copyright 2012-2015 the original author or authors.
 
 package org.assertj.swing.jide.grids;
 
 
 
 
 import  com.jidesoft.combobox.ListComboBox;

A AssertJ-Swing fixture for driving a com.jidesoft.combobox.ListComboBox.

Author(s):
Peter Murray
 
 public class ListComboBoxFixture extends
     implements ItemGroupFixture {
 
   public ListComboBoxFixture(Robot robotString comboBoxName) {
     super(ListComboBoxFixture.classrobotcomboBoxName, ListComboBox.class);
     createDriver(robot);
   }
 
   public ListComboBoxFixture(Robot robot, ListComboBox target) {
     super(ListComboBoxFixture.classrobottarget);
     createDriver(robot);
   }

  
Simulates a user entering the specified text in the ListComboBox, replacing any text. This action is executed only if the ListComboBox is editable.

Parameters:
text the text to enter.
Returns:
this fixture.
Throws:
IllegalStateException if this fixture's ListComboBox is disabled.
IllegalStateException if this fixture's ListComboBox is not showing on the screen.
IllegalStateException if this fixture's ListComboBox is not editable.
 
   public ListComboBoxFixture replaceText(String text) {
     driver().replaceText(target(), text);
     return this;
   }

  
Simulates a user selecting the text in the ListComboBox. This action is executed only if the ListComboBox is editable.

Returns:
this fixture.
Throws:
IllegalStateException if this fixture's ListComboBox is disabled.
IllegalStateException if this fixture's ListComboBox is not showing on the screen.
IllegalStateException if this fixture's ListComboBox is not editable.
 
     driver().selectAllText(target());
     return this;
   }

  
Simulates a user entering the specified text in this fixture's JComboBox. This action is executed only if the JComboBox is editable.

Parameters:
text the text to enter.
Returns:
this fixture.
Throws:
IllegalStateException if this fixture's JComboBox is disabled.
IllegalStateException if this fixture's JComboBox is not showing on the screen.
IllegalStateException if this fixture's JComboBox is not editable.
 
   public ListComboBoxFixture enterText(String text) {
     driver().enterText(target(), text);
     return this;
   }
 
   public String editorText() {
     return driver().getEditorText(target());
   }
    driver().requireEditorText(target(), text);
    return this;
  }
    driver().requirePopupVisible(target(), true);
    return this;
  }
    driver().requirePopupVisible(target(), false);
    return this;
  }

  
Finds and returns the JList in the pop-up raised by this fixture's JComboBox.

Returns:
the JList in the pop-up raised by this fixture's JComboBox.
Throws:
org.assertj.swing.exception.ComponentLookupException if the JList in the pop-up could not be found.
  public JList list() {
    return driver().getList(target());
  }
  public ItemGroupFixture requireItemCount(int expected) {
    driver().requireItemCount(target(), expected);
    return this;
  }

  
Simulates a user selecting an item in this fixture's JComboBox.

Parameters:
index the index of the item to select.
Returns:
this fixture.
Throws:
IllegalStateException if this fixture's JComboBox is disabled.
IllegalStateException if this fixture's JComboBox is not showing on the screen.
IndexOutOfBoundsException if the given index is negative or greater than the index of the last item in the JComboBox.
  public ListComboBoxFixture selectItem(int index) {
    driver().selectItem(target(), index);
    return this;
  }

  
Simulates a user selecting an item in this fixture's JComboBox. Value matching is performed by this fixture's org.assertj.swing.cell.JComboBoxCellReader.

Parameters:
text the text of the item to select.
Returns:
this fixture.
Throws:
org.assertj.swing.exception.LocationUnavailableException if an element matching the given text cannot be found.
IllegalStateException if this fixture's JComboBox is disabled.
IllegalStateException if this fixture's JComboBox is not showing on the screen.
See also:
cellReader(org.assertj.swing.jide.grids.driver.AbstractComboBoxCellReader)
    driver().selectItem(target(), text);
    return this;
  }

  
Returns the String representation of the value of an item in this fixture's JComboBox, using this fixture's org.assertj.swing.cell.JComboBoxCellReader.

Parameters:
index the index of the item to return.
Returns:
the String representation of the value of an item in this fixture's JComboBox.
Throws:
IndexOutOfBoundsException if the given index is negative or greater than the index of the last item in the JComboBox.
See also:
cellReader(org.assertj.swing.jide.grids.driver.AbstractComboBoxCellReader)
  public String valueAt(int index) {
    return driver().value(target(), index);
  }
    // Set the selection to -1
    throw new UnsupportedOperationException("Not Yet Implemented");
  }
  public ItemGroupFixture selectItem(Pattern pattern) {
    throw new UnsupportedOperationException("Not Yet Implemented");
  }
  public ItemGroupFixture requireSelection(Pattern pattern) {
    throw new UnsupportedOperationException("Not Yet Implemented");
  }
  public ItemGroupFixture requireSelection(int index) {
    throw new UnsupportedOperationException("Not Yet Implemented");
  }

  
Asserts that this fixture's JComboBox is editable.

Returns:
this fixture.
Throws:
AssertionError if this fixture's JComboBox is not editable.
    return this;
  }

  
Asserts that this fixture's JComboBox is not editable.

Returns:
this fixture.
Throws:
AssertionError if this fixture's JComboBox is editable.
    return this;
  }

  
Verifies that the String representation of the selected item in this fixture's JComboBox matches the given text.

Parameters:
value the text to match.
Returns:
this fixture.
Throws:
AssertionError if the selected item does not match the given text.
See also:
cellReader(org.assertj.swing.jide.grids.driver.AbstractComboBoxCellReader)
    driver().requireSelection(target(), value);
    return this;
  }
  public ListComboBoxFixture requireText(String value) {
    driver().requireText(target(), value);
    return this;
  }

  
Verifies that this fixture's JComboBox does not have any selection.

Returns:
this fixture.
Throws:
AssertionError if this fixture's JComboBox has a selection.
    return this;
  }

  
Updates the implementation of org.assertj.swing.jide.grids.driver.AbstractComboBoxCellReader to use when comparing internal values of this fixture's ListComboBox and the values expected in a test. The default implementation to use is org.assertj.swing.jide.grids.driver.AbstractComboBoxCellReader.

Parameters:
cellReader the new AbstractComboBoxCellReader to use.
Returns:
this fixture.
Throws:
NullPointerException if cellReader is null.
    driver().cellReader(cellReader);
    return this;
  }
  public String[] contents() {
    return driver().getContents(target());
  }
  protected ListComboBoxDriver createDriver(Robot robot) {
    return new ListComboBoxDriver(robot);
  }
    return this;
  }
New to GrepCode? Check out our FAQ X