Source Code Cross Referenced for UIFactory.java in  » Workflow-Engines » OSWorkflow » com » opensymphony » workflow » designer » 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 » Workflow Engines » OSWorkflow » com.opensymphony.workflow.designer 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package com.opensymphony.workflow.designer;
002:
003:        import java.awt.*;
004:        import java.awt.event.ActionListener;
005:        import java.text.NumberFormat;
006:        import javax.swing.*;
007:        import javax.swing.text.html.HTMLDocument;
008:        import javax.swing.text.View;
009:        import javax.swing.text.DefaultFormatterFactory;
010:        import javax.swing.text.NumberFormatter;
011:
012:        import com.jgoodies.forms.factories.ButtonBarFactory;
013:        import com.jgoodies.forms.builder.DefaultFormBuilder;
014:        import com.jgoodies.forms.layout.FormLayout;
015:
016:        /**
017:         * @author Hani Suleiman (hani@formicary.net)
018:         *         Date: May 21 2003
019:         *         Time: 9:46:11 PM
020:         */
021:        public class UIFactory {
022:            private static final DefaultFormatterFactory INT_FORMATTER_FACTORY;
023:
024:            static {
025:                NumberFormat format = NumberFormat.getIntegerInstance();
026:                format.setGroupingUsed(false);
027:                INT_FORMATTER_FACTORY = new DefaultFormatterFactory(
028:                        new NumberFormatter(format));
029:            }
030:
031:            public static JFormattedTextField createIntegerField() {
032:                JFormattedTextField field = new JFormattedTextField();
033:                field.setFormatterFactory(INT_FORMATTER_FACTORY);
034:                return field;
035:            }
036:
037:            public static JPanel getAddRemovePropertiesBar(
038:                    ActionListener listener, String prefix, String[] names) {
039:                if (prefix == null)
040:                    prefix = "";
041:                JButton[] buttons = new JButton[names.length];
042:                for (int i = 0; i < buttons.length; i++) {
043:                    buttons[i] = new JButton(ResourceManager
044:                            .getString(names[i]));
045:                    buttons[i].setActionCommand(prefix + names[i]);
046:                    buttons[i].addActionListener(listener);
047:                }
048:                return ButtonBarFactory.buildAddRemovePropertiesBar(buttons[0],
049:                        buttons[1], buttons[2]);
050:            }
051:
052:            public static DefaultFormBuilder getDialogBuilder(String separator,
053:                    Container contentPane) {
054:                FormLayout layout = new FormLayout(
055:                        "2dlu, left:max(40dlu;pref), 3dlu, 110dlu:grow, 7dlu");
056:                DefaultFormBuilder builder = createBuilder(
057:                        (JPanel) contentPane, layout, separator);
058:                builder.setDefaultDialogBorder();
059:                return builder;
060:            }
061:
062:            public static DefaultFormBuilder getTwoColumnBuilder(
063:                    String separator, JPanel panel) {
064:                FormLayout layout = new FormLayout(
065:                        "2dlu, left:pref, 3dlu, pref:grow, 2dlu", "");
066:                DefaultFormBuilder builder = createBuilder(panel, layout,
067:                        separator);
068:                return builder;
069:            }
070:
071:            private static DefaultFormBuilder createBuilder(JPanel panel,
072:                    FormLayout layout, String separator) {
073:                DefaultFormBuilder builder = new DefaultFormBuilder(panel,
074:                        layout, ResourceManager.getBundle());
075:                builder.setLeadingColumnOffset(1);
076:                if (separator == null) {
077:                    builder.appendRow(builder.getLineGapSpec());
078:                    builder.nextLine();
079:                } else {
080:                    builder.appendSeparator(separator);
081:                }
082:                return builder;
083:            }
084:
085:            public static JPanel getOKCancelBar(ActionListener listener,
086:                    String prefix) {
087:                if (prefix == null)
088:                    prefix = "";
089:                JButton ok = new JButton(ResourceManager.getString("ok"));
090:                ok.setActionCommand(prefix + "ok");
091:                JButton cancel = new JButton(ResourceManager
092:                        .getString("cancel"));
093:                cancel.setActionCommand(prefix + "cancel");
094:                ok.addActionListener(listener);
095:                cancel.addActionListener(listener);
096:                return ButtonBarFactory.buildOKCancelBar(ok, cancel);
097:            }
098:
099:            public static JPanel getButtonBar(ActionListener[] listener,
100:                    String prefix, String[] names) {
101:                if (prefix == null)
102:                    prefix = "";
103:                if (listener.length != names.length)
104:                    throw new IllegalArgumentException("listener.length="
105:                            + listener.length + " but names.length="
106:                            + names.length);
107:                JButton[] buttons = new JButton[names.length];
108:                for (int i = 0; i < buttons.length; i++) {
109:                    buttons[i] = new JButton(ResourceManager
110:                            .getString(names[i]));
111:                    buttons[i].setActionCommand(prefix + names[i]);
112:                    buttons[i].addActionListener(listener[i]);
113:                }
114:                return ButtonBarFactory.buildCenteredBar(buttons);
115:            }
116:
117:            public static JComponent createTablePanel(JTable table) {
118:                Color background = UIManager.getColor("window");
119:                JScrollPane scrollPane = new JScrollPane(table);
120:                scrollPane.getViewport().setOpaque(false);
121:                scrollPane.getViewport().setBackground(background);
122:                scrollPane.setOpaque(false);
123:                scrollPane.setCorner(JScrollPane.UPPER_RIGHT_CORNER,
124:                        new JPanel());
125:                scrollPane.setCorner(JScrollPane.LOWER_RIGHT_CORNER,
126:                        new JPanel());
127:                JPanel panel = new JPanel(new GridLayout(0, 1)) {
128:                    public void updateUI() {
129:                        super .updateUI();
130:                        setBackground(UIManager.getColor("window"));
131:                    }
132:                };
133:                panel.setPreferredSize(new Dimension(220, 100));
134:                panel.add(scrollPane);
135:                return panel;
136:            }
137:
138:            public static JTextField createReadOnlyTextField(int width) {
139:                JTextField field = new JTextField() {
140:                    public boolean isFocusable() {
141:                        return false;
142:                    }
143:
144:                    protected void processEvent(AWTEvent e) {
145:                    }
146:                };
147:                field.setEditable(false);
148:                field.setOpaque(false);
149:                field.setForeground(UIManager.getColor("TextField.foreground"));
150:                if (width != -1) {
151:                    field.setColumns(width);
152:                }
153:                return field;
154:            }
155:
156:            public static JTextField createReadOnlyTextField() {
157:                return createReadOnlyTextField(-1);
158:            }
159:
160:            public static void htmlize(JComponent component) {
161:                Font defaultFont = UIManager.getFont("Button.font");
162:
163:                String stylesheet = "body { margin-top: 0; margin-bottom: 0; margin-left: 0; margin-right: 0; font-family: "
164:                        + defaultFont.getName()
165:                        + "; font-size: "
166:                        + defaultFont.getSize()
167:                        + "pt;	}"
168:                        + "a, p, li { margin-top: 0; margin-bottom: 0; margin-left: 0; margin-right: 0; font-family: "
169:                        + defaultFont.getName()
170:                        + "; font-size: "
171:                        + defaultFont.getSize() + "pt;	}";
172:
173:                try {
174:                    HTMLDocument doc = null;
175:                    if (component instanceof  JEditorPane) {
176:                        doc = (HTMLDocument) ((JEditorPane) component)
177:                                .getDocument();
178:                    } else {
179:                        View v = (View) component
180:                                .getClientProperty(javax.swing.plaf.basic.BasicHTML.propertyKey);
181:                        if (v != null) {
182:                            doc = (HTMLDocument) v.getDocument();
183:                        }
184:                    }
185:                    if (doc != null) {
186:                        doc.getStyleSheet().loadRules(
187:                                new java.io.StringReader(stylesheet), null);
188:                    } // end of if (doc != null)
189:                } catch (Exception e) {
190:                    e.printStackTrace();
191:                }
192:            }
193:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.