![JAR search and dependency download from the Maven repository](/logo.png)
com.objogate.wl.swing.driver.WindowsFileChooserUIDriver 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.JToggleButton;
import org.hamcrest.Description;
import org.hamcrest.TypeSafeMatcher;
class WindowsFileChooserUIDriver extends MetalFileChooserUIDriver {
private static final String DESKTOP_BUTTON_TEXT = "Desktop";
private static final String HOME_BUTTON_TEXT = "My Documents";
public WindowsFileChooserUIDriver(JFileChooserDriver jFileChooserDriver) {
super(jFileChooserDriver);
}
@SuppressWarnings("unchecked")
@Override
public void desktop() {
new AbstractButtonDriver(parentOrOwner, JToggleButton.class,
new HtmlToggleButtonMatcher(DESKTOP_BUTTON_TEXT)).click();
}
@Override
public void home() {
throw new UnsupportedOperationException("There is no 'Home' button in the Windows L&F");
}
@SuppressWarnings("unchecked")
@Override
public void documents() {
new AbstractButtonDriver(parentOrOwner, JToggleButton.class,
new HtmlToggleButtonMatcher(HOME_BUTTON_TEXT)).click();
}
private class HtmlToggleButtonMatcher extends TypeSafeMatcher {
private String desktopButtonText;
public HtmlToggleButtonMatcher(String desktopButtonText) {
this.desktopButtonText = desktopButtonText;
}
@Override
public boolean matchesSafely(JToggleButton jButton) {
return jButton.getText().equals(wrapInWindowsHtml(desktopButtonText));
}
public void describeTo(Description description) {
description.appendText("Button with text '" + wrapInWindowsHtml(desktopButtonText) + "'");
}
private String wrapInWindowsHtml(String buttonText) {
return "" + buttonText + " ";
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy