Source Code Cross Referenced for Java2HtmlOptionsPanel.java in  » Code-Analyzer » Java2Html » de » java2html » gui » 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 » Code Analyzer » Java2Html » de.java2html.gui 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package de.java2html.gui;
002:
003:        import java.awt.GridBagConstraints;
004:        import java.awt.GridBagLayout;
005:        import java.awt.Insets;
006:        import java.awt.event.ItemEvent;
007:        import java.awt.event.ItemListener;
008:        import java.util.ArrayList;
009:        import java.util.Iterator;
010:        import java.util.List;
011:
012:        import javax.swing.JCheckBox;
013:        import javax.swing.JComboBox;
014:        import javax.swing.JComponent;
015:        import javax.swing.JLabel;
016:        import javax.swing.JPanel;
017:        import javax.swing.JSpinner;
018:        import javax.swing.SpinnerNumberModel;
019:        import javax.swing.event.ChangeEvent;
020:        import javax.swing.event.ChangeListener;
021:
022:        import de.java2html.JavaSourceConversionSettings;
023:        import de.java2html.converter.IJavaSourceConverter;
024:        import de.java2html.converter.JavaSourceConverterProvider;
025:        import de.java2html.options.HorizontalAlignment;
026:        import de.java2html.options.JavaSourceConversionOptions;
027:        import de.java2html.options.JavaSourceStyleTable;
028:
029:        public class Java2HtmlOptionsPanel {
030:            private final static JavaSourceStyleTable[] styles = JavaSourceStyleTable
031:                    .getPredefinedTables();
032:            private final static HorizontalAlignment[] alignments = new HorizontalAlignment[] {
033:                    HorizontalAlignment.LEFT, HorizontalAlignment.CENTER,
034:                    HorizontalAlignment.RIGHT };
035:
036:            private final SpinnerNumberModel tabModel = new SpinnerNumberModel(
037:                    2, 0, 16, 1);
038:
039:            private final JSpinner chTab;
040:            private final JComboBox chTarget;
041:            private final JComboBox chStyle;
042:            private final JComboBox chAlignment;
043:            private final JCheckBox cbShowLineNumbers;
044:            private final JCheckBox cbShowTableBorder;
045:            private final List/*<ChangeListener>*/listeners = new ArrayList();
046:
047:            private final JComponent content;
048:
049:            public Java2HtmlOptionsPanel() {
050:                chTab = new JSpinner(tabModel);
051:                ItemListener itemListener = new ItemListener() {
052:                    public void itemStateChanged(ItemEvent e) {
053:                        fireStateChanged();
054:                    }
055:                };
056:                tabModel.addChangeListener(new ChangeListener() {
057:                    public void stateChanged(ChangeEvent e) {
058:                        fireStateChanged();
059:                    }
060:                });
061:
062:                chTarget = new JComboBox(JavaSourceConverterProvider
063:                        .getAllConverters());
064:                chTarget.setRenderer(new AbstractSimpleListCellRenderer() {
065:                    protected String getLabel(Object value) {
066:                        IJavaSourceConverter converter = (IJavaSourceConverter) value;
067:                        return converter.getMetaData().getPrintName();
068:                    }
069:                });
070:                chTarget.addItemListener(itemListener);
071:
072:                chStyle = new JComboBox(styles);
073:                chStyle.setRenderer(new AbstractSimpleListCellRenderer() {
074:                    protected String getLabel(Object value) {
075:                        JavaSourceStyleTable table = (JavaSourceStyleTable) value;
076:                        return table.getName();
077:                    }
078:                });
079:                chStyle.addItemListener(itemListener);
080:
081:                chAlignment = new JComboBox(alignments);
082:                chAlignment.setRenderer(new AbstractSimpleListCellRenderer() {
083:                    protected String getLabel(Object value) {
084:                        HorizontalAlignment alignment = (HorizontalAlignment) value;
085:                        return alignment.getName();
086:                    }
087:                });
088:                chAlignment.addItemListener(itemListener);
089:
090:                cbShowLineNumbers = new JCheckBox("Line numbers", true);
091:                cbShowLineNumbers.addItemListener(itemListener);
092:
093:                cbShowTableBorder = new JCheckBox("Table border", true);
094:                cbShowTableBorder.addItemListener(itemListener);
095:
096:                JPanel panel = new JPanel(new GridBagLayout());
097:                final GridBagConstraints leftColumnConstraints = new GridBagConstraints();
098:                leftColumnConstraints.insets = new Insets(2, 2, 2, 2);
099:                leftColumnConstraints.gridx = 0;
100:                leftColumnConstraints.anchor = GridBagConstraints.EAST;
101:
102:                final GridBagConstraints rightColumnConstraints = new GridBagConstraints();
103:                rightColumnConstraints.insets = new Insets(2, 2, 2, 2);
104:                rightColumnConstraints.gridx = 1;
105:                rightColumnConstraints.fill = GridBagConstraints.NONE;
106:                rightColumnConstraints.anchor = GridBagConstraints.WEST;
107:
108:                final GridBagConstraints twoColumnConstraints = new GridBagConstraints();
109:                twoColumnConstraints.insets = new Insets(2, 2, 2, 2);
110:                twoColumnConstraints.gridx = 0;
111:                twoColumnConstraints.gridwidth = 2;
112:                twoColumnConstraints.anchor = GridBagConstraints.WEST;
113:
114:                panel.add(new JLabel("Target:"), leftColumnConstraints);
115:                panel.add(chTarget, rightColumnConstraints);
116:                panel.add(new JLabel("Style:"), leftColumnConstraints);
117:                panel.add(chStyle, rightColumnConstraints);
118:                panel.add(new JLabel("Tab-space:"), leftColumnConstraints);
119:                panel.add(chTab, rightColumnConstraints);
120:                panel.add(new JLabel("Alignment:"), leftColumnConstraints);
121:                panel.add(chAlignment, rightColumnConstraints);
122:                panel.add(cbShowLineNumbers, twoColumnConstraints);
123:                panel.add(cbShowTableBorder, twoColumnConstraints);
124:
125:                this .content = panel;
126:
127:                initDefaultOptions();
128:            }
129:
130:            public JComponent getContent() {
131:                return content;
132:            }
133:
134:            private void initDefaultOptions() {
135:                JavaSourceConversionOptions options = JavaSourceConversionOptions
136:                        .getDefault();
137:                tabModel.setValue(new Integer(options.getTabSize()));
138:
139:                chStyle.setSelectedItem(options.getStyleTable());
140:                cbShowLineNumbers.setSelected(options.isShowLineNumbers());
141:                cbShowTableBorder.setSelected(options.isShowTableBorder());
142:                chAlignment.setSelectedItem(options.getHorizontalAlignment());
143:            }
144:
145:            public JavaSourceConversionSettings getConversionSettings() {
146:                final IJavaSourceConverter selectedConverter = JavaSourceConverterProvider
147:                        .getAllConverters()[chTarget.getSelectedIndex()];
148:                String converterName = selectedConverter.getMetaData()
149:                        .getName();
150:                return new JavaSourceConversionSettings(getConversionOptions(),
151:                        converterName);
152:            }
153:
154:            private JavaSourceConversionOptions getConversionOptions() {
155:                JavaSourceConversionOptions options = JavaSourceConversionOptions
156:                        .getDefault();
157:                int tabs = tabModel.getNumber().intValue();
158:                options.setTabSize(tabs);
159:                options.setStyleTable(styles[chStyle.getSelectedIndex()]);
160:                options.setShowLineNumbers(cbShowLineNumbers.isSelected());
161:                options.setShowTableBorder(cbShowTableBorder.isSelected());
162:                options.setHorizontalAlignment(alignments[chAlignment
163:                        .getSelectedIndex()]);
164:                return options;
165:            }
166:
167:            public synchronized void addChangeListener(ChangeListener listener) {
168:                listeners.add(listener);
169:            }
170:
171:            public synchronized void removeChangeListener(
172:                    ChangeListener listener) {
173:                listeners.remove(listener);
174:            }
175:
176:            private synchronized void fireStateChanged() {
177:                ChangeEvent event = new ChangeEvent(this );
178:                for (Iterator iter = new ArrayList(listeners).iterator(); iter
179:                        .hasNext();) {
180:                    ChangeListener listener = (ChangeListener) iter.next();
181:                    listener.stateChanged(event);
182:                }
183:            }
184:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.