Source Code Cross Referenced for NoWindow.java in  » Workflow-Engines » osbl-1_0 » org » osbl » client » wings » shell » 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 » osbl 1_0 » org.osbl.client.wings.shell 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.osbl.client.wings.shell;
002:
003:        import org.osbl.client.wings.shell.Window;
004:        import org.osbl.client.action.ActionProvider;
005:        import org.osbl.client.action.ChooserAction;
006:        import org.wings.*;
007:
008:        import javax.swing.*;
009:        import java.util.*;
010:        import java.util.List;
011:        import java.awt.*;
012:        import java.awt.event.ActionListener;
013:        import java.awt.event.ActionEvent;
014:
015:        public class NoWindow extends Window {
016:            private List<SComponent> controls = new ArrayList<SComponent>();
017:
018:            public NoWindow(SComponent contentPane) {
019:                super (contentPane);
020:                setTitleCode("navigation.mainWindow");
021:            }
022:
023:            public void refreshTitle() {
024:                if (getContentPane() instanceof  TitleProvider) {
025:                    TitleProvider titleProvider = (TitleProvider) getContentPane();
026:                    setTitleCode(titleProvider.getTitleCode());
027:                    setTitleArguments(titleProvider.getTitleArguments());
028:                }
029:            }
030:
031:            public void refreshActions() {
032:                controls.clear();
033:                if (getContentPane() instanceof  ButtonsProvider) {
034:                    ButtonsProvider buttonsProvider = (ButtonsProvider) getContentPane();
035:                    createControls(buttonsProvider.getActions());
036:                }
037:                setControls(new ArrayList<SComponent>(controls));
038:            }
039:
040:            public void refreshTools() {
041:                List<Tool> toolsToBeShown = new LinkedList<Tool>();
042:                boolean helpTool = false;
043:
044:                SComponent shownComponent = getContentPane();
045:
046:                if (shownComponent instanceof  ToolsProvider) {
047:                    ToolsProvider toolsProvider = (ToolsProvider) shownComponent;
048:                    List<Tool> providersTools = toolsProvider.getTools();
049:                    if (providersTools != null) {
050:                        for (Iterator<Tool> iterator = providersTools
051:                                .iterator(); iterator.hasNext();) {
052:                            Tool tool = iterator.next();
053:                            if (tool instanceof  ContextHelpTool)
054:                                helpTool = true;
055:                            toolsToBeShown.add(tool);
056:                        }
057:                    }
058:                }
059:
060:                // context help tool
061:                if (!helpTool && shownComponent instanceof  HelpProvider) {
062:                    HelpProvider helpProvider = (HelpProvider) shownComponent;
063:                    String helpCode = helpProvider.getHelpCode();
064:                    if (helpCode == null) {
065:                        throw new IllegalStateException(
066:                                "Help code of the help provider ("
067:                                        + shownComponent.getClass().getName()
068:                                        + ") is null, but shouldn't be");
069:                    }
070:                    ContextHelpTool contextHelpTool = Client.getInstance().contextHelpTool;
071:                    contextHelpTool.setHelpCode(helpCode);
072:                    toolsToBeShown.add(contextHelpTool);
073:                }
074:                setTools(toolsToBeShown);
075:            }
076:
077:            protected void createControls(List<Action> actions) {
078:                ActionProvider actionProvider = client.getActionProvider();
079:                String[] names = new String[actions.size()];
080:                int i = 0;
081:                for (Action action : actions) {
082:                    if (action == null) {
083:                        i++;
084:                        continue;
085:                    }
086:                    actionProvider.configure(action);
087:                    names[i++] = (String) action.getValue(Action.NAME);
088:                }
089:                SIcon[] icons = createActionBarButtonIcons(names);
090:
091:                GridBagConstraints buttonConstraints = new GridBagConstraints();
092:                buttonConstraints.weightx = .01;
093:                buttonConstraints.gridwidth = 1;
094:                buttonConstraints.insets = new Insets(0, 0, 0, 10);
095:
096:                i = 0;
097:                for (Action action : actions) {
098:                    if (action == null) {
099:                        controls.add(new SLabel("<html>&nbsp;"));
100:                        i++;
101:                        continue;
102:                    }
103:
104:                    if (action instanceof  ChooserAction) {
105:                        controls
106:                                .add(createChooserActionComponent((ChooserAction) action));
107:                    } else {
108:                        SButton button = new SToolBarButton(action);
109:                        button.setStyle("XButton");
110:                        button.setText(null);
111:                        button.setIcon(icons[i * 2]);
112:                        button.setDisabledIcon(icons[i * 2 + 1]);
113:                        button.setToolTipText((String) action
114:                                .getValue(Action.SHORT_DESCRIPTION));
115:                        controls.add(button);
116:                    }
117:                    i++;
118:                }
119:                buttonConstraints.weightx = 1.0 - i * .01;
120:                controls.add(new SLabel("<html>&nbsp;"));
121:            }
122:
123:            protected SComboBox createChooserActionComponent(
124:                    final ChooserAction chooserAction) {
125:                final DefaultComboBoxModel model = new DefaultComboBoxModel(
126:                        chooserAction.getDomainProvider().getDomain().toArray());
127:
128:                final SComboBox cb = new SComboBox(model);
129:                cb.setRenderer(new SDefaultListCellRenderer() {
130:                    public SComponent getListCellRendererComponent(
131:                            SComponent list, Object value, boolean selected,
132:                            int row) {
133:                        SComponent rendererComponent = super 
134:                                .getListCellRendererComponent(list, value,
135:                                        selected, row);
136:                        setText(chooserAction.getFormat().format(value));
137:                        return rendererComponent;
138:                    }
139:                });
140:                cb.addActionListener(new ActionListener() {
141:                    public void actionPerformed(ActionEvent e) {
142:                        chooserAction.actionPerformed(e);
143:                        model.removeAllElements();
144:                        List domain = chooserAction.getDomainProvider()
145:                                .getDomain();
146:                        for (Object o : domain) {
147:                            model.addElement(o);
148:                        }
149:                        model.setSelectedItem(chooserAction.getSelectedItem());
150:                    }
151:                });
152:                Object chooserItem = chooserAction.getSelectedItem();
153:                if (chooserItem != null) {
154:                    model.setSelectedItem(chooserItem);
155:                }
156:                return cb;
157:            }
158:
159:            protected SIcon[] createActionBarButtonIcons(String[] txt) {
160:                SVGButtonRenderer renderer = SVGButtonRenderer.getInstance();
161:                Dimension dim = new Dimension(-1, -1);
162:                for (int i = 0; i < txt.length; i++) {
163:                    if (txt[i] == null || txt[i].length() == 0) {
164:                        continue;
165:                    }
166:                    Dimension newDim = renderer
167:                            .calculateButtonImageSize(txt[i]);
168:                    if (newDim.width > dim.width) {
169:                        dim.width = newDim.width;
170:                    }
171:                    if (newDim.height > dim.height) {
172:                        dim.height = newDim.height;
173:                    }
174:                }
175:                // use a fixed width for the buttons
176:                dim.width = 150; //dim.width + 10;
177:                SIcon[] icons = new SImageIcon[txt.length * 2];
178:                for (int i = 0; i < txt.length; i++) {
179:                    if (txt[i] == null) {
180:                        continue;
181:                    }
182:                    icons[2 * i] = renderer.retrieveRenderedButtonIcon(txt[i],
183:                            "svg/toolbar_button.svg", dim);
184:                    icons[2 * i + 1] = renderer.retrieveRenderedButtonIcon(
185:                            txt[i], "svg/toolbar_button_disabled.svg", dim);
186:                }
187:                return icons;
188:            }
189:
190:            public void showDetailHelp(String key) {
191:                for (Iterator<Tool> iterator = getTools().iterator(); iterator
192:                        .hasNext();) {
193:                    Tool tool = iterator.next();
194:                    if (key.equals(tool.getValue(Tool.KEY)))
195:                        iterator.remove();
196:                }
197:
198:                ContextHelpTool helpTool = new ContextHelpTool();
199:                helpTool.setHelpCode(key);
200:                helpTool.putValue(Tool.KEY, key);
201:                String tabTitle = Client.getInstance().getResourceProvider()
202:                        .getMessage(key);
203:                helpTool.putValue(Tool.NAME, tabTitle);
204:                addTool(helpTool);
205:            }
206:
207:            public void show(SComponent component) {
208:                setContentPane(component);
209:                refreshTitle();
210:                refreshActions();
211:                refreshTools();
212:            }
213:
214:            public void hide(SComponent component) {
215:                setContentPane(new SLabel());
216:                setTitleCode(null);
217:                setControls(null);
218:                setTools(null);
219:            }
220:
221:            protected class SToolBarButton extends SButton {
222:
223:                private String text;
224:
225:                private SIcon icon;
226:
227:                private SIcon disabledIcon;
228:
229:                public SToolBarButton(Action action) {
230:                    super (action);
231:                }
232:
233:                public String getText() {
234:                    return text;
235:                }
236:
237:                public void setText(String text) {
238:                    this .text = text;
239:                }
240:
241:                public SIcon getIcon() {
242:                    return icon;
243:                }
244:
245:                public void setIcon(SIcon icon) {
246:                    this .icon = icon;
247:                }
248:
249:                public void setDisabledIcon(SIcon icon) {
250:                    this .disabledIcon = icon;
251:                }
252:
253:                public SIcon getDisabledIcon() {
254:                    return disabledIcon;
255:                }
256:            }
257:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.