tn5250j/src/org/tn5250j/framework/tn5250 Screen5250.java,1.9,1.10 ScreenPlanes.java,1.6,1.7 ScreenField.java,1.4,1.5

"Kenneth J. Pouncey" <[email protected]> Mon, 02 Aug 2004 17:20:10 +0000
Newsgroups gmane.comp.java.tn5250j.cvs
Message-ID <[email protected]>
Update of /cvsroot/tn5250j/tn5250j/src/org/tn5250j/framework/tn5250
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16962/src/org/tn5250j/framework/tn5250

Modified Files:
	Screen5250.java ScreenPlanes.java ScreenField.java 
Log Message:
Added new methods for working with framework API

Index: ScreenPlanes.java
===================================================================
RCS file: /cvsroot/tn5250j/tn5250j/src/org/tn5250j/framework/tn5250/ScreenPlanes.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** ScreenPlanes.java	1 Aug 2004 14:21:29 -0000	1.6
--- ScreenPlanes.java	2 Aug 2004 17:20:07 -0000	1.7
***************
*** 50,54 ****
     protected char[] screenIsChanged;
  
!    protected char[] initArray;   
  
     protected char[] errorLine;
--- 50,54 ----
     protected char[] screenIsChanged;
  
!    protected char[] initArray;
  
     protected char[] errorLine;
***************
*** 94,98 ****
  
        initArray = new char[screenSize];
!       
        initalizePlanes();
     }
--- 94,98 ----
  
        initArray = new char[screenSize];
! 
        initalizePlanes();
     }
***************
*** 221,225 ****
        screenGUI[pos] = (char)which;
     }
!    
     private void disperseAttribute(int pos, int attr) {
  
--- 221,225 ----
        screenGUI[pos] = (char)which;
     }
! 
     private void disperseAttribute(int pos, int attr) {
  
***************
*** 368,371 ****
--- 368,372 ----
           case 63:  // nondisplay
              nd = EXTENDED_5250_NON_DSP;
+             cs = EXTENDED_5250_COL_SEP;
              break;
           default:
***************
*** 391,398 ****
  
        }
!       
!       // here we will just copy the initialized plane onto the other planes 
        // using arraycopy which will be faster.  I hope.
!      
        System.arraycopy(initArray,0,screen,0,screenSize);
        System.arraycopy(initArray,0,screenGUI,0,screenSize);
--- 392,399 ----
  
        }
! 
!       // here we will just copy the initialized plane onto the other planes
        // using arraycopy which will be faster.  I hope.
! 
        System.arraycopy(initArray,0,screen,0,screenSize);
        System.arraycopy(initArray,0,screenGUI,0,screenSize);

Index: ScreenField.java
===================================================================
RCS file: /cvsroot/tn5250j/tn5250j/src/org/tn5250j/framework/tn5250/ScreenField.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** ScreenField.java	1 Aug 2004 21:14:29 -0000	1.4
--- ScreenField.java	2 Aug 2004 17:20:07 -0000	1.5
***************
*** 169,173 ****
     }
  
!    public String getText() {
  
  
--- 169,173 ----
     }
  
!    protected String getText() {
  
  
***************
*** 216,219 ****
--- 216,269 ----
     }
  
+    public String getString() {
+ 
+ 
+       StringBuffer text = new StringBuffer();
+       getKeyPos(endPos);
+       int x = length;
+       text.setLength(x);
+       int nc = s.getColumns();
+       while (x-- > 0) {
+ 
+          // here we manipulate the unicode characters a little for attributes
+          //    that are imbedded in input fields.  We will offset them by unicode
+          //    \uff00.   All routines that process these fields will have to
+          //    return them to their proper offsets.
+          //    example:
+          //    if we read an attribute byte of 32 for normal display the unicode
+          //       character for this is \u0020 and the unicode character for
+          //       a space is also \u0020 thus the offset.
+          if (s.planes.isAttributePlace(cursorPos)) {
+             text.setCharAt(x,(char)('\uff00' + s.planes.getCharAttr(cursorPos)));
+          }
+          else {
+             if (s.planes.getChar(cursorPos) < ' ')
+                text.setCharAt(x,' ');
+             else
+                text.setCharAt(x,s.planes.getChar(cursorPos));
+          }
+          changePos(-1);
+ 
+       }
+ 
+       // Since only the mdt of the first continued field is set we will get
+       //    the text of the next continued field if we are dealing with continued
+       //    fields.  See routine setMDT for the whys of this.  This is only
+       //    executed if this is the first field of a continued field.
+       if (isContinued() && isContinuedFirst()) {
+          ScreenField sf = this;
+          do {
+             sf = sf.next;
+             text.append(sf.getString());
+          }
+          while (!sf.isContinuedLast());
+ 
+          sf = null;
+       }
+ 
+       return text.toString();
+ 
+    }
+ 
     public void setFieldChar(char c) {
  
***************
*** 459,462 ****
--- 509,541 ----
     }
  
+    /**
+     * Sets the field's text plane to the specified string. If the string is
+     * shorter than the length of the field, the rest of the field is cleared.
+     * If the string is longer than the field, the text is truncated. A subsequent
+     * call to getText on this field will not show the changed text. To see the
+     * changed text, do a refresh on the iOhioFields collection and retrieve the
+     * refreshed field object.
+     *
+     * @param text - The text to be placed in the field's text plane.
+     */
+    public void setString(String text) {
+ 
+ //      int y = length;
+ //      cursorPos = startPos;
+ //      int len = text.length();
+ //      char[] c = text.toCharArray();
+ //      char tc = ' ';
+ //      for (int x = 0; x < y; x++) {
+ //         tc = ' ';
+ //         if (x < len) {
+ //            tc = c[x];
+ //         }
+ //         data[x] = tc;
+          s.setScreenData(text,startPos);
+ //         changePos(1);
+ //      }
+ 
+    }
+ 
     public String toString() {
        int fcw = (fcw1 & 0xff) << 8 | fcw2 & 0xff;

Index: Screen5250.java
===================================================================
RCS file: /cvsroot/tn5250j/tn5250j/src/org/tn5250j/framework/tn5250/Screen5250.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** Screen5250.java	1 Aug 2004 21:14:29 -0000	1.9
--- Screen5250.java	2 Aug 2004 17:20:07 -0000	1.10
***************
*** 2646,2649 ****
--- 2646,2689 ----
     }
  
+    protected synchronized void setScreenData(String text, int location) {
+ //                                             throws OhioException {
+ 
+       if (location < 0 || location > lenScreen) {
+          return;
+ //         throw new OhioException(sessionVT.getSessionConfiguration(),
+ //         				OhioScreen5250.class.getName(), "osohio.screen.ohio00300", 1);
+       }
+ 
+       int pos = location;
+ 
+       int l = text.length();
+       boolean updated = false;
+       boolean flag = false;
+       int x =0;
+       for (; x < l; x++) {
+          if (isInField(pos + x,true)) {
+             if (!screenFields.getCurrentField().isBypassField()) {
+                if (!flag) {
+                   screenFields.getCurrentField().setMDT();
+                   updated = true;
+                   resetDirty(pos + x);
+                   screenFields.setMasterMDT();
+                   flag = true;
+                }
+ 
+                planes.screen[pos + x] = text.charAt(x);
+ //               screenFields.getCurrentField().setFieldChar(pos+x,text.charAt(x));
+                setDirty(pos + x);
+             }
+          }
+ 
+       }
+       lastPos = pos + x;
+       if (updated) {
+          fireScreenChanged(1);
+       }
+ 
+    }
+ 
  	/**
  	 * This routine is based on offset 1,1 not 0,0 it will translate to offset
***************
*** 3158,3162 ****
  
  		planes.setScreenCharAndAttr(lastPos, initChar, lastAttr, true);
! 		
  		setDirty(lastPos);
  
--- 3198,3202 ----
  
  		planes.setScreenCharAndAttr(lastPos, initChar, lastAttr, true);
! 
  		setDirty(lastPos);
  
***************
*** 3190,3197 ****
  					planes.setUseGUI(lastPos,FIELD_MIDDLE);
  				}
! 				
  				// now we set the field plane attributes
  				planes.setScreenFieldAttr(lastPos,ffw1);
! 				
  				advancePos();
  
--- 3230,3237 ----
  					planes.setUseGUI(lastPos,FIELD_MIDDLE);
  				}
! 
  				// now we set the field plane attributes
  				planes.setScreenFieldAttr(lastPos,ffw1);
! 
  				advancePos();
  
***************
*** 3412,3416 ****
  			setDirty(pos++);
  		}
! 		
  		updateDirty();
  
--- 3452,3456 ----
  			setDirty(pos++);
  		}
! 
  		updateDirty();
  



-------------------------------------------------------
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