Source Code Cross Referenced for AddressbookDNDListView.java in  » Mail-Clients » columba-1.4 » org » columba » addressbook » gui » list » 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 » Mail Clients » columba 1.4 » org.columba.addressbook.gui.list 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        //The contents of this file are subject to the Mozilla Public License Version 1.1
002:        //(the "License"); you may not use this file except in compliance with the 
003:        //License. You may obtain a copy of the License at http://www.mozilla.org/MPL/
004:        //
005:        //Software distributed under the License is distributed on an "AS IS" basis,
006:        //WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License 
007:        //for the specific language governing rights and
008:        //limitations under the License.
009:        //
010:        //The Original Code is "The Columba Project"
011:        //
012:        //The Initial Developers of the Original Code are Frederik Dietz and Timo Stich.
013:        //Portions created by Frederik Dietz and Timo Stich are Copyright (C) 2003. 
014:        //
015:        //All Rights Reserved.
016:        package org.columba.addressbook.gui.list;
017:
018:        import java.awt.datatransfer.StringSelection;
019:        import java.awt.dnd.DnDConstants;
020:        import java.awt.dnd.DragGestureEvent;
021:        import java.awt.dnd.DragGestureListener;
022:        import java.awt.dnd.DragSource;
023:        import java.awt.dnd.DragSourceDragEvent;
024:        import java.awt.dnd.DragSourceDropEvent;
025:        import java.awt.dnd.DragSourceEvent;
026:        import java.awt.dnd.DragSourceListener;
027:        import java.awt.dnd.DropTarget;
028:        import java.awt.dnd.DropTargetDragEvent;
029:        import java.awt.dnd.DropTargetDropEvent;
030:        import java.awt.dnd.DropTargetEvent;
031:        import java.awt.dnd.DropTargetListener;
032:
033:        import javax.swing.event.ListSelectionEvent;
034:        import javax.swing.event.ListSelectionListener;
035:
036:        import org.columba.addressbook.facade.IHeaderItem;
037:        import org.columba.addressbook.model.IBasicModelPartial;
038:
039:        //import sun.security.krb5.internal.i;
040:        //import sun.security.krb5.internal.crypto.b;
041:
042:        /**
043:         * @version 1.0
044:         * @author
045:         */
046:        @SuppressWarnings({"serial","serial"})
047:        public class AddressbookDNDListView extends AddressbookListView
048:                implements  DropTargetListener, DragSourceListener,
049:                DragGestureListener, ListSelectionListener {
050:
051:            /**
052:             * enables this component to be a dropTarget
053:             */
054:            DropTarget dropTarget = null;
055:
056:            /**
057:             * enables this component to be a Drag Source
058:             */
059:            DragSource dragSource = null;
060:
061:            boolean acceptDrop = true;
062:
063:            private IBasicModelPartial[] selection1;
064:
065:            private IBasicModelPartial[] selection2;
066:
067:            int index = -1;
068:
069:            private boolean dndAction = false;
070:
071:            // Where, in the drag image, the mouse was clicked
072:            public AddressbookDNDListView() {
073:                super ();
074:
075:                addListSelectionListener(this );
076:
077:                dropTarget = new DropTarget(this , this );
078:                dragSource = DragSource.getDefaultDragSource();
079:
080:                if (acceptDrop == true) {
081:                    dragSource.createDefaultDragGestureRecognizer(this ,
082:                            DnDConstants.ACTION_COPY_OR_MOVE, this );
083:                } else {
084:                    dragSource.createDefaultDragGestureRecognizer(this ,
085:                            DnDConstants.ACTION_COPY, this );
086:                }
087:            }
088:
089:            public AddressbookDNDListView(AddressbookListModel model) {
090:                super (model);
091:
092:                addListSelectionListener(this );
093:
094:                dropTarget = new DropTarget(this , this );
095:                dragSource = new DragSource();
096:
097:                if (acceptDrop == true) {
098:                    dragSource.createDefaultDragGestureRecognizer(this ,
099:                            DnDConstants.ACTION_COPY_OR_MOVE, this );
100:                } else {
101:                    dragSource.createDefaultDragGestureRecognizer(this ,
102:                            DnDConstants.ACTION_COPY, this );
103:                }
104:            }
105:
106:            public void setAcceptDrop(boolean b) {
107:                acceptDrop = b;
108:            }
109:
110:            /**
111:             * is invoked when you are dragging over the DropSite
112:             * 
113:             */
114:            public void dragEnter(DropTargetDragEvent event) {
115:                // debug messages for diagnostics
116:                if (acceptDrop == true) {
117:                    event.acceptDrag(DnDConstants.ACTION_COPY_OR_MOVE);
118:                } else {
119:                    event.acceptDrag(DnDConstants.ACTION_COPY);
120:                }
121:            }
122:
123:            /**
124:             * is invoked when you are exit the DropSite without dropping
125:             * 
126:             */
127:            public void dragExit(DropTargetEvent event) {
128:            }
129:
130:            /**
131:             * is invoked when a drag operation is going on
132:             * 
133:             */
134:            public void dragOver(DropTargetDragEvent event) {
135:            }
136:
137:            /**
138:             * a drop has occurred
139:             * 
140:             */
141:            public void drop(DropTargetDropEvent event) {
142:                if (acceptDrop == false) {
143:                    event.rejectDrop();
144:
145:                    clearSelection();
146:
147:                    return;
148:                }
149:
150:                IBasicModelPartial[] items = HeaderItemDNDManager.getInstance()
151:                        .getHeaderItemList();
152:
153:                for (int i = 0; i < items.length; i++) {
154:                    addElement((IBasicModelPartial) ((IBasicModelPartial) items[i])
155:                            .clone());
156:                }
157:
158:                event.getDropTargetContext().dropComplete(true);
159:
160:                clearSelection();
161:            }
162:
163:            /**
164:             * is invoked if the use modifies the current drop gesture
165:             * 
166:             */
167:            public void dropActionChanged(DropTargetDragEvent event) {
168:            }
169:
170:            /**
171:             * a drag gesture has been initiated
172:             * 
173:             */
174:            public void dragGestureRecognized(DragGestureEvent event) {
175:                if (dndAction == false) {
176:                    /*
177:                     * HeaderItem[] items = new HeaderItem[selection1.length]; items =
178:                     * selection1;
179:                     * HeaderItemDNDManager.getInstance().setHeaderItemList(items);
180:                     */
181:                    if (selection1 == null) {
182:                        IBasicModelPartial[] items = new IBasicModelPartial[1];
183:                        items[0] = (IBasicModelPartial) getSelectedValue();
184:
185:                        HeaderItemDNDManager.getInstance().setHeaderItemList(
186:                                items);
187:                    } else if (selection1.length != 0) {
188:                        IBasicModelPartial[] items = new IBasicModelPartial[selection1.length];
189:                        items = selection1;
190:                        HeaderItemDNDManager.getInstance().setHeaderItemList(
191:                                items);
192:                    }
193:
194:                    /*
195:                     * else {
196:                     * 
197:                     * HeaderItem[] items = new HeaderItem[1]; items[0] = (HeaderItem)
198:                     * getSelectedValue();
199:                     * HeaderItemDNDManager.getInstance().setHeaderItemList(items); }
200:                     */
201:                } else {
202:                    /*
203:                     * HeaderItem[] items = new HeaderItem[selection2.length]; items =
204:                     * selection2;
205:                     * HeaderItemDNDManager.getInstance().setHeaderItemList(items);
206:                     */
207:                    if (selection2.length != 0) {
208:                        IBasicModelPartial[] items = new IBasicModelPartial[selection2.length];
209:                        items = selection2;
210:                        HeaderItemDNDManager.getInstance().setHeaderItemList(
211:                                items);
212:                    } else {
213:                        IBasicModelPartial[] items = new IBasicModelPartial[1];
214:                        items[0] = (IBasicModelPartial) getSelectedValue();
215:
216:                        HeaderItemDNDManager.getInstance().setHeaderItemList(
217:                                items);
218:                    }
219:                }
220:
221:                /*
222:                 * dragSource.startDrag( event, new Cursor(Cursor.DEFAULT_CURSOR),
223:                 * ImageLoader.getImageIcon("contact_small","Add16").getImage(), new
224:                 * Point(5, 5), new StringSelection("contact"), this);
225:                 */
226:                StringSelection text = new StringSelection("contact");
227:
228:                dragSource.startDrag(event, DragSource.DefaultMoveDrop, text,
229:                        this );
230:
231:                clearSelection();
232:            }
233:
234:            /**
235:             * this message goes to DragSourceListener, informing it that the dragging
236:             * has ended
237:             * 
238:             */
239:            public void dragDropEnd(DragSourceDropEvent event) {
240:                if (event.getDropSuccess()) {
241:                    if (acceptDrop == true) {
242:                        IBasicModelPartial[] items = HeaderItemDNDManager
243:                                .getInstance().getHeaderItemList();
244:
245:                        for (int i = 0; i < items.length; i++) {
246:                            ((AddressbookListModel) getModel())
247:                                    .removeElement(items[i]);
248:                        }
249:
250:                        // removeElement();
251:                    }
252:                }
253:            }
254:
255:            /**
256:             * this message goes to DragSourceListener, informing it that the dragging
257:             * has entered the DropSite
258:             * 
259:             */
260:            public void dragEnter(DragSourceDragEvent event) {
261:            }
262:
263:            /**
264:             * this message goes to DragSourceListener, informing it that the dragging
265:             * has exited the DropSite
266:             * 
267:             */
268:            public void dragExit(DragSourceEvent event) {
269:            }
270:
271:            /**
272:             * this message goes to DragSourceListener, informing it that the dragging
273:             * is currently ocurring over the DropSite
274:             * 
275:             */
276:            public void dragOver(DragSourceDragEvent event) {
277:            }
278:
279:            /**
280:             * is invoked when the user changes the dropAction
281:             * 
282:             */
283:            public void dropActionChanged(DragSourceDragEvent event) {
284:            }
285:
286:            /**
287:             * adds elements to itself
288:             * 
289:             */
290:            /**
291:             * removes an element from itself
292:             */
293:            public void removeElement() {
294:                ((AddressbookListModel) getModel())
295:                        .removeElement((IBasicModelPartial) getSelectedValue());
296:            }
297:
298:            public void valueChanged(ListSelectionEvent e) {
299:                if (dndAction == true) {
300:                    Object[] list = getSelectedValues();
301:
302:                    selection1 = new IBasicModelPartial[list.length];
303:
304:                    for (int i = 0; i < list.length; i++) {
305:                        selection1[i] = (IBasicModelPartial) list[i];
306:                    }
307:
308:                    dndAction = false;
309:                } else {
310:                    Object[] list = getSelectedValues();
311:
312:                    selection2 = new IBasicModelPartial[list.length];
313:
314:                    for (int i = 0; i < list.length; i++) {
315:                        selection2[i] = (IBasicModelPartial) list[i];
316:                    }
317:
318:                    dndAction = true;
319:                }
320:            }
321:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.