diff options
Diffstat (limited to 'dozentenmodul')
39 files changed, 1080 insertions, 2940 deletions
diff --git a/dozentenmodul/src/main/java/App.java b/dozentenmodul/src/main/java/App.java index 2d6be271..11ab05a8 100644 --- a/dozentenmodul/src/main/java/App.java +++ b/dozentenmodul/src/main/java/App.java @@ -1,5 +1,3 @@ -import gui.intro.Login_GUI; - import java.awt.EventQueue; import java.io.File; import java.io.IOException; @@ -11,6 +9,7 @@ import org.apache.log4j.FileAppender; import org.apache.log4j.Logger; import org.apache.log4j.PatternLayout; +import util.GuiManager; import config.Config; import config.ConfigProxy; @@ -51,6 +50,7 @@ public class App { LOGGER.info("Logger initialised."); } + public static void main(final String[] args) { // Pruefe und Erzeuge gegebenfalls Config @@ -76,10 +76,7 @@ public class App { EventQueue.invokeLater(new Runnable() { public void run() { try { - // Aufruf und Anzeige des Login Fensters - Login_GUI frame = new Login_GUI(args); - frame.setVisible(true); - + GuiManager.initGui(); } catch (Exception e) { e.printStackTrace(); JOptionPane.showMessageDialog(null, e.getStackTrace(), diff --git a/dozentenmodul/src/main/java/auth/Authenticator.java b/dozentenmodul/src/main/java/auth/Authenticator.java new file mode 100644 index 00000000..fb3a7050 --- /dev/null +++ b/dozentenmodul/src/main/java/auth/Authenticator.java @@ -0,0 +1,9 @@ +package auth; + +public class Authenticator { + + public boolean auth(String username, String pass) { + return false; + + } +} diff --git a/dozentenmodul/src/main/java/auth/Authentification.java b/dozentenmodul/src/main/java/auth/Authentification.java deleted file mode 100644 index d7a195f7..00000000 --- a/dozentenmodul/src/main/java/auth/Authentification.java +++ /dev/null @@ -1,11 +0,0 @@ -package auth; - - -public class Authentification { - - public boolean auth(String username, String pass) - { - return false; - - } -} diff --git a/dozentenmodul/src/main/java/ftp/DownloadTask.java b/dozentenmodul/src/main/java/ftp/DownloadTask.java index 63335f46..143ff286 100644 --- a/dozentenmodul/src/main/java/ftp/DownloadTask.java +++ b/dozentenmodul/src/main/java/ftp/DownloadTask.java @@ -21,6 +21,7 @@ import org.apache.commons.io.FileUtils; import org.apache.log4j.Logger; import org.apache.thrift.TException; +import thrift.ThriftManager; import util.ResourceLoader; /** @@ -158,7 +159,7 @@ public class DownloadTask extends SwingWorker<Void, Void> { LOGGER.debug("Image's ID: " + Image.image.getImageId()); Map<String, String> imageData = null; try { - imageData = models.Client.clientcon.getClient().getImageData( + imageData = ThriftManager.getSatClient().getImageData( Image.image.getImageId(), Image.image.getVersion(), SessionData.session.getAuthToken()); } catch (TException e) { diff --git a/dozentenmodul/src/main/java/gui/image/CreateImageAllgemein_GUI.java b/dozentenmodul/src/main/java/gui/image/CreateImageAllgemein_GUI.java index 60f608a0..a212da9f 100644 --- a/dozentenmodul/src/main/java/gui/image/CreateImageAllgemein_GUI.java +++ b/dozentenmodul/src/main/java/gui/image/CreateImageAllgemein_GUI.java @@ -1,6 +1,5 @@ package gui.image; -import gui.intro.About_GUI; import gui.intro.MainMenue_GUI; import java.awt.Color; @@ -12,17 +11,10 @@ import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; -import java.awt.event.WindowAdapter; -import java.awt.event.WindowEvent; -import java.net.URI; -import java.net.URISyntaxException; import javax.swing.JButton; -import javax.swing.JFrame; +import javax.swing.JInternalFrame; import javax.swing.JLabel; -import javax.swing.JMenu; -import javax.swing.JMenuBar; -import javax.swing.JMenuItem; import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JScrollPane; @@ -34,19 +26,16 @@ import javax.swing.UIManager; import javax.swing.UnsupportedLookAndFeelException; import javax.swing.border.EmptyBorder; import javax.swing.border.TitledBorder; +import javax.swing.event.InternalFrameAdapter; +import javax.swing.event.InternalFrameEvent; import models.Image; -import models.Links; -import models.SessionData; import models.person; -import org.apache.thrift.TException; -import org.openslx.sat.thrift.iface.Server.Client; - -import util.OpenLinks; +import util.GuiManager; @SuppressWarnings("serial") -public class CreateImageAllgemein_GUI extends JFrame { +public class CreateImageAllgemein_GUI extends JInternalFrame { private final JPanel contentPanel = new JPanel(); String[] result; @@ -59,39 +48,28 @@ public class CreateImageAllgemein_GUI extends JFrame { private final int MAX_DESCRIPTION_LENGTH = 254; private JTextArea txtrGebenSieBitte_1; Component c = null; - private static final String HELP_MESSAGE = "<html><div align = \"center\">" + + public static final String HELP_MESSAGE = "<html><div align = \"center\">" + "Hier legen Sie zunächst ein Image an. <br />" + "Dieses stellt die Grundlage Ihres Labors dar. Das Image ist der \"PC\", mit dem die Studenten arbeiten. <br />" + "Installieren Sie alle benötigte Software und laden Sie am Ende dieses Prozesses die .vmdk-Datei hoch, um sie zu verwenden.<br />" + "Um das Image richtig zuordnen zu können, werden hier einige grundlegende Informationen benötigt.<br />" + "Geben Sie daher bitte einen allgemeinen Namen, sowie eine genauere Beschreibung ihres Images (Labors) an.<br />" + "</div></html>"; - Client client = models.Client.clientcon.getClient(); + /** * Create the dialog. */ - public CreateImageAllgemein_GUI(Component formerGUI) { - addWindowListener(new WindowAdapter() { + public CreateImageAllgemein_GUI() { + addInternalFrameListener(new InternalFrameAdapter() { @Override - public void windowClosing(WindowEvent arg0) { - try { - client.setSessionInvalid(SessionData.session.getAuthToken()); - } catch (TException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - // Beendet das Fenster auf X - System.exit(0); - } - - @Override - public void windowOpened(WindowEvent arg0) { + public void internalFrameActivated(InternalFrameEvent arg0) { imagename.requestFocusInWindow(); } }); // Verhindert das Vergroessern des Fensters setResizable(false); + try { // setzt das Look & Feel @@ -108,7 +86,6 @@ public class CreateImageAllgemein_GUI extends JFrame { setTitle("bwLehrpool Suite - Image erzeugen - "+person.verantwortlicher.getUserID()); // Zentriert das Fenster setBounds(0, 0, 603, 722); - setLocationRelativeTo(formerGUI); getContentPane().setLayout(null); { @@ -280,9 +257,7 @@ public class CreateImageAllgemein_GUI extends JFrame { @Override public void mouseClicked(MouseEvent arg0) { // oeffnet das Hauptmenue - CreateImageAllgemein_GUI.this.setVisible(false); - MainMenue_GUI main = new MainMenue_GUI(c); - main.setVisible(true); + GuiManager.show(new MainMenue_GUI()); } }); lblHauptmen.setForeground(Color.BLUE); @@ -317,9 +292,7 @@ public class CreateImageAllgemein_GUI extends JFrame { public void actionPerformed(ActionEvent e) { Image.image.setImagename(imagename.getText().trim()); Image.image.setDesc(textAreadesc.getText().trim()); - MainMenue_GUI sr = new MainMenue_GUI(c); - sr.setVisible(true); - dispose(); + GuiManager.show(new MainMenue_GUI()); } }); backButton.setActionCommand("Cancel"); @@ -341,9 +314,10 @@ public class CreateImageAllgemein_GUI extends JFrame { // + Image.image.getDesc()+"\""); // Zeige nächsten Schritt an - CreateImageTechnisch_GUI ea = new CreateImageTechnisch_GUI(c); - ea.setVisible(true); - dispose(); +// CreateImageTechnisch_GUI ea = new CreateImageTechnisch_GUI(); +// ea.setVisible(true); +// dispose(); + GuiManager.show(new CreateImageTechnisch_GUI()); } } }); @@ -361,69 +335,6 @@ public class CreateImageAllgemein_GUI extends JFrame { separator_1.setBounds(0, 627, 597, 2); getContentPane().add(separator_1); - JMenuBar menuBar = new JMenuBar(); - setJMenuBar(menuBar); - - JMenu mnNewMenu_1 = new JMenu("Hilfe"); - menuBar.add(mnNewMenu_1); - - JMenuItem mntmFaq = new JMenuItem("FAQ"); - mntmFaq.addMouseListener(new MouseAdapter() { - @Override - public void mousePressed(MouseEvent arg0) { - URI windows; - try { - windows = new URI(Links.getFAQ()); - OpenLinks.openWebpage(windows); - } catch (URISyntaxException e) { - e.printStackTrace(); - JOptionPane.showMessageDialog(c, - "Konnte die URL '" + Links.getFAQ() + "' nicht öffnen!", - "Fehler", - JOptionPane.ERROR_MESSAGE); - } - } - }); - mnNewMenu_1.add(mntmFaq); - - JMenuItem mntmOtrs = new JMenuItem("OTRS"); - mntmOtrs.addMouseListener(new MouseAdapter() { - @Override - public void mousePressed(MouseEvent arg0) { - URI windows; - try { - windows = new URI(Links.getOTRS()); - OpenLinks.openWebpage(windows); - } catch (URISyntaxException e) { - e.printStackTrace(); - JOptionPane.showMessageDialog(c, - "Konnte die URL '" + Links.getOTRS() + "' nicht öffnen!", - "Fehler", - JOptionPane.ERROR_MESSAGE); - } - - } - }); - mnNewMenu_1.add(mntmOtrs); - - JMenuItem menuItem = new JMenuItem("About"); - menuItem.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent arg0) { - About_GUI ab = new About_GUI(); - ab.setVisible(true); - } - }); - mnNewMenu_1.add(menuItem); - - JMenu mnNewMenu_Info = new JMenu("Info"); - mnNewMenu_Info.addMouseListener(new MouseAdapter() { - @Override - public void mouseClicked(MouseEvent arg0) { - JOptionPane.showMessageDialog(c, HELP_MESSAGE, "Hilfe zu dieser Oberfläche", JOptionPane.INFORMATION_MESSAGE); - } - }); - menuBar.add(mnNewMenu_Info); - c = this; }// end main /** diff --git a/dozentenmodul/src/main/java/gui/image/CreateImageTechnisch_GUI.java b/dozentenmodul/src/main/java/gui/image/CreateImageTechnisch_GUI.java index ac90c518..8c478f3c 100644 --- a/dozentenmodul/src/main/java/gui/image/CreateImageTechnisch_GUI.java +++ b/dozentenmodul/src/main/java/gui/image/CreateImageTechnisch_GUI.java @@ -1,7 +1,6 @@ package gui.image; -import gui.intro.About_GUI; import gui.intro.MainMenue_GUI; import java.awt.Color; @@ -13,21 +12,13 @@ import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; -import java.awt.event.WindowAdapter; -import java.awt.event.WindowEvent; -import java.net.URI; -import java.net.URISyntaxException; import java.util.List; import javax.swing.JButton; import javax.swing.JCheckBox; import javax.swing.JComboBox; -import javax.swing.JFrame; +import javax.swing.JInternalFrame; import javax.swing.JLabel; -import javax.swing.JMenu; -import javax.swing.JMenuBar; -import javax.swing.JMenuItem; -import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JSeparator; import javax.swing.JSpinner; @@ -40,7 +31,6 @@ import javax.swing.border.EmptyBorder; import javax.swing.border.TitledBorder; import models.Image; -import models.Links; import models.SessionData; import models.person; @@ -48,10 +38,10 @@ import org.apache.log4j.Logger; import org.apache.thrift.TException; import thrift.ThriftManager; -import util.OpenLinks; +import util.GuiManager; @SuppressWarnings("serial") -public class CreateImageTechnisch_GUI extends JFrame { +public class CreateImageTechnisch_GUI extends JInternalFrame { /** * Logger instance for this class. @@ -66,7 +56,7 @@ public class CreateImageTechnisch_GUI extends JFrame { private JCheckBox chckbxIsInternetBlocked; JComboBox<String> comboBox; Component c = null; - private static final String HELP_MESSAGE = "<html><div align = \"center\">" + + public static final String HELP_MESSAGE = "<html><div align = \"center\">" + "Geben Sie hier bitte einige technische Daten an, die dann mit dem Image angezeigt werden.<br />" + "Dies wird beispielsweise benötigt, wenn ein Dozent eine Veranstaltung hat,<br />" + "die eine hohe Rechnerleistung voraussetzt. Er hat dann die Möglichkeit, sich an diesen Daten zu orientieren und<br />" + @@ -77,19 +67,19 @@ public class CreateImageTechnisch_GUI extends JFrame { /** * Create the dialog. */ - public CreateImageTechnisch_GUI(Component formerGUI) { - addWindowListener(new WindowAdapter() { - @Override - public void windowClosing(WindowEvent arg0) { - try { - ThriftManager.getSatClient().setSessionInvalid(SessionData.session.getAuthToken()); - } catch (TException e1) { - // TODO Auto-generated catch block - e1.printStackTrace(); - } - System.exit(0); - } - }); + public CreateImageTechnisch_GUI() { +// addWindowListener(new WindowAdapter() { +// @Override +// public void windowClosing(WindowEvent arg0) { +// try { +// ThriftManager.getSatClient().setSessionInvalid(SessionData.session.getAuthToken()); +// } catch (TException e1) { +// // TODO Auto-generated catch block +// e1.printStackTrace(); +// } +// System.exit(0); +// } +// }); setResizable(false); try { @@ -102,7 +92,7 @@ public class CreateImageTechnisch_GUI extends JFrame { setTitle("bwLehrpool Suite - Image erzeugen - "+person.verantwortlicher.getUserID()); setBounds(0, 0, 603, 722); - setLocationRelativeTo(formerGUI); + getContentPane().setLayout(null); { @@ -279,10 +269,7 @@ public class CreateImageTechnisch_GUI extends JFrame { lblHauptmen.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent arg0) { - - CreateImageTechnisch_GUI.this.setVisible(false); - MainMenue_GUI main=new MainMenue_GUI(c); - main.setVisible(true); + GuiManager.show(new MainMenue_GUI()); } }); lblHauptmen.setForeground(Color.BLUE); @@ -322,9 +309,7 @@ public class CreateImageTechnisch_GUI extends JFrame { Image.image.setCpu(Integer.valueOf(spinnerCPU.getValue().toString()).intValue()); Image.image.setRam(Integer.valueOf(spinnerRam.getValue().toString()).intValue()); Image.image.setOS(comboBox.getSelectedItem().toString()); - CreateImageAllgemein_GUI sr=new CreateImageAllgemein_GUI(c); - sr.setVisible(true); - dispose(); + GuiManager.show(new CreateImageAllgemein_GUI()); } }); cancelButton.setActionCommand("OK"); @@ -342,9 +327,7 @@ public class CreateImageTechnisch_GUI extends JFrame { Image.image.setRam(Integer.valueOf(spinnerRam.getValue().toString()).intValue()); Image.image.setOS(comboBox.getSelectedItem().toString()); //LOGGER.info("Betriebssystem: "+Image.image.getOS()+", istVorlage: "+Image.image.isVorlage()+", Lizenzpflichtig: "+Image.image.isLicensed()+", Internetsperre: "+Image.image.isInternet()+", CPU: "+Image.image.getCpu()+", RAM: "+Image.image.getRam()); - PermissionCreateImage_GUI ea=new PermissionCreateImage_GUI(c); - ea.setVisible(true); - dispose(); + GuiManager.show(new PermissionCreateImage_GUI()); } }); continueButton.setActionCommand("Cancel"); @@ -360,64 +343,6 @@ public class CreateImageTechnisch_GUI extends JFrame { JSeparator separator_1 = new JSeparator(); separator_1.setBounds(0, 627, 597, 2); getContentPane().add(separator_1); - - JMenuBar menuBar = new JMenuBar(); - setJMenuBar(menuBar); - - JMenu mnNewMenu_1 = new JMenu("Hilfe"); - menuBar.add(mnNewMenu_1); - - JMenuItem mntmFaq = new JMenuItem("FAQ"); - mntmFaq.addMouseListener(new MouseAdapter() { - @Override - public void mousePressed(MouseEvent arg0) { - URI windows; - try { - windows = new URI(Links.getFAQ()); - OpenLinks.openWebpage(windows); - } catch (URISyntaxException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - }); - mnNewMenu_1.add(mntmFaq); - - JMenuItem mntmOtrs = new JMenuItem("OTRS"); - mntmOtrs.addMouseListener(new MouseAdapter() { - @Override - public void mousePressed(MouseEvent arg0) { - URI windows; - try { - windows = new URI(Links.getOTRS()); - OpenLinks.openWebpage(windows); - } catch (URISyntaxException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - }); - mnNewMenu_1.add(mntmOtrs); - - JMenuItem menuItem = new JMenuItem("About"); - menuItem.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - About_GUI ab = new About_GUI(); - ab.setVisible(true); - } - }); - mnNewMenu_1.add(menuItem); - - JMenu mnNewMenu_Info = new JMenu("Info"); - mnNewMenu_Info.addMouseListener(new MouseAdapter() { - @Override - public void mouseClicked(MouseEvent arg0) { - JOptionPane.showMessageDialog(c, HELP_MESSAGE, "Hilfe zu dieser Oberfläche", JOptionPane.INFORMATION_MESSAGE); - } - }); - menuBar.add(mnNewMenu_Info); - - c = this; } } diff --git a/dozentenmodul/src/main/java/gui/image/DeleteImage_GUI.java b/dozentenmodul/src/main/java/gui/image/DeleteImage_GUI.java index c6dc58c9..1ff11bae 100644 --- a/dozentenmodul/src/main/java/gui/image/DeleteImage_GUI.java +++ b/dozentenmodul/src/main/java/gui/image/DeleteImage_GUI.java @@ -1,6 +1,5 @@ package gui.image; -import gui.intro.About_GUI; import gui.intro.MainMenue_GUI; import java.awt.Color; @@ -15,10 +14,6 @@ import java.awt.event.KeyAdapter; import java.awt.event.KeyEvent; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; -import java.awt.event.WindowAdapter; -import java.awt.event.WindowEvent; -import java.net.URI; -import java.net.URISyntaxException; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.ArrayList; @@ -28,11 +23,8 @@ import java.util.Map; import javax.swing.JButton; import javax.swing.JComboBox; -import javax.swing.JFrame; +import javax.swing.JInternalFrame; import javax.swing.JLabel; -import javax.swing.JMenu; -import javax.swing.JMenuBar; -import javax.swing.JMenuItem; import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JRadioButton; @@ -48,13 +40,14 @@ import javax.swing.UIManager; import javax.swing.UnsupportedLookAndFeelException; import javax.swing.border.EmptyBorder; import javax.swing.border.TitledBorder; +import javax.swing.event.InternalFrameAdapter; +import javax.swing.event.InternalFrameEvent; import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionListener; import javax.swing.table.DefaultTableModel; import javax.swing.table.TableModel; import javax.swing.table.TableRowSorter; -import models.Links; import models.SessionData; import models.person; @@ -63,13 +56,13 @@ import org.apache.thrift.TException; import org.openslx.sat.thrift.iface.Image; import thrift.ThriftManager; -import util.OpenLinks; +import util.GuiManager; @SuppressWarnings("serial") -public class DeleteImage_GUI extends JFrame { +public class DeleteImage_GUI extends JInternalFrame { private final static Logger LOGGER = Logger - .getLogger(FTPCreateUploader_GUI.class); + .getLogger(DeleteImage_GUI.class); private final JPanel contentPanel = new JPanel(); JLabel labelName; @@ -109,7 +102,7 @@ public class DeleteImage_GUI extends JFrame { // Letztes // Update // (5) - private static final String HELP_MESSAGE = "<html><div align = \"center\">" + public static final String HELP_MESSAGE = "<html><div align = \"center\">" + "Löschen Sie hier die Images, die nicht mehr benötigt werden.<br />" + "Ein gelöschtes Image wird auch tatsächlich physisch gelöscht und kann nicht wiederhergestellt werden.<br />" + "Wird das Image nach dem Löschen nochmal benötigt, muss es erneut hochgeladen werden." @@ -132,29 +125,16 @@ public class DeleteImage_GUI extends JFrame { /** * Create the dialog. */ - public DeleteImage_GUI(Component formerGUI) { + public DeleteImage_GUI() { filters.add(RowFilter.regexFilter(".", 0)); rf = RowFilter.orFilter(filters); - addWindowListener(new WindowAdapter() { + addInternalFrameListener(new InternalFrameAdapter() { @Override - public void windowClosing(WindowEvent arg0) { - // Beendet die Anwendung nach klick auf X - try { - ThriftManager.getSatClient().setSessionInvalid(SessionData.session.getAuthToken()); - } catch (TException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - System.exit(0); - } - - @Override - public void windowOpened(WindowEvent arg0) { - + public void internalFrameActivated(InternalFrameEvent arg0) { + initTableModel(modelMyImages); - // auszublendende Angaben // 1=Lizenzpflichtig // 3=Veranstaltung @@ -186,8 +166,26 @@ public class DeleteImage_GUI extends JFrame { textFieldName.requestFocusInWindow(); } }); - // Verhindert das Vergroessern Des Fensters - setResizable(false); + +// addWindowListener(new WindowAdapter() { +// @Override +// public void windowClosing(WindowEvent arg0) { +// // Beendet die Anwendung nach klick auf X +// try { +// ThriftManager.getSatClient().setSessionInvalid(SessionData.session.getAuthToken()); +// } catch (TException e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// } +// System.exit(0); +// } +// +// @Override +// public void windowOpened(WindowEvent arg0) { +// +// +// } +// }); try { // Setzt das Look & Feel auf System @@ -202,7 +200,6 @@ public class DeleteImage_GUI extends JFrame { + person.verantwortlicher.getUserID()); // Zentriert das Fenster in die Bildmitte setBounds(0, 0, 918, 722); - setLocationRelativeTo(formerGUI); getContentPane().setLayout(null); { @@ -347,9 +344,7 @@ public class DeleteImage_GUI extends JFrame { lblHauptmen.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent arg0) { - DeleteImage_GUI.this.setVisible(false); - MainMenue_GUI main = new MainMenue_GUI(c); - main.setVisible(true); + GuiManager.show(new MainMenue_GUI()); } }); lblHauptmen.setForeground(Color.BLUE); @@ -425,11 +420,7 @@ public class DeleteImage_GUI extends JFrame { LOGGER.info("Image '" + imageid + "' erfolgreich gelöscht."); - DeleteImage_GUI di = new DeleteImage_GUI( - c); - di.setVisible(true); - dispose(); - + GuiManager.show(new DeleteImage_GUI()); } else { //could not delete file from DB LOGGER.info("Image '" @@ -555,9 +546,7 @@ public class DeleteImage_GUI extends JFrame { JButton okButton = new JButton("Zurück"); okButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { - MainMenue_GUI main = new MainMenue_GUI(c); - main.setVisible(true); - dispose(); + GuiManager.show(new MainMenue_GUI()); } }); okButton.setActionCommand("OK"); @@ -699,70 +688,7 @@ public class DeleteImage_GUI extends JFrame { textAreadesc.setBackground(SystemColor.menu); scrollPane.setViewportView(textAreadesc); - JMenuBar menuBar = new JMenuBar(); - setJMenuBar(menuBar); - - JMenu mnNewMenu_1 = new JMenu("Hilfe"); - menuBar.add(mnNewMenu_1); - - JMenuItem mntmFaq = new JMenuItem("FAQ"); - mntmFaq.addMouseListener(new MouseAdapter() { - @Override - public void mousePressed(MouseEvent arg0) { - URI windows; - try { - windows = new URI(Links.getFAQ()); - - OpenLinks.openWebpage(windows); - - } catch (URISyntaxException e) { - - e.printStackTrace(); - } - } - }); - mnNewMenu_1.add(mntmFaq); - - JMenuItem mntmOtrs = new JMenuItem("OTRS"); - mntmOtrs.addMouseListener(new MouseAdapter() { - @Override - public void mousePressed(MouseEvent arg0) { - URI windows; - try { - windows = new URI(Links.getOTRS()); - - OpenLinks.openWebpage(windows); - - } catch (URISyntaxException e) { - - e.printStackTrace(); - } - - } - }); - mnNewMenu_1.add(mntmOtrs); - - JMenuItem menuItem = new JMenuItem("About"); - menuItem.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - About_GUI ab = new About_GUI(); - ab.setVisible(true); - } - }); - mnNewMenu_1.add(menuItem); - - JMenu mnNewMenu_Info = new JMenu("Info"); - mnNewMenu_Info.addMouseListener(new MouseAdapter() { - @Override - public void mouseClicked(MouseEvent arg0) { - JOptionPane.showMessageDialog(c, HELP_MESSAGE, - "Hilfe zu dieser Oberfläche", - JOptionPane.INFORMATION_MESSAGE); - } - }); - menuBar.add(mnNewMenu_Info); - c = this; } // Initiale Beffuelung eines Table models diff --git a/dozentenmodul/src/main/java/gui/image/EditImageAllgemein_GUI.java b/dozentenmodul/src/main/java/gui/image/EditImageAllgemein_GUI.java index 57406817..69fdd2c0 100644 --- a/dozentenmodul/src/main/java/gui/image/EditImageAllgemein_GUI.java +++ b/dozentenmodul/src/main/java/gui/image/EditImageAllgemein_GUI.java @@ -1,6 +1,5 @@ package gui.image; -import gui.intro.About_GUI; import gui.intro.MainMenue_GUI; import java.awt.Color; @@ -12,18 +11,11 @@ import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; -import java.awt.event.WindowAdapter; -import java.awt.event.WindowEvent; -import java.net.URI; -import java.net.URISyntaxException; import java.util.Map; import javax.swing.JButton; -import javax.swing.JFrame; +import javax.swing.JInternalFrame; import javax.swing.JLabel; -import javax.swing.JMenu; -import javax.swing.JMenuBar; -import javax.swing.JMenuItem; import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JScrollPane; @@ -38,17 +30,16 @@ import javax.swing.border.TitledBorder; import models.Image; import models.ItemOwner; -import models.Links; import models.SessionData; import models.person; import org.apache.thrift.TException; import thrift.ThriftManager; -import util.OpenLinks; +import util.GuiManager; @SuppressWarnings("serial") -public class EditImageAllgemein_GUI extends JFrame { +public class EditImageAllgemein_GUI extends JInternalFrame { private final JPanel contentPanel = new JPanel(); String[] result; @@ -69,7 +60,7 @@ public class EditImageAllgemein_GUI extends JFrame { private boolean descriptionLengthOK = false; //description may not be longer than MAX_DESCRIPTION_LENGTH private final int MAX_DESCRIPTION_LENGTH = 254; Component c = null; - private static final String HELP_MESSAGE = "<html><div align = \"center\">" + + public static final String HELP_MESSAGE = "<html><div align = \"center\">" + "Bearbeiten Sie hier die allgemeinen Angaben, die Sie beim Erzeugen des Images hinterlegt haben.<br />" + "Sie können sowohl den Anzeigenamen als auch die Beschreibung ändern.<br />" + "Änderungen der Informationen zum Besitzer sind nicht zulässig." + @@ -78,35 +69,19 @@ public class EditImageAllgemein_GUI extends JFrame { /** * Create the dialog. */ - public EditImageAllgemein_GUI(Component formerGUI) { - addWindowListener(new WindowAdapter() { - @Override - public void windowClosing(WindowEvent arg0) { - // Beendet die Anwendung bei einem Klick auf das X - try { - ThriftManager.getSatClient().setSessionInvalid(SessionData.session.getAuthToken()); - } catch (TException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - System.exit(0); - } - }); - // Verhindert das vergroessern des Fensters - setResizable(false); - + public EditImageAllgemein_GUI() { try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException e) { e.printStackTrace(); } + // Setzt den Fenstertitel setTitle("bwLehrpool Suite - Image bearbeiten - "+person.verantwortlicher.getUserID()); // Zentriert das Fenster in der Bildmitte setBounds(0, 0, 603, 722); - setLocationRelativeTo(formerGUI); initData(); getContentPane().setLayout(null); { @@ -272,10 +247,7 @@ public class EditImageAllgemein_GUI extends JFrame { public void mouseClicked(MouseEvent arg0) { // Durch den Klick auf Button Hauptmenpue wird dieses Fenster // unsichtbar und das Hauptmenue sichtbar - - EditImageAllgemein_GUI.this.setVisible(false); - MainMenue_GUI main = new MainMenue_GUI(c); - main.setVisible(true); + GuiManager.show(new MainMenue_GUI()); } }); lblHauptmen.setForeground(Color.BLUE); @@ -312,10 +284,7 @@ public class EditImageAllgemein_GUI extends JFrame { // Setzen der Eingabe im Model, dadurch bleiben die // Daten bei einem erneuten Aufruf verfuegbar // Image.image.setImagename(imagename.getText().trim()); - - SearchEditImage_GUI se = new SearchEditImage_GUI(c); - se.setVisible(true); - dispose(); + GuiManager.show(new SearchEditImage_GUI()); } }); backButton.setActionCommand("CANCEL"); @@ -341,10 +310,7 @@ public class EditImageAllgemein_GUI extends JFrame { // + "\", Imagebeschreibung=\"" // + Image.image.getDesc()+"\""); - - EditImageTechnisch_GUI ea = new EditImageTechnisch_GUI(c); - ea.setVisible(true); - dispose(); + GuiManager.show(new EditImageTechnisch_GUI()); } else { @@ -366,64 +332,7 @@ public class EditImageAllgemein_GUI extends JFrame { separator_1.setBounds(0, 627, 597, 2); getContentPane().add(separator_1); - JMenuBar menuBar = new JMenuBar(); - setJMenuBar(menuBar); - - JMenu mnNewMenu_1 = new JMenu("Hilfe"); - menuBar.add(mnNewMenu_1); - - JMenuItem mntmFaq = new JMenuItem("FAQ"); - mntmFaq.addMouseListener(new MouseAdapter() { - @Override - public void mousePressed(MouseEvent arg0) { - - URI windows; - try { - windows = new URI(Links.getFAQ()); - OpenLinks.openWebpage(windows); - } catch (URISyntaxException e) { - e.printStackTrace(); - } - } - }); - mnNewMenu_1.add(mntmFaq); - - - JMenuItem mntmOtrs = new JMenuItem("OTRS"); - mntmOtrs.addMouseListener(new MouseAdapter() { - @Override - public void mousePressed(MouseEvent arg0) { - - URI windows; - try { - windows = new URI(Links.getOTRS()); - OpenLinks.openWebpage(windows); - } catch (URISyntaxException e) { - e.printStackTrace(); - } - - } - }); - mnNewMenu_1.add(mntmOtrs); - - JMenuItem menuItem = new JMenuItem("About"); - menuItem.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - About_GUI ab = new About_GUI(); - ab.setVisible(true); - } - }); - mnNewMenu_1.add(menuItem); - JMenu mnNewMenu_Info = new JMenu("Info"); - mnNewMenu_Info.addMouseListener(new MouseAdapter() { - @Override - public void mouseClicked(MouseEvent arg0) { - JOptionPane.showMessageDialog(c, HELP_MESSAGE, "Hilfe zu dieser Oberfläche", JOptionPane.INFORMATION_MESSAGE); - } - }); - menuBar.add(mnNewMenu_Info); - c = this; } public void initData() { diff --git a/dozentenmodul/src/main/java/gui/image/EditImageTechnisch_GUI.java b/dozentenmodul/src/main/java/gui/image/EditImageTechnisch_GUI.java index 679b3c62..790665c0 100644 --- a/dozentenmodul/src/main/java/gui/image/EditImageTechnisch_GUI.java +++ b/dozentenmodul/src/main/java/gui/image/EditImageTechnisch_GUI.java @@ -1,6 +1,5 @@ package gui.image; -import gui.intro.About_GUI; import gui.intro.MainMenue_GUI; import java.awt.Color; @@ -12,21 +11,13 @@ import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; -import java.awt.event.WindowAdapter; -import java.awt.event.WindowEvent; -import java.net.URI; -import java.net.URISyntaxException; import java.util.List; import javax.swing.JButton; import javax.swing.JCheckBox; import javax.swing.JComboBox; -import javax.swing.JFrame; +import javax.swing.JInternalFrame; import javax.swing.JLabel; -import javax.swing.JMenu; -import javax.swing.JMenuBar; -import javax.swing.JMenuItem; -import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JSeparator; import javax.swing.JSpinner; @@ -39,7 +30,6 @@ import javax.swing.border.EmptyBorder; import javax.swing.border.TitledBorder; import models.Image; -import models.Links; import models.SessionData; import models.person; @@ -47,10 +37,10 @@ import org.apache.log4j.Logger; import org.apache.thrift.TException; import thrift.ThriftManager; -import util.OpenLinks; +import util.GuiManager; @SuppressWarnings("serial") -public class EditImageTechnisch_GUI extends JFrame { +public class EditImageTechnisch_GUI extends JInternalFrame { /** * Logger instance for this class. @@ -65,7 +55,7 @@ public class EditImageTechnisch_GUI extends JFrame { private JCheckBox chckbxIsInternetBlocked; JComboBox<String> comboBox; Component c = null; - private static final String HELP_MESSAGE = "<html><div align = \"center\">" + + public static final String HELP_MESSAGE = "<html><div align = \"center\">" + "Bearbeiten Sie hier die technischen Angaben zu Ihrem Image, die Sie beim Erzeugen des Images hinterlegt haben.<br />" + "Wenn sich die technischen Anforderungen an Ihr Image geändert haben, müssen Sie es nicht erneut hochladen,<br />" + "sondern können die Angaben direkt hier korrigieren. Die Daten werden dann für Ihr Image übernommen." + @@ -74,21 +64,7 @@ public class EditImageTechnisch_GUI extends JFrame { /** * Create the dialog. */ - public EditImageTechnisch_GUI(Component formerGUI) { - addWindowListener(new WindowAdapter() { - @Override - public void windowClosing(WindowEvent arg0) { - // Beendet die Anwendung bei Klick auf das X - try { - ThriftManager.getSatClient().setSessionInvalid(SessionData.session.getAuthToken()); - } catch (TException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - System.exit(0); - } - - }); + public EditImageTechnisch_GUI() { // Verhindert das Vergrößern des Fensters setResizable(false); @@ -104,7 +80,6 @@ public class EditImageTechnisch_GUI extends JFrame { setTitle("bwLehrpool Suite - Image bearbeiten - "+person.verantwortlicher.getUserID()); // Zentriert das Fenster setBounds(0, 0, 603, 722); - setLocationRelativeTo(formerGUI); getContentPane().setLayout(null); { @@ -234,9 +209,7 @@ public class EditImageTechnisch_GUI extends JFrame { public void mouseClicked(MouseEvent arg0) { // Macht dieses Fenster unsichtbar und das vorhergehende Fenster // sichtbar - EditImageTechnisch_GUI.this.setVisible(false); - MainMenue_GUI main = new MainMenue_GUI(c); - main.setVisible(true); + GuiManager.show(new MainMenue_GUI()); } }); lblHauptmen.setForeground(Color.BLUE); @@ -349,9 +322,7 @@ public class EditImageTechnisch_GUI extends JFrame { Image.image.setLicensed(chckbxIsLicensed.isSelected()); Image.image.setOS(comboBox.getSelectedItem().toString()); // oeffnet das vorherige Fenster - EditImageAllgemein_GUI ei = new EditImageAllgemein_GUI(c); - ei.setVisible(true); - dispose(); + GuiManager.show(new EditImageAllgemein_GUI()); } }); okButton.setActionCommand("OK"); @@ -380,14 +351,10 @@ public class EditImageTechnisch_GUI extends JFrame { //check if user may change permissions and choose window if(ThriftManager.getSatClient().userIsImageAdmin(Image.image.getImageId(),SessionData.session.getAuthToken(), person.verantwortlicher.getUserID()) == true || (person.verantwortlicher.getRole().equals("Admin"))) { //user has permission, go to permission GUI - PermissionEditImage_GUI ea=new PermissionEditImage_GUI(c); - ea.setVisible(true); - dispose(); + GuiManager.show(new PermissionEditImage_GUI()); } else { // user does not have permission, go straight to upload GUI - FTPEditUploader_GUI ea = new FTPEditUploader_GUI(c); - ea.setVisible(true); - dispose(); + GuiManager.show(new FTPEditUploader_GUI()); } } catch (TException e1) { e1.printStackTrace(); @@ -407,62 +374,5 @@ public class EditImageTechnisch_GUI extends JFrame { JSeparator separator_1 = new JSeparator(); separator_1.setBounds(0, 627, 597, 2); getContentPane().add(separator_1); - - JMenuBar menuBar = new JMenuBar(); - setJMenuBar(menuBar); - - JMenu mnNewMenu_1 = new JMenu("Hilfe"); - menuBar.add(mnNewMenu_1); - - JMenuItem mntmFaq = new JMenuItem("FAQ"); - mntmFaq.addMouseListener(new MouseAdapter() { - @Override - public void mousePressed(MouseEvent arg0) { - URI windows; - try { - windows = new URI(Links.getFAQ()); - OpenLinks.openWebpage(windows); - } catch (URISyntaxException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - }); - mnNewMenu_1.add(mntmFaq); - - JMenuItem mntmOtrs = new JMenuItem("OTRS"); - mntmOtrs.addMouseListener(new MouseAdapter() { - @Override - public void mousePressed(MouseEvent arg0) { - URI windows; - try { - windows = new URI(Links.getOTRS()); - OpenLinks.openWebpage(windows); - } catch (URISyntaxException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - }); - mnNewMenu_1.add(mntmOtrs); - - JMenuItem mntmAbout = new JMenuItem("About"); - mntmAbout.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - About_GUI ab = new About_GUI(); - ab.setVisible(true); - } - }); - mnNewMenu_1.add(mntmAbout); - - JMenu mnNewMenu_Info = new JMenu("Info"); - mnNewMenu_Info.addMouseListener(new MouseAdapter() { - @Override - public void mouseClicked(MouseEvent arg0) { - JOptionPane.showMessageDialog(c, HELP_MESSAGE, "Hilfe zu dieser Oberfläche", JOptionPane.INFORMATION_MESSAGE); - } - }); - menuBar.add(mnNewMenu_Info); - c = this; } } diff --git a/dozentenmodul/src/main/java/gui/image/FTPCreateUploader_GUI.java b/dozentenmodul/src/main/java/gui/image/FTPCreateUploader_GUI.java index d201d3b7..88bc1cc8 100644 --- a/dozentenmodul/src/main/java/gui/image/FTPCreateUploader_GUI.java +++ b/dozentenmodul/src/main/java/gui/image/FTPCreateUploader_GUI.java @@ -10,13 +10,9 @@ import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; -import java.awt.event.WindowAdapter; -import java.awt.event.WindowEvent; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import java.io.File; -import java.net.URI; -import java.net.URISyntaxException; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Date; @@ -24,6 +20,7 @@ import java.util.Date; import javax.swing.JButton; import javax.swing.JFileChooser; import javax.swing.JFrame; +import javax.swing.JInternalFrame; import javax.swing.JLabel; import javax.swing.JMenu; import javax.swing.JMenuBar; @@ -37,10 +34,11 @@ import javax.swing.SwingConstants; import javax.swing.UIManager; import javax.swing.UnsupportedLookAndFeelException; import javax.swing.border.EmptyBorder; +import javax.swing.event.InternalFrameAdapter; +import javax.swing.event.InternalFrameEvent; import javax.swing.filechooser.FileNameExtensionFilter; import models.Image; -import models.Links; import models.RightsManagement; import models.SessionData; import models.person; @@ -50,6 +48,7 @@ import org.apache.thrift.TException; import org.openslx.sat.thrift.iface.User; import thrift.ThriftManager; +import util.GuiManager; import util.OpenLinks; import config.Config; import ftp.UploadTask; @@ -58,7 +57,7 @@ import gui.intro.MainMenue_GUI; import gui.lecture.CreateLectureAllgemein_GUI; @SuppressWarnings("serial") -public class FTPCreateUploader_GUI extends JFrame implements +public class FTPCreateUploader_GUI extends JInternalFrame implements PropertyChangeListener { /** @@ -101,7 +100,7 @@ public class FTPCreateUploader_GUI extends JFrame implements private boolean isAborted = false; // down- or upload was manually aborted private String uuid; - private static final String HELP_MESSAGE = "<html><div align = \"center\">" + public static final String HELP_MESSAGE = "<html><div align = \"center\">" + "Laden Sie hier Ihre .vmdk-Datei hoch, die dann als virtuelles Labor geladen werden kann.<br />" + "Wichtig ist, dass Sie zum Schluss auf \"Fertigstellen\" klicken, damit die Daten übernommen werden.<br />" + "Wenn Sie die Datei hochgeladen haben, dann aber auf \"zurück\" klicken, oder die Anwendung beenden,<br />" @@ -111,7 +110,7 @@ public class FTPCreateUploader_GUI extends JFrame implements /** * Create the frame. */ - public FTPCreateUploader_GUI(Component formerGUI) { + public FTPCreateUploader_GUI() { final Object[] options = { "Beenden", "Abbrechen" }; @@ -123,12 +122,9 @@ public class FTPCreateUploader_GUI extends JFrame implements e1.printStackTrace(); } - - addWindowListener(new WindowAdapter() { - + addInternalFrameListener(new InternalFrameAdapter() { @Override - public void windowClosing(WindowEvent arg0) { - + public void internalFrameClosing(InternalFrameEvent arg0) { if (taskrun == true) { // check if user wants to quit. int choice = JOptionPane @@ -158,20 +154,58 @@ public class FTPCreateUploader_GUI extends JFrame implements } System.exit(0); }// end if choice - } else { - // no upload running, close window - - try { - ThriftManager.getSatClient().setSessionInvalid(SessionData.session - .getAuthToken()); - } catch (TException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - System.exit(0); - } - }// end if taskrun - }// end window closing + } + } }); + +// addWindowListener(new WindowAdapter() { +// +// @Override +// public void windowClosing(WindowEvent arg0) { +// +// if (taskrun == true) { +// // check if user wants to quit. +// int choice = JOptionPane +// .showOptionDialog( +// c, +// "Aktuell ist ein Upload aktiv. Wollen Sie diesen Abbrechen und das Programm beenden?", +// "Upload aktiv", +// JOptionPane.YES_NO_CANCEL_OPTION, +// JOptionPane.QUESTION_MESSAGE, null, +// options, options[1]); +// // 0=beenden, 1=abbrechen +// if (choice == 0) { +// try { +// ThriftManager.getSatClient().DeleteFtpUser(user.userName, +// SessionData.session.getAuthToken()); +// } catch (TException e1) { +// +// e1.printStackTrace(); +// } +// task.cancel(true); +// try { +// ThriftManager.getSatClient().setSessionInvalid(SessionData.session +// .getAuthToken()); +// } catch (TException e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// } +// System.exit(0); +// }// end if choice +// } else { +// // no upload running, close window +// +// try { +// ThriftManager.getSatClient().setSessionInvalid(SessionData.session +// .getAuthToken()); +// } catch (TException e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// System.exit(0); +// } +// }// end if taskrun +// }// end window closing +// }); setResizable(false); try { @@ -193,7 +227,6 @@ public class FTPCreateUploader_GUI extends JFrame implements setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); setBounds(0, 0, 603, 722); - setLocationRelativeTo(formerGUI); getContentPane().setLayout(new BorderLayout()); contentPanel.setBackground(SystemColor.menu); @@ -346,10 +379,7 @@ public class FTPCreateUploader_GUI extends JFrame implements @Override public void mouseClicked(MouseEvent arg0) { // oeffnet das Hauptmenue - - FTPCreateUploader_GUI.this.dispose(); - MainMenue_GUI main = new MainMenue_GUI(c); - main.setVisible(true); + GuiManager.show(new MainMenue_GUI()); } }); @@ -460,9 +490,6 @@ public class FTPCreateUploader_GUI extends JFrame implements // save configuration Config.store(); - // dispose(); - // MainMenue_GUI m = new MainMenue_GUI(c); - // m.setVisible(true); if (taskrun == true) { try { @@ -496,16 +523,10 @@ public class FTPCreateUploader_GUI extends JFrame implements // 0=New Lecture, 1=Main Menu if (choice == 0) { - dispose(); - CreateLectureAllgemein_GUI cl = new CreateLectureAllgemein_GUI( - c); - cl.setVisible(true); + GuiManager.show(new CreateLectureAllgemein_GUI()); } else { - dispose(); - MainMenue_GUI m = new MainMenue_GUI(c); - m.setVisible(true); + GuiManager.show(new MainMenue_GUI()); } - } }); @@ -545,12 +566,7 @@ public class FTPCreateUploader_GUI extends JFrame implements if (selectedOption == JOptionPane.YES_OPTION) { // System.out.println("CreateUploader X:"+formerGUI.getLocation().getX()); // System.out.println("CreateUploader X:"+formerGUI.getLocation().getY()); - PermissionCreateImage_GUI m = new PermissionCreateImage_GUI( - c); - // m.setLocationRelativeTo(formerGUI); - m.setVisible(true); - dispose(); - + GuiManager.show(new PermissionCreateImage_GUI()); } else { // for actions if "no" is selected. tbd. } @@ -565,68 +581,7 @@ public class FTPCreateUploader_GUI extends JFrame implements } } - JMenuBar menuBar = new JMenuBar(); - setJMenuBar(menuBar); - - JMenu menu = new JMenu("Hilfe"); - menuBar.add(menu); - - JMenuItem menuItem = new JMenuItem("FAQ"); - menuItem.addMouseListener(new MouseAdapter() { - @Override - public void mousePressed(MouseEvent arg0) { - // OpenLinks open = new OpenLinks(); - URI windows; - try { - windows = new URI(Links.getFAQ()); - OpenLinks.openWebpage(windows); - } catch (URISyntaxException e) { - - e.printStackTrace(); - } - } - }); - - menu.add(menuItem); - - JMenuItem menuItem_1 = new JMenuItem("OTRS"); - menuItem_1.addMouseListener(new MouseAdapter() { - @Override - public void mousePressed(MouseEvent arg0) { - URI windows; - try { - windows = new URI(Links.getOTRS()); - OpenLinks.openWebpage(windows); - } catch (URISyntaxException e) { - - e.printStackTrace(); - } - } - }); - menu.add(menuItem_1); - - JMenuItem mntmAbout = new JMenuItem("About"); - mntmAbout.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - About_GUI ab = new About_GUI(); - ab.setVisible(true); - } - }); - menu.add(mntmAbout); - setVisible(true); - - JMenu mnNewMenu_Info = new JMenu("Info"); - mnNewMenu_Info.addMouseListener(new MouseAdapter() { - @Override - public void mouseClicked(MouseEvent arg0) { - JOptionPane.showMessageDialog(c, HELP_MESSAGE, - "Hilfe zu dieser Oberfläche", - JOptionPane.INFORMATION_MESSAGE); - } - }); - menuBar.add(mnNewMenu_Info); - c = this; } private void buttonUploadActionPerformed(ActionEvent event) { diff --git a/dozentenmodul/src/main/java/gui/image/FTPEditDownloader_GUI.java b/dozentenmodul/src/main/java/gui/image/FTPEditDownloader_GUI.java index 6db115fb..273005e7 100644 --- a/dozentenmodul/src/main/java/gui/image/FTPEditDownloader_GUI.java +++ b/dozentenmodul/src/main/java/gui/image/FTPEditDownloader_GUI.java @@ -10,21 +10,17 @@ import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; -import java.awt.event.WindowAdapter; -import java.awt.event.WindowEvent; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import java.io.File; -import java.net.URI; -import java.net.URISyntaxException; import javax.swing.JButton; import javax.swing.JFileChooser; import javax.swing.JFrame; +import javax.swing.JInternalFrame; import javax.swing.JLabel; import javax.swing.JMenu; import javax.swing.JMenuBar; -import javax.swing.JMenuItem; import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JProgressBar; @@ -34,9 +30,10 @@ import javax.swing.SwingConstants; import javax.swing.UIManager; import javax.swing.UnsupportedLookAndFeelException; import javax.swing.border.EmptyBorder; +import javax.swing.event.InternalFrameAdapter; +import javax.swing.event.InternalFrameEvent; import models.Image; -import models.Links; import models.SessionData; import models.person; @@ -45,14 +42,14 @@ import org.apache.thrift.TException; import org.openslx.sat.thrift.iface.User; import thrift.ThriftManager; +import util.GuiManager; import util.OpenLinks; import config.Config; import ftp.DownloadTask; -import gui.intro.About_GUI; import gui.intro.MainMenue_GUI; @SuppressWarnings("serial") -public class FTPEditDownloader_GUI extends JFrame implements +public class FTPEditDownloader_GUI extends JInternalFrame implements PropertyChangeListener { /** @@ -91,7 +88,7 @@ public class FTPEditDownloader_GUI extends JFrame implements private boolean isCurrentlyLoading = false; // currently up or downloading // file private boolean isAborted = false; // down- or upload was manually aborted - private static final String HELP_MESSAGE = "<html><div align=\"center\">" + public static final String HELP_MESSAGE = "<html><div align=\"center\">" + "Hier können Sie Images herunterladen.<br />" + "Klicken Sie anschließend auf \"Zurück\", um zu Ihrer vorherigen Auswahl zurückzugelangen.<br />" + "</div></html>"; @@ -99,14 +96,13 @@ public class FTPEditDownloader_GUI extends JFrame implements /** * Create the frame. */ - public FTPEditDownloader_GUI(Component formerGUI) { + public FTPEditDownloader_GUI() { final Object[] options = { "Beenden", "Abbrechen" }; - - addWindowListener(new WindowAdapter() { + addInternalFrameListener(new InternalFrameAdapter() { @Override - public void windowClosing(WindowEvent e) { + public void internalFrameClosing(InternalFrameEvent arg0) { if (taskrun == true) { // check if user wants to quit. int choice = JOptionPane @@ -134,18 +130,51 @@ public class FTPEditDownloader_GUI extends JFrame implements task.cancel(true); System.exit(0); }// end if coice - } else { - // no download running, close window - try { - ThriftManager.getSatClient().setSessionInvalid(SessionData.session.getAuthToken()); - } catch (TException e1) { - // TODO Auto-generated catch block - e1.printStackTrace(); - } - System.exit(0); - }// end if taskrun - }// end window closing + } + } }); +// addWindowListener(new WindowAdapter() { +// @Override +// public void windowClosing(WindowEvent e) { +// if (taskrun == true) { +// // check if user wants to quit. +// int choice = JOptionPane +// .showOptionDialog( +// c, +// "Aktuell ist ein Download aktiv. Wollen Sie diesen Abbrechen und das Programm beenden?", +// "Upload aktiv", +// JOptionPane.YES_NO_CANCEL_OPTION, +// JOptionPane.QUESTION_MESSAGE, null, +// options, options[1]); +// // 0=beenden, 1=abbrechen +// if (choice == 0) { +// try { +// ThriftManager.getSatClient().DeleteFtpUser(user.userName,SessionData.session.getAuthToken()); +// try { +// ThriftManager.getSatClient().setSessionInvalid(SessionData.session.getAuthToken()); +// } catch (TException e1) { +// // TODO Auto-generated catch block +// e1.printStackTrace(); +// } +// } catch (TException e1) { +// +// e1.printStackTrace(); +// } +// task.cancel(true); +// System.exit(0); +// }// end if coice +// } else { +// // no download running, close window +// try { +// ThriftManager.getSatClient().setSessionInvalid(SessionData.session.getAuthToken()); +// } catch (TException e1) { +// // TODO Auto-generated catch block +// e1.printStackTrace(); +// } +// System.exit(0); +// }// end if taskrun +// }// end window closing +// }); setResizable(false); try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); @@ -161,7 +190,6 @@ public class FTPEditDownloader_GUI extends JFrame implements setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); setBounds(0, 0, 603, 722); - setLocationRelativeTo(formerGUI); getContentPane().setLayout(new BorderLayout()); contentPanel.setBackground(SystemColor.menu); @@ -306,9 +334,7 @@ public class FTPEditDownloader_GUI extends JFrame implements @Override public void mouseClicked(MouseEvent arg0) { // oeffnet das Hauptmenue - dispose(); - MainMenue_GUI main = new MainMenue_GUI(c); - main.setVisible(true); + GuiManager.show(new MainMenue_GUI()); } }); @@ -353,51 +379,6 @@ public class FTPEditDownloader_GUI extends JFrame implements menuBar.setBounds(0, 0, 597, 21); contentPanel.add(menuBar); - JMenu menu = new JMenu("Hilfe"); - menuBar.add(menu); - - JMenuItem menuItem = new JMenuItem("FAQ"); - menuItem.addMouseListener(new MouseAdapter() { - @Override - public void mousePressed(MouseEvent arg0) { - URI windows; - try { - windows = new URI(Links.getFAQ()); - OpenLinks.openWebpage(windows); - } catch (URISyntaxException e) { - - e.printStackTrace(); - } - } - }); - - menu.add(menuItem); - - JMenuItem menuItem_1 = new JMenuItem("OTRS"); - menuItem_1.addMouseListener(new MouseAdapter() { - @Override - public void mousePressed(MouseEvent arg0) { - URI windows; - try { - windows = new URI(Links.getOTRS()); - OpenLinks.openWebpage(windows); - } catch (URISyntaxException e) { - - e.printStackTrace(); - } - } - }); - - menu.add(menuItem_1); - - JMenuItem mntmAbout = new JMenuItem("About"); - mntmAbout.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - About_GUI ab = new About_GUI(); - ab.setVisible(true); - } - }); - menu.add(mntmAbout); lblAnleitung = new JLabel( "<HTML><U>Anleitung zum Erstellen einer virtuellen Maschine herunterladen</U></HTML>"); @@ -405,14 +386,7 @@ public class FTPEditDownloader_GUI extends JFrame implements lblAnleitung.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent arg0) { - URI anleitung; - try { - anleitung = new URI(Links.getAnleitungVMDK()); - OpenLinks.openWebpage(anleitung); - } catch (URISyntaxException e) { - - e.printStackTrace(); - } + OpenLinks.openWebpage("intro"); } }); lblAnleitung.setBounds(102, 448, 311, 14); @@ -468,18 +442,13 @@ public class FTPEditDownloader_GUI extends JFrame implements } // go back one page - SearchEditImage_GUI se = new SearchEditImage_GUI( - c); - se.setVisible(true); - dispose(); + GuiManager.show(new SearchEditImage_GUI()); }// end choice } else { // go back one page - SearchEditImage_GUI se = new SearchEditImage_GUI(c); - se.setVisible(true); - dispose(); + GuiManager.show(new SearchEditImage_GUI()); }// end else // always save download path @@ -500,18 +469,6 @@ public class FTPEditDownloader_GUI extends JFrame implements } setVisible(true); - JMenu mnNewMenu_Info = new JMenu("Info"); - mnNewMenu_Info.addMouseListener(new MouseAdapter() { - @Override - public void mouseClicked(MouseEvent arg0) { - JOptionPane.showMessageDialog(c, HELP_MESSAGE, - "Hilfe zu dieser Oberfläche", - JOptionPane.INFORMATION_MESSAGE); - } - }); - menuBar.add(mnNewMenu_Info); - - c = this; } diff --git a/dozentenmodul/src/main/java/gui/image/FTPEditUploader_GUI.java b/dozentenmodul/src/main/java/gui/image/FTPEditUploader_GUI.java index 231fd82f..74205377 100644 --- a/dozentenmodul/src/main/java/gui/image/FTPEditUploader_GUI.java +++ b/dozentenmodul/src/main/java/gui/image/FTPEditUploader_GUI.java @@ -10,13 +10,9 @@ import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; -import java.awt.event.WindowAdapter; -import java.awt.event.WindowEvent; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import java.io.File; -import java.net.URI; -import java.net.URISyntaxException; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Date; @@ -24,6 +20,7 @@ import java.util.Date; import javax.swing.JButton; import javax.swing.JFileChooser; import javax.swing.JFrame; +import javax.swing.JInternalFrame; import javax.swing.JLabel; import javax.swing.JMenu; import javax.swing.JMenuBar; @@ -37,10 +34,11 @@ import javax.swing.SwingConstants; import javax.swing.UIManager; import javax.swing.UnsupportedLookAndFeelException; import javax.swing.border.EmptyBorder; +import javax.swing.event.InternalFrameAdapter; +import javax.swing.event.InternalFrameEvent; import javax.swing.filechooser.FileNameExtensionFilter; import models.Image; -import models.Links; import models.RightsManagement; import models.SessionData; import models.person; @@ -50,6 +48,7 @@ import org.apache.thrift.TException; import org.openslx.sat.thrift.iface.User; import thrift.ThriftManager; +import util.GuiManager; import util.OpenLinks; import config.Config; import ftp.UploadTask; @@ -57,7 +56,7 @@ import gui.intro.About_GUI; import gui.intro.MainMenue_GUI; @SuppressWarnings("serial") -public class FTPEditUploader_GUI extends JFrame implements +public class FTPEditUploader_GUI extends JInternalFrame implements PropertyChangeListener { /** @@ -99,7 +98,7 @@ public class FTPEditUploader_GUI extends JFrame implements // file private boolean isAborted = false; // down- or upload was manually aborted Component c = null; - private static final String HELP_MESSAGE = "<html><div align = \"center\">" + public static final String HELP_MESSAGE = "<html><div align = \"center\">" + "Laden Sie hier Ihre bearbeitete .vmdk-Datei hoch, die dann als virtuelles Labor geladen werden kann.<br />" + "Wichtig ist, dass Sie zum Schluss auf \"Fertigstellen\" klicken, damit die Daten übernommen werden.<br />" + "Wenn Sie die Datei hochgeladen haben, dann aber auf \"zurück\" klicken, oder die Anwendung beenden,<br />" @@ -109,16 +108,14 @@ public class FTPEditUploader_GUI extends JFrame implements /** * Create the frame. */ - public FTPEditUploader_GUI(Component formerGUI) { + public FTPEditUploader_GUI() { final Object[] options = { "Beenden", "Abbrechen" }; - - addWindowListener(new WindowAdapter() { + addInternalFrameListener(new InternalFrameAdapter() { @Override - public void windowClosing(WindowEvent arg0) { - + public void internalFrameClosing(InternalFrameEvent arg0) { if (taskrun == true) { // check if user wants to quit. int choice = JOptionPane @@ -151,18 +148,57 @@ public class FTPEditUploader_GUI extends JFrame implements } System.exit(0); }// end if choice - } else { - // no upload running, close window - try { - ThriftManager.getSatClient().setSessionInvalid(SessionData.session.getAuthToken()); - } catch (TException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - System.exit(0); - }// end if taskrun - }// end window closing + } + } }); +// addWindowListener(new WindowAdapter() { +// @Override +// public void windowClosing(WindowEvent arg0) { +// +// if (taskrun == true) { +// // check if user wants to quit. +// int choice = JOptionPane +// .showOptionDialog( +// c, +// "Aktuell ist ein Upload aktiv. Wollen Sie diesen Abbrechen und das Programm beenden?", +// "Upload aktiv", +// JOptionPane.YES_NO_CANCEL_OPTION, +// JOptionPane.QUESTION_MESSAGE, null, +// options, options[1]); +// // 0=beenden, 1=abbrechen +// if (choice == 0) { +// try { +// ThriftManager.getSatClient().DeleteFtpUser(user.userName,SessionData.session.getAuthToken()); +// } catch (TException e1) { +// e1.printStackTrace(); +// } +// task.cancel(true); +// try { +// ThriftManager.getSatClient().setSessionInvalid(SessionData.session.getAuthToken()); +// } catch (TException e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// } +// try { +// ThriftManager.getSatClient().setSessionInvalid(SessionData.session.getAuthToken()); +// } catch (TException e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// } +// System.exit(0); +// }// end if choice +// } else { +// // no upload running, close window +// try { +// ThriftManager.getSatClient().setSessionInvalid(SessionData.session.getAuthToken()); +// } catch (TException e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// } +// System.exit(0); +// }// end if taskrun +// }// end window closing +// }); setResizable(false); // Aktion die beim Schliessen durchgefuehrt werden soll setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); @@ -179,7 +215,6 @@ public class FTPEditUploader_GUI extends JFrame implements setTitle("Dozentenmodul - Image bearbeiten - "+person.verantwortlicher.getUserID()); setBounds(0, 0, 603, 722); - setLocationRelativeTo(formerGUI); getContentPane().setLayout(new BorderLayout()); contentPanel.setBackground(SystemColor.menu); @@ -322,10 +357,7 @@ public class FTPEditUploader_GUI extends JFrame implements lblNewLabel_1.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent arg0) { - // oeffnet das Hauptmenue - dispose(); - MainMenue_GUI main = new MainMenue_GUI(c); - main.setVisible(true); + GuiManager.show(new MainMenue_GUI()); } }); @@ -439,9 +471,7 @@ public class FTPEditUploader_GUI extends JFrame implements Config.store(); - dispose(); - MainMenue_GUI m = new MainMenue_GUI(c); - m.setVisible(true); + GuiManager.show(new MainMenue_GUI()); if (taskrun == true) { try { @@ -487,14 +517,10 @@ public class FTPEditUploader_GUI extends JFrame implements if(ThriftManager.getSatClient().userIsImageAdmin(Image.image.getImageId(), SessionData.session.getAuthToken(),person.verantwortlicher.getUserID()) == true || person.verantwortlicher.getRole().equals("Admin")){ //user is admin and may change permissions - PermissionEditImage_GUI ei = new PermissionEditImage_GUI(c); - ei.setVisible(true); - dispose(); + GuiManager.show(new PermissionEditImage_GUI()); } else { //user may not change permissions - EditImageTechnisch_GUI ei = new EditImageTechnisch_GUI(c); - ei.setVisible(true); - dispose(); + GuiManager.show(new EditImageTechnisch_GUI()); } } catch (TException e) { // TODO Auto-generated catch block @@ -518,14 +544,10 @@ public class FTPEditUploader_GUI extends JFrame implements if(ThriftManager.getSatClient().userIsImageAdmin(Image.image.getImageId(), SessionData.session.getAuthToken(),person.verantwortlicher.getUserID()) == true) { //user is admin and may change permissions - PermissionEditImage_GUI ei = new PermissionEditImage_GUI(c); - ei.setVisible(true); - dispose(); + GuiManager.show(new PermissionEditImage_GUI()); } else { //user may not change permissions - EditImageTechnisch_GUI ei = new EditImageTechnisch_GUI(c); - ei.setVisible(true); - dispose(); + GuiManager.show(new EditImageTechnisch_GUI()); } } catch (TException e) { // TODO Auto-generated catch block @@ -546,68 +568,6 @@ public class FTPEditUploader_GUI extends JFrame implements } } - JMenuBar menuBar = new JMenuBar(); - setJMenuBar(menuBar); - - JMenu menu = new JMenu("Hilfe"); - menuBar.add(menu); - - JMenuItem menuItem = new JMenuItem("FAQ"); - menuItem.addMouseListener(new MouseAdapter() { - @Override - public void mousePressed(MouseEvent arg0) { - URI windows; - try { - windows = new URI(Links.getFAQ()); - OpenLinks.openWebpage(windows); - } catch (URISyntaxException e) { - e.printStackTrace(); - } - - } - }); - - menu.add(menuItem); - - JMenuItem menuItem_1 = new JMenuItem("OTRS"); - menuItem_1.addMouseListener(new MouseAdapter() { - @Override - public void mousePressed(MouseEvent arg0) { - URI windows; - try { - windows = new URI(Links.getOTRS()); - OpenLinks.openWebpage(windows); - } catch (URISyntaxException e) { - e.printStackTrace(); - } - - } - }); - - menu.add(menuItem_1); - - JMenuItem mntmAbout = new JMenuItem("About"); - mntmAbout.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - About_GUI ab = new About_GUI(); - ab.setVisible(true); - } - }); - menu.add(mntmAbout); - - JMenu mnNewMenu_Info = new JMenu("Info"); - mnNewMenu_Info.addMouseListener(new MouseAdapter() { - @Override - public void mouseClicked(MouseEvent arg0) { - JOptionPane.showMessageDialog(c, HELP_MESSAGE, - "Hilfe zu dieser Oberfläche", - JOptionPane.INFORMATION_MESSAGE); - } - }); - menuBar.add(mnNewMenu_Info); - - setVisible(true); - } private void buttonUploadActionPerformed(ActionEvent event) { diff --git a/dozentenmodul/src/main/java/gui/image/FTPSearchDownloader_GUI.java b/dozentenmodul/src/main/java/gui/image/FTPSearchDownloader_GUI.java index 0cb63429..482abcc6 100644 --- a/dozentenmodul/src/main/java/gui/image/FTPSearchDownloader_GUI.java +++ b/dozentenmodul/src/main/java/gui/image/FTPSearchDownloader_GUI.java @@ -10,17 +10,14 @@ import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; -import java.awt.event.WindowAdapter; -import java.awt.event.WindowEvent; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import java.io.File; -import java.net.URI; -import java.net.URISyntaxException; import javax.swing.JButton; import javax.swing.JFileChooser; import javax.swing.JFrame; +import javax.swing.JInternalFrame; import javax.swing.JLabel; import javax.swing.JMenu; import javax.swing.JMenuBar; @@ -34,9 +31,10 @@ import javax.swing.SwingConstants; import javax.swing.UIManager; import javax.swing.UnsupportedLookAndFeelException; import javax.swing.border.EmptyBorder; +import javax.swing.event.InternalFrameAdapter; +import javax.swing.event.InternalFrameEvent; import models.Image; -import models.Links; import models.SessionData; import models.person; @@ -45,6 +43,7 @@ import org.apache.thrift.TException; import org.openslx.sat.thrift.iface.User; import thrift.ThriftManager; +import util.GuiManager; import util.OpenLinks; import config.Config; import ftp.DownloadTask; @@ -52,7 +51,7 @@ import gui.intro.About_GUI; import gui.intro.MainMenue_GUI; @SuppressWarnings("serial") -public class FTPSearchDownloader_GUI extends JFrame implements +public class FTPSearchDownloader_GUI extends JInternalFrame implements PropertyChangeListener { private final static Logger LOGGER = Logger @@ -89,7 +88,7 @@ public class FTPSearchDownloader_GUI extends JFrame implements private boolean isCurrentlyLoading = false; // currently up or downloading // file private boolean isAborted = false; // down- or upload was manually aborted - private static final String HELP_MESSAGE = "<html><div align=\"center\">" + + public static final String HELP_MESSAGE = "<html><div align=\"center\">" + "Hier können Sie Images herunterladen.<br />" + "Klicken Sie anschließend auf \"Zurück\" oder \"Hauptmenü\", um zu Ihrer vorherigen Auswahl oder zum Menü zurückzugelangen.<br />" + "</div></html>"; @@ -97,14 +96,13 @@ public class FTPSearchDownloader_GUI extends JFrame implements /** * Create the frame. */ - public FTPSearchDownloader_GUI(Component formerGUI) { + public FTPSearchDownloader_GUI() { final Object[] options = { "Beenden", "Abbrechen" }; - - addWindowListener(new WindowAdapter() { + addInternalFrameListener(new InternalFrameAdapter() { @Override - public void windowClosing(WindowEvent e) { + public void internalFrameClosing(InternalFrameEvent arg0) { if (taskrun == true) { // check if user wants to quit. int choice = JOptionPane @@ -140,18 +138,59 @@ public class FTPSearchDownloader_GUI extends JFrame implements System.exit(0); }// end if choice - } else { - // no download running, close window - try { - ThriftManager.getSatClient().setSessionInvalid(SessionData.session.getAuthToken()); - } catch (TException e1) { - // TODO Auto-generated catch block - e1.printStackTrace(); - } - System.exit(0); - }// end if taskrun - }// end window closing + } + } }); +// addWindowListener(new WindowAdapter() { +// @Override +// public void windowClosing(WindowEvent e) { +// if (taskrun == true) { +// // check if user wants to quit. +// int choice = JOptionPane +// .showOptionDialog( +// c, +// "Aktuell ist ein Download aktiv. Wollen Sie diesen Abbrechen und das Programm beenden?", +// "Upload aktiv", +// JOptionPane.YES_NO_CANCEL_OPTION, +// JOptionPane.QUESTION_MESSAGE, null, +// options, options[1]); +// // 0=beenden, 1=abbrechen +// if (choice == 0) { +// +// try { +// ThriftManager.getSatClient().DeleteFtpUser(user.userName,SessionData.session.getAuthToken()); +// try { +// ThriftManager.getSatClient().setSessionInvalid(SessionData.session.getAuthToken()); +// } catch (TException e1) { +// // TODO Auto-generated catch block +// e1.printStackTrace(); +// } +// try { +// ThriftManager.getSatClient().setSessionInvalid(SessionData.session.getAuthToken()); +// } catch (TException e1) { +// // TODO Auto-generated catch block +// e1.printStackTrace(); +// } +// } catch (TException e1) { +// // TODO Auto-generated catch block +// e1.printStackTrace(); +// } +// task.cancel(true); +// +// System.exit(0); +// }// end if choice +// } else { +// // no download running, close window +// try { +// ThriftManager.getSatClient().setSessionInvalid(SessionData.session.getAuthToken()); +// } catch (TException e1) { +// // TODO Auto-generated catch block +// e1.printStackTrace(); +// } +// System.exit(0); +// }// end if taskrun +// }// end window closing +// }); setResizable(false); try { @@ -167,7 +206,6 @@ public class FTPSearchDownloader_GUI extends JFrame implements // Aktion die beim Schliessen durchgefuehrt werden soll setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); setBounds(0, 0, 603, 722); - setLocationRelativeTo(formerGUI); getContentPane().setLayout(new BorderLayout()); contentPanel.setBackground(SystemColor.menu); @@ -346,79 +384,14 @@ public class FTPSearchDownloader_GUI extends JFrame implements "Klicken Sie auf \"Zurück\" oder \"Hauptmenü\"."); lblKlickenSieAuf.setBounds(102, 423, 241, 14); contentPanel.add(lblKlickenSieAuf); - - JMenuBar menuBar = new JMenuBar(); - menuBar.setBounds(0, 0, 597, 21); - contentPanel.add(menuBar); - - JMenu menu = new JMenu("Hilfe"); - menuBar.add(menu); - - JMenuItem menuItem = new JMenuItem("FAQ"); - menuItem.addMouseListener(new MouseAdapter() { - @Override - public void mousePressed(MouseEvent arg0) { - - URI windows; - try { - windows = new URI(Links.getFAQ()); - - OpenLinks.openWebpage(windows); - - } catch (URISyntaxException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - - } - }); - - menu.add(menuItem); - - JMenuItem menuItem_1 = new JMenuItem("OTRS"); - menuItem_1.addMouseListener(new MouseAdapter() { - @Override - public void mousePressed(MouseEvent arg0) { - - URI windows; - try { - windows = new URI(Links.getOTRS()); - - OpenLinks.openWebpage(windows); - - } catch (URISyntaxException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - - } - }); - - menu.add(menuItem_1); - - JMenuItem mntmAbout = new JMenuItem("About"); - mntmAbout.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - About_GUI ab = new About_GUI(); - ab.setVisible(true); - } - }); - menu.add(mntmAbout); - + lblAnleitung = new JLabel( "<HTML><U>Anleitung zum erstellen einer virtuellen Maschine herunterladen</U></HTML>"); lblAnleitung.setForeground(Color.BLUE); lblAnleitung.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent arg0) { - URI anleitung; - try { - anleitung = new URI(Links.getAnleitungVMDK()); - OpenLinks.openWebpage(anleitung); - } catch (URISyntaxException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } + OpenLinks.openWebpage("vmware"); } }); lblAnleitung.setBounds(102, 448, 311, 14); @@ -474,16 +447,12 @@ public class FTPSearchDownloader_GUI extends JFrame implements e1.printStackTrace(); } // go back one page - SearchImage_GUI si = new SearchImage_GUI(c); - si.setVisible(true); - dispose(); + GuiManager.show(new SearchImage_GUI()); }// end choice } else { // go back one page - SearchImage_GUI si = new SearchImage_GUI(c); - si.setVisible(true); - dispose(); + GuiManager.show(new SearchImage_GUI()); }// end else // save config in any case Config.setLastDownloadPath(lblPath.getText().trim()); @@ -499,26 +468,12 @@ public class FTPSearchDownloader_GUI extends JFrame implements Config.setLastDownloadPath(lblPath.getText().trim()); Config.store(); - MainMenue_GUI mm = new MainMenue_GUI(c); - mm.setVisible(true); - dispose(); + GuiManager.show(new MainMenue_GUI()); } }); btnMainMenu.setActionCommand("Cancel"); buttonPane.add(btnMainMenu); } - - JMenu mnNewMenu_Info = new JMenu("Info"); - mnNewMenu_Info.addMouseListener(new MouseAdapter() { - @Override - public void mouseClicked(MouseEvent arg0) { - JOptionPane.showMessageDialog(c, HELP_MESSAGE, "Hilfe zu dieser Oberfläche", JOptionPane.INFORMATION_MESSAGE); - } - }); - menuBar.add(mnNewMenu_Info); - - c = this; - setVisible(true); } diff --git a/dozentenmodul/src/main/java/gui/image/PermissionCreateImage_GUI.java b/dozentenmodul/src/main/java/gui/image/PermissionCreateImage_GUI.java index 2b590b0b..84891f6c 100644 --- a/dozentenmodul/src/main/java/gui/image/PermissionCreateImage_GUI.java +++ b/dozentenmodul/src/main/java/gui/image/PermissionCreateImage_GUI.java @@ -1,6 +1,5 @@ package gui.image; -import gui.intro.About_GUI; import gui.intro.MainMenue_GUI; import java.awt.Color; @@ -15,10 +14,6 @@ import java.awt.event.ItemListener; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import java.awt.event.MouseListener; -import java.awt.event.WindowAdapter; -import java.awt.event.WindowEvent; -import java.net.URI; -import java.net.URISyntaxException; import java.util.ArrayList; import java.util.Iterator; import java.util.List; @@ -28,12 +23,8 @@ import javax.swing.DefaultComboBoxModel; import javax.swing.JButton; import javax.swing.JCheckBox; import javax.swing.JComboBox; -import javax.swing.JFrame; +import javax.swing.JInternalFrame; import javax.swing.JLabel; -import javax.swing.JMenu; -import javax.swing.JMenuBar; -import javax.swing.JMenuItem; -import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.JSeparator; @@ -52,23 +43,18 @@ import javax.swing.table.TableColumn; import javax.swing.table.TableColumnModel; import models.Image; -import models.Links; import models.RightsManagement; -import models.SessionData; import models.person; -import org.apache.thrift.TException; import org.openslx.sat.thrift.iface.Person; -import org.openslx.sat.thrift.iface.Server.Client; import util.CheckIntegrity; +import util.GuiManager; import util.ListAllOtherUsers_GUI; -import util.OpenLinks; @SuppressWarnings("serial") -public class PermissionCreateImage_GUI extends JFrame { +public class PermissionCreateImage_GUI extends JInternalFrame { - Client client = models.Client.clientcon.getClient(); private final JPanel contentPanel = new JPanel(); String[] result; private JTable table = null; @@ -105,7 +91,7 @@ public class PermissionCreateImage_GUI extends JFrame { private JLabel lblWriteDesc; private JLabel lblAdminDesc; private JLabel lblLinkallowedDesc; - private static final String HELP_MESSAGE = "<html><div align=\"center\">" + public static final String HELP_MESSAGE = "<html><div align=\"center\">" + "Legen Sie fest, welche Personen welche Rechte an Ihrem Image haben.<br />" + "Sie können die Rechte Lesen, Schreiben, Link und Admin vergeben.<br />" + "Link bedeutet, dass diese Person Veranstaltungen auf Ihr Image verlinken darf und dieses somit<br />" @@ -115,22 +101,22 @@ public class PermissionCreateImage_GUI extends JFrame { private JButton btnAddUser; private JButton btnDeleteUser; - public PermissionCreateImage_GUI(Component formerGUI) { + public PermissionCreateImage_GUI() { - - addWindowListener(new WindowAdapter() { - @Override - public void windowClosing(WindowEvent arg0) { - try { - client.setSessionInvalid(SessionData.session.getAuthToken()); - } catch (TException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - System.exit(0); - } - }); +// +// addWindowListener(new WindowAdapter() { +// @Override +// public void windowClosing(WindowEvent arg0) { +// try { +// client.setSessionInvalid(SessionData.session.getAuthToken()); +// } catch (TException e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// } +// System.exit(0); +// } +// }); setResizable(false); @@ -144,7 +130,7 @@ public class PermissionCreateImage_GUI extends JFrame { setTitle("bwLehrpool Suite - Image bearbeiten - "+person.verantwortlicher.getUserID()); setBounds(0, 0, 603, 722); - setLocationRelativeTo(formerGUI); + getContentPane().setLayout(null); { @@ -362,9 +348,9 @@ public class PermissionCreateImage_GUI extends JFrame { panel_1.add(btnDeleteUser); btnAddUser.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { - //show list of all other relevant users - ListAllOtherUsers_GUI lu = new ListAllOtherUsers_GUI(c, table, 5); //give access to the table model and inform that the userID is position 5 in the model - lu.setVisible(true); + // show list of all other relevant users + // give access to the table model and inform that the userID is position 5 in the model + GuiManager.openPopup(new ListAllOtherUsers_GUI(table, 5)); } }); @@ -372,10 +358,7 @@ public class PermissionCreateImage_GUI extends JFrame { lblHauptmen.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent arg0) { - - PermissionCreateImage_GUI.this.setVisible(false); - MainMenue_GUI main = new MainMenue_GUI(c); - main.setVisible(true); + GuiManager.show(new MainMenue_GUI()); } }); lblHauptmen.setForeground(Color.BLUE); @@ -452,11 +435,7 @@ public class PermissionCreateImage_GUI extends JFrame { JButton cancelButton = new JButton("Zurück"); cancelButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { - - CreateImageTechnisch_GUI ci = new CreateImageTechnisch_GUI( - c); - ci.setVisible(true); - dispose(); + GuiManager.show(new CreateImageTechnisch_GUI()); } }); cancelButton.setActionCommand("OK"); @@ -479,9 +458,7 @@ public class PermissionCreateImage_GUI extends JFrame { saveTableToList(); Image.image.setShareMode(comboBox_1.getSelectedIndex()); - FTPCreateUploader_GUI ea = new FTPCreateUploader_GUI(c); - ea.setVisible(true); - dispose(); + GuiManager.show(new FTPCreateUploader_GUI()); } }); @@ -499,75 +476,6 @@ public class PermissionCreateImage_GUI extends JFrame { separator_1.setBounds(0, 627, 597, 2); getContentPane().add(separator_1); - JMenuBar menuBar = new JMenuBar(); - setJMenuBar(menuBar); - - JMenu mnNewMenu_1 = new JMenu("Hilfe"); - menuBar.add(mnNewMenu_1); - - JMenuItem mntmFaq = new JMenuItem("FAQ"); - mntmFaq.addMouseListener(new MouseAdapter() { - @Override - public void mousePressed(MouseEvent arg0) { - - URI windows; - try { - windows = new URI(Links.getFAQ()); - - OpenLinks.openWebpage(windows); - - } catch (URISyntaxException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - }); - mnNewMenu_1.add(mntmFaq); - - JMenuItem mntmOtrs = new JMenuItem("OTRS"); - mntmOtrs.addMouseListener(new MouseAdapter() { - @Override - public void mousePressed(MouseEvent arg0) { - - URI windows; - try { - windows = new URI(Links.getOTRS()); - - OpenLinks.openWebpage(windows); - - } catch (URISyntaxException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - - } - }); - mnNewMenu_1.add(mntmOtrs); - - JMenuItem mntmAbout = new JMenuItem("About"); - mntmAbout.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - About_GUI ab = new About_GUI(); - ab.setVisible(true); - } - }); - mnNewMenu_1.add(mntmAbout); - - JMenu mnNewMenu_Info = new JMenu("Info"); - mnNewMenu_Info.addMouseListener(new MouseAdapter() { - @Override - public void mouseClicked(MouseEvent arg0) { - JOptionPane.showMessageDialog(c, HELP_MESSAGE, - "Hilfe zu dieser Oberfläche", - JOptionPane.INFORMATION_MESSAGE); - } - }); - menuBar.add(mnNewMenu_Info); - - c = this; - - this.setLocationRelativeTo(formerGUI); - this.setVisible(true); }// end constructor private void checkIntegrity(int row) { diff --git a/dozentenmodul/src/main/java/gui/image/PermissionEditImage_GUI.java b/dozentenmodul/src/main/java/gui/image/PermissionEditImage_GUI.java index 053d279a..16cfb5c0 100644 --- a/dozentenmodul/src/main/java/gui/image/PermissionEditImage_GUI.java +++ b/dozentenmodul/src/main/java/gui/image/PermissionEditImage_GUI.java @@ -1,6 +1,5 @@ package gui.image; -import gui.intro.About_GUI; import gui.intro.MainMenue_GUI; import java.awt.Color; @@ -14,10 +13,6 @@ import java.awt.event.ItemEvent; import java.awt.event.ItemListener; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; -import java.awt.event.WindowAdapter; -import java.awt.event.WindowEvent; -import java.net.URI; -import java.net.URISyntaxException; import java.util.ArrayList; import java.util.Iterator; import java.util.List; @@ -26,12 +21,8 @@ import javax.swing.AbstractButton; import javax.swing.DefaultComboBoxModel; import javax.swing.JButton; import javax.swing.JComboBox; -import javax.swing.JFrame; +import javax.swing.JInternalFrame; import javax.swing.JLabel; -import javax.swing.JMenu; -import javax.swing.JMenuBar; -import javax.swing.JMenuItem; -import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.JSeparator; @@ -46,23 +37,21 @@ import javax.swing.table.DefaultTableModel; import javax.swing.table.TableColumn; import models.Image; -import models.Links; import models.RightsManagement; import models.SessionData; import models.person; import org.apache.thrift.TException; import org.openslx.sat.thrift.iface.Person; -import org.openslx.sat.thrift.iface.Server.Client; +import thrift.ThriftManager; import util.CheckIntegrity; +import util.GuiManager; import util.ListAllOtherUsers_GUI; -import util.OpenLinks; @SuppressWarnings("serial") -public class PermissionEditImage_GUI extends JFrame { +public class PermissionEditImage_GUI extends JInternalFrame { - Client client = models.Client.clientcon.getClient(); private final JPanel contentPanel = new JPanel(); String[] result; private JTable table; @@ -94,7 +83,7 @@ public class PermissionEditImage_GUI extends JFrame { private JLabel label_5; private JLabel label_6; private JLabel lblvolleRechteRead; - private static final String HELP_MESSAGE = "<html><div align=\"center\">" + public static final String HELP_MESSAGE = "<html><div align=\"center\">" + "Verändern Sie die Berechtigungen für Ihr Image.<br />" + "Sie können die Rechte Lesen, Schreiben, Link und Admin vergeben.<br />" + "Link bedeutet, dass diese Person Veranstaltungen auf Ihr Image verlinken darf und dieses somit<br />" @@ -102,21 +91,21 @@ public class PermissionEditImage_GUI extends JFrame { + "für andere Benutzer festlegen und ist somit wie der Besitzer zu betrachten." + "</div></html>"; - public PermissionEditImage_GUI(Component formerGUI) { - - - addWindowListener(new WindowAdapter() { - @Override - public void windowClosing(WindowEvent arg0) { - try { - client.setSessionInvalid(SessionData.session.getAuthToken()); - } catch (TException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - System.exit(0); - } - }); + public PermissionEditImage_GUI() { + +// +// addWindowListener(new WindowAdapter() { +// @Override +// public void windowClosing(WindowEvent arg0) { +// try { +// client.setSessionInvalid(SessionData.session.getAuthToken()); +// } catch (TException e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// } +// System.exit(0); +// } +// }); setResizable(false); try { @@ -129,7 +118,7 @@ public class PermissionEditImage_GUI extends JFrame { setTitle("bwLehrpool Suite - Image bearbeiten - "+person.verantwortlicher.getUserID()); setBounds(0, 0, 603, 722); - setLocationRelativeTo(formerGUI); + getContentPane().setLayout(null); { @@ -197,7 +186,7 @@ public class PermissionEditImage_GUI extends JFrame { //System.out.println("Loading data from db"); try { - map = client.getPermissionForUserAndImage(SessionData.session.getAuthToken(),Image.image.getImageId(),person.verantwortlicher.getUserID()); + map = ThriftManager.getSatClient().getPermissionForUserAndImage(SessionData.session.getAuthToken(),Image.image.getImageId(),person.verantwortlicher.getUserID()); Iterator<Person> i = map.iterator(); int x = 0; @@ -324,9 +313,7 @@ public class PermissionEditImage_GUI extends JFrame { btnAddUser.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { //show list of all other relevant users - ListAllOtherUsers_GUI lu = new ListAllOtherUsers_GUI(c, table, 5); //give access to the table model and inform that the userID is position 5 in the model - lu.setVisible(true); - + GuiManager.openPopup(new ListAllOtherUsers_GUI(table, 5)); } }); btnAddUser.setBounds(10, 217, 113, 23); @@ -357,10 +344,7 @@ public class PermissionEditImage_GUI extends JFrame { lblHauptmen.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent arg0) { - - PermissionEditImage_GUI.this.setVisible(false); - MainMenue_GUI main = new MainMenue_GUI(c); - main.setVisible(true); + GuiManager.show(new MainMenue_GUI()); } }); lblHauptmen.setForeground(Color.BLUE); @@ -437,13 +421,7 @@ public class PermissionEditImage_GUI extends JFrame { JButton cancelButton = new JButton("Zurück"); cancelButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { - - // EditImageFreigabe_GUI sr = new - // EditImageFreigabe_GUI(); - EditImageTechnisch_GUI ei = new EditImageTechnisch_GUI( - c); - ei.setVisible(true); - dispose(); + GuiManager.show(new EditImageTechnisch_GUI()); } }); cancelButton.setActionCommand("OK"); @@ -466,10 +444,7 @@ public class PermissionEditImage_GUI extends JFrame { saveTableToList(); Image.image.setShareMode(comboBox_1.getSelectedIndex()); - FTPEditUploader_GUI ea = new FTPEditUploader_GUI(c); - ea.setVisible(true); - dispose(); - + GuiManager.show(new FTPEditUploader_GUI()); } }); continueButton.setActionCommand("Cancel"); @@ -486,72 +461,7 @@ public class PermissionEditImage_GUI extends JFrame { separator_1.setBounds(0, 627, 597, 2); getContentPane().add(separator_1); - JMenuBar menuBar = new JMenuBar(); - setJMenuBar(menuBar); - - JMenu mnNewMenu_1 = new JMenu("Hilfe"); - menuBar.add(mnNewMenu_1); - - JMenuItem mntmFaq = new JMenuItem("FAQ"); - mntmFaq.addMouseListener(new MouseAdapter() { - @Override - public void mousePressed(MouseEvent arg0) { - - URI windows; - try { - windows = new URI(Links.getFAQ()); - - OpenLinks.openWebpage(windows); - - } catch (URISyntaxException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - }); - mnNewMenu_1.add(mntmFaq); - - JMenuItem mntmOtrs = new JMenuItem("OTRS"); - mntmOtrs.addMouseListener(new MouseAdapter() { - @Override - public void mousePressed(MouseEvent arg0) { - - URI windows; - try { - windows = new URI(Links.getOTRS()); - - OpenLinks.openWebpage(windows); - - } catch (URISyntaxException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - - } - }); - mnNewMenu_1.add(mntmOtrs); - JMenuItem mntmAbout = new JMenuItem("About"); - mntmAbout.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - About_GUI ab = new About_GUI(); - ab.setVisible(true); - } - }); - mnNewMenu_1.add(mntmAbout); - - JMenu mnNewMenu_Info = new JMenu("Info"); - mnNewMenu_Info.addMouseListener(new MouseAdapter() { - @Override - public void mouseClicked(MouseEvent arg0) { - JOptionPane.showMessageDialog(c, HELP_MESSAGE, - "Hilfe zu dieser Oberfläche", - JOptionPane.INFORMATION_MESSAGE); - } - }); - menuBar.add(mnNewMenu_Info); - - c = this; } // save the entered rights into the model and prepare them to be written to diff --git a/dozentenmodul/src/main/java/gui/image/SearchEditImage_GUI.java b/dozentenmodul/src/main/java/gui/image/SearchEditImage_GUI.java index 3ad45213..37512f2f 100644 --- a/dozentenmodul/src/main/java/gui/image/SearchEditImage_GUI.java +++ b/dozentenmodul/src/main/java/gui/image/SearchEditImage_GUI.java @@ -1,6 +1,5 @@ package gui.image; -import gui.intro.About_GUI; import gui.intro.MainMenue_GUI; import java.awt.Color; @@ -14,10 +13,6 @@ import java.awt.event.KeyAdapter; import java.awt.event.KeyEvent; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; -import java.awt.event.WindowAdapter; -import java.awt.event.WindowEvent; -import java.net.URI; -import java.net.URISyntaxException; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.ArrayList; @@ -28,11 +23,8 @@ import java.util.Map; import javax.swing.JButton; import javax.swing.JComboBox; -import javax.swing.JFrame; +import javax.swing.JInternalFrame; import javax.swing.JLabel; -import javax.swing.JMenu; -import javax.swing.JMenuBar; -import javax.swing.JMenuItem; import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JRadioButton; @@ -48,6 +40,8 @@ import javax.swing.UIManager; import javax.swing.UnsupportedLookAndFeelException; import javax.swing.border.EmptyBorder; import javax.swing.border.TitledBorder; +import javax.swing.event.InternalFrameAdapter; +import javax.swing.event.InternalFrameEvent; import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionListener; import javax.swing.table.DefaultTableModel; @@ -56,18 +50,17 @@ import javax.swing.table.TableRowSorter; import models.Image; import models.ItemOwner; -import models.Links; import models.SessionData; import models.person; import org.apache.thrift.TException; import thrift.ThriftManager; -import util.OpenLinks; +import util.GuiManager; //import models.person; @SuppressWarnings("serial") -public class SearchEditImage_GUI extends JFrame { +public class SearchEditImage_GUI extends JInternalFrame { private final JPanel contentPanel = new JPanel(); JLabel labelName; @@ -108,7 +101,7 @@ public class SearchEditImage_GUI extends JFrame { // Update // (5) - private static final String HELP_MESSAGE = "<html><div align=\"center\">" + public static final String HELP_MESSAGE = "<html><div align=\"center\">" + "Suchen Sie Images und laden Sie sie direkt herunter.<br />" + "Sie können die Volltextsuche nutzen und nach Betriebssystemen filtern.<br />" + "Die Volltextsuche sucht in den Feldern Name und Beschreibung.<br />" @@ -134,61 +127,49 @@ public class SearchEditImage_GUI extends JFrame { /** * Create the dialog. */ - public SearchEditImage_GUI(Component formerGUI) { + public SearchEditImage_GUI() { filters.add(RowFilter.regexFilter(".", 0)); rf = RowFilter.orFilter(filters); - - addWindowListener(new WindowAdapter() { - @Override - public void windowClosing(WindowEvent arg0) { - // Beendet die Anwendung nach klick auf X - try { - ThriftManager.getSatClient().setSessionInvalid(SessionData.session.getAuthToken()); - } catch (TException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - System.exit(0); - } - + addInternalFrameListener(new InternalFrameAdapter() { @Override - public void windowOpened(WindowEvent arg0) { - initTableModel(modelMyImages); - - // auszublendende Angaben - // 1=Lizenzpflichtig - // 3=Veranstaltung - // 6=ID - // 7=Version - // 8=Template - // 9=Beschreibung (needed for full text search) - tablemyImages.getColumnModel().getColumn(1).setWidth(0); - tablemyImages.getColumnModel().getColumn(1).setMinWidth(0); - tablemyImages.getColumnModel().getColumn(1).setMaxWidth(0); - tablemyImages.getColumnModel().getColumn(3).setWidth(0); - tablemyImages.getColumnModel().getColumn(3).setMinWidth(0); - tablemyImages.getColumnModel().getColumn(3).setMaxWidth(0); - tablemyImages.getColumnModel().getColumn(8).setWidth(0); - tablemyImages.getColumnModel().getColumn(8).setMinWidth(0); - tablemyImages.getColumnModel().getColumn(8).setMaxWidth(0); - tablemyImages.getColumnModel().getColumn(6).setWidth(0); - tablemyImages.getColumnModel().getColumn(6).setMinWidth(0); - tablemyImages.getColumnModel().getColumn(6).setMaxWidth(0); - tablemyImages.getColumnModel().getColumn(7).setWidth(0); - tablemyImages.getColumnModel().getColumn(7).setMinWidth(0); - tablemyImages.getColumnModel().getColumn(7).setMaxWidth(0); - tablemyImages.getColumnModel().getColumn(9).setWidth(0); - tablemyImages.getColumnModel().getColumn(9).setMinWidth(0); - tablemyImages.getColumnModel().getColumn(9).setMaxWidth(0); - - tablemyImages.getTableHeader().setReorderingAllowed(false); - tablemyImages.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); - textFieldName.requestFocusInWindow(); + public void internalFrameActivated(InternalFrameEvent arg0) { + initTableModel(modelMyImages); + + // auszublendende Angaben + // 1=Lizenzpflichtig + // 3=Veranstaltung + // 6=ID + // 7=Version + // 8=Template + // 9=Beschreibung (needed for full text search) + tablemyImages.getColumnModel().getColumn(1).setWidth(0); + tablemyImages.getColumnModel().getColumn(1).setMinWidth(0); + tablemyImages.getColumnModel().getColumn(1).setMaxWidth(0); + tablemyImages.getColumnModel().getColumn(3).setWidth(0); + tablemyImages.getColumnModel().getColumn(3).setMinWidth(0); + tablemyImages.getColumnModel().getColumn(3).setMaxWidth(0); + tablemyImages.getColumnModel().getColumn(8).setWidth(0); + tablemyImages.getColumnModel().getColumn(8).setMinWidth(0); + tablemyImages.getColumnModel().getColumn(8).setMaxWidth(0); + tablemyImages.getColumnModel().getColumn(6).setWidth(0); + tablemyImages.getColumnModel().getColumn(6).setMinWidth(0); + tablemyImages.getColumnModel().getColumn(6).setMaxWidth(0); + tablemyImages.getColumnModel().getColumn(7).setWidth(0); + tablemyImages.getColumnModel().getColumn(7).setMinWidth(0); + tablemyImages.getColumnModel().getColumn(7).setMaxWidth(0); + tablemyImages.getColumnModel().getColumn(9).setWidth(0); + tablemyImages.getColumnModel().getColumn(9).setMinWidth(0); + tablemyImages.getColumnModel().getColumn(9).setMaxWidth(0); + + tablemyImages.getTableHeader().setReorderingAllowed(false); + tablemyImages.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); + textFieldName.requestFocusInWindow(); } }); + // Verhindert das Vergroessern Des Fensters setResizable(false); @@ -203,7 +184,7 @@ public class SearchEditImage_GUI extends JFrame { setTitle("bwLehrpool Suite - Image bearbeiten - "+person.verantwortlicher.getUserID()); // Zentriert das Fenster in die Bildmitte setBounds(0, 0, 918, 722); - setLocationRelativeTo(formerGUI); + //final DefaultTableModel model = new DefaultTableModel(titles, 0); @@ -355,10 +336,8 @@ public class SearchEditImage_GUI extends JFrame { @Override public void mouseClicked(MouseEvent arg0) { // oeffnet das Hauuetmenue - - SearchEditImage_GUI.this.setVisible(false); - MainMenue_GUI main = new MainMenue_GUI(c); - main.setVisible(true); + GuiManager.show(new MainMenue_GUI()); + } }); lblHauptmen.setForeground(Color.BLUE); @@ -402,9 +381,7 @@ public class SearchEditImage_GUI extends JFrame { Image.image.setVersion(imageversion); - FTPEditDownloader_GUI ea = new FTPEditDownloader_GUI(c); - ea.setVisible(true); - dispose(); + GuiManager.show(new FTPEditDownloader_GUI()); } else { JOptionPane.showMessageDialog(c, @@ -483,10 +460,7 @@ public class SearchEditImage_GUI extends JFrame { okButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { // oeffnet das Hauptmenue - - MainMenue_GUI main = new MainMenue_GUI(c); - main.setVisible(true); - dispose(); + GuiManager.show(new MainMenue_GUI()); } }); okButton.setActionCommand("OK"); @@ -518,11 +492,7 @@ public class SearchEditImage_GUI extends JFrame { 7).toString(); Image.image.setVersion(imageversion); - - EditImageAllgemein_GUI ea = new EditImageAllgemein_GUI( - c); - ea.setVisible(true); - dispose(); + GuiManager.show(new EditImageAllgemein_GUI()); } }// end actionPerformed @@ -665,70 +635,6 @@ public class SearchEditImage_GUI extends JFrame { textAreadesc.setFont(new Font("Tahoma", Font.PLAIN, 11)); textAreadesc.setBackground(SystemColor.menu); scrollPane.setViewportView(textAreadesc); - JMenuBar menuBar = new JMenuBar(); - setJMenuBar(menuBar); - - JMenu mnNewMenu_1 = new JMenu("Hilfe"); - menuBar.add(mnNewMenu_1); - - JMenuItem mntmFaq = new JMenuItem("FAQ"); - mntmFaq.addMouseListener(new MouseAdapter() { - @Override - public void mousePressed(MouseEvent arg0) { - - URI windows; - try { - windows = new URI(Links.getFAQ()); - - OpenLinks.openWebpage(windows); - - } catch (URISyntaxException e) { - e.printStackTrace(); - } - } - }); - mnNewMenu_1.add(mntmFaq); - - JMenuItem mntmOtrs = new JMenuItem("OTRS"); - mntmOtrs.addMouseListener(new MouseAdapter() { - @Override - public void mousePressed(MouseEvent arg0) { - - URI windows; - try { - windows = new URI(Links.getOTRS()); - - OpenLinks.openWebpage(windows); - - } catch (URISyntaxException e) { - e.printStackTrace(); - } - - } - }); - mnNewMenu_1.add(mntmOtrs); - - JMenuItem mntmAbout = new JMenuItem("About"); - mntmAbout.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - About_GUI ab = new About_GUI(); - ab.setVisible(true); - } - }); - mnNewMenu_1.add(mntmAbout); - - JMenu mnNewMenu_Info = new JMenu("Info"); - mnNewMenu_Info.addMouseListener(new MouseAdapter() { - @Override - public void mouseClicked(MouseEvent arg0) { - JOptionPane.showMessageDialog(c, HELP_MESSAGE, - "Hilfe zu dieser Oberfläche", - JOptionPane.INFORMATION_MESSAGE); - } - }); - menuBar.add(mnNewMenu_Info); - - c = this; } diff --git a/dozentenmodul/src/main/java/gui/image/SearchImage_GUI.java b/dozentenmodul/src/main/java/gui/image/SearchImage_GUI.java index 78b21987..2c2a349a 100644 --- a/dozentenmodul/src/main/java/gui/image/SearchImage_GUI.java +++ b/dozentenmodul/src/main/java/gui/image/SearchImage_GUI.java @@ -1,6 +1,5 @@ package gui.image;
-import gui.intro.About_GUI;
import gui.intro.MainMenue_GUI;
import java.awt.Color;
@@ -14,10 +13,6 @@ import java.awt.event.KeyAdapter; import java.awt.event.KeyEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
-import java.awt.event.WindowAdapter;
-import java.awt.event.WindowEvent;
-import java.net.URI;
-import java.net.URISyntaxException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
@@ -27,11 +22,8 @@ import java.util.Map; import javax.swing.JButton;
import javax.swing.JComboBox;
-import javax.swing.JFrame;
+import javax.swing.JInternalFrame;
import javax.swing.JLabel;
-import javax.swing.JMenu;
-import javax.swing.JMenuBar;
-import javax.swing.JMenuItem;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
@@ -48,6 +40,8 @@ import javax.swing.UIManager; import javax.swing.UnsupportedLookAndFeelException;
import javax.swing.border.EmptyBorder;
import javax.swing.border.TitledBorder;
+import javax.swing.event.InternalFrameAdapter;
+import javax.swing.event.InternalFrameEvent;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import javax.swing.table.DefaultTableModel;
@@ -55,17 +49,16 @@ import javax.swing.table.TableModel; import javax.swing.table.TableRowSorter;
import models.Image;
-import models.Links;
import models.SessionData;
import models.person;
import org.apache.thrift.TException;
import thrift.ThriftManager;
-import util.OpenLinks;
+import util.GuiManager;
@SuppressWarnings("serial")
-public class SearchImage_GUI extends JFrame {
+public class SearchImage_GUI extends JInternalFrame {
private final JPanel contentPanel = new JPanel();
JLabel labelName;
@@ -107,7 +100,7 @@ public class SearchImage_GUI extends JFrame { // Letztes
// Update
// (5)
- private static final String HELP_MESSAGE = "<html><div align=\"center\">" +
+ public static final String HELP_MESSAGE = "<html><div align=\"center\">" +
"Suchen Sie Images und laden Sie sie direkt herunter.<br />" +
"Sie können die Volltextsuche nutzen und nach Betriebssystemen filtern.<br />" +
"Die Volltextsuche sucht in den Feldern Name und Beschreibung." +
@@ -157,23 +150,11 @@ public class SearchImage_GUI extends JFrame { /**
* Create the dialog.
*/
- public SearchImage_GUI(Component formerGUI) { + public SearchImage_GUI() { - addWindowListener(new WindowAdapter() {
+ addInternalFrameListener(new InternalFrameAdapter() {
@Override
- public void windowClosing(WindowEvent arg0) {
- // Beendet die Anwendung nach klick auf X
- try {
- ThriftManager.getSatClient().setSessionInvalid(SessionData.session.getAuthToken());
- } catch (TException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- System.exit(0);
- }
-
- @Override
- public void windowOpened(WindowEvent arg0) {
+ public void internalFrameActivated(InternalFrameEvent arg0) {
initTableModelAll(modelAll);
initTableModel(modelMyImages);
initTableModelTemplates(modelPublicVorlagen);
@@ -280,6 +261,7 @@ public class SearchImage_GUI extends JFrame { textFieldName.requestFocusInWindow();
}
});
+
// Verhindert das Vergroessern Des Fensters
setResizable(false);
@@ -295,7 +277,6 @@ public class SearchImage_GUI extends JFrame { setTitle("bwLehrpool Suite - Image suchen - "+person.verantwortlicher.getUserID());
// Zentriert das Fenster in die Bildmitte
setBounds(0, 0, 918, 722);
- setLocationRelativeTo(formerGUI);
final DefaultTableModel model = new DefaultTableModel(titles, 0);
@@ -464,10 +445,7 @@ public class SearchImage_GUI extends JFrame { @Override
public void mouseClicked(MouseEvent arg0) {
// oeffnet das Hauptmenue
-
- SearchImage_GUI.this.setVisible(false);
- MainMenue_GUI main = new MainMenue_GUI(c);
- main.setVisible(true);
+ GuiManager.show(new MainMenue_GUI());
}
});
lblHauptmen.setForeground(Color.BLUE);
@@ -645,9 +623,7 @@ public class SearchImage_GUI extends JFrame { .toString();
Image.image.setVersion(imageversion);
- SearchImage_GUI.this.setVisible(false);
- FTPSearchDownloader_GUI down = new FTPSearchDownloader_GUI(c);
- down.setVisible(true);
+ GuiManager.show(new FTPSearchDownloader_GUI());
}
} else if (tabbedPane.getSelectedIndex() == 1) {
@@ -679,10 +655,7 @@ public class SearchImage_GUI extends JFrame { .toString();
Image.image.setVersion(imageversion);
-
- SearchImage_GUI.this.setVisible(false);
- FTPSearchDownloader_GUI down = new FTPSearchDownloader_GUI(c);
- down.setVisible(true);
+ GuiManager.show(new FTPSearchDownloader_GUI());
}
} else if (tabbedPane.getSelectedIndex() == 2) {
//
@@ -724,9 +697,7 @@ public class SearchImage_GUI extends JFrame { Image.image.setVersion(imageversion);
- SearchImage_GUI.this.setVisible(false);
- FTPSearchDownloader_GUI down = new FTPSearchDownloader_GUI(c);
- down.setVisible(true);
+ GuiManager.show(new FTPSearchDownloader_GUI());
} else {
JOptionPane
.showMessageDialog(
@@ -765,10 +736,7 @@ public class SearchImage_GUI extends JFrame { okButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
// oeffnet das Hauptmenue
-
- MainMenue_GUI main = new MainMenue_GUI(c);
- main.setVisible(true);
- dispose();
+ GuiManager.show(new MainMenue_GUI());
}
});
okButton.setActionCommand("OK");
@@ -909,70 +877,6 @@ public class SearchImage_GUI extends JFrame { textAreadesc.setLineWrap(true);
textAreadesc.setBackground(SystemColor.menu);
scrollPane.setViewportView(textAreadesc);
- JMenuBar menuBar = new JMenuBar();
- setJMenuBar(menuBar);
-
- JMenu mnNewMenu_1 = new JMenu("Hilfe");
- menuBar.add(mnNewMenu_1);
-
- JMenuItem mntmFaq = new JMenuItem("FAQ");
- mntmFaq.addMouseListener(new MouseAdapter() {
- @Override
- public void mousePressed(MouseEvent arg0) {
-
- URI windows;
- try {
- windows = new URI(Links.getFAQ());
-
- OpenLinks.openWebpage(windows);
-
- } catch (URISyntaxException e) {
-
- e.printStackTrace();
- }
- }
- });
- mnNewMenu_1.add(mntmFaq);
-
- JMenuItem mntmOtrs = new JMenuItem("OTRS");
- mntmOtrs.addMouseListener(new MouseAdapter() {
- @Override
- public void mousePressed(MouseEvent arg0) {
-
- URI windows;
- try {
- windows = new URI(Links.getOTRS());
-
- OpenLinks.openWebpage(windows);
-
- } catch (URISyntaxException e) {
-
- e.printStackTrace();
- }
-
- }
- });
- mnNewMenu_1.add(mntmOtrs);
-
- JMenuItem mntmAbout = new JMenuItem("About");
- mntmAbout.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- About_GUI ab = new About_GUI();
- ab.setVisible(true);
- }
- });
- mnNewMenu_1.add(mntmAbout);
-
- JMenu mnNewMenu_Info = new JMenu("Info");
- mnNewMenu_Info.addMouseListener(new MouseAdapter() {
- @Override
- public void mouseClicked(MouseEvent arg0) {
- JOptionPane.showMessageDialog(c, HELP_MESSAGE, "Hilfe zu dieser Oberfläche", JOptionPane.INFORMATION_MESSAGE);
- }
- });
- menuBar.add(mnNewMenu_Info);
-
- c = this;
}
diff --git a/dozentenmodul/src/main/java/gui/intro/About_GUI.java b/dozentenmodul/src/main/java/gui/intro/About_GUI.java index 5d0c847d..6914ffa3 100644 --- a/dozentenmodul/src/main/java/gui/intro/About_GUI.java +++ b/dozentenmodul/src/main/java/gui/intro/About_GUI.java @@ -16,7 +16,7 @@ import javax.swing.UIManager; import javax.swing.UnsupportedLookAndFeelException; import javax.swing.border.EmptyBorder; -import util.GuiOrganizer; +import util.GuiManager; import util.ResourceLoader; @SuppressWarnings("serial") @@ -49,7 +49,6 @@ public class About_GUI extends JFrame { setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); // Groesse des Fensters definieren setBounds(0, 0, 355, 309); - GuiOrganizer.centerGUI(this); // Erzeugen eines Panels contentPane = new JPanel(); // Hintergrund Farbe des Panels setzen diff --git a/dozentenmodul/src/main/java/gui/intro/BillOfRights_GUI.java b/dozentenmodul/src/main/java/gui/intro/BillOfRights_GUI.java index 71e31d52..c136e743 100644 --- a/dozentenmodul/src/main/java/gui/intro/BillOfRights_GUI.java +++ b/dozentenmodul/src/main/java/gui/intro/BillOfRights_GUI.java @@ -8,14 +8,10 @@ import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; -import java.awt.event.WindowAdapter; -import java.awt.event.WindowEvent; -import java.net.URI; -import java.net.URISyntaxException; import javax.swing.JButton; import javax.swing.JCheckBox; -import javax.swing.JFrame; +import javax.swing.JInternalFrame; import javax.swing.JLabel; import javax.swing.JMenu; import javax.swing.JMenuBar; @@ -32,15 +28,14 @@ import javax.swing.border.EmptyBorder; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; -import models.Links; -import util.GuiOrganizer; +import util.GuiManager; import util.OpenLinks; import config.Config; @SuppressWarnings("serial") -public class BillOfRights_GUI extends JFrame { +public class BillOfRights_GUI extends JInternalFrame { private final JPanel contentPanel = new JPanel(); String[] result; @@ -53,13 +48,6 @@ public class BillOfRights_GUI extends JFrame { public BillOfRights_GUI() { setResizable(false); - addWindowListener(new WindowAdapter() { - @Override - public void windowClosing(WindowEvent arg0) { - //Beendet das Programm beim Klick auf das X - System.exit(0); - } - }); try { //Setzt das Look & Feel auf das System UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); @@ -73,7 +61,6 @@ public class BillOfRights_GUI extends JFrame { //Zentiert das Fenster in der Bildschirmmitte setBounds(0, 0, 603, 722); - GuiOrganizer.centerGUI(this); getContentPane().setLayout(null); { @@ -124,9 +111,7 @@ public class BillOfRights_GUI extends JFrame { public void actionPerformed(ActionEvent e) { Config.setBillOfRights(true); Config.store(); - VmWareLink_GUI ac=new VmWareLink_GUI(); - ac.setVisible(true); - dispose(); + GuiManager.show(new VmWareLink_GUI()); } }); fwdButton.setEnabled(false); @@ -162,51 +147,6 @@ public class BillOfRights_GUI extends JFrame { chckbxAkzeptieren.setBackground(SystemColor.menu); chckbxAkzeptieren.setBounds(10, 587, 567, 23); getContentPane().add(chckbxAkzeptieren); - - JMenuBar menuBar = new JMenuBar(); - setJMenuBar(menuBar); - - JMenu mnNewMenu_1 = new JMenu("Hilfe"); - mnNewMenu_1.setHorizontalAlignment(SwingConstants.CENTER); - menuBar.add(mnNewMenu_1); - - JMenuItem mntmFaq = new JMenuItem("FAQ"); - mntmFaq.addMouseListener(new MouseAdapter() { - @Override - public void mousePressed(MouseEvent arg0) { - URI windows; - try { - windows = new URI(Links.getFAQ()); - - OpenLinks.openWebpage(windows); - - } catch (URISyntaxException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - }); - mnNewMenu_1.add(mntmFaq); - - - JMenuItem mntmOtrs = new JMenuItem("OTRS"); - mntmOtrs.addMouseListener(new MouseAdapter() { - @Override - public void mousePressed(MouseEvent arg0) { - URI windows; - try { - windows = new URI(Links.getOTRS()); - - OpenLinks.openWebpage(windows); - - } catch (URISyntaxException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - - } - }); - mnNewMenu_1.add(mntmOtrs); } } diff --git a/dozentenmodul/src/main/java/gui/intro/Login_GUI.java b/dozentenmodul/src/main/java/gui/intro/Login_GUI.java index 16854c0f..02660011 100644 --- a/dozentenmodul/src/main/java/gui/intro/Login_GUI.java +++ b/dozentenmodul/src/main/java/gui/intro/Login_GUI.java @@ -6,8 +6,6 @@ import java.awt.Image; import java.awt.SystemColor; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; -import java.awt.event.WindowAdapter; -import java.awt.event.WindowEvent; import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; @@ -22,6 +20,7 @@ import javax.swing.JButton; import javax.swing.JCheckBox; import javax.swing.JComboBox; import javax.swing.JFrame; +import javax.swing.JInternalFrame; import javax.swing.JLabel; import javax.swing.JList; import javax.swing.JOptionPane; @@ -46,13 +45,13 @@ import org.openslx.imagemaster.thrift.iface.OrganizationData; import org.openslx.imagemaster.thrift.iface.UserInfo; import thrift.ThriftManager; -import util.GuiOrganizer; +import util.GuiManager; import util.ResourceLoader; import util.ShibbolethECP; import config.Config; @SuppressWarnings("serial") -public class Login_GUI extends JFrame { +public class Login_GUI extends JInternalFrame { /** * Logger instance for this class. @@ -72,7 +71,6 @@ public class Login_GUI extends JFrame { boolean isClientReturnedCorrectly = false; JCheckBox chckbxBenutzernameSpeichern; Component c = null; - String[] args = null; private JPanel panel; private JPanel panel_1; @@ -99,18 +97,7 @@ public class Login_GUI extends JFrame { /** * Create the frame. */ - public Login_GUI(String[] args) { - addWindowListener(new WindowAdapter() { - @Override - public void windowClosing(WindowEvent e) { - - System.exit(0); - } - }); - - this.args = args; - // Fenster darf nicht vergroessert werden - setResizable(false); + public Login_GUI() { try { // Setzt das Look and Feel auf System @@ -122,8 +109,6 @@ public class Login_GUI extends JFrame { } // Titel des Fensters setzen setTitle("bwLehrpool Suite"); - // Aktion die beim Schliessen durchgefuehrt werden soll - setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // Größe setzen und mittig ausrichten setBounds(0, 0, 785, 430); @@ -282,9 +267,6 @@ public class Login_GUI extends JFrame { panel.setVisible(true); panel_1.setVisible(true); contentPane.setVisible(true); - - GuiOrganizer.centerGUI(this); - c = this; }// end LoginGUI() @@ -341,9 +323,14 @@ public class Login_GUI extends JFrame { // set Information SessionData.session.setAuthToken(result.authToken); SessionData.session.setSessionID(result.sessionId); - // TODO: support list of adresses SessionData.session.setServerAdress(result.serverAddress); - ThriftManager.setSatellite(result.serverAddress); + if (!ThriftManager.setSatellite(result.serverAddress)) { + LOGGER.error("Setting satellite IP to '" + result.serverAddress + + "' failed. Appears to be empty. Is the satellite IP returned from masterserver correct?"); + setStatus(Color.green, "IP von Satelliten invalid.", null); + System.exit(1); + // TODO handle this correctly + } // Satellite-Connection setStatus(Color.black, "Hole Verbindungsdaten von Server...", null); @@ -367,8 +354,7 @@ public class Login_GUI extends JFrame { person.verantwortlicher.setRole("Dozent"); //person.verantwortlicher.setRole("Student"); } - - showMainMenu(); + postLogin(); //} } // end bwLehrpool-Login @@ -389,10 +375,27 @@ public class Login_GUI extends JFrame { switch(ecpReturn) { case NO_ERROR: setStatus(Color.green, "Info: bwIDM-Anmeldung erfolgreich.", null); - JOptionPane.showMessageDialog(c, "Der Shibboleth-Login war erfolgreich und das Holen der Resource hat geklappt! Der Rest ist noch in Entwicklung :)", - "Anmeldung erfolgreich", JOptionPane.PLAIN_MESSAGE); - // all done, show main menu - showMainMenu(); + /* + * Login successful + */ + person.verantwortlicher.setUsername(lblusername.getText().trim()); + person.verantwortlicher.setUserID(lblusername.getText().trim()); + person.verantwortlicher.setName(ShibbolethECP.getResponse().lastName); + person.verantwortlicher.setVorname(ShibbolethECP.getResponse().firstName); + person.verantwortlicher.setEMail(ShibbolethECP.getResponse().mail); + person.verantwortlicher.setHochschule(((OrganizationData)idpChoice.getSelectedItem()).getOrganizationId()); + person.verantwortlicher.setRole("Dozent"); + authToken = ShibbolethECP.getResponse().token; + ThriftManager.setSatellite(ShibbolethECP.getResponse().satellites.get("default")); + SessionData.session.setServerAdress(ShibbolethECP.getResponse().satellites.get("default")); + SessionData.session.setAuthToken(ShibbolethECP.getResponse().token); + SessionData.session.setSessionID(ShibbolethECP.getResponse().sessionId); + + /* + * Now postprocess successful login + */ + postLogin(); + //showMainMenu(); break; case ERROR_IDP: setStatus(Color.red, "Fehler: bwIDM-Anmeldung fehlgeschlagen!", null); @@ -430,18 +433,6 @@ public class Login_GUI extends JFrame { } }; worker.execute(); - - // now we fake the user information for testing purposes. - // TODO parse the response from the SP and set the correct user info - person.verantwortlicher.setUsername(lblusername.getText().trim()); - person.verantwortlicher.setUserID(lblusername.getText().trim()); - person.verantwortlicher.setName("Joe"); - person.verantwortlicher.setVorname("B"); - person.verantwortlicher.setEMail("spam@aol.com"); - person.verantwortlicher.setHochschule("fr-test.de"); - person.verantwortlicher.setRole("Dozent"); - SessionData.session.setServerAdress("132.230.8.199"); - } // always save to user's config file. @@ -459,16 +450,15 @@ public class Login_GUI extends JFrame { }// end performLogin /** - * Shows the next GUI's til the main menu. - * It checks if the user has already seen the bill of rights - * and/or the vmware license windows and shows them before - * continuing to the main menu. - * - * This function should be called on a successful login. + * Common function for either authentication method */ - private void showMainMenu() { + private void postLogin() { + LOGGER.debug("Post-processing login ..."); + // TODO here do all the session data stuff + // TODO and the telling the sat Server who we are + LOGGER.debug("Checking token: " + SessionData.session.getAuthToken()); try { - boolean authenticated = ThriftManager.getSatClient().authenticated(authToken); + boolean authenticated = ThriftManager.getSatClient().authenticated(SessionData.session.getAuthToken()); if(!authenticated) { //TODO message for user and deactivation of menu points, actually just system exit System.exit(0); @@ -484,28 +474,33 @@ public class Login_GUI extends JFrame { // TODO Auto-generated catch block e.printStackTrace(); } - - // Pruefe ob Bills Of Rights schon akzeptiert wurden, - // wenn nicht zeige diese an + // at the end + showMainMenu(); + } + /** + * Shows the next GUI's til the main menu. + * It checks if the user has already seen the bill of rights + * and/or the vmware license windows and shows them before + * continuing to the main menu. + * + * This function should be called on a successful login. + */ + private void showMainMenu() { + /** + * + * DISPLAY LICENSES / MAIN MENU + * + */ if (!Config.getBillOfRights()) { - // Erstellen einer Instanz der Aktionsauswahl - BillOfRights_GUI re = new BillOfRights_GUI(); - re.setVisible(true); - // Schliessen des Fensters nach erfolgreichen Login - setVisible(false); + // display bill of rights? + GuiManager.show(new BillOfRights_GUI(), true); } else { - // Pruefe ob die Links zu vmware angezeigt werden - // sollen + // display vmware license? if (!Config.getVmwareLicense()) { - VmWareLink_GUI vm = new VmWareLink_GUI(); - vm.setVisible(true); - setVisible(false); + GuiManager.show(new VmWareLink_GUI(), true); } else { - - // oeffne das Hauptmenue - MainMenue_GUI main = new MainMenue_GUI(c); - main.setVisible(true); - setVisible(false); + // main menu + GuiManager.show(new MainMenue_GUI(), true); } } } diff --git a/dozentenmodul/src/main/java/gui/intro/MainMenue_GUI.java b/dozentenmodul/src/main/java/gui/intro/MainMenue_GUI.java index c3bb41ef..42272091 100644 --- a/dozentenmodul/src/main/java/gui/intro/MainMenue_GUI.java +++ b/dozentenmodul/src/main/java/gui/intro/MainMenue_GUI.java @@ -16,20 +16,11 @@ import java.awt.ScrollPane; import java.awt.SystemColor; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; -import java.awt.event.WindowAdapter; -import java.awt.event.WindowEvent; -import java.net.URI; -import java.net.URISyntaxException; import javax.swing.ButtonGroup; import javax.swing.JButton; -import javax.swing.JFrame; +import javax.swing.JInternalFrame; import javax.swing.JLabel; -import javax.swing.JMenu; -import javax.swing.JMenuBar; -import javax.swing.JMenuItem; import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JRadioButton; @@ -47,21 +38,18 @@ import models.GUIRights; import models.Image; import models.ImageRights; import models.ItemOwner; -import models.Links; import models.RightsManagement; import models.SessionData; import models.person; import org.apache.log4j.Logger; -import org.apache.thrift.TException; -import thrift.ThriftManager; +import util.GuiManager; import util.News; -import util.OpenLinks; import util.ResourceLoader; @SuppressWarnings("serial") -public class MainMenue_GUI extends JFrame { +public class MainMenue_GUI extends JInternalFrame { private final static Logger LOGGER = Logger.getLogger(MainMenue_GUI.class); @@ -79,7 +67,6 @@ public class MainMenue_GUI extends JFrame { JRadioButton rdbtnLectureDelete; JRadioButton rdbtnLectureSearch; private final ButtonGroup buttonGroup = new ButtonGroup(); - private JMenuItem mntmAbout; Component c = null; // for testing @@ -88,25 +75,8 @@ public class MainMenue_GUI extends JFrame { boolean tokenDeleted; - public MainMenue_GUI(Component formerGUI) { - - addWindowListener(new WindowAdapter() { - @Override - public void windowClosing(WindowEvent arg0) { - try { - tokenDeleted = ThriftManager.getSatClient().setSessionInvalid(SessionData.session.getAuthToken()); - } catch (TException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - if(tokenDeleted) - { - System.out.println("test"); - System.exit(0); - } - - } - }); + public MainMenue_GUI() { + try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (ClassNotFoundException | InstantiationException @@ -116,8 +86,8 @@ public class MainMenue_GUI extends JFrame { } setTitle("bwLehrpool Suite - Connected Server: " + SessionData.session.getServerAdress()+" - "+person.verantwortlicher.getUserID()); + setBounds(0, 0, 603, 722); - this.setLocationRelativeTo(formerGUI); getContentPane().setLayout(null); { @@ -142,15 +112,11 @@ public class MainMenue_GUI extends JFrame { panel.add(txtpnBitteWhlenSie); } - - //reset the list of permissions and models //every time the user goes back to the main menu RightsManagement.rightsManagement.getPermittedUserList().clear(); Image.image.reset(); ItemOwner.itemOwner.reset(); - - setResizable(false); // window is not resizable @@ -399,40 +365,22 @@ public class MainMenue_GUI extends JFrame { // Images if (rdbtnImageNew.isSelected() == true) { - CreateImageAllgemein_GUI sr = new CreateImageAllgemein_GUI(c); - sr.setVisible(true); - dispose(); + GuiManager.show(new CreateImageAllgemein_GUI()); } else if (rdbtnImageEdit.isSelected() == true) { - SearchEditImage_GUI si = new SearchEditImage_GUI(c); - si.setVisible(true); - dispose(); + GuiManager.show(new SearchEditImage_GUI()); } else if (rdbtnImageDelete.isSelected() == true) { - DeleteImage_GUI di = new DeleteImage_GUI(c); - di.setVisible(true); - dispose(); + GuiManager.show(new DeleteImage_GUI()); } else if (rdbtnImageSearchDownload.isSelected() == true) { - // SearchMethodLecture_GUI sm = new - // SearchMethodLecture_GUI(); - SearchImage_GUI si = new SearchImage_GUI(c); - si.setVisible(true); - dispose(); + GuiManager.show(new SearchImage_GUI()); // Lectures } else if (rdbtnLectureNew.isSelected() == true) { - CreateLectureAllgemein_GUI av = new CreateLectureAllgemein_GUI(c); - av.setVisible(true); - dispose(); + GuiManager.show(new CreateLectureAllgemein_GUI()); } else if (rdbtnLectureEdit.isSelected() == true) { - EditLectureSearch_GUI el = new EditLectureSearch_GUI(c); - el.setVisible(true); - dispose(); + GuiManager.show(new EditLectureSearch_GUI()); } else if (rdbtnLectureDelete.isSelected() == true) { - DeleteLecture_GUI dl = new DeleteLecture_GUI(c); - dl.setVisible(true); - dispose(); + GuiManager.show(new DeleteLecture_GUI()); } else if (rdbtnLectureSearch.isSelected() == true) { - SearchLecture_GUI sl = new SearchLecture_GUI(c); - sl.setVisible(true); - dispose(); + GuiManager.show(new SearchLecture_GUI()); } else JOptionPane.showMessageDialog(c, "Keine Auswahl getroffen.", @@ -454,64 +402,7 @@ public class MainMenue_GUI extends JFrame { separator.setBounds(0, 91, 587, 2); getContentPane().add(separator); } - - JMenuBar menuBar = new JMenuBar(); - setJMenuBar(menuBar); - - JMenu mnNewMenu_1 = new JMenu("Hilfe"); - menuBar.add(mnNewMenu_1); - - - - JMenuItem mntmFaq = new JMenuItem("FAQ"); - mntmFaq.addMouseListener(new MouseAdapter() { - @Override - public void mousePressed(MouseEvent arg0) { - URI windows; - try { - windows = new URI(Links.getFAQ()); - OpenLinks.openWebpage(windows); - } catch (URISyntaxException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - }); - mnNewMenu_1.add(mntmFaq); - - JMenuItem mntmOtrs = new JMenuItem("OTRS"); - mntmOtrs.addMouseListener(new MouseAdapter() { - @Override - public void mousePressed(MouseEvent arg0) { - URI windows; - try { - windows = new URI(Links.getOTRS()); - OpenLinks.openWebpage(windows); - } catch (URISyntaxException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - }); - mnNewMenu_1.add(mntmOtrs); - - mntmAbout = new JMenuItem("About"); - mntmAbout.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent arg0) { - About_GUI ab = new About_GUI(); - ab.setVisible(true); - } - }); - mnNewMenu_1.add(mntmAbout); - - - - c = this; }// end main - - - - /** * Enables/disables radio button given the user's rights diff --git a/dozentenmodul/src/main/java/gui/intro/VmWareLink_GUI.java b/dozentenmodul/src/main/java/gui/intro/VmWareLink_GUI.java index 71715d24..8445af0d 100644 --- a/dozentenmodul/src/main/java/gui/intro/VmWareLink_GUI.java +++ b/dozentenmodul/src/main/java/gui/intro/VmWareLink_GUI.java @@ -10,14 +10,10 @@ import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; -import java.awt.event.WindowAdapter; -import java.awt.event.WindowEvent; -import java.net.URI; -import java.net.URISyntaxException; import javax.swing.JButton; import javax.swing.JCheckBox; -import javax.swing.JFrame; +import javax.swing.JInternalFrame; import javax.swing.JLabel; import javax.swing.JMenu; import javax.swing.JMenuBar; @@ -31,14 +27,13 @@ import javax.swing.border.EmptyBorder; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; -import models.Links; -import util.GuiOrganizer; +import util.GuiManager; import util.OpenLinks; import config.Config; @SuppressWarnings("serial") -public class VmWareLink_GUI extends JFrame { +public class VmWareLink_GUI extends JInternalFrame { private final JPanel contentPanel = new JPanel(); String[] result; @@ -50,12 +45,6 @@ public class VmWareLink_GUI extends JFrame { * Create the dialog. */ public VmWareLink_GUI() { - addWindowListener(new WindowAdapter() { - @Override - public void windowClosing(WindowEvent e) { - System.exit(0); - } - }); try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (ClassNotFoundException | InstantiationException @@ -65,7 +54,7 @@ public class VmWareLink_GUI extends JFrame { } setTitle("bwLehrpool Suite"); setBounds(0, 0, 603, 722); - GuiOrganizer.centerGUI(this); + getContentPane().setLayout(null); { @@ -122,15 +111,7 @@ public class VmWareLink_GUI extends JFrame { btnWindows = new JButton("VMware Player herunterladen"); btnWindows.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { - try { - URI windows= new URI(Links.getUriWindows()); - - OpenLinks.openWebpage(windows); - - } catch (URISyntaxException e) { - - e.printStackTrace(); - } + OpenLinks.openWebpage("vmware"); } }); @@ -140,15 +121,7 @@ public class VmWareLink_GUI extends JFrame { JButton btnLinux = new JButton("VMware Player herunterladen"); btnLinux.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { - try { - URI linux= new URI(Links.getUriLinux()); - - OpenLinks.openWebpage(linux); - - } catch (URISyntaxException f) { - - f.printStackTrace(); - } + OpenLinks.openWebpage("vmware"); } }); btnLinux.setBounds(10, 203, 186, 23); @@ -158,14 +131,7 @@ public class VmWareLink_GUI extends JFrame { label.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { - URI anleitung; - try { - anleitung = new URI(Links.getAnleitungVMDK()); - OpenLinks.openWebpage(anleitung); - } catch (URISyntaxException e1) { - - e1.printStackTrace(); - } + OpenLinks.openWebpage("intro"); } }); @@ -182,9 +148,7 @@ public class VmWareLink_GUI extends JFrame { JButton cancelButton = new JButton("Weiter"); cancelButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { - MainMenue_GUI ea=new MainMenue_GUI(c); - ea.setVisible(true); - dispose(); + GuiManager.show(new MainMenue_GUI()); } }); cancelButton.setActionCommand("Cancel"); @@ -201,58 +165,7 @@ public class VmWareLink_GUI extends JFrame { separator.setBounds(0, 91, 587, 2); getContentPane().add(separator); } - { - JMenuBar menuBar = new JMenuBar(); - setJMenuBar(menuBar); - { - JMenu mnHilfe = new JMenu("Hilfe"); - menuBar.add(mnHilfe); - { - JMenuItem mntmFaq = new JMenuItem("FAQ"); - mntmFaq.addMouseListener(new MouseAdapter() { - @Override - public void mousePressed(MouseEvent arg0) { - URI windows; - try { - windows = new URI(Links.getFAQ()); - - OpenLinks.openWebpage(windows); - - } catch (URISyntaxException e) { - - e.printStackTrace(); - } - - } - }); - - mnHilfe.add(mntmFaq); - } - { - JMenuItem mntmOTRS = new JMenuItem("OTRS"); - mntmOTRS.addMouseListener(new MouseAdapter() { - @Override - public void mousePressed(MouseEvent arg0) { - URI windows; - try { - windows = new URI(Links.getOTRS()); - - OpenLinks.openWebpage(windows); - - } catch (URISyntaxException e) { - - e.printStackTrace(); - } - - } - }); - mnHilfe.add(mntmOTRS); - } - } - } - - c = this; }//end constructor }// end class diff --git a/dozentenmodul/src/main/java/gui/lecture/CreateLectureAllgemein_GUI.java b/dozentenmodul/src/main/java/gui/lecture/CreateLectureAllgemein_GUI.java index 1bac4642..89dff1a9 100644 --- a/dozentenmodul/src/main/java/gui/lecture/CreateLectureAllgemein_GUI.java +++ b/dozentenmodul/src/main/java/gui/lecture/CreateLectureAllgemein_GUI.java @@ -1,6 +1,5 @@ package gui.lecture; -import gui.intro.About_GUI; import gui.intro.MainMenue_GUI; import java.awt.Color; @@ -13,21 +12,14 @@ import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; -import java.awt.event.WindowAdapter; -import java.awt.event.WindowEvent; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; -import java.net.URI; -import java.net.URISyntaxException; import java.util.Calendar; import java.util.Date; import javax.swing.JButton; -import javax.swing.JFrame; +import javax.swing.JInternalFrame; import javax.swing.JLabel; -import javax.swing.JMenu; -import javax.swing.JMenuBar; -import javax.swing.JMenuItem; import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JRadioButton; @@ -39,21 +31,17 @@ import javax.swing.UIManager; import javax.swing.UnsupportedLookAndFeelException; import javax.swing.border.EmptyBorder; import javax.swing.border.TitledBorder; +import javax.swing.event.InternalFrameAdapter; +import javax.swing.event.InternalFrameEvent; import models.Lecture; -import models.Links; -import models.SessionData; import models.person; - -import org.apache.thrift.TException; - -import thrift.ThriftManager; -import util.OpenLinks; +import util.GuiManager; import com.toedter.calendar.JDateChooser; @SuppressWarnings("serial") -public class CreateLectureAllgemein_GUI extends JFrame { +public class CreateLectureAllgemein_GUI extends JInternalFrame { private final JPanel contentPanel = new JPanel(); String[] result; @@ -74,7 +62,7 @@ public class CreateLectureAllgemein_GUI extends JFrame { // longer than // MAX_DESCRIPTION_LENGTH private final int MAX_DESCRIPTION_LENGTH = 254; - private static final String HELP_MESSAGE = "<html><div align=\"center\">Geben Sie hier die Daten zu Ihrer Veranstaltung an.<br />" + + public static final String HELP_MESSAGE = "<html><div align=\"center\">Geben Sie hier die Daten zu Ihrer Veranstaltung an.<br />" + "Der Anzeigename ist nachher der Titel im VMChooser, also dort, wo die Studenten das Labor auswählen.<br />" + "Eine Angabe des Namens des Dozenten kann daher hilfreich sein, wenn mehrere ähnliche Veranstaltungen vorliegen.<br />" + "Geben Sie in der Beschreibung kurz an, was in dieser Veranstaltung behandelt wird, evtl. auch mit welcher Software" + @@ -88,24 +76,14 @@ public class CreateLectureAllgemein_GUI extends JFrame { /** * Create the dialog. */ - public CreateLectureAllgemein_GUI(Component formerGUI) { - addWindowListener(new WindowAdapter() { + public CreateLectureAllgemein_GUI() { + addInternalFrameListener(new InternalFrameAdapter() { @Override - public void windowClosing(WindowEvent arg0) { - try { - ThriftManager.getSatClient().setSessionInvalid(SessionData.session.getAuthToken()); - } catch (TException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - System.exit(0); - } - - @Override - public void windowOpened(WindowEvent arg0) { + public void internalFrameActivated(InternalFrameEvent arg0) { txtFldVeranstaltungsname.requestFocusInWindow(); } }); + setResizable(false); try { @@ -117,7 +95,7 @@ public class CreateLectureAllgemein_GUI extends JFrame { } setTitle("bwLehrpool Suite - Veranstaltung erzeugen - "+person.verantwortlicher.getUserID()); setBounds(0, 0, 603, 722); - setLocationRelativeTo(formerGUI); + getContentPane().setLayout(null); { @@ -222,10 +200,7 @@ public class CreateLectureAllgemein_GUI extends JFrame { lblHauptmen.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent arg0) { - - CreateLectureAllgemein_GUI.this.setVisible(false); - MainMenue_GUI main = new MainMenue_GUI(c); - main.setVisible(true); + GuiManager.show(new MainMenue_GUI()); } }); lblHauptmen.setForeground(Color.BLUE); @@ -396,10 +371,7 @@ public class CreateLectureAllgemein_GUI extends JFrame { Lecture.lecture.setDesc(description.getText().trim()); Lecture.lecture.setEnddate(dateChooserend.getDate()); Lecture.lecture.setStartdate(dateChooserstart.getDate()); - - MainMenue_GUI sr = new MainMenue_GUI(c); - sr.setVisible(true); - dispose(); + GuiManager.show(new MainMenue_GUI()); } }); backButton.setActionCommand("Cancel"); @@ -477,9 +449,7 @@ public class CreateLectureAllgemein_GUI extends JFrame { Lecture.lecture.setStartdate(dateChooserstart .getDate()); - PermissionCreateLecture_GUI ev = new PermissionCreateLecture_GUI(c); - ev.setVisible(true); - dispose(); + GuiManager.show(new PermissionCreateLecture_GUI()); } } @@ -501,63 +471,6 @@ public class CreateLectureAllgemein_GUI extends JFrame { lblPflichtfelder.setBounds(32, 602, 136, 14); getContentPane().add(lblPflichtfelder); - JMenuBar menuBar = new JMenuBar(); - setJMenuBar(menuBar); - - JMenu mnNewMenu_1 = new JMenu("Hilfe"); - menuBar.add(mnNewMenu_1); - - JMenuItem mntmFaq = new JMenuItem("FAQ"); - mntmFaq.addMouseListener(new MouseAdapter() { - @Override - public void mousePressed(MouseEvent arg0) { - URI windows; - try { - windows = new URI(Links.getFAQ()); - OpenLinks.openWebpage(windows); - } catch (URISyntaxException e) { - - e.printStackTrace(); - } - } - }); - mnNewMenu_1.add(mntmFaq); - - JMenuItem mntmOtrs = new JMenuItem("OTRS"); - mntmOtrs.addMouseListener(new MouseAdapter() { - @Override - public void mousePressed(MouseEvent arg0) { - URI windows; - try { - windows = new URI(Links.getOTRS()); - OpenLinks.openWebpage(windows); - } catch (URISyntaxException e) { - - e.printStackTrace(); - } - } - }); - mnNewMenu_1.add(mntmOtrs); - - JMenuItem mnmtAbout = new JMenuItem("About"); - mnmtAbout.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - About_GUI ab = new About_GUI(); - ab.setVisible(true); - } - }); - mnNewMenu_1.add(mnmtAbout); - - JMenu mnNewMenu_Info = new JMenu("Info"); - mnNewMenu_Info.addMouseListener(new MouseAdapter() { - @Override - public void mouseClicked(MouseEvent arg0) { - JOptionPane.showMessageDialog(c, HELP_MESSAGE, "Hilfe zu dieser Oberfläche", JOptionPane.INFORMATION_MESSAGE); - } - }); - menuBar.add(mnNewMenu_Info); - - c = this; } public Date addDays(Date date, int days) { diff --git a/dozentenmodul/src/main/java/gui/lecture/CreateLectureLink_GUI.java b/dozentenmodul/src/main/java/gui/lecture/CreateLectureLink_GUI.java index 837b6683..d1c6bed0 100644 --- a/dozentenmodul/src/main/java/gui/lecture/CreateLectureLink_GUI.java +++ b/dozentenmodul/src/main/java/gui/lecture/CreateLectureLink_GUI.java @@ -1,7 +1,6 @@ package gui.lecture; import gui.image.FTPCreateUploader_GUI; -import gui.intro.About_GUI; import gui.intro.MainMenue_GUI; import java.awt.Color; @@ -15,10 +14,6 @@ import java.awt.event.KeyAdapter; import java.awt.event.KeyEvent; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; -import java.awt.event.WindowAdapter; -import java.awt.event.WindowEvent; -import java.net.URI; -import java.net.URISyntaxException; import java.text.DateFormat; import java.text.ParseException; import java.text.SimpleDateFormat; @@ -29,11 +24,8 @@ import java.util.Map; import javax.swing.JButton; import javax.swing.JComboBox; -import javax.swing.JFrame; +import javax.swing.JInternalFrame; import javax.swing.JLabel; -import javax.swing.JMenu; -import javax.swing.JMenuBar; -import javax.swing.JMenuItem; import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JRadioButton; @@ -48,6 +40,8 @@ import javax.swing.UIManager; import javax.swing.UnsupportedLookAndFeelException; import javax.swing.border.EmptyBorder; import javax.swing.border.TitledBorder; +import javax.swing.event.InternalFrameAdapter; +import javax.swing.event.InternalFrameEvent; import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionListener; import javax.swing.table.DefaultTableModel; @@ -55,7 +49,6 @@ import javax.swing.table.TableModel; import javax.swing.table.TableRowSorter; import models.Lecture; -import models.Links; import models.RightsManagement; import models.SessionData; import models.person; @@ -65,10 +58,10 @@ import org.apache.thrift.TException; import org.openslx.sat.thrift.iface.Image; import thrift.ThriftManager; -import util.OpenLinks; +import util.GuiManager; @SuppressWarnings("serial") -public class CreateLectureLink_GUI extends JFrame { +public class CreateLectureLink_GUI extends JInternalFrame { private final static Logger LOGGER = Logger.getLogger(FTPCreateUploader_GUI.class); @@ -100,7 +93,7 @@ public class CreateLectureLink_GUI extends JFrame { String[] titles = { "Image-Name", "Lizenzpflichtig", "OS", "Veranstaltung", "Verantwortlicher", "Letztes Update", "ID", "Version", "Template", "Beschreibung" }; - private static final String HELP_MESSAGE = "<html><div align=\"center\">" + public static final String HELP_MESSAGE = "<html><div align=\"center\">" + "Damit Ihre Veranstaltung geladen werden kann, muss sie mit einem Image verbunden werden.<br />" + "Das Image liegt entweder schon vor, oder Sie haben es im Vorfeld hochgeladen.<br />" + "Wählen Sie das Image aus, das zu Ihrer Veranstaltung passt und klicken Sie anschließend auf \"Veranstaltung erzeugen\"." @@ -129,26 +122,16 @@ public class CreateLectureLink_GUI extends JFrame { /** * Create the dialog. */ - public CreateLectureLink_GUI(Component formerGUI) { + public CreateLectureLink_GUI() { filters.add(RowFilter.regexFilter(".", 0)); rf = RowFilter.orFilter(filters); - addWindowListener(new WindowAdapter() { - @Override - public void windowClosing(WindowEvent arg0) { - try { - ThriftManager.getSatClient().setSessionInvalid(SessionData.session.getAuthToken()); - } catch (TException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - System.exit(0); - } - + + addInternalFrameListener(new InternalFrameAdapter() { @Override - public void windowOpened(WindowEvent arg0) { + public void internalFrameActivated(InternalFrameEvent arg0) { try { initTableModel(modelMyImages); @@ -199,6 +182,7 @@ public class CreateLectureLink_GUI extends JFrame { textFieldName.requestFocusInWindow(); } }); + setResizable(false); try { @@ -210,7 +194,6 @@ public class CreateLectureLink_GUI extends JFrame { } setTitle("bwLehrpool Suite - Veranstaltung erzeugen - "+person.verantwortlicher.getUserID()); setBounds(0, 0, 918, 722); - setLocationRelativeTo(formerGUI); getContentPane().setLayout(null); { @@ -336,10 +319,7 @@ public class CreateLectureLink_GUI extends JFrame { lblHauptmen.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent arg0) { - - CreateLectureLink_GUI.this.setVisible(false); - MainMenue_GUI main = new MainMenue_GUI(c); - main.setVisible(true); + GuiManager.show(new MainMenue_GUI()); } }); lblHauptmen.setForeground(Color.BLUE); @@ -421,11 +401,7 @@ public class CreateLectureLink_GUI extends JFrame { JButton cancelButton = new JButton("Zurück"); cancelButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { - - PermissionCreateLecture_GUI eVAG = new PermissionCreateLecture_GUI( - c); - eVAG.setVisible(true); - dispose(); + GuiManager.show(new PermissionCreateLecture_GUI()); } }); cancelButton.setActionCommand("CANCEL"); @@ -497,8 +473,7 @@ public class CreateLectureLink_GUI extends JFrame { "Veranstaltung angelegt", JOptionPane.INFORMATION_MESSAGE); // zurueck zum Menue - MainMenue_GUI m = new MainMenue_GUI(c); - m.setVisible(true); + GuiManager.show(new MainMenue_GUI()); } catch (TException e1) { LOGGER.error("Veranstaltung '"+Lecture.lecture.getName()+"' konnte nicht angelegt werden."); @@ -663,69 +638,6 @@ public class CreateLectureLink_GUI extends JFrame { textAreadesc.setBackground(SystemColor.menu); textAreadesc.setFont(new Font("Tahoma", Font.PLAIN, 11)); scrollPane.setViewportView(textAreadesc); - - JMenuBar menuBar = new JMenuBar(); - setJMenuBar(menuBar); - - JMenu mnNewMenu_1 = new JMenu("Hilfe"); - menuBar.add(mnNewMenu_1); - - JMenuItem mntmFaq = new JMenuItem("FAQ"); - mntmFaq.addMouseListener(new MouseAdapter() { - @Override - public void mousePressed(MouseEvent arg0) { - URI windows; - try { - windows = new URI(Links.getFAQ()); - - OpenLinks.openWebpage(windows); - - } catch (URISyntaxException e) { - - e.printStackTrace(); - } - } - }); - mnNewMenu_1.add(mntmFaq); - - JMenuItem mntmOtrs = new JMenuItem("OTRS"); - mntmOtrs.addMouseListener(new MouseAdapter() { - @Override - public void mousePressed(MouseEvent arg0) { - URI windows; - try { - windows = new URI(Links.getOTRS()); - - OpenLinks.openWebpage(windows); - - } catch (URISyntaxException e) { - - e.printStackTrace(); - } - - } - }); - mnNewMenu_1.add(mntmOtrs); - - JMenuItem mntmAbout = new JMenuItem("About"); - mntmAbout.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - About_GUI ab = new About_GUI(); - ab.setVisible(true); - } - }); - mnNewMenu_1.add(mntmAbout); - - JMenu mnNewMenu_Info = new JMenu("Info"); - mnNewMenu_Info.addMouseListener(new MouseAdapter() { - @Override - public void mouseClicked(MouseEvent arg0) { - JOptionPane.showMessageDialog(c, HELP_MESSAGE, - "Hilfe zu dieser Oberfläche", - JOptionPane.INFORMATION_MESSAGE); - } - }); - menuBar.add(mnNewMenu_Info); try { @@ -737,7 +649,6 @@ public class CreateLectureLink_GUI extends JFrame { e1.printStackTrace(); } - c = this; } diff --git a/dozentenmodul/src/main/java/gui/lecture/DeleteLecture_GUI.java b/dozentenmodul/src/main/java/gui/lecture/DeleteLecture_GUI.java index 0dd68697..004ed2b7 100644 --- a/dozentenmodul/src/main/java/gui/lecture/DeleteLecture_GUI.java +++ b/dozentenmodul/src/main/java/gui/lecture/DeleteLecture_GUI.java @@ -1,6 +1,5 @@ package gui.lecture; -import gui.intro.About_GUI; import gui.intro.MainMenue_GUI; import java.awt.Color; @@ -14,10 +13,6 @@ import java.awt.event.KeyAdapter; import java.awt.event.KeyEvent; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; -import java.awt.event.WindowAdapter; -import java.awt.event.WindowEvent; -import java.net.URI; -import java.net.URISyntaxException; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.ArrayList; @@ -26,11 +21,8 @@ import java.util.List; import java.util.Map; import javax.swing.JButton; -import javax.swing.JFrame; +import javax.swing.JInternalFrame; import javax.swing.JLabel; -import javax.swing.JMenu; -import javax.swing.JMenuBar; -import javax.swing.JMenuItem; import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JRadioButton; @@ -46,13 +38,14 @@ import javax.swing.UIManager; import javax.swing.UnsupportedLookAndFeelException; import javax.swing.border.EmptyBorder; import javax.swing.border.TitledBorder; +import javax.swing.event.InternalFrameAdapter; +import javax.swing.event.InternalFrameEvent; import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionListener; import javax.swing.table.DefaultTableModel; import javax.swing.table.TableModel; import javax.swing.table.TableRowSorter; -import models.Links; import models.SessionData; import models.person; @@ -61,10 +54,10 @@ import org.apache.thrift.TException; import org.openslx.sat.thrift.iface.Lecture; import thrift.ThriftManager; -import util.OpenLinks; +import util.GuiManager; @SuppressWarnings("serial") -public class DeleteLecture_GUI extends JFrame { +public class DeleteLecture_GUI extends JInternalFrame { private final static Logger LOGGER = Logger .getLogger(DeleteLecture_GUI.class); @@ -104,7 +97,7 @@ public class DeleteLecture_GUI extends JFrame { Component c = null; - private static final String HELP_MESSAGE = "<html><div align=\"center\">" + public static final String HELP_MESSAGE = "<html><div align=\"center\">" + "In der Übersicht sehen Sie primär alle Veranstaltungen, die Sie erzeugt haben.<br />" + "Sie können die Veranstaltungen hier löschen. Alternativ werden veraltete Einträge irgendwann automatisch gelöscht.<br />" + "Veraltet bedeutet, dass Veranstaltungen, die drei Monate lang nicht augerufen wurden, vorerst deaktiviert werden." @@ -116,27 +109,15 @@ public class DeleteLecture_GUI extends JFrame { /** * Create the dialog. */ - public DeleteLecture_GUI(Component formerGUI) { + public DeleteLecture_GUI() { filters.add(RowFilter.regexFilter(".", 0)); rf = RowFilter.orFilter(filters); - addWindowListener(new WindowAdapter() { + addInternalFrameListener(new InternalFrameAdapter() { @Override - public void windowClosing(WindowEvent arg0) { - // Beendet die Anwendung nach klick auf X - try { - ThriftManager.getSatClient().setSessionInvalid(SessionData.session.getAuthToken()); - } catch (TException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - System.exit(0); - } - - @Override - public void windowOpened(WindowEvent arg0) { + public void internalFrameActivated(InternalFrameEvent arg0) { textFieldName.requestFocusInWindow(); try { initTableModel(modelMyLectures); @@ -204,7 +185,6 @@ public class DeleteLecture_GUI extends JFrame { setTitle("bwLehrpool Suite - Veranstaltung löschen - "+person.verantwortlicher.getUserID()); // Zentriert das Fenster in die Bildmitte setBounds(0, 0, 842, 722); - setLocationRelativeTo(formerGUI); getContentPane().setLayout(null); { @@ -292,10 +272,7 @@ public class DeleteLecture_GUI extends JFrame { @Override public void mouseClicked(MouseEvent arg0) { // oeffnet das Hauptmenue - - DeleteLecture_GUI.this.setVisible(false); - MainMenue_GUI main = new MainMenue_GUI(c); - main.setVisible(true); + GuiManager.show(new MainMenue_GUI()); } }); lblHauptmen.setForeground(Color.BLUE); @@ -403,10 +380,7 @@ public class DeleteLecture_GUI extends JFrame { // delete successful LOGGER.info("Veranstaltung erfolgreich '"+lectureID+"' gelöscht."); - - DeleteLecture_GUI dl = new DeleteLecture_GUI(c); - dl.setVisible(true); - dispose(); + GuiManager.show(new DeleteLecture_GUI()); } else { // delete not successful LOGGER.error("Konnte Veranstaltung '" @@ -439,10 +413,7 @@ public class DeleteLecture_GUI extends JFrame { btnBack.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { // oeffnet das Hauptmenue - - MainMenue_GUI main = new MainMenue_GUI(c); - main.setVisible(true); - dispose(); + GuiManager.show(new MainMenue_GUI()); } }); btnBack.setActionCommand("OK"); @@ -550,70 +521,6 @@ public class DeleteLecture_GUI extends JFrame { scrollPaneName.setBounds(10, 40, 218, 55); panel.add(scrollPaneName); - JMenuBar menuBar = new JMenuBar(); - setJMenuBar(menuBar); - - JMenu mnNewMenu_1 = new JMenu("Hilfe"); - menuBar.add(mnNewMenu_1); - - JMenuItem mntmFaq = new JMenuItem("FAQ"); - mntmFaq.addMouseListener(new MouseAdapter() { - @Override - public void mousePressed(MouseEvent arg0) { - URI windows; - try { - windows = new URI(Links.getFAQ()); - - OpenLinks.openWebpage(windows); - - } catch (URISyntaxException e) { - - e.printStackTrace(); - } - } - }); - mnNewMenu_1.add(mntmFaq); - - JMenuItem mntmOtrs = new JMenuItem("OTRS"); - mntmOtrs.addMouseListener(new MouseAdapter() { - @Override - public void mousePressed(MouseEvent arg0) { - URI windows; - try { - windows = new URI(Links.getOTRS()); - - OpenLinks.openWebpage(windows); - - } catch (URISyntaxException e) { - - e.printStackTrace(); - } - - } - }); - mnNewMenu_1.add(mntmOtrs); - - JMenuItem mntmAbout = new JMenuItem("About"); - mntmAbout.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - About_GUI ab = new About_GUI(); - ab.setVisible(true); - } - }); - mnNewMenu_1.add(mntmAbout); - - JMenu mnNewMenu_Info = new JMenu("Info"); - mnNewMenu_Info.addMouseListener(new MouseAdapter() { - @Override - public void mouseClicked(MouseEvent arg0) { - JOptionPane.showMessageDialog(c, HELP_MESSAGE, - "Hilfe zu dieser Oberfläche", - JOptionPane.INFORMATION_MESSAGE); - } - }); - menuBar.add(mnNewMenu_Info); - - c = this; } diff --git a/dozentenmodul/src/main/java/gui/lecture/EditLectureAllgemein_GUI.java b/dozentenmodul/src/main/java/gui/lecture/EditLectureAllgemein_GUI.java index 597a3539..648406f0 100644 --- a/dozentenmodul/src/main/java/gui/lecture/EditLectureAllgemein_GUI.java +++ b/dozentenmodul/src/main/java/gui/lecture/EditLectureAllgemein_GUI.java @@ -1,6 +1,5 @@ package gui.lecture; -import gui.intro.About_GUI; import gui.intro.MainMenue_GUI; import java.awt.Color; @@ -13,22 +12,15 @@ import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; -import java.awt.event.WindowAdapter; -import java.awt.event.WindowEvent; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; -import java.net.URI; -import java.net.URISyntaxException; import java.util.Calendar; import java.util.Date; import javax.swing.ButtonGroup; import javax.swing.JButton; -import javax.swing.JFrame; +import javax.swing.JInternalFrame; import javax.swing.JLabel; -import javax.swing.JMenu; -import javax.swing.JMenuBar; -import javax.swing.JMenuItem; import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JRadioButton; @@ -44,21 +36,19 @@ import javax.swing.border.TitledBorder; import models.Image; import models.ItemOwner; import models.Lecture; -import models.Links; import models.SessionData; -//import models.person; import models.person; import org.apache.thrift.TException; -import org.openslx.sat.thrift.iface.Server; -import util.OpenLinks; +import thrift.ThriftManager; +import util.GuiManager; import com.toedter.calendar.JDateChooser; -//import server.generated.Server.Client; + @SuppressWarnings("serial") -public class EditLectureAllgemein_GUI extends JFrame { +public class EditLectureAllgemein_GUI extends JInternalFrame { private final JPanel contentPanel = new JPanel(); String[] result; @@ -76,7 +66,7 @@ public class EditLectureAllgemein_GUI extends JFrame { Date endDate; Component c = null; private final ButtonGroup buttonGroup = new ButtonGroup(); - Server.Client client = models.Client.clientcon.getClient(); + private boolean descriptionLengthOK = false; // description may not be // longer than // MAX_DESCRIPTION_LENGTH @@ -87,7 +77,7 @@ public class EditLectureAllgemein_GUI extends JFrame { boolean isDateOrderCorrect, isDateMaxLifeTimeCorrect, isAllInformationReady = false; - private static final String HELP_MESSAGE = "<html><div align=\"center\">" + + public static final String HELP_MESSAGE = "<html><div align=\"center\">" + "Bearbeiten Sie hier Ihre allgemeinen Informationen zu einer Veranstaltung.<br />" + "Sie können auch den Zeitraum neu wählen und die Beschreibung ändern.<br />" + "Klicken Sie anschließend auf \"Witer\" um die Daten im nächsten Schritt zu übernehmen." + @@ -96,19 +86,8 @@ public class EditLectureAllgemein_GUI extends JFrame { /** * Create the dialog. */ - public EditLectureAllgemein_GUI(Component formerGUI) { - addWindowListener(new WindowAdapter() { - @Override - public void windowClosing(WindowEvent arg0) { - try { - client.setSessionInvalid(SessionData.session.getAuthToken()); - } catch (TException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - System.exit(0); - } - }); + public EditLectureAllgemein_GUI() { + setResizable(false); try { @@ -121,7 +100,7 @@ public class EditLectureAllgemein_GUI extends JFrame { setTitle("bwLehrpool Suite - Veranstaltung bearbeiten - "+person.verantwortlicher.getUserID()); ; setBounds(0, 0, 603, 722); - setLocationRelativeTo(formerGUI); + getContentPane().setLayout(null); { @@ -230,10 +209,7 @@ public class EditLectureAllgemein_GUI extends JFrame { lblHauptmen.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent arg0) { - - EditLectureAllgemein_GUI.this.setVisible(false); - MainMenue_GUI main = new MainMenue_GUI(c); - main.setVisible(true); + GuiManager.show(new MainMenue_GUI()); } }); lblHauptmen.setForeground(Color.BLUE); @@ -418,10 +394,8 @@ public class EditLectureAllgemein_GUI extends JFrame { Lecture.lecture.setEnddate(dateChooserend.getDate()); Lecture.lecture.setStartdate(dateChooserstart.getDate()); Image.image.setImagename(textFieldLaborname.getText().trim()); - - EditLectureSearch_GUI sr = new EditLectureSearch_GUI(c); - sr.setVisible(true); - dispose(); + + GuiManager.show(new EditLectureSearch_GUI()); } }); okButton.setActionCommand("OK"); @@ -506,17 +480,12 @@ public class EditLectureAllgemein_GUI extends JFrame { //check which GUI to open try { - if((client.userIsLectureAdmin(person.verantwortlicher.getUserID(), Lecture.lecture.getid(),SessionData.session.getAuthToken()) || (person.verantwortlicher.getRole().equals("Admin")))){ + if((ThriftManager.getSatClient().userIsLectureAdmin(person.verantwortlicher.getUserID(), Lecture.lecture.getid(),SessionData.session.getAuthToken()) || (person.verantwortlicher.getRole().equals("Admin")))){ //user is admin of the lecture - PermissionEditLecture_GUI ev = new PermissionEditLecture_GUI(c); - ev.setVisible(true); - dispose(); - + GuiManager.show(new PermissionEditLecture_GUI()); } else { //user is not admin of the lecture - EditLectureLink_GUI el = new EditLectureLink_GUI(c); - el.setVisible(true); - dispose(); + GuiManager.show(new EditLectureLink_GUI()); } } catch (TException e1) { // TODO Auto-generated catch block @@ -546,64 +515,6 @@ public class EditLectureAllgemein_GUI extends JFrame { lblPflichtfelder.setBounds(32, 602, 136, 14); getContentPane().add(lblPflichtfelder); - JMenuBar menuBar = new JMenuBar(); - setJMenuBar(menuBar); - - JMenu mnNewMenu_1 = new JMenu("Hilfe"); - menuBar.add(mnNewMenu_1); - - JMenuItem mntmFaq = new JMenuItem("FAQ"); - mntmFaq.addMouseListener(new MouseAdapter() { - @Override - public void mousePressed(MouseEvent arg0) { - URI windows; - try { - windows = new URI(Links.getFAQ()); - OpenLinks.openWebpage(windows); - } catch (URISyntaxException e) { - - e.printStackTrace(); - } - } - }); - mnNewMenu_1.add(mntmFaq); - - JMenuItem mntmOtrs = new JMenuItem("OTRS"); - mntmOtrs.addMouseListener(new MouseAdapter() { - @Override - public void mousePressed(MouseEvent arg0) { - URI windows; - try { - windows = new URI(Links.getOTRS()); - OpenLinks.openWebpage(windows); - } catch (URISyntaxException e) { - - e.printStackTrace(); - } - } - }); - mnNewMenu_1.add(mntmOtrs); - - JMenuItem mntmAbout = new JMenuItem("About"); - mntmAbout.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - About_GUI ab = new About_GUI(); - ab.setVisible(true); - } - }); - mnNewMenu_1.add(mntmAbout); - - JMenu mnNewMenu_Info = new JMenu("Info"); - mnNewMenu_Info.addMouseListener(new MouseAdapter() { - @Override - public void mouseClicked(MouseEvent arg0) { - JOptionPane.showMessageDialog(c, HELP_MESSAGE, "Hilfe zu dieser Oberfläche", JOptionPane.INFORMATION_MESSAGE); - } - }); - menuBar.add(mnNewMenu_Info); - - c = this; - setLocationRelativeTo(formerGUI); } public Date addDays(Date date, int days) { diff --git a/dozentenmodul/src/main/java/gui/lecture/EditLectureLink_GUI.java b/dozentenmodul/src/main/java/gui/lecture/EditLectureLink_GUI.java index 3e78751c..9b14335b 100644 --- a/dozentenmodul/src/main/java/gui/lecture/EditLectureLink_GUI.java +++ b/dozentenmodul/src/main/java/gui/lecture/EditLectureLink_GUI.java @@ -1,6 +1,5 @@ package gui.lecture; -import gui.intro.About_GUI; import gui.intro.MainMenue_GUI; import java.awt.Color; @@ -14,10 +13,6 @@ import java.awt.event.KeyAdapter; import java.awt.event.KeyEvent; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; -import java.awt.event.WindowAdapter; -import java.awt.event.WindowEvent; -import java.net.URI; -import java.net.URISyntaxException; import java.text.DateFormat; import java.text.ParseException; import java.text.SimpleDateFormat; @@ -28,11 +23,8 @@ import java.util.Map; import javax.swing.JButton; import javax.swing.JComboBox; -import javax.swing.JFrame; +import javax.swing.JInternalFrame; import javax.swing.JLabel; -import javax.swing.JMenu; -import javax.swing.JMenuBar; -import javax.swing.JMenuItem; import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JRadioButton; @@ -48,6 +40,8 @@ import javax.swing.UIManager; import javax.swing.UnsupportedLookAndFeelException; import javax.swing.border.EmptyBorder; import javax.swing.border.TitledBorder; +import javax.swing.event.InternalFrameAdapter; +import javax.swing.event.InternalFrameEvent; import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionListener; import javax.swing.table.DefaultTableModel; @@ -55,7 +49,6 @@ import javax.swing.table.TableModel; import javax.swing.table.TableRowSorter; import models.Lecture; -import models.Links; import models.RightsManagement; import models.SessionData; import models.person; @@ -64,10 +57,10 @@ import org.apache.thrift.TException; import org.openslx.sat.thrift.iface.Image; import thrift.ThriftManager; -import util.OpenLinks; +import util.GuiManager; @SuppressWarnings("serial") -public class EditLectureLink_GUI extends JFrame { +public class EditLectureLink_GUI extends JInternalFrame { private final JPanel contentPanel = new JPanel(); String[] result; @@ -134,7 +127,7 @@ public class EditLectureLink_GUI extends JFrame { ArrayList<RowFilter<Object, Object>> finalFilters = new ArrayList<RowFilter<Object, Object>>(); - private static final String HELP_MESSAGE = "<html><div align=\"center\">" + public static final String HELP_MESSAGE = "<html><div align=\"center\">" + "Ändern Sie hier das Image, zu dem Ihre Veranstaltung gehört.<br />" + "Wählen Sie das Image aus, das zu Ihrer Veranstaltung passt und klicken Sie anschließend auf \"Veranstaltung ändern und abschließen\"." + "</div></html>"; @@ -142,23 +135,11 @@ public class EditLectureLink_GUI extends JFrame { /** * Create the dialog. */ - public EditLectureLink_GUI(Component formerGUI) { + public EditLectureLink_GUI() { - - addWindowListener(new WindowAdapter() { - @Override - public void windowClosing(WindowEvent arg0) { - try { - ThriftManager.getSatClient().setSessionInvalid(SessionData.session.getAuthToken()); - } catch (TException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - System.exit(0); - } - + addInternalFrameListener(new InternalFrameAdapter() { @Override - public void windowOpened(WindowEvent arg0) { + public void internalFrameActivated(InternalFrameEvent arg0) { try { initTableModelAll(modelAll); initTableModel(modelMyImages); @@ -270,11 +251,11 @@ public class EditLectureLink_GUI extends JFrame { tableAllImages.setRowSelectionInterval(tableAllImages.rowAtPoint(e.getPoint()), tableAllImages.rowAtPoint(e.getPoint())); } }); - - + textFieldName.requestFocusInWindow(); } }); + setResizable(false); try { @@ -287,7 +268,6 @@ public class EditLectureLink_GUI extends JFrame { setTitle("bwLehrpool Suite - Veranstaltung bearbeiten - "+person.verantwortlicher.getUserID()); setBounds(0, 0, 918, 722); - setLocationRelativeTo(formerGUI); final DefaultTableModel model = new DefaultTableModel(titles, 0); @@ -442,10 +422,7 @@ public class EditLectureLink_GUI extends JFrame { lblHauptmen.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent arg0) { - - EditLectureLink_GUI.this.setVisible(false); - MainMenue_GUI main = new MainMenue_GUI(c); - main.setVisible(true); + GuiManager.show(new MainMenue_GUI()); } }); lblHauptmen.setForeground(Color.BLUE); @@ -626,15 +603,10 @@ public class EditLectureLink_GUI extends JFrame { if(ThriftManager.getSatClient().userIsLectureAdmin(person.verantwortlicher.getUserID(), Lecture.lecture.getid(),SessionData.session.getAuthToken()) || (person.verantwortlicher.getRole().equals("Admin"))){ //user is admin of the lecture - PermissionEditLecture_GUI ev = new PermissionEditLecture_GUI(c); - ev.setVisible(true); - dispose(); - + GuiManager.show(new PermissionEditLecture_GUI()); } else { //user is not admin of the lecture - EditLectureAllgemein_GUI el = new EditLectureAllgemein_GUI(c); - el.setVisible(true); - dispose(); + GuiManager.show(new EditLectureAllgemein_GUI()); } } catch (TException e1) { // TODO Auto-generated catch block @@ -743,8 +715,7 @@ public class EditLectureLink_GUI extends JFrame { "Veranstaltung angelegt", JOptionPane.INFORMATION_MESSAGE); // zurueck zum Menue - MainMenue_GUI m = new MainMenue_GUI(c); - m.setVisible(true); + GuiManager.show(new MainMenue_GUI()); } catch (TException e1) { e1.printStackTrace(); @@ -850,8 +821,7 @@ public class EditLectureLink_GUI extends JFrame { "Veranstaltung angelegt", JOptionPane.INFORMATION_MESSAGE); // zurueck zum Menue - MainMenue_GUI m = new MainMenue_GUI(c); - m.setVisible(true); + GuiManager.show(new MainMenue_GUI()); } catch (TException e1) { e1.printStackTrace(); @@ -954,8 +924,7 @@ public class EditLectureLink_GUI extends JFrame { "Veranstaltung angelegt", JOptionPane.INFORMATION_MESSAGE); // zurueck zum Menue - MainMenue_GUI m = new MainMenue_GUI(c); - m.setVisible(true); + GuiManager.show(new MainMenue_GUI()); } catch (TException e1) { e1.printStackTrace(); @@ -1121,71 +1090,7 @@ public class EditLectureLink_GUI extends JFrame { textAreadesc.setBackground(SystemColor.menu); textAreadesc.setFont(new Font("Tahoma", Font.PLAIN, 11)); scrollPane.setViewportView(textAreadesc); - - JMenuBar menuBar = new JMenuBar(); - setJMenuBar(menuBar); - - JMenu mnNewMenu_1 = new JMenu("Hilfe"); - menuBar.add(mnNewMenu_1); - - JMenuItem mntmFaq = new JMenuItem("FAQ"); - mntmFaq.addMouseListener(new MouseAdapter() { - @Override - public void mousePressed(MouseEvent arg0) { - URI windows; - try { - windows = new URI(Links.getFAQ()); - - OpenLinks.openWebpage(windows); - - } catch (URISyntaxException e) { - - e.printStackTrace(); - } - } - }); - mnNewMenu_1.add(mntmFaq); - - JMenuItem mntmOtrs = new JMenuItem("OTRS"); - mntmOtrs.addMouseListener(new MouseAdapter() { - @Override - public void mousePressed(MouseEvent arg0) { - URI windows; - try { - windows = new URI(Links.getOTRS()); - - OpenLinks.openWebpage(windows); - - } catch (URISyntaxException e) { - - e.printStackTrace(); - } - - } - }); - mnNewMenu_1.add(mntmOtrs); - - JMenuItem mntmAbout = new JMenuItem("About"); - mntmAbout.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - About_GUI ab = new About_GUI(); - ab.setVisible(true); - } - }); - mnNewMenu_1.add(mntmAbout); - - JMenu mnNewMenu_Info = new JMenu("Info"); - mnNewMenu_Info.addMouseListener(new MouseAdapter() { - @Override - public void mouseClicked(MouseEvent arg0) { - JOptionPane.showMessageDialog(c, HELP_MESSAGE, - "Hilfe zu dieser Oberfläche", - JOptionPane.INFORMATION_MESSAGE); - } - }); - menuBar.add(mnNewMenu_Info); - c = this; } diff --git a/dozentenmodul/src/main/java/gui/lecture/EditLectureSearch_GUI.java b/dozentenmodul/src/main/java/gui/lecture/EditLectureSearch_GUI.java index 3f2da363..437e7ab1 100644 --- a/dozentenmodul/src/main/java/gui/lecture/EditLectureSearch_GUI.java +++ b/dozentenmodul/src/main/java/gui/lecture/EditLectureSearch_GUI.java @@ -1,6 +1,5 @@ package gui.lecture; -import gui.intro.About_GUI; import gui.intro.MainMenue_GUI; import java.awt.Color; @@ -14,10 +13,6 @@ import java.awt.event.KeyAdapter; import java.awt.event.KeyEvent; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; -import java.awt.event.WindowAdapter; -import java.awt.event.WindowEvent; -import java.net.URI; -import java.net.URISyntaxException; import java.text.DateFormat; import java.text.ParseException; import java.text.SimpleDateFormat; @@ -28,12 +23,8 @@ import java.util.List; import java.util.Map; import javax.swing.JButton; -import javax.swing.JFrame; +import javax.swing.JInternalFrame; import javax.swing.JLabel; -import javax.swing.JMenu; -import javax.swing.JMenuBar; -import javax.swing.JMenuItem; -import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JRadioButton; import javax.swing.JScrollPane; @@ -48,6 +39,8 @@ import javax.swing.UIManager; import javax.swing.UnsupportedLookAndFeelException; import javax.swing.border.EmptyBorder; import javax.swing.border.TitledBorder; +import javax.swing.event.InternalFrameAdapter; +import javax.swing.event.InternalFrameEvent; import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionListener; import javax.swing.table.DefaultTableModel; @@ -56,17 +49,16 @@ import javax.swing.table.TableRowSorter; import models.ItemOwner; import models.Lecture; -import models.Links; import models.SessionData; import models.person; import org.apache.thrift.TException; import thrift.ThriftManager; -import util.OpenLinks; +import util.GuiManager; @SuppressWarnings("serial") -public class EditLectureSearch_GUI extends JFrame { +public class EditLectureSearch_GUI extends JInternalFrame { private final JPanel contentPanel = new JPanel(); String[] result; @@ -88,7 +80,7 @@ public class EditLectureSearch_GUI extends JFrame { String[] titles = { "Veranstaltungsname", "Beschreibung", "Gültigkeitsdatum", "Aktiv", "Letzte Benutzung", "Verantwortlicher", "Image", "Schlagwort", "ID" }; - private static final String HELP_MESSAGE = "<html><div align=\"center\">" + public static final String HELP_MESSAGE = "<html><div align=\"center\">" + "Suchen Sie hier Ihre Veranstaltungen und wählen Sie sie für weitere Schritte aus.<br />" + "Klicken Sie anschließend auf \"Weiter\", um die Details der Veranstaltung sowie die Berechtigungen zu ändern." + "</div></html>"; @@ -109,27 +101,15 @@ public class EditLectureSearch_GUI extends JFrame { /** * Create the dialog. */ - public EditLectureSearch_GUI(Component formerGUI) { + public EditLectureSearch_GUI() { filters.add(RowFilter.regexFilter(".", 0)); rf = RowFilter.orFilter(filters); - addWindowListener(new WindowAdapter() { + addInternalFrameListener(new InternalFrameAdapter() { @Override - public void windowClosing(WindowEvent arg0) { - // Beendet die Anwendung nach klick auf X - try { - ThriftManager.getSatClient().setSessionInvalid(SessionData.session.getAuthToken()); - } catch (TException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - System.exit(0); - } - - @Override - public void windowOpened(WindowEvent arg0) { + public void internalFrameActivated(InternalFrameEvent arg0) { textFieldName.requestFocusInWindow(); try { initTableModel(modelMyLectures); @@ -177,9 +157,9 @@ public class EditLectureSearch_GUI extends JFrame { tablemyLectures.setRowSelectionInterval(tablemyLectures.rowAtPoint(e.getPoint()), tablemyLectures.rowAtPoint(e.getPoint())); } }); - } }); + // Verhindert das Vergroessern Des Fensters setResizable(false); @@ -195,7 +175,6 @@ public class EditLectureSearch_GUI extends JFrame { setTitle("bwLehrpool Suite - Veranstaltung bearbeiten - "+person.verantwortlicher.getUserID()); // Zentriert das Fenster in die Bildmitte setBounds(0, 0, 842, 722); - setLocationRelativeTo(formerGUI); getContentPane().setLayout(null); { @@ -284,10 +263,7 @@ public class EditLectureSearch_GUI extends JFrame { @Override public void mouseClicked(MouseEvent arg0) { // oeffnet das Hauptmenue - - EditLectureSearch_GUI.this.setVisible(false); - MainMenue_GUI main = new MainMenue_GUI(c); - main.setVisible(true); + GuiManager.show(new MainMenue_GUI()); } }); lblHauptmen.setForeground(Color.BLUE); @@ -374,10 +350,7 @@ public class EditLectureSearch_GUI extends JFrame { btnBack.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { // oeffnet das Hauptmenue - - MainMenue_GUI main = new MainMenue_GUI(c); - main.setVisible(true); - dispose(); + GuiManager.show(new MainMenue_GUI()); } }); btnBack.setActionCommand("OK"); @@ -466,12 +439,7 @@ public class EditLectureSearch_GUI extends JFrame { Lecture.lecture.setActive(false); } - // EditImageAllgemein_GUI ea=new - // EditImageAllgemein_GUI(); - EditLectureAllgemein_GUI el = new EditLectureAllgemein_GUI( - c); - el.setVisible(true); - dispose(); + GuiManager.show(new EditLectureAllgemein_GUI()); } } // end action @@ -580,72 +548,7 @@ public class EditLectureSearch_GUI extends JFrame { JScrollPane scrollPaneName = new JScrollPane(labelName); scrollPaneName.setBounds(10, 40, 218, 55); panel.add(scrollPaneName); - // panel.add(labelName); - // panel.add(labelimage); - JMenuBar menuBar = new JMenuBar(); - setJMenuBar(menuBar); - - JMenu mnNewMenu_1 = new JMenu("Hilfe"); - menuBar.add(mnNewMenu_1); - - JMenuItem mntmFaq = new JMenuItem("FAQ"); - mntmFaq.addMouseListener(new MouseAdapter() { - @Override - public void mousePressed(MouseEvent arg0) { - URI windows; - try { - windows = new URI(Links.getFAQ()); - - OpenLinks.openWebpage(windows); - - } catch (URISyntaxException e) { - - e.printStackTrace(); - } - } - }); - mnNewMenu_1.add(mntmFaq); - - JMenuItem mntmOtrs = new JMenuItem("OTRS"); - mntmOtrs.addMouseListener(new MouseAdapter() { - @Override - public void mousePressed(MouseEvent arg0) { - URI windows; - try { - windows = new URI(Links.getOTRS()); - - OpenLinks.openWebpage(windows); - - } catch (URISyntaxException e) { - - e.printStackTrace(); - } - - } - }); - mnNewMenu_1.add(mntmOtrs); - - JMenuItem mntmAbout = new JMenuItem("About"); - mntmAbout.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - About_GUI ab = new About_GUI(); - ab.setVisible(true); - } - }); - mnNewMenu_1.add(mntmAbout); - - JMenu mnNewMenu_Info = new JMenu("Info"); - mnNewMenu_Info.addMouseListener(new MouseAdapter() { - @Override - public void mouseClicked(MouseEvent arg0) { - JOptionPane.showMessageDialog(c, HELP_MESSAGE, - "Hilfe zu dieser Oberfläche", - JOptionPane.INFORMATION_MESSAGE); - } - }); - menuBar.add(mnNewMenu_Info); - c = this; } diff --git a/dozentenmodul/src/main/java/gui/lecture/PermissionCreateLecture_GUI.java b/dozentenmodul/src/main/java/gui/lecture/PermissionCreateLecture_GUI.java index 3c4e74b1..93006089 100644 --- a/dozentenmodul/src/main/java/gui/lecture/PermissionCreateLecture_GUI.java +++ b/dozentenmodul/src/main/java/gui/lecture/PermissionCreateLecture_GUI.java @@ -1,6 +1,5 @@ package gui.lecture; -import gui.intro.About_GUI; import gui.intro.MainMenue_GUI; import java.awt.Color; @@ -15,10 +14,6 @@ import java.awt.event.ItemListener; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import java.awt.event.MouseListener; -import java.awt.event.WindowAdapter; -import java.awt.event.WindowEvent; -import java.net.URI; -import java.net.URISyntaxException; import java.util.ArrayList; import java.util.Iterator; import java.util.List; @@ -26,12 +21,8 @@ import java.util.List; import javax.swing.AbstractButton; import javax.swing.JButton; import javax.swing.JCheckBox; -import javax.swing.JFrame; +import javax.swing.JInternalFrame; import javax.swing.JLabel; -import javax.swing.JMenu; -import javax.swing.JMenuBar; -import javax.swing.JMenuItem; -import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JRadioButton; import javax.swing.JScrollPane; @@ -51,30 +42,24 @@ import javax.swing.table.TableColumnModel; import javax.swing.table.TableModel; import javax.swing.table.TableRowSorter; -import models.Links; import models.RightsManagement; -import models.SessionData; import models.person; - -import org.apache.thrift.TException; -import org.openslx.sat.thrift.iface.Server.Client; - import util.CheckIntegrity; +import util.GuiManager; import util.ListAllOtherUsers_GUI; -import util.OpenLinks; @SuppressWarnings("serial") -public class PermissionCreateLecture_GUI extends JFrame { +public class PermissionCreateLecture_GUI extends JInternalFrame { private final JPanel contentPanel = new JPanel(); - Client client = models.Client.clientcon.getClient(); + String[] result; // private JTable table = null; private JTable tablePermittedUsers = null; Object[] titles = { "Name", "Lesen", "Schreiben", "Admin", "userID" }; // Object[] titles = { "Name", "Read", "Write", "Link", "Admin", "userID" }; Component c = null; - private static final String HELP_MESSAGE = "<html><div align=\"center\">" + public static final String HELP_MESSAGE = "<html><div align=\"center\">" + "Hier können Sie die Berechtigungen für Ihre Veranstaltung ändern.<br />" + "Es wird unterschieden, ob innerhalb der Suite (dieses Programm) Änderungen vorgenommen werden dürfen, <br />" + "und/oder ob die Veranstaltung auch im VMChooser angezeigt wird." @@ -113,21 +98,8 @@ public class PermissionCreateLecture_GUI extends JFrame { // private JTable tablePermittedUsers; - public PermissionCreateLecture_GUI(Component formerGUI) { - - - addWindowListener(new WindowAdapter() { - @Override - public void windowClosing(WindowEvent arg0) { - try { - client.setSessionInvalid(SessionData.session.getAuthToken()); - } catch (TException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - System.exit(0); - } - }); + public PermissionCreateLecture_GUI() { + setResizable(false); try { @@ -139,7 +111,6 @@ public class PermissionCreateLecture_GUI extends JFrame { setTitle("bwLehrpool Suite - Berechtigungen - "+person.verantwortlicher.getUserID()); setBounds(0, 0, 603, 722); - setLocationRelativeTo(formerGUI); getContentPane().setLayout(null); { @@ -266,10 +237,7 @@ public class PermissionCreateLecture_GUI extends JFrame { lblHauptmen.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent arg0) { - - PermissionCreateLecture_GUI.this.setVisible(false); - MainMenue_GUI main = new MainMenue_GUI(c); - main.setVisible(true); + GuiManager.show(new MainMenue_GUI()); } }); lblHauptmen.setForeground(Color.BLUE); @@ -351,12 +319,11 @@ public class PermissionCreateLecture_GUI extends JFrame { btnAddUser.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { // show list of all other relevant users - ListAllOtherUsers_GUI lu = new ListAllOtherUsers_GUI(c, - tablePermittedUsers, 4); // give access to the table - // model and inform that the - // userID is position 5 in - // the model - lu.setVisible(true); + GuiManager.openPopup(new ListAllOtherUsers_GUI(tablePermittedUsers, 4)); + // give access to the table + // model and inform that the + // userID is position 5 in + // the model } }); btnAddUser.setBounds(10, 290, 113, 23); @@ -433,11 +400,7 @@ public class PermissionCreateLecture_GUI extends JFrame { JButton cancelButton = new JButton("Zurück"); cancelButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { - - CreateLectureAllgemein_GUI sr = new CreateLectureAllgemein_GUI( - c); - sr.setVisible(true); - dispose(); + GuiManager.show(new CreateLectureAllgemein_GUI()); } }); cancelButton.setActionCommand("OK"); @@ -458,11 +421,7 @@ public class PermissionCreateLecture_GUI extends JFrame { } saveTableToList(); - - CreateLectureLink_GUI ea = new CreateLectureLink_GUI(c); - ea.setVisible(true); - dispose(); - + GuiManager.show(new CreateLectureLink_GUI()); } }); continueButton.setActionCommand("Cancel"); @@ -479,66 +438,6 @@ public class PermissionCreateLecture_GUI extends JFrame { separator_1.setBounds(0, 627, 597, 2); getContentPane().add(separator_1); - JMenuBar menuBar = new JMenuBar(); - setJMenuBar(menuBar); - - JMenu mnNewMenu_1 = new JMenu("Hilfe"); - menuBar.add(mnNewMenu_1); - - JMenuItem mntmFaq = new JMenuItem("FAQ"); - mntmFaq.addMouseListener(new MouseAdapter() { - @Override - public void mousePressed(MouseEvent arg0) { - - URI windows; - try { - windows = new URI(Links.getFAQ()); - OpenLinks.openWebpage(windows); - } catch (URISyntaxException e) { - e.printStackTrace(); - } - } - }); - mnNewMenu_1.add(mntmFaq); - - JMenuItem mntmOtrs = new JMenuItem("OTRS"); - mntmOtrs.addMouseListener(new MouseAdapter() { - @Override - public void mousePressed(MouseEvent arg0) { - - URI windows; - try { - windows = new URI(Links.getOTRS()); - OpenLinks.openWebpage(windows); - } catch (URISyntaxException e) { - e.printStackTrace(); - } - - } - }); - mnNewMenu_1.add(mntmOtrs); - - JMenuItem mntmAbout = new JMenuItem("About"); - mntmAbout.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - About_GUI ab = new About_GUI(); - ab.setVisible(true); - } - }); - mnNewMenu_1.add(mntmAbout); - - JMenu mnNewMenu_Info = new JMenu("Info"); - mnNewMenu_Info.addMouseListener(new MouseAdapter() { - @Override - public void mouseClicked(MouseEvent arg0) { - JOptionPane.showMessageDialog(c, HELP_MESSAGE, - "Hilfe zu dieser Oberfläche", - JOptionPane.INFORMATION_MESSAGE); - } - }); - menuBar.add(mnNewMenu_Info); - - c = this; }// end constructor diff --git a/dozentenmodul/src/main/java/gui/lecture/PermissionEditLecture_GUI.java b/dozentenmodul/src/main/java/gui/lecture/PermissionEditLecture_GUI.java index 5eb40b0b..39443196 100644 --- a/dozentenmodul/src/main/java/gui/lecture/PermissionEditLecture_GUI.java +++ b/dozentenmodul/src/main/java/gui/lecture/PermissionEditLecture_GUI.java @@ -1,6 +1,5 @@ package gui.lecture; -import gui.intro.About_GUI; import gui.intro.MainMenue_GUI; import java.awt.Color; @@ -14,22 +13,14 @@ import java.awt.event.ItemEvent; import java.awt.event.ItemListener; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; -import java.awt.event.WindowAdapter; -import java.awt.event.WindowEvent; -import java.net.URI; -import java.net.URISyntaxException; import java.util.ArrayList; import java.util.Iterator; import java.util.List; import javax.swing.AbstractButton; import javax.swing.JButton; -import javax.swing.JFrame; +import javax.swing.JInternalFrame; import javax.swing.JLabel; -import javax.swing.JMenu; -import javax.swing.JMenuBar; -import javax.swing.JMenuItem; -import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JRadioButton; import javax.swing.JScrollPane; @@ -45,7 +36,6 @@ import javax.swing.table.DefaultTableModel; import javax.swing.table.TableColumn; import models.Lecture; -import models.Links; import models.RightsManagement; import models.SessionData; import models.person; @@ -55,11 +45,11 @@ import org.openslx.sat.thrift.iface.Person; import thrift.ThriftManager; import util.CheckIntegrity; +import util.GuiManager; import util.ListAllOtherUsers_GUI; -import util.OpenLinks; @SuppressWarnings("serial") -public class PermissionEditLecture_GUI extends JFrame { +public class PermissionEditLecture_GUI extends JInternalFrame { private final JPanel contentPanel = new JPanel(); String[] result; @@ -67,7 +57,7 @@ public class PermissionEditLecture_GUI extends JFrame { Object[] titles = { "Name", "Lesen", "Schreiben", "Admin", "userID" }; private List<Person> map = null; // List of people who have rights Component c = null; - private static final String HELP_MESSAGE = "<html><div align=\"center\">" + public static final String HELP_MESSAGE = "<html><div align=\"center\">" + "Hier können Sie die Berechtigungen für Ihre Veranstaltung festlegen.<br />" + "Es wird unterschieden, ob innerhalb der Suite (dieses Programm) Änderungen vorgenommen werden dürfen, <br />" + "und/oder ob die Veranstaltung auch im VMChooser angezeigt wird." @@ -93,21 +83,8 @@ public class PermissionEditLecture_GUI extends JFrame { }; - public PermissionEditLecture_GUI(Component formerGUI) { - + public PermissionEditLecture_GUI() { - addWindowListener(new WindowAdapter() { - @Override - public void windowClosing(WindowEvent arg0) { - try { - ThriftManager.getSatClient().setSessionInvalid(SessionData.session.getAuthToken()); - } catch (TException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - System.exit(0); - } - }); setResizable(false); try { @@ -120,7 +97,7 @@ public class PermissionEditLecture_GUI extends JFrame { setTitle("bwLehrpool Suite - Berechtigungen - "+person.verantwortlicher.getUserID()); setBounds(0, 0, 603, 722); - setLocationRelativeTo(formerGUI); + getContentPane().setLayout(null); { @@ -314,10 +291,9 @@ public class PermissionEditLecture_GUI extends JFrame { btnAddUser.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { // show list of all other relevant users - ListAllOtherUsers_GUI lu = new ListAllOtherUsers_GUI(c, table, - 4); // give access to the table model and inform that - // the userID is position 5 in the model - lu.setVisible(true); + GuiManager.openPopup(new ListAllOtherUsers_GUI(table, 4)); + // give access to the table model and inform that + // the userID is position 5 in the model } }); btnAddUser.setBounds(10, 290, 113, 23); @@ -353,10 +329,7 @@ public class PermissionEditLecture_GUI extends JFrame { lblHauptmen.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent arg0) { - - PermissionEditLecture_GUI.this.setVisible(false); - MainMenue_GUI main = new MainMenue_GUI(c); - main.setVisible(true); + GuiManager.show(new MainMenue_GUI()); } }); lblHauptmen.setForeground(Color.BLUE); @@ -425,11 +398,7 @@ public class PermissionEditLecture_GUI extends JFrame { JButton cancelButton = new JButton("Zurück"); cancelButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { - - EditLectureAllgemein_GUI sr = new EditLectureAllgemein_GUI( - c); - sr.setVisible(true); - dispose(); + GuiManager.show(new EditLectureAllgemein_GUI()); } }); cancelButton.setActionCommand("OK"); @@ -450,11 +419,7 @@ public class PermissionEditLecture_GUI extends JFrame { } saveTableToList(); - - EditLectureLink_GUI ea = new EditLectureLink_GUI(c); - ea.setVisible(true); - dispose(); - + GuiManager.show(new EditLectureLink_GUI()); } }); continueButton.setActionCommand("Cancel"); @@ -487,70 +452,6 @@ public class PermissionEditLecture_GUI extends JFrame { separator_1.setBounds(0, 627, 597, 2); getContentPane().add(separator_1); - JMenuBar menuBar = new JMenuBar(); - setJMenuBar(menuBar); - - JMenu mnNewMenu_1 = new JMenu("Hilfe"); - menuBar.add(mnNewMenu_1); - - JMenuItem mntmFaq = new JMenuItem("FAQ"); - mntmFaq.addMouseListener(new MouseAdapter() { - @Override - public void mousePressed(MouseEvent arg0) { - URI windows; - try { - windows = new URI(Links.getFAQ()); - - OpenLinks.openWebpage(windows); - - } catch (URISyntaxException e) { - - e.printStackTrace(); - } - } - }); - mnNewMenu_1.add(mntmFaq); - - JMenuItem mntmOtrs = new JMenuItem("OTRS"); - mntmOtrs.addMouseListener(new MouseAdapter() { - @Override - public void mousePressed(MouseEvent arg0) { - URI windows; - try { - windows = new URI(Links.getOTRS()); - - OpenLinks.openWebpage(windows); - - } catch (URISyntaxException e) { - - e.printStackTrace(); - } - - } - }); - mnNewMenu_1.add(mntmOtrs); - - JMenuItem mntmAbout = new JMenuItem("About"); - mntmAbout.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - About_GUI ab = new About_GUI(); - ab.setVisible(true); - } - }); - mnNewMenu_1.add(mntmAbout); - - JMenu mnNewMenu_Info = new JMenu("Info"); - mnNewMenu_Info.addMouseListener(new MouseAdapter() { - @Override - public void mouseClicked(MouseEvent arg0) { - JOptionPane.showMessageDialog(c, HELP_MESSAGE, - "Hilfe zu dieser Oberfläche", - JOptionPane.INFORMATION_MESSAGE); - } - }); - menuBar.add(mnNewMenu_Info); - - c = this; }// end constructor diff --git a/dozentenmodul/src/main/java/gui/lecture/SearchLecture_GUI.java b/dozentenmodul/src/main/java/gui/lecture/SearchLecture_GUI.java index fbb24849..2263fe59 100644 --- a/dozentenmodul/src/main/java/gui/lecture/SearchLecture_GUI.java +++ b/dozentenmodul/src/main/java/gui/lecture/SearchLecture_GUI.java @@ -1,6 +1,5 @@ package gui.lecture;
-import gui.intro.About_GUI;
import gui.intro.MainMenue_GUI;
import java.awt.Color;
@@ -14,10 +13,6 @@ import java.awt.event.KeyAdapter; import java.awt.event.KeyEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
-import java.awt.event.WindowAdapter;
-import java.awt.event.WindowEvent;
-import java.net.URI;
-import java.net.URISyntaxException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
@@ -26,11 +21,8 @@ import java.util.List; import java.util.Map;
import javax.swing.JButton;
-import javax.swing.JFrame;
+import javax.swing.JInternalFrame;
import javax.swing.JLabel;
-import javax.swing.JMenu;
-import javax.swing.JMenuBar;
-import javax.swing.JMenuItem;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.JScrollPane;
@@ -48,13 +40,14 @@ import javax.swing.border.EmptyBorder; import javax.swing.border.TitledBorder;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
+import javax.swing.event.InternalFrameAdapter;
+import javax.swing.event.InternalFrameEvent;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableModel;
import javax.swing.table.TableRowSorter;
-import models.Links;
import models.SessionData;
import models.person;
@@ -62,10 +55,10 @@ import org.apache.thrift.TException; import org.openslx.sat.thrift.iface.Lecture;
import thrift.ThriftManager;
-import util.OpenLinks;
+import util.GuiManager;
@SuppressWarnings("serial")
-public class SearchLecture_GUI extends JFrame {
+public class SearchLecture_GUI extends JInternalFrame {
private final JPanel contentPanel = new JPanel();
String[] result;
@@ -113,27 +106,15 @@ public class SearchLecture_GUI extends JFrame { /**
* Create the dialog.
*/
- public SearchLecture_GUI(Component formerGUI) {
+ public SearchLecture_GUI() {
filters.add(RowFilter.regexFilter(".", 0));
rf = RowFilter.orFilter(filters);
-
-
- addWindowListener(new WindowAdapter() {
- @Override
- public void windowClosing(WindowEvent arg0) {
- // Beendet die Anwendung nach klick auf X
- try {
- ThriftManager.getSatClient().setSessionInvalid(SessionData.session.getAuthToken());
- } catch (TException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- System.exit(0);
- }
+
+ addInternalFrameListener(new InternalFrameAdapter() {
@Override
- public void windowOpened(WindowEvent arg0) {
+ public void internalFrameActivated(InternalFrameEvent arg0) {
try {
initTableModel(modelMyLectures);
initTableModelAll(modelAll);
@@ -205,6 +186,7 @@ public class SearchLecture_GUI extends JFrame { });
}
});
+
// Verhindert das Vergroessern Des Fensters
setResizable(false);
@@ -220,7 +202,7 @@ public class SearchLecture_GUI extends JFrame { setTitle("bwLehrpool Suite - Veranstaltung suchen - "+person.verantwortlicher.getUserID());
// Zentriert das Fenster in die Bildmitte 2;
setBounds(0, 0, 842, 722);
- setLocationRelativeTo(formerGUI);
+
getContentPane().setLayout(null);
{
@@ -305,10 +287,7 @@ public class SearchLecture_GUI extends JFrame { @Override
public void mouseClicked(MouseEvent arg0) {
// oeffnet das Hauptmenue
-
- SearchLecture_GUI.this.setVisible(false);
- MainMenue_GUI main = new MainMenue_GUI(c);
- main.setVisible(true);
+ GuiManager.show(new MainMenue_GUI());
}
});
lblHauptmen.setForeground(Color.BLUE);
@@ -438,10 +417,7 @@ public class SearchLecture_GUI extends JFrame { btnBack.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
// oeffnet das Hauptmenue
-
- MainMenue_GUI main = new MainMenue_GUI(c);
- main.setVisible(true);
- dispose();
+ GuiManager.show(new MainMenue_GUI());
}
});
btnBack.setActionCommand("OK");
@@ -548,71 +524,7 @@ public class SearchLecture_GUI extends JFrame { JScrollPane scrollPaneName = new JScrollPane(labelName);
scrollPaneName.setBounds(10, 40, 218, 55);
panel.add(scrollPaneName);
- //panel.add(labelName);
- //panel.add(labelimage);
-
- JMenuBar menuBar = new JMenuBar();
- setJMenuBar(menuBar);
-
- JMenu mnNewMenu_1 = new JMenu("Hilfe");
- menuBar.add(mnNewMenu_1);
-
- JMenuItem mntmFaq = new JMenuItem("FAQ");
- mntmFaq.addMouseListener(new MouseAdapter() {
- @SuppressWarnings("static-access")
- @Override
- public void mousePressed(MouseEvent arg0) {
-
- OpenLinks open = new OpenLinks();
-
- URI windows;
- try {
- windows = new URI(Links.getFAQ());
-
- open.openWebpage(windows);
-
- } catch (URISyntaxException e) {
-
- e.printStackTrace();
- }
- }
- });
- mnNewMenu_1.add(mntmFaq);
-
-
- JMenuItem mntmOtrs = new JMenuItem("OTRS");
- mntmOtrs.addMouseListener(new MouseAdapter() {
- @SuppressWarnings("static-access")
- @Override
- public void mousePressed(MouseEvent arg0) {
-
- OpenLinks open = new OpenLinks();
-
- URI windows;
- try {
- windows = new URI(Links.getOTRS());
-
- open.openWebpage(windows);
-
- } catch (URISyntaxException e) {
-
- e.printStackTrace();
- }
-
- }
- });
- mnNewMenu_1.add(mntmOtrs);
-
- JMenuItem mntmAbout = new JMenuItem("About");
- mntmAbout.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- About_GUI ab = new About_GUI();
- ab.setVisible(true);
- }
- });
- mnNewMenu_1.add(mntmAbout);
- c = this;
}
diff --git a/dozentenmodul/src/main/java/models/Links.java b/dozentenmodul/src/main/java/models/Links.java deleted file mode 100644 index 80e3182e..00000000 --- a/dozentenmodul/src/main/java/models/Links.java +++ /dev/null @@ -1,31 +0,0 @@ -package models; - -public class Links { - - private static String FAQ = "http://bwlehrpool.hs-offenburg.de/"; - private static String OTRS = "http://bwlehrpool.hs-offenburg.de/"; - private static String uriWindows = "https://my.vmware.com/de/web/vmware/free#desktop_end_user_computing/vmware_player/6_0"; - private static String uriLinux = "https://my.vmware.com/de/web/vmware/free#desktop_end_user_computing/vmware_player/6_0"; - private static String AnleitungVMDK = "http://www.hs-offenburg.de/fileadmin/Einrichtungen/hrz/Projekte/bwLehrpool/3_bwLehrpool_-_Image_einbinden_und_starten.pdf"; - - public static String getFAQ() { - return FAQ; - } - - public static String getAnleitungVMDK(){ - return AnleitungVMDK; - } - - public static String getOTRS() { - return OTRS; - } - - public static String getUriWindows() { - return uriWindows; - } - - public static String getUriLinux() { - return uriLinux; - } - -}// end class diff --git a/dozentenmodul/src/main/java/thrift/ThriftManager.java b/dozentenmodul/src/main/java/thrift/ThriftManager.java index 716c4439..cc085ecd 100644 --- a/dozentenmodul/src/main/java/thrift/ThriftManager.java +++ b/dozentenmodul/src/main/java/thrift/ThriftManager.java @@ -1,5 +1,8 @@ package thrift; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + import org.apache.log4j.Logger; import org.apache.thrift.protocol.TBinaryProtocol; import org.apache.thrift.protocol.TProtocol; @@ -44,6 +47,15 @@ public class ThriftManager { private static final int SATELLITE_TIMEOUT = 10000; /** + * IP Validation Regex + */ + private static final String IP_VALID_PATTERN = + "^([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\." + + "([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\." + + "([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\." + + "([01]?\\d\\d?|2[0-4]\\d|25[0-5])$"; + + /** * Protected constructor to avoid external instantiation */ protected ThriftManager() { @@ -106,6 +118,7 @@ public class ThriftManager { final TProtocol protocol = new TBinaryProtocol(transport); // now we are ready to create the client, according to ClientType! _satClient.set(new Server.Client(protocol)); + LOGGER.info("Satellite '" + SATELLITE_IP + "' reachable. Client initialised."); } return true; } @@ -119,7 +132,22 @@ public class ThriftManager { LOGGER.error("Given IP for satellite is empty."); return false; } + // validate + Matcher matcher = Pattern.compile(IP_VALID_PATTERN).matcher(ip); + if (!matcher.matches()) { + LOGGER.error("Given form of IP is invalid: " + ip); + return false; + } + // finally set it SATELLITE_IP = ip; + + // last check: try to connect + if (!init(ClientType.SATELLITE, SATELLITE_IP, SATELLITE_PORT, SATELLITE_TIMEOUT)) { + // init failed + LOGGER.error("Could not initialise new client to satellite: " + SATELLITE_IP); + return false; + } + // TODO final last: get version from server return true; } /** diff --git a/dozentenmodul/src/main/java/util/GuiManager.java b/dozentenmodul/src/main/java/util/GuiManager.java new file mode 100644 index 00000000..a2c4cd1f --- /dev/null +++ b/dozentenmodul/src/main/java/util/GuiManager.java @@ -0,0 +1,273 @@ +package util; + +import gui.intro.About_GUI; +import gui.intro.Login_GUI; + +import java.awt.BorderLayout; +import java.awt.Component; +import java.awt.GraphicsConfiguration; +import java.awt.GraphicsDevice; +import java.awt.GraphicsEnvironment; +import java.awt.HeadlessException; +import java.awt.Rectangle; +import java.awt.Window; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; + +import javax.swing.JFrame; +import javax.swing.JInternalFrame; +import javax.swing.JMenu; +import javax.swing.JMenuBar; +import javax.swing.JMenuItem; +import javax.swing.JOptionPane; +import javax.swing.plaf.basic.BasicInternalFrameUI; + +import org.apache.log4j.Logger; + +/** + * An abstract class to organize the GUI. + * Currently only provide a method for centering Window-objects. + */ +public abstract class GuiManager { + + private final static Logger LOGGER = Logger.getLogger(GuiManager.class); + + /** + * The rectangle representing the bounds of the primary display + */ + private static Rectangle rect = null; + + /** + * Gets the bounds of the primary display using + * AWT's GraphicsEnvironment class. + */ + private static boolean getDisplayBounds() { + GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); + GraphicsDevice gd = null; + try { + gd = ge.getDefaultScreenDevice(); + } catch (HeadlessException he) { + he.printStackTrace(); + JOptionPane.showMessageDialog(null, "Konnte kein Display ermittelt werden.", + "Fehler", JOptionPane.ERROR_MESSAGE); + return false; + } + + GraphicsConfiguration gc = gd.getDefaultConfiguration(); + rect = gc.getBounds(); + + if (rect == null) { + JOptionPane.showMessageDialog(null, "Konnte die Resolution des Bildschirms nicht ermitteln!", + "Fehler", JOptionPane.ERROR_MESSAGE); + return false; + } else { + return true; + } + } + + /** + * Centers the given Window within the bounds of the display + * @param gui The Window object to be centered. + */ + public static void centerGUI(Window gui) { + + if (rect == null) getDisplayBounds(); + double width = rect.getWidth(); + double height = rect.getHeight(); + double xCenter = (width / 2 - gui.getWidth() / 2); + double yCenter = (height / 2 - gui.getHeight() / 2); + gui.setLocation((int) xCenter, (int) yCenter); + } + + private static JFrame mainWindow = null; + public static JFrame getMainWindow() { + return mainWindow; + } + private static JInternalFrame currentFrame = null; + // TODO use this formerFrame when going "back" in the gui + private static JInternalFrame formerFrame = null; + + /** + * Starts the GUI by creating the main window + * and showing the Login_GUI as the first frame. + */ + public static void initGui() { + // get the screen size + getDisplayBounds(); + if (rect == null) { + LOGGER.error("Could not get display size. Contact developper."); + System.exit(1); + } + + // create main window + mainWindow = new JFrame("DozMod"); + mainWindow.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + mainWindow.setResizable(false); + + // create login frame + currentFrame = new Login_GUI(); + mainWindow.getContentPane().add(currentFrame, BorderLayout.CENTER); + ((BasicInternalFrameUI)currentFrame.getUI()).setNorthPane(null); + mainWindow.pack(); + + // size management + mainWindow.setBounds(0, 0, 785, 430); + mainWindow.setLocation((int) (rect.getWidth() / 2 - mainWindow.getWidth() / 2), + (int) (rect.getHeight() / 2 - mainWindow.getHeight() / 2)); + + // finally let's see the frames + currentFrame.setVisible(true); + mainWindow.setVisible(true); + } + + /** + * Private function to add the menu bar to the main window. + * @return true if adding the menu bar worked, false otherwise + */ + private static boolean addMenuBar() { + JMenuBar menuBar = new JMenuBar(); + mainWindow.setJMenuBar(menuBar); + + JMenu helpMenu = new JMenu("Hilfe"); + menuBar.add(helpMenu); + + // FAQ Field + JMenuItem mntmFaq = new JMenuItem("FAQ"); + mntmFaq.addMouseListener(new MouseAdapter() { + @Override + public void mousePressed(MouseEvent arg0) { + OpenLinks.openWebpage("faq"); + } + }); + helpMenu.add(mntmFaq); + // OTRS Field + JMenuItem mntmOtrs = new JMenuItem("OTRS"); + mntmOtrs.addMouseListener(new MouseAdapter() { + @Override + public void mousePressed(MouseEvent arg0) { + OpenLinks.openWebpage("otrs"); + } + }); + helpMenu.add(mntmOtrs); + // About Field + JMenuItem mntmAbout = new JMenuItem("About"); + mntmAbout.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent arg0) { + GuiManager.openPopup(new About_GUI()); + } + }); + helpMenu.add(mntmAbout); + return true; + } + /** + * Private function to determine whether the currentFrame has a + * 'HELP_MESSAGE' defined and to add it to the menu bar if found one. + * @return true if setting the help button to the menu bar worked, false otherwise + */ + private static boolean addHelp() { + // let's see if we have a HELP_MESSAGE variable defined in + // the class of the currentFrame, if so we need to show it by pressing "Hilfe" + String test = ""; + try { + test = (String) (currentFrame.getClass().getDeclaredField("HELP_MESSAGE").get(currentFrame)); + } catch (NoSuchFieldException e) { + // only this case if interesting for us, + // since we now we don't have a help message to show + LOGGER.debug("No 'HELP_MESSAGE' defined in class: " + currentFrame.getClass().getName()); + return true; + } catch (IllegalArgumentException|IllegalAccessException|SecurityException e) { + LOGGER.error("Failed to check for 'HELP_MESSAGE' variable in '" + + currentFrame.getClass() + "' class, see trace: " + e); + // just do nothing + } + // print it for debugging purposes + LOGGER.debug("HELP_MESSAGE of '" + currentFrame.getClass().getName() + "': " + test); + // still here? means we have a HELP_MESSAGE to display + JMenu mnNewMenu_Info = new JMenu("Info"); + mnNewMenu_Info.addMouseListener(new MouseAdapter() { + @Override + public void mousePressed(MouseEvent arg0) { + String helpMessage = null; + try { + helpMessage = (String) currentFrame.getClass().getField("HELP_MESSAGE").get(currentFrame); + } catch (IllegalArgumentException | IllegalAccessException + | NoSuchFieldException | SecurityException e) { + LOGGER.error("Failed to check for 'HELP_MESSAGE' variable in '" + + currentFrame.getClass() + "' class, see trace: " + e); + } + JOptionPane.showMessageDialog(currentFrame, helpMessage != null ? helpMessage : "No help message.", + "Hilfe zu dieser Oberfläche", JOptionPane.INFORMATION_MESSAGE); + } + }); + mainWindow.getJMenuBar().add(mnNewMenu_Info); + return true; + } + + /** + * Public function to show the given frame, replacing the current frame + * @param newFrame the new frame to show + */ + public static void show(JInternalFrame newFrame) { + // first remove the current component + currentFrame.setVisible(false); + mainWindow.getContentPane().remove(currentFrame); + // save it as formerFrame in case we need it + formerFrame = currentFrame; + // from now on currentFrame is newFrame !!! + currentFrame = newFrame; + currentFrame.setBorder(null); + + // show the menu bar for everything but the Login_GUI + if (!(currentFrame instanceof Login_GUI)) { + if (mainWindow.getMenuBar() == null) { + if (!addMenuBar()) { + LOGGER.error("Failed to add menu to main window. See logs."); + } + } + // add help if needed + if (!addHelp()) { + LOGGER.error("Failed to add help to main window's menu. See logs."); + } + } + // prepare the switch + if (currentFrame.getUI() instanceof BasicInternalFrameUI) { + BasicInternalFrameUI bar = ((BasicInternalFrameUI) currentFrame.getUI()); + if (bar.getNorthPane() != null) bar.setNorthPane(null); + } + // TODO else case + + mainWindow.setTitle(newFrame.getTitle() != null ? newFrame.getTitle() : "bwLehrpool Suite"); + mainWindow.getContentPane().add(currentFrame, BorderLayout.CENTER); + mainWindow.setBounds((int)mainWindow.getLocationOnScreen().getX(), (int)mainWindow.getLocationOnScreen().getY(), + currentFrame.getWidth(), currentFrame.getHeight()); + currentFrame.setVisible(true); + + } + /** + * Public function to show the given frame, replacing the current frame + * @param newFrame the new frame to show + * @param center true if the main window is to be centered, false otherwise + */ + public static void show(JInternalFrame newFrame, boolean center) { + show(newFrame); + if (center) { + double xCenter = (rect.getWidth() / 2 - newFrame.getWidth() / 2); + double yCenter = (rect.getHeight() / 2 - newFrame.getHeight() / 2); + mainWindow.setBounds((int) xCenter, (int) yCenter, + newFrame.getWidth(), newFrame.getHeight()); + } + } + /** + * + */ + public static void openPopup(Component popup) { + if (!(popup instanceof JFrame)) { + LOGGER.error("Popup classes need to be JFrame, given a: " + popup.getClass().getName()); + return; + } + ((JFrame)popup).setLocation((int)(rect.getWidth() / 2 - popup.getWidth() / 2), (int)(rect.getHeight() / 2 - popup.getHeight() / 2)); + ((JFrame)popup).setVisible(true); + } +} diff --git a/dozentenmodul/src/main/java/util/GuiOrganizer.java b/dozentenmodul/src/main/java/util/GuiOrganizer.java deleted file mode 100644 index 55cc2030..00000000 --- a/dozentenmodul/src/main/java/util/GuiOrganizer.java +++ /dev/null @@ -1,66 +0,0 @@ -package util; - -import java.awt.GraphicsConfiguration; -import java.awt.GraphicsDevice; -import java.awt.GraphicsEnvironment; -import java.awt.HeadlessException; -import java.awt.Rectangle; -import java.awt.Window; - - -import javax.swing.JOptionPane; - -/** - * An abstract class to organize the GUI. - * Currently only provide a method for centering Window-objects. - */ -public abstract class GuiOrganizer { - - /** - * The rectangle representing the bounds of the primary display - */ - private static Rectangle rect = null; - - /** - * Gets the bounds of the primary display using - * AWT's GraphicsEnvironment class. - */ - private static boolean getDisplayBounds() { - GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); - GraphicsDevice gd = null; - try { - gd = ge.getDefaultScreenDevice(); - } catch (HeadlessException he) { - he.printStackTrace(); - JOptionPane.showMessageDialog(null, "Konnte kein Display ermittelt werden.", - "Fehler", JOptionPane.ERROR_MESSAGE); - return false; - } - - GraphicsConfiguration gc = gd.getDefaultConfiguration(); - rect = gc.getBounds(); - - if (rect == null) { - JOptionPane.showMessageDialog(null, "Konnte die Resolution des Bildschirms nicht ermitteln!", - "Fehler", JOptionPane.ERROR_MESSAGE); - return false; - } else { - return true; - } - } - - /** - * Centers the given Window within the bounds of the display - * @param gui The Window object to be centered. - */ - public static void centerGUI(Window gui) { - - if (rect == null) getDisplayBounds(); - - double width = rect.getWidth(); - double height = rect.getHeight(); - double xPosition = (width / 2 - gui.getWidth() / 2); - double yPosition = (height / 2 - gui.getHeight() / 2); - gui.setLocation((int) xPosition, (int) yPosition); - } -} diff --git a/dozentenmodul/src/main/java/util/ListAllOtherUsers_GUI.java b/dozentenmodul/src/main/java/util/ListAllOtherUsers_GUI.java index 56adaf4f..37f30dc3 100644 --- a/dozentenmodul/src/main/java/util/ListAllOtherUsers_GUI.java +++ b/dozentenmodul/src/main/java/util/ListAllOtherUsers_GUI.java @@ -1,19 +1,13 @@ package util; -import gui.intro.About_GUI; - import java.awt.Component; import java.awt.FlowLayout; import java.awt.Font; import java.awt.SystemColor; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; -import java.net.URI; -import java.net.URISyntaxException; import java.util.ArrayList; import java.util.Iterator; import java.util.List; @@ -22,10 +16,6 @@ import javax.swing.DefaultListSelectionModel; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JLabel; -import javax.swing.JMenu; -import javax.swing.JMenuBar; -import javax.swing.JMenuItem; -import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.JSeparator; @@ -38,7 +28,6 @@ import javax.swing.table.DefaultTableModel; import javax.swing.table.TableModel; import javax.swing.table.TableRowSorter; -import models.Links; import models.SessionData; import models.person; @@ -69,7 +58,7 @@ public class ListAllOtherUsers_GUI extends JFrame { List<String> user = new ArrayList<String>(); - private static final String HELP_MESSAGE = "<html><div align=\"center\">" + public static final String HELP_MESSAGE = "<html><div align=\"center\">" + "In der Übersicht sehen Sie primär alle Veranstaltungen, die Sie erzeugt haben.<br />" + "Sie können die Veranstaltungen hier löschen. Alternativ werden veraltete Einträge irgendwann automatisch gelöscht.<br />" + "Veraltet bedeutet, dass Veranstaltungen, die drei Monate lang nicht augerufen wurden, vorerst deaktiviert werden." @@ -90,7 +79,7 @@ public class ListAllOtherUsers_GUI extends JFrame { * Constructor */ - public ListAllOtherUsers_GUI(Component formerGUI, final JTable table, + public ListAllOtherUsers_GUI(final JTable table, final int userIDPos) { // get table model to work with @@ -101,11 +90,6 @@ public class ListAllOtherUsers_GUI extends JFrame { this.userIDPos=userIDPos; addWindowListener(new WindowAdapter() { - @Override - public void windowClosing(WindowEvent arg0) { - // Beendet die Anwendung nach klick auf X - dispose(); - } @Override public void windowOpened(WindowEvent arg0) { @@ -133,7 +117,7 @@ public class ListAllOtherUsers_GUI extends JFrame { setTitle("bwLehrpool Suite - Benutzer hinzufügen"); // Zentriert das Fenster in die Bildmitte setBounds(0, 0, 531, 673); - setLocationRelativeTo(formerGUI); + getContentPane().setLayout(null); { @@ -270,68 +254,6 @@ public class ListAllOtherUsers_GUI extends JFrame { JSeparator separator_1 = new JSeparator(); separator_1.setBounds(0, 552, 836, 1); getContentPane().add(separator_1); - - JMenuBar menuBar = new JMenuBar(); - setJMenuBar(menuBar); - - JMenu mnNewMenu_1 = new JMenu("Hilfe"); - menuBar.add(mnNewMenu_1); - - JMenuItem mntmFaq = new JMenuItem("FAQ"); - mntmFaq.addMouseListener(new MouseAdapter() { - @Override - public void mousePressed(MouseEvent arg0) { - - URI windows; - try { - windows = new URI(Links.getFAQ()); - OpenLinks.openWebpage(windows); - } catch (URISyntaxException e) { - - e.printStackTrace(); - } - } - }); - mnNewMenu_1.add(mntmFaq); - - JMenuItem mntmOtrs = new JMenuItem("OTRS"); - mntmOtrs.addMouseListener(new MouseAdapter() { - @Override - public void mousePressed(MouseEvent arg0) { - - URI windows; - try { - windows = new URI(Links.getOTRS()); - OpenLinks.openWebpage(windows); - } catch (URISyntaxException e) { - e.printStackTrace(); - } - } - }); - mnNewMenu_1.add(mntmOtrs); - - JMenuItem mntmAbout = new JMenuItem("About"); - mntmAbout.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - About_GUI ab = new About_GUI(); - ab.setVisible(true); - } - }); - mnNewMenu_1.add(mntmAbout); - - JMenu mnNewMenu_Info = new JMenu("Info"); - mnNewMenu_Info.addMouseListener(new MouseAdapter() { - @Override - public void mouseClicked(MouseEvent arg0) { - JOptionPane.showMessageDialog(c, HELP_MESSAGE, - "Hilfe zu dieser Oberfläche", - JOptionPane.INFORMATION_MESSAGE); - } - }); - menuBar.add(mnNewMenu_Info); - - c = this; - } diff --git a/dozentenmodul/src/main/java/util/OpenLinks.java b/dozentenmodul/src/main/java/util/OpenLinks.java index 2dd7b936..51695c96 100644 --- a/dozentenmodul/src/main/java/util/OpenLinks.java +++ b/dozentenmodul/src/main/java/util/OpenLinks.java @@ -2,17 +2,74 @@ package util; import java.awt.Desktop; import java.net.URI; +import java.net.URISyntaxException; +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; import javax.swing.JOptionPane; +import org.apache.log4j.Logger; + public class OpenLinks { - public static void openWebpage(URI uri) { + /** + * Logger instance for this class + */ + private final static Logger LOGGER = Logger.getLogger(ShibbolethECP.class); + + /** + * Map containing the links + */ + @SuppressWarnings("serial") + private static Map<String, String> links = Collections.unmodifiableMap(new HashMap<String, String>(){{ + put("faq", "http://bwlehrpool.hs-offenburg.de"); + put("otrs", "http://bwlehrpool.hs-offenburg.de"); + put("vmware", "https://my.vmware.com/de/web/vmware/free#desktop_end_user_computing/vmware_player/6_0"); + put("intro", "http://www.hs-offenburg.de/fileadmin/Einrichtungen/hrz/Projekte/bwLehrpool/3_bwLehrpool_-_Image_einbinden_und_starten.pdf"); + + }}); + + /** + * Static URIs + */ + + private static Map<String, URI> uris; + static { + // temp map + Map<String, URI> tmpUris = new HashMap<String, URI>(); + for (String key : links.keySet()) { + URI tmp; + try { + tmp = new URI(links.get(key)); + } catch (URISyntaxException e) { + // should never happen! + LOGGER.error("Bad URI syntax of '" + key + "', see trace: ", e); + tmp = null; + } + tmpUris.put(key, tmp); + } + // check sizes of maps to be equal + if (links.size() != tmpUris.size()) { + LOGGER.error("Links and URIs have different sizes, this should not happen. Contact a developper."); + } + + // all good, save it to the actual 'uris' map + uris = Collections.unmodifiableMap(tmpUris); + } + + + public static void openWebpage(String key) { + // first check if we have the link for the request key + if (!uris.containsKey(key)) { + LOGGER.error("OpenLinks has to link to '" + key + "'. Check if the given key actually exists."); + return; + } Desktop desktop = Desktop.isDesktopSupported() ? Desktop.getDesktop() : null; if (desktop != null && desktop.isSupported(Desktop.Action.BROWSE)) { try { - desktop.browse(uri); + desktop.browse(uris.get(key)); } catch (Exception e) { e.printStackTrace(); JOptionPane.showMessageDialog(null, diff --git a/dozentenmodul/src/main/java/util/ServiceProviderResponse.java b/dozentenmodul/src/main/java/util/ServiceProviderResponse.java index 99f120f1..37b93b33 100644 --- a/dozentenmodul/src/main/java/util/ServiceProviderResponse.java +++ b/dozentenmodul/src/main/java/util/ServiceProviderResponse.java @@ -1,7 +1,15 @@ package util; +import java.util.HashMap; + public class ServiceProviderResponse { public String status; - public String id; + public String firstName; + public String lastName; + public String mail; + public HashMap<String, String> satellites; + public String token; + public String sessionId; public String url; + public String error; } diff --git a/dozentenmodul/src/main/java/util/ShibbolethECP.java b/dozentenmodul/src/main/java/util/ShibbolethECP.java index b834b1a2..a3e13a38 100644 --- a/dozentenmodul/src/main/java/util/ShibbolethECP.java +++ b/dozentenmodul/src/main/java/util/ShibbolethECP.java @@ -33,6 +33,10 @@ public class ShibbolethECP { private static final Gson GSON = new GsonBuilder().create(); /** + * + */ + private static ServiceProviderResponse _lastResponse = null; + /** * URL for bwLehrpool registration */ private static URL _registrationUrl = null; @@ -71,7 +75,7 @@ public class ShibbolethECP { static { URI tmp; try { - tmp = new URI("https://bwlp-masterserver.ruf.uni-freiburg.de/secure-all/api.php"); + tmp = new URI("https://bwlp-masterserver.ruf.uni-freiburg.de/webif/shib/api.php"); } catch (URISyntaxException e) { // should never happen! LOGGER.error("Bad URI syntax of the service provider, see trace: ", e); @@ -80,6 +84,9 @@ public class ShibbolethECP { BWLP_SP = tmp; } + public static ServiceProviderResponse getResponse() { + return _lastResponse; + } /** * Fetches the resource * @@ -149,18 +156,18 @@ public class ShibbolethECP { LOGGER.error("I/O error, see trace: ", e); return ReturnCode.ERROR_OTHER; } - ServiceProviderResponse spr = null; + _lastResponse = null; try { - spr = GSON.fromJson(responseBody, ServiceProviderResponse.class); + _lastResponse = GSON.fromJson(responseBody, ServiceProviderResponse.class); } catch (JsonSyntaxException e) { LOGGER.error("Bad JSON syntax, see trace: ", e); return ReturnCode.ERROR_SP; } // TODO: here we will need to parse the answer accordingly. // no errors, meaning everything worked fine. - if (spr.status.equals("unregistered")) { + if (_lastResponse.status.equals("unregistered")) { try { - _registrationUrl = new URL(spr.url); + _registrationUrl = new URL(_lastResponse.url); } catch (MalformedURLException e) { LOGGER.error("URL returned by masterserver is malformed, see trace: " + e); return ReturnCode.ERROR_URL; @@ -168,7 +175,17 @@ public class ShibbolethECP { return ReturnCode.ERROR_UNREG; } // TODO the rest of the cases... - + if (_lastResponse.status.equals("error")) { + LOGGER.error("Server side error: " + _lastResponse.error); + return ReturnCode.ERROR_OTHER; + } + if (_lastResponse.status.equals("anonymous")) { + LOGGER.error("IdP did not forward user account information to SP. Contact developper."); + return ReturnCode.ERROR_OTHER; + } + if (_lastResponse.status.equals("ok")) { + return ReturnCode.NO_ERROR; + } // still here? then something else went wrong return ReturnCode.ERROR_OTHER; } |