Source Code Cross Referenced for DragSourcePanel.java in  » Report » jmagallanes-1.0 » com » calipso » reportgenerator » userinterface » 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 » jmagallanes 1.0 » com.calipso.reportgenerator.userinterface 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package com.calipso.reportgenerator.userinterface;
002:
003:        import com.calipso.reportgenerator.common.InfoException;
004:
005:        import javax.swing.*;
006:        import java.awt.*;
007:        import java.awt.datatransfer.StringSelection;
008:        import java.awt.dnd.*;
009:        import java.util.Vector;
010:        import java.util.Iterator;
011:        import java.util.Set;
012:        import com.calipso.reportgenerator.common.IReportManager;
013:        import com.calipso.reportgenerator.common.ShowExceptionMessageDialog;
014:
015:        /**
016:         * Clese utilizada para crear un componente con propiedades de Drag
017:         */
018:        public class DragSourcePanel extends JPanel implements 
019:                DragGestureListener, DragSourceListener {
020:
021:            private JLabel label;
022:            private JButton button;
023:            private DimensionColumnValue framColVal;
024:            private Vector colVecJCeck;
025:            private PivotTable pivote;
026:            private String location;
027:            private IReportManager reportManager;
028:            private int reportHandle;
029:
030:            /**
031:             * Retorna el JLabel utilizado para colocar el nombre de la dimension
032:             * @return
033:             */
034:            public JLabel getLabel() {
035:                return label;
036:            }
037:
038:            /**
039:             *  Retorna el botón con los valores de las dimensiones
040:             * @return
041:             */
042:            public JButton getButton() {
043:                return button;
044:            }
045:
046:            /**
047:             * Setea al componente como drageable
048:             * @param name
049:             */
050:            public DragSourcePanel(String name, PivotTable pivote,
051:                    String description, String location,
052:                    IReportManager reportManager, int reportHandle) {
053:                this .pivote = pivote;
054:                this .location = location;
055:                this .reportManager = reportManager;
056:                this .reportHandle = reportHandle;
057:                label = new JLabel(description + "   ");
058:                label.setBackground(Color.BLACK);
059:                label.setForeground(Color.WHITE);
060:                Font font = new Font("Arial", Font.BOLD, 10);
061:                label.setFont(font);
062:                setName(name);
063:                setLayout(new BorderLayout());
064:                button = new JButton("  ");
065:                button.setPreferredSize(new Dimension(10, 10));
066:                add(button, BorderLayout.EAST);
067:                button.addActionListener(new java.awt.event.ActionListener() {
068:                    public void actionPerformed(java.awt.event.ActionEvent evt) {
069:                        try {
070:                            jButton1ActionPerformed();
071:                        } catch (Exception e) {
072:                            ShowExceptionMessageDialog
073:                                    .initExceptionDialogMessage(
074:                                            com.calipso.reportgenerator.common.LanguageTraslator
075:                                                    .traslate("89"), e);
076:                        }
077:                    }
078:                });
079:                add(label, BorderLayout.CENTER);
080:                DragSource.getDefaultDragSource()
081:                        .createDefaultDragGestureRecognizer(this ,
082:                                DnDConstants.ACTION_COPY_OR_MOVE, this );
083:            }
084:
085:            /**
086:             * Retorna un Objeto DimensionColumnValue
087:             * @return
088:             */
089:            public DimensionColumnValue getFramColVal() {
090:                return framColVal;
091:            }
092:
093:            /**
094:             * Dispara el evento en caso de realizar un ActionEvent sobre el botón con los valores de las dimensiones
095:             *
096:             */
097:            private void jButton1ActionPerformed() throws InfoException {
098:                Set set = getReportManager().getDimensionValues(
099:                        getReportHandle(), getName());
100:                int maxWidthLabel = Math.max((int) (getPreferredSize()
101:                        .getWidth()),
102:                        getMaxWidthLabel(storeCheckButtonLabel(set)));
103:                this .framColVal = new DimensionColumnValue(maxWidthLabel,
104:                        getLocationOnScreen(), pivote, colVecJCeck, location,
105:                        getName());
106:
107:            }
108:
109:            /**
110:             * Retorna el size máximo del label
111:             * @param vector
112:             * @return
113:             */
114:            private int getMaxWidthLabel(Vector vector) {
115:                Font font = new Font("Arial", Font.BOLD, 10);
116:                int width = 0;
117:                int max = -1;
118:                JTextField aux = null;
119:                for (int index = 0; index < vector.size(); index++) {
120:                    Object vec[] = (Object[]) vector.get(index);
121:                    String str = (vec[0]).toString();
122:                    width = getFontMetrics(font).stringWidth(str);
123:                    if (width > max) {
124:                        aux = new JTextField(str.trim());
125:                        max = (int) aux.getPreferredSize().getWidth()
126:                                + str.length();
127:                    }
128:                }
129:                return max;
130:            }
131:
132:            /**
133:             * Carga los valores de las dimensiones para cada componente
134:             * @return
135:             */
136:            private Vector storeCheckButtonLabel(Set set) {
137:                ColumnProperties properties = pivote.getTableProperties()
138:                        .getRowColumn(getName());
139:                Set unchecked = properties.getExcludeValue();
140:                colVecJCeck = new Vector();
141:                Iterator iterator = set.iterator();
142:                while (iterator.hasNext()) {
143:                    Object value = iterator.next();
144:                    Object[] btnArray = new Object[2];
145:                    btnArray[0] = value;
146:                    btnArray[1] = new Boolean(unchecked == null
147:                            || !unchecked.contains(value));
148:                    colVecJCeck.add(btnArray);
149:                }
150:                return colVecJCeck;
151:            }
152:
153:            public String getLocationOfComponent() {
154:                return location;
155:            }
156:
157:            /**
158:             * Implementación  de la interface DragGestureListener
159:             * @param dge
160:             */
161:            public void dragGestureRecognized(DragGestureEvent dge) {
162:                dge.startDrag(DragSource.DefaultCopyNoDrop,
163:                        new StringSelection(this .getName()), this );
164:            }
165:
166:            /**
167:             * Implementación de la interface DragSourceListener
168:             * @param dsde
169:             */
170:            public void dragEnter(DragSourceDragEvent dsde) {
171:                dsde.getDragSourceContext().setCursor(
172:                        DragSource.DefaultCopyDrop);
173:            }
174:
175:            /**
176:             * Implementación de la interface DragSourceListener
177:             * @param dsde
178:             */
179:            public void dragOver(DragSourceDragEvent dsde) {
180:            }
181:
182:            /**
183:             * Implementación de la interface DragSourceListener
184:             * @param dsde
185:             */
186:            public void dropActionChanged(DragSourceDragEvent dsde) {
187:            }
188:
189:            /**
190:             * Implementación de la interface DragSourceListener
191:             * @param dse
192:             */
193:            public void dragExit(DragSourceEvent dse) {
194:                dse.getDragSourceContext().setCursor(
195:                        DragSource.DefaultCopyNoDrop);
196:            }
197:
198:            /**
199:             * Implementación de la interface DragSourceListener
200:             * @param dsde
201:             */
202:            public void dragDropEnd(DragSourceDropEvent dsde) {
203:            }
204:
205:            public IReportManager getReportManager() {
206:                return reportManager;
207:            }
208:
209:            public int getReportHandle() {
210:                return reportHandle;
211:            }
212:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.