1 11 package org.eclipse.pde.internal.ui.editor.schema; 12 import org.eclipse.osgi.util.NLS; 13 import org.eclipse.pde.internal.core.ischema.ISchemaCompositor; 14 import org.eclipse.pde.internal.core.ischema.ISchemaObject; 15 import org.eclipse.pde.internal.core.schema.SchemaCompositor; 16 import org.eclipse.pde.internal.ui.PDEUIMessages; 17 import org.eclipse.pde.internal.ui.parts.ComboPart; 18 import org.eclipse.swt.SWT; 19 import org.eclipse.swt.events.SelectionAdapter; 20 import org.eclipse.swt.events.SelectionEvent; 21 import org.eclipse.swt.layout.GridData; 22 import org.eclipse.swt.widgets.Composite; 23 import org.eclipse.swt.widgets.Label; 24 import org.eclipse.ui.forms.IFormColors; 25 import org.eclipse.ui.forms.widgets.FormToolkit; 26 27 public class SchemaCompositorDetails extends AbstractSchemaDetails { 28 29 private SchemaCompositor fCompositor; 30 private ComboPart fKind; 31 private Label fKindLabel; 32 33 public SchemaCompositorDetails(ElementSection section) { 34 super(section, true); 35 } 36 37 public void createDetails(Composite parent) { 38 FormToolkit toolkit = getManagedForm().getToolkit(); 39 40 createMinOccurComp(parent, toolkit); 41 createMaxOccurComp(parent, toolkit); 42 43 fKindLabel = toolkit.createLabel(parent, PDEUIMessages.SchemaCompositorDetails_type); 44 fKindLabel.setForeground(toolkit.getColors().getColor(IFormColors.TITLE)); 45 fKind = new ComboPart(); 46 fKind.createControl(parent, toolkit, SWT.READ_ONLY); 47 GridData gd = new GridData(GridData.FILL_HORIZONTAL); 48 gd.horizontalSpan = 2; 49 fKind.getControl().setLayoutData(gd); 50 fKind.setItems(new String [] { 51 ISchemaCompositor.kindTable[ISchemaCompositor.CHOICE], 52 ISchemaCompositor.kindTable[ISchemaCompositor.SEQUENCE]}); 53 fKind.getControl().setEnabled(isEditable()); 54 55 setText(PDEUIMessages.SchemaCompositorDetails_title); 56 } 57 58 public void updateFields(ISchemaObject object) { 59 if (!(object instanceof SchemaCompositor)) 60 return; 61 fCompositor = (SchemaCompositor)object; 62 setDecription(NLS.bind(PDEUIMessages.SchemaCompositorDetails_description, fCompositor.getName())); 63 updateMinOccur(fCompositor.getMinOccurs()); 64 updateMaxOccur(fCompositor.getMaxOccurs()); 65 fKind.select(fCompositor.getKind() - 1); 66 67 boolean editable = isEditableElement(); 68 fKindLabel.setEnabled(editable); 69 fKind.setEnabled(editable); 70 enableMinMax(editable); 71 } 72 73 public void hookListeners() { 74 hookMinOccur(new SelectionAdapter() { 75 public void widgetSelected(SelectionEvent e) { 76 if (blockListeners()) 77 return; 78 fCompositor.setMinOccurs(getMinOccur()); 79 } 80 }); 81 hookMaxOccur(new SelectionAdapter() { 82 public void widgetSelected(SelectionEvent e) { 83 if (blockListeners()) 84 return; 85 fCompositor.setMaxOccurs(getMaxOccur()); 86 } 87 }); 88 fKind.addSelectionListener(new SelectionAdapter() { 89 public void widgetSelected(SelectionEvent e) { 90 if (blockListeners()) 91 return; 92 fCompositor.setKind(fKind.getSelectionIndex() + 1); 93 setDecription(NLS.bind(PDEUIMessages.SchemaCompositorDetails_description, fCompositor.getName())); 94 } 95 }); 96 } 97 98 101 public void commit(boolean onSave) { 102 super.commit(onSave); 103 } 106 } 107 | Popular Tags |