Source Code Cross Referenced for OwnerTable.java in  » Content-Management-System » contelligent » de » finix » contelligent » client » gui » access » 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 » Content Management System » contelligent » de.finix.contelligent.client.gui.access 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2001-2006 C:1 Financial Services GmbH
003:         *
004:         * This software is free software; you can redistribute it and/or
005:         * modify it under the terms of the GNU Lesser General Public
006:         * License Version 2.1, as published by the Free Software Foundation.
007:         *
008:         * This software is distributed in the hope that it will be useful,
009:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
010:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
011:         * Lesser General Public License for more details.
012:         *
013:         * You should have received a copy of the GNU Lesser General Public
014:         * License along with this library; if not, write to the Free Software
015:         * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA
016:         */
017:
018:        package de.finix.contelligent.client.gui.access;
019:
020:        import java.awt.datatransfer.Transferable;
021:        import java.awt.datatransfer.UnsupportedFlavorException;
022:        import java.awt.dnd.DnDConstants;
023:        import java.awt.dnd.DragGestureEvent;
024:        import java.awt.dnd.DragGestureListener;
025:        import java.awt.dnd.DragSource;
026:        import java.awt.dnd.DragSourceDragEvent;
027:        import java.awt.dnd.DragSourceDropEvent;
028:        import java.awt.dnd.DragSourceEvent;
029:        import java.awt.dnd.DragSourceListener;
030:        import java.awt.dnd.DropTarget;
031:        import java.awt.dnd.DropTargetDragEvent;
032:        import java.awt.dnd.DropTargetDropEvent;
033:        import java.awt.dnd.DropTargetEvent;
034:        import java.awt.dnd.DropTargetListener;
035:        import java.io.IOException;
036:
037:        import javax.swing.JLabel;
038:        import javax.swing.JTable;
039:        import javax.swing.ListSelectionModel;
040:        import javax.swing.table.TableCellRenderer;
041:
042:        import de.finix.contelligent.client.base.ContelligentComponent;
043:        import de.finix.contelligent.client.base.Type;
044:        import de.finix.contelligent.client.security.Principal;
045:        import de.finix.contelligent.client.util.dnd.SingleComponentTransferable;
046:
047:        public class OwnerTable extends JTable implements  DropTargetListener,
048:                DragSourceListener, DragGestureListener {
049:
050:            private boolean editable;
051:
052:            public OwnerTable(OwnerTableModel ownerTableModel) {
053:                super (ownerTableModel);
054:                setDefaultRenderer(Principal.class, new PrincipalRenderer());
055:                DropTarget dropTarget = new DropTarget(this , this );
056:                DragSource dragSource = new DragSource();
057:                dragSource.createDefaultDragGestureRecognizer(this ,
058:                        DnDConstants.ACTION_MOVE, this );
059:                getSelectionModel().setSelectionMode(
060:                        ListSelectionModel.SINGLE_SELECTION);
061:            }
062:
063:            static class PrincipalRenderer implements  TableCellRenderer {
064:                public java.awt.Component getTableCellRendererComponent(
065:                        JTable table, Object object, boolean isSelected,
066:                        boolean hasFocus, int row, int column) {
067:                    JLabel cellRenderer = new JLabel();
068:                    cellRenderer.setOpaque(true);
069:                    if (isSelected) {
070:                        cellRenderer.setBackground(table
071:                                .getSelectionBackground());
072:                        cellRenderer.setForeground(table
073:                                .getSelectionForeground());
074:                    } else {
075:                        cellRenderer.setBackground(table.getBackground());
076:                    }
077:                    Principal principal = (Principal) object;
078:                    cellRenderer.setFont(table.getFont());
079:                    cellRenderer.setText(principal.getDisplayName());
080:                    return cellRenderer;
081:                }
082:
083:                private java.awt.Component renderingComponent = null;
084:            }
085:
086:            /**
087:             * is invoked when you are dragging over the DropSite
088:             * 
089:             */
090:            public void dragEnter(DropTargetDragEvent event) {
091:                // debug messages for diagnostics
092:                event.acceptDrag(DnDConstants.ACTION_MOVE);
093:            }
094:
095:            /**
096:             * is invoked when you are exit the DropSite without dropping
097:             * 
098:             */
099:            public void dragExit(DropTargetEvent event) {
100:            }
101:
102:            /**
103:             * is invoked when a drag operation is going on
104:             * 
105:             */
106:            public void dragOver(DropTargetDragEvent event) {
107:            }
108:
109:            /**
110:             * a drop has occurred
111:             * 
112:             */
113:            public void drop(DropTargetDropEvent event) {
114:                // TODO: This seems to be code for the old, old user system. See if we can remove this.
115:                if (editable) {
116:                    try {
117:                        Transferable transferable = event.getTransferable();
118:
119:                        // we accept ContelligentComponent and Strings
120:                        if (transferable
121:                                .isDataFlavorSupported(SingleComponentTransferable.componentFlavor)) {
122:                            event.acceptDrop(DnDConstants.ACTION_MOVE);
123:                            ContelligentComponent droppedComponent = (ContelligentComponent) transferable
124:                                    .getTransferData(SingleComponentTransferable.componentFlavor);
125:                            if (droppedComponent.instanceOf(Type.ROLE)
126:                                    || droppedComponent.instanceOf(Type.USER)) {
127:                                String principalString = droppedComponent
128:                                        .getPropertyValue(ContelligentComponent.PRINCIPAL_STRING);
129:                                String principalGroupId = principalString
130:                                        .substring(0, principalString
131:                                                .indexOf(":"));
132:                                ;
133:                                String principalId = principalString
134:                                        .substring(principalString.indexOf(":") + 1);
135:                                ;
136:                                ((OwnerTableModel) getModel())
137:                                        .addOwner(new Principal(
138:                                                principalGroupId, principalId));
139:                            }
140:                            event.getDropTargetContext().dropComplete(true);
141:                        } else {
142:                            event.rejectDrop();
143:                        }
144:                    } catch (IOException exception) {
145:                        exception.printStackTrace();
146:                        event.rejectDrop();
147:                    } catch (UnsupportedFlavorException ufException) {
148:                        ufException.printStackTrace();
149:                        event.rejectDrop();
150:                    }
151:                }
152:            }
153:
154:            /**
155:             * is invoked if the use modifies the current drop gesture
156:             * 
157:             */
158:            public void dropActionChanged(DropTargetDragEvent event) {
159:            }
160:
161:            /**
162:             * a drag gesture has been initiated
163:             * 
164:             */
165:            public void dragGestureRecognized(DragGestureEvent event) {
166:            }
167:
168:            /**
169:             * this message goes to DragSourceListener, informing it that the dragging
170:             * has ended
171:             * 
172:             */
173:            public void dragDropEnd(DragSourceDropEvent event) {
174:                if (event.getDropSuccess()) {
175:                    // removeElement((ContelligentComponent)event.getDragSourceContext().getTransferable());
176:                }
177:            }
178:
179:            /**
180:             * this message goes to DragSourceListener, informing it that the dragging
181:             * has entered the DropSite
182:             * 
183:             */
184:            public void dragEnter(DragSourceDragEvent event) {
185:            }
186:
187:            /**
188:             * this message goes to DragSourceListener, informing it that the dragging
189:             * has exited the DropSite
190:             * 
191:             */
192:            public void dragExit(DragSourceEvent event) {
193:            }
194:
195:            /**
196:             * this message goes to DragSourceListener, informing it that the dragging
197:             * is currently ocurring over the DropSite
198:             * 
199:             */
200:            public void dragOver(DragSourceDragEvent event) {
201:            }
202:
203:            /**
204:             * is invoked when the user changes the dropAction
205:             * 
206:             */
207:            public void dropActionChanged(DragSourceDragEvent event) {
208:            }
209:
210:            public void setEditable(boolean editable) {
211:                this .editable = editable;
212:            }
213:
214:            public boolean isEditable() {
215:                return editable;
216:            }
217:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.