X-Git-Url: https://gitweb.fperrin.net/?p=GpsPrune.git;a=blobdiff_plain;f=src%2Ftim%2Fprune%2Ffunction%2Fsettings%2FSetPathsFunction.java;fp=src%2Ftim%2Fprune%2Ffunction%2Fsettings%2FSetPathsFunction.java;h=a5d08711e61841fe21f8763b899870c2d7bd0ba0;hp=0000000000000000000000000000000000000000;hb=ce6f2161b8596f7018d6a76bff79bc9e571f35fd;hpb=2d8cb72e84d5cc1089ce77baf1e34ea3ea2f8465 diff --git a/src/tim/prune/function/settings/SetPathsFunction.java b/src/tim/prune/function/settings/SetPathsFunction.java new file mode 100644 index 0000000..a5d0871 --- /dev/null +++ b/src/tim/prune/function/settings/SetPathsFunction.java @@ -0,0 +1,170 @@ +package tim.prune.function.settings; + +import java.awt.BorderLayout; +import java.awt.FlowLayout; +import java.awt.GridLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +import javax.swing.BorderFactory; +import javax.swing.JButton; +import javax.swing.JDialog; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JTextField; +import javax.swing.SwingConstants; + +import tim.prune.App; +import tim.prune.ExternalTools; +import tim.prune.GenericFunction; +import tim.prune.I18nManager; +import tim.prune.config.Config; + +/** + * Function to set the paths for the external programs (eg gnuplot) + */ +public class SetPathsFunction extends GenericFunction +{ + /** dialog object, cached */ + private JDialog _dialog = null; + /** edit boxes */ + private JTextField[] _editFields = null; + /** yes/no labels */ + private JLabel[] _installedLabels = null; + /** Config keys */ + private static final String[] CONFIG_KEYS = {Config.KEY_GPSBABEL_PATH, Config.KEY_GNUPLOT_PATH, Config.KEY_EXIFTOOL_PATH}; + /** Label keys */ + private static final String[] LABEL_KEYS = {"gpsbabel", "gnuplot", "exiftool"}; + /** Number of entries */ + private static final int NUM_KEYS = CONFIG_KEYS.length; + + /** + * Constructor from superclass + * @param inApp app object + */ + public SetPathsFunction(App inApp) + { + super(inApp); + } + + /** + * @return key for function name + */ + public String getNameKey() + { + return "function.setpaths"; + } + + /** + * Show the dialog + */ + public void begin() + { + // Make dialog window + if (_dialog == null) + { + _dialog = new JDialog(_parentFrame, I18nManager.getText(getNameKey()), true); + _dialog.setLocationRelativeTo(_parentFrame); + _dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); + _dialog.getContentPane().add(makeDialogComponents()); + _dialog.pack(); + } + checkPaths(); + // Show dialog + _dialog.setVisible(true); + } + + + /** + * Make the dialog components + * @return panel containing gui elements + */ + private JPanel makeDialogComponents() + { + JPanel dialogPanel = new JPanel(); + dialogPanel.setLayout(new BorderLayout()); + dialogPanel.add(new JLabel(I18nManager.getText("dialog.setpaths.intro")), BorderLayout.NORTH); + + // Main panel with edit boxes for paths + JPanel mainPanel = new JPanel(); + mainPanel.setLayout(new GridLayout(NUM_KEYS+1, 3, 10, 1)); + mainPanel.add(new JLabel(" ")); + mainPanel.add(new JLabel(" ")); + mainPanel.add(new JLabel(I18nManager.getText("dialog.setpaths.found"))); + _editFields = new JTextField[NUM_KEYS]; + _installedLabels = new JLabel[NUM_KEYS]; + for (int i=0; i