@Override public final void createContents(Composite parent) { // This is a hacked fix to ensure that the label columns on every details // page have the same width. SchemaDetails_translatable plus 11 pixels // represents the longest label on any field on any details page. This // occurs on SchemaStringAttributeDetails and 11 is the size of the // horizontal indent that contributes to the label's width. GC gc = new GC(parent); minLabelWeight = gc.textExtent(PDEUIMessages.SchemaDetails_translatable).x + 11; gc.dispose(); gc = null; parent.setLayout(FormLayoutFactory.createDetailsGridLayout(false, 1)); FormToolkit toolkit = getManagedForm().getToolkit(); fSection = toolkit.createSection(parent, Section.DESCRIPTION | ExpandableComposite.TITLE_BAR); fSection.clientVerticalSpacing = FormLayoutFactory.SECTION_HEADER_VERTICAL_SPACING; fSection.setLayout(FormLayoutFactory.createClearGridLayout(false, 1)); GridData gd; if (fShowDescription) gd = new GridData(GridData.FILL_BOTH); else gd = new GridData(GridData.FILL_HORIZONTAL); fSection.setLayoutData(gd); // Align the master and details section headers (misalignment caused // by section toolbar icons) getPage().alignSectionHeaders(fElementSection.getSection(), fSection); Composite client = toolkit.createComposite(fSection); client.setLayout(FormLayoutFactory.createSectionClientGridLayout(false, 3)); createDetails(client); if (fShowDescription) createDescription(client, toolkit); // If the DTD Approximation section was requested, instantiate it and create it's contents // on the same parent Composite if (fShowDTD) { fDtdSection = new SchemaDtdDetailsSection(); fDtdSection.initialize(getManagedForm()); fDtdSection.createContents(parent); } toolkit.paintBordersFor(client); fSection.setClient(client); markDetailsPart(fSection); if (fShowDescription) fDescriptionViewer.createUIListeners(); hookListeners(); }
@Override public void modelChanged(IModelChangedEvent event) { if ((event.getChangeType() == IModelChangedEvent.REMOVE) || (fShowDTD == false) || (fDtdSection == null)) { return; } Object[] objects = event.getChangedObjects(); for (int i = 0; i < objects.length; i++) { if (objects[i] instanceof ISchemaCompositor) fDtdSection.updateDTDLabel(objects[i]); } }
@Override public void selectionChanged(IFormPart part, ISelection selection) { if (!(part instanceof ElementSection)) return; Object obj = ((IStructuredSelection) selection).getFirstElement(); if (obj instanceof ISchemaObject) { setBlockListeners(true); ISchemaObject sObj = (ISchemaObject) obj; fSchemaObject = sObj; if (fShowDTD && fDtdSection != null) fDtdSection.updateDTDLabel(obj); if (fShowDescription && fDescriptionViewer != null) updateDescriptionViewer(sObj); updateFields(sObj); setBlockListeners(false); } }