01: /*******************************************************************************
02: * Copyright (c) 2007 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: *******************************************************************************/package org.eclipse.pde.internal.ui.editor.schema;
11:
12: import org.eclipse.pde.internal.core.ischema.ISchemaAttribute;
13: import org.eclipse.pde.internal.core.ischema.ISchemaCompositor;
14: import org.eclipse.pde.internal.core.ischema.ISchemaElement;
15: import org.eclipse.pde.internal.ui.PDEUIMessages;
16: import org.eclipse.pde.internal.ui.editor.FormLayoutFactory;
17: import org.eclipse.swt.SWT;
18: import org.eclipse.swt.layout.GridData;
19: import org.eclipse.swt.widgets.Composite;
20: import org.eclipse.swt.widgets.Menu;
21: import org.eclipse.swt.widgets.Text;
22: import org.eclipse.ui.forms.AbstractFormPart;
23: import org.eclipse.ui.forms.widgets.ExpandableComposite;
24: import org.eclipse.ui.forms.widgets.FormToolkit;
25: import org.eclipse.ui.forms.widgets.Section;
26:
27: public class SchemaDtdDetailsSection extends AbstractFormPart {
28: private Text fDtdText;
29: private Section fSection;
30:
31: public void createContents(Composite parent) {
32: FormToolkit toolkit = getManagedForm().getToolkit();
33:
34: fSection = toolkit.createSection(parent,
35: ExpandableComposite.TITLE_BAR);
36: fSection.clientVerticalSpacing = FormLayoutFactory.SECTION_HEADER_VERTICAL_SPACING;
37: fSection.setLayout(FormLayoutFactory.createClearGridLayout(
38: false, 1));
39:
40: GridData gd = new GridData(GridData.FILL_HORIZONTAL);
41: fSection.setLayoutData(gd);
42:
43: Composite client = toolkit.createComposite(fSection);
44: client.setLayout(FormLayoutFactory
45: .createSectionClientGridLayout(false, 1));
46:
47: fDtdText = toolkit.createText(client,
48: "", SWT.WRAP | SWT.V_SCROLL | SWT.MULTI);//$NON-NLS-1$
49: gd = new GridData(GridData.FILL_HORIZONTAL);
50: gd.heightHint = 60;
51: fDtdText.setLayoutData(gd);
52: fDtdText.setEditable(false);
53: // remove pop-up menu
54: fDtdText.setMenu(new Menu(client));
55:
56: toolkit.paintBordersFor(client);
57: fSection.setClient(client);
58:
59: fSection.setText(PDEUIMessages.SchemaDtdDetailsSection_title);
60: }
61:
62: protected void updateDTDLabel(Object changeObject) {
63: if ((fDtdText == null) || (fDtdText.isDisposed())) {
64: return;
65: }
66: if (changeObject instanceof ISchemaAttribute) {
67: changeObject = ((ISchemaAttribute) changeObject)
68: .getParent();
69: } else if (changeObject instanceof ISchemaCompositor) {
70: while (changeObject != null) {
71: if (changeObject instanceof ISchemaElement)
72: break;
73: changeObject = ((ISchemaCompositor) changeObject)
74: .getParent();
75: }
76: }
77: if (changeObject instanceof ISchemaElement)
78: fDtdText.setText(((ISchemaElement) changeObject)
79: .getDTDRepresentation(false));
80: }
81: }
|