Source Code Cross Referenced for JavaAppPage.java in  » Installer » jsmooth » net » charabia » jsmoothgen » application » swtgui » 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 » Installer » jsmooth » net.charabia.jsmoothgen.application.swtgui 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Created on May 22, 2004
003:         */
004:        package net.charabia.jsmoothgen.application.swtgui;
005:
006:        import java.io.File;
007:        import java.util.ArrayList;
008:        import java.util.Arrays;
009:
010:        import net.charabia.jsmoothgen.application.JSmoothModelBean;
011:        import net.charabia.jsmoothgen.application.swtgui.resources.JSmoothResources;
012:
013:        import org.eclipse.swt.SWT;
014:        import org.eclipse.swt.events.ModifyEvent;
015:        import org.eclipse.swt.events.ModifyListener;
016:        import org.eclipse.swt.events.SelectionAdapter;
017:        import org.eclipse.swt.events.SelectionEvent;
018:        import org.eclipse.swt.events.SelectionListener;
019:        import org.eclipse.swt.layout.GridData;
020:        import org.eclipse.swt.layout.GridLayout;
021:        import org.eclipse.swt.widgets.Button;
022:        import org.eclipse.swt.widgets.Composite;
023:        import org.eclipse.swt.widgets.Control;
024:        import org.eclipse.swt.widgets.DirectoryDialog;
025:        import org.eclipse.swt.widgets.FileDialog;
026:        import org.eclipse.swt.widgets.Group;
027:        import org.eclipse.swt.widgets.Label;
028:        import org.eclipse.swt.widgets.List;
029:        import org.eclipse.swt.widgets.Text;
030:
031:        /**
032:         * @author Dumon
033:         */
034:        public class JavaAppPage extends JSmoothPage {
035:            protected SelectionListener LISTENER_USEJAR = new SelectionAdapter() {
036:                public void widgetSelected(SelectionEvent e) {
037:                    setModelUsejar(usejar.getSelection());
038:                    updateUsejarWidgets();
039:                }
040:            };
041:
042:            private Text jar;
043:            private Text mainclass;
044:            private Text args;
045:            private List classpath;
046:            private Button usejar;
047:            private Button setjar;
048:            private Button addjar;
049:            private Button addfolder;
050:            private Button remove;
051:
052:            public JavaAppPage(JSmoothApplication js) {
053:                super (js);
054:            }
055:
056:            public Control createPageArea(Composite parent) {
057:                Composite top = new Composite(parent, SWT.NONE);
058:                top.setLayout(new GridLayout());
059:
060:                Composite composite = new Composite(top, SWT.NONE);
061:                GridLayout layout = new GridLayout(3, false);
062:                layout.marginHeight = 0;
063:                layout.marginWidth = 0;
064:                composite.setLayout(layout);
065:                composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
066:
067:                usejar = new Button(composite, SWT.CHECK);
068:                usejar.setText("Use embedded JAR");
069:                usejar.addSelectionListener(LISTENER_USEJAR);
070:                GridData grid = new GridData(GridData.FILL);
071:                grid.horizontalSpan = 3;
072:                usejar.setLayoutData(grid);
073:
074:                // Jar location
075:                Label label = new Label(composite, SWT.NONE);
076:                label.setText("JAR location:");
077:                grid = new GridData(GridData.FILL);
078:                label.setLayoutData(grid);
079:
080:                jar = new Text(composite, SWT.BORDER);
081:                grid = new GridData(GridData.FILL_HORIZONTAL);
082:                grid.widthHint = 250;
083:                jar.setLayoutData(grid);
084:                jar.addModifyListener(new ModifyListener() {
085:                    public void modifyText(ModifyEvent e) {
086:                        setModelJar(jar.getText());
087:                    }
088:                });
089:
090:                setjar = new Button(composite, SWT.NONE);
091:                setjar.setText("Browse...");
092:                setjar.addSelectionListener(new SelectionAdapter() {
093:                    public void widgetSelected(SelectionEvent e) {
094:                        FileDialog dialog = new FileDialog(getShell(), SWT.SAVE);
095:                        dialog.setText("JAR Location");
096:                        String file = dialog.open();
097:                        if (file != null)
098:                            jar.setText(file);
099:                        setModelJar(file);
100:                    }
101:                });
102:                grid = new GridData(GridData.FILL);
103:                grid.widthHint = 100;
104:                setjar.setLayoutData(grid);
105:
106:                label = new Label(composite, SWT.SEPARATOR | SWT.HORIZONTAL);
107:                grid = new GridData(GridData.FILL_HORIZONTAL);
108:                grid.horizontalSpan = 3;
109:                label.setLayoutData(grid);
110:
111:                // Main class
112:                label = new Label(composite, SWT.NONE);
113:                label.setText("Main class:");
114:                grid = new GridData(GridData.FILL);
115:                label.setLayoutData(grid);
116:
117:                mainclass = new Text(composite, SWT.BORDER);
118:                grid = new GridData(GridData.FILL_HORIZONTAL);
119:                grid.widthHint = 250;
120:                mainclass.setLayoutData(grid);
121:                mainclass.addModifyListener(new ModifyListener() {
122:                    public void modifyText(ModifyEvent e) {
123:                        setModelMainclass(mainclass.getText());
124:                    }
125:                });
126:
127:                new Label(composite, SWT.NONE); // empty cell
128:
129:                // Arguments
130:                label = new Label(composite, SWT.NONE);
131:                label.setText("Arguments:");
132:                grid = new GridData(GridData.FILL);
133:                label.setLayoutData(grid);
134:
135:                args = new Text(composite, SWT.BORDER);
136:                grid = new GridData(GridData.FILL_HORIZONTAL);
137:                grid.widthHint = 250;
138:                args.setLayoutData(grid);
139:                args.addModifyListener(new ModifyListener() {
140:                    public void modifyText(ModifyEvent e) {
141:                        setModelArguments(args.getText());
142:                    }
143:                });
144:
145:                new Label(composite, SWT.NONE); // empty cell
146:
147:                // Classpath list
148:                Group group = new Group(top, SWT.NONE);
149:                group.setText("Classpath");
150:                group.setLayout(new GridLayout());
151:                grid = new GridData(GridData.FILL_HORIZONTAL);
152:                grid.horizontalSpan = 3;
153:                group.setLayoutData(grid);
154:                group.setLayout(new GridLayout(2, false));
155:
156:                classpath = new List(group, SWT.BORDER | SWT.V_SCROLL
157:                        | SWT.H_SCROLL | SWT.MULTI);
158:                grid = new GridData(GridData.FILL_BOTH);
159:                grid.widthHint = 250; // TODO: Hardscoded
160:                grid.heightHint = classpath.getItemHeight() * 10; // TODO: Hardcoded
161:                classpath.setLayoutData(grid);
162:                classpath.addSelectionListener(new SelectionAdapter() {
163:                    public void widgetSelected(SelectionEvent e) {
164:                        updateRemoveButton();
165:                    }
166:                });
167:
168:                // The classpath Button bar
169:                composite = new Composite(group, SWT.NONE);
170:                composite.setLayoutData(new GridData(GridData.FILL_VERTICAL));
171:                layout = new GridLayout();
172:                layout.marginHeight = 0;
173:                layout.marginWidth = 2;
174:                composite.setLayout(layout);
175:
176:                addjar = new Button(composite, SWT.NONE);
177:                addjar.setText("Add JAR File...");
178:                addjar.addSelectionListener(new SelectionAdapter() {
179:                    public void widgetSelected(SelectionEvent e) {
180:                        FileDialog dialog = new FileDialog(getShell(), SWT.OPEN
181:                                | SWT.MULTI);
182:                        dialog.setText("JAR File");
183:                        String choice = dialog.open();
184:                        if (choice != null) {
185:                            String path = dialog.getFilterPath();
186:                            String[] filenames = dialog.getFileNames();
187:                            ArrayList files = new ArrayList();
188:                            for (int i = 0; i < filenames.length; i++) {
189:                                files.add(path + File.separator + filenames[i]);
190:                            }
191:                            addClasspathItems((String[]) files
192:                                    .toArray(new String[0]));
193:                        }
194:                    }
195:                });
196:                grid = new GridData(GridData.FILL_HORIZONTAL);
197:                grid.widthHint = 130;
198:                addjar.setLayoutData(grid);
199:
200:                addfolder = new Button(composite, SWT.NONE);
201:                addfolder.setText("Add Class Folder...");
202:                addfolder.addSelectionListener(new SelectionAdapter() {
203:                    public void widgetSelected(SelectionEvent e) {
204:                        DirectoryDialog dialog = new DirectoryDialog(
205:                                getShell(), SWT.SAVE);
206:                        dialog.setText("Class Folder");
207:                        String folder = dialog.open();
208:                        if (folder != null)
209:                            addClasspathItems(new String[] { folder });
210:                    }
211:                });
212:                grid = new GridData(GridData.FILL_HORIZONTAL);
213:                grid.widthHint = 130;
214:                addfolder.setLayoutData(grid);
215:
216:                remove = new Button(composite, SWT.NONE);
217:                remove.setText("Remove");
218:                remove.addSelectionListener(new SelectionAdapter() {
219:                    public void widgetSelected(SelectionEvent e) {
220:                        removeItem();
221:                    }
222:                });
223:                grid = new GridData(GridData.FILL_HORIZONTAL);
224:                grid.widthHint = 130;
225:                remove.setLayoutData(grid);
226:
227:                updateRemoveButton();
228:                updateUsejarWidgets();
229:
230:                return top;
231:            }
232:
233:            private void setModelMainclass(String mainclass) {
234:                System.out
235:                        .println("[DEBUG] Setting mainclass to: " + mainclass);
236:                JSmoothModelBean jsmodel = getApplication().getModelBean();
237:                jsmodel.setMainClassName(mainclass);
238:            }
239:
240:            private void removeItem() {
241:                classpath.remove(classpath.getSelectionIndices());
242:                updateRemoveButton();
243:                setModelClasspath(classpath.getItems());
244:            }
245:
246:            private void setModelClasspath(String[] classpath) {
247:                String classpathString = Arrays.asList(classpath).toString();
248:                System.out.println("[DEBUG] Setting classpath to: "
249:                        + classpathString);
250:                JSmoothModelBean jsmodel = getApplication().getModelBean();
251:                jsmodel.setClassPath(classpath);
252:            }
253:
254:            private void updateRemoveButton() {
255:                int i = classpath.getItemCount();
256:                boolean enable = true;
257:                if (i == 0) {
258:                    enable = false;
259:                } else {
260:                    int s = classpath.getSelectionCount();
261:                    if (s == 0)
262:                        enable = false;
263:                }
264:                remove.setEnabled(enable);
265:            }
266:
267:            private void addClasspathItems(String[] items) {
268:                String[] olditems = classpath.getItems();
269:                for (int i = 0; i < items.length; i++) {
270:                    // Check for duplicates
271:                    if (Arrays.binarySearch(olditems, items[i]) >= 0)
272:                        continue;
273:                    classpath.add(items[i]);
274:                }
275:                setModelClasspath(classpath.getItems());
276:            }
277:
278:            private void updateUsejarWidgets() {
279:                boolean b = usejar.getSelection();
280:                setjar.setEnabled(b);
281:                jar.setEnabled(b);
282:            }
283:
284:            private void setModelJar(String jarfile) {
285:                System.out.println("[DEBUG] Setting jarfile to: " + jarfile);
286:                JSmoothModelBean jsmodel = getApplication().getModelBean();
287:                jsmodel.setJarLocation(jarfile);
288:            }
289:
290:            private void setModelUsejar(boolean b) {
291:                System.out.println("[DEBUG] Setting use embedded jar to: " + b);
292:                JSmoothModelBean jsmodel = getApplication().getModelBean();
293:                jsmodel.setEmbeddedJar(b);
294:            }
295:
296:            private void setModelArguments(String args) {
297:                System.out.println("[DEBUG] Setting argument to: " + args);
298:                JSmoothModelBean jsmodel = getApplication().getModelBean();
299:                jsmodel.setArguments(args);
300:            }
301:
302:            protected void configureResources() {
303:                setImage(JSmoothResources.IMG_SWITCHER_APPLICATION);
304:                setToolTip("Java Application");
305:            }
306:
307:            public void load() {
308:                JSmoothModelBean jsmodel = getApplication().getModelBean();
309:                String[] classpath = jsmodel.getClassPath();
310:                if (classpath == null)
311:                    classpath = new String[0];
312:                this .classpath.setItems(classpath);
313:
314:                boolean usejar = jsmodel.getEmbeddedJar();
315:                this .usejar.setSelection(usejar);
316:                LISTENER_USEJAR.widgetSelected(null);
317:
318:                String mainclass = jsmodel.getMainClassName();
319:                if (mainclass == null)
320:                    mainclass = "";
321:                this .mainclass.setText(mainclass);
322:
323:                String jar = jsmodel.getJarLocation();
324:                if (jar == null)
325:                    jar = "";
326:                this .jar.setText(jar);
327:
328:                String args = jsmodel.getArguments();
329:                if (args == null)
330:                    args = "";
331:                this.args.setText(args);
332:            }
333:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.