001: package tide;
002:
003: import javax.swing.UIManager;
004: import javax.swing.ToolTipManager;
005: import java.util.prefs.Preferences;
006: import java.util.*;
007: import tide.update.UpdaterUtils;
008: import java.awt.EventQueue;
009: import javax.swing.RepaintManager;
010: import snow.datatransfer.ClipboardUtils;
011:
012: /*
013: * tIDE -- a small java IDE.
014: *
015: * Copyright (c) 2005-2008 Stephan Heiss (stephan.heiss@gmail.com)
016: *
017: * This program is free software; you can redistribute it and/or modify it
018: * under the terms of the GNU General Public License as published by the Free
019: * Software Foundation; either version 2 of the License, or (at your option)
020: * any later version.
021: *
022: * This program is distributed in the hope that it will be useful, but WITHOUT
023: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
024: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
025: * more details.
026: *
027: * You should have received a copy of the GNU General Public License along
028: * with this program; if not, write to the Free Software Foundation, Inc.,
029: * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
030: *
031: */
032: import java.io.*;
033:
034: import tide.editor.MainEditorFrame;
035: import snow.lookandfeel.ThemesManager;
036:
037: /** Main launcher class for tIDE. Run this to run tIDE. Scans some args.
038: * Last arg maybe a project name.
039: */
040: @net.jcip.annotations.ThreadSafe
041: public final class Main // need not to be a public type to be started !! (strange !)
042: {
043:
044: private Main() {
045: }
046:
047: @SuppressWarnings("unchecked")
048: public static void main(final String[] args) {
049:
050: Locale.setDefault(Locale.ENGLISH);
051: System.out.println(MainEditorFrame._VERSION);
052:
053: // for Mike Karas: so he can pass com.sun.java.swing.plaf.windows.WindowsLookAndFeel
054: if (!hasOption_EqualsIgnoreCase(args, "-noTheme")) {
055: ThemesManager.getInstance().installSelectedTheme();
056: }
057:
058: // only works if in the classpath !
059: if (hasOption_EqualsIgnoreCase(args, "-jgoodiesLook")) {
060: try {
061: UIManager
062: .setLookAndFeel("com.jgoodies.looks.windows.WindowsLookAndFeel");
063: } catch (Exception e) {
064: }
065: }
066:
067: ClipboardUtils.getInstance();
068:
069: ToolTipManager.sharedInstance().setDismissDelay(30000); // idea for sun: make the tips longer visible if they are long !
070:
071: final List<String> argsForMEF = new ArrayList<String>();
072:
073: // args
074: if (args != null) {
075: argsForMEF.addAll(Arrays.asList(args));
076:
077: for (final String ai : args) {
078: if (ai.trim().equalsIgnoreCase("-debug")) {
079: MainEditorFrame.debug = true;
080: RepaintManager
081: .setCurrentManager(new debug.CheckThreadViolationRepaintManager());
082: } else if (ai.trim().equalsIgnoreCase(
083: "-enableExperimental")) {
084: MainEditorFrame.enableExperimental = true;
085: } else if (ai.trim().equalsIgnoreCase("-help")) {
086: System.out
087: .println("Available arguments are "
088: + "{ -enableExperimental, -debug, -logtab, -help, -lowMem, -openLastProj, -compileAll, -noSearchTab, -compactUI }"
089: + "\nAs last arg, a project file or sourcefile may be passed.");
090: } else if (ai.trim().equalsIgnoreCase("-logtab")) {
091: MainEditorFrame.redirectConsoleInTab = true;
092: } else if (ai.trim().equalsIgnoreCase("-noSearchTab")) {
093: MainEditorFrame.noSearchTab = true;
094: } else if (ai.trim().equalsIgnoreCase("-compactUI")) {
095: MainEditorFrame.compactUI = true;
096: } else if (ai.trim().equalsIgnoreCase("-lowmem")) {
097: // don't load libs...
098: // don't cache syntax trees
099: MainEditorFrame.lowMemoryMode = true;
100: } else if (ai.trim().equalsIgnoreCase("-compileAll")) {
101: MainEditorFrame.compileAllAtStartup = true;
102: } else if (ai.trim().equalsIgnoreCase("-openLastProj")) {
103: // opens the last opened project, without dialog.
104: String lp = Preferences.userRoot().get(
105: "tide_last_opened_proj", null);
106: if (lp != null) {
107: File lastP = new File(lp);
108: if (lastP.exists()) {
109: argsForMEF.add(lp);
110: }
111: }
112: }
113: }
114: }
115:
116: // This main call solve almost all bad EDT calls
117: // not critical, because these components are not still realized (visible), but it is better
118: // to run them in the EDT. (no invokeandwait should be within this call...)
119: // the CheckThreadViolationRepaintManager that is running when -debug is set will
120: // show us all the real bad calls during the runtime.
121: EventQueue.invokeLater(new Runnable() {
122: public void run() {
123: MainEditorFrame.mainmet(argsForMEF
124: .toArray(new String[argsForMEF.size()]));
125: }
126: });
127:
128: UpdaterUtils.deleteReplacer();
129: }
130:
131: private static boolean hasOption_EqualsIgnoreCase(String[] args,
132: String opt) {
133: if (args == null)
134: return false;
135:
136: for (final String ai : args) {
137: if (ai.trim().equalsIgnoreCase(opt)) {
138: return true;
139: }
140: }
141:
142: return false;
143: }
144:
145: /*Changes (part):
146: 1.46: minor bugfixes (completion of methods after fields)
147: autostart after update.
148: 1.48: corrected a major bug in dependencies detection (was ignoring sst)
149: moved Main
150: invalidate dependencies at startup (once per project)
151: invalidate compiled state if no classes seen. (as on ramdisks)
152: allow selecting custom project root (useful for ramdisk)
153: allow reset of working time
154: static launcher (beta)
155: 1.49
156: ameliorated tabs visibilities
157: ameliorated recent search
158: added Ctrl+Shift+M to see messages of current source
159: fixed a bug in the updater when called from startup.
160: 1.51
161: improved UI, moved the toolbar in the menubar
162: resources explorer (Ctrl+shift+R) with code insert
163: improved class params in completion (generics)
164: started to simplify the parser tree (less depth, better visibility with colors)
165: improved tide's eye utility
166: -compactUI start flag. tIDE should be nice on the Asus EEE PC !
167:
168:
169: */
170: }
|