├── .classpath
├── .externalToolBuilders
└── Ant_Builder.launch
├── .gitignore
├── .project
├── .settings
└── org.eclipse.jdt.core.prefs
├── README.md
├── Todo, GSoC 2013.txt
├── application
├── Info.plist.tmpl
├── sketch.icns
├── template.app
│ └── Contents
│ │ ├── MacOS
│ │ └── JavaApplicationStub
│ │ ├── PkgInfo
│ │ └── Resources
│ │ └── sketch.icns
├── template.exe
└── template.plist
├── build.properties
├── build.xml
├── data
└── icons
│ ├── class_obj.png
│ ├── field_default_obj.png
│ ├── field_icon.png
│ ├── field_private_obj.png
│ ├── field_protected_obj.png
│ ├── field_public_obj.png
│ ├── info_icon.png
│ ├── innerclass_private_obj.png
│ ├── innerclass_protected_obj.png
│ ├── methdef_obj.png
│ ├── methpri_obj.png
│ ├── methpro_obj.png
│ ├── methpub_obj.png
│ ├── refresh_icon.png
│ └── sort_icon.png
├── keywords.txt
├── mode.properties
├── mode
├── .gitignore
├── CompilationChecker.jar
├── classpath-explorer-1.0.jar
├── com.ibm.icu_4.4.2.v20110823.jar
├── jdi-src.zip
├── jdi.jar
├── jdimodel-src.zip
├── jdimodel.jar
├── jsoup-1.7.1-javadoc.jar
├── jsoup-1.7.1.jar
├── org.eclipse.core.contenttype_3.4.200.v20120523-2004.jar
├── org.eclipse.core.jobs_3.5.300.v20120622-204750.jar
├── org.eclipse.core.resources_3.8.1.v20120802-154922.jar
├── org.eclipse.core.runtime_3.8.0.v20120521-2346.jar
├── org.eclipse.equinox.common_3.6.100.v20120522-1841.jar
├── org.eclipse.equinox.preferences_3.5.0.v20120522-1841.jar
├── org.eclipse.jdt.core_3.8.2.v20120814-155456.jar
├── org.eclipse.jdt.debug_3.7.101.v20120725-115645.jar
├── org.eclipse.osgi_3.8.1.v20120830-144521.jar
├── org.eclipse.text_3.5.200.v20120523-1310.jar
└── readme.txt
├── pdeX.txt
├── revisions.txt
├── src
└── processing
│ └── mode
│ └── experimental
│ ├── ASTGenerator.java
│ ├── ASTNodeWrapper.java
│ ├── ArrayFieldNode.java
│ ├── AutoSaveUtil.java
│ ├── ClassLoadListener.java
│ ├── Compiler.java
│ ├── CompletionCandidate.java
│ ├── CompletionPanel.java
│ ├── DebugBuild.java
│ ├── DebugEditor.java
│ ├── DebugRunner.java
│ ├── DebugToolbar.java
│ ├── Debugger.java
│ ├── ErrorBar.java
│ ├── ErrorCheckerService.java
│ ├── ErrorMarker.java
│ ├── ErrorMessageSimplifier.java
│ ├── ErrorWindow.java
│ ├── ExperimentalMode.java
│ ├── FieldNode.java
│ ├── ImportStatement.java
│ ├── JavadocHelper.java
│ ├── LineBreakpoint.java
│ ├── LineHighlight.java
│ ├── LineID.java
│ ├── LineListener.java
│ ├── LocalVariableNode.java
│ ├── OffsetMatcher.java
│ ├── Problem.java
│ ├── SketchOutline.java
│ ├── TextArea.java
│ ├── TextAreaPainter.java
│ ├── Utils.java
│ ├── VMEventListener.java
│ ├── VMEventReader.java
│ ├── VariableInspector.form
│ ├── VariableInspector.java
│ ├── VariableNode.java
│ ├── XQConsoleToggle.java
│ ├── XQErrorTable.java
│ └── XQPreprocessor.java
├── theme
├── buttons-2x.png
├── buttons-debug-2x.png
├── buttons-debug.png
├── buttons.png
├── mode-2x.png
├── mode.png
├── theme.txt
└── var-icons.gif
└── todo.txt
/.classpath:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/.externalToolBuilders/Ant_Builder.launch:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | .AppleDouble
3 | ._*
4 | *~
5 | bin
6 | mode/ExperimentalMode.jar
7 | dist
8 | build.properties
--------------------------------------------------------------------------------
/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | processing-experimental
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.jdt.core.javabuilder
10 |
11 |
12 |
13 |
14 | org.eclipse.ui.externaltools.ExternalToolBuilder
15 |
16 |
17 | LaunchConfigHandle
18 | <project>/.externalToolBuilders/Ant_Builder.launch
19 |
20 |
21 |
22 |
23 |
24 | org.eclipse.jdt.core.javanature
25 |
26 |
27 |
--------------------------------------------------------------------------------
/.settings/org.eclipse.jdt.core.prefs:
--------------------------------------------------------------------------------
1 | eclipse.preferences.version=1
2 | org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
3 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
4 | org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
5 | org.eclipse.jdt.core.compiler.compliance=1.6
6 | org.eclipse.jdt.core.compiler.debug.lineNumber=generate
7 | org.eclipse.jdt.core.compiler.debug.localVariable=generate
8 | org.eclipse.jdt.core.compiler.debug.sourceFile=generate
9 | org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
10 | org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
11 | org.eclipse.jdt.core.compiler.source=1.6
12 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | **Update**: This repo is no longer active. PDE X codebase was merged into the [main processing repo](https://github.com/processing/processing/) starting with the 3.0 alpha releases (July 2014), further development continues in the main repo. So please report any issues in the main Processing repo.
2 |
3 | PDE X
4 | =====
5 |
6 | PDE X is a [Processing](http://processing.org/) Mode that brings powerful new features to the Processing Development Environment:
7 |
8 | * Intelligent Code Completion
9 | * Quick Renaming(Refactoring)
10 | * Quick Navigation
11 | * Import Suggestions
12 | * Live Error Checker
13 | * Integrated Debugger
14 |
15 | Find out more at [Getting Started](https://github.com/processing/processing-experimental/wiki/Getting-Started). Or checkout the [FAQ](https://github.com/processing/processing-experimental/wiki/FAQ)
16 |
17 | ####How to Install
18 |
19 | 
20 |
21 | Click on the down arrow besides the mode switch button, and select Add Mode. In the Mode Manager window, select PDE X and click 'Install'. You'll need Processing 2.0.2 or higher.
22 |
23 | For installing it manually, download the latest version from [here](http://download.processing.org/pdeX.zip). Extract the zip contents into `/modes` folder. Restart Processing.
24 |
25 | Manindra Moharana
26 |
27 | 21 October 2013
28 |
29 | --
30 | PDE X is supported by [Google Summer of Code 2013](http://www.google-melange.com/gsoc/homepage/google/gsoc2013)
--------------------------------------------------------------------------------
/Todo, GSoC 2013.txt:
--------------------------------------------------------------------------------
1 | TODO List for Experimental Mode Plus- GSOC 2013
2 |
3 | This would also be a break down of my thought process and ideas as I tackle various tasks. Also lines are fairly long. Make sure you turn on word wrap. ;)
4 |
5 | Manindra Moharana (me@mkmoharana.com)
6 |
7 | [ ]: Todo, [x] : Done, ? : Undecided Todo, ! : Critical, + : Minor Todo
8 |
9 | Code Completion
10 | ===============
11 |
12 | The big stuff:
13 |
14 | *! May be I should just implement recursive find for compiled code first, see how it goes and hopefully it would give me some ideas about how to integrating the two.
15 | - Making very good progress here. The elegance of recurion - Hats off!
16 | - Many of the cases seem to have been covered, and I'm achieving more and more code unification as I'm working through the problem step by step
17 | - Looks almost complete now, nearly all cases covered(July 13th)
18 | x After popup appears, the popup location is fixed for the current line. So if editor window is moved while staying in the same line, popup appears at the prev location. Need to ensure editor is still at last know location. Fixed.
19 | [ ]Keyboard Shortcut for completion popup - Ctrl + Space
20 | [ ]Scope handling? Static/non static scope?
21 | [ ]Disable completions on comment line
22 | [ ]Trie implementation would be lower priority, "premature optimisation is pure evil". Get all features of CC working good enough and then plan this.
23 |
24 | [x]Ensure that a compilation unit is created at startup!
25 | x! Code competition for local code is working with recursive look up.
26 | [x]Completion doesn't seem to show up for fields of a type defined locally. But works for methods with return type defined locally. Take ideas. Some case missing most probably. Fixed
27 | [x]Discovered another major issue due to offset differences -> While looking for predictions, if the parsed string contains pde enhancements, predictions FAIL! Zomg.
28 | Ex - "s.substring(int(13.4))." fails. Thinking to just do the substitutions before sending it to updatePredictions(), coz offsets aren't really a concern here, right? Yup, fixed it!
29 | x! Code completion with library code, non-nested seems to be broken, fix it. Fixed.
30 | [x]Completion for external classes - ArrayList, HashMap, etc.
31 | x! Recursive lookup for compiled(library) code!
32 | x! Library CC for nested would be tricky. Need to jump from local->compiled code while searching recursively. Recursive find's current implementation is based on ASTNode return type. Afaik, no way to instantiate orphaned ASTNode objects(or did I miss it?). ASTNode objects have to be created only from the main ast instance. But I need to find a way to switch to compiled instances from local class instance.
33 | x! Should I implement wrapper for ASTNode? - possibly needed for code completion with compiled and non-compiled code. Done.
34 | [x]Differentiating between multiple statements on the same line. How to? Done with offset handling.
35 | [x]- Cache predictions if current 'word' is increasing in length. If already showing predictions beginning with 's', for 'sa', remove extra completions, rather than recalculating predictions. Performance increase.
36 | [x]Parameterized type support is broken.
37 | [x]Array types, all all other types support broken. :\
38 | [x]Completion for array access, strings[0].
39 |
40 | Finer details
41 |
42 | [ ]findDeclarations should support 3rd party classes too. It's about time. ;)
43 | [ ]printStuff(int,float,String) - completion endings have to be appropriate. Right now it's just printStuff(,,). Cursor positioning also needs to be taken care of(done). Argument list as tooltip if possible?
44 | *! p5 enhanced stuff in java, how does it fit in with everything else, and edge cases. Possibly add support for them. Offset handling improvements should help here.
45 | [ ]Diamond operator isn't supported for now. Bummer.
46 |
47 | [x]Completion popup height is now dynamic, decreases to fit.
48 | [ ]Completion width can be dynamic, if really needed..
49 | [x]Icons for completions? Or overkill right now?
50 | [x]'Show Usage' menu item added
51 | [x]Show declaring class for completions
52 | x! Ignore String case while finding completion candidates
53 | [x]Multiple 3rd party classes found in various packages. Not a chance no more.
54 | [x]Obj a1; a1.-> completion doesn't work before it is instantiated. Look into that. Began working again by itself. Yay!
55 | [x]Cursor positioning should be after the first ( if arguments present, else after ()
56 | [x]Display the type of Completion(method return type, variable type) in the popup.
57 | - facing some issues for local types. Fixed.
58 | [x]Sorted list of completion candidates - fields, then methods. It's unsorted presently.
59 | [x]Reflection API - getMethods vs getDeclaredMethods. declared.
60 | [x]Need to add offset correction to ASTGenerator and its lookup methods. Or leave it for later? All set to implement
61 | [x]Completion List should get hidden on hitting esc key
62 |
63 | Offset Mapping
64 | ==============
65 |
66 | First major hurdle is offset mapping
67 | *! pde<->java code offset : precise conversion needed
68 | [ ]W.r.t PDE specific enhancements, things are almost working. There are some offset issues when multiple pde statements are in the same line, but I guess it's good enough for now to proceed ahead. Will keep a close watch for potential bugs.
69 | [x]for the above, I've decide to first implement a sketch outline like feature, which would highlight an AST element precisely in the pde code. This would ensure I've got the mapping working properly. And may lead to a future feature.
70 | [x]This is precise upto a certain line. Once on a line, pde stuff have to be taken into consideration.
71 | [x]Edge case - multiple statements in a single line
72 | [x]PDE specific enhancements will also have to be tackled like int(), # literals. The length of the node returned needs to be modified to make up for extra chars added like PApplet.parseFloat, etc. Also the 2nd or futher pde enhancements in the same line means even the beginning offset would need adjustment. Meh.
73 |
74 | Refactoring
75 | ===========
76 |
77 | [ ]Undo misbehaves here, handle carefully.
78 | [ ]Fails to rename the first defined global variable, if a javadoc comment precedes it. But owrds for single/multiline comments. Wth!
79 | [x]New Name is validated.
80 | [x]Ordered list in 'Show Usage' window
81 | [x]Add support for word select on right click and rename, mouse co-ordinates need to obtained carefully
82 |
83 | Refactoring would work only when code is compiler error free. I plan to do a find replace type op on the compile ready code.
84 | 1. First identify the declaration of the variable in the AST. We'll then make a list of all its occurrences.
85 | 2. DFS through the AST, for each (SimpleName)instance of the word in code, find if the matched word is the same one whose declaration we found.
86 | [x]Edge Case: For renaming a TypeDeclaration, the declaration of SimpleName instance of the TD and it's constructor(s) aren't added to the list generated by DFS. So for renaming TD, will have to manually add the TD SimpleName and it's constructors' SimpleNames to the a list of declaration nodes that can be positively matched against.
87 | [x]Renaming any constructor is equivalent to renaming the TD
88 | 3. Find corresponding PDE offsets of the SimpleNames, rename in each line.
89 | [x]Edge Case: Need to take displaced offsets on a line, due to pde enhancements, into consideration.
90 | 4. All the changes in code would be made in a separate copy of the code(?). After all the renaming is done, allow it only if the new code compiles. Basically an undo should be possible in case of conflicts.
91 | [x]Refactoring ui
92 | [x]For now, user needs to highlight the name of the var, and then right-click -> Rename..
93 | [x]Handle saving. If sketch closed after renaming w/o saving find bugs. Done, marking the sketch as modified after renaming.
94 |
95 | Quick Navigation
96 | ================
97 |
98 | *+ A silly bug where the name of the first field declaration isn't highlighted correctly. Seems to be happening if there's a javadoc or multiline comment near about the top.
99 |
100 | [x]On OS X, Ctrl + Click is right mouse click, so implement Cmd + Click instead. isMetaDown()?
101 | [x]Ctrl + Click on an element to scroll to its definition in code
102 | [x]Local Vars
103 | [x]Local Methods
104 | [x]Local Classes
105 | [x]Recursive lookup, a.b().c()
106 | [x]Now highlihgting the declaration name, rather than the whole declaration.
107 |
108 | Sketch Outline
109 | ==============
110 |
111 | [x]Show Sketch Outline Tree
112 | [x]Filter stuff in text field
113 | [x]Add icons - custom cell renderer
114 |
115 | Suggestion for missing imports
116 | ==============================
117 |
118 | [ ]Find a more subtle way to suggest for imports. The current method is too troublesome. Randomly pops up offering suggestions. May intimidate beginners.
119 |
120 | 1. In compileCheck() in ECS, check if error message is of the type "__" cannot be resolved to a type.
121 | 2. Find the class name via astGen, and suggest import as a popup.
122 | [x]Barebones functionality done.
123 | [x]Add imports only to beginning of first tab.
124 | [x]Search within contributed libraries folder
125 | [x]Hide suggestion list before showing import suggestions
126 | [x]Search within code folder of sketch
127 |
128 | Labels for Java elements
129 | ========================
130 |
131 | [x]Working for local code
132 | [ ]Need to modify getASTNodeAt to also fetch the type for predefined classes.
133 | [ ]Labels for predefined class objects
134 | [ ]Chaining support for labels
135 |
136 | Synchronization
137 | ===============
138 |
139 | Gotta do it carefully between main thread, ECS Thread, and SwingWorker threads
140 | Fields that are concurrently accessed:
141 |
142 | ECS members:
143 | [x]ArrayList problems - updated in ECS, accessed by ErrorBar.update()
144 | [x]ArrayList classpathJars - updated in ECS, accessed by ASTGenerator.loadJars()
145 | [x]hasErrors, syntaxErrors - Atomic Boolean
146 | [x]boolean warningsEnabled - made it volatile
147 | [ ]CompilationUnit cu - updated in ECS, accessed a zillion times in ASTGenerator :'(
148 |
149 |
150 | General Stuff
151 | =============
152 |
153 | [ ][Critical] PermGen out of memory bug. Manually triggering GC after making the classloader null ensures permgen memory is reclaimed on editor exit. Max open window still limited by max permgen size. Also, added a classloadcounter in ECS to trigger GC periodically.
154 | https://github.com/processing/processing-experimental/issues/1
155 | See: http://stackoverflow.com/questions/2095974/how-to-unload-a-already-loaded-class-in-java
156 | I'm making the classLoader null, but what about the classes loaded by ASTGen? Investigate.
157 | [x]Disabling Error Checking disables predictions as well! Fixed.
158 | [x]Added doc listener for text area updates
159 | [x]Consult Ben on where to save preferences - main preferences.txt or custom one. - Main prefs file
160 | [x]Save preferences to main preference.txt
161 | [x]Hide breakpoint markers when Debugger isn't active
162 | [x]Ensure gutter mouse handler is taken care of when hiding Debugger breakpoint bar.
163 | [x]Ensure all editor windows are closed when editor is closed.
164 | [x]Add a red marker near Errors label in console toggle, to indicate errors present in sketch.
165 | [x]Add option for toggling debug output
166 | [x]On Run/Debug Console is visible(ProblemsList hidden)
167 | [ ]Update wiki for Ctrl + H instead of Ctrl + J shortcuts
168 | [x]update build.xml to produce dists
169 | [x]Make this a contributed mode - mode.txt, github releases feature, version numbering, git tags, etc
170 | [x]Add GitHub link to PDE X Menu
171 |
--------------------------------------------------------------------------------
/application/Info.plist.tmpl:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | English
7 | CFBundleExecutable
8 | @@sketch@@
9 | CFBundleIconFile
10 | sketch.icns
11 | CFBundleIdentifier
12 | @@sketch@@
13 | CFBundleDisplayName
14 | @@sketch@@
15 | CFBundleInfoDictionaryVersion
16 | 6.0
17 | CFBundleName
18 | @@sketch@@
19 | CFBundlePackageType
20 | APPL
21 |
22 |
23 | CFBundleShortVersionString
24 | 1
25 | CFBundleVersion
26 | 1
27 | CFBundleSignature
28 | ????
29 | NSHumanReadableCopyright
30 | Your copyright here
31 | CFBundleGetInfoString
32 | Created with Processing
33 |
34 |
35 | @@jvm_runtime@@
36 |
37 | JVMMainClassName
38 | @@sketch@@
39 |
40 | LSMinimumSystemVersion
41 | 10.7.3
42 |
43 | NSHighResolutionCapable
44 |
45 |
46 | LSArchitecturePriority
47 |
48 | x86_64
49 |
50 |
51 | LSEnvironment
52 |
53 | LC_CTYPE
54 | UTF-8
55 |
56 |
57 | LSUIPresentationMode
58 | @@lsuipresentationmode@@
59 |
60 | JVMOptions
61 |
62 | @@jvm_options_list@@
63 | -Xdock:icon=Contents/Resources/sketch.icns
64 | -Dapple.laf.useScreenMenuBar=true
65 | -Dcom.apple.macos.use-file-dialog-packages=true
66 | -Dcom.apple.macos.useScreenMenuBar=true
67 | -Dcom.apple.mrj.application.apple.menu.about.name=@@sketch@@
68 | -Dcom.apple.smallTabs=true
69 |
70 | JVMArguments
71 |
72 |
73 |
74 |
75 |
--------------------------------------------------------------------------------
/application/sketch.icns:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/processing/processing-experimental/2efe9b256724e1b13baf0f6e1b1074305d79ec47/application/sketch.icns
--------------------------------------------------------------------------------
/application/template.app/Contents/MacOS/JavaApplicationStub:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/processing/processing-experimental/2efe9b256724e1b13baf0f6e1b1074305d79ec47/application/template.app/Contents/MacOS/JavaApplicationStub
--------------------------------------------------------------------------------
/application/template.app/Contents/PkgInfo:
--------------------------------------------------------------------------------
1 | APPL????
--------------------------------------------------------------------------------
/application/template.app/Contents/Resources/sketch.icns:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/processing/processing-experimental/2efe9b256724e1b13baf0f6e1b1074305d79ec47/application/template.app/Contents/Resources/sketch.icns
--------------------------------------------------------------------------------
/application/template.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/processing/processing-experimental/2efe9b256724e1b13baf0f6e1b1074305d79ec47/application/template.exe
--------------------------------------------------------------------------------
/application/template.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleName
6 | @@sketch@@
7 | CFBundleVersion
8 | 1.0
9 | CFBundleAllowMixedLocalizations
10 | true
11 | CFBundleExecutable
12 | JavaApplicationStub
13 | CFBundleDevelopmentRegion
14 | English
15 | CFBundlePackageType
16 | APPL
17 | CFBundleSignature
18 | ????
19 | CFBundleInfoDictionaryVersion
20 | 6.0
21 | CFBundleIconFile
22 | sketch.icns
23 | CFBundleIdentifier
24 | @@sketch@@
25 |
26 |
27 | LSUIPresentationMode
28 | @@lsuipresentationmode@@
29 |
30 | LSArchitecturePriority
31 |
32 | @@lsarchitecturepriority@@
33 |
34 |
35 | Java
36 |
37 | VMOptions
38 | @@vmoptions@@
39 |
40 | MainClass
41 | @@sketch@@
42 |
43 |
45 | JVMVersion
46 | 1.6*
47 |
48 | ClassPath
49 | @@classpath@@
50 |
51 |
52 | Properties
53 |
54 | apple.laf.useScreenMenuBar
55 | true
56 | apple.awt.showGrowBox
57 | false
58 | com.apple.smallTabs
59 | true
60 | apple.awt.Antialiasing
61 | false
62 | apple.awt.TextAntialiasing
63 | true
64 | com.apple.hwaccel
65 | true
66 |
72 | apple.awt.use-file-dialog-packages
73 | true
74 |
75 |
76 |
77 |
78 |
--------------------------------------------------------------------------------
/build.properties:
--------------------------------------------------------------------------------
1 | sketchbook.location=${user.home}/Documents/Processing
2 | classpath.local.location=${user.home}/Documents/workspace/libs
3 | core.library.location=/home/quarkninja/Workspaces/processing-workspace/processing/app/core/library
4 | app.library.location=/home/quarkninja/Workspaces/processing-workspace/processing/app/
5 | java.target.version=1.7
6 | lib.name=ExperimentalMode
7 | prettyName=PDE X
8 | dist=dist
9 | release=7
10 | prettyVersion=1.0.4b
11 |
--------------------------------------------------------------------------------
/build.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
--------------------------------------------------------------------------------
/data/icons/class_obj.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/processing/processing-experimental/2efe9b256724e1b13baf0f6e1b1074305d79ec47/data/icons/class_obj.png
--------------------------------------------------------------------------------
/data/icons/field_default_obj.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/processing/processing-experimental/2efe9b256724e1b13baf0f6e1b1074305d79ec47/data/icons/field_default_obj.png
--------------------------------------------------------------------------------
/data/icons/field_icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/processing/processing-experimental/2efe9b256724e1b13baf0f6e1b1074305d79ec47/data/icons/field_icon.png
--------------------------------------------------------------------------------
/data/icons/field_private_obj.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/processing/processing-experimental/2efe9b256724e1b13baf0f6e1b1074305d79ec47/data/icons/field_private_obj.png
--------------------------------------------------------------------------------
/data/icons/field_protected_obj.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/processing/processing-experimental/2efe9b256724e1b13baf0f6e1b1074305d79ec47/data/icons/field_protected_obj.png
--------------------------------------------------------------------------------
/data/icons/field_public_obj.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/processing/processing-experimental/2efe9b256724e1b13baf0f6e1b1074305d79ec47/data/icons/field_public_obj.png
--------------------------------------------------------------------------------
/data/icons/info_icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/processing/processing-experimental/2efe9b256724e1b13baf0f6e1b1074305d79ec47/data/icons/info_icon.png
--------------------------------------------------------------------------------
/data/icons/innerclass_private_obj.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/processing/processing-experimental/2efe9b256724e1b13baf0f6e1b1074305d79ec47/data/icons/innerclass_private_obj.png
--------------------------------------------------------------------------------
/data/icons/innerclass_protected_obj.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/processing/processing-experimental/2efe9b256724e1b13baf0f6e1b1074305d79ec47/data/icons/innerclass_protected_obj.png
--------------------------------------------------------------------------------
/data/icons/methdef_obj.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/processing/processing-experimental/2efe9b256724e1b13baf0f6e1b1074305d79ec47/data/icons/methdef_obj.png
--------------------------------------------------------------------------------
/data/icons/methpri_obj.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/processing/processing-experimental/2efe9b256724e1b13baf0f6e1b1074305d79ec47/data/icons/methpri_obj.png
--------------------------------------------------------------------------------
/data/icons/methpro_obj.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/processing/processing-experimental/2efe9b256724e1b13baf0f6e1b1074305d79ec47/data/icons/methpro_obj.png
--------------------------------------------------------------------------------
/data/icons/methpub_obj.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/processing/processing-experimental/2efe9b256724e1b13baf0f6e1b1074305d79ec47/data/icons/methpub_obj.png
--------------------------------------------------------------------------------
/data/icons/refresh_icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/processing/processing-experimental/2efe9b256724e1b13baf0f6e1b1074305d79ec47/data/icons/refresh_icon.png
--------------------------------------------------------------------------------
/data/icons/sort_icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/processing/processing-experimental/2efe9b256724e1b13baf0f6e1b1074305d79ec47/data/icons/sort_icon.png
--------------------------------------------------------------------------------
/mode.properties:
--------------------------------------------------------------------------------
1 | name=PDE X
2 | authorList=[The Processing Foundation](http://processing.org)
3 | url=https://github.com/processing/processing-experimental
4 | sentence=The next generation of PDE
5 | paragraph=Intelligent Code Completion, Quick Navigation, Refactoring, Live Error Checker, Debugger, etc.
6 | version=@@version@@
7 | prettyVersion=@@pretty-version@@
8 |
--------------------------------------------------------------------------------
/mode/.gitignore:
--------------------------------------------------------------------------------
1 | experimental.jar
2 |
--------------------------------------------------------------------------------
/mode/CompilationChecker.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/processing/processing-experimental/2efe9b256724e1b13baf0f6e1b1074305d79ec47/mode/CompilationChecker.jar
--------------------------------------------------------------------------------
/mode/classpath-explorer-1.0.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/processing/processing-experimental/2efe9b256724e1b13baf0f6e1b1074305d79ec47/mode/classpath-explorer-1.0.jar
--------------------------------------------------------------------------------
/mode/com.ibm.icu_4.4.2.v20110823.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/processing/processing-experimental/2efe9b256724e1b13baf0f6e1b1074305d79ec47/mode/com.ibm.icu_4.4.2.v20110823.jar
--------------------------------------------------------------------------------
/mode/jdi-src.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/processing/processing-experimental/2efe9b256724e1b13baf0f6e1b1074305d79ec47/mode/jdi-src.zip
--------------------------------------------------------------------------------
/mode/jdi.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/processing/processing-experimental/2efe9b256724e1b13baf0f6e1b1074305d79ec47/mode/jdi.jar
--------------------------------------------------------------------------------
/mode/jdimodel-src.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/processing/processing-experimental/2efe9b256724e1b13baf0f6e1b1074305d79ec47/mode/jdimodel-src.zip
--------------------------------------------------------------------------------
/mode/jdimodel.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/processing/processing-experimental/2efe9b256724e1b13baf0f6e1b1074305d79ec47/mode/jdimodel.jar
--------------------------------------------------------------------------------
/mode/jsoup-1.7.1-javadoc.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/processing/processing-experimental/2efe9b256724e1b13baf0f6e1b1074305d79ec47/mode/jsoup-1.7.1-javadoc.jar
--------------------------------------------------------------------------------
/mode/jsoup-1.7.1.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/processing/processing-experimental/2efe9b256724e1b13baf0f6e1b1074305d79ec47/mode/jsoup-1.7.1.jar
--------------------------------------------------------------------------------
/mode/org.eclipse.core.contenttype_3.4.200.v20120523-2004.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/processing/processing-experimental/2efe9b256724e1b13baf0f6e1b1074305d79ec47/mode/org.eclipse.core.contenttype_3.4.200.v20120523-2004.jar
--------------------------------------------------------------------------------
/mode/org.eclipse.core.jobs_3.5.300.v20120622-204750.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/processing/processing-experimental/2efe9b256724e1b13baf0f6e1b1074305d79ec47/mode/org.eclipse.core.jobs_3.5.300.v20120622-204750.jar
--------------------------------------------------------------------------------
/mode/org.eclipse.core.resources_3.8.1.v20120802-154922.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/processing/processing-experimental/2efe9b256724e1b13baf0f6e1b1074305d79ec47/mode/org.eclipse.core.resources_3.8.1.v20120802-154922.jar
--------------------------------------------------------------------------------
/mode/org.eclipse.core.runtime_3.8.0.v20120521-2346.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/processing/processing-experimental/2efe9b256724e1b13baf0f6e1b1074305d79ec47/mode/org.eclipse.core.runtime_3.8.0.v20120521-2346.jar
--------------------------------------------------------------------------------
/mode/org.eclipse.equinox.common_3.6.100.v20120522-1841.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/processing/processing-experimental/2efe9b256724e1b13baf0f6e1b1074305d79ec47/mode/org.eclipse.equinox.common_3.6.100.v20120522-1841.jar
--------------------------------------------------------------------------------
/mode/org.eclipse.equinox.preferences_3.5.0.v20120522-1841.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/processing/processing-experimental/2efe9b256724e1b13baf0f6e1b1074305d79ec47/mode/org.eclipse.equinox.preferences_3.5.0.v20120522-1841.jar
--------------------------------------------------------------------------------
/mode/org.eclipse.jdt.core_3.8.2.v20120814-155456.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/processing/processing-experimental/2efe9b256724e1b13baf0f6e1b1074305d79ec47/mode/org.eclipse.jdt.core_3.8.2.v20120814-155456.jar
--------------------------------------------------------------------------------
/mode/org.eclipse.jdt.debug_3.7.101.v20120725-115645.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/processing/processing-experimental/2efe9b256724e1b13baf0f6e1b1074305d79ec47/mode/org.eclipse.jdt.debug_3.7.101.v20120725-115645.jar
--------------------------------------------------------------------------------
/mode/org.eclipse.osgi_3.8.1.v20120830-144521.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/processing/processing-experimental/2efe9b256724e1b13baf0f6e1b1074305d79ec47/mode/org.eclipse.osgi_3.8.1.v20120830-144521.jar
--------------------------------------------------------------------------------
/mode/org.eclipse.text_3.5.200.v20120523-1310.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/processing/processing-experimental/2efe9b256724e1b13baf0f6e1b1074305d79ec47/mode/org.eclipse.text_3.5.200.v20120523-1310.jar
--------------------------------------------------------------------------------
/mode/readme.txt:
--------------------------------------------------------------------------------
1 | Packages from Eclipse 4.2.1:
2 | http://download.eclipse.org/eclipse/downloads/
3 |
4 | The jdi.jar and jdimodel.jar files are unpacked
5 | from the org.eclipse.jdt.debug JAR file.
6 |
--------------------------------------------------------------------------------
/pdeX.txt:
--------------------------------------------------------------------------------
1 | name=PDE X
2 | authorList=[The Processing Foundation](http://processing.org)
3 | url=https://github.com/processing/processing-experimental
4 | sentence=The next generation of PDE
5 | paragraph=Intelligent Code Completion, Live Error Checker, Debugger, Auto Refactor, etc.
6 | version=7
7 | prettyVersion=1.0.4b
8 |
--------------------------------------------------------------------------------
/revisions.txt:
--------------------------------------------------------------------------------
1 |
2 | PDE X v1.0.4b - May 9, 2014
3 |
4 | Requires Processing 2.1.2 or above.
5 |
6 | Bug fixes
7 |
8 | + Disabled auto-save. My sincere apologies to those who lost data due
9 | to this bug. It was wrong of me to release an untested feature without
10 | adding an option to enable/disable it. I've learnt a lesson and I shall
11 | ensure this sort of thing doesn't happen again in the future.
12 |
13 | + Autocompletion bug, column is sometimes off by 1
14 | https://github.com/processing/processing-experimental/issues/38
15 |
16 | + Persistent completion dialog on OS X
17 | https://github.com/processing/processing-experimental/issues/32
18 |
19 | + Status bar update bug
20 | https://github.com/processing/processing-experimental/issues/29
21 |
22 | + Export application broken
23 | https://github.com/processing/processing-experimental/issues/45
24 |
25 | + Status Bar - New Tab prompt bug
26 | https://github.com/processing/processing-experimental/issues/53
27 |
28 | + Show usage fails for methods which have javadoc comment
29 | https://github.com/processing/processing-experimental/issues/51
30 |
31 | . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
32 |
33 | PDE X v1.0.3b - January 21, 2014
34 |
35 | New Feature
36 |
37 | + PDE X now saves a backup of your sketch every 3 minutes(configurable in preferences.txt).
38 | In case of an unexpected crash, this should save the day!
39 | https://github.com/processing/processing-experimental/issues/36
40 |
41 | Bug fixes
42 |
43 | + Outline Window width is now fixed
44 | https://github.com/processing/processing-experimental/issues/31
45 |
46 | + Export Application works again on OS X
47 | https://github.com/processing/processing-experimental/issues/33
48 |
49 | . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
50 |
51 | PDE X v1.0.2b - October 21, 2013
52 |
53 | Bug fixes
54 |
55 | + Code completion window gets stuck when Processing loses focus
56 | https://github.com/processing/processing-experimental/issues/21
57 |
58 | + Live-error checker is more efficient with memory now.
59 | You can have upto 7 editor windows open at a time with PDE X.
60 | https://github.com/processing/processing-experimental/issues/1
61 |
62 | + Cmd + Left Click should be working again in OS X with Processing 2.1
63 | https://github.com/processing/processing-experimental/issues/11
64 |
65 | + TextAreaPainter updated for Processing 2.1
66 |
67 | . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
68 |
69 | PDE X v1.0.1b - 25 September, 2013
70 |
71 | Bug fix
72 |
73 | + Fixed a major issue where completion list was going blank.
74 | https://github.com/processing/processing-experimental/issues/19
75 |
76 | Changes
77 |
78 | - Removed the tiny markers shown at the start of error lines. Too. Much. Red.
79 |
80 | . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
81 |
82 | PDE X v1.0.0b - 22 September, 2013
83 |
84 | Boom! First Public Beta Release!
85 |
86 |
--------------------------------------------------------------------------------
/src/processing/mode/experimental/ArrayFieldNode.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2012 Martin Leopold
3 | *
4 | * This program is free software; you can redistribute it and/or
5 | * modify it under the terms of the GNU General Public License
6 | * as published by the Free Software Foundation; either version 2
7 | * of the License, or (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program; if not, write to the Free Software
16 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 | */
18 | package processing.mode.experimental;
19 |
20 | import com.sun.jdi.ArrayReference;
21 | import com.sun.jdi.ClassNotLoadedException;
22 | import com.sun.jdi.InvalidTypeException;
23 | import com.sun.jdi.Value;
24 | import java.util.logging.Level;
25 | import java.util.logging.Logger;
26 |
27 | /**
28 | * Specialized {@link VariableNode} for representing single fields in an array.
29 | * Overrides {@link #setValue} to properly change the value of the encapsulated
30 | * array field.
31 | *
32 | * @author Martin Leopold
33 | */
34 | public class ArrayFieldNode extends VariableNode {
35 |
36 | protected ArrayReference array;
37 | protected int index;
38 |
39 | /**
40 | * Construct an {@link ArrayFieldNode}.
41 | *
42 | * @param name the name
43 | * @param type the type
44 | * @param value the value
45 | * @param array a reference to the array
46 | * @param index the index inside the array
47 | */
48 | public ArrayFieldNode(String name, String type, Value value, ArrayReference array, int index) {
49 | super(name, type, value);
50 | this.array = array;
51 | this.index = index;
52 | }
53 |
54 | @Override
55 | public void setValue(Value value) {
56 | try {
57 | array.setValue(index, value);
58 | } catch (InvalidTypeException ex) {
59 | Logger.getLogger(ArrayFieldNode.class.getName()).log(Level.SEVERE, null, ex);
60 | } catch (ClassNotLoadedException ex) {
61 | Logger.getLogger(ArrayFieldNode.class.getName()).log(Level.SEVERE, null, ex);
62 | }
63 | this.value = value;
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/src/processing/mode/experimental/AutoSaveUtil.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2012-14 Manindra Moharana
3 | *
4 | * This program is free software; you can redistribute it and/or modify it under
5 | * the terms of the GNU General Public License as published by the Free Software
6 | * Foundation; either version 2 of the License, or (at your option) any later
7 | * version.
8 | *
9 | * This program is distributed in the hope that it will be useful, but WITHOUT
10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
12 | * details.
13 | *
14 | * You should have received a copy of the GNU General Public License along with
15 | * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
16 | * Place - Suite 330, Boston, MA 02111-1307, USA.
17 | */
18 |
19 | package processing.mode.experimental;
20 |
21 | import java.io.File;
22 | import java.io.FileFilter;
23 | import java.io.IOException;
24 | import java.util.Timer;
25 | import java.util.TimerTask;
26 |
27 | import processing.app.Base;
28 | import processing.app.Sketch;
29 |
30 | import static processing.mode.experimental.ExperimentalMode.log;
31 |
32 | /**
33 | * Autosave utility for saving sketch backups in the background after
34 | * certain intervals
35 | *
36 | * @author Manindra Moharana
37 | *
38 | */
39 | public class AutoSaveUtil {
40 |
41 | private DebugEditor editor;
42 |
43 | private Timer timer;
44 |
45 | private int saveTime;
46 |
47 | private File autosaveDir, pastSave;
48 |
49 | private boolean isSaving;
50 |
51 | private boolean isAutoSaveBackup;
52 |
53 | private File sketchFolder, sketchBackupFolder;
54 |
55 | private static final String AUTOSAVEFOLDER = "__autosave__";
56 |
57 | /**
58 | *
59 | * @param dedit
60 | * @param timeOut - in minutes, how frequently should saves occur
61 | */
62 | public AutoSaveUtil(DebugEditor dedit, int timeOut){
63 | /*
64 | editor = dedit;
65 | if (timeOut < 1) { // less than 1 minute not allowed!
66 | saveTime = -1;
67 | throw new IllegalArgumentException("");
68 | }
69 | else{
70 | saveTime = timeOut * 60 * 1000;
71 | log("AutoSaver Interval(mins): " + timeOut);
72 | }
73 | checkIfBackup();
74 | if(isAutoSaveBackup){
75 | sketchBackupFolder = sketchFolder;
76 | }
77 | else{
78 | autosaveDir = new File(editor.getSketch().getFolder().getAbsolutePath() + File.separator + AUTOSAVEFOLDER);
79 | sketchFolder = editor.getSketch().getFolder();
80 | sketchBackupFolder = autosaveDir;
81 | }*/
82 | }
83 |
84 | /**
85 | * If the sketch path looks like ../__autosave__/../FooSketch
86 | * then assume this is a backup sketch
87 | */
88 | private void checkIfBackup(){
89 | File parent = sketchFolder.getParentFile().getParentFile();
90 | if(parent.isDirectory() && parent.getName().equals(AUTOSAVEFOLDER)){
91 | isAutoSaveBackup = true;
92 | log("IS AUTOSAVE " + sketchFolder.getAbsolutePath());
93 | }
94 | }
95 |
96 | public File getActualSketchFolder(){
97 | if(isAutoSaveBackup)
98 | return sketchFolder.getParentFile().getParentFile().getParentFile();
99 | else
100 | return sketchFolder;
101 | }
102 |
103 | public boolean isAutoSaveBackup() {
104 | return isAutoSaveBackup;
105 | }
106 |
107 | /**
108 | * Check if any previous autosave exists
109 | * @return
110 | */
111 | public boolean checkForPastSave(){
112 | if(autosaveDir.exists()){
113 | String prevSaves[] = Base.listFiles(autosaveDir, false);
114 | if(prevSaves.length > 0){
115 | File t = new File(Base.listFiles(new File(prevSaves[0]), false)[0]);
116 | sketchBackupFolder = t;
117 | pastSave = new File(t.getAbsolutePath() + File.separator + t.getName() + ".pde");
118 | if(pastSave.exists())
119 | return true;
120 | }
121 | }
122 | return false;
123 | }
124 |
125 | /**
126 | * Refresh autosave directory if current sketch location in the editor changes
127 | */
128 | public void reloadAutosaveDir(){
129 | while(isSaving);
130 | autosaveDir = new File(editor.getSketch().getFolder().getAbsolutePath() + File.separator + AUTOSAVEFOLDER);
131 | }
132 |
133 | public File getAutoSaveDir(){
134 | return autosaveDir;
135 | }
136 |
137 | /**
138 | * The folder of the original sketch
139 | * @return
140 | */
141 | public File getSketchFolder(){
142 | return sketchFolder;
143 | }
144 |
145 | public File getSketchBackupFolder(){
146 | return sketchBackupFolder;
147 | }
148 |
149 | public File getPastSave(){
150 | return pastSave;
151 | }
152 |
153 | /**
154 | * Start the auto save service
155 | */
156 | public void init(){
157 | /*
158 | if(isAutoSaveBackup) {
159 | log("AutoSaver not started");
160 | return;
161 | }
162 | if(saveTime < 10000) saveTime = 10 * 1000;
163 | saveTime = 5 * 1000; //TODO: remove
164 | timer = new Timer();
165 | timer.schedule(new SaveTask(), saveTime, saveTime);
166 | isSaving = false;
167 | log("AutoSaver started");
168 | */
169 | }
170 |
171 | /**
172 | * Stop the autosave service
173 | */
174 | public void stop(){
175 | while(isSaving); // save operation mustn't be interrupted
176 | if(timer != null) timer.cancel();
177 | Base.removeDir(autosaveDir);
178 | ExperimentalMode.log("Stopping autosaver and deleting backup dir");
179 | }
180 |
181 | /**
182 | * Main function that performs the save operation
183 | * Code reused from processing.app.Sketch.saveAs()
184 | * @return
185 | * @throws IOException
186 | */
187 | private boolean saveSketch() throws IOException{
188 | if(!editor.getSketch().isModified()) return false;
189 | isSaving = true;
190 | Sketch sc = editor.getSketch();
191 |
192 | boolean deleteOldSave = false;
193 | String oldSave = null;
194 | if(!autosaveDir.exists()){
195 | autosaveDir = new File(sc.getFolder().getAbsolutePath(), AUTOSAVEFOLDER);
196 | autosaveDir.mkdir();
197 | }
198 | else
199 | {
200 | // delete the previous backup after saving current one.
201 | String prevSaves[] = Base.listFiles(autosaveDir, false);
202 | if(prevSaves.length > 0){
203 | deleteOldSave = true;
204 | oldSave = prevSaves[0];
205 | }
206 | }
207 | String newParentDir = autosaveDir + File.separator + System.currentTimeMillis();
208 | String newName = sc.getName();
209 |
210 |
211 | // check on the sanity of the name
212 | String sanitaryName = Sketch.checkName(newName);
213 | File newFolder = new File(newParentDir, sanitaryName);
214 | if (!sanitaryName.equals(newName) && newFolder.exists()) {
215 | Base.showMessage("Cannot Save",
216 | "A sketch with the cleaned name\n" +
217 | "“" + sanitaryName + "” already exists.");
218 | isSaving = false;
219 | return false;
220 | }
221 | newName = sanitaryName;
222 |
223 | // String newPath = newFolder.getAbsolutePath();
224 | // String oldPath = folder.getAbsolutePath();
225 |
226 | // if (newPath.equals(oldPath)) {
227 | // return false; // Can't save a sketch over itself
228 | // }
229 |
230 | // make sure there doesn't exist a tab with that name already
231 | // but ignore this situation for the first tab, since it's probably being
232 | // resaved (with the same name) to another location/folder.
233 | for (int i = 1; i < sc.getCodeCount(); i++) {
234 | if (newName.equalsIgnoreCase(sc.getCode()[i].getPrettyName())) {
235 | Base.showMessage("Nope",
236 | "You can't save the sketch as \"" + newName + "\"\n" +
237 | "because the sketch already has a tab with that name.");
238 | isSaving = false;
239 | return false;
240 | }
241 | }
242 |
243 |
244 |
245 | // if the new folder already exists, then first remove its contents before
246 | // copying everything over (user will have already been warned).
247 | if (newFolder.exists()) {
248 | Base.removeDir(newFolder);
249 | }
250 | // in fact, you can't do this on Windows because the file dialog
251 | // will instead put you inside the folder, but it happens on OS X a lot.
252 |
253 | // now make a fresh copy of the folder
254 | newFolder.mkdirs();
255 |
256 | // grab the contents of the current tab before saving
257 | // first get the contents of the editor text area
258 | if (sc.getCurrentCode().isModified()) {
259 | sc.getCurrentCode().setProgram(editor.getText());
260 | }
261 |
262 | File[] copyItems = sc.getFolder().listFiles(new FileFilter() {
263 | public boolean accept(File file) {
264 | String name = file.getName();
265 | // just in case the OS likes to return these as if they're legit
266 | if (name.equals(".") || name.equals("..")) {
267 | return false;
268 | }
269 | // list of files/folders to be ignored during "save as"
270 | for (String ignorable : editor.getMode().getIgnorable()) {
271 | if (name.equals(ignorable)) {
272 | return false;
273 | }
274 | }
275 | // ignore the extensions for code, since that'll be copied below
276 | for (String ext : editor.getMode().getExtensions()) {
277 | if (name.endsWith(ext)) {
278 | return false;
279 | }
280 | }
281 | // don't do screen captures, since there might be thousands. kind of
282 | // a hack, but seems harmless. hm, where have i heard that before...
283 | if (name.startsWith("screen-")) {
284 | return false;
285 | }
286 | return true;
287 | }
288 | });
289 | // now copy over the items that make sense
290 | for (File copyable : copyItems) {
291 | if (copyable.isDirectory()) {
292 | Base.copyDir(copyable, new File(newFolder, copyable.getName()));
293 | } else {
294 | Base.copyFile(copyable, new File(newFolder, copyable.getName()));
295 | }
296 | }
297 |
298 | // save the other tabs to their new location
299 | for (int i = 1; i < sc.getCodeCount(); i++) {
300 | File newFile = new File(newFolder, sc.getCode()[i].getFileName());
301 | sc.getCode()[i].saveAs(newFile);
302 | }
303 |
304 | // While the old path to the main .pde is still set, remove the entry from
305 | // the Recent menu so that it's not sticking around after the rename.
306 | // If untitled, it won't be in the menu, so there's no point.
307 | // if (!isUntitled()) {
308 | // editor.removeRecent();
309 | // }
310 |
311 | // save the main tab with its new name
312 | File newFile = new File(newFolder, newName + ".pde");
313 | sc.getCode()[0].saveAs(newFile);
314 |
315 | // updateInternal(newName, newFolder);
316 | //
317 | // // Make sure that it's not an untitled sketch
318 | // setUntitled(false);
319 | //
320 | // // Add this sketch back using the new name
321 | // editor.addRecent();
322 |
323 | // let Editor know that the save was successful
324 |
325 | if(deleteOldSave){
326 | Base.removeDir(new File(oldSave));
327 | }
328 | isSaving = false;
329 | return true;
330 | }
331 |
332 | /**
333 | * Timertask used to perform the save operation every X minutes
334 | * @author quarkninja
335 | *
336 | */
337 | private class SaveTask extends TimerTask{
338 |
339 | @Override
340 | public void run() {
341 | try {
342 | if(saveSketch())
343 | ExperimentalMode.log("Backup Saved " + editor.getSketch().getMainFilePath());
344 | } catch (IOException e) {
345 | e.printStackTrace();
346 | }
347 |
348 | }
349 |
350 | }
351 |
352 | }
353 |
--------------------------------------------------------------------------------
/src/processing/mode/experimental/ClassLoadListener.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2012 Martin Leopold
3 | *
4 | * This program is free software; you can redistribute it and/or
5 | * modify it under the terms of the GNU General Public License
6 | * as published by the Free Software Foundation; either version 2
7 | * of the License, or (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program; if not, write to the Free Software
16 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 | */
18 | package processing.mode.experimental;
19 |
20 | import com.sun.jdi.ReferenceType;
21 |
22 | /**
23 | * Listener to be notified when a class is loaded in the debugger. Used by
24 | * {@link LineBreakpoint}s to activate themselves as soon as the respective
25 | * class is loaded.
26 | *
27 | * @author Martin Leopold
28 | */
29 | public interface ClassLoadListener {
30 |
31 | /**
32 | * Event handler called when a class is loaded.
33 | *
34 | * @param theClass the class
35 | */
36 | public void classLoaded(ReferenceType theClass);
37 | }
38 |
--------------------------------------------------------------------------------
/src/processing/mode/experimental/CompletionCandidate.java:
--------------------------------------------------------------------------------
1 | package processing.mode.experimental;
2 | import static processing.mode.experimental.ExperimentalMode.log;
3 | import java.lang.reflect.Field;
4 | import java.lang.reflect.Method;
5 | import java.util.List;
6 |
7 | import org.eclipse.jdt.core.dom.ASTNode;
8 | import org.eclipse.jdt.core.dom.FieldDeclaration;
9 | import org.eclipse.jdt.core.dom.MethodDeclaration;
10 | import org.eclipse.jdt.core.dom.SingleVariableDeclaration;
11 | import org.eclipse.jdt.core.dom.TypeDeclaration;
12 | import org.eclipse.jdt.core.dom.VariableDeclarationFragment;
13 |
14 | public class CompletionCandidate implements Comparable{
15 |
16 | private String elementName; //
17 |
18 | private String label; // the toString value
19 |
20 | private String completionString;
21 |
22 | private Object wrappedObject;
23 |
24 | private int type;
25 |
26 | public static final int PREDEF_CLASS = 0, PREDEF_FIELD = 1,
27 | PREDEF_METHOD = 2, LOCAL_CLASS = 3, LOCAL_METHOD = 4, LOCAL_FIELD = 5,
28 | LOCAL_VAR = 6;
29 |
30 | public CompletionCandidate(Method method) {
31 | method.getDeclaringClass().getName();
32 | elementName = method.getName();
33 | StringBuffer label = new StringBuffer(method.getName() + "(");
34 | StringBuffer cstr = new StringBuffer(method.getName() + "(");
35 | for (int i = 0; i < method.getParameterTypes().length; i++) {
36 | label.append(method.getParameterTypes()[i].getSimpleName());
37 | if (i < method.getParameterTypes().length - 1) {
38 | label.append(",");
39 | cstr.append(",");
40 | }
41 | }
42 | if(method.getParameterTypes().length == 1) {
43 | cstr.append(' ');
44 | }
45 | label.append(")");
46 | if(method.getReturnType() != null)
47 | label.append(" : " + method.getReturnType().getSimpleName());
48 | label.append(" - " + method.getDeclaringClass().getSimpleName());
49 | cstr.append(")");
50 | this.label = label.toString();
51 | this.completionString = cstr.toString();
52 | type = PREDEF_METHOD;
53 | wrappedObject = method;
54 | }
55 |
56 | public Object getWrappedObject() {
57 | return wrappedObject;
58 | }
59 |
60 | public CompletionCandidate(SingleVariableDeclaration svd) {
61 | completionString = svd.getName().toString();
62 | elementName = svd.getName().toString();
63 | if(svd.getParent() instanceof FieldDeclaration)
64 | type = LOCAL_FIELD;
65 | else
66 | type = LOCAL_VAR;
67 | label = svd.getName() + " : " + svd.getType();
68 | }
69 |
70 | public CompletionCandidate(VariableDeclarationFragment vdf) {
71 | completionString = vdf.getName().toString();
72 | elementName = vdf.getName().toString();
73 | if(vdf.getParent() instanceof FieldDeclaration)
74 | type = LOCAL_FIELD;
75 | else
76 | type = LOCAL_VAR;
77 | label = vdf.getName() + " : " + ASTGenerator.extracTypeInfo2(vdf);
78 | }
79 |
80 | public CompletionCandidate(MethodDeclaration method) {
81 | // log("ComCan " + method.getName());
82 | elementName = method.getName().toString();
83 | type = LOCAL_METHOD;
84 | List params = (List) method
85 | .getStructuralProperty(MethodDeclaration.PARAMETERS_PROPERTY);
86 | StringBuffer label = new StringBuffer(elementName + "(");
87 | StringBuffer cstr = new StringBuffer(method.getName() + "(");
88 | for (int i = 0; i < params.size(); i++) {
89 | label.append(params.get(i).toString());
90 | if (i < params.size() - 1) {
91 | label.append(",");
92 | cstr.append(",");
93 | }
94 | }
95 | if (params.size() == 1) {
96 | cstr.append(' ');
97 | }
98 | label.append(")");
99 | if (method.getReturnType2() != null)
100 | label.append(" : " + method.getReturnType2());
101 | cstr.append(")");
102 | this.label = label.toString();
103 | this.completionString = cstr.toString();
104 | }
105 |
106 | public CompletionCandidate(TypeDeclaration td){
107 | type = LOCAL_CLASS;
108 | elementName = td.getName().toString();
109 | label = elementName;
110 | completionString = elementName;
111 | }
112 |
113 | public CompletionCandidate(Field f) {
114 | f.getDeclaringClass().getName();
115 | elementName = f.getName();
116 | type = PREDEF_FIELD;
117 | label = f.getName() + " : " + f.getType().getSimpleName()
118 | + " - " + f.getDeclaringClass().getSimpleName();
119 | completionString = elementName;
120 | wrappedObject = f;
121 | }
122 |
123 | public CompletionCandidate(String name, String labelStr, String completionStr, int type) {
124 | elementName = name;
125 | label = labelStr;
126 | completionString = completionStr;
127 | this.type = type;
128 | }
129 |
130 | public CompletionCandidate(String name, int type) {
131 | elementName = name;
132 | label = name;
133 | completionString = name;
134 | this.type = type;
135 | }
136 |
137 | public String getElementName() {
138 | return elementName;
139 | }
140 |
141 | public String getCompletionString() {
142 | return completionString;
143 | }
144 |
145 | public String toString() {
146 | return label;
147 | }
148 |
149 | public int getType() {
150 | return type;
151 | }
152 |
153 | public int compareTo(CompletionCandidate cc) {
154 | if(type != cc.getType()){
155 | return cc.getType() - type;
156 | }
157 | return (elementName.compareTo(cc.getElementName()));
158 | }
159 |
160 | }
161 |
--------------------------------------------------------------------------------
/src/processing/mode/experimental/DebugBuild.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2012 Martin Leopold
3 | *
4 | * This program is free software; you can redistribute it and/or modify it under
5 | * the terms of the GNU General Public License as published by the Free Software
6 | * Foundation; either version 2 of the License, or (at your option) any later
7 | * version.
8 | *
9 | * This program is distributed in the hope that it will be useful, but WITHOUT
10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
12 | * details.
13 | *
14 | * You should have received a copy of the GNU General Public License along with
15 | * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
16 | * Place - Suite 330, Boston, MA 02111-1307, USA.
17 | */
18 | package processing.mode.experimental;
19 |
20 | import java.io.File;
21 | import processing.app.Sketch;
22 | import processing.app.SketchException;
23 | import processing.mode.java.JavaBuild;
24 |
25 | /**
26 | * Copied from processing.mode.java.JavaBuild, just changed compiler.
27 | *
28 | * @author Martin Leopold
29 | */
30 | public class DebugBuild extends JavaBuild {
31 |
32 | public DebugBuild(Sketch sketch) {
33 | super(sketch);
34 | }
35 |
36 | /**
37 | * Preprocess and compile sketch. Copied from
38 | * processing.mode.java.JavaBuild, just changed compiler.
39 | *
40 | * @param srcFolder
41 | * @param binFolder
42 | * @param sizeWarning
43 | * @return main class name or null on compile failure
44 | * @throws SketchException
45 | */
46 | @Override
47 | public String build(File srcFolder, File binFolder, boolean sizeWarning) throws SketchException {
48 | this.srcFolder = srcFolder;
49 | this.binFolder = binFolder;
50 |
51 | // Base.openFolder(srcFolder);
52 | // Base.openFolder(binFolder);
53 |
54 | // run the preprocessor
55 | String classNameFound = preprocess(srcFolder, sizeWarning);
56 |
57 | // compile the program. errors will happen as a RunnerException
58 | // that will bubble up to whomever called build().
59 | // Compiler compiler = new Compiler(this);
60 | // String bootClasses = System.getProperty("sun.boot.class.path");
61 | // if (compiler.compile(this, srcFolder, binFolder, primaryClassName, getClassPath(), bootClasses)) {
62 |
63 | if (Compiler.compile(this)) { // use compiler with debug info enabled (-g switch flicked)
64 | sketchClassName = classNameFound;
65 | return classNameFound;
66 | }
67 | return null;
68 | }
69 |
70 | public ExperimentalMode getMode() {
71 | return (ExperimentalMode)mode;
72 | }
73 | }
74 |
--------------------------------------------------------------------------------
/src/processing/mode/experimental/DebugRunner.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2012 Martin Leopold
3 | *
4 | * This program is free software; you can redistribute it and/or modify it under
5 | * the terms of the GNU General Public License as published by the Free Software
6 | * Foundation; either version 2 of the License, or (at your option) any later
7 | * version.
8 | *
9 | * This program is distributed in the hope that it will be useful, but WITHOUT
10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
12 | * details.
13 | *
14 | * You should have received a copy of the GNU General Public License along with
15 | * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
16 | * Place - Suite 330, Boston, MA 02111-1307, USA.
17 | */
18 | package processing.mode.experimental;
19 |
20 | import com.sun.jdi.VirtualMachine;
21 | import processing.app.RunnerListener;
22 | import processing.app.SketchException;
23 | import processing.app.exec.StreamRedirectThread;
24 | import processing.mode.java.JavaBuild;
25 | import processing.mode.java.runner.MessageSiphon;
26 |
27 | /**
28 | * Runs a {@link JavaBuild}. Launches the build in a new debuggee VM.
29 | *
30 | * @author Martin Leopold
31 | */
32 | public class DebugRunner extends processing.mode.java.runner.Runner {
33 |
34 | // important inherited fields
35 | // protected VirtualMachine vm;
36 | public DebugRunner(JavaBuild build, RunnerListener listener) throws SketchException {
37 | super(build, listener);
38 | }
39 |
40 | /**
41 | * Launch the virtual machine. Simple non-blocking launch. VM starts
42 | * suspended.
43 | *
44 | * @return debuggee VM or null on failure
45 | */
46 | public VirtualMachine launch() {
47 | // String[] machineParamList = getMachineParams();
48 | // String[] sketchParamList = getSketchParams(false);
49 | // /*
50 | // * System.out.println("vm launch sketch params:"); for (int i=0;
51 | // * i
3 | *
4 | * This program is free software; you can redistribute it and/or modify it under
5 | * the terms of the GNU General Public License as published by the Free Software
6 | * Foundation; either version 2 of the License, or (at your option) any later
7 | * version.
8 | *
9 | * This program is distributed in the hope that it will be useful, but WITHOUT
10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
12 | * details.
13 | *
14 | * You should have received a copy of the GNU General Public License along with
15 | * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
16 | * Place - Suite 330, Boston, MA 02111-1307, USA.
17 | */
18 | package processing.mode.experimental;
19 |
20 | import java.awt.Graphics;
21 | import java.awt.Image;
22 | import java.awt.event.MouseEvent;
23 | import java.awt.image.BufferedImage;
24 | import java.util.logging.Level;
25 | import java.util.logging.Logger;
26 | import processing.app.Base;
27 | import processing.app.Editor;
28 | import processing.app.Preferences;
29 | import processing.app.Toolkit;
30 | import processing.mode.java.JavaToolbar;
31 |
32 | /**
33 | * Custom toolbar for the editor window. Preserves original button numbers
34 | * ({@link JavaToolbar#RUN}, {@link JavaToolbar#STOP}, {@link JavaToolbar#NEW},
35 | * {@link JavaToolbar#OPEN}, {@link JavaToolbar#SAVE}, {@link JavaToolbar#EXPORT})
36 | * which can be used e.g. in {@link #activate} and
37 | * {@link #deactivate}.
38 | *
39 | * @author Martin Leopold
40 | */
41 | public class DebugToolbar extends JavaToolbar {
42 | // preserve original button id's, but re-define so they are accessible
43 | // (they are used by DebugEditor, so they want to be public)
44 |
45 | static protected final int RUN = 100; // change this, to be able to get it's name via getTitle()
46 | static protected final int DEBUG = JavaToolbar.RUN;
47 |
48 | static protected final int CONTINUE = 101;
49 | static protected final int STEP = 102;
50 | static protected final int TOGGLE_BREAKPOINT = 103;
51 | static protected final int TOGGLE_VAR_INSPECTOR = 104;
52 |
53 | static protected final int STOP = JavaToolbar.STOP;
54 |
55 | static protected final int NEW = JavaToolbar.NEW;
56 | static protected final int OPEN = JavaToolbar.OPEN;
57 | static protected final int SAVE = JavaToolbar.SAVE;
58 | static protected final int EXPORT = JavaToolbar.EXPORT;
59 |
60 |
61 | // the sequence of button ids. (this maps button position = index to button ids)
62 | static protected final int[] buttonSequence = {
63 | DEBUG, CONTINUE, STEP, STOP, TOGGLE_BREAKPOINT, TOGGLE_VAR_INSPECTOR,
64 | NEW, OPEN, SAVE, EXPORT
65 | };
66 |
67 |
68 | public DebugToolbar(Editor editor, Base base) {
69 | super(editor, base);
70 | }
71 | public Image[][] loadDebugImages() {
72 | int res = Toolkit.highResDisplay() ? 2 : 1;
73 |
74 | String suffix = null;
75 | Image allButtons = null;
76 | // Some modes may not have a 2x version. If a mode doesn't have a 1x
77 | // version, this will cause an error... they should always have 1x.
78 | if (res == 2) {
79 | suffix = "-2x.png";
80 | allButtons = mode.loadImage("theme/buttons-debug" + suffix);
81 | if (allButtons == null) {
82 | res = 1; // take him down a notch
83 | }
84 | }
85 | if (res == 1) {
86 | suffix = ".png";
87 | allButtons = mode.loadImage("theme/buttons-debug" + suffix);
88 | if (allButtons == null) {
89 | // use the old (pre-2.0b9) file name
90 | suffix = ".gif";
91 | allButtons = mode.loadImage("theme/buttons-debug" + suffix);
92 | }
93 | }
94 |
95 | // The following three final fields were not accessible, so just copied the values here
96 | // for the time being. TODO: inform Ben, make these fields public
97 | /** Width of each toolbar button. */
98 | final int BUTTON_WIDTH = 27;
99 | /** Size (both width and height) of the buttons in the source image. */
100 | final int BUTTON_IMAGE_SIZE = 33;
101 | int count = allButtons.getWidth(this) / BUTTON_WIDTH*res;
102 | final int GRID_SIZE = 32;
103 |
104 | Image[][] buttonImages = new Image[count][3];
105 |
106 | for (int i = 0; i < count; i++) {
107 | for (int state = 0; state < 3; state++) {
108 | Image image = new BufferedImage(BUTTON_WIDTH*res, GRID_SIZE*res, BufferedImage.TYPE_INT_ARGB);
109 | Graphics g = image.getGraphics();
110 | g.drawImage(allButtons,
111 | -(i*BUTTON_IMAGE_SIZE*res) - 3,
112 | (state-2)*BUTTON_IMAGE_SIZE*res, null);
113 | g.dispose();
114 | buttonImages[i][state] = image;
115 | }
116 | }
117 |
118 | return buttonImages;
119 | }
120 |
121 | /**
122 | * Initialize buttons. Loads images and adds the buttons to the toolbar.
123 | */
124 | @Override
125 | public void init() {
126 | Image[][] images = loadDebugImages();
127 | for (int idx = 0; idx < buttonSequence.length; idx++) {
128 | int id = buttonId(idx);
129 | addButton(getTitle(id, false), getTitle(id, true), images[idx], id == NEW || id == TOGGLE_BREAKPOINT);
130 | }
131 | }
132 |
133 |
134 | /**
135 | * Get the title for a toolbar button. Displayed in the toolbar when
136 | * hovering over a button.
137 | * @param id id of the toolbar button
138 | * @param shift true if shift is pressed
139 | * @return the title
140 | */
141 | public static String getTitle(int id, boolean shift) {
142 | switch (id) {
143 | case DebugToolbar.RUN:
144 | return JavaToolbar.getTitle(JavaToolbar.RUN, shift);
145 | case STOP:
146 | return JavaToolbar.getTitle(JavaToolbar.STOP, shift);
147 | case NEW:
148 | return JavaToolbar.getTitle(JavaToolbar.NEW, shift);
149 | case OPEN:
150 | return JavaToolbar.getTitle(JavaToolbar.OPEN, shift);
151 | case SAVE:
152 | return JavaToolbar.getTitle(JavaToolbar.SAVE, shift);
153 | case EXPORT:
154 | return JavaToolbar.getTitle(JavaToolbar.EXPORT, shift);
155 | case DEBUG:
156 | if (shift) {
157 | return "Run";
158 | } else {
159 | return "Debug";
160 | }
161 | case CONTINUE:
162 | return "Continue";
163 | case TOGGLE_BREAKPOINT:
164 | return "Toggle Breakpoint";
165 | case STEP:
166 | if (shift) {
167 | return "Step Into";
168 | } else {
169 | return "Step";
170 | }
171 | case TOGGLE_VAR_INSPECTOR:
172 | return "Variable Inspector";
173 | }
174 | return null;
175 | }
176 |
177 |
178 | /**
179 | * Event handler called when a toolbar button is clicked.
180 | * @param e the mouse event
181 | * @param idx index (i.e. position) of the toolbar button clicked
182 | */
183 | @Override
184 | public void handlePressed(MouseEvent e, int idx) {
185 | boolean shift = e.isShiftDown();
186 | DebugEditor deditor = (DebugEditor) editor;
187 | int id = buttonId(idx); // convert index/position to button id
188 |
189 | switch (id) {
190 | // case DebugToolbar.RUN:
191 | // super.handlePressed(e, JavaToolbar.RUN);
192 | // break;
193 | case STOP:
194 | Logger.getLogger(DebugToolbar.class.getName()).log(Level.INFO, "Invoked 'Stop' toolbar button");
195 | super.handlePressed(e, JavaToolbar.STOP);
196 | break;
197 | case NEW:
198 | Logger.getLogger(DebugToolbar.class.getName()).log(Level.INFO, "Invoked 'New' toolbar button");
199 | super.handlePressed(e, JavaToolbar.NEW);
200 | break;
201 | case OPEN:
202 | Logger.getLogger(DebugToolbar.class.getName()).log(Level.INFO, "Invoked 'Open' toolbar button");
203 | super.handlePressed(e, JavaToolbar.OPEN);
204 | break;
205 | case SAVE:
206 | Logger.getLogger(DebugToolbar.class.getName()).log(Level.INFO, "Invoked 'Save' toolbar button");
207 | super.handlePressed(e, JavaToolbar.SAVE);
208 | break;
209 | case EXPORT:
210 | Logger.getLogger(DebugToolbar.class.getName()).log(Level.INFO, "Invoked 'Export' toolbar button");
211 | super.handlePressed(e, JavaToolbar.EXPORT);
212 | break;
213 | case DEBUG:
214 | deditor.handleStop(); // Close any running sketches
215 | deditor.showProblemListView(XQConsoleToggle.CONSOLE);
216 | if (shift) {
217 | Logger.getLogger(DebugToolbar.class.getName()).log(Level.INFO, "Invoked 'Run' toolbar button");
218 | deditor.handleRun();
219 | } else {
220 | Logger.getLogger(DebugToolbar.class.getName()).log(Level.INFO, "Invoked 'Debug' toolbar button");
221 | deditor.dbg.startDebug();
222 | }
223 | break;
224 | case CONTINUE:
225 | Logger.getLogger(DebugToolbar.class.getName()).log(Level.INFO, "Invoked 'Continue' toolbar button");
226 | deditor.dbg.continueDebug();
227 | break;
228 | case TOGGLE_BREAKPOINT:
229 | Logger.getLogger(DebugToolbar.class.getName()).log(Level.INFO, "Invoked 'Toggle Breakpoint' toolbar button");
230 | deditor.dbg.toggleBreakpoint();
231 | break;
232 | case STEP:
233 | if (shift) {
234 | Logger.getLogger(DebugToolbar.class.getName()).log(Level.INFO, "Invoked 'Step Into' toolbar button");
235 | deditor.dbg.stepInto();
236 | } else {
237 | Logger.getLogger(DebugToolbar.class.getName()).log(Level.INFO, "Invoked 'Step' toolbar button");
238 | deditor.dbg.stepOver();
239 | }
240 | break;
241 | // case STEP_INTO:
242 | // deditor.dbg.stepInto();
243 | // break;
244 | // case STEP_OUT:
245 | // deditor.dbg.stepOut();
246 | // break;
247 | case TOGGLE_VAR_INSPECTOR:
248 | Logger.getLogger(DebugToolbar.class.getName()).log(Level.INFO, "Invoked 'Variable Inspector' toolbar button");
249 | deditor.toggleVariableInspector();
250 | break;
251 | }
252 | }
253 |
254 |
255 | /**
256 | * Activate (light up) a button.
257 | * @param id the button id
258 | */
259 | @Override
260 | public void activate(int id) {
261 | //System.out.println("activate button idx: " + buttonIndex(id));
262 | super.activate(buttonIndex(id));
263 | }
264 |
265 |
266 | /**
267 | * Set a button to be inactive.
268 | * @param id the button id
269 | */
270 | @Override
271 | public void deactivate(int id) {
272 | //System.out.println("deactivate button idx: " + buttonIndex(id));
273 | super.deactivate(buttonIndex(id));
274 | }
275 |
276 |
277 | /**
278 | * Get button position (index) from it's id.
279 | * @param buttonId the button id
280 | * ({@link #RUN}, {@link #DEBUG}, {@link #CONTINUE}), {@link #STEP}, ...)
281 | * @return the button index
282 | */
283 | protected int buttonIndex(int buttonId) {
284 | for (int i = 0; i < buttonSequence.length; i++) {
285 | if (buttonSequence[i] == buttonId) {
286 | return i;
287 | }
288 | }
289 | return -1;
290 | }
291 |
292 |
293 | /**
294 | * Get the button id from its position (index).
295 | * @param buttonIdx the button index
296 | * @return the button id
297 | * ({@link #RUN}, {@link #DEBUG}, {@link #CONTINUE}), {@link #STEP}, ...)
298 | */
299 | protected int buttonId(int buttonIdx) {
300 | return buttonSequence[buttonIdx];
301 | }
302 | }
303 |
--------------------------------------------------------------------------------
/src/processing/mode/experimental/ErrorBar.java:
--------------------------------------------------------------------------------
1 | /*
2 | Part of the XQMode project - https://github.com/Manindra29/XQMode
3 |
4 | Under Google Summer of Code 2012 -
5 | http://www.google-melange.com/gsoc/homepage/google/gsoc2012
6 |
7 | Copyright (C) 2012 Manindra Moharana
8 |
9 | This program is free software; you can redistribute it and/or modify
10 | it under the terms of the GNU General Public License version 2
11 | as published by the Free Software Foundation.
12 |
13 | This program is distributed in the hope that it will be useful,
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | GNU General Public License for more details.
17 |
18 | You should have received a copy of the GNU General Public License
19 | along with this program; if not, write to the Free Software Foundation,
20 | Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 | */
22 |
23 | package processing.mode.experimental;
24 |
25 | import java.awt.Color;
26 | import java.awt.Cursor;
27 | import java.awt.Dimension;
28 | import java.awt.Graphics;
29 | import java.awt.Graphics2D;
30 | import java.awt.RenderingHints;
31 | import java.awt.event.MouseAdapter;
32 | import java.awt.event.MouseEvent;
33 | import java.awt.event.MouseMotionListener;
34 | import java.util.ArrayList;
35 |
36 | import javax.swing.JPanel;
37 | import javax.swing.SwingWorker;
38 | import javax.swing.text.BadLocationException;
39 |
40 | import processing.app.Base;
41 | import processing.app.SketchCode;
42 |
43 | /**
44 | * The bar on the left of the text area which displays all errors as rectangles.
45 | *
46 | * All errors and warnings of a sketch are drawn on the bar, clicking on one,
47 | * scrolls to the tab and location. Error messages displayed on hover. Markers
48 | * are not in sync with the error line. Similar to eclipse's right error bar
49 | * which displays the overall errors in a document
50 | *
51 | * @author Manindra Moharana <me@mkmoharana.com>
52 | *
53 | */
54 | public class ErrorBar extends JPanel {
55 | /**
56 | * Preferred height of the component
57 | */
58 | protected int preferredHeight;
59 |
60 | /**
61 | * Preferred height of the component
62 | */
63 | protected int preferredWidth = 12;
64 |
65 | /**
66 | * Height of marker
67 | */
68 | public static final int errorMarkerHeight = 4;
69 |
70 | /**
71 | * Color of Error Marker
72 | */
73 | public Color errorColor = new Color(0xED2630);
74 |
75 | /**
76 | * Color of Warning Marker
77 | */
78 | public Color warningColor = new Color(0xFFC30E);
79 |
80 | /**
81 | * Background color of the component
82 | */
83 | public Color backgroundColor = new Color(0x2C343D);
84 |
85 | /**
86 | * DebugEditor instance
87 | */
88 | protected DebugEditor editor;
89 |
90 | /**
91 | * ErrorCheckerService instance
92 | */
93 | protected ErrorCheckerService errorCheckerService;
94 |
95 | /**
96 | * Stores error markers displayed PER TAB along the error bar.
97 | */
98 | protected ArrayList errorPoints = new ArrayList();
99 |
100 | /**
101 | * Stores previous list of error markers.
102 | */
103 | protected ArrayList errorPointsOld = new ArrayList();
104 |
105 | public void paintComponent(Graphics g) {
106 | Graphics2D g2d = (Graphics2D) g;
107 | g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
108 | RenderingHints.VALUE_ANTIALIAS_ON);
109 | g.setColor(backgroundColor);
110 | g.fillRect(0, 0, getWidth(), getHeight());
111 |
112 | for (ErrorMarker emarker : errorPoints) {
113 | if (emarker.getType() == ErrorMarker.Error) {
114 | g.setColor(errorColor);
115 | } else {
116 | g.setColor(warningColor);
117 | }
118 | g.fillRect(2, emarker.getY(), (getWidth() - 3), errorMarkerHeight);
119 | }
120 | }
121 |
122 | public Dimension getPreferredSize() {
123 | return new Dimension(preferredWidth, preferredHeight);
124 | }
125 |
126 | public Dimension getMinimumSize() {
127 | return getPreferredSize();
128 | }
129 |
130 | public ErrorBar(DebugEditor editor, int height, ExperimentalMode mode) {
131 | this.editor = editor;
132 | this.preferredHeight = height;
133 | this.errorCheckerService = editor.errorCheckerService;
134 | errorColor = mode.getThemeColor("errorbar.errorcolor", errorColor);
135 | warningColor = mode
136 | .getThemeColor("errorbar.warningcolor", warningColor);
137 | backgroundColor = mode.getThemeColor("errorbar.backgroundcolor",
138 | backgroundColor);
139 | addListeners();
140 | }
141 |
142 | /**
143 | * Update error markers in the error bar.
144 | *
145 | * @param problems
146 | * - List of problems.
147 | */
148 | synchronized public void updateErrorPoints(final ArrayList problems) {
149 |
150 | // NOTE TO SELF: ErrorMarkers are calculated for the present tab only
151 | // Error Marker index in the arraylist is LOCALIZED for current tab.
152 | // Also, need to do the update in the UI thread to prevent concurrency issues.
153 | final int fheight = this.getHeight();
154 | SwingWorker worker = new SwingWorker() {
155 |
156 | protected Object doInBackground() throws Exception {
157 | SketchCode sc = editor.getSketch().getCurrentCode();
158 | int totalLines = 0, currentTab = editor.getSketch()
159 | .getCurrentCodeIndex();
160 | try {
161 | totalLines = Base.countLines(sc.getDocument()
162 | .getText(0, sc.getDocument().getLength())) + 1;
163 | } catch (BadLocationException e) {
164 | e.printStackTrace();
165 | }
166 | // System.out.println("Total lines: " + totalLines);
167 | synchronized (errorPoints) {
168 | errorPointsOld.clear();
169 | for (ErrorMarker marker : errorPoints) {
170 | errorPointsOld.add(marker);
171 | }
172 | errorPoints.clear();
173 |
174 | // Each problem.getSourceLine() will have an extra line added
175 | // because of
176 | // class declaration in the beginning as well as default imports
177 | synchronized (problems) {
178 | for (Problem problem : problems) {
179 | if (problem.getTabIndex() == currentTab) {
180 | // Ratio of error line to total lines
181 | float y = (problem.getLineNumber() - errorCheckerService.defaultImportsOffset)
182 | / ((float) totalLines);
183 | // Ratio multiplied by height of the error bar
184 | y *= fheight - 15; // -15 is just a vertical offset
185 | errorPoints
186 | .add(new ErrorMarker(problem, (int) y,
187 | problem.isError() ? ErrorMarker.Error
188 | : ErrorMarker.Warning));
189 | // System.out.println("Y: " + y);
190 | }
191 | }
192 | }
193 | }
194 | return null;
195 | }
196 |
197 | protected void done() {
198 | repaint();
199 | }
200 | };
201 |
202 | try {
203 | worker.execute(); // I eat concurrency bugs for breakfast.
204 | } catch (Exception exp) {
205 | System.out.println("Errorbar update markers is slacking."
206 | + exp.getMessage());
207 | // e.printStackTrace();
208 | }
209 | }
210 |
211 | /**
212 | * Check if new errors have popped up in the sketch since the last check
213 | *
214 | * @return true - if errors have changed
215 | */
216 | public boolean errorPointsChanged() {
217 | if (errorPointsOld.size() != errorPoints.size()) {
218 | editor.getTextArea().repaint();
219 | // System.out.println("2 Repaint " + System.currentTimeMillis());
220 | return true;
221 | }
222 |
223 | else {
224 | for (int i = 0; i < errorPoints.size(); i++) {
225 | if (errorPoints.get(i).getY() != errorPointsOld.get(i).getY()) {
226 | editor.getTextArea().repaint();
227 | // System.out.println("3 Repaint " +
228 | // System.currentTimeMillis());
229 | return true;
230 | }
231 | }
232 | }
233 | return false;
234 | }
235 |
236 | /**
237 | * Add various mouse listeners.
238 | */
239 | protected void addListeners() {
240 |
241 | this.addMouseListener(new MouseAdapter() {
242 |
243 | // Find out which error/warning the user has clicked
244 | // and then scroll to that
245 | @SuppressWarnings("rawtypes")
246 | @Override
247 | public void mouseClicked(final MouseEvent e) {
248 | SwingWorker worker = new SwingWorker() {
249 |
250 | protected Object doInBackground() throws Exception {
251 | for (ErrorMarker eMarker : errorPoints) {
252 | // -2 and +2 are extra allowance, clicks in the
253 | // vicinity of the markers register that way
254 | if (e.getY() >= eMarker.getY() - 2
255 | && e.getY() <= eMarker.getY() + 2 + errorMarkerHeight) {
256 | errorCheckerService.scrollToErrorLine(eMarker.getProblem());
257 | return null;
258 | }
259 | }
260 | return null;
261 | }
262 | };
263 |
264 | try {
265 | worker.execute();
266 | } catch (Exception exp) {
267 | System.out.println("Errorbar mouseClicked is slacking."
268 | + exp.getMessage());
269 | // e.printStackTrace();
270 | }
271 |
272 | }
273 | });
274 |
275 | // Tooltip on hover
276 | this.addMouseMotionListener(new MouseMotionListener() {
277 |
278 | @SuppressWarnings("rawtypes")
279 | @Override
280 | public void mouseMoved(final MouseEvent evt) {
281 | // System.out.println(e);
282 | SwingWorker worker = new SwingWorker() {
283 |
284 | protected Object doInBackground() throws Exception {
285 | for (ErrorMarker eMarker : errorPoints) {
286 | if (evt.getY() >= eMarker.getY() - 2
287 | && evt.getY() <= eMarker.getY() + 2 + errorMarkerHeight) {
288 | Problem p = eMarker.getProblem();
289 | String msg = (p.isError() ? "Error: " : "Warning: ")
290 | + p.getMessage();
291 | setToolTipText(msg);
292 | setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
293 | break;
294 | }
295 | }
296 | return null;
297 | }
298 | };
299 |
300 | try {
301 | worker.execute();
302 | } catch (Exception exp) {
303 | System.out
304 | .println("Errorbar mousemoved Worker is slacking."
305 | + exp.getMessage());
306 | // e.printStackTrace();
307 | }
308 | }
309 |
310 | @Override
311 | public void mouseDragged(MouseEvent arg0) {
312 |
313 | }
314 | });
315 |
316 | }
317 |
318 | }
319 |
--------------------------------------------------------------------------------
/src/processing/mode/experimental/ErrorMarker.java:
--------------------------------------------------------------------------------
1 | package processing.mode.experimental;
2 | /**
3 | * Error markers displayed on the Error Bar.
4 | *
5 | * @author Manindra Moharana <me@mkmoharana.com>
6 | *
7 | */
8 | public class ErrorMarker {
9 | /**
10 | * y co-ordinate of the marker
11 | */
12 | private int y;
13 | /**
14 | * Type of marker: Error or Warning?
15 | */
16 | private int type = -1;
17 | /**
18 | * Error Type constant
19 | */
20 | public static final int Error = 1;
21 | /**
22 | * Warning Type constant
23 | */
24 | public static final int Warning = 2;
25 | /**
26 | * Problem that the error marker represents
27 | * @see Problem
28 | */
29 | private Problem problem;
30 |
31 | public ErrorMarker(Problem problem, int y, int type) {
32 | this.problem = problem;
33 | this.y = y;
34 | this.type = type;
35 | }
36 |
37 | /**
38 | * y co-ordinate of the marker
39 | */
40 | public int getY() {
41 | return y;
42 | }
43 |
44 | /**
45 | * Type of marker: ErrorMarker.Error or ErrorMarker.Warning?
46 | */
47 | public int getType() {
48 | return type;
49 | }
50 |
51 | /**
52 | * Problem that the error marker represents
53 | * @see Problem
54 | */
55 | public Problem getProblem() {
56 | return problem;
57 | }
58 |
59 | }
--------------------------------------------------------------------------------
/src/processing/mode/experimental/ErrorMessageSimplifier.java:
--------------------------------------------------------------------------------
1 | package processing.mode.experimental;
2 |
3 | import java.lang.reflect.Field;
4 | import java.lang.reflect.Modifier;
5 | import java.util.TreeMap;
6 |
7 | import org.eclipse.jdt.internal.compiler.problem.DefaultProblem;
8 |
9 | public class ErrorMessageSimplifier {
10 |
11 | // private ErrorCheckerService errorCheckerService;
12 |
13 | /**
14 | * Mapping between ProblemID constant and the constant name. Holds about 650
15 | * of them. Also, this is just temporary, will be used to find the common
16 | * error types, cos you know, identifying String names is easier than
17 | * identifying 8 digit int constants!
18 | * TODO: this is temporary
19 | */
20 | private TreeMap constantsMap;
21 |
22 | public ErrorMessageSimplifier() {
23 |
24 | new Thread() {
25 | public void run() {
26 | prepareConstantsList();
27 | }
28 | }.start();
29 | }
30 |
31 | private void prepareConstantsList() {
32 | constantsMap = new TreeMap();
33 | Class probClass = DefaultProblem.class;
34 | Field f[] = probClass.getFields();
35 | for (Field field : f) {
36 | if (Modifier.isStatic(field.getModifiers()))
37 | try {
38 | //System.out.println(field.getName() + " :" + field.get(null));
39 | Object val = field.get(null);
40 | if (val instanceof Integer) {
41 | constantsMap.put((Integer) (val), field.getName());
42 | }
43 | } catch (Exception e) {
44 | System.out.println("Here");
45 | e.printStackTrace();
46 | break;
47 | }
48 | }
49 | //System.out.println("Total items: " + constantsMap.size());
50 | }
51 |
52 | public String getIDName(int id) {
53 | if (constantsMap == null)
54 | return null;
55 | return constantsMap.get(id);
56 | }
57 |
58 | }
59 |
--------------------------------------------------------------------------------
/src/processing/mode/experimental/ErrorWindow.java:
--------------------------------------------------------------------------------
1 | /*
2 | Part of the XQMode project - https://github.com/Manindra29/XQMode
3 |
4 | Under Google Summer of Code 2012 -
5 | http://www.google-melange.com/gsoc/homepage/google/gsoc2012
6 |
7 | Copyright (C) 2012 Manindra Moharana
8 |
9 | This program is free software; you can redistribute it and/or modify
10 | it under the terms of the GNU General Public License version 2
11 | as published by the Free Software Foundation.
12 |
13 | This program is distributed in the hope that it will be useful,
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | GNU General Public License for more details.
17 |
18 | You should have received a copy of the GNU General Public License
19 | along with this program; if not, write to the Free Software Foundation,
20 | Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 | */
22 |
23 | package processing.mode.experimental;
24 |
25 | import java.awt.BorderLayout;
26 | import java.awt.Frame;
27 | import java.awt.Point;
28 | import java.awt.event.ComponentEvent;
29 | import java.awt.event.ComponentListener;
30 | import java.awt.event.WindowAdapter;
31 | import java.awt.event.WindowEvent;
32 |
33 | import javax.swing.JFrame;
34 | import javax.swing.JPanel;
35 | import javax.swing.JScrollPane;
36 | import javax.swing.WindowConstants;
37 | import javax.swing.border.EmptyBorder;
38 | import javax.swing.table.TableModel;
39 |
40 | import processing.app.Editor;
41 | import processing.app.Toolkit;
42 |
43 | /**
44 | * Error Window that displays a tablular list of errors. Clicking on an error
45 | * scrolls to its location in the code.
46 | *
47 | * @author Manindra Moharana <me@mkmoharana.com>
48 | *
49 | */
50 | public class ErrorWindow extends JFrame {
51 |
52 | private JPanel contentPane;
53 | /**
54 | * The table displaying the errors
55 | */
56 | protected XQErrorTable errorTable;
57 | /**
58 | * Scroll pane that contains the Error Table
59 | */
60 | protected JScrollPane scrollPane;
61 |
62 | protected DebugEditor thisEditor;
63 | private JFrame thisErrorWindow;
64 |
65 | /**
66 | * Handles the sticky Problem window
67 | */
68 | private DockTool2Base Docker;
69 |
70 | protected ErrorCheckerService errorCheckerService;
71 |
72 | /**
73 | * Preps up ErrorWindow
74 | *
75 | * @param editor
76 | * - Editor
77 | * @param ecs - ErrorCheckerService
78 | */
79 | public ErrorWindow(DebugEditor editor, ErrorCheckerService ecs) {
80 | thisErrorWindow = this;
81 | errorCheckerService = ecs;
82 | thisEditor = editor;
83 | setTitle("Problems");
84 | prepareFrame();
85 | }
86 |
87 | /**
88 | * Sets up ErrorWindow
89 | */
90 | protected void prepareFrame() {
91 | Toolkit.setIcon(this);
92 | setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE);
93 | // Default size: setBounds(100, 100, 458, 160);
94 | setBounds(100, 100, 458, 160); // Yeah, I hardcode such things sometimes. Hate me.
95 |
96 | contentPane = new JPanel();
97 | contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
98 | setContentPane(contentPane);
99 | contentPane.setLayout(new BorderLayout(0, 0));
100 |
101 | scrollPane = new JScrollPane();
102 | contentPane.add(scrollPane);
103 |
104 | errorTable = new XQErrorTable(errorCheckerService);
105 | scrollPane.setViewportView(errorTable);
106 |
107 | try {
108 | Docker = new DockTool2Base();
109 | addListeners();
110 | } catch (Exception e) {
111 | System.out.println("addListeners() acted silly.");
112 | e.printStackTrace();
113 | }
114 |
115 | if (thisEditor != null) {
116 | setLocation(new Point(thisEditor.getLocation().x
117 | + thisEditor.getWidth(), thisEditor.getLocation().y));
118 | }
119 |
120 | }
121 |
122 | /**
123 | * Updates the error table with new data(Table Model). Called from Error
124 | * Checker Service.
125 | *
126 | * @param tableModel
127 | * - Table Model
128 | * @return True - If error table was updated successfully.
129 | */
130 | synchronized public boolean updateTable(final TableModel tableModel) {
131 | // XQErrorTable handles evrything now
132 | return errorTable.updateTable(tableModel);
133 | }
134 |
135 | /**
136 | * Adds various listeners to components of EditorWindow and to the Editor
137 | * window
138 | */
139 | protected void addListeners() {
140 |
141 | if (thisErrorWindow == null)
142 | System.out.println("ERW null");
143 |
144 | thisErrorWindow.addComponentListener(new ComponentListener() {
145 |
146 | @Override
147 | public void componentShown(ComponentEvent e) {
148 |
149 | }
150 |
151 | @Override
152 | public void componentResized(ComponentEvent e) {
153 | Docker.tryDocking();
154 | }
155 |
156 | @Override
157 | public void componentMoved(ComponentEvent e) {
158 | Docker.tryDocking();
159 | }
160 |
161 | @Override
162 | public void componentHidden(ComponentEvent e) {
163 |
164 | }
165 | });
166 |
167 | thisErrorWindow.addWindowListener(new WindowAdapter() {
168 |
169 | @Override
170 | public void windowClosing(WindowEvent e) {
171 | thisEditor.problemWindowMenuCB.setSelected(false);
172 | }
173 |
174 | @Override
175 | public void windowDeiconified(WindowEvent e) {
176 | thisEditor.setExtendedState(Frame.NORMAL);
177 | }
178 |
179 | });
180 |
181 | if (thisEditor == null) {
182 | System.out.println("Editor null");
183 | return;
184 | }
185 |
186 | /*thisEditor.addWindowListener(new WindowAdapter() {
187 |
188 | @Override
189 | public void windowClosing(WindowEvent e) {
190 |
191 | }
192 |
193 | @Override
194 | public void windowClosed(WindowEvent e) {
195 | errorCheckerService.pauseThread();
196 | errorCheckerService.stopThread(); // Bye bye thread.
197 | thisErrorWindow.dispose();
198 | }
199 |
200 | @Override
201 | public void windowIconified(WindowEvent e) {
202 | thisErrorWindow.setExtendedState(Frame.ICONIFIED);
203 | }
204 |
205 | @Override
206 | public void windowDeiconified(WindowEvent e) {
207 | thisErrorWindow.setExtendedState(Frame.NORMAL);
208 | }
209 |
210 | });*/
211 |
212 | thisEditor.addComponentListener(new ComponentListener() {
213 |
214 | @Override
215 | public void componentShown(ComponentEvent e) {
216 |
217 | }
218 |
219 | @Override
220 | public void componentResized(ComponentEvent e) {
221 | if (Docker.isDocked()) {
222 | Docker.dock();
223 | } else {
224 | Docker.tryDocking();
225 | }
226 | }
227 |
228 | @Override
229 | public void componentMoved(ComponentEvent e) {
230 |
231 | if (Docker.isDocked()) {
232 | Docker.dock();
233 | } else {
234 | Docker.tryDocking();
235 | }
236 |
237 | }
238 |
239 | @Override
240 | public void componentHidden(ComponentEvent e) {
241 | // System.out.println("ed hidden");
242 | }
243 | });
244 |
245 | }
246 |
247 |
248 | /**
249 | * Implements the docking feature of the tool - The frame sticks to the
250 | * editor and once docked, moves along with it as the editor is resized,
251 | * moved, or closed.
252 | *
253 | * This class has been borrowed from Tab Manager tool by Thomas Diewald. It
254 | * has been slightly modified and used here.
255 | *
256 | * @author Thomas Diewald , http://thomasdiewald.com
257 | */
258 | private class DockTool2Base {
259 |
260 | private int docking_border = 0;
261 | private int dock_on_editor_y_offset_ = 0;
262 | private int dock_on_editor_x_offset_ = 0;
263 |
264 | // ///////////////////////////////
265 | // ____2____
266 | // | |
267 | // | |
268 | // 0 | editor | 1
269 | // | |
270 | // |_________|
271 | // 3
272 | // ///////////////////////////////
273 |
274 | // public void reset() {
275 | // dock_on_editor_y_offset_ = 0;
276 | // dock_on_editor_x_offset_ = 0;
277 | // docking_border = 0;
278 | // }
279 |
280 | public boolean isDocked() {
281 | return (docking_border >= 0);
282 | }
283 |
284 | private final int MAX_GAP_ = 20;
285 |
286 | //
287 | public void tryDocking() {
288 | if (thisEditor == null)
289 | return;
290 | Editor editor = thisEditor;
291 | Frame frame = thisErrorWindow;
292 |
293 | int ex = editor.getX();
294 | int ey = editor.getY();
295 | int ew = editor.getWidth();
296 | int eh = editor.getHeight();
297 |
298 | int fx = frame.getX();
299 | int fy = frame.getY();
300 | int fw = frame.getWidth();
301 | int fh = frame.getHeight();
302 |
303 | if (((fy > ey) && (fy < ey + eh))
304 | || ((fy + fh > ey) && (fy + fh < ey + eh))) {
305 | int dis_border_left = Math.abs(ex - (fx + fw));
306 | int dis_border_right = Math.abs((ex + ew) - (fx));
307 |
308 | if (dis_border_left < MAX_GAP_ || dis_border_right < MAX_GAP_) {
309 | docking_border = (dis_border_left < dis_border_right) ? 0
310 | : 1;
311 | dock_on_editor_y_offset_ = fy - ey;
312 | dock();
313 | return;
314 | }
315 | }
316 |
317 | if (((fx > ex) && (fx < ex + ew))
318 | || ((fx + fw > ey) && (fx + fw < ex + ew))) {
319 | int dis_border_top = Math.abs(ey - (fy + fh));
320 | int dis_border_bot = Math.abs((ey + eh) - (fy));
321 |
322 | if (dis_border_top < MAX_GAP_ || dis_border_bot < MAX_GAP_) {
323 | docking_border = (dis_border_top < dis_border_bot) ? 2 : 3;
324 | dock_on_editor_x_offset_ = fx - ex;
325 | dock();
326 | return;
327 | }
328 | }
329 | docking_border = -1;
330 | }
331 |
332 | public void dock() {
333 | if (thisEditor == null)
334 | return;
335 | Editor editor = thisEditor;
336 | Frame frame = thisErrorWindow;
337 |
338 | int ex = editor.getX();
339 | int ey = editor.getY();
340 | int ew = editor.getWidth();
341 | int eh = editor.getHeight();
342 |
343 | // int fx = frame.getX();
344 | // int fy = frame.getY();
345 | int fw = frame.getWidth();
346 | int fh = frame.getHeight();
347 |
348 | int x = 0, y = 0;
349 | if (docking_border == -1) {
350 | return;
351 | }
352 |
353 | if (docking_border == 0) {
354 | x = ex - fw;
355 | y = ey + dock_on_editor_y_offset_;
356 | }
357 | if (docking_border == 1) {
358 | x = ex + ew;
359 | y = ey + dock_on_editor_y_offset_;
360 | }
361 |
362 | if (docking_border == 2) {
363 | x = ex + dock_on_editor_x_offset_;
364 | y = ey - fh;
365 | }
366 | if (docking_border == 3) {
367 | x = ex + dock_on_editor_x_offset_;
368 | y = ey + eh;
369 | }
370 | frame.setLocation(x, y);
371 | }
372 |
373 | }
374 | }
375 |
--------------------------------------------------------------------------------
/src/processing/mode/experimental/FieldNode.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2012 Martin Leopold
3 | *
4 | * This program is free software; you can redistribute it and/or
5 | * modify it under the terms of the GNU General Public License
6 | * as published by the Free Software Foundation; either version 2
7 | * of the License, or (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program; if not, write to the Free Software
16 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 | */
18 | package processing.mode.experimental;
19 |
20 | import com.sun.jdi.ClassNotLoadedException;
21 | import com.sun.jdi.Field;
22 | import com.sun.jdi.InvalidTypeException;
23 | import com.sun.jdi.ObjectReference;
24 | import com.sun.jdi.Value;
25 | import java.util.logging.Level;
26 | import java.util.logging.Logger;
27 |
28 | /**
29 | * Specialized {@link VariableNode} for representing fields. Overrides
30 | * {@link #setValue} to properly change the value of the encapsulated field.
31 | *
32 | * @author Martin Leopold
33 | */
34 | public class FieldNode extends VariableNode {
35 |
36 | protected Field field;
37 | protected ObjectReference obj;
38 |
39 | /**
40 | * Construct a {@link FieldNode}.
41 | *
42 | * @param name the name
43 | * @param type the type
44 | * @param value the value
45 | * @param field the field
46 | * @param obj a reference to the object containing the field
47 | */
48 | public FieldNode(String name, String type, Value value, Field field, ObjectReference obj) {
49 | super(name, type, value);
50 | this.field = field;
51 | this.obj = obj;
52 | }
53 |
54 | @Override
55 | public void setValue(Value value) {
56 | try {
57 | obj.setValue(field, value);
58 | } catch (InvalidTypeException ex) {
59 | Logger.getLogger(FieldNode.class.getName()).log(Level.SEVERE, null, ex);
60 | } catch (ClassNotLoadedException ex) {
61 | Logger.getLogger(FieldNode.class.getName()).log(Level.SEVERE, null, ex);
62 | }
63 | this.value = value;
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/src/processing/mode/experimental/ImportStatement.java:
--------------------------------------------------------------------------------
1 | /*
2 | Part of the XQMode project - https://github.com/Manindra29/XQMode
3 |
4 | Under Google Summer of Code 2012 -
5 | http://www.google-melange.com/gsoc/homepage/google/gsoc2012
6 |
7 | Copyright (C) 2012 Manindra Moharana
8 |
9 | This program is free software; you can redistribute it and/or modify
10 | it under the terms of the GNU General Public License version 2
11 | as published by the Free Software Foundation.
12 |
13 | This program is distributed in the hope that it will be useful,
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | GNU General Public License for more details.
17 |
18 | You should have received a copy of the GNU General Public License
19 | along with this program; if not, write to the Free Software Foundation,
20 | Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 | */
22 |
23 | package processing.mode.experimental;
24 |
25 | /**
26 | * Wrapper for import statements
27 | *
28 | * @author Manindra Moharana <me@mkmoharana.com>
29 | *
30 | */
31 | public class ImportStatement {
32 | /**
33 | * Ex: processing.opengl.*, java.util.*
34 | */
35 | private String importName;
36 |
37 | /**
38 | * Which tab does it belong to?
39 | */
40 | private int tab;
41 |
42 | /**
43 | * Line number(pde code) of the import
44 | */
45 | private int lineNumber;
46 |
47 | /**
48 | *
49 | * @param importName - Ex: processing.opengl.*, java.util.*
50 | * @param tab - Which tab does it belong to?
51 | * @param lineNumber - Line number(pde code) of the import
52 | */
53 | public ImportStatement(String importName, int tab, int lineNumber) {
54 | this.importName = importName;
55 | this.tab = tab;
56 | this.lineNumber = lineNumber;
57 | }
58 |
59 | public String getImportName() {
60 | return importName;
61 | }
62 |
63 | public String getPackageName(){
64 | String ret = new String(importName.trim());
65 | if(ret.startsWith("import "))
66 | ret = ret.substring(7);
67 | if(ret.endsWith(";"))
68 | ret = ret.substring(0, ret.length() - 1);
69 | return ret;
70 | }
71 |
72 | public int getTab() {
73 | return tab;
74 | }
75 |
76 | public int getLineNumber() {
77 | return lineNumber;
78 | }
79 | }
--------------------------------------------------------------------------------
/src/processing/mode/experimental/JavadocHelper.java:
--------------------------------------------------------------------------------
1 | package processing.mode.experimental;
2 |
3 | import java.io.File;
4 | import java.io.FileFilter;
5 | import java.util.Iterator;
6 | import java.util.TreeMap;
7 |
8 | import org.jsoup.Jsoup;
9 | import org.jsoup.nodes.Document;
10 | import org.jsoup.nodes.Element;
11 | import org.jsoup.select.Elements;
12 |
13 | public class JavadocHelper {
14 |
15 | public static void loadJavaDoc(TreeMap jdocMap, File p5Ref){
16 | Document doc;
17 |
18 | //Pattern pat = Pattern.compile("\\w+");
19 | try {
20 | if (p5Ref == null) {
21 | System.out.println("P5 Ref location null");
22 | p5Ref = new File(
23 | "/home/quarkninja/Workspaces/processing-workspace/processing/build/linux/work/modes/java/reference");
24 | }
25 |
26 | FileFilter fileFilter = new FileFilter() {
27 | public boolean accept(File file) {
28 | if(!file.getName().endsWith("_.html"))
29 | return false;
30 | int k = 0;
31 | for (int i = 0; i < file.getName().length(); i++) {
32 | if(file.getName().charAt(i)== '_')
33 | k++;
34 | if(k > 1)
35 | return false;
36 | }
37 | return true;
38 | }
39 | };
40 |
41 | for (File docFile : p5Ref.listFiles(fileFilter)) {
42 |
43 | doc = Jsoup.parse(docFile, null);
44 | Elements elm = doc.getElementsByClass("ref-item");
45 | String msg = "";
46 | String methodName = docFile.getName().substring(0, docFile.getName().indexOf('_'));
47 | //System.out.println(methodName);
48 | for (Iterator it = elm.iterator(); it.hasNext();) {
49 | Element ele = (Element) it.next();
50 | msg = "