package tide;
import javax.swing.UIManager;
import javax.swing.ToolTipManager;
import java.util.prefs.Preferences;
import java.util.*;
import tide.update.UpdaterUtils;import java.awt.EventQueue;
import javax.swing.RepaintManager;
import snow.datatransfer.ClipboardUtils;
/*
* tIDE -- a small java IDE.
*
* Copyright (c) 2005-2008 Stephan Heiss (stephan.heiss@gmail.com)
*
* 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.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
import java.io.*;
import tide.editor.MainEditorFrame;
import snow.lookandfeel.ThemesManager;
/** Main launcher class for tIDE. Run this to run tIDE. Scans some args.
* Last arg maybe a project name.
*/
@net.jcip.annotations.ThreadSafe
public final class Main // need not to be a public type to be started !! (strange !)
{
private Main() {}
@SuppressWarnings("unchecked")
public static void main(final String[] args)
{
Locale.setDefault(Locale.ENGLISH);
System.out.println(MainEditorFrame._VERSION);
// for Mike Karas: so he can pass com.sun.java.swing.plaf.windows.WindowsLookAndFeel
if(!hasOption_EqualsIgnoreCase(args, "-noTheme"))
{
ThemesManager.getInstance().installSelectedTheme();
}
// only works if in the classpath !
if(hasOption_EqualsIgnoreCase(args, "-jgoodiesLook"))
{
try {
UIManager.setLookAndFeel("com.jgoodies.looks.windows.WindowsLookAndFeel");
} catch (Exception e) {}
}
ClipboardUtils.getInstance();
ToolTipManager.sharedInstance().setDismissDelay(30000); // idea for sun: make the tips longer visible if they are long !
final List<String> argsForMEF = new ArrayList<String>();
// args
if(args!=null)
{
argsForMEF.addAll(Arrays.asList(args));
for(final String ai : args)
{
if(ai.trim().equalsIgnoreCase("-debug"))
{
MainEditorFrame.debug = true;
RepaintManager.setCurrentManager(new debug.CheckThreadViolationRepaintManager());
}
else if(ai.trim().equalsIgnoreCase("-enableExperimental"))
{
MainEditorFrame.enableExperimental = true;
}
else if(ai.trim().equalsIgnoreCase("-help"))
{
System.out.println("Available arguments are "
+"{ -enableExperimental, -debug, -logtab, -help, -lowMem, -openLastProj, -compileAll, -noSearchTab, -compactUI }"
+"\nAs last arg, a project file or sourcefile may be passed.");
}
else if(ai.trim().equalsIgnoreCase("-logtab"))
{
MainEditorFrame.redirectConsoleInTab = true;
}
else if(ai.trim().equalsIgnoreCase("-noSearchTab"))
{
MainEditorFrame.noSearchTab = true;
}
else if(ai.trim().equalsIgnoreCase("-compactUI"))
{
MainEditorFrame.compactUI = true;
}
else if(ai.trim().equalsIgnoreCase("-lowmem"))
{
// don't load libs...
// don't cache syntax trees
MainEditorFrame.lowMemoryMode = true;
}
else if(ai.trim().equalsIgnoreCase("-compileAll"))
{
MainEditorFrame.compileAllAtStartup = true;
}
else if(ai.trim().equalsIgnoreCase("-openLastProj"))
{
// opens the last opened project, without dialog.
String lp = Preferences.userRoot().get("tide_last_opened_proj", null);
if(lp!=null)
{
File lastP = new File(lp);
if(lastP.exists())
{
argsForMEF.add(lp);
}
}
}
}
}
// This main call solve almost all bad EDT calls
// not critical, because these components are not still realized (visible), but it is better
// to run them in the EDT. (no invokeandwait should be within this call...)
// the CheckThreadViolationRepaintManager that is running when -debug is set will
// show us all the real bad calls during the runtime.
EventQueue.invokeLater(new Runnable() { public void run() {
MainEditorFrame.mainmet(argsForMEF.toArray(new String[argsForMEF.size()]));
}});
UpdaterUtils.deleteReplacer();
}
private static boolean hasOption_EqualsIgnoreCase(String[] args, String opt)
{
if(args==null) return false;
for(final String ai : args)
{
if(ai.trim().equalsIgnoreCase(opt))
{
return true;
}
}
return false;
}
/*Changes (part):
1.46: minor bugfixes (completion of methods after fields)
autostart after update.
1.48: corrected a major bug in dependencies detection (was ignoring sst)
moved Main
invalidate dependencies at startup (once per project)
invalidate compiled state if no classes seen. (as on ramdisks)
allow selecting custom project root (useful for ramdisk)
allow reset of working time
static launcher (beta)
1.49
ameliorated tabs visibilities
ameliorated recent search
added Ctrl+Shift+M to see messages of current source
fixed a bug in the updater when called from startup.
1.51
improved UI, moved the toolbar in the menubar
resources explorer (Ctrl+shift+R) with code insert
improved class params in completion (generics)
started to simplify the parser tree (less depth, better visibility with colors)
improved tide's eye utility
-compactUI start flag. tIDE should be nice on the Asus EEE PC !
*/
}
|