Source Code Cross Referenced for BeanManagerController.java in  » Swing-Library » abeille-forms-designer » com » jeta » swingbuilder » gui » beanmgr » 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 » Swing Library » abeille forms designer » com.jeta.swingbuilder.gui.beanmgr 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright (C) 2005 Jeff Tassin
003:         *
004:         * This library is free software; you can redistribute it and/or
005:         * modify it under the terms of the GNU Lesser General Public
006:         * License as published by the Free Software Foundation; either
007:         * version 2.1 of the License, or (at your option) any later version.
008:         *
009:         * This library is distributed in the hope that it will be useful,
010:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
011:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
012:         * Lesser General Public License for more details.
013:         *
014:         * You should have received a copy of the GNU Lesser General Public
015:         * License along with this library; if not, write to the Free Software
016:         * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
017:         */
018:
019:        package com.jeta.swingbuilder.gui.beanmgr;
020:
021:        import java.awt.Component;
022:        import java.awt.event.ActionEvent;
023:        import java.awt.event.ActionListener;
024:        import java.io.File;
025:
026:        import javax.swing.JOptionPane;
027:
028:        import com.jeta.forms.gui.common.FormException;
029:        import com.jeta.forms.store.memento.IconMemento;
030:        import com.jeta.open.gui.framework.JETAController;
031:        import com.jeta.open.gui.framework.JETADialog;
032:        import com.jeta.open.gui.utils.JETAToolbox;
033:        import com.jeta.open.i18n.I18N;
034:        import com.jeta.swingbuilder.gui.filechooser.FileChooserConfig;
035:        import com.jeta.swingbuilder.gui.filechooser.TSFileChooserFactory;
036:        import com.jeta.swingbuilder.gui.filechooser.TSFileFilter;
037:        import com.jeta.swingbuilder.store.ImportedBeanInfo;
038:
039:        /**
040:         * The controller for the BeanManagerView
041:         * 
042:         * @author Jeff Tassin
043:         */
044:        public class BeanManagerController extends JETAController {
045:            /**
046:             * The view
047:             */
048:            private BeanManagerView m_view;
049:
050:            /**
051:             * The beans table model
052:             */
053:            private BeansModel m_beansmodel;
054:
055:            /**
056:             * ctor
057:             */
058:            public BeanManagerController(BeanManagerView view) {
059:                super (view);
060:                m_view = view;
061:                m_beansmodel = view.getBeansModel();
062:                assignAction(BeanManagerNames.ID_ADD_BEAN, new AddBeanAction());
063:                assignAction(BeanManagerNames.ID_DELETE_BEAN,
064:                        new DeleteBeanAction());
065:                assignAction(BeanManagerNames.ID_SET_BEAN_ICON,
066:                        new SetBeanIconAction());
067:                assignAction(BeanManagerNames.ID_ADD_JAR, new AddPathAction(
068:                        false));
069:                assignAction(BeanManagerNames.ID_ADD_PATH, new AddPathAction(
070:                        true));
071:                assignAction(BeanManagerNames.ID_DELETE_JAR,
072:                        new DeletePathAction());
073:            }
074:
075:            /**
076:             * Adds a bean to the view
077:             */
078:            public class AddBeanAction implements  ActionListener {
079:                public void actionPerformed(ActionEvent evt) {
080:                    BeanDefinitionView view = new BeanDefinitionView();
081:                    JETADialog dlg = (JETADialog) JETAToolbox.createDialog(
082:                            JETADialog.class, m_view, true);
083:                    dlg.setPrimaryPanel(view);
084:                    dlg.setTitle(I18N.getLocalizedMessage("Bean Definition"));
085:                    dlg.setSize(dlg.getPreferredSize());
086:                    dlg.addValidator(new Object[] { view,
087:                            m_view.getBeanLoader() },
088:                            new BeanDefinitionValidator());
089:                    dlg.showCenter();
090:                    if (dlg.isOk()) {
091:                        BeanLoader loader = m_view.getBeanLoader();
092:                        try {
093:                            Component comp = loader.createBean(view
094:                                    .getBeanName());
095:                            ImportedBeanInfo info = new ImportedBeanInfo(view
096:                                    .getBeanName(), view.isScrollable());
097:                            m_beansmodel.addRow(info);
098:
099:                            if (!(comp.isLightweight() || comp instanceof  javax.swing.JComponent)) {
100:                                String msg = I18N
101:                                        .getLocalizedMessage("Warning. Only lightweight Java beans are supported.");
102:                                String title = I18N
103:                                        .getLocalizedMessage("Error");
104:                                JOptionPane.showMessageDialog(m_view, msg,
105:                                        title, JOptionPane.ERROR_MESSAGE);
106:                            }
107:                        } catch (FormException e) {
108:                            e.printStackTrace();
109:                        }
110:                    }
111:                }
112:            }
113:
114:            /**
115:             * Adds a path to the project
116:             */
117:            public class AddPathAction implements  ActionListener {
118:                private boolean m_dir_only = false;
119:
120:                public AddPathAction(boolean dir_only) {
121:                    m_dir_only = dir_only;
122:                }
123:
124:                public void actionPerformed(ActionEvent evt) {
125:                    int mode = (m_dir_only ? javax.swing.JFileChooser.DIRECTORIES_ONLY
126:                            : javax.swing.JFileChooser.FILES_ONLY);
127:
128:                    TSFileFilter filter = null;
129:                    if (!m_dir_only)
130:                        filter = new TSFileFilter("jar,zip",
131:                                "JAR Files(*.jar,*.zip)");
132:
133:                    FileChooserConfig fcc = new FileChooserConfig(null, mode,
134:                            filter);
135:                    fcc.setParentComponent(m_view);
136:                    File f = TSFileChooserFactory.showOpenDialog(fcc);
137:                    if (f != null && f.exists()) {
138:                        try {
139:                            m_view.addUrl(f.toURL());
140:                        } catch (Exception e) {
141:                            e.printStackTrace();
142:                        }
143:                    }
144:                }
145:            }
146:
147:            /**
148:             * Deletes a bean from the view
149:             */
150:            public class DeleteBeanAction implements  ActionListener {
151:                public void actionPerformed(ActionEvent evt) {
152:                    m_view.deleteSelectedBean();
153:                }
154:            }
155:
156:            /**
157:             * Deletes a path from the project
158:             */
159:            public class DeletePathAction implements  ActionListener {
160:                public void actionPerformed(ActionEvent evt) {
161:                    m_view.deleteSelectedUrl();
162:                }
163:            }
164:
165:            /**
166:             * Sets an icon for the selected bean
167:             */
168:            public class SetBeanIconAction implements  ActionListener {
169:                public void actionPerformed(ActionEvent evt) {
170:                    ImportedBeanInfo bi = (ImportedBeanInfo) m_view
171:                            .getSelectedBean();
172:                    if (bi != null) {
173:                        File f = TSFileChooserFactory.showOpenDialog(".img",
174:                                new TSFileFilter("gif,png,jpg,jpeg",
175:                                        "Image Files(*.gif,*.png,*.jpg)"));
176:                        if (f != null) {
177:                            bi.setIconMemento(new IconMemento(f));
178:                            m_beansmodel.fireTableDataChanged();
179:                        }
180:                    }
181:                }
182:            }
183:
184:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.