Source Code Cross Referenced for InternalWindowPanel.java in  » Database-Client » SQLMinus » isql » 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 » Database Client » SQLMinus » isql 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package isql;
002:
003:        import javax.swing.*;
004:        import javax.swing.border.*;
005:        import javax.accessibility.*;
006:        import javax.swing.table.*;
007:
008:        import java.awt.Panel;
009:        import java.awt.Color;
010:        import java.awt.BorderLayout;
011:        import java.awt.GridLayout;
012:        import java.awt.Font;
013:        import java.awt.event.ActionListener;
014:        import java.awt.event.ActionEvent;
015:        import java.awt.Dimension;
016:        import java.awt.Graphics;
017:        import java.awt.Color;
018:        import java.awt.Rectangle;
019:        import java.awt.Container;
020:        import java.awt.Component;
021:        import java.util.*;
022:        import util.*;
023:        import java.awt.event.*;
024:
025:        /*
026:         */
027:        public class InternalWindowPanel extends JPanel {
028:            // Maker values
029:            //JLayeredPane lc;
030:            JDesktopPane lc;
031:            int makeCount = 0;
032:            SQLForm _form = null;
033:
034:            public InternalWindowPanel(SQLForm form) {
035:                setLayout(new BorderLayout());
036:                lc = new JDesktopPane();
037:                lc.setOpaque(false);
038:                _form = form;
039:
040:                add("Center", lc);
041:                //JInternalFrame maker = new JInternalFrame("maker",true,true,true,true);
042:                //   lc.add(maker, JLayeredPane.PALETTE_LAYER);  
043:
044:                /*
045:                   maker = createMakerFrame();
046:                   lc.add(maker, JLayeredPane.PALETTE_LAYER);  
047:                   add("Center", lc);
048:                 */
049:            }
050:
051:            /** returns frames whose titles match the given perl pattern
052:             */
053:            public JInternalFrame[] getMatchingFrames(String pattern) {
054:                JInternalFrame[] jifs = lc.getAllFrames();
055:                if (".".equals(pattern))
056:                    return jifs; // optimization
057:
058:                List vect = new ArrayList();
059:                for (int i = 0; i < jifs.length; i++) {
060:                    String title = jifs[i].getTitle();
061:                    if (PerlWrapper.isMatching(pattern, title)) {
062:                        vect.add(jifs[i]);
063:                    }
064:                }
065:                JInternalFrame[] ret = new JInternalFrame[vect.size()];
066:                vect.toArray(ret);
067:                return ret;
068:            }
069:
070:            /* this would recieve a JTable inside a scrollpane
071:             * and put it up as a internl frame
072:             */
073:            public void addFrame(TableModel tm, String title) {
074:                JTable jt = new JTable(tm);
075:                jt
076:                        .setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
077:                jt.setColumnSelectionAllowed(true);
078:                loadActions(jt);
079:
080:                // if you modify the next line, horizontal scrolling
081:                // wont happen !!! this could be a bug in 1.2/1.3
082:                jt.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
083:                TableColumnModel cm = jt.getColumnModel();
084:                if (cm == null) {
085:                    System.err.println("table is null");
086:                    return;
087:                }
088:                // TODO check for no rows and return.
089:                if (tm instanceof  TableMap) {
090:                    TableMap tmap = (TableMap) tm;
091:                    int cc = jt.getColumnCount();
092:                    for (int i = 0; i < cc; i++) {
093:                        TableColumn tc = cm.getColumn(i);
094:                        int cw = 4 * tmap.getWidth(i + 1);
095:                        if (cw < 75)
096:                            cw = 75;
097:                        if (cw > 200)
098:                            cw = 200;
099:                        tc.setPreferredWidth(cw);
100:                        tc.setMinWidth(50); // this is required for tables with many columns
101:                        // but it wont let user make a field less than this
102:                        // width - he will not be able to see columns on right
103:                    }
104:                }
105:
106:                JScrollPane panel = new JScrollPane(jt);
107:                addFrame(panel, title);
108:            }
109:
110:            public void addFrame(JComponent jc, String title) {
111:                JInternalFrame w;
112:                w = new JInternalFrame(title, true, true, true, true);
113:                /*
114:                   w.setClosable(closeBox.isSelected());
115:                   w.setMaximizable(maxBox.isSelected());
116:                   w.setIconifiable(iconBox.isSelected());
117:                 */
118:                //w.setResizable(resizeBox.isSelected());
119:                Integer layer = JLayeredPane.PALETTE_LAYER;
120:                int count = lc.getAllFrames().length;
121:                count++;
122:                makeCount++;
123:                Dimension size = lc.getSize();
124:                JTable jt = getJTable((JScrollPane) jc);
125:                //Dimension preferredsize = jt.getPreferredScrollableViewportSize();
126:                //too large like 343 pix
127:                int htpixels = (jt.getRowCount() + 5)
128:                        * ((JTable) jt).getRowHeight();
129:                int prefht2 = Math.min(htpixels, size.height);
130:                switch (count) {
131:                case 1:
132:                    w.setBounds(0, 0, size.width, prefht2);
133:                    break;
134:                //case 1: w.setBounds(0,0, size.width, size.height/2); break;
135:                ///case 1: w.setBounds(20,10, size.width/4, size.height/4); break;
136:                case 2:
137:                    w.setBounds(0, size.height / 2, size.width, prefht2);
138:                    //case 2: w.setBounds(20,size.height/2,size.width, size.height/2);
139:                    //case 2: w.setBounds(0,size.height/2,size.width/4, size.height/4);
140:                    break;
141:                default:
142:                    w.setBounds(0, 20 * (makeCount % 10), size.width, prefht2);
143:                    //w.setBounds(20+(makeCount*5), 40*(makeCount%5), size.width/4, size.height/4);
144:                }
145:                w.setContentPane(jc);
146:
147:                lc.add(w, layer);
148:                w.setVisible(true);
149:                try {
150:                    w.setSelected(true);
151:                } catch (java.beans.PropertyVetoException e2) {
152:                    System.err.println("JIF EXC" + e2.toString());
153:                }
154:                //drawStuff();
155:            }
156:
157:            private void makepopup(JTable jt, JMenuItem jmia[]) {
158:                final JTable jtf = jt;
159:                final JMenuItem jmiaf[] = jmia;
160:
161:                jt.addMouseListener(new MouseAdapter() {
162:                    public void mousePressed(MouseEvent e) {
163:                        if (e.isPopupTrigger()) {
164:                            JPopupMenu jpm = new JPopupMenu();
165:                            for (int i = 0; i < jmiaf.length; i++) {
166:                                jpm.add(jmiaf[i]);
167:                            }
168:                            jpm.pack();
169:                            jpm.show(jtf, e.getX(), e.getY());
170:                            jpm.setVisible(true);
171:                            jpm.requestFocus();
172:                        }
173:                    }
174:                });
175:            }
176:
177:            public void drawStuff() { // XXXX
178:
179:                java.awt.Graphics g = lc.getGraphics();
180:                JInternalFrame[] jifs = lc.getAllFrames();
181:                int prevx = 0, prevy = 0;
182:                int x, y;
183:                java.awt.Rectangle r1 = lc.getBounds(new Rectangle());
184:                g.clearRect(r1.x, r1.y, r1.width, r1.height);
185:                lc.paintImmediately(r1.x, r1.y, r1.width, r1.height);
186:                for (int i = 0; i < jifs.length; i++) {
187:                    java.awt.Rectangle r = jifs[i].getBounds(new Rectangle());
188:                    y = r.y + 40;
189:                    //x = (r.getX()+r.getWidth())/2;
190:                    x = r.x;
191:                    // draw linw
192:                    g.drawLine(x, y, prevx, prevy);
193:                    prevx = x;
194:                    prevy = y;
195:                }
196:            } // draw stuff
197:
198:            /** Load actions from table actions class.
199:             * RK added on 20031225 20:43:25
200:             * Load all actions automatically, now that TableA gives a map.
201:             */
202:            public void loadActions(JTable jt) {
203:
204:                Map actions = TableActions.getActionMap(_form, jt);
205:                JMenuItem jmia[] = new JMenuItem[actions.size()];
206:                Iterator it = actions.keySet().iterator();
207:                int i = 0;
208:                while (it.hasNext()) {
209:                    String s = (String) it.next();
210:                    AbstractAction a = (AbstractAction) actions.get(s);
211:                    jt.getActionMap().put(s, a);
212:                    jmia[i] = new JMenuItem(a);
213:                    // RK added on 20040103 22:55:21 added accelerators
214:                    String acc = (String) a.getValue("accelerator");
215:                    if (acc != null)
216:                        jmia[i].setAccelerator(KeyStroke.getKeyStroke(acc));
217:                    i++;
218:
219:                }
220:                makepopup(jt, jmia);
221:                // these need to be picked from the file TODO
222:                jt.getInputMap().put(KeyStroke.getKeyStroke("control DELETE"),
223:                        TableActions.deleteAction);
224:                jt.getInputMap().put(
225:                        KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0),
226:                        TableActions.deleteAction);
227:                jt.getInputMap().put(KeyStroke.getKeyStroke("alt U"),
228:                        TableActions.updateAction);
229:                jt.getInputMap().put(
230:                        KeyStroke.getKeyStroke(KeyEvent.VK_INSERT, 0),
231:                        TableActions.insertAction);
232:                jt.getInputMap().put(KeyStroke.getKeyStroke('/'),
233:                        TableActions.searchAction);
234:                jt.getInputMap().put(KeyStroke.getKeyStroke('o'),
235:                        TableActions.sortAction);
236:                jt.getInputMap().put(KeyStroke.getKeyStroke('O'),
237:                        TableActions.reversesortAction);
238:                jt.getInputMap().put(KeyStroke.getKeyStroke("control O"),
239:                        TableActions.asksortAction);
240:
241:                //Map bindings = _form.TNS.getBindingsForFrame();
242:                //IsqlUtil.bindToTable(bindings, jt);
243:                Map bindings = _form.getBindings().getBindingsForFrame();
244:                _form.getBindings().bindToTable(bindings, jt);
245:                //System.out.println(  "Loaded.");
246:
247:            }
248:
249:            /** add the given binding to all jtables, for the given perl
250:             * pattern. Use a dot (".") for all tables.
251:             */
252:            public void addBinding(String pattern, String key, String action) {
253:                JInternalFrame[] jifs = this .getMatchingFrames(pattern);
254:                for (int i = 0; i < jifs.length; i++) {
255:                    System.out.print("Binding " + key + " to Frame:"
256:                            + jifs[i].getTitle());
257:                    JScrollPane jsp = (JScrollPane) jifs[i].getContentPane();
258:                    JViewport jvp = jsp.getViewport();
259:                    Component co = jvp.getView();
260:                    if (!(co instanceof  JTable))
261:                        continue;
262:                    JTable jt = (JTable) co;
263:                    key = key.replace('-', ' ');
264:                    KeyStroke ks = KeyStroke.getKeyStroke(key);
265:                    if (ks == null) {
266:                        System.err.println("Binding failed for key:" + key);
267:                        return;
268:                    }
269:                    jt.getInputMap().put(ks, action);
270:                    System.out.println("  Done.");
271:                } // for
272:            } // addBinding
273:
274:            /** return the jtable from a jsp !!!.
275:             */
276:            public JTable getJTable(JScrollPane jsp) {
277:                //JScrollPane jsp = (JScrollPane) jif.getContentPane();
278:                JViewport jvp = jsp.getViewport();
279:                Component co = jvp.getView();
280:                if (!(co instanceof  JTable))
281:                    return null;
282:                ;
283:                return (JTable) co;
284:            }
285:
286:            /** return the jtable from a jif !!!.
287:             */
288:            public JTable getJTable(JInternalFrame jif) {
289:                JScrollPane jsp = (JScrollPane) jif.getContentPane();
290:                JViewport jvp = jsp.getViewport();
291:                Component co = jvp.getView();
292:                if (!(co instanceof  JTable))
293:                    return null;
294:                return (JTable) co;
295:            }
296:        } // class
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.