View | Details | Raw Unified | Return to bug 93806 | Differences between
and this patch

Collapse All | Expand All

(-)Eclipse UI/org/eclipse/ui/internal/presentations/defaultpresentation/NativePresentationFactory.java (-4 / +3 lines)
Lines 30-36 Link Here
30
     */
30
     */
31
    public StackPresentation createEditorPresentation(Composite parent,
31
    public StackPresentation createEditorPresentation(Composite parent,
32
            IStackPresentationSite site) {        
32
            IStackPresentationSite site) {        
33
        return new TabbedStackPresentation(site, new NativeTabFolder(parent), new StandardEditorSystemMenu(site));
33
        return new TabbedStackPresentation(site, new NativeTabFolder(parent, site), new StandardEditorSystemMenu(site));
34
    }
34
    }
35
35
36
    /*
36
    /*
Lines 40-46 Link Here
40
     */
40
     */
41
    public StackPresentation createViewPresentation(Composite parent,
41
    public StackPresentation createViewPresentation(Composite parent,
42
            IStackPresentationSite site) {
42
            IStackPresentationSite site) {
43
        return new TabbedStackPresentation(site, new NativeTabFolder(parent), new StandardViewSystemMenu(site));
43
        return new TabbedStackPresentation(site, new NativeTabFolder(parent, site), new StandardViewSystemMenu(site));
44
    }
44
    }
45
45
46
    /*
46
    /*
Lines 51-58 Link Here
51
    public StackPresentation createStandaloneViewPresentation(Composite parent,
51
    public StackPresentation createStandaloneViewPresentation(Composite parent,
52
            IStackPresentationSite site, boolean showTitle) {
52
            IStackPresentationSite site, boolean showTitle) {
53
        // TODO honour showTitle
53
        // TODO honour showTitle
54
        return new TabbedStackPresentation(site, new NativeTabFolder(parent), 
54
        return new TabbedStackPresentation(site, new NativeTabFolder(parent, site), new StandardViewSystemMenu(site));
55
                new StandardViewSystemMenu(site));
56
    }
55
    }
57
56
58
}
57
}
(-)Eclipse UI/org/eclipse/ui/internal/presentations/defaultpresentation/NativeTabFolder.java (-37 / +77 lines)
Lines 10-52 Link Here
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.ui.internal.presentations.defaultpresentation;
11
package org.eclipse.ui.internal.presentations.defaultpresentation;
12
12
13
import org.eclipse.jface.preference.IPreferenceStore;
13
import org.eclipse.jface.util.Geometry;
14
import org.eclipse.jface.util.Geometry;
14
import org.eclipse.swt.SWT;
15
import org.eclipse.swt.SWT;
15
import org.eclipse.swt.custom.CLabel;
16
import org.eclipse.swt.custom.CLabel;
16
import org.eclipse.swt.custom.ViewForm;
17
import org.eclipse.swt.custom.ViewForm;
18
import org.eclipse.swt.events.*;
17
import org.eclipse.swt.graphics.Image;
19
import org.eclipse.swt.graphics.Image;
18
import org.eclipse.swt.graphics.Point;
20
import org.eclipse.swt.graphics.Point;
19
import org.eclipse.swt.graphics.Rectangle;
21
import org.eclipse.swt.graphics.Rectangle;
20
import org.eclipse.swt.widgets.Composite;
22
import org.eclipse.swt.widgets.*;
21
import org.eclipse.swt.widgets.Control;
22
import org.eclipse.swt.widgets.Event;
23
import org.eclipse.swt.widgets.Listener;
24
import org.eclipse.swt.widgets.TabFolder;
25
import org.eclipse.swt.widgets.TabItem;
26
import org.eclipse.swt.widgets.Widget;
27
import org.eclipse.ui.IPropertyListener;
23
import org.eclipse.ui.IPropertyListener;
24
import org.eclipse.ui.internal.*;
28
import org.eclipse.ui.internal.dnd.DragUtil;
25
import org.eclipse.ui.internal.dnd.DragUtil;
29
import org.eclipse.ui.internal.layout.SizeCache;
26
import org.eclipse.ui.internal.layout.SizeCache;
30
import org.eclipse.ui.internal.presentations.util.AbstractTabFolder;
27
import org.eclipse.ui.internal.presentations.util.*;
31
import org.eclipse.ui.internal.presentations.util.AbstractTabItem;
32
import org.eclipse.ui.internal.presentations.util.PartInfo;
33
import org.eclipse.ui.internal.presentations.util.ProxyControl;
34
import org.eclipse.ui.internal.presentations.util.StandardSystemToolbar;
35
import org.eclipse.ui.internal.presentations.util.TabFolderEvent;
36
import org.eclipse.ui.internal.util.Util;
28
import org.eclipse.ui.internal.util.Util;
29
import org.eclipse.ui.presentations.*;
37
30
38
/**
31
/**
39
 * @since 3.1
32
 * @since 3.1
40
 */
33
 */
41
public class NativeTabFolder extends AbstractTabFolder {
34
public class NativeTabFolder extends AbstractTabFolder {
42
35
36
    private IStackPresentationSite site;
43
    private TabFolder control;
37
    private TabFolder control;
44
    private ViewForm viewForm;
38
    private ViewForm viewForm;
45
    private StandardSystemToolbar systemToolbar;
46
    private CLabel title;
39
    private CLabel title;
40
    
41
    private ToolBar viewToolBar;
42
    private ToolItem menuButton;
43
    private ToolItem closeButton;
44
    
47
    private ProxyControl topCenter;
45
    private ProxyControl topCenter;
48
    private SizeCache topCenterCache;
46
    private SizeCache topCenterCache;
49
    
47
    
48
    private IPreferenceStore preferenceStore = WorkbenchPlugin.getDefault().getPreferenceStore();
49
    
50
    private static final String FULL_TITLE = "part_title"; //$NON-NLS-1$
50
    private static final String FULL_TITLE = "part_title"; //$NON-NLS-1$
51
    
51
    
52
    private Listener selectionListener = new Listener() {
52
    private Listener selectionListener = new Listener() {
Lines 71-86 Link Here
71
        
71
        
72
    };
72
    };
73
    
73
    
74
    public NativeTabFolder(Composite parent) {
74
    public NativeTabFolder(Composite parent, final IStackPresentationSite site) {
75
        control = new TabFolder(parent, SWT.BOTTOM);
75
        
76
        this.site = site;
77
        
78
        int tabPos = preferenceStore.getInt(IPreferenceConstants.VIEW_TAB_POSITION);
79
        
80
        control = new TabFolder(parent, tabPos);
76
        control.addListener(SWT.Selection, selectionListener);
81
        control.addListener(SWT.Selection, selectionListener);
77
        attachListeners(control, false);
82
        attachListeners(control, false);
78
        
83
        
79
        viewForm = new ViewForm(control, SWT.FLAT);
84
        viewForm = new ViewForm(control, SWT.FLAT);
80
        attachListeners(viewForm, false);
85
        attachListeners(viewForm, false);
81
        systemToolbar = new StandardSystemToolbar(viewForm, true, false, true, true, true);
86
        
82
        systemToolbar.addListener(systemToolbarListener);
87
        viewToolBar = new ToolBar(viewForm, SWT.HORIZONTAL|SWT.FLAT);
83
        viewForm.setTopRight(systemToolbar.getControl());
88
        viewForm.setTopRight(viewToolBar);
89
        
90
        menuButton = new ToolItem(viewToolBar, SWT.PUSH);
91
        menuButton.setDisabledImage(null); // TODO: comment this out?
92
        // PR#1GE56QT - Avoid creation of unnecessary image.
93
        menuButton.setImage(WorkbenchImages.getImage(IWorkbenchGraphicConstants.IMG_LCL_VIEW_MENU));
94
        menuButton.setToolTipText("Menu"); //$NON-NLS-1$
95
        menuButton.addSelectionListener(new SelectionAdapter() {
96
            public void widgetSelected(SelectionEvent e) {
97
                IPresentablePart part = site.getSelectedPart();
98
                if (part == null) 
99
                    return;
100
101
                IPartMenu menu = part.getMenu();
102
103
                if (menu != null) {
104
                    menu.showMenu(getPaneMenuLocation());
105
                }
106
            }
107
        });
108
        
109
        closeButton = new ToolItem(viewToolBar, SWT.PUSH);
110
        closeButton.setDisabledImage(null); // TODO: comment this out?
111
        // PR#1GE56QT - Avoid creation of unnecessary image.
112
        closeButton.setImage(WorkbenchImages.getImage(IWorkbenchGraphicConstants.IMG_LCL_CLOSE_VIEW));
113
        closeButton.setToolTipText("Close"); //$NON-NLS-1$
114
        closeButton.addSelectionListener(new SelectionAdapter() {
115
            public void widgetSelected(SelectionEvent e) {
116
                IPresentablePart part = site.getSelectedPart();
117
                if (part == null) 
118
                    return;
119
                
120
                //fireEvent(TabFolderEvent.EVENT_CLOSE);
121
                if (part != null) {
122
                    site.close(new IPresentablePart[] { part });
123
                }
124
            }
125
        });
84
        
126
        
85
        topCenter = new ProxyControl(viewForm);
127
        topCenter = new ProxyControl(viewForm);
86
        topCenterCache = new SizeCache();
128
        topCenterCache = new SizeCache();
Lines 127-142 Link Here
127
     * @see org.eclipse.ui.internal.presentations.util.AbstractTabFolder#getPaneMenuLocation()
169
     * @see org.eclipse.ui.internal.presentations.util.AbstractTabFolder#getPaneMenuLocation()
128
     */
170
     */
129
    public Point getPaneMenuLocation() {
171
    public Point getPaneMenuLocation() {
130
        return systemToolbar.getPaneMenuLocation();
172
        Rectangle bounds = DragUtil.getDisplayBounds(viewToolBar);
131
    }
173
        return new Point(bounds.x, bounds.y + bounds.height);
132
    
133
    /* (non-Javadoc)
134
     * @see org.eclipse.ui.internal.presentations.util.AbstractTabFolder#setState(int)
135
     */
136
    public void setState(int state) {
137
        super.setState(state);
138
        
139
        systemToolbar.setState(state);
140
    }
174
    }
141
    
175
    
142
    /* (non-Javadoc)
176
    /* (non-Javadoc)
Lines 192-202 Link Here
192
     * @see org.eclipse.ui.internal.presentations.util.AbstractTabFolder#setSelectedInfo(org.eclipse.ui.internal.presentations.util.PartInfo)
226
     * @see org.eclipse.ui.internal.presentations.util.AbstractTabFolder#setSelectedInfo(org.eclipse.ui.internal.presentations.util.PartInfo)
193
     */
227
     */
194
    public void setSelectedInfo(PartInfo info) {
228
    public void setSelectedInfo(PartInfo info) {
195
        if (!Util.equals(title.getText(), info.title)) {
229
        if (!Util.equals(title.getText(), info.contentDescription)) {
196
            title.setText(info.title);
230
            title.setText(info.contentDescription);
197
        }
198
        if (title.getImage() != info.image) {
199
            title.setImage(info.image);
200
        }
231
        }
201
    }
232
    }
202
    /* (non-Javadoc)
233
    /* (non-Javadoc)
Lines 264-269 Link Here
264
        return getTab(sel[0]);
295
        return getTab(sel[0]);
265
    }
296
    }
266
    
297
    
298
    private TabItem getSelectedTabItem() {
299
        WidgetTabItem selection = (WidgetTabItem)getSelection();
300
        
301
        if (selection==null)
302
            return null;
303
        
304
        return (TabItem)selection.getWidget();
305
    }
306
    
267
    /* (non-Javadoc)
307
    /* (non-Javadoc)
268
     * @see org.eclipse.ui.internal.presentations.util.AbstractTabFolder#getContentParent()
308
     * @see org.eclipse.ui.internal.presentations.util.AbstractTabFolder#getContentParent()
269
     */
309
     */
Lines 292-298 Link Here
292
     * @since 3.1
332
     * @since 3.1
293
     */
333
     */
294
    /* protected */ void setSelectedTitle(String newTitle) {
334
    /* protected */ void setSelectedTitle(String newTitle) {
295
        title.setText(newTitle);
335
        getSelectedTabItem().setText(newTitle);
296
    }
336
    }
297
337
298
    /**
338
    /**
Lines 300-306 Link Here
300
     * @since 3.1
340
     * @since 3.1
301
     */
341
     */
302
    /* protected */ void setSelectedImage(Image image) {
342
    /* protected */ void setSelectedImage(Image image) {
303
        title.setImage(image);
343
        getSelectedTabItem().setImage(image);
304
    }
344
    }
305
345
306
    /* (non-Javadoc)
346
    /* (non-Javadoc)
Lines 315-320 Link Here
315
     * @since 3.1
355
     * @since 3.1
316
     */
356
     */
317
    public void enablePaneMenu(boolean enabled) {
357
    public void enablePaneMenu(boolean enabled) {
318
        systemToolbar.enablePaneMenu(enabled);
358
        menuButton.setEnabled(enabled);
319
    }
359
    }
320
}
360
}
(-)Eclipse UI/org/eclipse/ui/internal/presentations/defaultpresentation/NativeTabItem.java (+5 lines)
Lines 39-44 Link Here
39
        if (!Util.equals(widget.getText(), info.name)) {
39
        if (!Util.equals(widget.getText(), info.name)) {
40
            widget.setText(info.name);
40
            widget.setText(info.name);
41
        }
41
        }
42
        
43
        if (!Util.equals(widget.getImage(), info.image)) {
44
            widget.setImage(info.image);
45
        }
46
        
42
        String oldToolTip = Util.safeString(widget.getToolTipText());
47
        String oldToolTip = Util.safeString(widget.getToolTipText());
43
        
48
        
44
        if (!Util.equals(info.toolTip, oldToolTip)) {
49
        if (!Util.equals(info.toolTip, oldToolTip)) {

Return to bug 93806