protected void closingDown(TerminalViewInterface view) { Sessions sess = manager.getSessions(); if (log.isDebugEnabled()) { log.debug("number of active sessions is " + sess.getCount()); } if (viewNamesForNextStartBuilder == null) { // preserve sessions for next boot viewNamesForNextStartBuilder = new StringBuilder(); } while (view.getSessionViewCount() > 0) { SessionPanel sesspanel = view.getSessionAt(0); viewNamesForNextStartBuilder.append("-s ").append(sesspanel.getSessionName()).append(" "); closeSessionInternal(sesspanel); } sessions.setProperty( "emul.frame" + view.getFrameSequence(), view.getX() + "," + view.getY() + "," + view.getWidth() + "," + view.getHeight()); frames.remove(view); view.dispose(); log.debug("number of active sessions we have after shutting down " + sess.getCount()); log.info("view settings " + viewNamesForNextStartBuilder); if (sess.getCount() == 0) { sessions.setProperty("emul.width", Integer.toString(view.getWidth())); sessions.setProperty("emul.height", Integer.toString(view.getHeight())); sessions.setProperty("emul.view", viewNamesForNextStartBuilder.toString()); // save off the session settings before closing down ConfigureFactory.getInstance() .saveSettings( ConfigureFactory.SESSIONS, ConfigureFactory.SESSIONS, "------ Defaults --------"); if (controller != null) { controller.interrupt(); } System.exit(0); } }
protected void closeSessionInternal(SessionPanel sesspanel) { TerminalViewInterface f = getParentView(sesspanel); if (f == null) { return; } Sessions sessions = manager.getSessions(); if ((sessions.item(sesspanel.getSession())) != null) { f.removeSessionView(sesspanel); manager.closeSession(sesspanel); } if (manager.getSessions().getCount() < 1) { closingDown(f); } }
protected synchronized SessionPanel newSession(String sel, String[] args) { Properties sesProps = new Properties(); String propFileName = null; String session = args[0]; // Start loading properties sesProps.put(TN5250jConstants.SESSION_HOST, session); if (isSpecified("-e", args)) sesProps.put(TN5250jConstants.SESSION_TN_ENHANCED, "1"); if (isSpecified("-p", args)) { sesProps.put(TN5250jConstants.SESSION_HOST_PORT, getParm("-p", args)); } if (isSpecified("-f", args)) propFileName = getParm("-f", args); // TODO: remove default codepage behavior and replace it with 870 if (isSpecified("-cp", args)) sesProps.put(TN5250jConstants.SESSION_CODE_PAGE, getParm("-cp", args)); sesProps.put(TN5250jConstants.SESSION_USE_GUI, "1"); if (isSpecified("-t", args)) sesProps.put(TN5250jConstants.SESSION_TERM_NAME_SYSTEM, "1"); sesProps.put(TN5250jConstants.SESSION_SCREEN_SIZE, TN5250jConstants.SCREEN_SIZE_24X80_STR); // TODO: are we to use a ssl and if we are what type sesProps.put(TN5250jConstants.SSL_TYPE, TN5250jConstants.SSL_TYPE_TLS); // check if device name is specified if (isSpecified("-dn=hostname", args)) { String dnParam; // use IP address as device name try { dnParam = InetAddress.getLocalHost().getHostName(); } catch (UnknownHostException uhe) { dnParam = "UNKNOWN_HOST"; } sesProps.put(TN5250jConstants.SESSION_DEVICE_NAME, dnParam); } else if (isSpecified("-dn", args)) { sesProps.put(TN5250jConstants.SESSION_DEVICE_NAME, getParm("-dn", args)); } if (isSpecified("-hb", args)) sesProps.put(TN5250jConstants.SESSION_HEART_BEAT, "1"); int sessionCount = manager.getSessions().getCount(); // here we open a new 5250 session on the current session manager Session5250 s2 = manager.openSession(sesProps, propFileName, sel); // ... and a panel containing it SessionPanel s = new SessionPanel(s2); newView(); frame.setVisible(true); frame.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); if (isSpecified("-t", args)) frame.addSessionView(sel, s); else frame.addSessionView(session, s); s.connect(); s.addEmulatorActionListener(this); return s; }