Source Code Cross Referenced for TargetDefinitionWizardPage.java in  » IDE-Eclipse » Eclipse-plug-in-development » org » eclipse » pde » internal » ui » wizards » 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.wizards.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.wizards.target;
011:
012:        import java.io.BufferedInputStream;
013:        import java.io.IOException;
014:        import java.io.InputStream;
015:        import java.net.URL;
016:
017:        import org.eclipse.core.runtime.CoreException;
018:        import org.eclipse.core.runtime.IConfigurationElement;
019:        import org.eclipse.jface.dialogs.Dialog;
020:        import org.eclipse.jface.viewers.IStructuredSelection;
021:        import org.eclipse.pde.internal.core.PDECore;
022:        import org.eclipse.pde.internal.core.TargetDefinitionManager;
023:        import org.eclipse.pde.internal.core.itarget.ITargetModel;
024:        import org.eclipse.pde.internal.core.target.TargetModel;
025:        import org.eclipse.pde.internal.ui.IHelpContextIds;
026:        import org.eclipse.pde.internal.ui.PDEUIMessages;
027:        import org.eclipse.pde.internal.ui.editor.target.OpenTargetProfileAction;
028:        import org.eclipse.pde.internal.ui.util.SWTUtil;
029:        import org.eclipse.pde.internal.ui.wizards.PDEWizardNewFileCreationPage;
030:        import org.eclipse.swt.SWT;
031:        import org.eclipse.swt.events.SelectionAdapter;
032:        import org.eclipse.swt.events.SelectionEvent;
033:        import org.eclipse.swt.layout.GridData;
034:        import org.eclipse.swt.layout.GridLayout;
035:        import org.eclipse.swt.widgets.Button;
036:        import org.eclipse.swt.widgets.Combo;
037:        import org.eclipse.swt.widgets.Composite;
038:        import org.eclipse.swt.widgets.Group;
039:        import org.eclipse.ui.PlatformUI;
040:
041:        public class TargetDefinitionWizardPage extends
042:                PDEWizardNewFileCreationPage {
043:
044:            protected static final int USE_DEFAULT = 0;
045:            protected static final int USE_CURRENT_TP = 1;
046:            protected static final int USE_EXISTING_TARGET = 2;
047:
048:            private Button fDefaultButton;
049:            private Button fCurrentTPButton;
050:            private Button fExistingTargetButton;
051:            private Combo fTargets;
052:            private String[] fTargetIds;
053:            private Button fPreviewButton;
054:
055:            private static String EXTENSION = "target"; //$NON-NLS-1$
056:
057:            public TargetDefinitionWizardPage(String pageName,
058:                    IStructuredSelection selection) {
059:                super (pageName, selection);
060:                setTitle(PDEUIMessages.TargetProfileWizardPage_title);
061:                setDescription(PDEUIMessages.TargetProfileWizardPage_description);
062:                // Force the file extension to be 'target'
063:                setFileExtension(EXTENSION);
064:            }
065:
066:            public void createControl(Composite parent) {
067:                super .createControl(parent);
068:
069:                PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(),
070:                        IHelpContextIds.TARGET_DEFINITION_PAGE);
071:            }
072:
073:            protected void createAdvancedControls(Composite parent) {
074:                Group group = new Group(parent, SWT.NONE);
075:                group.setText(PDEUIMessages.TargetProfileWizardPage_groupTitle);
076:                group.setLayout(new GridLayout(3, false));
077:                group.setLayoutData(new GridData(GridData.FILL_BOTH));
078:
079:                fDefaultButton = new Button(group, SWT.RADIO);
080:                fDefaultButton
081:                        .setText(PDEUIMessages.TargetProfileWizardPage_blankTarget);
082:                GridData gd = new GridData(GridData.FILL_HORIZONTAL);
083:                gd.horizontalSpan = 3;
084:                fDefaultButton.setLayoutData(gd);
085:                fDefaultButton.setSelection(true);
086:
087:                fCurrentTPButton = new Button(group, SWT.RADIO);
088:                fCurrentTPButton
089:                        .setText(PDEUIMessages.TargetProfileWizardPage_currentPlatform);
090:                gd = new GridData(GridData.FILL_HORIZONTAL);
091:                gd.horizontalSpan = 3;
092:                fCurrentTPButton.setLayoutData(gd);
093:
094:                fExistingTargetButton = new Button(group, SWT.RADIO);
095:                fExistingTargetButton
096:                        .setText(PDEUIMessages.TargetProfileWizardPage_existingTarget);
097:                fExistingTargetButton.setLayoutData(new GridData());
098:                fExistingTargetButton
099:                        .addSelectionListener(new SelectionAdapter() {
100:                            public void widgetSelected(SelectionEvent e) {
101:                                boolean enabled = fExistingTargetButton
102:                                        .getSelection();
103:                                fTargets.setEnabled(enabled);
104:                                fPreviewButton.setEnabled(enabled);
105:                            }
106:                        });
107:
108:                fTargets = new Combo(group, SWT.SINGLE | SWT.READ_ONLY);
109:                fTargets.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
110:                fTargets.setEnabled(false);
111:                initializeTargetCombo();
112:
113:                fPreviewButton = new Button(group, SWT.PUSH);
114:                fPreviewButton
115:                        .setText(PDEUIMessages.TargetProfileWizardPage_viewProfile);
116:                fPreviewButton.setLayoutData(new GridData());
117:                SWTUtil.setButtonDimensionHint(fPreviewButton);
118:                fPreviewButton.setEnabled(false);
119:                fPreviewButton.addSelectionListener(new SelectionAdapter() {
120:                    public void widgetSelected(SelectionEvent e) {
121:                        InputStream stream = null;
122:                        try {
123:                            URL url = getExternalTargetURL();
124:                            if (url != null)
125:                                stream = new BufferedInputStream(url
126:                                        .openStream());
127:                            if (stream != null) {
128:                                ITargetModel model = new TargetModel();
129:                                model.load(stream, false);
130:                                new OpenTargetProfileAction(getShell(), model,
131:                                        fTargets.getText()).run();
132:                            }
133:                        } catch (IOException e1) {
134:                        } catch (CoreException e2) {
135:                        } finally {
136:                            try {
137:                                if (stream != null)
138:                                    stream.close();
139:                            } catch (IOException e3) {
140:                            }
141:                        }
142:                    }
143:                });
144:
145:                Dialog.applyDialogFont(group);
146:            }
147:
148:            private URL getExternalTargetURL() {
149:                TargetDefinitionManager manager = PDECore.getDefault()
150:                        .getTargetProfileManager();
151:                IConfigurationElement elem = manager
152:                        .getTarget(fTargetIds[fTargets.getSelectionIndex()]);
153:                if (elem != null) {
154:                    String path = elem.getAttribute("definition"); //$NON-NLS-1$
155:                    String symbolicName = elem.getDeclaringExtension()
156:                            .getNamespaceIdentifier();
157:                    return TargetDefinitionManager.getResourceURL(symbolicName,
158:                            path);
159:                }
160:                return null;
161:            }
162:
163:            protected void initializeTargetCombo() {
164:                IConfigurationElement[] elements = PDECore.getDefault()
165:                        .getTargetProfileManager().getSortedTargets();
166:                fTargetIds = new String[elements.length];
167:                for (int i = 0; i < elements.length; i++) {
168:                    String name = elements[i].getAttribute("name"); //$NON-NLS-1$
169:                    if (fTargets.indexOf(name) == -1)
170:                        fTargets.add(name);
171:                    fTargetIds[i] = elements[i].getAttribute("id"); //$NON-NLS-1$
172:                }
173:                if (elements.length > 0)
174:                    fTargets.select(0);
175:            }
176:
177:            protected int getInitializationOption() {
178:                if (fDefaultButton.getSelection())
179:                    return USE_DEFAULT;
180:                else if (fCurrentTPButton.getSelection())
181:                    return USE_CURRENT_TP;
182:                return USE_EXISTING_TARGET;
183:            }
184:
185:            protected String getTargetId() {
186:                return fTargetIds[fTargets.getSelectionIndex()];
187:            }
188:
189:        }
w___w__w__.j__a___va2___s__._co__m_ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.