Skip to content

Commit ce2bd38

Browse files
committed
pulling apart Java Mode from the rest of the PDE
1 parent 928fc80 commit ce2bd38

7 files changed

Lines changed: 66 additions & 39 deletions

File tree

app/src/processing/app/Base.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535

3636
import processing.app.contrib.*;
3737
import processing.core.*;
38-
import processing.mode.java.JavaMode;
38+
3939

4040
/**
4141
* The base class for the main processing application.
@@ -276,7 +276,7 @@ public static void initRequirements() {
276276
private void buildCoreModes() {
277277
Mode javaMode =
278278
ModeContribution.load(this, getContentFile("modes/java"), //$NON-NLS-1$
279-
"processing.mode.java.JavaMode").getMode(); //$NON-NLS-1$
279+
getDefaultModeIdentifier()).getMode(); //$NON-NLS-1$
280280

281281
// PDE X calls getModeList() while it's loading, so coreModes must be set
282282
coreModes = new Mode[] { javaMode };
@@ -620,6 +620,11 @@ private void saveModeSettings(final File sketchProps, final Mode mode) {
620620
}
621621

622622

623+
private String getDefaultModeIdentifier() {
624+
return "processing.mode.java.JavaMode";
625+
}
626+
627+
623628
public Mode getDefaultMode() {
624629
return coreModes[0];
625630
}
@@ -851,8 +856,7 @@ private Mode promptForMode(final File sketch, final ModeInfo preferredMode) {
851856
}
852857
}
853858
if (possibleModes.size() == 1 &&
854-
possibleModes.get(0).getIdentifier()
855-
.equals(JavaMode.class.getCanonicalName())) {
859+
possibleModes.get(0).getIdentifier().equals(getDefaultModeIdentifier())) {
856860
// If default mode can open it, then do so without prompting.
857861
return possibleModes.get(0);
858862
}

app/src/processing/app/syntax/JEditTextArea.java

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1930,19 +1930,13 @@ public void removeNotify() {
19301930
}
19311931
}
19321932

1933-
/**
1934-
* Forwards key events directly to the input handler.
1935-
* This is slightly faster than using a KeyListener
1936-
* because some Swing overhead is avoided.
1937-
*/
1938-
public processing.mode.java.PdeKeyListener editorListener;
1939-
19401933
/**
19411934
* The component that tracks the current line number.
19421935
*/
19431936
public EditorLineStatus editorLineStatus;
19441937

19451938

1939+
/*
19461940
public void processKeyEvent(KeyEvent evt) {
19471941
// this had to be added in Processing 007X, because the menu key
19481942
// events weren't making it up to the frame.
@@ -1968,6 +1962,7 @@ public void processKeyEvent(KeyEvent evt) {
19681962
break;
19691963
}
19701964
}
1965+
*/
19711966

19721967
// protected members
19731968
protected static String CENTER = "center";

app/src/processing/mode/java/JavaEditor.java

Lines changed: 40 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,16 @@
1515
import processing.app.*;
1616
import processing.app.Toolkit;
1717
import processing.app.contrib.ToolContribution;
18+
import processing.app.syntax.JEditTextArea;
19+
import processing.app.syntax.PdeTextAreaDefaults;
1820
import processing.mode.java.runner.Runner;
1921

2022

2123
public class JavaEditor extends Editor {
2224
JavaMode jmode;
2325

2426
// TODO this needs prefs to be applied when necessary
25-
PdeKeyListener listener;
27+
// PdeKeyListener listener;
2628

2729
// Runner associated with this editor window
2830
private Runner runtime;
@@ -31,12 +33,46 @@ public class JavaEditor extends Editor {
3133
protected JavaEditor(Base base, String path, EditorState state, Mode mode) {
3234
super(base, path, state, mode);
3335

34-
// hopefully these are no longer needed w/ swing
35-
// (har har har.. that was wishful thinking)
36-
listener = new PdeKeyListener(this, textarea);
36+
// // hopefully these are no longer needed w/ swing
37+
// // (har har har.. that was wishful thinking)
38+
// listener = new PdeKeyListener(this, textarea);
3739

3840
jmode = (JavaMode) mode;
3941
}
42+
43+
44+
protected JEditTextArea createTextArea() {
45+
return new JEditTextArea(new PdeTextAreaDefaults(mode)) {
46+
// Forwards key events directly to the input handler. This is slightly
47+
// faster than using a KeyListener because some Swing overhead is avoided.
48+
PdeKeyListener editorListener = new PdeKeyListener(JavaEditor.this, this);
49+
50+
// Moved out of JEditTextArea for 3.0a6 to remove dependency on Java Mode
51+
public void processKeyEvent(KeyEvent evt) {
52+
// this had to be added in Processing 007X, because the menu key
53+
// events weren't making it up to the frame.
54+
super.processKeyEvent(evt);
55+
56+
if (inputHandler != null) {
57+
switch (evt.getID()) {
58+
case KeyEvent.KEY_TYPED:
59+
if ((editorListener == null) || !editorListener.keyTyped(evt)) {
60+
inputHandler.keyTyped(evt);
61+
}
62+
break;
63+
case KeyEvent.KEY_PRESSED:
64+
if ((editorListener == null) || !editorListener.keyPressed(evt)) {
65+
inputHandler.keyPressed(evt);
66+
}
67+
break;
68+
case KeyEvent.KEY_RELEASED:
69+
inputHandler.keyReleased(evt);
70+
break;
71+
}
72+
}
73+
}
74+
};
75+
}
4076

4177

4278
public EditorToolbar createToolbar() {

app/src/processing/mode/java/PdeKeyListener.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ public PdeKeyListener(Editor editor, JEditTextArea textarea) {
6161
this.editor = editor;
6262
this.textarea = textarea;
6363

64-
// let him know that i'm leechin'
65-
textarea.editorListener = this;
64+
// // let him know that i'm leechin'
65+
// textarea.editorListener = this;
6666
}
6767

6868

pdex/.classpath

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,17 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<classpath>
33
<classpathentry kind="src" path="src"/>
4-
<classpathentry kind="lib" path="mode/com.ibm.icu_4.4.2.v20110823.jar"/>
54
<classpathentry kind="lib" path="mode/jdi.jar"/>
65
<classpathentry kind="lib" path="mode/jdimodel.jar"/>
7-
<classpathentry kind="lib" path="mode/org.eclipse.core.contenttype_3.4.200.v20120523-2004.jar"/>
8-
<classpathentry kind="lib" path="mode/org.eclipse.core.jobs_3.5.300.v20120622-204750.jar"/>
9-
<classpathentry kind="lib" path="mode/org.eclipse.core.resources_3.8.1.v20120802-154922.jar"/>
10-
<classpathentry kind="lib" path="mode/org.eclipse.core.runtime_3.8.0.v20120521-2346.jar"/>
11-
<classpathentry kind="lib" path="mode/org.eclipse.equinox.common_3.6.100.v20120522-1841.jar"/>
12-
<classpathentry kind="lib" path="mode/org.eclipse.equinox.preferences_3.5.0.v20120522-1841.jar"/>
13-
<classpathentry kind="lib" path="mode/org.eclipse.jdt.core_3.8.2.v20120814-155456.jar"/>
14-
<classpathentry kind="lib" path="mode/org.eclipse.jdt.debug_3.7.101.v20120725-115645.jar"/>
15-
<classpathentry kind="lib" path="mode/org.eclipse.osgi_3.8.1.v20120830-144521.jar"/>
16-
<classpathentry kind="lib" path="mode/org.eclipse.text_3.5.200.v20120523-1310.jar"/>
6+
<classpathentry kind="lib" path="mode/org.eclipse.core.contenttype_3.4.200.v20140207-1251.jar"/>
7+
<classpathentry kind="lib" path="mode/org.eclipse.core.jobs_3.6.0.v20140424-0053.jar"/>
8+
<classpathentry kind="lib" path="mode/org.eclipse.core.resources_3.9.1.v20140825-1431.jar"/>
9+
<classpathentry kind="lib" path="mode/org.eclipse.core.runtime_3.10.0.v20140318-2214.jar"/>
10+
<classpathentry kind="lib" path="mode/org.eclipse.equinox.common_3.6.200.v20130402-1505.jar"/>
11+
<classpathentry kind="lib" path="mode/org.eclipse.equinox.preferences_3.5.200.v20140224-1527.jar"/>
12+
<classpathentry kind="lib" path="mode/org.eclipse.jdt.core_3.10.0.v20140902-0626.jar"/>
13+
<classpathentry kind="lib" path="mode/org.eclipse.osgi_3.10.1.v20140909-1633.jar"/>
14+
<classpathentry kind="lib" path="mode/org.eclipse.text_3.5.300.v20130515-1451.jar"/>
1715
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
1816
<classpathentry combineaccessrules="false" kind="src" path="/processing-app"/>
1917
<classpathentry combineaccessrules="false" kind="src" path="/processing-core"/>

pdex/src/processing/mode/experimental/SketchOutline.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -320,8 +320,7 @@ protected void generateSketchOutlineTree(DefaultMutableTreeNode node,
320320
.toString());
321321
} else if (awnode.getNode() instanceof FieldDeclaration) {
322322
FieldDeclaration fd = (FieldDeclaration) awnode.getNode();
323-
for (VariableDeclarationFragment vdf : (List<VariableDeclarationFragment>) fd
324-
.fragments()) {
323+
for (VariableDeclarationFragment vdf : (List<VariableDeclarationFragment>) fd.fragments()) {
325324
DefaultMutableTreeNode newNode = new DefaultMutableTreeNode(
326325
new ASTNodeWrapper(
327326
vdf.getName(),

todo.txt

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,6 @@ X http://download.eclipse.org/eclipse/downloads/drops4/R-4.4.1-201409250400/
1616
X update to launch4j 3.6
1717
X http://sourceforge.net/projects/launch4j/files/launch4j-3/3.6/
1818

19-
20-
_ Determine shortcut for Export vs Use Selection for Find
21-
_ https://github.com/processing/processing/issues/2985
22-
23-
2419
earlier
2520
X any problems with new code signing crap?
2621
X issues raised around the symlink (just replace with a copy of the binary?)
@@ -94,8 +89,6 @@ _ finish Ant task to download JRE and JDK from Oracle
9489
_ add method to prompt OS X developers to download the JDK update
9590
_ https://github.com/processing/processing/issues/2960
9691

97-
_ Add support for localizing contributions
98-
_ https://github.com/processing/processing/pull/2833
9992

10093
from the todo list
10194
_ reas: comments go nasty when auto-formatted
@@ -120,8 +113,6 @@ _ https://github.com/processing/processing/issues/2944
120113

121114

122115
pending
123-
_ bug in getCaretLocation of CompositionTextPainter class
124-
_ https://github.com/processing/processing/issues/2934
125116
_ look at the sound library https://github.com/wirsing/ProcessingSound
126117
_ sound is not yet supported on Windows
127118
_ make reference build process part of dist
@@ -132,6 +123,8 @@ _ processing-docs/java_generate/ReferenceGenerator/processingrefBuild.sh
132123
_ remove reference.zip from main repo
133124
_ clean out the repo
134125
_ https://github.com/processing/processing/issues/1898
126+
_ Add support for localizing contributions
127+
_ https://github.com/processing/processing/pull/2833
135128

136129

137130
help me
@@ -163,6 +156,8 @@ _ https://github.com/processing/processing/issues/2955
163156

164157

165158
medium
159+
_ Determine shortcut for Export vs Use Selection for Find
160+
_ https://github.com/processing/processing/issues/2985
166161
_ remove toolbar menu references and code to rebuild
167162
_ fix single instance server on OS X to load double-clicked files
168163
_ when run from Eclipse, the single instance thing punts

0 commit comments

Comments
 (0)