diff options
author | Jonathan Bauer | 2015-08-31 17:45:16 +0200 |
---|---|---|
committer | Jonathan Bauer | 2015-08-31 17:45:16 +0200 |
commit | 447cffee62d97ee02d09c7298d40639602c91433 (patch) | |
tree | dd03098a8e817f43df95134acac0b37e18070c40 /dozentenmodul | |
parent | [client] slightly improved user info message when deleting a basis image in I... (diff) | |
download | tutor-module-447cffee62d97ee02d09c7298d40639602c91433.tar.gz tutor-module-447cffee62d97ee02d09c7298d40639602c91433.tar.xz tutor-module-447cffee62d97ee02d09c7298d40639602c91433.zip |
[client] MainMenu -> Einstellungen
added ConfigWindow to graphically config Proxy-Setting, MailMe stuff and FontScaling
Diffstat (limited to 'dozentenmodul')
4 files changed, 220 insertions, 8 deletions
diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/Config.java b/dozentenmodul/src/main/java/org/openslx/dozmod/Config.java index 2f8bebd4..46717110 100644 --- a/dozentenmodul/src/main/java/org/openslx/dozmod/Config.java +++ b/dozentenmodul/src/main/java/org/openslx/dozmod/Config.java @@ -179,17 +179,16 @@ public class Config { */ /** - * Query the value of 'BillOfRights' from the configuration file. + * Query the value of 'DisclaimerAgreement' from the configuration file. * - * @return true if the user already accepted bill of rights, false - * otherwise. + * @return version of the disclaimer the user accepted, 0 otherwise. */ public static int getDisclaimerAgreement() { return getInteger("disclaimer.accepted_version", 0); } /** - * Sets the value of 'BillOfRights' in the configuration file to 'value' + * Sets the value of 'DisclaimerAgreement' in the configuration file to 'value' * * @return true if it succeeded, false otherwise */ @@ -363,6 +362,14 @@ public class Config { } } + public static boolean getMailMe() { + return getBoolean("notice.mail", false); + } + + public static void setMailMe(boolean selection) { + setBoolean("notice.mail", selection); + } + /* * Generic helpers for different data types */ diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/MainWindow.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/MainWindow.java index 7da7ccdc..25fb2fbd 100644 --- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/MainWindow.java +++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/MainWindow.java @@ -27,10 +27,7 @@ import javax.swing.JSeparator; import org.apache.log4j.Logger; import org.apache.thrift.TException; import org.openslx.bwlp.thrift.iface.SatelliteStatus; -import org.openslx.bwlp.thrift.iface.WhoamiInfo; -import org.openslx.dozmod.App; import org.openslx.dozmod.Config; -import org.openslx.dozmod.Config.SavedSession; import org.openslx.dozmod.filetransfer.DownloadTask; import org.openslx.dozmod.gui.Gui.GuiCallable; import org.openslx.dozmod.gui.activity.ActivityPanel; @@ -41,6 +38,7 @@ import org.openslx.dozmod.gui.helper.CompositePage; import org.openslx.dozmod.gui.helper.DebugWindow; import org.openslx.dozmod.gui.helper.MessageType; import org.openslx.dozmod.gui.helper.UiFeedback; +import org.openslx.dozmod.gui.window.ConfigWindow; import org.openslx.dozmod.gui.window.DisclaimerWindow; import org.openslx.dozmod.gui.window.ImageListWindow; import org.openslx.dozmod.gui.window.LectureListWindow; @@ -303,6 +301,8 @@ public abstract class MainWindow { JMenu cascadeFileMenu = new JMenu("Session"); menuBar.add(cascadeFileMenu); + JMenuItem configItem = new JMenuItem("Einstellungen"); + cascadeFileMenu.add(configItem); JMenuItem logoutItem = new JMenuItem("Logout"); cascadeFileMenu.add(logoutItem); JMenuItem exitItem = new JMenuItem("Exit"); @@ -322,7 +322,12 @@ public abstract class MainWindow { menuBar.add(memStats); // Define actions - + configItem.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + ConfigWindow.open(mainWindow); + } + }); logoutItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/ConfigWindow.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/ConfigWindow.java new file mode 100644 index 00000000..ddcf6539 --- /dev/null +++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/ConfigWindow.java @@ -0,0 +1,75 @@ +package org.openslx.dozmod.gui.window; + +import java.awt.Frame; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +import org.apache.log4j.Logger; +import org.openslx.dozmod.Config; +import org.openslx.dozmod.Config.ProxyMode; +import org.openslx.dozmod.gui.MainWindow; +import org.openslx.dozmod.gui.window.layout.ConfigWindowLayout; + +public class ConfigWindow extends ConfigWindowLayout { + + private final static Logger LOGGER = Logger.getLogger(ConfigWindow.class); + + public ConfigWindow(Frame modalParent) { + super(modalParent); + + // set proxy mode as saved in config + switch(Config.getProxyMode()) { + case NONE: + btnProxyNone.setSelected(true); + break; + case AUTO: + btnProxyAuto.setSelected(true); + break; + case HTTP_CONNECT: + case SOCKS: + default: + break; + } + // set mail me stuff as saved in config + btnSendMeMail.setSelected(Config.getMailMe()); + // set font scaling as saved in config + btnFontSize.setValue(Config.getFontScaling()); + + btnSave.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + // save proxy mode to config + ProxyMode selectedMode = null; + if (btnProxyAuto.isSelected()) + selectedMode = ProxyMode.AUTO; + if (btnProxyNone.isSelected()) + selectedMode = ProxyMode.NONE; + if (selectedMode != null) { + Config.setProxyMode(selectedMode); + } + // save mail stuff + Config.setMailMe(btnSendMeMail.isSelected()); + // save font scaling + Config.setFontScaling(btnFontSize.getValue()); + } + }); + + btnClose.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + dispose(); + } + }); + } + + public static boolean shouldBeShown() { + // TODO query Config + return true; + } + + public static void open(Frame modalParent) { + ConfigWindow win = new ConfigWindow(modalParent); + MainWindow.centerShell(win); + win.setVisible(true); + } +} diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/ConfigWindowLayout.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/ConfigWindowLayout.java new file mode 100644 index 00000000..e52deb69 --- /dev/null +++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/ConfigWindowLayout.java @@ -0,0 +1,125 @@ +package org.openslx.dozmod.gui.window.layout; + +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.Frame; + +import javax.swing.BorderFactory; +import javax.swing.Box; +import javax.swing.BoxLayout; +import javax.swing.ButtonGroup; +import javax.swing.JButton; +import javax.swing.JCheckBox; +import javax.swing.JDialog; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JRadioButton; +import javax.swing.JSlider; + +import org.openslx.dozmod.gui.helper.GridManager; + +@SuppressWarnings("serial") +public class ConfigWindowLayout extends JDialog { + + private static String title = "bwLehrpool Suite - Konfiguration"; + + protected JRadioButton btnProxyNone; + protected JRadioButton btnProxyAuto; + protected JRadioButton btnProxySocks; + protected JRadioButton btnProxyHttp; + protected JCheckBox btnSendMeMail; + protected JSlider btnFontSize; + + protected JButton btnSave; + protected JButton btnClose; + + public ConfigWindowLayout(Frame modalParent) { + super(modalParent, title, modalParent != null ? ModalityType.APPLICATION_MODAL : ModalityType.MODELESS); + + // regular layout as a helper for the whole page + setLayout(new BorderLayout()); + setMinimumSize(new Dimension(500, 300)); + + // Panel to add everything into, needed for the border. + JPanel contentPanel = new JPanel(); + add(contentPanel, BorderLayout.CENTER); + + // -- one panel per option for borders -- + // proxy config panel + JPanel proxyPanel = new JPanel(); + proxyPanel.setBorder(BorderFactory.createTitledBorder("Proxy-Einstellungen")); + GridManager proxyGrid = new GridManager(proxyPanel, 2); + + proxyGrid.add(new JLabel("Hier können Sie Einstellungen bezüglich Proxies vornehmen")).fill(false, false).expand(false, false); + proxyGrid.skip().fill(true, false).expand(true, false); + proxyGrid.nextRow(); + + // radio button for proxy mode + JPanel radioGroupPanel = new JPanel(); + ButtonGroup radioGroup = new ButtonGroup(); + btnProxyNone = new JRadioButton("Keine"); + btnProxyAuto = new JRadioButton("Automatisch"); + radioGroup.add(btnProxyNone); + radioGroup.add(btnProxyAuto); + + radioGroupPanel.add(btnProxyNone); + radioGroupPanel.add(btnProxyAuto); + proxyGrid.add(radioGroupPanel, 2); + proxyGrid.nextRow(); + proxyGrid.finish(false); + + // mail config panel + JPanel mailPanel = new JPanel(); + mailPanel.setBorder(BorderFactory.createTitledBorder("E-Mail Benachrichtigung")); + GridManager mailGrid = new GridManager(mailPanel, 3); + mailGrid.add(new JLabel("Invalide Versionen, auslaufende Veranstaltungen, Updates, ..."), 2).fill(false, false).expand(false, false); + mailGrid.skip().fill(true, false).expand(true, false); + mailGrid.nextRow(); + + btnSendMeMail = new JCheckBox("Image- und Veranstaltungsänderungen per E-Mail erhalten"); + mailGrid.add(btnSendMeMail, 2).fill(false, false).expand(false, false); + mailGrid.skip(); + mailGrid.nextRow(); + mailGrid.finish(false); + + JPanel fontPanel = new JPanel(); + fontPanel.setBorder(BorderFactory.createTitledBorder("Schriftart-Einstellungen")); + GridManager fontGrid = new GridManager(fontPanel, 3); + btnFontSize = new JSlider(JSlider.HORIZONTAL, 50, 200, 100); + fontGrid.skip(); + fontGrid.add(new JLabel("Hier können Sie die Größe der Schriftart festlegen"), 2).fill(false, false).expand(false, false); + fontGrid.nextRow(); + fontGrid.skip(); + fontGrid.add(btnFontSize, 2).fill(true, false).expand(true, false); + fontGrid.nextRow(); + + // bottom button panel + JPanel buttonPanel = new JPanel(); + btnSave = new JButton("Speichern"); + btnClose = new JButton("Schliessen"); + buttonPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); + buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.LINE_AXIS)); + buttonPanel.add(Box.createGlue()); + buttonPanel.add(btnSave); + buttonPanel.add(btnClose); + + // Start the grid stuff + GridManager grid = new GridManager(contentPanel, 1); + grid.add(proxyPanel).fill(true, false).expand(false, false); + grid.nextRow(); + grid.add(Box.createRigidArea(new Dimension(0, 10))); + grid.nextRow(); + grid.add(mailPanel).fill(true, false).expand(false, false); + grid.nextRow(); + grid.add(Box.createRigidArea(new Dimension(0, 10))); + grid.nextRow(); + grid.add(fontPanel).fill(true, false).expand(false, false); + grid.nextRow(); + grid.finish(true); + + add(buttonPanel, BorderLayout.PAGE_END); + pack(); + + + } +} |