1 11 12 package org.eclipse.pde.internal.ui.editor.cheatsheet; 13 14 import org.eclipse.jface.viewers.ISelection; 15 import org.eclipse.jface.viewers.IStructuredSelection; 16 import org.eclipse.pde.core.IModelChangedEvent; 17 import org.eclipse.pde.internal.ui.editor.FormLayoutFactory; 18 import org.eclipse.pde.internal.ui.editor.PDEDetails; 19 import org.eclipse.pde.internal.ui.editor.PDEFormPage; 20 import org.eclipse.swt.widgets.Composite; 21 import org.eclipse.ui.forms.IFormPart; 22 import org.eclipse.ui.forms.widgets.FormToolkit; 23 24 28 public abstract class CSAbstractDetails extends PDEDetails implements ICSDetails { 29 30 private ICSMaster fMasterSection; 31 32 private String fContextID; 33 34 37 public CSAbstractDetails(ICSMaster masterSection, String contextID) { 38 fMasterSection = masterSection; 39 fContextID = contextID; 40 } 41 42 45 public void createContents(Composite parent) { 46 configureParentLayout(parent); 47 createDetails(parent); 48 hookListeners(); 49 } 50 51 54 private void configureParentLayout(Composite parent) { 55 parent.setLayout(FormLayoutFactory.createDetailsGridLayout(false, 1)); 56 } 57 58 61 public abstract void createDetails(Composite parent); 62 63 66 public abstract void updateFields(); 67 68 71 public abstract void hookListeners(); 72 73 76 public void selectionChanged(IFormPart part, ISelection selection) { 77 } 80 81 84 public void fireSaveNeeded() { 85 markDirty(); 86 getPage().getPDEEditor().fireSaveNeeded(getContextId(), false); 87 } 88 89 92 public String getContextId() { 93 return fContextID; 94 } 95 96 99 public PDEFormPage getPage() { 100 return (PDEFormPage)getManagedForm().getContainer(); 101 } 102 103 106 public boolean isEditable() { 107 return fMasterSection.isEditable(); 108 } 109 110 113 public void modelChanged(IModelChangedEvent event) { 114 } 116 117 120 public boolean isEditableElement() { 121 return fMasterSection.isEditable(); 122 } 123 124 127 public FormToolkit getToolkit() { 128 return getManagedForm().getToolkit(); 129 } 130 131 134 public ICSMaster getMasterSection() { 135 return fMasterSection; 136 } 137 138 142 protected Object getFirstSelectedObject(ISelection selection) { 143 IStructuredSelection structuredSel = ((IStructuredSelection)selection); 145 if (structuredSel == null) { 147 return null; 148 } 149 return structuredSel.getFirstElement(); 150 } 151 152 } 153 | Popular Tags |