X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fde%2Ftodesbaum%2Fjsite%2Fgui%2FPreferencesPage.java;h=66ab6abd1bfe76bf27ddde289a8c8dcce76d52b6;hb=4f84b1633c3f3c9a8af2fa5e15b29fb1b728bb2e;hp=27ff163db8d459452cb7cbe4d4ef18db6e4660e9;hpb=a03efa6ebf81fc25c9b3e4effdd1529e956ad24b;p=jSite.git
diff --git a/src/de/todesbaum/jsite/gui/PreferencesPage.java b/src/de/todesbaum/jsite/gui/PreferencesPage.java
index 27ff163..66ab6ab 100644
--- a/src/de/todesbaum/jsite/gui/PreferencesPage.java
+++ b/src/de/todesbaum/jsite/gui/PreferencesPage.java
@@ -1,6 +1,5 @@
/*
- * jSite - PreferencesPage.java -
- * Copyright © 2009 David Roden
+ * jSite - PreferencesPage.java - Copyright © 2009â2012 David Roden
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -30,6 +29,8 @@ import javax.swing.Action;
import javax.swing.BorderFactory;
import javax.swing.ButtonGroup;
import javax.swing.JButton;
+import javax.swing.JCheckBox;
+import javax.swing.JComboBox;
import javax.swing.JFileChooser;
import javax.swing.JLabel;
import javax.swing.JPanel;
@@ -38,8 +39,8 @@ import javax.swing.JTextField;
import de.todesbaum.jsite.i18n.I18n;
import de.todesbaum.jsite.i18n.I18nContainer;
-import de.todesbaum.jsite.main.Configuration;
-import de.todesbaum.jsite.main.Configuration.ConfigurationDirectory;
+import de.todesbaum.jsite.main.ConfigurationLocator.ConfigurationLocation;
+import de.todesbaum.util.freenet.fcp2.PriorityClass;
import de.todesbaum.util.swing.TWizard;
import de.todesbaum.util.swing.TWizardPage;
@@ -65,17 +66,29 @@ public class PreferencesPage extends TWizardPage {
/** Action when selecting âhome directory.â */
private Action homeDirectoryAction;
+ /** Action when selecting âcustom directory.â */
+ private Action customDirectoryAction;
+
+ /** Action when selecting âuse early encode.â */
+ private Action useEarlyEncodeAction;
+
+ /** Action when a priority was selected. */
+ private Action priorityAction;
+
/** The text field containing the directory. */
private JTextField tempDirectoryTextField;
/** The temp directory. */
private String tempDirectory;
- /** The configuration. */
- private Configuration configuration;
+ /** The configuration location. */
+ private ConfigurationLocation configurationLocation;
+
+ /** Whether to use âearly encode.â */
+ private boolean useEarlyEncode;
- /** The configuration directory. */
- private ConfigurationDirectory configurationDirectory;
+ /** The prioriy for inserts. */
+ private PriorityClass priority;
/** The âdefaultâ button. */
private JRadioButton defaultTempDirectory;
@@ -86,21 +99,25 @@ public class PreferencesPage extends TWizardPage {
/** The ânext to JAR fileâ checkbox. */
private JRadioButton nextToJarFile;
- /** The âcurrent directoryâ checkbox. */
- private JRadioButton currentDirectory;
-
/** The âhome directoryâ checkbox. */
private JRadioButton homeDirectory;
+ /** The âcustom directoryâ checkbox. */
+ private JRadioButton customDirectory;
+
+ /** The âuse early encodeâ checkbox. */
+ private JCheckBox useEarlyEncodeCheckBox;
+
+ /** The insert priority select box. */
+ private JComboBox insertPriorityComboBox;
+
/**
* Creates a new âpreferencesâ page.
*
* @param wizard
* The wizard this page belongs to
- * @param configuration
- * The configuration that is controlled
*/
- public PreferencesPage(TWizard wizard, Configuration configuration) {
+ public PreferencesPage(TWizard wizard) {
super(wizard);
pageInit();
setHeading(I18n.getMessage("jsite.preferences.heading"));
@@ -115,7 +132,6 @@ public class PreferencesPage extends TWizardPage {
setDescription(I18n.getMessage("jsite.preferences.description"));
}
});
- this.configuration = configuration;
}
//
@@ -151,34 +167,100 @@ public class PreferencesPage extends TWizardPage {
}
/**
- * Returns the configuration directory.
+ * Returns the configuration location.
*
- * @return The configuration directory
+ * @return The configuration location
*/
- public ConfigurationDirectory getConfigurationDirectory() {
- return configurationDirectory;
+ public ConfigurationLocation getConfigurationLocation() {
+ return configurationLocation;
}
/**
- * Sets the configuration directory.
+ * Sets the configuration location.
*
- * @param configurationDirectory
- * The configuration directory
+ * @param configurationLocation
+ * The configuration location
*/
- public void setConfigurationDirectory(ConfigurationDirectory configurationDirectory) {
- this.configurationDirectory = configurationDirectory;
- configuration.setConfigurationDirectory(configurationDirectory);
- switch (configurationDirectory) {
+ public void setConfigurationLocation(ConfigurationLocation configurationLocation) {
+ this.configurationLocation = configurationLocation;
+ switch (configurationLocation) {
case NEXT_TO_JAR_FILE:
nextToJarFile.setSelected(true);
break;
case HOME_DIRECTORY:
homeDirectory.setSelected(true);
break;
+ case CUSTOM:
+ customDirectory.setSelected(true);
+ break;
}
}
/**
+ * Sets whether it is possible to select the ânext to JAR fileâ option for
+ * the configuration location.
+ *
+ * @param nextToJarFile
+ * {@code true} if the configuration file can be saved next to
+ * the JAR file, {@code false} otherwise
+ */
+ public void setHasNextToJarConfiguration(boolean nextToJarFile) {
+ this.nextToJarFile.setEnabled(nextToJarFile);
+ }
+
+ /**
+ * Sets whether it is possible to select the âcustom locationâ option for
+ * the configuration location.
+ *
+ * @param customDirectory
+ * {@code true} if the configuration file can be saved to a
+ * custom location, {@code false} otherwise
+ */
+ public void setHasCustomConfiguration(boolean customDirectory) {
+ this.customDirectory.setEnabled(customDirectory);
+ }
+
+ /**
+ * Returns whether to use the âearly encodeâ flag for the insert.
+ *
+ * @return {@code true} to set the âearly encodeâ flag for the insert,
+ * {@code false} otherwise
+ */
+ public boolean useEarlyEncode() {
+ return useEarlyEncode;
+ }
+
+ /**
+ * Sets whether to use the âearly encodeâ flag for the insert.
+ *
+ * @param useEarlyEncode
+ * {@code true} to set the âearly encodeâ flag for the insert,
+ * {@code false} otherwise
+ */
+ public void setUseEarlyEncode(boolean useEarlyEncode) {
+ useEarlyEncodeCheckBox.setSelected(useEarlyEncode);
+ }
+
+ /**
+ * Returns the configured insert priority.
+ *
+ * @return The insert priority
+ */
+ public PriorityClass getPriority() {
+ return priority;
+ }
+
+ /**
+ * Sets the insert priority.
+ *
+ * @param priority
+ * The insert priority
+ */
+ public void setPriority(PriorityClass priority) {
+ insertPriorityComboBox.setSelectedItem(priority);
+ }
+
+ /**
* {@inheritDoc}
*/
@Override
@@ -238,14 +320,35 @@ public class PreferencesPage extends TWizardPage {
@SuppressWarnings("synthetic-access")
public void actionPerformed(ActionEvent actionevent) {
- configurationDirectory = ConfigurationDirectory.NEXT_TO_JAR_FILE;
+ configurationLocation = ConfigurationLocation.NEXT_TO_JAR_FILE;
}
};
homeDirectoryAction = new AbstractAction(I18n.getMessage("jsite.preferences.config-directory.home")) {
@SuppressWarnings("synthetic-access")
public void actionPerformed(ActionEvent actionevent) {
- configurationDirectory = ConfigurationDirectory.HOME_DIRECTORY;
+ configurationLocation = ConfigurationLocation.HOME_DIRECTORY;
+ }
+ };
+ customDirectoryAction = new AbstractAction(I18n.getMessage("jsite.preferences.config-directory.custom")) {
+
+ @SuppressWarnings("synthetic-access")
+ public void actionPerformed(ActionEvent actionEvent) {
+ configurationLocation = ConfigurationLocation.CUSTOM;
+ }
+ };
+ useEarlyEncodeAction = new AbstractAction(I18n.getMessage("jsite.preferences.insert-options.use-early-encode")) {
+
+ @SuppressWarnings("synthetic-access")
+ public void actionPerformed(ActionEvent actionEvent) {
+ useEarlyEncode = useEarlyEncodeCheckBox.isSelected();
+ }
+ };
+ priorityAction = new AbstractAction(I18n.getMessage("jsite.preferences.insert-options.priority")) {
+
+ @SuppressWarnings("synthetic-access")
+ public void actionPerformed(ActionEvent actionEvent) {
+ priority = (PriorityClass) insertPriorityComboBox.getSelectedItem();
}
};
@@ -258,6 +361,8 @@ public class PreferencesPage extends TWizardPage {
chooseTempDirectoryAction.putValue(Action.NAME, I18n.getMessage("jsite.preferences.temp-directory.choose"));
nextToJarFileAction.putValue(Action.NAME, I18n.getMessage("jsite.preferences.config-directory.jar"));
homeDirectoryAction.putValue(Action.NAME, I18n.getMessage("jsite.preferences.config-directory.home"));
+ customDirectoryAction.putValue(Action.NAME, I18n.getMessage("jsite.preferences.config-directory.custom"));
+ useEarlyEncodeAction.putValue(Action.NAME, I18n.getMessage("jsite.preferences.insert-options.use-early-encode"));
}
});
}
@@ -307,10 +412,26 @@ public class PreferencesPage extends TWizardPage {
homeDirectory = new JRadioButton(homeDirectoryAction);
preferencesPanel.add(homeDirectory, new GridBagConstraints(0, 5, 3, 1, 1.0, 0.0, GridBagConstraints.LINE_START, GridBagConstraints.BOTH, new Insets(0, 18, 0, 0), 0, 0));
+ customDirectory = new JRadioButton(customDirectoryAction);
+ preferencesPanel.add(customDirectory, new GridBagConstraints(0, 6, 3, 1, 1.0, 0.0, GridBagConstraints.LINE_START, GridBagConstraints.BOTH, new Insets(0, 18, 0, 0), 0, 0));
+
ButtonGroup configurationDirectoryButtonGroup = new ButtonGroup();
configurationDirectoryButtonGroup.add(nextToJarFile);
- configurationDirectoryButtonGroup.add(currentDirectory);
configurationDirectoryButtonGroup.add(homeDirectory);
+ configurationDirectoryButtonGroup.add(customDirectory);
+
+ final JLabel insertOptionsLabel = new JLabel("" + I18n.getMessage("jsite.preferences.insert-options") + "");
+ preferencesPanel.add(insertOptionsLabel, new GridBagConstraints(0, 7, 3, 1, 1.0, 0.0, GridBagConstraints.LINE_START, GridBagConstraints.NONE, new Insets(12, 0, 0, 0), 0, 0));
+
+ useEarlyEncodeCheckBox = new JCheckBox(useEarlyEncodeAction);
+ preferencesPanel.add(useEarlyEncodeCheckBox, new GridBagConstraints(0, 8, 3, 1, 1.0, 0.0, GridBagConstraints.LINE_START, GridBagConstraints.NONE, new Insets(6, 18, 0, 0), 0, 0));
+
+ final JLabel insertPriorityLabel = new JLabel(I18n.getMessage("jsite.preferences.insert-options.priority"));
+ preferencesPanel.add(insertPriorityLabel, new GridBagConstraints(0, 9, 1, 1, 0.0, 0.0, GridBagConstraints.LINE_START, GridBagConstraints.NONE, new Insets(6, 18, 0, 0), 0, 0));
+
+ insertPriorityComboBox = new JComboBox(new PriorityClass[] { PriorityClass.MINIMUM, PriorityClass.PREFETCH, PriorityClass.BULK, PriorityClass.UPDATABLE, PriorityClass.SEMI_INTERACTIVE, PriorityClass.INTERACTIVE, PriorityClass.MAXIMUM });
+ insertPriorityComboBox.setAction(priorityAction);
+ preferencesPanel.add(insertPriorityComboBox, new GridBagConstraints(1, 9, 2, 1, 1.0, 0.0, GridBagConstraints.LINE_START, GridBagConstraints.VERTICAL, new Insets(0, 18, 0, 0), 0, 0));
I18nContainer.getInstance().registerRunnable(new Runnable() {
@@ -320,6 +441,8 @@ public class PreferencesPage extends TWizardPage {
public void run() {
tempDirectoryLabel.setText("" + I18n.getMessage("jsite.preferences.temp-directory") + "");
configurationDirectoryLabel.setText("" + I18n.getMessage("jsite.preferences.config-directory") + "");
+ insertOptionsLabel.setText("" + I18n.getMessage("jsite.preferences.insert-options") + "");
+ insertPriorityLabel.setText(I18n.getMessage("jsite.preferences.insert-options.priority"));
}
});