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


001:        /*******************************************************************************
002:         * Copyright (c) 2005, 2007 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.editor.target;
011:
012:        import org.eclipse.debug.ui.StringVariableSelectionDialog;
013:        import org.eclipse.pde.core.IModelChangedEvent;
014:        import org.eclipse.pde.internal.core.itarget.IArgumentsInfo;
015:        import org.eclipse.pde.internal.core.itarget.ITarget;
016:        import org.eclipse.pde.internal.core.itarget.ITargetModel;
017:        import org.eclipse.pde.internal.ui.PDEPluginImages;
018:        import org.eclipse.pde.internal.ui.PDEUIMessages;
019:        import org.eclipse.pde.internal.ui.editor.FormEntryAdapter;
020:        import org.eclipse.pde.internal.ui.editor.FormLayoutFactory;
021:        import org.eclipse.pde.internal.ui.editor.PDEFormPage;
022:        import org.eclipse.pde.internal.ui.editor.PDESection;
023:        import org.eclipse.pde.internal.ui.parts.FormEntry;
024:        import org.eclipse.swt.SWT;
025:        import org.eclipse.swt.custom.CTabFolder;
026:        import org.eclipse.swt.custom.CTabItem;
027:        import org.eclipse.swt.dnd.Clipboard;
028:        import org.eclipse.swt.events.SelectionAdapter;
029:        import org.eclipse.swt.events.SelectionEvent;
030:        import org.eclipse.swt.graphics.Color;
031:        import org.eclipse.swt.graphics.Image;
032:        import org.eclipse.swt.layout.GridData;
033:        import org.eclipse.swt.widgets.Button;
034:        import org.eclipse.swt.widgets.Composite;
035:        import org.eclipse.swt.widgets.Display;
036:        import org.eclipse.swt.widgets.Text;
037:        import org.eclipse.ui.IActionBars;
038:        import org.eclipse.ui.forms.IFormColors;
039:        import org.eclipse.ui.forms.widgets.FormToolkit;
040:        import org.eclipse.ui.forms.widgets.Section;
041:
042:        public class ArgumentsSection extends PDESection {
043:
044:            private static final String[] TAB_LABELS = new String[2];
045:            static {
046:                TAB_LABELS[0] = PDEUIMessages.ArgumentsSection_programTabLabel;
047:                TAB_LABELS[1] = PDEUIMessages.ArgumentsSection_vmTabLabel;
048:            }
049:
050:            private CTabFolder fTabFolder;
051:            private FormEntry fArgument;
052:            private int fLastTab;
053:            private Image fImage;
054:
055:            public ArgumentsSection(PDEFormPage page, Composite parent) {
056:                super (page, parent, Section.DESCRIPTION);
057:                fImage = PDEPluginImages.DESC_ARGUMENT_TAB.createImage();
058:                createClient(getSection(), page.getEditor().getToolkit());
059:            }
060:
061:            protected void createClient(Section section, FormToolkit toolkit) {
062:                section.setLayout(FormLayoutFactory.createClearGridLayout(
063:                        false, 1));
064:                section.setText(PDEUIMessages.ArgumentsSection_editorTitle);
065:                section
066:                        .setDescription(PDEUIMessages.ArgumentsSection_description);
067:                GridData data = new GridData(GridData.FILL_BOTH);
068:                data.horizontalSpan = 1;
069:                section.setLayoutData(data);
070:
071:                Composite client = toolkit.createComposite(section);
072:                client.setLayout(FormLayoutFactory
073:                        .createSectionClientGridLayout(false, 1));
074:                GridData gd = new GridData(GridData.FILL_BOTH);
075:                gd.widthHint = 100;
076:                client.setLayoutData(gd);
077:
078:                fTabFolder = new CTabFolder(client, SWT.FLAT | SWT.TOP);
079:                toolkit.adapt(fTabFolder, true, true);
080:                gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
081:                fTabFolder.setLayoutData(gd);
082:                gd.heightHint = 2;
083:                toolkit.getColors().initializeSectionToolBarColors();
084:                Color selectedColor = toolkit.getColors().getColor(
085:                        IFormColors.TB_BG);
086:                fTabFolder.setSelectionBackground(new Color[] { selectedColor,
087:                        toolkit.getColors().getBackground() },
088:                        new int[] { 100 }, true);
089:                fTabFolder.addSelectionListener(new SelectionAdapter() {
090:                    public void widgetSelected(SelectionEvent e) {
091:                        if (fArgument.isDirty())
092:                            fArgument.commit();
093:                        refresh();
094:                    }
095:                });
096:
097:                IActionBars actionBars = getPage().getPDEEditor()
098:                        .getEditorSite().getActionBars();
099:
100:                fArgument = new FormEntry(client, toolkit,
101:                        PDEUIMessages.ArgumentsSection_argumentsTextLabel,
102:                        SWT.MULTI | SWT.WRAP);
103:                fArgument.getText().setLayoutData(
104:                        new GridData(GridData.FILL_BOTH));
105:                fArgument.setFormEntryListener(new FormEntryAdapter(this ,
106:                        actionBars) {
107:                    public void textValueChanged(FormEntry entry) {
108:                        if (fLastTab == 0)
109:                            getArgumentInfo().setProgramArguments(
110:                                    fArgument.getValue());
111:                        else
112:                            getArgumentInfo().setVMArguments(
113:                                    fArgument.getValue());
114:                    }
115:                });
116:
117:                Button variables = toolkit.createButton(client,
118:                        PDEUIMessages.ArgumentsSection_variableButtonTitle,
119:                        SWT.NONE);
120:                variables.setLayoutData(new GridData(
121:                        GridData.HORIZONTAL_ALIGN_END));
122:                variables.addSelectionListener(new SelectionAdapter() {
123:                    public void widgetSelected(SelectionEvent e) {
124:                        StringVariableSelectionDialog dialog = new StringVariableSelectionDialog(
125:                                getSection().getShell());
126:                        dialog.open();
127:                        String variable = dialog.getVariableExpression();
128:                        if (variable != null) {
129:                            fArgument.getText().insert(variable);
130:                        }
131:                    }
132:                });
133:
134:                createTabs();
135:                toolkit.paintBordersFor(client);
136:                section.setClient(client);
137:
138:                // Register to be notified when the model changes
139:                getModel().addModelChangedListener(this );
140:            }
141:
142:            /* (non-Javadoc)
143:             * @see org.eclipse.pde.internal.ui.editor.PDESection#modelChanged(org.eclipse.pde.core.IModelChangedEvent)
144:             */
145:            public void modelChanged(IModelChangedEvent e) {
146:                // No need to call super, handling world changed event here
147:                if (e.getChangeType() == IModelChangedEvent.WORLD_CHANGED) {
148:                    handleModelEventWorldChanged(e);
149:                }
150:            }
151:
152:            /**
153:             * @param event
154:             */
155:            private void handleModelEventWorldChanged(IModelChangedEvent event) {
156:                // Perform the refresh
157:                refresh();
158:            }
159:
160:            private void createTabs() {
161:                for (int i = 0; i < TAB_LABELS.length; i++) {
162:                    CTabItem item = new CTabItem(fTabFolder, SWT.NULL);
163:                    item.setText(TAB_LABELS[i]);
164:                    item.setImage(fImage);
165:                }
166:                fLastTab = 0;
167:                fTabFolder.setSelection(fLastTab);
168:            }
169:
170:            private IArgumentsInfo getArgumentInfo() {
171:                IArgumentsInfo info = getTarget().getArguments();
172:                if (info == null) {
173:                    info = getModel().getFactory().createArguments();
174:                    getTarget().setArguments(info);
175:                }
176:                return info;
177:            }
178:
179:            private ITarget getTarget() {
180:                return getModel().getTarget();
181:            }
182:
183:            private ITargetModel getModel() {
184:                return (ITargetModel) getPage().getPDEEditor()
185:                        .getAggregateModel();
186:            }
187:
188:            public void refresh() {
189:                fLastTab = fTabFolder.getSelectionIndex();
190:                if (fLastTab == 0)
191:                    fArgument.setValue(getArgumentInfo().getProgramArguments(),
192:                            true);
193:                else
194:                    fArgument
195:                            .setValue(getArgumentInfo().getVMArguments(), true);
196:                super .refresh();
197:            }
198:
199:            public void commit(boolean onSave) {
200:                fArgument.commit();
201:                super .commit(onSave);
202:            }
203:
204:            public void cancelEdit() {
205:                fArgument.cancelEdit();
206:                super .cancelEdit();
207:            }
208:
209:            public boolean canPaste(Clipboard clipboard) {
210:                Display d = getSection().getDisplay();
211:                return d.getFocusControl() instanceof  Text;
212:            }
213:
214:            public void dispose() {
215:                ITargetModel model = getModel();
216:                if (model != null) {
217:                    model.removeModelChangedListener(this);
218:                }
219:                if (fImage != null)
220:                    fImage.dispose();
221:                super.dispose();
222:            }
223:
224:        }
w___w__w_.__j__av__a___2_s__._c___o_m | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.