Search in sources :

Example 6 with PushButton

use of org.apache.pivot.wtk.PushButton 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);
            }
        }
    });
}
Also used : Path(org.apache.pivot.collections.Sequence.Tree.Path) ButtonPressListener(org.apache.pivot.wtk.ButtonPressListener) TreeBranch(org.apache.pivot.wtk.content.TreeBranch) PushButton(org.apache.pivot.wtk.PushButton) Button(org.apache.pivot.wtk.Button) TreeViewSelectionListener(org.apache.pivot.wtk.TreeViewSelectionListener) TreeView(org.apache.pivot.wtk.TreeView)

Example 7 with PushButton

use of org.apache.pivot.wtk.PushButton 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.");
            }
        }
    });
}
Also used : ButtonPressListener(org.apache.pivot.wtk.ButtonPressListener) PushButton(org.apache.pivot.wtk.PushButton) Button(org.apache.pivot.wtk.Button) ListButton(org.apache.pivot.wtk.ListButton)

Example 8 with PushButton

use of org.apache.pivot.wtk.PushButton 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");
}
Also used : ButtonPressListener(org.apache.pivot.wtk.ButtonPressListener) PushButton(org.apache.pivot.wtk.PushButton) Button(org.apache.pivot.wtk.Button)

Example 9 with PushButton

use of org.apache.pivot.wtk.PushButton in project pivot by apache.

the class Pivot721 method startup.

@Override
public void startup(Display display, Map<String, String> properties) throws Exception {
    BXMLSerializer bxmlSerializer = new BXMLSerializer();
    window = (Window) bxmlSerializer.readObject(Pivot721.class, "pivot_721.bxml");
    // force fill into button renderer, but only in some buttons ...
    ButtonDataRenderer filledButtonDataRenderer = new ButtonDataRenderer();
    filledButtonDataRenderer.setFillIcon(true);
    PushButton button3 = (PushButton) bxmlSerializer.getNamespace().get("button3");
    // ((ButtonDataRenderer)button3.getDataRenderer()).setFillIcon(true); //
    // ok, but note that all buttons share a common renderer instance
    // set/use the
    button3.setDataRenderer(filledButtonDataRenderer);
    // customized
    // renderer instance
    PushButton button4 = (PushButton) bxmlSerializer.getNamespace().get("button4");
    // set/use the
    button4.setDataRenderer(filledButtonDataRenderer);
    // customized
    // renderer instance
    window.open(display);
}
Also used : ButtonDataRenderer(org.apache.pivot.wtk.content.ButtonDataRenderer) PushButton(org.apache.pivot.wtk.PushButton) BXMLSerializer(org.apache.pivot.beans.BXMLSerializer)

Example 10 with PushButton

use of org.apache.pivot.wtk.PushButton 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);
            }
        }
    });
}
Also used : Path(org.apache.pivot.collections.Sequence.Tree.Path) ButtonPressListener(org.apache.pivot.wtk.ButtonPressListener) TreeBranch(org.apache.pivot.wtk.content.TreeBranch) PushButton(org.apache.pivot.wtk.PushButton) Button(org.apache.pivot.wtk.Button) TreeViewSelectionListener(org.apache.pivot.wtk.TreeViewSelectionListener) TreeView(org.apache.pivot.wtk.TreeView)

Aggregations

PushButton (org.apache.pivot.wtk.PushButton)39 Button (org.apache.pivot.wtk.Button)29 ButtonPressListener (org.apache.pivot.wtk.ButtonPressListener)23 Window (org.apache.pivot.wtk.Window)9 BoxPane (org.apache.pivot.wtk.BoxPane)8 Component (org.apache.pivot.wtk.Component)6 GradientPaint (java.awt.GradientPaint)5 ListButton (org.apache.pivot.wtk.ListButton)5 BXMLSerializer (org.apache.pivot.beans.BXMLSerializer)4 Path (org.apache.pivot.collections.Sequence.Tree.Path)3 Checkbox (org.apache.pivot.wtk.Checkbox)3 Frame (org.apache.pivot.wtk.Frame)3 ListView (org.apache.pivot.wtk.ListView)3 Sheet (org.apache.pivot.wtk.Sheet)3 TreeView (org.apache.pivot.wtk.TreeView)3 TreeViewSelectionListener (org.apache.pivot.wtk.TreeViewSelectionListener)3 TreeBranch (org.apache.pivot.wtk.content.TreeBranch)3 File (java.io.File)2 TaskExecutionException (org.apache.pivot.util.concurrent.TaskExecutionException)2 Alert (org.apache.pivot.wtk.Alert)2