1 11 12 package org.eclipse.pde.internal.ui.editor.cheatsheet.comp; 13 14 import org.eclipse.jface.viewers.ISelection; 15 import org.eclipse.pde.core.IModelChangedEvent; 16 import org.eclipse.pde.core.IModelChangedListener; 17 import org.eclipse.pde.internal.core.icheatsheet.comp.ICompCS; 18 import org.eclipse.pde.internal.core.icheatsheet.comp.ICompCSTask; 19 import org.eclipse.pde.internal.core.icheatsheet.comp.ICompCSTaskGroup; 20 import org.eclipse.pde.internal.ui.editor.PDEFormPage; 21 import org.eclipse.pde.internal.ui.editor.PDEMasterDetailsBlock; 22 import org.eclipse.pde.internal.ui.editor.PDESection; 23 import org.eclipse.pde.internal.ui.editor.cheatsheet.comp.details.CompCSDetails; 24 import org.eclipse.pde.internal.ui.editor.cheatsheet.comp.details.CompCSTaskDetails; 25 import org.eclipse.pde.internal.ui.editor.cheatsheet.comp.details.CompCSTaskGroupDetails; 26 import org.eclipse.swt.widgets.Composite; 27 import org.eclipse.ui.forms.DetailsPart; 28 import org.eclipse.ui.forms.IDetailsPage; 29 import org.eclipse.ui.forms.IDetailsPageProvider; 30 import org.eclipse.ui.forms.IManagedForm; 31 32 36 public class CompCSBlock extends PDEMasterDetailsBlock implements 37 IModelChangedListener, IDetailsPageProvider { 38 39 private CompCSMasterTreeSection fMasterSection; 40 41 private CompCSDetails fDetails; 42 43 private CompCSTaskGroupDetails fTaskGroupDetails; 44 45 private CompCSTaskDetails fTaskDetails; 46 47 50 public CompCSBlock(PDEFormPage page) { 51 super(page); 52 } 53 54 57 protected PDESection createMasterSection(IManagedForm managedForm, 58 Composite parent) { 59 fMasterSection = new CompCSMasterTreeSection(getPage(), parent); 60 return fMasterSection; 61 } 62 63 66 protected void registerPages(DetailsPart detailsPart) { 67 detailsPart.setPageLimit(0); 69 fDetails = new CompCSDetails(fMasterSection); 71 detailsPart.registerPage(CompCSDetails.class, fDetails); 72 fTaskGroupDetails = new CompCSTaskGroupDetails(fMasterSection); 74 detailsPart.registerPage(CompCSTaskGroupDetails.class, fTaskGroupDetails); 75 fTaskDetails = new CompCSTaskDetails(fMasterSection); 77 detailsPart.registerPage(CompCSTaskDetails.class, fTaskDetails); 78 detailsPart.setPageProvider(this); 80 } 81 82 85 public Object getPageKey(Object object) { 86 if (object instanceof ICompCS) { 88 return CompCSDetails.class; 90 } else if (object instanceof ICompCSTaskGroup) { 91 return CompCSTaskGroupDetails.class; 93 } else if (object instanceof ICompCSTask) { 94 return CompCSTaskDetails.class; 96 } 97 return object.getClass(); 99 } 100 101 104 public IDetailsPage getPage(Object key) { 105 return null; 107 } 108 109 112 public void modelChanged(IModelChangedEvent event) { 113 if (fMasterSection != null) { 115 fMasterSection.modelChanged(event); 116 } 117 } 123 124 127 public CompCSMasterTreeSection getMastersSection() { 128 return fMasterSection; 129 } 130 131 134 public ISelection getSelection() { 135 if (fMasterSection != null) { 136 return fMasterSection.getSelection(); 137 } 138 return null; 139 } 140 141 } 142 | Popular Tags |