Package slash.navigation.converter.gui

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


        this.table = table;
        this.catalogModel = catalogModel;
    }

    public void run() {
        RouteConverter r = RouteConverter.getInstance();

        RouteModel route = getSelectedRouteModel(table);
        if(route == null)
            return;

        String name = (String) showInputDialog(r.getFrame(),
                    format(RouteConverter.getBundle().getString("rename-route-label"), formatName(route)),
                    r.getFrame().getTitle(), QUESTION_MESSAGE, null, null, route.getDescription());
        if (trim(name) == null)
            return;

        catalogModel.renameRoute(route, name);
    }
View Full Code Here


            public void run() {
                close();
            }
        }, KeyStroke.getKeyStroke(VK_ESCAPE, 0), WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);

        RouteConverter r = RouteConverter.getInstance();

        textFieldSearch.setText(r.getSearchPositionPreference());
        textFieldSearch.registerKeyboardAction(new DialogAction(this) {
            public void run() {
                searchPositions();
            }
        }, KeyStroke.getKeyStroke(VK_ENTER, 0), WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
View Full Code Here

        }
        savePreferences();
    }

    private void insertPosition() {
        RouteConverter r = RouteConverter.getInstance();
        PositionsModel positionsModel = r.getPositionsModel();

        int[] selectedRows = r.getPositionsView().getSelectedRows();
        int row = selectedRows.length > 0 ? selectedRows[0] : positionsModel.getRowCount();
        int insertRow = row > positionsModel.getRowCount() - 1 ? row : row + 1;
        Object[] objects = listResult.getSelectedValues();
        for (int i = objects.length - 1; i >= 0; i -= 1) {
            NavigationPosition position = (NavigationPosition) objects[i];
            positionsModel.add(insertRow, position.getLongitude(), position.getLatitude(),
                    position.getElevation(), null, null, position.getDescription());

            int[] rows = new int[]{insertRow};
            r.getPositionsSelectionModel().setSelectedPositions(rows, true);
            r.getBatchPositionAugmenter().addData(rows, false, true, true);
        }
    }
View Full Code Here

            r.getBatchPositionAugmenter().addData(rows, false, true, true);
        }
    }

    private void savePreferences() {
        RouteConverter r = RouteConverter.getInstance();
        r.setSearchPositionPreference(textFieldSearch.getText());
    }
View Full Code Here

    public DeletePositionsDialog() {
        super(RouteConverter.getInstance().getFrame(), "delete-positions");
        setTitle(RouteConverter.getBundle().getString("delete-positions-title"));
        setContentPane(contentPane);

        final RouteConverter r = RouteConverter.getInstance();

        labelDouglasPeucker.addMouseListener(new MouseAdapter() {
            public void mouseClicked(MouseEvent me) {
                startBrowserForDouglasPeucker(DeletePositionsDialog.this);
            }
        });

        setMnemonic(buttonSelectByDistance, "select-mnemonic");
        buttonSelectByDistance.addActionListener(new DialogAction(this) {
            public void run() {
                selectByDistance();
            }
        });

        setMnemonic(buttonSelectByOrder, "select-mnemonic");
        buttonSelectByOrder.addActionListener(new DialogAction(this) {
            public void run() {
                selectByOrder();
            }
        });

        setMnemonic(buttonSelectBySignificance, "select-mnemonic");
        buttonSelectBySignificance.addActionListener(new DialogAction(this) {
            public void run() {
                selectBySignificance();
            }
        });

        setMnemonic(buttonClearSelection, "clear-selection-mnemonic");
        buttonClearSelection.addActionListener(new DialogAction(this) {
            public void run() {
                clearSelection();
            }
        });

        setMnemonic(buttonDeletePositions, "delete-selected-positions-mnemonic");
        buttonDeletePositions.addActionListener(new DialogAction(this) {
            public void run() {
                deletePositions();
            }
        });

        setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
        addWindowListener(new WindowAdapter() {
            public void windowClosing(WindowEvent e) {
                close();
            }
        });

        contentPane.registerKeyboardAction(new DialogAction(this) {
            public void run() {
                close();
            }
        }, getKeyStroke(VK_ESCAPE, 0), WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);

        distance = new DoubleDocument(r.getSelectByDistancePreference());
        textFieldDistance.setDocument(distance);
        order = new IntegerDocument(r.getSelectByOrderPreference());
        textFieldOrder.setDocument(order);
        threshold = new DoubleDocument(r.getSelectBySignificancePreference());
        textFieldSignificance.setDocument(threshold);

        r.getPositionsView().getSelectionModel().addListSelectionListener(new ListSelectionListener() {
            public void valueChanged(ListSelectionEvent e) {
                if (e.getValueIsAdjusting())
                    return;
                if (r.getPositionsModel().isContinousRange())
                    return;
                handlePositionsUpdate();
            }
        });
        r.getPositionsModel().addTableModelListener(new TableModelListener() {
            public void tableChanged(TableModelEvent e) {
                if (r.getPositionsModel().isContinousRange())
                    return;
                handlePositionsUpdate();
            }
        });
View Full Code Here

        Application.getInstance().getContext().getActionManager().run("delete");
        handlePositionsUpdate();
    }

    private void savePreferences() {
        RouteConverter r = RouteConverter.getInstance();
        r.setSelectByDistancePreference(distance.getDouble());
        r.setSelectByOrderPreference(order.getInt());
        r.setSelectBySignificancePreference(threshold.getDouble());
    }
View Full Code Here

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

        final RouteConverter r = RouteConverter.getInstance();

        ComboBoxModel<Locale> localeModel = new DefaultComboBoxModel<>(new Locale[]{
                ARABIA, CHINA, CZECH, GERMANY, US, SPAIN, FRANCE, CROATIA,
                ITALY, NEDERLANDS, POLAND, RUSSIA, SLOVAKIA, SERBIA, ROOT
        });
        localeModel.setSelectedItem(Application.getInstance().getLocale());
        comboBoxLocale.setModel(localeModel);
        comboBoxLocale.setRenderer(new LocaleListCellRenderer());
        comboBoxLocale.addItemListener(new ItemListener() {
            public void itemStateChanged(ItemEvent e) {
                if (e.getStateChange() != SELECTED)
                    return;
                Locale locale = (Locale) e.getItem();
                Application.getInstance().setLocale(locale);
            }
        });

        textFieldBabelPath.getDocument().addDocumentListener(new DocumentListener() {
            public void insertUpdate(DocumentEvent e) {
                BabelFormat.setBabelPathPreference(textFieldBabelPath.getText());
            }

            public void removeUpdate(DocumentEvent e) {
                insertUpdate(e);
            }

            public void changedUpdate(DocumentEvent e) {
                insertUpdate(e);
            }
        });
        textFieldBabelPath.setText(BabelFormat.getBabelPathPreference());
        buttonChooseBabelPath.addActionListener(new FrameAction() {
            public void run() {
                chooseBabelPath();
            }
        });

        new CheckBoxPreferencesSynchronizer(checkBoxAutomaticUpdateCheck, getPreferences(), AUTOMATIC_UPDATE_CHECK_PREFERENCE, true);

        new CheckBoxPreferencesSynchronizer(checkBoxRecenterAfterZooming, getPreferences(), RECENTER_AFTER_ZOOMING_PREFERENCE, false);
        checkBoxRecenterAfterZooming.addItemListener(new ItemListener() {
            public void itemStateChanged(ItemEvent e) {
                r.setRecenterAfterZooming(checkBoxRecenterAfterZooming.isSelected());
            }
        });

        new CheckBoxPreferencesSynchronizer(checkBoxShowCoordinates, getPreferences(), SHOW_COORDINATES_PREFERENCE, false);
        checkBoxShowCoordinates.addItemListener(new ItemListener() {
            public void itemStateChanged(ItemEvent e) {
                r.setShowCoordinates(checkBoxShowCoordinates.isSelected());
            }
        });

        new CheckBoxPreferencesSynchronizer(checkBoxShowWaypointDescription, getPreferences(), SHOW_WAYPOINT_DESCRIPTION_PREFERENCE, false);
        checkBoxShowWaypointDescription.addItemListener(new ItemListener() {
            public void itemStateChanged(ItemEvent e) {
                r.setShowWaypointDescription(checkBoxShowWaypointDescription.isSelected());
            }
        });

        DefaultComboBoxModel<RoutingService> routingServiceModel = new DefaultComboBoxModel<>();
        for (RoutingService service : r.getRoutingServiceFacade().getRoutingServices())
            routingServiceModel.addElement(service);
        routingServiceModel.setSelectedItem(r.getRoutingServiceFacade().getRoutingService());
        comboBoxRoutingService.setModel(routingServiceModel);
        comboBoxRoutingService.setRenderer(new RoutingServiceListCellRenderer());
        comboBoxRoutingService.addItemListener(new ItemListener() {
            public void itemStateChanged(ItemEvent e) {
                if (e.getStateChange() != SELECTED)
                    return;
                RoutingService service = RoutingService.class.cast(e.getItem());
                r.getRoutingServiceFacade().setRoutingService(service);
                handleRoutingServiceUpdate();
            }
        });

        textFieldRoutingServicePath.getDocument().addDocumentListener(new DocumentListener() {
            public void insertUpdate(DocumentEvent e) {
                r.getRoutingServiceFacade().getRoutingService().setPath(textFieldRoutingServicePath.getText());
            }

            public void removeUpdate(DocumentEvent e) {
                insertUpdate(e);
            }

            public void changedUpdate(DocumentEvent e) {
                insertUpdate(e);
            }
        });
        buttonChooseRoutingServicePath.addActionListener(new FrameAction() {
            public void run() {
                chooseRoutingServicePath();
            }
        });
        handleRoutingServiceUpdate();

        comboboxTravelMode.setRenderer(new TravelModeListCellRenderer());
        comboboxTravelMode.addItemListener(new ItemListener() {
            public void itemStateChanged(ItemEvent e) {
                if (e.getStateChange() != SELECTED)
                    return;
                TravelMode travelMode = (TravelMode) e.getItem();
                r.getRoutingServiceFacade().setTravelMode(travelMode);
            }
        });
        checkBoxAvoidFerries.addItemListener(new ItemListener() {
            public void itemStateChanged(ItemEvent e) {
                r.getRoutingServiceFacade().setAvoidFerries(checkBoxAvoidFerries.isSelected());
            }
        });
        checkBoxAvoidHighways.addItemListener(new ItemListener() {
            public void itemStateChanged(ItemEvent e) {
                r.getRoutingServiceFacade().setAvoidHighways(checkBoxAvoidHighways.isSelected());
            }
        });
        checkBoxAvoidTolls.addItemListener(new ItemListener() {
            public void itemStateChanged(ItemEvent e) {
                r.getRoutingServiceFacade().setAvoidTolls(checkBoxAvoidTolls.isSelected());
            }
        });

        ComboBoxModel<NumberPattern> numberPatternModel = new DefaultComboBoxModel<>(new NumberPattern[]{
                Description_Only, Number_Only, Number_Directly_Followed_By_Description, Number_Space_Then_Description
        });
        numberPatternModel.setSelectedItem(r.getNumberPatternPreference());
        comboboxNumberPattern.setModel(numberPatternModel);
        comboboxNumberPattern.setRenderer(new NumberPatternListCellRenderer());
        comboboxNumberPattern.addItemListener(new ItemListener() {
            public void itemStateChanged(ItemEvent e) {
                if (e.getStateChange() != SELECTED)
                    return;
                NumberPattern numberPattern = NumberPattern.class.cast(e.getItem());
                r.setNumberPatternPreference(numberPattern);
            }
        });

        DefaultComboBoxModel<ElevationService> elevationServiceModel = new DefaultComboBoxModel<>();
        for (ElevationService service : r.getElevationServiceFacade().getElevationServices())
            elevationServiceModel.addElement(service);
        elevationServiceModel.setSelectedItem(r.getElevationServiceFacade().getElevationService());
        comboBoxElevationService.setModel(elevationServiceModel);
        comboBoxElevationService.setRenderer(new ElevationServiceListCellRenderer());
        comboBoxElevationService.addItemListener(new ItemListener() {
            public void itemStateChanged(ItemEvent e) {
                if (e.getStateChange() != SELECTED)
                    return;
                ElevationService service = ElevationService.class.cast(e.getItem());
                r.getElevationServiceFacade().setElevationService(service);
                handleElevationServiceUpdate();
            }
        });

        textFieldElevationServicePath.getDocument().addDocumentListener(new DocumentListener() {
            public void insertUpdate(DocumentEvent e) {
                r.getElevationServiceFacade().getElevationService().setPath(textFieldElevationServicePath.getText());
            }

            public void removeUpdate(DocumentEvent e) {
                insertUpdate(e);
            }

            public void changedUpdate(DocumentEvent e) {
                insertUpdate(e);
            }
        });
        buttonChooseElevationServicePath.addActionListener(new FrameAction() {
            public void run() {
                chooseElevationServicePath();
            }
        });
        handleElevationServiceUpdate();

        ComboBoxModel<UnitSystem> unitSystemModel = new DefaultComboBoxModel<>(new UnitSystem[]{
                Metric, Statute, Nautic
        });
        unitSystemModel.setSelectedItem(r.getUnitSystemModel().getUnitSystem());
        comboBoxUnitSystem.setModel(unitSystemModel);
        comboBoxUnitSystem.setRenderer(new UnitSystemListCellRenderer());
        comboBoxUnitSystem.addItemListener(new ItemListener() {
            public void itemStateChanged(ItemEvent e) {
                if (e.getStateChange() != SELECTED)
                    return;
                UnitSystem unitSystem = UnitSystem.class.cast(e.getItem());
                r.getUnitSystemModel().setUnitSystem(unitSystem);
            }
        });

        ComboBoxModel<DegreeFormat> degreeFormatModel = new DefaultComboBoxModel<>(new DegreeFormat[]{
                Degrees, Degrees_Minutes, Degrees_Minutes_Seconds
        });
        degreeFormatModel.setSelectedItem(r.getUnitSystemModel().getDegreeFormat());
        comboBoxDegreeFormat.setModel(degreeFormatModel);
        comboBoxDegreeFormat.setRenderer(new DegreeFormatListCellRenderer());
        comboBoxDegreeFormat.addItemListener(new ItemListener() {
            public void itemStateChanged(ItemEvent e) {
                if (e.getStateChange() != SELECTED)
                    return;
                DegreeFormat degreeFormat = DegreeFormat.class.cast(e.getItem());
                r.getUnitSystemModel().setDegreeFormat(degreeFormat);
            }
        });

        ComboBoxModel<String> timeZoneModel = new DefaultComboBoxModel<>(getTimeZoneIds());
        timeZoneModel.setSelectedItem(r.getTimeZonePreference());
        comboBoxTimeZone.setModel(timeZoneModel);
        comboBoxTimeZone.addItemListener(new ItemListener() {
            public void itemStateChanged(ItemEvent e) {
                if (e.getStateChange() != SELECTED)
                    return;
                String timeZoneId = String.valueOf(e.getItem());
                r.setTimeZonePreference(timeZoneId);
            }
        });

        buttonClose.addActionListener(new DialogAction(this) {
            public void run() {
View Full Code Here

        this.tree = tree;
        this.catalogModel = catalogModel;
    }

    public void run() {
        RouteConverter r = RouteConverter.getInstance();

        final CategoryTreeNode category = getSelectedCategoryTreeNode(tree);
        if (category == null)
            return;

        final String name = showInputDialog(r.getFrame(),
                format(RouteConverter.getBundle().getString("add-category-label"), category.getName()),
                r.getFrame().getTitle(), QUESTION_MESSAGE);
        if (trim(name) == null)
            return;

        catalogModel.addCategories(asList(category), asList(name),
                new Runnable() {
View Full Code Here

        textFieldBabelPath.setText(selected.getAbsolutePath());
    }

    private void chooseRoutingServicePath() {
        RouteConverter r = RouteConverter.getInstance();
        JFileChooser chooser = createJFileChooser();
        chooser.setDialogTitle(RouteConverter.getBundle().getString("choose-routing-service-path"));
        chooser.setSelectedFile(new File(r.getRoutingServiceFacade().getRoutingService().getPath()));
        chooser.setFileSelectionMode(DIRECTORIES_ONLY);
        chooser.setMultiSelectionEnabled(false);
        int open = chooser.showOpenDialog(r.getFrame());
        if (open != APPROVE_OPTION)
            return;

        File selected = chooser.getSelectedFile();
        if (selected == null || selected.getName().length() == 0)
View Full Code Here

        textFieldRoutingServicePath.setText(selected.getAbsolutePath());
    }

    private void chooseElevationServicePath() {
        RouteConverter r = RouteConverter.getInstance();
        JFileChooser chooser = createJFileChooser();
        chooser.setDialogTitle(RouteConverter.getBundle().getString("choose-elevation-service-path"));
        chooser.setSelectedFile(new File(r.getElevationServiceFacade().getElevationService().getPath()));
        chooser.setFileSelectionMode(DIRECTORIES_ONLY);
        chooser.setMultiSelectionEnabled(false);
        int open = chooser.showOpenDialog(r.getFrame());
        if (open != APPROVE_OPTION)
            return;

        File selected = chooser.getSelectedFile();
        if (selected == null || selected.getName().length() == 0)
View Full Code Here

TOP

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

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.