001: /*******************************************************************************
002: * Copyright (c) 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.tests.views.properties.tabbed.override.tablist;
011:
012: import org.eclipse.jface.viewers.ISelection;
013: import org.eclipse.swt.widgets.Composite;
014: import org.eclipse.ui.IWorkbenchPart;
015: import org.eclipse.ui.views.properties.tabbed.AbstractOverridableTabListPropertySection;
016: import org.eclipse.ui.views.properties.tabbed.ITabItem;
017: import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage;
018:
019: /**
020: * Section for a tab list used by the tabbed properties view for the override
021: * tests example.
022: * <p>
023: * The OverrideTestsView TabbedPropertySheetPage example is a look at the
024: * properties view after the migration of a TabFolder/TabItem framework to the
025: * tabbed properties view. In the case of a TabFolder, the folder (provider)
026: * knows both the tab labels and tab items. This aligns to the tabbed properties
027: * view, but the tab labels are tab descriptors and tab items are section
028: * descriptions. This does not work with the default framework as the tabs
029: * provide the sections. In this case, the IOverridableTabListContentProvider
030: * framework has been provided.
031: * <p>
032: * The overridable tab list is a content provider that provides both the
033: * sections and the tab labels.
034: *
035: * @author Anthony Hunter
036: * @since 3.4
037: */
038: public class OverrideTestsSection extends
039: AbstractOverridableTabListPropertySection {
040: private OverrideTestsTabListsContentsManager contentsManager;
041:
042: /*
043: * (non-Javadoc)
044: *
045: * @see org.eclipse.ui.views.properties.tabbed.AbstractPropertySection#createControls(org.eclipse.swt.widgets.Composite,
046: * org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage)
047: */
048: public void createControls(Composite parent,
049: TabbedPropertySheetPage tabbedPropertySheetPage) {
050: super .createControls(parent, tabbedPropertySheetPage);
051: contentsManager = new OverrideTestsTabListsContentsManager(
052: parent, tabbedPropertySheetPage, this );
053: }
054:
055: /*
056: * (non-Javadoc)
057: *
058: * @see org.eclipse.ui.views.properties.tabbed.AbstractPropertySection#dispose()
059: */
060: public void dispose() {
061: if (contentsManager != null) {
062: contentsManager.dispose();
063: contentsManager = null;
064: }
065: }
066:
067: /*
068: * (non-Javadoc)
069: *
070: * @see org.eclipse.ui.views.properties.tabbed.AbstractOverridableTabListPropertySection#getTabs()
071: */
072: public ITabItem[] getTabs() {
073: if (contentsManager != null) {
074: return contentsManager.getTabs();
075: }
076: return null;
077: }
078:
079: /*
080: * (non-Javadoc)
081: *
082: * @see org.eclipse.ui.views.properties.tabbed.AbstractOverridableTabListPropertySection#selectTab(int)
083: */
084: public void selectTab(int index) {
085: if (contentsManager != null) {
086: contentsManager.selectTab(index);
087: }
088: }
089:
090: /*
091: * (non-Javadoc)
092: *
093: * @see org.eclipse.ui.views.properties.tabbed.AbstractPropertySection#setInput(org.eclipse.ui.IWorkbenchPart,
094: * org.eclipse.jface.viewers.ISelection)
095: */
096: public void setInput(IWorkbenchPart part, ISelection selection) {
097: super .setInput(part, selection);
098: if (contentsManager != null) {
099: contentsManager.selectionChanged(getPart(), getSelection());
100: }
101: }
102:
103: /*
104: * (non-Javadoc)
105: *
106: * @see org.eclipse.ui.views.properties.tabbed.AbstractPropertySection#shouldUseExtraSpace()
107: */
108: public boolean shouldUseExtraSpace() {
109: return true;
110: }
111: }
|