use of org.apache.pivot.wtk.PushButton in project pivot by apache.
the class BackgroundTasks method initialize.
@Override
public void initialize(Map<String, Object> namespace, URL location, Resources resources) {
activityIndicator = (ActivityIndicator) namespace.get("activityIndicator");
executeSynchronousButton = (PushButton) namespace.get("executeSynchronousButton");
executeAsynchronousButton = (PushButton) namespace.get("executeAsynchronousButton");
executeSynchronousButton.getButtonPressListeners().add(new ButtonPressListener() {
@Override
public void buttonPressed(Button button) {
activityIndicator.setActive(true);
System.out.println("Starting synchronous task execution.");
SleepTask sleepTask = new SleepTask();
String result = null;
try {
result = sleepTask.execute();
} catch (TaskExecutionException exception) {
System.err.println(exception);
}
System.out.println("Synchronous task execution complete: \"" + result + "\"");
activityIndicator.setActive(false);
}
});
executeAsynchronousButton.getButtonPressListeners().add(new ButtonPressListener() {
@Override
public void buttonPressed(Button button) {
activityIndicator.setActive(true);
setEnabled(false);
System.out.println("Starting asynchronous task execution.");
SleepTask sleepTask = new SleepTask();
TaskListener<String> taskListener = new TaskListener<String>() {
@Override
public void taskExecuted(Task<String> task) {
activityIndicator.setActive(false);
setEnabled(true);
System.out.println("Synchronous task execution complete: \"" + task.getResult() + "\"");
}
@Override
public void executeFailed(Task<String> task) {
activityIndicator.setActive(false);
setEnabled(true);
System.err.println(task.getFault());
}
};
sleepTask.execute(new TaskAdapter<>(taskListener));
}
});
}
use of org.apache.pivot.wtk.PushButton in project pivot by apache.
the class FileBrowserWithCharsetTest method startup.
@Override
public void startup(Display display, Map<String, String> properties) throws Exception {
BoxPane windowContent = new BoxPane();
windowContent.getStyles().put(Style.verticalAlignment, VerticalAlignment.CENTER);
final Checkbox showHiddenCheckbox = new Checkbox("Show hidden files");
windowContent.add(showHiddenCheckbox);
PushButton button = new PushButton("Open File Browser");
button.getStyles().put(Style.padding, "[2, 4, 2, 4]");
button.getButtonPressListeners().add(new ButtonPressListener() {
@Override
public void buttonPressed(Button buttonArgument) {
final Window window = Window.getActiveWindow();
final FileBrowserWithCharsetTest fileBrowserSheet = new FileBrowserWithCharsetTest(FileBrowserSheet.Mode.OPEN);
fileBrowserSheet.getStyles().put(Style.showHiddenFiles, showHiddenCheckbox.isSelected());
fileBrowserSheet.open(window, new SheetCloseListener() {
@Override
public void sheetClosed(Sheet sheet) {
if (sheet.getResult()) {
Sequence<File> selectedFiles = fileBrowserSheet.getSelectedFiles();
ListView listView = new ListView();
listView.setListData(new ArrayList<>(selectedFiles));
listView.setSelectMode(ListView.SelectMode.NONE);
listView.getStyles().put(Style.backgroundColor, null);
Alert.alert(MessageType.INFO, "You selected (charset " + fileBrowserSheet.getCharsetName() + "):", listView, window);
} else {
Alert.alert(MessageType.INFO, "You didn't select anything.", window);
}
}
});
}
});
windowContent.add(button);
frame = new Frame(windowContent);
frame.setMaximized(true);
frame.open(display);
}
use of org.apache.pivot.wtk.PushButton in project pivot by apache.
the class VFSBrowserTest method startup.
@Override
public void startup(final Display display, final Map<String, String> properties) throws Exception {
BoxPane windowContent = new BoxPane();
windowContent.getStyles().put(Style.verticalAlignment, VerticalAlignment.CENTER);
final Checkbox showHiddenCheckbox = new Checkbox("Show hidden files");
windowContent.add(showHiddenCheckbox);
PushButton button = new PushButton("Open File Browser");
button.getStyles().put(Style.padding, "[2, 4, 2, 4]");
button.getButtonPressListeners().add(new ButtonPressListener() {
@Override
public void buttonPressed(final Button buttonArgument) {
try {
final VFSBrowserSheet vfsBrowserSheet = new VFSBrowserSheet(VFSBrowserSheet.Mode.OPEN);
vfsBrowserSheet.getStyles().put(Style.showHiddenFiles, showHiddenCheckbox.isSelected());
vfsBrowserSheet.open(frame, new SheetCloseListener() {
@Override
public void sheetClosed(final Sheet sheet) {
if (sheet.getResult()) {
Sequence<FileObject> selectedFiles = vfsBrowserSheet.getSelectedFiles();
ListView listView = new ListView();
listView.setListData(new ArrayList<>(selectedFiles));
listView.setSelectMode(ListView.SelectMode.NONE);
listView.getStyles().put(Style.backgroundColor, null);
Alert.alert(MessageType.INFO, "You selected:", listView, frame);
} else {
Alert.alert(MessageType.INFO, "You didn't select anything.", frame);
}
}
});
} catch (FileSystemException fse) {
Alert.alert(MessageType.ERROR, String.format("File System Exception: %1$s", fse.getMessage()), frame);
}
}
});
windowContent.add(button);
frame = new Frame(windowContent);
frame.setMaximized(true);
frame.open(display);
}
use of org.apache.pivot.wtk.PushButton in project pivot by apache.
the class DOMInteractionDemo method startup.
@Override
public void startup(Display display, Map<String, String> properties) throws Exception {
BoxPane boxPane = new BoxPane();
boxPane.getStyles().put(Style.horizontalAlignment, HorizontalAlignment.CENTER);
helloButton = new PushButton("Say Hello");
boxPane.add(helloButton);
helloButton.getButtonPressListeners().add(new ButtonPressListener() {
@Override
public void buttonPressed(Button button) {
BrowserApplicationContext.eval("sayHello(\"Hello from Pivot!\")", DOMInteractionDemo.this);
}
});
Border border = new Border(boxPane);
border.getStyles().put(Style.color, 7);
border.getStyles().put(Style.padding, 5);
window = new Window(border);
window.setMaximized(true);
window.open(display);
}
use of org.apache.pivot.wtk.PushButton in project pivot by apache.
the class ButtonGroupTest method startup.
@Override
public void startup(Display display, Map<String, String> properties) throws Exception {
ButtonGroup buttonGroup = new ButtonGroup();
buttonGroup.getButtonGroupListeners().add(new ButtonGroupListener() {
@Override
public void selectionChanged(ButtonGroup buttonGroupArgument, Button previousSelection) {
System.out.println("selectionChanged(): previousSelection = " + previousSelection + ", selection = " + buttonGroupArgument.getSelection());
}
@Override
public void buttonAdded(ButtonGroup buttonGroupArgument, Button button) {
System.out.println("buttonAdded(): " + button);
}
@Override
public void buttonRemoved(ButtonGroup buttonGroupArgument, Button button) {
System.out.println("buttonRemoved(): " + button);
}
});
BoxPane boxPane = new BoxPane();
PushButton button1 = new PushButton("One");
button1.setToggleButton(true);
button1.setButtonGroup(buttonGroup);
boxPane.add(button1);
PushButton button2 = new PushButton("Two");
button2.setToggleButton(true);
button2.setButtonGroup(buttonGroup);
boxPane.add(button2);
PushButton button3 = new PushButton("Three");
button3.setToggleButton(true);
button3.setButtonGroup(buttonGroup);
boxPane.add(button3);
PushButton button4 = new PushButton("Four");
button4.setToggleButton(true);
button4.setButtonGroup(buttonGroup);
boxPane.add(button4);
// button1.setSelected(true);
// buttonGroup.setSelection(button1);
// buttonGroup.setSelection(null);
window = new Window(boxPane);
window.setMaximized(true);
window.open(display);
}
Aggregations