Total members 11895 |It is currently Mon Dec 30, 2024 6:41 pm Login / Join Codemiles

Java

C/C++

PHP

C#

HTML

CSS

ASP

Javascript

JQuery

AJAX

XSD

Python

Matlab

R Scripts

Weka






 Project Name:   Free "tail -f" Tool for all Platforms: Tail for Windows, Tail for Linux and Tail for Mac
 Programmer:   Madanu Ujjwal Kumar
 Type:   Application
 Technology:  Java
 IDE:   NONE
 Description:   MakeLogic Tail is similar to the "tail -f" of Linux. It is a free software. It requires Java Runtime Environment 5.0 (JRE 5.0) and hence can run on any platform. Hence it is:

* Tail for Windows
* Tail for Linux and other UNIX flavors
* Tail for Mac

Code sample.
java code
/*********************************************************

Copyright (C) 2006 MakeLogic

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 of the License, 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 program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA


Date : 14th December 2005
Authors : MakeLogic

Design : Ujjwal
Developer : Dharma

*****************************************/

package com.makeLogic;

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.Rectangle;
import java.awt.Toolkit;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

import java.io.*;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;

import java.util.Enumeration;
import java.util.Properties;
import java.util.Vector;
import java.util.Hashtable;

import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JDesktopPane;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.JInternalFrame;
import javax.swing.JLabel;
import javax.swing.JScrollPane;
import javax.swing.JMenuItem;
import javax.swing.JMenu;
import javax.swing.JPanel;
import javax.swing.JPopupMenu;
import javax.swing.JSplitPane;
import javax.swing.JToolBar;
import javax.swing.JToolBar.Separator;
import javax.swing.KeyStroke;

import javax.swing.tree.DefaultTreeModel;
import javax.swing.tree.MutableTreeNode;
import javax.swing.tree.TreeNode;

import javax.swing.*;
import java.awt.*;

import com.makeLogic.FileTransferHandler;
import com.makeLogic.HelpAction;

import com.makeLogic.utils.WindowMenu;
import com.makeLogic.utils.FileMenu;
import com.makeLogic.utils.*;

public class TailMDI extends JFrame {

//...Fields
MakeLogicDesktopPane desktop;
Tail tempTail;
TailMenuBar tailMenuBar;
TailToolBar tailToolBar;
public Properties keySetValues;
public static boolean findDialogOpened;
public MLProjectsPanel projPanel;
JSplitPane splitPane;
Hashtable currentlyOpenFiles;
boolean fileDetailsInternalFrameVisible;
FileDetailsInternalFrame fileDetailsInternalFrame;

//..Projects

//..MenuItems
JMenuItem addFileItem;
JMenuItem removeFileItem;
JMenuItem addProjectItem;
JMenuItem removeProjectItem;
JMenuItem newProjectItem;

JMenuItem showHideProjectItem;
JMenuItem fileDetailsItem;

//..Popup MenuItems
JMenuItem popAddFileItem;
JMenuItem popRemoveFileItem;
JMenuItem popAddProjectItem;
JMenuItem popRemoveProjectItem;
JMenuItem popNewProjectItem;

JMenuItem popHideProjectItem;
JMenuItem popFileDetailsItem;

//..Toolbar buttons
JButton newProjectButton;
JButton addFileButton;
JButton removeFileButton;
JButton addProjectButton;
JButton removeProjectButton;

//..Hide Button
JButton hideButton;

//..MakeLogic Popup Menu
MLPopupMenu mlPopupMenu;

//..File open action listener
//..This will be used in double click desltop-pane action
public ActionListener fileOpenActionListener;

//..For reading no of projects
public static int noOfProjects;
public static int sendBugInfo;
public static long ut;

//..Application Constants File
public static final String APP_CONSTANTS_FILE = Tail.INSTALL_DIR + "appconst.ml";
//..Configiuration File
public static final String CONF_FILE = Tail.INSTALL_DIR + "conf.ml";
//..Keyset File
public static final String KEYSET_FILE = Tail.INSTALL_DIR+"keyset.ml";
//..Projects File
public static final String PROJECTS_FILE = Tail.INSTALL_DIR+"projects.ml";
//..Suggested Keywords Set File
public static final String SUGGESTED_KEYSET_FILE = Tail.INSTALL_DIR+"suggestedkeyset.ml";


//...Constructors
public TailMDI()
{

super("MakeLogic - Tail");

Trace.enter("TailMDI.TailMDI");

/*
//..Set the no of proj to read 4
//noOfProjects = 4;
*/

//..Get the kwset from keyset.ml file
keySetValues = new Properties();

//..Load the application constant variables
loadApplicationConstants();

try
{
//..Read the values into properties
keySetValues = new Properties();
keySetValues.load(new FileInputStream(TailMDI.KEYSET_FILE));
}
catch(FileNotFoundException fnfe)
{
//Trace.exception(fnfe);
try
{
//..Create the file
File createFile = new File(TailMDI.KEYSET_FILE);
createFile.createNewFile();
}
catch(IOException exp)
{
//..Do Nothing
Trace.exception(exp);
}
}
catch(IOException ioe)
{
//..Do Nothing
//System.outprintln("IOE");
Trace.exception(ioe);
}

//..currentlyOpenFiles
currentlyOpenFiles = new Hashtable();
fileDetailsInternalFrameVisible = false;

//..Set the icon
//..Get current classloader
ClassLoader cl = this.getClass().getClassLoader();
Toolkit toolkit = Toolkit.getDefaultToolkit();

try
{
this.setIconImage(toolkit.getImage(cl.getResource("TailIcon.jpg")));
}
catch(Exception excpt)
{
Trace.exception(excpt);
}

//..Make the big window be indented 50 pixels from each edge of the screen
int inset = 50;
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
setBounds(inset, inset,
screenSize.width - inset*2,
screenSize.height-inset*2);

//..Quit this app when the big window closes
addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent e)
{

Trace.enter("WindowAdapter.windowClosing");

//..updates the conf File for Recenly Opened Documents
FileMenu.updateConfFile();

Trace.exit("WindowAdapter.windowClosing");

//..Stop Trace
Trace.stop();
System.exit(0);
}
});

//..Set up the GUI.
desktop = new MakeLogicDesktopPane(this); //a specialized layered pane

//Make dragging faster:
desktop.putClientProperty("JDesktopPane.dragMode", "outline");

//..Add Drop handler to desktop.
desktop.setTransferHandler(new FileTransferHandler(this));

tailMenuBar = new TailMenuBar();

//..Add new File Menu
FileMenu fileMenu=new FileMenu(this);
fileOpenActionListener = fileMenu.getOpenMenuItem().getActionListeners()[0];

tailMenuBar.add(fileMenu);

//..FindAction
FindAction findAction = new FindAction(this);

JMenu editMenu = new JMenu("Edit");
editMenu.setMnemonic('E');

//..First get the ActionEvent for cut copy and paste events
JTextPane textPane = new JTextPane();
Action [] actionEvents = textPane.getEditorKit().getActions();

//..Action
Action cutAction = actionEvents[14];
Action copyAction = actionEvents[26];
Action pasteAction = actionEvents[65];
//..Action selectAllAction = actionEvents[63];

//..Add cut copy paste menuItems
JMenuItem cutItem = new JMenuItem(cutAction);
cutItem.setText("Cut");
try
{
cutItem.setIcon(new ImageIcon(cl.getResource("cut.gif")));
}
catch(Exception excpt)
{
Trace.exception(excpt);
}


cutItem.setAccelerator(KeyStroke.getKeyStroke('X',java.awt.Event.CTRL_MASK,false));
editMenu.add(cutItem);

JMenuItem copyItem = new JMenuItem(copyAction);
copyItem.setText("Copy");

try
{
copyItem.setIcon(new ImageIcon(cl.getResource("copy.gif")));
}
catch(Exception excpt)
{
Trace.exception(excpt);
}

copyItem.setAccelerator(KeyStroke.getKeyStroke('C',java.awt.Event.CTRL_MASK,false));
editMenu.add(copyItem);

JMenuItem pasteItem = new JMenuItem(pasteAction);
pasteItem.setText("Paste");

try
{
pasteItem.setIcon(new ImageIcon(cl.getResource("paste.gif")));
}
catch(Exception excpt)
{
Trace.exception(excpt);
}



pasteItem.setAccelerator(KeyStroke.getKeyStroke('V',java.awt.Event.CTRL_MASK,false));
editMenu.add(pasteItem);

editMenu.add(new JSeparator());

JMenuItem findItem = new JMenuItem(findAction);
findItem.setText("Find");

try
{
findItem.setIcon(new ImageIcon(cl.getResource("Find.gif")));
}
catch(Exception excpt)
{
Trace.exception(excpt);
}


findItem.setAccelerator(KeyStroke.getKeyStroke('F',java.awt.Event.CTRL_MASK,false));
editMenu.add(findItem);

tailMenuBar.add(editMenu);

//..OptionsMenu
SettingsAction settingsAction = new SettingsAction(this);

JMenu optionsMenu = new JMenu("Options");
optionsMenu.setMnemonic('O');

JMenuItem settingsItem = new JMenuItem(settingsAction);

try
{
settingsItem.setIcon(new ImageIcon(cl.getResource("settings.gif")));
}
catch(Exception excpt)
{
Trace.exception(excpt);
}

settingsItem.setText("Settings");
optionsMenu.add(settingsItem);

//..Add separator
optionsMenu.add(new JSeparator());

//..Show/Hide Project Panel
HideAction hideAction = new HideAction(this);
showHideProjectItem = new JMenuItem(hideAction);

try
{
showHideProjectItem.setIcon(new ImageIcon(cl.getResource("hideButton.png")));
}
catch(Exception excpt)
{
Trace.exception(excpt);
}

showHideProjectItem.setText("Hide Project Panel");
showHideProjectItem.setAccelerator

(KeyStroke.getKeyStroke('L',java.awt.Event.CTRL_MASK|java.awt.Event.SHIFT_MASK,false));
optionsMenu.add(showHideProjectItem);

//..Popup object
popHideProjectItem = new JMenuItem(hideAction);

try
{
popHideProjectItem.setIcon(new ImageIcon(cl.getResource("hideButton.png")));
}
catch(Exception excpt)
{
Trace.exception(excpt);
}

popHideProjectItem.setText("Hide Project Panel");

//..FileDetails
fileDetailsItem = new JMenuItem();

try
{
fileDetailsItem.setIcon(new ImageIcon(cl.getResource("filedetails.gif")));
}
catch(Exception excpt)
{
Trace.exception(excpt);
}

//..Set action listener
fileDetailsItem.addActionListener(
new ActionListener()
{
public void actionPerformed(ActionEvent ae)
{
if(!isFileDetailsInternalFrameVisible())
{
fileDetailsInternalFrame = new FileDetailsInternalFrame();
fileDetailsInternalFrame.show();
//fileDetailsInternalFrame.pack();
fileDetailsInternalFrame.validate();

setFileDetailsInternalFrameVisible(true);
}
else if(fileDetailsInternalFrame!=null && fileDetailsInternalFrame.isIcon())
{
try
{
fileDetailsInternalFrame.setMaximum(true);
fileDetailsInternalFrame.setMaximum(false);

fileDetailsInternalFrame.setSelected(true);
}
catch(Exception e)
{
Trace.exception(e);
}
}
else if(fileDetailsInternalFrame!=null && !fileDetailsInternalFrame.isIcon())
{
try
{
fileDetailsInternalFrame.setSelected(true);
}
catch(Exception e)
{
Trace.exception(e);
}
}
}
});

fileDetailsItem.setText("File Details");
fileDetailsItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F4,0));
optionsMenu.add(fileDetailsItem);

try
{
fileDetailsItem.setIcon(new ImageIcon(cl.getResource("filedetails.gif")));
}
catch(Exception excpt)
{
Trace.exception(excpt);
}

fileDetailsItem.setText("File Details");
optionsMenu.add(fileDetailsItem);

tailMenuBar.add(optionsMenu);

//..Popup object
popFileDetailsItem = new JMenuItem();

try
{
popFileDetailsItem.setIcon(new ImageIcon(cl.getResource("filedetails.gif")));
}
catch(Exception excpt)
{
Trace.exception(excpt);
}

popFileDetailsItem.setText("File Details");
popFileDetailsItem.addActionListener(optionsMenu.getItem(3).getActionListeners()[0]);

//...Projects Menu

JMenu projectMenu = new JMenu("Project");
projectMenu.setMnemonic('P');

//..Add File
AddFileAction addFileAction = new AddFileAction(this);
addFileItem = new JMenuItem(addFileAction);
addFileItem.setEnabled(false);

try
{
addFileItem.setIcon(new ImageIcon(cl.getResource("addFile_icon.png")));
}
catch(Exception excpt)
{
Trace.exception(excpt);
}

projectMenu.add(addFileItem);
addFileItem.setText("Add File");

//..Set accelerator key as Ctrl+Shift+A
addFileItem.setAccelerator

(KeyStroke.getKeyStroke('A',java.awt.Event.CTRL_MASK|java.awt.Event.SHIFT_MASK,false));

//..Popup object
popAddFileItem = new JMenuItem(addFileAction);

try
{
popAddFileItem.setIcon(new ImageIcon(cl.getResource("addFile_icon.png")));
}
catch(Exception excpt)
{
Trace.exception(excpt);
}

popAddFileItem.setText("Add File");

projectMenu.add(addFileItem);

//..Remove File
RemoveFileAction removeFileAction = new RemoveFileAction(this);
removeFileItem = new JMenuItem(removeFileAction);
removeFileItem.setEnabled(false);

try
{
removeFileItem.setIcon(new ImageIcon(cl.getResource("removeFile_icon.png")));
}
catch(Exception excpt)
{
Trace.exception(excpt);
}

projectMenu.add(removeFileItem);
removeFileItem.setText("Remove File");

//..Popup object
popRemoveFileItem = new JMenuItem(removeFileAction);

try
{
popRemoveFileItem.setIcon(new ImageIcon(cl.getResource("removeFile_icon.png")));
}
catch(Exception excpt)
{
Trace.exception(excpt);
}

popRemoveFileItem.setText("Remove File");

projectMenu.add(removeFileItem);

projectMenu.add(new JSeparator());

//..Add Project
addProjectItem = new JMenuItem();

//..Set accelerator key
addProjectItem.setAccelerator

(KeyStroke.getKeyStroke('O',java.awt.Event.CTRL_MASK|java.awt.Event.SHIFT_MASK,false));

try
{
addProjectItem.setIcon(new ImageIcon(cl.getResource("addProject_icon.png")));
}
catch(Exception excpt)
{
Trace.exception(excpt);
}


addProjectItem.addActionListener(fileMenu.getOpenProjectMenuItem().getActionListeners()[0]);
projectMenu.add(addProjectItem);
addProjectItem.setText("Add Existing Project");

//..popup object for Add project
popAddProjectItem = new JMenuItem();

try
{
popAddProjectItem.setIcon(new ImageIcon(cl.getResource("addProject_icon.png")));
}
catch(Exception excpt)
{
Trace.exception(excpt);
}

popAddProjectItem.addActionListener(fileMenu.getOpenProjectMenuItem().getActionListeners()[0]);
popAddProjectItem.setText("Add Existing Project");

//..Remove Project
RemoveProjectAction removeProjectAction = new RemoveProjectAction(this);
removeProjectItem = new JMenuItem(removeProjectAction);
removeProjectItem.setEnabled(false);

try
{
removeProjectItem.setIcon(new ImageIcon(cl.getResource("removeProject_icon.png")));

}
catch(Exception excpt)
{
Trace.exception(excpt);
}


projectMenu.add(removeProjectItem);
removeProjectItem.setText("Remove Project");

//..Popup object
popRemoveProjectItem = new JMenuItem(removeProjectAction);

try
{
popRemoveProjectItem.setIcon(new ImageIcon(cl.getResource("removeProject_icon.png")));
}
catch(Exception excpt)
{
Trace.exception(excpt);
}

popRemoveProjectItem.setText("Remove Project");

projectMenu.add(removeProjectItem);

//..New Project
newProjectItem = new JMenuItem();

//..Set accelerator key
newProjectItem.setAccelerator(KeyStroke.getKeyStroke('N',java.awt.Event.CTRL_MASK,false));

try
{
newProjectItem.setIcon(new ImageIcon(cl.getResource("createProject_icon.png")));
}
catch(Exception excpt)
{
Trace.exception(excpt);
}

newProjectItem.addActionListener(fileMenu.getNewMenuItem().getActionListeners()[0]);
projectMenu.add(newProjectItem);
newProjectItem.setText("New Project");

//..Popup object
popNewProjectItem = new JMenuItem();

try
{
popNewProjectItem.setIcon(new ImageIcon(cl.getResource("createProject_icon.png")));
}
catch(Exception excpt)
{
Trace.exception(excpt);
}

popNewProjectItem.addActionListener(fileMenu.getNewMenuItem().getActionListeners()[0]);
popNewProjectItem.setText("New Project");

projectMenu.add(newProjectItem);

tailMenuBar.add(projectMenu);

//...WindowMenu
WindowMenu windowMenu = new WindowMenu(desktop);
tailMenuBar.add(windowMenu);

//...HelpMenu
HelpAction helpAction = new HelpAction(this);

JMenu helpMenu = new JMenu("Help");
helpMenu.setMnemonic('H');

//...HelpMenuItem
HelpDocumentAction helpDocAction = new HelpDocumentAction(this);

JMenuItem helpDocItem = new JMenuItem(helpDocAction);
helpMenu.add(helpDocItem);
helpDocItem.setText("Contents");
helpDocItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F1,0));


tailMenuBar.add(helpMenu);
setJMenuBar(tailMenuBar);

//...HelpAboutMenuItem
JMenuItem helpItem = new JMenuItem(helpAction);
helpMenu.add(helpItem);
helpItem.setText("Help About");
//helpItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F1,0));
//helpMenu.add(helpItem);



//...Create ToolBar

tailToolBar = new TailToolBar();
tailToolBar.setFloatable(false);

//..OpenButton
JButton openButton = new MLButton();//new JButton();
openButton.addActionListener(fileMenu.getOpenMenuItem().getActionListeners()[0]);

try
{
openButton.setIcon(new ImageIcon(cl.getResource("FileOpen.gif")));
}
catch(Exception excpt)
{
openButton.setText("Open");
Trace.exception(excpt);
}

openButton.setToolTipText("Open");
tailToolBar.add(openButton);

//..Add separator
tailToolBar.addSeparator();

//..Add buttons for project items

//..Add file button
try
{
addFileButton = new MLButton();
addFileButton.setIcon(new ImageIcon(cl.getResource("addFile_icon.png")));
}
catch(Exception excpt)
{
addFileButton.setText("Add File");
Trace.exception(excpt);
}

addFileButton.addActionListener(addFileAction);
addFileButton.setToolTipText("Add File");
addFileButton.setEnabled(false);
tailToolBar.add(addFileButton);

//..Remove File button
try
{
removeFileButton = new MLButton();
removeFileButton.setIcon(new ImageIcon(cl.getResource("removeFile_icon.png")));

}
catch(Exception excpt)
{
removeFileButton = new JButton("Remove File");
Trace.exception(excpt);
}

removeFileButton.addActionListener(removeFileAction);
removeFileButton.setEnabled(false);
removeFileButton.setToolTipText("Remove File");
tailToolBar.add(removeFileButton);

//..Add separator
tailToolBar.addSeparator();

//..New Project
newProjectButton = new MLButton();//new JButton();

try
{
newProjectButton.setIcon(new ImageIcon(cl.getResource("createProject_icon.png")));
}
catch(Exception excpt)
{
newProjectButton.setText("New Project");
Trace.exception(excpt);
}



newProjectButton.addActionListener(fileMenu.getNewMenuItem().getActionListeners()[0]);
newProjectButton.setToolTipText("Create New Project");
tailToolBar.add(newProjectButton);

//..Add Project Button
try
{
addProjectButton = new MLButton();
addProjectButton.setIcon(new ImageIcon(cl.getResource("addProject_icon.png")));
}
catch(Exception excpt)
{
addProjectButton = new MLButton("Add Project");
Trace.exception(excpt);
}

addProjectButton.addActionListener(fileMenu.getOpenProjectMenuItem().getActionListeners()[0]);
addProjectButton.setToolTipText("Add Existing Project");
tailToolBar.add(addProjectButton);

//..Remove Project
try
{
removeProjectButton = new MLButton();
removeProjectButton.setIcon(new ImageIcon(cl.getResource("removeProject_icon.png")));
}
catch(Exception excpt)
{
removeProjectButton = new MLButton("Remove Project");
Trace.exception(excpt);
}

removeProjectButton.addActionListener(removeProjectAction);
removeProjectButton.setEnabled(false);
removeProjectButton.setToolTipText("Remove Project");
tailToolBar.add(removeProjectButton);

//..Add separator
tailToolBar.addSeparator();

//..Add the cut,copy,paste and selectAll buttons

//..cut Button
JButton cutButton = new MLButton(cutAction);
try
{
cutButton.setIcon(new ImageIcon(cl.getResource("cut.gif")));
}
catch(Exception excpt)
{
cutButton.setText("Cut");
Trace.exception(excpt);
}

cutButton.setToolTipText("Cut");
cutButton.setText("");
tailToolBar.add(cutButton);

//..copy Button
JButton copyButton = new MLButton(copyAction);

try
{
copyButton.setIcon(new ImageIcon(cl.getResource("copy.gif")));
}
catch(Exception excpt)
{
copyButton.setText("Copy");
Trace.exception(excpt);
}

copyButton.setToolTipText("Copy");
copyButton.setText("");
tailToolBar.add(copyButton);

//..paste Button
JButton pasteButton = new MLButton(pasteAction);
try
{
pasteButton.setIcon(new ImageIcon(cl.getResource("paste.gif")));
}
catch(Exception excpt)
{
pasteButton.setText("Paste");
Trace.exception(excpt);
}

pasteButton.setToolTipText("Paste");
pasteButton.setText("");
tailToolBar.add(pasteButton);

//..Add separator
tailToolBar.addSeparator();

//..findButton
ActionListener findListener = editMenu.getItem(4).getActionListeners()[0];
JButton findButton = null;
try
{
findButton = new MLButton(new ImageIcon(cl.getResource("Find.gif")));
}
catch(Exception excpt)
{
findButton = new MLButton("Find");
Trace.exception(excpt);
}

findButton.addActionListener(findListener);
findButton.setToolTipText("Find");
tailToolBar.add(findButton);

//..settings Button
ActionListener settingsListener = optionsMenu.getItem(0).getActionListeners()[0];
JButton settingsButton = new MLButton();

try
{
settingsButton.setIcon(new ImageIcon(cl.getResource("settings.gif")));
}
catch(Exception excpt)
{
settingsButton.setText("Settings");
Trace.exception(excpt);
}

settingsButton.addActionListener(settingsListener);
settingsButton.setToolTipText("Settings");
settingsButton.setText("");
tailToolBar.add(settingsButton);

//..Add separator
tailToolBar.addSeparator();

//..Cascade event listener
ActionListener cascadeListener = windowMenu.getItem(0).getActionListeners()[0];

JButton cascadeButton = null;
try
{
cascadeButton = new MLButton(new ImageIcon(cl.getResource("Cascade.gif")));
}
catch(Exception excpt)
{
cascadeButton = new MLButton("Cascade");
Trace.exception(excpt);
}

cascadeButton.addActionListener(cascadeListener);
cascadeButton.setToolTipText("Cascade");

tailToolBar.add(cascadeButton);

//..Tile Horizontal event listener
ActionListener tileHorizontalListener = windowMenu.getItem(1).getActionListeners()[0];

JButton tileHorizontalButton = null;
try
{
tileHorizontalButton = new MLButton(new ImageIcon(cl.getResource("TileHorizontally.gif")));
}
catch(Exception excpt)
{
tileHorizontalButton = new MLButton("Tile Horizontally");
Trace.exception(excpt);
}

tileHorizontalButton.addActionListener(tileHorizontalListener);
tileHorizontalButton.setToolTipText("Tile Horizontally");

tailToolBar.add(tileHorizontalButton);

//..Tile Vertical event listener
ActionListener tileVerticalListener = windowMenu.getItem(2).getActionListeners()[0];

JButton tileVerticalButton = null;
try
{
tileVerticalButton = new MLButton(new ImageIcon(cl.getResource("TileVertically.gif")));
}
catch(Exception excpt)
{
tileVerticalButton = new MLButton("Tile Vertically");
Trace.exception(excpt);
}

tileVerticalButton.addActionListener(tileVerticalListener);
tileVerticalButton.setToolTipText("Tile Vertically");

tailToolBar.add(tileVerticalButton);

getContentPane().setLayout(new BorderLayout());
getContentPane().add(tailToolBar,BorderLayout.NORTH);
//getContentPane().add(desktop,BorderLayout.CENTER);

//..Add separator
tailToolBar.addSeparator();

//..Hide/Show Projects Panel Button
//HideAction hideAction = new HideAction(this);

try
{
hideButton = new MLButton(new ImageIcon(cl.getResource("hideButton.png")));
}
catch(Exception excpt)
{
hideButton = new MLButton("Hide");
Trace.exception(excpt);
}

hideButton.setToolTipText("Hide Project Panel");
hideButton.addActionListener(hideAction);
tailToolBar.add(hideButton);

//..FileDetails Button
JButton fileDetailsButton = new MLButton();
try
{
fileDetailsButton.setIcon(new ImageIcon(cl.getResource("filedetails.gif")));
}
catch(Exception excpt)
{
fileDetailsButton.setText("ShowDetails");
Trace.exception(excpt);
}
fileDetailsButton.setToolTipText("Show File Details");
fileDetailsButton.addActionListener(optionsMenu.getItem(3).getActionListeners()[0]);

tailToolBar.add(fileDetailsButton);
/*
fileDetailsButton.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent ae)
{
if(!isFileDetailsInternalFrameVisible())
{

fileDetailsInternalFrame = new FileDetailsInternalFrame();
fileDetailsInternalFrame.show();
//fileDetailsInternalFrame.pack();
fileDetailsInternalFrame.validate();

setFileDetailsInternalFrameVisible(true);
}
else if(fileDetailsInternalFrame!=null && fileDetailsInternalFrame.isIcon())
{
try
{
fileDetailsInternalFrame.setMaximum(true);
fileDetailsInternalFrame.setMaximum(false);

fileDetailsInternalFrame.setSelected(true);
}
catch(Exception e)
{
Trace.exception(e);
}
}
else if(fileDetailsInternalFrame!=null && !fileDetailsInternalFrame.isIcon())
{
try
{
fileDetailsInternalFrame.setSelected(true);
}
catch(Exception e)
{
Trace.exception(e);
}
}
}
});
*/


//..Add separator
tailToolBar.addSeparator();

//..Help Button
JButton helpButton = new MLButton();

try
{
helpButton.setIcon(new ImageIcon(cl.getResource("help.gif")));
}
catch(Exception excpt)
{
helpButton.setText("Help");
Trace.exception(excpt);
}
helpButton.setToolTipText("Opens Help In Browser");
helpButton.addActionListener(helpDocAction);

tailToolBar.add(helpButton);


//..Add west Panel
projPanel = new MLProjectsPanel(this);

//..Split the Project panel and desktop

//..Debug
//splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,projPanel,new

//JScrollPane(desktop,ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,
//ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS));

splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,projPanel,desktop);
getContentPane().add(splitPane,BorderLayout.CENTER);

//...Create Status bar
JPanel statusBar = new JPanel();
statusBar.setLayout(new BorderLayout());

statusBar.add(new JLabel("MakeLogic - Tail "),BorderLayout.EAST);

getContentPane().add(statusBar,BorderLayout.SOUTH);


//...mouse event for showing the popup menu
addMouseListener(new MouseAdapter()
{

public void mouseReleased(MouseEvent e)
{
if(e.isPopupTrigger())
{
}

}
});

Trace.exit("TailMDI.TailMDI");
}

//...methods

public void loadApplicationConstants()
{
//..Get the appconst from appconst.ml file

Properties appConst = new Properties();

try
{
//..Read the values into properties
appConst.load(new FileInputStream(TailMDI.APP_CONSTANTS_FILE));

//..Set the default values
this.noOfProjects = 4;
TailInternalFrame.MAX_LINES_TO_DISPLAY = 100;
FileMenu.maxEntriesInRecentFilesMenu = 8;
this.sendBugInfo = 1;
this.ut = 0;

//..Read the values
TailInternalFrame.MAX_LINES_TO_DISPLAY = Integer.parseInt(appConst.getProperty("maxlines"));
this.noOfProjects = Integer.parseInt(appConst.getProperty("noofproj"));
FileMenu.maxEntriesInRecentFilesMenu = Integer.parseInt(appConst.getProperty("maxrecentfiles"));
this.sendBugInfo = Integer.parseInt(appConst.getProperty("sendbuginfo"));
this.ut = Long.parseLong(appConst.getProperty("ut"));

}
catch(FileNotFoundException fnfe)
{
//Trace.exception(fnfe);
try
{
//..Create the file
File createFile = new File(TailMDI.APP_CONSTANTS_FILE);
createFile.createNewFile();

//..Set the default values
this.noOfProjects = 4;
TailInternalFrame.MAX_LINES_TO_DISPLAY = 100;
FileMenu.maxEntriesInRecentFilesMenu = 8;
this.sendBugInfo = 1;
this.ut = 0;

//..add the properties to the file
appConst.setProperty("maxlines",""+100);
appConst.setProperty("noofproj",""+4);
appConst.setProperty("maxrecentfiles",""+8);
appConst.setProperty("sendbuginfo",""+1);
appConst.setProperty("ut",""+0);

//..Store the Properties into a file.
try
{
appConst.store(new FileOutputStream(TailMDI.APP_CONSTANTS_FILE),null);
}
catch(Exception ex)
{
//..Do Nothing
Trace.exception(ex);
}


//..Write the default values
}
catch(IOException exp)
{
//..Set the default values
this.noOfProjects = 4;
TailInternalFrame.MAX_LINES_TO_DISPLAY = 100;
FileMenu.maxEntriesInRecentFilesMenu = 8;
this.sendBugInfo = 1;
this.ut = 0;

Trace.exception(exp);
}
}
catch(Exception e)
{
//..Do Nothing
//Trace.exception(ioe);

try
{
//..Create the file
java.io.File createFile = new java.io.File(TailMDI.APP_CONSTANTS_FILE);
createFile.createNewFile();
}
catch(Exception exp)
{
Trace.exception(exp);
}

//..Set the default values
this.noOfProjects = 4;
TailInternalFrame.MAX_LINES_TO_DISPLAY = 100;
FileMenu.maxEntriesInRecentFilesMenu = 8;
this.sendBugInfo = 1;
this.ut = 0;

//..add the properties to the file
appConst.setProperty("maxlines",""+100);
appConst.setProperty("noofproj",""+4);
appConst.setProperty("maxrecentfiles",""+8);
appConst.setProperty("sendbuginfo",""+1);
appConst.setProperty("ut",""+0);

//..Store the Properties into a file.
try
{
appConst.store(new FileOutputStream(TailMDI.APP_CONSTANTS_FILE),null);
}
catch(Exception writeException)
{
//..Do Nothing
Trace.exception(writeException);
}
}
}

public MLProjectsPanel getProjPanel()
{
return projPanel;
}

public Hashtable getCurrentlyOpenFiles()
{
return currentlyOpenFiles;
}

public void setFileDetailsInternalFrameVisible(boolean visible)
{
this.fileDetailsInternalFrameVisible = visible;
}

public boolean isFileDetailsInternalFrameVisible()
{
return fileDetailsInternalFrameVisible;
}

public void setFileDetailsInternalFrame(FileDetailsInternalFrame frame)
{
this.fileDetailsInternalFrame = frame;
}

public FileDetailsInternalFrame getFileDetailsInternalFrame()
{
return fileDetailsInternalFrame;
}


//public void addFrame(String fileName){
public TailInternalFrame addFrame(String fileName)
{

Trace.enter("TailMDI.addFrame "+fileName);

//..Verify if file exists or not
File tempFile = new File(fileName);

if(!tempFile.exists())
{
JOptionPane.showMessageDialog(Tail.tailMDI, "Could not open \n"+ fileName, "MakeLogic Tail", JOptionPane.ERROR_MESSAGE);
Trace.exit("TailMDI.addFrame "+fileName);
return null;
}

//..Check of this file is already running
if(currentlyOpenFiles.get(fileName)==null)
{

tempTail = new Tail(fileName);

if(tempTail != null && tempTail.getInternalFrame() != null)
{
desktop.add(tempTail.getInternalFrame());
}
else
{
Trace.exit("TailMDI.addFrame "+fileName);
return null;
}

//..Add the fileName and InternalFrame to Hashtable
currentlyOpenFiles.put(fileName, tempTail.getInternalFrame());

try
{
tempTail.getInternalFrame().setSelected(true);
tempTail.show();
}
catch (Exception e)
{

Trace.exception(e);
return null;
}
}
else
{
try
{
TailInternalFrame openFrame = ((TailInternalFrame)currentlyOpenFiles.get(fileName));

if(openFrame.isIcon())
{
/*
Rectangle rect = openFrame.getNormalBounds();
System.out.println("..ML.. Rect : "+rect);
openFrame.reshape( (int)rect.getX(), (int)rect.getY(),(int)rect.getWidth(),(int)rect.getHeight() );
//openFrame.setBounds( (int)rect.getX(), (int)rect.getY(),(int)rect.getWidth(),(int)rect.getHeight() );
//openFrame.updateUI();
//openFrame.reshape( 10,10, 200, 200);
openFrame.setLocation((int)rect.getX(), (int)rect.getY());
openFrame.setSize(new Dimension((int)rect.getWidth(), (int)rect.getHeight()));
openFrame.validate();
openFrame.show();
//openFrame.pack();
openFrame.repaint();
*/
openFrame.setMaximum(true);
openFrame.setMaximum(false);

openFrame.setSelected(true);
}
else
{
openFrame.setSelected(true);
}
}
catch (Exception e)
{

Trace.exception(e);
return null;
}

}

Trace.exit("TailMDI.addFrame "+fileName);
return tempTail.getInternalFrame();
}

//..return the desktop pane
public JDesktopPane getDesktop(){

Trace.enter("TailMDI.getDesktop");
Trace.exit("TailMDI.getDesktop");

return desktop;
}

//..Add the project to ml file
public void addProject(String projName)
{
Trace.enter("TailMDI.addProject "+projName);

try
{
//..Check for Projects.ml exists
File projectsListFile = new File(TailMDI.PROJECTS_FILE);
if(!projectsListFile.exists())
{
projectsListFile.createNewFile();
}

//..Read projs into vector
Vector projList = getProjectsVector(projectsListFile);

//..Verify if Proj exists in vector
boolean projExists = verifyProject(projList,projName);

//..if proj exists move to top
if(projExists)
{
moveToTop(projList,projName);
}
else
{
projList.add(0,projName);
}

//..Save projs into File
saveToFile(projList,projectsListFile);
}
catch(IOException ioe)
{
Trace.exception(ioe);
}

Trace.exit("TailMDI.addProject "+projName);
}

//..Remove project from ml file
public void removeProject(String projName)
{
Trace.enter("TailMDI.removeProject "+projName);

try
{
//..Check for Projects.ml exists
File projectsListFile = new File(TailMDI.PROJECTS_FILE);
if(!projectsListFile.exists())
{
projectsListFile.createNewFile();
Trace.exit("TailMDI.removeProject "+projName);
return;
}

//..Read projs into vector
Vector projList = getProjectsVector(projectsListFile);

//..Verify if Proj exists in vector
boolean projExists = verifyProject(projList,projName);

//..if proj exists move to top
if(projExists)
{
if(!remove(projList,projName))
{
//..Failed to remove
Trace.exit("TailMDI.removeProject "+projName);
return;
}
}
else
{
//..Project entry doesnot exists
Trace.exit("TailMDI.removeProject "+projName);
return;
}

//..Save projs into File
saveToFile(projList,projectsListFile);
}
catch(IOException ioe)
{
Trace.exception(ioe);
}

Trace.exit("TailMDI.removeProject "+projName);
}


//..Add file to project
public void addFileToProject(String projName,String fileName)
{
Trace.enter("TailMDI.addFileToProject "+projName+" "+fileName);

try
{
//..Check for Project file exists
File filesListFile = new File(projName);
if(!filesListFile.exists())
{
filesListFile.createNewFile();
}

//..Read files into vector
Vector fileList = getProjectsVector(filesListFile);

//..Verify if file exists in vector
boolean fileExists = verifyProject(fileList,fileName);

//..if file exists move to top
if(fileExists)
{
moveToTop(fileList,fileName);
}
else
{
fileList.add(0,fileName);
}

//..Save files into proj
saveToFile(fileList,filesListFile);
}
catch(IOException ioe)
{
Trace.exception(ioe);
}

Trace.exit("TailMDI.addFileToProject "+projName+" "+fileName);
}

//..Gets all the projs into vector
public Vector getProjectsVector(File projectsListFile)
{
Trace.enter("TailMDI.getProjectsVector "+projectsListFile);

Vector projectsVector = new Vector();
try
{
//..Read all the entries to vector
BufferedReader reader = new BufferedReader(new FileReader(projectsListFile));

String projectName = "";

while((projectName = reader.readLine()) != null )
{
projectsVector.addElement(projectName);

//..Debug
//System.out.println("..ML.. Proj ->"+projectName);
}

//..Close the streams
reader.close();
}
catch(FileNotFoundException fnfe)
{
//..Do nothing
}
catch(IOException ioe)
{
Trace.exception(ioe);
}

Trace.exit("TailMDI.getProjectsVector "+projectsListFile);
return projectsVector;
}

//..Set projs from vector
public void saveToFile(Vector projectsVector,File projectsListFile)
{
Trace.enter("TailMDI.saveToFile");

//..Open the file and write into file
try
{
//..Write to file from vector
BufferedWriter writer = new BufferedWriter(new FileWriter(projectsListFile));
Enumeration projsList = projectsVector.elements();

while(projsList.hasMoreElements())
{
String projPath = (String)projsList.nextElement();

//..TODO Verify if file exists or not

writer.write(projPath);
writer.newLine();

//..Debug
//System.out.println("..ML.. --->"+projPath);
}

//..Close the streams
writer.close();

}
catch(IOException ioe)
{
//ioe.printStackTrace();
Trace.exception(ioe);
}

Trace.exit("TailMDI.saveToFile");
}

//..Verify for the proj if exists or not
public boolean verifyProject(Vector projList,String projName)
{
Trace.enter("TailMDI.verifyProject "+projName);

boolean projExists = false;

if(projList.contains(projName))
{
projExists = true;
}
else
{
projExists = false;
}

Trace.exit("TailMDI.verifyProject "+projName);
return projExists;
}

//..move the entry in vector to top
public void moveToTop(Vector projList,String projName)
{
Trace.enter("TailMDI.moveToTop "+projName);

if(remove(projList,projName))
{
//..Add element at top
projList.add(0,projName);
}

Trace.exit("TailMDI.moveToTop "+projName);
}

//..remove the file from Project file
public boolean removeFileFromProject(File projFile,String removeFileEntry)
{
Trace.enter("TailMDI.removeFileFromProject "+removeFileEntry);

//..Read projs into vector
Vector projList = getProjectsVector(projFile);

//..remove the entry from vector
if(!remove(projList,removeFileEntry))
{
Trace.exit("TailMDI.removeFileFromProject "+removeFileEntry);

return false;
}

//..save the vector into file
saveToFile(projList,projFile);

Trace.exit("TailMDI.removeFileFromProject "+removeFileEntry);
return true;
}

//..remove the element
public boolean remove(Vector projList,String projName)
{
Trace.enter("TailMDI.remove "+projName);

boolean response = projList.removeElement(projName);

Trace.exit("TailMDI.remove "+projName);

return response;
}

//..returns addFileItem
public JMenuItem getAddFileItem()
{
Trace.enter("TailMDI.getAddFileItem");
Trace.exit("TailMDI.getAddFileItem");

return addFileItem;
}

//..returns removeFileItem
public JMenuItem getRemoveFileItem()
{
Trace.enter("TailMDI.getRemoveFileItem");
Trace.exit("TailMDI.getRemoveFileItem");

return removeFileItem;
}

//..returns removeProjectItem
public JMenuItem getRemoveProjectItem()
{
Trace.enter("TailMDI.getRemoveProjectItem");
Trace.exit("TailMDI.getRemoveProjectItem");

return removeProjectItem;
}

//..returns newProjectItem
public JMenuItem getNewMenuItem()
{
Trace.enter("TailMDI.getNewMenuItem");
Trace.exit("TailMDI.getNewMenuItem");

return newProjectItem;
}

//..returns addProjectItem
public JMenuItem getAddProjectItem()
{
Trace.enter("TailMDI.getAddProjectMenuItem");
Trace.exit("TailMDI.getAddProjectMenuItem");

return addProjectItem;
}

//..returns addFileButton
public JButton getAddFileButton()
{
Trace.enter("TailMDI.getAddFileButton");
Trace.exit("TailMDI.getAddFileButton");

return addFileButton;
}

//..returns addFileButton
public JButton getRemoveFileButton()
{
Trace.enter("TailMDI.getRemoveFileButton");
Trace.exit("TailMDI.getRemoveFileButton");

return removeFileButton;
}

//..returns addProjectButton
public JButton getAddProjectButton()
{
Trace.enter("TailMDI.getAddProjectButton");
Trace.exit("TailMDI.getAddProjectButton");

return addProjectButton;
}

//..returns removeProjectButton
public JButton getRemoveProjectButton()
{
Trace.enter("TailMDI.getRemoveProjectButton");
Trace.exit("TailMDI.getRemoveProjectButton");

return removeProjectButton;
}


//..Add the project to the tree
public void addProjectToTree(String projName)
{
Trace.enter("TailMDI.addProjectToTree "+projName);

//..Get the tree model
DefaultTreeModel treeModel = (DefaultTreeModel)projPanel.mainTree.getModel();
MLTreeNode parentNode = (MLTreeNode)treeModel.getRoot();

//..Create a new - tree node
MLTreeNode childNode = searchNode(parentNode,projName);

//..Search the node
TreeNode[] nodes = treeModel.getPathToRoot(childNode);

if(childNode != null)
{
//..Node already exists
//System.out.println("..ML.. Already Exists");
Trace.exit("TailMDI.addProjectToTree "+projName);
return;
}
else
{
//..Node not found
childNode = new MLTreeNode(projName);
childNode.setIsProject(true);
}

//..create child node for a given project
childNode = projPanel.getProjectNode(projName);

//..Solution to Bug - 14 June 2006
//if(childNode == null)
//{
// JOptionPane.showMessageDialog(Tail.tailMDI, "Could not open the project\n"+ fileName, "MakeLogic Tail", JOptionPane.ERROR_MESSAGE);
// Trace.exit("TailMDI.addProjectToTree "+projName);
// return;

//}

//..Insert the node
treeModel.insertNodeInto(childNode,(MutableTreeNode)parentNode,0);

//..now expand the tree
projPanel.expandAll(projPanel.mainTree,true);

Trace.exit("TailMDI.addProjectToTree "+projName);
}

//..Check the node in a Node
public MLTreeNode searchNode(MLTreeNode m_rootNode,String nodeStr)
{
Trace.enter("TailMDI.searchNode "+nodeStr);

try
{
MLTreeNode node = null;

//..Get the Enumeration
Enumeration enumeration = m_rootNode.breadthFirstEnumeration();

//..Find the node
while(enumeration.hasMoreElements())
{
//..get the node fron enum
node = (MLTreeNode)enumeration.nextElement();

//Check for the project path
if(nodeStr.equals(node.absolutePath))
{
//..Tree node Found
Trace.exit("TailMDI.searchNode "+nodeStr);
return node;
}
}
}
catch(Exception e)
{
Trace.exception(e);
}

//..Node not found
Trace.exit("TailMDI.searchNode "+nodeStr);
return null;
}

//..Return the PopupMenu
public MLPopupMenu getPopupMenu()
{
Trace.enter("TailMDI.getPopupMenu");

//..Create obj
if(mlPopupMenu == null)
{
mlPopupMenu = new MLPopupMenu("Popup Menu");

//..Add items and return
mlPopupMenu.add(popAddFileItem);
mlPopupMenu.add(popRemoveFileItem);

//..Add Separator
mlPopupMenu.addSeparator();

mlPopupMenu.add(popAddProjectItem);
mlPopupMenu.add(popRemoveProjectItem);
mlPopupMenu.add(popNewProjectItem);

//..Add Separator
mlPopupMenu.addSeparator();

mlPopupMenu.add(popHideProjectItem);
mlPopupMenu.add(popFileDetailsItem);
}

//..Set the text
popAddFileItem.setText(addFileItem.getText());
popRemoveFileItem.setText(removeFileItem.getText());
popRemoveProjectItem.setText(removeProjectItem.getText());

//..Enable or Disable the items
popAddFileItem.setEnabled(addFileItem.isEnabled());
popRemoveFileItem.setEnabled(removeFileItem.isEnabled());
popAddProjectItem.setEnabled(addProjectItem.isEnabled());
popRemoveProjectItem.setEnabled(removeProjectItem.isEnabled());
popNewProjectItem.setEnabled(newProjectItem.isEnabled());

Trace.exit("TailMDI.getPopupMenu");

return mlPopupMenu;
}
}


Attachment:
MakeLogic_Tail_210.gif
MakeLogic_Tail_210.gif [ 22.21 KiB | Viewed 6144 times ]





Attachments:
MakeLogicTail210.zip [246.92 KiB]
Downloaded 1012 times
MakeLogicTail210SetUp.zip [481.93 KiB]
Downloaded 1003 times
MakeLogicTail210src.zip [126.26 KiB]
Downloaded 952 times

_________________
Please recommend my post if you found it helpful. ,
java,j2ee,ccna ,ccnp certified .
Author:
Expert
User avatar Posts: 838
Have thanks: 2 time

updated.


_________________
M. S. Rakha, Ph.D.
Queen's University
Canada


Author:
Mastermind
User avatar Posts: 2715
Have thanks: 74 time
Post new topic Reply to topic  [ 2 posts ] 

  Related Posts  to : Free "tail -f" Tool for all Platforms: Tail for Windows, Tai
 Make your own Visual Basic 6 Version of "Tail for windows"     -  
 Temu Coupon Code $100 off |"|act796165|"| for New and Exis     -  
 Program for "Selection of arithmetic operations" in Java     -  
 Invalid unicode sequence error ("u")     -  
 How to save in a file the ASCII Characters? Like "☺"     -  
 help for "Note pad code in java"     -  
 @SuppressWarnings("unchecked")     -  
 How to add "Description" on every topics ?     -  
 how to write a "c' program on fibannoic series     -  
 using pen tool in photoshop     -  



Topic Tags

Java Projects







Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com