1 11 package org.eclipse.ui.internal.intro.impl.swt; 12 13 import org.eclipse.swt.SWT; 14 import org.eclipse.swt.widgets.Composite; 15 import org.eclipse.swt.widgets.Label; 16 import org.eclipse.ui.forms.widgets.FormToolkit; 17 import org.eclipse.ui.forms.widgets.ScrolledPageBook; 18 import org.eclipse.ui.forms.widgets.TableWrapData; 19 import org.eclipse.ui.forms.widgets.TableWrapLayout; 20 import org.eclipse.ui.internal.intro.impl.IIntroConstants; 21 import org.eclipse.ui.internal.intro.impl.model.AbstractIntroElement; 22 import org.eclipse.ui.internal.intro.impl.model.AbstractIntroPage; 23 import org.eclipse.ui.internal.intro.impl.model.IntroModelRoot; 24 import org.eclipse.ui.intro.config.IIntroContentProviderSite; 25 26 30 public class PageContentForm implements IIntroConstants { 31 32 private FormToolkit toolkit; 33 private IntroModelRoot model; 34 private PageStyleManager styleManager; 35 private Composite contentComposite; 37 38 private AbstractIntroPage page; 40 41 private IIntroContentProviderSite site; 44 45 46 public PageContentForm(FormToolkit toolkit, IntroModelRoot modelRoot) { 47 this.toolkit = toolkit; 48 this.model = modelRoot; 49 page = model.getCurrentPage(); 50 } 51 52 public PageContentForm(FormToolkit toolkit, IntroModelRoot modelRoot, 53 AbstractIntroPage page) { 54 this(toolkit, modelRoot); 55 this.page = page; 56 } 57 58 59 66 public void createPartControl(ScrolledPageBook contentPageBook, 67 PageStyleManager pageStyleManager) { 68 styleManager = pageStyleManager; 69 70 contentComposite = contentPageBook.createPage(page.getId()); 73 TableWrapLayout layout = new TableWrapLayout(); 75 layout.topMargin = 15; 76 layout.leftMargin = 15; 77 layout.rightMargin = 15; 78 layout.bottomMargin = 15; 79 layout.verticalSpacing = 15; 80 contentComposite.setLayout(layout); 81 82 if (styleManager.getPageDescription() != null) { 83 Label label = toolkit.createLabel(contentComposite, styleManager 84 .getPageDescription(), SWT.WRAP); 85 label.setFont(PageStyleManager.getBannerFont()); 86 TableWrapData td = new TableWrapData(); 87 td.align = TableWrapData.FILL; 88 label.setLayoutData(td); 89 } 90 91 contentComposite.setData(PAGE_SUBTITLE, styleManager.getPageSubTitle()); 95 96 createPageChildren(page, contentComposite); 97 98 styleManager = null; 99 } 100 101 private void createPageChildren(AbstractIntroPage page, Composite parent) { 102 PageWidgetFactory factory = new PageWidgetFactory(toolkit, styleManager); 104 factory.setContentProviderSite(site); 105 Composite pageComposite = createPageTableComposite(factory, toolkit, styleManager, parent); 106 AbstractIntroElement[] children = page.getChildren(); 108 for (int i = 0; i < children.length; i++) 109 factory.createIntroElement(pageComposite, children[i]); 110 111 } 112 113 120 static Composite createPageTableComposite(PageWidgetFactory factory, FormToolkit toolkit, 121 PageStyleManager styleManager, Composite parent) { 122 Composite client = toolkit.createComposite(parent); 123 TableWrapLayout layout = new TableWrapLayout(); 124 layout.topMargin = 0; 125 layout.bottomMargin = 0; 126 layout.leftMargin = 0; 127 layout.rightMargin = 0; 128 int numColumns = styleManager.getPageNumberOfColumns(); 129 layout.numColumns = numColumns == 0 ? 1 : numColumns; 130 layout.horizontalSpacing = styleManager.getPageHorizantalSpacing(); 131 layout.verticalSpacing = styleManager.getPageVerticalSpacing(); 132 client.setLayout(layout); 133 134 TableWrapData td = new TableWrapData(TableWrapData.FILL, 136 TableWrapData.FILL); 137 td.grabHorizontal = true; 139 client.setLayoutData(td); 140 return client; 141 } 142 143 144 public void setContentProviderSite(IIntroContentProviderSite site) { 145 this.site = site; 146 } 147 148 149 150 } 151 | Popular Tags |