public void manageThreads() { try { DDTP request = new DDTP(); request.setRequestID(String.valueOf(System.currentTimeMillis())); DDTP response = channel.sendRequest("ThreadProcessor", "manageThreadsLoad", request); if (response != null) { DialogThreadManager dlg = new DialogThreadManager(this, channel, response.getVector("vtTableData")); dlg.setComboStartupType(response.getVector("vtStartupType"), ""); WindowManager.centeredWindow(dlg); } } catch (Exception e) { e.printStackTrace(); MessageBox.showMessageDialog(this, e, Global.APP_NAME, MessageBox.ERROR_MESSAGE); } }
//////////////////////////////////////////////////////// // Purpose: send message stop server // Author: TrungDD // Date: 10/2003 //////////////////////////////////////////////////////// public void stopServer() { if (MessageBox.showConfirmDialog( this, MonitorDictionary.getString("Confirm.Shutdown"), Global.APP_NAME, MessageBox.YES_NO_OPTION) == MessageBox.NO_OPTION) return; try { DDTP request = new DDTP(); request.setRequestID(String.valueOf(System.currentTimeMillis())); channel.sendRequest("ThreadProcessor", "closeServer", request); } catch (Exception e) { e.printStackTrace(); MessageBox.showMessageDialog(this, e, Global.APP_NAME, MessageBox.ERROR_MESSAGE); } }
public void updateLanguage() { ////////////////////////////////////////////////////////////// mdic = MonitorDictionary.getChildDictionary("ThreadManager"); MonitorDictionary.applyButton(btnKick, "Kick"); MonitorDictionary.applyButton(btnRefresh, "Refresh"); MonitorDictionary.applyButton(btnSend, "Send"); tblUser.setColumnNameEx(mdic.getString("LoginName"), 1); tblUser.setColumnNameEx(mdic.getString("LoginTime"), 2); tblUser.setColumnNameEx(mdic.getString("Host"), 3); ////////////////////////////////////////////////////////////// MonitorDictionary.applyButton(mnuSelectAll, "jmenu.Edit.SelectAll"); MonitorDictionary.applyButton(mnuClearAll, "jmenu.Edit.ClearAll"); MonitorDictionary.applyButton(mnuClearSelected, "jmenu.Edit.ClearSelected"); ////////////////////////////////////////////////////////////// MonitorDictionary.applyButton(mnuSystem, "jmenu.System"); MonitorDictionary.applyButton(mnuSystem_ChangePassword, "jmenu.System.ChangePassword"); MonitorDictionary.applyButton(mnuSystem_StopServer, "jmenu.System.Shutdown"); MonitorDictionary.applyButton(mnuSystem_EnableThreads, "jmenu.System.ThreadManager"); MonitorDictionary.applyButton(mnuHelp, "jmenu.Help"); MonitorDictionary.applyButton(mnuHelp_About, "jmenu.Help.About"); ////////////////////////////////////////////////////////////// MonitorDictionary.applyButton(mnuUI, "jmenu.UI"); ////////////////////////////////////////////////////////////// if (isOpen()) { lblStatus.setText( " " + MonitorDictionary.getString("LoggedUser") + ": " + channel.getUserName()); MonitorDictionary.applyButton(mnuSystem_Login, "jmenu.System.Logout"); mnuSystem_ChangePassword.setEnabled(true); mnuSystem_StopServer.setEnabled(true); mnuSystem_EnableThreads.setEnabled(true); } else { lblStatus.setText(""); MonitorDictionary.applyButton(mnuSystem_Login, "jmenu.System.Login"); mnuSystem_ChangePassword.setEnabled(false); mnuSystem_StopServer.setEnabled(false); mnuSystem_EnableThreads.setEnabled(false); } ////////////////////////////////////////////////////////////// for (int iIndex = 0; iIndex < pnlThread.getTabCount(); iIndex++) ((PanelThreadMonitor) pnlThread.getComponentAt(iIndex)).updateLanguage(); }
public void disconnect() { if (channel != null) channel.close(); }
public void login() { mbAutoLogIn = false; while (!mbAutoLogIn) { try { // Confirm logout if (isOpen()) { if (MessageBox.showConfirmDialog( this, MonitorDictionary.getString("Confirm.Exit"), Global.APP_NAME, MessageBox.YES_NO_OPTION) == MessageBox.NO_OPTION) return; // Disconnect from server disconnect(); } // Login DialogLogin dlgLogin = new DialogLogin(this); WindowManager.centeredWindow(dlgLogin); if (dlgLogin.miReturn == JOptionPane.OK_OPTION) { // Update UI SwingUtilities.updateComponentTreeUI(pnlUser); SwingUtilities.updateComponentTreeUI(pnlThread); // Request to connect Socket sck = new Socket(dlgLogin.mstrHost, Integer.parseInt(dlgLogin.mstrPort)); sck.setSoLinger(true, 0); // Start up a channel thread that reads messages from the server channel = new SocketTransmitter(sck) { public void close() { if (msckMain != null) { super.close(); closeAll(); if (mbAutoLogIn) login(); } } }; channel.setUserName(dlgLogin.mstrUserName); channel.setPackage("com.fss.thread."); channel.start(); // Request to Server DDTP request = new DDTP(); request.setRequestID(String.valueOf(System.currentTimeMillis())); request.setString("UserName", dlgLogin.mstrUserName); request.setString("Password", dlgLogin.mstrPassword); // Response from Server DDTP response = channel.sendRequest("ThreadProcessor", "login", request); mstrThreadAppName = response.getString("strThreadAppName"); mstrThreadAppVersion = response.getString("strThreadAppVersion"); mstrAppName = response.getString("strAppName"); mstrAppVersion = response.getString("strAppVersion"); if (response != null) { if (response.getString("PasswordExpired") != null) { DialogChangePassword frm = new DialogChangePassword(this, channel); WindowManager.centeredWindow(frm); if (frm.miReturnValue != JOptionPane.OK_OPTION) throw new AppException("FSS-10003"); } String strLog = StringUtil.nvl(response.getString("strLog"), ""); showResult(txtBoard, strLog); Vector vtThread = response.getVector("vtThread"); updateTabBar(vtThread); mstrChannel = response.getString("strChannel"); if (mstrChannel != null) removeUser(mstrChannel); } btnRefresh.doClick(); pnlThread.setVisible(true); pnlUser.setVisible(true); setResizeWeight(1); setDividerLocation((int) (getSize().getHeight() - 160)); } mbAutoLogIn = true; updateLanguage(); } catch (Exception e) { e.printStackTrace(); MessageBox.showMessageDialog(this, e, Global.APP_NAME, MessageBox.ERROR_MESSAGE); // Disconnect from server mstrChannel = null; disconnect(); } } }
public boolean isOpen() { return (channel != null && channel.isOpen()); }