Source Code Cross Referenced for SQLSettingsDefaults.java in  » Database-Client » squirrel-sql-2.6.5a » net » sourceforge » squirrel_sql » plugins » syntax » netbeans » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Database Client » squirrel sql 2.6.5a » net.sourceforge.squirrel_sql.plugins.syntax.netbeans 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package net.sourceforge.squirrel_sql.plugins.syntax.netbeans;
002:
003:        import java.awt.Color;
004:        import java.awt.Font;
005:        import java.util.Map;
006:        import java.util.TreeMap;
007:
008:        import net.sourceforge.squirrel_sql.plugins.syntax.SyntaxPreferences;
009:        import net.sourceforge.squirrel_sql.plugins.syntax.SyntaxPugin;
010:        import net.sourceforge.squirrel_sql.plugins.syntax.SyntaxStyle;
011:
012:        import org.netbeans.editor.Coloring;
013:        import org.netbeans.editor.Settings;
014:        import org.netbeans.editor.SettingsDefaults;
015:        import org.netbeans.editor.SettingsUtil;
016:        import org.netbeans.editor.TokenCategory;
017:        import org.netbeans.editor.TokenContextPath;
018:        import org.netbeans.editor.ext.ExtSettingsDefaults;
019:        import org.netbeans.editor.ext.java.JavaLayerTokenContext;
020:
021:        public class SQLSettingsDefaults extends ExtSettingsDefaults {
022:            // Formatting
023:            public static final Boolean defaultJavaFormatSpaceBeforeParenthesis = Boolean.FALSE;
024:            public static final Boolean defaultJavaFormatSpaceAfterComma = Boolean.TRUE;
025:
026:            static class SQLTokenColoringInitializer extends
027:                    SettingsUtil.TokenColoringInitializer {
028:
029:                Font boldFont;
030:                Font italicFont;
031:                Font normalFont;
032:
033:                Settings.Evaluator boldSubst = new SettingsUtil.FontStylePrintColoringEvaluator(
034:                        Font.BOLD);
035:                Settings.Evaluator italicSubst = new SettingsUtil.FontStylePrintColoringEvaluator(
036:                        Font.ITALIC);
037:                Settings.Evaluator lightGraySubst = new SettingsUtil.ForeColorPrintColoringEvaluator(
038:                        Color.lightGray);
039:
040:                Coloring commentColoring = new Coloring(null, new Color(115,
041:                        115, 115), null);
042:
043:                Coloring numbersColoring = new Coloring(null, new Color(120, 0,
044:                        0), null);
045:                private SyntaxPreferences _syntaxPreferences;
046:
047:                public SQLTokenColoringInitializer(
048:                        SyntaxPreferences syntaxPreferences, Font font) {
049:                    super (SQLTokenContext.context);
050:                    _syntaxPreferences = syntaxPreferences;
051:
052:                    boldFont = font.deriveFont(Font.BOLD);
053:                    italicFont = font.deriveFont(Font.ITALIC);
054:                    normalFont = font;
055:                }
056:
057:                public Object getTokenColoring(
058:                        TokenContextPath tokenContextPath,
059:                        TokenCategory tokenIDOrCategory, boolean printingSet) {
060:                    if (!printingSet) {
061:                        switch (tokenIDOrCategory.getNumericID()) {
062:                        case SQLTokenContext.IDENTIFIER_ID:
063:                            return createColoringFromStyle(_syntaxPreferences
064:                                    .getIdentifierStyle());
065:
066:                        case SQLTokenContext.WHITESPACE_ID:
067:                            return createColoringFromStyle(_syntaxPreferences
068:                                    .getWhiteSpaceStyle());
069:
070:                        case SQLTokenContext.OPERATORS_ID:
071:                            return createColoringFromStyle(_syntaxPreferences
072:                                    .getOperatorStyle());
073:
074:                        case SQLTokenContext.TABLE_ID:
075:                            return createColoringFromStyle(_syntaxPreferences
076:                                    .getTableStyle());
077:
078:                        case SQLTokenContext.COLUMN_ID:
079:                            return createColoringFromStyle(_syntaxPreferences
080:                                    .getColumnStyle());
081:
082:                        case SQLTokenContext.FUNCTION_ID:
083:                            return createColoringFromStyle(_syntaxPreferences
084:                                    .getFunctionStyle());
085:
086:                        case SQLTokenContext.DATA_TYPE_ID:
087:                            return createColoringFromStyle(_syntaxPreferences
088:                                    .getDataTypeStyle());
089:
090:                        case SQLTokenContext.STATEMENT_SEPARATOR_ID:
091:                            return createColoringFromStyle(_syntaxPreferences
092:                                    .getSeparatorStyle());
093:
094:                        case SQLTokenContext.ERROR_ID:
095:                            return createColoringFromStyle(_syntaxPreferences
096:                                    .getErrorStyle());
097:
098:                        case SQLTokenContext.ERRORS_ID:
099:                            return createColoringFromStyle(_syntaxPreferences
100:                                    .getErrorStyle());
101:
102:                        case SQLTokenContext.KEYWORDS_ID:
103:                            return createColoringFromStyle(_syntaxPreferences
104:                                    .getReservedWordStyle());
105:
106:                        case SQLTokenContext.LINE_COMMENT_ID:
107:                        case SQLTokenContext.BLOCK_COMMENT_ID:
108:                            return createColoringFromStyle(_syntaxPreferences
109:                                    .getCommentStyle());
110:
111:                        case SQLTokenContext.CHAR_LITERAL_ID:
112:                            return createColoringFromStyle(_syntaxPreferences
113:                                    .getLiteralStyle());
114:
115:                        case SQLTokenContext.STRING_LITERAL_ID:
116:                            return createColoringFromStyle(_syntaxPreferences
117:                                    .getLiteralStyle());
118:
119:                        case SQLTokenContext.NUMERIC_LITERALS_ID:
120:                            return createColoringFromStyle(_syntaxPreferences
121:                                    .getLiteralStyle());
122:
123:                            //               case SQLTokenContext.ANNOTATION_ID: // JDK 1.5 annotations
124:                            //                  return new Coloring(null, new Color(0, 111, 0), null);
125:
126:                        }
127:
128:                    } else { // printing set
129:                        switch (tokenIDOrCategory.getNumericID()) {
130:                        case SQLTokenContext.LINE_COMMENT_ID:
131:                        case SQLTokenContext.BLOCK_COMMENT_ID:
132:                            return lightGraySubst; // print fore color will be gray
133:
134:                        default:
135:                            return SettingsUtil.defaultPrintColoringEvaluator;
136:                        }
137:
138:                    }
139:
140:                    return null;
141:
142:                }
143:
144:                private Coloring createColoringFromStyle(SyntaxStyle style) {
145:                    if (style.isBold()) {
146:                        return new Coloring(boldFont,
147:                                Coloring.FONT_MODE_DEFAULT, new Color(style
148:                                        .getTextRGB()), new Color(style
149:                                        .getBackgroundRGB()));
150:                    } else if (style.isItalic()) {
151:                        return new Coloring(italicFont,
152:                                Coloring.FONT_MODE_DEFAULT, new Color(style
153:                                        .getTextRGB()), new Color(style
154:                                        .getBackgroundRGB()));
155:                    } else {
156:                        return new Coloring(normalFont,
157:                                Coloring.FONT_MODE_DEFAULT, new Color(style
158:                                        .getTextRGB()), new Color(style
159:                                        .getBackgroundRGB()));
160:                    }
161:                }
162:
163:            }
164:
165:            static class SQLLayerTokenColoringInitializer extends
166:                    SettingsUtil.TokenColoringInitializer {
167:
168:                Font boldFont = SettingsDefaults.defaultFont
169:                        .deriveFont(Font.BOLD);
170:                Settings.Evaluator italicSubst = new SettingsUtil.FontStylePrintColoringEvaluator(
171:                        Font.ITALIC);
172:
173:                public SQLLayerTokenColoringInitializer() {
174:                    super (JavaLayerTokenContext.context);
175:                }
176:
177:                public Object getTokenColoring(
178:                        TokenContextPath tokenContextPath,
179:                        TokenCategory tokenIDOrCategory, boolean printingSet) {
180:                    if (!printingSet) {
181:                        switch (tokenIDOrCategory.getNumericID()) {
182:                        case JavaLayerTokenContext.METHOD_ID:
183:                            return new Coloring(boldFont,
184:                                    Coloring.FONT_MODE_APPLY_STYLE, null, null);
185:
186:                        }
187:
188:                    } else { // printing set
189:                        switch (tokenIDOrCategory.getNumericID()) {
190:                        case JavaLayerTokenContext.METHOD_ID:
191:                            return italicSubst;
192:
193:                        default:
194:                            return SettingsUtil.defaultPrintColoringEvaluator;
195:                        }
196:
197:                    }
198:
199:                    return null;
200:                }
201:
202:            }
203:
204:            public static Map<String, String> getAbbrevMap(SyntaxPugin plugin) {
205:                Map<String, String> javaAbbrevMap = new TreeMap<String, String>();
206:
207:                // We do abrevs ourselfs in the DocumentListener in NetbeansSQLEntryPanel.
208:                // We don't use the Netbeans implementation mainly because it is case sensitive.
209:                // If we come across a performance problem one day we can still try to use this.
210:
211:                //Hashtable autoCorrects = plugin.getAutoCorrectProviderImpl().getAutoCorrects();
212:                //javaAbbrevMap.putAll(autoCorrects);
213:
214:                return javaAbbrevMap;
215:
216:                //      javaAbbrevMap.put("sout", "System.out.println(\"|\");"); // NOI18N
217:                //      javaAbbrevMap.put("serr", "System.err.println(\"|\");"); // NOI18N
218:                //
219:                //      javaAbbrevMap.put("psf", "private static final "); // NOI18N
220:                //      javaAbbrevMap.put("psfi", "private static final int "); // NOI18N
221:                //      javaAbbrevMap.put("psfs", "private static final String "); // NOI18N
222:                //      javaAbbrevMap.put("psfb", "private static final boolean "); // NOI18N
223:                //      javaAbbrevMap.put("Psf", "public static final "); // NOI18N
224:                //      javaAbbrevMap.put("Psfi", "public static final int "); // NOI18N
225:                //      javaAbbrevMap.put("Psfs", "public static final String "); // NOI18N
226:                //      javaAbbrevMap.put("Psfb", "public static final boolean "); // NOI18N
227:                //
228:                //      javaAbbrevMap.put("ab", "abstract "); // NOI18N
229:                //      javaAbbrevMap.put("bo", "boolean "); // NOI18N
230:                //      javaAbbrevMap.put("br", "break"); // NOI18N
231:                //      javaAbbrevMap.put("ca", "catch ("); // NOI18N
232:                //      javaAbbrevMap.put("cl", "class "); // NOI18N
233:                //      javaAbbrevMap.put("cn", "continue"); // NOI18N
234:                //      javaAbbrevMap.put("df", "default:"); // NOI18N
235:                //      javaAbbrevMap.put("ex", "extends "); // NOI18N
236:                //      javaAbbrevMap.put("fa", "false"); // NOI18N
237:                //      javaAbbrevMap.put("fi", "final "); // NOI18N
238:                //      javaAbbrevMap.put("fl", "float "); // NOI18N
239:                //      javaAbbrevMap.put("fy", "finally "); // NOI18N
240:                //      javaAbbrevMap.put("im", "implements "); // NOI18N
241:                //      javaAbbrevMap.put("ir", "import "); // NOI18N
242:                //      javaAbbrevMap.put("iof", "instanceof "); // NOI18N
243:                //      javaAbbrevMap.put("ie", "interface "); // NOI18N
244:                //      javaAbbrevMap.put("pr", "private "); // NOI18N
245:                //      javaAbbrevMap.put("pe", "protected "); // NOI18N
246:                //      javaAbbrevMap.put("pu", "public "); // NOI18N
247:                //      javaAbbrevMap.put("re", "return "); // NOI18N
248:                //      javaAbbrevMap.put("st", "static "); // NOI18N
249:                //      javaAbbrevMap.put("sw", "switch ("); // NOI18N
250:                //      javaAbbrevMap.put("sy", "synchronized "); // NOI18N
251:                //      javaAbbrevMap.put("th", "throws "); // NOI18N
252:                //      javaAbbrevMap.put("tw", "throw "); // NOI18N
253:                //      javaAbbrevMap.put("twn", "throw new "); // NOI18N
254:                //      javaAbbrevMap.put("wh", "while ("); // NOI18N
255:                //
256:                //      javaAbbrevMap.put("eq", "equals"); // NOI18N
257:                //      javaAbbrevMap.put("le", "length"); // NOI18N
258:                //
259:                //      javaAbbrevMap.put("En", "Enumeration"); // NOI18N
260:                //      javaAbbrevMap.put("Ex", "Exception"); // NOI18N
261:                //      javaAbbrevMap.put("Ob", "Object"); // NOI18N
262:                //      javaAbbrevMap.put("St", "String"); // NOI18N
263:                //
264:                //      javaAbbrevMap.put("pst", "printStackTrace();"); // NOI18N
265:                //      javaAbbrevMap.put("tds", "Thread.dumpStack();"); // NOI18N
266:                //
267:                //      return javaAbbrevMap;
268:            }
269:
270:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.