Merge branch 'master' of https://source.jalview.org/git/jalviewjs.git
[jalviewjs.git] / site / swingjs / j2s / javax / swing / JTextArea.js
index 9cdb5c2..7d2487f 100644 (file)
-Clazz.declarePackage ("javax.swing");\r
-Clazz.load (["javax.swing.text.JTextComponent"], "javax.swing.JTextArea", ["java.lang.IllegalArgumentException", "java.awt.Dimension", "javax.swing.JComponent", "$.LookAndFeel", "javax.swing.text.BadLocationException", "$.JSMinimalAbstractDocument", "swingjs.JSToolkit"], function () {\r
-c$ = Clazz.decorateAsClass (function () {\r
-this.rows = 0;\r
-this.columns = 0;\r
-this.columnWidth = 0;\r
-this.rowHeight = 0;\r
-this.wrap = false;\r
-this.word = false;\r
-Clazz.instantialize (this, arguments);\r
-}, javax.swing, "JTextArea", javax.swing.text.JTextComponent);\r
-Clazz.makeConstructor (c$, \r
-function () {\r
-this.construct (null, null, 0, 0);\r
-});\r
-Clazz.makeConstructor (c$, \r
-function (text) {\r
-this.construct (null, text, 0, 0);\r
-}, "~S");\r
-Clazz.makeConstructor (c$, \r
-function (rows, columns) {\r
-this.construct (null, null, rows, columns);\r
-}, "~N,~N");\r
-Clazz.makeConstructor (c$, \r
-function (text, rows, columns) {\r
-this.construct (null, text, rows, columns);\r
-}, "~S,~N,~N");\r
-Clazz.makeConstructor (c$, \r
-function (doc) {\r
-this.construct (doc, null, 0, 0);\r
-}, "javax.swing.text.Document");\r
-Clazz.makeConstructor (c$, \r
-function (doc, text, rows, columns) {\r
-Clazz.superConstructor (this, javax.swing.JTextArea);\r
-this.rows = rows;\r
-this.columns = columns;\r
-if (doc == null) {\r
-doc = this.createDefaultModel ();\r
-}this.setDocument (doc);\r
-if (text != null) {\r
-this.setText (text);\r
-this.select (0, 0);\r
-}if (rows < 0) {\r
-throw  new IllegalArgumentException ("rows: " + rows);\r
-}if (columns < 0) {\r
-throw  new IllegalArgumentException ("columns: " + columns);\r
-}javax.swing.LookAndFeel.installProperty (this, "focusTraversalKeysForward", javax.swing.JComponent.getManagingFocusForwardTraversalKeys ());\r
-javax.swing.LookAndFeel.installProperty (this, "focusTraversalKeysBackward", javax.swing.JComponent.getManagingFocusBackwardTraversalKeys ());\r
-}, "javax.swing.text.Document,~S,~N,~N");\r
-Clazz.overrideMethod (c$, "getUIClassID", \r
-function () {\r
-return "TextAreaUI";\r
-});\r
-Clazz.defineMethod (c$, "createDefaultModel", \r
-function () {\r
-return swingjs.JSToolkit.getPlainDocument (this);\r
-});\r
-Clazz.defineMethod (c$, "setTabSize", \r
-function (size) {\r
-var doc = this.getDocument ();\r
-if (doc != null) {\r
-var old = this.getTabSize ();\r
-doc.putProperty ("tabSize",  new Integer (size));\r
-this.firePropertyChangeInt ("tabSize", old, size);\r
-}}, "~N");\r
-Clazz.defineMethod (c$, "getTabSize", \r
-function () {\r
-var size = 8;\r
-var doc = this.getDocument ();\r
-if (doc != null) {\r
-var i = doc.getProperty ("tabSize");\r
-if (i != null) {\r
-size = i.intValue ();\r
-}}return size;\r
-});\r
-Clazz.defineMethod (c$, "setLineWrap", \r
-function (wrap) {\r
-var old = this.wrap;\r
-this.wrap = wrap;\r
-this.firePropertyChangeBool ("lineWrap", old, wrap);\r
-}, "~B");\r
-Clazz.defineMethod (c$, "getLineWrap", \r
-function () {\r
-return this.wrap;\r
-});\r
-Clazz.defineMethod (c$, "setWrapStyleWord", \r
-function (word) {\r
-var old = this.word;\r
-this.word = word;\r
-this.firePropertyChangeBool ("wrapStyleWord", old, word);\r
-}, "~B");\r
-Clazz.defineMethod (c$, "getWrapStyleWord", \r
-function () {\r
-return this.word;\r
-});\r
-Clazz.defineMethod (c$, "getLineOfOffset", \r
-function (offset) {\r
-var doc = this.getDocument ();\r
-if (offset < 0) {\r
-throw  new javax.swing.text.BadLocationException ("Can't translate offset to line", -1);\r
-} else if (offset > doc.getLength ()) {\r
-throw  new javax.swing.text.BadLocationException ("Can't translate offset to line", doc.getLength () + 1);\r
-} else {\r
-var map = this.getDocument ().getDefaultRootElement ();\r
-return map.getElementIndex (offset);\r
-}}, "~N");\r
-Clazz.defineMethod (c$, "getLineCount", \r
-function () {\r
-var map = this.getDocument ().getDefaultRootElement ();\r
-return map.getElementCount ();\r
-});\r
-Clazz.defineMethod (c$, "getLineStartOffset", \r
-function (line) {\r
-var lineCount = this.getLineCount ();\r
-if (line < 0) {\r
-throw  new javax.swing.text.BadLocationException ("Negative line", -1);\r
-} else if (line >= lineCount) {\r
-throw  new javax.swing.text.BadLocationException ("No such line", this.getDocument ().getLength () + 1);\r
-} else {\r
-var map = this.getDocument ().getDefaultRootElement ();\r
-var lineElem = map.getElement (line);\r
-return lineElem.getStartOffset ();\r
-}}, "~N");\r
-Clazz.defineMethod (c$, "getLineEndOffset", \r
-function (line) {\r
-var lineCount = this.getLineCount ();\r
-if (line < 0) {\r
-throw  new javax.swing.text.BadLocationException ("Negative line", -1);\r
-} else if (line >= lineCount) {\r
-throw  new javax.swing.text.BadLocationException ("No such line", this.getDocument ().getLength () + 1);\r
-} else {\r
-var map = this.getDocument ().getDefaultRootElement ();\r
-var lineElem = map.getElement (line);\r
-var endOffset = lineElem.getEndOffset ();\r
-return ((line == lineCount - 1) ? (endOffset - 1) : endOffset);\r
-}}, "~N");\r
-Clazz.defineMethod (c$, "insert", \r
-function (str, pos) {\r
-var doc = this.getDocument ();\r
-if (doc != null) {\r
-try {\r
-doc.insertString (pos, str, null);\r
-} catch (e) {\r
-if (Clazz.exceptionOf (e, javax.swing.text.BadLocationException)) {\r
-throw  new IllegalArgumentException (e.getMessage ());\r
-} else {\r
-throw e;\r
-}\r
-}\r
-}}, "~S,~N");\r
-Clazz.defineMethod (c$, "append", \r
-function (str) {\r
-var doc = this.getDocument ();\r
-if (doc != null) {\r
-try {\r
-doc.insertString (doc.getLength (), str, null);\r
-} catch (e) {\r
-if (Clazz.exceptionOf (e, javax.swing.text.BadLocationException)) {\r
-} else {\r
-throw e;\r
-}\r
-}\r
-}}, "~S");\r
-Clazz.defineMethod (c$, "replaceRange", \r
-function (str, start, end) {\r
-if (end < start) {\r
-throw  new IllegalArgumentException ("end before start");\r
-}var doc = this.getDocument ();\r
-if (doc != null) {\r
-try {\r
-if (Clazz.instanceOf (doc, javax.swing.text.JSMinimalAbstractDocument)) {\r
-(doc).replace (start, end - start, str, null);\r
-} else {\r
-doc.remove (start, end - start);\r
-doc.insertString (start, str, null);\r
-}} catch (e) {\r
-if (Clazz.exceptionOf (e, javax.swing.text.BadLocationException)) {\r
-throw  new IllegalArgumentException (e.getMessage ());\r
-} else {\r
-throw e;\r
-}\r
-}\r
-}}, "~S,~N,~N");\r
-Clazz.defineMethod (c$, "getRows", \r
-function () {\r
-return this.rows;\r
-});\r
-Clazz.defineMethod (c$, "setRows", \r
-function (rows) {\r
-var oldVal = this.rows;\r
-if (rows < 0) {\r
-throw  new IllegalArgumentException ("rows less than zero.");\r
-}if (rows != oldVal) {\r
-this.rows = rows;\r
-this.invalidate ();\r
-}}, "~N");\r
-Clazz.defineMethod (c$, "getRowHeight", \r
-function () {\r
-if (this.rowHeight == 0) {\r
-var metrics = this.getFontMetrics (this.getFont ());\r
-this.rowHeight = metrics.getHeight ();\r
-}return this.rowHeight;\r
-});\r
-Clazz.defineMethod (c$, "getColumns", \r
-function () {\r
-return this.columns;\r
-});\r
-Clazz.defineMethod (c$, "setColumns", \r
-function (columns) {\r
-var oldVal = this.columns;\r
-if (columns < 0) {\r
-throw  new IllegalArgumentException ("columns less than zero.");\r
-}if (columns != oldVal) {\r
-this.columns = columns;\r
-this.invalidate ();\r
-}}, "~N");\r
-Clazz.defineMethod (c$, "getColumnWidth", \r
-function () {\r
-if (this.columnWidth == 0) {\r
-var metrics = this.getFontMetrics (this.getFont ());\r
-this.columnWidth = metrics.charWidth ('m');\r
-}return this.columnWidth;\r
-});\r
-Clazz.overrideMethod (c$, "getPreferredSize", \r
-function () {\r
-var d = this.getPrefSizeJComp ();\r
-d = (d == null) ?  new java.awt.Dimension (400, 400) : d;\r
-var insets = this.getInsets ();\r
-if (this.columns != 0) {\r
-d.width = Math.max (d.width, this.columns * this.getColumnWidth () + insets.left + insets.right);\r
-}if (this.rows != 0) {\r
-d.height = Math.max (d.height, this.rows * this.getRowHeight () + insets.top + insets.bottom);\r
-}return d;\r
-});\r
-Clazz.defineMethod (c$, "setFont", \r
-function (f) {\r
-Clazz.superCall (this, javax.swing.JTextArea, "setFont", [f]);\r
-this.rowHeight = 0;\r
-this.columnWidth = 0;\r
-}, "java.awt.Font");\r
-Clazz.defineMethod (c$, "paramString", \r
-function () {\r
-var wrapString = (this.wrap ? "true" : "false");\r
-var wordString = (this.word ? "true" : "false");\r
-return Clazz.superCall (this, javax.swing.JTextArea, "paramString", []) + ",colums=" + this.columns + ",columWidth=" + this.columnWidth + ",rows=" + this.rows + ",rowHeight=" + this.rowHeight + ",word=" + wordString + ",wrap=" + wrapString;\r
-});\r
-Clazz.defineMethod (c$, "getScrollableTracksViewportWidth", \r
-function () {\r
-return (this.wrap) ? true : Clazz.superCall (this, javax.swing.JTextArea, "getScrollableTracksViewportWidth", []);\r
-});\r
-Clazz.defineMethod (c$, "getPreferredScrollableViewportSize", \r
-function () {\r
-var size = Clazz.superCall (this, javax.swing.JTextArea, "getPreferredScrollableViewportSize", []);\r
-size = (size == null) ?  new java.awt.Dimension (400, 400) : size;\r
-var insets = this.getInsets ();\r
-size.width = (this.columns == 0) ? size.width : this.columns * this.getColumnWidth () + insets.left + insets.right;\r
-size.height = (this.rows == 0) ? size.height : this.rows * this.getRowHeight () + insets.top + insets.bottom;\r
-return size;\r
-});\r
-Clazz.overrideMethod (c$, "getScrollableUnitIncrement", \r
-function (visibleRect, orientation, direction) {\r
-switch (orientation) {\r
-case 1:\r
-return this.getRowHeight ();\r
-case 0:\r
-return this.getColumnWidth ();\r
-default:\r
-throw  new IllegalArgumentException ("Invalid orientation: " + orientation);\r
-}\r
-}, "java.awt.Rectangle,~N,~N");\r
-Clazz.defineStatics (c$,\r
-"$uiClassID", "TextAreaUI");\r
-});\r
+Clazz.declarePackage ("javax.swing");
+Clazz.load (["javax.swing.text.JTextComponent"], "javax.swing.JTextArea", ["java.lang.IllegalArgumentException", "java.awt.Dimension", "javax.swing.JComponent", "$.LookAndFeel", "javax.swing.text.BadLocationException", "$.JSMinimalAbstractDocument", "swingjs.JSToolkit"], function () {
+c$ = Clazz.decorateAsClass (function () {
+this.rows = 0;
+this.columns = 0;
+this.columnWidth = 0;
+this.rowHeight = 0;
+this.wrap = false;
+this.word = false;
+Clazz.instantialize (this, arguments);
+}, javax.swing, "JTextArea", javax.swing.text.JTextComponent);
+Clazz.makeConstructor (c$, 
+function () {
+this.construct (null, null, 0, 0);
+});
+Clazz.makeConstructor (c$, 
+function (text) {
+this.construct (null, text, 0, 0);
+}, "~S");
+Clazz.makeConstructor (c$, 
+function (rows, columns) {
+this.construct (null, null, rows, columns);
+}, "~N,~N");
+Clazz.makeConstructor (c$, 
+function (text, rows, columns) {
+this.construct (null, text, rows, columns);
+}, "~S,~N,~N");
+Clazz.makeConstructor (c$, 
+function (doc) {
+this.construct (doc, null, 0, 0);
+}, "javax.swing.text.Document");
+Clazz.makeConstructor (c$, 
+function (doc, text, rows, columns) {
+Clazz.superConstructor (this, javax.swing.JTextArea);
+this.rows = rows;
+this.columns = columns;
+if (doc == null) {
+doc = this.createDefaultModel ();
+}this.setDocument (doc);
+if (text != null) {
+this.setText (text);
+this.select (0, 0);
+}if (rows < 0) {
+throw  new IllegalArgumentException ("rows: " + rows);
+}if (columns < 0) {
+throw  new IllegalArgumentException ("columns: " + columns);
+}javax.swing.LookAndFeel.installProperty (this, "focusTraversalKeysForward", javax.swing.JComponent.getManagingFocusForwardTraversalKeys ());
+javax.swing.LookAndFeel.installProperty (this, "focusTraversalKeysBackward", javax.swing.JComponent.getManagingFocusBackwardTraversalKeys ());
+}, "javax.swing.text.Document,~S,~N,~N");
+Clazz.overrideMethod (c$, "getUIClassID", 
+function () {
+return "TextAreaUI";
+});
+Clazz.defineMethod (c$, "createDefaultModel", 
+function () {
+return swingjs.JSToolkit.getPlainDocument (this);
+});
+Clazz.defineMethod (c$, "setTabSize", 
+function (size) {
+var doc = this.getDocument ();
+if (doc != null) {
+var old = this.getTabSize ();
+doc.putProperty ("tabSize",  new Integer (size));
+this.firePropertyChangeInt ("tabSize", old, size);
+}}, "~N");
+Clazz.defineMethod (c$, "getTabSize", 
+function () {
+var size = 8;
+var doc = this.getDocument ();
+if (doc != null) {
+var i = doc.getProperty ("tabSize");
+if (i != null) {
+size = i.intValue ();
+}}return size;
+});
+Clazz.defineMethod (c$, "setLineWrap", 
+function (wrap) {
+var old = this.wrap;
+this.wrap = wrap;
+this.firePropertyChangeBool ("lineWrap", old, wrap);
+}, "~B");
+Clazz.defineMethod (c$, "getLineWrap", 
+function () {
+return this.wrap;
+});
+Clazz.defineMethod (c$, "setWrapStyleWord", 
+function (word) {
+var old = this.word;
+this.word = word;
+this.firePropertyChangeBool ("wrapStyleWord", old, word);
+}, "~B");
+Clazz.defineMethod (c$, "getWrapStyleWord", 
+function () {
+return this.word;
+});
+Clazz.defineMethod (c$, "getLineOfOffset", 
+function (offset) {
+var doc = this.getDocument ();
+if (offset < 0) {
+throw  new javax.swing.text.BadLocationException ("Can't translate offset to line", -1);
+} else if (offset > doc.getLength ()) {
+throw  new javax.swing.text.BadLocationException ("Can't translate offset to line", doc.getLength () + 1);
+} else {
+var map = this.getDocument ().getDefaultRootElement ();
+return map.getElementIndex (offset);
+}}, "~N");
+Clazz.defineMethod (c$, "getLineCount", 
+function () {
+var map = this.getDocument ().getDefaultRootElement ();
+return map.getElementCount ();
+});
+Clazz.defineMethod (c$, "getLineStartOffset", 
+function (line) {
+var lineCount = this.getLineCount ();
+if (line < 0) {
+throw  new javax.swing.text.BadLocationException ("Negative line", -1);
+} else if (line >= lineCount) {
+throw  new javax.swing.text.BadLocationException ("No such line", this.getDocument ().getLength () + 1);
+} else {
+var map = this.getDocument ().getDefaultRootElement ();
+var lineElem = map.getElement (line);
+return lineElem.getStartOffset ();
+}}, "~N");
+Clazz.defineMethod (c$, "getLineEndOffset", 
+function (line) {
+var lineCount = this.getLineCount ();
+if (line < 0) {
+throw  new javax.swing.text.BadLocationException ("Negative line", -1);
+} else if (line >= lineCount) {
+throw  new javax.swing.text.BadLocationException ("No such line", this.getDocument ().getLength () + 1);
+} else {
+var map = this.getDocument ().getDefaultRootElement ();
+var lineElem = map.getElement (line);
+var endOffset = lineElem.getEndOffset ();
+return ((line == lineCount - 1) ? (endOffset - 1) : endOffset);
+}}, "~N");
+Clazz.defineMethod (c$, "insert", 
+function (str, pos) {
+var doc = this.getDocument ();
+if (doc != null) {
+try {
+doc.insertString (pos, str, null);
+} catch (e) {
+if (Clazz.exceptionOf (e, javax.swing.text.BadLocationException)) {
+throw  new IllegalArgumentException (e.getMessage ());
+} else {
+throw e;
+}
+}
+}}, "~S,~N");
+Clazz.defineMethod (c$, "append", 
+function (str) {
+var doc = this.getDocument ();
+if (doc != null) {
+try {
+doc.insertString (doc.getLength (), str, null);
+} catch (e) {
+if (Clazz.exceptionOf (e, javax.swing.text.BadLocationException)) {
+} else {
+throw e;
+}
+}
+}}, "~S");
+Clazz.defineMethod (c$, "replaceRange", 
+function (str, start, end) {
+if (end < start) {
+throw  new IllegalArgumentException ("end before start");
+}var doc = this.getDocument ();
+if (doc != null) {
+try {
+if (Clazz.instanceOf (doc, javax.swing.text.JSMinimalAbstractDocument)) {
+(doc).replace (start, end - start, str, null);
+} else {
+doc.remove (start, end - start);
+doc.insertString (start, str, null);
+}} catch (e) {
+if (Clazz.exceptionOf (e, javax.swing.text.BadLocationException)) {
+throw  new IllegalArgumentException (e.getMessage ());
+} else {
+throw e;
+}
+}
+}}, "~S,~N,~N");
+Clazz.defineMethod (c$, "getRows", 
+function () {
+return this.rows;
+});
+Clazz.defineMethod (c$, "setRows", 
+function (rows) {
+var oldVal = this.rows;
+if (rows < 0) {
+throw  new IllegalArgumentException ("rows less than zero.");
+}if (rows != oldVal) {
+this.rows = rows;
+this.invalidate ();
+}}, "~N");
+Clazz.defineMethod (c$, "getRowHeight", 
+function () {
+if (this.rowHeight == 0) {
+var metrics = this.getFontMetrics (this.getFont ());
+this.rowHeight = metrics.getHeight ();
+}return this.rowHeight;
+});
+Clazz.defineMethod (c$, "getColumns", 
+function () {
+return this.columns;
+});
+Clazz.defineMethod (c$, "setColumns", 
+function (columns) {
+var oldVal = this.columns;
+if (columns < 0) {
+throw  new IllegalArgumentException ("columns less than zero.");
+}if (columns != oldVal) {
+this.columns = columns;
+this.invalidate ();
+}}, "~N");
+Clazz.defineMethod (c$, "getColumnWidth", 
+function () {
+if (this.columnWidth == 0) {
+var metrics = this.getFontMetrics (this.getFont ());
+this.columnWidth = metrics.charWidth ('m');
+}return this.columnWidth;
+});
+Clazz.overrideMethod (c$, "getPreferredSize", 
+function () {
+var d = this.getPrefSizeJComp ();
+d = (d == null) ?  new java.awt.Dimension (400, 400) : d;
+var insets = this.getInsets ();
+if (this.columns != 0) {
+d.width = Math.max (d.width, this.columns * this.getColumnWidth () + insets.left + insets.right);
+}if (this.rows != 0) {
+d.height = Math.max (d.height, this.rows * this.getRowHeight () + insets.top + insets.bottom);
+}return d;
+});
+Clazz.defineMethod (c$, "setFont", 
+function (f) {
+Clazz.superCall (this, javax.swing.JTextArea, "setFont", [f]);
+this.rowHeight = 0;
+this.columnWidth = 0;
+}, "java.awt.Font");
+Clazz.defineMethod (c$, "paramString", 
+function () {
+var wrapString = (this.wrap ? "true" : "false");
+var wordString = (this.word ? "true" : "false");
+return Clazz.superCall (this, javax.swing.JTextArea, "paramString", []) + ",colums=" + this.columns + ",columWidth=" + this.columnWidth + ",rows=" + this.rows + ",rowHeight=" + this.rowHeight + ",word=" + wordString + ",wrap=" + wrapString;
+});
+Clazz.defineMethod (c$, "getScrollableTracksViewportWidth", 
+function () {
+return (this.wrap) ? true : Clazz.superCall (this, javax.swing.JTextArea, "getScrollableTracksViewportWidth", []);
+});
+Clazz.defineMethod (c$, "getPreferredScrollableViewportSize", 
+function () {
+var size = Clazz.superCall (this, javax.swing.JTextArea, "getPreferredScrollableViewportSize", []);
+size = (size == null) ?  new java.awt.Dimension (400, 400) : size;
+var insets = this.getInsets ();
+size.width = (this.columns == 0) ? size.width : this.columns * this.getColumnWidth () + insets.left + insets.right;
+size.height = (this.rows == 0) ? size.height : this.rows * this.getRowHeight () + insets.top + insets.bottom;
+return size;
+});
+Clazz.overrideMethod (c$, "getScrollableUnitIncrement", 
+function (visibleRect, orientation, direction) {
+switch (orientation) {
+case 1:
+return this.getRowHeight ();
+case 0:
+return this.getColumnWidth ();
+default:
+throw  new IllegalArgumentException ("Invalid orientation: " + orientation);
+}
+}, "java.awt.Rectangle,~N,~N");
+Clazz.defineStatics (c$,
+"$uiClassID", "TextAreaUI");
+});