Search in sources :

Example 21 with ButtonPressListener

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

the class ActivityIndicators method initialize.

@Override
public void initialize(Map<String, Object> namespace, URL location, Resources resources) {
    activityIndicator1 = (ActivityIndicator) namespace.get("activityIndicator1");
    activityIndicator2 = (ActivityIndicator) namespace.get("activityIndicator2");
    activityIndicator3 = (ActivityIndicator) namespace.get("activityIndicator3");
    activityButton = (PushButton) namespace.get("activityButton");
    activityButton.getButtonPressListeners().add(new ButtonPressListener() {

        @Override
        public void buttonPressed(Button button) {
            activityIndicator1.setActive(!activityIndicator1.isActive());
            activityIndicator2.setActive(!activityIndicator2.isActive());
            activityIndicator3.setActive(!activityIndicator3.isActive());
            updateButtonData();
        }
    });
    updateButtonData();
}
Also used : ButtonPressListener(org.apache.pivot.wtk.ButtonPressListener) PushButton(org.apache.pivot.wtk.PushButton) Button(org.apache.pivot.wtk.Button)

Example 22 with ButtonPressListener

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

the class Pivot694 method initializeFields.

private void initializeFields(BXMLSerializer serializer) {
    System.out.println("initializeFields: start");
    // TODO: for release 2.1 ... maybe generalizing some test here
    // pushButtons =
    // (ButtonGroup)serializer.getNamespace().get("pushButtons");
    // toggleButtons =
    // (ButtonGroup)serializer.getNamespace().get("toggleButtons");
    // radioButtons =
    // (ButtonGroup)serializer.getNamespace().get("radioButtons");
    // checkButtons =
    // (ButtonGroup)serializer.getNamespace().get("checkButtons");
    // checkTriButtons =
    // (ButtonGroup)serializer.getNamespace().get("checkTriButtons");
    calendarButton1 = (CalendarButton) serializer.getNamespace().get("calendarButton1");
    calendarButton2 = (CalendarButton) serializer.getNamespace().get("calendarButton2");
    spinner1 = (Spinner) serializer.getNamespace().get("spinner1");
    spinner2 = (Spinner) serializer.getNamespace().get("spinner2");
    listView1 = (ListView) serializer.getNamespace().get("listView1");
    listView2 = (ListView) serializer.getNamespace().get("listView2");
    tableView1 = (TableView) serializer.getNamespace().get("tableView1");
    tableView2 = (TableView) serializer.getNamespace().get("tableView2");
    treeView1 = (TreeView) serializer.getNamespace().get("treeView1");
    treeView2 = (TreeView) serializer.getNamespace().get("treeView2");
    listButton1 = (ListButton) serializer.getNamespace().get("listButton1");
    listButton2 = (ListButton) serializer.getNamespace().get("listButton2");
    clearSelectionButton = (PushButton) serializer.getNamespace().get("clearSelectionButton");
    clearSelectionButton.getButtonPressListeners().add(new ButtonPressListener() {

        @Override
        public void buttonPressed(Button button) {
            System.out.println("Clearing selection from " + button.getName() + " at " + new Date());
            // TODO: for release 2.1 ... maybe generalizing some test here
            // pushButtons.clearSelection();
            // toggleButtons.clearSelection();
            // radioButtons.clearSelection();
            // checkButtons.clearSelection();
            // checkTriButtons.clearSelection();
            calendarButton1.clearSelection();
            calendarButton2.clearSelection();
            spinner1.clearSelection();
            spinner2.clearSelection();
            listButton1.clearSelection();
            listButton2.clearSelection();
            listView1.clearSelection();
            listView2.clearSelection();
            tableView1.clearSelection();
            tableView2.clearSelection();
            treeView1.clearSelection();
            treeView2.clearSelection();
        }
    });
    clearButton = (PushButton) serializer.getNamespace().get("clearButton");
    clearButton.getButtonPressListeners().add(new ButtonPressListener() {

        @Override
        public void buttonPressed(Button button) {
            System.out.println("Clearing data from " + button.getName() + " at " + new Date());
            // TODO: verify for release 2.1 if implement a method to empty
            // components inside ...
            // pushButtons.remove(button);
            // toggleButtons.remove(button);
            // radioButtons.remove(button);
            // checkButtons.remove(button);
            // checkTriButtons.remove(button);
            // force clear of elements data ...
            clearComponent(calendarButton1);
            clearComponent(calendarButton2);
            clearComponent(spinner1);
            clearComponent(spinner2);
            clearComponent(listButton1);
            clearComponent(listButton2);
            clearComponent(listView1);
            clearComponent(listView2);
            clearComponent(tableView1);
            clearComponent(tableView2);
            clearComponent(treeView1);
            clearComponent(treeView2);
        // TODO: put (in bxml) the two tableView in a SplitPane, and see
        // some strange moving mouse over ...
        // TODO: add clear/clearSelection methods even to some type of
        // buttons (all types in the first row displayed) ...
        }
    });
    System.out.println("initializeFields: end");
}
Also used : ButtonPressListener(org.apache.pivot.wtk.ButtonPressListener) CalendarButton(org.apache.pivot.wtk.CalendarButton) PushButton(org.apache.pivot.wtk.PushButton) Button(org.apache.pivot.wtk.Button) ListButton(org.apache.pivot.wtk.ListButton) Date(java.util.Date)

Example 23 with ButtonPressListener

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

the class Pivot718 method controlList.

private void controlList(BXMLSerializer bxmlSerializer) {
    listDelButton = (PushButton) bxmlSerializer.getNamespace().get("listDelButton");
    list = (ListView) bxmlSerializer.getNamespace().get("list");
    list.getListViewSelectionListeners().add(new ListViewSelectionListener() {

        @Override
        public void selectedRangeAdded(ListView listView, int rangeStart, int rangeEnd) {
            System.out.println("selectedRangeAdded");
        }

        @Override
        public void selectedRangeRemoved(ListView listView, int rangeStart, int rangeEnd) {
            System.out.println("selectedRangeRemoved");
        }

        @Override
        public void selectedRangesChanged(ListView listView, Sequence<Span> previousSelectedRanges) {
            System.out.println("selectedRangesChanged");
        }

        @Override
        public void selectedItemChanged(ListView listView, Object previousSelectedItem) {
            System.out.println("selectedItemChanged :::" + listView.getSelectedItem());
        }
    });
    listDelButton.getButtonPressListeners().add(new ButtonPressListener() {

        @Override
        public void buttonPressed(Button button) {
            Object x = list.getSelectedItem();
            System.out.println("delete :: " + x);
            // List data = list.getListData();
            @SuppressWarnings("unchecked") List<Object> data = (List<Object>) list.getListData();
            data.remove(x);
        }
    });
}
Also used : ButtonPressListener(org.apache.pivot.wtk.ButtonPressListener) ListView(org.apache.pivot.wtk.ListView) PushButton(org.apache.pivot.wtk.PushButton) Button(org.apache.pivot.wtk.Button) List(org.apache.pivot.collections.List) ListViewSelectionListener(org.apache.pivot.wtk.ListViewSelectionListener) Span(org.apache.pivot.wtk.Span)

Example 24 with ButtonPressListener

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

the class SheetTest method startup.

@SuppressWarnings("unused")
@Override
public void startup(final Display display, Map<String, String> properties) throws Exception {
    Picture picture = (Picture) Image.load(getClass().getResource("IMG_0767_2.jpg"));
    picture.resample(120);
    BoxPane windowContent = new BoxPane();
    PushButton button = new PushButton(picture);
    button.getStyles().put(Style.toolbar, true);
    windowContent.add(button);
    frame = new Frame(windowContent);
    frame.setPreferredSize(480, 360);
    frame.getStyles().put(Style.padding, 0);
    frame.open(display);
    final TablePane tablePane = new TablePane();
    tablePane.setPreferredSize(320, 240);
    new TablePane.Column(tablePane, 1, true);
    TablePane.Row row0 = new TablePane.Row(tablePane, 1, true);
    TablePane.Row row1 = new TablePane.Row(tablePane, -1);
    final Label sheetContent = new Label("Sheet Content");
    sheetContent.getStyles().put(Style.wrapText, true);
    sheetContent.getStyles().put(Style.horizontalAlignment, HorizontalAlignment.CENTER);
    sheetContent.getStyles().put(Style.verticalAlignment, VerticalAlignment.CENTER);
    row0.add(sheetContent);
    Label promptBody = new Label("Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.");
    promptBody.getStyles().put(Style.wrapText, true);
    final Prompt prompt = new Prompt(MessageType.INFO, "Prompt", new ArrayList<>("OK"), promptBody);
    prompt.setTitle("Prompt");
    prompt.getStyles().put(Style.resizable, true);
    prompt.getComponentMouseListeners().add(new ComponentMouseListener() {

        @Override
        public void mouseOver(Component component) {
            System.out.println("Mouse Over");
        }

        @Override
        public void mouseOut(Component component) {
            System.out.println("Mouse out");
        }
    });
    Label alertBody = new Label("Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.");
    alertBody.getStyles().put(Style.wrapText, true);
    final Alert alert = new Alert(MessageType.INFO, "Alert", new ArrayList<>("OK"), alertBody);
    alert.setTitle("Alert");
    BoxPane boxPane = new BoxPane();
    row1.add(boxPane);
    boxPane.getStyles().put(Style.horizontalAlignment, HorizontalAlignment.RIGHT);
    final PushButton closeButton = new PushButton("Close");
    closeButton.getStyles().put(Style.minimumAspectRatio, 3);
    boxPane.add(closeButton);
    sheet = new Sheet(tablePane);
    closeButton.getButtonPressListeners().add(new ButtonPressListener() {

        @Override
        public void buttonPressed(Button buttonArgument) {
            buttonArgument.getWindow().close();
        }
    });
    button.getButtonPressListeners().add(new ButtonPressListener() {

        @Override
        public void buttonPressed(Button buttonArgument) {
            prompt.open(frame);
            Display displayLocal = DesktopApplicationContext.createDisplay(640, 480, 100, 100, true, true, false, buttonArgument.getDisplay().getHostWindow(), null);
            Window window = new Window();
            window.setTitle("New Secondary Window");
            window.setMaximized(true);
            window.setContent(new Label("I am a secondary window!"));
            window.open(displayLocal);
        }
    });
    sheet.getWindowStateListeners().add(new WindowStateListener() {

        @Override
        public void windowOpened(Window window) {
            closeButton.requestFocus();
        }
    });
    DesktopApplicationContext.sizeHostToFit(frame);
}
Also used : Window(org.apache.pivot.wtk.Window) Frame(org.apache.pivot.wtk.Frame) WindowStateListener(org.apache.pivot.wtk.WindowStateListener) Label(org.apache.pivot.wtk.Label) ButtonPressListener(org.apache.pivot.wtk.ButtonPressListener) BoxPane(org.apache.pivot.wtk.BoxPane) PushButton(org.apache.pivot.wtk.PushButton) Button(org.apache.pivot.wtk.Button) Picture(org.apache.pivot.wtk.media.Picture) Prompt(org.apache.pivot.wtk.Prompt) Alert(org.apache.pivot.wtk.Alert) PushButton(org.apache.pivot.wtk.PushButton) Component(org.apache.pivot.wtk.Component) ComponentMouseListener(org.apache.pivot.wtk.ComponentMouseListener) Sheet(org.apache.pivot.wtk.Sheet) TablePane(org.apache.pivot.wtk.TablePane) Display(org.apache.pivot.wtk.Display)

Example 25 with ButtonPressListener

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

the class PromptTest 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);
    boxPane.getStyles().put(Style.verticalAlignment, VerticalAlignment.BOTTOM);
    helloButton = new PushButton("Say Hello");
    boxPane.add(helloButton);
    helloButton.getButtonPressListeners().add(new ButtonPressListener() {

        @Override
        public void buttonPressed(Button button) {
            String text = button.getButtonData().toString();
            if (window.isBlocked()) {
                System.out.println("I'm already saying \"" + text + "\" !");
            } else {
                Prompt.prompt(text, window);
            }
        }
    });
    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);
}
Also used : ButtonPressListener(org.apache.pivot.wtk.ButtonPressListener) Window(org.apache.pivot.wtk.Window) BoxPane(org.apache.pivot.wtk.BoxPane) PushButton(org.apache.pivot.wtk.PushButton) Button(org.apache.pivot.wtk.Button) PushButton(org.apache.pivot.wtk.PushButton) Border(org.apache.pivot.wtk.Border)

Aggregations

ButtonPressListener (org.apache.pivot.wtk.ButtonPressListener)44 Button (org.apache.pivot.wtk.Button)43 PushButton (org.apache.pivot.wtk.PushButton)40 Component (org.apache.pivot.wtk.Component)13 IOException (java.io.IOException)11 File (java.io.File)9 BXMLSerializer (org.apache.pivot.beans.BXMLSerializer)9 ListButton (org.apache.pivot.wtk.ListButton)8 Sheet (org.apache.pivot.wtk.Sheet)8 ListView (org.apache.pivot.wtk.ListView)7 SheetCloseListener (org.apache.pivot.wtk.SheetCloseListener)7 Sequence (org.apache.pivot.collections.Sequence)6 BoxPane (org.apache.pivot.wtk.BoxPane)6 FileBrowserSheet (org.apache.pivot.wtk.FileBrowserSheet)6 Span (org.apache.pivot.wtk.Span)6 Window (org.apache.pivot.wtk.Window)6 List (org.apache.pivot.collections.List)5 SerializationException (org.apache.pivot.serialization.SerializationException)5 ComponentKeyListener (org.apache.pivot.wtk.ComponentKeyListener)5 ComponentMouseButtonListener (org.apache.pivot.wtk.ComponentMouseButtonListener)5