tn5250j/src/org/tn5250j Gui5250SplitFrame.java,1.5,1.6 GuiGraphicBuffer.java,1.32,1.33 Gui5250.java,1.71,1.72
"Kenneth J. Pouncey" <[email protected]> Fri, 30 Jul 2004 06:01:54 +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-serv6074/src/org/tn5250j
Modified Files:
Gui5250SplitFrame.java GuiGraphicBuffer.java Gui5250.java
Log Message:
change to use new framework modules
Index: Gui5250SplitFrame.java
===================================================================
RCS file: /cvsroot/tn5250j/tn5250j/src/org/tn5250j/Gui5250SplitFrame.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** Gui5250SplitFrame.java 22 Jul 2004 05:49:47 -0000 1.5
--- Gui5250SplitFrame.java 30 Jul 2004 06:01:51 -0000 1.6
***************
*** 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;
! }
! }
!
! }
--- 1,398 ----
! 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;
! import org.tn5250j.framework.common.SessionManager;
!
! 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: GuiGraphicBuffer.java
===================================================================
RCS file: /cvsroot/tn5250j/tn5250j/src/org/tn5250j/GuiGraphicBuffer.java,v
retrieving revision 1.32
retrieving revision 1.33
diff -C2 -d -r1.32 -r1.33
*** GuiGraphicBuffer.java 26 Jul 2004 19:31:25 -0000 1.32
--- GuiGraphicBuffer.java 30 Jul 2004 06:01:51 -0000 1.33
***************
*** 1799,1804 ****
log.info("screen size change");
gui.resizeMe();
- // screen.setCursorActive(false);
- // screen.setCursorActive(true);
}
--- 1799,1802 ----
Index: Gui5250.java
===================================================================
RCS file: /cvsroot/tn5250j/tn5250j/src/org/tn5250j/Gui5250.java,v
retrieving revision 1.71
retrieving revision 1.72
diff -C2 -d -r1.71 -r1.72
*** Gui5250.java 26 Jul 2004 20:00:48 -0000 1.71
--- Gui5250.java 30 Jul 2004 06:01:51 -0000 1.72
***************
*** 1,1129 ****
! /**
! * Title: tn5250J
! * Copyright: Copyright (c) 2001
! * Company:
! * @author Kenneth J. Pouncey
! * @version 0.5
! *
! * Description:
! *
! * This program is free software; you can redistribute it and/or modify
[...2227 lines suppressed...]
! setEndPoint(p);
! }
! return this.endPoint;
! }
!
! protected Point getStartPoint() {
!
! if(this.startPoint == null) {
! Point p = new Point(0,0);
! bi.getPointFromRowCol(0,0,p);
! setStartPoint(p);
! }
! return this.startPoint;
!
! }
! }
!
! }
!
!
-------------------------------------------------------
This SF.Net email is sponsored by OSTG. Have you noticed the changes on
Linux.com, ITManagersJournal and NewsForge in the past few weeks? Now,
one more big change to announce. We are now OSTG- Open Source Technology
Group. Come see the changes on the new OSTG site. www.ostg.com