use of org.apache.pivot.wtk.Button in project pivot by apache.
the class Pivot859 method initializeFields.
private void initializeFields(BXMLSerializer serializer) {
System.out.println("initializeFields: start");
urlInput = (TextInput) serializer.getNamespace().get("textInput");
if (defaultURL.length() > 0) {
urlInput.setText(defaultURL);
}
goButton = (PushButton) serializer.getNamespace().get("goButton");
goButton.getButtonPressListeners().add(new ButtonPressListener() {
@Override
public void buttonPressed(Button button) {
clearContent();
retrieveURLContentSync();
}
});
contentArea = (TextArea) serializer.getNamespace().get("textArea");
clearButton = (PushButton) serializer.getNamespace().get("clearButton");
clearButton.getButtonPressListeners().add(new ButtonPressListener() {
@Override
public void buttonPressed(Button button) {
clearContent();
}
});
statusLabel = (Label) serializer.getNamespace().get("textStatus");
System.out.println("initializeFields: end");
}
use of org.apache.pivot.wtk.Button in project pivot by apache.
the class Pivot734WithWorkaround method controlTree.
private void controlTree(BXMLSerializer bxmlSerializer) {
treeButtonAdd = (PushButton) bxmlSerializer.getNamespace().get("treeButtonAdd");
treeButtonRemove = (PushButton) bxmlSerializer.getNamespace().get("treeButtonRemove");
tree = (TreeView) bxmlSerializer.getNamespace().get("tree");
boolean treeStyleForShowEmptyBranchControls = tree.getStyles().getBoolean(Style.showEmptyBranchControls);
System.out.println("tree style for showEmptyBranchControls is " + treeStyleForShowEmptyBranchControls);
tree.getTreeViewSelectionListeners().add(new TreeViewSelectionListener() {
@Override
public void selectedPathAdded(TreeView treeView, Path path) {
System.out.println("selectedPathAdded");
}
@Override
public void selectedPathRemoved(TreeView treeView, Path path) {
System.out.println("selectedPathRemoved");
}
@Override
public void selectedPathsChanged(TreeView treeView, Sequence<Path> previousSelectedPaths) {
System.out.println("selectedPathsChanged");
}
@Override
public void selectedNodeChanged(TreeView treeView, Object previousSelectedNode) {
System.out.println("selectedNodeChanged");
}
});
treeButtonAdd.getButtonPressListeners().add(new ButtonPressListener() {
@Override
public void buttonPressed(Button button) {
Object x = tree.getSelectedNode();
System.out.println("add a 'new branch' element to the selected element :: " + x);
if (x != null && x instanceof TreeBranch) {
// workaround for PIVOT-734
Path path = tree.getSelectedPath();
tree.setBranchExpanded(path, true);
// end of workaround for PIVOT-734
((TreeBranch) x).add(newBranch);
}
}
});
treeButtonRemove.getButtonPressListeners().add(new ButtonPressListener() {
@Override
public void buttonPressed(Button button) {
Object x = tree.getSelectedNode();
System.out.println("remove a 'new branch' element under the selected element :: " + x);
if (x != null && x instanceof TreeBranch) {
((TreeBranch) x).remove(newBranch);
}
}
});
}
use of org.apache.pivot.wtk.Button in project pivot by apache.
the class Pivot832 method startup.
@Override
public void startup(Display display, Map<String, String> properties) throws Exception {
BXMLSerializer bxmlSerializer = new BXMLSerializer();
window = (Window) bxmlSerializer.readObject(getClass().getResource("pivot_832.bxml"));
bxmlSerializer.bind(this, Pivot832.class);
selectFolderButton.getButtonPressListeners().add(new ButtonPressListener() {
@Override
public void buttonPressed(Button button) {
final FileBrowserSheet fileBrowserSheet = new FileBrowserSheet();
// to
fileBrowserSheet.setMode(FileBrowserSheet.Mode.SAVE_TO);
// be
// able
// to
// select
// a
// folder
fileBrowserSheet.open(window, new SheetCloseListener() {
@Override
public void sheetClosed(Sheet sheet) {
if (sheet.getResult()) {
File loadedFile = fileBrowserSheet.getSelectedFile();
try {
selectedFolder = loadedFile.getCanonicalPath();
System.out.println("Selected folder '" + selectedFolder + "'");
// multiple tests ...
System.out.println("Verify: Root folder (display from getName) was set to '" + fileBrowserSheet.getRootDirectory().getName() + "'");
System.out.println("Verify: Root folder (display from getCanonicalPath) was set to '" + fileBrowserSheet.getRootDirectory().getCanonicalPath() + "'");
System.out.println("Verify: Root folder (display from getCanonicalFile) was set to '" + fileBrowserSheet.getRootDirectory().getCanonicalFile() + "'");
openFileButton.setEnabled(true);
} catch (IOException e) {
e.printStackTrace();
openFileButton.setEnabled(false);
}
window.setTitle("Selected folder: " + selectedFolder);
}
}
});
}
});
openFileButton.getButtonPressListeners().add(new ButtonPressListener() {
@Override
public void buttonPressed(Button button) {
System.out.println("Now opening a BrowserSheet starting from the previous selected folder: \"" + selectedFolder + "\"");
final FileBrowserSheet fileBrowserSheet = new FileBrowserSheet(FileBrowserSheet.Mode.OPEN, selectedFolder);
try {
// multiple tests ...
System.out.println("Verify: Root folder (display from getName) was set to '" + fileBrowserSheet.getRootDirectory().getName() + "'");
System.out.println("Verify: Root folder (display from getCanonicalPath) was set to '" + fileBrowserSheet.getRootDirectory().getCanonicalPath() + "'");
System.out.println("Verify: Root folder (display from getCanonicalFile) was set to '" + fileBrowserSheet.getRootDirectory().getCanonicalFile() + "'");
} catch (IOException e) {
e.printStackTrace();
}
fileBrowserSheet.open(window, new SheetCloseListener() {
@Override
public void sheetClosed(Sheet sheet) {
// empty block
}
});
}
});
window.open(display);
}
use of org.apache.pivot.wtk.Button in project pivot by apache.
the class Pivot686 method initializeFields.
private void initializeFields(BXMLSerializer serializer) {
System.out.println("initializeFields: start");
textInput = (TextInput) serializer.getNamespace().get("textInput");
// note that this has no effect here
textInput.requestFocus();
System.out.println("textInput has focus: " + textInput.isFocused());
pushButton = (PushButton) serializer.getNamespace().get("pushButton");
pushButton.getButtonPressListeners().add(new ButtonPressListener() {
@Override
public void buttonPressed(Button button) {
String msg = "You clicked me!";
System.out.println(msg);
// Alert.alert(MessageType.INFO, msg, window);
textInput.setText("");
textInput.requestFocus();
}
});
System.out.println("initializeFields: end");
}
use of org.apache.pivot.wtk.Button in project pivot by apache.
the class ButtonSkin method install.
@Override
public void install(Component component) {
super.install(component);
Button button = (Button) component;
button.getButtonListeners().add(this);
button.getButtonStateListeners().add(this);
button.getButtonPressListeners().add(this);
button.setCursor(Cursor.HAND);
}
Aggregations