From 0aeed532af48cd9b7ab147507821b8c1a423ac76 Mon Sep 17 00:00:00 2001 From: fjenett Date: Sun, 9 Dec 2012 19:52:14 +0000 Subject: [PATCH] updated js mode theme to have new colors and additional keywords, updated examples to not show 'Contributed Libraries' entry --- .../mode/javascript/JavaScriptMode.java | 30 +++++++++++++++-- javascript/theme/theme.txt | 32 +++++++------------ 2 files changed, 38 insertions(+), 24 deletions(-) diff --git a/app/src/processing/mode/javascript/JavaScriptMode.java b/app/src/processing/mode/javascript/JavaScriptMode.java index 9d3dc1bd8..7d609c942 100644 --- a/app/src/processing/mode/javascript/JavaScriptMode.java +++ b/app/src/processing/mode/javascript/JavaScriptMode.java @@ -6,6 +6,8 @@ import java.io.IOException; import processing.app.*; import processing.mode.java.JavaMode; +import javax.swing.*; +import javax.swing.tree.*; /** * JS Mode for Processing based on Processing.js. Comes with a server as @@ -196,9 +198,9 @@ public class JavaScriptMode extends Mode File jExamples = jMode.getContentFile("examples"); File[] jModeExamples = new File[] { new File(jExamples, "Basics"), - new File(jExamples, "Topics"), - new File(jExamples, "3D") /*, - new File(jExamples, "Books")*/ + //new File(jExamples, "Topics"), + //new File(jExamples, "3D") , + //new File(jExamples, "Books") }; // merge them all @@ -208,8 +210,30 @@ public class JavaScriptMode extends Mode for ( int i = 0; i < jModeExamples.length; i++ ) finalExamples[inclExamples.length+i] = jModeExamples[i]; + java.util.Arrays.sort(finalExamples); + return finalExamples; } + + /** + * Overriding this from Mode.java to remove "Contributed Libraries" + */ + + public JTree buildExamplesTree() + { + JTree superTree = super.buildExamplesTree(); + + DefaultTreeModel model = (DefaultTreeModel) superTree.getModel(); + DefaultMutableTreeNode root = (DefaultMutableTreeNode) model.getRoot(); + DefaultMutableTreeNode contribExamples = (DefaultMutableTreeNode) root.getLastChild(); + Object title = contribExamples.getUserObject(); + if ( title != null && title.getClass() == String.class && ((String)title).equals("Contributed Libraries") ) + { + root.remove( contribExamples ); + } + + return superTree; + } /** * Return the default extension for this mode, same as Java diff --git a/javascript/theme/theme.txt b/javascript/theme/theme.txt index b9fcb31ef..780b37844 100644 --- a/javascript/theme/theme.txt +++ b/javascript/theme/theme.txt @@ -72,28 +72,18 @@ editor.brackethighlight = true editor.brackethighlight.color = #006699 -# TEXT - KEYWORDS +# TEXT - FUNCTIONS, KEYWORDS, LITERALS -editor.function1.style = #cc6600,plain -editor.function2.style = #cc6600,bold - -# e.g abstract, final, private -editor.keyword1.style = #cc6600,plain - -# e.g. beginShape, point, line -editor.keyword2.style = #cc6600,plain - -# e.g. byte, char, short, color -editor.keyword3.style = #cc6600,bold - - -# TEXT - LITERALS - -# constants: e.g. null, true, this, RGB, TWO_PI -editor.literal1.style = #006699,plain - -# p5 built in variables: e.g. mouseX, width, pixels -editor.literal2.style = #006699,plain +editor.function1.style = #006699,plain +editor.function2.style = #006699,plain +editor.function3.style = #669933,plain +editor.keyword1.style = #7e3d22,plain +editor.keyword2.style = #EE3C96,plain +editor.keyword3.style = #669933,plain +editor.keyword4.style = #EE3C96,plain +editor.keyword5.style = #D86736,plain +editor.literal1.style = #7D4793,plain +editor.literal2.style = #5F6C53,plain # e.g. + - = / editor.operator.style = #000000,plain