1 11 12 package org.eclipse.pde.internal.ui.editor.cheatsheet.comp; 13 14 import java.io.File ; 15 16 import org.eclipse.core.resources.IFile; 17 import org.eclipse.jface.viewers.ISelection; 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 import org.eclipse.ui.forms.editor.IFormPage; 30 31 35 public class CompCSEditor extends PDEFormEditor { 36 37 40 public CompCSEditor() { 41 super(); 42 } 43 44 47 protected String getEditorID() { 48 return IPDEUIConstants.COMPOSITE_CHEAT_SHEET_EDITOR_ID; 49 } 50 51 54 public boolean isSaveAsAllowed() { 55 return true; 56 } 57 58 61 public String getContextIDForSaveAs() { 62 return CompCSInputContext.CONTEXT_ID; 63 } 64 65 68 protected void addEditorPages() { 69 try { 70 addPage(new CompCSPage(this)); 71 } catch (PartInitException e) { 72 PDEPlugin.logException(e); 73 } 74 } 75 76 79 protected ISortableContentOutlinePage createContentOutline() { 80 return new CompCSFormOutlinePage(this); 81 } 82 83 86 protected InputContextManager createInputContextManager() { 87 return new CompCSInputContextManager(this); 88 } 89 90 93 protected void createResourceContexts(InputContextManager contexts, 94 IFileEditorInput input) { 95 contexts.putContext(input, new CompCSInputContext(this, input, true)); 96 contexts.monitorFile(input.getFile()); 97 } 98 99 102 protected void createStorageContexts(InputContextManager contexts, 103 IStorageEditorInput input) { 104 contexts.putContext(input, new CompCSInputContext(this, input, true)); 105 } 106 107 110 protected void createSystemFileContexts(InputContextManager contexts, 111 SystemFileEditorInput input) { 112 File file = (File )input.getAdapter(File .class); 113 if (file != null) { 114 IEditorInput in = new SystemFileEditorInput(file); 115 contexts.putContext(in, new CompCSInputContext(this, in, true)); 116 } 117 } 118 119 122 public void editorContextAdded(InputContext context) { 123 } 125 126 129 protected InputContext getInputContext(Object object) { 130 return fInputContextManager.findContext(CompCSInputContext.CONTEXT_ID); 131 } 132 133 136 public void contextRemoved(InputContext context) { 137 close(false); 138 } 139 140 143 public void monitoredFileAdded(IFile monitoredFile) { 144 } 146 147 150 public boolean monitoredFileRemoved(IFile monitoredFile) { 151 return true; 152 } 153 154 157 public ISelection getSelection() { 158 IFormPage formPage = getActivePageInstance(); 164 if ((formPage != null) && 165 (formPage instanceof CompCSPage)) { 166 return ((CompCSPage)formPage).getSelection(); 170 } 171 return super.getSelection(); 172 } 173 174 } 175 | Popular Tags |