Source Code Cross Referenced for StyleMaintenancePanel.java in  » Database-Client » squirrel-sql-2.6.5a » net » sourceforge » squirrel_sql » plugins » syntax » prefspanel » 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.prefspanel 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package net.sourceforge.squirrel_sql.plugins.syntax.prefspanel;
002:
003:        /*
004:         * Copyright (C) 2003 Colin Bell
005:         * colbell@users.sourceforge.net
006:         *
007:         * This program is free software; you can redistribute it and/or
008:         * modify it under the terms of the GNU General Public License
009:         * as published by the Free Software Foundation; either version 2
010:         * of the License, or any later version.
011:         *
012:         * This program is distributed in the hope that it will be useful,
013:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
014:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
015:         * GNU General Public License for more details.
016:         *
017:         * You should have received a copy of the GNU General Public License
018:         * along with this program; if not, write to the Free Software
019:         * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
020:         */
021:        import java.awt.Color;
022:        import java.awt.event.ActionEvent;
023:        import java.awt.event.ActionListener;
024:
025:        import javax.swing.JButton;
026:        import javax.swing.JColorChooser;
027:        import javax.swing.JToggleButton;
028:        import javax.swing.JToolBar;
029:
030:        import net.sourceforge.squirrel_sql.plugins.syntax.SyntaxPluginResources;
031:        import net.sourceforge.squirrel_sql.plugins.syntax.SyntaxStyle;
032:        import net.sourceforge.squirrel_sql.fw.util.StringManager;
033:        import net.sourceforge.squirrel_sql.fw.util.StringManagerFactory;
034:
035:        /**
036:         * This panel allows maintenance of the selected Syntax Style.
037:         *
038:         * @author <A HREF="mailto:colbell@users.sourceforge.net">Colin Bell</A>
039:         */
040:        public class StyleMaintenancePanel extends JToolBar {
041:
042:            private static final StringManager s_stringMgr = StringManagerFactory
043:                    .getStringManager(StyleMaintenancePanel.class);
044:
045:            private final StylesList _list;
046:            private final JToggleButton _boldChk;
047:            private final JToggleButton _italicChk;
048:            private final JButton _fontColorBtn;
049:            private final JButton _backgroundColorBtn;
050:            private FontColorButtonListener _fontColorBtnLis;
051:            private BackgroundColorButtonListener _backgroundColorBtnLis;
052:            private ActionListener _toggleLis;
053:
054:            private SyntaxStyle _style;
055:
056:            public StyleMaintenancePanel(StylesList list,
057:                    SyntaxPluginResources rsrc) {
058:                super ();
059:                _list = list;
060:
061:                this .setFloatable(false);
062:
063:                _boldChk = new JToggleButton(rsrc
064:                        .getIcon(SyntaxPluginResources.IKeys.BOLD_IMAGE));
065:                //i18n[syntax.bold=Bold]
066:                _boldChk.setToolTipText(s_stringMgr.getString("syntax.bold"));
067:                _italicChk = new JToggleButton(rsrc
068:                        .getIcon(SyntaxPluginResources.IKeys.ITALIC_IMAGE));
069:                //i18n[syntax.italic=Italic]
070:                _italicChk.setToolTipText(s_stringMgr
071:                        .getString("syntax.italic"));
072:
073:                _fontColorBtn = new JButton(rsrc
074:                        .getIcon(SyntaxPluginResources.IKeys.FOREGROUND_IMAGE));
075:                //i18n[syntax.font=Select font color]
076:                _fontColorBtn.setToolTipText(s_stringMgr
077:                        .getString("syntax.font"));
078:                _backgroundColorBtn = new JButton(rsrc
079:                        .getIcon(SyntaxPluginResources.IKeys.BACKGROUND_IMAGE));
080:                //i18n[syntax.background=Select background color]
081:                _backgroundColorBtn.setToolTipText(s_stringMgr
082:                        .getString("syntax.background"));
083:
084:                add(_boldChk);
085:                add(_italicChk);
086:                add(_fontColorBtn);
087:                add(_backgroundColorBtn);
088:            }
089:
090:            /**
091:             * Component has been added to its parent so setup listeners etc.
092:             */
093:            public void addNotify() {
094:                super .addNotify();
095:
096:                if (_fontColorBtnLis == null) {
097:                    _fontColorBtnLis = new FontColorButtonListener(_list);
098:                    _fontColorBtn.addActionListener(_fontColorBtnLis);
099:                    _backgroundColorBtnLis = new BackgroundColorButtonListener(
100:                            _list);
101:                    _backgroundColorBtn
102:                            .addActionListener(_backgroundColorBtnLis);
103:                }
104:
105:                if (_toggleLis == null) {
106:                    _toggleLis = new ToggleButtonListener();
107:                    _boldChk.addActionListener(_toggleLis);
108:                    _italicChk.addActionListener(_toggleLis);
109:                }
110:            }
111:
112:            /**
113:             * Component has been removed from its parent so remove listeners etc.
114:             */
115:            public void removeNotify() {
116:                if (_fontColorBtnLis != null) {
117:                    _fontColorBtn.removeActionListener(_fontColorBtnLis);
118:                    _backgroundColorBtn
119:                            .removeActionListener(_backgroundColorBtnLis);
120:                    _fontColorBtnLis = null;
121:                    _backgroundColorBtnLis = null;
122:                }
123:                if (_toggleLis != null) {
124:                    _boldChk.removeActionListener(_toggleLis);
125:                    _italicChk.removeActionListener(_toggleLis);
126:                    _toggleLis = null;
127:                }
128:
129:                super .removeNotify();
130:            }
131:
132:            public void setEnabled(boolean enable) {
133:                _boldChk.setEnabled(enable);
134:                _italicChk.setEnabled(enable);
135:                _fontColorBtn.setEnabled(enable);
136:                _backgroundColorBtn.setEnabled(enable);
137:            }
138:
139:            public void setStyle(SyntaxStyle style) {
140:                _boldChk.setSelected(style.isBold());
141:                _italicChk.setSelected(style.isItalic());
142:                _style = style;
143:            }
144:
145:            private final class ToggleButtonListener implements  ActionListener {
146:                public void actionPerformed(ActionEvent evt) {
147:                    _style.setBold(_boldChk.isSelected());
148:                    _style.setItalic(_italicChk.isSelected());
149:                    _list.repaint();
150:                }
151:            }
152:
153:            /**
154:             * Listener for the Font Color selection button. Show a Color selection
155:             * dialog and if the user selects a color update the current style with
156:             * that color.
157:             */
158:            private static class FontColorButtonListener implements 
159:                    ActionListener {
160:                private final StylesList _list;
161:
162:                FontColorButtonListener(StylesList list) {
163:                    super ();
164:                    _list = list;
165:                }
166:
167:                public void actionPerformed(ActionEvent evt) {
168:                    final SyntaxStyle style = _list.getSelectedSyntaxStyle();
169:                    final int origRGB = style.getTextRGB();
170:                    final Color color = JColorChooser.showDialog(null,
171:                            //i18n[syntax.selColor=Select Color]
172:                            s_stringMgr.getString("syntax.selColor"),
173:                            new Color(origRGB));
174:                    if (color != null) {
175:                        style.setTextRGB(color.getRGB());
176:                    }
177:                }
178:            }
179:
180:            /**
181:             * Listener for the Background Color selection button. Show a Color
182:             * selection dialog and if the user selects a color update the current
183:             * style with that color.
184:             */
185:            private static class BackgroundColorButtonListener implements 
186:                    ActionListener {
187:                private final StylesList _list;
188:
189:                BackgroundColorButtonListener(StylesList list) {
190:                    super ();
191:                    _list = list;
192:                }
193:
194:                public void actionPerformed(ActionEvent evt) {
195:                    final SyntaxStyle style = _list.getSelectedSyntaxStyle();
196:                    final int origRGB = style.getBackgroundRGB();
197:                    final Color color = JColorChooser.showDialog(null,
198:                            //i18n[syntax.selColor2=Select Color]
199:                            s_stringMgr.getString("syntax.selColor2"),
200:                            new Color(origRGB));
201:                    if (color != null) {
202:                        style.setBackgroundRGB(color.getRGB());
203:                    }
204:
205:                }
206:            }
207:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.