Source Code Cross Referenced for ProjectSettingsController.java in  » Swing-Library » abeille-forms-designer » com » jeta » swingbuilder » gui » project » 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.project 
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.project;
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.DefaultComboBoxModel;
027:        import javax.swing.JCheckBox;
028:        import javax.swing.JComboBox;
029:        import javax.swing.JFileChooser;
030:        import javax.swing.JOptionPane;
031:
032:        import com.jeta.forms.gui.common.FormException;
033:        import com.jeta.forms.store.memento.IconMemento;
034:        import com.jeta.open.gui.framework.JETAController;
035:        import com.jeta.open.gui.framework.JETADialog;
036:        import com.jeta.open.gui.utils.JETAToolbox;
037:        import com.jeta.open.i18n.I18N;
038:        import com.jeta.swingbuilder.gui.beanmgr.BeanDefinitionValidator;
039:        import com.jeta.swingbuilder.gui.beanmgr.BeanDefinitionView;
040:        import com.jeta.swingbuilder.gui.beanmgr.BeanLoader;
041:        import com.jeta.swingbuilder.gui.beanmgr.BeanManagerNames;
042:        import com.jeta.swingbuilder.gui.filechooser.FileChooserConfig;
043:        import com.jeta.swingbuilder.gui.filechooser.TSFileChooserFactory;
044:        import com.jeta.swingbuilder.gui.filechooser.TSFileFilter;
045:        import com.jeta.swingbuilder.gui.utils.FormDesignerUtils;
046:        import com.jeta.swingbuilder.store.ImportedBeanInfo;
047:
048:        /**
049:         * The controller for the ProjectSettingsView class
050:         * 
051:         * @author Jeff Tassin
052:         */
053:        public class ProjectSettingsController extends JETAController {
054:            /**
055:             * The view we are handling events for
056:             */
057:            private ProjectSettingsView m_view;
058:
059:            /**
060:             * The beans table model
061:             */
062:            // private BeansModel m_beansmodel;
063:            /**
064:             * ctor
065:             */
066:            public ProjectSettingsController(ProjectSettingsView view) {
067:                super (view);
068:                m_view = view;
069:                //
070:                // 1st tab...
071:                assignAction(ProjectSettingsNames.ID_PROJECT_FILE_SHARED,
072:                        new ProjectSharedAction());
073:                assignAction(ProjectSettingsNames.ID_PROJECT_ROOT_ENV_VARIABLE,
074:                        new ProjectEnvVarAction());
075:                assignAction(
076:                        ProjectSettingsNames.ID_PROJECT_ENV_VAR_REFRESH_BTN,
077:                        new ProjectEnvVarsRefreshAction());
078:                assignAction(ProjectSettingsNames.ID_PROJECT_ADD_PATH,
079:                        new AddPathAction());
080:                assignAction(ProjectSettingsNames.ID_PROJECT_DELETE_PATH,
081:                        new DeletePathAction());
082:                assignAction(ProjectSettingsNames.ID_PROJECT_FILE_BTN,
083:                        new ProjectFileAction());
084:                assignAction(ProjectSettingsNames.ID_PROJECT_CLASSPATH_BTN,
085:                        new ProjectClassPathAction());
086:                //
087:                // 2nd tab...;
088:                assignAction(BeanManagerNames.ID_ADD_BEAN, new AddBeanAction());
089:                assignAction(BeanManagerNames.ID_DELETE_BEAN,
090:                        new DeleteBeanAction());
091:                assignAction(BeanManagerNames.ID_SET_BEAN_ICON,
092:                        new SetBeanIconAction());
093:                assignAction(BeanManagerNames.ID_ADD_JAR,
094:                        new AddBeanPathAction(false));
095:                assignAction(BeanManagerNames.ID_ADD_PATH,
096:                        new AddBeanPathAction(true));
097:                assignAction(BeanManagerNames.ID_DELETE_JAR,
098:                        new DeleteBeanPathAction());
099:            }
100:
101:            /**
102:             * Adds a path to the project
103:             */
104:            public class AddPathAction implements  ActionListener {
105:                public void actionPerformed(ActionEvent evt) {
106:                    FileChooserConfig fcc = new FileChooserConfig(m_view
107:                            .getProjectRootDir().getPath(), null,
108:                            JFileChooser.DIRECTORIES_ONLY, (TSFileFilter) null);
109:                    fcc.setParentComponent(m_view);
110:                    File f = TSFileChooserFactory.showOpenDialog(fcc);
111:                    if (f != null) {
112:                        m_view.addPath(f.getPath());
113:                    }
114:                }
115:            }
116:
117:            /**
118:             * Deletes a path from the project
119:             */
120:            public class DeletePathAction implements  ActionListener {
121:                public void actionPerformed(ActionEvent evt) {
122:                    m_view.deleteSelectedPath();
123:                }
124:            }
125:
126:            /**
127:             * Adds a class path to the project
128:             */
129:            public class ProjectClassPathAction implements  ActionListener {
130:                public void actionPerformed(ActionEvent evt) {
131:                    File rootDir = m_view.getProjectRootDir();
132:                    FileChooserConfig fcc = new FileChooserConfig(rootDir
133:                            .getPath(), null, JFileChooser.DIRECTORIES_ONLY,
134:                            (TSFileFilter) null);
135:                    fcc.setParentComponent(m_view);
136:                    File f = TSFileChooserFactory.showOpenDialog(fcc);
137:                    //
138:                    if ((f != null) && (rootDir != null)) {
139:                        String classpath = PathParser.getRelativePath(rootDir,
140:                                f);
141:                        m_view.setText(
142:                                ProjectSettingsNames.ID_PROJECT_CLASSPATH,
143:                                classpath);
144:                    }
145:                }
146:            }
147:
148:            /**
149:             * Set the project as "shared"
150:             */
151:            public class ProjectEnvVarAction implements  ActionListener {
152:                public void actionPerformed(ActionEvent evt) {
153:                    String envVar = (String) ((JComboBox) evt.getSource())
154:                            .getSelectedItem();
155:                }
156:            }
157:
158:            /**
159:             * Set the project as "shared"
160:             */
161:            public class ProjectEnvVarsRefreshAction implements  ActionListener {
162:                public void actionPerformed(ActionEvent evt) {
163:                    JComboBox comboBox = m_view
164:                            .getComboBox(ProjectSettingsNames.ID_PROJECT_ROOT_ENV_VARIABLE);
165:                    comboBox.setModel(new DefaultComboBoxModel(
166:                            FormDesignerUtils.getEnvVars(true)));
167:                    comboBox.getModel().setSelectedItem(null);
168:                }
169:            }
170:
171:            /**
172:             * Set the project as "shared"
173:             */
174:            public class ProjectSharedAction implements  ActionListener {
175:                public void actionPerformed(ActionEvent evt) {
176:                    boolean isShared = ((JCheckBox) evt.getSource())
177:                            .isSelected();
178:                    m_view.setSelected(
179:                            ProjectSettingsNames.ID_PROJECT_FILE_SHARED,
180:                            isShared);
181:                    m_view.enableComponent(
182:                            ProjectSettingsNames.ID_PROJECT_ROOT_ENV_VARIABLE,
183:                            isShared);
184:                    m_view
185:                            .enableComponent(
186:                                    ProjectSettingsNames.ID_PROJECT_ENV_VAR_REFRESH_BTN,
187:                                    isShared);
188:                    m_view.getTabbedPane(
189:                            ProjectSettingsNames.ID_PROJECT_SETTINGS_TAB)
190:                            .setEnabledAt(1, isShared);
191:                    if (!isShared) {
192:                        m_view
193:                                .setSelectedItem(
194:                                        ProjectSettingsNames.ID_PROJECT_ROOT_ENV_VARIABLE,
195:                                        null);
196:                    }
197:                }
198:            }
199:
200:            public class ProjectFileAction implements  ActionListener {
201:                public void actionPerformed(ActionEvent evt) {
202:                    File f = TSFileChooserFactory.showSaveDialog("project",
203:                            new TSFileFilter("jfpr", "Project Files (*.jfpr)"));
204:                    if (f != null) {
205:                        String fname = f.getName();
206:                        if (fname != null && fname.length() > 0) {
207:                            int pos = fname.indexOf(".");
208:                            if (pos < 0) {
209:                                fname = fname + ".jfpr";
210:                            }
211:                        }
212:                        String path = f.getParent() + File.separatorChar
213:                                + fname;
214:                        m_view
215:                                .setText(
216:                                        ProjectSettingsNames.ID_PROJECT_FILE_PATH,
217:                                        path);
218:                    }
219:                }
220:            }
221:
222:            /**
223:             * Adds a bean to the view
224:             */
225:            public class AddBeanAction implements  ActionListener {
226:                public void actionPerformed(ActionEvent evt) {
227:                    BeanDefinitionView view = new BeanDefinitionView();
228:                    JETADialog dlg = (JETADialog) JETAToolbox.createDialog(
229:                            JETADialog.class, m_view, true);
230:                    dlg.setPrimaryPanel(view);
231:                    dlg.setTitle(I18N.getLocalizedMessage("Bean Definition"));
232:                    dlg.setSize(dlg.getPreferredSize());
233:                    dlg.addValidator(new Object[] { view,
234:                            m_view.getBeanLoader() },
235:                            new BeanDefinitionValidator());
236:                    dlg.showCenter();
237:                    if (dlg.isOk()) {
238:                        BeanLoader loader = m_view.getBeanLoader();
239:                        try {
240:                            Component comp = loader.createBean(view
241:                                    .getBeanName());
242:                            ImportedBeanInfo info = new ImportedBeanInfo(view
243:                                    .getBeanName(), view.isScrollable());
244:                            m_view.getBeansModel().addRow(info);
245:
246:                            if (!(comp.isLightweight() || comp instanceof  javax.swing.JComponent)) {
247:                                String msg = I18N
248:                                        .getLocalizedMessage("Warning. Only lightweight Java beans are supported.");
249:                                String title = I18N
250:                                        .getLocalizedMessage("Error");
251:                                JOptionPane.showMessageDialog(m_view, msg,
252:                                        title, JOptionPane.ERROR_MESSAGE);
253:                            }
254:                        } catch (FormException e) {
255:                            e.printStackTrace();
256:                        }
257:                    }
258:                }
259:            }
260:
261:            /**
262:             * Adds a path to the project
263:             */
264:            public class AddBeanPathAction implements  ActionListener {
265:                private boolean m_dir_only = false;
266:
267:                public AddBeanPathAction(boolean dir_only) {
268:                    m_dir_only = dir_only;
269:                }
270:
271:                public void actionPerformed(ActionEvent evt) {
272:                    int mode = (m_dir_only ? javax.swing.JFileChooser.DIRECTORIES_ONLY
273:                            : javax.swing.JFileChooser.FILES_ONLY);
274:
275:                    TSFileFilter filter = null;
276:                    if (!m_dir_only)
277:                        filter = new TSFileFilter("jar,zip",
278:                                "JAR Files(*.jar,*.zip)");
279:
280:                    FileChooserConfig fcc = new FileChooserConfig(null, mode,
281:                            filter);
282:                    //FileChooserConfig fcc = new FileChooserConfig(m_view.getProjectRootDir().getPath(), "jar,zip", mode, filter);
283:                    fcc.setParentComponent(m_view);
284:                    File f = TSFileChooserFactory.showOpenDialog(fcc);
285:
286:                    if (f != null && f.exists()) {
287:                        try {
288:                            m_view.addBeanPath(f, mode);
289:                        } catch (Exception e) {
290:                            e.printStackTrace();
291:                        }
292:                    }
293:                }
294:            }
295:
296:            /**
297:             * Deletes a bean from the view
298:             */
299:            public class DeleteBeanAction implements  ActionListener {
300:                public void actionPerformed(ActionEvent evt) {
301:                    m_view.deleteSelectedBean();
302:                }
303:            }
304:
305:            /**
306:             * Deletes a path from the project
307:             */
308:            public class DeleteBeanPathAction implements  ActionListener {
309:                public void actionPerformed(ActionEvent evt) {
310:                    m_view.deleteSelectedUrl();
311:                }
312:            }
313:
314:            /**
315:             * Sets an icon for the selected bean
316:             */
317:            public class SetBeanIconAction implements  ActionListener {
318:                public void actionPerformed(ActionEvent evt) {
319:                    ImportedBeanInfo bi = (ImportedBeanInfo) m_view
320:                            .getSelectedBean();
321:                    if (bi != null) {
322:                        File f = TSFileChooserFactory
323:                                .showOpenDialog(
324:                                        ".img",
325:                                        new TSFileFilter("gif,png,jpg,jpeg",
326:                                                "Image Files(*.gif,*.png,*.jpg,*.jpeg)"));
327:                        if (f != null) {
328:                            bi.setIconMemento(new IconMemento(f));
329:                            m_view.getBeansModel().fireTableDataChanged();
330:                        }
331:                    }
332:                }
333:            }
334:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.