001: package tide.editor;
002:
003: import java.util.*;
004:
005: /** Used in the help menu...
006: * Contains tips and links.
007: */
008: public final class Tips {
009: private Tips() {
010: }
011:
012: public final static String[][] tips = new String[][] {
013: {
014: "Mini - Tutorial 1",
015: "This should help you to discover some of the basic features of tIDE"
016: + "<ol><li>Create a new package: right click on the sources tree root and select \"create a new package\". Give the name <code>example1</code>."
017: + "<br><li>Create a new source file: right click on the just created package and create a new java source file named <code>Main1<code>."
018: + "<br><li>Right click on <code>Main1</code> and choose \"define as project main class\"."
019: + "<br><li>Click after <code>public Main1() {</code> and type the \"sysop\". It will expand to <code>System.out.println(\"\");</code> write <code>\"Hello World\"</code>."
020: + "<br><li>Press F9 to compile the whole project and F10 to run it. and finally Ctrl+J to create a Jar."
021: + "</ol>" },
022:
023: {
024: "Mini - Tutorial 2",
025: "This should help you to discover some of the basic features of tIDE"
026: + "<ol><li>Create a new source named <code>Model</code> in package <code>example1</code> (see tutorial 1)."
027: + "<li>Let it be a TableModel, just write <code>public class Model extends DefaultTableModel</code>."
028: + "<br>(You may use CTRL+T to find the class based on a name fragment if you are not sure)."
029: + "<li>Right click on the <code>DefaultTableModel</code> and add the missing import."
030: + "<li>Compile the changed files with Shift+F9."
031: + "<li>Place the caret after the constructor bloc (after the \"}\") on an empty line and press Ctrl+Space."
032: + "<li>Type getvalue, select the method <code>getValueAt(int, int)</code> and press the \"override\" button."
033: + "<li>write the body method <code>return row * column;</code> ."
034: + "<li>Also override both getColumnCount and getRowCount methods and give them the body <code>return 4;</code>."
035: + "<li>Write in the constructor body <code>JFrame f = new JFrame(\"Mult table\");</code>."
036: + "<li>Right click on JFrame and add the missing import while pressing <code>Shift</code> for the whole <code>swing</code> package."
037: + "<li>Add the lines <pre>f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);"
038: + "<br>JTable t = new JTable(this);"
039: + "<br>f.add(t);"
040: + "<br>f.pack();"
041: + "<br>f.setVisible(true);</li>"
042: + "<li>Run this perticular class, with Shift+F10. This will compile if necessary."
043: + "</ol>" },
044:
045: {
046: "Search functions",
047: "<b>CTRL+F</b> in the editor pane, or any output tab shows a search tool for that panel.<p>"
048: + "<b>F4</b> jumps to the next occurence.<p>"
049: + "The trees also offers search functions, for any subbranches in the right-click context menu. "
050: + "<br>Search options are case sensitivity, reverse search, or regex syntax, for advanced possibilities. "
051: + "One can also specify if comments and litterals (strings) should be included in the search. "
052: + "<p>CTRL+G searches in all source files, Ctrl + Shift + G searches in all sourcefile names."
053: + "<p>CTRL+Down or Up jumps to the next line containing a message (warning, error, ...)" },
054: {
055: "Decompiling classes",
056: "The external JAD decompiler alows you to decompile transparently the class files "
057: + "that are in the libraries (jar files).<br>Set the option \"Apply Jad per default on lib classes\" "
058: + "and you can browse your compiled libs as if they were sources !" },
059: {
060: "Detecting unused imports",
061: "Use the external PMD tool on any source branch (right click and choose PMD). "
062: + "In the PMD settings (main menu Ext Tools}, set \"imports\" as only rule. " },
063: {
064: "Copy pasting stack traces",
065: "The execution, compiler and search output tabs contents can be copied and "
066: + "pasted.<br>Very practical if somebody send you an exception stack trace of your application "
067: + "just paste it in the execution tab.<p> You can also format the outputs of your own tools or external "
068: + "applications in a manner that can be recognized by the output tab to jump to source code lines.<br> "
069: + "This is exactely the way PMD or other external tools were embedded in tide.<br> "
070: + "An XML output is transformed with XSLT to produce stacktrace like texts " },
071: {
072: "Processes tab",
073: "The processes tab allows you to see which processes are running (compilations, executions, tools) "
074: + "it also offers an overview of old completed processes along with their starting date and duration."
075: + "You can kill selected running processes from context menu if you want."
076: + "<br>From java 1.6, you can generate stacktraces, heap dumps and launch heap analysis from the context menu." },
077: {
078: "Bookmarks",
079: "Bookmarks allow you to remember a set of source or class files lines. "
080: + "In the bookmarks manager, you can browse and add remarks describing what your intentions are "
081: + "with a perticular bookmark (todo, analyse, remove, ...). Bookmarks can be defined from the "
082: + "Editor context menu or from the sources tree (in this case, line 1 is marked)." },
083: {
084: "Autoreplacements",
085: "Autoreplacements are automatic expansions in the editor, for exemaple, when you "
086: + "type <code>sysop</code>, it is automatically replaced with <code>System.out.println(\"\")</code>. "
087: + "You can manage the replacements, create your own or delete existing ones from the menu "
088: + "Editor / Auto replacements." },
089: {
090: "JConsole inspection",
091: "Running JVMs started with <pre>-Dcom.sun.management.jmxremote</pre> (JVM arguments in the project settings) "
092: + "can be inspected/profiled during their life with jconsole. Start it from java_home/bin/jconsole directly or from "
093: + "the tIDE processes manager. You can see the current threads stacktrace, graphics of memory usage, threads, and "
094: + "set/get the MXBeans properties. Since 1.6, no flag is required, all started JVM are jmxremote enabled." },
095: {
096: "Local variables completion",
097: "Press Ctrl+Space to open a completion dialog for local variables at the edited point (method)."
098: + "<br>\"this.\" gives the attributes (method and fields) completion for the closest enclosing class,"
099: + "<br>\"ClassName.this\" gives the completion for the specified enclosing class."
100: + "<br>CTRL+Space also offers the completion for class names starting with the text already entered."
101: + " For example, type <code>\"JInterna\"</code> and Ctrl+Space. You can also create a named instance using the button in the completion dialog." },
102: {
103: "Adding missing import",
104: "A right click on an class name in the editor offer you to add the missing import (if it is missing)."
105: + "Pressing SHIFT inserts the import for the whole package" },
106: {
107: "Generating getter/setter",
108: "A right click on an field name in the editor offer you to add the getter and/or setter code."
109: + " After having performed that function, click to the place where you want to insert the code and press Ctrl+V." },
110: // not useful
111: /*
112: {"jdb - The Java Debugger", "Just start the app with java -agentlib:jdwp=transport=dt_shmem,address=jdbconn,server=y,suspend=n "
113: +" and start the jda debugger with: jdb -attach jdbconn in a console."
114: +"Docs are in technotes/tools/windows/jdb.html "
115: },*/
116: {
117: "Live component tree",
118: "Press Ctrl+Shift+F1 to see a full current component structure dump on the console "
119: + " for the current focused window. From the execution tab context menu, you can parse and view the tree"
120: + " and locate immediately a common violation: if awt and swing components are used together." },
121:
122: {
123: "Filename completion",
124: "All file dialogs in tide have \"linux-like\" completions for the path. Press TAB at the end of the path "
125: + "to see a list of possible valid paths." },
126:
127: {
128: "Syntax tree search",
129: "click somewhere on the syntaxtree panel and start typing some field/node name to search for..." },
130: {
131: "Sources positions history",
132: "right click on the left arrow in the sources tab to see an history of last edited files and an history"
133: + " of the previous caret positions in sources (stored before jumps/changes)." },
134:
135: {
136: "Syntax tree navigation",
137: "Right-clik somewhere in the source code and the corresponding syntax tree node becomes selected."
138: + "<br>Click on the node and the corresponding source beginning (declaration) becomes selected."
139: + "<br>Hold Shift + Click on the node jumps to the item source's end." },
140:
141: {
142: "Navigate messages/errors",
143: "Ctrl+Up and Ctrl+down goes to prev/next error/message in the source."
144: + "<br>Ctrl+1 and Ctrl+9 jumps to the first or last message in the source."
145: + "<br>Ctrl+Shipf+Up/down navigates through the methods." },
146:
147: {
148: "Debug swing calls",
149: "All swing calls should be made in the event dispatch thread edt. Use the autocompletion <code>\"edtlater\"</code> to quickly"
150: + " generate correct call. Use the external CheckThreadViolationRepaintManager from the swinghelper homepage to detect invalid calls."
151: + " The execution panel stacktrace browser let you quickly filter the invalid calls that are coming from your project classes." },
152: {
153: "View bytecode",
154: "From the syntax tree, on type nodes (class, enum, interface), you can see the bytecode of the associated disassembled class." },
155:
156: {
157: "Identifier selection",
158: "just double-click on an identifier word to select it. Same words are shown highlighted in the document and the total count is shown. "
159: + "hit Ctrl to also select the dots." },
160:
161: {
162: "Next/previous selection",
163: "place the caret on some word and press Alt+Up or Down to jump to the previous/next same word. Press Alt+1 or 9 to jump to the first or last occurence." },
164:
165: {
166: "Passing parameters as members",
167: "press Ctrl-C when some parameter list is selected (from a constructor or method declaration), place the caret at the beginning of the constructor bloc, after an eventual super call and press Alt+A." },
168:
169: {
170: "Importing sources to the project",
171: "A convenient way is to drag and drop some java file from the system to the tIDE sources panel. The content will be imported (as a copy)." },
172:
173: /* {"Profiling", "pass the argument \"-agentlib:hprof=cpu=samples\" to the jvm and your application (at shutdown) will leave a"
174: +"<br> java.hprof.txt file in the working directory containing the places where most CPU was used !"}*/
175: {
176: "Profiling",
177: "From the tree, you can run any main class in profiler mode (already in JDK 1.2.2 !).<br>Memory sites allocations "
178: + "or CPU usage can be monitored. These functions uses the internal JDK profiler launched with the option -agentlib:hprof."
179: + "After having started the app in profiler mode, perform the operations you want to monitor in your app and close it."
180: + "After the regular shutdown of the app JVM, tide will parse the profiler results and display them in a tab."
181: + "Old profiler results are stored in the project subfolder profiler. You can load some old profiler results "
182: + "from previous tide runs from the tIDE Project menu."
183: + "<p>From the processes tab, you can also create on-demand heap dumps and perform their analyse with jhat." },
184:
185: // todo:
186: // code generation
187: // enum list generation
188: // override
189: //null,
190:
191: {
192: "Octal constants",
193: "012 is not 12 !, it is interpreted as an octal value, that is 8+2 = 10.<p> "
194: + "You can detect such potential dangerous constants over the whole project "
195: + "using the global search (CTRL+G) or from a tree branch with the following regex pattern "
196: + "<br><pre> [^0-9a-z.,]0\\\\d+[^.,a-z]</pre> " },
197:
198: {
199: "API trap",
200: "You should know how to use the java API... Well... Sure ? what about Math.abs( -2147483648 ) ? is it positive ? "
201: + "Also be aware of % and Math.round(-359697435) and a lot of other issues as Map.remove(obj), ... Read Neil Gafter's book Java Puzzlers." }
202:
203: // API TRAP : url.getPath for a file... JOPtionPane.internalXXX CRASHES !!
204: /*TODO: not reflected in tide {"System.err", "Calls to System.err are not buffered, calls to System.out are buffered."
205: +" "
206: },*/
207:
208: };
209:
210: public final static String[] slogans = new String[] {
211: "Have tide on your side!", "Make tide your bride!",
212: "Have wide sights with tide!",
213: "Ride over your code with tide!", "Don't hide tide!",
214: "Join the tide pride", "Save CO2 with tide",
215: "Save money with tide" };
216:
217: public final static String[][] cautions = new String[][] {
218: { "String.lastIndexOf",
219: "String.lastIndexOf(xx, from) search backwards !" },
220: { "TextPane.getText",
221: "TextPane.getText() and TextPane.getDocument().getText() are not the same !" } };
222:
223: public static final String JVMOptionsURL = "http://blogs.sun.com/watt/resource/jvm-options-list.html";
224: public static final String tideManual = "http://snowmail.sn.funpic.de/tide/tide_manual.pdf";
225:
226: // null => separator
227: public final static String[][] links = new String[][] {
228: { "SUN Java home", "http://java.sun.com" },
229: { "IBM developerworks",
230: "http://www.ibm.com/developerworks/java/" },
231: null,
232: { "Java Tutorials",
233: "http://java.sun.com/docs/books/tutorial/" },
234: { "Core Java tech tips (old)",
235: "http://java.sun.com/developer/JDCTechTips/" },
236: { "Core Java tech tips (blog)",
237: "http://blogs.sun.com/CoreJavaTechTips/" },
238: { "Java forums", "http://forum.java.sun.com/index.jspa" },
239: { "Java World Tips",
240: "http://www.javaworld.com/columns/jw-tips-index.html" },
241: null,
242: // boring...
243: //{"An inofficial collection of JVM Options", JVMOptionsURL},
244: //null,
245: // cool corner cases, pitfalls,...
246: { "Java Puzzlers Book", "http://www.javapuzzlers.com/" },
247: // good articles, deep details
248: { "Angelica Langer Publications",
249: "http://www.angelikalanger.com/Publications.html" },
250: null,
251: // good actual security news
252: { "Heise security news", "http://www.heise-security.co.uk/" },
253: null,
254: // cool persons
255: { "SUN research minds", "http://research.sun.com/minds/" }
256: // null,
257: // {"Singleton detector", "http://code.google.com/p/google-singleton-detector/"}
258: // yWorks obfuscator ??
259: // JPC !!
260: // ==> javaOne
261: };
262:
263: //http://www.zurich.ibm.com
264: //http://ch.sun.com/aboutsun/
265:
266: // null => separator
267: final static String[][] docLinks = new String[][] {
268: //{"Online JDK1.5 API", "http://java.sun.com/j2se/1.5.0/docs/api/index.html"},
269: //{"Online JDK6 API", "http://java.sun.com/javase/6/docs/api/"},
270: //{"Online JDK1.5 Guides","http://java.sun.com/j2se/1.5.0/docs/#guide"},
271: //{"Online JDK6 Docs","http://java.sun.com/javase/6/docs/"},
272: //{"Online JDK1.5 Tooldocs","http://java.sun.com/j2se/1.5.0/docs/#tools"}, //?
273: { "Online JDK6 Docs & Api",
274: "http://java.sun.com/javase/reference/index.jsp" },
275: { "Troubleshooting Java SE",
276: "http://java.sun.com/javase/6/webnotes/trouble/" },
277: { "Performance White Paper",
278: "http://java.sun.com/performance/reference/whitepapers/6_performance.html" },
279: null,
280: { "Java language specification",
281: "http://java.sun.com/docs/books/jls/third_edition/html/j3TOC.html" },
282: { "Java expressions",
283: "http://java.sun.com/docs/books/jls/third_edition/html/expressions.html" },
284: null,
285: { "How to Write Doc Comments for Javadoc",
286: "http://java.sun.com/j2se/javadoc/writingdoccomments/index.html" }
287:
288: };
289:
290: /* manually added
291: public final static String[][] otherApps = new String[][]{
292: {"Snowmail mail client", "http://snowmail.sn.funpic.de/", "http://snowmail.sn.funpic.de/snowmailclient.jnlp"},
293: {"T-Restorizer (Zip/unzip)", "http://www.geocities.com/stephanchaud/junzipper/index.htm", "http://snowmail.sn.funpic.de/trestorizer/trestorizer.jnlp"},
294: {"tIDE", "http://snowmail.sn.funpic.de/tide/", "http://snowmail.sn.funpic.de/tide/tide.jnlp"}
295: };*/
296:
297: final static String[][] goodBooks = new String[][] { {
298: "Java Puzzlers",
299: "Java Puzzlers, Traps, Pitfalls and Corner Cases, Jushua Bloch, Neal Gafter, Addison Wesley, 2005. (http://www.javapuzzlers.com/)" } };
300:
301: static final String[][] javaTips = new String[][] {
302: {
303: "File Compare",
304: "Comparing files with File.equals() work not if the files have relative paths in them. For example on windows, "
305: + " <pre>c:/temp/../Temp</pre> and <pre>c:\\temp</pre> fails to be equals with File.equals(). "
306: + "A robust solution consist to use getCanonicalPath() on the file before comparing them. URIs also fail to equals !." },
307: { "", "" } };
308:
309: public static final String[][] cool = new String[][] {
310: { "Eifersucht",
311: "Eifersucht ist eine Leidenschaft, die mit Eifer sucht was Leiden schafft." },
312: { "10 Reasons to Dump Your Java IDE",
313: "http://www.devx.com/devx/editorial/16364" },
314: { "Monitoring",
315: "http://java.sun.com/developer/technicalArticles/J2SE/monitoring/" },
316: {
317: "A bug report",
318: "http://googleresearch.blogspot.com/2006/06/extra-extra-read-all-about-it-nearly.html" },
319: { "A good shutdown app",
320: "http://www.microsoft.com/technet/sysinternals/utilities/psshutdown.mspx" } };
321:
322: //unstructured pointers (sometimes grammatic, sometimes examples, ...)
323: // offered in the editor context menu for id at caret.
324:
325: public static final String langSpecBaseURL = "http://java.sun.com/docs/books/jls/third_edition/html/"; // todo: allow offline if specified...
326:
327: public final static String[][] langSpecRelPathsForKeyWords = new String[][] {
328: { "abstract", "classes.html#8.1.1.1" },
329: { "assert", "statements.html#14.10" },
330: { "const", "lexical.html#3.9" },
331: { "continue", "statements.html#14.16" },
332: { "default", "interfaces.html#9.6" },
333: { "for", "statements.html#14.14" },
334: { "new", "execution.html#12.5" },
335: { "switch", "statements.html#14.11" },
336: { "if", "statements.html#14.9" },
337: { "package", "packages.html" },
338: { "synchronized", "statements.html#14.19" },
339: { "boolean", "typesValues.html#4.2.5" },
340: { "do", "statements.html#14.13" },
341: { "goto", "lexical.html#3.9" },
342: { "private", "names.html#6.6" },
343: { "this", "expressions.html#15.8.3" },
344: { "break", "statements.html#14.15" },
345: { "double", "lexical.html#76707" },
346: { "implements", "classes.html#8.1.5" },
347: { "protected", "names.html#6.6" },
348: { "throw", "statements.html#14.18" },
349: { "byte", "typesValues.html#4.2" },
350: { "else", "statements.html#14.9.2" },
351: { "import", "packages.html#7.5" },
352: { "public", "names.html#6.6" },
353: { "throws", "classes.html#8.4.6" },
354: { "case", "statements.html#14.11 " },
355: { "enum", "classes.html#8.9 " },
356: { "instanceof", "expressions.html#15.20.2" },
357: { "return", "statements.html#14.17" },
358: { "transient", "classes.html#8.3.1.3" },
359: { "catch", "statements.html#14.20" },
360: { "extends", "classes.html#8.1.4" },
361: { "int", "lexical.html#3.10.1" },
362: { "short", "typesValues.html#4.2" },
363: { "try", "statements.html#14.20" },
364: { "char", "lexical.html#3.10.1" },
365: { "final", "typesValues.html#4.12.4" },
366: { "interface", "classes.html#8.1.5" },
367: { "static", "classes.html#8.3.1.1" },
368: { "void", "classes.html#8.4" },
369: { "class", "classes.html" },
370: { "finally", "statements.html#14.20" },
371: { "long", "lexical.html#3.10.1" },
372: { "strictfp", "expressions.html#249198" },
373: { "volatile", "classes.html#8.3.1.4" },
374: { "float", "typesValues.html#11998" },
375: { "native", "classes.html#8.4.3.4" },
376: { "super", "expressions.html#15.11.2" },
377: { "while", "statements.html#14.12" },
378:
379: // not keywords, but maybe useful
380:
381: { "true", "typesValues.html#4.2.5" },
382: { "false", "typesValues.html#4.2.5" },
383: { "null", "lexical.html#3.10.7" },
384: { "String", "lexical.html#3.10.5" },
385: { ">>", "expressions.html#15.19" },
386: { "<<", "expressions.html#15.19" },
387: { ">>>", "expressions.html#15.19" },
388: { "&", "expressions.html#15.22" },
389: { "^", "expressions.html#15.22" },
390: { "!", "expressions.html#15.22" },
391: { "~", "expressions.html#15.15" }, { "[", "arrays.html" },
392: { "]", "arrays.html" }, { "[]", "arrays.html" }
393:
394: };
395:
396: public static Map<String, String> langSpecRelPathsForKeyWordsMap = new HashMap<String, String>();
397: static {
398: for (String[] kv : langSpecRelPathsForKeyWords) {
399: if (kv != null) {
400: langSpecRelPathsForKeyWordsMap.put(kv[0], kv[1]);
401: }
402: }
403: }
404:
405: // Michel Petrucciani - Caravan http://de.youtube.com/watch?v=3YreBEG1pTA
406:
407: // https://visualvm.dev.java.net/
408: // https://javatools-incubator.dev.java.net/
409:
410: // puzzler
411: /*
412: String a="";
413: System.out.println(""+(a!=null+")"));
414: */
415: }
|