Search in sources :

Example 11 with BXMLSerializer

use of org.apache.pivot.beans.BXMLSerializer in project pivot by apache.

the class HelloBXML method startup.

@Override
public void startup(Display display, Map<String, String> properties) throws Exception {
    BXMLSerializer bxmlSerializer = new BXMLSerializer();
    this.window = (Window) bxmlSerializer.readObject(HelloBXML.class, "hello.bxml");
    this.window.open(display);
}
Also used : BXMLSerializer(org.apache.pivot.beans.BXMLSerializer)

Example 12 with BXMLSerializer

use of org.apache.pivot.beans.BXMLSerializer 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 13 with BXMLSerializer

use of org.apache.pivot.beans.BXMLSerializer in project pivot by apache.

the class Pivot734WithWorkaround method startup.

@Override
public void startup(Display display, Map<String, String> properties) throws Exception {
    BXMLSerializer bxmlSerializer = new BXMLSerializer();
    window = (Window) bxmlSerializer.readObject(Pivot734WithWorkaround.class, "pivot_734.bxml");
    controlTree(bxmlSerializer);
    window.open(display);
}
Also used : BXMLSerializer(org.apache.pivot.beans.BXMLSerializer)

Example 14 with BXMLSerializer

use of org.apache.pivot.beans.BXMLSerializer 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);
}
Also used : ButtonPressListener(org.apache.pivot.wtk.ButtonPressListener) FileBrowserSheet(org.apache.pivot.wtk.FileBrowserSheet) PushButton(org.apache.pivot.wtk.PushButton) Button(org.apache.pivot.wtk.Button) SheetCloseListener(org.apache.pivot.wtk.SheetCloseListener) IOException(java.io.IOException) Sheet(org.apache.pivot.wtk.Sheet) FileBrowserSheet(org.apache.pivot.wtk.FileBrowserSheet) File(java.io.File) BXMLSerializer(org.apache.pivot.beans.BXMLSerializer)

Example 15 with BXMLSerializer

use of org.apache.pivot.beans.BXMLSerializer in project pivot by apache.

the class SuggestionPopupTest method startup.

@Override
public void startup(final Display display, final Map<String, String> properties) throws Exception {
    BXMLSerializer bxmlSerializer = new BXMLSerializer();
    window = (Window) bxmlSerializer.readObject(SuggestionPopupTest.class, "suggestion_popup_test.bxml");
    bxmlSerializer.bind(this);
    textInput.getTextInputContentListeners().add(new TextInputContentListener() {

        @Override
        public void textInserted(final TextInput textInputArgument, final int index, final int count) {
            ArrayList<String> suggestions = new ArrayList<>("One", "Two", "Three", "Four", "Five");
            suggestionPopup.setSuggestionData(suggestions);
            suggestionPopup.open(textInputArgument, new SuggestionPopupCloseListener() {

                @Override
                public void suggestionPopupClosed(final SuggestionPopup suggestionPopupArgument) {
                    if (suggestionPopupArgument.getResult()) {
                        selectedIndexLabel.setText("You selected suggestion number " + suggestionPopupArgument.getSelectedIndex() + ".");
                    } else {
                        selectedIndexLabel.setText("You didn't select anything.");
                    }
                }
            });
        }

        @Override
        public void textRemoved(final TextInput textInputArgument, final int index, final int count) {
            suggestionPopup.close();
        }
    });
    window.open(display);
}
Also used : TextInputContentListener(org.apache.pivot.wtk.TextInputContentListener) SuggestionPopupCloseListener(org.apache.pivot.wtk.SuggestionPopupCloseListener) SuggestionPopup(org.apache.pivot.wtk.SuggestionPopup) ArrayList(org.apache.pivot.collections.ArrayList) TextInput(org.apache.pivot.wtk.TextInput) BXMLSerializer(org.apache.pivot.beans.BXMLSerializer)

Aggregations

BXMLSerializer (org.apache.pivot.beans.BXMLSerializer)86 Component (org.apache.pivot.wtk.Component)24 IOException (java.io.IOException)19 SerializationException (org.apache.pivot.serialization.SerializationException)14 Window (org.apache.pivot.wtk.Window)13 Button (org.apache.pivot.wtk.Button)11 PushButton (org.apache.pivot.wtk.PushButton)11 File (java.io.File)9 ButtonPressListener (org.apache.pivot.wtk.ButtonPressListener)9 Frame (org.apache.pivot.wtk.Frame)8 TextInput (org.apache.pivot.wtk.TextInput)8 ArrayList (org.apache.pivot.collections.ArrayList)7 List (org.apache.pivot.collections.List)7 Mouse (org.apache.pivot.wtk.Mouse)6 Sequence (org.apache.pivot.collections.Sequence)5 ComponentMouseButtonListener (org.apache.pivot.wtk.ComponentMouseButtonListener)5 ListButton (org.apache.pivot.wtk.ListButton)5 TextInputContentListener (org.apache.pivot.wtk.TextInputContentListener)5 URL (java.net.URL)4 MalformedURLException (java.net.MalformedURLException)3