001: /*******************************************************************************
002: * Copyright (c) 2001, 2007 IBM Corporation and others.
003: * All rights reserved. This program and the accompanying materials
004: * are made available under the terms of the Eclipse Public License v1.0
005: * which accompanies this distribution, and is available at
006: * http://www.eclipse.org/legal/epl-v10.html
007: *
008: * Contributors:
009: * IBM Corporation - initial API and implementation
010: *******************************************************************************/package org.eclipse.ui.internal.views.properties.tabbed.view;
011:
012: import org.eclipse.swt.SWT;
013: import org.eclipse.swt.custom.ScrolledComposite;
014: import org.eclipse.swt.layout.FormAttachment;
015: import org.eclipse.swt.layout.FormData;
016: import org.eclipse.swt.layout.FormLayout;
017: import org.eclipse.swt.widgets.Composite;
018: import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetWidgetFactory;
019:
020: /**
021: * Composite responsible for drawing the tabbed property sheet page.
022: *
023: * @author Anthony Hunter
024: */
025: public class TabbedPropertyComposite extends Composite {
026:
027: private TabbedPropertySheetWidgetFactory factory;
028:
029: private Composite mainComposite;
030:
031: private Composite leftComposite;
032:
033: private ScrolledComposite scrolledComposite;
034:
035: private Composite tabComposite;
036:
037: private TabbedPropertyTitle title;
038:
039: private TabbedPropertyList listComposite;
040:
041: private boolean displayTitle;
042:
043: /**
044: * Constructor for a TabbedPropertyComposite
045: *
046: * @param parent
047: * the parent widget.
048: * @param factory
049: * the widget factory.
050: * @param displayTitle
051: * if <code>true</code>, then the title bar will be displayed.
052: */
053: public TabbedPropertyComposite(Composite parent,
054: TabbedPropertySheetWidgetFactory factory,
055: boolean displayTitle) {
056: super (parent, SWT.NO_FOCUS);
057: this .factory = factory;
058: this .displayTitle = displayTitle;
059:
060: createMainComposite();
061: }
062:
063: /**
064: * Create the main composite.
065: */
066: protected void createMainComposite() {
067: mainComposite = factory.createComposite(this , SWT.NO_FOCUS);
068: mainComposite.setLayout(new FormLayout());
069: FormData formData = new FormData();
070: formData.left = new FormAttachment(0, 0);
071: formData.right = new FormAttachment(100, 0);
072: formData.top = new FormAttachment(0, 0);
073: formData.bottom = new FormAttachment(100, 0);
074: mainComposite.setLayoutData(formData);
075:
076: createMainContents();
077: }
078:
079: /**
080: * Create the contents in the main composite.
081: */
082: protected void createMainContents() {
083: if (displayTitle) {
084: title = new TabbedPropertyTitle(mainComposite, factory);
085:
086: FormData data = new FormData();
087: data.left = new FormAttachment(0, 0);
088: data.right = new FormAttachment(100, 0);
089: data.top = new FormAttachment(0, 0);
090: title.setLayoutData(data);
091: }
092:
093: leftComposite = factory.createComposite(mainComposite,
094: SWT.NO_FOCUS);
095: leftComposite.setLayout(new FormLayout());
096:
097: scrolledComposite = factory.createScrolledComposite(
098: mainComposite, SWT.H_SCROLL | SWT.V_SCROLL
099: | SWT.NO_FOCUS);
100: scrolledComposite.setLayout(new FormLayout());
101:
102: FormData formData = new FormData();
103: formData.left = new FormAttachment(leftComposite, 0);
104: formData.right = new FormAttachment(100, 0);
105: if (displayTitle) {
106: formData.top = new FormAttachment(title, 0);
107: } else {
108: formData.top = new FormAttachment(0, 0);
109: }
110: formData.bottom = new FormAttachment(100, 0);
111: scrolledComposite.setLayoutData(formData);
112:
113: formData = new FormData();
114: formData.left = new FormAttachment(0, 0);
115: formData.right = new FormAttachment(scrolledComposite, 0);
116: if (displayTitle) {
117: formData.top = new FormAttachment(title, 0);
118: } else {
119: formData.top = new FormAttachment(0, 0);
120: }
121: formData.bottom = new FormAttachment(100, 0);
122: leftComposite.setLayoutData(formData);
123:
124: tabComposite = factory.createComposite(scrolledComposite,
125: SWT.NO_FOCUS);
126: tabComposite.setLayout(new FormLayout());
127:
128: scrolledComposite.setContent(tabComposite);
129: scrolledComposite.setAlwaysShowScrollBars(false);
130: scrolledComposite.setExpandVertical(true);
131: scrolledComposite.setExpandHorizontal(true);
132:
133: listComposite = new TabbedPropertyList(leftComposite, factory);
134: formData = new FormData();
135: formData.left = new FormAttachment(0, 0);
136: formData.right = new FormAttachment(100, 0);
137: formData.top = new FormAttachment(0, 0);
138: formData.bottom = new FormAttachment(100, 0);
139: listComposite.setLayoutData(formData);
140:
141: FormData data = new FormData();
142: data.left = new FormAttachment(0, 0);
143: data.right = new FormAttachment(100, 0);
144: data.top = new FormAttachment(0, 0);
145: data.bottom = new FormAttachment(100, 0);
146: tabComposite.setLayoutData(data);
147: }
148:
149: /**
150: * Get the tabbed property list, which is the list of tabs on the left hand
151: * side of this composite.
152: *
153: * @return the tabbed property list.
154: */
155: public TabbedPropertyList getList() {
156: return listComposite;
157: }
158:
159: /**
160: * Get the tabbed property title bar.
161: *
162: * @return the tabbed property title bar or <code>null</code> if not used.
163: */
164: public TabbedPropertyTitle getTitle() {
165: return title;
166: }
167:
168: /**
169: * Get the tab composite where sections display their property contents.
170: *
171: * @return the tab composite.
172: */
173: public Composite getTabComposite() {
174: return tabComposite;
175: }
176:
177: /**
178: * Get the scrolled composite which surrounds the title bar and tab
179: * composite.
180: *
181: * @return the scrolled composite.
182: */
183: public ScrolledComposite getScrolledComposite() {
184: return scrolledComposite;
185: }
186:
187: /**
188: * Get the widget factory.
189: *
190: * @return the widget factory.
191: */
192: protected TabbedPropertySheetWidgetFactory getFactory() {
193: return factory;
194: }
195:
196: /**
197: * @see org.eclipse.swt.widgets.Widget#dispose()
198: */
199: public void dispose() {
200: listComposite.dispose();
201: if (displayTitle) {
202: title.dispose();
203: }
204: super.dispose();
205: }
206: }
|