![JAR search and dependency download from the Maven repository](/logo.png)
com.objogate.wl.swing.driver.AbstractButtonDriver Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of windowlicker-swing Show documentation
Show all versions of windowlicker-swing Show documentation
This is the Windowlicker Swing library.
The newest version!
package com.objogate.wl.swing.driver;
import javax.swing.AbstractButton;
import java.awt.Component;
import org.hamcrest.Description;
import org.hamcrest.Matcher;
import org.hamcrest.Matchers;
import org.hamcrest.TypeSafeMatcher;
import com.objogate.wl.Prober;
import com.objogate.wl.Query;
import com.objogate.wl.internal.PropertyQuery;
import com.objogate.wl.swing.ComponentSelector;
import com.objogate.wl.swing.gesture.GesturePerformer;
import com.objogate.wl.swing.internal.query.MnemonicQuery;
import com.objogate.wl.swing.internal.query.TextQuery;
public class AbstractButtonDriver extends JComponentDriver
implements TextQuery, MnemonicQuery {
public AbstractButtonDriver(GesturePerformer gesturePerformer, ComponentSelector componentSelector, Prober prober) {
super(gesturePerformer, componentSelector, prober);
}
public AbstractButtonDriver(ComponentDriver extends Component> parentOrOwner, ComponentSelector componentSelector) {
super(parentOrOwner, componentSelector);
}
public AbstractButtonDriver(ComponentDriver extends Component> parentOrOwner, Class componentType, Matcher super T>... matchers) {
super(parentOrOwner, componentType, matchers);
}
public void click() {
leftClickOnComponent();
}
public void hasText(Matcher matcher) {
has(text(), matcher);
}
private Query text() {
return new Query() {
public String query(T button) {
return button.getText();
}
public void describeTo(Description description) {
description.appendText("text");
}
};
}
public void mnemonic(Matcher matcher) {
has(mnemonic(), matcher);
}
private static Query mnemonic() {
return new PropertyQuery("mnemonic") {
public Character query(B button) {
return (char) button.getMnemonic();
}
};
}
public void isChecked() {
is(selected());
}
public void isNotChecked() {
is(Matchers.not(selected()));
}
private TypeSafeMatcher selected() {
return new TypeSafeMatcher() {
@Override
public boolean matchesSafely(AbstractButton item) {
return item.isSelected();
}
public void describeTo(Description description) {
description.appendText("is selected");
}
};
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy