+ _dialog = new JDialog(_parentFrame, I18nManager.getText(getNameKey()), true);
+ _dialog.setLocationRelativeTo(_parentFrame);
+ _dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
+ _dialog.getContentPane().add(makeDialogComponents());
+ _dialog.pack();
+ _colourChooser = new ColourChooser(_dialog);
+ }
+ enableCheckboxes();
+ _descriptionField.setEnabled(true);
+ _okButton.setEnabled(true);
+ _progressLabel.setText("");
+ _progressBar.setVisible(false);
+ _dialog.setVisible(true);
+ }
+
+
+ /**
+ * Create dialog components
+ * @return Panel containing all gui elements in dialog
+ */
+ private Component makeDialogComponents()
+ {
+ JPanel dialogPanel = new JPanel();
+ dialogPanel.setLayout(new BorderLayout(0, 5));
+ JPanel mainPanel = new JPanel();
+ mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS));
+ // Make a central panel with the text box and checkboxes
+ JPanel descPanel = new JPanel();
+ descPanel.setLayout(new FlowLayout());
+ descPanel.add(new JLabel(I18nManager.getText("dialog.exportkml.text")));
+ _descriptionField = new JTextField(20);
+ descPanel.add(_descriptionField);
+ descPanel.setAlignmentX(Component.CENTER_ALIGNMENT);
+ mainPanel.add(descPanel);
+ dialogPanel.add(mainPanel, BorderLayout.CENTER);
+ // point type selection
+ _pointTypeSelector = new PointTypeSelector();
+ _pointTypeSelector.setAlignmentX(Component.CENTER_ALIGNMENT);
+ mainPanel.add(_pointTypeSelector);
+ // Colour definition
+ Color trackColour = ColourUtils.colourFromHex(Config.getConfigString(Config.KEY_KML_TRACK_COLOUR));
+ if (trackColour == null) {
+ trackColour = DEFAULT_TRACK_COLOUR;
+ }
+ _colourPatch = new ColourPatch(trackColour);
+ _colourPatch.addMouseListener(new MouseAdapter() {
+ public void mouseClicked(MouseEvent e) {
+ _colourChooser.showDialog(_colourPatch.getBackground());
+ Color colour = _colourChooser.getChosenColour();
+ if (colour != null) _colourPatch.setColour(colour);
+ }
+ });
+ JPanel colourPanel = new JPanel();
+ colourPanel.add(new JLabel(I18nManager.getText("dialog.exportkml.trackcolour")));
+ colourPanel.add(_colourPatch);
+ mainPanel.add(colourPanel);
+ // Checkbox for altitude export
+ _altitudesCheckbox = new JCheckBox(I18nManager.getText("dialog.exportkml.altitude"));
+ _altitudesCheckbox.setHorizontalTextPosition(SwingConstants.LEFT);
+ _altitudesCheckbox.setAlignmentX(Component.CENTER_ALIGNMENT);
+ mainPanel.add(_altitudesCheckbox);
+ // Checkboxes for kmz export and image export
+ _kmzCheckbox = new JCheckBox(I18nManager.getText("dialog.exportkml.kmz"));
+ _kmzCheckbox.setHorizontalTextPosition(SwingConstants.LEFT);
+ _kmzCheckbox.setAlignmentX(Component.CENTER_ALIGNMENT);
+ _kmzCheckbox.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent e)
+ {
+ // enable image checkbox if kmz activated
+ enableCheckboxes();
+ }
+ });
+ mainPanel.add(_kmzCheckbox);
+ _exportImagesCheckbox = new JCheckBox(I18nManager.getText("dialog.exportkml.exportimages"));
+ _exportImagesCheckbox.setHorizontalTextPosition(SwingConstants.LEFT);
+ _exportImagesCheckbox.setAlignmentX(Component.CENTER_ALIGNMENT);
+ mainPanel.add(_exportImagesCheckbox);
+ mainPanel.add(Box.createVerticalStrut(10));
+ _progressLabel = new JLabel("...");
+ _progressLabel.setAlignmentX(Component.CENTER_ALIGNMENT);
+ mainPanel.add(_progressLabel);
+ _progressBar = new JProgressBar(0, 100);
+ _progressBar.setVisible(false);
+ _progressBar.setAlignmentX(Component.CENTER_ALIGNMENT);
+ mainPanel.add(_progressBar);
+ mainPanel.add(Box.createVerticalStrut(10));
+ // button panel at bottom
+ JPanel buttonPanel = new JPanel();
+ buttonPanel.setLayout(new FlowLayout(FlowLayout.RIGHT));
+ _okButton = new JButton(I18nManager.getText("button.ok"));
+ ActionListener okListener = new ActionListener() {
+ public void actionPerformed(ActionEvent e)
+ {
+ startExport();
+ }
+ };
+ _okButton.addActionListener(okListener);
+ _descriptionField.addActionListener(okListener);
+ buttonPanel.add(_okButton);
+ JButton cancelButton = new JButton(I18nManager.getText("button.cancel"));
+ cancelButton.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent e)
+ {
+ _cancelPressed = true;
+ _dialog.dispose();
+ }
+ });
+ buttonPanel.add(cancelButton);
+ dialogPanel.add(buttonPanel, BorderLayout.SOUTH);
+ return dialogPanel;
+ }
+
+
+ /**
+ * Enable the checkboxes according to data
+ */
+ private void enableCheckboxes()
+ {
+ _pointTypeSelector.init(_trackInfo);
+ boolean hasAltitudes = _track.hasData(Field.ALTITUDE);
+ if (!hasAltitudes) {_altitudesCheckbox.setSelected(false);}
+ boolean hasPhotos = _trackInfo.getPhotoList() != null && _trackInfo.getPhotoList().getNumPhotos() > 0;
+ _exportImagesCheckbox.setSelected(hasPhotos && _kmzCheckbox.isSelected());
+ _exportImagesCheckbox.setEnabled(hasPhotos && _kmzCheckbox.isSelected());
+ }
+
+
+ /**
+ * Start the export process based on the input parameters
+ */
+ private void startExport()
+ {
+ // OK pressed, now validate selection checkboxes
+ if (!_pointTypeSelector.getAnythingSelected()) {
+ JOptionPane.showMessageDialog(_parentFrame, I18nManager.getText("dialog.save.notypesselected"),
+ I18nManager.getText("dialog.saveoptions.title"), JOptionPane.WARNING_MESSAGE);
+ return;
+ }
+ // Choose output file
+ if (_fileChooser == null)
+ {
+ _fileChooser = new JFileChooser();