Source Code Cross Referenced for HoSwingComboBox.java in  » J2EE » WiSerFramework » de » ug2t » channel » ho » client » swing » 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 » J2EE » WiSerFramework » de.ug2t.channel.ho.client.swing 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        // @@
002:        // @@
003:        /*
004:         * Wi.Ser Framework
005:         *
006:         * LGPL Version: 1.8.1, 20-September-2007  
007:         * Copyright (C) 2005-2006 Dirk von der Weiden <dvdw@imail.de>
008:         *
009:         * This library is free software; you can redistribute it and/or
010:         * modify it under the terms of the GNU Lesser General Public
011:         * License as published by the Free Software Foundation; either
012:         * version 2 of the License, or (at your option) any later version.
013:         *
014:         * This library is distributed in the hope that it will be useful,
015:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
016:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
017:         * Lesser General Public License for more details.
018:         *
019:         * You should have received a copy of the GNU Lesser General Public
020:         * License along with this library located in LGPL.txt in the 
021:         * license directory; if not, write to the 
022:         * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
023:         * Boston, MA  02111-1307, USA.
024:         * 
025:         * If this agreement does not cover your requirements, please contact us
026:         * via email to get detailed information about the commercial license 
027:         * or our service offerings!
028:         *
029:         */
030:        // @@
031:        package de.ug2t.channel.ho.client.swing;
032:
033:        import java.awt.*;
034:        import java.awt.event.*;
035:        import java.util.*;
036:
037:        import javax.swing.*;
038:        import javax.swing.plaf.basic.*;
039:
040:        import de.ug2t.kernel.*;
041:        import de.ug2t.unifiedGui.interfaces.*;
042:
043:        public final class HoSwingComboBox extends HoSwingComponent implements 
044:                IUnComboBox, IUnSyncComponent {
045:            protected MyJComboBox pdm_swingObj = null;
046:            protected HashMap pdm_values = new LinkedHashMap();
047:            protected HashMap pdm_values2 = new LinkedHashMap();
048:            protected Component pdm_subCmp = null;
049:
050:            class MyJComboBox extends JComboBox {
051:                public boolean selectWithKeyChar(char keyChar) {
052:                    if (HoSwingComboBox.this .pdm_subCmp == null)
053:                        return (super .selectWithKeyChar(keyChar));
054:                    else
055:                        return (false);
056:                }
057:            }
058:
059:            final class MyComboBoxUI extends BasicComboBoxUI {
060:                public Rectangle pcmf_getItemRect() {
061:                    return (this .rectangleForCurrentValue());
062:                }
063:            }
064:
065:            final class MyMouseDisp implements  MouseListener {
066:                public void pemf_handle(MouseEvent e, char xType) {
067:                    HoSwingComboBox.this .pdm_subCmp = null;
068:
069:                    Object l_sel = HoSwingComboBox.this .pdm_swingObj
070:                            .getSelectedItem();
071:                    Rectangle l_rect = ((MyComboBoxUI) HoSwingComboBox.this .pdm_swingObj
072:                            .getUI()).pcmf_getItemRect();
073:
074:                    if (l_sel instanceof  HoSwingComponent) {
075:                        ((HoSwingComponent) l_sel).pcmf_getSwingWidget()
076:                                .setBounds(0, 0, l_rect.width, l_rect.height);
077:
078:                        ((HoSwingComponent) l_sel).pcmf_getSwingWidget()
079:                                .validate();
080:
081:                        Container l_comp = (Container) ((Container) ((HoSwingComponent) l_sel)
082:                                .pcmf_getSwingWidget()).getComponentAt((int) e
083:                                .getX(), (int) e.getY());
084:
085:                        if (l_comp != null) {
086:                            Object l_source = e.getSource();
087:                            e.setSource(l_comp);
088:
089:                            int l_x = l_comp.getBounds().x;
090:                            int l_y = l_comp.getBounds().y;
091:
092:                            if (l_comp != ((HoSwingComponent) l_sel)
093:                                    .pcmf_getSwingWidget()) {
094:                                l_x = l_comp.getBounds().x;
095:                                l_y = l_comp.getBounds().y;
096:                            }
097:
098:                            e.translatePoint(-l_x, -l_y);
099:
100:                            HoSwingComboBox.this .pdm_subCmp = HoSwingMouseEventDispatcher
101:                                    .pcmf_dispatch(e, xType, l_comp);
102:
103:                            if (HoSwingComboBox.this .pdm_subCmp.hasFocus())
104:                                HoSwingComboBox.this .pdm_swingObj
105:                                        .requestFocus();
106:
107:                            e.translatePoint(+l_x, +l_y);
108:                            e.setSource(l_source);
109:                        }
110:                    }
111:
112:                    HoSwingComboBox.this .pdm_swingObj.repaint();
113:                }
114:
115:                public void mouseClicked(MouseEvent e) {
116:                    this .pemf_handle(e,
117:                            HoSwingMouseEventDispatcher.MOUSE_CLICKED);
118:                }
119:
120:                public void mousePressed(MouseEvent e) {
121:                    this .pemf_handle(e,
122:                            HoSwingMouseEventDispatcher.MOUSE_PRESSED);
123:                }
124:
125:                public void mouseReleased(MouseEvent e) {
126:                    this .pemf_handle(e,
127:                            HoSwingMouseEventDispatcher.MOUSE_RELEASED);
128:                }
129:
130:                public void mouseEntered(MouseEvent e) {
131:                    this .pemf_handle(e,
132:                            HoSwingMouseEventDispatcher.MOUSE_ENTERED);
133:                }
134:
135:                public void mouseExited(MouseEvent e) {
136:                    this .pemf_handle(e,
137:                            HoSwingMouseEventDispatcher.MOUSE_EXITED);
138:                }
139:            };
140:
141:            final class MyKeyDisp implements  KeyListener {
142:                public void pcmf_handle(KeyEvent arg0) {
143:                    if (HoSwingComboBox.this .pdm_subCmp != null) {
144:                        arg0.setSource(HoSwingComboBox.this .pdm_subCmp);
145:                        HoSwingComboBox.this .pdm_subCmp.dispatchEvent(arg0);
146:                        HoSwingComboBox.this .pdm_subCmp.repaint();
147:                    }
148:                    HoSwingComboBox.this .pdm_swingObj.repaint();
149:                }
150:
151:                public void keyPressed(KeyEvent arg0) {
152:                    this .pcmf_handle(arg0);
153:                }
154:
155:                public void keyReleased(KeyEvent arg0) {
156:                    this .pcmf_handle(arg0);
157:                }
158:
159:                public void keyTyped(KeyEvent arg0) {
160:                    this .pcmf_handle(arg0);
161:                }
162:            };
163:
164:            public HoSwingComboBox(String xName, String xValue, String xString,
165:                    IUnApplication xAppl) throws Exception {
166:                super (xName, xAppl);
167:
168:                this .pdm_swingObj = new MyJComboBox();
169:                this .pdm_swingObj.setUI(new MyComboBoxUI());
170:                this .pdm_swingObj.addMouseListener(new MyMouseDisp());
171:                this .pdm_swingObj.addKeyListener(new MyKeyDisp());
172:
173:                super .pdm_realSwingCmp = this .pdm_swingObj;
174:                pdm_swingObj.setRenderer(new HoSwingFlexListCellRenderer());
175:                this .pcmf_setLocalValue(xValue);
176:
177:                if (xString.equals("") == false) {
178:                    pdm_values.put(xString, xValue);
179:                    pdm_values2.put(xValue, xString);
180:                    this .pdm_swingObj.addItem(xString);
181:                    this .pdm_swingObj.setEditable(false);
182:                }
183:                this .pdm_swingObj.setMinimumSize(this .pdm_swingObj
184:                        .getPreferredSize());
185:                ((HoSwingClient) xAppl).pcmf_addKeyDispatcher(this );
186:
187:                final ActionListener l_f = new ActionListener() {
188:                    public void actionPerformed(ActionEvent ev) {
189:                        try {
190:                            if (HoSwingComboBox.this .pcmf_getAppl()
191:                                    .pcmf_getActive() == null)
192:                                return;
193:
194:                            String l_objName = HoSwingComboBox.this 
195:                                    .pcmf_getObjName();
196:
197:                            // Lokale Listener aufrufen
198:                            Object l_selection = HoSwingComboBox.this .pdm_swingObj
199:                                    .getSelectedItem();
200:                            if (l_selection == null) {
201:                                HoSwingComboBox.this .pdm_swingObj
202:                                        .setSelectedItem(HoSwingComboBox.this .pdm_values2
203:                                                .get(HoSwingComboBox.this 
204:                                                        .pcmf_getValue()));
205:                                return;
206:                            }
207:                            ;
208:                            Object l_value = HoSwingComboBox.this .pdm_values
209:                                    .get(HoSwingComboBox.this .pdm_swingObj
210:                                            .getSelectedItem());
211:                            if (l_value == null)
212:                                l_value = HoSwingComboBox.this .pdm_swingObj
213:                                        .getSelectedItem();
214:
215:                            HoSwingComboBox.this .pcmf_setLocalValue(l_value);
216:                            HoSwingComboBox.this .pcmf_setRefresh();
217:                            HoSwingComboBox.this .pcmf_dispatchEvent();
218:
219:                            if (HoSwingComboBox.this .pem_session
220:                                    .pcmf_isDisabled())
221:                                return;
222:
223:                            // Werte setzen um diese zum Server zu übertragen
224:                            ((HoSwingPage) HoSwingComboBox.this .pcmf_getAppl()
225:                                    .pcmf_getActive()).pcmf_setSubmitValue(
226:                                    l_objName, HoSwingComboBox.this 
227:                                            .pcmf_getValue().toString());
228:                            HoSwingComboBox.this .pcmf_addSyncedWidgets(
229:                                    (HoSwingPage) HoSwingComboBox.this 
230:                                            .pcmf_getAppl().pcmf_getActive(),
231:                                    HoSwingComboBox.this );
232:                            if (HoSwingComboBox.this .pcmf_getUnComponent()
233:                                    .pcmf_isSubmit() == true)
234:                                ((HoSwingPage) HoSwingComboBox.this 
235:                                        .pcmf_getAppl().pcmf_getActive())
236:                                        .pcmf_submit();
237:                        } catch (Exception e) {
238:                            KeLog.pcmf_logException("ug2t", this , e);
239:                        }
240:                        ;
241:                    };
242:                };
243:                this .pdm_swingObj.addActionListener(l_f);
244:
245:                return;
246:            }
247:
248:            public void pcmf_addValueObj(String xValue, KeRegisteredObject xObj) {
249:                pdm_values.put(xObj, xValue);
250:                pdm_values2.put(xValue, xObj);
251:                this .pdm_swingObj.addItem(xObj);
252:                ((HoSwingFlexListCellRenderer) this .pdm_swingObj.getRenderer())
253:                        .pcmf_resetAllColors();
254:                this .pdm_swingObj
255:                        .setRenderer(new HoSwingFlexListCellRenderer());
256:                this .pdm_swingObj.setMinimumSize(this .pdm_swingObj
257:                        .getPreferredSize());
258:            };
259:
260:            public void pcmf_addValue(String xValue, String xString) {
261:                pdm_values.put(KeTools.pcmf_deRefObj(xString), xValue);
262:                pdm_values2.put(xValue, KeTools.pcmf_deRefObj(xString));
263:                this .pdm_swingObj.addItem(KeTools.pcmf_deRefObj(xString));
264:                ((HoSwingFlexListCellRenderer) this .pdm_swingObj.getRenderer())
265:                        .pcmf_resetAllColors();
266:                this .pdm_swingObj
267:                        .setRenderer(new HoSwingFlexListCellRenderer());
268:                this .pdm_swingObj.setMinimumSize(this .pdm_swingObj
269:                        .getPreferredSize());
270:            };
271:
272:            public void pcmf_removeValue(String xValue) {
273:                pdm_values2.remove(pdm_values.remove(xValue));
274:                this .pdm_swingObj.removeItem(KeTools.pcmf_deRefObj(xValue));
275:                ((HoSwingFlexListCellRenderer) this .pdm_swingObj.getRenderer())
276:                        .pcmf_resetAllColors();
277:                this .pdm_swingObj
278:                        .setRenderer(new HoSwingFlexListCellRenderer());
279:                this .pdm_swingObj.setMinimumSize(this .pdm_swingObj
280:                        .getPreferredSize());
281:            };
282:
283:            public void pcmf_beginTr() {
284:                return;
285:            }
286:
287:            public void pcmf_commitTr() {
288:                return;
289:            }
290:
291:            public HashMap pcmf_getValues() {
292:                return (pdm_values);
293:            };
294:
295:            public void pcmf_setValue(Object xValue) {
296:                this .pcmf_setLocalValue(xValue);
297:                if (xValue == null)
298:                    this .pdm_swingObj.setSelectedItem(null);
299:                else
300:                    this .pdm_swingObj.setSelectedItem(this .pdm_values2
301:                            .get(xValue));
302:
303:                return;
304:            };
305:
306:            public Object pcmf_getSelectedObject() {
307:                int l_idx = this .pcmf_getSelectedRow();
308:                if (l_idx == -1)
309:                    return (null);
310:
311:                Object l_ret = this .pdm_values2.keySet().toArray()[l_idx];
312:                return (l_ret);
313:            }
314:
315:            public Object pcmf_setSelectedRow(int xRow) {
316:                if (xRow >= this .pdm_values.size())
317:                    return (null);
318:
319:                Object l_ret = this .pdm_values2.keySet().toArray()[xRow];
320:                this .pcmf_setValue(l_ret);
321:
322:                return (l_ret);
323:            }
324:
325:            public int pcmf_getSelectedRow() {
326:                return (new ArrayList(this .pdm_values2.keySet()).indexOf(this 
327:                        .pcmf_getValue()));
328:            }
329:
330:            public void pcmf_clearComboBox() {
331:                this .pdm_values.clear();
332:                this .pdm_values2.clear();
333:
334:                Iterator l_it = new ArrayList(this .pcmf_getAllSubs())
335:                        .iterator();
336:                Object l_obj = null;
337:                while (l_it.hasNext()) {
338:                    l_obj = l_it.next();
339:                    if (l_obj instanceof  IUnContextMenu
340:                            || l_obj instanceof  IUnEventChannel)
341:                        continue;
342:
343:                    this .pcmf_removeNode((KeTreeNode) l_obj);
344:                }
345:
346:                this .pdm_swingObj.removeAllItems();
347:                ((HoSwingFlexListCellRenderer) this .pdm_swingObj.getRenderer())
348:                        .pcmf_resetAllColors();
349:                this .pdm_swingObj
350:                        .setRenderer(new HoSwingFlexListCellRenderer());
351:            };
352:
353:            public void pcmf_clearAndReleaseComboBox() {
354:                this .pdm_values.clear();
355:                this .pdm_values2.clear();
356:
357:                Iterator l_it = new ArrayList(this .pcmf_getAllSubs())
358:                        .iterator();
359:                Object l_obj = null;
360:                while (l_it.hasNext()) {
361:                    l_obj = l_it.next();
362:                    if (l_obj instanceof  IUnContextMenu
363:                            || l_obj instanceof  IUnEventChannel)
364:                        continue;
365:
366:                    this .pcmf_removeNode((KeTreeNode) l_obj);
367:                    ((KeTreeNode) l_obj).pcmf_releaseSubs();
368:                }
369:
370:                this .pdm_swingObj.removeAllItems();
371:                ((HoSwingFlexListCellRenderer) this .pdm_swingObj.getRenderer())
372:                        .pcmf_resetAllColors();
373:                this .pdm_swingObj
374:                        .setRenderer(new HoSwingFlexListCellRenderer());
375:            };
376:
377:            public void pcmf_setReadOnly(boolean xReadOnly) {
378:                this .pdm_swingObj.setEditable(!xReadOnly);
379:            }
380:
381:            public boolean pcmf_isReadOnly() {
382:                return (!this .pdm_swingObj.isEditable());
383:            }
384:
385:            private int pem_syncCnt = 0;
386:
387:            public Object pcmf_getValueToSync() {
388:                Object l_value = this .pdm_values
389:                        .get(HoSwingComboBox.this .pdm_swingObj
390:                                .getSelectedItem());
391:                if (l_value == null)
392:                    l_value = this .pdm_swingObj.getSelectedItem();
393:
394:                return (l_value);
395:            }
396:
397:            public void pcmf_setSynced() {
398:                this .pem_syncCnt++;
399:            }
400:
401:            public void pcmf_unSync() {
402:                this .pem_syncCnt--;
403:                if (this .pem_syncCnt < 0)
404:                    this .pem_syncCnt = 0;
405:            }
406:
407:            public boolean pcmf_isSynced() {
408:                if (this .pem_syncCnt == 0)
409:                    return (false);
410:                else
411:                    return (true);
412:            }
413:
414:            public void pcmf_clearListWidget() {
415:                this .pcmf_clearComboBox();
416:            }
417:
418:            public void pcmf_clearAndReleaseListWidget() {
419:                this .pcmf_clearAndReleaseComboBox();
420:            }
421:
422:            public boolean pcmf_isSelectable() {
423:                return (true);
424:            }
425:
426:            public KeTreeNode pcmf_addNode(String xName, KeTreeNode xNode) {
427:                if (xNode instanceof  IUnContextMenu)
428:                    this .pdm_realSwingCmp
429:                            .add(((HoSwingComponent) xNode).pdm_realSwingCmp);
430:
431:                if (xNode instanceof  IUnEventChannel)
432:                    this .pdmf_addChannelListener((IUnEventChannel) xNode);
433:
434:                return (super .pcmf_addNodeLocal(xName, xNode));
435:            };
436:
437:            public KeTreeElement pcmf_addElement(String xName,
438:                    KeTreeElement xNode) {
439:                if (xNode instanceof  IUnContextMenu)
440:                    this .pdm_realSwingCmp
441:                            .add(((HoSwingComponent) xNode).pdm_realSwingCmp);
442:
443:                if (xNode instanceof  IUnEventChannel) {
444:                    this .pdmf_addChannelListener((IUnEventChannel) xNode);
445:                    return (this);
446:                }
447:                ;
448:
449:                return (super.pcmf_addElementLocal(xName, xNode));
450:            };
451:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.