use of org.apache.pivot.wtk.Button in project pivot by apache.
the class Pivot718 method controlTree.
private void controlTree(BXMLSerializer bxmlSerializer) {
treeDelButton = (PushButton) bxmlSerializer.getNamespace().get("treeDelButton");
tree = (TreeView) bxmlSerializer.getNamespace().get("tree");
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");
}
});
treeDelButton.getButtonPressListeners().add(new ButtonPressListener() {
@Override
public void buttonPressed(Button button) {
TreeNode selectedNode = (TreeNode) tree.getSelectedNode();
System.out.println("delete :: " + selectedNode);
if (selectedNode != null) {
TreeBranch parent = selectedNode.getParent();
if (parent != null) {
parent.remove(selectedNode);
}
}
}
});
}
use of org.apache.pivot.wtk.Button in project pivot by apache.
the class Pivot734 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) {
((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 FileBrowsing method initialize.
@Override
public void initialize(Map<String, Object> namespace, URL location, Resources resources) {
openSheetButton.getButtonPressListeners().add(new ButtonPressListener() {
@Override
public void buttonPressed(Button button) {
Button selection = fileBrowserSheetModeGroup.getSelection();
String mode = (String) selection.getUserData().get("mode");
FileBrowserSheet.Mode fileBrowserSheetMode = FileBrowserSheet.Mode.valueOf(mode.toUpperCase());
final FileBrowserSheet fileBrowserSheet = new FileBrowserSheet();
if (fileBrowserSheetMode == FileBrowserSheet.Mode.SAVE_AS) {
fileBrowserSheet.setSelectedFile(new File(fileBrowserSheet.getRootDirectory(), "New File"));
}
fileBrowserSheet.setMode(fileBrowserSheetMode);
fileBrowserSheet.open(FileBrowsing.this, 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:", listView, FileBrowsing.this);
} else {
Alert.alert(MessageType.INFO, "You didn't select anything.", FileBrowsing.this);
}
}
});
}
});
}
use of org.apache.pivot.wtk.Button in project pivot by apache.
the class FillPanes method initialize.
@Override
public void initialize(Map<String, Object> namespace, URL location, Resources resources) {
fillPane = (FillPane) namespace.get("fillPane");
horizontalOrientationButton = (RadioButton) namespace.get("horizontalOrientationButton");
verticalOrientationButton = (RadioButton) namespace.get("verticalOrientationButton");
ButtonStateListener buttonStateListener = new ButtonStateListener() {
@Override
public void stateChanged(Button button, Button.State previousState) {
updateFillPaneState();
}
};
horizontalOrientationButton.getButtonStateListeners().add(buttonStateListener);
verticalOrientationButton.getButtonStateListeners().add(buttonStateListener);
updateFillPaneState();
}
use of org.apache.pivot.wtk.Button in project pivot by apache.
the class Forms method initialize.
@Override
public void initialize(Map<String, Object> namespace, URL location, Resources resources) {
titleListButton = (ListButton) namespace.get("titleListButton");
nameBoxPane = (BoxPane) namespace.get("nameBoxPane");
lastNameTextInput = (TextInput) namespace.get("lastNameTextInput");
firstNameTextInput = (TextInput) namespace.get("firstNameTextInput");
submitButton = (PushButton) namespace.get("submitButton");
errorLabel = (Label) namespace.get("errorLabel");
submitButton.getButtonPressListeners().add(new ButtonPressListener() {
@Override
public void buttonPressed(Button button) {
String titleOfPerson = (String) titleListButton.getButtonData();
System.out.println("The title of the person is: \"" + titleOfPerson + "\"");
String lastName = lastNameTextInput.getText();
String firstName = firstNameTextInput.getText();
Form.Flag flag = null;
if (lastName.length() == 0 || firstName.length() == 0) {
flag = new Form.Flag(MessageType.ERROR, "Name is required.");
}
Form.setFlag(nameBoxPane, flag);
if (flag == null) {
errorLabel.setText("");
Prompt.prompt("Pretending to submit...", Forms.this);
} else {
errorLabel.setText("Some required information is missing.");
}
}
});
}
Aggregations