1 11 package org.eclipse.ui.forms; 12 13 import org.eclipse.swt.widgets.Composite; 14 import org.eclipse.swt.widgets.Control; 15 import org.eclipse.ui.forms.events.ExpansionAdapter; 16 import org.eclipse.ui.forms.events.ExpansionEvent; 17 import org.eclipse.ui.forms.widgets.FormToolkit; 18 import org.eclipse.ui.forms.widgets.Section; 19 20 32 public class SectionPart extends AbstractFormPart { 33 private Section section; 34 35 41 public SectionPart(Section section) { 42 this.section = section; 43 hookListeners(); 44 } 45 46 57 public SectionPart(Composite parent, FormToolkit toolkit, int style) { 58 this(toolkit.createSection(parent, style)); 59 } 60 61 64 protected void hookListeners() { 65 if ((section.getExpansionStyle() & Section.TWISTIE) != 0 66 || (section.getExpansionStyle() & Section.TREE_NODE) != 0) { 67 section.addExpansionListener(new ExpansionAdapter() { 68 public void expansionStateChanging(ExpansionEvent e) { 69 SectionPart.this.expansionStateChanging(e.getState()); 70 } 71 72 public void expansionStateChanged(ExpansionEvent e) { 73 SectionPart.this.expansionStateChanged(e.getState()); 74 } 75 }); 76 } 77 } 78 79 84 public Section getSection() { 85 return section; 86 } 87 88 95 protected void expansionStateChanging(boolean expanding) { 96 } 97 98 105 protected void expansionStateChanged(boolean expanded) { 106 getManagedForm().getForm().reflow(false); 107 } 108 109 112 public void setFocus() { 113 Control client = section.getClient(); 114 if (client != null) 115 client.setFocus(); 116 } 117 } 118 | Popular Tags |