1 11 package org.eclipse.pde.internal.ui.editor.product; 12 13 import java.io.File ; 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 36 public ProductEditor() { 37 super(); 38 } 39 40 43 protected String getEditorID() { 44 return IPDEUIConstants.PRODUCT_EDITOR_ID; 45 } 46 47 50 public boolean isSaveAsAllowed() { 51 return true; 52 } 53 54 57 public String getContextIDForSaveAs() { 58 return ProductInputContext.CONTEXT_ID; 59 } 60 61 64 protected InputContextManager createInputContextManager() { 65 return new ProductInputContextManager(this); 66 } 67 68 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 79 protected void createSystemFileContexts(InputContextManager manager, 80 SystemFileEditorInput input) { 81 File file = (File ) input.getAdapter(File .class); 82 if (file != null) { 83 String name = file.getName(); 84 if (name.endsWith(".product")) { IEditorInput in = new SystemFileEditorInput(file); 86 manager.putContext(in, new ProductInputContext(this, in, true)); 87 } 88 } 89 } 90 91 94 protected void createStorageContexts(InputContextManager manager, 95 IStorageEditorInput input) { 96 if (input.getName().endsWith(".product")) { manager.putContext(input, new ProductInputContext(this, input, true)); 98 } 99 } 100 101 104 protected ISortableContentOutlinePage createContentOutline() { 105 return new ProductOutlinePage(this); 106 } 107 108 111 protected InputContext getInputContext(Object object) { 112 return fInputContextManager.findContext(ProductInputContext.CONTEXT_ID); 113 } 114 115 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 146 public void editorContextAdded(InputContext context) { 147 } 148 149 152 public void contextRemoved(InputContext context) { 153 close(false); 154 } 155 156 159 public void monitoredFileAdded(IFile monitoredFile) { 160 } 161 162 165 public boolean monitoredFileRemoved(IFile monitoredFile) { 166 return true; 167 } 168 169 } 170 | Popular Tags |