Package slash.navigation.gui.actions

Examples of slash.navigation.gui.actions.ActionManager$ProxyAction


                    return;
                handlePositionsUpdate();
            }
        });

        final ActionManager actionManager = r.getContext().getActionManager();
        tablePositions.setModel(getPositionsModel());
        PositionsTableColumnModel tableColumnModel = new PositionsTableColumnModel();
        tablePositions.setColumnModel(tableColumnModel);
        tablePositions.registerKeyboardAction(new FrameAction() {
            public void run() {
                actionManager.run("delete");
            }
        }, getKeyStroke(VK_DELETE, 0), WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
        tablePositions.registerKeyboardAction(new FrameAction() {
            public void run() {
                selectAndScrollToPosition(tablePositions, 0, 0);
            }
        }, getKeyStroke(VK_HOME, 0), WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
        tablePositions.registerKeyboardAction(new FrameAction() {
            public void run() {
                selectAndScrollToPosition(tablePositions, 0, tablePositions.getSelectedRow());
            }
        }, getKeyStroke(VK_HOME, SHIFT_DOWN_MASK), WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
        tablePositions.registerKeyboardAction(new FrameAction() {
            public void run() {
                int lastRow = tablePositions.getRowCount() - 1;
                selectAndScrollToPosition(tablePositions, lastRow, lastRow);
            }
        }, getKeyStroke(VK_END, 0), WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
        tablePositions.registerKeyboardAction(new FrameAction() {
            public void run() {
                selectAndScrollToPosition(tablePositions, tablePositions.getRowCount() - 1, tablePositions.getSelectedRow());
            }
        }, getKeyStroke(VK_END, SHIFT_DOWN_MASK), WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
        tablePositions.setDragEnabled(true);
        tablePositions.setDropMode(ON);
        TableDragAndDropHandler dropHandler = new TableDragAndDropHandler(new PanelDropHandler());
        tablePositions.setTransferHandler(dropHandler);

        getPositionsModel().addTableModelListener(new TableModelListener() {
            public void tableChanged(TableModelEvent e) {
                if (!isFirstToLastRow(e))
                    return;
                if (getPositionsModel().isContinousRange())
                    return;

                handlePositionsUpdate();
            }
        });

        JMenuBar menuBar = Application.getInstance().getContext().getMenuBar();
        tableHeaderMenu = new TableHeaderMenu(tablePositions.getTableHeader(), menuBar, getPositionsModel(),
                tableColumnModel, actionManager);
        JPopupMenu menu = new TablePopupMenu(tablePositions).createPopupMenu();
        JMenu mergeMenu = (JMenu) findMenuComponent(menu, "merge-positionlist");
        new MergePositionListMenu(mergeMenu, getPositionsView(), getFormatAndRoutesModel());

        ClipboardInteractor clipboardInteractor = new ClipboardInteractor();
        clipboardInteractor.watchClipboard();
        actionManager.register("undo", new UndoAction());
        actionManager.register("redo", new RedoAction());
        actionManager.register("copy", new CopyAction(getPositionsView(), getPositionsModel(), clipboardInteractor));
        actionManager.register("cut", new CutAction(getPositionsView(), getPositionsModel(), clipboardInteractor));
        actionManager.register("delete", new DeleteAction(getPositionsView(), getPositionsModel()));
        actionManager.register("new-position", new AddPositionAction(getPositionsView(), getPositionsModel(), getPositionsSelectionModel()));
        actionManager.register("new-file", new NewFileAction(this));
        actionManager.register("open", new OpenAction(this));
        actionManager.register("paste", new PasteAction(getPositionsView(), getPositionsModel(), clipboardInteractor));
        actionManager.register("save", new SaveAction(this));
        actionManager.register("save-as", new SaveAsAction(this));
        actionManager.register("select-all", new SelectAllAction(getPositionsView()));
        actionManager.register("new-positionlist", new AddPositionListAction(getFormatAndRoutesModel()));
        actionManager.register("rename-positionlist", new RenamePositionListAction(getFormatAndRoutesModel()));
        actionManager.register("delete-positionlist", new RemovePositionListAction(getFormatAndRoutesModel()));
        actionManager.register("add-coordinates", new AddCoordinatesToPositionsAction());
        actionManager.register("add-elevation", new AddElevationToPositionsAction());
        actionManager.register("add-postal-address", new AddPostalAddressToPositionsAction());
        actionManager.register("add-populated-place", new AddPopulatedPlaceToPositionsAction());
        actionManager.register("add-speed", new AddSpeedToPositionsAction());
        actionManager.register("add-time", new AddTimeToPositionsAction());
        actionManager.register("add-number", new AddNumberToPositionsAction());
        actionManager.register("split-positionlist", new SplitPositionListAction(tablePositions, getPositionsModel(), formatAndRoutesModel));
        actionManager.register("import-positionlist", new ImportPositionListAction(this));
        actionManager.register("export-positionlist", new ExportPositionListAction(this));

        registerKeyStroke(tablePositions, "copy");
        registerKeyStroke(tablePositions, "cut");
        registerKeyStroke(tablePositions, "paste");

        formatAndRoutesModel.addModifiedListener(new ChangeListener() {
            public void stateChanged(ChangeEvent e) {
                actionManager.enable("save", formatAndRoutesModel.isModified() &&
                        formatAndRoutesModel.getFormat() != null &&
                        formatAndRoutesModel.getFormat().isSupportsWriting());
            }
        });
View Full Code Here


    }

    // handle notifications

    private void handleUndoUpdate() {
        ActionManager actionManager = Application.getInstance().getContext().getActionManager();
        UndoManager undoManager = Application.getInstance().getContext().getUndoManager();
        actionManager.enable("undo", undoManager.canUndo());
        actionManager.enable("redo", undoManager.canRedo());
    }
View Full Code Here

        RouteCharacteristics characteristics = getCharacteristicsModel().getSelectedCharacteristics();

        comboBoxChoosePositionList.setEnabled(existsMoreThanOneRoute);

        RouteConverter r = RouteConverter.getInstance();
        ActionManager actionManager = r.getContext().getActionManager();
        actionManager.enable("insert-positions", existsMoreThanOnePosition);
        actionManager.enable("delete-positions", existsMoreThanOnePosition);
        actionManager.enable("new-positionlist", supportsMultipleRoutes);
        actionManager.enable("rename-positionlist", existsARoute);
        actionManager.enable("convert-route-to-track", existsAPosition && characteristics.equals(Route));
        actionManager.enable("convert-track-to-route", existsAPosition && characteristics.equals(Track));
        actionManager.enable("delete-positionlist", existsMoreThanOneRoute);
        actionManager.enable("split-positionlist", supportsMultipleRoutes && existsARoute && existsMoreThanOnePosition);
        tableHeaderMenu.enable(existsMoreThanOnePosition);
        //noinspection ConstantConditions
        actionManager.enable("complete-flight-plan", existsAPosition && format instanceof GarminFlightPlanFormat);
        actionManager.enable("print-map", r.isMapViewAvailable() && existsAPosition);
        actionManager.enable("print-map-and-route", r.isMapViewAvailable() && existsAPosition && characteristics.equals(Route));
        actionManager.enable("print-profile", existsAPosition);
    }
View Full Code Here

        boolean lastRowNotSelected = existsASelectedPosition && selectedPositions[selectedPositions.length - 1] != tablePositions.getRowCount() - 1;
        buttonMovePositionDown.setEnabled(lastRowNotSelected);
        buttonMovePositionToBottom.setEnabled(lastRowNotSelected);

        RouteConverter r = RouteConverter.getInstance();
        ActionManager actionManager = r.getContext().getActionManager();
        actionManager.enable("cut", existsASelectedPosition);
        actionManager.enable("copy", existsASelectedPosition);
        actionManager.enable("delete", existsASelectedPosition);
        actionManager.enable("select-all", existsAPosition && !allPositionsSelected);
        findMenu(r.getFrame().getJMenuBar(), "position", "complete").setEnabled(existsASelectedPosition);
        actionManager.enable("add-coordinates", existsASelectedPosition);
        actionManager.enable("add-elevation", existsASelectedPosition);
        actionManager.enable("add-postal-address", existsASelectedPosition);
        actionManager.enable("add-populated-place", existsASelectedPosition);
        actionManager.enable("add-speed", existsASelectedPosition);
        actionManager.enable("add-time", existsASelectedPosition);
        actionManager.enable("add-number", existsASelectedPosition);
        actionManager.enable("split-positionlist", supportsMultipleRoutes && existsASelectedPosition);
        actionManager.enable("insert-positions", existsAPosition);
        actionManager.enable("delete-positions", existsAPosition);
        actionManager.enable("revert-positions", existsMoreThanOnePosition);
        tableHeaderMenu.enable(existsMoreThanOnePosition);
        actionManager.enable("print-map", r.isMapViewAvailable() && existsAPosition);
        actionManager.enable("print-map-and-route", r.isMapViewAvailable() && existsAPosition && characteristics.equals(Route));
        actionManager.enable("print-profile", existsAPosition);

        r.selectPositions(selectedPositions);
    }
View Full Code Here

        CategoryTreeNode localRoot = new CategoryTreeNodeImpl(localCatalog.getRootCategory(), true, false);
        final CategoryTreeNodeImpl remoteRoot = new CategoryTreeNodeImpl(remoteCatalog.getRootCategory(), false, true);
        final RootTreeNode root = new RootTreeNode(localRoot, remoteRoot);
        catalogModel = new UndoCatalogModel(r.getContext().getUndoManager(), root, getOperator());

        final ActionManager actionManager = r.getContext().getActionManager();
        registerAction(buttonAddCategory, "add-category");
        registerAction(buttonRenameCategory, "rename-category");
        registerAction(buttonRemoveCategory, "remove-category");
        registerAction(buttonAddRouteFromFile, "add-route-from-file");
        registerAction(buttonAddRouteFromUrl, "add-route-from-url");
        registerAction(buttonRenameRoute, "rename-route");
        registerAction(buttonRemoveRoute, "remove-route");

        actionManager.register("add-category", new AddCategoryAction(treeCategories, catalogModel));
        actionManager.register("add-route-from-file", new AddFileAction());
        actionManager.register("add-route-from-url", new AddUrlAction());
        actionManager.register("rename-category", new RenameCategoryAction(treeCategories, catalogModel));
        actionManager.register("remove-category", new RemoveCategoriesAction(treeCategories, catalogModel));
        actionManager.register("rename-route", new RenameRouteAction(tableRoutes, catalogModel));
        actionManager.register("remove-route", new RemoveRoutesAction(tableRoutes, catalogModel));

        buttonLogin.addActionListener(new FrameAction() {
            public void run() {
                getOperator().showLogin();
            }
        });

        treeCategories.setModel(catalogModel.getCategoryTreeModel());
        treeCategories.addTreeSelectionListener(new TreeSelectionListener() {
            public void valueChanged(TreeSelectionEvent e) {
                selectTreePath(e.getPath(), false);
            }
        });
        treeCategories.getModel().addTreeModelListener(new TreeModelListener() {
            public void treeNodesChanged(TreeModelEvent e) {
                selectTreePath(treeCategories.getSelectionModel().getSelectionPath(), true);
            }

            public void treeNodesInserted(TreeModelEvent e) {
            }

            public void treeNodesRemoved(TreeModelEvent e) {
            }

            public void treeStructureChanged(TreeModelEvent e) {
            }
        });
        treeCategories.setCellRenderer(new CategoryTreeCellRenderer());
        treeCategories.setDragEnabled(true);
        treeCategories.setDropMode(ON);
        treeCategories.setTransferHandler(new TreeDragAndDropHandler());
        treeCategories.getSelectionModel().setSelectionMode(CONTIGUOUS_TREE_SELECTION);

        tableRoutes.setModel(catalogModel.getRoutesTableModel());
        tableRoutes.setDefaultRenderer(Object.class, new RoutesTableCellRenderer());
        tableRoutes.registerKeyboardAction(new FrameAction() {
            public void run() {
                actionManager.run("remove-route");
            }
        }, getKeyStroke(VK_DELETE, 0), WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
        tableRoutes.registerKeyboardAction(new FrameAction() {
            public void run() {
                selectAndScrollToPosition(tableRoutes, 0, 0);
View Full Code Here

        hgtFilesService = new HgtFilesService(dataSourceManager);
        elevationServiceFacade = new ElevationServiceFacade();
    }

    private void initializeActions() {
        final ActionManager actionManager = getContext().getActionManager();
        actionManager.register("exit", new ExitAction());
        actionManager.register("print-map", new PrintMapAction(false));
        actionManager.register("print-map-and-route", new PrintMapAction(true));
        actionManager.register("print-profile", new PrintProfileAction());
        actionManager.register("find-place", new FindPlaceAction());
        actionManager.register("show-map-and-positionlist", new ShowMapAndPositionListAction());
        actionManager.register("show-profile", new ShowProfileAction());
        actionManager.register("maximize-map", new MoveSplitPaneDividersAction(mapSplitPane, MAX_VALUE, profileSplitPane, MAX_VALUE));
        actionManager.register("maximize-positionlist", new MoveSplitPaneDividersAction(mapSplitPane, 0, profileSplitPane, MAX_VALUE));
        actionManager.register("insert-positions", new InsertPositionsAction());
        actionManager.register("delete-positions", new DeletePositionsAction());
        actionManager.register("revert-positions", new RevertPositionListAction());
        actionManager.register("convert-route-to-track", new ConvertRouteToTrackAction());
        actionManager.register("convert-track-to-route", new ConvertTrackToRouteAction());
        actionManager.register("show-downloads", new ShowDownloadsAction());
        actionManager.register("show-options", new ShowOptionsAction());
        actionManager.register("complete-flight-plan", new CompleteFlightPlanAction());
        actionManager.register("help-topics", new HelpTopicsAction());
        actionManager.register("check-for-update", new CheckForUpdateAction(updateChecker));
        actionManager.register("send-error-report", new SendErrorReportAction());
        actionManager.register("show-about", new ShowAboutAction());
        JMenu mergeMenu = findMenuComponent(getContext().getMenuBar(), "positionlist", "merge-positionlist", JMenu.class);
        new MergePositionListMenu(mergeMenu, getPositionsView(), getConvertPanel().getFormatAndRoutesModel());

        setHelpIDString(frame.getRootPane(), "top");
        setHelpIDString(convertPanel, "convert");
        setHelpIDString(browsePanel, "browse");
        setHelpIDString(mapPanel, "map");

        // delay JavaHelp initialization
        ActionListener actionListener = new ActionListener() {
            public void actionPerformed(ActionEvent event) {
                actionManager.run("help-topics", event);
            }
        };
        frame.getRootPane().registerKeyboardAction(actionListener,
                getKeyStroke(VK_HELP, 0), WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
        frame.getRootPane().registerKeyboardAction(actionListener,
View Full Code Here

    private void initializeSortPositions(JMenu sortPositionListMenu) {
        // JMenu sortPositionsPopupMenu = createMenu("sort-positions");
        // popupMenu.add(sortPositionsPopupMenu);

        ActionManager actionManager = Application.getInstance().getContext().getActionManager();
        for (PositionTableColumn column : columnModel.getPreparedColumns()) {
            if(column.getComparator() == null)
                continue;

            String menuItemText = RouteConverter.getBundle().getString(column.getName());
            SortColumnAction action = new SortColumnAction(positionsModel, column);
            actionManager.register("sort-column-" + column.getName(), action);

            // JMenuItem popupItem = new JMenuItem(action);
            // popupItem.setText(menuItemText);
            // sortPositionsPopupMenu.add(popupItem);
View Full Code Here

    private void initializeShowColumn(JMenu showColumnMenu) {
        // JMenu showColumnPopupMenu = createMenu("show-column-popup");
        // popupMenu.add(showColumnPopupMenu);

        VisibleListener visibleListener = new VisibleListener();
        ActionManager actionManager = Application.getInstance().getContext().getActionManager();
        for (PositionTableColumn column : columnModel.getPreparedColumns()) {
            column.addPropertyChangeListener(visibleListener);

            String menuItemText = RouteConverter.getBundle().getString(column.getName());
            ToggleColumnVisibilityAction action = new ToggleColumnVisibilityAction(column);
            actionManager.register("show-column-" + column.getName(), action);

            JCheckBoxMenuItem popupItem = new JCheckBoxMenuItem(menuItemText);
            popupItem.setModel(new PositionTableColumnButtonModel(column, action));
            popupMenu.add(popupItem);
View Full Code Here

            disableLastSelectedAction();
    }

    private List<ToggleColumnVisibilityAction> getActions() {
        List<ToggleColumnVisibilityAction> result = new ArrayList<>();
        ActionManager actionManager = Application.getInstance().getContext().getActionManager();
        for (PositionTableColumn column : columnModel.getPreparedColumns()) {
            result.add((ToggleColumnVisibilityAction) actionManager.get("show-column-" + column.getName()));
        }
        return result;
    }
View Full Code Here

                }
            }
        }

        private void enableActions() {
            ActionManager actionManager = getContext().getActionManager();
            actionManager.enable("maximize-map", location < mapSplitPane.getMaximumDividerLocation() - 10);
            actionManager.enable("maximize-positionlist", location > mapSplitPane.getMinimumDividerLocation() + 10);
            actionManager.enable("show-map-and-positionlist", location == 1 || location > mapSplitPane.getMaximumDividerLocation() + tabbedPane.getMinimumSize().width - 1);
        }
View Full Code Here

TOP

Related Classes of slash.navigation.gui.actions.ActionManager$ProxyAction

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.