tn5250j/src/org/tn5250j Gui5250Frame.java,1.23,1.24 Gui5250MDIFrame.java,1.19,1.20 Gui5250SplitFrame.java,1.4,1.5

"Kenneth J. Pouncey" <[email protected]> Thu, 22 Jul 2004 05:49:49 +0000
Newsgroups gmane.comp.java.tn5250j.cvs
Message-ID <[email protected]>
Update of /cvsroot/tn5250j/tn5250j/src/org/tn5250j
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10694

Modified Files:
	Gui5250Frame.java Gui5250MDIFrame.java Gui5250SplitFrame.java 
Log Message:
Updates for headless

Index: Gui5250SplitFrame.java
===================================================================
RCS file: /cvsroot/tn5250j/tn5250j/src/org/tn5250j/Gui5250SplitFrame.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** Gui5250SplitFrame.java	30 Jun 2004 06:18:56 -0000	1.4
--- Gui5250SplitFrame.java	22 Jul 2004 05:49:47 -0000	1.5
***************
*** 1,397 ****
! package org.tn5250j;
! /**
!  * Title: Gui5250SplitFrame
!  * Copyright:   Copyright (c) 2001
!  * Company:
!  * @author  Kenneth J. Pouncey
!  * @version 0.4
!  *
!  * Description:
!  *
!  * This program is free software; you can redistribute it and/or modify
!  * it under the terms of the GNU General Public License as published by
!  * the Free Software Foundation; either version 2, or (at your option)
!  * any later version.
!  *
!  * This program is distributed in the hope that it will be useful,
!  * but WITHOUT ANY WARRANTY; without even the implied warranty of
!  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
!  * GNU General Public License for more details.
!  *
!  * You should have received a copy of the GNU General Public License
!  * along with this software; see the file COPYING.  If not, write to
!  * the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
!  * Boston, MA 02111-1307 USA
!  *
!  */
! 
! import java.awt.*;
! import java.awt.event.*;
! import javax.swing.*;
! import java.util.*;
! import javax.swing.event.ListSelectionEvent;
! import javax.swing.event.ListSelectionListener;
! 
! import org.tn5250j.tools.logging.*;
! import org.tn5250j.interfaces.GUIViewInterface;
! import org.tn5250j.event.SessionJumpListener;
! import org.tn5250j.event.SessionJumpEvent;
! import org.tn5250j.event.SessionListener;
! import org.tn5250j.event.SessionChangeEvent;
! 
! public class Gui5250SplitFrame extends GUIViewInterface implements
!                                                     TN5250jConstants,
!                                                     SessionListener,
!                                                     SessionJumpListener {
! 
!    BorderLayout borderLayout1 = new BorderLayout();
!    JSplitPane sessionPane;
!    private SessionManager manager;
!    private int selectedIndex = 0;
! 
!    private Vector sessionList;
!    private JList sessionPicker;
!    private DefaultListModel lm = new DefaultListModel();
!    private JPanel sessionPanel;
!    private JScrollPane scroller;
!    private JPanel toolsPanel;
! 	
!    private TN5250jLogger log = TN5250jLogFactory.getLogger(this.getClass());
!    
!    //Construct the frame
!    public Gui5250SplitFrame(My5250 m) {
! 
!       super(m);
! 
!       enableEvents(AWTEvent.WINDOW_EVENT_MASK);
!       try  {
!          jbInit();
!       }
!       catch(Exception e) {
!          log.warn("In constructor: "+e);
!       }
!    }
! 
!    //Component initialization
!    private void jbInit() throws Exception  {
! 
!       this.getContentPane().setLayout(borderLayout1);
! 
!       if (sequence > 0)
!          setTitle("tn5250j <" + sequence + "> - " + tn5250jRelease + tn5250jVersion + tn5250jSubVer);
!       else
!          setTitle("tn5250j - " + tn5250jRelease + tn5250jVersion + tn5250jSubVer);
! 
!       // update the frame sequences
!       frameSeq = sequence++;
! 
!       sessionList = new Vector(3);
! 
! //    note to myself if needed on how to add a listener to the the divider of
! //    of a scroll pane.  This is really a pain in the ass to figure out.
! //
! //      You can use a mouse listener but you cannot add a mouse listener
! //         directly to a split pane. You will have to get the splitpanedivider
! //          and then add the mouselistener to that.
! //
! //      (((BasicSplitPaneUI)yoursplitpane.getUI()).getDivider()).addMouseListener(yourmouselistener);      // create the split pane
!       sessionPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
!       sessionPane.setOneTouchExpandable(true);
!       sessionPane.setContinuousLayout(true);
! 
!       sessionPane.setBorder(BorderFactory.createEtchedBorder());
!       sessionPane.setOpaque(true);
!       sessionPane.setRequestFocusEnabled(false);
!       sessionPane.setDoubleBuffered(false);
! 
!       this.getContentPane().add(sessionPane, BorderLayout.CENTER);
!       sessionPanel = new JPanel();
!       sessionPanel.setLayout(new BorderLayout());
! 
!       sessionPane.setLeftComponent(sessionPanel);
! 
! 
!       toolsPanel = new JPanel();
!       toolsPanel.setLayout(new BorderLayout());
! 
!       sessionPane.setRightComponent(toolsPanel);
! 
!       sessionPicker = new JList(lm);
!       sessionPicker.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
!       SessionRenderer renderer = new SessionRenderer();
!       sessionPicker.setCellRenderer(renderer);
! 
!       // add list selection listener to our functions list so that we
!       //   can display the mapped key(s) to the function when a new
!       //   function is selected.
!       sessionPicker.addListSelectionListener(new ListSelectionListener() {
!          public void valueChanged(ListSelectionEvent lse) {
!             if (!lse.getValueIsAdjusting()) {
!                showSelectedSession(sessionPicker.getSelectedIndex());
!             }
!          }
!       });
! 
!       if (packFrame)
!          pack();
!       else
!          validate();
! 
!    }
! 
!    //Overridden so we can exit on System Close
!    protected void processWindowEvent(WindowEvent e) {
!       super.processWindowEvent(e);
!       if(e.getID() == WindowEvent.WINDOW_CLOSING) {
!          me.closingDown(this);
!       }
!    }
! 
! 
!    void showSelectedSession(int whichOne) {
! 
!       if (whichOne < 0 || whichOne > sessionList.size() - 1)
!          return;
! 
!       Session session = (Session)sessionList.get(whichOne);
!       sessionPicker.setSelectedIndex(whichOne);
! 
!       Session current = getCurrentViewedSession();
! 
!       if (current != null)
!          current.setVisible(false);
! 
!       // now remove all components from the panel
!       sessionPanel.removeAll();
!       // set the session to visible so that we get screen updates again
!       session.setVisible(true);
! 
!       // add the session to the panel so that we can see it.
!       sessionPanel.add(session,BorderLayout.CENTER);
!       // make sure we update the screen
!       sessionPanel.revalidate();
!       sessionPanel.repaint();
!       // make sure we have the focus after switching.
!       session.grabFocus();
!    }
! 
!    public void update(Graphics g) {
!       paint(g);
!       sessionPanel.repaint();
!    }
! 
!    public void onSessionJump(SessionJumpEvent jumpEvent) {
! 
!       switch (jumpEvent.getJumpDirection()) {
! 
!          case JUMP_PREVIOUS:
!             prevSession();
!             break;
!          case JUMP_NEXT:
!             nextSession();
!             break;
!       }
!    }
! 
!    /**
!     * Helper method to return the currently viewed session
!     *
!     * @return
!     */
!    private Session getCurrentViewedSession() {
! 
!       Session current = null;
!       Component[] comps = sessionPanel.getComponents();
!       int count = comps.length;
!       // make the current session non visible to keep from over writting the
!       //  session screens.
!       for (int x = 0; x < count; x++) {
! 
!          if (comps[x] instanceof Session) {
!             current = (Session)comps[x];
!          }
!       }
! 
!       return current;
! 
!    }
! 
!    /**
!     * Bring the next session to front
!     */
!    private void nextSession() {
! 
!       Session current = getCurrentViewedSession();
! 
!       int index = sessionList.indexOf(current) + 1;
! 
!       int size = sessionList.size() - 1;
! 
!       if (index > size)
!          showSelectedSession(0);
!       else
!          showSelectedSession(index);
!    }
! 
!    /**
!     * Bring the previous session to front
!     */
!    private void prevSession() {
! 
!       Session current = getCurrentViewedSession();
! 
!       int index = sessionList.indexOf(current) - 1;
! 
!       int size = sessionList.size() - 1;
! 
!       if (index < 0)
!          showSelectedSession(size);
!       else
!          showSelectedSession(index);
! 
!    }
! 
!    /**
!     * Add a session to the view
!     *
!     * @param sessionName
!     * @param session
!     */
!    public void addSessionView(String sessionName,Session session) {
! 
!       lm.addElement(session);
! 
!       if (sessionList.size() == 0) {
!          sessionList.addElement(session);
!          sessionPanel.add(session,BorderLayout.CENTER);
!          scroller = new JScrollPane();
!          scroller.setViewportView(sessionPicker);
!          toolsPanel.add(scroller,BorderLayout.CENTER);
!          sessionPane.setDividerLocation(0.90);
!       }
!       else {
!          sessionList.addElement(session);
!          sessionPicker.setSelectedIndex(sessionList.size()-1);
!       }
! 
!       // add ourselves to the listner list
!       session.addSessionListener(this);
!       session.addSessionJumpListener(this);
! 
!       // now show it to the user
!       showSelectedSession(sessionList.size()-1);
! 
! 
!    }
! 
!    public void removeSessionView(Session targetSession) {
! 
! 
!       int index = sessionList.indexOf(targetSession);
! 
!       lm.remove(index);
! 
!       if (index > 0 || index == sessionList.size() - 1)
!          prevSession();
!       if (index == 0)
!          nextSession();
! 
!       sessionList.remove(targetSession);
! 
!       updateScrollPane();
! 
!    }
! 
!    /**
!     * Return the count of views contained in the frame
!     * @return
!     */
!    public int getSessionViewCount() {
! 
!       return sessionList.size();
! 
!    }
! 
!    /**
!     * Return the Session object at the specific index.
!     *
!     * @param index
!     * @return
!     */
!    public Session getSessionAt( int index) {
! 
!       return (Session)sessionList.get(index);
!    }
! 
!    public void onSessionChanged(SessionChangeEvent changeEvent) {
! 
!       updateScrollPane();
!    }
! 
!    /**
!     * Update the scroll pane whenever something changes
!     */
!    private void updateScrollPane() {
! 
!       scroller.invalidate();
!       scroller.repaint();
!    }
! 
!    public boolean containsSession(Session session) {
! 
!       return sessionList.contains(session);
! 
!    }
! 
!    /**
!     * List renderer for sessions
!     */
!    class SessionRenderer extends JLabel
!                        implements ListCellRenderer {
! 
!       public SessionRenderer() {
!          setOpaque(true);
!          setHorizontalAlignment(LEFT);
!          setVerticalAlignment(CENTER);
!       }
! 
!       /*
!        * This method finds the image and text corresponding
!        * to the selected value and returns the label, set up
!        * to display the text and image.
!        */
!       public Component getListCellRendererComponent(
!                                        JList list,
!                                        Object value,
!                                        int index,
!                                        boolean isSelected,
!                                        boolean cellHasFocus) {
! 
!          //Get the selected index. (The index param isn't
!          //always valid, so just use the value.)
!          Session ses = (Session)value;
! 
!          // set the correct focused or unfocused and selected or unselected
!          //  colors
!          if (isSelected) {
!             setIcon(focused);
!             setBackground(list.getSelectionBackground());
!             setForeground(list.getSelectionForeground());
!          }
!          else {
!             setIcon(unfocused);
!             setBackground(list.getBackground());
!             setForeground(list.getForeground());
!          }
! 
!          //Set the text of this label.
!          if (ses.getAllocDeviceName() != null)
!             setText(ses.getAllocDeviceName());
!          else
!             setText(ses.getSessionName());
! 
!          return this;
!       }
!    }
! 
! }
--- 1,397 ----
! package org.tn5250j;
! /**
!  * Title: Gui5250SplitFrame
!  * Copyright:   Copyright (c) 2001
!  * Company:
!  * @author  Kenneth J. Pouncey
!  * @version 0.4
!  *
!  * Description:
!  *
!  * This program is free software; you can redistribute it and/or modify
!  * it under the terms of the GNU General Public License as published by
!  * the Free Software Foundation; either version 2, or (at your option)
!  * any later version.
!  *
!  * This program is distributed in the hope that it will be useful,
!  * but WITHOUT ANY WARRANTY; without even the implied warranty of
!  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
!  * GNU General Public License for more details.
!  *
!  * You should have received a copy of the GNU General Public License
!  * along with this software; see the file COPYING.  If not, write to
!  * the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
!  * Boston, MA 02111-1307 USA
!  *
!  */
! 
! import java.awt.*;
! import java.awt.event.*;
! import javax.swing.*;
! import java.util.*;
! import javax.swing.event.ListSelectionEvent;
! import javax.swing.event.ListSelectionListener;
! 
! import org.tn5250j.tools.logging.*;
! import org.tn5250j.interfaces.GUIViewInterface;
! import org.tn5250j.event.SessionJumpListener;
! import org.tn5250j.event.SessionJumpEvent;
! import org.tn5250j.event.SessionListener;
! import org.tn5250j.event.SessionChangeEvent;
! 
! public class Gui5250SplitFrame extends GUIViewInterface implements
!                                                     TN5250jConstants,
!                                                     SessionListener,
!                                                     SessionJumpListener {
! 
!    BorderLayout borderLayout1 = new BorderLayout();
!    JSplitPane sessionPane;
!    private SessionManager manager;
!    private int selectedIndex = 0;
! 
!    private Vector sessionList;
!    private JList sessionPicker;
!    private DefaultListModel lm = new DefaultListModel();
!    private JPanel sessionPanel;
!    private JScrollPane scroller;
!    private JPanel toolsPanel;
! 	
!    private TN5250jLogger log = TN5250jLogFactory.getLogger(this.getClass());
!    
!    //Construct the frame
!    public Gui5250SplitFrame(My5250 m) {
! 
!       super(m);
! 
!       enableEvents(AWTEvent.WINDOW_EVENT_MASK);
!       try  {
!          jbInit();
!       }
!       catch(Exception e) {
!          log.warn("In constructor: "+e);
!       }
!    }
! 
!    //Component initialization
!    private void jbInit() throws Exception  {
! 
!       this.getContentPane().setLayout(borderLayout1);
! 
!       if (sequence > 0)
!          setTitle("tn5250j <" + sequence + "> - " + tn5250jRelease + tn5250jVersion + tn5250jSubVer);
!       else
!          setTitle("tn5250j - " + tn5250jRelease + tn5250jVersion + tn5250jSubVer);
! 
!       // update the frame sequences
!       frameSeq = sequence++;
! 
!       sessionList = new Vector(3);
! 
! //    note to myself if needed on how to add a listener to the the divider of
! //    of a scroll pane.  This is really a pain in the ass to figure out.
! //
! //      You can use a mouse listener but you cannot add a mouse listener
! //         directly to a split pane. You will have to get the splitpanedivider
! //          and then add the mouselistener to that.
! //
! //      (((BasicSplitPaneUI)yoursplitpane.getUI()).getDivider()).addMouseListener(yourmouselistener);      // create the split pane
!       sessionPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
!       sessionPane.setOneTouchExpandable(true);
!       sessionPane.setContinuousLayout(true);
! 
!       sessionPane.setBorder(BorderFactory.createEtchedBorder());
!       sessionPane.setOpaque(true);
!       sessionPane.setRequestFocusEnabled(false);
!       sessionPane.setDoubleBuffered(false);
! 
!       this.getContentPane().add(sessionPane, BorderLayout.CENTER);
!       sessionPanel = new JPanel();
!       sessionPanel.setLayout(new BorderLayout());
! 
!       sessionPane.setLeftComponent(sessionPanel);
! 
! 
!       toolsPanel = new JPanel();
!       toolsPanel.setLayout(new BorderLayout());
! 
!       sessionPane.setRightComponent(toolsPanel);
! 
!       sessionPicker = new JList(lm);
!       sessionPicker.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
!       SessionRenderer renderer = new SessionRenderer();
!       sessionPicker.setCellRenderer(renderer);
! 
!       // add list selection listener to our functions list so that we
!       //   can display the mapped key(s) to the function when a new
!       //   function is selected.
!       sessionPicker.addListSelectionListener(new ListSelectionListener() {
!          public void valueChanged(ListSelectionEvent lse) {
!             if (!lse.getValueIsAdjusting()) {
!                showSelectedSession(sessionPicker.getSelectedIndex());
!             }
!          }
!       });
! 
!       if (packFrame)
!          pack();
!       else
!          validate();
! 
!    }
! 
!    //Overridden so we can exit on System Close
!    protected void processWindowEvent(WindowEvent e) {
!       super.processWindowEvent(e);
!       if(e.getID() == WindowEvent.WINDOW_CLOSING) {
!          me.closingDown(this);
!       }
!    }
! 
! 
!    void showSelectedSession(int whichOne) {
! 
!       if (whichOne < 0 || whichOne > sessionList.size() - 1)
!          return;
! 
!       SessionGUI session = (SessionGUI)sessionList.get(whichOne);
!       sessionPicker.setSelectedIndex(whichOne);
! 
!       SessionGUI current = getCurrentViewedSession();
! 
!       if (current != null)
!          current.setVisible(false);
! 
!       // now remove all components from the panel
!       sessionPanel.removeAll();
!       // set the session to visible so that we get screen updates again
!       session.setVisible(true);
! 
!       // add the session to the panel so that we can see it.
!       sessionPanel.add(session,BorderLayout.CENTER);
!       // make sure we update the screen
!       sessionPanel.revalidate();
!       sessionPanel.repaint();
!       // make sure we have the focus after switching.
!       session.grabFocus();
!    }
! 
!    public void update(Graphics g) {
!       paint(g);
!       sessionPanel.repaint();
!    }
! 
!    public void onSessionJump(SessionJumpEvent jumpEvent) {
! 
!       switch (jumpEvent.getJumpDirection()) {
! 
!          case JUMP_PREVIOUS:
!             prevSession();
!             break;
!          case JUMP_NEXT:
!             nextSession();
!             break;
!       }
!    }
! 
!    /**
!     * Helper method to return the currently viewed session
!     *
!     * @return
!     */
!    private SessionGUI getCurrentViewedSession() {
! 
!       SessionGUI current = null;
!       Component[] comps = sessionPanel.getComponents();
!       int count = comps.length;
!       // make the current session non visible to keep from over writting the
!       //  session screens.
!       for (int x = 0; x < count; x++) {
! 
!          if (comps[x] instanceof SessionGUI) {
!             current = (SessionGUI)comps[x];
!          }
!       }
! 
!       return current;
! 
!    }
! 
!    /**
!     * Bring the next session to front
!     */
!    private void nextSession() {
! 
!       SessionGUI current = getCurrentViewedSession();
! 
!       int index = sessionList.indexOf(current) + 1;
! 
!       int size = sessionList.size() - 1;
! 
!       if (index > size)
!          showSelectedSession(0);
!       else
!          showSelectedSession(index);
!    }
! 
!    /**
!     * Bring the previous session to front
!     */
!    private void prevSession() {
! 
!       SessionGUI current = getCurrentViewedSession();
! 
!       int index = sessionList.indexOf(current) - 1;
! 
!       int size = sessionList.size() - 1;
! 
!       if (index < 0)
!          showSelectedSession(size);
!       else
!          showSelectedSession(index);
! 
!    }
! 
!    /**
!     * Add a session to the view
!     *
!     * @param sessionName
!     * @param session
!     */
!    public void addSessionView(String sessionName,SessionGUI session) {
! 
!       lm.addElement(session);
! 
!       if (sessionList.size() == 0) {
!          sessionList.addElement(session);
!          sessionPanel.add(session,BorderLayout.CENTER);
!          scroller = new JScrollPane();
!          scroller.setViewportView(sessionPicker);
!          toolsPanel.add(scroller,BorderLayout.CENTER);
!          sessionPane.setDividerLocation(0.90);
!       }
!       else {
!          sessionList.addElement(session);
!          sessionPicker.setSelectedIndex(sessionList.size()-1);
!       }
! 
!       // add ourselves to the listner list
!       session.addSessionListener(this);
!       session.addSessionJumpListener(this);
! 
!       // now show it to the user
!       showSelectedSession(sessionList.size()-1);
! 
! 
!    }
! 
!    public void removeSessionView(SessionGUI targetSession) {
! 
! 
!       int index = sessionList.indexOf(targetSession);
! 
!       lm.remove(index);
! 
!       if (index > 0 || index == sessionList.size() - 1)
!          prevSession();
!       if (index == 0)
!          nextSession();
! 
!       sessionList.remove(targetSession);
! 
!       updateScrollPane();
! 
!    }
! 
!    /**
!     * Return the count of views contained in the frame
!     * @return
!     */
!    public int getSessionViewCount() {
! 
!       return sessionList.size();
! 
!    }
! 
!    /**
!     * Return the Session object at the specific index.
!     *
!     * @param index
!     * @return
!     */
!    public SessionGUI getSessionAt( int index) {
! 
!       return (SessionGUI)sessionList.get(index);
!    }
! 
!    public void onSessionChanged(SessionChangeEvent changeEvent) {
! 
!       updateScrollPane();
!    }
! 
!    /**
!     * Update the scroll pane whenever something changes
!     */
!    private void updateScrollPane() {
! 
!       scroller.invalidate();
!       scroller.repaint();
!    }
! 
!    public boolean containsSession(SessionGUI session) {
! 
!       return sessionList.contains(session);
! 
!    }
! 
!    /**
!     * List renderer for sessions
!     */
!    class SessionRenderer extends JLabel
!                        implements ListCellRenderer {
! 
!       public SessionRenderer() {
!          setOpaque(true);
!          setHorizontalAlignment(LEFT);
!          setVerticalAlignment(CENTER);
!       }
! 
!       /*
!        * This method finds the image and text corresponding
!        * to the selected value and returns the label, set up
!        * to display the text and image.
!        */
!       public Component getListCellRendererComponent(
!                                        JList list,
!                                        Object value,
!                                        int index,
!                                        boolean isSelected,
!                                        boolean cellHasFocus) {
! 
!          //Get the selected index. (The index param isn't
!          //always valid, so just use the value.)
!          SessionGUI ses = (SessionGUI)value;
! 
!          // set the correct focused or unfocused and selected or unselected
!          //  colors
!          if (isSelected) {
!             setIcon(focused);
!             setBackground(list.getSelectionBackground());
!             setForeground(list.getSelectionForeground());
!          }
!          else {
!             setIcon(unfocused);
!             setBackground(list.getBackground());
!             setForeground(list.getForeground());
!          }
! 
!          //Set the text of this label.
!          if (ses.getAllocDeviceName() != null)
!             setText(ses.getAllocDeviceName());
!          else
!             setText(ses.getSessionName());
! 
!          return this;
!       }
!    }
! 
! }

Index: Gui5250Frame.java
===================================================================
RCS file: /cvsroot/tn5250j/tn5250j/src/org/tn5250j/Gui5250Frame.java,v
retrieving revision 1.23
retrieving revision 1.24
diff -C2 -d -r1.23 -r1.24
*** Gui5250Frame.java	18 Jul 2004 13:38:54 -0000	1.23
--- Gui5250Frame.java	22 Jul 2004 05:49:47 -0000	1.24
***************
*** 1,475 ****
! /**
!  * Title: tn5250J
!  * Copyright:   Copyright (c) 2001-2003
!  * Company:
!  * @author  Kenneth J. Pouncey
!  * @version 0.4
!  *
!  * Description:
!  *
!  * This program is free software; you can redistribute it and/or modify
!  * it under the terms of the GNU General Public License as published by
!  * the Free Software Foundation; either version 2, or (at your option)
!  * any later version.
!  *
!  * This program is distributed in the hope that it will be useful,
!  * but WITHOUT ANY WARRANTY; without even the implied warranty of
!  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
!  * GNU General Public License for more details.
!  *
!  * You should have received a copy of the GNU General Public License
!  * along with this software; see the file COPYING.  If not, write to
!  * the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
!  * Boston, MA 02111-1307 USA
!  *
!  */
! package org.tn5250j;
! 
! import java.awt.*;
! import java.awt.event.*;
! import javax.swing.*;
! import java.util.*;
! 
! import javax.swing.event.ChangeListener;
! import javax.swing.event.ChangeEvent;
! 
! import org.tn5250j.tools.logging.*;
! import org.tn5250j.event.SessionJumpListener;
! import org.tn5250j.event.SessionJumpEvent;
! import org.tn5250j.event.SessionListener;
! import org.tn5250j.event.SessionChangeEvent;
! import org.tn5250j.event.TabClosedListener;
! import org.tn5250j.interfaces.GUIViewInterface;
! import org.tn5250j.interfaces.ConfigureFactory;
! import org.tn5250j.gui.TN5250jTabbedPane;
! 
! public class Gui5250Frame extends GUIViewInterface implements
!                                                     ChangeListener,
!                                                     TN5250jConstants,
!                                                     SessionListener,
!                                                     TabClosedListener,
!                                                     SessionJumpListener {
! 
!    BorderLayout borderLayout1 = new BorderLayout();
!    //JTabbedPane sessionPane = new JTabbedPane();
!    TN5250jTabbedPane sessionPane = new TN5250jTabbedPane();
!    private int selectedIndex = 0;
!    private boolean embedded = false;
!    private boolean hideTabBar = false;
!    public static int count = 0;
!    private TN5250jLogger log = TN5250jLogFactory.getLogger (this.getClass());
! 
! 
!    //Construct the frame
!    public Gui5250Frame(My5250 m) {
!       super(m);
!       enableEvents(AWTEvent.WINDOW_EVENT_MASK);
!       try  {
!          jbInit();
!       }
!       catch(Exception e) {
!          e.printStackTrace();
!       }
!    }
! 
!    //Component initialization
!    private void jbInit() throws Exception  {
! 
!       this.getContentPane().setLayout(borderLayout1);
! 
!       // update the frame sequences
!       frameSeq = sequence++;
! 
!       sessionPane.setBorder(BorderFactory.createEtchedBorder());
!       sessionPane.setBounds(new Rectangle(78, 57, 5, 5));
!       sessionPane.setOpaque(true);
!       sessionPane.setRequestFocusEnabled(false);
!       sessionPane.setDoubleBuffered(false);
! 
!       sessionPane.addChangeListener(this);
!       sessionPane.addtabCloseListener(this);
! 
!       Properties props = ConfigureFactory.getInstance().
!                            getProperties(ConfigureFactory.SESSIONS);
! 
!       if (props.getProperty("emul.hideTabBar","no").equals("yes"))
!          hideTabBar = true;
! 
!       if (!hideTabBar) {
!          this.getContentPane().add(sessionPane, BorderLayout.CENTER);
!       }
! 
!       if (count == 0) setSessionTitle();
! 
!       if (packFrame)
!          pack();
!       else
!          validate();
! 
! 
!    }
! 
!    public void centerFrame() {
! 
!       if (packFrame)
!          pack();
!       else
!          validate();
! 
!       //Center the window
!       Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
!       Dimension frameSize = getSize();
!       if (frameSize.height > screenSize.height)
!          frameSize.height = screenSize.height;
!       if (frameSize.width > screenSize.width)
!          frameSize.width = screenSize.width;
! 
!       setLocation((screenSize.width - frameSize.width) / 2,
!                      (screenSize.height - frameSize.height) / 2);
! 
! 
!    }
! 
!    public int getFrameSequence() {
! 
!       return frameSeq;
!    }
! 
!    //Overridden so we can exit on System Close
!    protected void processWindowEvent(WindowEvent e) {
!       super.processWindowEvent(e);
!       if(e.getID() == WindowEvent.WINDOW_CLOSING) {
!          me.closingDown(this);
!       }
!    }
! 
! 
!    public void update(Graphics g) {
!       paint(g);
!    }
! 
!    public void onSessionJump(SessionJumpEvent jumpEvent) {
! 
!       switch (jumpEvent.getJumpDirection()) {
! 
!          case JUMP_PREVIOUS:
!             prevSession();
!             break;
!          case JUMP_NEXT:
!             nextSession();
!             break;
!       }
!    }
! 
!    private void nextSession() {
! 
!       final int index = sessionPane.getSelectedIndex();
!       sessionPane.setForegroundAt(index,Color.black);
!       sessionPane.setIconAt(index,unfocused);
! 
! 
!       SwingUtilities.invokeLater(new Runnable() {
!          public void run() {
!             int index1 = index;
!             if (index1 < sessionPane.getTabCount() - 1) {
!                sessionPane.setSelectedIndex(++index1);
!                sessionPane.setForegroundAt(index1,Color.blue);
!                sessionPane.setIconAt(index1,focused);
! 
!             }
!             else {
!                sessionPane.setSelectedIndex(0);
!                sessionPane.setForegroundAt(0,Color.blue);
!                sessionPane.setIconAt(0,focused);
! 
!             }
! 
!             ((Session)sessionPane.getComponent(sessionPane.getSelectedIndex())).grabFocus();
! 
!             setSessionTitle();
!        }
!       });
! 
!    }
! 
!    private void prevSession() {
! 
!       final int index = sessionPane.getSelectedIndex();
!       sessionPane.setForegroundAt(index,Color.black);
!       sessionPane.setIconAt(index,unfocused);
! 
!       SwingUtilities.invokeLater(new Runnable() {
!          public void run() {
!             int index1 = index;
!             if (index1 == 0) {
!                sessionPane.setSelectedIndex(sessionPane.getTabCount() - 1);
!                sessionPane.setForegroundAt(sessionPane.getSelectedIndex(),Color.blue);
!                sessionPane.setIconAt(sessionPane.getSelectedIndex(),focused);
! 
!             }
!             else {
!                sessionPane.setSelectedIndex(--index1);
!                sessionPane.setForegroundAt(index1,Color.blue);
!                sessionPane.setIconAt(index1,focused);
! 
!             }
! 
!             ((Session)sessionPane.getComponent(sessionPane.getSelectedIndex())).grabFocus();
!             setSessionTitle();
!        }
!       });
!    }
! 
!    public void stateChanged(ChangeEvent e) {
! 
!       JTabbedPane p = (JTabbedPane)e.getSource();
! 
!       p.setForegroundAt(selectedIndex,Color.black);
!       p.setIconAt(selectedIndex,unfocused);
! 
!       Session sg = (Session)p.getComponentAt(selectedIndex);
!       sg.setVisible(false);
! 
!       sg = (Session)p.getSelectedComponent();
! 
!       if (sg == null)
!          return;
! 
!       sg.setVisible(true);
!       sg.grabFocus();
! 
!       selectedIndex = p.getSelectedIndex();
!       p.setForegroundAt(selectedIndex,Color.blue);
!       p.setIconAt(selectedIndex,focused);
! 
!       setSessionTitle();
! 
!    }
! 
!    private void setSessionTitle() {
! 
!       Session ses = getSessionAt(selectedIndex);
! 
!       if (ses != null && ses.getAllocDeviceName() != null && ses.isConnected()) {
!          if (sequence - 1 > 0)
!             setTitle(ses.getAllocDeviceName() + " - tn5250j <" + sequence + "> - " + tn5250jRelease + tn5250jVersion + tn5250jSubVer);
!          else
!             setTitle(ses.getAllocDeviceName() + " - tn5250j - " + tn5250jRelease + tn5250jVersion + tn5250jSubVer);
!       }
!       else {
! 
!          if (sequence - 1 > 0)
!             setTitle("tn5250j <" + sequence + "> - " + tn5250jRelease + tn5250jVersion + tn5250jSubVer);
!          else
!             setTitle("tn5250j - " + tn5250jRelease + tn5250jVersion + tn5250jSubVer);
!       }
! 
! 		count +=1;
! 
!    }
! 
!    public void addSessionView(String tabText,Session sessionView) {
! 
!       final Session session = sessionView;
! 
!       if (hideTabBar && sessionPane.getTabCount() == 0 && !embedded) {
! 
!          this.getContentPane().add(session, BorderLayout.CENTER);
!          session.addSessionListener(this);
! 
!          session.resizeMe();
!          repaint();
!          if (packFrame)
!             pack();
!          else
!             validate();
!          embedded = true;
!          session.grabFocus();
!          setSessionTitle();
!       }
!       else {
! 
!          if (hideTabBar && sessionPane.getTabCount() == 0 ) {
!             Session ses = null;
!             for (int x=0; x < this.getContentPane().getComponentCount(); x++) {
! 
!                if (this.getContentPane().getComponent(x) instanceof Session) {
!                   ses = (Session)(this.getContentPane().getComponent(x));
!                   this.getContentPane().remove(x);
!                   break;
!                }
!             }
! 
!             //ses = (Session)(this.getContentPane().getComponent(0));
!             sessionPane.addTab(tabText,focused,ses);
! 
!             final Session finalSession = ses;
! 
!             SwingUtilities.invokeLater(new Runnable() {
!                public void run() {
!                   finalSession.resizeMe();
!                   finalSession.repaint();
!                }
!             });
! 
! 
!             if (ses.getAllocDeviceName() != null)
!                sessionPane.setTitleAt(0,ses.getAllocDeviceName());
!             else
!                sessionPane.setTitleAt(0,ses.getSessionName());
! 
!             ses.addSessionListener(this);
!             ses.addSessionJumpListener(this);
! 
!             this.getContentPane().add(sessionPane, BorderLayout.CENTER);
!             SwingUtilities.invokeLater(new Runnable() {
!                public void run() {
!                   repaint();
!                   finalSession.grabFocus();
!                }
!             });
!          }
! 
!          sessionPane.addTab(tabText,focused,session);
! 
!          sessionPane.setForegroundAt(sessionPane.getSelectedIndex(),Color.black);
!          sessionPane.setIconAt(sessionPane.getSelectedIndex(),unfocused);
! 
!          sessionPane.setSelectedIndex(sessionPane.getTabCount()-1);
!          sessionPane.setForegroundAt(sessionPane.getSelectedIndex(),Color.blue);
!          sessionPane.setIconAt(sessionPane.getSelectedIndex(),focused);
! 
!          session.addSessionListener(this);
!          session.addSessionJumpListener(this);
! 
!          SwingUtilities.invokeLater(new Runnable() {
!             public void run() {
!                session.resizeMe();
!                session.repaint();
!                session.grabFocus();
!             }
!          });
!       }
!    }
! 
!    public void tabClosed(int tabToBeClosed){
! 
!       me.closeSession(this.getSessionAt(tabToBeClosed));
!    }
! 
!    public void removeSessionView(Session targetSession) {
! 
!       if (hideTabBar && sessionPane.getTabCount() == 0) {
!          for (int x=0; x < getContentPane().getComponentCount(); x++) {
! 
!             if (getContentPane().getComponent(x) instanceof Session) {
!                getContentPane().remove(x);
!             }
!          }
!       }
!       else {
! 
!          int index = sessionPane.indexOfComponent(targetSession);
!          log.info("session found and closing down " + index);
!          targetSession.removeSessionListener(this);
!          targetSession.removeSessionJumpListener(this);
!          int tabs = sessionPane.getTabCount();
!          sessionPane.remove(index);
!          tabs--;
! 
! 
!          if (index < tabs) {
!             sessionPane.setSelectedIndex(index);
!             sessionPane.setForegroundAt(index,Color.blue);
!             sessionPane.setIconAt(index,focused);
!             ((Session)sessionPane.getComponentAt(index)).requestFocus();
!          }
!          else {
! 
!             if (tabs > 0) {
!                sessionPane.setSelectedIndex(0);
!                sessionPane.setForegroundAt(0,Color.blue);
!                sessionPane.setIconAt(0,focused);
!                ((Session)sessionPane.getComponentAt(0)).requestFocus();
!             }
! 
!          }
!       }
!    }
! 
!    public int getSessionViewCount() {
! 
!       if (hideTabBar && sessionPane.getTabCount() == 0) {
!          for (int x=0; x < this.getContentPane().getComponentCount(); x++) {
! 
!             if (this.getContentPane().getComponent(x) instanceof Session) {
!                return 1;
!             }
!          }
!          return 0;
!       }
!       else
!          return sessionPane.getTabCount();
!    }
! 
!    public Session getSessionAt( int index) {
! 
!       if (hideTabBar && sessionPane.getTabCount() == 0) {
!          for (int x=0; x < this.getContentPane().getComponentCount(); x++) {
! 
!             if (this.getContentPane().getComponent(x) instanceof Session) {
!                return (Session)getContentPane().getComponent(x);
!             }
!          }
!          return null;
!       }
!       else {
!          if (sessionPane.getTabCount() <= 0)
!             return null;
!          return (Session)sessionPane.getComponentAt(index);
!       }
!    }
! 
!    public void onSessionChanged(SessionChangeEvent changeEvent) {
! 
!       Session ses = (Session)changeEvent.getSource();
! 
!       switch (changeEvent.getState()) {
!          case STATE_CONNECTED:
! 
!             final String d = ses.getAllocDeviceName();
!             if (d != null) {
!                System.out.println(changeEvent.getState() + " " + d);
!                final int index = sessionPane.indexOfComponent(ses);
!                if (index >= 0) {
!                   Runnable tc = new Runnable () {
!                      public void run() {
!                         sessionPane.setTitleAt(index,d);
!                      }
!                   };
!                   SwingUtilities.invokeLater(tc);
!                }
!                setSessionTitle();
! 
!             }
!             break;
!       }
!    }
! 
!    public boolean containsSession(Session session) {
! 
!       if (hideTabBar && sessionPane.getTabCount() == 0) {
!          for (int x=0; x < this.getContentPane().getComponentCount(); x++) {
! 
!             if (this.getContentPane().getComponent(x) instanceof Session) {
!                return ((Session)getContentPane().getComponent(x)).equals(session);
!             }
!          }
!          return false;
!       }
!       else
!          return (sessionPane.indexOfComponent(session) >= 0);
! 
!    }
! 
! }
--- 1,476 ----
! /**
!  * Title: tn5250J
!  * Copyright:   Copyright (c) 2001-2003
!  * Company:
!  * @author  Kenneth J. Pouncey
!  * @version 0.4
!  *
!  * Description:
!  *
!  * This program is free software; you can redistribute it and/or modify
!  * it under the terms of the GNU General Public License as published by
!  * the Free Software Foundation; either version 2, or (at your option)
!  * any later version.
!  *
!  * This program is distributed in the hope that it will be useful,
!  * but WITHOUT ANY WARRANTY; without even the implied warranty of
!  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
!  * GNU General Public License for more details.
!  *
!  * You should have received a copy of the GNU General Public License
!  * along with this software; see the file COPYING.  If not, write to
!  * the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
!  * Boston, MA 02111-1307 USA
!  *
!  */
! package org.tn5250j;
! 
! import java.awt.*;
! import java.awt.event.*;
! import javax.swing.*;
! import java.util.*;
! 
! import javax.swing.event.ChangeListener;
! import javax.swing.event.ChangeEvent;
! 
! import org.tn5250j.tools.logging.*;
! import org.tn5250j.event.SessionJumpListener;
! import org.tn5250j.event.SessionJumpEvent;
! import org.tn5250j.event.SessionListener;
! import org.tn5250j.event.SessionChangeEvent;
! import org.tn5250j.event.TabClosedListener;
! import org.tn5250j.interfaces.GUIViewInterface;
! import org.tn5250j.interfaces.ConfigureFactory;
! import org.tn5250j.gui.TN5250jTabbedPane;
! 
! public class Gui5250Frame extends GUIViewInterface implements
!                                                     ChangeListener,
!                                                     TN5250jConstants,
!                                                     SessionListener,
!                                                     TabClosedListener,
!                                                     SessionJumpListener {
! 
!    BorderLayout borderLayout1 = new BorderLayout();
!    //JTabbedPane sessionPane = new JTabbedPane();
!    TN5250jTabbedPane sessionPane = new TN5250jTabbedPane();
!    private int selectedIndex = 0;
!    private boolean embedded = false;
!    private boolean hideTabBar = false;
!    public static int count = 0;
!    private TN5250jLogger log = TN5250jLogFactory.getLogger (this.getClass());
! 
! 
!    //Construct the frame
!    public Gui5250Frame(My5250 m) {
!       super(m);
!       enableEvents(AWTEvent.WINDOW_EVENT_MASK);
!       try  {
!          jbInit();
!       }
!       catch(Exception e) {
!          e.printStackTrace();
!       }
!    }
! 
!    //Component initialization
!    private void jbInit() throws Exception  {
! 
!       this.getContentPane().setLayout(borderLayout1);
! 
!       // update the frame sequences
!       frameSeq = sequence++;
! 
!       sessionPane.setBorder(BorderFactory.createEtchedBorder());
!       sessionPane.setBounds(new Rectangle(78, 57, 5, 5));
!       sessionPane.setOpaque(true);
!       sessionPane.setRequestFocusEnabled(false);
!       sessionPane.setDoubleBuffered(false);
! 
!       sessionPane.addChangeListener(this);
!       sessionPane.addtabCloseListener(this);
! 
!       Properties props = ConfigureFactory.getInstance().
!                            getProperties(ConfigureFactory.SESSIONS);
! 
!       if (props.getProperty("emul.hideTabBar","no").equals("yes"))
!          hideTabBar = true;
! 
!       if (!hideTabBar) {
!          this.getContentPane().add(sessionPane, BorderLayout.CENTER);
!       }
! 
!       if (count == 0) setSessionTitle();
! 
!       if (packFrame)
!          pack();
!       else
!          validate();
! 
! 
!    }
! 
!    public void centerFrame() {
! 
!       if (packFrame)
!          pack();
!       else
!          validate();
! 
!       //Center the window
!       Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
!       Dimension frameSize = getSize();
!       if (frameSize.height > screenSize.height)
!          frameSize.height = screenSize.height;
!       if (frameSize.width > screenSize.width)
!          frameSize.width = screenSize.width;
! 
!       setLocation((screenSize.width - frameSize.width) / 2,
!                      (screenSize.height - frameSize.height) / 2);
! 
! 
!    }
! 
!    public int getFrameSequence() {
! 
!       return frameSeq;
!    }
! 
!    //Overridden so we can exit on System Close
!    protected void processWindowEvent(WindowEvent e) {
!       super.processWindowEvent(e);
!       if(e.getID() == WindowEvent.WINDOW_CLOSING) {
!          me.closingDown(this);
!       }
!    }
! 
! 
!    public void update(Graphics g) {
!       paint(g);
!    }
! 
!    public void onSessionJump(SessionJumpEvent jumpEvent) {
! 
!       switch (jumpEvent.getJumpDirection()) {
! 
!          case JUMP_PREVIOUS:
!             prevSession();
!             break;
!          case JUMP_NEXT:
!             nextSession();
!             break;
!       }
!    }
! 
!    private void nextSession() {
! 
!       final int index = sessionPane.getSelectedIndex();
!       sessionPane.setForegroundAt(index,Color.black);
!       sessionPane.setIconAt(index,unfocused);
! 
! 
!       SwingUtilities.invokeLater(new Runnable() {
!          public void run() {
!             int index1 = index;
!             if (index1 < sessionPane.getTabCount() - 1) {
!                sessionPane.setSelectedIndex(++index1);
!                sessionPane.setForegroundAt(index1,Color.blue);
!                sessionPane.setIconAt(index1,focused);
! 
!             }
!             else {
!                sessionPane.setSelectedIndex(0);
!                sessionPane.setForegroundAt(0,Color.blue);
!                sessionPane.setIconAt(0,focused);
! 
!             }
! 
!             ((SessionGUI)sessionPane.getComponent(sessionPane.getSelectedIndex())).grabFocus();
! 
!             setSessionTitle();
!        }
!       });
! 
!    }
! 
!    private void prevSession() {
! 
!       final int index = sessionPane.getSelectedIndex();
!       sessionPane.setForegroundAt(index,Color.black);
!       sessionPane.setIconAt(index,unfocused);
! 
!       SwingUtilities.invokeLater(new Runnable() {
!          public void run() {
!             int index1 = index;
!             if (index1 == 0) {
!                sessionPane.setSelectedIndex(sessionPane.getTabCount() - 1);
!                sessionPane.setForegroundAt(sessionPane.getSelectedIndex(),Color.blue);
!                sessionPane.setIconAt(sessionPane.getSelectedIndex(),focused);
! 
!             }
!             else {
!                sessionPane.setSelectedIndex(--index1);
!                sessionPane.setForegroundAt(index1,Color.blue);
!                sessionPane.setIconAt(index1,focused);
! 
!             }
! 
!             ((SessionGUI)sessionPane.getComponent(sessionPane.getSelectedIndex())).grabFocus();
!             setSessionTitle();
!        }
!       });
!    }
! 
!    public void stateChanged(ChangeEvent e) {
! 
!       JTabbedPane p = (JTabbedPane)e.getSource();
! 
!       p.setForegroundAt(selectedIndex,Color.black);
!       p.setIconAt(selectedIndex,unfocused);
! 
!       SessionGUI sg = (SessionGUI)p.getComponentAt(selectedIndex);
!       sg.setVisible(false);
! 
!       sg = (SessionGUI)p.getSelectedComponent();
! 
!       if (sg == null)
!          return;
! 
!       sg.setVisible(true);
!       sg.grabFocus();
! 
!       selectedIndex = p.getSelectedIndex();
!       p.setForegroundAt(selectedIndex,Color.blue);
!       p.setIconAt(selectedIndex,focused);
! 
!       setSessionTitle();
! 
!    }
! 
!    private void setSessionTitle() {
! 
!       SessionGUI ses = getSessionAt(selectedIndex);
! 
!       if (ses != null && ses.getAllocDeviceName() != null && ses.isConnected()) {
!          if (sequence - 1 > 0)
!             setTitle(ses.getAllocDeviceName() + " - tn5250j <" + sequence + "> - " + tn5250jRelease + tn5250jVersion + tn5250jSubVer);
!          else
!             setTitle(ses.getAllocDeviceName() + " - tn5250j - " + tn5250jRelease + tn5250jVersion + tn5250jSubVer);
!       }
!       else {
! 
!          if (sequence - 1 > 0)
!             setTitle("tn5250j <" + sequence + "> - " + tn5250jRelease + tn5250jVersion + tn5250jSubVer);
!          else
!             setTitle("tn5250j - " + tn5250jRelease + tn5250jVersion + tn5250jSubVer);
!       }
! 
! 		count +=1;
! 
!    }
! 
!    public void addSessionView(String tabText,SessionGUI sessionView) {
! 
!       final SessionGUI session = sessionView;
! 
!       if (hideTabBar && sessionPane.getTabCount() == 0 && !embedded) {
! 
!          this.getContentPane().add(session, BorderLayout.CENTER);
!          session.addSessionListener(this);
! 
!          session.resizeMe();
!          repaint();
!          if (packFrame)
!             pack();
!          else
!             validate();
!          embedded = true;
!          session.grabFocus();
!          setSessionTitle();
!       }
!       else {
! 
!          if (hideTabBar && sessionPane.getTabCount() == 0 ) {
!             SessionGUI ses = null;
!             for (int x=0; x < this.getContentPane().getComponentCount(); x++) {
! 
!                if (this.getContentPane().getComponent(x) instanceof SessionGUI) {
!                   ses = (SessionGUI)(this.getContentPane().getComponent(x));
!                   this.getContentPane().remove(x);
!                   break;
!                }
!             }
! 
!             //ses = (Session)(this.getContentPane().getComponent(0));
!             sessionPane.addTab(tabText,focused,ses);
! 
!             final SessionGUI finalSession = ses;
! 
!             SwingUtilities.invokeLater(new Runnable() {
!                public void run() {
!                   finalSession.resizeMe();
!                   finalSession.repaint();
!                }
!             });
! 
! 
!             if (ses.getAllocDeviceName() != null)
!                sessionPane.setTitleAt(0,ses.getAllocDeviceName());
!             else
!                sessionPane.setTitleAt(0,ses.getSessionName());
! 
!             ses.addSessionListener(this);
!             ses.addSessionJumpListener(this);
! 
!             this.getContentPane().add(sessionPane, BorderLayout.CENTER);
!             SwingUtilities.invokeLater(new Runnable() {
!                public void run() {
!                   repaint();
!                   finalSession.grabFocus();
!                }
!             });
!          }
! 
!          sessionPane.addTab(tabText,focused,session);
! 
!          sessionPane.setForegroundAt(sessionPane.getSelectedIndex(),Color.black);
!          sessionPane.setIconAt(sessionPane.getSelectedIndex(),unfocused);
! 
!          sessionPane.setSelectedIndex(sessionPane.getTabCount()-1);
!          sessionPane.setForegroundAt(sessionPane.getSelectedIndex(),Color.blue);
!          sessionPane.setIconAt(sessionPane.getSelectedIndex(),focused);
! 
!          session.addSessionListener(this);
!          session.addSessionJumpListener(this);
! 
!          SwingUtilities.invokeLater(new Runnable() {
!             public void run() {
!                session.resizeMe();
!                session.repaint();
!                session.grabFocus();
!             }
!          });
!       }
!    }
! 
!    public void tabClosed(int tabToBeClosed){
! 
!       me.closeSession(this.getSessionAt(tabToBeClosed));
!    }
! 
!    public void removeSessionView(SessionGUI targetSession) {
! 
!       if (hideTabBar && sessionPane.getTabCount() == 0) {
!          for (int x=0; x < getContentPane().getComponentCount(); x++) {
! 
!             if (getContentPane().getComponent(x) instanceof SessionGUI) {
!                getContentPane().remove(x);
!             }
!          }
!       }
!       else {
! 
!          int index = sessionPane.indexOfComponent(targetSession);
!          log.info("session found and closing down " + index);
!          targetSession.removeSessionListener(this);
!          targetSession.removeSessionJumpListener(this);
!          int tabs = sessionPane.getTabCount();
!          sessionPane.remove(index);
!          tabs--;
! 
! 
!          if (index < tabs) {
!             sessionPane.setSelectedIndex(index);
!             sessionPane.setForegroundAt(index,Color.blue);
!             sessionPane.setIconAt(index,focused);
!             ((SessionGUI)sessionPane.getComponentAt(index)).requestFocus();
!          }
!          else {
! 
!             if (tabs > 0) {
!                sessionPane.setSelectedIndex(0);
!                sessionPane.setForegroundAt(0,Color.blue);
!                sessionPane.setIconAt(0,focused);
!                ((SessionGUI)sessionPane.getComponentAt(0)).requestFocus();
!             }
! 
!          }
!       }
!    }
! 
!    public int getSessionViewCount() {
! 
!       if (hideTabBar && sessionPane.getTabCount() == 0) {
!          for (int x=0; x < this.getContentPane().getComponentCount(); x++) {
! 
!             if (this.getContentPane().getComponent(x) instanceof SessionGUI) {
!                return 1;
!             }
!          }
!          return 0;
!       }
!       else
!          return sessionPane.getTabCount();
!    }
! 
!    public SessionGUI getSessionAt( int index) {
! 
!       if (hideTabBar && sessionPane.getTabCount() == 0) {
!          for (int x=0; x < this.getContentPane().getComponentCount(); x++) {
! 
!             if (this.getContentPane().getComponent(x) instanceof SessionGUI) {
!                return (SessionGUI)getContentPane().getComponent(x);
!             }
!          }
!          return null;
!       }
!       else {
!          if (sessionPane.getTabCount() <= 0)
!             return null;
!          return (SessionGUI)sessionPane.getComponentAt(index);
!       }
!    }
! 
!    public void onSessionChanged(SessionChangeEvent changeEvent) {
! 
!       Session5250 ses5250 = (Session5250)changeEvent.getSource();
!       SessionGUI ses = ses5250.getGUI();
! 
!       switch (changeEvent.getState()) {
!          case STATE_CONNECTED:
! 
!             final String d = ses.getAllocDeviceName();
!             if (d != null) {
!                System.out.println(changeEvent.getState() + " " + d);
!                final int index = sessionPane.indexOfComponent(ses);
!                if (index >= 0) {
!                   Runnable tc = new Runnable () {
!                      public void run() {
!                         sessionPane.setTitleAt(index,d);
!                      }
!                   };
!                   SwingUtilities.invokeLater(tc);
!                }
!                setSessionTitle();
! 
!             }
!             break;
!       }
!    }
! 
!    public boolean containsSession(SessionGUI session) {
! 
!       if (hideTabBar && sessionPane.getTabCount() == 0) {
!          for (int x=0; x < this.getContentPane().getComponentCount(); x++) {
! 
!             if (this.getContentPane().getComponent(x) instanceof SessionGUI) {
!                return ((SessionGUI)getContentPane().getComponent(x)).equals(session);
!             }
!          }
!          return false;
!       }
!       else
!          return (sessionPane.indexOfComponent(session) >= 0);
! 
!    }
! 
! }

Index: Gui5250MDIFrame.java
===================================================================
RCS file: /cvsroot/tn5250j/tn5250j/src/org/tn5250j/Gui5250MDIFrame.java,v
retrieving revision 1.19
retrieving revision 1.20
diff -C2 -d -r1.19 -r1.20
*** Gui5250MDIFrame.java	18 Jul 2004 13:38:53 -0000	1.19
--- Gui5250MDIFrame.java	22 Jul 2004 05:49:47 -0000	1.20
***************
*** 1,647 ****
! package org.tn5250j;
! /**
!  * Title: Gui5250MDIFrame.java
!  * Copyright:   Copyright (c) 2001
!  * Company:
!  * @author  Kenneth J. Pouncey
!  * @version 0.5
!  *
!  * Description:
!  *
[...1265 lines suppressed...]
!              y=0;                    // flush against the top
!            }
!            else {
!              if (y+h > d.height) {   // too low?
!                if (resizing)
!                  h = d.height - y;   // don't get taller!
!                else
!                  y = d.height-h;     // flush against the bottom
!              }
!            }
! 
!            // Set 'em the way we like 'em
!            super.setBoundsForFrame(f, x, y, w, h);
! //           ((MyInternalFrame)f).resizeMe();
!          }
! 
!        }
! 
!      }
! }



-------------------------------------------------------
This SF.Net email is sponsored by BEA Weblogic Workshop
FREE Java Enterprise J2EE developer tools!
Get your free copy of BEA WebLogic Workshop 8.1 today.
http://ads.osdn.com/?ad_id=4721&alloc_id=10040&op=click