summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Rettberg2015-07-28 14:42:13 +0200
committerSimon Rettberg2015-07-28 14:42:13 +0200
commit95b388cfb49e92e5395f3158a9f25bb4c575dfe5 (patch)
treed14bb5e072285170710223ffd13240b7f280494f
parent[client] Swing (diff)
downloadtutor-module-95b388cfb49e92e5395f3158a9f25bb4c575dfe5.tar.gz
tutor-module-95b388cfb49e92e5395f3158a9f25bb4c575dfe5.tar.xz
tutor-module-95b388cfb49e92e5395f3158a9f25bb4c575dfe5.zip
[client] bwKrischan
-rw-r--r--dozentenmodul/src/main/java/org/openslx/dozmod/App.java11
-rw-r--r--dozentenmodul/src/main/java/org/openslx/dozmod/gui/MainWindow.java34
-rw-r--r--dozentenmodul/src/main/java/org/openslx/dozmod/gui/helper/SwtUtil.java29
-rw-r--r--dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/DisclaimerWindow.java16
-rw-r--r--dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/MainMenuWindow.java23
-rw-r--r--dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/VirtualizerNoticeWindow.java26
-rw-r--r--dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/MainMenuWindowLayout.java6
-rw-r--r--dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/VirtualizerNoticeWindowLayout.java99
8 files changed, 108 insertions, 136 deletions
diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/App.java b/dozentenmodul/src/main/java/org/openslx/dozmod/App.java
index 50a43aa3..80d703c7 100644
--- a/dozentenmodul/src/main/java/org/openslx/dozmod/App.java
+++ b/dozentenmodul/src/main/java/org/openslx/dozmod/App.java
@@ -5,6 +5,7 @@ import java.io.IOException;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
+import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import org.apache.log4j.AppenderSkeleton;
@@ -14,8 +15,8 @@ import org.apache.log4j.Logger;
import org.apache.log4j.PatternLayout;
import org.apache.log4j.spi.LoggingEvent;
import org.openslx.dozmod.gui.Gui;
+import org.openslx.dozmod.gui.MainWindow;
import org.openslx.dozmod.gui.helper.MessageType;
-import org.openslx.dozmod.gui.window.LoginWindow;
import org.openslx.dozmod.util.ProxyConfigurator;
import org.openslx.thrifthelper.ThriftManager;
@@ -126,8 +127,12 @@ public class App {
// Set master server to use (TODO: make configurable via command line)
ThriftManager.setMasterServerAddress("bwlp-masterserver.ruf.uni-freiburg.de");
-// MainWindow.open();
- LoginWindow.open();
+ SwingUtilities.invokeLater(new Runnable() {
+ @Override
+ public void run() {
+ MainWindow.open();
+ }
+ });
}
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 859ae870..8b11d4d2 100644
--- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/MainWindow.java
+++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/MainWindow.java
@@ -1,5 +1,6 @@
package org.openslx.dozmod.gui;
+import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.KeyEventDispatcher;
import java.awt.KeyboardFocusManager;
@@ -17,6 +18,7 @@ import javax.swing.JFrame;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
+import javax.swing.JPanel;
import org.apache.log4j.Logger;
import org.openslx.dozmod.App;
@@ -25,8 +27,6 @@ import org.openslx.dozmod.gui.Gui.GuiCallable;
import org.openslx.dozmod.gui.helper.CompositePage;
import org.openslx.dozmod.gui.helper.MessageType;
import org.openslx.dozmod.gui.window.DisclaimerWindow;
-import org.openslx.dozmod.gui.window.ImageListWindow;
-import org.openslx.dozmod.gui.window.LectureListWindow;
import org.openslx.dozmod.gui.window.LoginWindow;
import org.openslx.dozmod.gui.window.MainMenuWindow;
import org.openslx.dozmod.gui.window.VirtualizerNoticeWindow;
@@ -39,7 +39,8 @@ public abstract class MainWindow {
private final static Logger LOGGER = Logger.getLogger(MainWindow.class);
- private static final JFrame mainShell = new JFrame("bwLehrstuhl");
+ private static final JFrame mainWindow = new JFrame("bwLehrstuhl");
+ private static final JPanel mainContainer = new JPanel();
private static CompositePage currentPage;
@@ -71,11 +72,11 @@ public abstract class MainWindow {
// sets the starting preferred size.
currentPage.requestShow();
currentPage.setVisible(true);
- mainShell.validate();
+ mainWindow.validate();
}
public static void centerShell(Window shell) {
- Gui.centerShellOverShell(mainShell, shell);
+ Gui.centerShellOverShell(mainWindow, shell);
}
/**
@@ -87,10 +88,10 @@ public abstract class MainWindow {
public static void open() {
// init SWT stuff
- mainShell.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
+ mainWindow.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
// Catch the close button (X)
- mainShell.addWindowListener(new WindowAdapter() {
+ mainWindow.addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
MainWindow.askApplicationQuit();
@@ -144,20 +145,21 @@ public abstract class MainWindow {
createMenu();
// Set layout for the mainshell, items added to the shell should get a gridData
- mainShell.setLayout(new BoxLayout(mainShell, BoxLayout.PAGE_AXIS));
- mainShell.setMinimumSize(new Dimension(850, 650));
+ mainContainer.setLayout(new BoxLayout(mainContainer, BoxLayout.PAGE_AXIS));
+ mainWindow.setMinimumSize(new Dimension(850, 650));
// register all pages of the main window
registerPage(new MainMenuWindow());
- registerPage(new ImageListWindow());
- registerPage(new LectureListWindow());
+ //registerPage(new ImageListWindow());
+ //registerPage(new LectureListWindow());
// Show main menu by default
showPage(MainMenuWindow.class);
// center the window on the primary monitor
- mainShell.setVisible(true);
- Gui.centerShell(mainShell);
- Gui.limitShellSize(mainShell);
+ mainWindow.getContentPane().add(mainContainer, BorderLayout.CENTER);
+ mainWindow.setVisible(true);
+ Gui.centerShell(mainWindow);
+ Gui.limitShellSize(mainWindow);
// here we can check for Session information
if (Session.getSatelliteToken() != null) {
@@ -194,14 +196,14 @@ public abstract class MainWindow {
if (pages.containsKey(clazz))
throw new IllegalArgumentException("Page " + clazz.getSimpleName() + " already registered!");
pages.put(clazz, window);
- mainShell.getContentPane().add(window);
+ mainContainer.add(window);
window.setVisible(false);
}
private static void createMenu() {
// the File menu button
JMenuBar menuBar = new JMenuBar();
- mainShell.setJMenuBar(menuBar);
+ mainWindow.setJMenuBar(menuBar);
JMenu cascadeFileMenu = new JMenu("&File");
menuBar.add(cascadeFileMenu);
diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/helper/SwtUtil.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/helper/SwtUtil.java
index 495b94a3..6cb413cd 100644
--- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/helper/SwtUtil.java
+++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/helper/SwtUtil.java
@@ -1,6 +1,5 @@
package org.openslx.dozmod.gui.helper;
-import org.eclipse.swt.layout.GridData;
public class SwtUtil {
@@ -20,32 +19,4 @@ public class SwtUtil {
return input.replace("&", "&&");
}
- /**
- * Helper for creating a GridData instance with horizontal span in one call.
- *
- * @param horizontalAlignment how control will be positioned horizontally
- * within a cell,
- * one of: SWT.BEGINNING (or SWT.LEFT), SWT.CENTER, SWT.END (or
- * SWT.RIGHT), or SWT.FILL
- * @param verticalAlignment how control will be positioned vertically within
- * a cell,
- * one of: SWT.BEGINNING (or SWT.TOP), SWT.CENTER, SWT.END (or
- * SWT.BOTTOM), or SWT.FILL
- * @param grabExcessHorizontalSpace whether cell will be made wide enough to
- * fit the remaining horizontal space
- * @param grabExcessVerticalSpace whether cell will be made high enough to
- * fit the remaining vertical space
- * @param horizontalSpan specifies the number of column cells that the
- * control
- * will take up.
- * @return {@link GridData} instance
- */
- public static GridData gridData(int horizontalAlignment, int verticalAlignment,
- boolean grabExcessHorizontalSpace, boolean grabExcessVerticalSpace, int horizontalSpan) {
- GridData gd = new GridData(horizontalAlignment, verticalAlignment, grabExcessHorizontalSpace,
- grabExcessVerticalSpace);
- gd.horizontalSpan = horizontalSpan;
- return gd;
- }
-
}
diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/DisclaimerWindow.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/DisclaimerWindow.java
index 82552980..d39144a0 100644
--- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/DisclaimerWindow.java
+++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/DisclaimerWindow.java
@@ -1,9 +1,9 @@
package org.openslx.dozmod.gui.window;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+
import org.apache.log4j.Logger;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.widgets.Shell;
import org.openslx.dozmod.Config;
import org.openslx.dozmod.gui.window.layout.DisclaimerWindowLayout;
@@ -21,20 +21,20 @@ public class DisclaimerWindow extends DisclaimerWindowLayout {
final DisclaimerWindow me = this;
// function for agreement checkbox
- agreeBox.addSelectionListener(new SelectionAdapter() {
+ agreeBox.addActionListener(new ActionListener() {
@Override
- public void widgetSelected(SelectionEvent e) {
+ public void actionPerformed(ActionEvent e) {
continueButton.setEnabled(!continueButton.isEnabled());
}
});
// function for continue button
- continueButton.addSelectionListener(new SelectionAdapter() {
+ continueButton.addActionListener(new ActionListener() {
@Override
- public void widgetSelected(SelectionEvent e) {
+ public void actionPerformed(ActionEvent e) {
// save the agreement to config
Config.setDisclaimerAgreement(DISCLAIMER_VERSION);
- me.getShell().dispose();
+ me.dispose();
}
});
}
diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/MainMenuWindow.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/MainMenuWindow.java
index ca9dc670..328f6570 100644
--- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/MainMenuWindow.java
+++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/MainMenuWindow.java
@@ -1,12 +1,15 @@
package org.openslx.dozmod.gui.window;
-import java.awt.Button;
-import java.awt.Image;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.Reader;
import java.net.URL;
+import javax.swing.ImageIcon;
+import javax.swing.JButton;
+
import org.openslx.dozmod.gui.Gui;
import org.openslx.dozmod.gui.MainWindow;
import org.openslx.dozmod.gui.window.layout.MainMenuWindowLayout;
@@ -20,17 +23,17 @@ public class MainMenuWindow extends MainMenuWindowLayout {
public MainMenuWindow() {
super();
// function for vmButton
- vmButton.addSelectionListener(new SelectionAdapter() {
+ vmButton.addActionListener(new ActionListener() {
@Override
- public void widgetSelected(SelectionEvent e) {
+ public void actionPerformed(ActionEvent e) {
MainWindow.showPage(ImageListWindow.class);
}
});
// function for lecturesButton
- lecturesButton.addSelectionListener(new SelectionAdapter() {
+ lecturesButton.addActionListener(new ActionListener() {
@Override
- public void widgetSelected(SelectionEvent e) {
+ public void actionPerformed(ActionEvent e) {
MainWindow.showPage(LectureListWindow.class);
}
});
@@ -57,18 +60,18 @@ public class MainMenuWindow extends MainMenuWindowLayout {
private String tbUrl;
}
- private int loadImageToControl(int start, GResult[] results, final Button control) {
+ private int loadImageToControl(int start, GResult[] results, final JButton control) {
if (start >= results.length)
start = results.length - 1;
while (start < results.length) {
try {
URL oracle = new URL(results[start].tbUrl);
- final ImageData img = new ImageData(oracle.openStream());
+ final ImageIcon img = new ImageIcon(oracle);
Gui.asyncExec(new Runnable() {
@Override
public void run() {
- control.setImage(new Image(control.getDisplay(), img));
- control.getParent().layout(true, true);
+ control.setIcon(img);
+ control.getParent().validate();
}
});
break;
diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/VirtualizerNoticeWindow.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/VirtualizerNoticeWindow.java
index dc2f3bcb..841faf8a 100644
--- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/VirtualizerNoticeWindow.java
+++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/VirtualizerNoticeWindow.java
@@ -1,9 +1,9 @@
package org.openslx.dozmod.gui.window;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+
import org.apache.log4j.Logger;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.widgets.Shell;
import org.openslx.dozmod.Config;
import org.openslx.dozmod.gui.window.layout.VirtualizerNoticeWindowLayout;
@@ -17,34 +17,34 @@ public class VirtualizerNoticeWindow extends VirtualizerNoticeWindowLayout {
final VirtualizerNoticeWindow me = this;
// function for agreement checkbox
- continueButton.addSelectionListener(new SelectionAdapter() {
+ continueButton.addActionListener(new ActionListener() {
@Override
- public void widgetSelected(SelectionEvent e) {
- Config.setVirtualizerRead(readCheck.getSelection());
- me.getShell().dispose();
+ public void actionPerformed(ActionEvent e) {
+ Config.setVirtualizerRead(readCheck.isSelected());
+ me.dispose();
}
});
// actions of the login button
- linuxDLButton.addSelectionListener(new SelectionAdapter() {
+ linuxDLButton.addActionListener(new ActionListener() {
@Override
- public void widgetSelected(SelectionEvent e) {
+ public void actionPerformed(ActionEvent e) {
//clickedLinuxDLButton();
}
});
// actions of the login button
- windowsDLButton.addSelectionListener(new SelectionAdapter() {
+ windowsDLButton.addActionListener(new ActionListener() {
@Override
- public void widgetSelected(SelectionEvent e) {
+ public void actionPerformed(ActionEvent e) {
//clickedWindowsDLButton();
}
});
// actions of the login button
- readCheck.addSelectionListener(new SelectionAdapter() {
+ readCheck.addActionListener(new ActionListener() {
@Override
- public void widgetSelected(SelectionEvent e) {
+ public void actionPerformed(ActionEvent e) {
//clickedReadCheckButton();
}
});
diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/MainMenuWindowLayout.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/MainMenuWindowLayout.java
index 5cf3dfa0..2cd76be7 100644
--- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/MainMenuWindowLayout.java
+++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/MainMenuWindowLayout.java
@@ -1,6 +1,6 @@
package org.openslx.dozmod.gui.window.layout;
-import java.awt.FlowLayout;
+import java.awt.GridLayout;
import javax.swing.BoxLayout;
import javax.swing.JButton;
@@ -48,7 +48,7 @@ public abstract class MainMenuWindowLayout extends CompositePage {
protected JButton lecturesButton;
public MainMenuWindowLayout() {
- super(new FlowLayout());
+ super(new GridLayout(1, 2));
// group for the vm selection
JPanel vmGroup = new JPanel();
@@ -60,7 +60,7 @@ public abstract class MainMenuWindowLayout extends CompositePage {
// group for the lecture selection
JPanel lecturesGroup = new JPanel();
- lecturesGroup.setLayout(new BoxLayout(vmGroup, BoxLayout.PAGE_AXIS));
+ lecturesGroup.setLayout(new BoxLayout(lecturesGroup, BoxLayout.PAGE_AXIS));
lecturesGroup.setBorder(new TitledBorder("Veranstaltungen"));
lecturesButton = new JButton("Veranstaltungen");
diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/VirtualizerNoticeWindowLayout.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/VirtualizerNoticeWindowLayout.java
index ab1d9327..2742d931 100644
--- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/VirtualizerNoticeWindowLayout.java
+++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/VirtualizerNoticeWindowLayout.java
@@ -1,23 +1,27 @@
package org.openslx.dozmod.gui.window.layout;
+import java.awt.BorderLayout;
import java.awt.Button;
-import java.awt.Composite;
-import java.awt.GridLayout;
-import java.awt.Label;
+import java.awt.Container;
+import java.awt.Dimension;
+import java.awt.Font;
+import javax.swing.Box;
+import javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JLabel;
-
-import org.openslx.dozmod.gui.Gui;
+import javax.swing.JPanel;
public abstract class VirtualizerNoticeWindowLayout extends JDialog {
private static final String title = "Hinweis VMWare Player";
- private static final String infoText = "Für die Arbeit mit der bwLehrpool Suite wird zwingend ein VMWare Player benötigt. "
+ private static final String infoText = "<html><body style='width:100%'>"
+ + "Für die Arbeit mit der bwLehrpool Suite wird zwingend ein VMWare Player benötigt. "
+ "Diesen können Sie sich unter folgendem Link kostenfrei downloaden. "
- + "Wenn Sie bereits den VMWare Player oder die VMWare Workstation installiert haben, können Sie diesen Hinweis ignorieren.";
+ + "Wenn Sie bereits den VMWare Player oder die VMWare Workstation installiert haben, können Sie diesen Hinweis ignorieren."
+ + "</body></html>";
- private final String infoTitle = "bwLehrpool Suite";
+ private final static String infoTitle = "bwLehrpool Suite";
protected JButton windowsDLButton;
protected JButton linuxDLButton;
@@ -26,58 +30,45 @@ public abstract class VirtualizerNoticeWindowLayout extends JDialog {
public VirtualizerNoticeWindowLayout(boolean modal) {
super(null, title, modal ? ModalityType.APPLICATION_MODAL : ModalityType.MODELESS);
+
- // layout for this composite
- this.setLayout(new GridLayout(1, false));
- GridData gd = new GridData();
- gd.widthHint = 500;
- this.setLayoutData(gd);
+ JPanel infoPane = new JPanel();
+ infoPane.setLayout(new BoxLayout(infoPane, BoxLayout.PAGE_AXIS));
// bold title at start.
- JLabel titleLabel = new JLabel(this, SWT.NONE);
- titleLabel.setText(infoTitle);
- JFontData fontData = titleLabel.getFont().getFontData()[0];
- final JFont font = new JFont(Gui.display, new FontData(fontData.getName(), fontData.getHeight(), SWT.BOLD));
+ JLabel titleLabel = new JLabel(infoTitle);
+ final Font font = titleLabel.getFont().deriveFont(Font.BOLD);
titleLabel.setFont(font);
+ infoPane.add(titleLabel);
// infotext
- JLabel infoLabel = new JLabel(this, SWT.NONE | SWT.WRAP);
- infoLabel.setText(infoText);
- infoLabel.setLayoutData(new GridData(GridData.FILL, GridData.BEGINNING, true, false));
-
- // composite for the windows vmware-download button
- Composite windowsComposite = new Composite(this, SWT.NONE);
- windowsComposite.setLayout(new GridLayout());
- windowsComposite.setLayoutData(new GridData(GridData.FILL, GridData.BEGINNING, true, false));
-
- new Label(windowsComposite, SWT.NONE).setText("Windows:");
- windowsDLButton = new Button(windowsComposite, SWT.PUSH);
- windowsDLButton.setText("VMWare Player Herunterladen");
-
- // composite for the linux vmware-download button
- Composite linuxComposite = new Composite(this, SWT.NONE);
- linuxComposite.setLayout(new GridLayout());
- linuxComposite.setLayoutData(new GridData(GridData.FILL, GridData.BEGINNING, true, false));
-
- new Label(windowsComposite, SWT.NONE).setText("Linux:");
- linuxDLButton = new Button(windowsComposite, SWT.PUSH);
- linuxDLButton.setText("VMWare Player Herunterladen");
-
- readCheck = new Button(this, SWT.CHECK);
- readCheck.setText("Diese Benachrichtigung nicht mehr anzeigen.");
- readCheck.setLayoutData(new GridData(GridData.BEGINNING, GridData.END, false, false));
-
- continueButton = new Button(this, SWT.PUSH);
- continueButton.setText("Weiter");
- continueButton.setLayoutData(new GridData(GridData.BEGINNING, GridData.END, false, false));
-
- // Dispose of stuff we allocated
- this.addDisposeListener(new DisposeListener() {
- @Override
- public void widgetDisposed(DisposeEvent e) {
- font.dispose();
- }
- });
+ JLabel infoLabel = new JLabel(infoText);
+ infoPane.add(infoLabel);
+
+ // Spacing
+ infoPane.add(Box.createRigidArea(new Dimension(0, 10)));
+
+ // Download buttons
+ windowsDLButton = new JButton("<html>VMWare Player für <b>Windows</b> herunterladen</html>");
+ linuxDLButton = new JButton("<html>VMWare Player für <b>Linux</b> herunterladen</html>");
+ infoPane.add(windowsDLButton);
+ infoPane.add(linuxDLButton);
+
+ // Bottom controls
+ JPanel bottomPane = new JPanel();
+ bottomPane.setLayout(new BoxLayout(infoPane, BoxLayout.PAGE_AXIS));
+
+ readCheck = new JButton("Diese Benachrichtigung nicht mehr anzeigen");
+ bottomPane.add(readCheck);
+
+ bottomPane.add(Box.createHorizontalGlue());
+
+ continueButton = new JButton("Schließen");
+ bottomPane.add(continueButton);
+
+ final Container content = getContentPane();
+ content.add(infoPane, BorderLayout.CENTER);
+ content.add(bottomPane, BorderLayout.PAGE_END);
}