01: /*******************************************************************************
02: * Copyright (c) 2004, 2005 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.ui.internal.presentations.defaultpresentation;
11:
12: import org.eclipse.swt.SWT;
13: import org.eclipse.swt.graphics.Rectangle;
14: import org.eclipse.swt.widgets.TabItem;
15: import org.eclipse.ui.internal.presentations.util.PartInfo;
16: import org.eclipse.ui.internal.presentations.util.WidgetTabItem;
17: import org.eclipse.ui.internal.util.Util;
18:
19: /**
20: * @since 3.1
21: */
22: public class NativeTabItem extends WidgetTabItem {
23:
24: public NativeTabItem(NativeTabFolder parent, int index) {
25: super (new TabItem(parent.getTabFolder(), SWT.NONE, index));
26: }
27:
28: /* (non-Javadoc)
29: * @see org.eclipse.ui.internal.presentations.util.AbstractTabItem#getBounds()
30: */
31: public Rectangle getBounds() {
32: return new Rectangle(0, 0, 0, 0);
33: }
34:
35: public void setInfo(PartInfo info) {
36: TabItem widget = (TabItem) getWidget();
37:
38: if (!Util.equals(widget.getText(), info.name)) {
39: widget.setText(info.name);
40: }
41: String oldToolTip = Util.safeString(widget.getToolTipText());
42:
43: if (!Util.equals(info.toolTip, oldToolTip)) {
44: String toolTip = info.toolTip;
45: if (toolTip.length() == 0) {
46: toolTip = null;
47: }
48: widget.setToolTipText(toolTip);
49: }
50: }
51: }
|