Package org.apache.pivot.wtk

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> contextLocal = new HashMap<String, Object>();
                            editGreetingSheet.store(contextLocal);
View Full Code Here


                String mode = (String)selection.getUserData().get("mode");
                final FileBrowserSheet fileBrowserSheet =
                    new FileBrowserSheet(FileBrowserSheet.Mode.valueOf(mode.toUpperCase()));

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

            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> contextLocal = new HashMap<String, Object>();
                            editGreetingSheet.store(contextLocal);
View Full Code Here

            @Override
            public void buttonPressed(Button buttonArgument) {
                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

                body.getStyles().put("wrapText", true);

                final Prompt prompt = new Prompt(MessageType.QUESTION, message, options, body);
                prompt.setSelectedOptionIndex(0);

                prompt.open(TablePanes.this, new SheetCloseListener() {
                    @Override
                    public void sheetClosed(Sheet sheet) {
                        if (prompt.getResult() && prompt.getSelectedOptionIndex() == 0) {
                            int rowIndex = tablePane.getRowAt(contextMenuHandler.getY());
                            tablePane.getRows().remove(rowIndex, 1);
                        }
                    }
                });
            }
        });

        namedActions.put("configureColumn", new Action() {
            @Override
            public void perform(Component source) {
                BXMLSerializer bxmlSerializer = new BXMLSerializer();
                Sheet sheet;

                // Make the selected column available to script blocks
                int columnIndex = tablePane.getColumnAt(contextMenuHandler.getX());
                TablePane.Column column = tablePane.getColumns().get(columnIndex);
                bxmlSerializer.getNamespace().put("column", column);

                try {
                    sheet = (Sheet)bxmlSerializer.readObject(TablePanes.class,
                        "table_panes_configure_column.bxml");
                } catch (SerializationException exception) {
                    throw new RuntimeException(exception);
                } catch (IOException exception) {
                    throw new RuntimeException(exception);
                }

                sheet.open(TablePanes.this);
            }
        });

        namedActions.put("insertColumn", new Action() {
            @Override
            public void perform(Component source) {
                BXMLSerializer bxmlSerializer = new BXMLSerializer();
                Sheet sheet;

                // Create and insert a new column
                TablePane.Column column = new TablePane.Column();
                int columnIndex = tablePane.getColumnAt(contextMenuHandler.getX());
                tablePane.getColumns().insert(column, columnIndex);

                // Populate the column with the expected content
                TablePane.RowSequence rows = tablePane.getRows();
                rows.get(0).insert(new Label("-1"), columnIndex);
                for (int i = 1, n = rows.getLength(); i < n; i++) {
                    Panel panel = new Panel();
                    panel.getStyles().put("backgroundColor", "#dddcd5");
                    rows.get(i).insert(panel, columnIndex);
                }

                // Make the new column available to script blocks
                bxmlSerializer.getNamespace().put("column", column);

                try {
                    sheet = (Sheet)bxmlSerializer.readObject(TablePanes.class,
                        "table_panes_configure_column.bxml");
                } catch (SerializationException exception) {
                    throw new RuntimeException(exception);
                } catch (IOException exception) {
                    throw new RuntimeException(exception);
                }

                sheet.open(TablePanes.this);
            }
        });

        namedActions.put("removeColumn", new Action() {
            @Override
            public void perform(Component source) {
                ArrayList<String> options = new ArrayList<String>("OK", "Cancel");
                String message = "Remove Column?";
                Label body = new Label("Are you sure you want to remove the column?");
                body.getStyles().put("wrapText", true);

                final Prompt prompt = new Prompt(MessageType.QUESTION, message, options, body);
                prompt.setSelectedOptionIndex(0);

                prompt.open(TablePanes.this, new SheetCloseListener() {
                    @Override
                    public void sheetClosed(Sheet sheet) {
                        if (prompt.getResult() && prompt.getSelectedOptionIndex() == 0) {
                            int columnIndex = tablePane.getColumnAt(contextMenuHandler.getX());
View Full Code Here

        tabPane.getTabPaneListeners().add(new TabPaneListener.Adapter() {
            @Override
            public Vote previewRemoveTabs(final TabPane tabPaneArgument, final int index, final int count) {
                Vote vote;
                if (confirmCloseTab) {
                    confirmCloseTabPrompt.open(TabPanes.this, new SheetCloseListener() {
                        @Override
                        public void sheetClosed(Sheet sheet) {
                            if (confirmCloseTabPrompt.getResult()
                                && confirmCloseTabPrompt.getSelectedOptionIndex() == 1) {
                                confirmCloseTab = false;
View Full Code Here

    }

    @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

    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> expenseLocal = new HashMap<String, Object>();
View Full Code Here

    @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

            @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 + "\"");
                FileBrowserSheet fileBrowserSheet =
                        // new FileBrowserSheet(FileBrowserSheet.Mode.OPEN, selectedFolder);  // use this as a workaround ...
                        new FileBrowserSheet(FileBrowserSheet.Mode.OPEN)// test to see the wrong behavior
                        // new FileBrowserSheet();  // test to see the wrong behavior
                fileBrowserSheet.setRootFolder(selectedFolder)// ok, but doesn't solve this issue ...
                System.out.println("\nNote: the behavior here is right only when using the constructor with two parameters ..."
                    + " but in this source it's used one of other constructors.\n");

                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

TOP

Related Classes of org.apache.pivot.wtk.SheetCloseListener

Copyright © 2018 www.massapicom. 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.