1 11 12 package org.eclipse.pde.internal.ui.editor.cheatsheet.simple; 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.simple.ISimpleCS; 18 import org.eclipse.pde.internal.core.icheatsheet.simple.ISimpleCSIntro; 19 import org.eclipse.pde.internal.core.icheatsheet.simple.ISimpleCSItem; 20 import org.eclipse.pde.internal.core.icheatsheet.simple.ISimpleCSSubItem; 21 import org.eclipse.pde.internal.ui.editor.PDEFormPage; 22 import org.eclipse.pde.internal.ui.editor.PDEMasterDetailsBlock; 23 import org.eclipse.pde.internal.ui.editor.PDESection; 24 import org.eclipse.pde.internal.ui.editor.cheatsheet.ICSMaster; 25 import org.eclipse.pde.internal.ui.editor.cheatsheet.simple.details.SimpleCSDetails; 26 import org.eclipse.pde.internal.ui.editor.cheatsheet.simple.details.SimpleCSIntroDetails; 27 import org.eclipse.pde.internal.ui.editor.cheatsheet.simple.details.SimpleCSItemDetails; 28 import org.eclipse.pde.internal.ui.editor.cheatsheet.simple.details.SimpleCSSubItemDetails; 29 import org.eclipse.swt.widgets.Composite; 30 import org.eclipse.ui.forms.DetailsPart; 31 import org.eclipse.ui.forms.IDetailsPage; 32 import org.eclipse.ui.forms.IDetailsPageProvider; 33 import org.eclipse.ui.forms.IManagedForm; 34 35 39 public class SimpleCSBlock extends PDEMasterDetailsBlock implements 40 IDetailsPageProvider, IModelChangedListener { 41 42 private SimpleCSMasterTreeSection fMasterSection; 43 44 private SimpleCSItemDetails fItemDetails; 45 46 private SimpleCSSubItemDetails fSubItemDetails; 47 48 private SimpleCSDetails fCheatSheetDetails; 49 50 private SimpleCSIntroDetails fIntroDetails; 51 52 55 public SimpleCSBlock(PDEFormPage page) { 56 super(page); 57 } 58 59 62 protected PDESection createMasterSection(IManagedForm managedForm, 63 Composite parent) { 64 fMasterSection = new SimpleCSMasterTreeSection(getPage(), parent); 65 return fMasterSection; 66 } 67 68 71 protected void registerPages(DetailsPart detailsPart) { 72 detailsPart.setPageLimit(0); 74 fItemDetails = new SimpleCSItemDetails(fMasterSection); 76 detailsPart.registerPage(SimpleCSItemDetails.class, fItemDetails); 77 fSubItemDetails = new SimpleCSSubItemDetails(fMasterSection); 79 detailsPart.registerPage(SimpleCSSubItemDetails.class, fSubItemDetails); 80 fCheatSheetDetails = new SimpleCSDetails(fMasterSection); 82 detailsPart.registerPage(SimpleCSDetails.class, fCheatSheetDetails); 83 fIntroDetails = new SimpleCSIntroDetails(fMasterSection); 85 detailsPart.registerPage(SimpleCSIntroDetails.class, fIntroDetails); 86 detailsPart.setPageProvider(this); 88 } 89 90 93 public Object getPageKey(Object object) { 94 if (object instanceof ISimpleCSItem) { 96 return SimpleCSItemDetails.class; 98 } else if (object instanceof ISimpleCSSubItem) { 99 return SimpleCSSubItemDetails.class; 101 } else if (object instanceof ISimpleCS) { 102 return SimpleCSDetails.class; 104 } else if (object instanceof ISimpleCSIntro) { 105 return SimpleCSIntroDetails.class; 107 } 108 return object.getClass(); 110 } 111 112 115 public IDetailsPage getPage(Object key) { 116 return null; 118 } 119 120 123 public void modelChanged(IModelChangedEvent event) { 124 if (fMasterSection != null) { 126 fMasterSection.modelChanged(event); 127 } 128 } 134 135 138 public ICSMaster getMastersSection() { 139 return fMasterSection; 140 } 141 142 145 public ISelection getSelection() { 146 if (fMasterSection != null) { 147 return fMasterSection.getSelection(); 148 } 149 return null; 150 } 151 152 } 153 | Popular Tags |