final void setGuiInstance() { gui = cfg.getInstanceOfGUI(); }
public class ApplicationActions implements ActionListener { /** * ************************************************************************* Action-Listener = * Programm-Logik ***************************************** */ private Config cfg = Config.getInstance(); private Jan gui = cfg.getInstanceOfGUI(); private StatusBar statusBar = StatusBar.getInstance(); private Sound snd = Sound.getInstance(); private Resources res = Resources.getInstance(); private static ApplicationActions instance; private static LoginDialog lD = null; private SwingWorker<String, Void> workerWait; private SwingWorker<String, Void> workerLogin; private Wait wt = null; private static String act_dst = ""; private static Destination_List dl = null; public static synchronized ApplicationActions getInstance() { if (instance == null) { instance = new ApplicationActions(); } return instance; } private ApplicationActions() { this.setGuiInstance(); } final void setGuiInstance() { gui = cfg.getInstanceOfGUI(); } @Override public void actionPerformed(ActionEvent event) { String cmd = event.getActionCommand(); statusBar.setStatus("Befehl " + cmd + " wird ausgefuehrt..."); System.out.println(cmd); if (cfg.useCmd_log()) { SendToServer.info("Action:" + cmd); } /* * Aufruf einer "Unterfunktion" in separatem thread: * * !!! Setzt aber voraus, daß der ActionListener in einem separaten * "NichtSwingThread" läuft! * * SwingUtilities.invokeLater(new Runnable() { * * public void run() { jIntKfzLb lb = new jIntKfzLb(); MyEventListener * el = new MyEventListener(); lb.addMyEventListener(el); * lb.setVisible(true); dp.add(lb); } }); } */ /* * LOGIN mit Aufbau Vbdg. */ if (cmd.equals("Anmeldung")) { this.cfg.initLDAP(); this.gui.initMenu(); this.cfg.setDst_list(null); System.out.println("Starte Anmelde-Prozess..."); lD = LoginDialog.getInstance(); } if (cmd.equals("USER")) { String user = LoginDialog.getInstance().getUserName(); this.snd.play(Sound.SoundClip.KASSE); if (this.cfg.isDebug()) { System.out.println("USER: "******"LOGIN")) { if (this.cfg.isWaitPanel() && this.cfg.isUseSwingWorker()) { this.workerWait = new SwingWorker<String, Void>() { @Override protected String doInBackground() { wt = new Wait("WARTE", "Anmeldung am System..."); return "OK"; } @Override protected void done() {} }; workerLogin = new SwingWorker<String, Void>() { @Override protected String doInBackground() { gui.login2(); return "OK"; } @Override protected void done() { wt.stop(); } }; // bei Anmeldung wird versucht, LOG-Eintrag zu erstellen, auch // wenn eventuell vorher die Vbdg. zum CMD-Server ohne Erfolg war cfg.setCmd_log(true); workerWait.execute(); workerLogin.execute(); } else { CursorTools.startWaitCursor(gui); gui.login2(); CursorTools.stopWaitCursor(gui); } } if (cmd.equals("ABBRUCH")) { if (lD != null) { System.out.println("Abbruch LOGIN- Bearbeitung..."); lD.close(); lD = null; cfg.initLDAP(); cfg.setLogin_usr(""); cfg.setLogin_pwd(""); cfg.setLogin_ok(false); Jan.logger.info("===> Abbruch der Anmeldung "); snd.play(Sound.SoundClip.LASER); gui.setTitle(cfg.getTitle() + " <NICHT ANGEMELDET>"); } } // mit VM verbinden if (cmd.equals("CVM")) { if (cfg.isLogin_ok()) { act_dst = ""; dl = LdapEntry_Parser.parse_protocol(cfg.getLdap_vm().trim()); if (dl != null) { if (dl.getEntryNum() > 1) { SelectDestination sd = new SelectDestination(); act_dst = sd.getDestination(dl); } else if (dl.getEntryNum() == 1) { act_dst = dl.getDstList().get(0).getDestinationTitle(); } else { System.out.println("CVM: destination list is empty!!!"); } } else { System.out.println("CVM: destination list is NULL!!!"); } if (cfg.isDebug()) { System.out.print("selected destination: " + act_dst + "\n"); } StartClientReturnCode rc = Destination_Hub.startThis(act_dst); } else { String msg = "\n Sie sind nicht erfolgreich angemeldet! \n\n"; if (cfg.isInternalFrames()) { JOptionPane.showInternalMessageDialog( gui.getContentPane(), msg, "FEHLER", JOptionPane.ERROR_MESSAGE); } else { JOptionPane.showMessageDialog(gui, msg, "FEHLER", JOptionPane.ERROR_MESSAGE); } } } // Info/Version if (cmd.equals("VERSION")) { snd.play(Sound.SoundClip.TAB); String msg = "\n Titel: " + cfg.getTitle() + "\n Version: " + cfg.getVersion() + "\n\n Autor: " + cfg.getAutor() + "\n\n Info: " + cfg.getInfo() + "\n\n"; if (cfg.isInternalFrames()) { JOptionPane.showInternalMessageDialog( gui.getContentPane(), msg, "Info", JOptionPane.INFORMATION_MESSAGE); } else { JOptionPane.showMessageDialog(gui, msg, "Info", JOptionPane.INFORMATION_MESSAGE); } } // Info/Umgebung if (cmd.equals("ENV")) { String param; snd.play(Sound.SoundClip.TAB); if (cfg.getLdap_vm().length() > 77) { param = cfg.getLdap_vm().substring(1, 77) + "..."; } else { param = cfg.getLdap_vm(); } String msg = "\n" + cfg.getTitle() + "\n" + cfg.getVersion() + "\n\n Host: " + cfg.getLocal_HostName() + "\n IP: " + cfg.getLocal_IP() + "\n MAC: " + cfg.getLocal_MAC() + "\n java version: " + cfg.getLocal_java_version() + "\n os name: " + cfg.getLocal_os_name() + "\n linux Rel.: " + cfg.getLinuxRelease() + "\n jvm version: " + cfg.getLocal_jvm_version() + "\n\n user: "******"\n context: " + cfg.getLogin_context() + "\n PARAM: " + param + "\n eMail: " + cfg.getLdap_mail() + "\n fullName: " + cfg.getLdap_fullName() + "\n last login time: " + Tools.t2s(cfg.getLdap_loginTime()) + "\n login exp. time: " + Tools.t2s(cfg.getLdap_passwordExpirationTime()) + "\n login disabled : " + cfg.getLdap_loginDisabled() + "\n login grace limit : " + cfg.getLdap_loginGraceLimit() + "\n login grace remaining : " + cfg.getLdap_loginGraceRemaining() + "\n passwordMinimumLength : " + cfg.getLdap_passwordMinimumLength() + "\n passwordUniqueRequired: " + cfg.getLdap_passwordUniqueRequired() + "\n\n"; if (cfg.isInternalFrames()) { JOptionPane.showInternalMessageDialog( gui.getContentPane(), msg, "Umgebung", JOptionPane.INFORMATION_MESSAGE); } else { JOptionPane.showMessageDialog(gui, msg, "Umgebung", JOptionPane.INFORMATION_MESSAGE); } } // Info/Uhr if (cmd.equals("UHR")) { JDialog f = new JDialog(); f.setTitle("Uhr-Zeit"); f.setIconImage(res.clockIcon); f.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); f.setResizable(false); f.getContentPane().add(new Clock()); f.pack(); f.setLocationRelativeTo(null); f.setAlwaysOnTop(true); f.setResizable(false); f.setVisible(true); } // Hilfe001 if (cmd.equals("HELP001")) { Calendar cal = Calendar.getInstance(); int day = cal.get(Calendar.DAY_OF_MONTH); int month = cal.get(Calendar.MONTH); if (day == 7 && month == 9) { // 7. October Help00x.show(); } else { Help000.show(); } } // CountDown via ProgressMonitor if (cmd.equals("CNTDWN")) { final JDialog f = new JDialog(); f.setTitle("FRAGE"); f.setResizable(false); f.setIconImage(res.clockIcon); f.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); f.setSize(290, 220); JLabel l1 = new JLabel("Start-Befehl wurde gesendet."); JLabel l2 = new JLabel(" Was soll ich jetzt tun?"); final JButton ok = new JButton("VERBINDEN"); ok.setMnemonic('v'); ok.setIcon(res.computerImageIcon); ok.setToolTipText("Verbindung wird erneut versucht."); ok.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { gui.getInstance().startRHEV(true); f.dispose(); } }); final JButton cancel = new JButton("Abbruch"); cancel.setMnemonic('a'); cancel.setIcon(res.cancelImageIcon); cancel.setToolTipText("Funktion abbrechen."); cancel.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { f.dispose(); } }); JPanel p = new JPanel(); p.setLayout(new BorderLayout()); JPanel p_north = new JPanel(); JPanel p_south = new JPanel(); JPanel p_center = new JPanel(); JPanel p_east = new JPanel(); JPanel p_west = new JPanel(); p_center.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.RAISED)); p_north.add(l1); p_center.add(l2); p_south.add(ok); p_south.add(cancel); p.add(BorderLayout.NORTH, p_north); p.add(BorderLayout.SOUTH, p_south); p.add(BorderLayout.CENTER, p_center); p.add(BorderLayout.EAST, p_east); p.add(BorderLayout.WEST, p_west); CountDown cd = new CountDown(cfg.getRhevCntDwnVMstart()); // p.add(cd); f.add(p); f.pack(); f.setLocationRelativeTo(null); f.setVisible(true); cd.start(); } // Senden if (cmd.equals("SENDEN")) { if (cfg.isLogin_ok()) { System.out.println("starte Sende-Dialog!"); int result = ImportSelector.selectFiles(); if (result > 0) { System.out.println("" + result + " Dateien übertragen"); } else { System.out.println("Fehler " + result + " beim Senden der Dateien aufgetreten."); } } else { String msg = "\n Sie sind nicht erfolgreich angemeldet! \n\n"; if (cfg.isInternalFrames()) { JOptionPane.showInternalMessageDialog( gui.getContentPane(), msg, "FEHLER", JOptionPane.ERROR_MESSAGE); } else { JOptionPane.showMessageDialog(gui, msg, "FEHLER", JOptionPane.ERROR_MESSAGE); } } } // Empfangen if (cmd.equals("EMPFANGEN")) { if (cfg.isLogin_ok()) { System.out.println("starte Empfang-Dialog!"); int result = ExportSelector.selectFiles(); if (result > 0) { System.out.println("" + result + " Dateien kopiert"); } else { System.out.println("Fehler " + result + " beim Empfang der Dateien aufgetreten."); } } else { String msg = "\n Sie sind nicht erfolgreich angemeldet! \n\n"; if (cfg.isInternalFrames()) { JOptionPane.showInternalMessageDialog( gui.getContentPane(), msg, "FEHLER", JOptionPane.ERROR_MESSAGE); } else { JOptionPane.showMessageDialog(gui, msg, "FEHLER", JOptionPane.ERROR_MESSAGE); } } } // Programm-Ende if (cmd.equals("ENDE")) { gui.sac(); } // Computer ausschalten if (cmd.equals("SHUTDOWN")) { System.out.println("Starte Shutdown-Prozess..."); gui.shutdownClient(); } statusBar.setStatus("Befehl " + cmd + " beendet."); } }