KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ui > internal > presentations > defaultpresentation > NativeTabItem


1 /*******************************************************************************
2  * Copyright (c) 2004, 2005 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.ui.internal.presentations.defaultpresentation;
12
13 import org.eclipse.swt.SWT;
14 import org.eclipse.swt.graphics.Rectangle;
15 import org.eclipse.swt.widgets.TabItem;
16 import org.eclipse.ui.internal.presentations.util.PartInfo;
17 import org.eclipse.ui.internal.presentations.util.WidgetTabItem;
18 import org.eclipse.ui.internal.util.Util;
19
20 /**
21  * @since 3.1
22  */

23 public class NativeTabItem extends WidgetTabItem {
24     
25     public NativeTabItem(NativeTabFolder parent, int index) {
26         super(new TabItem(parent.getTabFolder(), SWT.NONE, index));
27     }
28     
29     /* (non-Javadoc)
30      * @see org.eclipse.ui.internal.presentations.util.AbstractTabItem#getBounds()
31      */

32     public Rectangle getBounds() {
33         return new Rectangle(0,0,0,0);
34     }
35
36     public void setInfo(PartInfo info) {
37         TabItem widget = (TabItem) getWidget();
38         
39         if (!Util.equals(widget.getText(), info.name)) {
40             widget.setText(info.name);
41         }
42         String JavaDoc oldToolTip = Util.safeString(widget.getToolTipText());
43         
44         if (!Util.equals(info.toolTip, oldToolTip)) {
45             String JavaDoc toolTip = info.toolTip;
46             if (toolTip.length() == 0) {
47                 toolTip = null;
48             }
49             widget.setToolTipText(toolTip);
50         }
51     }
52 }
53
Popular Tags