Source Code Cross Referenced for LoaderSelectionDialog.java in  » 6.0-JDK-Modules » java-3d » org » jdesktop » j3dfly » utils » loadercontrol » 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 » 6.0 JDK Modules » java 3d » org.jdesktop.j3dfly.utils.loadercontrol 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *  $Header: /cvs/j3dfly/J3dFly/src/org/jdesktop/j3dfly/utils/loadercontrol/LoaderSelectionDialog.java,v 1.1 2005/04/20 21:05:07 paulby Exp $
003:         *
004:         *                         Sun Public License Notice
005:         *
006:         *  The contents of this file are subject to the Sun Public License Version
007:         *  1.0 (the "License"). You may not use this file except in compliance with
008:         *  the License. A copy of the License is available at http://www.sun.com/
009:         *  
010:         *  The Original Code is Java 3D(tm) Fly Through.
011:         *  The Initial Developer of the Original Code is Paul Byrne.
012:         *  Portions created by Paul Byrne are Copyright (C) 2002.
013:         *  All Rights Reserved.
014:         *  
015:         *  Contributor(s): Paul Byrne.
016:         *  
017:         **/
018:        package org.jdesktop.j3dfly.utils.loadercontrol;
019:
020:        import java.util.HashMap;
021:        import java.util.ArrayList;
022:        import java.util.Iterator;
023:        import javax.swing.table.DefaultTableModel;
024:        import javax.swing.table.TableColumn;
025:        import javax.swing.event.TableModelEvent;
026:
027:        /**
028:         * A Dialog which allows users to choose which loaders are used for
029:         * a particular file format.
030:         *
031:         * @author Paul Byrne
032:         * @version	1.7, 01/18/02
033:         */
034:        public class LoaderSelectionDialog extends javax.swing.JDialog
035:                implements  javax.swing.event.TableModelListener {
036:
037:            private DefaultTableModel tableModel;
038:            private LoaderTableCellRenderer cellRenderer = new LoaderTableCellRenderer();
039:
040:            private HashMap loaderTypes;
041:            private int currentRow;
042:
043:            boolean okQuit = false;
044:
045:            /** Creates new form LoaderSelectionDialog */
046:            public LoaderSelectionDialog(java.awt.Frame parent, boolean modal) {
047:                super (parent, modal);
048:                initComponents();
049:
050:                if (org.jdesktop.j3dfly.utils.help.Help.isEnabled()) {
051:                    org.jdesktop.j3dfly.utils.help.Help.addHelpButton(helpB,
052:                            "loader.selection.dialog");
053:                } else {
054:                    buttonPanel.remove(helpB);
055:                }
056:
057:                pack();
058:
059:                tableModel = (DefaultTableModel) loaderTable.getModel();
060:                currentRow = 0;
061:                tableModel.addTableModelListener(this );
062:
063:                loaderTypes = new HashMap();
064:
065:                TableColumn nameColumn = loaderTable.getColumn("Loader Name");
066:                nameColumn.setCellRenderer(cellRenderer);
067:
068:                TableColumn extColumn = loaderTable.getColumn("File Extension");
069:                extColumn.setCellRenderer(cellRenderer);
070:
071:                TableColumn paramColumn = loaderTable.getColumn("Parameters");
072:                paramColumn.setCellRenderer(cellRenderer);
073:            }
074:
075:            /**
076:             * Show the dialog,
077:             * return true if Apply was pressed
078:             */
079:            public boolean showDialog() {
080:                okQuit = false;
081:                super .show();
082:
083:                return okQuit;
084:            }
085:
086:            /**
087:             * Add a loader to the list of available loaders
088:             */
089:            public void addLoader(String name, String fileExtension,
090:                    String parameters, boolean enabled, boolean available,
091:                    String classpathURL) {
092:
093:                if (!available) {
094:                    name = name.concat(".");
095:                    fileExtension = fileExtension.concat(".");
096:                    parameters = parameters.concat(".");
097:                    enabled = false;
098:                }
099:
100:                Boolean en = new Boolean(enabled);
101:                Boolean avail = new Boolean(available);
102:                tableModel.insertRow(currentRow, new Object[] { name,
103:                        fileExtension, parameters, en, avail, classpathURL });
104:                if (available) {
105:                    recordType(fileExtension, currentRow);
106:                }
107:                currentRow++;
108:            }
109:
110:            /**
111:             * Record which types are in which table row
112:             */
113:            private void recordType(String fileExtension, int row) {
114:                ArrayList rows = (ArrayList) loaderTypes.get(fileExtension);
115:                if (rows == null) {
116:                    rows = new ArrayList();
117:                    rows.add(new Integer(row));
118:                    loaderTypes.put(fileExtension, rows);
119:                } else {
120:                    rows.add(new Integer(row));
121:                }
122:            }
123:
124:            /**
125:             * Enable the loader in the specified row
126:             * Disable all other loaders that take the same file extension
127:             */
128:            private void enableLoader(int row) {
129:                String fileExtension = (String) tableModel.getValueAt(row, 1);
130:                ArrayList rowList = (ArrayList) loaderTypes.get(fileExtension);
131:                if (rowList != null) {
132:                    Iterator it = rowList.iterator();
133:                    while (it.hasNext()) {
134:                        Integer i = (Integer) it.next();
135:                        if (i.intValue() != row) {
136:                            tableModel.setValueAt(new Boolean(false), i
137:                                    .intValue(), 3);
138:                        }
139:                    }
140:                }
141:            }
142:
143:            /** This method is called from within the constructor to
144:             * initialize the form.
145:             * WARNING: Do NOT modify this code. The content of this method is
146:             * always regenerated by the FormEditor.
147:             */
148:            private void initComponents() {//GEN-BEGIN:initComponents
149:                jPanel1 = new javax.swing.JPanel();
150:                jScrollPane1 = new javax.swing.JScrollPane();
151:                loaderTable = new javax.swing.JTable();
152:                buttonPanel = new javax.swing.JPanel();
153:                applyB = new javax.swing.JButton();
154:                cancelB = new javax.swing.JButton();
155:                helpB = new javax.swing.JButton();
156:
157:                addWindowListener(new java.awt.event.WindowAdapter() {
158:                    public void windowClosing(java.awt.event.WindowEvent evt) {
159:                        closeDialog(evt);
160:                    }
161:                });
162:
163:                loaderTable.setModel(new javax.swing.table.DefaultTableModel(
164:                        new Object[][] {
165:
166:                        }, new String[] { "Loader Name", "File Extension",
167:                                "Parameters", "Enabled", "Available",
168:                                "Classpath URL" }) {
169:                    Class[] types = new Class[] { java.lang.String.class,
170:                            java.lang.String.class, java.lang.String.class,
171:                            java.lang.Boolean.class, java.lang.Boolean.class,
172:                            java.lang.String.class };
173:                    boolean[] canEdit = new boolean[] { false, false, false,
174:                            true, true, false };
175:
176:                    public Class getColumnClass(int columnIndex) {
177:                        return types[columnIndex];
178:                    }
179:
180:                    public boolean isCellEditable(int rowIndex, int columnIndex) {
181:                        return canEdit[columnIndex];
182:                    }
183:                });
184:                jScrollPane1.setViewportView(loaderTable);
185:
186:                jPanel1.add(jScrollPane1);
187:
188:                getContentPane().add(jPanel1, java.awt.BorderLayout.CENTER);
189:
190:                applyB.setText("Apply");
191:                applyB.addActionListener(new java.awt.event.ActionListener() {
192:                    public void actionPerformed(java.awt.event.ActionEvent evt) {
193:                        applyBActionPerformed(evt);
194:                    }
195:                });
196:
197:                buttonPanel.add(applyB);
198:
199:                cancelB.setText("Cancel");
200:                cancelB.addActionListener(new java.awt.event.ActionListener() {
201:                    public void actionPerformed(java.awt.event.ActionEvent evt) {
202:                        cancelBActionPerformed(evt);
203:                    }
204:                });
205:
206:                buttonPanel.add(cancelB);
207:
208:                helpB.setText("Help...");
209:                buttonPanel.add(helpB);
210:
211:                getContentPane().add(buttonPanel, java.awt.BorderLayout.SOUTH);
212:
213:            }//GEN-END:initComponents
214:
215:            private void cancelBActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancelBActionPerformed
216:            // Add your handling code here:
217:                setVisible(false);
218:                dispose();
219:                okQuit = false;
220:            }//GEN-LAST:event_cancelBActionPerformed
221:
222:            private void applyBActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_applyBActionPerformed
223:            // Add your handling code here:
224:                setVisible(false);
225:                dispose();
226:                okQuit = true;
227:            }//GEN-LAST:event_applyBActionPerformed
228:
229:            /** Closes the dialog */
230:            private void closeDialog(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_closeDialog
231:                setVisible(false);
232:                dispose();
233:            }//GEN-LAST:event_closeDialog
234:
235:            /**
236:             * Return true if user applied changes, false otherwise
237:             */
238:            public boolean changesApplied() {
239:                return okQuit;
240:            }
241:
242:            public void tableChanged(final javax.swing.event.TableModelEvent evt) {
243:                if (evt.getType() == TableModelEvent.UPDATE) {
244:                    //System.out.println( evt.getColumn()+"  "+evt.getFirstRow() );
245:                    if (((Boolean) tableModel.getValueAt(evt.getFirstRow(), 3))
246:                            .booleanValue())
247:                        enableLoader(evt.getFirstRow());
248:                }
249:            }
250:
251:            /**
252:             * Set enabledList to represent the enable state of each loader
253:             */
254:            public void getEnabledLoaders(java.util.ArrayList loaderList) {
255:                LoaderControl.LoaderConfig loader;
256:                for (int i = 0; i < loaderList.size(); i++) {
257:                    loader = (LoaderControl.LoaderConfig) loaderList.get(i);
258:                    loader.setEnabled(((Boolean) tableModel.getValueAt(i, 3))
259:                            .booleanValue());
260:                }
261:            }
262:
263:            // Variables declaration - do not modify//GEN-BEGIN:variables
264:            private javax.swing.JTable loaderTable;
265:            private javax.swing.JPanel jPanel1;
266:            private javax.swing.JPanel buttonPanel;
267:            private javax.swing.JScrollPane jScrollPane1;
268:            private javax.swing.JButton helpB;
269:            private javax.swing.JButton applyB;
270:            private javax.swing.JButton cancelB;
271:            // End of variables declaration//GEN-END:variables
272:
273:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.