Source Code Cross Referenced for JDraggableTabbedPane.java in  » Report » iReport-2.0.5 » it » businesslogic » ireport » gui » docking » 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 » Report » iReport 2.0.5 » it.businesslogic.ireport.gui.docking 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright (C) 2005 - 2008 JasperSoft Corporation.  All rights reserved. 
003:         * http://www.jaspersoft.com.
004:         *
005:         * Unless you have purchased a commercial license agreement from JasperSoft,
006:         * the following license terms apply:
007:         *
008:         * This program is free software; you can redistribute it and/or modify
009:         * it under the terms of the GNU General Public License version 2 as published by
010:         * the Free Software Foundation.
011:         *
012:         * This program is distributed WITHOUT ANY WARRANTY; and without the
013:         * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
014:         * See the GNU General Public License for more details.
015:         *
016:         * You should have received a copy of the GNU General Public License
017:         * along with this program; if not, see http://www.gnu.org/licenses/gpl.txt
018:         * or write to:
019:         *
020:         * Free Software Foundation, Inc.,
021:         * 59 Temple Place - Suite 330,
022:         * Boston, MA  USA  02111-1307
023:         *
024:         *
025:         *
026:         *
027:         * JDraggableTabbedPane.java
028:         * 
029:         * Created on January 26, 2006, 9:16 AM
030:         *
031:         */
032:
033:        package it.businesslogic.ireport.gui.docking;
034:
035:        import it.businesslogic.ireport.gui.MainFrame;
036:        import java.awt.datatransfer.DataFlavor;
037:        import java.awt.datatransfer.Transferable;
038:        import java.awt.dnd.DnDConstants;
039:        import java.awt.dnd.DragGestureEvent;
040:        import java.awt.dnd.DragGestureListener;
041:        import java.awt.dnd.DragSource;
042:        import java.awt.dnd.DragSourceContext;
043:        import java.awt.dnd.DragSourceDragEvent;
044:        import java.awt.dnd.DragSourceDropEvent;
045:        import java.awt.dnd.DragSourceEvent;
046:        import java.awt.dnd.DragSourceListener;
047:        import java.awt.dnd.DropTarget;
048:        import java.awt.dnd.DropTargetContext;
049:        import java.awt.dnd.DropTargetDragEvent;
050:        import java.awt.dnd.DropTargetDropEvent;
051:        import java.awt.dnd.DropTargetEvent;
052:        import java.awt.dnd.DropTargetListener;
053:        import java.awt.dnd.InvalidDnDOperationException;
054:        import java.awt.event.MouseAdapter;
055:        import javax.swing.JPopupMenu;
056:        import javax.swing.JTabbedPane;
057:        import it.businesslogic.ireport.util.LanguageChangedEvent;
058:        import it.businesslogic.ireport.util.I18n;
059:        import it.businesslogic.ireport.util.*;
060:
061:        /**
062:         *
063:         * @author gtoffoli
064:         */
065:        public class JDraggableTabbedPane extends ExtendedTabbedPane implements 
066:                LanguageChangedListener {
067:
068:            private javax.swing.JMenuItem jMenuItemMerge;
069:            private javax.swing.JMenuItem jMenuItemUnmerge;
070:            private javax.swing.JPopupMenu jPopupMenu;
071:
072:            private DockingContainer dockingContainer = null;
073:            private int position = 0;
074:
075:            /** Creates a new instance of JDraggableTabbedPane */
076:            public JDraggableTabbedPane() {
077:                super ();
078:                it.businesslogic.ireport.util.I18n
079:                        .setCurrentLocale(System.getProperty("Language"),
080:                                System.getProperty("Country"));
081:                this .dragSource = DragSource.getDefaultDragSource();
082:                this .dgListener = new DGListener();
083:                this .dsListener = new DSListener((int) (1000 * Math.random()));
084:                this .dtListener = new GenericDragTargetListener();
085:
086:                // component, ops, listener, accepting
087:                this .dropTarget = new DropTarget(this , this .acceptableActions,
088:                        this .dtListener, true);
089:
090:                // component, action, listener
091:                this .dragSource.createDefaultDragGestureRecognizer(this ,
092:                        this .dragAction, this .dgListener);
093:
094:                jPopupMenu = new JPopupMenu();
095:
096:                jMenuItemMerge = new javax.swing.JMenuItem();
097:                jMenuItemMerge.setText("Merge panels");
098:                jMenuItemMerge.setEnabled(true);
099:                jMenuItemMerge
100:                        .addActionListener(new java.awt.event.ActionListener() {
101:                            public void actionPerformed(
102:                                    java.awt.event.ActionEvent evt) {
103:                                jMenuItemMergeActionPerformed(evt);
104:                            }
105:                        });
106:
107:                jPopupMenu.add(jMenuItemMerge);
108:
109:                jMenuItemUnmerge = new javax.swing.JMenuItem();
110:                jMenuItemUnmerge.setText("Separate panel");
111:                jMenuItemUnmerge.setEnabled(true);
112:                jMenuItemUnmerge
113:                        .addActionListener(new java.awt.event.ActionListener() {
114:                            public void actionPerformed(
115:                                    java.awt.event.ActionEvent evt) {
116:                                jMenuItemUnmergeActionPerformed(evt);
117:                            }
118:                        });
119:
120:                jPopupMenu.add(jMenuItemUnmerge);
121:
122:                this .addMouseListener(new java.awt.event.MouseAdapter() {
123:                    public void mouseClicked(java.awt.event.MouseEvent evt) {
124:                        onMouseClicked(evt);
125:                    }
126:                });
127:
128:                this .setOpaque(true);
129:
130:                I18n.addOnLanguageChangedListener(this );
131:
132:            }
133:
134:            private void jMenuItemUnmergeActionPerformed(
135:                    java.awt.event.ActionEvent evt) {
136:
137:                PanelView pv = new PanelView(JDraggableTabbedPane.this 
138:                        .getTitleAt(JDraggableTabbedPane.this 
139:                                .getSelectedIndex()), JDraggableTabbedPane.this 
140:                        .getSelectedComponent(), JDraggableTabbedPane.this 
141:                        .getPosition(), JDraggableTabbedPane.this 
142:                        .isClosable(JDraggableTabbedPane.this 
143:                                .getSelectedIndex()));
144:                getDockingContainer().moveComponent(pv, pv.getPosition(),
145:                        DockingContainer.INSERT_MODE_NEWPOSITION);
146:            }
147:
148:            private void jMenuItemMergeActionPerformed(
149:                    java.awt.event.ActionEvent evt) {
150:                getDockingContainer().mergePosition(this .getPosition());
151:            }
152:
153:            public void onMouseClicked(java.awt.event.MouseEvent evt) {
154:                if (evt.getButton() == evt.BUTTON3 && evt.getClickCount() == 1) {
155:                    this .jPopupMenu.show(this , evt.getPoint().x,
156:                            evt.getPoint().y);
157:                }
158:            }
159:
160:            /**
161:             * DGListener
162:             * a listener that will start the drag.
163:             * has access to top level's dsListener and dragSource
164:             * @see java.awt.dnd.DragGestureListener
165:             * @see java.awt.dnd.DragSource
166:             * @see java.awt.datatransfer.StringSelection
167:             */
168:            class DGListener implements  DragGestureListener {
169:                /**
170:                 * Start the drag if the operation is ok.
171:                 * uses java.awt.datatransfer.StringSelection to transfer
172:                 * the label's data
173:                 * @param e the event object
174:                 */
175:                public void dragGestureRecognized(DragGestureEvent e) {
176:
177:                    // if the action is ok we go ahead
178:                    // otherwise we punt
179:                    if ((e.getDragAction() & JDraggableTabbedPane.this .dragAction) == 0)
180:                        return;
181:
182:                    // get the label's text and put it inside a Transferable
183:                    // Transferable transferable = new StringSelection( DragLabel.this.getText() );
184:                    if (JDraggableTabbedPane.this .getSelectedIndex() < 0)
185:                        return;
186:
187:                    PanelView pv = new PanelView(JDraggableTabbedPane.this 
188:                            .getTitleAt(JDraggableTabbedPane.this 
189:                                    .getSelectedIndex()),
190:                            JDraggableTabbedPane.this .getSelectedComponent(),
191:                            JDraggableTabbedPane.this .getPosition(),
192:                            JDraggableTabbedPane.this 
193:                                    .isClosable(JDraggableTabbedPane.this 
194:                                            .getSelectedIndex()));
195:                    pv.setDockingContainer(JDraggableTabbedPane.this 
196:                            .getDockingContainer());
197:                    Transferable transferable = new PanelTransferable(pv);
198:
199:                    // now kick off the drag
200:                    try {
201:                        // initial cursor, transferrable, dsource listener
202:                        e.startDrag(DragSource.DefaultCopyNoDrop, transferable,
203:                                JDraggableTabbedPane.this .dsListener);
204:
205:                        // or if dragSource is a variable
206:                        // dragSource.startDrag(e, DragSource.DefaultCopyDrop, transferable, dsListener);
207:
208:                        // or if you'd like to use a drag image if supported
209:
210:                        /*
211:                          if(DragSource.isDragImageSupported() )
212:                          // cursor, image, point, transferrable, dsource listener
213:                          e.startDrag(DragSource.DefaultCopyDrop, image, point, transferable, dsListener);
214:                         */
215:
216:                    } catch (InvalidDnDOperationException idoe) {
217:                    }
218:                }
219:            }
220:
221:            /**
222:             * DSListener
223:             * a listener that will track the state of the DnD operation
224:             *
225:             * @see java.awt.dnd.DragSourceListener
226:             * @see java.awt.dnd.DragSource
227:             * @see java.awt.datatransfer.StringSelection
228:             */
229:            class DSListener implements  DragSourceListener {
230:
231:                public int myId = 0;
232:
233:                public DSListener(int id) {
234:                    super ();
235:                    myId = id;
236:                }
237:
238:                /**
239:                 * @param e the event
240:                 */
241:                public void dragDropEnd(DragSourceDropEvent e) {
242:
243:                    if (GenericDragTargetListener.lastDp != null) {
244:                        GenericDragTargetListener.lastDp.repaint();
245:                        GenericDragTargetListener.lastDp = null;
246:                    }
247:                }
248:
249:                /**
250:                 * @param e the event
251:                 */
252:                public void dragEnter(DragSourceDragEvent e) {
253:                    DragSourceContext context = e.getDragSourceContext();
254:                    //intersection of the users selected action, and the source and target actions
255:                    int myaction = e.getDropAction();
256:                    if ((myaction & JDraggableTabbedPane.this .dragAction) != 0) {
257:                        context.setCursor(DragSource.DefaultCopyDrop);
258:                    } else {
259:                        context.setCursor(DragSource.DefaultCopyNoDrop);
260:                    }
261:                }
262:
263:                /**
264:                 * @param e the event
265:                 */
266:                public void dragOver(DragSourceDragEvent e) {
267:                    DragSourceContext context = e.getDragSourceContext();
268:                    int sa = context.getSourceActions();
269:                    int ua = e.getUserAction();
270:                    int da = e.getDropAction();
271:                    int ta = e.getTargetActions();
272:
273:                }
274:
275:                /**
276:                 * @param e the event
277:                 */
278:                public void dragExit(DragSourceEvent e) {
279:                }
280:
281:                /**
282:                 * for example, press shift during drag to change to
283:                 * a link action
284:                 * @param e the event
285:                 */
286:                public void dropActionChanged(DragSourceDragEvent e) {
287:                    DragSourceContext context = e.getDragSourceContext();
288:                    context.setCursor(DragSource.DefaultCopyNoDrop);
289:                }
290:            }
291:
292:            private DragSource dragSource;
293:            private DragGestureListener dgListener;
294:            private DragSourceListener dsListener;
295:            private DropTarget dropTarget;
296:            private DropTargetListener dtListener;
297:            private int dragAction = DnDConstants.ACTION_MOVE;
298:            private int acceptableActions = DnDConstants.ACTION_MOVE;
299:
300:            public DockingContainer getDockingContainer() {
301:                return dockingContainer;
302:            }
303:
304:            public void setDockingContainer(DockingContainer dockingContainer) {
305:                this .dockingContainer = dockingContainer;
306:            }
307:
308:            public int getPosition() {
309:                return position;
310:            }
311:
312:            public void setPosition(int position) {
313:                this .position = position;
314:            }
315:
316:            //added by Felix Firgau on April 24th 2006
317:            public void applyI18n() {
318:                // Start autogenerated code ----------------------
319:                // End autogenerated code ----------------------
320:                jMenuItemMerge.setText(it.businesslogic.ireport.util.I18n
321:                        .getString("mergePanels", "Merge panels"));
322:                jMenuItemUnmerge.setText(it.businesslogic.ireport.util.I18n
323:                        .getString("unmergePanel", "Seperate panel"));
324:            }
325:
326:            public void languageChanged(LanguageChangedEvent evt) {
327:                applyI18n();
328:            }
329:            //Modification end
330:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.