KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > pde > internal > ui > editor > product > ProductEditor


1 /*******************************************************************************
2  * Copyright (c) 2005, 2007 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.pde.internal.ui.editor.product;
12
13 import java.io.File JavaDoc;
14
15 import org.eclipse.core.resources.IFile;
16 import org.eclipse.pde.core.IBaseModel;
17 import org.eclipse.pde.internal.core.iproduct.IProductModel;
18 import org.eclipse.pde.internal.ui.IPDEUIConstants;
19 import org.eclipse.pde.internal.ui.PDEPlugin;
20 import org.eclipse.pde.internal.ui.editor.ISortableContentOutlinePage;
21 import org.eclipse.pde.internal.ui.editor.PDEFormEditor;
22 import org.eclipse.pde.internal.ui.editor.SystemFileEditorInput;
23 import org.eclipse.pde.internal.ui.editor.context.InputContext;
24 import org.eclipse.pde.internal.ui.editor.context.InputContextManager;
25 import org.eclipse.ui.IEditorInput;
26 import org.eclipse.ui.IFileEditorInput;
27 import org.eclipse.ui.IStorageEditorInput;
28 import org.eclipse.ui.PartInitException;
29
30
31 public class ProductEditor extends PDEFormEditor {
32
33     /**
34      *
35      */

36     public ProductEditor() {
37         super();
38     }
39
40     /* (non-Javadoc)
41      * @see org.eclipse.pde.internal.ui.editor.PDEFormEditor#getEditorID()
42      */

43     protected String JavaDoc getEditorID() {
44         return IPDEUIConstants.PRODUCT_EDITOR_ID;
45     }
46     
47     /* (non-Javadoc)
48      * @see org.eclipse.pde.internal.ui.editor.PDEFormEditor#isSaveAsAllowed()
49      */

50     public boolean isSaveAsAllowed() {
51         return true;
52     }
53     
54     /* (non-Javadoc)
55      * @see org.eclipse.pde.internal.ui.editor.PDEFormEditor#getContextIDForSaveAs()
56      */

57     public String JavaDoc getContextIDForSaveAs() {
58         return ProductInputContext.CONTEXT_ID;
59     }
60     
61     /* (non-Javadoc)
62      * @see org.eclipse.pde.internal.ui.editor.PDEFormEditor#createInputContextManager()
63      */

64     protected InputContextManager createInputContextManager() {
65         return new ProductInputContextManager(this);
66     }
67
68     /* (non-Javadoc)
69      * @see org.eclipse.pde.internal.ui.editor.PDEFormEditor#createResourceContexts(org.eclipse.pde.internal.ui.editor.context.InputContextManager, org.eclipse.ui.IFileEditorInput)
70      */

71     protected void createResourceContexts(InputContextManager manager, IFileEditorInput input) {
72         manager.putContext(input, new ProductInputContext(this, input, true));
73         manager.monitorFile(input.getFile());
74     }
75
76     /* (non-Javadoc)
77      * @see org.eclipse.pde.internal.ui.editor.PDEFormEditor#createSystemFileContexts(org.eclipse.pde.internal.ui.editor.context.InputContextManager, org.eclipse.pde.internal.ui.editor.SystemFileEditorInput)
78      */

79     protected void createSystemFileContexts(InputContextManager manager,
80             SystemFileEditorInput input) {
81         File JavaDoc file = (File JavaDoc) input.getAdapter(File JavaDoc.class);
82         if (file != null) {
83             String JavaDoc name = file.getName();
84             if (name.endsWith(".product")) { //$NON-NLS-1$
85
IEditorInput in = new SystemFileEditorInput(file);
86                 manager.putContext(in, new ProductInputContext(this, in, true));
87             }
88         }
89     }
90
91     /* (non-Javadoc)
92      * @see org.eclipse.pde.internal.ui.editor.PDEFormEditor#createStorageContexts(org.eclipse.pde.internal.ui.editor.context.InputContextManager, org.eclipse.ui.IStorageEditorInput)
93      */

94     protected void createStorageContexts(InputContextManager manager,
95             IStorageEditorInput input) {
96         if (input.getName().endsWith(".product")) { //$NON-NLS-1$
97
manager.putContext(input, new ProductInputContext(this, input, true));
98         }
99     }
100
101     /* (non-Javadoc)
102      * @see org.eclipse.pde.internal.ui.editor.PDEFormEditor#createContentOutline()
103      */

104     protected ISortableContentOutlinePage createContentOutline() {
105         return new ProductOutlinePage(this);
106     }
107
108     /* (non-Javadoc)
109      * @see org.eclipse.pde.internal.ui.editor.PDEFormEditor#getInputContext(java.lang.Object)
110      */

111     protected InputContext getInputContext(Object JavaDoc object) {
112         return fInputContextManager.findContext(ProductInputContext.CONTEXT_ID);
113     }
114
115     /* (non-Javadoc)
116      * @see org.eclipse.ui.forms.editor.FormEditor#addPages()
117      */

118     protected void addEditorPages() {
119         try {
120             addPage(new OverviewPage(this));
121             addPage(new ConfigurationPage(this, useFeatures()));
122             addPage(new LaunchingPage(this));
123             addPage(new SplashPage(this));
124             addPage(new BrandingPage(this));
125         } catch (PartInitException e) {
126             PDEPlugin.logException(e);
127         }
128     }
129     
130     public void updateConfigurationPage() {
131         try {
132             removePage(1);
133             addPage(1, new ConfigurationPage(this, useFeatures()));
134         } catch (PartInitException e) {
135         }
136     }
137     
138     public boolean useFeatures() {
139         IBaseModel model = getAggregateModel();
140         return ((IProductModel)model).getProduct().useFeatures();
141     }
142
143     /* (non-Javadoc)
144      * @see org.eclipse.pde.internal.ui.editor.context.IInputContextListener#contextAdded(org.eclipse.pde.internal.ui.editor.context.InputContext)
145      */

146     public void editorContextAdded(InputContext context) {
147     }
148
149     /* (non-Javadoc)
150      * @see org.eclipse.pde.internal.ui.editor.context.IInputContextListener#contextRemoved(org.eclipse.pde.internal.ui.editor.context.InputContext)
151      */

152     public void contextRemoved(InputContext context) {
153         close(false);
154     }
155
156     /* (non-Javadoc)
157      * @see org.eclipse.pde.internal.ui.editor.context.IInputContextListener#monitoredFileAdded(org.eclipse.core.resources.IFile)
158      */

159     public void monitoredFileAdded(IFile monitoredFile) {
160     }
161
162     /* (non-Javadoc)
163      * @see org.eclipse.pde.internal.ui.editor.context.IInputContextListener#monitoredFileRemoved(org.eclipse.core.resources.IFile)
164      */

165     public boolean monitoredFileRemoved(IFile monitoredFile) {
166         return true;
167     }
168
169 }
170
Popular Tags