import java.io.*; import javax.swing.*; import java.awt.*; import java.awt.event.*; import java.util.*; import javax.swing.tree.*; import java.lang.*; import javax.swing.event.*; import java.awt.event.*; public class FBro3 extends JInternalFrame implements MouseListener,TreeExpansionListener{ protected DefaultMutableTreeNode rootNode; protected DefaultTreeModel treeModel; DefaultMutableTreeNode gen; JTextField status, destination, sourcefile; JTree tree; JMenuBar bar; JTextField text ; JMenu filemenu; boolean added=false; int exprow = 0; JFrame F; boolean test = false; JScrollPane JSP; boolean proc = false; String TotalPath; String root; boolean once = false; //FBrowCtr ctr = new FBrowCtr(); boolean found = false; Vector hierarchy; DefaultMutableTreeNode p1, p2; DefaultMutableTreeNode parentNode; JPanel JTreePanel; private final String fileSeparator="/"; private String CurrentFile=""; private String CurrentDirectory=""; private String Current=""; public FBro3(desktop d) { super("File Browser", true, true, true, true); getContentPane().setLayout(new BorderLayout()); JPanel BrowserPanel = new JPanel(); JPanel ControlsPanel = new JPanel(); BrowserPanel.setLayout(new BorderLayout()); JPanel northPanel = new JPanel(); northPanel.setLayout(new GridLayout(3,1)); bar = new JMenuBar(); northPanel.add(bar,BorderLayout.NORTH); northPanel.add(new JLabel("Enter the Directory here:")); text = new JTextField(); northPanel.add(text); BrowserPanel.add(northPanel,BorderLayout.NORTH); JTreePanel = new JPanel(); JTreePanel.setLayout(new BorderLayout()); JSP = new JScrollPane(JTreePanel,ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS); BrowserPanel.add(JSP, BorderLayout.CENTER); JPanel StatusPanel = new JPanel(); StatusPanel.setLayout(new GridLayout(3,1)); JPanel StatusLine = new JPanel(); StatusLine.setLayout(new BorderLayout()); JLabel l2 = new JLabel(" status :"); l2.setFont(new Font("Courier", Font.BOLD, 12)); l2.setForeground(Color.black); StatusLine.add(l2,BorderLayout.WEST); status = new JTextField(); StatusLine.add(status,BorderLayout.CENTER); StatusPanel.add(StatusLine); JPanel SourceLine = new JPanel(); SourceLine.setLayout(new BorderLayout()); JLabel l3 = new JLabel("selected:"); l3.setFont(new Font("Courier", Font.BOLD, 12)); l3.setForeground(Color.black); SourceLine.add(l3,BorderLayout.WEST); sourcefile = new JTextField(); SourceLine.add(sourcefile,BorderLayout.CENTER); StatusPanel.add(SourceLine); JPanel DestLine = new JPanel(); DestLine.setLayout(new BorderLayout()); JLabel l1 = new JLabel("new name:"); l1.setFont(new Font("Courier", Font.BOLD, 12)); l1.setForeground(Color.black); DestLine.add(l1,BorderLayout.WEST); destination = new JTextField(); DestLine.add(destination,BorderLayout.CENTER); StatusPanel.add(DestLine); BrowserPanel.add(StatusPanel,BorderLayout.SOUTH); getContentPane().add(BrowserPanel,BorderLayout.CENTER); ActionListener bListener = new ActionListener() { public void actionPerformed(ActionEvent ev) { String what=ev.getActionCommand().toString(); ButtonAction(what); } }; ControlsPanel.setLayout(new GridLayout(2,5)); JButton MkDirButton = new JButton("MkDir"); JButton RmDirButton = new JButton("RmDir"); JButton DelButton = new JButton("Delete"); JButton RenButton = new JButton("Rename"); JButton MvButton = new JButton("Move"); JButton CpButton = new JButton("Copy"); JButton UpButton = new JButton("Upload"); JButton DwButton = new JButton("Download"); JButton ViButton = new JButton("View"); JButton MarkButton = new JButton("Mark"); ControlsPanel.add(MkDirButton); ControlsPanel.add(RmDirButton); ControlsPanel.add(DelButton); ControlsPanel.add(RenButton); ControlsPanel.add(MvButton); ControlsPanel.add(CpButton); ControlsPanel.add(UpButton); ControlsPanel.add(DwButton); ControlsPanel.add(ViButton); ControlsPanel.add(MarkButton); MkDirButton.addActionListener(bListener); DelButton.addActionListener(bListener); RenButton.addActionListener(bListener); MvButton.addActionListener(bListener); CpButton.addActionListener(bListener); UpButton.addActionListener(bListener); DwButton.addActionListener(bListener); ViButton.addActionListener(bListener); RmDirButton.addActionListener(bListener); MarkButton.addActionListener(bListener); getContentPane().add(ControlsPanel,BorderLayout.SOUTH); /* filemenu = new JMenu("File"); JMenuItem exit = new JMenuItem("Exit"); filemenu.add(exit); bar.add(filemenu); //System.out.println("the root uis "+root); exit.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ev) { System.exit(0); } }); */ text.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ev) { root = text.getText(); CurrentDirectory = root.substring(0,root.length()-1); System.out.println("Presssed"); proc = true; status.setText(""); createTree(); } }); }//end of constructor void createTree() { //File check = new File(root); if (Connection.browser.checkforexist(root)) { status.setText("Command Successful"); System.out.println("Check exists"); rootNode = new DefaultMutableTreeNode(root); treeModel = new DefaultTreeModel(rootNode); if (once == true) JTreePanel.remove(tree); tree = new JTree(treeModel); //tree.setEditable(true); once = true; addObject(null,"c"); System.out.println("Frtom root node"+rootNode.getChildCount()); System.out.println(" root node re p"+rootNode.toString()); tree.addMouseListener(this); tree.addTreeExpansionListener(this); JTreePanel.add(tree,BorderLayout.CENTER); JTreePanel.validate(); } else { System.out.println("check no exists"); status. setText("File does not exist"); } }//end of create tree public void mouseEntered(MouseEvent e) {} public void mouseExited(MouseEvent e) {} public void mousePressed(MouseEvent e) {} public void mouseReleased(MouseEvent e) {} public void mouseClicked(MouseEvent e) { int selRow = tree.getRowForLocation(e.getX(), e.getY()); TreePath selPath = tree.getPathForLocation(e.getX(), e.getY()); if(selRow != -1) { if(e.getClickCount() == 1) { Object[] objarray = new Object[selPath.getPathCount()]; objarray=selPath.getPath(); TotalPath=""; System.out.println("the objaaray length is "+objarray.length); CurrentDirectory=""; for (int i=0;i", true); for (int i=0;i