From a8cd6d598ba8fb7166613eade779ad8372fd0b4d Mon Sep 17 00:00:00 2001 From: Manindra Moharana Date: Mon, 19 Aug 2013 16:02:45 +0530 Subject: [PATCH] improving old code in Problem --- .../mode/experimental/ErrorBar.java | 6 ++--- .../experimental/ErrorCheckerService.java | 24 +++++++++---------- .../processing/mode/experimental/Problem.java | 16 +++++++++---- .../mode/experimental/TextAreaPainter.java | 2 +- 4 files changed, 28 insertions(+), 20 deletions(-) diff --git a/pdex/src/processing/mode/experimental/ErrorBar.java b/pdex/src/processing/mode/experimental/ErrorBar.java index d6b64f9bf..9670df68f 100755 --- a/pdex/src/processing/mode/experimental/ErrorBar.java +++ b/pdex/src/processing/mode/experimental/ErrorBar.java @@ -175,9 +175,9 @@ public class ErrorBar extends JPanel { // because of // class declaration in the beginning as well as default imports for (Problem problem : problems) { - if (problem.tabIndex == currentTab) { + if (problem.getTabIndex() == currentTab) { // Ratio of error line to total lines - float y = (problem.lineNumber - errorCheckerService.defaultImportsOffset) + float y = (problem.getLineNumber() - errorCheckerService.defaultImportsOffset) / ((float) totalLines); // Ratio multiplied by height of the error bar y *= fheight - 15; // -15 is just a vertical offset @@ -294,7 +294,7 @@ public class ErrorBar extends JPanel { && evt.getY() <= eMarker.getY() + 2 + errorMarkerHeight) { Problem p = eMarker.getProblem(); String msg = (p.isError() ? "Error: " : "Warning: ") - + p.message; + + p.getMessage(); setToolTipText(msg); setCursor(Cursor .getPredefinedCursor(Cursor.HAND_CURSOR)); diff --git a/pdex/src/processing/mode/experimental/ErrorCheckerService.java b/pdex/src/processing/mode/experimental/ErrorCheckerService.java index da498bdf5..2f1d168e4 100644 --- a/pdex/src/processing/mode/experimental/ErrorCheckerService.java +++ b/pdex/src/processing/mode/experimental/ErrorCheckerService.java @@ -717,15 +717,15 @@ public class ErrorCheckerService implements Runnable{ try { String[][] errorData = new String[problemsList.size()][3]; for (int i = 0; i < problemsList.size(); i++) { - errorData[i][0] = problemsList.get(i).message; ////TODO: this is temporary + errorData[i][0] = problemsList.get(i).getMessage(); ////TODO: this is temporary //+ " : " + errorMsgSimplifier.getIDName(problemsList.get(i).getIProblem().getID()); errorData[i][1] = editor.getSketch() - .getCode(problemsList.get(i).tabIndex).getPrettyName(); - errorData[i][2] = problemsList.get(i).lineNumber + ""; + .getCode(problemsList.get(i).getTabIndex()).getPrettyName(); + errorData[i][2] = problemsList.get(i).getLineNumber() + ""; //TODO: This is temporary if(tempErrorLog.size() < 200) - tempErrorLog.put(problemsList.get(i).message,problemsList.get(i).getIProblem()); + tempErrorLog.put(problemsList.get(i).getMessage(),problemsList.get(i).getIProblem()); } if (errorWindow != null) { @@ -787,15 +787,15 @@ public class ErrorCheckerService implements Runnable{ // editor.statusNotice("Position: " + // editor.getTextArea().getCaretLine()); for (ErrorMarker emarker : editor.errorBar.errorPoints) { - if (emarker.getProblem().lineNumber == editor.getTextArea() + if (emarker.getProblem().getLineNumber() == editor.getTextArea() .getCaretLine() + 1) { if (emarker.getType() == ErrorMarker.Warning) { - editor.statusNotice(emarker.getProblem().message); + editor.statusNotice(emarker.getProblem().getMessage()); //+ " : " + errorMsgSimplifier.getIDName(emarker.problem.getIProblem().getID())); //TODO: this is temporary } else { - editor.statusError(emarker.getProblem().message); + editor.statusError(emarker.getProblem().getMessage()); //+ " : " + errorMsgSimplifier.getIDName(emarker.problem.getIProblem().getID())); } return; @@ -1172,16 +1172,16 @@ public class ErrorCheckerService implements Runnable{ return; try { editor.toFront(); - editor.getSketch().setCurrentCode(p.tabIndex); + editor.getSketch().setCurrentCode(p.getTabIndex()); editor .setSelection(editor.getTextArea() - .getLineStartNonWhiteSpaceOffset(p.lineNumber - 1) + .getLineStartNonWhiteSpaceOffset(p.getLineNumber() - 1) + editor.getTextArea() - .getLineText(p.lineNumber - 1).trim().length(), + .getLineText(p.getLineNumber() - 1).trim().length(), editor.getTextArea() - .getLineStartNonWhiteSpaceOffset(p.lineNumber - 1)); - editor.getTextArea().scrollTo(p.lineNumber - 1, 0); + .getLineStartNonWhiteSpaceOffset(p.getLineNumber() - 1)); + editor.getTextArea().scrollTo(p.getLineNumber() - 1, 0); editor.repaint(); } catch (Exception e) { System.err.println(e diff --git a/pdex/src/processing/mode/experimental/Problem.java b/pdex/src/processing/mode/experimental/Problem.java index 56cc0e833..e7c907ae9 100644 --- a/pdex/src/processing/mode/experimental/Problem.java +++ b/pdex/src/processing/mode/experimental/Problem.java @@ -44,21 +44,21 @@ public class Problem { /** * The tab number to which the error belongs to */ - public int tabIndex; + private int tabIndex; /** * Line number(pde code) of the error */ - public int lineNumber; + private int lineNumber; /** * Error Message. Processed form of IProblem.getMessage() */ - public String message; + private String message; /** * The type of error - WARNING or ERROR. */ - public int type; + private int type; public static final int ERROR = 1, WARNING = 2; @@ -101,6 +101,14 @@ public class Problem { public IProblem getIProblem(){ return iProblem; } + + public int getTabIndex(){ + return tabIndex; + } + + public int getLineNumber(){ + return lineNumber; + } public void setType(int ProblemType){ if(ProblemType == ERROR) diff --git a/pdex/src/processing/mode/experimental/TextAreaPainter.java b/pdex/src/processing/mode/experimental/TextAreaPainter.java index b5d174038..f8db484bb 100644 --- a/pdex/src/processing/mode/experimental/TextAreaPainter.java +++ b/pdex/src/processing/mode/experimental/TextAreaPainter.java @@ -311,7 +311,7 @@ public class TextAreaPainter extends processing.app.syntax.TextAreaPainter { // Check if current line contains an error. If it does, find if it's an // error or warning for (ErrorMarker emarker : errorCheckerService.getEditor().errorBar.errorPoints) { - if (emarker.getProblem().lineNumber == line + 1) { + if (emarker.getProblem().getLineNumber() == line + 1) { notFound = false; if (emarker.getType() == ErrorMarker.Warning) { isWarning = true;