From d151ec2eb5dd4fc97232491cf3de0323a07136e7 Mon Sep 17 00:00:00 2001 From: benfry Date: Tue, 20 Oct 2009 12:10:35 +0000 Subject: [PATCH] remove menu dimming (bug #786), other fixes --- app/src/processing/app/Base.java | 22 ++----- app/src/processing/app/Editor.java | 63 +++++++++++++++++++++ app/src/processing/app/macosx/Platform.java | 1 + 3 files changed, 68 insertions(+), 18 deletions(-) diff --git a/app/src/processing/app/Base.java b/app/src/processing/app/Base.java index 6dc93040b..003a6908d 100644 --- a/app/src/processing/app/Base.java +++ b/app/src/processing/app/Base.java @@ -926,16 +926,9 @@ public class Base { protected void rebuildSketchbookMenu(JMenu menu) { //System.out.println("rebuilding sketchbook menu"); //new Exception().printStackTrace(); - boolean nativeButBroken = Base.isMacOS() ? - Preferences.getBoolean("apple.laf.useScreenMenuBar") : false; - try { - if (nativeButBroken) { // osx workaround - menu.setEnabled(false); - } else { - menu.removeAll(); - addSketches(menu, getSketchbookFolder(), false); - } + menu.removeAll(); + addSketches(menu, getSketchbookFolder(), false); } catch (IOException e) { e.printStackTrace(); } @@ -974,16 +967,9 @@ public class Base { public void rebuildExamplesMenu(JMenu menu) { //System.out.println("rebuilding examples menu"); - boolean nativeButBroken = Base.isMacOS() ? - Preferences.getBoolean("apple.laf.useScreenMenuBar") : false; - try { - if (nativeButBroken) { // osx workaround - menu.setEnabled(false); - } else { - menu.removeAll(); - addSketches(menu, examplesFolder, false); - } + menu.removeAll(); + addSketches(menu, examplesFolder, false); } catch (IOException e) { e.printStackTrace(); } diff --git a/app/src/processing/app/Editor.java b/app/src/processing/app/Editor.java index 91a08372e..e520b7868 100644 --- a/app/src/processing/app/Editor.java +++ b/app/src/processing/app/Editor.java @@ -41,6 +41,11 @@ import javax.swing.event.*; import javax.swing.text.*; import javax.swing.undo.*; +//import org.netbeans.api.java.source.ui.DialogBinding; +//import org.openide.filesystems.*; +//import org.openide.loaders.DataObject; +//import org.openide.text.CloneableEditorSupport; + /** * Main editor panel for the Processing Development Environment. @@ -100,6 +105,9 @@ public class Editor extends JFrame implements RunnerListener { EditorLineStatus lineStatus; + boolean newEditor = true; + JEditorPane editorPane; + JEditTextArea textarea; EditorListener listener; @@ -207,7 +215,22 @@ public class Editor extends JFrame implements RunnerListener { lineStatus = new EditorLineStatus(textarea); consolePanel.add(lineStatus, BorderLayout.SOUTH); +// if (newEditor) { +// try { +// setupEditorPane(); +// upper.add(editorPane); +// } catch (Exception e1) { +// PrintWriter w = PApplet.createWriter(new File("/Users/fry/Desktop/blah.txt")); +// w.println(e1.getMessage()); +// e1.printStackTrace(w); +// w.flush(); +// w.close(); +//// e1.printStackTrace()); +//// e1.printStackTrace(System.out); +// } +// } else { upper.add(textarea); +// } splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, upper, consolePanel); @@ -323,6 +346,46 @@ public class Editor extends JFrame implements RunnerListener { } + /* + // http://wiki.netbeans.org/DevFaqEditorCodeCompletionAnyJEditorPane + void setupEditorPane() throws IOException { + editorPane = new JEditorPane(); + + // This will find the Java editor kit and associate it with + // our editor pane. But that does not give us code completion + // just yet because we have no Java context (i.e. no class path, etc.). + // However, this does give us syntax coloring. + EditorKit kit = CloneableEditorSupport.getEditorKit("text/x-java"); + editorPane.setEditorKit(kit); + + // You can specify any ".java" file. + // If the file does not exist, it will be created. + // The contents of the file does not matter. + // The extension must be ".java", however. +// String newSourcePath = "/Users/fry/Desktop/tmp.java"; + +// File tmpFile = new File(newSourcePath); +// System.out.println(tmpFile.getParent() + " " + tmpFile.getName()); +// FileObject fob = FileUtil.createData(tmpFile); + File tmpFile = File.createTempFile("temp", ".java"); + FileObject fob = FileUtil.toFileObject(FileUtil.normalizeFile(tmpFile)); + + DataObject dob = DataObject.find(fob); + editorPane.getDocument().putProperty(Document.StreamDescriptionProperty, dob); + + // This sets up a default class path for us so that + // we can find all the JDK classes via code completion. + DialogBinding.bindComponentToFile(fob, 0, 0, editorPane); + + // Last but not least, we need to fill the editor pane with + // some initial dummy code - as it seems somehow required to + // kick-start code completion. + // A simple dummy package declaration will do. + editorPane.setText("package dummy;"); + } + */ + + protected void setPlacement(int[] location) { setBounds(location[0], location[1], location[2], location[3]); if (location[4] != 0) { diff --git a/app/src/processing/app/macosx/Platform.java b/app/src/processing/app/macosx/Platform.java index b7cbf6356..048f90b48 100644 --- a/app/src/processing/app/macosx/Platform.java +++ b/app/src/processing/app/macosx/Platform.java @@ -48,6 +48,7 @@ public class Platform extends processing.app.Platform { public void init(Base base) { + System.setProperty("apple.laf.useScreenMenuBar", "true"); ThinkDifferent.init(base); /* try {