Source Code Cross Referenced for ErdFontStyleDialog.java in  » Database-Client » executequery » org » executequery » gui » erd » 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 » executequery » org.executequery.gui.erd 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * ErdFontStyleDialog.java
003:         *
004:         * Copyright (C) 2002, 2003, 2004, 2005, 2006 Takis Diakoumis
005:         *
006:         * This program is free software; you can redistribute it and/or
007:         * modify it under the terms of the GNU General Public License
008:         * as published by the Free Software Foundation; either version 2
009:         * of the License, or any later version.
010:         *
011:         * This program is distributed in the hope that it will be useful,
012:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
013:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
014:         * GNU General Public License for more details.
015:         *
016:         * You should have received a copy of the GNU General Public License
017:         * along with this program; if not, write to the Free Software
018:         * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
019:         *
020:         */
021:
022:        package org.executequery.gui.erd;
023:
024:        import java.awt.Color;
025:        import java.awt.Container;
026:        import java.awt.Dimension;
027:        import java.awt.FlowLayout;
028:        import java.awt.Font;
029:        import java.awt.GridBagConstraints;
030:        import java.awt.GridBagLayout;
031:        import java.awt.Insets;
032:        import java.awt.event.ActionEvent;
033:        import java.awt.event.ActionListener;
034:
035:        import java.util.Vector;
036:
037:        import javax.swing.BorderFactory;
038:        import javax.swing.BoxLayout;
039:        import javax.swing.JButton;
040:        import javax.swing.JComboBox;
041:        import javax.swing.JDialog;
042:        import javax.swing.JLabel;
043:        import javax.swing.JList;
044:        import javax.swing.JPanel;
045:        import javax.swing.JScrollPane;
046:        import javax.swing.ScrollPaneConstants;
047:        import javax.swing.event.ListSelectionEvent;
048:        import javax.swing.event.ListSelectionListener;
049:        import org.executequery.Constants;
050:
051:        import org.executequery.GUIUtilities;
052:        import org.underworldlabs.swing.GUIUtils;
053:
054:        /* ----------------------------------------------------------
055:         * CVS NOTE: Changes to the CVS repository prior to the 
056:         *           release of version 3.0.0beta1 has meant a 
057:         *           resetting of CVS revision numbers.
058:         * ----------------------------------------------------------
059:         */
060:
061:        /**
062:         *
063:         * @author   Takis Diakoumis
064:         * @version  $Revision: 1.4 $
065:         * @date     $Date: 2006/05/14 06:56:52 $
066:         */
067:        public class ErdFontStyleDialog extends JDialog implements 
068:                ActionListener {
069:
070:            /** The font list */
071:            private JList fontList;
072:            /** The font size options list */
073:            private JList sizeList;
074:            /** The ERD parent panel */
075:            private ErdViewerPanel parent;
076:            /** The currently selected font */
077:            private Font currentFont;
078:            /** The table name style combo */
079:            private JComboBox tableNameCombo;
080:            /** The column name style combo */
081:            private JComboBox columnNameCombo;
082:
083:            private JLabel normalSample;
084:            private JLabel italicSample;
085:            private JLabel boldSample;
086:            private JLabel italicBoldSample;
087:
088:            public ErdFontStyleDialog(ErdViewerPanel parent) {
089:                super (GUIUtilities.getParentFrame(), "Font Style", true);
090:
091:                this .parent = parent;
092:
093:                try {
094:                    jbInit();
095:                } catch (Exception e) {
096:                    e.printStackTrace();
097:                }
098:
099:                // set the currently selected values
100:                sizeList.setSelectedValue(Integer.toString(parent
101:                        .getTableFontSize()), true);
102:                fontList.setSelectedValue(parent.getTableFontName(), true);
103:
104:                int tableNameFontStyle = parent.getTableNameFontStyle();
105:                int columnNameFontStyle = parent.getColumnNameFontStyle();
106:
107:                if (tableNameFontStyle == Font.PLAIN)
108:                    tableNameCombo.setSelectedIndex(0);
109:                else if (tableNameFontStyle == Font.ITALIC)
110:                    tableNameCombo.setSelectedIndex(1);
111:                else if (tableNameFontStyle == Font.BOLD)
112:                    tableNameCombo.setSelectedIndex(2);
113:                else if (tableNameFontStyle == Font.ITALIC + Font.BOLD)
114:                    tableNameCombo.setSelectedIndex(3);
115:
116:                if (columnNameFontStyle == Font.PLAIN)
117:                    columnNameCombo.setSelectedIndex(0);
118:                else if (columnNameFontStyle == Font.ITALIC)
119:                    columnNameCombo.setSelectedIndex(1);
120:                else if (columnNameFontStyle == Font.BOLD)
121:                    columnNameCombo.setSelectedIndex(2);
122:                else if (columnNameFontStyle == Font.ITALIC + Font.BOLD)
123:                    columnNameCombo.setSelectedIndex(3);
124:
125:                fontLists_actionPerformed();
126:
127:                ListSelectionListener listListener = new ListSelectionListener() {
128:                    public void valueChanged(ListSelectionEvent e) {
129:                        fontLists_actionPerformed();
130:                    }
131:                };
132:
133:                fontList.addListSelectionListener(listListener);
134:                sizeList.addListSelectionListener(listListener);
135:
136:                pack();
137:
138:                this .setLocation(GUIUtilities.getLocationForDialog(this 
139:                        .getSize()));
140:
141:                setVisible(true);
142:
143:            }
144:
145:            /** <p>Initialises the state of this instance. */
146:            private void jbInit() throws Exception {
147:
148:                Vector fontNames = GUIUtils.getSystemFonts();
149:                fontList = new JList(fontNames);
150:
151:                String[] fontSizes = { "7", "8", "9", "10", "11", "12", "14" };
152:                sizeList = new JList(fontSizes);
153:
154:                JScrollPane fontScroll = new JScrollPane(fontList);
155:                JScrollPane sizeScroll = new JScrollPane(sizeList);
156:
157:                fontScroll
158:                        .setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
159:
160:                String[] fontStyles = { "Plain", "Italic", "Bold",
161:                        "Bold/Italic" };
162:                tableNameCombo = new JComboBox(fontStyles);
163:                columnNameCombo = new JComboBox(fontStyles);
164:
165:                Dimension comboDim = new Dimension(90, 20);
166:                tableNameCombo.setPreferredSize(comboDim);
167:                columnNameCombo.setPreferredSize(comboDim);
168:
169:                JButton cancelButton = new JButton("Cancel");
170:                JButton okButton = new JButton("OK");
171:
172:                cancelButton.setPreferredSize(Constants.BUTTON_SIZE);
173:                okButton.setPreferredSize(Constants.BUTTON_SIZE);
174:
175:                cancelButton.addActionListener(this );
176:                okButton.addActionListener(this );
177:
178:                JPanel stylesPanel = new JPanel(new GridBagLayout());
179:                GridBagConstraints gbc = new GridBagConstraints();
180:                gbc.insets = new Insets(5, 0, 5, 10);
181:                gbc.anchor = GridBagConstraints.NORTHWEST;
182:                stylesPanel.add(new JLabel("Table Name Style:"), gbc);
183:                gbc.gridx = 1;
184:                gbc.insets.right = 0;
185:                gbc.weightx = 1.0;
186:                stylesPanel.add(tableNameCombo, gbc);
187:                gbc.insets.top = 0;
188:                gbc.insets.bottom = 0;
189:                gbc.gridy = 1;
190:                stylesPanel.add(columnNameCombo, gbc);
191:                gbc.insets.right = 10;
192:                gbc.gridx = 0;
193:                gbc.weightx = 0;
194:                stylesPanel.add(new JLabel("Column Name Style:"), gbc);
195:
196:                JPanel panel = new JPanel(new GridBagLayout());
197:                gbc.insets.top = 5;
198:                gbc.insets.bottom = 5;
199:                gbc.insets.left = 10;
200:                gbc.insets.right = 0;
201:                gbc.gridx = 0;
202:                gbc.gridy = 0;
203:                gbc.weightx = 0;
204:                panel.add(new JLabel("Font Name:"), gbc);
205:                gbc.insets.left = 5;
206:                gbc.gridx = 1;
207:                panel.add(new JLabel("Font Size:"), gbc);
208:                gbc.insets.left = 10;
209:                gbc.insets.bottom = 0;
210:                gbc.insets.top = 0;
211:                gbc.insets.right = 5;
212:                gbc.gridx = 0;
213:                gbc.gridy = 1;
214:                gbc.fill = GridBagConstraints.BOTH;
215:                gbc.weighty = 1.0;
216:                gbc.weightx = 1.0;
217:                panel.add(fontScroll, gbc);
218:                gbc.weightx = 0.5;
219:                gbc.insets.left = 5;
220:                gbc.insets.right = 10;
221:                gbc.gridx = 1;
222:                panel.add(sizeScroll, gbc);
223:                gbc.gridx = 0;
224:                gbc.gridy = 2;
225:                gbc.weightx = 1.0;
226:                gbc.weighty = 0;
227:                gbc.gridwidth = 2;
228:                gbc.insets.left = 10;
229:                gbc.insets.bottom = 5;
230:                panel.add(stylesPanel, gbc);
231:
232:                // setup the sample panel
233:                normalSample = new JLabel("  SAMPLE NORMAL TEXT");
234:                italicSample = new JLabel("  SAMPLE ITALIC TEXT");
235:                boldSample = new JLabel("  SAMPLE BOLD TEXT");
236:                italicBoldSample = new JLabel("  SAMPLE BOLD AND ITALIC TEXT");
237:
238:                JPanel samplePanel = new JPanel();
239:                samplePanel.setLayout(new BoxLayout(samplePanel,
240:                        BoxLayout.Y_AXIS));
241:                samplePanel.add(normalSample);
242:                samplePanel.add(italicSample);
243:                samplePanel.add(boldSample);
244:                samplePanel.add(italicBoldSample);
245:                samplePanel.setBackground(Color.white);
246:
247:                JScrollPane sampleScroll = new JScrollPane(samplePanel);
248:                sampleScroll.setPreferredSize(new Dimension(315, 62));
249:
250:                gbc.gridy = 3;
251:                gbc.weighty = 0.7;
252:                panel.add(sampleScroll, gbc);
253:
254:                JPanel buttonPanel = new JPanel(new FlowLayout(
255:                        FlowLayout.RIGHT, 5, 0));
256:                buttonPanel.add(okButton);
257:                buttonPanel.add(cancelButton);
258:
259:                gbc.gridy = 4;
260:                gbc.weighty = 0;
261:                gbc.insets.right = 5;
262:                gbc.insets.top = 5;
263:                gbc.insets.bottom = 10;
264:                panel.add(buttonPanel, gbc);
265:
266:                panel.setBorder(BorderFactory.createEtchedBorder());
267:                panel.setPreferredSize(new Dimension(340, 350));
268:
269:                Container c = this .getContentPane();
270:                c.setLayout(new GridBagLayout());
271:                c.add(panel, new GridBagConstraints(1, 1, 1, 1, 1.0, 1.0,
272:                        GridBagConstraints.SOUTHEAST, GridBagConstraints.BOTH,
273:                        new Insets(7, 7, 7, 7), 0, 0));
274:
275:                setResizable(false);
276:                this .setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
277:            }
278:
279:            /** <p>Modifies the sample labels following a list selection. */
280:            private void fontLists_actionPerformed() {
281:                String fontName = (String) fontList.getSelectedValue();
282:                int fontSize = Integer.parseInt((String) sizeList
283:                        .getSelectedValue());
284:
285:                int italicBold = Font.BOLD + Font.ITALIC;
286:
287:                normalSample.setFont(new Font(fontName, Font.PLAIN, fontSize));
288:                italicSample.setFont(new Font(fontName, Font.ITALIC, fontSize));
289:                boldSample.setFont(new Font(fontName, Font.BOLD, fontSize));
290:                italicBoldSample.setFont(new Font(fontName, italicBold,
291:                        fontSize));
292:            }
293:
294:            /** <p>Performs the respective action upon selection
295:             *  of a button within this dialog.
296:             *
297:             *  @param the <code>ActionEvent</code>
298:             */
299:            public void actionPerformed(ActionEvent e) {
300:                String command = e.getActionCommand();
301:
302:                if (command.equals("Cancel"))
303:                    dispose();
304:
305:                else if (command.equals("OK")) {
306:                    int index = tableNameCombo.getSelectedIndex();
307:                    int tableNameStyle = -1;
308:
309:                    if (index == 0)
310:                        tableNameStyle = Font.PLAIN;
311:                    else if (index == 1)
312:                        tableNameStyle = Font.ITALIC;
313:                    else if (index == 2)
314:                        tableNameStyle = Font.BOLD;
315:                    else if (index == 3)
316:                        tableNameStyle = Font.BOLD + Font.ITALIC;
317:
318:                    index = columnNameCombo.getSelectedIndex();
319:                    int columnNameStyle = -1;
320:
321:                    if (index == 0)
322:                        columnNameStyle = Font.PLAIN;
323:                    else if (index == 1)
324:                        columnNameStyle = Font.ITALIC;
325:                    else if (index == 2)
326:                        columnNameStyle = Font.BOLD;
327:                    else if (index == 3)
328:                        columnNameStyle = Font.BOLD + Font.ITALIC;
329:
330:                    parent.setTableDisplayFont((String) fontList
331:                            .getSelectedValue(), tableNameStyle,
332:                            columnNameStyle, Integer.parseInt((String) sizeList
333:                                    .getSelectedValue()));
334:
335:                    dispose();
336:
337:                }
338:
339:            }
340:
341:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.