Author: vyemialyanchyk
Date: 2007-12-14 07:41:48 -0500 (Fri, 14 Dec 2007)
New Revision: 5306
Added:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.seam/src/org/
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.seam/src/org/jboss/
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.seam/src/org/jboss/seam/
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.seam/src/org/jboss/seam/test/
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.seam/src/org/jboss/seam/test/unit/
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.seam/src/org/jboss/seam/test/unit/SeamTextTest.java
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.seam/src/org/jboss/seam/test/unit/SeamTextTest.txt
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.seam/src/org/jboss/seam/text/
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.seam/src/org/jboss/seam/text/SeamTextLexer.java
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.seam/src/org/jboss/seam/text/SeamTextParser.java
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.seam/src/org/jboss/seam/text/SeamTextParserTokenTypes.java
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.seam/src/org/jboss/seam/text/SeamTextParserTokenTypes.txt
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.seam/src/org/jboss/tools/
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.seam/src/org/jboss/tools/jsf/
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.seam/src/org/jboss/tools/jsf/vpe/
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.seam/src/org/jboss/tools/jsf/vpe/seam/
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.seam/src/org/jboss/tools/jsf/vpe/seam/ComponentUtil.java
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.seam/src/org/jboss/tools/jsf/vpe/seam/SeamTemplatesActivator.java
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.seam/src/org/jboss/tools/jsf/vpe/seam/template/
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.seam/src/org/jboss/tools/jsf/vpe/seam/template/SeamFormattedTextTemplate.java
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.seam/src/org/jboss/tools/jsf/vpe/seam/template/SeamTextTest2.txt
Log:
http://jira.jboss.com/jira/browse/JBIDE-1449
Added:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.seam/src/org/jboss/seam/test/unit/SeamTextTest.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.seam/src/org/jboss/seam/test/unit/SeamTextTest.java
(rev 0)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.seam/src/org/jboss/seam/test/unit/SeamTextTest.java 2007-12-14
12:41:48 UTC (rev 5306)
@@ -0,0 +1,18 @@
+package org.jboss.seam.test.unit;
+
+import java.io.InputStreamReader;
+import java.io.Reader;
+
+import org.jboss.seam.text.SeamTextLexer;
+import org.jboss.seam.text.SeamTextParser;
+
+public class SeamTextTest
+{
+ public static void main(String[] args) throws Exception {
+ Reader r = new InputStreamReader(
SeamTextTest.class.getResourceAsStream("SeamTextTest.txt") );
+ SeamTextLexer lexer = new SeamTextLexer(r);
+ SeamTextParser parser = new SeamTextParser(lexer);
+ parser.startRule();
+ System.out.println(parser);
+ }
+}
Added:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.seam/src/org/jboss/seam/test/unit/SeamTextTest.txt
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.seam/src/org/jboss/seam/test/unit/SeamTextTest.txt
(rev 0)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.seam/src/org/jboss/seam/test/unit/SeamTextTest.txt 2007-12-14
12:41:48 UTC (rev 5306)
@@ -0,0 +1,104 @@
++Seam Text!
+This page demonstrates Seam Text.
+
+++Some examples:
+
+Here is some wiki text:
+*bold* |mono| ~deleted~ _underline_ /italic/ ^super^
+
+This is a new paragraph. (Just leave a blank line.)
+
+*/_Multiple ~tags~ styles_ can be nested!/*
+
+Special characters can be escaped: \| \* \_
+
+This is especially useful for HTML: \<notatag\> \¬anentity;
+
+But if we don't want to use escapes in our preformatted
+text, we can wrap it in backwards quotes, and special
+characters get escaped automagically:
+
+`//This is some code:
+
+<some-tag/>
+"a string"
+a_variable_name
+a||b
+x=y*z/2`
+
+We wrap quoted text in double quotes:
+
+"This is a block quote with /formatting/. The quote can cross multiple
+lines, but a blank line does not start a new paragraph. If you
+need multiple paragraphs in a quote, you have to use \<p\>."
+
+You can even have "a quote", or `some code` inside
+a regular paragraph!
+
+We use ordinary old HTML for tables:
+
+<table>
+
<tr><td>foo</td><td>*bar*</td><td>baz</td></tr><tr>
+ <td>fee</td>
+ <td>fi</td>
+ <td>/fo/</td>
+ </tr>
+</table>
+
+And we can use HTML for lists:
+
+<ol>
+ <li>foo</li>
+ <li>*bar*</li>
+ <li>/baz/</li>
+</ol>
+
+<ul><li>foo</li><li>*bar*</li><li>/baz/</li></ul>
+
+But if the items fit on a line, we can use \#
+for ordered lists:
+
+# item 1
+# item 2
+# item 3
+
+And \= for unordered lists:
+
+= item 1
+= item 2
+= item 3
+
+We use HTML for <a
href="http://www.hibernate.org/">links</a>.
+
+Or we can use [a special
syntax=>http://jboss.com/products/seam] to
+link to [=>http://jboss.com/products/seam].
+
+And for images: <img
src="http://www.hibernate.org/tpl/jboss/img/01_oben_logo.gif"/>
+
+And even for more exotic formatting, for example:
+
+<q>This is a /HTML/ quote with a <a
href="http://jboss.org/">link</a>,
+and a "nested quote" and even `some code` in it.</q>
+
+<p>
+This is a HTML paragraph with some lists:
+
+# item 1
+# item 2
+
+= an item
+= another item
+
+And "a quote" in it.
+</p>
+
+Oh, and one last thing:
+
+"This is a block quote with
+
+= a list,
+= with 2 items
+
+and <i>some HTML</i> formatting and `some code` and
+and <a
href="http://jboss.com/products/seam"><i>yet
+another</i> link</a>."
Added:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.seam/src/org/jboss/seam/text/SeamTextLexer.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.seam/src/org/jboss/seam/text/SeamTextLexer.java
(rev 0)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.seam/src/org/jboss/seam/text/SeamTextLexer.java 2007-12-14
12:41:48 UTC (rev 5306)
@@ -0,0 +1,711 @@
+// $ANTLR 2.7.6 (2005-12-22): "seam-text.g" ->
"SeamTextLexer.java"$
+
+package org.jboss.seam.text;
+
+import java.io.InputStream;
+import antlr.TokenStreamException;
+import antlr.TokenStreamIOException;
+import antlr.TokenStreamRecognitionException;
+import antlr.CharStreamException;
+import antlr.CharStreamIOException;
+import antlr.ANTLRException;
+import java.io.Reader;
+import java.util.Hashtable;
+import antlr.CharScanner;
+import antlr.InputBuffer;
+import antlr.ByteBuffer;
+import antlr.CharBuffer;
+import antlr.Token;
+import antlr.CommonToken;
+import antlr.RecognitionException;
+import antlr.NoViableAltForCharException;
+import antlr.MismatchedCharException;
+import antlr.TokenStream;
+import antlr.ANTLRHashString;
+import antlr.LexerSharedInputState;
+import antlr.collections.impl.BitSet;
+import antlr.SemanticException;
+
+public class SeamTextLexer extends antlr.CharScanner implements SeamTextParserTokenTypes,
TokenStream
+ {
+public SeamTextLexer(InputStream in) {
+ this(new ByteBuffer(in));
+}
+public SeamTextLexer(Reader in) {
+ this(new CharBuffer(in));
+}
+public SeamTextLexer(InputBuffer ib) {
+ this(new LexerSharedInputState(ib));
+}
+public SeamTextLexer(LexerSharedInputState state) {
+ super(state);
+ caseSensitiveLiterals = true;
+ setCaseSensitive(true);
+ literals = new Hashtable();
+}
+
+public Token nextToken() throws TokenStreamException {
+ Token theRetToken=null;
+tryAgain:
+ for (;;) {
+ Token _token = null;
+ int _ttype = Token.INVALID_TYPE;
+ resetText();
+ try { // for char stream error handling
+ try { // for lexical error handling
+ switch ( LA(1)) {
+ case '!': case '$': case '%': case '\'':
+ case '(': case ')': case ',': case '-':
+ case '.': case ':': case ';': case '?':
+ case '@': case '{': case '}':
+ {
+ mPUNCTUATION(true);
+ theRetToken=_returnToken;
+ break;
+ }
+ case '=':
+ {
+ mEQ(true);
+ theRetToken=_returnToken;
+ break;
+ }
+ case '+':
+ {
+ mPLUS(true);
+ theRetToken=_returnToken;
+ break;
+ }
+ case '_':
+ {
+ mUNDERSCORE(true);
+ theRetToken=_returnToken;
+ break;
+ }
+ case '*':
+ {
+ mSTAR(true);
+ theRetToken=_returnToken;
+ break;
+ }
+ case '/':
+ {
+ mSLASH(true);
+ theRetToken=_returnToken;
+ break;
+ }
+ case '\\':
+ {
+ mESCAPE(true);
+ theRetToken=_returnToken;
+ break;
+ }
+ case '|':
+ {
+ mBAR(true);
+ theRetToken=_returnToken;
+ break;
+ }
+ case '`':
+ {
+ mBACKTICK(true);
+ theRetToken=_returnToken;
+ break;
+ }
+ case '~':
+ {
+ mTWIDDLE(true);
+ theRetToken=_returnToken;
+ break;
+ }
+ case '"':
+ {
+ mDOUBLEQUOTE(true);
+ theRetToken=_returnToken;
+ break;
+ }
+ case '[':
+ {
+ mOPEN(true);
+ theRetToken=_returnToken;
+ break;
+ }
+ case ']':
+ {
+ mCLOSE(true);
+ theRetToken=_returnToken;
+ break;
+ }
+ case '#':
+ {
+ mHASH(true);
+ theRetToken=_returnToken;
+ break;
+ }
+ case '^':
+ {
+ mHAT(true);
+ theRetToken=_returnToken;
+ break;
+ }
+ case '>':
+ {
+ mGT(true);
+ theRetToken=_returnToken;
+ break;
+ }
+ case '<':
+ {
+ mLT(true);
+ theRetToken=_returnToken;
+ break;
+ }
+ case '&':
+ {
+ mAMPERSAND(true);
+ theRetToken=_returnToken;
+ break;
+ }
+ case '\t': case ' ':
+ {
+ mSPACE(true);
+ theRetToken=_returnToken;
+ break;
+ }
+ case '\n': case '\r':
+ {
+ mNEWLINE(true);
+ theRetToken=_returnToken;
+ break;
+ }
+ case '\uffff':
+ {
+ mEOF(true);
+ theRetToken=_returnToken;
+ break;
+ }
+ default:
+ if ((_tokenSet_0.member(LA(1)))) {
+ mWORD(true);
+ theRetToken=_returnToken;
+ }
+ else {
+ if (LA(1)==EOF_CHAR) {uponEOF(); _returnToken = makeToken(Token.EOF_TYPE);}
+ else {throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(),
getColumn());}
+ }
+ }
+ if ( _returnToken==null ) continue tryAgain; // found SKIP token
+ _ttype = _returnToken.getType();
+ _ttype = testLiteralsTable(_ttype);
+ _returnToken.setType(_ttype);
+ return _returnToken;
+ }
+ catch (RecognitionException e) {
+ throw new TokenStreamRecognitionException(e);
+ }
+ }
+ catch (CharStreamException cse) {
+ if ( cse instanceof CharStreamIOException ) {
+ throw new TokenStreamIOException(((CharStreamIOException)cse).io);
+ }
+ else {
+ throw new TokenStreamException(cse.getMessage());
+ }
+ }
+ }
+}
+
+ public final void mWORD(boolean _createToken) throws RecognitionException,
CharStreamException, TokenStreamException {
+ int _ttype; Token _token=null; int _begin=text.length();
+ _ttype = WORD;
+ int _saveIndex;
+
+ {
+ int _cnt107=0;
+ _loop107:
+ do {
+ switch ( LA(1)) {
+ case 'a': case 'b': case 'c': case 'd':
+ case 'e': case 'f': case 'g': case 'h':
+ case 'i': case 'j': case 'k': case 'l':
+ case 'm': case 'n': case 'o': case 'p':
+ case 'q': case 'r': case 's': case 't':
+ case 'u': case 'v': case 'w': case 'x':
+ case 'y': case 'z':
+ {
+ matchRange('a','z');
+ break;
+ }
+ case 'A': case 'B': case 'C': case 'D':
+ case 'E': case 'F': case 'G': case 'H':
+ case 'I': case 'J': case 'K': case 'L':
+ case 'M': case 'N': case 'O': case 'P':
+ case 'Q': case 'R': case 'S': case 'T':
+ case 'U': case 'V': case 'W': case 'X':
+ case 'Y': case 'Z':
+ {
+ matchRange('A','Z');
+ break;
+ }
+ case '0': case '1': case '2': case '3':
+ case '4': case '5': case '6': case '7':
+ case '8': case '9':
+ {
+ matchRange('0','9');
+ break;
+ }
+ case '\u00a0': case '\u00a1': case '\u00a2': case
'\u00a3':
+ case '\u00a4': case '\u00a5': case '\u00a6': case
'\u00a7':
+ case '\u00a8': case '\u00a9': case '\u00aa': case
'\u00ab':
+ case '\u00ac': case '\u00ad': case '\u00ae': case
'\u00af':
+ case '\u00b0': case '\u00b1': case '\u00b2': case
'\u00b3':
+ case '\u00b4': case '\u00b5': case '\u00b6': case
'\u00b7':
+ case '\u00b8': case '\u00b9': case '\u00ba': case
'\u00bb':
+ case '\u00bc': case '\u00bd': case '\u00be': case
'\u00bf':
+ case '\u00c0': case '\u00c1': case '\u00c2': case
'\u00c3':
+ case '\u00c4': case '\u00c5': case '\u00c6': case
'\u00c7':
+ case '\u00c8': case '\u00c9': case '\u00ca': case
'\u00cb':
+ case '\u00cc': case '\u00cd': case '\u00ce': case
'\u00cf':
+ case '\u00d0': case '\u00d1': case '\u00d2': case
'\u00d3':
+ case '\u00d4': case '\u00d5': case '\u00d6': case
'\u00d7':
+ case '\u00d8': case '\u00d9': case '\u00da': case
'\u00db':
+ case '\u00dc': case '\u00dd': case '\u00de': case
'\u00df':
+ case '\u00e0': case '\u00e1': case '\u00e2': case
'\u00e3':
+ case '\u00e4': case '\u00e5': case '\u00e6': case
'\u00e7':
+ case '\u00e8': case '\u00e9': case '\u00ea': case
'\u00eb':
+ case '\u00ec': case '\u00ed': case '\u00ee': case
'\u00ef':
+ case '\u00f0': case '\u00f1': case '\u00f2': case
'\u00f3':
+ case '\u00f4': case '\u00f5': case '\u00f6': case
'\u00f7':
+ case '\u00f8': case '\u00f9': case '\u00fa': case
'\u00fb':
+ case '\u00fc': case '\u00fd': case '\u00fe': case
'\u00ff':
+ {
+ matchRange('\u00a0','\u00ff');
+ break;
+ }
+ default:
+ if (((LA(1) >= '\u0100' && LA(1) <= '\u017f'))) {
+ matchRange('\u0100','\u017f');
+ }
+ else if (((LA(1) >= '\u0180' && LA(1) <= '\u024f'))) {
+ matchRange('\u0180','\u024f');
+ }
+ else if (((LA(1) >= '\u0250' && LA(1) <= '\ufaff'))) {
+ matchRange('\u0250','\ufaff');
+ }
+ else if (((LA(1) >= '\uff00' && LA(1) <= '\uffef'))) {
+ matchRange('\uff00','\uffef');
+ }
+ else {
+ if ( _cnt107>=1 ) { break _loop107; } else {throw new
NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());}
+ }
+ }
+ _cnt107++;
+ } while (true);
+ }
+ if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
+ _token = makeToken(_ttype);
+ _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
+ }
+ _returnToken = _token;
+ }
+
+ public final void mPUNCTUATION(boolean _createToken) throws RecognitionException,
CharStreamException, TokenStreamException {
+ int _ttype; Token _token=null; int _begin=text.length();
+ _ttype = PUNCTUATION;
+ int _saveIndex;
+
+ switch ( LA(1)) {
+ case '-':
+ {
+ match('-');
+ break;
+ }
+ case ';':
+ {
+ match(';');
+ break;
+ }
+ case ':':
+ {
+ match(':');
+ break;
+ }
+ case '(':
+ {
+ match('(');
+ break;
+ }
+ case ')':
+ {
+ match(')');
+ break;
+ }
+ case '{':
+ {
+ match('{');
+ break;
+ }
+ case '}':
+ {
+ match('}');
+ break;
+ }
+ case '?':
+ {
+ match('?');
+ break;
+ }
+ case '!':
+ {
+ match('!');
+ break;
+ }
+ case '@':
+ {
+ match('@');
+ break;
+ }
+ case '%':
+ {
+ match('%');
+ break;
+ }
+ case '.':
+ {
+ match('.');
+ break;
+ }
+ case ',':
+ {
+ match(',');
+ break;
+ }
+ case '\'':
+ {
+ match('\'');
+ break;
+ }
+ case '$':
+ {
+ match('$');
+ break;
+ }
+ default:
+ {
+ throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(),
getColumn());
+ }
+ }
+ if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
+ _token = makeToken(_ttype);
+ _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
+ }
+ _returnToken = _token;
+ }
+
+ public final void mEQ(boolean _createToken) throws RecognitionException,
CharStreamException, TokenStreamException {
+ int _ttype; Token _token=null; int _begin=text.length();
+ _ttype = EQ;
+ int _saveIndex;
+
+ match('=');
+ if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
+ _token = makeToken(_ttype);
+ _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
+ }
+ _returnToken = _token;
+ }
+
+ public final void mPLUS(boolean _createToken) throws RecognitionException,
CharStreamException, TokenStreamException {
+ int _ttype; Token _token=null; int _begin=text.length();
+ _ttype = PLUS;
+ int _saveIndex;
+
+ match('+');
+ if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
+ _token = makeToken(_ttype);
+ _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
+ }
+ _returnToken = _token;
+ }
+
+ public final void mUNDERSCORE(boolean _createToken) throws RecognitionException,
CharStreamException, TokenStreamException {
+ int _ttype; Token _token=null; int _begin=text.length();
+ _ttype = UNDERSCORE;
+ int _saveIndex;
+
+ match('_');
+ if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
+ _token = makeToken(_ttype);
+ _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
+ }
+ _returnToken = _token;
+ }
+
+ public final void mSTAR(boolean _createToken) throws RecognitionException,
CharStreamException, TokenStreamException {
+ int _ttype; Token _token=null; int _begin=text.length();
+ _ttype = STAR;
+ int _saveIndex;
+
+ match('*');
+ if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
+ _token = makeToken(_ttype);
+ _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
+ }
+ _returnToken = _token;
+ }
+
+ public final void mSLASH(boolean _createToken) throws RecognitionException,
CharStreamException, TokenStreamException {
+ int _ttype; Token _token=null; int _begin=text.length();
+ _ttype = SLASH;
+ int _saveIndex;
+
+ match('/');
+ if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
+ _token = makeToken(_ttype);
+ _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
+ }
+ _returnToken = _token;
+ }
+
+ public final void mESCAPE(boolean _createToken) throws RecognitionException,
CharStreamException, TokenStreamException {
+ int _ttype; Token _token=null; int _begin=text.length();
+ _ttype = ESCAPE;
+ int _saveIndex;
+
+ match('\\');
+ if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
+ _token = makeToken(_ttype);
+ _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
+ }
+ _returnToken = _token;
+ }
+
+ public final void mBAR(boolean _createToken) throws RecognitionException,
CharStreamException, TokenStreamException {
+ int _ttype; Token _token=null; int _begin=text.length();
+ _ttype = BAR;
+ int _saveIndex;
+
+ match('|');
+ if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
+ _token = makeToken(_ttype);
+ _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
+ }
+ _returnToken = _token;
+ }
+
+ public final void mBACKTICK(boolean _createToken) throws RecognitionException,
CharStreamException, TokenStreamException {
+ int _ttype; Token _token=null; int _begin=text.length();
+ _ttype = BACKTICK;
+ int _saveIndex;
+
+ match('`');
+ if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
+ _token = makeToken(_ttype);
+ _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
+ }
+ _returnToken = _token;
+ }
+
+ public final void mTWIDDLE(boolean _createToken) throws RecognitionException,
CharStreamException, TokenStreamException {
+ int _ttype; Token _token=null; int _begin=text.length();
+ _ttype = TWIDDLE;
+ int _saveIndex;
+
+ match('~');
+ if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
+ _token = makeToken(_ttype);
+ _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
+ }
+ _returnToken = _token;
+ }
+
+ public final void mDOUBLEQUOTE(boolean _createToken) throws RecognitionException,
CharStreamException, TokenStreamException {
+ int _ttype; Token _token=null; int _begin=text.length();
+ _ttype = DOUBLEQUOTE;
+ int _saveIndex;
+
+ match('"');
+ if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
+ _token = makeToken(_ttype);
+ _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
+ }
+ _returnToken = _token;
+ }
+
+ public final void mOPEN(boolean _createToken) throws RecognitionException,
CharStreamException, TokenStreamException {
+ int _ttype; Token _token=null; int _begin=text.length();
+ _ttype = OPEN;
+ int _saveIndex;
+
+ match('[');
+ if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
+ _token = makeToken(_ttype);
+ _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
+ }
+ _returnToken = _token;
+ }
+
+ public final void mCLOSE(boolean _createToken) throws RecognitionException,
CharStreamException, TokenStreamException {
+ int _ttype; Token _token=null; int _begin=text.length();
+ _ttype = CLOSE;
+ int _saveIndex;
+
+ match(']');
+ if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
+ _token = makeToken(_ttype);
+ _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
+ }
+ _returnToken = _token;
+ }
+
+ public final void mHASH(boolean _createToken) throws RecognitionException,
CharStreamException, TokenStreamException {
+ int _ttype; Token _token=null; int _begin=text.length();
+ _ttype = HASH;
+ int _saveIndex;
+
+ match('#');
+ if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
+ _token = makeToken(_ttype);
+ _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
+ }
+ _returnToken = _token;
+ }
+
+ public final void mHAT(boolean _createToken) throws RecognitionException,
CharStreamException, TokenStreamException {
+ int _ttype; Token _token=null; int _begin=text.length();
+ _ttype = HAT;
+ int _saveIndex;
+
+ match('^');
+ if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
+ _token = makeToken(_ttype);
+ _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
+ }
+ _returnToken = _token;
+ }
+
+ public final void mGT(boolean _createToken) throws RecognitionException,
CharStreamException, TokenStreamException {
+ int _ttype; Token _token=null; int _begin=text.length();
+ _ttype = GT;
+ int _saveIndex;
+
+ match('>');
+ if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
+ _token = makeToken(_ttype);
+ _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
+ }
+ _returnToken = _token;
+ }
+
+ public final void mLT(boolean _createToken) throws RecognitionException,
CharStreamException, TokenStreamException {
+ int _ttype; Token _token=null; int _begin=text.length();
+ _ttype = LT;
+ int _saveIndex;
+
+ match('<');
+ if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
+ _token = makeToken(_ttype);
+ _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
+ }
+ _returnToken = _token;
+ }
+
+ public final void mAMPERSAND(boolean _createToken) throws RecognitionException,
CharStreamException, TokenStreamException {
+ int _ttype; Token _token=null; int _begin=text.length();
+ _ttype = AMPERSAND;
+ int _saveIndex;
+
+ match('&');
+ if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
+ _token = makeToken(_ttype);
+ _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
+ }
+ _returnToken = _token;
+ }
+
+ public final void mSPACE(boolean _createToken) throws RecognitionException,
CharStreamException, TokenStreamException {
+ int _ttype; Token _token=null; int _begin=text.length();
+ _ttype = SPACE;
+ int _saveIndex;
+
+ {
+ int _cnt128=0;
+ _loop128:
+ do {
+ switch ( LA(1)) {
+ case ' ':
+ {
+ match(' ');
+ break;
+ }
+ case '\t':
+ {
+ match('\t');
+ break;
+ }
+ default:
+ {
+ if ( _cnt128>=1 ) { break _loop128; } else {throw new
NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());}
+ }
+ }
+ _cnt128++;
+ } while (true);
+ }
+ if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
+ _token = makeToken(_ttype);
+ _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
+ }
+ _returnToken = _token;
+ }
+
+ public final void mNEWLINE(boolean _createToken) throws RecognitionException,
CharStreamException, TokenStreamException {
+ int _ttype; Token _token=null; int _begin=text.length();
+ _ttype = NEWLINE;
+ int _saveIndex;
+
+ if ((LA(1)=='\r') && (LA(2)=='\n')) {
+ match("\r\n");
+ }
+ else if ((LA(1)=='\r') && (true)) {
+ match('\r');
+ }
+ else if ((LA(1)=='\n')) {
+ match('\n');
+ }
+ else {
+ throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(),
getColumn());
+ }
+
+ if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
+ _token = makeToken(_ttype);
+ _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
+ }
+ _returnToken = _token;
+ }
+
+ public final void mEOF(boolean _createToken) throws RecognitionException,
CharStreamException, TokenStreamException {
+ int _ttype; Token _token=null; int _begin=text.length();
+ _ttype = Token.EOF_TYPE;
+ int _saveIndex;
+
+ match('\uFFFF');
+ if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
+ _token = makeToken(_ttype);
+ _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
+ }
+ _returnToken = _token;
+ }
+
+
+ private static final long[] mk_tokenSet_0() {
+ long[] data = new long[4084];
+ data[0]=287948901175001088L;
+ data[1]=576460743847706622L;
+ data[2]=-4294967296L;
+ for (int i = 3; i<=1003; i++) { data[i]=-1L; }
+ for (int i = 1020; i<=1022; i++) { data[i]=-1L; }
+ data[1023]=281474976710655L;
+ return data;
+ }
+ public static final BitSet _tokenSet_0 = new BitSet(mk_tokenSet_0());
+
+ }
Added:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.seam/src/org/jboss/seam/text/SeamTextParser.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.seam/src/org/jboss/seam/text/SeamTextParser.java
(rev 0)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.seam/src/org/jboss/seam/text/SeamTextParser.java 2007-12-14
12:41:48 UTC (rev 5306)
@@ -0,0 +1,1828 @@
+// $ANTLR 2.7.6 (2005-12-22): "seam-text.g" ->
"SeamTextParser.java"$
+
+package org.jboss.seam.text;
+
+import antlr.TokenBuffer;
+import antlr.TokenStreamException;
+import antlr.TokenStreamIOException;
+import antlr.ANTLRException;
+import antlr.LLkParser;
+import antlr.Token;
+import antlr.TokenStream;
+import antlr.RecognitionException;
+import antlr.NoViableAltException;
+import antlr.MismatchedTokenException;
+import antlr.SemanticException;
+import antlr.ParserSharedInputState;
+import antlr.collections.impl.BitSet;
+
+public class SeamTextParser extends antlr.LLkParser implements
SeamTextParserTokenTypes
+ {
+
+ private java.util.Set htmlElements = new java.util.HashSet( java.util.Arrays.asList( new
String[] { "a", "p", "q", "code", "pre",
"table", "tr", "td", "th", "ul",
"ol", "li", "b", "i", "u",
"tt", "del", "em", "hr", "br",
"div", "span", "h1", "h2", "h3",
"h4", "img" , "object", "param",
"embed"} ) );
+ private java.util.Set htmlAttributes = new java.util.HashSet( java.util.Arrays.asList(
new String[] { "src", "href", "lang", "class",
"id", "style", "width", "height",
"name", "value", "type", "wmode" } ) );
+
+ private StringBuilder mainBuilder = new StringBuilder();
+ private StringBuilder builder = mainBuilder;
+
+ public String toString() {
+ return builder.toString();
+ }
+
+ private void append(String... strings) {
+ for (String string: strings) builder.append(string);
+ }
+
+ private static boolean hasMultiple(String string, char c) {
+ return string.indexOf(c)!=string.lastIndexOf(c);
+ }
+
+ private void validateElement(Token t) throws NoViableAltException {
+ if ( !htmlElements.contains( t.getText().toLowerCase() ) ) {
+ throw new NoViableAltException(t, null);
+ }
+ }
+
+ private void validateAttribute(Token t) throws NoViableAltException {
+ if ( !htmlAttributes.contains( t.getText().toLowerCase() ) ) {
+ throw new NoViableAltException(t, null);
+ }
+ }
+
+ private void beginCapture() {
+ builder = new StringBuilder();
+ }
+
+ private String endCapture() {
+ String result = builder.toString();
+ builder = mainBuilder;
+ return result;
+ }
+
+ protected String linkTag(String description, String url) {
+ return "<a href=\"" + url + "\"
styleClass=\"seamTextLink\">" + description + "</a>";
+ }
+
+ protected String macroInclude(String macroName) {
+ return "";
+ }
+
+protected SeamTextParser(TokenBuffer tokenBuf, int k) {
+ super(tokenBuf,k);
+ tokenNames = _tokenNames;
+}
+
+public SeamTextParser(TokenBuffer tokenBuf) {
+ this(tokenBuf,4);
+}
+
+protected SeamTextParser(TokenStream lexer, int k) {
+ super(lexer,k);
+ tokenNames = _tokenNames;
+}
+
+public SeamTextParser(TokenStream lexer) {
+ this(lexer,4);
+}
+
+public SeamTextParser(ParserSharedInputState state) {
+ super(state,4);
+ tokenNames = _tokenNames;
+}
+
+ public final void startRule() throws RecognitionException, TokenStreamException {
+
+
+ {
+ _loop3:
+ do {
+ if ((LA(1)==NEWLINE)) {
+ newline();
+ }
+ else {
+ break _loop3;
+ }
+
+ } while (true);
+ }
+ {
+ switch ( LA(1)) {
+ case DOUBLEQUOTE:
+ case BACKTICK:
+ case WORD:
+ case PUNCTUATION:
+ case ESCAPE:
+ case STAR:
+ case SLASH:
+ case BAR:
+ case HAT:
+ case PLUS:
+ case EQ:
+ case HASH:
+ case TWIDDLE:
+ case UNDERSCORE:
+ case OPEN:
+ case LT:
+ case SPACE:
+ {
+ {
+ switch ( LA(1)) {
+ case PLUS:
+ {
+ heading();
+ {
+ _loop7:
+ do {
+ if ((LA(1)==NEWLINE)) {
+ newline();
+ }
+ else {
+ break _loop7;
+ }
+
+ } while (true);
+ }
+ break;
+ }
+ case DOUBLEQUOTE:
+ case BACKTICK:
+ case WORD:
+ case PUNCTUATION:
+ case ESCAPE:
+ case STAR:
+ case SLASH:
+ case BAR:
+ case HAT:
+ case EQ:
+ case HASH:
+ case TWIDDLE:
+ case UNDERSCORE:
+ case OPEN:
+ case LT:
+ case SPACE:
+ {
+ break;
+ }
+ default:
+ {
+ throw new NoViableAltException(LT(1), getFilename());
+ }
+ }
+ }
+ text();
+ {
+ _loop11:
+ do {
+ if ((LA(1)==PLUS)) {
+ heading();
+ {
+ _loop10:
+ do {
+ if ((LA(1)==NEWLINE)) {
+ newline();
+ }
+ else {
+ break _loop10;
+ }
+
+ } while (true);
+ }
+ text();
+ }
+ else {
+ break _loop11;
+ }
+
+ } while (true);
+ }
+ break;
+ }
+ case EOF:
+ {
+ break;
+ }
+ default:
+ {
+ throw new NoViableAltException(LT(1), getFilename());
+ }
+ }
+ }
+ }
+
+ public final void newline() throws RecognitionException, TokenStreamException {
+
+ Token n = null;
+
+ n = LT(1);
+ match(NEWLINE);
+ append( n.getText() );
+ }
+
+ public final void heading() throws RecognitionException, TokenStreamException {
+
+
+ {
+ if ((LA(1)==PLUS) && (_tokenSet_0.member(LA(2)))) {
+ h1();
+ }
+ else if ((LA(1)==PLUS) && (LA(2)==PLUS) && (_tokenSet_0.member(LA(3))))
{
+ h2();
+ }
+ else if ((LA(1)==PLUS) && (LA(2)==PLUS) && (LA(3)==PLUS) &&
(_tokenSet_0.member(LA(4)))) {
+ h3();
+ }
+ else if ((LA(1)==PLUS) && (LA(2)==PLUS) && (LA(3)==PLUS) &&
(LA(4)==PLUS)) {
+ h4();
+ }
+ else {
+ throw new NoViableAltException(LT(1), getFilename());
+ }
+
+ }
+ newlineOrEof();
+ }
+
+ public final void text() throws RecognitionException, TokenStreamException {
+
+
+ {
+ int _cnt17=0;
+ _loop17:
+ do {
+ if ((_tokenSet_1.member(LA(1)))) {
+ {
+ switch ( LA(1)) {
+ case WORD:
+ case PUNCTUATION:
+ case ESCAPE:
+ case STAR:
+ case SLASH:
+ case BAR:
+ case HAT:
+ case TWIDDLE:
+ case UNDERSCORE:
+ case OPEN:
+ case SPACE:
+ {
+ paragraph();
+ break;
+ }
+ case BACKTICK:
+ {
+ preformatted();
+ break;
+ }
+ case DOUBLEQUOTE:
+ {
+ blockquote();
+ break;
+ }
+ case EQ:
+ case HASH:
+ {
+ list();
+ break;
+ }
+ case LT:
+ {
+ html();
+ break;
+ }
+ default:
+ {
+ throw new NoViableAltException(LT(1), getFilename());
+ }
+ }
+ }
+ {
+ _loop16:
+ do {
+ if ((LA(1)==NEWLINE)) {
+ newline();
+ }
+ else {
+ break _loop16;
+ }
+
+ } while (true);
+ }
+ }
+ else {
+ if ( _cnt17>=1 ) { break _loop17; } else {throw new NoViableAltException(LT(1),
getFilename());}
+ }
+
+ _cnt17++;
+ } while (true);
+ }
+ }
+
+ public final void paragraph() throws RecognitionException, TokenStreamException {
+
+
+ append("<p>\n");
+ {
+ int _cnt20=0;
+ _loop20:
+ do {
+ if ((_tokenSet_0.member(LA(1)))) {
+ line();
+ newlineOrEof();
+ }
+ else {
+ if ( _cnt20>=1 ) { break _loop20; } else {throw new NoViableAltException(LT(1),
getFilename());}
+ }
+
+ _cnt20++;
+ } while (true);
+ }
+ append("</p>\n");
+ newlineOrEof();
+ }
+
+ public final void preformatted() throws RecognitionException, TokenStreamException {
+
+
+ match(BACKTICK);
+ append("<pre>");
+ {
+ _loop30:
+ do {
+ switch ( LA(1)) {
+ case WORD:
+ {
+ word();
+ break;
+ }
+ case PUNCTUATION:
+ {
+ punctuation();
+ break;
+ }
+ case ESCAPE:
+ case STAR:
+ case SLASH:
+ case BAR:
+ case HAT:
+ case PLUS:
+ case EQ:
+ case HASH:
+ case TWIDDLE:
+ case UNDERSCORE:
+ {
+ specialChars();
+ break;
+ }
+ case OPEN:
+ case CLOSE:
+ {
+ moreSpecialChars();
+ break;
+ }
+ case DOUBLEQUOTE:
+ case GT:
+ case LT:
+ case AMPERSAND:
+ {
+ htmlSpecialChars();
+ break;
+ }
+ case SPACE:
+ {
+ space();
+ break;
+ }
+ case NEWLINE:
+ {
+ newline();
+ break;
+ }
+ default:
+ {
+ break _loop30;
+ }
+ }
+ } while (true);
+ }
+ match(BACKTICK);
+ append("</pre>");
+ }
+
+ public final void blockquote() throws RecognitionException, TokenStreamException {
+
+
+ match(DOUBLEQUOTE);
+ append("<blockquote>\n");
+ {
+ _loop27:
+ do {
+ switch ( LA(1)) {
+ case WORD:
+ case PUNCTUATION:
+ case ESCAPE:
+ case OPEN:
+ case SPACE:
+ {
+ plain();
+ break;
+ }
+ case STAR:
+ case SLASH:
+ case BAR:
+ case HAT:
+ case TWIDDLE:
+ case UNDERSCORE:
+ {
+ formatted();
+ break;
+ }
+ case BACKTICK:
+ {
+ preformatted();
+ break;
+ }
+ case NEWLINE:
+ {
+ newline();
+ break;
+ }
+ case LT:
+ {
+ html();
+ break;
+ }
+ case EQ:
+ case HASH:
+ {
+ list();
+ break;
+ }
+ default:
+ {
+ break _loop27;
+ }
+ }
+ } while (true);
+ }
+ match(DOUBLEQUOTE);
+ newlineOrEof();
+ append("</blockquote>\n");
+ }
+
+ public final void list() throws RecognitionException, TokenStreamException {
+
+
+ {
+ switch ( LA(1)) {
+ case HASH:
+ {
+ olist();
+ break;
+ }
+ case EQ:
+ {
+ ulist();
+ break;
+ }
+ default:
+ {
+ throw new NoViableAltException(LT(1), getFilename());
+ }
+ }
+ }
+ newlineOrEof();
+ }
+
+ public final void html() throws RecognitionException, TokenStreamException {
+
+
+ openTag();
+ {
+ _loop87:
+ do {
+ if ((LA(1)==SPACE) && (LA(2)==SLASH||LA(2)==GT||LA(2)==SPACE)) {
+ space();
+ }
+ else if ((LA(1)==SPACE) && (LA(2)==WORD)) {
+ space();
+ attribute();
+ }
+ else {
+ break _loop87;
+ }
+
+ } while (true);
+ }
+ {
+ switch ( LA(1)) {
+ case GT:
+ {
+ {
+ beforeBody();
+ body();
+ closeTagWithBody();
+ }
+ break;
+ }
+ case SLASH:
+ {
+ closeTagWithNoBody();
+ break;
+ }
+ default:
+ {
+ throw new NoViableAltException(LT(1), getFilename());
+ }
+ }
+ }
+ }
+
+ public final void line() throws RecognitionException, TokenStreamException {
+
+
+ {
+ switch ( LA(1)) {
+ case WORD:
+ case PUNCTUATION:
+ case ESCAPE:
+ case OPEN:
+ case SPACE:
+ {
+ plain();
+ break;
+ }
+ case STAR:
+ case SLASH:
+ case BAR:
+ case HAT:
+ case TWIDDLE:
+ case UNDERSCORE:
+ {
+ formatted();
+ break;
+ }
+ default:
+ {
+ throw new NoViableAltException(LT(1), getFilename());
+ }
+ }
+ }
+ {
+ _loop24:
+ do {
+ switch ( LA(1)) {
+ case WORD:
+ case PUNCTUATION:
+ case ESCAPE:
+ case OPEN:
+ case SPACE:
+ {
+ plain();
+ break;
+ }
+ case STAR:
+ case SLASH:
+ case BAR:
+ case HAT:
+ case TWIDDLE:
+ case UNDERSCORE:
+ {
+ formatted();
+ break;
+ }
+ case BACKTICK:
+ {
+ preformatted();
+ break;
+ }
+ case DOUBLEQUOTE:
+ {
+ quoted();
+ break;
+ }
+ case LT:
+ {
+ html();
+ break;
+ }
+ default:
+ {
+ break _loop24;
+ }
+ }
+ } while (true);
+ }
+ }
+
+ public final void newlineOrEof() throws RecognitionException, TokenStreamException {
+
+
+ switch ( LA(1)) {
+ case NEWLINE:
+ {
+ newline();
+ break;
+ }
+ case EOF:
+ {
+ match(Token.EOF_TYPE);
+ break;
+ }
+ default:
+ {
+ throw new NoViableAltException(LT(1), getFilename());
+ }
+ }
+ }
+
+ public final void plain() throws RecognitionException, TokenStreamException {
+
+
+ switch ( LA(1)) {
+ case WORD:
+ {
+ word();
+ break;
+ }
+ case PUNCTUATION:
+ {
+ punctuation();
+ break;
+ }
+ case ESCAPE:
+ {
+ escape();
+ break;
+ }
+ case SPACE:
+ {
+ space();
+ break;
+ }
+ default:
+ if ((LA(1)==OPEN) && (_tokenSet_2.member(LA(2)))) {
+ link();
+ }
+ else if ((LA(1)==OPEN) && (LA(2)==LT)) {
+ macro();
+ }
+ else {
+ throw new NoViableAltException(LT(1), getFilename());
+ }
+ }
+ }
+
+ public final void formatted() throws RecognitionException, TokenStreamException {
+
+
+ switch ( LA(1)) {
+ case STAR:
+ {
+ bold();
+ break;
+ }
+ case UNDERSCORE:
+ {
+ underline();
+ break;
+ }
+ case SLASH:
+ {
+ italic();
+ break;
+ }
+ case BAR:
+ {
+ monospace();
+ break;
+ }
+ case HAT:
+ {
+ superscript();
+ break;
+ }
+ case TWIDDLE:
+ {
+ deleted();
+ break;
+ }
+ default:
+ {
+ throw new NoViableAltException(LT(1), getFilename());
+ }
+ }
+ }
+
+ public final void quoted() throws RecognitionException, TokenStreamException {
+
+
+ match(DOUBLEQUOTE);
+ append("<q>");
+ {
+ int _cnt65=0;
+ _loop65:
+ do {
+ switch ( LA(1)) {
+ case WORD:
+ case PUNCTUATION:
+ case ESCAPE:
+ case OPEN:
+ case SPACE:
+ {
+ plain();
+ break;
+ }
+ case STAR:
+ {
+ bold();
+ break;
+ }
+ case UNDERSCORE:
+ {
+ underline();
+ break;
+ }
+ case SLASH:
+ {
+ italic();
+ break;
+ }
+ case BAR:
+ {
+ monospace();
+ break;
+ }
+ case HAT:
+ {
+ superscript();
+ break;
+ }
+ case TWIDDLE:
+ {
+ deleted();
+ break;
+ }
+ case NEWLINE:
+ {
+ newline();
+ break;
+ }
+ default:
+ {
+ if ( _cnt65>=1 ) { break _loop65; } else {throw new NoViableAltException(LT(1),
getFilename());}
+ }
+ }
+ _cnt65++;
+ } while (true);
+ }
+ match(DOUBLEQUOTE);
+ append("</q>");
+ }
+
+ public final void word() throws RecognitionException, TokenStreamException {
+
+ Token w = null;
+
+ w = LT(1);
+ match(WORD);
+ append( w.getText() );
+ }
+
+ public final void punctuation() throws RecognitionException, TokenStreamException {
+
+ Token p = null;
+
+ p = LT(1);
+ match(PUNCTUATION);
+ append( p.getText() );
+ }
+
+ public final void specialChars() throws RecognitionException, TokenStreamException {
+
+ Token st = null;
+ Token sl = null;
+ Token b = null;
+ Token h = null;
+ Token p = null;
+ Token eq = null;
+ Token hh = null;
+ Token e = null;
+ Token t = null;
+ Token u = null;
+
+ switch ( LA(1)) {
+ case STAR:
+ {
+ st = LT(1);
+ match(STAR);
+ append( st.getText() );
+ break;
+ }
+ case SLASH:
+ {
+ sl = LT(1);
+ match(SLASH);
+ append( sl.getText() );
+ break;
+ }
+ case BAR:
+ {
+ b = LT(1);
+ match(BAR);
+ append( b.getText() );
+ break;
+ }
+ case HAT:
+ {
+ h = LT(1);
+ match(HAT);
+ append( h.getText() );
+ break;
+ }
+ case PLUS:
+ {
+ p = LT(1);
+ match(PLUS);
+ append( p.getText() );
+ break;
+ }
+ case EQ:
+ {
+ eq = LT(1);
+ match(EQ);
+ append( eq.getText() );
+ break;
+ }
+ case HASH:
+ {
+ hh = LT(1);
+ match(HASH);
+ append( hh.getText() );
+ break;
+ }
+ case ESCAPE:
+ {
+ e = LT(1);
+ match(ESCAPE);
+ append( e.getText() );
+ break;
+ }
+ case TWIDDLE:
+ {
+ t = LT(1);
+ match(TWIDDLE);
+ append( t.getText() );
+ break;
+ }
+ case UNDERSCORE:
+ {
+ u = LT(1);
+ match(UNDERSCORE);
+ append( u.getText() );
+ break;
+ }
+ default:
+ {
+ throw new NoViableAltException(LT(1), getFilename());
+ }
+ }
+ }
+
+ public final void moreSpecialChars() throws RecognitionException, TokenStreamException
{
+
+ Token o = null;
+ Token c = null;
+
+ switch ( LA(1)) {
+ case OPEN:
+ {
+ o = LT(1);
+ match(OPEN);
+ append( o.getText() );
+ break;
+ }
+ case CLOSE:
+ {
+ c = LT(1);
+ match(CLOSE);
+ append( c.getText() );
+ break;
+ }
+ default:
+ {
+ throw new NoViableAltException(LT(1), getFilename());
+ }
+ }
+ }
+
+ public final void htmlSpecialChars() throws RecognitionException, TokenStreamException
{
+
+
+ switch ( LA(1)) {
+ case GT:
+ {
+ match(GT);
+ append(">");
+ break;
+ }
+ case LT:
+ {
+ match(LT);
+ append("<");
+ break;
+ }
+ case DOUBLEQUOTE:
+ {
+ match(DOUBLEQUOTE);
+ append(""");
+ break;
+ }
+ case AMPERSAND:
+ {
+ match(AMPERSAND);
+ append("&");
+ break;
+ }
+ default:
+ {
+ throw new NoViableAltException(LT(1), getFilename());
+ }
+ }
+ }
+
+ public final void space() throws RecognitionException, TokenStreamException {
+
+ Token s = null;
+
+ s = LT(1);
+ match(SPACE);
+ append( s.getText() );
+ }
+
+ public final void escape() throws RecognitionException, TokenStreamException {
+
+
+ match(ESCAPE);
+ {
+ switch ( LA(1)) {
+ case ESCAPE:
+ case STAR:
+ case SLASH:
+ case BAR:
+ case HAT:
+ case PLUS:
+ case EQ:
+ case HASH:
+ case TWIDDLE:
+ case UNDERSCORE:
+ {
+ specialChars();
+ break;
+ }
+ case OPEN:
+ case CLOSE:
+ {
+ moreSpecialChars();
+ break;
+ }
+ case QUOTE:
+ {
+ evenMoreSpecialChars();
+ break;
+ }
+ case DOUBLEQUOTE:
+ case GT:
+ case LT:
+ case AMPERSAND:
+ {
+ htmlSpecialChars();
+ break;
+ }
+ default:
+ {
+ throw new NoViableAltException(LT(1), getFilename());
+ }
+ }
+ }
+ }
+
+ public final void link() throws RecognitionException, TokenStreamException {
+
+
+ match(OPEN);
+ beginCapture();
+ {
+ _loop43:
+ do {
+ if ((_tokenSet_3.member(LA(1)))) {
+ plain();
+ }
+ else {
+ break _loop43;
+ }
+
+ } while (true);
+ }
+ String text=endCapture();
+ match(EQ);
+ match(GT);
+ beginCapture();
+ attributeValue();
+ String link = endCapture(); append(linkTag(text, link));
+ match(CLOSE);
+ }
+
+ public final void macro() throws RecognitionException, TokenStreamException {
+
+
+ match(OPEN);
+ match(LT);
+ match(EQ);
+ beginCapture();
+ attributeValue();
+ String macroName = endCapture(); append(macroInclude(macroName));
+ match(CLOSE);
+ }
+
+ public final void bold() throws RecognitionException, TokenStreamException {
+
+
+ match(STAR);
+ append("<b>");
+ {
+ int _cnt47=0;
+ _loop47:
+ do {
+ switch ( LA(1)) {
+ case WORD:
+ case PUNCTUATION:
+ case ESCAPE:
+ case OPEN:
+ case SPACE:
+ {
+ plain();
+ break;
+ }
+ case UNDERSCORE:
+ {
+ underline();
+ break;
+ }
+ case SLASH:
+ {
+ italic();
+ break;
+ }
+ case BAR:
+ {
+ monospace();
+ break;
+ }
+ case HAT:
+ {
+ superscript();
+ break;
+ }
+ case TWIDDLE:
+ {
+ deleted();
+ break;
+ }
+ case NEWLINE:
+ {
+ newline();
+ break;
+ }
+ default:
+ {
+ if ( _cnt47>=1 ) { break _loop47; } else {throw new NoViableAltException(LT(1),
getFilename());}
+ }
+ }
+ _cnt47++;
+ } while (true);
+ }
+ match(STAR);
+ append("</b>");
+ }
+
+ public final void underline() throws RecognitionException, TokenStreamException {
+
+
+ match(UNDERSCORE);
+ append("<u>");
+ {
+ int _cnt50=0;
+ _loop50:
+ do {
+ switch ( LA(1)) {
+ case WORD:
+ case PUNCTUATION:
+ case ESCAPE:
+ case OPEN:
+ case SPACE:
+ {
+ plain();
+ break;
+ }
+ case STAR:
+ {
+ bold();
+ break;
+ }
+ case SLASH:
+ {
+ italic();
+ break;
+ }
+ case BAR:
+ {
+ monospace();
+ break;
+ }
+ case HAT:
+ {
+ superscript();
+ break;
+ }
+ case TWIDDLE:
+ {
+ deleted();
+ break;
+ }
+ case NEWLINE:
+ {
+ newline();
+ break;
+ }
+ default:
+ {
+ if ( _cnt50>=1 ) { break _loop50; } else {throw new NoViableAltException(LT(1),
getFilename());}
+ }
+ }
+ _cnt50++;
+ } while (true);
+ }
+ match(UNDERSCORE);
+ append("</u>");
+ }
+
+ public final void italic() throws RecognitionException, TokenStreamException {
+
+
+ match(SLASH);
+ append("<i>");
+ {
+ int _cnt53=0;
+ _loop53:
+ do {
+ switch ( LA(1)) {
+ case WORD:
+ case PUNCTUATION:
+ case ESCAPE:
+ case OPEN:
+ case SPACE:
+ {
+ plain();
+ break;
+ }
+ case STAR:
+ {
+ bold();
+ break;
+ }
+ case UNDERSCORE:
+ {
+ underline();
+ break;
+ }
+ case BAR:
+ {
+ monospace();
+ break;
+ }
+ case HAT:
+ {
+ superscript();
+ break;
+ }
+ case TWIDDLE:
+ {
+ deleted();
+ break;
+ }
+ case NEWLINE:
+ {
+ newline();
+ break;
+ }
+ default:
+ {
+ if ( _cnt53>=1 ) { break _loop53; } else {throw new NoViableAltException(LT(1),
getFilename());}
+ }
+ }
+ _cnt53++;
+ } while (true);
+ }
+ match(SLASH);
+ append("</i>");
+ }
+
+ public final void monospace() throws RecognitionException, TokenStreamException {
+
+ Token st = null;
+ Token sl = null;
+ Token h = null;
+ Token p = null;
+ Token eq = null;
+ Token hh = null;
+ Token e = null;
+ Token t = null;
+ Token u = null;
+
+ match(BAR);
+ append("<tt>");
+ {
+ int _cnt56=0;
+ _loop56:
+ do {
+ switch ( LA(1)) {
+ case WORD:
+ {
+ word();
+ break;
+ }
+ case PUNCTUATION:
+ {
+ punctuation();
+ break;
+ }
+ case SPACE:
+ {
+ space();
+ break;
+ }
+ case STAR:
+ {
+ st = LT(1);
+ match(STAR);
+ append( st.getText() );
+ break;
+ }
+ case SLASH:
+ {
+ sl = LT(1);
+ match(SLASH);
+ append( sl.getText() );
+ break;
+ }
+ case HAT:
+ {
+ h = LT(1);
+ match(HAT);
+ append( h.getText() );
+ break;
+ }
+ case PLUS:
+ {
+ p = LT(1);
+ match(PLUS);
+ append( p.getText() );
+ break;
+ }
+ case EQ:
+ {
+ eq = LT(1);
+ match(EQ);
+ append( eq.getText() );
+ break;
+ }
+ case HASH:
+ {
+ hh = LT(1);
+ match(HASH);
+ append( hh.getText() );
+ break;
+ }
+ case ESCAPE:
+ {
+ e = LT(1);
+ match(ESCAPE);
+ append( e.getText() );
+ break;
+ }
+ case TWIDDLE:
+ {
+ t = LT(1);
+ match(TWIDDLE);
+ append( t.getText() );
+ break;
+ }
+ case UNDERSCORE:
+ {
+ u = LT(1);
+ match(UNDERSCORE);
+ append( u.getText() );
+ break;
+ }
+ case OPEN:
+ case CLOSE:
+ {
+ moreSpecialChars();
+ break;
+ }
+ case DOUBLEQUOTE:
+ case GT:
+ case LT:
+ case AMPERSAND:
+ {
+ htmlSpecialChars();
+ break;
+ }
+ case NEWLINE:
+ {
+ newline();
+ break;
+ }
+ default:
+ {
+ if ( _cnt56>=1 ) { break _loop56; } else {throw new NoViableAltException(LT(1),
getFilename());}
+ }
+ }
+ _cnt56++;
+ } while (true);
+ }
+ match(BAR);
+ append("</tt>");
+ }
+
+ public final void superscript() throws RecognitionException, TokenStreamException {
+
+
+ match(HAT);
+ append("<sup>");
+ {
+ int _cnt59=0;
+ _loop59:
+ do {
+ switch ( LA(1)) {
+ case WORD:
+ case PUNCTUATION:
+ case ESCAPE:
+ case OPEN:
+ case SPACE:
+ {
+ plain();
+ break;
+ }
+ case STAR:
+ {
+ bold();
+ break;
+ }
+ case UNDERSCORE:
+ {
+ underline();
+ break;
+ }
+ case SLASH:
+ {
+ italic();
+ break;
+ }
+ case BAR:
+ {
+ monospace();
+ break;
+ }
+ case TWIDDLE:
+ {
+ deleted();
+ break;
+ }
+ case NEWLINE:
+ {
+ newline();
+ break;
+ }
+ default:
+ {
+ if ( _cnt59>=1 ) { break _loop59; } else {throw new NoViableAltException(LT(1),
getFilename());}
+ }
+ }
+ _cnt59++;
+ } while (true);
+ }
+ match(HAT);
+ append("</sup>");
+ }
+
+ public final void deleted() throws RecognitionException, TokenStreamException {
+
+
+ match(TWIDDLE);
+ append("<del>");
+ {
+ int _cnt62=0;
+ _loop62:
+ do {
+ switch ( LA(1)) {
+ case WORD:
+ case PUNCTUATION:
+ case ESCAPE:
+ case OPEN:
+ case SPACE:
+ {
+ plain();
+ break;
+ }
+ case STAR:
+ {
+ bold();
+ break;
+ }
+ case UNDERSCORE:
+ {
+ underline();
+ break;
+ }
+ case SLASH:
+ {
+ italic();
+ break;
+ }
+ case BAR:
+ {
+ monospace();
+ break;
+ }
+ case HAT:
+ {
+ superscript();
+ break;
+ }
+ case NEWLINE:
+ {
+ newline();
+ break;
+ }
+ default:
+ {
+ if ( _cnt62>=1 ) { break _loop62; } else {throw new NoViableAltException(LT(1),
getFilename());}
+ }
+ }
+ _cnt62++;
+ } while (true);
+ }
+ match(TWIDDLE);
+ append("</del>");
+ }
+
+ public final void evenMoreSpecialChars() throws RecognitionException,
TokenStreamException {
+
+ Token q = null;
+
+ q = LT(1);
+ match(QUOTE);
+ append( q.getText() );
+ }
+
+ public final void attributeValue() throws RecognitionException, TokenStreamException {
+
+
+ {
+ _loop104:
+ do {
+ switch ( LA(1)) {
+ case AMPERSAND:
+ {
+ match(AMPERSAND);
+ append("&");
+ break;
+ }
+ case WORD:
+ {
+ word();
+ break;
+ }
+ case PUNCTUATION:
+ {
+ punctuation();
+ break;
+ }
+ case SPACE:
+ {
+ space();
+ break;
+ }
+ case ESCAPE:
+ case STAR:
+ case SLASH:
+ case BAR:
+ case HAT:
+ case PLUS:
+ case EQ:
+ case HASH:
+ case TWIDDLE:
+ case UNDERSCORE:
+ {
+ specialChars();
+ break;
+ }
+ default:
+ {
+ break _loop104;
+ }
+ }
+ } while (true);
+ }
+ }
+
+ public final void h1() throws RecognitionException, TokenStreamException {
+
+
+ match(PLUS);
+ append("<h1>");
+ line();
+ append("</h1>");
+ }
+
+ public final void h2() throws RecognitionException, TokenStreamException {
+
+
+ match(PLUS);
+ match(PLUS);
+ append("<h2>");
+ line();
+ append("</h2>");
+ }
+
+ public final void h3() throws RecognitionException, TokenStreamException {
+
+
+ match(PLUS);
+ match(PLUS);
+ match(PLUS);
+ append("<h3>");
+ line();
+ append("</h3>");
+ }
+
+ public final void h4() throws RecognitionException, TokenStreamException {
+
+
+ match(PLUS);
+ match(PLUS);
+ match(PLUS);
+ match(PLUS);
+ append("<h4>");
+ line();
+ append("</h4>");
+ }
+
+ public final void olist() throws RecognitionException, TokenStreamException {
+
+
+ append("<ol>\n");
+ {
+ int _cnt76=0;
+ _loop76:
+ do {
+ if ((LA(1)==HASH)) {
+ olistLine();
+ newlineOrEof();
+ }
+ else {
+ if ( _cnt76>=1 ) { break _loop76; } else {throw new NoViableAltException(LT(1),
getFilename());}
+ }
+
+ _cnt76++;
+ } while (true);
+ }
+ append("</ol>\n");
+ }
+
+ public final void ulist() throws RecognitionException, TokenStreamException {
+
+
+ append("<ul>\n");
+ {
+ int _cnt80=0;
+ _loop80:
+ do {
+ if ((LA(1)==EQ)) {
+ ulistLine();
+ newlineOrEof();
+ }
+ else {
+ if ( _cnt80>=1 ) { break _loop80; } else {throw new NoViableAltException(LT(1),
getFilename());}
+ }
+
+ _cnt80++;
+ } while (true);
+ }
+ append("</ul>\n");
+ }
+
+ public final void olistLine() throws RecognitionException, TokenStreamException {
+
+
+ match(HASH);
+ append("<li>");
+ line();
+ append("</li>");
+ }
+
+ public final void ulistLine() throws RecognitionException, TokenStreamException {
+
+
+ match(EQ);
+ append("<li>");
+ line();
+ append("</li>");
+ }
+
+ public final void openTag() throws RecognitionException, TokenStreamException {
+
+ Token name = null;
+
+ match(LT);
+ name = LT(1);
+ match(WORD);
+ validateElement(name); append("<"); append(name.getText());
+ }
+
+ public final void attribute() throws RecognitionException, TokenStreamException {
+
+ Token att = null;
+
+ att = LT(1);
+ match(WORD);
+ {
+ _loop99:
+ do {
+ if ((LA(1)==SPACE)) {
+ space();
+ }
+ else {
+ break _loop99;
+ }
+
+ } while (true);
+ }
+ match(EQ);
+ {
+ _loop101:
+ do {
+ if ((LA(1)==SPACE)) {
+ space();
+ }
+ else {
+ break _loop101;
+ }
+
+ } while (true);
+ }
+ match(DOUBLEQUOTE);
+ validateAttribute(att); append(att.getText()); append("=\"");
+ attributeValue();
+ match(DOUBLEQUOTE);
+ append("\"");
+ }
+
+ public final void beforeBody() throws RecognitionException, TokenStreamException {
+
+
+ match(GT);
+ append(">");
+ }
+
+ public final void body() throws RecognitionException, TokenStreamException {
+
+
+ {
+ _loop92:
+ do {
+ switch ( LA(1)) {
+ case WORD:
+ case PUNCTUATION:
+ case ESCAPE:
+ case OPEN:
+ case SPACE:
+ {
+ plain();
+ break;
+ }
+ case STAR:
+ case SLASH:
+ case BAR:
+ case HAT:
+ case TWIDDLE:
+ case UNDERSCORE:
+ {
+ formatted();
+ break;
+ }
+ case BACKTICK:
+ {
+ preformatted();
+ break;
+ }
+ case DOUBLEQUOTE:
+ {
+ quoted();
+ break;
+ }
+ case EQ:
+ case HASH:
+ {
+ list();
+ break;
+ }
+ case NEWLINE:
+ {
+ newline();
+ break;
+ }
+ default:
+ if ((LA(1)==LT) && (LA(2)==WORD)) {
+ html();
+ }
+ else {
+ break _loop92;
+ }
+ }
+ } while (true);
+ }
+ }
+
+ public final void closeTagWithBody() throws RecognitionException, TokenStreamException
{
+
+ Token name = null;
+
+ match(LT);
+ match(SLASH);
+ name = LT(1);
+ match(WORD);
+ match(GT);
+ append("</"); append(name.getText()); append(">");
+ }
+
+ public final void closeTagWithNoBody() throws RecognitionException, TokenStreamException
{
+
+
+ match(SLASH);
+ match(GT);
+ append("/>");
+ }
+
+
+ public static final String[] _tokenNames = {
+ "<0>",
+ "EOF",
+ "<2>",
+ "NULL_TREE_LOOKAHEAD",
+ "DOUBLEQUOTE",
+ "BACKTICK",
+ "WORD",
+ "PUNCTUATION",
+ "ESCAPE",
+ "STAR",
+ "SLASH",
+ "BAR",
+ "HAT",
+ "PLUS",
+ "EQ",
+ "HASH",
+ "TWIDDLE",
+ "UNDERSCORE",
+ "OPEN",
+ "CLOSE",
+ "QUOTE",
+ "GT",
+ "LT",
+ "AMPERSAND",
+ "SPACE",
+ "NEWLINE"
+ };
+
+ private static final long[] mk_tokenSet_0() {
+ long[] data = { 17244096L, 0L};
+ return data;
+ }
+ public static final BitSet _tokenSet_0 = new BitSet(mk_tokenSet_0());
+ private static final long[] mk_tokenSet_1() {
+ long[] data = { 21487600L, 0L};
+ return data;
+ }
+ public static final BitSet _tokenSet_1 = new BitSet(mk_tokenSet_1());
+ private static final long[] mk_tokenSet_2() {
+ long[] data = { 17056192L, 0L};
+ return data;
+ }
+ public static final BitSet _tokenSet_2 = new BitSet(mk_tokenSet_2());
+ private static final long[] mk_tokenSet_3() {
+ long[] data = { 17039808L, 0L};
+ return data;
+ }
+ public static final BitSet _tokenSet_3 = new BitSet(mk_tokenSet_3());
+
+ }
Added:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.seam/src/org/jboss/seam/text/SeamTextParserTokenTypes.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.seam/src/org/jboss/seam/text/SeamTextParserTokenTypes.java
(rev 0)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.seam/src/org/jboss/seam/text/SeamTextParserTokenTypes.java 2007-12-14
12:41:48 UTC (rev 5306)
@@ -0,0 +1,30 @@
+// $ANTLR 2.7.6 (2005-12-22): "seam-text.g" ->
"SeamTextLexer.java"$
+
+package org.jboss.seam.text;
+
+public interface SeamTextParserTokenTypes {
+ int EOF = 1;
+ int NULL_TREE_LOOKAHEAD = 3;
+ int DOUBLEQUOTE = 4;
+ int BACKTICK = 5;
+ int WORD = 6;
+ int PUNCTUATION = 7;
+ int ESCAPE = 8;
+ int STAR = 9;
+ int SLASH = 10;
+ int BAR = 11;
+ int HAT = 12;
+ int PLUS = 13;
+ int EQ = 14;
+ int HASH = 15;
+ int TWIDDLE = 16;
+ int UNDERSCORE = 17;
+ int OPEN = 18;
+ int CLOSE = 19;
+ int QUOTE = 20;
+ int GT = 21;
+ int LT = 22;
+ int AMPERSAND = 23;
+ int SPACE = 24;
+ int NEWLINE = 25;
+}
Added:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.seam/src/org/jboss/seam/text/SeamTextParserTokenTypes.txt
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.seam/src/org/jboss/seam/text/SeamTextParserTokenTypes.txt
(rev 0)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.seam/src/org/jboss/seam/text/SeamTextParserTokenTypes.txt 2007-12-14
12:41:48 UTC (rev 5306)
@@ -0,0 +1,24 @@
+// $ANTLR 2.7.6 (2005-12-22): seam-text.g -> SeamTextParserTokenTypes.txt$
+SeamTextParser // output token vocab name
+DOUBLEQUOTE=4
+BACKTICK=5
+WORD=6
+PUNCTUATION=7
+ESCAPE=8
+STAR=9
+SLASH=10
+BAR=11
+HAT=12
+PLUS=13
+EQ=14
+HASH=15
+TWIDDLE=16
+UNDERSCORE=17
+OPEN=18
+CLOSE=19
+QUOTE=20
+GT=21
+LT=22
+AMPERSAND=23
+SPACE=24
+NEWLINE=25
Added:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.seam/src/org/jboss/tools/jsf/vpe/seam/ComponentUtil.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.seam/src/org/jboss/tools/jsf/vpe/seam/ComponentUtil.java
(rev 0)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.seam/src/org/jboss/tools/jsf/vpe/seam/ComponentUtil.java 2007-12-14
12:41:48 UTC (rev 5306)
@@ -0,0 +1,25 @@
+package org.jboss.tools.jsf.vpe.seam;
+
+import org.mozilla.interfaces.nsIDOMElement;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+
+public class ComponentUtil {
+
+ /**
+ * Copies all attributes from source node to visual node.
+ *
+ * @param sourceNode
+ * @param visualNode
+ */
+ public static void copyAttributes(Node sourceNode,
+ nsIDOMElement visualElement) {
+ NamedNodeMap namedNodeMap = sourceNode.getAttributes();
+ for (int i = 0; i < namedNodeMap.getLength(); i++) {
+ Node attribute = namedNodeMap.item(i);
+ visualElement.setAttribute(attribute.getNodeName(), attribute
+ .getNodeValue());
+ }
+ }
+
+}
Added:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.seam/src/org/jboss/tools/jsf/vpe/seam/SeamTemplatesActivator.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.seam/src/org/jboss/tools/jsf/vpe/seam/SeamTemplatesActivator.java
(rev 0)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.seam/src/org/jboss/tools/jsf/vpe/seam/SeamTemplatesActivator.java 2007-12-14
12:41:48 UTC (rev 5306)
@@ -0,0 +1,82 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.jsf.vpe.seam;
+
+import java.net.URL;
+
+import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.core.runtime.Platform;
+import org.jboss.tools.common.log.BaseUIPlugin;
+import org.jboss.tools.common.log.IPluginLog;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The activator class controls the plug-in life cycle
+ */
+public class SeamTemplatesActivator extends BaseUIPlugin {
+
+ // The plug-in ID
+ public static final String PLUGIN_ID = "org.jboss.tools.jsf.vpe.seam";
+
+ // The shared instance
+ private static SeamTemplatesActivator plugin;
+
+ /**
+ * The constructor
+ */
+ public SeamTemplatesActivator() {
+ plugin = this;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
+ */
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
+ */
+ public void stop(BundleContext context) throws Exception {
+ plugin = null;
+ super.stop(context);
+ }
+
+ /**
+ * Returns the shared instance
+ *
+ * @return the shared instance
+ */
+ public static SeamTemplatesActivator getDefault() {
+ return plugin;
+ }
+
+ /** /
+ public static String getPluginResourcePath() {
+ Bundle bundle = Platform.getBundle(PLUGIN_ID);
+ URL url = null;
+ try {
+ url = bundle == null ? null :
FileLocator.resolve(bundle.getEntry("/resources"));
+ } catch (Exception e) {
+ url = bundle.getEntry("/resources");
+ }
+ return (url == null) ? null : url.getPath();
+ }
+ /**/
+
+ public static IPluginLog getPluginLog() {
+ return getDefault();
+ }
+}
Added:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.seam/src/org/jboss/tools/jsf/vpe/seam/template/SeamFormattedTextTemplate.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.seam/src/org/jboss/tools/jsf/vpe/seam/template/SeamFormattedTextTemplate.java
(rev 0)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.seam/src/org/jboss/tools/jsf/vpe/seam/template/SeamFormattedTextTemplate.java 2007-12-14
12:41:48 UTC (rev 5306)
@@ -0,0 +1,138 @@
+package org.jboss.tools.jsf.vpe.seam.template;
+
+import java.io.InputStreamReader;
+import java.io.Reader;
+import java.io.StringReader;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jboss.seam.test.unit.SeamTextTest;
+import org.jboss.seam.text.SeamTextLexer;
+import org.jboss.seam.text.SeamTextParser;
+import org.jboss.tools.jsf.vpe.seam.ComponentUtil;
+import org.jboss.tools.jsf.vpe.seam.SeamTemplatesActivator;
+import org.jboss.tools.vpe.editor.context.VpePageContext;
+import org.jboss.tools.vpe.editor.template.VpeAbstractTemplate;
+import org.jboss.tools.vpe.editor.template.VpeChildrenInfo;
+import org.jboss.tools.vpe.editor.template.VpeCreationData;
+import org.mozilla.interfaces.nsIComponentManager;
+import org.mozilla.interfaces.nsIDOMDocument;
+import org.mozilla.interfaces.nsIDOMDocumentRange;
+import org.mozilla.interfaces.nsIDOMElement;
+import org.mozilla.interfaces.nsIDOMNode;
+import org.mozilla.interfaces.nsIDOMNodeList;
+import org.mozilla.interfaces.nsIDOMParser;
+import org.mozilla.interfaces.nsIDOMText;
+import org.mozilla.interfaces.nsISupportsArray;
+import org.mozilla.xpcom.Mozilla;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+import antlr.RecognitionException;
+import antlr.TokenStreamException;
+
+public class SeamFormattedTextTemplate extends VpeAbstractTemplate {
+
+ private static final String CID_DOMPARSER =
"(a)mozilla.org/xmlextras/domparser;1";
+
+ /**
+ * component manager
+ */
+ private nsIComponentManager componentManager;
+
+ /**
+ * Creates a node of the visual tree on the node of the source tree. This
+ * visual node should not have the parent node This visual node can have
+ * child nodes.
+ *
+ * @param pageContext
+ * Contains the information on edited page.
+ * @param sourceNode
+ * The current node of the source tree.
+ * @param visualDocument
+ * The document of the visual tree.
+ * @return The information on the created node of the visual tree.
+ */
+ public VpeCreationData create(VpePageContext pageContext, Node sourceNode,
+ nsIDOMDocument visualDocument) {
+
+ Element sourceElement = (Element) sourceNode;
+ String valueT = sourceElement.getAttribute("value");
+ // complex test case:
+ //Reader r = new InputStreamReader(
SeamFormattedTextTemplate.class.getResourceAsStream("SeamTextTest2.txt") );
+ StringReader r = new StringReader(valueT);
+ SeamTextLexer lexer = new SeamTextLexer(r);
+ SeamTextParser parser = new SeamTextParser(lexer);
+ try {
+ parser.startRule();
+ } catch (RecognitionException e) {
+ SeamTemplatesActivator.getPluginLog().logError(e);
+ } catch (TokenStreamException e) {
+ SeamTemplatesActivator.getPluginLog().logError(e);
+ }
+ nsIDOMParser parserDom = null;
+ try {
+ parserDom = (nsIDOMParser)getComponentManager().
+ createInstanceByContractID(CID_DOMPARSER, null,
nsIDOMParser.NS_IDOMPARSER_IID);
+ } catch (Exception e) {
+ SeamTemplatesActivator.getPluginLog().logError(e);
+ }
+ String strDoc = "<HTML><BODY>" + parser.toString() +
"</BODY></HTML>";
+ nsIDOMDocument domDoc = null != parserDom ? parserDom.parseFromString(strDoc,
"application/xhtml+xml") : null;
+ nsIDOMNode patronItem = null, nodeTmp = null;
+ nsIDOMNodeList list = null;
+ if (null != domDoc && null != domDoc.getDocumentElement()) {
+ list = domDoc.getDocumentElement().getChildNodes();
+ long i = 0;
+ for (; i < list.getLength(); i++) {
+ nodeTmp = list.item(i);
+ if ("BODY".equalsIgnoreCase(nodeTmp.getNodeName())) {
+ patronItem = nodeTmp.cloneNode(true);
+ break;
+ }
+ }
+ }
+ if (null != patronItem) {
+ list = patronItem.getChildNodes();
+ //mainItem = visualDocument.createElement("DIV");
+ patronItem = visualDocument.createElement("SPAN");
+ createCopyChildren(visualDocument, patronItem, list);
+ }
+ VpeCreationData creationData = new VpeCreationData(patronItem);
+ return creationData;
+ }
+
+ public void createCopyChildren(nsIDOMDocument visualDocument,
+ nsIDOMNode nodeParent, nsIDOMNodeList listCopyChildren) {
+ long i = 0;
+ nsIDOMNode nodeTmp = null, nodeTmp2 = null;
+ for (; i < listCopyChildren.getLength(); i++) {
+ nodeTmp = listCopyChildren.item(i);
+ // remark: cloneNode true/false - is not suitable function here
+ //nodeTmp2 = nodeTmp.cloneNode(false);
+ if (nodeTmp.getNodeName().startsWith("#text")) {
+ nodeTmp2 = visualDocument.createTextNode(nodeTmp.getNodeValue());
+ }
+ else {
+ if (!nodeTmp.getNodeName().startsWith("#")) {
+ nodeTmp2 = visualDocument.createElement(nodeTmp.getNodeName());
+ }
+ }
+ if (null == nodeTmp2) {
+ continue;
+ }
+ nodeParent.appendChild(nodeTmp2);
+ createCopyChildren(visualDocument, nodeTmp2, nodeTmp.getChildNodes());
+ nodeTmp2 = null;
+ }
+ }
+
+ public nsIComponentManager getComponentManager() {
+ if (null == componentManager) {
+ componentManager = Mozilla.getInstance().getComponentManager();
+ }
+ return componentManager;
+ }
+}
+// html code
Added:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.seam/src/org/jboss/tools/jsf/vpe/seam/template/SeamTextTest2.txt
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.seam/src/org/jboss/tools/jsf/vpe/seam/template/SeamTextTest2.txt
(rev 0)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.seam/src/org/jboss/tools/jsf/vpe/seam/template/SeamTextTest2.txt 2007-12-14
12:41:48 UTC (rev 5306)
@@ -0,0 +1,6 @@
+Here is some wiki text:
+*bold* |mono| ~deleted~ _underline_ /italic/ ^super^
+
+This is a new paragraph. (Just leave a blank line.)
+
+*/_Multiple ~tags~ styles_ can be nested!/*