Examples of SheetCloseListener


Examples of org.apache.pivot.wtk.SheetCloseListener

            @Override
            public void buttonPressed(Button button) {
                final FileBrowserSheet fileBrowserSheet = new FileBrowserSheet();

                fileBrowserSheet.setMode(FileBrowserSheet.Mode.OPEN);
                fileBrowserSheet.open(window, new SheetCloseListener() {
                    @Override
                    public void sheetClosed(Sheet sheet) {
                        if (sheet.getResult()) {
                            loadedFile = fileBrowserSheet.getSelectedFile();

                            try {
                                BufferedReader reader = new BufferedReader(new FileReader(loadedFile));
                                PlainTextSerializer serializer = new PlainTextSerializer();
                                textPane.setDocument(serializer.readObject(reader));
                                reader.close();
                                window.setTitle(loadedFile.getCanonicalPath());
                            } catch (IOException ex) {
                                ex.printStackTrace();
                                Alert.alert(ex.getMessage(), window);
                            }
                        }
                    }
                });
            }
        });

        saveFileButton.getButtonPressListeners().add(new ButtonPressListener() {
            @Override
            public void buttonPressed(Button button) {
                final FileBrowserSheet fileBrowserSheet = new FileBrowserSheet();

                if (loadedFile != null) {
                    fileBrowserSheet.setSelectedFile(loadedFile);
                }

                fileBrowserSheet.setMode(FileBrowserSheet.Mode.SAVE_AS);
                fileBrowserSheet.open(window, new SheetCloseListener() {
                    @Override
                    public void sheetClosed(Sheet sheet) {
                        if (sheet.getResult()) {
                            File selectedFile = fileBrowserSheet.getSelectedFile();
View Full Code Here

Examples of org.apache.pivot.wtk.SheetCloseListener

            @Override
            public void buttonPressed(Button button) {
                final FileBrowserSheet fileBrowserSheet = new FileBrowserSheet();

                fileBrowserSheet.setMode(FileBrowserSheet.Mode.SAVE_TO)// 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
                    }
                });
View Full Code Here

Examples of org.apache.pivot.wtk.SheetCloseListener

        });

        Action.getNamedActions().put("fileOpen", new Action() {
            @Override
            public void perform(Component source) {
                fileBrowserSheet.open(BXMLExplorerWindow.this, new SheetCloseListener() {
                    @Override
                    public void sheetClosed(Sheet sheet) {
                        if (!sheet.getResult()) {
                            return;
                        }
View Full Code Here

Examples of org.apache.pivot.wtk.SheetCloseListener

    }

    @SuppressWarnings("unchecked")
    private void addExpense() {
        expenseSheet.clear();
        expenseSheet.open(this, new SheetCloseListener() {
            @Override
            public void sheetClosed(Sheet sheet) {
                if (sheet.getResult()) {
                    // Get the expense data from the sheet
                    final HashMap<String, Object> expense = new HashMap<String, Object>();
View Full Code Here

Examples of org.apache.pivot.wtk.SheetCloseListener

    private void updateSelectedExpense() {
        Object expense = expenseTableView.getSelectedRow();
        final int id = JSON.getInt(expense, "id");

        expenseSheet.load(expense);
        expenseSheet.open(this, new SheetCloseListener() {
            @Override
            public void sheetClosed(Sheet sheet) {
                if (sheet.getResult()) {
                    // Get the expense data from the sheet
                    final HashMap<String, Object> expense = new HashMap<String, Object>();
View Full Code Here

Examples of org.apache.pivot.wtk.SheetCloseListener

    @SuppressWarnings("unchecked")
    private void deleteSelectedExpense() {
        Object expense = expenseTableView.getSelectedRow();
        final int id = JSON.getInt(expense, "id");

        deleteConfirmationPrompt.open(this, new SheetCloseListener() {
            @Override
            public void sheetClosed(Sheet sheet) {
                if (sheet.getResult()
                    && ((Prompt)sheet).getSelectedOptionIndex() == 1) {
                    // DELETE expense from server and then remove from table
View Full Code Here

Examples of org.apache.pivot.wtk.SheetCloseListener

            @Override
            public void buttonPressed(Button button) {
                final FileBrowserSheet fileBrowserSheet = new FileBrowserSheet();

                fileBrowserSheet.setMode(FileBrowserSheet.Mode.OPEN);
                fileBrowserSheet.open(window, new SheetCloseListener() {
                    @Override
                    public void sheetClosed(Sheet sheet) {
                        if (sheet.getResult()) {
                            loadedFile = fileBrowserSheet.getSelectedFile();

                            try {
                                BufferedReader reader = new BufferedReader(new FileReader(loadedFile));
                                PlainTextSerializer serializer = new PlainTextSerializer();
                                textPane.setDocument(serializer.readObject(reader));
                                reader.close();
                                window.setTitle(loadedFile.getCanonicalPath());
                            } catch (IOException ex) {
                                ex.printStackTrace();
                                Alert.alert(ex.getMessage(), window);
                            }
                        }
                    }
                });
            }
        });

        saveFileButton.getButtonPressListeners().add(new ButtonPressListener() {
            @Override
            public void buttonPressed(Button button) {
                final FileBrowserSheet fileBrowserSheet = new FileBrowserSheet();

                if (loadedFile != null) {
                    fileBrowserSheet.setSelectedFile(loadedFile);
                }

                fileBrowserSheet.setMode(FileBrowserSheet.Mode.SAVE_AS);
                fileBrowserSheet.open(window, new SheetCloseListener() {
                    @Override
                    public void sheetClosed(Sheet sheet) {
                        if (sheet.getResult()) {
                            File selectedFile = fileBrowserSheet.getSelectedFile();
View Full Code Here

Examples of org.apache.pivot.wtk.SheetCloseListener

            @Override
            public void buttonPressed(Button button) {
                final Window window = FileBrowserWithCharsetTest.getActiveWindow();
                final FileBrowserSheet fileBrowserSheet = new FileBrowserWithCharsetTest(FileBrowserSheet.Mode.OPEN);

                fileBrowserSheet.open(window, new SheetCloseListener() {
                    @Override
                    public void sheetClosed(Sheet sheet) {
                        if (sheet.getResult()) {
                            Sequence<File> selectedFiles = fileBrowserSheet.getSelectedFiles();
View Full Code Here

Examples of org.apache.pivot.wtk.SheetCloseListener

            @Override
            public void buttonPressed(Button button) {
                final FileBrowserSheet fileBrowserSheet = new FileBrowserSheet();

                fileBrowserSheet.setMode(FileBrowserSheet.Mode.OPEN);
                fileBrowserSheet.open(window, new SheetCloseListener() {
                    @Override
                    public void sheetClosed(Sheet sheet) {
                        if (sheet.getResult()) {
                            loadedFile = fileBrowserSheet.getSelectedFile();

                            try {
                                BufferedReader reader = new BufferedReader(new FileReader(loadedFile));
                                PlainTextSerializer serializer = new PlainTextSerializer();
                                textPane.setDocument(serializer.readObject(reader));
                                reader.close();
                                window.setTitle(loadedFile.getCanonicalPath());
                            } catch (IOException ex) {
                                ex.printStackTrace();
                                Alert.alert(ex.getMessage(), window);
                            }
                        }
                    }
                });
            }
        });

        saveFileButton.getButtonPressListeners().add(new ButtonPressListener() {
            @Override
            public void buttonPressed(Button button) {
                final FileBrowserSheet fileBrowserSheet = new FileBrowserSheet();

                if (loadedFile != null) {
                    fileBrowserSheet.setSelectedFile(loadedFile);
                }

                fileBrowserSheet.setMode(FileBrowserSheet.Mode.SAVE_AS);
                fileBrowserSheet.open(window, new SheetCloseListener() {
                    @Override
                    public void sheetClosed(Sheet sheet) {
                        if (sheet.getResult()) {
                            File selectedFile = fileBrowserSheet.getSelectedFile();
View Full Code Here

Examples of org.apache.pivot.wtk.SheetCloseListener

            public void buttonPressed(Button button) {
                HashMap<String, Object> context = new HashMap<String, Object>();
                store(context);
                editGreetingSheet.load(context);

                editGreetingSheet.open(SheetExampleWindow.this, new SheetCloseListener() {
                    @Override
                    public void sheetClosed(Sheet sheet) {
                        if (sheet.getResult()) {
                            HashMap<String, Object> context = new HashMap<String, Object>();
                            editGreetingSheet.store(context);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.