You are on page 1of 6

/*Written by SAISYSTEMS S.A. DE C.V.

* Creation date: 02/03/2015


* This APPLICATION is provided without any warranty or support SAISYSTEMS S.A.
DE C.V.
*/
import java.awt.*;
import java.awt.event.*;
import java.io.InputStreamReader;
import javax.swing.JButton;
import javax.swing.JToggleButton;
public class xWin extends XBASIC{
Thread thread, thread2,thread3;
FTPC ftp=new FTPC();
public xWin(){
grph();
thread = new Thread(){
public void run(){
SVR(true);
}
};
thread.start();
Cnfg();
}
@SuppressWarnings("static-access")
public javax.swing.JFrame grph(){
final String[] fun={"STOP","START"};
final javax.swing.JFrame grp=new javax.swing.JFrame();
javax.swing.JPanel jp=new javax.swing.JPanel();
final javax.swing.JButton cmd=new javax.swing.JButton();
cmd.setBounds(0, 0, 100, 50);
cmd.setFont(new java.awt.Font("",java.awt.Font.BOLD,36));
cmd.setText(fun[0]);
cmd.setActionCommand(fun[0]);
jp.setBounds(0, 0, 295, 153);
jp.setVisible(true);
jp.setLayout(new java.awt.GridLayout(1,1));
jp.add(cmd);
grp.getContentPane().add(jp);
grp.getContentPane().setLayout(null);
grp.setTitle("OASYS");
grp.setSize(300,180);
grp.setLocationRelativeTo(null);
grp.setDefaultCloseOperation(grp.DISPOSE_ON_CLOSE);
grp.setVisible(true);
Keys(cmd,grp,Dlg());
grp.setResizable(false);
cmd.addActionListener(new java.awt.event.ActionListener(){
public void actionPerformed(java.awt.event.ActionEvent e
){
if(e.getActionCommand().equals(fun[0])){
try{
if(xclc!=0){
if(xclc==1){
xbf=null;
Cs.close();
}else{
Ss.close();
}
}
thread2.interrupt();

if(thread2.isInterrupted()){
Ss.close();
Ss=null;
Cs=null;
thread2=null;
}
}catch(Exception ex){
ex.printStackTrace();
}
PRINT("STOP SERVER");
cmd.setText(fun[1]);
cmd.setActionCommand(fun[1]);
}else if(e.getActionCommand().equals(fun[1])){
try{
Ss=new java.net.ServerSocket(100
1);
PRINT("RESTART SERVER");
}catch(Exception ex){ex.printStackTrace(
);}
cmd.setText(fun[0]);
cmd.setActionCommand(fun[0]);
}
}
});
grp.addWindowListener(new java.awt.event.WindowAdapter() {
//public void windowClosed(java.awt.event.WindowEvent e)
{
//
Instructions
//}
@SuppressWarnings("deprecation")
public void windowClosing(java.awt.event.WindowEvent e){
if(thread.isAlive()){
thread.interrupt();
thread.stop();
}
try{
Cs.close();
Ss.close();
}catch(Exception ex){}
thread=null;
PRINT("SHUTDOWN SYSTEM");
End(0);
}
});
return grp;
}
public javax.swing.JList ls=new javax.swing.JList();
@SuppressWarnings("static-access")
public javax.swing.JDialog Dlg(){
javax.swing.JDialog grp=new javax.swing.JDialog();
javax.swing.JPanel jp=new javax.swing.JPanel();
final javax.swing.JTextField txt=new javax.swing.JTextField();
txt.setSize(130, 30);
txt.setLocation(5, 3);
txt.setText("*.lpc");
final javax.swing.JButton cmd=new javax.swing.JButton();
cmd.setSize(90, 30);
cmd.setLocation(137, 3);
cmd.setText("FIND");
final javax.swing.JList ls=new javax.swing.JList();

javax.swing.JScrollPane sp = new javax.swing.JScrollPane(ls);


sp.setBounds(5, 36, 220, 180);
ls.setSize(205, 180);
ls.setLocation(5, 36);
Mous(ls);
jp.setBounds(0, 0, 240, 250);
jp.setVisible(true);
jp.setLayout(null);
jp.setBackground(null);
jp.add(txt);
jp.add(cmd);
jp.add(cmd);
jp.add(sp);
jp.setBorder(null);
grp.getContentPane().add(jp);
grp.getContentPane().setLayout(null);
grp.setTitle("MANAGEMENT");
grp.setSize(240,250);
grp.setLocationRelativeTo(null);
grp.setResizable(false);
grp.setDefaultCloseOperation(grp.DISPOSE_ON_CLOSE);
grp.setFocusableWindowState(true);
cmd.setActionCommand("FIND");
cmd.addActionListener(new java.awt.event.ActionListener(){
public void actionPerformed(java.awt.event.ActionEvent e
){
if(e.getActionCommand().equals("FIND") && txt.ge
tText()!=""){
ftp.xFl="";
ftp.ftpc();
ls.setModel(ftp.find(txt.getText()));
ls.setSelectionMode(javax.swing.ListSele
ctionModel.SINGLE_SELECTION );
l=ls;
if(ls.getModel().getSize()!=0){
cmd.setText("EXPORT");
cmd.setActionCommand("EXPORT");
}
}else if(e.getActionCommand().equals("EXPORT")){
ftp.download(ls.getSelectedValue().toStr
ing());
cmd.setText("FIND");
cmd.setActionCommand("FIND");
}
}
});
grp.addWindowListener(new java.awt.event.WindowAdapter() {
//public void windowClosed(java.awt.event.WindowEvent e)
{
//
Instructions
//}
public void windowClosing(java.awt.event.WindowEvent e){
status=true;
stat();
ls.setModel(new javax.swing.DefaultListModel());
ftp.disconect();
}
});
return grp;
}

public static void main(String args[]){


if(args.length == 2){
new xWin();
}else{
new xWin();
}
}
javax.swing.JList l;
public void Mous(final java.awt.Component c){
c.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent ev){
if(l!=null){
if(ev.getClickCount()==2 && l.getModel()
.getSize()>0){
ftp.download(l.getSelectedValue(
).toString());
}
}
}
});
}
Integer xclc=0;
java.io.BufferedReader xbf=null;
@SuppressWarnings("deprecation")
public void SVR(boolean b){
String xdem="";
java.util.StringTokenizer st=null;
Integer g;
try{
Ss=new java.net.ServerSocket(1001);
PRINT("START SERVER");
while(true){
Thread.sleep(500);
if(Ss==null){
}else{
if(thread2==null){
thread2 = new Thread(){
public void run(){
try{
if(xclc<1){
Cs=Ss.ac
cept();
xclc=1;
}
}catch(Exception ex){
PRINT("FORCED SH
UT OFF ACTIVE CUSTOMERS");
}
}
};
thread2.start();
}
if(xclc==1){
xbf=new java.io.BufferedReader(n
ew InputStreamReader(Cs.getInputStream()));
try{
PRINT("STRING RECEIVED:
"+(xdem=xbf.readLine()));
xbf.close();
}catch(Exception ex){

PRINT("STRING RECEIVED:
"+null);
Cs.close();
Ss.close();
Cs=null;
Ss=null;
}
xbf=null;
thread2.stop();
thread2=null;
}
xclc=0;
if(xdem!=null){
st=new java.util.StringTokenizer
(TRIM(xdem),"\\"+Chr(42)+Chr(32));
g=st.countTokens();
for(int i=0;i<g;i++){
xdem=st.nextToken().trim
();
switch(g-st.countTokens(
)){
case 1:
ftp.Svr=
xdem;
break;
case 2:
ftp.xUs=
xdem;
break;
case 3:
ftp.xPs=
xdem;
break;
case 4:
ftp.xFl=
xdem;
break;
case 5:
ftp.xDr=
xdem;
break;
case 6:
ftp.xCmd
=xdem;
break;
}
}
ftp.ftpc();
ftp.disconect();
xdem=null;
}
Thread.sleep(300);
}
}
}catch(Exception ex){
ex.printStackTrace();
}
}
/**
* @wbp.parser.entryPoint

*/
@SuppressWarnings("static-access")
public javax.swing.JFrame Cnfg(){
javax.swing.JFrame grp=new javax.swing.JFrame();
javax.swing.JPanel jp=new javax.swing.JPanel();
javax.swing.JButton[] cmd=new javax.swing.JButton[10];
javax.swing.JTextField[] txt=new javax.swing.JTextField[10];
grp.getContentPane().setLayout(new BorderLayout());
grp.setTitle("Titulo de Ventana");
grp.setSize(300, 300);
jp.setLayout(new BorderLayout());
for(int index=0;index<cmd.length;index++){
cmd[index]=new javax.swing.JButton();
cmd[index].setMargin(new Insets(0, 0, 0, 0));
cmd[index].setText("cmd #"+index);
cmd[index].setSize(100,jp.getHeight());
//jp.add(cmd[index]);
txt[index]=new javax.swing.JTextField();
txt[index].setSize(100, 30);
//jp.add(txt[index]);
LMT(txt[index],10);
}
jp.setSize(new Dimension(grp.getSize()));
grp.getContentPane().add(jp);
JButton btnNewButton = new JButton("New button");
jp.add(btnNewButton, BorderLayout.WEST);
JButton btnNewButton_1 = new JButton("New button");
btnNewButton_1.setSize(100, 100);
jp.add(btnNewButton_1, BorderLayout.SOUTH);
JButton btnNewButton_2 = new JButton("New button");
jp.add(btnNewButton_2, BorderLayout.NORTH);
JButton btnNewButton_3 = new JButton("New button");
jp.add(btnNewButton_3, BorderLayout.EAST);
JToggleButton tglbtnNewToggleButton = new JToggleButton("New tog
gle button");
jp.add(tglbtnNewToggleButton, BorderLayout.CENTER);
grp.setResizable(true);
grp.setDefaultCloseOperation(grp.DISPOSE_ON_CLOSE);
grp.setExtendedState(grp.MAXIMIZED_BOTH);
grp.setVisible(true);
return grp;
}
}

You might also like