From: <aki...@us...> - 2006-05-28 22:05:05
|
Revision: 64 Author: akirschbaum Date: 2006-05-28 15:04:50 -0700 (Sun, 28 May 2006) ViewCVS: http://svn.sourceforge.net/gridarta/?rev=64&view=rev Log Message: ----------- Unified classes: whitespace changes, add final/static. Modified Paths: -------------- trunk/crossfire/src/cfeditor/textedit/textarea/TokenMarker.java trunk/daimonin/src/daieditor/textedit/textarea/TokenMarker.java Modified: trunk/crossfire/src/cfeditor/textedit/textarea/TokenMarker.java =================================================================== --- trunk/crossfire/src/cfeditor/textedit/textarea/TokenMarker.java 2006-05-28 21:56:20 UTC (rev 63) +++ trunk/crossfire/src/cfeditor/textedit/textarea/TokenMarker.java 2006-05-28 22:04:50 UTC (rev 64) @@ -31,24 +31,23 @@ * @param line the line * @param lineIndex the line number */ - public Token markTokens(Segment line, int lineIndex) { + public final Token markTokens(final Segment line, final int lineIndex) { if (lineIndex >= length) { throw new IllegalArgumentException("Tokenizing invalid line: " + lineIndex); } lastToken = null; - LineInfo info = lineInfo[lineIndex]; - LineInfo prev; + final LineInfo info = lineInfo[lineIndex]; + final LineInfo prev; if (lineIndex == 0) { prev = null; } else { prev = lineInfo[lineIndex - 1]; } - byte oldToken = info.token; - byte token = markTokensImpl(prev == null ? - Token.NULL : prev.token, line, lineIndex); + final byte oldToken = info.token; + final byte token = markTokensImpl(prev == null ? Token.NULL : prev.token, line, lineIndex); info.token = token; @@ -91,7 +90,7 @@ * duplicate it. */ if (!(lastLine == lineIndex && nextLineRequested)) { - nextLineRequested = (oldToken != token); + nextLineRequested = oldToken != token; } lastLine = lineIndex; @@ -115,8 +114,7 @@ * @param lineIndex the index of the line in the document, starting at 0 * @return the initial token type for the next line */ - protected abstract byte markTokensImpl(byte token, Segment line, - int lineIndex); + protected abstract byte markTokensImpl(byte token, Segment line, int lineIndex); /** * Returns if the token marker supports tokens that span multiple lines. If @@ -127,7 +125,7 @@ * The default implementation returns true; it should be overridden to * return false on simpler token markers for increased speed. */ - public boolean supportsMultilineTokens() { + public static final boolean supportsMultilineTokens() { return true; } @@ -137,14 +135,13 @@ * @param index the first line number * @param lines the number of lines */ - public void insertLines(int index, int lines) { + public final void insertLines(final int index, final int lines) { if (lines <= 0) { return; } - length += lines; ensureCapacity(length); - int len = index + lines; + final int len = index + lines; System.arraycopy(lineInfo, index, lineInfo, len, lineInfo.length - len); for (int i = index + lines - 1; i >= index; i--) { @@ -158,18 +155,17 @@ * @param index the first line number * @param lines the number of lines */ - public void deleteLines(int index, int lines) { + public final void deleteLines(final int index, final int lines) { if (lines <= 0) { return; } - - int len = index + lines; + final int len = index + lines; length -= lines; System.arraycopy(lineInfo, len, lineInfo, index, lineInfo.length - len); } /** Returns the number of lines in this token marker. */ - public int getLineCount() { + public final int getLineCount() { return length; } @@ -178,7 +174,7 @@ * after a line has been tokenized that starts a multiline token that * continues onto the next line. */ - public boolean isNextLineRequested() { + public final boolean isNextLineRequested() { return nextLineRequested; } @@ -233,11 +229,11 @@ * array automatically. * @param index the array index */ - protected void ensureCapacity(int index) { + protected final void ensureCapacity(final int index) { if (lineInfo == null) { lineInfo = new LineInfo[index + 1]; } else if (lineInfo.length <= index) { - LineInfo[] lineInfoN = new LineInfo[(index + 1) * 2]; + final LineInfo[] lineInfoN = new LineInfo[(index + 1) * 2]; System.arraycopy(lineInfo, 0, lineInfoN, 0, lineInfo.length); lineInfo = lineInfoN; } @@ -248,7 +244,7 @@ * @param length the length of the token * @param id the id of the token */ - protected void addToken(int length, byte id) { + protected final void addToken(final int length, final byte id) { if (id >= Token.INTERNAL_FIRST && id <= Token.INTERNAL_LAST) { throw new InternalError("Invalid id: " + id); } @@ -275,7 +271,7 @@ } /** Inner class for storing information about tokenized lines. */ - public class LineInfo { + public static final class LineInfo { /** * Creates a new LineInfo object with token = Token.NULL and obj = @@ -284,8 +280,10 @@ public LineInfo() { } - /** Creates a new LineInfo object with the specified parameters. */ - public LineInfo(byte token, Object obj) { + /** + * Creates a new LineInfo object with the specified parameters. + */ + public LineInfo(final byte token, final Object obj) { this.token = token; this.obj = obj; } @@ -299,5 +297,6 @@ * exist on a per-line basis. */ public Object obj; - } -} + } // class LineInfo + +} // class TokenMarker Modified: trunk/daimonin/src/daieditor/textedit/textarea/TokenMarker.java =================================================================== --- trunk/daimonin/src/daieditor/textedit/textarea/TokenMarker.java 2006-05-28 21:56:20 UTC (rev 63) +++ trunk/daimonin/src/daieditor/textedit/textarea/TokenMarker.java 2006-05-28 22:04:50 UTC (rev 64) @@ -12,25 +12,24 @@ import javax.swing.text.Segment; /** - * A token marker that splits lines of text into tokens. Each token carries - * a length field and an indentification tag that can be mapped to a color - * for painting that token.<p> + * A token marker that splits lines of text into tokens. Each token carries a + * length field and an indentification tag that can be mapped to a color for + * painting that token.<p> * <p/> - * For performance reasons, the linked list of tokens is reused after each - * line is tokenized. Therefore, the return value of <code>markTokens</code> - * should only be used for immediate painting. Notably, it cannot be - * cached. + * For performance reasons, the linked list of tokens is reused after each line + * is tokenized. Therefore, the return value of <code>markTokens</code> should + * only be used for immediate painting. Notably, it cannot be cached. * @author Slava Pestov * @version $Id: TokenMarker.java,v 1.8 2005/08/09 13:41:55 christianhujer Exp $ - * @see "org.gjt.sp.jedit.syntax.Token" + * @see Token */ public abstract class TokenMarker { /** - * A wrapper for the lower-level <code>markTokensImpl</code> method - * that is called to split a line up into tokens. - * @param line The line - * @param lineIndex The line number + * A wrapper for the lower-level <code>markTokensImpl</code> method that is + * called to split a line up into tokens. + * @param line the line + * @param lineIndex the line number */ public final Token markTokens(final Segment line, final int lineIndex) { if (lineIndex >= length) { @@ -102,42 +101,39 @@ } /** - * An abstract method that splits a line up into tokens. It - * should parse the line, and call <code>addToken()</code> to - * add syntax tokens to the token list. Then, it should return - * the initial token type for the next line.<p> + * An abstract method that splits a line up into tokens. It should parse + * the line, and call <code>addToken()</code> to add syntax tokens to the + * token list. Then, it should return the initial token type for the next + * line.<p> * <p/> - * For example if the current line contains the start of a - * multiline comment that doesn't end on that line, this method - * should return the comment token type so that it continues on - * the next line. - * @param token The initial token type for this line - * @param line The line to be tokenized - * @param lineIndex The index of the line in the document, - * starting at 0 - * @return The initial token type for the next line + * For example if the current line contains the start of a multiline + * comment that doesn't end on that line, this method should return the + * comment token type so that it continues on the next line. + * @param token the initial token type for this line + * @param line the line to be tokenized + * @param lineIndex the index of the line in the document, starting at 0 + * @return the initial token type for the next line */ protected abstract byte markTokensImpl(byte token, Segment line, int lineIndex); /** - * Returns if the token marker supports tokens that span multiple - * lines. If this is true, the object using this token marker is - * required to pass all lines in the document to the - * <code>markTokens()</code> method (in turn).<p> + * Returns if the token marker supports tokens that span multiple lines. If + * this is true, the object using this token marker is required to pass all + * lines in the document to the <code>markTokens()</code> method (in + * turn).<p> * <p/> - * The default implementation returns true; it should be overridden - * to return false on simpler token markers for increased speed. + * The default implementation returns true; it should be overridden to + * return false on simpler token markers for increased speed. */ public static final boolean supportsMultilineTokens() { return true; } /** - * Informs the token marker that lines have been inserted into - * the document. This inserts a gap in the <code>lineInfo</code> - * array. - * @param index The first line number - * @param lines The number of lines + * Informs the token marker that lines have been inserted into the + * document. This inserts a gap in the <code>lineInfo</code> array. + * @param index the first line number + * @param lines the number of lines */ public final void insertLines(final int index, final int lines) { if (lines <= 0) { @@ -154,11 +150,10 @@ } /** - * Informs the token marker that line have been deleted from - * the document. This removes the lines in question from the - * <code>lineInfo</code> array. - * @param index The first line number - * @param lines The number of lines + * Informs the token marker that line have been deleted from the document. + * This removes the lines in question from the <code>lineInfo</code> array. + * @param index the first line number + * @param lines the number of lines */ public final void deleteLines(final int index, final int lines) { if (lines <= 0) { @@ -175,9 +170,9 @@ } /** - * Returns true if the next line should be repainted. This - * will return true after a line has been tokenized that starts - * a multiline token that continues onto the next line. + * Returns true if the next line should be repainted. This will return true + * after a line has been tokenized that starts a multiline token that + * continues onto the next line. */ public final boolean isNextLineRequested() { return nextLineRequested; @@ -186,27 +181,27 @@ // protected members /** - * The first token in the list. This should be used as the return - * value from <code>markTokens()</code>. + * The first token in the list. This should be used as the return value + * from <code>markTokens()</code>. */ protected Token firstToken; /** - * The last token in the list. New tokens are added here. - * This should be set to null before a new line is to be tokenized. + * The last token in the list. New tokens are added here. This should be + * set to null before a new line is to be tokenized. */ protected Token lastToken; /** - * An array for storing information about lines. It is enlarged and - * shrunk automatically by the <code>insertLines()</code> and + * An array for storing information about lines. It is enlarged and shrunk + * automatically by the <code>insertLines()</code> and * <code>deleteLines()</code> methods. */ protected LineInfo[] lineInfo; /** - * The number of lines in the model being tokenized. This can be - * less than the length of the <code>lineInfo</code> array. + * The number of lines in the model being tokenized. This can be less than + * the length of the <code>lineInfo</code> array. */ protected int length; @@ -217,29 +212,28 @@ protected boolean nextLineRequested; /** - * Creates a new <code>TokenMarker</code>. This DOES NOT create - * a lineInfo array; an initial call to <code>insertLines()</code> - * does that. + * Creates a new <code>TokenMarker</code>. This DOES NOT create a lineInfo + * array; an initial call to <code>insertLines()</code> does that. */ protected TokenMarker() { lastLine = -1; } /** - * Ensures that the <code>lineInfo</code> array can contain the - * specified index. This enlarges it if necessary. No action is - * taken if the array is large enough already.<p> + * Ensures that the <code>lineInfo</code> array can contain the specified + * index. This enlarges it if necessary. No action is taken if the array is + * large enough already.<p> * <p/> - * It should be unnecessary to call this under normal - * circumstances; <code>insertLine()</code> should take care of - * enlarging the line info array automatically. - * @param index The array index + * It should be unnecessary to call this under normal circumstances; + * <code>insertLine()</code> should take care of enlarging the line info + * array automatically. + * @param index the array index */ protected final void ensureCapacity(final int index) { if (lineInfo == null) { lineInfo = new LineInfo[index + 1]; } else if (lineInfo.length <= index) { - final LineInfo[] lineInfoN = new LineInfo[index + 1 << 1]; + final LineInfo[] lineInfoN = new LineInfo[(index + 1) * 2]; System.arraycopy(lineInfo, 0, lineInfoN, 0, lineInfo.length); lineInfo = lineInfoN; } @@ -247,8 +241,8 @@ /** * Adds a token to the token list. - * @param length The length of the token - * @param id The id of the token + * @param length the length of the token + * @param id the id of the token */ protected final void addToken(final int length, final byte id) { if (id >= Token.INTERNAL_FIRST && id <= Token.INTERNAL_LAST) { @@ -280,15 +274,14 @@ public static final class LineInfo { /** - * Creates a new LineInfo object with token = Token.NULL - * and obj = null. + * Creates a new LineInfo object with token = Token.NULL and obj = + * null. */ public LineInfo() { } /** - * Creates a new LineInfo object with the specified - * parameters. + * Creates a new LineInfo object with the specified parameters. */ public LineInfo(final byte token, final Object obj) { this.setToken(token); @@ -299,10 +292,9 @@ private byte token; /** - * This is for use by the token marker implementations - * themselves. It can be used to store anything that - * is an object and that needs to exist on a per-line - * basis. + * This is for use by the token marker implementations themselves. It + * can be used to store anything that is an object and that needs to + * exist on a per-line basis. */ private Object obj; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2006-05-29 08:45:05
|
Revision: 67 Author: akirschbaum Date: 2006-05-29 01:44:37 -0700 (Mon, 29 May 2006) ViewCVS: http://svn.sourceforge.net/gridarta/?rev=67&view=rev Log Message: ----------- Unified classes: whitespace changes, add final/static. Modified Paths: -------------- trunk/crossfire/src/cfeditor/textedit/textarea/JEditTextArea.java trunk/crossfire/src/cfeditor/textedit/textarea/JavaScriptTokenMarker.java trunk/crossfire/src/cfeditor/textedit/textarea/KeywordMap.java trunk/crossfire/src/cfeditor/textedit/textarea/SyntaxDocument.java trunk/crossfire/src/cfeditor/textedit/textarea/SyntaxStyle.java trunk/crossfire/src/cfeditor/textedit/textarea/SyntaxUtilities.java trunk/crossfire/src/cfeditor/textedit/textarea/TextAreaDefaults.java trunk/crossfire/src/cfeditor/textedit/textarea/TextAreaPainter.java trunk/crossfire/src/cfeditor/textedit/textarea/TextUtilities.java trunk/crossfire/src/cfeditor/textedit/textarea/Token.java trunk/crossfire/src/cfeditor/textedit/textarea/XMLTokenMarker.java trunk/daimonin/src/daieditor/textedit/textarea/JEditTextArea.java trunk/daimonin/src/daieditor/textedit/textarea/KeywordMap.java trunk/daimonin/src/daieditor/textedit/textarea/SyntaxDocument.java trunk/daimonin/src/daieditor/textedit/textarea/SyntaxStyle.java trunk/daimonin/src/daieditor/textedit/textarea/SyntaxUtilities.java trunk/daimonin/src/daieditor/textedit/textarea/TextAreaDefaults.java trunk/daimonin/src/daieditor/textedit/textarea/TextAreaPainter.java trunk/daimonin/src/daieditor/textedit/textarea/TextUtilities.java trunk/daimonin/src/daieditor/textedit/textarea/Token.java Modified: trunk/crossfire/src/cfeditor/textedit/textarea/JEditTextArea.java =================================================================== --- trunk/crossfire/src/cfeditor/textedit/textarea/JEditTextArea.java 2006-05-28 23:20:56 UTC (rev 66) +++ trunk/crossfire/src/cfeditor/textedit/textarea/JEditTextArea.java 2006-05-29 08:44:37 UTC (rev 67) @@ -82,26 +82,29 @@ * ta.setTokenMarker(new JavaTokenMarker()); * ta.setText("public class Test {\n" * + " public static void main(String[] args) {\n" - * + " System.out.println(\"Hello World\");\n" + * + " System.err.println(\"Hello World\");\n" * + " }\n" * + "}");</pre> * @author Slava Pestov * @author <a href="mailto:and...@gm...">Andreas Vogl</a> * @version $Id: JEditTextArea.java,v 1.11 2006/03/26 00:48:57 akirschbaum Exp $ */ -public class JEditTextArea extends JComponent { +public final class JEditTextArea extends JComponent { private static final Logger log = Logger.getLogger(JEditTextArea.class); /** + * Serial Version UID. + */ + private static final long serialVersionUID = -1060281617538289153L; + + /** * Adding components with this name to the text area will place them left * of the horizontal scroll bar. In jEdit, the status bar is added this * way. */ public static final String LEFT_OF_SCROLLBAR = "los"; - private static final long serialVersionUID = -1060281617538289153L; - /** Creates a new JEditTextArea with the default settings. */ public JEditTextArea() { this(TextAreaDefaults.getDefaults()); @@ -111,7 +114,7 @@ * Creates a new JEditTextArea with the specified settings. * @param defaults the default settings */ - public JEditTextArea(TextAreaDefaults defaults) { + public JEditTextArea(final TextAreaDefaults defaults) { // Enable the necessary events enableEvents(AWTEvent.KEY_EVENT_MASK); @@ -160,7 +163,7 @@ * key normally does not "work" inside the text area. But that would be a pity, * because we need the tab key for indentation. * <p/> - * So what this method does is setting the focus traversal to "tab + <control>", + * So what this method does is setting the focus traversal to "tab + <control>", * in order to "free" the tab key from focus traversal events. * In JDKs above 1.4, this task can be accomplished simply by three lines of code: * <code> @@ -181,29 +184,29 @@ private void freeTabKeyFromFocusTraversal() { try { // preparing the key set first, this should be harmless - Set forwardTraversalKeys = new HashSet(); + final Set forwardTraversalKeys = new HashSet(); forwardTraversalKeys.add(KeyStroke.getKeyStroke("control TAB")); // here we try to access java.awt.KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS - Field field = Class.forName("java.awt.KeyboardFocusManager").getField("FORWARD_TRAVERSAL_KEYS"); - Integer value = new Integer(field.getInt(field)); // store the value of this field + final Field field = Class.forName("java.awt.KeyboardFocusManager").getField("FORWARD_TRAVERSAL_KEYS"); + final Integer value = new Integer(field.getInt(field)); // store the value of this field - Method[] methods = getClass().getMethods(); + final Method[] methods = getClass().getMethods(); if (methods != null) { for (int i = 0; i < methods.length; i++) { // here we try to find the method "setFocusTraversalKeys", and execute it if found if (methods[i].getName().equalsIgnoreCase("setFocusTraversalKeys")) { - methods[i].invoke(this, new Object[]{value, forwardTraversalKeys,}); - // System.out.println("freeTabKeyFromFocusTraversal() succeeded!"); + methods[i].invoke(this, new Object[] { value, forwardTraversalKeys, }); + // System.err.println("freeTabKeyFromFocusTraversal() succeeded!"); } } } - } catch (Exception e) { + } catch (final Exception e) { // If something is undefined which was tried to access above, an exception // is thrown and we end up here. But that's okay, it is intended to happen // for all JDKs 1.3.*. Those older JDKs don't need to set focus traversal anyways. - // System.out.println("freeTabKeyFromFocusTraversal() failed: "+e.getClass().getName()+"\n"+e.getMessage()); + // System.err.println("freeTabKeyFromFocusTraversal() failed: "+e.getClass().getName()+"\n"+e.getMessage()); } } @@ -211,7 +214,7 @@ * Set the TextArea font * @param f font */ - public void setFont(Font f) { + public final void setFont(final Font f) { getPainter().setFont(f); } @@ -229,7 +232,7 @@ * Sets the input handler. * @param inputHandler the new input handler */ - public void setInputHandler(InputHandler inputHandler) { + public final void setInputHandler(final InputHandler inputHandler) { this.inputHandler = inputHandler; } @@ -242,7 +245,7 @@ * Toggles caret blinking. * @param caretBlinks true if the caret should blink, false otherwise */ - public void setCaretBlinkEnabled(boolean caretBlinks) { + public final void setCaretBlinkEnabled(final boolean caretBlinks) { this.caretBlinks = caretBlinks; if (!caretBlinks) { blink = false; @@ -260,7 +263,7 @@ * Sets if the caret should be visible. * @param caretVisible true if the caret should be visible, false otherwise */ - public void setCaretVisible(boolean caretVisible) { + public final void setCaretVisible(final boolean caretVisible) { this.caretVisible = caretVisible; blink = true; @@ -291,7 +294,7 @@ * @param electricScroll the number of lines always visible from the top or * bottom */ - public final void setElectricScroll(int electricScroll) { + public final void setElectricScroll(final int electricScroll) { this.electricScroll = electricScroll; } @@ -300,7 +303,7 @@ * number of lines in the document changes, or when the size of the text * are changes. */ - public void updateScrollBars() { + public final void updateScrollBars() { if (vertical != null && visibleLines != 0) { vertical.setValues(firstLine, visibleLines, 0, getLineCount()); //vertical.setUnitIncrement(2); @@ -308,7 +311,7 @@ vertical.setBlockIncrement(visibleLines); } - int width = painter.getWidth(); + final int width = painter.getWidth(); if (horizontal != null && width != 0) { horizontal.setValues(-horizontalOffset, width, 0, width * 5); //horizontal.setUnitIncrement(painter.getFontMetrics().charWidth('w')); @@ -326,7 +329,7 @@ * Sets the line displayed at the text area's origin without updating the * scroll bars. */ - public void setFirstLine(int firstLine) { + public final void setFirstLine(final int firstLine) { if (firstLine == this.firstLine) { return; } @@ -353,17 +356,17 @@ return; } - int height = painter.getHeight(); + final int height = painter.getHeight(); // get line height - int lineHeight; + final int lineHeight; if (painter == null || painter.getFontMetrics() == null) { lineHeight = painter.getDefaultLineHeight(); // default height might be wrong, take it only when needed } else { lineHeight = painter.getFontMetrics().getHeight(); } - int oldVisibleLines = visibleLines; + final int oldVisibleLines = visibleLines; visibleLines = height / lineHeight; updateScrollBars(); } @@ -378,7 +381,7 @@ * horizontal scrolling. * @param horizontalOffset offset The new horizontal offset */ - public void setHorizontalOffset(int horizontalOffset) { + public final void setHorizontalOffset(final int horizontalOffset) { if (horizontalOffset == this.horizontalOffset) { return; } @@ -397,7 +400,7 @@ * @param horizontalOffset the new horizontal offset * @return true if any of the values were changed, false otherwise */ - public boolean setOrigin(int firstLine, int horizontalOffset) { + public final boolean setOrigin(final int firstLine, final int horizontalOffset) { boolean changed = false; int oldFirstLine = this.firstLine; @@ -425,11 +428,10 @@ * @return true if scrolling was actually performed, false if the caret was * already visible */ - public boolean scrollToCaret() { - int line = getCaretLine(); - int lineStart = getLineStartOffset(line); - int offset = Math.max(0, Math.min(getLineLength(line) - 1, - getCaretPosition() - lineStart)); + public final boolean scrollToCaret() { + final int line = getCaretLine(); + final int lineStart = getLineStartOffset(line); + final int offset = Math.max(0, Math.min(getLineLength(line) - 1, getCaretPosition() - lineStart)); return scrollTo(line, offset); } @@ -439,14 +441,14 @@ * registered for keypress-events. The graphics context must be fully * initialized before calling this method. */ - public void setEditingFocus() { + public final void setEditingFocus() { try { requestFocus(); setCaretVisible(true); focusedComponent = this; setCaretPosition(0); // set caret to 0, 0 coords - } catch (NullPointerException e) { - System.out.println("Nullpointer Excepion in JEditTextArea.setEditingFocus()"); + } catch (final NullPointerException e) { + System.err.println("Nullpointer Excepion in JEditTextArea.setEditingFocus()"); } } @@ -458,7 +460,7 @@ * @return true if scrolling was actually performed, false if the line and * offset was already visible */ - public boolean scrollTo(int line, int offset) { + public final boolean scrollTo(final int line, final int offset) { // visibleLines == 0 before the component is realized // we can't do any proper scrolling then, so we have // this hack... @@ -482,8 +484,8 @@ } } - int x = _offsetToX(line, offset); - int width = painter.getFontMetrics().charWidth('w'); + final int x = _offsetToX(line, offset); + final int width = painter.getFontMetrics().charWidth('w'); if (x < 0) { newHorizontalOffset = Math.min(0, horizontalOffset - x + width + 5); @@ -498,8 +500,8 @@ * Converts a line index to a y co-ordinate. * @param line the line */ - public int lineToY(int line) { - FontMetrics fm = painter.getFontMetrics(); + public final int lineToY(final int line) { + final FontMetrics fm = painter.getFontMetrics(); return (line - firstLine) * fm.getHeight() - (fm.getLeading() + fm.getMaxDescent()); } @@ -507,9 +509,9 @@ * Converts a y co-ordinate to a line index. * @param y the y co-ordinate */ - public int yToLine(int y) { - FontMetrics fm = painter.getFontMetrics(); - int height = fm.getHeight(); + public final int yToLine(final int y) { + final FontMetrics fm = painter.getFontMetrics(); + final int height = fm.getHeight(); return Math.max(0, Math.min(getLineCount() - 1, y / height + firstLine)); } @@ -519,7 +521,7 @@ * @param line the line * @param offset the offset, from the start of the line */ - public final int offsetToX(int line, int offset) { + public final int offsetToX(final int line, final int offset) { // don't use cached tokens painter.setCurrentLineTokens(null); return _offsetToX(line, offset); @@ -532,15 +534,15 @@ * @param line the line * @param offset the offset, from the start of the line */ - public int _offsetToX(int line, int offset) { - TokenMarker tokenMarker = getTokenMarker(); + public final int _offsetToX(final int line, final int offset) { + final TokenMarker tokenMarker = getTokenMarker(); /* Use painter's cached info for speed */ FontMetrics fm = painter.getFontMetrics(); getLineText(line, lineSegment); - int segmentOffset = lineSegment.offset; + final int segmentOffset = lineSegment.offset; int x = horizontalOffset; /* If syntax coloring is disabled, do simple translation */ @@ -548,10 +550,9 @@ lineSegment.count = offset; return x + Utilities.getTabbedTextWidth(lineSegment, fm, x, painter, 0); - + } else { /* If syntax coloring is enabled, we have to do this because * tokens can vary in width */ - } else { Token tokens; if (painter.getCurrentLineIndex() == line && painter.getCurrentLineTokens() != null) { tokens = painter.getCurrentLineTokens(); @@ -561,12 +562,12 @@ painter.setCurrentLineTokens(tokens); } - Toolkit toolkit = painter.getToolkit(); - Font defaultFont = painter.getFont(); - SyntaxStyle[] styles = painter.getStyles(); + final Toolkit toolkit = painter.getToolkit(); + final Font defaultFont = painter.getFont(); + final SyntaxStyle[] styles = painter.getStyles(); - for (; ;) { - byte id = tokens.getId(); + while (true) { + final byte id = tokens.getId(); if (id == Token.END) { return x; } @@ -577,7 +578,7 @@ fm = styles[id].getFontMetrics(defaultFont, painter.getGraphics()); } - int length = tokens.getLength(); + final int length = tokens.getLength(); if (offset + segmentOffset < lineSegment.offset + length) { lineSegment.count = offset - (lineSegment.offset - segmentOffset); @@ -597,24 +598,24 @@ * @param line the line * @param x the x co-ordinate */ - public int xToOffset(int line, int x) { - TokenMarker tokenMarker = getTokenMarker(); + public final int xToOffset(final int line, final int x) { + final TokenMarker tokenMarker = getTokenMarker(); /* Use painter's cached info for speed */ FontMetrics fm = painter.getFontMetrics(); getLineText(line, lineSegment); - char[] segmentArray = lineSegment.array; - int segmentOffset = lineSegment.offset; - int segmentCount = lineSegment.count; + final char[] segmentArray = lineSegment.array; + final int segmentOffset = lineSegment.offset; + final int segmentCount = lineSegment.count; int width = horizontalOffset; if (tokenMarker == null) { for (int i = 0; i < segmentCount; i++) { - char c = segmentArray[i + segmentOffset]; - int charWidth; + final char c = segmentArray[i + segmentOffset]; + final int charWidth; if (c == '\t') { charWidth = (int) painter.nextTabStop(width, i) - width; } else { @@ -646,12 +647,12 @@ } int offset = 0; - Toolkit toolkit = painter.getToolkit(); - Font defaultFont = painter.getFont(); - SyntaxStyle[] styles = painter.getStyles(); + final Toolkit toolkit = painter.getToolkit(); + final Font defaultFont = painter.getFont(); + final SyntaxStyle[] styles = painter.getStyles(); - for (; ;) { - byte id = tokens.getId(); + while (true) { + final byte id = tokens.getId(); if (id == Token.END) { return offset; } @@ -662,11 +663,11 @@ fm = styles[id].getFontMetrics(defaultFont, painter.getGraphics()); } - int length = tokens.getLength(); + final int length = tokens.getLength(); for (int i = 0; i < length; i++) { - char c = segmentArray[segmentOffset + offset + i]; - int charWidth; + final char c = segmentArray[segmentOffset + offset + i]; + final int charWidth; if (c == '\t') { charWidth = (int) painter.nextTabStop(width, offset + i) - width; } else { @@ -697,9 +698,9 @@ * @param x the x co-ordinate of the point * @param y the y co-ordinate of the point */ - public int xyToOffset(int x, int y) { - int line = yToLine(y); - int start = getLineStartOffset(line); + public final int xyToOffset(final int x, final int y) { + final int line = yToLine(y); + final int start = getLineStartOffset(line); return start + xToOffset(line, x); } @@ -712,7 +713,7 @@ * Sets the document this text area is editing. * @param document the document */ - public void setDocument(SyntaxDocument document) { + public final void setDocument(final SyntaxDocument document) { if (this.document == document) { return; } @@ -743,7 +744,7 @@ * <code>getDocument().setTokenMarker()</code>. * @param tokenMarker the token marker */ - public final void setTokenMarker(TokenMarker tokenMarker) { + public final void setTokenMarker(final TokenMarker tokenMarker) { document.setTokenMarker(tokenMarker); } @@ -764,7 +765,7 @@ * Returns the line containing the specified offset. * @param offset the offset */ - public final int getLineOfOffset(int offset) { + public final int getLineOfOffset(final int offset) { return document.getDefaultRootElement().getElementIndex(offset); } @@ -774,9 +775,8 @@ * @return the start offset of the specified line, or -1 if the line is * invalid */ - public int getLineStartOffset(int line) { - Element lineElement = document.getDefaultRootElement() - .getElement(line); + public final int getLineStartOffset(final int line) { + final Element lineElement = document.getDefaultRootElement().getElement(line); if (lineElement == null) { return -1; } else { @@ -790,9 +790,8 @@ * @return the end offset of the specified line, or -1 if the line is * invalid */ - public int getLineEndOffset(int line) { - Element lineElement = document.getDefaultRootElement() - .getElement(line); + public final int getLineEndOffset(final int line) { + final Element lineElement = document.getDefaultRootElement().getElement(line); if (lineElement == null) { return -1; } else { @@ -804,9 +803,8 @@ * Returns the length of the specified line. * @param line the line */ - public int getLineLength(int line) { - Element lineElement = document.getDefaultRootElement() - .getElement(line); + public final int getLineLength(final int line) { + final Element lineElement = document.getDefaultRootElement().getElement(line); if (lineElement == null) { return -1; } else { @@ -814,26 +812,30 @@ } } - /** Returns the entire text of this text area. */ - public String getText() { + /** + * Returns the entire text of this text area. + */ + public final String getText() { try { return document.getText(0, document.getLength()); - } catch (BadLocationException bl) { + } catch (final BadLocationException bl) { bl.printStackTrace(); return null; } } - /** Sets the entire text of this text area. */ - public void setText(String text) { + /** + * Sets the entire text of this text area. + */ + public final void setText(final String text) { try { - document.beginCompoundEdit(); + SyntaxDocument.beginCompoundEdit(); document.remove(0, document.getLength()); document.insertString(0, text, null); - } catch (BadLocationException bl) { + } catch (final BadLocationException bl) { bl.printStackTrace(); } finally { - document.endCompoundEdit(); + SyntaxDocument.endCompoundEdit(); } } @@ -843,10 +845,10 @@ * @param len the length of the substring * @return the substring, or null if the offsets are invalid */ - public final String getText(int start, int len) { + public final String getText(final int start, final int len) { try { return document.getText(start, len); - } catch (BadLocationException bl) { + } catch (final BadLocationException bl) { bl.printStackTrace(); return null; } @@ -859,10 +861,10 @@ * @param len the length of the substring * @param segment the segment */ - public final void getText(int start, int len, Segment segment) { + public final void getText(final int start, final int len, final Segment segment) { try { document.getText(start, len, segment); - } catch (BadLocationException bl) { + } catch (final BadLocationException bl) { bl.printStackTrace(); segment.offset = segment.count = 0; } @@ -873,8 +875,8 @@ * @param lineIndex the line * @return the text, or null if the line is invalid */ - public final String getLineText(int lineIndex) { - int start = getLineStartOffset(lineIndex); + public final String getLineText(final int lineIndex) { + final int start = getLineStartOffset(lineIndex); return getText(start, getLineEndOffset(lineIndex) - start - 1); } @@ -883,8 +885,8 @@ * invalid, the segment will contain a null string. * @param lineIndex the line */ - public final void getLineText(int lineIndex, Segment segment) { - int start = getLineStartOffset(lineIndex); + public final void getLineText(final int lineIndex, final Segment segment) { + final int start = getLineStartOffset(lineIndex); getText(start, getLineEndOffset(lineIndex) - start - 1, segment); } @@ -893,17 +895,19 @@ return selectionStart; } - /** Returns the offset where the selection starts on the specified line. */ - public int getSelectionStart(int line) { + /** + * Returns the offset where the selection starts on the specified line. + */ + public final int getSelectionStart(final int line) { if (line == selectionStartLine) { return selectionStart; } else if (rectSelect) { - Element map = document.getDefaultRootElement(); - int start = selectionStart - map.getElement(selectionStartLine).getStartOffset(); + final Element map = document.getDefaultRootElement(); + final int start = selectionStart - map.getElement(selectionStartLine).getStartOffset(); - Element lineElement = map.getElement(line); - int lineStart = lineElement.getStartOffset(); - int lineEnd = lineElement.getEndOffset() - 1; + final Element lineElement = map.getElement(line); + final int lineStart = lineElement.getStartOffset(); + final int lineEnd = lineElement.getEndOffset() - 1; return Math.min(lineEnd, lineStart + start); } else { return getLineStartOffset(line); @@ -921,7 +925,7 @@ * @param selectionStart the selection start * @see #select(int, int) */ - public final void setSelectionStart(int selectionStart) { + public final void setSelectionStart(final int selectionStart) { select(selectionStart, selectionEnd); } @@ -930,17 +934,19 @@ return selectionEnd; } - /** Returns the offset where the selection ends on the specified line. */ - public int getSelectionEnd(int line) { + /** + * Returns the offset where the selection ends on the specified line. + */ + public final int getSelectionEnd(final int line) { if (line == selectionEndLine) { return selectionEnd; } else if (rectSelect) { - Element map = document.getDefaultRootElement(); - int end = selectionEnd - map.getElement(selectionEndLine).getStartOffset(); + final Element map = document.getDefaultRootElement(); + final int end = selectionEnd - map.getElement(selectionEndLine).getStartOffset(); - Element lineElement = map.getElement(line); - int lineStart = lineElement.getStartOffset(); - int lineEnd = lineElement.getEndOffset() - 1; + final Element lineElement = map.getElement(line); + final int lineStart = lineElement.getStartOffset(); + final int lineEnd = lineElement.getEndOffset() - 1; return Math.min(lineEnd, lineStart + end); } else { return getLineEndOffset(line) - 1; @@ -958,7 +964,7 @@ * @param selectionEnd the selection end * @see #select(int, int) */ - public final void setSelectionEnd(int selectionEnd) { + public final void setSelectionEnd(final int selectionEnd) { select(selectionStart, selectionEnd); } @@ -996,16 +1002,20 @@ * @param caret the caret position * @see #select(int, int) */ - public final void setCaretPosition(int caret) { + public final void setCaretPosition(final int caret) { select(caret, caret); } - /** Selects all text in the document. */ + /** + * Selects all text in the document. + */ public final void selectAll() { select(0, getDocumentLength()); } - /** Moves the mark to the caret position. */ + /** + * Moves the mark to the caret position. + */ public final void selectNone() { select(getCaretPosition(), getCaretPosition()); } @@ -1017,9 +1027,10 @@ * @param start the start offset * @param end the end offset */ - public void select(int start, int end) { - int newStart, newEnd; - boolean newBias; + public final void select(final int start, final int end) { + final int newStart; + final int newEnd; + final boolean newBias; if (start <= end) { newStart = start; newEnd = end; @@ -1038,8 +1049,8 @@ // do all this crap, however we still do the stuff at // the end (clearing magic position, scrolling) if (newStart != selectionStart || newEnd != selectionEnd || newBias != biasLeft) { - int newStartLine = getLineOfOffset(newStart); - int newEndLine = getLineOfOffset(newEnd); + final int newStartLine = getLineOfOffset(newStart); + final int newEndLine = getLineOfOffset(newEnd); if (painter.isBracketHighlightEnabled()) { if (bracketLine != -1) { @@ -1055,8 +1066,7 @@ painter.invalidateLineRange(selectionStartLine, selectionEndLine); painter.invalidateLineRange(newStartLine, newEndLine); - document.addUndoableEdit(new CaretUndo( - selectionStart, selectionEnd)); + SyntaxDocument.addUndoableEdit(new CaretUndo(selectionStart, selectionEnd)); selectionStart = newStart; selectionEnd = newEnd; @@ -1083,7 +1093,9 @@ scrollToCaret(); } - /** Returns the selected text, or null if no selection is active. */ + /** + * Returns the selected text, or null if no selection is active. + */ public final String getSelectedText() { if (selectionStart == selectionEnd) { return null; @@ -1092,25 +1104,25 @@ if (rectSelect) { // Return each row of the selection on a new line - Element map = document.getDefaultRootElement(); + final Element map = document.getDefaultRootElement(); int start = selectionStart - map.getElement(selectionStartLine).getStartOffset(); int end = selectionEnd - map.getElement(selectionEndLine).getStartOffset(); // Certain rectangles satisfy this condition... if (end < start) { - int tmp = end; + final int tmp = end; end = start; start = tmp; } - StringBuffer buf = new StringBuffer(); - Segment seg = new Segment(); + final StringBuffer buf = new StringBuffer(); + final Segment seg = new Segment(); for (int i = selectionStartLine; i <= selectionEndLine; i++) { - Element lineElement = map.getElement(i); + final Element lineElement = map.getElement(i); int lineStart = lineElement.getStartOffset(); - int lineEnd = lineElement.getEndOffset() - 1; + final int lineEnd = lineElement.getEndOffset() - 1; int lineLen = lineEnd - lineStart; lineStart = Math.min(lineStart + start, lineEnd); @@ -1134,7 +1146,7 @@ * Replaces the selection with the specified text. * @param selectedText the replacement text for the selection */ - public void setSelectedText(String selectedText) { + public final void setSelectedText(final String selectedText) { if (!editable) { throw new InternalError("Text component read only"); } @@ -1143,14 +1155,14 @@ try { if (rectSelect) { - Element map = document.getDefaultRootElement(); + final Element map = document.getDefaultRootElement(); int start = selectionStart - map.getElement(selectionStartLine).getStartOffset(); int end = selectionEnd - map.getElement(selectionEndLine).getStartOffset(); // Certain rectangles satisfy this condition... if (end < start) { - int tmp = end; + final int tmp = end; end = start; start = tmp; } @@ -1159,10 +1171,10 @@ int currNewline = 0; for (int i = selectionStartLine; i <= selectionEndLine; i++) { - Element lineElement = map.getElement(i); - int lineStart = lineElement.getStartOffset(); - int lineEnd = lineElement.getEndOffset() - 1; - int rectStart = Math.min(lineEnd, lineStart + start); + final Element lineElement = map.getElement(i); + final int lineStart = lineElement.getStartOffset(); + final int lineEnd = lineElement.getEndOffset() - 1; + final int rectStart = Math.min(lineEnd, lineStart + start); document.remove(rectStart, Math.min(lineEnd - rectStart, end - start)); @@ -1181,7 +1193,7 @@ } if (selectedText != null && currNewline != selectedText.length()) { - int offset = map.getElement(selectionEndLine).getEndOffset() - 1; + final int offset = map.getElement(selectionEndLine).getEndOffset() - 1; document.insertString(offset, "\n", null); document.insertString(offset + 1, selectedText.substring(currNewline + 1), null); } @@ -1191,12 +1203,12 @@ document.insertString(selectionStart, selectedText, null); } } - } catch (BadLocationException bl) { + } catch (final BadLocationException bl) { bl.printStackTrace(); throw new InternalError("Cannot replace selection"); + } finally { // No matter what happends... stops us from leaving document // in a bad state - } finally { document.endCompoundEdit(); } @@ -1213,7 +1225,7 @@ * @param editable true if this text area should be editable, false * otherwise */ - public final void setEditable(boolean editable) { + public final void setEditable(final boolean editable) { this.editable = editable; } @@ -1226,7 +1238,7 @@ * Sets the right click popup menu. * @param popup the popup */ - public final void setRightClickPopup(JPopupMenu popup) { + public final void setRightClickPopup(final JPopupMenu popup) { this.popup = popup; } @@ -1243,7 +1255,7 @@ * position when moving up and down lines. * @param magicCaret the magic caret position */ - public final void setMagicCaretPosition(int magicCaret) { + public final void setMagicCaretPosition(final int magicCaret) { this.magicCaret = magicCaret; } @@ -1254,7 +1266,7 @@ * @see #setSelectedText(String) * @see #isOverwriteEnabled() */ - public void overwriteSetSelectedText(String str) { + public final void overwriteSetSelectedText(final String str) { // Don't overstrike if there is a selection if (!overwrite || selectionStart != selectionEnd) { setSelectedText(str); @@ -1263,22 +1275,22 @@ // Don't overstrike if we're on the end of // the line - int caret = getCaretPosition(); - int caretLineEnd = getLineEndOffset(getCaretLine()); + final int caret = getCaretPosition(); + final int caretLineEnd = getLineEndOffset(getCaretLine()); if (caretLineEnd - caret <= str.length()) { setSelectedText(str); return; } - document.beginCompoundEdit(); + SyntaxDocument.beginCompoundEdit(); try { document.remove(caret, str.length()); document.insertString(caret, str, null); - } catch (BadLocationException bl) { + } catch (final BadLocationException bl) { bl.printStackTrace(); } finally { - document.endCompoundEdit(); + SyntaxDocument.endCompoundEdit(); } } @@ -1292,7 +1304,7 @@ * @param overwrite true if overwrite mode should be enabled, false * otherwise */ - public final void setOverwriteEnabled(boolean overwrite) { + public final void setOverwriteEnabled(final boolean overwrite) { this.overwrite = overwrite; painter.invalidateSelectedLines(); } @@ -1307,7 +1319,7 @@ * @param rectSelect true if the selection should be rectangular, false * otherwise */ - public final void setSelectionRectangular(boolean rectSelect) { + public final void setSelectionRectangular(final boolean rectSelect) { this.rectSelect = rectSelect; painter.invalidateSelectedLines(); } @@ -1332,7 +1344,7 @@ * Adds a caret change listener to this text area. * @param listener the listener */ - public final void addCaretListener(CaretListener listener) { + public final void addCaretListener(final CaretListener listener) { listenerList.add(CaretListener.class, listener); } @@ -1340,7 +1352,7 @@ * Removes a caret change listener from this text area. * @param listener the listener */ - public final void removeCaretListener(CaretListener listener) { + public final void removeCaretListener(final CaretListener listener) { listenerList.remove(CaretListener.class, listener); } @@ -1348,7 +1360,7 @@ * Deletes the selected text from the text area and places it into the * clipboard. */ - public void cut() { + public final void cut() { if (editable) { copy(); setSelectedText(""); @@ -1356,14 +1368,14 @@ } /** Places the selected text into the clipboard. */ - public void copy() { + public final void copy() { if (selectionStart != selectionEnd) { - Clipboard clipboard = getToolkit().getSystemClipboard(); + final Clipboard clipboard = getToolkit().getSystemClipboard(); - String selection = getSelectedText(); + final String selection = getSelectedText(); - int repeatCount = inputHandler.getRepeatCount(); - StringBuffer buf = new StringBuffer(); + final int repeatCount = inputHandler.getRepeatCount(); + final StringBuffer buf = new StringBuffer(); for (int i = 0; i < repeatCount; i++) { buf.append(selection); } @@ -1372,23 +1384,25 @@ } } - /** Inserts the clipboard contents into the text. */ - public void paste() { + /** + * Inserts the clipboard contents into the text. + */ + public final void paste() { if (editable) { - Clipboard clipboard = getToolkit().getSystemClipboard(); + final Clipboard clipboard = getToolkit().getSystemClipboard(); try { // The MacOS MRJ doesn't convert \r to \n, // so do it here String selection = ((String) clipboard.getContents(this).getTransferData(DataFlavor.stringFlavor)).replace('\r', '\n'); - int repeatCount = inputHandler.getRepeatCount(); - StringBuffer buf = new StringBuffer(); + final int repeatCount = inputHandler.getRepeatCount(); + final StringBuffer buf = new StringBuffer(); for (int i = 0; i < repeatCount; i++) { buf.append(selection); } selection = buf.toString(); setSelectedText(selection); - } catch (Exception e) { + } catch (final Exception e) { getToolkit().beep(); log.error("Clipboard does not contain a string"); } @@ -1399,7 +1413,7 @@ * Called by the AWT when this component is removed from it's parent. This * stops clears the currently focused component. */ - public void removeNotify() { + public final void removeNotify() { super.removeNotify(); if (focusedComponent == this) { focusedComponent = null; @@ -1410,7 +1424,7 @@ * Forwards key events directly to the input handler. This is slightly * faster than using a KeyListener because some Swing overhead is avoided. */ - public void processKeyEvent(KeyEvent evt) { + public final void processKeyEvent(final KeyEvent evt) { if (inputHandler == null) { return; } @@ -1431,23 +1445,23 @@ } // protected members - protected static String CENTER = "center"; + protected static final String CENTER = "center"; - protected static String RIGHT = "right"; + protected static final String RIGHT = "right"; - protected static String BOTTOM = "bottom"; + protected static final String BOTTOM = "bottom"; protected static JEditTextArea focusedComponent; - protected static Timer caretTimer; + protected static final Timer caretTimer; - protected TextAreaPainter painter; + protected final TextAreaPainter painter; protected JPopupMenu popup; - protected EventListenerList listenerList; + protected final EventListenerList listenerList; - protected MutableCaretEvent caretEvent; + protected final MutableCaretEvent caretEvent; protected boolean caretBlinks; @@ -1465,9 +1479,9 @@ protected int horizontalOffset; - protected JScrollBar vertical; + protected final JScrollBar vertical; - protected JScrollBar horizontal; + protected final JScrollBar horizontal; protected boolean scrollBarsInitialized; @@ -1475,9 +1489,9 @@ protected SyntaxDocument document; - protected DocumentHandler documentHandler; + protected final DocumentHandler documentHandler; - protected Segment lineSegment; + protected final Segment lineSegment; protected int selectionStart; @@ -1499,8 +1513,8 @@ protected boolean rectSelect; - protected void fireCaretEvent() { - Object[] listeners = listenerList.getListenerList(); + protected final void fireCaretEvent() { + final Object[] listeners = listenerList.getListenerList(); for (int i = listeners.length - 2; i >= 0; i--) { if (listeners[i] == CaretListener.class) { ((CaretListener) listeners[i + 1]).caretUpdate(caretEvent); @@ -1508,38 +1522,37 @@ } } - protected void updateBracketHighlight(int newCaretPosition) { + protected final void updateBracketHighlight(final int newCaretPosition) { if (newCaretPosition == 0) { bracketPosition = bracketLine = -1; return; } try { - int offset = TextUtilities.findMatchingBracket(document, newCaretPosition - 1); + final int offset = TextUtilities.findMatchingBracket(document, newCaretPosition - 1); if (offset != -1) { bracketLine = getLineOfOffset(offset); bracketPosition = offset - getLineStartOffset(bracketLine); return; } - } catch (BadLocationException bl) { + } catch (final BadLocationException bl) { bl.printStackTrace(); } bracketLine = bracketPosition = -1; } - protected void documentChanged(DocumentEvent evt) { - DocumentEvent.ElementChange ch = evt.getChange( - document.getDefaultRootElement()); + protected final void documentChanged(final DocumentEvent evt) { + final DocumentEvent.ElementChange ch = evt.getChange(document.getDefaultRootElement()); - int count; + final int count; if (ch == null) { count = 0; } else { count = ch.getChildrenAdded().length - ch.getChildrenRemoved().length; } - int line = getLineOfOffset(evt.getOffset()); + final int line = getLineOfOffset(evt.getOffset()); if (count == 0) { painter.invalidateLine(line); } else if (line < firstLine) { @@ -1552,9 +1565,9 @@ } } - class ScrollLayout implements LayoutManager { + final class ScrollLayout implements LayoutManager { - public void addLayoutComponent(String name, Component comp) { + public final void addLayoutComponent(final String name, final Component comp) { if (name.equals(CENTER)) { center = comp; } else if (name.equals(RIGHT)) { @@ -1566,7 +1579,7 @@ } } - public void removeLayoutComponent(Component comp) { + public final void removeLayoutComponent(final Component comp) { if (center == comp) { center = null; } @@ -1582,52 +1595,52 @@ } } - public Dimension preferredLayoutSize(Container parent) { - Dimension dim = new Dimension(); - Insets insets = getInsets(); + public final Dimension preferredLayoutSize(final Container parent) { + final Dimension dim = new Dimension(); + final Insets insets = getInsets(); dim.width = insets.left + insets.right; dim.height = insets.top + insets.bottom; - Dimension centerPref = center.getPreferredSize(); + final Dimension centerPref = center.getPreferredSize(); dim.width += centerPref.width; dim.height += centerPref.height; - Dimension rightPref = right.getPreferredSize(); + final Dimension rightPref = right.getPreferredSize(); dim.width += rightPref.width; - Dimension bottomPref = bottom.getPreferredSize(); + final Dimension bottomPref = bottom.getPreferredSize(); dim.height += bottomPref.height; return dim; } - public Dimension minimumLayoutSize(Container parent) { - Dimension dim = new Dimension(); - Insets insets = getInsets(); + public final Dimension minimumLayoutSize(final Container parent) { + final Dimension dim = new Dimension(); + final Insets insets = getInsets(); dim.width = insets.left + insets.right; dim.height = insets.top + insets.bottom; - Dimension centerPref = center.getMinimumSize(); + final Dimension centerPref = center.getMinimumSize(); dim.width += centerPref.width; dim.height += centerPref.height; - Dimension rightPref = right.getMinimumSize(); + final Dimension rightPref = right.getMinimumSize(); dim.width += rightPref.width; - Dimension bottomPref = bottom.getMinimumSize(); + final Dimension bottomPref = bottom.getMinimumSize(); dim.height += bottomPref.height; return dim; } - public void layoutContainer(Container parent) { - Dimension size = parent.getSize(); - Insets insets = parent.getInsets(); - int itop = insets.top; + public final void layoutContainer(final Container parent) { + final Dimension size = parent.getSize(); + final Insets insets = parent.getInsets(); + final int itop = insets.top; int ileft = insets.left; - int ibottom = insets.bottom; - int iright = insets.right; + final int ibottom = insets.bottom; + final int iright = insets.right; - int rightWidth = right.getPreferredSize().width; - int bottomHeight = bottom.getPreferredSize().height; - int centerWidth = size.width - rightWidth - ileft - iright; - int centerHeight = size.height - bottomHeight - itop - ibottom; + final int rightWidth = right.getPreferredSize().width; + final int bottomHeight = bottom.getPreferredSize().height; + final int centerWidth = size.width - rightWidth - ileft - iright; + final int centerHeight = size.height - bottomHeight - itop - ibottom; center.setBounds( ileft, @@ -1642,14 +1655,11 @@ centerHeight); // Lay out all status components, in order - Enumeration status = leftOfScrollBar.elements(); + final Enumeration status = leftOfScrollBar.elements(); while (status.hasMoreElements()) { - Component comp = (Component) status.nextElement(); - Dimension dim = comp.getPreferredSize(); - comp.setBounds(ileft, - itop + centerHeight, - dim.width, - bottomHeight); + final Component comp = (Component) status.nextElement(); + final Dimension dim = comp.getPreferredSize(); + comp.setBounds(ileft, itop + centerHeight, dim.width, bottomHeight); ileft += dim.width; } @@ -1667,38 +1677,41 @@ private Component bottom; - private Vector leftOfScrollBar = new Vector(); - } + private final Vector leftOfScrollBar = new Vector(); + } // class ScrollLayout - static class CaretBlinker implements ActionListener { + static final class CaretBlinker implements ActionListener { - public void actionPerformed(ActionEvent evt) { + public final void actionPerformed(final ActionEvent evt) { if (focusedComponent != null && focusedComponent.hasFocus()) { focusedComponent.blinkCaret(); } } - } + } // class CaretBlinger - class MutableCaretEvent extends CaretEvent { + final class MutableCaretEvent extends CaretEvent { + /** + * Serial Version UID. + */ private static final long serialVersionUID = -906781128141622273L; MutableCaretEvent() { super(JEditTextArea.this); } - public int getDot() { + public final int getDot() { return getCaretPosition(); } - public int getMark() { + public final int getMark() { return getMarkPosition(); } - } + } // class MutableCaretEvent - class AdjustHandler implements AdjustmentListener { + final class AdjustHandler implements AdjustmentListener { - public void adjustmentValueChanged(final AdjustmentEvent evt) { + public final void adjustmentValueChanged(final AdjustmentEvent evt) { if (!scrollBarsInitialized) { return; } @@ -1716,26 +1729,26 @@ } }); } - } + } // class AdjustHandler - class ComponentHandler extends ComponentAdapter { + final class ComponentHandler extends ComponentAdapter { - public void componentResized(ComponentEvent evt) { + public final void componentResized(final ComponentEvent evt) { recalculateVisibleLines(); scrollBarsInitialized = true; } - } + } // class ComponentHandler - class DocumentHandler implements DocumentListener { + final class DocumentHandler implements DocumentListener { - public void insertUpdate(DocumentEvent evt) { + public final void insertUpdate(final DocumentEvent evt) { documentChanged(evt); - int offset = evt.getOffset(); - int length = evt.getLength(); + final int offset = evt.getOffset(); + final int length = evt.getLength(); - int newStart; - int newEnd; + final int newStart; + final int newEnd; if (selectionStart > offset || (selectionStart == selectionEnd && selectionStart == offset)) { newStart = selectionStart + length; @@ -1752,14 +1765,14 @@ select(newStart, newEnd); } - public void removeUpdate(DocumentEvent evt) { + public final void removeUpdate(final DocumentEvent evt) { documentChanged(evt); - int offset = evt.getOffset(); - int length = evt.getLength(); + final int offset = evt.getOffset(); + final int length = evt.getLength(); - int newStart; - int newEnd; + final int newStart; + final int newEnd; if (selectionStart > offset) { if (selectionStart > offset + length) { @@ -1784,42 +1797,43 @@ select(newStart, newEnd); } - public void changedUpdate(DocumentEvent evt) { + public final void changedUpdate(final DocumentEvent evt) { } - } + } // class DocumentHandler - class DragHandler implements MouseMotionListener { + final class DragHandler implements MouseMotionListener { - public void mouseDragged(MouseEvent evt) { + public final void mouseDragged(final MouseEvent evt) { if (popup != null && popup.isVisible()) { return; } - setSelectionRectangular((evt.getModifiers() - & InputEvent.CTRL_MASK) != 0); + setSelectionRectangular((evt.getModifiers() & InputEvent.CTRL_MASK) != 0); select(getMarkPosition(), xyToOffset(evt.getX(), evt.getY())); } - public void mouseMoved(MouseEvent evt) { + public final void mouseMoved(final MouseEvent evt) { } - } - class FocusHandler implements FocusListener { + } // class DragHandler - public void focusGained(FocusEvent evt) { + final class FocusHandler implements FocusListener { + + public final void focusGained(final FocusEvent evt) { setCaretVisible(true); focusedComponent = JEditTextArea.this; } - public void focusLost(FocusEvent evt) { + public final void focusLost(final FocusEvent evt) { setCaretVisible(false); focusedComponent = null; } - } - class MouseHandler extends MouseAdapter { + } // class FocusHandler - public void mousePressed(MouseEvent evt) { + final class MouseHandler extends MouseAdapter { + + public final void mousePressed(final MouseEvent evt) { requestFocus(); // Focus events not fired sometimes? @@ -1831,9 +1845,9 @@ return; } - int line = yToLine(evt.getY()); - int offset = xToOffset(line, evt.getX()); - int dot = getLineStartOffset(line) + offset; + final int line = yToLine(evt.getY()); + final int offset = xToOffset(line, evt.getX()); + final int dot = getLineStartOffset(line) + offset; switch (evt.getClickCount()) { case 1: @@ -1844,7 +1858,7 @@ // it can throw a BLE try { doDoubleClick(evt, line, offset, dot); - } catch (BadLocationException bl) { + } catch (final BadLocationException bl) { bl.printStackTrace(); } break; @@ -1854,8 +1868,7 @@ } } - private void doSingleClick(MouseEvent evt, int line, - int offset, int dot) { + private void doSingleClick(final MouseEvent evt, final int line, final int offset, final int dot) { if ((evt.getModifiers() & InputEvent.SHIFT_MASK) != 0) { rectSelect = (evt.getModifiers() & InputEvent.CTRL_MASK) != 0; select(getMarkPosition(), dot); @@ -1864,16 +1877,14 @@ } } - private void doDoubleClick(MouseEvent evt, int line, - int offset, int dot) throws BadLocationException { + private void doDoubleClick(final MouseEvent evt, final int line, final int offset, final int dot) throws BadLocationException { // Ignore empty lines if (getLineLength(line) == 0) { return; } try { - int bracket = TextUtilities.findMatchingBracket( - document, Math.max(0, dot - 1)); + int bracket = TextUtilities.findMatchingBracket(document, Math.max(0, dot - 1)); if (bracket != -1) { int mark = getMarkPosition(); // Hack @@ -1884,12 +1895,12 @@ select(mark, bracket); return; } - } catch (BadLocationException bl) { + } catch (final BadLocationException bl) { bl.printStackTrace(); } // Ok, it's not a bracket... select the word - String lineText = getLineText(line); + final String lineText = getLineText(line); char ch = lineText.charAt(Math.max(0, offset - 1)); String noWordSep = (String) document.getProperty("noWordSep"); @@ -1899,9 +1910,7 @@ // If the user clicked on a non-letter char, // we select the surrounding non-letters - boolean selectNoLetter = (!Character - .isLetterOrDigit(ch) - && noWordSep.indexOf(ch) == -1); + final boolean selectNoLetter = !Character.isLetterOrDigit(ch) && noWordSep.indexOf(ch) == -1; int wordStart = 0; @@ -1922,7 +1931,7 @@ } } - int lineStart = getLineStartOffset(line); + final int lineStart = getLineStartOffset(line); select(lineStart + wordStart, lineStart + wordEnd); /* @@ -1932,52 +1941,55 @@ int wordEnd = TextUtilities.findWordEnd(lineText, offset, noWordSep); int lineStart = getLineStartOffset(line); - select(lineStart+wordStart, lineStart+wordEnd); + select(lineStart + wordStart, lineStart + wordEnd); */ } - private void doTripleClick(MouseEvent evt, int line, - int offset, int dot) { + private void doTripleClick(final MouseEvent evt, final int line, final int offset, final int dot) { select(getLineStartOffset(line), getLineEndOffset(line) - 1); } - } - class CaretUndo extends AbstractUndoableEdit { + } // class MouseHandler + final class CaretUndo extends AbstractUndoableEdit { + + /** + * Serial Version UID. + */ + private static final long serialVersionUID = -7132615163216882489L; + private int start; private int end; - private static final long serialVersionUID = -7132615163216882489L; - - CaretUndo(int start, int end) { + CaretUndo(final int start, final int end) { this.start = start; this.end = end; } - public boolean isSignificant() { + public final boolean isSignificant() { return false; } - public String getPresentationName() { + public final String getPresentationName() { return "caret move"; } - public void undo() { + public final void undo() { super.undo(); select(start, end); } - public void redo() { + public final void redo() { super.redo(); select(start, end); } - public boolean addEdit(UndoableEdit edit) { + public final boolean addEdit(final UndoableEdit edit) { if (edit instanceof CaretUndo) { - CaretUndo cedit = (CaretUndo) edit; + final CaretUndo ce... [truncated message content] |
From: <aki...@us...> - 2006-05-29 18:51:48
|
Revision: 68 Author: akirschbaum Date: 2006-05-29 11:51:18 -0700 (Mon, 29 May 2006) ViewCVS: http://svn.sourceforge.net/gridarta/?rev=68&view=rev Log Message: ----------- Unify classes: whitespace changes, add final/static. Modified Paths: -------------- trunk/crossfire/src/cfeditor/textedit/scripteditor/CFPythonPopup.java trunk/crossfire/src/cfeditor/textedit/scripteditor/ScriptEditControl.java trunk/crossfire/src/cfeditor/textedit/scripteditor/ScriptEditMenuBar.java trunk/crossfire/src/cfeditor/textedit/scripteditor/ScriptEditView.java trunk/crossfire/src/cfeditor/textedit/textarea/CTokenMarker.java trunk/crossfire/src/cfeditor/textedit/textarea/DefaultInputHandler.java trunk/crossfire/src/cfeditor/textedit/textarea/HTMLTokenMarker.java trunk/crossfire/src/cfeditor/textedit/textarea/InputHandler.java trunk/crossfire/src/cfeditor/textedit/textarea/JEditTextArea.java trunk/daimonin/src/daieditor/textedit/scripteditor/CFPythonPopup.java trunk/daimonin/src/daieditor/textedit/scripteditor/ScriptEditControl.java trunk/daimonin/src/daieditor/textedit/scripteditor/ScriptEditMenuBar.java trunk/daimonin/src/daieditor/textedit/scripteditor/ScriptEditView.java trunk/daimonin/src/daieditor/textedit/textarea/CTokenMarker.java trunk/daimonin/src/daieditor/textedit/textarea/DefaultInputHandler.java trunk/daimonin/src/daieditor/textedit/textarea/HTMLTokenMarker.java trunk/daimonin/src/daieditor/textedit/textarea/InputHandler.java Modified: trunk/crossfire/src/cfeditor/textedit/scripteditor/CFPythonPopup.java =================================================================== --- trunk/crossfire/src/cfeditor/textedit/scripteditor/CFPythonPopup.java 2006-05-29 08:44:37 UTC (rev 67) +++ trunk/crossfire/src/cfeditor/textedit/scripteditor/CFPythonPopup.java 2006-05-29 18:51:18 UTC (rev 68) @@ -52,8 +52,13 @@ * time consuming task. * @author <a href="mailto:and...@gm...">Andreas Vogl</a> */ -public class CFPythonPopup extends JComboBox { +public final class CFPythonPopup extends JComboBox { + /** + * Serial Version UID. + */ + private static final long serialVersionUID = 9041336072540973409L; + private static ScriptEditControl control; // control object // list of menu entries (all CFPython commands) @@ -65,9 +70,9 @@ private int caretPos; // caret position in document where this popup was opened - private static final long serialVersionUID = 9041336072540973409L; - - /** Constructor - builds the CFPython popup menu. */ + /** + * Constructor - builds the CFPython popup menu. + */ public CFPythonPopup() { super(); setBackground(Color.white); // white background @@ -97,10 +102,12 @@ setRequestFocusEnabled(true); } - /** Load the list of CFPython commands from the datafile. */ + /** + * Load the list of CFPython commands from the datafile. + */ public static void loadCommandlist() { CFileReader reader = null; // file reader - Vector cmdList = new Vector(); // temporare list to store commands + final Vector cmdList = new Vector(); // temporare list to store commands int k; try { @@ -113,11 +120,11 @@ } } - String baseDir = (IGUIConstants.isoView ? isoArchDefFolder + File.separator + IGUIConstants.CONFIG_DIR : IGUIConstants.CONFIG_DIR); + final String baseDir = IGUIConstants.isoView ? isoArchDefFolder + File.separator + IGUIConstants.CONFIG_DIR : IGUIConstants.CONFIG_DIR; reader = new CFileReader(baseDir, IGUIConstants.PYTHONMENU_FILE); - String line; // tmp string for reading lines // read file into the cmdList vector: + String line; // tmp string for reading lines line = reader.getReader().readLine(); // read first line while (line != null) { line = line.trim(); @@ -127,8 +134,8 @@ if ((k = line.indexOf("(")) > 0) { line = line.substring(0, k) + "()"; } else { - System.out.println("Parse error in " + IGUIConstants.PYTHONMENU_FILE + ":"); - System.out.println(" \"" + line + "\" missing '()'"); + System.err.println("Parse error in " + IGUIConstants.PYTHONMENU_FILE + ":"); + System.err.println(" \"" + line + "\" missing '()'"); line += "()"; // that line is probably garbage, but will work } cmdList.addElement(line); @@ -141,24 +148,23 @@ // now create the 'menuEntries' array if (cmdList.size() > 0) { - menuEntries = new String[cmdList.size()]; // set array dimensio + menuEntries = new String[cmdList.size()]; // set array dimension for (int i = 0; i < cmdList.size(); i++) { - menuEntries[i] = (String) (cmdList.elementAt(i)); + menuEntries[i] = (String) cmdList.elementAt(i); } - cmdList = null; } // close file reader reader.close(); - } catch (FileNotFoundException e) { - System.out.println("File '" + IGUIConstants.PYTHONMENU_FILE + "' not found."); + } catch (final FileNotFoundException e) { + System.err.println("File '" + IGUIConstants.PYTHONMENU_FILE + "' not found."); return; - } catch (EOFException e) { + } catch (final EOFException e) { // end of file/spell struct reached reader.close(); - } catch (IOException e) { - System.out.println("Cannot read file '" + IGUIConstants.PYTHONMENU_FILE + "'!"); + } catch (final IOException e) { + System.err.println("Cannot read file '" + IGUIConstants.PYTHONMENU_FILE + "'!"); return; } } @@ -168,11 +174,11 @@ * bubblesort because the expected number of objects is low (~300). * @param v Vector to be sorted */ - private static void sortVector(Vector v) { + private static void sortVector(final Vector v) { for (int j = 0; j < v.size() + 1; j++) { for (int i = 0; i < v.size() - 1; i++) { if (((String) v.elementAt(i)).compareToIgnoreCase((String) v.elementAt(i + 1)) > 0) { - Object node = v.elementAt(i); + final Object node = v.elementAt(i); v.setElementAt(v.elementAt(i + 1), i); v.setElementAt(node, i + 1); } @@ -184,7 +190,7 @@ * @return true when this popup menu has been fully initialized and is * ready for use */ - public boolean isInitialized() { + public final boolean isInitialized() { return isReady; } @@ -192,31 +198,33 @@ * Set the caret position where this menu has been invoked. * @param pos caret position in the document */ - public void setCaretPosition(int pos) { + public final void setCaretPosition(final int pos) { this.caretPos = pos; this.getMenu().requestFocus(); control.registerActivePopup(this); } - public CFPythonPopupMenu getMenu() { + public final CFPythonPopupMenu getMenu() { return menu; } // ------------------------ SUBCLASSES ----------------------- - /** Subclass MenuActionListener handles the actionevents for the menu items. */ - private class MenuActionListener implements ActionListener { + /** + * Subclass MenuActionListener handles the actionevents for the menu items. + */ + private final class MenuActionListener implements ActionListener { private final CFPythonPopup popup; private boolean ignore; // while true, all ActionEvents get ignored - public MenuActionListener(CFPythonPopup popup) { + public MenuActionListener(final CFPythonPopup popup) { this.popup = popup; ignore = false; } - public void actionPerformed(ActionEvent e) { + public final void actionPerformed(final ActionEvent e) { if (!ignore) { // get method name to insert String method = popup.getSelectedItem().toString(); @@ -225,8 +233,8 @@ try { // insert method into the document control.getActiveTextArea().getDocument().insertString(caretPos, method, null); - } catch (BadLocationException ex) { - System.out.println("BadLocationException"); + } catch (final BadLocationException ex) { + System.err.println("BadLocationException"); } ignore = true; @@ -235,21 +243,26 @@ popup.getMenu().hide(); // in some JRE versions, this doesn't happen automatically } } - } + } // class MenuActionListener - /** Menu class, inherits from JPopupMenu. */ - public class CFPythonPopupMenu extends BasicComboPopup { + /** + * Menu class, inherits from JPopupMenu. + */ + public static final class CFPythonPopupMenu extends BasicComboPopup { + /** + * Serial Version UID. + */ + private static final long serialVersionUID = -8559415985336516117L; + final JComboBox comboBox; - private static final long serialVersionUID = -8559415985336516117L; - - public CFPythonPopupMenu(JComboBox box) { + public CFPythonPopupMenu(final JComboBox box) { super(box); this.comboBox = box; //this.addMouseListener(new ListenerMenuClick()); this.setPreferredSize(new Dimension(220, 200)); } - } + } // class CFPythonPopupMenu -} +} // class CFPythonPopup Modified: trunk/crossfire/src/cfeditor/textedit/scripteditor/ScriptEditControl.java =================================================================== --- trunk/crossfire/src/cfeditor/textedit/scripteditor/ScriptEditControl.java 2006-05-29 08:44:37 UTC (rev 67) +++ trunk/crossfire/src/cfeditor/textedit/scripteditor/ScriptEditControl.java 2006-05-29 18:51:18 UTC (rev 68) @@ -42,7 +42,7 @@ * to the tab bar. * @author <a href="mailto:and...@gm...">Andreas Vogl</a> */ -public class ScriptEditControl { +public final class ScriptEditControl { private static final Logger log = Logger.getLogger(ScriptEditControl.class); @@ -64,7 +64,7 @@ private final Vector opened; // open tabs, contains absolute filenames (or "<>") in order left to right /** Constructor is private, instance is created by calling 'init()' */ - private ScriptEditControl(CMainControl m_control) { + private ScriptEditControl(final CMainControl m_control) { opened = new Vector(); // start with empty vector this.m_control = m_control; view = new ScriptEditView(this); // initialize window @@ -75,7 +75,7 @@ * called before once using this class. * @param mapDefFolder map default folder */ - public static void init(String mapDefFolder, CMainControl main_control) { + public static void init(final String mapDefFolder, final CMainControl main_control) { if (instance == null) { isStandAlone = false; instance = new ScriptEditControl(main_control); @@ -88,7 +88,7 @@ * run stand-alone, window close operations will terminate the application. * @param mapDefFolder map default folder */ - private static void init(String mapDefFolder) { + private static void init(final String mapDefFolder) { if (instance == null) { isStandAlone = true; instance = new ScriptEditControl(null); @@ -101,7 +101,7 @@ return instance; } - public boolean isStandAlone() { + public static final boolean isStandAlone() { return isStandAlone; } @@ -109,12 +109,12 @@ * @return instance of cfeditor main control (is null for stand-alone * configuration!) */ - CMainControl getMainControl() { + final CMainControl getMainControl() { return m_control; } /** Notifies that the application is about to exit. */ - public void appExitNotify() { + public final void appExitNotify() { view.appExitNotify(); // notify view } @@ -123,22 +123,26 @@ * popup will be closed (if still open). * @param p active popup to register */ - public void registerActivePopup(CFPythonPopup p) { + public static final void registerActivePopup(final CFPythonPopup p) { activePopup = p; } - /** Open a new empty python script document. */ - public void openScriptNew() { - opened.addElement(new String("<>")); // this script has no filename assigned yet + /** + * Open a new empty Python script document. + */ + public final void openScriptNew() { + opened.addElement("<>"); // this script has no filename assigned yet view.addTab("<New Script>", null); } - /** Open a new empty python script document. */ - public void openScriptFile(String pathname) { - File f = new File(pathname); + /** + * Open a new empty Python script document. + */ + public final void openScriptFile(final String pathname) { + final File f = new File(pathname); if (f.exists() && f.isFile()) { - opened.addElement(new String(f.getAbsolutePath())); + opened.addElement(f.getAbsolutePath()); view.addTab(f.getName(), f); } else { if (log.isInfoEnabled()) { @@ -148,9 +152,11 @@ } } - /** Open a file which is chosen by the user. */ - public void openUserWanted() { - JFileChooser fileChooser = new JFileChooser(); + /** + * Open a file which is chosen by the user. + */ + public final void openUserWanted() { + final JFileChooser fileChooser = new JFileChooser(); fileChooser.setDialogTitle("Open Script File"); fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY); fileChooser.setMultiSelectionEnabled(false); @@ -159,14 +165,14 @@ fileChooser.setFileFilter(new FileFilterPython()); // set default folder for new scripts - File baseDir = new File(defaultScriptDir); + final File baseDir = new File(defaultScriptDir); if (baseDir != null && baseDir.exists() && baseDir.isDirectory()) { fileChooser.setCurrentDirectory(baseDir); } - int returnVal = fileChooser.showOpenDialog(view); + final int returnVal = fileChooser.showOpenDialog(view); if (returnVal == JFileChooser.APPROVE_OPTION) { - File file = fileChooser.getSelectedFile(); + final File file = fileChooser.getSelectedFile(); if (file.exists() && !file.isDirectory()) { // everything okay do far, now open up that scriptfile openScriptFile(file.getAbsolutePath()); @@ -177,8 +183,10 @@ } } - /** Close the active script-tab. */ - public void closeActiveTab() { + /** + * Close the active script-tab. + */ + public final void closeActiveTab() { if (view.getSelectedIndex() >= 0 && opened.size() > 0) { opened.removeElementAt(view.getSelectedIndex()); // dump the filename } @@ -200,8 +208,10 @@ } } - /** Close all opened script-tabs. */ - public void closeAllTabs() { + /** + * Close all opened script-tabs. + */ + public final void closeAllTabs() { // simply keep closing active tabs till none are left while (view.getSelectedIndex() >= 0 || opened.size() > 0) { closeActiveTab(); @@ -212,14 +222,14 @@ * Open a filebrowser and prompt the user for a location/name to store this * file. If everything goes fine, the file is saved. */ - public void saveAsActiveTab() { - String activePath = getActiveFilePath(); // active file path ('null' if undefined) - String text = getActiveTextArea().getText(); // Store text data to ensure that the right text is saved later. + public final void saveAsActiveTab() { + final String activePath = getActiveFilePath(); // active file path ('null' if undefined) + final String text = getActiveTextArea().getText(); // Store text data to ensure that the right text is saved later. // User could switch tabs or type text in the meantime, who knows. - int tabIndex = view.getSelectedIndex(); // save tab-index of this script + final int tabIndex = view.getSelectedIndex(); // save tab-index of this script // create the file-chooser dialog: - JFileChooser fileChooser = new JFileChooser(); + final JFileChooser fileChooser = new JFileChooser(); fileChooser.setDialogTitle("Save Script File As"); fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY); fileChooser.setMultiSelectionEnabled(false); @@ -229,7 +239,7 @@ // if file already exists, select it if (activePath != null) { - File f = new File(activePath); + final File f = new File(activePath); if (f != null && f.getParentFile().exists() && f.getParentFile().isDirectory()) { fileChooser.setCurrentDirectory(f.getParentFile()); @@ -237,26 +247,23 @@ } } else { // set default folder for new scripts - File baseDir = new File(defaultScriptDir); + final File baseDir = new File(defaultScriptDir); if (baseDir != null && baseDir.exists() && baseDir.isDirectory()) { fileChooser.setCurrentDirectory(baseDir); } } - int returnVal = fileChooser.showSaveDialog(view); + final int returnVal = fileChooser.showSaveDialog(view); if (returnVal == JFileChooser.APPROVE_OPTION) { File file = fileChooser.getSelectedFile(); if (!file.getName().endsWith(".py")) { // We have to attach the ".py" ending to this file - String fname = file.getAbsolutePath(); - file = null; + final String fname = file.getAbsolutePath(); file = new File(fname + ".py"); } // now it is our duty to doublecheck if user attempts to overwrite - if (!file.exists() || (activePath != null && file.getAbsolutePath().equals(activePath)) || - view.askConfirm("Overwrite?", "A file named \"" + file.getName() + "\" already exists.\n" + - "Are you sure you want to overwrite it?")) { + if (!file.exists() || (activePath != null && file.getAbsolutePath().equals(activePath)) || view.askConfirm("Overwrite?", "A file named \"" + file.getName() + "\" already exists.\n" + "Are you sure you want to overwrite it?")) { // looks like we can finally save the data saveTextToFile(file, text); @@ -267,7 +274,7 @@ //String path = (String)(opened.elementAt(tabIndex)); // set new path - opened.setElementAt(new String(file.getAbsolutePath()), tabIndex); + opened.setElementAt(file.getAbsolutePath(), tabIndex); view.setTitleAt(tabIndex, file.getName()); view.refreshMenuBar(); @@ -276,13 +283,15 @@ } } - /** Save the active script-tab to the stored filepath. */ - public void saveActiveTab() { + /** + * Save the active script-tab to the stored filepath. + */ + public final void saveActiveTab() { if (getActiveFilePath() != null) { - File f = new File(getActiveFilePath()); // get active path + final File f = new File(getActiveFilePath()); // get active path saveTextToFile(f, getActiveTextArea().getText()); // write text to file } else { - System.out.println("ScriptEditControl.saveActiveTab(): Cannot save file without name!"); + System.err.println("ScriptEditControl.saveActiveTab(): Cannot save file without name!"); // Path is missing? This shouldn't happen, but let's do a saveAs instead... saveAsActiveTab(); } @@ -293,7 +302,7 @@ * @param f text gets saved into this file * @param text text to be saved */ - public void saveTextToFile(File f, String text) { + public final void saveTextToFile(final File f, String text) { if (text == null) { text = ""; } @@ -303,35 +312,38 @@ if (!f.exists()) { if (!f.createNewFile()) { // failed to create new file - System.out.println("Couldn't create file '" + f.getName() + "'!"); + System.err.println("Couldn't create file '" + f.getName() + "'!"); } } - FileWriter fwrite = new FileWriter(f); + final FileWriter fwrite = new FileWriter(f); fwrite.write(text); fwrite.close(); - } catch (IOException e) { + } catch (final IOException e) { // tell the user because it is important to know that saving failed - view.showMessage("Write Error", "The file \"" + f.getName() + "\" could not be written.\n" + - "Please use the 'Save As...' menu.", JOptionPane.ERROR_MESSAGE); + view.showMessage("Write Error", "The file \"" + f.getName() + "\" could not be written.\nPlease use the 'Save As...' menu.", JOptionPane.ERROR_MESSAGE); } } else { - System.out.println("ScriptEditControl.saveTextToFile(): Cannot save - File is NULL!"); + System.err.println("ScriptEditControl.saveTextToFile(): Cannot save - File is NULL!"); } } - /** @return currently active JEditTextArea, or null if none are open */ - JEditTextArea getActiveTextArea() { + /** + * @return currently active JEditTextArea, or null if none are open + */ + final JEditTextArea getActiveTextArea() { return view.getActiveTextArea(); } - /** @return file path of active tab, null if no path is available */ - String getActiveFilePath() { + /** + * @return file path of active tab, null if no path is available + */ + final String getActiveFilePath() { if (view != null && opened != null && view.getSelectedIndex() >= 0 && opened.size() > 0) { // get stored path - String path = (String) (opened.elementAt(view.getSelectedIndex())); + final String path = (String) opened.elementAt(view.getSelectedIndex()); if (path == null || path.length() == 0 || path.equals("<>")) { return null; @@ -342,13 +354,18 @@ return null; } - /** Global font has been changed, update the menu bar */ + /** + * Global font has been changed, update the menu bar. + */ public void updateGlobalFont() { view.updateGlobalFont(); } - /** Main method for testing purpose. */ - public static void main(String[] args) { + /** + * Main method for testing purpose. + * @param args + */ + public static void main(final String[] args) { init(System.getProperty("user.dir")); getInstance().openScriptNew(); getInstance().openScriptNew(); @@ -367,8 +384,9 @@ return "*.py"; } - public boolean accept(File f) { + public boolean accept(final File f) { return f.isDirectory() || f.getName().endsWith(".py"); } } -} + +} // class ScriptEditControl Modified: trunk/crossfire/src/cfeditor/textedit/scripteditor/ScriptEditMenuBar.java =================================================================== --- trunk/crossfire/src/cfeditor/textedit/scripteditor/ScriptEditMenuBar.java 2006-05-29 08:44:37 UTC (rev 67) +++ trunk/crossfire/src/cfeditor/textedit/scripteditor/ScriptEditMenuBar.java 2006-05-29 18:51:18 UTC (rev 68) @@ -25,10 +25,10 @@ import cfeditor.textedit.textarea.InputHandler; import cfeditor.textedit.textarea.JEditTextArea; -import java.awt.Event; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.KeyEvent; +import java.awt.Event; import javax.swing.JMenu; import javax.swing.JMenuBar; import javax.swing.JMenuItem; @@ -39,10 +39,13 @@ * This class implements the MenuBar of the script editor. * @author <a href="mailto:and...@gm...">Andreas Vogl</a> */ -public class ScriptEditMenuBar extends JMenuBar { +public final class ScriptEditMenuBar extends JMenuBar { private static final Logger log = Logger.getLogger(ScriptEditMenuBar.class); + /** Serial Version UID. */ + private static final long serialVersionUID = -7022723165514964970L; + private final ScriptEditControl control; // controler object // File menu: @@ -78,10 +81,11 @@ private JMenuItem m_colors; - private static final long serialVersionUID = -7022723165514964970L; - - /** Constructor - Builds the MenuBar. */ - public ScriptEditMenuBar(ScriptEditControl control) { + /** + * Constructor - Builds the MenuBar. + * @param control + */ + public ScriptEditMenuBar(final ScriptEditControl control) { this.control = control; // reference to ScriptEditControl control buildFileMenu(); buildEditMenu(); @@ -89,14 +93,16 @@ refresh(); } - /** Build File menu. */ + /** + * Build File menu. + */ private void buildFileMenu() { menu_file = new JMenu("File"); m_new = new JMenuItem("New Script"); m_new.setMnemonic('N'); m_new.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent event) { + public void actionPerformed(final ActionEvent event) { // open new script control.openScriptNew(); } @@ -106,7 +112,7 @@ m_open = new JMenuItem("Open"); m_open.setMnemonic('O'); m_open.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent event) { + public void actionPerformed(final ActionEvent event) { // open new script control.openUserWanted(); } @@ -119,7 +125,7 @@ //m_save.setIcon(CGUIUtils.getIcon(IGUIConstants.SAVE_LEVEL_SMALLICON)); m_save_as.setMnemonic('v'); m_save_as.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent event) { + public void actionPerformed(final ActionEvent event) { // save as control.saveAsActiveTab(); } @@ -129,10 +135,9 @@ m_save = new JMenuItem("Save"); //m_save.setIcon(CGUIUtils.getIcon(IGUIConstants.SAVE_LEVEL_SMALLICON)); m_save.setMnemonic('S'); - m_save.setAccelerator( - KeyStroke.getKeyStroke(KeyEvent.VK_S, Event.CTRL_MASK)); + m_save.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, Event.CTRL_MASK)); m_save.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent event) { + public void actionPerformed(final ActionEvent event) { // save control.saveActiveTab(); } @@ -145,7 +150,7 @@ m_close.setMnemonic('C'); m_close.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_Q, Event.CTRL_MASK)); m_close.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent event) { + public void actionPerformed(final ActionEvent event) { // close control.closeActiveTab(); } @@ -155,7 +160,7 @@ m_close_all = new JMenuItem("Close All"); m_close_all.setMnemonic('l'); m_close_all.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent event) { + public void actionPerformed(final ActionEvent event) { // close control.closeAllTabs(); } @@ -165,7 +170,9 @@ add(menu_file); } - /** Build Edit Menu. */ + /** + * Build Edit Menu. + */ private void buildEditMenu() { menu_edit = new JMenu("Edit"); @@ -173,9 +180,9 @@ m_cut.setMnemonic('t'); m_cut.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X, Event.CTRL_MASK)); m_cut.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent event) { + public void actionPerformed(final ActionEvent event) { // cut - JEditTextArea activeTA = control.getActiveTextArea(); + final JEditTextArea activeTA = control.getActiveTextArea(); if (activeTA != null) { InputHandler.getAction("cut").actionPerformed(new ActionEvent(activeTA, 0, "cut")); } @@ -187,9 +194,9 @@ m_copy.setMnemonic('C'); m_copy.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C, Event.CTRL_MASK)); m_copy.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent event) { + public void actionPerformed(final ActionEvent event) { // copy - JEditTextArea activeTA = control.getActiveTextArea(); + final JEditTextArea activeTA = control.getActiveTextArea(); if (activeTA != null) { InputHandler.getAction("copy").actionPerformed(new ActionEvent(activeTA, 0, "copy")); } @@ -201,9 +208,9 @@ m_paste.setMnemonic('P'); m_paste.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_V, Event.CTRL_MASK)); m_paste.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent event) { + public void actionPerformed(final ActionEvent event) { // paste - JEditTextArea activeTA = control.getActiveTextArea(); + final JEditTextArea activeTA = control.getActiveTextArea(); if (activeTA != null) { InputHandler.getAction("paste").actionPerformed(new ActionEvent(activeTA, 0, "paste")); } @@ -217,7 +224,7 @@ m_find.setMnemonic('F'); m_find.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F, Event.CTRL_MASK)); m_find.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent event) { + public void actionPerformed(final ActionEvent event) { // find if (log.isInfoEnabled()) { log.info("find..."); @@ -229,14 +236,16 @@ add(menu_edit); } - /** Build Edit Menu */ + /** + * Build Edit Menu. + */ private void buildSettingsMenu() { menu_settings = new JMenu("Settings"); m_font = new JMenuItem("Font"); m_font.setMnemonic('F'); m_font.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent event) { + public void actionPerformed(final ActionEvent event) { // set font } }); @@ -245,7 +254,7 @@ m_colors = new JMenuItem("Colors"); m_colors.setMnemonic('C'); m_colors.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent event) { + public void actionPerformed(final ActionEvent event) { // set colors } }); @@ -254,8 +263,10 @@ add(menu_settings); } - /** Refreshes the enable/disable state of all menus. */ - public void refresh() { + /** + * Refreshes the enable/disable state of all menus. + */ + public final void refresh() { m_find.setEnabled(false); m_colors.setEnabled(false); m_font.setEnabled(false); @@ -268,7 +279,7 @@ * Redraws the whole menu with latest custom fonts. * @param do_redraw if true, menu is redrawn at the end */ - public void updateFont(boolean do_redraw) { + public void updateFont(final boolean do_redraw) { if (!control.isStandAlone()) { // File menu: control.getMainControl().setBoldFont(menu_file); @@ -300,4 +311,5 @@ } } } -} + +} // class ScriptEditMenuBar Modified: trunk/crossfire/src/cfeditor/textedit/scripteditor/ScriptEditView.java =================================================================== --- trunk/crossfire/src/cfeditor/textedit/scripteditor/ScriptEditView.java 2006-05-29 08:44:37 UTC (rev 67) +++ trunk/crossfire/src/cfeditor/textedit/scripteditor/ScriptEditView.java 2006-05-29 18:51:18 UTC (rev 68) @@ -54,14 +54,17 @@ * ScriptEditControl. No other class should refer to it. * @author <a href="mailto:and...@gm...">Andreas Vogl</a> */ -public class ScriptEditView extends JFrame { +public final class ScriptEditView extends JFrame { private static final Logger log = Logger.getLogger(ScriptEditView.class); - /** key used to store the main windows X-coordinate to settings-file. */ + /** Serial Version UID. */ + private static final long serialVersionUID = 1L; + + /** key used to store the main windows x-coordinate to settings-file. */ private static final String WINDOW_X = "ScriptPadWindow.x"; - /** key used to store the main windows Y-coordinate to settings-file. */ + /** key used to store the main windows y-coordinate to settings-file. */ private static final String WINDOW_Y = "ScriptPadWindow.y"; /** key used to store the main windows width to settings-file. */ @@ -78,10 +81,10 @@ private final Vector textAreas; // list of 'JEditTextArea' objects, same order as tabs - private static final long serialVersionUID = -8476542220406619382L; - - /** Build frame but keep it hidden (it is shown when first file is opened). */ - public ScriptEditView(ScriptEditControl control) { + /** + * Build frame but keep it hidden (it is shown when first file is opened). + */ + public ScriptEditView(final ScriptEditControl control) { super("Script Pad"); // window title setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); @@ -94,7 +97,7 @@ tabPane.addChangeListener(new EditTabListener(control, this)); // set the window icon - ImageIcon icon = CGUIUtils.getIcon("Script.gif"); + final ImageIcon icon = CGUIUtils.getIcon("Script.gif"); if (icon != null) { setIconImage(icon.getImage()); } @@ -103,16 +106,16 @@ addWindowListener(new EditWindowListener(control)); // add listener for close box // calculate some default values in case there is no settings file - Dimension screen = Toolkit.getDefaultToolkit().getScreenSize(); - int defwidth = (int) (0.6 * screen.getWidth()); - int defheight = (int) (0.8 * screen.getHeight()); + final Dimension screen = Toolkit.getDefaultToolkit().getScreenSize(); + final int defwidth = (int) (0.6 * screen.getWidth()); + final int defheight = (int) (0.8 * screen.getHeight()); // get the old location and size - CSettings settings = CSettings.getInstance(IGUIConstants.APP_NAME); - int x = Integer.parseInt(settings.getProperty(WINDOW_X, "" + (int) ((screen.getWidth() - defwidth) / 2.))); - int y = Integer.parseInt(settings.getProperty(WINDOW_Y, "" + (int) ((screen.getHeight() - defheight) / 2.))); - int width = Integer.parseInt(settings.getProperty(WINDOW_WIDTH, "" + defwidth)); - int height = Integer.parseInt(settings.getProperty(WINDOW_HEIGHT, "" + defheight)); + final CSettings settings = CSettings.getInstance(IGUIConstants.APP_NAME); + final int x = Integer.parseInt(settings.getProperty(WINDOW_X, "" + (int) ((screen.getWidth() - defwidth) / 2.))); + final int y = Integer.parseInt(settings.getProperty(WINDOW_Y, "" + (int) ((screen.getHeight() - defheight) / 2.))); + final int width = Integer.parseInt(settings.getProperty(WINDOW_WIDTH, "" + defwidth)); + final int height = Integer.parseInt(settings.getProperty(WINDOW_HEIGHT, "" + defheight)); this.setBounds(x, y, width, height); } @@ -122,8 +125,8 @@ * @param title title of this script (filename) * @param f file where this script is stored, null if new script opened */ - public void addTab(String title, File f) { - JEditTextArea ta = new JEditTextArea(); // open new TextArea + public final void addTab(final String title, final File f) { + final JEditTextArea ta = new JEditTextArea(); // open new TextArea //ta.setFont(new Font("Courier New", Font.PLAIN, 12)); ta.setDocument(new SyntaxDocument()); ta.getDocument().setTokenMarker(new PythonTokenMarker()); @@ -153,17 +156,16 @@ BufferedReader bfread = new BufferedReader(fread); boolean firstLine = true; + final StringBuffer buff = new StringBuffer(""); String line = bfread.readLine(); - StringBuffer buff = new StringBuffer(""); while (line != null) { if (!firstLine) { - buff.append("\n"); + buff.append('\n'); } else { firstLine = false; } buff.append(line); line = bfread.readLine(); - } // close filestreams @@ -172,11 +174,11 @@ // insert buffer into the document ta.getDocument().insertString(0, buff.toString(), null); - } catch (FileNotFoundException e) { + } catch (final FileNotFoundException e) { log.info("addTab(): File '" + f.getName() + "' not found."); - } catch (IOException e) { + } catch (final IOException e) { log.info("addTab(): I/O-Error while reading '" + f.getName() + "'."); - } catch (BadLocationException e) { + } catch (final BadLocationException e) { log.info("addTab(): Bad Location in Document!"); } } @@ -188,8 +190,10 @@ refreshMenuBar(); } - /** Close the active script-tab. */ - public void closeActiveTab() { + /** + * Close the active script-tab. + */ + public final void closeActiveTab() { if (textAreas.size() > 0) { // remove textArea textAreas.removeElementAt(tabPane.getSelectedIndex()); @@ -199,8 +203,10 @@ } } - /** @return the currently active TextArea (in front) */ - public JEditTextArea getActiveTextArea() { + /** + * @return the currently active TextArea (in front) + */ + public final JEditTextArea getActiveTextArea() { if (getTabCount() > 0) { return (JEditTextArea) (textAreas.elementAt(tabPane.getSelectedIndex())); } @@ -208,13 +214,17 @@ return null; // no window is open } - /** @return index of selected tab pane */ - public int getSelectedIndex() { + /** + * @return index of selected tab pane + */ + public final int getSelectedIndex() { return tabPane.getSelectedIndex(); } - /** @return number of open tabs. */ - public int getTabCount() { + /** + * @return number of open tabs + */ + public final int getTabCount() { return tabPane.getTabCount(); } @@ -223,16 +233,20 @@ * @param index index of the tab to change title * @param title new title string */ - public void setTitleAt(int index, String title) { + public final void setTitleAt(final int index, final String title) { tabPane.setTitleAt(index, title); } - /** Refresh the menu bar (update enable/disable state of all menus). */ + /** + * Refresh the menu bar (update enable/disable state of all menus). + */ public void refreshMenuBar() { menuBar.updateFont(true); } - /** Update the global fonts (-> menu bar and tab labels). */ + /** + * Update the global fonts (-> menu bar and tab labels). + */ public void updateGlobalFont() { if (!control.isStandAlone()) { control.getMainControl().setBoldFont(tabPane); @@ -250,22 +264,21 @@ * @return true if the user agrees, false if user disagrees */ public boolean askConfirm(String title, String message) { - return JOptionPane.showConfirmDialog(this, message, title, - JOptionPane.YES_NO_OPTION, JOptionPane.INFORMATION_MESSAGE) == JOptionPane.YES_OPTION; + return JOptionPane.showConfirmDialog(this, message, title, JOptionPane.YES_NO_OPTION, JOptionPane.INFORMATION_MESSAGE) == JOptionPane.YES_OPTION; } /** * Shows the given message in the UI. * @param title the title of the message * @param message the message to be shown - * @param messageType Type of message (see JOptionPane constants), defines + * @param messageType type of message (see JOptionPane constants), defines * icon used */ - public void showMessage(String title, String message, int messageType) { + public final void showMessage(final String title, final String message, final int messageType) { JOptionPane.showMessageDialog(this, message, title, messageType); } - public void showMessage(String title, String message) { + public final void showMessage(final String title, final String message) { JOptionPane.showMessageDialog(this, message, title, JOptionPane.INFORMATION_MESSAGE); } @@ -273,10 +286,10 @@ * Notifies that the application is about to exit. The window settings get * saved to the settings file here. */ - void appExitNotify() { + final void appExitNotify() { // store location and size - CSettings settings = CSettings.getInstance(IGUIConstants.APP_NAME); - Rectangle bounds = getBounds(); // window frame bounds + final CSettings settings = CSettings.getInstance(IGUIConstants.APP_NAME); + final Rectangle bounds = getBounds(); // window frame bounds settings.setProperty(WINDOW_X, "" + bounds.x); settings.setProperty(WINDOW_Y, "" + bounds.y); settings.setProperty(WINDOW_WIDTH, "" + bounds.width); @@ -285,40 +298,45 @@ // -------------------------------------- - /** Subclass: Listener for ChangeEvents in the tabPane. */ - private class EditTabListener implements ChangeListener { + /** + * Subclass: Listener for ChangeEvents in the tabPane. + */ + private final class EditTabListener implements ChangeListener { - ScriptEditControl control; // controler + final ScriptEditControl control; // controler - ScriptEditView view; // view + final ScriptEditView view; // view int index; // index of selected tab - public EditTabListener(ScriptEditControl control, ScriptEditView view) { + public EditTabListener(final ScriptEditControl control, final ScriptEditView view) { this.control = control; this.view = view; index = view.getSelectedIndex(); } - public void stateChanged(ChangeEvent e) { + public final void stateChanged(final ChangeEvent e) { if (index != view.getSelectedIndex()) { // active selected tab has changed menuBar.refresh(); // refresh state of menus index = view.getSelectedIndex(); // update index } } - } - /** Subclass: Listener for closebox on the window. */ - private class EditWindowListener implements WindowListener { + } // class EditTabListener - ScriptEditControl control; // controler + /** + * Subclass: Listener for closebox on the window. + */ + private static final class EditWindowListener implements WindowListener { + final ScriptEditControl control; // controller + /** * Constructor. * @param control ScriptEditControl */ - public EditWindowListener(ScriptEditControl control) { + public EditWindowListener(final ScriptEditControl control) { this.control = control; } @@ -326,27 +344,29 @@ * Window closebox has been clicked. * @param e WindowEvent */ - public void windowClosing(WindowEvent e) { + public final void windowClosing(final WindowEvent e) { control.closeAllTabs(); } - public void windowClosed(WindowEvent e) { + public final void windowClosed(final WindowEvent e) { control.closeAllTabs(); // (just make sure tabs are removed...) } - public void windowActivated(WindowEvent e) { + public void windowActivated(final WindowEvent e) { } - public void windowDeactivated(WindowEvent e) { + public void windowDeactivated(final WindowEvent e) { } - public void windowDeiconified(WindowEvent e) { + public void windowDeiconified(final WindowEvent e) { } - public void windowIconified(WindowEvent e) { + public void windowIconified(final WindowEvent e) { } - public void windowOpened(WindowEvent e) { + public void windowOpened(final WindowEvent e) { } - } -} + + } // class EditWindowListener + +} // class ScriptEditView Modified: trunk/crossfire/src/cfeditor/textedit/textarea/CTokenMarker.java =================================================================== --- trunk/crossfire/src/cfeditor/textedit/textarea/CTokenMarker.java 2006-05-29 08:44:37 UTC (rev 67) +++ trunk/crossfire/src/cfeditor/textedit/textarea/CTokenMarker.java 2006-05-29 18:51:18 UTC (rev 68) @@ -22,24 +22,24 @@ this(true, getKeywords()); } - public CTokenMarker(boolean cpp, KeywordMap keywords) { + public CTokenMarker(final boolean cpp, final KeywordMap keywords) { this.cpp = cpp; this.keywords = keywords; } - public byte markTokensImpl(byte token, Segment line, int lineIndex) { - char[] array = line.array; - int offset = line.offset; + public final byte markTokensImpl(byte token, final Segment line, final int lineIndex) { + final char[] array = line.array; + final int offset = line.offset; lastOffset = offset; lastKeyword = offset; - int length = line.count + offset; + final int length = line.count + offset; boolean backslash = false; loop: for (int i = offset; i < length; i++) { - int i1 = i + 1; + final int i1 = i + 1; - char c = array[i]; + final char c = array[i]; if (c == '\\') { backslash = !backslash; continue; @@ -57,7 +57,8 @@ } addToken(i - lastOffset, token); addToken(length - i, Token.KEYWORD2); - lastOffset = lastKeyword = length; + lastOffset = length; + lastKeyword = length; break loop; } break; @@ -69,7 +70,8 @@ } else { addToken(i - lastOffset, token); token = Token.LITERAL1; - lastOffset = lastKeyword = i; + lastOffset = i; + lastKeyword = i; } break; @@ -80,7 +82,8 @@ } else { addToken(i - lastOffset, token); token = Token.LITERAL2; - lastOffset = lastKeyword = i; + lastOffset = i; + lastKeyword = i; } break; @@ -91,7 +94,8 @@ } backslash = false; addToken(i1 - lastOffset, Token.LABEL); - lastOffset = lastKeyword = i1; + lastOffset = i1; + lastKeyword = i1; } else if (doKeyword(line, i, c)) { break; } @@ -104,7 +108,8 @@ switch (array[i1]) { case '*': addToken(i - lastOffset, token); - lastOffset = lastKeyword = i; + lastOffset = i; + lastKeyword = i; if (length - i > 2 && array[i + 2] == '*') { token = Token.COMMENT2; } else { @@ -115,7 +120,8 @@ case '/': addToken(i - lastOffset, token); addToken(length - i, Token.COMMENT1); - lastOffset = lastKeyword = length; + lastOffset = length; + lastKeyword = length; break loop; } } @@ -136,9 +142,10 @@ if (c == '*' && length - i > 1) { if (array[i1] == '/') { i++; - addToken((i + 1) - lastOffset, token); + addToken(i + 1 - lastOffset, token); token = Token.NULL; - lastOffset = lastKeyword = i + 1; + lastOffset = i + 1; + lastKeyword = i + 1; } } break; @@ -149,7 +156,8 @@ } else if (c == '"') { addToken(i1 - lastOffset, token); token = Token.NULL; - lastOffset = lastKeyword = i1; + lastOffset = i1; + lastKeyword = i1; } break; @@ -159,7 +167,8 @@ } else if (c == '\'') { addToken(i1 - lastOffset, Token.LITERAL1); token = Token.NULL; - lastOffset = lastKeyword = i1; + lastOffset = i1; + lastKeyword = i1; } break; @@ -185,6 +194,7 @@ token = Token.NULL; } + // @devs what is with this fallthrough? Intention or Accident? default: addToken(length - lastOffset, token); break; @@ -253,11 +263,11 @@ private int lastKeyword; - private boolean doKeyword(Segment line, int i, char c) { - int i1 = i + 1; + private boolean doKeyword(final Segment line, final int i, final char c) { + final int i1 = i + 1; - int len = i - lastKeyword; - byte id = keywords.lookup(line, lastKeyword, len); + final int len = i - lastKeyword; + final byte id = keywords.lookup(line, lastKeyword, len); if (id != Token.NULL) { if (lastKeyword != lastOffset) { addToken(lastKeyword - lastOffset, Token.NULL); Modified: trunk/crossfire/src/cfeditor/textedit/textarea/DefaultInputHandler.java =================================================================== --- trunk/crossfire/src/cfeditor/textedit/textarea/DefaultInputHandler.java 2006-05-29 08:44:37 UTC (rev 67) +++ trunk/crossfire/src/cfeditor/textedit/textarea/DefaultInputHandler.java 2006-05-29 18:51:18 UTC (rev 68) @@ -25,16 +25,25 @@ * @author <a href="mailto:and...@gm...">Andreas Vogl</a> * @version $Id: DefaultInputHandler.java,v 1.7 2006/03/26 00:48:57 akirschbaum Exp $ */ -public class DefaultInputHandler extends InputHandler { +public final class DefaultInputHandler extends InputHandler { + private Hashtable bindings; + + private Hashtable currentBindings; + private static final Logger log = Logger.getLogger(DefaultInputHandler.class); - /** Creates a new input handler with no key bindings defined. */ + /** + * Creates a new input handler with no key bindings defined. + */ public DefaultInputHandler() { - bindings = currentBindings = new Hashtable(); + currentBindings = new Hashtable(); + bindings = currentBindings; } - /** Sets up the default key bindings. */ + /** + * Sets up the default key bindings. + */ public void addDefaultKeyBindings() { addKeyBinding("BACK_SPACE", BACKSPACE); addKeyBinding("C+BACK_SPACE", BACKSPACE_WORD); @@ -93,12 +102,12 @@ * @param keyBinding the key binding * @param action the action */ - public void addKeyBinding(String keyBinding, ActionListener action) { + public void addKeyBinding(final String keyBinding, final ActionListener action) { Hashtable current = bindings; - StringTokenizer st = new StringTokenizer(keyBinding); + final StringTokenizer st = new StringTokenizer(keyBinding); while (st.hasMoreTokens()) { - KeyStroke keyStroke = parseKeyStroke(st.nextToken()); + final KeyStroke keyStroke = parseKeyStroke(st.nextToken()); if (keyStroke == null) { return; } @@ -123,7 +132,7 @@ * implemented. * @param keyBinding the key binding */ - public void removeKeyBinding(String keyBinding) { + public void removeKeyBinding(final String keyBinding) { throw new InternalError("Not yet implemented"); } @@ -144,9 +153,9 @@ * Handle a key pressed event. This will look up the binding for the key * stroke and execute it. */ - public void keyPressed(KeyEvent evt) { - int keyCode = evt.getKeyCode(); - int modifiers = evt.getModifiers(); + public void keyPressed(final KeyEvent evt) { + final int keyCode = evt.getKeyCode(); + final int modifiers = evt.getModifiers(); if (keyCode == KeyEvent.VK_CONTROL || keyCode == KeyEvent.VK_SHIFT @@ -167,8 +176,8 @@ return; } - KeyStroke keyStroke = KeyStroke.getKeyStroke(keyCode, modifiers); - Object o = currentBindings.get(keyStroke); + final KeyStroke keyStroke = KeyStroke.getKeyStroke(keyCode, modifiers); + final Object o = currentBindings.get(keyStroke); if (o == null) { // Don't beep if the user presses some // key we don't know about unless a @@ -186,9 +195,7 @@ return; } else if (o instanceof ActionListener) { currentBindings = bindings; - - executeAction(((ActionListener) o), evt.getSource(), null); - + executeAction((ActionListener) o, evt.getSource(), null); evt.consume(); return; } else if (o instanceof Hashtable) { @@ -199,16 +206,17 @@ } } - /** Handle a key typed event. This inserts the key into the text area. */ - public void keyTyped(KeyEvent evt) { - int modifiers = evt.getModifiers(); - char c = evt.getKeyChar(); + /** + * Handle a key typed event. This inserts the key into the text area. + */ + public void keyTyped(final KeyEvent evt) { + final int modifiers = evt.getModifiers(); + final char c = evt.getKeyChar(); if (c != KeyEvent.CHAR_UNDEFINED && (modifiers & KeyEvent.ALT_MASK) == 0) { if (c >= 0x20 && c != 0x7f) { - KeyStroke keyStroke = KeyStroke.getKeyStroke( - Character.toUpperCase(c)); - Object o = currentBindings.get(keyStroke); + final KeyStroke keyStroke = KeyStroke.getKeyStroke(Character.toUpperCase(c)); + final Object o = currentBindings.get(keyStroke); if (o instanceof Hashtable) { currentBindings = (Hashtable) o; @@ -231,7 +239,7 @@ // 0-9 adds another 'digit' to the repeat number if (repeat && Character.isDigit(c)) { repeatCount *= 10; - repeatCount += (c - '0'); + repeatCount += c - '0'; return; } @@ -251,13 +259,13 @@ * <code>KeyEvent</code> class, without the <code>VK_</code> prefix. * @param keyStroke a string description of the key stroke */ - public static KeyStroke parseKeyStroke(String keyStroke) { + public static KeyStroke parseKeyStroke(final String keyStroke) { if (keyStroke == null) { return null; } int modifiers = 0; - int index = keyStroke.indexOf('+'); + final int index = keyStroke.indexOf('+'); if (index != -1) { for (int i = 0; i < index; i++) { switch (Character.toUpperCase(keyStroke.charAt(i))) { @@ -276,9 +284,10 @@ } } } - String key = keyStroke.substring(index + 1); + + final String key = keyStroke.substring(index + 1); if (key.length() == 1) { - char ch = Character.toUpperCase(key.charAt(0)); + final char ch = Character.toUpperCase(key.charAt(0)); if (modifiers == 0) { return KeyStroke.getKeyStroke(ch); } else { @@ -288,12 +297,11 @@ log.error("Invalid key stroke: " + keyStroke); return null; } else { - int ch; + final int ch; try { - ch = KeyEvent.class.getField("VK_".concat(key)) - .getInt(null); - } catch (Exception e) { + ch = KeyEvent.class.getField("VK_".concat(key)).getInt(null); + } catch (final Exception e) { log.error("Invalid key stroke: " + keyStroke); return null; } @@ -302,12 +310,9 @@ } } - // private members - private Hashtable bindings; + private DefaultInputHandler(final DefaultInputHandler copy) { + currentBindings = copy.bindings; + bindings = currentBindings; + } - private Hashtable currentBindings; - - private DefaultInputHandler(DefaultInputHandler copy) { - bindings = currentBindings = copy.bindings; - } -} +} // class DefaultInputHandler Modified: trunk/crossfire/src/cfeditor/textedit/textarea/HTMLTokenMarker.java =================================================================== --- trunk/crossfire/src/cfeditor/textedit/textarea/HTMLTokenMarker.java 2006-05-29 08:44:37 UTC (rev 67) +++ trunk/crossfire/src/cfeditor/textedit/textarea/HTMLTokenMarker.java 2006-05-29 18:51:18 UTC (rev 68) @@ -24,24 +24,24 @@ this(true); } - public HTMLTokenMarker(boolean js) { + public HTMLTokenMarker(final boolean js) { this.js = js; keywords = JavaScriptTokenMarker.getKeywords(); } - public byte markTokensImpl(byte token, Segment line, int lineIndex) { - char[] array = line.array; - int offset = line.offset; + public final byte markTokensImpl(byte token, final Segment line, final int lineIndex) { + final char[] array = line.array; + final int offset = line.offset; lastOffset = offset; lastKeyword = offset; - int length = line.c... [truncated message content] |
From: <aki...@us...> - 2006-05-29 18:59:52
|
Revision: 69 Author: akirschbaum Date: 2006-05-29 11:59:39 -0700 (Mon, 29 May 2006) ViewCVS: http://svn.sourceforge.net/gridarta/?rev=69&view=rev Log Message: ----------- Replace TAB with spaces. Modified Paths: -------------- trunk/crossfire/src/cfeditor/textedit/textarea/DefaultInputHandler.java trunk/daimonin/src/daieditor/textedit/textarea/DefaultInputHandler.java Modified: trunk/crossfire/src/cfeditor/textedit/textarea/DefaultInputHandler.java =================================================================== --- trunk/crossfire/src/cfeditor/textedit/textarea/DefaultInputHandler.java 2006-05-29 18:51:18 UTC (rev 68) +++ trunk/crossfire/src/cfeditor/textedit/textarea/DefaultInputHandler.java 2006-05-29 18:59:39 UTC (rev 69) @@ -285,7 +285,7 @@ } } - final String key = keyStroke.substring(index + 1); + final String key = keyStroke.substring(index + 1); if (key.length() == 1) { final char ch = Character.toUpperCase(key.charAt(0)); if (modifiers == 0) { Modified: trunk/daimonin/src/daieditor/textedit/textarea/DefaultInputHandler.java =================================================================== --- trunk/daimonin/src/daieditor/textedit/textarea/DefaultInputHandler.java 2006-05-29 18:51:18 UTC (rev 68) +++ trunk/daimonin/src/daieditor/textedit/textarea/DefaultInputHandler.java 2006-05-29 18:59:39 UTC (rev 69) @@ -282,7 +282,7 @@ } } - final String key = keyStroke.substring(index + 1); + final String key = keyStroke.substring(index + 1); if (key.length() == 1) { final char ch = Character.toUpperCase(key.charAt(0)); if (modifiers == 0) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2006-06-22 17:55:44
|
Revision: 171 Author: akirschbaum Date: 2006-06-22 10:55:24 -0700 (Thu, 22 Jun 2006) ViewCVS: http://svn.sourceforge.net/gridarta/?rev=171&view=rev Log Message: ----------- Unify comments and whitespace. Modified Paths: -------------- trunk/crossfire/src/cfeditor/textedit/scripteditor/CFPythonPopup.java trunk/crossfire/src/cfeditor/textedit/scripteditor/ScriptEditView.java trunk/crossfire/src/cfeditor/textedit/textarea/DefaultInputHandler.java trunk/crossfire/src/cfeditor/textedit/textarea/InputHandler.java trunk/daimonin/src/daieditor/textedit/scripteditor/ScriptEditView.java trunk/daimonin/src/daieditor/textedit/textarea/InputHandler.java trunk/daimonin/src/daieditor/textedit/textarea/JEditTextArea.java Modified: trunk/crossfire/src/cfeditor/textedit/scripteditor/CFPythonPopup.java =================================================================== --- trunk/crossfire/src/cfeditor/textedit/scripteditor/CFPythonPopup.java 2006-06-22 17:43:41 UTC (rev 170) +++ trunk/crossfire/src/cfeditor/textedit/scripteditor/CFPythonPopup.java 2006-06-22 17:55:24 UTC (rev 171) @@ -207,7 +207,7 @@ return menu; } - // ------------------------ SUBCLASSES ----------------------- + // ------------------------ NESTED / INNER CLASSES ----------------------- /** * Subclass MenuActionListener handles the actionevents for the menu items. Modified: trunk/crossfire/src/cfeditor/textedit/scripteditor/ScriptEditView.java =================================================================== --- trunk/crossfire/src/cfeditor/textedit/scripteditor/ScriptEditView.java 2006-06-22 17:43:41 UTC (rev 170) +++ trunk/crossfire/src/cfeditor/textedit/scripteditor/ScriptEditView.java 2006-06-22 17:55:24 UTC (rev 171) @@ -300,7 +300,7 @@ // -------------------------------------- /** - * Subclass: Listener for ChangeEvents in the tabPane. + * Inner class: Listener for ChangeEvents in the tabPane. */ private final class EditTabListener implements ChangeListener { @@ -324,7 +324,7 @@ } // class EditTabListener /** - * Subclass: Listener for closebox on the window. + * Inner class: Listener for closebox on the window. */ private static final class EditWindowListener implements WindowListener { Modified: trunk/crossfire/src/cfeditor/textedit/textarea/DefaultInputHandler.java =================================================================== --- trunk/crossfire/src/cfeditor/textedit/textarea/DefaultInputHandler.java 2006-06-22 17:43:41 UTC (rev 170) +++ trunk/crossfire/src/cfeditor/textedit/textarea/DefaultInputHandler.java 2006-06-22 17:55:24 UTC (rev 171) @@ -311,6 +311,7 @@ } } + // private members private DefaultInputHandler(final DefaultInputHandler copy) { currentBindings = copy.bindings; bindings = currentBindings; Modified: trunk/crossfire/src/cfeditor/textedit/textarea/InputHandler.java =================================================================== --- trunk/crossfire/src/cfeditor/textedit/textarea/InputHandler.java 2006-06-22 17:43:41 UTC (rev 170) +++ trunk/crossfire/src/cfeditor/textedit/textarea/InputHandler.java 2006-06-22 17:55:24 UTC (rev 171) @@ -186,7 +186,7 @@ /** * Returns a named text area action. - * @param name the action + * @param name the action name */ public static ActionListener getAction(final String name) { return (ActionListener) actions.get(name); Modified: trunk/daimonin/src/daieditor/textedit/scripteditor/ScriptEditView.java =================================================================== --- trunk/daimonin/src/daieditor/textedit/scripteditor/ScriptEditView.java 2006-06-22 17:43:41 UTC (rev 170) +++ trunk/daimonin/src/daieditor/textedit/scripteditor/ScriptEditView.java 2006-06-22 17:55:24 UTC (rev 171) @@ -277,7 +277,7 @@ // -------------------------------------- /** - * Inner bclass: Listener for ChangeEvents in the tabPane. + * Inner class: Listener for ChangeEvents in the tabPane. */ private final class EditTabListener implements ChangeListener { @@ -301,7 +301,7 @@ } // class EditTabListener /** - * Inner bclass: Listener for closebox on the window. + * Inner class: Listener for closebox on the window. */ private static final class EditWindowListener extends WindowAdapter { Modified: trunk/daimonin/src/daieditor/textedit/textarea/InputHandler.java =================================================================== --- trunk/daimonin/src/daieditor/textedit/textarea/InputHandler.java 2006-06-22 17:43:41 UTC (rev 170) +++ trunk/daimonin/src/daieditor/textedit/textarea/InputHandler.java 2006-06-22 17:55:24 UTC (rev 171) @@ -183,7 +183,7 @@ /** * Returns a named text area action. - * @param name The action name + * @param name the action name */ public static ActionListener getAction(final String name) { return actions.get(name); Modified: trunk/daimonin/src/daieditor/textedit/textarea/JEditTextArea.java =================================================================== --- trunk/daimonin/src/daieditor/textedit/textarea/JEditTextArea.java 2006-06-22 17:43:41 UTC (rev 170) +++ trunk/daimonin/src/daieditor/textedit/textarea/JEditTextArea.java 2006-06-22 17:55:24 UTC (rev 171) @@ -396,6 +396,7 @@ */ public final boolean setOrigin(final int firstLine, final int horizontalOffset) { boolean changed = false; + if (horizontalOffset != this.horizontalOffset) { this.horizontalOffset = horizontalOffset; changed = true; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2006-05-29 19:51:42
|
Revision: 72 Author: akirschbaum Date: 2006-05-29 12:51:19 -0700 (Mon, 29 May 2006) ViewCVS: http://svn.sourceforge.net/gridarta/?rev=72&view=rev Log Message: ----------- Make fields private or protected; add accessor functions. Modified Paths: -------------- trunk/crossfire/src/cfeditor/textedit/scripteditor/ScriptEditView.java trunk/crossfire/src/cfeditor/textedit/textarea/KeywordMap.java trunk/crossfire/src/cfeditor/textedit/textarea/TextAreaDefaults.java trunk/crossfire/src/cfeditor/textedit/textarea/TextAreaPainter.java trunk/crossfire/src/cfeditor/textedit/textarea/Token.java trunk/crossfire/src/cfeditor/textedit/textarea/TokenMarker.java trunk/daimonin/src/daieditor/textedit/scripteditor/ScriptEditView.java trunk/daimonin/src/daieditor/textedit/textarea/JEditTextArea.java trunk/daimonin/src/daieditor/textedit/textarea/KeywordMap.java trunk/daimonin/src/daieditor/textedit/textarea/SyntaxUtilities.java trunk/daimonin/src/daieditor/textedit/textarea/TextAreaDefaults.java trunk/daimonin/src/daieditor/textedit/textarea/TextAreaPainter.java trunk/daimonin/src/daieditor/textedit/textarea/Token.java trunk/daimonin/src/daieditor/textedit/textarea/TokenMarker.java Modified: trunk/crossfire/src/cfeditor/textedit/scripteditor/ScriptEditView.java =================================================================== --- trunk/crossfire/src/cfeditor/textedit/scripteditor/ScriptEditView.java 2006-05-29 19:06:56 UTC (rev 71) +++ trunk/crossfire/src/cfeditor/textedit/scripteditor/ScriptEditView.java 2006-05-29 19:51:19 UTC (rev 72) @@ -303,11 +303,11 @@ */ private final class EditTabListener implements ChangeListener { - final ScriptEditControl control; // controler + private final ScriptEditControl control; // controler - final ScriptEditView view; // view + private final ScriptEditView view; // view - int index; // index of selected tab + private int index; // index of selected tab public EditTabListener(final ScriptEditControl control, final ScriptEditView view) { this.control = control; @@ -330,7 +330,7 @@ */ private static final class EditWindowListener implements WindowListener { - final ScriptEditControl control; // controller + private final ScriptEditControl control; // controller /** * Constructor. Modified: trunk/crossfire/src/cfeditor/textedit/textarea/KeywordMap.java =================================================================== --- trunk/crossfire/src/cfeditor/textedit/textarea/KeywordMap.java 2006-05-29 19:06:56 UTC (rev 71) +++ trunk/crossfire/src/cfeditor/textedit/textarea/KeywordMap.java 2006-05-29 19:51:19 UTC (rev 72) @@ -97,7 +97,7 @@ } // protected members - protected final int mapLength; + private final int mapLength; protected final int getStringMapKey(final String s) { return (Character.toUpperCase(s.charAt(0)) + Character.toUpperCase(s.charAt(s.length() - 1))) % mapLength; @@ -116,11 +116,11 @@ this.next = next; } - public final char[] keyword; + private final char[] keyword; - public final byte id; + private final byte id; - public final Keyword next; + private final Keyword next; } private final Keyword[] map; Modified: trunk/crossfire/src/cfeditor/textedit/textarea/TextAreaDefaults.java =================================================================== --- trunk/crossfire/src/cfeditor/textedit/textarea/TextAreaDefaults.java 2006-05-29 19:06:56 UTC (rev 71) +++ trunk/crossfire/src/cfeditor/textedit/textarea/TextAreaDefaults.java 2006-05-29 19:51:19 UTC (rev 72) @@ -178,4 +178,5 @@ public JPopupMenu getPopup() { return popup; } + } // class TextAreaDefaults Modified: trunk/crossfire/src/cfeditor/textedit/textarea/TextAreaPainter.java =================================================================== --- trunk/crossfire/src/cfeditor/textedit/textarea/TextAreaPainter.java 2006-05-29 19:06:56 UTC (rev 71) +++ trunk/crossfire/src/cfeditor/textedit/textarea/TextAreaPainter.java 2006-05-29 19:51:19 UTC (rev 72) @@ -547,7 +547,7 @@ } } - final protected void paintPlainLine(final Graphics gfx, final int line, final Font defaultFont, final Color defaultColor, int x, int y) { + protected final void paintPlainLine(final Graphics gfx, final int line, final Font defaultFont, final Color defaultColor, int x, int y) { paintHighlight(gfx, line, y); textArea.getLineText(line, currentLine); @@ -567,7 +567,7 @@ * When syntax highlighting is enabled, this method is called from * paintLine() to do the actual drawing of the line. */ - final protected void paintSyntaxLine(final Graphics gfx, final TokenMarker tokenMarker, final int line, final Font defaultFont, final Color defaultColor, int x, int y) { + protected final void paintSyntaxLine(final Graphics gfx, final TokenMarker tokenMarker, final int line, final Font defaultFont, final Color defaultColor, int x, int y) { textArea.getLineText(currentLineIndex, currentLine); currentLineTokens = tokenMarker.markTokens(currentLine, currentLineIndex); @@ -587,7 +587,7 @@ } } - final protected void paintHighlight(final Graphics gfx, final int line, final int y) { + protected final void paintHighlight(final Graphics gfx, final int line, final int y) { if (line >= textArea.getSelectionStartLine() && line <= textArea.getSelectionEndLine()) { paintLineHighlight(gfx, line, y); } @@ -605,7 +605,7 @@ } } - final protected void paintLineHighlight(final Graphics gfx, final int line, int y) { + protected final void paintLineHighlight(final Graphics gfx, final int line, int y) { final int height = fm.getHeight(); y += fm.getLeading() + fm.getMaxDescent(); @@ -653,7 +653,7 @@ } - final protected void paintBracketHighlight(final Graphics gfx, final int line, int y) { + protected final void paintBracketHighlight(final Graphics gfx, final int line, int y) { final int position = textArea.getBracketPosition(); if (position == -1) { return; @@ -668,7 +668,7 @@ gfx.drawRect(x, y, fm.charWidth('(') - 1, fm.getHeight() - 1); } - final protected void paintCaret(final Graphics gfx, final int line, int y) { + protected final void paintCaret(final Graphics gfx, final int line, int y) { if (textArea.isCaretVisible()) { final int offset = textArea.getCaretPosition() - textArea.getLineStartOffset(line); final int caretX = textArea._offsetToX(line, offset); @@ -708,4 +708,5 @@ public void setCurrentLineTokens(Token token) { currentLineTokens = token; } + } // class TextAreaPainter Modified: trunk/crossfire/src/cfeditor/textedit/textarea/Token.java =================================================================== --- trunk/crossfire/src/cfeditor/textedit/textarea/Token.java 2006-05-29 19:06:56 UTC (rev 71) +++ trunk/crossfire/src/cfeditor/textedit/textarea/Token.java 2006-05-29 19:51:19 UTC (rev 72) @@ -146,4 +146,5 @@ public void setNext(Token next_) { next = next_; } + } // class Token Modified: trunk/crossfire/src/cfeditor/textedit/textarea/TokenMarker.java =================================================================== --- trunk/crossfire/src/cfeditor/textedit/textarea/TokenMarker.java 2006-05-29 19:06:56 UTC (rev 71) +++ trunk/crossfire/src/cfeditor/textedit/textarea/TokenMarker.java 2006-05-29 19:51:19 UTC (rev 72) @@ -284,8 +284,8 @@ * Creates a new LineInfo object with the specified parameters. */ public LineInfo(final byte token, final Object obj) { - this.token = token; - this.obj = obj; + this.setToken(token); + this.setObj(obj); } /** The id of the last token of the line. */ Modified: trunk/daimonin/src/daieditor/textedit/scripteditor/ScriptEditView.java =================================================================== --- trunk/daimonin/src/daieditor/textedit/scripteditor/ScriptEditView.java 2006-05-29 19:06:56 UTC (rev 71) +++ trunk/daimonin/src/daieditor/textedit/scripteditor/ScriptEditView.java 2006-05-29 19:51:19 UTC (rev 72) @@ -285,7 +285,7 @@ private int index; // index of selected tab - EditTabListener(final ScriptEditView view) { + public EditTabListener(final ScriptEditView view) { this.view = view; index = view.getSelectedIndex(); } @@ -311,7 +311,7 @@ * Constructor. * @param control ScriptEditControl */ - EditWindowListener(final ScriptEditControl control) { + public EditWindowListener(final ScriptEditControl control) { this.control = control; } Modified: trunk/daimonin/src/daieditor/textedit/textarea/JEditTextArea.java =================================================================== --- trunk/daimonin/src/daieditor/textedit/textarea/JEditTextArea.java 2006-05-29 19:06:56 UTC (rev 71) +++ trunk/daimonin/src/daieditor/textedit/textarea/JEditTextArea.java 2006-05-29 19:51:19 UTC (rev 72) @@ -141,14 +141,14 @@ addFocusListener(new FocusHandler()); // Load the defaults - setInputHandler(defaults.inputHandler); - setDocument(defaults.document); - editable = defaults.editable; - caretVisible = defaults.caretVisible; - caretBlinks = defaults.caretBlinks; - electricScroll = defaults.electricScroll; + setInputHandler(defaults.getInputHandler()); + setDocument(defaults.getDocument()); + editable = defaults.getEditable(); + caretVisible = defaults.getCaretVisible(); + caretBlinks = defaults.getCaretBlinks(); + electricScroll = defaults.getElectricScroll(); - popup = defaults.popup; + popup = defaults.getPopup(); // free tab key from the focus traversal manager freeTabKeyFromFocusTraversal(); @@ -515,7 +515,7 @@ */ public final int offsetToX(final int line, final int offset) { // don't use cached tokens - painter.currentLineTokens = null; + painter.setCurrentLineTokens(null); return _offsetToX(line, offset); } @@ -546,18 +546,19 @@ /* If syntax coloring is enabled, we have to do this because * tokens can vary in width */ Token tokens; - if (painter.currentLineIndex == line && painter.currentLineTokens != null) { - tokens = painter.currentLineTokens; + if (painter.getCurrentLineIndex() == line && painter.getCurrentLineTokens() != null) { + tokens = painter.getCurrentLineTokens(); } else { - painter.currentLineIndex = line; - tokens = painter.currentLineTokens = tokenMarker.markTokens(lineSegment, line); + painter.setCurrentLineIndex(line); + tokens = tokenMarker.markTokens(lineSegment, line); + painter.setCurrentLineTokens(tokens); } final Font defaultFont = painter.getFont(); final SyntaxStyle[] styles = painter.getStyles(); while (true) { - final byte id = tokens.id; + final byte id = tokens.getId(); if (id == Token.END) { return x; } @@ -568,7 +569,7 @@ fm = styles[id].getFontMetrics(defaultFont, painter.getGraphics()); } - final int length = tokens.length; + final int length = tokens.getLength(); if (offset + segmentOffset < lineSegment.offset + length) { lineSegment.count = offset - (lineSegment.offset - segmentOffset); @@ -577,7 +578,7 @@ lineSegment.count = length; x += Utilities.getTabbedTextWidth(lineSegment, fm, x, painter, 0); lineSegment.offset += length; - tokens = tokens.next; + tokens = tokens.getNext(); } } } @@ -627,11 +628,12 @@ return segmentCount; } else { Token tokens; - if (painter.currentLineIndex == line && painter .currentLineTokens != null) { - tokens = painter.currentLineTokens; + if (painter.getCurrentLineIndex() == line && painter.getCurrentLineTokens() != null) { + tokens = painter.getCurrentLineTokens(); } else { - painter.currentLineIndex = line; - tokens = painter.currentLineTokens = tokenMarker.markTokens(lineSegment, line); + painter.setCurrentLineIndex(line); + tokens = tokenMarker.markTokens(lineSegment, line); + painter.setCurrentLineTokens(tokens); } int offset = 0; @@ -639,7 +641,7 @@ final SyntaxStyle[] styles = painter.getStyles(); while (true) { - final byte id = tokens.id; + final byte id = tokens.getId(); if (id == Token.END) { return offset; } @@ -650,7 +652,7 @@ fm = styles[id].getFontMetrics(defaultFont, painter.getGraphics()); } - final int length = tokens.length; + final int length = tokens.getLength(); for (int i = 0; i < length; i++) { final char c = segmentArray[segmentOffset + offset + i]; @@ -675,7 +677,7 @@ } offset += length; - tokens = tokens.next; + tokens = tokens.getNext(); } } } @@ -1500,7 +1502,7 @@ protected boolean rectSelect; - final void fireCaretEvent() { + protected final void fireCaretEvent() { final Object[] listeners = listenerList.getListenerList(); for (int i = listeners.length - 2; i >= 0; i--) { if (listeners[i] == CaretListener.class) { @@ -1509,7 +1511,7 @@ } } - final void updateBracketHighlight(final int newCaretPosition) { + protected final void updateBracketHighlight(final int newCaretPosition) { if (newCaretPosition == 0) { bracketPosition = bracketLine = -1; return; @@ -1529,7 +1531,7 @@ bracketLine = bracketPosition = -1; } - final void documentChanged(final DocumentEvent evt) { + protected final void documentChanged(final DocumentEvent evt) { final DocumentEvent.ElementChange ch = evt.getChange(document.getDefaultRootElement()); final int count; Modified: trunk/daimonin/src/daieditor/textedit/textarea/KeywordMap.java =================================================================== --- trunk/daimonin/src/daieditor/textedit/textarea/KeywordMap.java 2006-05-29 19:06:56 UTC (rev 71) +++ trunk/daimonin/src/daieditor/textedit/textarea/KeywordMap.java 2006-05-29 19:51:19 UTC (rev 72) @@ -98,30 +98,30 @@ } // protected members - final int mapLength; + private final int mapLength; - final int getStringMapKey(final String s) { + public final int getStringMapKey(final String s) { return (Character.toUpperCase(s.charAt(0)) + Character.toUpperCase(s.charAt(s.length() - 1))) % mapLength; } - final int getSegmentMapKey(final Segment s, final int off, final int len) { + public final int getSegmentMapKey(final Segment s, final int off, final int len) { return (Character.toUpperCase(s.array[off]) + Character.toUpperCase(s.array[off + len - 1])) % mapLength; } // private members static final class Keyword { - Keyword(final char[] keyword, final byte id, final Keyword next) { + public Keyword(final char[] keyword, final byte id, final Keyword next) { this.keyword = keyword; this.id = id; this.next = next; } - final char[] keyword; + private final char[] keyword; - final byte id; + private final byte id; - final Keyword next; + private final Keyword next; } private final Keyword[] map; Modified: trunk/daimonin/src/daieditor/textedit/textarea/SyntaxUtilities.java =================================================================== --- trunk/daimonin/src/daieditor/textedit/textarea/SyntaxUtilities.java 2006-05-29 19:06:56 UTC (rev 71) +++ trunk/daimonin/src/daieditor/textedit/textarea/SyntaxUtilities.java 2006-05-29 19:51:19 UTC (rev 72) @@ -122,12 +122,12 @@ int offset = 0; while (true) { - final byte id = tokens.id; + final byte id = tokens.getId(); if (id == Token.END) { break; } - final int length = tokens.length; + final int length = tokens.getLength(); if (id == Token.NULL) { if (!defaultColor.equals(gfx.getColor())) { gfx.setColor(defaultColor); @@ -144,7 +144,7 @@ line.offset += length; offset += length; - tokens = tokens.next; + tokens = tokens.getNext(); } return x; Modified: trunk/daimonin/src/daieditor/textedit/textarea/TextAreaDefaults.java =================================================================== --- trunk/daimonin/src/daieditor/textedit/textarea/TextAreaDefaults.java 2006-05-29 19:06:56 UTC (rev 71) +++ trunk/daimonin/src/daieditor/textedit/textarea/TextAreaDefaults.java 2006-05-29 19:51:19 UTC (rev 72) @@ -22,45 +22,45 @@ private static TextAreaDefaults DEFAULTS; - public InputHandler inputHandler; + private InputHandler inputHandler; - public SyntaxDocument document; + private SyntaxDocument document; - public boolean editable; + private boolean editable; - public boolean caretVisible; + private boolean caretVisible; - public boolean caretBlinks; + private boolean caretBlinks; - public boolean blockCaret; + private boolean blockCaret; - public int electricScroll; + private int electricScroll; - public int cols; + private int cols; - public int rows; + private int rows; - public SyntaxStyle[] styles; + private SyntaxStyle[] styles; - public Color caretColor; + private Color caretColor; - public Color selectionColor; + private Color selectionColor; - public Color lineHighlightColor; + private Color lineHighlightColor; - public boolean lineHighlight; + private boolean lineHighlight; - public Color bracketHighlightColor; + private Color bracketHighlightColor; - public boolean bracketHighlight; + private boolean bracketHighlight; - public Color eolMarkerColor; + private Color eolMarkerColor; - public boolean eolMarkers; + private boolean eolMarkers; - public boolean paintInvalid; + private boolean paintInvalid; - public JPopupMenu popup; + private JPopupMenu popup; /** * Returns a new TextAreaDefaults object with the default values filled in. @@ -98,4 +98,84 @@ return DEFAULTS; } + public InputHandler getInputHandler() { + return inputHandler; + } + + public SyntaxDocument getDocument() { + return document; + } + + public boolean getEditable() { + return editable; + } + + public boolean getCaretVisible() { + return caretVisible; + } + + public boolean getCaretBlinks() { + return caretBlinks; + } + + public boolean getBlockCaret() { + return blockCaret; + } + + public int getElectricScroll() { + return electricScroll; + } + + public int getCols() { + return cols; + } + + public int getRows() { + return rows; + } + + public SyntaxStyle[] getStyles() { + return styles; + } + + public Color getCaretColor() { + return caretColor; + } + + public Color getSelectionColor() { + return selectionColor; + } + + public Color getLineHighlightColor() { + return lineHighlightColor; + } + + public boolean getLineHighlight() { + return lineHighlight; + } + + public Color getBracketHighlightColor() { + return bracketHighlightColor; + } + + public boolean getBracketHighlight() { + return bracketHighlight; + } + + public Color getEolMarkerColor() { + return eolMarkerColor; + } + + public boolean getEolMarkers() { + return eolMarkers; + } + + public boolean getPaintInvalid() { + return paintInvalid; + } + + public JPopupMenu getPopup() { + return popup; + } + } // class TextAreaDefaults Modified: trunk/daimonin/src/daieditor/textedit/textarea/TextAreaPainter.java =================================================================== --- trunk/daimonin/src/daieditor/textedit/textarea/TextAreaPainter.java 2006-05-29 19:06:56 UTC (rev 71) +++ trunk/daimonin/src/daieditor/textedit/textarea/TextAreaPainter.java 2006-05-29 19:51:19 UTC (rev 72) @@ -42,11 +42,11 @@ private static final long serialVersionUID = 1L; // package-private members - int currentLineIndex; + private int currentLineIndex; - Token currentLineTokens; + private Token currentLineTokens; - final Segment currentLine; + private final Segment currentLine; // protected members protected final JEditTextArea textArea; @@ -113,19 +113,19 @@ setForeground(Color.black); setBackground(Color.white); - blockCaret = defaults.blockCaret; - styles = defaults.styles; - cols = defaults.cols; - rows = defaults.rows; - caretColor = defaults.caretColor; - selectionColor = defaults.selectionColor; - lineHighlightColor = defaults.lineHighlightColor; - lineHighlight = defaults.lineHighlight; - bracketHighlightColor = defaults.bracketHighlightColor; - bracketHighlight = defaults.bracketHighlight; - paintInvalid = defaults.paintInvalid; - eolMarkerColor = defaults.eolMarkerColor; - eolMarkers = defaults.eolMarkers; + blockCaret = defaults.getBlockCaret(); + styles = defaults.getStyles(); + cols = defaults.getCols(); + rows = defaults.getRows(); + caretColor = defaults.getCaretColor(); + selectionColor = defaults.getSelectionColor(); + lineHighlightColor = defaults.getLineHighlightColor(); + lineHighlight = defaults.getLineHighlight(); + bracketHighlightColor = defaults.getBracketHighlightColor(); + bracketHighlight = defaults.getBracketHighlight(); + paintInvalid = defaults.getPaintInvalid(); + eolMarkerColor = defaults.getEolMarkerColor(); + eolMarkers = defaults.getEolMarkers(); needMetricsUpdate = true; // need to update font metrics before drawing needLineUpdate = true; } @@ -526,7 +526,7 @@ * This is the first method which gets directly called from paint(). All * lines which are sceduled for redraw get drawn with this method. */ - final void paintLine(final Graphics gfx, final TokenMarker tokenMarker, final int line, final int x) { + protected final void paintLine(final Graphics gfx, final TokenMarker tokenMarker, final int line, final int x) { final Font defaultFont = getFont(); final Color defaultColor = getForeground(); @@ -546,7 +546,7 @@ } } - final void paintPlainLine(final Graphics gfx, final int line, final Font defaultFont, final Color defaultColor, int x, int y) { + protected final void paintPlainLine(final Graphics gfx, final int line, final Font defaultFont, final Color defaultColor, int x, int y) { paintHighlight(gfx, line, y); textArea.getLineText(line, currentLine); @@ -566,7 +566,7 @@ * When syntax highlighting is enabled, this method is called from * paintLine() to do the actual drawing of the line. */ - final void paintSyntaxLine(final Graphics gfx, final TokenMarker tokenMarker, final int line, final Font defaultFont, final Color defaultColor, int x, int y) { + protected final void paintSyntaxLine(final Graphics gfx, final TokenMarker tokenMarker, final int line, final Font defaultFont, final Color defaultColor, int x, int y) { textArea.getLineText(currentLineIndex, currentLine); currentLineTokens = tokenMarker.markTokens(currentLine, currentLineIndex); @@ -586,7 +586,7 @@ } } - final void paintHighlight(final Graphics gfx, final int line, final int y) { + protected final void paintHighlight(final Graphics gfx, final int line, final int y) { if (line >= textArea.getSelectionStartLine() && line <= textArea.getSelectionEndLine()) { paintLineHighlight(gfx, line, y); } @@ -604,7 +604,7 @@ } } - final void paintLineHighlight(final Graphics gfx, final int line, int y) { + protected final void paintLineHighlight(final Graphics gfx, final int line, int y) { final int height = fm.getHeight(); y += fm.getLeading() + fm.getMaxDescent(); @@ -654,7 +654,7 @@ } - final void paintBracketHighlight(final Graphics gfx, final int line, int y) { + protected final void paintBracketHighlight(final Graphics gfx, final int line, int y) { final int position = textArea.getBracketPosition(); if (position == -1) { return; @@ -669,7 +669,7 @@ gfx.drawRect(x, y, fm.charWidth('(') - 1, fm.getHeight() - 1); } - final void paintCaret(final Graphics gfx, final int line, int y) { + protected final void paintCaret(final Graphics gfx, final int line, int y) { if (textArea.isCaretVisible()) { final int offset = textArea.getCaretPosition() - textArea.getLineStartOffset(line); final int caretX = textArea._offsetToX(line, offset); @@ -693,4 +693,21 @@ } } } + + public int getCurrentLineIndex() { + return currentLineIndex; + } + + public void setCurrentLineIndex(int lineIndex) { + currentLineIndex = lineIndex; + } + + public Token getCurrentLineTokens() { + return currentLineTokens; + } + + public void setCurrentLineTokens(Token token) { + currentLineTokens = token; + } + } // class TextAreaPainter Modified: trunk/daimonin/src/daieditor/textedit/textarea/Token.java =================================================================== --- trunk/daimonin/src/daieditor/textedit/textarea/Token.java 2006-05-29 19:06:56 UTC (rev 71) +++ trunk/daimonin/src/daieditor/textedit/textarea/Token.java 2006-05-29 19:51:19 UTC (rev 72) @@ -100,13 +100,13 @@ public static final byte END = 127; /** The length of this token. */ - public int length; + private int length; /** The id of this token. */ - public byte id; + private byte id; /** The next token in the linked list. */ - public Token next; + private Token next; /** * Creates a new token. @@ -123,4 +123,28 @@ return "[id=" + id + ",length=" + length + "]"; } + public byte getId() { + return id; + } + + public void setId(byte id_) { + id = id_; + } + + public int getLength() { + return length; + } + + public void setLength(int length_) { + length = length_; + } + + public Token getNext() { + return next; + } + + public void setNext(Token next_) { + next = next_; + } + } // class Token Modified: trunk/daimonin/src/daieditor/textedit/textarea/TokenMarker.java =================================================================== --- trunk/daimonin/src/daieditor/textedit/textarea/TokenMarker.java 2006-05-29 19:06:56 UTC (rev 71) +++ trunk/daimonin/src/daieditor/textedit/textarea/TokenMarker.java 2006-05-29 19:51:19 UTC (rev 72) @@ -258,15 +258,15 @@ lastToken = firstToken; } else if (lastToken == null) { lastToken = firstToken; - firstToken.length = length; - firstToken.id = id; - } else if (lastToken.next == null) { - lastToken.next = new Token(length, id); - lastToken = lastToken.next; + firstToken.setLength(length); + firstToken.setId(id); + } else if (lastToken.getNext() == null) { + lastToken.setNext(new Token(length, id)); + lastToken = lastToken.getNext(); } else { - lastToken = lastToken.next; - lastToken.length = length; - lastToken.id = id; + lastToken = lastToken.getNext(); + lastToken.setLength(length); + lastToken.setId(id); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2006-05-31 20:51:47
|
Revision: 97 Author: akirschbaum Date: 2006-05-31 13:51:28 -0700 (Wed, 31 May 2006) ViewCVS: http://svn.sourceforge.net/gridarta/?rev=97&view=rev Log Message: ----------- Unify modifiers. Modified Paths: -------------- trunk/crossfire/src/cfeditor/textedit/scripteditor/ScriptEditView.java trunk/daimonin/src/daieditor/textedit/textarea/KeywordMap.java Modified: trunk/crossfire/src/cfeditor/textedit/scripteditor/ScriptEditView.java =================================================================== --- trunk/crossfire/src/cfeditor/textedit/scripteditor/ScriptEditView.java 2006-05-31 20:44:06 UTC (rev 96) +++ trunk/crossfire/src/cfeditor/textedit/scripteditor/ScriptEditView.java 2006-05-31 20:51:28 UTC (rev 97) @@ -263,7 +263,7 @@ * @param message the message to be shown * @return true if the user agrees, false if user disagrees */ - public boolean askConfirm(String title, String message) { + public final boolean askConfirm(String title, String message) { return JOptionPane.showConfirmDialog(this, message, title, JOptionPane.YES_NO_OPTION, JOptionPane.INFORMATION_MESSAGE) == JOptionPane.YES_OPTION; } Modified: trunk/daimonin/src/daieditor/textedit/textarea/KeywordMap.java =================================================================== --- trunk/daimonin/src/daieditor/textedit/textarea/KeywordMap.java 2006-05-31 20:44:06 UTC (rev 96) +++ trunk/daimonin/src/daieditor/textedit/textarea/KeywordMap.java 2006-05-31 20:51:28 UTC (rev 97) @@ -99,11 +99,11 @@ // protected members private final int mapLength; - public final int getStringMapKey(final String s) { + protected final int getStringMapKey(final String s) { return (Character.toUpperCase(s.charAt(0)) + Character.toUpperCase(s.charAt(s.length() - 1))) % mapLength; } - public final int getSegmentMapKey(final Segment s, final int off, final int len) { + protected final int getSegmentMapKey(final Segment s, final int off, final int len) { return (Character.toUpperCase(s.array[off]) + Character.toUpperCase(s.array[off + len - 1])) % mapLength; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2006-07-31 18:30:16
|
Revision: 238 Author: christianhujer Date: 2006-07-31 11:29:27 -0700 (Mon, 31 Jul 2006) ViewCVS: http://svn.sourceforge.net/gridarta/?rev=238&view=rev Log Message: ----------- Removed version information from textedit files for easier diff. Also, in SVN they are unused. Modified Paths: -------------- trunk/crossfire/src/cfeditor/textedit/textarea/CTokenMarker.java trunk/crossfire/src/cfeditor/textedit/textarea/DefaultInputHandler.java trunk/crossfire/src/cfeditor/textedit/textarea/HTMLTokenMarker.java trunk/crossfire/src/cfeditor/textedit/textarea/InputHandler.java trunk/crossfire/src/cfeditor/textedit/textarea/JEditTextArea.java trunk/crossfire/src/cfeditor/textedit/textarea/JavaScriptTokenMarker.java trunk/crossfire/src/cfeditor/textedit/textarea/KeywordMap.java trunk/crossfire/src/cfeditor/textedit/textarea/PythonTokenMarker.java trunk/crossfire/src/cfeditor/textedit/textarea/SyntaxDocument.java trunk/crossfire/src/cfeditor/textedit/textarea/SyntaxStyle.java trunk/crossfire/src/cfeditor/textedit/textarea/SyntaxUtilities.java trunk/crossfire/src/cfeditor/textedit/textarea/TextAreaPainter.java trunk/crossfire/src/cfeditor/textedit/textarea/TextUtilities.java trunk/crossfire/src/cfeditor/textedit/textarea/Token.java trunk/crossfire/src/cfeditor/textedit/textarea/TokenMarker.java trunk/crossfire/src/cfeditor/textedit/textarea/XMLTokenMarker.java trunk/daimonin/src/daieditor/textedit/textarea/CTokenMarker.java trunk/daimonin/src/daieditor/textedit/textarea/DefaultInputHandler.java trunk/daimonin/src/daieditor/textedit/textarea/HTMLTokenMarker.java trunk/daimonin/src/daieditor/textedit/textarea/InputHandler.java trunk/daimonin/src/daieditor/textedit/textarea/JEditTextArea.java trunk/daimonin/src/daieditor/textedit/textarea/JavaScriptTokenMarker.java trunk/daimonin/src/daieditor/textedit/textarea/KeywordMap.java trunk/daimonin/src/daieditor/textedit/textarea/SyntaxDocument.java trunk/daimonin/src/daieditor/textedit/textarea/SyntaxStyle.java trunk/daimonin/src/daieditor/textedit/textarea/SyntaxUtilities.java trunk/daimonin/src/daieditor/textedit/textarea/TextAreaPainter.java trunk/daimonin/src/daieditor/textedit/textarea/TextUtilities.java trunk/daimonin/src/daieditor/textedit/textarea/Token.java trunk/daimonin/src/daieditor/textedit/textarea/TokenMarker.java trunk/daimonin/src/daieditor/textedit/textarea/XMLTokenMarker.java Modified: trunk/crossfire/src/cfeditor/textedit/textarea/CTokenMarker.java =================================================================== --- trunk/crossfire/src/cfeditor/textedit/textarea/CTokenMarker.java 2006-07-30 17:56:25 UTC (rev 237) +++ trunk/crossfire/src/cfeditor/textedit/textarea/CTokenMarker.java 2006-07-31 18:29:27 UTC (rev 238) @@ -14,7 +14,6 @@ /** * C token marker. * @author Slava Pestov - * @version $Id: CTokenMarker.java,v 1.5 2006/03/26 00:48:57 akirschbaum Exp $ */ public class CTokenMarker extends TokenMarker { Modified: trunk/crossfire/src/cfeditor/textedit/textarea/DefaultInputHandler.java =================================================================== --- trunk/crossfire/src/cfeditor/textedit/textarea/DefaultInputHandler.java 2006-07-30 17:56:25 UTC (rev 237) +++ trunk/crossfire/src/cfeditor/textedit/textarea/DefaultInputHandler.java 2006-07-31 18:29:27 UTC (rev 238) @@ -25,7 +25,6 @@ * and inserts key typed events into the text area. * @author Slava Pestov * @author <a href="mailto:and...@gm...">Andreas Vogl</a> - * @version $Id: DefaultInputHandler.java,v 1.7 2006/03/26 00:48:57 akirschbaum Exp $ */ public final class DefaultInputHandler extends InputHandler { Modified: trunk/crossfire/src/cfeditor/textedit/textarea/HTMLTokenMarker.java =================================================================== --- trunk/crossfire/src/cfeditor/textedit/textarea/HTMLTokenMarker.java 2006-07-30 17:56:25 UTC (rev 237) +++ trunk/crossfire/src/cfeditor/textedit/textarea/HTMLTokenMarker.java 2006-07-31 18:29:27 UTC (rev 238) @@ -14,7 +14,6 @@ /** * HTML token marker. * @author Slava Pestov - * @version $Id: HTMLTokenMarker.java,v 1.4 2006/03/01 21:13:44 akirschbaum Exp $ */ public class HTMLTokenMarker extends TokenMarker { Modified: trunk/crossfire/src/cfeditor/textedit/textarea/InputHandler.java =================================================================== --- trunk/crossfire/src/cfeditor/textedit/textarea/InputHandler.java 2006-07-30 17:56:25 UTC (rev 237) +++ trunk/crossfire/src/cfeditor/textedit/textarea/InputHandler.java 2006-07-31 18:29:27 UTC (rev 238) @@ -41,7 +41,6 @@ * to the implementations of this class to do so. * @author Slava Pestov * @author <a href="mailto:and...@gm...">Andreas Vogl</a> - * @version $Id: InputHandler.java,v 1.10 2006/03/26 00:48:57 akirschbaum Exp $ * @see DefaultInputHandler */ public abstract class InputHandler extends KeyAdapter { Modified: trunk/crossfire/src/cfeditor/textedit/textarea/JEditTextArea.java =================================================================== --- trunk/crossfire/src/cfeditor/textedit/textarea/JEditTextArea.java 2006-07-30 17:56:25 UTC (rev 237) +++ trunk/crossfire/src/cfeditor/textedit/textarea/JEditTextArea.java 2006-07-31 18:29:27 UTC (rev 238) @@ -89,7 +89,6 @@ * + "}");</pre> * @author Slava Pestov * @author <a href="mailto:and...@gm...">Andreas Vogl</a> - * @version $Id: JEditTextArea.java,v 1.11 2006/03/26 00:48:57 akirschbaum Exp $ */ public final class JEditTextArea extends JComponent { Modified: trunk/crossfire/src/cfeditor/textedit/textarea/JavaScriptTokenMarker.java =================================================================== --- trunk/crossfire/src/cfeditor/textedit/textarea/JavaScriptTokenMarker.java 2006-07-30 17:56:25 UTC (rev 237) +++ trunk/crossfire/src/cfeditor/textedit/textarea/JavaScriptTokenMarker.java 2006-07-31 18:29:27 UTC (rev 238) @@ -12,7 +12,6 @@ /** * JavaScript token marker. * @author Slava Pestov - * @version $Id: JavaScriptTokenMarker.java,v 1.5 2006/03/01 21:13:44 akirschbaum Exp $ */ public final class JavaScriptTokenMarker extends CTokenMarker { Modified: trunk/crossfire/src/cfeditor/textedit/textarea/KeywordMap.java =================================================================== --- trunk/crossfire/src/cfeditor/textedit/textarea/KeywordMap.java 2006-07-30 17:56:25 UTC (rev 237) +++ trunk/crossfire/src/cfeditor/textedit/textarea/KeywordMap.java 2006-07-31 18:29:27 UTC (rev 238) @@ -19,7 +19,6 @@ * <p/> * This class is used by <code>CTokenMarker</code> to map keywords to ids. * @author Slava Pestov, Mike Dillon - * @version $Id: KeywordMap.java,v 1.6 2006/03/26 00:48:57 akirschbaum Exp $ */ public final class KeywordMap { Modified: trunk/crossfire/src/cfeditor/textedit/textarea/PythonTokenMarker.java =================================================================== --- trunk/crossfire/src/cfeditor/textedit/textarea/PythonTokenMarker.java 2006-07-30 17:56:25 UTC (rev 237) +++ trunk/crossfire/src/cfeditor/textedit/textarea/PythonTokenMarker.java 2006-07-31 18:29:27 UTC (rev 238) @@ -15,7 +15,6 @@ /** * Python token marker. * @author Jonathan Revusky - * @version $Id: PythonTokenMarker.java,v 1.5 2006/03/26 00:48:57 akirschbaum Exp $ */ public class PythonTokenMarker extends TokenMarker { Modified: trunk/crossfire/src/cfeditor/textedit/textarea/SyntaxDocument.java =================================================================== --- trunk/crossfire/src/cfeditor/textedit/textarea/SyntaxDocument.java 2006-07-30 17:56:25 UTC (rev 237) +++ trunk/crossfire/src/cfeditor/textedit/textarea/SyntaxDocument.java 2006-07-31 18:29:27 UTC (rev 238) @@ -20,7 +20,6 @@ * A document implementation that can be tokenized by the syntax highlighting * system. * @author Slava Pestov - * @version $Id: SyntaxDocument.java,v 1.6 2006/03/25 23:19:57 akirschbaum Exp $ */ public final class SyntaxDocument extends PlainDocument { Modified: trunk/crossfire/src/cfeditor/textedit/textarea/SyntaxStyle.java =================================================================== --- trunk/crossfire/src/cfeditor/textedit/textarea/SyntaxStyle.java 2006-07-30 17:56:25 UTC (rev 237) +++ trunk/crossfire/src/cfeditor/textedit/textarea/SyntaxStyle.java 2006-07-31 18:29:27 UTC (rev 238) @@ -18,7 +18,6 @@ * A simple text style class. It can specify the color, italic flag, * and bold flag of a run of text. * @author Slava Pestov - * @version $Id: SyntaxStyle.java,v 1.7 2006/03/26 00:48:57 akirschbaum Exp $ */ public final class SyntaxStyle { Modified: trunk/crossfire/src/cfeditor/textedit/textarea/SyntaxUtilities.java =================================================================== --- trunk/crossfire/src/cfeditor/textedit/textarea/SyntaxUtilities.java 2006-07-30 17:56:25 UTC (rev 237) +++ trunk/crossfire/src/cfeditor/textedit/textarea/SyntaxUtilities.java 2006-07-31 18:29:27 UTC (rev 238) @@ -20,7 +20,6 @@ * Class with several utility functions used by jEdit's syntax colorizing * subsystem. * @author Slava Pestov - * @version $Id: SyntaxUtilities.java,v 1.6 2006/03/25 22:04:22 akirschbaum Exp $ */ public final class SyntaxUtilities { Modified: trunk/crossfire/src/cfeditor/textedit/textarea/TextAreaPainter.java =================================================================== --- trunk/crossfire/src/cfeditor/textedit/textarea/TextAreaPainter.java 2006-07-30 17:56:25 UTC (rev 237) +++ trunk/crossfire/src/cfeditor/textedit/textarea/TextAreaPainter.java 2006-07-31 18:29:27 UTC (rev 238) @@ -33,7 +33,6 @@ * of text. * @author Slava Pestov * @author <a href="mailto:and...@gm...">Andreas Vogl</a> - * @version $Id: TextAreaPainter.java,v 1.11 2006/03/26 00:48:57 akirschbaum Exp $ */ public final class TextAreaPainter extends JComponent implements TabExpander { Modified: trunk/crossfire/src/cfeditor/textedit/textarea/TextUtilities.java =================================================================== --- trunk/crossfire/src/cfeditor/textedit/textarea/TextUtilities.java 2006-07-30 17:56:25 UTC (rev 237) +++ trunk/crossfire/src/cfeditor/textedit/textarea/TextUtilities.java 2006-07-31 18:29:27 UTC (rev 238) @@ -15,7 +15,6 @@ /** * Class with several utility functions used by the text area component. * @author Slava Pestov - * @version $Id: TextUtilities.java,v 1.6 2006/04/06 18:31:36 akirschbaum Exp $ */ public final class TextUtilities { Modified: trunk/crossfire/src/cfeditor/textedit/textarea/Token.java =================================================================== --- trunk/crossfire/src/cfeditor/textedit/textarea/Token.java 2006-07-30 17:56:25 UTC (rev 237) +++ trunk/crossfire/src/cfeditor/textedit/textarea/Token.java 2006-07-31 18:29:27 UTC (rev 238) @@ -16,7 +16,6 @@ * which is the length of the token in the text, and a pointer to the next * token in the list. * @author Slava Pestov - * @version $Id: Token.java,v 1.5 2006/03/25 22:04:22 akirschbaum Exp $ */ public final class Token { Modified: trunk/crossfire/src/cfeditor/textedit/textarea/TokenMarker.java =================================================================== --- trunk/crossfire/src/cfeditor/textedit/textarea/TokenMarker.java 2006-07-30 17:56:25 UTC (rev 237) +++ trunk/crossfire/src/cfeditor/textedit/textarea/TokenMarker.java 2006-07-31 18:29:27 UTC (rev 238) @@ -20,7 +20,6 @@ * is tokenized. Therefore, the return value of <code>markTokens</code> should * only be used for immediate painting. Notably, it cannot be cached. * @author Slava Pestov - * @version $Id: TokenMarker.java,v 1.7 2006/03/25 22:04:22 akirschbaum Exp $ * @see Token */ public abstract class TokenMarker { Modified: trunk/crossfire/src/cfeditor/textedit/textarea/XMLTokenMarker.java =================================================================== --- trunk/crossfire/src/cfeditor/textedit/textarea/XMLTokenMarker.java 2006-07-30 17:56:25 UTC (rev 237) +++ trunk/crossfire/src/cfeditor/textedit/textarea/XMLTokenMarker.java 2006-07-31 18:29:27 UTC (rev 238) @@ -12,7 +12,6 @@ /** * XML token marker. * @author Slava Pestov - * @version $Id: XMLTokenMarker.java,v 1.4 2006/03/01 21:13:44 akirschbaum Exp $ */ public final class XMLTokenMarker extends HTMLTokenMarker { Modified: trunk/daimonin/src/daieditor/textedit/textarea/CTokenMarker.java =================================================================== --- trunk/daimonin/src/daieditor/textedit/textarea/CTokenMarker.java 2006-07-30 17:56:25 UTC (rev 237) +++ trunk/daimonin/src/daieditor/textedit/textarea/CTokenMarker.java 2006-07-31 18:29:27 UTC (rev 238) @@ -14,7 +14,6 @@ /** * C token marker. * @author Slava Pestov - * @version $Id: CTokenMarker.java,v 1.7 2006/02/26 15:44:39 christianhujer Exp $ */ public class CTokenMarker extends TokenMarker { Modified: trunk/daimonin/src/daieditor/textedit/textarea/DefaultInputHandler.java =================================================================== --- trunk/daimonin/src/daieditor/textedit/textarea/DefaultInputHandler.java 2006-07-30 17:56:25 UTC (rev 237) +++ trunk/daimonin/src/daieditor/textedit/textarea/DefaultInputHandler.java 2006-07-31 18:29:27 UTC (rev 238) @@ -25,7 +25,6 @@ * and inserts key typed events into the text area. * @author Slava Pestov * @author <a href="mailto:and...@gm...">Andreas Vogl</a> - * @version $Id: DefaultInputHandler.java,v 1.12 2006/04/20 15:07:04 derdanny Exp $ */ public final class DefaultInputHandler extends InputHandler { Modified: trunk/daimonin/src/daieditor/textedit/textarea/HTMLTokenMarker.java =================================================================== --- trunk/daimonin/src/daieditor/textedit/textarea/HTMLTokenMarker.java 2006-07-30 17:56:25 UTC (rev 237) +++ trunk/daimonin/src/daieditor/textedit/textarea/HTMLTokenMarker.java 2006-07-31 18:29:27 UTC (rev 238) @@ -14,7 +14,6 @@ /** * HTML token marker. * @author Slava Pestov - * @version $Id: HTMLTokenMarker.java,v 1.5 2005/08/09 13:41:54 christianhujer Exp $ */ public class HTMLTokenMarker extends TokenMarker { Modified: trunk/daimonin/src/daieditor/textedit/textarea/InputHandler.java =================================================================== --- trunk/daimonin/src/daieditor/textedit/textarea/InputHandler.java 2006-07-30 17:56:25 UTC (rev 237) +++ trunk/daimonin/src/daieditor/textedit/textarea/InputHandler.java 2006-07-31 18:29:27 UTC (rev 238) @@ -40,7 +40,6 @@ * to the implementations of this class to do so. * @author Slava Pestov * @author <a href="mailto:and...@gm...">Andreas Vogl</a> - * @version $Id: InputHandler.java,v 1.14 2006/04/20 15:07:04 derdanny Exp $ * @see DefaultInputHandler */ public abstract class InputHandler extends KeyAdapter { Modified: trunk/daimonin/src/daieditor/textedit/textarea/JEditTextArea.java =================================================================== --- trunk/daimonin/src/daieditor/textedit/textarea/JEditTextArea.java 2006-07-30 17:56:25 UTC (rev 237) +++ trunk/daimonin/src/daieditor/textedit/textarea/JEditTextArea.java 2006-07-31 18:29:27 UTC (rev 238) @@ -89,7 +89,6 @@ * + "}");</pre> * @author Slava Pestov * @author <a href="mailto:and...@gm...">Andreas Vogl</a> - * @version $Id: JEditTextArea.java,v 1.16 2006/04/20 15:07:04 derdanny Exp $ */ public final class JEditTextArea extends JComponent { Modified: trunk/daimonin/src/daieditor/textedit/textarea/JavaScriptTokenMarker.java =================================================================== --- trunk/daimonin/src/daieditor/textedit/textarea/JavaScriptTokenMarker.java 2006-07-30 17:56:25 UTC (rev 237) +++ trunk/daimonin/src/daieditor/textedit/textarea/JavaScriptTokenMarker.java 2006-07-31 18:29:27 UTC (rev 238) @@ -12,7 +12,6 @@ /** * JavaScript token marker. * @author Slava Pestov - * @version $Id: JavaScriptTokenMarker.java,v 1.6 2005/05/20 20:13:45 christianhujer Exp $ */ public final class JavaScriptTokenMarker extends CTokenMarker { Modified: trunk/daimonin/src/daieditor/textedit/textarea/KeywordMap.java =================================================================== --- trunk/daimonin/src/daieditor/textedit/textarea/KeywordMap.java 2006-07-30 17:56:25 UTC (rev 237) +++ trunk/daimonin/src/daieditor/textedit/textarea/KeywordMap.java 2006-07-31 18:29:27 UTC (rev 238) @@ -19,7 +19,6 @@ * <p/> * This class is used by <code>CTokenMarker</code> to map keywords to ids. * @author Slava Pestov, Mike Dillon - * @version $Id: KeywordMap.java,v 1.7 2005/08/09 13:41:55 christianhujer Exp $ */ public final class KeywordMap { Modified: trunk/daimonin/src/daieditor/textedit/textarea/SyntaxDocument.java =================================================================== --- trunk/daimonin/src/daieditor/textedit/textarea/SyntaxDocument.java 2006-07-30 17:56:25 UTC (rev 237) +++ trunk/daimonin/src/daieditor/textedit/textarea/SyntaxDocument.java 2006-07-31 18:29:27 UTC (rev 238) @@ -20,7 +20,6 @@ * A document implementation that can be tokenized by the syntax highlighting * system. * @author Slava Pestov - * @version $Id: SyntaxDocument.java,v 1.10 2005/11/05 23:31:39 christianhujer Exp $ */ public final class SyntaxDocument extends PlainDocument { Modified: trunk/daimonin/src/daieditor/textedit/textarea/SyntaxStyle.java =================================================================== --- trunk/daimonin/src/daieditor/textedit/textarea/SyntaxStyle.java 2006-07-30 17:56:25 UTC (rev 237) +++ trunk/daimonin/src/daieditor/textedit/textarea/SyntaxStyle.java 2006-07-31 18:29:27 UTC (rev 238) @@ -18,7 +18,6 @@ * A simple text style class. It can specify the color, italic flag, * and bold flag of a run of text. * @author Slava Pestov - * @version $Id: SyntaxStyle.java,v 1.9 2006/04/14 14:08:45 derdanny Exp $ */ public final class SyntaxStyle { Modified: trunk/daimonin/src/daieditor/textedit/textarea/SyntaxUtilities.java =================================================================== --- trunk/daimonin/src/daieditor/textedit/textarea/SyntaxUtilities.java 2006-07-30 17:56:25 UTC (rev 237) +++ trunk/daimonin/src/daieditor/textedit/textarea/SyntaxUtilities.java 2006-07-31 18:29:27 UTC (rev 238) @@ -20,7 +20,6 @@ * Class with several utility functions used by jEdit's syntax colorizing * subsystem. * @author Slava Pestov - * @version $Id: SyntaxUtilities.java,v 1.7 2006/04/14 14:08:45 derdanny Exp $ */ public final class SyntaxUtilities { Modified: trunk/daimonin/src/daieditor/textedit/textarea/TextAreaPainter.java =================================================================== --- trunk/daimonin/src/daieditor/textedit/textarea/TextAreaPainter.java 2006-07-30 17:56:25 UTC (rev 237) +++ trunk/daimonin/src/daieditor/textedit/textarea/TextAreaPainter.java 2006-07-31 18:29:27 UTC (rev 238) @@ -33,7 +33,6 @@ * of text. * @author Slava Pestov * @author <a href="mailto:and...@gm...">Andreas Vogl</a> - * @version $Id: TextAreaPainter.java,v 1.15 2006/04/20 15:07:04 derdanny Exp $ */ public final class TextAreaPainter extends JComponent implements TabExpander { Modified: trunk/daimonin/src/daieditor/textedit/textarea/TextUtilities.java =================================================================== --- trunk/daimonin/src/daieditor/textedit/textarea/TextUtilities.java 2006-07-30 17:56:25 UTC (rev 237) +++ trunk/daimonin/src/daieditor/textedit/textarea/TextUtilities.java 2006-07-31 18:29:27 UTC (rev 238) @@ -15,7 +15,6 @@ /** * Class with several utility functions used by the text area component. * @author Slava Pestov - * @version $Id: TextUtilities.java,v 1.7 2006/04/20 15:07:04 derdanny Exp $ */ public final class TextUtilities { Modified: trunk/daimonin/src/daieditor/textedit/textarea/Token.java =================================================================== --- trunk/daimonin/src/daieditor/textedit/textarea/Token.java 2006-07-30 17:56:25 UTC (rev 237) +++ trunk/daimonin/src/daieditor/textedit/textarea/Token.java 2006-07-31 18:29:27 UTC (rev 238) @@ -16,7 +16,6 @@ * which is the length of the token in the text, and a pointer to the next * token in the list. * @author Slava Pestov - * @version $Id: Token.java,v 1.7 2005/08/09 13:41:55 christianhujer Exp $ */ public final class Token { Modified: trunk/daimonin/src/daieditor/textedit/textarea/TokenMarker.java =================================================================== --- trunk/daimonin/src/daieditor/textedit/textarea/TokenMarker.java 2006-07-30 17:56:25 UTC (rev 237) +++ trunk/daimonin/src/daieditor/textedit/textarea/TokenMarker.java 2006-07-31 18:29:27 UTC (rev 238) @@ -20,7 +20,6 @@ * is tokenized. Therefore, the return value of <code>markTokens</code> should * only be used for immediate painting. Notably, it cannot be cached. * @author Slava Pestov - * @version $Id: TokenMarker.java,v 1.8 2005/08/09 13:41:55 christianhujer Exp $ * @see Token */ public abstract class TokenMarker { Modified: trunk/daimonin/src/daieditor/textedit/textarea/XMLTokenMarker.java =================================================================== --- trunk/daimonin/src/daieditor/textedit/textarea/XMLTokenMarker.java 2006-07-30 17:56:25 UTC (rev 237) +++ trunk/daimonin/src/daieditor/textedit/textarea/XMLTokenMarker.java 2006-07-31 18:29:27 UTC (rev 238) @@ -12,7 +12,6 @@ /** * XML token marker. * @author Slava Pestov - * @version $Id: XMLTokenMarker.java,v 1.5 2005/08/09 13:41:55 christianhujer Exp $ */ public final class XMLTokenMarker extends HTMLTokenMarker { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2006-07-31 20:07:33
|
Revision: 240 Author: christianhujer Date: 2006-07-31 13:07:17 -0700 (Mon, 31 Jul 2006) ViewCVS: http://svn.sourceforge.net/gridarta/?rev=240&view=rev Log Message: ----------- Fixed some code style violations. Modified Paths: -------------- trunk/crossfire/src/cfeditor/textedit/textarea/InputHandler.java trunk/daimonin/src/daieditor/textedit/textarea/InputHandler.java Modified: trunk/crossfire/src/cfeditor/textedit/textarea/InputHandler.java =================================================================== --- trunk/crossfire/src/cfeditor/textedit/textarea/InputHandler.java 2006-07-31 18:41:56 UTC (rev 239) +++ trunk/crossfire/src/cfeditor/textedit/textarea/InputHandler.java 2006-07-31 20:07:17 UTC (rev 240) @@ -186,17 +186,19 @@ /** * Returns a named text area action. * @param name the action name + * @return action stored for <var>name</var> or <code>null</code> if no such action was found */ - public static ActionListener getAction(final String name) { + @Nullable public static ActionListener getAction(final String name) { return actions.get(name); } /** * Returns the name of the specified text area action. * @param listener the action name + * @return name for the supplied <var>listener</var> or <code>null</code> if no name was found */ @Nullable public static String getActionName(final ActionListener listener) { - for (String name : actions.keySet()) { + for (final String name : actions.keySet()) { if (actions.get(name) == listener) { return name; } @@ -204,10 +206,6 @@ return null; } - public static CFPythonPopup getPopup() { - return cfPythonPopup; - } - /** * Adds the default key bindings to this input handler. This should not be * called in the constructor of this input handler, because applications @@ -242,18 +240,20 @@ } /** - * Returns if repeating is enabled. When repeating is enabled, actions will - * be executed multiple times. This is usually invoked with a special key - * stroke in the input handler. + * Returns if repetition is enabled. + * When repetition is enabled, actions will be executed multiple times. + * This is usually invoked with a special key stroke in the input handler. + * @return <code>true</code> if repeating is enabled, otherwise <code>false</code> */ public final boolean isRepeatEnabled() { return repeat; } /** - * Enables repeating. When repeating is enabled, actions will be executed - * multiple times. Once repeating is enabled, the input handler should read - * a number from the keyboard. + * Sets the enabled state of repetition. + * When repetition is enabled, actions will be executed multiple times. + * Once repeating is enabled, the input handler should read a number from the keyboard. + * @param repeat <code>true</code> for enabling repetition, <code>false</code> for disabling it */ public final void setRepeatEnabled(final boolean repeat) { this.repeat = repeat; @@ -261,6 +261,7 @@ /** * Returns the number of times the next action will be repeated. + * @return number of times the next action will be repeated (1 or the set repeat count) */ public final int getRepeatCount() { return repeat ? Math.max(1, repeatCount) : 1; @@ -275,10 +276,11 @@ } /** - * Returns the macro recorder. If this is non-null, all executed actions - * should be forwarded to the recorder. + * Returns the macro recorder. + * If this is non-null, all executed actions should be forwarded to the recorder. + * @return the macro recorder */ - public final InputHandler.MacroRecorder getMacroRecorder() { + @Nullable public final InputHandler.MacroRecorder getMacroRecorder() { return recorder; } @@ -287,13 +289,14 @@ * should be forwarded to the recorder. * @param recorder the macro recorder */ - public final void setMacroRecorder(final InputHandler.MacroRecorder recorder) { + public final void setMacroRecorder(@Nullable final InputHandler.MacroRecorder recorder) { this.recorder = recorder; } /** * Returns a copy of this input handler that shares the same key bindings. * Setting key bindings in the copy will also set them in the original. + * @return copy of this InputHandler */ public abstract InputHandler copy(); @@ -333,9 +336,11 @@ if (recorder != null) { if (!(listener instanceof InputHandler.NonRecordable)) { if (repeatCountBak != 1) { + //noinspection ConstantConditions recorder.actionPerformed(REPEAT, String.valueOf(repeatCountBak)); } + //noinspection ConstantConditions recorder.actionPerformed(listener, actionCommand); } } @@ -351,9 +356,11 @@ /** * Returns the text area that fired the specified event. + * This method will throw an {@link Error} if <var>evt</var> does not have a JEditTextArea in it's source component hierarchy. * @param evt the event + * @return the JEditTextArea found as the source of <var>evt</var> */ - @Nullable public static JEditTextArea getTextArea(final EventObject evt) { + @Nullable private static JEditTextArea getTextArea(final EventObject evt) { if (evt != null) { final Object o = evt.getSource(); if (o instanceof Component) { @@ -377,15 +384,17 @@ // this shouldn't happen log.fatal("BUG: getTextArea() returning null"); log.fatal("Report this to Slava Pestov <sp...@gj...>"); - return null; + assert false : "BUG: getTextArea() returning null"; + throw new Error("BUG: getTextArea() returning null"); } // protected members /** * If a key is being grabbed, this method should be called with the - * appropriate key event. It executes the grab action with the typed - * character as the parameter. + * appropriate key event. + * It executes the grab action with the typed character as the parameter. + * @param evt The KeyEvent the key should be grabbed of */ protected final void handleGrabAction(final KeyEvent evt) { // Clear it *before* it is executed so that executeAction() @@ -402,13 +411,13 @@ protected int repeatCount; - protected InputHandler.MacroRecorder recorder; + @Nullable protected InputHandler.MacroRecorder recorder; /** * If an action implements this interface, it should not be repeated. * Instead, it will handle the repetition itself. */ - public interface NonRepeatable { + public static interface NonRepeatable { } @@ -416,7 +425,7 @@ * If an action implements this interface, it should not be recorded * by the macro recorder. Instead, it will do its own recording. */ - public interface NonRecordable { + public static interface NonRecordable { } @@ -424,12 +433,12 @@ * For use by EditAction.Wrapper only. * @since jEdit 2.2final */ - public interface Wrapper { + public static interface Wrapper { } /** Macro recorder. */ - public interface MacroRecorder { + public static interface MacroRecorder { void actionPerformed(ActionListener listener, String actionCommand); @@ -437,8 +446,9 @@ public static final class backspace implements ActionListener { - public final void actionPerformed(final ActionEvent evt) { - final JEditTextArea textArea = getTextArea(evt); + /** {@inheritDoc} */ + public final void actionPerformed(final ActionEvent e) { + final JEditTextArea textArea = getTextArea(e); if (!textArea.isEditable()) { textArea.getToolkit().beep(); @@ -465,8 +475,9 @@ public static final class backspace_word implements ActionListener { - public final void actionPerformed(final ActionEvent evt) { - final JEditTextArea textArea = getTextArea(evt); + /** {@inheritDoc} */ + public final void actionPerformed(final ActionEvent e) { + final JEditTextArea textArea = getTextArea(e); final int start = textArea.getSelectionStart(); if (start != textArea.getSelectionEnd()) { textArea.setSelectedText(""); @@ -499,8 +510,9 @@ public static final class delete implements ActionListener { - public final void actionPerformed(final ActionEvent evt) { - final JEditTextArea textArea = getTextArea(evt); + /** {@inheritDoc} */ + public final void actionPerformed(final ActionEvent e) { + final JEditTextArea textArea = getTextArea(e); if (!textArea.isEditable()) { textArea.getToolkit().beep(); @@ -527,8 +539,9 @@ public static final class delete_word implements ActionListener { - public final void actionPerformed(final ActionEvent evt) { - final JEditTextArea textArea = getTextArea(evt); + /** {@inheritDoc} */ + public final void actionPerformed(final ActionEvent e) { + final JEditTextArea textArea = getTextArea(e); final int start = textArea.getSelectionStart(); if (start != textArea.getSelectionEnd()) { textArea.setSelectedText(""); @@ -567,8 +580,9 @@ this.select = select; } - public final void actionPerformed(final ActionEvent evt) { - final JEditTextArea textArea = getTextArea(evt); + /** {@inheritDoc} */ + public final void actionPerformed(final ActionEvent e) { + final JEditTextArea textArea = getTextArea(e); int caret = textArea.getCaretPosition(); @@ -612,8 +626,9 @@ this.select = select; } - public final void actionPerformed(final ActionEvent evt) { - final JEditTextArea textArea = getTextArea(evt); + /** {@inheritDoc} */ + public final void actionPerformed(final ActionEvent e) { + final JEditTextArea textArea = getTextArea(e); if (select) { textArea.select(textArea.getMarkPosition(), textArea.getDocumentLength()); } else { @@ -630,8 +645,9 @@ this.select = select; } - public final void actionPerformed(final ActionEvent evt) { - final JEditTextArea textArea = getTextArea(evt); + /** {@inheritDoc} */ + public final void actionPerformed(final ActionEvent e) { + final JEditTextArea textArea = getTextArea(e); int caret = textArea.getCaretPosition(); @@ -670,8 +686,9 @@ this.select = select; } - public final void actionPerformed(final ActionEvent evt) { - final JEditTextArea textArea = getTextArea(evt); + /** {@inheritDoc} */ + public final void actionPerformed(final ActionEvent e) { + final JEditTextArea textArea = getTextArea(e); if (select) { textArea.select(textArea.getMarkPosition(), 0); } else { @@ -682,8 +699,8 @@ public static final class insert_break implements ActionListener { - public final void actionPerformed(final ActionEvent evt) { - final JEditTextArea textArea = getTextArea(evt); + public final void actionPerformed(final ActionEvent e) { + final JEditTextArea textArea = getTextArea(e); if (!textArea.isEditable()) { textArea.getToolkit().beep(); @@ -696,8 +713,9 @@ public static final class insert_tab implements ActionListener { - public final void actionPerformed(final ActionEvent evt) { - final JEditTextArea textArea = getTextArea(evt); + /** {@inheritDoc} */ + public final void actionPerformed(final ActionEvent e) { + final JEditTextArea textArea = getTextArea(e); if (!textArea.isEditable()) { textArea.getToolkit().beep(); @@ -717,8 +735,9 @@ this.select = select; } - public final void actionPerformed(final ActionEvent evt) { - final JEditTextArea textArea = getTextArea(evt); + /** {@inheritDoc} */ + public final void actionPerformed(final ActionEvent e) { + final JEditTextArea textArea = getTextArea(e); final int caret = textArea.getCaretPosition(); if (caret == textArea.getDocumentLength()) { textArea.getToolkit().beep(); @@ -741,8 +760,9 @@ this.select = select; } - public final void actionPerformed(final ActionEvent evt) { - final JEditTextArea textArea = getTextArea(evt); + /** {@inheritDoc} */ + public final void actionPerformed(final ActionEvent e) { + final JEditTextArea textArea = getTextArea(e); int caret = textArea.getCaretPosition(); final int line = textArea.getCaretLine(); @@ -774,8 +794,9 @@ this.select = select; } - public final void actionPerformed(final ActionEvent evt) { - final JEditTextArea textArea = getTextArea(evt); + /** {@inheritDoc} */ + public final void actionPerformed(final ActionEvent e) { + final JEditTextArea textArea = getTextArea(e); final int lineCount = textArea.getLineCount(); int firstLine = textArea.getFirstLine(); final int visibleLines = textArea.getVisibleLines(); @@ -806,8 +827,9 @@ this.select = select; } - public final void actionPerformed(final ActionEvent evt) { - final JEditTextArea textArea = getTextArea(evt); + /** {@inheritDoc} */ + public final void actionPerformed(final ActionEvent e) { + final JEditTextArea textArea = getTextArea(e); int caret = textArea.getCaretPosition(); final int line = textArea.getCaretLine(); final int lineStart = textArea.getLineStartOffset(line); @@ -836,8 +858,9 @@ public static final class overwrite implements ActionListener { - public final void actionPerformed(final ActionEvent evt) { - final JEditTextArea textArea = getTextArea(evt); + /** {@inheritDoc} */ + public final void actionPerformed(final ActionEvent e) { + final JEditTextArea textArea = getTextArea(e); textArea.setOverwriteEnabled( !textArea.isOverwriteEnabled()); } @@ -851,8 +874,9 @@ this.select = select; } - public final void actionPerformed(final ActionEvent evt) { - final JEditTextArea textArea = getTextArea(evt); + /** {@inheritDoc} */ + public final void actionPerformed(final ActionEvent e) { + final JEditTextArea textArea = getTextArea(e); final int caret = textArea.getCaretPosition(); if (caret == 0) { textArea.getToolkit().beep(); @@ -875,8 +899,9 @@ this.select = select; } - public final void actionPerformed(final ActionEvent evt) { - final JEditTextArea textArea = getTextArea(evt); + /** {@inheritDoc} */ + public final void actionPerformed(final ActionEvent e) { + final JEditTextArea textArea = getTextArea(e); int caret = textArea.getCaretPosition(); final int line = textArea.getCaretLine(); @@ -908,8 +933,9 @@ this.select = select; } - public final void actionPerformed(final ActionEvent evt) { - final JEditTextArea textArea = getTextArea(evt); + /** {@inheritDoc} */ + public final void actionPerformed(final ActionEvent e) { + final JEditTextArea textArea = getTextArea(e); int firstLine = textArea.getFirstLine(); final int visibleLines = textArea.getVisibleLines(); final int line = textArea.getCaretLine(); @@ -937,8 +963,9 @@ this.select = select; } - public final void actionPerformed(final ActionEvent evt) { - final JEditTextArea textArea = getTextArea(evt); + /** {@inheritDoc} */ + public final void actionPerformed(final ActionEvent e) { + final JEditTextArea textArea = getTextArea(e); int caret = textArea.getCaretPosition(); final int line = textArea.getCaretLine(); final int lineStart = textArea.getLineStartOffset(line); @@ -967,10 +994,11 @@ public static final class repeat implements ActionListener, InputHandler.NonRecordable { - public final void actionPerformed(final ActionEvent evt) { - final JEditTextArea textArea = getTextArea(evt); + /** {@inheritDoc} */ + public final void actionPerformed(final ActionEvent e) { + final JEditTextArea textArea = getTextArea(e); textArea.getInputHandler().setRepeatEnabled(true); - final String actionCommand = evt.getActionCommand(); + final String actionCommand = e.getActionCommand(); if (actionCommand != null) { textArea.getInputHandler().setRepeatCount(Integer.parseInt(actionCommand)); } @@ -979,17 +1007,19 @@ public static final class toggle_rect implements ActionListener { - public final void actionPerformed(final ActionEvent evt) { - final JEditTextArea textArea = getTextArea(evt); + /** {@inheritDoc} */ + public final void actionPerformed(final ActionEvent e) { + final JEditTextArea textArea = getTextArea(e); textArea.setSelectionRectangular(!textArea.isSelectionRectangular()); } } public static final class insert_char implements ActionListener, InputHandler.NonRepeatable { - public final void actionPerformed(final ActionEvent evt) { - final JEditTextArea textArea = getTextArea(evt); - final String str = evt.getActionCommand(); + /** {@inheritDoc} */ + public final void actionPerformed(final ActionEvent e) { + final JEditTextArea textArea = getTextArea(e); + final String str = e.getActionCommand(); final int repeatCount = textArea.getInputHandler().getRepeatCount(); if (textArea.isEditable()) { @@ -1012,11 +1042,11 @@ /** * Copy current selection into the system clipboard. - * @param evt ActionEvent (was Control-C) + * {@inheritDoc} */ - public final void actionPerformed(final ActionEvent evt) { + public final void actionPerformed(final ActionEvent e) { // get the selected string - final String text = getTextArea(evt).getSelectedText(); + final String text = getTextArea(e).getSelectedText(); if (text != null) { final StringSelection selection = new StringSelection(text); // set above string to the system clipboard @@ -1032,19 +1062,19 @@ public static final class cut implements ActionListener { /** + * {@inheritDoc} * Copy current selection into the system clipboard, then delete the * selected text. - * @param evt ActionEvent (was Control-X) */ - public final void actionPerformed(final ActionEvent evt) { + public final void actionPerformed(final ActionEvent e) { // get the selected string - final String text = getTextArea(evt).getSelectedText(); + final String text = getTextArea(e).getSelectedText(); if (text != null) { final StringSelection selection = new StringSelection(text); // set above string to the system clipboard Toolkit.getDefaultToolkit().getSystemClipboard().setContents(selection, selection); // now delete the original text - getTextArea(evt).setSelectedText(""); + getTextArea(e).setSelectedText(""); } } } @@ -1056,11 +1086,11 @@ public static final class paste implements ActionListener { /** + * {@inheritDoc} * Get content of the system clipboard and insert it at caret position. - * @param evt ActionEvent (was Control-V) */ - public final void actionPerformed(final ActionEvent evt) { - final JEditTextArea textarea = getTextArea(evt); + public final void actionPerformed(final ActionEvent e) { + final JEditTextArea textarea = getTextArea(e); final StringBuffer buff = new StringBuffer(""); // set above string to the system clipboard @@ -1091,15 +1121,15 @@ // insert text at caret position textarea.getDocument().insertString(textarea.getCaretPosition(), buff.toString(), null); } - } catch (final ClassNotFoundException e) { + } catch (final ClassNotFoundException ex) { System.err.println("syntax.InputHandler: Paste action failed due to ClassNotFoundException"); - } catch (final UnsupportedFlavorException e) { + } catch (final UnsupportedFlavorException ex) { System.err.println("syntax.InputHandler: Paste action failed because clipboard data flavour is not supported."); - } catch (final IOException e) { + } catch (final IOException ex) { System.err.println("syntax.InputHandler: Paste action failed due to IOException"); - } catch (final BadLocationException e) { + } catch (final BadLocationException ex) { System.err.println("syntax.InputHandler: Paste action failed due to BadLocationException"); - } catch (final NullPointerException e) { + } catch (final NullPointerException ex) { // this happens when clipboard is empty, it's not an error } @@ -1113,10 +1143,10 @@ public static final class save implements ActionListener { /** + * {@inheritDoc} * Save the currently active tab - * @param evt ActionEvent (was Control-S) */ - public final void actionPerformed(final ActionEvent evt) { + public final void actionPerformed(final ActionEvent e) { ScriptEditControl.getInstance().saveActiveTab(); } } @@ -1129,11 +1159,11 @@ public static final class function_menu implements ActionListener { /** + * {@inheritDoc} * Get content of the system clipboard and insert it at caret position. - * @param evt ActionEvent (was Control-V) */ - public final void actionPerformed(final ActionEvent evt) { - final JEditTextArea textarea = getTextArea(evt); + public final void actionPerformed(final ActionEvent e) { + final JEditTextArea textarea = getTextArea(e); final int caretPos = textarea.getCaretPosition(); // caret position try { @@ -1157,8 +1187,10 @@ cfPythonPopup.getMenu().show(textarea, textarea._offsetToX(line, offset), 30 + textarea.lineToY(line)); } } - } catch (final BadLocationException e) { + } catch (final BadLocationException ble) { } } - } -} + + } // class function_menu + +} // class InputHandler Modified: trunk/daimonin/src/daieditor/textedit/textarea/InputHandler.java =================================================================== --- trunk/daimonin/src/daieditor/textedit/textarea/InputHandler.java 2006-07-31 18:41:56 UTC (rev 239) +++ trunk/daimonin/src/daieditor/textedit/textarea/InputHandler.java 2006-07-31 20:07:17 UTC (rev 240) @@ -186,17 +186,19 @@ /** * Returns a named text area action. * @param name the action name + * @return action stored for <var>name</var> or <code>null</code> if no such action was found */ - public static ActionListener getAction(final String name) { + @Nullable public static ActionListener getAction(final String name) { return actions.get(name); } /** * Returns the name of the specified text area action. * @param listener the action name + * @return name for the supplied <var>listener</var> or <code>null</code> if no name was found */ @Nullable public static String getActionName(final ActionListener listener) { - for (String name : actions.keySet()) { + for (final String name : actions.keySet()) { if (actions.get(name) == listener) { return name; } @@ -204,10 +206,6 @@ return null; } - public static CFPythonPopup getPopup() { - return cfPythonPopup; - } - /** * Adds the default key bindings to this input handler. This should not be * called in the constructor of this input handler, because applications @@ -242,18 +240,20 @@ } /** - * Returns if repeating is enabled. When repeating is enabled, actions will - * be executed multiple times. This is usually invoked with a special key - * stroke in the input handler. + * Returns if repetition is enabled. + * When repetition is enabled, actions will be executed multiple times. + * This is usually invoked with a special key stroke in the input handler. + * @return <code>true</code> if repeating is enabled, otherwise <code>false</code> */ public final boolean isRepeatEnabled() { return repeat; } /** - * Enables repeating. When repeating is enabled, actions will be executed - * multiple times. Once repeating is enabled, the input handler should read - * a number from the keyboard. + * Sets the enabled state of repetition. + * When repetition is enabled, actions will be executed multiple times. + * Once repeating is enabled, the input handler should read a number from the keyboard. + * @param repeat <code>true</code> for enabling repetition, <code>false</code> for disabling it */ public final void setRepeatEnabled(final boolean repeat) { this.repeat = repeat; @@ -261,6 +261,7 @@ /** * Returns the number of times the next action will be repeated. + * @return number of times the next action will be repeated (1 or the set repeat count) */ public final int getRepeatCount() { return repeat ? Math.max(1, repeatCount) : 1; @@ -275,10 +276,11 @@ } /** - * Returns the macro recorder. If this is non-null, all executed actions - * should be forwarded to the recorder. + * Returns the macro recorder. + * If this is non-null, all executed actions should be forwarded to the recorder. + * @return the macro recorder */ - public final InputHandler.MacroRecorder getMacroRecorder() { + @Nullable public final InputHandler.MacroRecorder getMacroRecorder() { return recorder; } @@ -287,13 +289,14 @@ * should be forwarded to the recorder. * @param recorder the macro recorder */ - public final void setMacroRecorder(final InputHandler.MacroRecorder recorder) { + public final void setMacroRecorder(@Nullable final InputHandler.MacroRecorder recorder) { this.recorder = recorder; } /** * Returns a copy of this input handler that shares the same key bindings. * Setting key bindings in the copy will also set them in the original. + * @return copy of this InputHandler */ public abstract InputHandler copy(); @@ -333,9 +336,11 @@ if (recorder != null) { if (!(listener instanceof InputHandler.NonRecordable)) { if (repeatCountBak != 1) { + //noinspection ConstantConditions recorder.actionPerformed(REPEAT, String.valueOf(repeatCountBak)); } + //noinspection ConstantConditions recorder.actionPerformed(listener, actionCommand); } } @@ -351,9 +356,11 @@ /** * Returns the text area that fired the specified event. + * This method will throw an {@link Error} if <var>evt</var> does not have a JEditTextArea in it's source component hierarchy. * @param evt the event + * @return the JEditTextArea found as the source of <var>evt</var> */ - @Nullable public static JEditTextArea getTextArea(final EventObject evt) { + @Nullable private static JEditTextArea getTextArea(final EventObject evt) { if (evt != null) { final Object o = evt.getSource(); if (o instanceof Component) { @@ -377,15 +384,17 @@ // this shouldn't happen log.fatal("BUG: getTextArea() returning null"); log.fatal("Report this to Slava Pestov <sp...@gj...>"); - return null; + assert false : "BUG: getTextArea() returning null"; + throw new Error("BUG: getTextArea() returning null"); } // protected members /** * If a key is being grabbed, this method should be called with the - * appropriate key event. It executes the grab action with the typed - * character as the parameter. + * appropriate key event. + * It executes the grab action with the typed character as the parameter. + * @param evt The KeyEvent the key should be grabbed of */ protected final void handleGrabAction(final KeyEvent evt) { // Clear it *before* it is executed so that executeAction() @@ -402,13 +411,13 @@ protected int repeatCount; - protected InputHandler.MacroRecorder recorder; + @Nullable protected InputHandler.MacroRecorder recorder; /** * If an action implements this interface, it should not be repeated. * Instead, it will handle the repetition itself. */ - public interface NonRepeatable { + public static interface NonRepeatable { } @@ -416,7 +425,7 @@ * If an action implements this interface, it should not be recorded * by the macro recorder. Instead, it will do its own recording. */ - public interface NonRecordable { + public static interface NonRecordable { } @@ -424,12 +433,12 @@ * For use by EditAction.Wrapper only. * @since jEdit 2.2final */ - public interface Wrapper { + public static interface Wrapper { } /** Macro recorder. */ - public interface MacroRecorder { + public static interface MacroRecorder { void actionPerformed(ActionListener listener, String actionCommand); @@ -437,8 +446,9 @@ public static final class backspace implements ActionListener { - public final void actionPerformed(final ActionEvent evt) { - final JEditTextArea textArea = getTextArea(evt); + /** {@inheritDoc} */ + public final void actionPerformed(final ActionEvent e) { + final JEditTextArea textArea = getTextArea(e); if (!textArea.isEditable()) { textArea.getToolkit().beep(); @@ -465,8 +475,9 @@ public static final class backspace_word implements ActionListener { - public final void actionPerformed(final ActionEvent evt) { - final JEditTextArea textArea = getTextArea(evt); + /** {@inheritDoc} */ + public final void actionPerformed(final ActionEvent e) { + final JEditTextArea textArea = getTextArea(e); final int start = textArea.getSelectionStart(); if (start != textArea.getSelectionEnd()) { textArea.setSelectedText(""); @@ -499,8 +510,9 @@ public static final class delete implements ActionListener { - public final void actionPerformed(final ActionEvent evt) { - final JEditTextArea textArea = getTextArea(evt); + /** {@inheritDoc} */ + public final void actionPerformed(final ActionEvent e) { + final JEditTextArea textArea = getTextArea(e); if (!textArea.isEditable()) { textArea.getToolkit().beep(); @@ -527,8 +539,9 @@ public static final class delete_word implements ActionListener { - public final void actionPerformed(final ActionEvent evt) { - final JEditTextArea textArea = getTextArea(evt); + /** {@inheritDoc} */ + public final void actionPerformed(final ActionEvent e) { + final JEditTextArea textArea = getTextArea(e); final int start = textArea.getSelectionStart(); if (start != textArea.getSelectionEnd()) { textArea.setSelectedText(""); @@ -567,8 +580,9 @@ this.select = select; } - public final void actionPerformed(final ActionEvent evt) { - final JEditTextArea textArea = getTextArea(evt); + /** {@inheritDoc} */ + public final void actionPerformed(final ActionEvent e) { + final JEditTextArea textArea = getTextArea(e); int caret = textArea.getCaretPosition(); @@ -612,8 +626,9 @@ this.select = select; } - public final void actionPerformed(final ActionEvent evt) { - final JEditTextArea textArea = getTextArea(evt); + /** {@inheritDoc} */ + public final void actionPerformed(final ActionEvent e) { + final JEditTextArea textArea = getTextArea(e); if (select) { textArea.select(textArea.getMarkPosition(), textArea.getDocumentLength()); } else { @@ -630,8 +645,9 @@ this.select = select; } - public final void actionPerformed(final ActionEvent evt) { - final JEditTextArea textArea = getTextArea(evt); + /** {@inheritDoc} */ + public final void actionPerformed(final ActionEvent e) { + final JEditTextArea textArea = getTextArea(e); int caret = textArea.getCaretPosition(); @@ -670,8 +686,9 @@ this.select = select; } - public final void actionPerformed(final ActionEvent evt) { - final JEditTextArea textArea = getTextArea(evt); + /** {@inheritDoc} */ + public final void actionPerformed(final ActionEvent e) { + final JEditTextArea textArea = getTextArea(e); if (select) { textArea.select(textArea.getMarkPosition(), 0); } else { @@ -682,8 +699,8 @@ public static final class insert_break implements ActionListener { - public final void actionPerformed(final ActionEvent evt) { - final JEditTextArea textArea = getTextArea(evt); + public final void actionPerformed(final ActionEvent e) { + final JEditTextArea textArea = getTextArea(e); if (!textArea.isEditable()) { textArea.getToolkit().beep(); @@ -696,8 +713,9 @@ public static final class insert_tab implements ActionListener { - public final void actionPerformed(final ActionEvent evt) { - final JEditTextArea textArea = getTextArea(evt); + /** {@inheritDoc} */ + public final void actionPerformed(final ActionEvent e) { + final JEditTextArea textArea = getTextArea(e); if (!textArea.isEditable()) { textArea.getToolkit().beep(); @@ -717,8 +735,9 @@ this.select = select; } - public final void actionPerformed(final ActionEvent evt) { - final JEditTextArea textArea = getTextArea(evt); + /** {@inheritDoc} */ + public final void actionPerformed(final ActionEvent e) { + final JEditTextArea textArea = getTextArea(e); final int caret = textArea.getCaretPosition(); if (caret == textArea.getDocumentLength()) { textArea.getToolkit().beep(); @@ -741,8 +760,9 @@ this.select = select; } - public final void actionPerformed(final ActionEvent evt) { - final JEditTextArea textArea = getTextArea(evt); + /** {@inheritDoc} */ + public final void actionPerformed(final ActionEvent e) { + final JEditTextArea textArea = getTextArea(e); int caret = textArea.getCaretPosition(); final int line = textArea.getCaretLine(); @@ -774,8 +794,9 @@ this.select = select; } - public final void actionPerformed(final ActionEvent evt) { - final JEditTextArea textArea = getTextArea(evt); + /** {@inheritDoc} */ + public final void actionPerformed(final ActionEvent e) { + final JEditTextArea textArea = getTextArea(e); final int lineCount = textArea.getLineCount(); int firstLine = textArea.getFirstLine(); final int visibleLines = textArea.getVisibleLines(); @@ -806,8 +827,9 @@ this.select = select; } - public final void actionPerformed(final ActionEvent evt) { - final JEditTextArea textArea = getTextArea(evt); + /** {@inheritDoc} */ + public final void actionPerformed(final ActionEvent e) { + final JEditTextArea textArea = getTextArea(e); int caret = textArea.getCaretPosition(); final int line = textArea.getCaretLine(); final int lineStart = textArea.getLineStartOffset(line); @@ -836,8 +858,9 @@ public static final class overwrite implements ActionListener { - public final void actionPerformed(final ActionEvent evt) { - final JEditTextArea textArea = getTextArea(evt); + /** {@inheritDoc} */ + public final void actionPerformed(final ActionEvent e) { + final JEditTextArea textArea = getTextArea(e); textArea.setOverwriteEnabled( !textArea.isOverwriteEnabled()); } @@ -851,8 +874,9 @@ this.select = select; } - public final void actionPerformed(final ActionEvent evt) { - final JEditTextArea textArea = getTextArea(evt); + /** {@inheritDoc} */ + public final void actionPerformed(final ActionEvent e) { + final JEditTextArea textArea = getTextArea(e); final int caret = textArea.getCaretPosition(); if (caret == 0) { textArea.getToolkit().beep(); @@ -875,8 +899,9 @@ this.select = select; } - public final void actionPerformed(final ActionEvent evt) { - final JEditTextArea textArea = getTextArea(evt); + /** {@inheritDoc} */ + public final void actionPerformed(final ActionEvent e) { + final JEditTextArea textArea = getTextArea(e); int caret = textArea.getCaretPosition(); final int line = textArea.getCaretLine(); @@ -908,8 +933,9 @@ this.select = select; } - public final void actionPerformed(final ActionEvent evt) { - final JEditTextArea textArea = getTextArea(evt); + /** {@inheritDoc} */ + public final void actionPerformed(final ActionEvent e) { + final JEditTextArea textArea = getTextArea(e); int firstLine = textArea.getFirstLine(); final int visibleLines = textArea.getVisibleLines(); final int line = textArea.getCaretLine(); @@ -937,8 +963,9 @@ this.select = select; } - public final void actionPerformed(final ActionEvent evt) { - final JEditTextArea textArea = getTextArea(evt); + /** {@inheritDoc} */ + public final void actionPerformed(final ActionEvent e) { + final JEditTextArea textArea = getTextArea(e); int caret = textArea.getCaretPosition(); final int line = textArea.getCaretLine(); final int lineStart = textArea.getLineStartOffset(line); @@ -967,10 +994,11 @@ public static final class repeat implements ActionListener, InputHandler.NonRecordable { - public final void actionPerformed(final ActionEvent evt) { - final JEditTextArea textArea = getTextArea(evt); + /** {@inheritDoc} */ + public final void actionPerformed(final ActionEvent e) { + final JEditTextArea textArea = getTextArea(e); textArea.getInputHandler().setRepeatEnabled(true); - final String actionCommand = evt.getActionCommand(); + final String actionCommand = e.getActionCommand(); if (actionCommand != null) { textArea.getInputHandler().setRepeatCount(Integer.parseInt(actionCommand)); } @@ -979,17 +1007,19 @@ public static final class toggle_rect implements ActionListener { - public final void actionPerformed(final ActionEvent evt) { - final JEditTextArea textArea = getTextArea(evt); + /** {@inheritDoc} */ + public final void actionPerformed(final ActionEvent e) { + final JEditTextArea textArea = getTextArea(e); textArea.setSelectionRectangular(!textArea.isSelectionRectangular()); } } public static final class insert_char implements ActionListener, InputHandler.NonRepeatable { - public final void actionPerformed(final ActionEvent evt) { - final JEditTextArea textArea = getTextArea(evt); - final String str = evt.getActionCommand(); + /** {@inheritDoc} */ + public final void actionPerformed(final ActionEvent e) { + final JEditTextArea textArea = getTextArea(e); + final String str = e.getActionCommand(); final int repeatCount = textArea.getInputHandler().getRepeatCount(); if (textArea.isEditable()) { @@ -1012,11 +1042,11 @@ /** * Copy current selection into the system clipboard. - * @param evt ActionEvent (was Control-C) + * {@inheritDoc} */ - public final void actionPerformed(final ActionEvent evt) { + public final void actionPerformed(final ActionEvent e) { // get the selected string - final String text = getTextArea(evt).getSelectedText(); + final String text = getTextArea(e).getSelectedText(); if (text != null) { final StringSelection selection = new StringSelection(text); // set above string to the system clipboard @@ -1032,19 +1062,19 @@ public static final class cut implements ActionListener { /** + * {@inheritDoc} * Copy current selection into the system clipboard, then delete the * selected text. - * @param evt ActionEvent (was Control-X) */ - public final void actionPerformed(final ActionEvent evt) { + public final void actionPerformed(final ActionEvent e) { // get the selected string - final String text = getTextArea(evt).getSelectedText(); + final String text = getTextArea(e).getSelectedText(); if (text != null) { final StringSelection selection = new StringSelection(text); // set above string to the system clipboard Toolkit.getDefaultToolkit().getSystemClipboard().setContents(selection, selection); // now delete the original text - getTextArea(evt).setSelectedText(""); + getTextArea(e).setSelectedText(""); } } } @@ -1056,11 +1086,11 @@ public static final class paste implements ActionListener { /** + * {@inheritDoc} * Get content of the system clipboard and insert it at caret position. - * @param evt ActionEvent (was Control-V) */ - public final void actionPerformed(final ActionEvent evt) { - final JEditTextArea textarea = getTextArea(evt); + public final void actionPerformed(final ActionEvent e) { + final JEditTextArea textarea = getTextArea(e); final StringBuffer buff = new StringBuffer(""); // set above string to the system clipboard @@ -1091,15 +1121,15 @@ // insert text at caret position textarea.getDocument().insertString(textarea.getCaretPosition(), buff.toString(), null); } - } catch (final ClassNotFoundException e) { + } catch (final ClassNotFoundException ex) { System.err.println("syntax.InputHandler: Paste action failed due to ClassNotFoundException"); - } catch (final UnsupportedFlavorException e) { + } catch (final UnsupportedFlavorException ex) { System.err.println("syntax.InputHandler: Paste action failed because clipboard data flavour is not supported."); - } catch (final IOException e) { + } catch (final IOException ex) { System.err.println("syntax.InputHandler: Paste action failed due to IOException"); - } catch (final BadLocationException e) { + } catch (final BadLocationException ex) { System.err.println("syntax.InputHandler: Paste action failed due to BadLocationException"); - } catch (final NullPointerException e) { + } catch (final NullPointerException ex) { // this happens when clipboard is empty, it's not an error } @@ -1113,10 +1143,10 @@ public static final class save implements ActionListener { /** + * {@inheritDoc} * Save the currently active tab - * @param evt ActionEvent (was Control-S) */ - public final void actionPerformed(final ActionEvent evt) { + public final void actionPerformed(final ActionEvent e) { ScriptEditControl.getInstance().saveActiveTab(); } } @@ -1129,11 +1159,11 @@ public static final class function_menu implements ActionListener { /** + * {@inheritDoc} * Get content of the system clipboard and insert it at caret position. - * @param evt ActionEvent (was Control-V) */ - public final void actionPerformed(final ActionEvent evt) { - final JEditTextArea textarea = getTextArea(evt); + public final void actionPerformed(final ActionEvent e) { + final JEditTextArea textarea = getTextArea(e); final int caretPos = textarea.getCaretPosition(); // caret position try { @@ -1157,8 +1187,10 @@ cfPythonPopup.getMenu().show(textarea, textarea._offsetToX(line, offset), 30 + textarea.lineToY(line)); } } - } catch (final BadLocationException e) { + } catch (final BadLocationException ble) { } } - } -} + + } // class function_menu + +} // class InputHandler This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2006-07-31 20:36:06
|
Revision: 241 Author: christianhujer Date: 2006-07-31 13:35:54 -0700 (Mon, 31 Jul 2006) ViewCVS: http://svn.sourceforge.net/gridarta/?rev=241&view=rev Log Message: ----------- Replaced bogus @Nullable with correct @NotNull. Modified Paths: -------------- trunk/crossfire/src/cfeditor/textedit/textarea/InputHandler.java trunk/daimonin/src/daieditor/textedit/textarea/InputHandler.java Modified: trunk/crossfire/src/cfeditor/textedit/textarea/InputHandler.java =================================================================== --- trunk/crossfire/src/cfeditor/textedit/textarea/InputHandler.java 2006-07-31 20:07:17 UTC (rev 240) +++ trunk/crossfire/src/cfeditor/textedit/textarea/InputHandler.java 2006-07-31 20:35:54 UTC (rev 241) @@ -29,6 +29,7 @@ import javax.swing.JPopupMenu; import javax.swing.text.BadLocationException; import org.apache.log4j.Logger; +import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; /** @@ -360,7 +361,7 @@ * @param evt the event * @return the JEditTextArea found as the source of <var>evt</var> */ - @Nullable private static JEditTextArea getTextArea(final EventObject evt) { + @NotNull private static JEditTextArea getTextArea(final EventObject evt) { if (evt != null) { final Object o = evt.getSource(); if (o instanceof Component) { Modified: trunk/daimonin/src/daieditor/textedit/textarea/InputHandler.java =================================================================== --- trunk/daimonin/src/daieditor/textedit/textarea/InputHandler.java 2006-07-31 20:07:17 UTC (rev 240) +++ trunk/daimonin/src/daieditor/textedit/textarea/InputHandler.java 2006-07-31 20:35:54 UTC (rev 241) @@ -29,6 +29,7 @@ import javax.swing.JPopupMenu; import javax.swing.text.BadLocationException; import org.apache.log4j.Logger; +import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; /** @@ -360,7 +361,7 @@ * @param evt the event * @return the JEditTextArea found as the source of <var>evt</var> */ - @Nullable private static JEditTextArea getTextArea(final EventObject evt) { + @NotNull private static JEditTextArea getTextArea(final EventObject evt) { if (evt != null) { final Object o = evt.getSource(); if (o instanceof Component) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |