1 11 package org.eclipse.pde.internal.ui.editor; 12 13 import org.eclipse.jface.viewers.ISelection; 14 import org.eclipse.pde.core.IModelChangedEvent; 15 import org.eclipse.swt.widgets.Composite; 16 import org.eclipse.ui.forms.IFormPart; 17 18 21 public abstract class PDEDetailsSections extends PDEDetails { 22 private PDESection sections[]; 23 24 protected abstract PDESection[] createSections(PDEFormPage page, 25 Composite parent); 26 27 32 public void createContents(Composite parent) { 33 sections = createSections(getPage(), parent); 34 parent.setLayout(FormLayoutFactory.createDetailsGridLayout(false, 1)); 35 for (int i = 0; i < sections.length; i++) { 36 getManagedForm().addPart(sections[i]); 37 } 38 } 39 40 public void dispose() { 41 for (int i = 0; i < sections.length; i++) { 42 sections[i].dispose(); 43 } 44 } 45 46 public void fireSaveNeeded() { 47 markDirty(); 48 getPage().getPDEEditor().fireSaveNeeded(getContextId(), false); 49 } 50 51 public abstract String getContextId(); 52 53 public PDEFormPage getPage() { 54 return (PDEFormPage) getManagedForm().getContainer(); 55 } 56 57 62 public boolean isDirty() { 63 for (int i = 0; i < sections.length; i++) { 64 if (sections[i].isDirty()) { 65 return true; 66 } 67 } 68 return super.isDirty(); 69 } 70 71 public boolean isEditable() { 72 return getPage().getPDEEditor().getAggregateModel().isEditable(); 73 } 74 75 80 public boolean isStale() { 81 for (int i = 0; i < sections.length; i++) { 82 if (sections[i].isStale()) { 83 return true; 84 } 85 } 86 return super.isStale(); 87 } 88 89 94 public void modelChanged(IModelChangedEvent event) { 95 } 96 97 102 public void selectionChanged(IFormPart masterPart, ISelection selection) { 103 } 104 105 110 public void setFocus() { 111 if (sections.length > 0) { 112 sections[0].setFocus(); 113 } 114 } 115 } 116 | Popular Tags |