Click here to Skip to main content
15,893,588 members
Articles / Programming Languages / Java / Java SE

Free "tail -f" Tool for all Platforms: Tail for Windows, Tail for Linux and Tail for Mac

Rate me:
Please Sign up or sign in to vote.
2.08/5 (8 votes)
19 Jul 2006CPOL3 min read 56K   1.1K   24  
MakeLogic Tail is a freeware similar to " tail -f " of Linux. It is Tail for Windows, Tail for Linux and Tail for Mac
/******************************************************************************
 
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		: 30th December 2005
Authors		: MakeLogic

Design		: Ujjwal
Developer	: Dharma

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

package com.makeLogic.utils;

import java.awt.Container;

import java.io.File;

import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;

import javax.swing.ImageIcon;
import javax.swing.JFileChooser;
import javax.swing.JMenuItem;
import javax.swing.KeyStroke;

import com.makeLogic.TailMDI;

/**
 * Summary description for OpenProjectMenuItem.
 */
public class OpenProjectMenuItem extends JMenuItem implements ActionListener{

	//.. variables declaration
	Container container;
	JFileChooser fileChooser;
	File file[];

	TailMDI tailMDI;
	public OpenProjectMenuItem(Container container){

		//..calls the super class constructor with string as parameter
		super("Add Existing Project");

		Trace.enter("OpenProjectMenuItem.OpenProjectMenuItem");

		//..Get current classloader 
		ClassLoader cl = this.getClass().getClassLoader();
		
		try
		{
			setIcon(new ImageIcon(cl.getResource("addProject_icon.png")));			
		}
		catch(Exception excpt)
		{
			Trace.exception(excpt);			
		}
		
		//this.container=container;
		tailMDI = (TailMDI)container;

		//..sets the Default accelerator as CTRL+SHIFT+O for the OpenProjectMenuItem
		setAccelerator(KeyStroke.getKeyStroke('O',java.awt.Event.CTRL_MASK|java.awt.Event.SHIFT_MASK,false));

		//..Adds the ActionListerner to handle the Event
		addActionListener(this);

		this.container=container;

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

	public void setKeyStrokeForNewMenuItem(KeyStroke newMenuItemKeyStroke){

		Trace.enter("OpenProjectMenuItem.setKeyStrokeForNewMenuItem");
		
		//..sets user defined Accelerator for the NewMenuItem
		setAccelerator(newMenuItemKeyStroke);

		Trace.exit("OpenProjectMenuItem.setKeyStrokeForNewMenuItem");
	}

	public void actionPerformed(ActionEvent evt){
		/* Opens a New JInternalFrame when this event is generated */

		Trace.enter("OpenProjectMenuItem.actionPerformed");
		
		if(fileChooser == null)
		{
			fileChooser = new JFileChooser();

			fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
			fileChooser.setMultiSelectionEnabled(true);
			fileChooser.setFileFilter(new CreateProjectFileFilter());
		}
		
		//...................................................
		fileChooser.setDialogTitle("Add Existing Project");
		int returnValue = fileChooser.showDialog(tailMDI, "Add Project");

		//..Check if cancel is clicked
		if(returnValue == JFileChooser.CANCEL_OPTION)
		{
			Trace.exit("OpenProjectMenuItem.actionPerformed");
			return;
		}

		file = fileChooser.getSelectedFiles();

		//..Project file
		String tempProjFileName;

		//..Debug
		//System.out.println("..ML.. File Length is ->"+file.length);

		if(file!=null&&file.length>0)
		{
			int i=0;

			while(i<file.length)
			{

				tempProjFileName = file[i].getAbsolutePath();
				
				//System.out.println("..ML.. ProjFile ->"+tempProjFileName);

				//..Add or move the project to the top
				tailMDI.addProject(tempProjFileName);

				//..Add the project to the tree
				tailMDI.addProjectToTree(tempProjFileName);

				i++;
			}
		}
		Trace.exit("OpenProjectMenuItem.actionPerformed");
	}
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Web Developer
India India
Founder of MakeLogic - A Mobile Solutions and XML Web Services Company. B-Tech engineer from India's reputed IITs.

Designed and Authored products like MicroGraphs, MakeLogic VersionManager and MakeLogic Device Broker. Pls see http://www.makelogic.com

MakeLogic is a strategic business partner of Microsoft, Sun, IBM, HP and Citrix.

Contact : madanuuk@makelogic.com OR +91 - 40 - 55322433

Comments and Discussions