KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > pde > internal > ui > editor > schema > SchemaCompositorDetails


1 /*******************************************************************************
2  * Copyright (c) 2000, 2007 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

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 JavaDoc[] {
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     /* (non-Javadoc)
99      * @see org.eclipse.ui.forms.AbstractFormPart#commit(boolean)
100      */

101     public void commit(boolean onSave) {
102         super.commit(onSave);
103         // Only required for form entries
104
// NO-OP
105
}
106 }
107
Popular Tags