Source Code Cross Referenced for TracingPropertySource.java in  » IDE-Eclipse » Eclipse-plug-in-development » org » eclipse » pde » internal » ui » launcher » 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 » IDE Eclipse » Eclipse plug in development » org.eclipse.pde.internal.ui.launcher 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*******************************************************************************
002:         * Copyright (c) 2000, 2005 IBM Corporation and others.
003:         * All rights reserved. This program and the accompanying materials
004:         * are made available under the terms of the Eclipse Public License v1.0
005:         * which accompanies this distribution, and is available at
006:         * http://www.eclipse.org/legal/epl-v10.html
007:         *
008:         * Contributors:
009:         *     IBM Corporation - initial API and implementation
010:         *******************************************************************************/package org.eclipse.pde.internal.ui.launcher;
011:
012:        import java.util.Arrays;
013:        import java.util.Comparator;
014:        import java.util.Enumeration;
015:        import java.util.Hashtable;
016:        import java.util.Locale;
017:        import java.util.Properties;
018:        import java.util.Vector;
019:
020:        import org.eclipse.core.runtime.IPath;
021:        import org.eclipse.core.runtime.Path;
022:        import org.eclipse.pde.core.plugin.IPluginModelBase;
023:        import org.eclipse.swt.SWT;
024:        import org.eclipse.swt.events.ModifyEvent;
025:        import org.eclipse.swt.events.ModifyListener;
026:        import org.eclipse.swt.events.SelectionAdapter;
027:        import org.eclipse.swt.events.SelectionEvent;
028:        import org.eclipse.swt.widgets.Button;
029:        import org.eclipse.swt.widgets.Composite;
030:        import org.eclipse.swt.widgets.Label;
031:        import org.eclipse.swt.widgets.Text;
032:        import org.eclipse.ui.forms.widgets.TableWrapData;
033:        import org.eclipse.ui.forms.widgets.TableWrapLayout;
034:
035:        public class TracingPropertySource {
036:            private IPluginModelBase fModel;
037:            private Vector fDescriptors;
038:            private Hashtable fTemplate;
039:            private Hashtable fValues;
040:            private Hashtable fDvalues;
041:            private static final String[] fBooleanChoices = { "false", "true" }; //$NON-NLS-1$ //$NON-NLS-2$
042:            private Properties fMasterOptions;
043:            private boolean fModified;
044:            private TracingBlock fBlock;
045:
046:            private abstract class PropertyEditor {
047:                private String key;
048:                private String label;
049:
050:                public PropertyEditor(String key, String label) {
051:                    this .key = key;
052:                    this .label = label;
053:                }
054:
055:                public String getKey() {
056:                    return key;
057:                }
058:
059:                public String getLabel() {
060:                    return label;
061:                }
062:
063:                abstract void create(Composite parent);
064:
065:                abstract void update();
066:
067:                abstract void initialize();
068:
069:                protected void valueModified(Object value) {
070:                    fValues.put(getKey(), value);
071:                    fModified = true;
072:                    fBlock.getTab().updateLaunchConfigurationDialog();
073:                }
074:            }
075:
076:            private class BooleanEditor extends PropertyEditor {
077:                private Button checkbox;
078:
079:                public BooleanEditor(String key, String label) {
080:                    super (key, label);
081:                }
082:
083:                public void create(Composite parent) {
084:                    checkbox = fBlock.getToolkit().createButton(parent,
085:                            getLabel(), SWT.CHECK);
086:                    TableWrapData td = new TableWrapData();
087:                    td.colspan = 2;
088:                    checkbox.setLayoutData(td);
089:                }
090:
091:                public void update() {
092:                    Integer value = (Integer) fValues.get(getKey());
093:                    checkbox.setSelection(value.intValue() == 1);
094:                }
095:
096:                public void initialize() {
097:                    update();
098:                    checkbox.addSelectionListener(new SelectionAdapter() {
099:                        public void widgetSelected(SelectionEvent e) {
100:                            int value = checkbox.getSelection() ? 1 : 0;
101:                            valueModified(new Integer(value));
102:                        }
103:                    });
104:                }
105:            }
106:
107:            private class TextEditor extends PropertyEditor {
108:                private Text text;
109:
110:                public TextEditor(String key, String label) {
111:                    super (key, label);
112:                }
113:
114:                public void create(Composite parent) {
115:                    Label label = fBlock.getToolkit().createLabel(parent,
116:                            getLabel());
117:                    TableWrapData td = new TableWrapData();
118:                    td.valign = TableWrapData.MIDDLE;
119:                    label.setLayoutData(td);
120:                    text = fBlock.getToolkit().createText(parent, ""); //$NON-NLS-1$
121:                    td = new TableWrapData(TableWrapData.FILL_GRAB);
122:                    //gd.widthHint = 100;
123:                    text.setLayoutData(td);
124:                }
125:
126:                public void update() {
127:                    String value = (String) fValues.get(getKey());
128:                    text.setText(value);
129:                }
130:
131:                public void initialize() {
132:                    update();
133:                    text.addModifyListener(new ModifyListener() {
134:                        public void modifyText(ModifyEvent e) {
135:                            valueModified(text.getText());
136:                        }
137:                    });
138:                }
139:            }
140:
141:            public TracingPropertySource(IPluginModelBase model,
142:                    Properties masterOptions, Hashtable template,
143:                    TracingBlock block) {
144:                fModel = model;
145:                fMasterOptions = masterOptions;
146:                fTemplate = template;
147:                fBlock = block;
148:                fValues = new Hashtable();
149:                fDvalues = new Hashtable();
150:            }
151:
152:            public IPluginModelBase getModel() {
153:                return fModel;
154:            }
155:
156:            private Object[] getSortedKeys(int size) {
157:                Object[] keyArray = new Object[size];
158:                int i = 0;
159:                for (Enumeration keys = fTemplate.keys(); keys
160:                        .hasMoreElements();) {
161:                    String key = (String) keys.nextElement();
162:                    keyArray[i++] = key;
163:                }
164:                Arrays.sort(keyArray, new Comparator() {
165:                    public int compare(Object o1, Object o2) {
166:                        return compareKeys(o1, o2);
167:                    }
168:                });
169:                return keyArray;
170:            }
171:
172:            private int compareKeys(Object o1, Object o2) {
173:                String s1 = (String) o1;
174:                String s2 = (String) o2;
175:                // equal
176:                return s1.compareTo(s2);
177:            }
178:
179:            public void createContents(Composite parent) {
180:                fDescriptors = new Vector();
181:                TableWrapLayout layout = new TableWrapLayout();
182:                layout.numColumns = 2;
183:                parent.setLayout(layout);
184:                boolean bordersNeeded = false;
185:                Object[] sortedKeys = getSortedKeys(fTemplate.size());
186:                for (int i = 0; i < sortedKeys.length; i++) {
187:                    String key = (String) sortedKeys[i];
188:                    IPath path = new Path(key);
189:                    path = path.removeFirstSegments(1);
190:                    String shortKey = path.toString();
191:                    String value = (String) fTemplate.get(key);
192:                    String lvalue = null;
193:                    String masterValue = fMasterOptions.getProperty(key);
194:                    PropertyEditor editor;
195:                    if (value != null)
196:                        lvalue = value.toLowerCase(Locale.ENGLISH);
197:                    if (lvalue != null
198:                            && (lvalue.equals("true") || lvalue.equals("false"))) { //$NON-NLS-1$ //$NON-NLS-2$
199:                        editor = new BooleanEditor(shortKey, shortKey);
200:                        Integer dvalue = new Integer(
201:                                lvalue.equals("true") ? 1 : 0); //$NON-NLS-1$
202:                        fDvalues.put(shortKey, dvalue);
203:                        if (masterValue != null) {
204:                            Integer mvalue = new Integer(masterValue
205:                                    .equals("true") //$NON-NLS-1$
206:                            ? 1
207:                                    : 0);
208:                            fValues.put(shortKey, mvalue);
209:                        }
210:                    } else {
211:                        editor = new TextEditor(shortKey, shortKey);
212:                        fDvalues.put(shortKey, value != null ? value : ""); //$NON-NLS-1$
213:                        if (masterValue != null) {
214:                            fValues.put(shortKey, masterValue);
215:                        }
216:                        bordersNeeded = true;
217:                    }
218:                    editor.create(parent);
219:                    editor.initialize();
220:                    fDescriptors.add(editor);
221:                    if (bordersNeeded)
222:                        fBlock.getToolkit().paintBordersFor(parent);
223:                }
224:            }
225:
226:            /**
227:             */
228:            public void save() {
229:                String pid = fModel.getPluginBase().getId();
230:                for (Enumeration keys = fValues.keys(); keys.hasMoreElements();) {
231:                    String shortKey = (String) keys.nextElement();
232:                    Object value = fValues.get(shortKey);
233:                    String svalue = value.toString();
234:                    if (value instanceof  Integer)
235:                        svalue = fBooleanChoices[((Integer) value).intValue()];
236:                    IPath path = new Path(pid).append(shortKey);
237:                    fMasterOptions.setProperty(path.toString(), svalue);
238:                }
239:                fModified = false;
240:            }
241:
242:            public void dispose() {
243:            }
244:
245:            public boolean isModified() {
246:                return fModified;
247:            }
248:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.