From 01c65e11a84f63e1951fabc9c6b5317e23e7bb64 Mon Sep 17 00:00:00 2001 From: benfry Date: Tue, 15 Jul 2003 23:53:34 +0000 Subject: [PATCH] resizable console and text area [danh] beginnings of better error message when void is missing [danh] --- processing/app/PdeCompilerKjc.java | 5 +++ processing/app/PdeEditor.java | 53 ++++++++++++++++++---------- processing/app/PdeEditorConsole.java | 15 +++++--- 3 files changed, 50 insertions(+), 23 deletions(-) diff --git a/processing/app/PdeCompilerKjc.java b/processing/app/PdeCompilerKjc.java index f8e78f370..6c44373b7 100644 --- a/processing/app/PdeCompilerKjc.java +++ b/processing/app/PdeCompilerKjc.java @@ -51,6 +51,11 @@ public class PdeCompilerKjc extends PdeCompiler { //err += "error:".length(); String description = s1.substring(err + "error:".length()); description = description.trim(); + + // as in: ...error:Constructor setup must be named Temporary_5362_2548 [JL1 8.6] + if(description.indexOf("Constructor setup must be named") != -1) { + description = "Missing function return type, or constructor does not match class name"; + } //exception = new PdeException(description, lineNumber-2); exception = new PdeException(description, lineNumber-1); editor.error(exception); diff --git a/processing/app/PdeEditor.java b/processing/app/PdeEditor.java index 810c3e24f..3993a0490 100644 --- a/processing/app/PdeEditor.java +++ b/processing/app/PdeEditor.java @@ -13,7 +13,8 @@ import javax.swing.event.*; import javax.swing.text.*; -public class PdeEditor extends Panel { +//public class PdeEditor extends Panel { +public class PdeEditor extends JPanel { static final String DEFAULT_PROGRAM = "// type program here\n"; @@ -45,9 +46,11 @@ public class PdeEditor extends Panel { PdeEditorHeader header; PdeEditorStatus status; PdeEditorConsole console; + + // new swing jpanel/console + JSplitPane splitPane; + JPanel consolePanel; - //JEditorPane textarea; - //public PdeEditorTextPane textarea; JEditTextArea textarea; boolean externalEditor; @@ -117,6 +120,8 @@ public class PdeEditor extends Panel { add("West", leftPanel); + +/* pre-swing version Panel rightPanel = new Panel(); rightPanel.setLayout(new BoxLayout(rightPanel, BoxLayout.Y_AXIS)); @@ -138,29 +143,39 @@ public class PdeEditor extends Panel { statusPanel.add("South", console); rightPanel.add("South", statusPanel); +*/ + // swing version from danh + JPanel rightPanel = new JPanel(); + rightPanel.setLayout(new BorderLayout()); - /* not sure why this doesn't work, probably a heavy vs. lightweight component issue - Panel consolePanel = new Panel(); - consolePanel.setLayout(new BoxLayout(consolePanel, BoxLayout.Y_AXIS)); + header = new PdeEditorHeader(this); + rightPanel.add(header, BorderLayout.NORTH); + + textarea = new JEditTextArea(); + textarea.setTokenMarker(new PdeTokenMarker()); + + // assemble console panel, consisting of status area and the console itself + consolePanel = new JPanel(); + consolePanel.setLayout(new BorderLayout()); status = new PdeEditorStatus(this); - consolePanel.add("North",status); + consolePanel.add(status, BorderLayout.NORTH); console = new PdeEditorConsole(this); - consolePanel.add("South",console); + consolePanel.add(console, BorderLayout.CENTER); -/// - JSplitPane splitPane = new JSplitPane( - JSplitPane.VERTICAL_SPLIT, -/// textarea, consolePanel); - //splitPane.setOneTouchExpandable(true); - splitPane.setDividerLocation(100); + splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, + textarea, consolePanel); + + splitPane.setOneTouchExpandable(true); + // repaint child panes while resizing + splitPane.setContinuousLayout(true); + // if window increases in size, give all of increase to textarea (top pane) + splitPane.setResizeWeight(1D); - //Provide minimum sizes for the two components in the split pane - Dimension minimumSize = new Dimension(200, 300); - top.setMinimumSize(minimumSize); - bottom.setMinimumSize(minimumSize); -*/ + rightPanel.add(splitPane, BorderLayout.CENTER); + + // end swing version from danh add("Center", rightPanel); diff --git a/processing/app/PdeEditorConsole.java b/processing/app/PdeEditorConsole.java index cd0a4d57b..8fc14c952 100644 --- a/processing/app/PdeEditorConsole.java +++ b/processing/app/PdeEditorConsole.java @@ -84,9 +84,13 @@ public class PdeEditorConsole extends JScrollPane { // add the jtextpane to this scrollpane this.setViewportView(consoleTextPane); - // todo: don't think this does anything - //XXX the initial size should be from properties file - this.setPreferredSize(new Dimension(200, 50)); + // calculate height of a line of text in pixels and size window accordingly + FontMetrics metrics = this.getFontMetrics(font); + int height = metrics.getAscent() + metrics.getDescent(); + int lines = PdeBase.getInteger("editor.console.lines", 6); + int sizeFudge = 10; // unclear why this is necessary, but it is + Dimension prefDimension = new Dimension(1024, (height * lines) + sizeFudge); + setPreferredSize(prefDimension); if (systemOut == null) { systemOut = System.out; @@ -183,6 +187,9 @@ public class PdeEditorConsole extends JScrollPane { catch(Exception e) {} } +/* +// no longer needed because setPreferredSize is used + public Dimension getPreferredSize() { return getMinimumSize(); } @@ -194,7 +201,7 @@ public class PdeEditorConsole extends JScrollPane { public Dimension getMaximumSize() { return new Dimension(3000, PdeEditor.GRID_SIZE * 3); } - +*/ }