import java.io.*; import java.beans.*; import java.net.*; import java.net.URL; import java.text.*; import java.awt.*; import java.awt.Window; import java.awt.event.*; import javax.swing.*; import javax.swing.JOptionPane; import javax.swing.border.*; import javax.swing.plaf.*; import javax.swing.event.*; import javax.swing.JFrame; import javax.swing.JList; import javax.swing.JTextArea; import javax.swing.JTextField; import javax.swing.JButton; import javax.swing.JScrollPane; import javax.swing.DefaultListModel; import java.util.*; import java.util.List; import java.util.Vector; import java.util.ResourceBundle; import sun.net.ftp.FtpClient; public class plt2pdf_01 extends JInternalFrame implements ListSelectionListener { static int openFrameCount = 0; static final int offset = 20; String loc_ftp_cham = "Beeper_HEISCO1@CHAMELEON-1"; public plt2pdf_01 ( String loc_ftp_cham ) { super( "JetBlade Query Table - ( "+loc_ftp_cham+" )", true, true, true, true); setResizable( true ); openFrameCount++; String[] uwArr = creTArray( loc_ftp_cham, "@" ); UtmpStg = uwArr[0]; ChamLoc = uwArr[1]; Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); Dimension frameSize=new Dimension((int)(screenSize.width/2),(int)(screenSize.height/2)); int x=(int)(frameSize.width/2); int y=(int)(frameSize.height/2); JPanel topPanel = new JPanel(); topPanel.setBorder(new EmptyBorder(1,1,1,1)); topPanel.setLayout(new BorderLayout()); JPanel jb_out = new JPanel(); jb_out.setLayout(new BorderLayout()); jb_out.add(buildJBallPanel(), BorderLayout.NORTH); JPanel buttonPanel = new JPanel(); buttonPanel.setLayout ( new FlowLayout(FlowLayout.CENTER) ); ButRef = new JButton("Refresh"); ButRef.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { fieldCheck(); }}); buttonPanel.add(ButRef); ButRQry = new JButton("View Rejects"); ButRQry.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { fileRead(); }}); buttonPanel.add(ButRQry); ButRtf = new JButton("Open RTF"); ButRtf.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { openRTF(); }}); buttonPanel.add(ButRtf); ResBut = new JButton("Reset All"); ResBut.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { setResetAll(); }}); buttonPanel.add(ResBut); ExitBut = new JButton("EXIT"); ExitBut.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { DelOut(); ExitSelected(); //System.exit(0); }}); buttonPanel.add(ExitBut); topPanel.add(jb_out, BorderLayout.NORTH); topPanel.add(buttonPanel, BorderLayout.SOUTH); setContentPane(topPanel); pack(); setLocation( offset * openFrameCount, offset * openFrameCount); } public JPanel buildJBallPanel() { JPanel JBallGrid = new JPanel(); GridBagLayout gbc0 = new GridBagLayout(); JBallGrid.setLayout(gbc0); // Input Grid JPanel JBinPanel = new JPanel(); GridBagLayout gbc1 = new GridBagLayout(); JBinPanel.setLayout(gbc1); JBinPanel.setBorder( new TitledBorder("INPUT") ); // FTP Panel JPanel ftp_Panel = new JPanel(); JLabel ftp_Label = new JLabel (" FTP Location Selected : "); ftp_Field = new JTextField(18); ftp_Field.setEditable(false); ftp_Panel.add(ftp_Label); ftp_Panel.add(ftp_Field); JBinPanel.add(ftp_Panel, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0 ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(3, 3, 3, 3), 5, 0)); //JBinPanel.add(jbchcPanel, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0 //,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(3, 3, 3, 3), 5, 0)); // Part, Lot & Control Number Panels JPanel JBtaPanel = new JPanel(); GridBagLayout gbc2 = new GridBagLayout(); JBtaPanel.setLayout(gbc2); JBtaPanel.setBorder( new TitledBorder("INPUT") ); // Part Number Panel (JLabel(2), JTextArea & JTextField) JPanel PnumJl_StgPanel = new JPanel(); PnumJl_StgPanel.setLayout(new BorderLayout()); JLabel PnumJl_StgLabel = new JLabel(" Part Number: "); PnumJl_StgPanel.add(PnumJl_StgLabel, BorderLayout.NORTH); PlistModel = new DefaultListModel(); PnumJList = new JList(PlistModel); PnumJList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); PnumJList.addListSelectionListener(this); PtextScroller = new JScrollPane( PnumJList, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); PtextScroller.setPreferredSize(new Dimension(80, 160)); PnumJl_StgPanel.add(PtextScroller); PnumField = new JTextField(14); PnumField.setEditable(false); PnumJl_StgPanel.add(PnumField, BorderLayout.SOUTH); // Lot Number Panel (JLabel(2), JTextArea & JTextField) JPanel LnumJl_StgPanel = new JPanel(); LnumJl_StgPanel.setLayout(new BorderLayout()); JLabel LnumJl_StgLabel = new JLabel (" Lot Number: "); LnumJl_StgPanel.add(LnumJl_StgLabel, BorderLayout.NORTH); LlistModel = new DefaultListModel(); LnumJList = new JList(LlistModel); LnumJList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); LnumJList.addListSelectionListener(this); LtextScroller = new JScrollPane( LnumJList, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); LtextScroller.setPreferredSize(new Dimension(80, 160)); LnumJl_StgPanel.add(LtextScroller); LnumField = new JTextField(14); LnumField.setEditable(false); LnumJl_StgPanel.add(LnumField, BorderLayout.SOUTH); // Control Number Panel (JLabel(2), JTextArea & JTextField) JPanel CnumJl_StgPanel = new JPanel(); CnumJl_StgPanel.setLayout(new BorderLayout()); JLabel CnumJl_StgLabel = new JLabel ("Control Number: "); CnumJl_StgPanel.add(CnumJl_StgLabel, BorderLayout.NORTH); SlistModel = new DefaultListModel(); CnumJList = new JList(SlistModel); CnumJList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); CnumJList.addListSelectionListener(this); StextScroller = new JScrollPane( CnumJList, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); StextScroller.setPreferredSize(new Dimension(80, 160)); CnumJl_StgPanel.add(StextScroller); CnumField = new JTextField(10); CnumField.setEditable(false); CnumJl_StgPanel.add(CnumField, BorderLayout.SOUTH); JBtaPanel.add(PnumJl_StgPanel, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0 ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(3, 3, 3, 3), 5, 0)); JBtaPanel.add(LnumJl_StgPanel, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0 ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(3, 3, 3, 3), 5, 0)); JBtaPanel.add(CnumJl_StgPanel, new GridBagConstraints(2, 0, 1, 1, 0.0, 0.0 ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(3, 3, 3, 3), 5, 0)); // Status Grid JPanel JBoutPanel = new JPanel(); GridBagLayout gbc3 = new GridBagLayout(); JBoutPanel.setLayout(gbc3); JBoutPanel.setBorder( new TitledBorder("STATUS") ); JPanel Prog_StgPanel = new JPanel(); Prog_StgPanel.setLayout(new BorderLayout()); JLabel Prog_StgLabel = new JLabel ("Status Results:"); Prog_StgPanel.add(Prog_StgLabel, BorderLayout.NORTH); ProgField = new JTextField(40); ProgField.setEditable(false); Prog_StgPanel.add(ProgField, BorderLayout.SOUTH); JBoutPanel.add(Prog_StgPanel, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0 ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(3, 3, 3, 3), 5, 0)); // All Panel Grid JBallGrid.add(JBinPanel, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0 ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(3, 3, 3, 3), 5, 0)); JBallGrid.add(JBtaPanel, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0 ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(3, 3, 3, 3), 5, 0)); JBallGrid.add(JBoutPanel, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0 ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(3, 3, 3, 3), 5, 0)); setResetAll(); if ( UtmpStg.indexOf("HEISCO1") > -1 ) { ftp_Field.setText( "heisco1.heico-dc.com" ); } else if ( UtmpStg.indexOf("BLACMM1") > -1 ) { ftp_Field.setText( "blacmm1.heico-dc.com" ); } else { ftp_Field.setText( "meatii.heico-dc.com" ); } DirGetFeed(); return JBallGrid; } public void fileRead() { Fstg = getftp_Fstg(); Pnum = getPnum(); Lnum = getLnum(); Cnum = getCnum(); entV = new Vector(); try { if ( Fstg.indexOf("heisco1") >= 0 ) { path1 = "../../"; } String ftpAdd = "ftp://" + uNm + ":" + pWd + "@" + Fstg + path1 + jbStg; outInPut = ftpAdd + Pnum + "/" + Lnum + "/MRB.TXT"; String surl = outInPut; URL url = new URL(surl); BufferedReader reader = new BufferedReader(new InputStreamReader(url.openStream())); lines = new Vector(); String aLine = reader.readLine(); while( aLine != null ) { lines.addElement( aLine ); aLine = reader.readLine(); } fulText = new String[ lines.size() ]; lines.copyInto( fulText ); reader.close(); } catch (IOException exc2) { fulText = new String[0]; ProgField.setText("No Airfoil MRB.TXT Found."); } if ( lines.size() == 0 ) { ProgField.setText("File: " + outInPut + " has 0 size."); } AirRead(); RootRead(); String NewRjtFile = Pnum + "_" + Lnum + "_rej_out.txt"; SaveRjt( NewRjtFile ); RunCmdInt( NewRjtFile, "np" ); } public void AirRead() { entV.addElement(" ");entV.addElement( strStg ); String tmpT_Stg = "AIRFOIL MRB.TXT OUTPUT:"; entV.addElement( tmpT_Stg );entV.addElement( strStg );entV.addElement(" "); for (i = 0; i < fulText.length; i++) { entV.addElement( fulText[i] ); } } public void RootRead() { Lnum = getLnum(); Pnum = getPnum(); int fndFile = 0; rjtFile="\\\\"+ChamLoc+"\\PC-DMIS\\LOT_DATA\\"+Lnum+"\\"+Pnum+"_"+Lnum+".txt"; //System.out.println("rtfFile: " + rtfFile); File aFile = new File(rjtFile); if(!aFile.exists()) { ProgField.setText(Pnum+"_"+Lnum+".txt does NOT exist."); System.out.println(Pnum+"_"+Lnum+".txt does NOT exist at any of the Chameleon 1-4 Locations."); } else { rjtRead( rjtFile ); rjtText = new String[ entV.size() ]; entV.copyInto( rjtText ); } } public void rjtRead( String rjtFn ) { entV.addElement(" ");entV.addElement( strStg ); String tmpT_Stg = "ROOT REJECT "+Pnum+"_"+Lnum+".txt OUTPUT:\r"; entV.addElement( tmpT_Stg );entV.addElement( strStg );entV.addElement(" "); try { FileInputStream fis = new FileInputStream(rjtFn); InputStreamReader isr = new InputStreamReader(fis); LineNumberReader lnr = new LineNumberReader(isr); String afLineN = lnr.readLine(); while( afLineN != null ) { entV.addElement( afLineN ); afLineN = lnr.readLine(); } isr.close(); } catch (IOException exc2) { System.out.println("Root Reject Exception for File: " + rjtFn); //exc2.printStackTrace(); } } public void CnumQuery( String sName, String uName, String pWord, String cdPath ) { try { outInPut = "ftp://" + uName + ":" + pWord + "@" + sName + cdPath + "/OUTPUT.TXT"; //System.out.println("outInPut: " + outInPut); String surl = outInPut; URL url = new URL(surl); BufferedReader reader = new BufferedReader(new InputStreamReader(url.openStream())); lines = new Vector(); String aLine = reader.readLine(); while( aLine != null ) { lines.addElement( aLine ); aLine = reader.readLine(); } fulText = new String[ lines.size() ]; lines.copyInto( fulText ); reader.close(); } catch (IOException exc2) { fulText = new String[0]; ProgField.setText("No OUTPUT.TXT Found on: "+ sName + cdPath); CnumJList.setModel(SlistModel = new DefaultListModel()); } if (fulText.length==0) { ProgField.setText("NO DATA Found on: "+ sName + cdPath); } else { QueryRead( fulText ); } if ( lines.size() == 0 ) { ProgField.setText("File: " + outInPut + " has 0 size."); } } public void QueryRead( String[] fulText ) { Pnum = getPnum();Cnum = getCnum(); String tstStg, dirStg1, dirStg2, dirStg1p4, dirStg2p4, finStg = ""; int rcntr, tstPos, dirPos, lcntr = 0; Vector serV = new Vector(); for (i = 0; i < fulText.length; i++) { int sec2Pos = fulText[i].indexOf("SECT"); int prt2Pos = fulText[i].indexOf(Pnum); if ( sec2Pos > 0 && prt2Pos == 0 ) { dirStg1 = fulText[i].substring(sec2Pos-1,fulText[i].length()); int ptPos = dirStg1.lastIndexOf("."); int spPos = dirStg1.lastIndexOf(" "); dirStg2 = dirStg1.substring(ptPos+1,spPos); serV.addElement( dirStg2 ); } } String[] serStgArr = new String[ serV.size() ]; serV.copyInto( serStgArr ); String[] serStgArr1 = sortStrings( serStgArr ); String[] serStgArrS = reverseStrings( serStgArr1 ); for (int s = 0; s < serStgArrS.length; s++) { int ftlg = serStgArrS.length; int spl = s+1; if ( spl < serStgArrS.length ) { if(serStgArrS[s].compareToIgnoreCase(serStgArrS[spl]) == 0) { lcntr++; } else { lcntr++; finStg = serStgArrS[s] + " - " + lcntr; if (!alreadyInSList(finStg)) { SlistModel.addElement(finStg); } lcntr=0; finStg = ""; } } else { lcntr++; finStg = serStgArrS[s] + " - " + lcntr; if (!alreadyInSList(finStg)) { SlistModel.addElement(finStg); } lcntr=0; finStg = ""; } } } public void DirGetFeed() { Fstg = getftp_Fstg(); Pnum = getPnum(); Lnum = getLnum(); String cdP = path1 + jbStg + Pnum + "/" + Lnum; if ( Pnum.length() > 0 && Lnum.length() > 0 ) { CnumQuery( Fstg, uNm, pWd, cdP ); } else { DirGet( Fstg, uNm, pWd, cdP ); } } public void fieldCheck() { Fstg = getftp_Fstg();Pnum = getPnum();Lnum = getLnum();Cnum = getCnum(); if (Fstg.length()==0 || Pnum.length()==0 || Lnum.length()==0) { ProgField.setText("Insufficient Data. Please Select FTP Location, Part, Lot & Control Numbers."); } else { DirGetFeed(); } if (Fstg.length()>0 && Pnum.length()>0 && Lnum.length()>0 ) { if ( CnumJList.getModel().getSize() > 0 ) { fulText = new String[0]; CnumJList.setModel(SlistModel = new DefaultListModel()); CnumField.setText(""); } DirGetFeed(); } } public void DirGet( String sName, String uName, String pWord, String cdPath ) { Vector getV = new Vector(); int tstInt = 0; try { FtpWr ftpt = new FtpWr(); String[] fulTextR = null; ftpt.openServer(sName); if (ftpt.serverIsOpen()) { try { ftpt.login(uName, pWord); ftpt.cdDir(cdPath); fulTextR=ftpt.listRawStg(); tstInt = 0; for (int i = 0; i < fulTextR.length; i++) { int spPos = fulTextR[i].lastIndexOf(" "); dirStg = fulTextR[i].substring(spPos+1,fulTextR[i].length()); int dotPos = dirStg.indexOf("."); int dPos = fulTextR[i].indexOf("d"); int revPos = dirStg.indexOf("rev"); int tmpPos = dirStg.indexOf("TMP"); if ( dotPos < 0 && dPos == 0 && revPos < 0 && tmpPos < 0) { getV.addElement( dirStg ); tstInt++; } } } catch (Exception ftpe) { ftpe.printStackTrace(); } finally { ftpt.closeServer(); } } else { System.out.println("Unable to connect to" + sName); } } catch(Exception e) { ProgField.setText("Unable to connect to: " + sName + ", Please select another Location."); } String[] serStgArr = new String[ getV.size() ]; getV.copyInto( serStgArr ); String[] serStgArr1 = sortStrings( serStgArr ); String[] serStgArrS = reverseStrings( serStgArr1 ); for (int s = 0; s < serStgArrS.length; s++) { if ( Pnum.length() > 0 ) { if (!alreadyInLList(serStgArrS[s])) { LlistModel.addElement(serStgArrS[s]); } } else { if (!alreadyInPList(serStgArrS[s])) { PlistModel.addElement(serStgArrS[s]); } } } if ( tstInt == 0 ) { ProgField.setText("No Data Found."); LnumField.setText(""); LnumJList.setModel(LlistModel = new DefaultListModel()); CnumJList.setModel(SlistModel = new DefaultListModel()); } else { tstInt = 0; } } public void valueChanged(ListSelectionEvent e) { if (e.getValueIsAdjusting() == false) { if (PnumJList.getSelectedIndex() != -1) { PnumSnm = PnumJList.getSelectedValue().toString(); ProgField.setText(""); PnumField.setText(""); PnumField.setText(PnumSnm); PnumJList.clearSelection(); if ( LnumJList.getModel().getSize() > 0 ) { LnumJList.setModel(LlistModel = new DefaultListModel()); LnumField.setText(""); } if ( CnumJList.getModel().getSize() > 0 ) { CnumJList.setModel(SlistModel = new DefaultListModel()); CnumField.setText(""); } DirGetFeed(); } if (LnumJList.getSelectedIndex() != -1) { LnumSnm = LnumJList.getSelectedValue().toString(); ProgField.setText(""); LnumField.setText(""); LnumField.setText(LnumSnm); LnumJList.clearSelection(); if ( CnumJList.getModel().getSize() > 0 ) { CnumJList.setModel(SlistModel = new DefaultListModel()); CnumField.setText(""); } DirGetFeed(); } if (CnumJList.getSelectedIndex() != -1) { String CnumSnm1 = CnumJList.getSelectedValue().toString(); int dshPos = CnumSnm1.lastIndexOf(" - "); CnumSnm = CnumSnm1.substring(0,dshPos); CnumField.setText(""); ProgField.setText(""); CnumField.setText(CnumSnm); CnumJList.clearSelection(); stgRead(); getDataNm = getDataNm(); SaveSelected( getDataNm ); RunCmdInt( getDataNm, "np" ); } } } public void stgRead() { Pnum = getPnum(); Cnum = getCnum(); int tcntr = cntr; int scntr = 0; finText = new String[ fulText.length ]; for (h = 0; h < finText.length; h++) {finText[h] = "";} for (i = 0; i < fulText.length; i++) { int serPos = fulText[i].indexOf("." + Cnum); int prtPos = fulText[i].indexOf(Pnum); if ( serPos > 0 && prtPos == 0 ) { finText[nctr] = fulText[i]; scntr++; finText[nctr+1] = fulText[i+1]; finText[nctr+2] = fulText[i+2]; finText[nctr+3] = fulText[i+3]; nctr=nctr+4; } } ProgField.setText(scntr + " Sections with CONTROL NUMBER: " + Cnum + " were Found."); } protected boolean alreadyInPList(String name) { return PlistModel.contains(name); } protected boolean alreadyInLList(String name) { return LlistModel.contains(name); } protected boolean alreadyInSList(String name) { return SlistModel.contains(name); } public void openRTF() { Lnum = getLnum(); Cnum = getCnum(); int fndFile = 0; Vector rtfLoopV = new Vector(); String[] rtfLoop = new String[] { "\\ROOTPLATSLOT", "\\PLAT", "\\PROD_FILLET", "\\TIP" }; for (j = 0; j < 4; j++) { rtfFile = "\\\\"+ChamLoc+"\\PC-DMIS\\LOT_DATA\\" + Lnum + rtfLoop[j] + Cnum + ".RTF"; //System.out.println( "rtfFile: " + rtfFile ); File aFile = new File(rtfFile); if(aFile.exists()) { rtfLoopV.addElement( rtfFile ); fndFile++; } } String[] rtfLoop2 = new String[ rtfLoopV.size() ]; rtfLoopV.copyInto( rtfLoop2 ); if ( fndFile == 0 ) { System.out.println( ".RTF file could not be located." ); } else { for (k = 0; k < rtfLoop2.length; k++) { rtfRead( rtfLoop2[k] ); rtfText = new String[0]; rtfText = new String[ rtflines.size() ]; rtflines.copyInto( rtfText ); String NewRtfFile = Lnum + "_" + Cnum + "_" + k + "_out.RTF"; SaveRtf( NewRtfFile ); RunCmdInt( NewRtfFile, "wp" ); } } } public void rtfRead( String rtfFn ) { rtflines = new Vector(); try { FileInputStream fis = new FileInputStream(rtfFn); InputStreamReader isr = new InputStreamReader(fis); LineNumberReader lnr = new LineNumberReader(isr); String afLineN = lnr.readLine(); while( afLineN != null ) { if ( afLineN.indexOf("\\page") < 0 ) { rtflines.addElement( afLineN ); //System.out.println( "rtfFn: " + rtfFn + " & afLineN: " + afLineN ); } afLineN = lnr.readLine(); } isr.close(); } catch (IOException exc2) { System.out.println("RTF Exception: "); //exc2.printStackTrace(); } } public void SaveRjt( String RjtNew ) { try { PrintStream expfl = new PrintStream(new FileOutputStream(RjtNew)); for (j = 0; j < rjtText.length; j++) { if ( rjtText[j] != "" ) { expfl.println( rjtText[j] ); //System.out.println( "SaveRjt: rjtText[j]: " + rjtText[j] + " & j: " + j ); } } expfl.flush(); expfl.close(); } catch(java.io.IOException IOEx) { System.out.println("Cannot create " + RjtNew + " file."); } } public void SaveRtf( String RtfNew ) { try { PrintStream expfl = new PrintStream(new FileOutputStream(RtfNew)); for (j = 0; j < rtfText.length; j++) { if ( rtfText[j] != "" ) { expfl.println( rtfText[j] ); //System.out.println( "SaveRtf: rtfText[j]: " + rtfText[j] + " & j: " + j ); } } expfl.flush(); expfl.close(); } catch(java.io.IOException IOEx) { System.out.println("Cannot create " + RtfNew + " file."); } } public void SaveSelected( String getDataNm ) { try { PrintStream expfl = new PrintStream(new FileOutputStream(getDataNm)); for (j = 0; j < finText.length; j++) { if ( finText[j] != "" ) { expfl.println( finText[j] ); } } expfl.flush(); expfl.close(); } catch(java.io.IOException IOEx) { System.out.println("Cannot create " + getDataNm + " file."); } } public String[] sortStrings( String[] strings ) { for ( int i = 0; i < strings.length - 1; ++i ) { for ( int j = i + 1; j < strings.length; ++j ) { if ( strings[i].compareTo( strings[j] ) > 0 ) { String t = strings[i]; strings[i] = strings[j]; strings[j] = t; } } } return strings; } public String[] reverseStrings( String[] strings ) { String temp; int left = 0; int right = strings.length - 1; while (left < right) { temp = strings[left]; strings[left] = strings[right]; strings[right] = temp; right--; left++; } return strings; } public String[] creTArray(String toArray, String splitChar) { StringTokenizer token1 = new StringTokenizer(toArray,splitChar); int number1 = token1.countTokens(); String[] newArray = new String[ number1 ]; for (int i = 0; i < number1; i++) { String st = token1.nextToken(); newArray[i] = st; } return newArray; } public void DelOut() { String s2 = null; try { String delStg = ("\"del *_out.*\""); Process p2 = Runtime.getRuntime().exec("cmd /C " + delStg ); BufferedReader stdInput2 = new BufferedReader(new InputStreamReader(p2.getInputStream())); BufferedReader stdError2 = new BufferedReader(new InputStreamReader(p2.getErrorStream())); while ((s2 = stdInput2.readLine()) != null) { System.out.println( s2 ); } } catch (IOException e9) { System.out.println("Exception: "); //e9.printStackTrace(); System.exit(-1); } } public void RunCmdInt ( String getDataNm, String ed ) { String s = null; try { String notepad = ("\"%windir%\\notepad.exe\""); String wordpad = ("\"C:\\Program Files\\Windows NT\\Accessories\\wordpad.exe\""); String editor = notepad; if ( ed.compareTo( "wp" ) >= 0 ) { editor = wordpad; } Process p = Runtime.getRuntime().exec("cmd /C " + editor + " " + getDataNm ); BufferedReader stdInput = new BufferedReader(new InputStreamReader(p.getInputStream())); BufferedReader stdError = new BufferedReader(new InputStreamReader(p.getErrorStream())); while ((s = stdInput.readLine()) != null) { System.out.println( s ); } } catch (IOException e) { System.out.println("Exception: " ); //e.printStackTrace(); System.exit(-1); } } public String getDataNm() { Pnum = getPnum(); Lnum = getLnum(); OutFileNm = Pnum + "." + Lnum + "_out.txt"; return OutFileNm; } public String getPnum() { Pnum = PnumField.getText(); return Pnum; } public String getLnum(){ Lnum = LnumField.getText(); return Lnum; } public String getCnum() { Cnum = CnumField.getText(); return Cnum; } public String getftp_Fstg(){ ftp_Fstg = ftp_Field.getText(); return ftp_Fstg; } public void setResetAll() { PnumField.setText(""); LnumField.setText(""); CnumField.setText(""); //ftp_Field.setText(""); ProgField.setText(""); //if ( PnumJList.getModel().getSize() > 0 ) { PnumJList.setModel(PlistModel = new DefaultListModel()); } if ( LnumJList.getModel().getSize() > 0 ) { LnumJList.setModel(LlistModel = new DefaultListModel()); } if ( CnumJList.getModel().getSize() > 0 ) { CnumJList.setModel(SlistModel = new DefaultListModel()); } } public void ExitSelected() { this.setVisible(false); } JList PnumJList, LnumJList, CnumJList; JTextField PnumField, LnumField, CnumField, ProgField, ftp_Field; JButton ButQry, ButRQry, ButRef, ExitBut, ResBut, OpenBut; JButton GetBut, RInBut, RStatBut, RQuBut, ButRtf; JScrollPane PtextScroller, LtextScroller, StextScroller; ListSelectionModel listSelectionModel; DefaultListModel PlistModel, LlistModel, SlistModel; String Fstg, Pnum, Lnum, Cnum, query, ftp_stg, ftp_Fstg, OutFileNm, dirStg, codeStg, tfulStg; String PnumSnm, LnumSnm, CnumSnm, outInPut, cdPath, hostName, afLineN, rtfFile, rjtFile; String TmpFileNm, getDataNm, dataOutStg, DOSubNm, DataOutSubStg, delStg, SubStg, UtmpStg, ChamLoc; static String argStg; static int argInt; Vector ncrV, fulV, entV, rtfV, lines, flines, rtflines; String[] fulText, finText, strpText, rtfText, rjtText; String strStg = "****************************************"; int cntr, scntr, nctr, rcntr, h, i, j, k = 0; String uNm = "transfer", pWd = "transfer", jbStg = "/JB_FILES/", path1 = "/u/mm4"; String ed, statStg = "STATISTICAL PROCESS CONTROL"; } class jb_item { private String jb_name; private String jb_stg; public jb_item() { jb_name = ""; jb_stg = ""; } jb_item( String jb_name_, String jb_stg_ ) { jb_name = jb_name_; jb_stg = jb_stg_; } public String getName() { return jb_name; } public String getStg() { return jb_stg; } public String toString() { return jb_name; } } class FtpWr extends FtpClient { public boolean cdDir (String dirPath) throws IOException { issueCommand("CWD " + dirPath); return isValidResponse(); } public String[] listRawStg() throws IOException { BufferedReader reader = new BufferedReader(new InputStreamReader(list())); Vector lines = new Vector(); String aLine = reader.readLine(); while( aLine != null ) { lines.addElement( aLine ); aLine = reader.readLine(); } String[] lineArray = new String[ lines.size() ]; lines.copyInto( lineArray ); return lineArray; } public boolean isValidResponse() { try { int respCode = Integer.parseInt(getResponseString().substring(0, 3)); return (respCode >= 200 && respCode < 300); } catch (Exception e) { return false; } } }