Package slash.navigation.converter.gui

Examples of slash.navigation.converter.gui.RouteConverter$ProfileSplitPaneListener


* @author Christian Pesch
*/

public class ConvertRouteToTrackAction extends FrameAction {
    public void run() {
        RouteConverter r = RouteConverter.getInstance();
        r.setRouteCharacteristics(Track);
        r.getContext().getActionManager().run("select-all");
        r.getInsertPositionFacade().insertAllWaypoints();
    }
View Full Code Here


* @author Christian Pesch
*/

public class AddFileAction extends FrameAction {
    public void run() {
        RouteConverter r = RouteConverter.getInstance();

        JFileChooser chooser = createJFileChooser();
        chooser.setDialogTitle(RouteConverter.getBundle().getString("add-file"));
        chooser.setSelectedFile(r.getUploadRoutePreference());
        chooser.setFileSelectionMode(FILES_ONLY);
        chooser.setMultiSelectionEnabled(true);
        int open = chooser.showOpenDialog(r.getFrame());
        if (open != APPROVE_OPTION)
            return;

        File[] selected = chooser.getSelectedFiles();
        if (selected == null || selected.length == 0)
            return;

        r.setUploadRoutePreference(selected[0]);
        r.addFilesToCatalog(asList(selected));
    }
View Full Code Here

    public BrowsePanel() {
        initialize();
    }

    private void initialize() {
        final RouteConverter r = RouteConverter.getInstance();

        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);
            }
        }, getKeyStroke(VK_HOME, 0), WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
        tableRoutes.registerKeyboardAction(new FrameAction() {
            public void run() {
                selectAndScrollToPosition(tableRoutes, 0, tableRoutes.getSelectedRow());
            }
        }, getKeyStroke(VK_HOME, SHIFT_DOWN_MASK), WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
        tableRoutes.registerKeyboardAction(new FrameAction() {
            public void run() {
                int lastRow = tableRoutes.getRowCount() - 1;
                selectAndScrollToPosition(tableRoutes, lastRow, lastRow);
            }
        }, getKeyStroke(VK_END, 0), WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
        tableRoutes.registerKeyboardAction(new FrameAction() {
            public void run() {
                selectAndScrollToPosition(tableRoutes, tableRoutes.getRowCount() - 1, tableRoutes.getSelectedRow());
            }
        }, getKeyStroke(VK_END, SHIFT_DOWN_MASK), WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
        tableRoutes.setDragEnabled(true);
        tableRoutes.setTransferHandler(new TableDragHandler());
        tableRoutes.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
            public void valueChanged(ListSelectionEvent e) {
                if (e.getValueIsAdjusting())
                    return;
                handlePositionListUpdate();
            }
        });
        TableCellRenderer headerRenderer = new SimpleHeaderRenderer("description", "creator");
        TableColumnModel columns = tableRoutes.getColumnModel();
        for (int i = 0; i < columns.getColumnCount(); i++) {
            TableColumn column = columns.getColumn(i);
            column.setHeaderRenderer(headerRenderer);
            if (i == 1) {
                column.setPreferredWidth(80);
                column.setMaxWidth(100);
            }
        }

        browsePanel.setTransferHandler(new PanelDropHandler());

        new Thread(new Runnable() {
            public void run() {
                // do the loading in a separate thread since treeCategories.setModel(categoryTreeModel)
                // would do it in the AWT EventQueue
                catalogModel.getCategoryTreeModel().getChildCount(remoteRoot);

                invokeLater(new Runnable() {
                    public void run() {
                        startWaitCursor(r.getFrame().getRootPane());
                        try {
                            String selected = r.getCategoryPreference();
                            selectTreePath(TreePathStringConversion.fromString(root, selected), true);
                            // make sure the subcategories of the remote catalog are visible, too
                            treeCategories.expandPath(new TreePath(new Object[]{root, remoteRoot}));
                        } finally {
                            stopWaitCursor(r.getFrame().getRootPane());
                        }
                    }
                });
            }
        }, "CategoryTreeInitializer").start();
View Full Code Here

        addFileDialog.restoreLocation();
        addFileDialog.setVisible(true);
    }

    private void addFileToCatalog(CategoryTreeNode categoryTreeNode, File file) {
        RouteConverter r = RouteConverter.getInstance();
        String path = Files.createReadablePath(file);
        String description = null;
        Double length = null;
        try {
            NavigationFormatParser parser = new NavigationFormatParser();
            ParserResult result = parser.read(file);
            if (result.isSuccessful()) {
                BaseRoute<BaseNavigationPosition, BaseNavigationFormat> route = result.getTheRoute();
                if (route != null) {
                    description = createRouteDescription(route);
                    length = route.getDistance();
                }
                showAddFileToCatalog(categoryTreeNode, description, length, file);
            } else
                r.handleUnsupportedFormat(path);
        } catch (BabelException e) {
            r.handleBabelError(e);
        } catch (OutOfMemoryError e) {
            r.handleOutOfMemoryError();
        } catch (FileNotFoundException e) {
            r.handleFileNotFound(path);
        } catch (Throwable t) {
            log.severe("Cannot parse description from route " + path + ": " + t.getMessage());
            r.handleOpenError(t, path);
        }
    }
View Full Code Here

        }
    }

    private void addFilesToCatalog(CategoryTreeNode category, List<File> files) {
        if (category == null || category.getParent() == null) {
            RouteConverter r = RouteConverter.getInstance();
            showMessageDialog(r.getFrame(),
                    r.getContext().getBundle().getString("add-file-category-missing"),
                    r.getFrame().getTitle(), ERROR_MESSAGE);
            return;
        }

        for (File file : files) {
            addFileToCatalog(category, file);
View Full Code Here

        super(RouteConverter.getInstance().getFrame(), "about");
        setTitle(RouteConverter.getBundle().getString("about-title"));
        setContentPane(contentPane);
        getRootPane().setDefaultButton(buttonClose);

        final RouteConverter r = RouteConverter.getInstance();

        labelBrowse.addMouseListener(new MouseAdapter() {
            public void mouseClicked(MouseEvent me) {
                startBrowserForHomepage(r.getFrame());
            }
        });

        labelCp.addMouseListener(new MouseAdapter() {
            public void mouseClicked(MouseEvent me) {
                startMail(r.getFrame());
            }
        });

        labelMail.addMouseListener(new MouseAdapter() {
            public void mouseClicked(MouseEvent me) {
                startBrowserForForum(r.getFrame());
            }
        });

        labelCredit.addMouseListener(new MouseAdapter() {
            public void mouseClicked(MouseEvent me) {
                startBrowserForGeonames(r.getFrame());
            }
        });

        String featuredTo = getFeature("featured-to");
        if (featuredTo != null) {
View Full Code Here

        }
        return result;
    }

    private void openOrAdd(List<File> files) {
        RouteConverter r = RouteConverter.getInstance();
        if (r.isConvertPanelSelected()) {
            List<File> onlyFiles = toFilesOnly(files);
            r.openPositionList(toUrls(onlyFiles.toArray(new File[onlyFiles.size()])));
        } else if (r.isBrowsePanelSelected())
            r.addFilesToCatalog(files);
    }
View Full Code Here

        } else if (r.isBrowsePanelSelected())
            r.addFilesToCatalog(files);
    }

    private void openOrAdd(String string) {
        RouteConverter r = RouteConverter.getInstance();
        if (r.isConvertPanelSelected()) {
            String url = extractUrl(string);
            r.openPositionList(toUrls(url));
        } else if (r.isBrowsePanelSelected()) {
            r.addUrlToCatalog(string);
        }
    }
View Full Code Here

* @author Christian Pesch
*/

public class AddPopulatedPlaceToPositionsAction extends FrameAction {
    public void run() {
        RouteConverter r = RouteConverter.getInstance();
        int[] selectedRows = r.getPositionsView().getSelectedRows();
        if (selectedRows.length > 0) {
            r.getBatchPositionAugmenter().addPopulatedPlaces(selectedRows);
        }
    }
View Full Code Here

* @author Christian Pesch
*/

public class AddPostalAddressToPositionsAction extends FrameAction {
    public void run() {
        RouteConverter r = RouteConverter.getInstance();
        int[] selectedRows = r.getPositionsView().getSelectedRows();
        if (selectedRows.length > 0) {
            r.getBatchPositionAugmenter().addPostalAddresses(selectedRows);
        }
    }
View Full Code Here

TOP

Related Classes of slash.navigation.converter.gui.RouteConverter$ProfileSplitPaneListener

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.