Source Code Cross Referenced for TargetEditor.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 java.io.File;
013:        import java.lang.reflect.InvocationTargetException;
014:        import java.net.URL;
015:
016:        import org.eclipse.core.resources.IFile;
017:        import org.eclipse.core.runtime.CoreException;
018:        import org.eclipse.core.runtime.IPath;
019:        import org.eclipse.core.runtime.IProgressMonitor;
020:        import org.eclipse.core.runtime.OperationCanceledException;
021:        import org.eclipse.core.runtime.Path;
022:        import org.eclipse.core.runtime.Platform;
023:        import org.eclipse.jface.action.ControlContribution;
024:        import org.eclipse.jface.action.IToolBarManager;
025:        import org.eclipse.jface.dialogs.IPageChangedListener;
026:        import org.eclipse.jface.dialogs.MessageDialog;
027:        import org.eclipse.jface.dialogs.PageChangedEvent;
028:        import org.eclipse.jface.operation.IRunnableWithProgress;
029:        import org.eclipse.osgi.service.datalocation.Location;
030:        import org.eclipse.pde.internal.core.LoadTargetOperation;
031:        import org.eclipse.pde.internal.core.itarget.ITarget;
032:        import org.eclipse.pde.internal.core.itarget.ITargetModel;
033:        import org.eclipse.pde.internal.ui.IPDEUIConstants;
034:        import org.eclipse.pde.internal.ui.PDEPlugin;
035:        import org.eclipse.pde.internal.ui.PDEUIMessages;
036:        import org.eclipse.pde.internal.ui.editor.ISortableContentOutlinePage;
037:        import org.eclipse.pde.internal.ui.editor.PDEFormEditor;
038:        import org.eclipse.pde.internal.ui.editor.SystemFileEditorInput;
039:        import org.eclipse.pde.internal.ui.editor.context.InputContext;
040:        import org.eclipse.pde.internal.ui.editor.context.InputContextManager;
041:        import org.eclipse.swt.SWT;
042:        import org.eclipse.swt.widgets.Composite;
043:        import org.eclipse.swt.widgets.Control;
044:        import org.eclipse.ui.IEditorInput;
045:        import org.eclipse.ui.IFileEditorInput;
046:        import org.eclipse.ui.IStorageEditorInput;
047:        import org.eclipse.ui.PartInitException;
048:        import org.eclipse.ui.PlatformUI;
049:        import org.eclipse.ui.forms.events.HyperlinkEvent;
050:        import org.eclipse.ui.forms.events.IHyperlinkListener;
051:        import org.eclipse.ui.forms.widgets.ImageHyperlink;
052:        import org.eclipse.ui.progress.IProgressService;
053:
054:        public class TargetEditor extends PDEFormEditor {
055:
056:            protected static String LAST_PATH;
057:
058:            static {
059:                Location installLoc = Platform.getInstallLocation();
060:                if (installLoc == null) {
061:                    LAST_PATH = ""; //$NON-NLS-1$
062:                }
063:                URL url = installLoc.getURL();
064:                LAST_PATH = new Path(url.getPath()).toOSString();
065:            }
066:
067:            public TargetEditor() {
068:                super ();
069:            }
070:
071:            /* (non-Javadoc)
072:             * @see org.eclipse.pde.internal.ui.editor.PDEFormEditor#getEditorID()
073:             */
074:            protected String getEditorID() {
075:                return IPDEUIConstants.TARGET_EDITOR_ID;
076:            }
077:
078:            /* (non-Javadoc)
079:             * @see org.eclipse.pde.internal.ui.editor.PDEFormEditor#isSaveAsAllowed()
080:             */
081:            public boolean isSaveAsAllowed() {
082:                return true;
083:            }
084:
085:            /* (non-Javadoc)
086:             * @see org.eclipse.pde.internal.ui.editor.PDEFormEditor#getContextIDForSaveAs()
087:             */
088:            public String getContextIDForSaveAs() {
089:                return TargetInputContext.CONTEXT_ID;
090:            }
091:
092:            /* (non-Javadoc)
093:             * @see org.eclipse.pde.internal.ui.editor.PDEFormEditor#createInputContextManager()
094:             */
095:            protected InputContextManager createInputContextManager() {
096:                return new TargetInputContextManager(this );
097:            }
098:
099:            /* (non-Javadoc)
100:             * @see org.eclipse.pde.internal.ui.editor.PDEFormEditor#createResourceContexts(org.eclipse.pde.internal.ui.editor.context.InputContextManager, org.eclipse.ui.IFileEditorInput)
101:             */
102:            protected void createResourceContexts(InputContextManager manager,
103:                    IFileEditorInput input) {
104:                manager.putContext(input, new TargetInputContext(this , input,
105:                        true));
106:                manager.monitorFile(input.getFile());
107:            }
108:
109:            /* (non-Javadoc)
110:             * @see org.eclipse.pde.internal.ui.editor.PDEFormEditor#createSystemFileContexts(org.eclipse.pde.internal.ui.editor.context.InputContextManager, org.eclipse.pde.internal.ui.editor.SystemFileEditorInput)
111:             */
112:            protected void createSystemFileContexts(
113:                    InputContextManager manager, SystemFileEditorInput input) {
114:                File file = (File) input.getAdapter(File.class);
115:                if (file != null) {
116:                    String name = file.getName();
117:                    if (name.endsWith(".target")) { //$NON-NLS-1$
118:                        IEditorInput in = new SystemFileEditorInput(file);
119:                        manager.putContext(in, new TargetInputContext(this , in,
120:                                true));
121:                    }
122:                }
123:            }
124:
125:            /* (non-Javadoc)
126:             * @see org.eclipse.pde.internal.ui.editor.PDEFormEditor#createStorageContexts(org.eclipse.pde.internal.ui.editor.context.InputContextManager, org.eclipse.ui.IStorageEditorInput)
127:             */
128:            protected void createStorageContexts(InputContextManager manager,
129:                    IStorageEditorInput input) {
130:                if (input.getName().endsWith(".target")) { //$NON-NLS-1$
131:                    manager.putContext(input, new TargetInputContext(this ,
132:                            input, true));
133:                }
134:            }
135:
136:            /* (non-Javadoc)
137:             * @see org.eclipse.pde.internal.ui.editor.PDEFormEditor#createContentOutline()
138:             */
139:            protected ISortableContentOutlinePage createContentOutline() {
140:                return new TargetOutlinePage(this );
141:            }
142:
143:            /* (non-Javadoc)
144:             * @see org.eclipse.pde.internal.ui.editor.PDEFormEditor#getInputContext(java.lang.Object)
145:             */
146:            protected InputContext getInputContext(Object object) {
147:                return fInputContextManager
148:                        .findContext(TargetInputContext.CONTEXT_ID);
149:            }
150:
151:            /* (non-Javadoc)
152:             * @see org.eclipse.ui.forms.editor.FormEditor#addPages()
153:             */
154:            protected void addEditorPages() {
155:                try {
156:                    addPage(new OverviewPage(this ));
157:                    addPage(new ContentPage(this ));
158:                    addPage(new EnvironmentPage(this ));
159:                    addPageChangedListener(new IPageChangedListener() {
160:
161:                        public void pageChanged(PageChangedEvent event) {
162:                            Object o = event.getSelectedPage();
163:                            if (o instanceof  EnvironmentPage)
164:                                ((EnvironmentPage) o).updateChoices();
165:                        }
166:
167:                    });
168:                } catch (PartInitException e) {
169:                    PDEPlugin.log(e);
170:                }
171:            }
172:
173:            /* (non-Javadoc)
174:             * @see org.eclipse.pde.internal.ui.editor.context.IInputContextListener#contextAdded(org.eclipse.pde.internal.ui.editor.context.InputContext)
175:             */
176:            public void editorContextAdded(InputContext context) {
177:            }
178:
179:            /* (non-Javadoc)
180:             * @see org.eclipse.pde.internal.ui.editor.context.IInputContextListener#contextRemoved(org.eclipse.pde.internal.ui.editor.context.InputContext)
181:             */
182:            public void contextRemoved(InputContext context) {
183:                close(false);
184:            }
185:
186:            /* (non-Javadoc)
187:             * @see org.eclipse.pde.internal.ui.editor.context.IInputContextListener#monitoredFileAdded(org.eclipse.core.resources.IFile)
188:             */
189:            public void monitoredFileAdded(IFile monitoredFile) {
190:            }
191:
192:            /* (non-Javadoc)
193:             * @see org.eclipse.pde.internal.ui.editor.context.IInputContextListener#monitoredFileRemoved(org.eclipse.core.resources.IFile)
194:             */
195:            public boolean monitoredFileRemoved(IFile monitoredFile) {
196:                return true;
197:            }
198:
199:            public void contributeToToolbar(IToolBarManager manager) {
200:                ControlContribution save = new ControlContribution("Set") { //$NON-NLS-1$
201:                    protected Control createControl(Composite parent) {
202:                        final ImageHyperlink hyperlink = new ImageHyperlink(
203:                                parent, SWT.NONE);
204:                        hyperlink
205:                                .setText(PDEUIMessages.AbstractTargetPage_setTarget);
206:                        hyperlink.setUnderlined(true);
207:                        hyperlink.setForeground(getToolkit()
208:                                .getHyperlinkGroup().getForeground());
209:                        hyperlink
210:                                .addHyperlinkListener(new IHyperlinkListener() {
211:                                    public void linkActivated(HyperlinkEvent e) {
212:                                        doLoadTarget();
213:                                    }
214:
215:                                    public void linkEntered(HyperlinkEvent e) {
216:                                        hyperlink.setForeground(getToolkit()
217:                                                .getHyperlinkGroup()
218:                                                .getActiveForeground());
219:                                    }
220:
221:                                    public void linkExited(HyperlinkEvent e) {
222:                                        hyperlink.setForeground(getToolkit()
223:                                                .getHyperlinkGroup()
224:                                                .getForeground());
225:                                    }
226:                                });
227:                        return hyperlink;
228:                    }
229:                };
230:                manager.add(save);
231:            }
232:
233:            private void doLoadTarget() {
234:                IRunnableWithProgress run = new IRunnableWithProgress() {
235:                    public void run(IProgressMonitor monitor)
236:                            throws InvocationTargetException,
237:                            InterruptedException {
238:                        try {
239:                            ITargetModel model = getTargetModel();
240:                            if (!model.isLoaded()) {
241:                                MessageDialog
242:                                        .openError(
243:                                                getActiveEditor().getSite()
244:                                                        .getShell(),
245:                                                PDEUIMessages.TargetPlatformPreferencePage_invalidTitle,
246:                                                PDEUIMessages.TargetPlatformPreferencePage_invalidDescription);
247:                                monitor.done();
248:                                return;
249:                            }
250:                            LoadTargetOperation op = new LoadTargetOperation(
251:                                    getTarget(), getFilePath());
252:                            PDEPlugin.getWorkspace().run(op, monitor);
253:                            Object[] features = op.getMissingFeatures();
254:                            Object[] plugins = op.getMissingPlugins();
255:                            if (plugins.length + features.length > 0)
256:                                TargetErrorDialog.showDialog(getActiveEditor()
257:                                        .getSite().getShell(), features,
258:                                        plugins);
259:                        } catch (CoreException e) {
260:                            throw new InvocationTargetException(e);
261:                        } catch (OperationCanceledException e) {
262:                            throw new InterruptedException(e.getMessage());
263:                        } finally {
264:                            monitor.done();
265:                        }
266:                    }
267:                };
268:                IProgressService service = PlatformUI.getWorkbench()
269:                        .getProgressService();
270:                try {
271:                    service.runInUI(service, run, PDEPlugin.getWorkspace()
272:                            .getRoot());
273:                } catch (InvocationTargetException e) {
274:                } catch (InterruptedException e) {
275:                }
276:            }
277:
278:            private ITarget getTarget() {
279:                return getTargetModel().getTarget();
280:            }
281:
282:            private ITargetModel getTargetModel() {
283:                return ((ITargetModel) getAggregateModel());
284:            }
285:
286:            private IPath getFilePath() {
287:                IEditorInput input = getEditorInput();
288:                if (input instanceof  IFileEditorInput) {
289:                    IFile file = ((IFileEditorInput) input).getFile();
290:                    if (file != null)
291:                        return file.getFullPath();
292:                }
293:                return null;
294:            }
295:
296:        }
ww__w___.___j_a__v__a___2_s___._com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.