/**
* © 2008 INA Service GmbH
*/
+
package net.pterodactylus.jsite.gui;
import java.awt.BorderLayout;
import java.awt.FlowLayout;
+import java.awt.GridBagConstraints;
+import java.awt.GridBagLayout;
+import java.awt.Insets;
import java.awt.event.ActionEvent;
import javax.swing.BorderFactory;
/**
* The configuration dialog.
- *
+ *
* @author <a href="mailto:dr@ina-germany.de">David Roden</a>
* @version $Id$
*/
/** The “beautify GUI” action. */
private I18nAction beautifyAction;
+ /** The “use custom control font” action. */
+ private I18nAction useCustomControlFontAction;
+
+ /** The “use custom user font” action. */
+ private I18nAction useCustomUserFontAction;
+
/** The “beautify” checkbox. */
private JCheckBox beautifyCheckBox;
+ /** The “use custom” fonts checkbox. */
+ private JCheckBox useCustomControlFontCheckBox;
+
+ /** The control font list. */
+ private FontComboBox controlFontList;
+
+ /** The checkbox for “use same as control font”. */
+ private JCheckBox useCustomUserFontCheckBox;
+
+ /** The user font list. */
+ private FontComboBox userFontList;
+
/** Whether the dialog was cancelled. */
private boolean cancelled;
/**
* Creates a new configuration dialog.
- *
+ *
* @param swingInterface
* The Swing interface
*/
/**
* Returns whether the dialog was cancelled or confirmed. If the dialog was
* cancelled, no further processing should be done.
- *
+ *
* @return <code>true</code> if the dialog was cancelled,
* <code>false</code> otherwise
*/
* Returns whether the “beautify” checkbox has been selected. The result of
* this method should not be used if {@link #wasCancelled()} returned
* <code>true</code>!
- *
+ *
* @return <code>true</code> if the checkbox was selected,
* <code>false</code> otherwise
*/
/**
* Sets the state of the “beautify” checkbox.
- *
+ *
* @param beautify
* The state of the checkbox
*/
public void setBeautify(boolean beautify) {
beautifyCheckBox.setSelected(beautify);
+ useCustomControlFontCheckBox.setEnabled(beautify);
+ controlFontList.setEnabled(beautify && useCustomControlFontCheckBox.isSelected());
+ useCustomUserFontCheckBox.setEnabled(beautify);
+ userFontList.setEnabled(beautify && useCustomUserFontCheckBox.isSelected());
+ }
+
+ /**
+ * Returns the font for the controls.
+ *
+ * @return The control font, or <code>null</code> if no custom control
+ * font is to be used
+ */
+ public String getControlFont() {
+ return (String) ((beautifyCheckBox.isSelected() && useCustomControlFontCheckBox.isSelected()) ? controlFontList.getSelectedItem() : null);
+ }
+
+ /**
+ * Sets the font for the controls.
+ *
+ * @param controlFont
+ * The control font, or <code>null</code> if no custom control
+ * font is to be used
+ */
+ public void setControlFont(String controlFont) {
+ useCustomControlFontCheckBox.setSelected(controlFont != null);
+ controlFontList.setEnabled(beautifyCheckBox.isSelected() && (controlFont != null));
+ controlFontList.setSelectedItem(controlFont);
+ }
+
+ /**
+ * Returns the font for user input.
+ *
+ * @return The font for user input, or <code>null</code> if no custom user
+ * input font is to be used
+ */
+ public String getUserFont() {
+ return (String) ((beautifyCheckBox.isSelected() && useCustomUserFontCheckBox.isSelected()) ? userFontList.getSelectedItem() : null);
+ }
+
+ /**
+ * Sets the font for user input.
+ *
+ * @param userFont
+ * The font for user input, or <code>null</code> if no custom
+ * user input font is to be used
+ */
+ public void setUserFont(String userFont) {
+ useCustomUserFontCheckBox.setSelected(userFont != null);
+ userFontList.setEnabled(beautifyCheckBox.isSelected() && (userFont != null));
+ userFontList.setSelectedItem(userFont);
}
//
*/
private void initActions() {
okayAction = new I18nAction("general.button.okay") {
+
/**
* @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
*/
}
};
cancelAction = new I18nAction("general.button.cancel") {
+
/**
* @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
*/
}
};
beautifyAction = new I18nAction("configurationDialog.page.interface.item.beautify") {
+
/**
* @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
*/
+ @SuppressWarnings("synthetic-access")
public void actionPerformed(ActionEvent actionEvent) {
- /* don't do anything. */
+ setBeautify(beautifyCheckBox.isSelected());
+ }
+ };
+ useCustomControlFontAction = new I18nAction("configurationDialog.page.interface.item.useCustomControlFont") {
+
+ /**
+ * {@inheritDoc}
+ */
+ @SuppressWarnings("synthetic-access")
+ public void actionPerformed(ActionEvent e) {
+ controlFontList.setEnabled(useCustomControlFontCheckBox.isSelected());
+ }
+ };
+ useCustomUserFontAction = new I18nAction("configurationDialog.page.interface.item.useCustomUserFont") {
+
+ /**
+ * {@inheritDoc}
+ */
+ @SuppressWarnings("synthetic-access")
+ public void actionPerformed(ActionEvent e) {
+ userFontList.setEnabled(useCustomUserFontCheckBox.isSelected());
}
};
}
/**
* Creates the panel for the interface configuration.
- *
+ *
* @return The interface configuration panel
*/
private JComponent createInterfaceConfig() {
- JPanel interfaceConfigPanel = new JPanel(new BorderLayout(12, 12));
+ JPanel interfaceConfigPanel = new JPanel(new GridBagLayout());
interfaceConfigPanel.setBorder(BorderFactory.createEmptyBorder(12, 12, 12, 12));
beautifyCheckBox = new JCheckBox(beautifyAction);
- interfaceConfigPanel.add(beautifyCheckBox, BorderLayout.PAGE_START);
+ interfaceConfigPanel.add(beautifyCheckBox, new GridBagConstraints(0, 0, 2, 1, 0.0, 0.0, GridBagConstraints.LINE_START, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
+
+ useCustomControlFontCheckBox = new JCheckBox(useCustomControlFontAction);
+ interfaceConfigPanel.add(useCustomControlFontCheckBox, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.LINE_START, GridBagConstraints.BOTH, new Insets(6, 18, 0, 0), 0, 0));
+
+ controlFontList = new FontComboBox();
+ interfaceConfigPanel.add(controlFontList, new GridBagConstraints(1, 1, 1, 1, 1.0, 0.0, GridBagConstraints.LINE_START, GridBagConstraints.BOTH, new Insets(6, 6, 0, 0), 0, 0));
+
+ useCustomUserFontCheckBox = new JCheckBox(useCustomUserFontAction);
+ interfaceConfigPanel.add(useCustomUserFontCheckBox, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0, GridBagConstraints.LINE_START, GridBagConstraints.NONE, new Insets(6, 18, 0, 0), 0, 0));
+
+ userFontList = new FontComboBox();
+ interfaceConfigPanel.add(userFontList, new GridBagConstraints(1, 2, 1, 1, 1.0, 0.0, GridBagConstraints.LINE_START, GridBagConstraints.BOTH, new Insets(6, 6, 0, 0), 0, 0));
+
+ interfaceConfigPanel.add(new JPanel(), new GridBagConstraints(0, 3, 2, 1, 1.0, 1.0, GridBagConstraints.LINE_START, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
return interfaceConfigPanel;
}