Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 58003
Collapse All | Expand All

(-)Eclipse UI/org/eclipse/ui/internal/DetachedWindow.java (-17 / +107 lines)
Lines 33-51 Link Here
33
import org.eclipse.swt.widgets.Monitor;
33
import org.eclipse.swt.widgets.Monitor;
34
import org.eclipse.swt.widgets.Shell;
34
import org.eclipse.swt.widgets.Shell;
35
import org.eclipse.ui.IMemento;
35
import org.eclipse.ui.IMemento;
36
import org.eclipse.ui.IPropertyListener;
36
import org.eclipse.ui.IWorkbenchPage;
37
import org.eclipse.ui.IWorkbenchPage;
38
import org.eclipse.ui.IWorkbenchPartConstants;
39
import org.eclipse.ui.IWorkbenchPartReference;
37
import org.eclipse.ui.contexts.IContextService;
40
import org.eclipse.ui.contexts.IContextService;
41
import org.eclipse.ui.internal.dnd.DragUtil;
42
import org.eclipse.ui.internal.dnd.IDragOverListener;
43
import org.eclipse.ui.internal.dnd.IDropTarget;
38
import org.eclipse.ui.internal.presentations.PresentationFactoryUtil;
44
import org.eclipse.ui.internal.presentations.PresentationFactoryUtil;
45
import org.eclipse.ui.internal.presentations.defaultpresentation.DetachedViewPresentationFactory;
46
import org.eclipse.ui.presentations.AbstractPresentationFactory;
47
import org.eclipse.ui.presentations.WorkbenchPresentationFactory;
39
48
40
public class DetachedWindow {
49
50
/**
51
 * TODO: Drag from detached to fast view bar back to detached causes NPE
52
 * 
53
 * @since 3.1
54
 */
55
public class DetachedWindow implements IDragOverListener {
41
56
42
    private PartStack folder;
57
    private PartStack folder;
43
58
44
    private WorkbenchPage page;
59
    private WorkbenchPage page;
45
60
    
46
    //Keep the state of a DetachedWindow when switching perspectives.
47
    private String title;
48
49
    private Rectangle bounds = new Rectangle(0,0,0,0);
61
    private Rectangle bounds = new Rectangle(0,0,0,0);
50
62
51
    private Shell s;
63
    private Shell s;
Lines 64-69 Link Here
64
            folder.setBounds(shell.getClientArea());
76
            folder.setBounds(shell.getClientArea());
65
        }
77
        }
66
    };
78
    };
79
80
    private IPropertyListener propertyListener = new IPropertyListener() {
81
        public void propertyChanged(Object source, int propId) {
82
            if (propId == PartStack.PROP_SELECTION) {
83
                activePartChanged(getPartReference(folder.getSelection()));
84
            }
85
        }
86
    };
87
88
    private IWorkbenchPartReference activePart;
89
90
    private IPropertyListener partPropertyListener = new IPropertyListener() {
91
        public void propertyChanged(Object source, int propId) {
92
            if (propId == IWorkbenchPartConstants.PROP_TITLE) {
93
                updateTitle();
94
            }
95
        }
96
    };
67
    
97
    
68
    /**
98
    /**
69
     * Create a new FloatingWindow.
99
     * Create a new FloatingWindow.
Lines 73-79 Link Here
73
        //setShellStyle( //SWT.CLOSE | SWT.MIN | SWT.MAX | 
103
        //setShellStyle( //SWT.CLOSE | SWT.MIN | SWT.MAX | 
74
        //SWT.RESIZE | getDefaultOrientation());
104
        //SWT.RESIZE | getDefaultOrientation());
75
        this.page = workbenchPage;
105
        this.page = workbenchPage;
76
        folder = new ViewStack(page, false, PresentationFactoryUtil.ROLE_VIEW);
106
        
107
        // Ugly hack: if we're using the default presentation, change the appearance
108
        // of detached views. Really, each presentation should be able to provide an
109
        // alternate appearance for detached views
110
        AbstractPresentationFactory defaultFactory = ((WorkbenchWindow)page
111
            .getWorkbenchWindow()).getWindowConfigurer()
112
            .getPresentationFactory();
113
        
114
        AbstractPresentationFactory factory = null;
115
        
116
        if (defaultFactory.getClass() == WorkbenchPresentationFactory.class) {
117
            factory = new DetachedViewPresentationFactory();
118
        }
119
        
120
        folder = new ViewStack(page, false, PresentationFactoryUtil.ROLE_VIEW, factory);
121
        folder.addListener(propertyListener);
122
    }
123
124
    protected void activePartChanged(IWorkbenchPartReference partReference) {
125
        if (activePart == partReference) {
126
            return;
127
        }
128
         
129
        if (activePart != null) {
130
            activePart.removePropertyListener(partPropertyListener);
131
        }
132
        activePart = partReference;
133
        if (partReference != null) {
134
            partReference.addPropertyListener(partPropertyListener);   
135
        }
136
        updateTitle();
137
    }
138
139
    private void updateTitle() {
140
        if (activePart != null) {
141
            s.setText(activePart.getTitle());
142
            s.setImage(activePart.getTitleImage());
143
        } else {
144
            s.setImage(null);
145
        }
146
    }
147
148
    private static IWorkbenchPartReference getPartReference(PartPane pane) {
149
        
150
        if (pane == null) {
151
            return null;
152
        }
153
        
154
        return pane.getPartReference();
77
    }
155
    }
78
156
79
    public Shell getShell() {
157
    public Shell getShell() {
Lines 83-88 Link Here
83
    public void create() {
161
    public void create() {
84
        s = ((WorkbenchWindow)page.getWorkbenchWindow()).getDetachedWindowPool().allocateShell(shellListener);
162
        s = ((WorkbenchWindow)page.getWorkbenchWindow()).getDetachedWindowPool().allocateShell(shellListener);
85
        s.setData(this);
163
        s.setData(this);
164
        DragUtil.addDragTarget(s, this);
86
        hideViewsOnClose = true;
165
        hideViewsOnClose = true;
87
        if (bounds.isEmpty()) {
166
        if (bounds.isEmpty()) {
88
            Point center = Geometry.centerPoint(page.getWorkbenchWindow().getShell().getBounds());
167
            Point center = Geometry.centerPoint(page.getWorkbenchWindow().getShell().getBounds());
Lines 144-153 Link Here
144
        if (folder != null)
223
        if (folder != null)
145
            folder.dispose();
224
            folder.dispose();
146
        
225
        
147
//        Shell s = getShell();
148
        if (s != null) {
226
        if (s != null) {
149
            s.removeListener(SWT.Resize, resizeListener);
227
            s.removeListener(SWT.Resize, resizeListener);
150
            title = s.getText();
228
            DragUtil.removeDragTarget(s, this);
151
            bounds = s.getBounds();
229
            bounds = s.getBounds();
152
230
153
            // Unregister this detached view as a window (for key bindings).
231
            // Unregister this detached view as a window (for key bindings).
Lines 163-168 Link Here
163
        return true;
241
        return true;
164
    }
242
    }
165
243
244
    /* (non-Javadoc)
245
     * @see org.eclipse.ui.internal.dnd.IDragOverListener#drag(org.eclipse.swt.widgets.Control, java.lang.Object, org.eclipse.swt.graphics.Point, org.eclipse.swt.graphics.Rectangle)
246
     */
247
    public IDropTarget drag(Control currentControl, Object draggedObject,
248
            Point position, Rectangle dragRectangle) {
249
250
        if (!(draggedObject instanceof LayoutPart)) {
251
            return null;
252
        }
253
254
        final LayoutPart sourcePart = (LayoutPart) draggedObject;
255
256
        if (sourcePart.getWorkbenchWindow() != page.getWorkbenchWindow()) {
257
            return null;
258
        }
259
        
260
        IDropTarget target = folder.getDropTarget(draggedObject, position);
261
        return target;
262
    }
263
    
166
    /**
264
    /**
167
     * Answer a list of the view panes.
265
     * Answer a list of the view panes.
168
     */
266
     */
Lines 179-186 Link Here
179
     * This method will be called to initialize the given Shell's layout
277
     * This method will be called to initialize the given Shell's layout
180
     */
278
     */
181
    protected void configureShell(Shell shell) {
279
    protected void configureShell(Shell shell) {
182
        if (title != null)
280
        updateTitle();
183
            shell.setText(title);
184
        shell.addListener(SWT.Resize, resizeListener);
281
        shell.addListener(SWT.Resize, resizeListener);
185
282
186
        // Register this detached view as a window (for key bindings).
283
        // Register this detached view as a window (for key bindings).
Lines 226-234 Link Here
226
     * @see IPersistablePart
323
     * @see IPersistablePart
227
     */
324
     */
228
    public void restoreState(IMemento memento) {
325
    public void restoreState(IMemento memento) {
229
        // Read the title.
230
        title = memento.getString(IWorkbenchConstants.TAG_TITLE);
231
232
        // Read the bounds.
326
        // Read the bounds.
233
        Integer bigInt;
327
        Integer bigInt;
234
        bigInt = memento.getInteger(IWorkbenchConstants.TAG_X);
328
        bigInt = memento.getInteger(IWorkbenchConstants.TAG_X);
Lines 244-250 Link Here
244
        // Set the bounds.
338
        // Set the bounds.
245
        bounds = new Rectangle(x, y, width, height);
339
        bounds = new Rectangle(x, y, width, height);
246
        if (getShell() != null) {
340
        if (getShell() != null) {
247
            getShell().setText(title);
248
            getShell().setBounds(bounds);
341
            getShell().setBounds(bounds);
249
        }
342
        }
250
        
343
        
Lines 259-269 Link Here
259
     */
352
     */
260
    public void saveState(IMemento memento) {
353
    public void saveState(IMemento memento) {
261
        if (getShell() != null) {
354
        if (getShell() != null) {
262
            title = getShell().getText();
263
            bounds = getShell().getBounds();
355
            bounds = getShell().getBounds();
264
        }
356
        }
265
        // Save the title.
266
        memento.putString(IWorkbenchConstants.TAG_TITLE, title);
267
357
268
        // Save the bounds.
358
        // Save the bounds.
269
        memento.putInteger(IWorkbenchConstants.TAG_X, bounds.x);
359
        memento.putInteger(IWorkbenchConstants.TAG_X, bounds.x);
(-)Eclipse UI/org/eclipse/ui/internal/PageLayout.java (-1 / +1 lines)
Lines 365-371 Link Here
365
                }
365
                }
366
366
367
                ViewStack newFolder = new ViewStack(rootLayoutContainer.page,
367
                ViewStack newFolder = new ViewStack(rootLayoutContainer.page,
368
                        true, appearance);
368
                        true, appearance, null);
369
                newFolder.add(newPart);
369
                newFolder.add(newPart);
370
                setFolderPart(viewId, newFolder);
370
                setFolderPart(viewId, newFolder);
371
                addPart(newFolder, viewId, relationship, ratio, refId);
371
                addPart(newFolder, viewId, relationship, ratio, refId);
(-)Eclipse UI/org/eclipse/ui/internal/PartSashContainer.java (-3 / +7 lines)
Lines 1125-1135 Link Here
1125
                    targetPart);
1125
                    targetPart);
1126
        }
1126
        }
1127
1127
1128
        setVisiblePart(visiblePart.getContainer(), visiblePart);
1128
        if (visiblePart != null) {
1129
            setVisiblePart(visiblePart.getContainer(), visiblePart);
1130
        }
1129
1131
1130
        getControl().setRedraw(true);
1132
        getControl().setRedraw(true);
1131
1133
        
1132
        visiblePart.setFocus();
1134
        if (visiblePart != null) {
1135
            visiblePart.setFocus();
1136
        }
1133
    }
1137
    }
1134
1138
1135
    /**
1139
    /**
(-)Eclipse UI/org/eclipse/ui/internal/PartStack.java (-7 / +60 lines)
Lines 21-26 Link Here
21
import org.eclipse.jface.action.IMenuManager;
21
import org.eclipse.jface.action.IMenuManager;
22
import org.eclipse.jface.util.Assert;
22
import org.eclipse.jface.util.Assert;
23
import org.eclipse.jface.util.Geometry;
23
import org.eclipse.jface.util.Geometry;
24
import org.eclipse.jface.util.ListenerList;
24
import org.eclipse.swt.graphics.Cursor;
25
import org.eclipse.swt.graphics.Cursor;
25
import org.eclipse.swt.graphics.Point;
26
import org.eclipse.swt.graphics.Point;
26
import org.eclipse.swt.graphics.Rectangle;
27
import org.eclipse.swt.graphics.Rectangle;
Lines 29-34 Link Here
29
import org.eclipse.swt.widgets.Display;
30
import org.eclipse.swt.widgets.Display;
30
import org.eclipse.ui.IMemento;
31
import org.eclipse.ui.IMemento;
31
import org.eclipse.ui.IPersistable;
32
import org.eclipse.ui.IPersistable;
33
import org.eclipse.ui.IPropertyListener;
32
import org.eclipse.ui.IWorkbenchPartReference;
34
import org.eclipse.ui.IWorkbenchPartReference;
33
import org.eclipse.ui.PlatformUI;
35
import org.eclipse.ui.PlatformUI;
34
import org.eclipse.ui.XMLMemento;
36
import org.eclipse.ui.XMLMemento;
Lines 53-58 Link Here
53
 */
55
 */
54
public abstract class PartStack extends LayoutPart implements ILayoutContainer {
56
public abstract class PartStack extends LayoutPart implements ILayoutContainer {
55
57
58
    public static final int PROP_SELECTION = 0x42;
59
    
56
    private List children = new ArrayList(3);
60
    private List children = new ArrayList(3);
57
61
58
    protected int appearance = PresentationFactoryUtil.ROLE_VIEW;
62
    protected int appearance = PresentationFactoryUtil.ROLE_VIEW;
Lines 207-212 Link Here
207
    private static final PartStackDropResult dropResult = new PartStackDropResult();
211
    private static final PartStackDropResult dropResult = new PartStackDropResult();
208
212
209
    private boolean isMinimized;
213
    private boolean isMinimized;
214
215
    private ListenerList listeners = new ListenerList();
216
217
    /**
218
     * Custom presentation factory to use for this stack, or null to
219
     * use the default
220
     */
221
    private AbstractPresentationFactory factory;
210
            
222
            
211
    protected abstract boolean isMoveable(IPresentablePart part);
223
    protected abstract boolean isMoveable(IPresentablePart part);
212
224
Lines 228-243 Link Here
228
            m.add(item);
240
            m.add(item);
229
        }
241
        }
230
    }
242
    }
231
243
    
232
    /**
244
    /**
233
     * Creates a new PartStack, given a constant determining which presentation to use
245
     * Creates a new PartStack, given a constant determining which presentation to use
234
     * 
246
     * 
235
     * @param appearance one of the PresentationFactoryUtil.ROLE_* constants
247
     * @param appearance one of the PresentationFactoryUtil.ROLE_* constants
236
     */
248
     */
237
    public PartStack(int appearance) {
249
    public PartStack(int appearance) {
250
        this(appearance, null);
251
    }
252
    
253
    /**
254
     * Creates a new part stack that uses the given custom presentation factory
255
     * @param appearance
256
     * @param factory custom factory to use (or null to use the default)
257
     */
258
    public PartStack(int appearance, AbstractPresentationFactory factory) {
238
        super("PartStack"); //$NON-NLS-1$
259
        super("PartStack"); //$NON-NLS-1$
239
260
240
        this.appearance = appearance;
261
        this.appearance = appearance;
262
        this.factory = factory;
263
    }
264
265
    /**
266
     * Adds a property listener to this stack. The listener will receive a PROP_SELECTION
267
     * event whenever the result of getSelection changes
268
     * 
269
     * @param listener
270
     */
271
    public void addListener(IPropertyListener listener) {
272
        listeners.add(listener);
273
    }
274
    
275
    public void removeListener(IPropertyListener listener) {
276
        listeners.remove(listener);
241
    }
277
    }
242
    
278
    
243
    protected final boolean isStandalone() {
279
    protected final boolean isStandalone() {
Lines 465-477 Link Here
465
    }
501
    }
466
502
467
    protected AbstractPresentationFactory getFactory() {
503
    protected AbstractPresentationFactory getFactory() {
468
        AbstractPresentationFactory factory = ((WorkbenchWindow) getPage()
504
        
505
        if (factory != null) {
506
            return factory;
507
        }
508
        
509
        return ((WorkbenchWindow) getPage()
469
                .getWorkbenchWindow()).getWindowConfigurer()
510
                .getWorkbenchWindow()).getWindowConfigurer()
470
                .getPresentationFactory();
511
                .getPresentationFactory();
471
472
        return factory;
473
    }
512
    }
474
513
    
475
    public void createControl(Composite parent) {
514
    public void createControl(Composite parent) {
476
        if (!isDisposed()) {
515
        if (!isDisposed()) {
477
            return;
516
            return;
Lines 509-519 Link Here
509
            return null;
548
            return null;
510
        }
549
        }
511
550
512
        final StackDropResult dropResult = getPresentation().dragOver(
551
        StackDropResult dropResult = getPresentation().dragOver(
513
                getControl(), position);
552
                getControl(), position);
514
        
553
        
515
        if (dropResult == null) {
554
        if (dropResult == null) {
516
            return null;
555
            Rectangle displayBounds = DragUtil.getDisplayBounds(getControl());
556
            if (displayBounds.contains(position)) {
557
                dropResult = new StackDropResult(displayBounds, null);
558
            } else {
559
                return null;
560
            }
517
        }
561
        }
518
        
562
        
519
        return createDropTarget(pane, dropResult); 
563
        return createDropTarget(pane, dropResult); 
Lines 602-607 Link Here
602
        
646
        
603
        presentationCurrent = null;
647
        presentationCurrent = null;
604
        current = null;
648
        current = null;
649
        fireInternalPropertyChange(PROP_SELECTION);
605
    }
650
    }
606
651
607
    public void findSashes(LayoutPart part, PartPane.Sashes sashes) {
652
    public void findSashes(LayoutPart part, PartPane.Sashes sashes) {
Lines 1067-1072 Link Here
1067
        
1112
        
1068
            // Update the return value of getVisiblePart
1113
            // Update the return value of getVisiblePart
1069
            current = requestedCurrent;
1114
            current = requestedCurrent;
1115
            fireInternalPropertyChange(PROP_SELECTION);
1070
        }
1116
        }
1071
    }
1117
    }
1072
1118
Lines 1340-1343 Link Here
1340
    public IMemento getSavedPresentationState() {
1386
    public IMemento getSavedPresentationState() {
1341
        return savedPresentationState;
1387
        return savedPresentationState;
1342
    }
1388
    }
1389
    
1390
    private void fireInternalPropertyChange(int id) {
1391
        Object listeners[] = this.listeners.getListeners();
1392
        for (int i = 0; i < listeners.length; i++) {
1393
            ((IPropertyListener) listeners[i]).propertyChanged(this, id);
1394
        }
1395
    }
1343
}
1396
}
(-)Eclipse UI/org/eclipse/ui/internal/ViewStack.java (-3 / +4 lines)
Lines 18-23 Link Here
18
import org.eclipse.ui.internal.presentations.SystemMenuFastView;
18
import org.eclipse.ui.internal.presentations.SystemMenuFastView;
19
import org.eclipse.ui.internal.presentations.SystemMenuSize;
19
import org.eclipse.ui.internal.presentations.SystemMenuSize;
20
import org.eclipse.ui.internal.presentations.UpdatingActionContributionItem;
20
import org.eclipse.ui.internal.presentations.UpdatingActionContributionItem;
21
import org.eclipse.ui.presentations.AbstractPresentationFactory;
21
import org.eclipse.ui.presentations.IPresentablePart;
22
import org.eclipse.ui.presentations.IPresentablePart;
22
23
23
/**
24
/**
Lines 59-70 Link Here
59
    }
60
    }
60
61
61
    public ViewStack(WorkbenchPage page, boolean allowsStateChanges) {
62
    public ViewStack(WorkbenchPage page, boolean allowsStateChanges) {
62
        this(page, allowsStateChanges, PresentationFactoryUtil.ROLE_VIEW);
63
        this(page, allowsStateChanges, PresentationFactoryUtil.ROLE_VIEW, null);
63
    }
64
    }
64
65
65
    public ViewStack(WorkbenchPage page, boolean allowsStateChanges,
66
    public ViewStack(WorkbenchPage page, boolean allowsStateChanges,
66
            int appearance) {
67
            int appearance, AbstractPresentationFactory factory) {
67
        super(appearance);
68
        super(appearance, factory);
68
69
69
        this.page = page;
70
        this.page = page;
70
        setID(this.toString());
71
        setID(this.toString());
(-)Eclipse UI/org/eclipse/ui/internal/WorkbenchWindow.java (-1 / +1 lines)
Lines 840-846 Link Here
840
    protected void configureShell(Shell shell) {
840
    protected void configureShell(Shell shell) {
841
        super.configureShell(shell);
841
        super.configureShell(shell);
842
842
843
        detachedWindowShells = new ShellPool(shell, SWT.RESIZE | getDefaultOrientation());
843
        detachedWindowShells = new ShellPool(shell, SWT.SHELL_TRIM | SWT.TOOL | SWT.TITLE | SWT.MIN | SWT.MAX | SWT.RESIZE | getDefaultOrientation());
844
        
844
        
845
        String title = getWindowConfigurer().basicGetTitle();
845
        String title = getWindowConfigurer().basicGetTitle();
846
        if (title != null) {
846
        if (title != null) {
(-)Eclipse UI/org/eclipse/ui/internal/presentations/defaultpresentation/DefaultTabFolder.java (-2 / +4 lines)
Lines 11-17 Link Here
11
package org.eclipse.ui.internal.presentations.defaultpresentation;
11
package org.eclipse.ui.internal.presentations.defaultpresentation;
12
12
13
import org.eclipse.jface.util.Assert;
13
import org.eclipse.jface.util.Assert;
14
import org.eclipse.jface.util.Geometry;
14
import org.eclipse.swt.SWT;
15
import org.eclipse.swt.SWT;
16
import org.eclipse.swt.custom.CTabFolder;
15
import org.eclipse.swt.custom.CTabFolderEvent;
17
import org.eclipse.swt.custom.CTabFolderEvent;
16
import org.eclipse.swt.custom.CTabItem;
18
import org.eclipse.swt.custom.CTabItem;
17
import org.eclipse.swt.events.MouseAdapter;
19
import org.eclipse.swt.events.MouseAdapter;
Lines 176-182 Link Here
176
     * @see org.eclipse.ui.internal.presentations.util.AbstractTabFolder#add(int)
178
     * @see org.eclipse.ui.internal.presentations.util.AbstractTabFolder#add(int)
177
     */
179
     */
178
    public AbstractTabItem add(int index, int flags) {
180
    public AbstractTabItem add(int index, int flags) {
179
        DefaultTabItem result = new DefaultTabItem(this, index, flags);
181
        DefaultTabItem result = new DefaultTabItem((CTabFolder)getFolder().getControl(), index, flags);
180
        
182
        
181
        result.getWidget().setData(result);
183
        result.getWidget().setData(result);
182
        
184
        
Lines 253-259 Link Here
253
     * @see org.eclipse.ui.internal.presentations.util.AbstractTabFolder#getTabArea()
255
     * @see org.eclipse.ui.internal.presentations.util.AbstractTabFolder#getTabArea()
254
     */
256
     */
255
    public Rectangle getTabArea() {
257
    public Rectangle getTabArea() {
256
        return paneFolder.getTitleArea();
258
        return Geometry.toDisplay(paneFolder.getControl().getParent(), paneFolder.getTitleArea());
257
    }
259
    }
258
260
259
    /**
261
    /**
(-)Eclipse UI/org/eclipse/ui/internal/presentations/defaultpresentation/DefaultTabItem.java (-3 / +5 lines)
Lines 13-18 Link Here
13
import java.text.MessageFormat;
13
import java.text.MessageFormat;
14
14
15
import org.eclipse.jface.resource.FontRegistry;
15
import org.eclipse.jface.resource.FontRegistry;
16
import org.eclipse.jface.util.Geometry;
17
import org.eclipse.swt.custom.CTabFolder;
16
import org.eclipse.swt.custom.CTabItem;
18
import org.eclipse.swt.custom.CTabItem;
17
import org.eclipse.swt.graphics.Font;
19
import org.eclipse.swt.graphics.Font;
18
import org.eclipse.swt.graphics.Rectangle;
20
import org.eclipse.swt.graphics.Rectangle;
Lines 36-43 Link Here
36
    private String shortName = Util.ZERO_LENGTH_STRING;
38
    private String shortName = Util.ZERO_LENGTH_STRING;
37
    private String longName = Util.ZERO_LENGTH_STRING;
39
    private String longName = Util.ZERO_LENGTH_STRING;
38
    
40
    
39
    public DefaultTabItem(DefaultTabFolder parent, int index, int flags) {
41
    public DefaultTabItem(CTabFolder parent, int index, int flags) {
40
        super(parent.getFolder().createItem(flags, index));
42
        super(new CTabItem(parent, flags, index));
41
        updateFont();
43
        updateFont();
42
    }
44
    }
43
    
45
    
Lines 45-51 Link Here
45
     * @see org.eclipse.ui.internal.presentations.util.AbstractTabItem#getBounds()
47
     * @see org.eclipse.ui.internal.presentations.util.AbstractTabItem#getBounds()
46
     */
48
     */
47
    public Rectangle getBounds() {
49
    public Rectangle getBounds() {
48
        return getItem().getBounds();
50
        return Geometry.toDisplay(getItem().getParent(), getItem().getBounds());
49
    }
51
    }
50
    
52
    
51
    public CTabItem getItem() {
53
    public CTabItem getItem() {
(-)Eclipse UI/org/eclipse/ui/internal/presentations/defaultpresentation/NativeTabFolder.java (-2 / +2 lines)
Lines 70-76 Link Here
70
        }
70
        }
71
        
71
        
72
    };
72
    };
73
73
    
74
    public NativeTabFolder(Composite parent) {
74
    public NativeTabFolder(Composite parent) {
75
        control = new TabFolder(parent, SWT.BOTTOM);
75
        control = new TabFolder(parent, SWT.BOTTOM);
76
        control.addListener(SWT.Selection, selectionListener);
76
        control.addListener(SWT.Selection, selectionListener);
Lines 219-225 Link Here
219
        bounds.y = 0;
219
        bounds.y = 0;
220
        Geometry.expand(bounds, 0, 0, - (clientArea.height + clientArea.y), 0);
220
        Geometry.expand(bounds, 0, 0, - (clientArea.height + clientArea.y), 0);
221
        
221
        
222
        return bounds;
222
        return Geometry.toDisplay(control.getParent(), bounds);
223
    }
223
    }
224
    
224
    
225
    /* (non-Javadoc)
225
    /* (non-Javadoc)
(-)Eclipse UI/org/eclipse/ui/internal/presentations/util/AbstractTabFolder.java (-6 / +21 lines)
Lines 311-323 Link Here
311
        }
311
        }
312
    }
312
    }
313
    
313
    
314
    protected void detachListeners(Control theControl, boolean recursive) {
315
        theControl.removeListener(SWT.MenuDetect, menuListener);
316
        theControl.removeMouseListener(mouseListener);
317
        PresentationUtil.removeDragListener(theControl, dragListener);
318
        
319
        if (recursive && theControl instanceof Composite) {
320
            Composite composite = (Composite) theControl;
321
            Control[] children = composite.getChildren();
322
            
323
            for (int i = 0; i < children.length; i++) {
324
                Control control = children[i];
325
                
326
                detachListeners(control, recursive);
327
            }
328
        }
329
    }
330
    
314
    protected void handleContextMenu(Point displayPos, Event e) {
331
    protected void handleContextMenu(Point displayPos, Event e) {
315
        if (isOnBorder(displayPos)) {
332
        if (isOnBorder(displayPos)) {
316
            return;
333
            return;
317
        }
334
        }
318
        
335
319
        Point localPos = getControl().toControl(displayPos);
336
        AbstractTabItem tab = getItem(displayPos); 
320
        AbstractTabItem tab = getItem(localPos); 
321
        
337
        
322
        fireEvent(TabFolderEvent.EVENT_SYSTEM_MENU, tab, displayPos);
338
        fireEvent(TabFolderEvent.EVENT_SYSTEM_MENU, tab, displayPos);
323
    }
339
    }
Lines 339-351 Link Here
339
    }
355
    }
340
    
356
    
341
    protected void handleDragStarted(Point displayPos, Event e) {
357
    protected void handleDragStarted(Point displayPos, Event e) {
342
        Point localPos = getControl().toControl(displayPos);
358
343
        
344
        if (isOnBorder(displayPos)) {
359
        if (isOnBorder(displayPos)) {
345
            return;
360
            return;
346
        }
361
        }
347
        
362
        
348
        AbstractTabItem tab = getItem(localPos);
363
        AbstractTabItem tab = getItem(displayPos);
349
        fireEvent(TabFolderEvent.EVENT_DRAG_START, tab, displayPos);
364
        fireEvent(TabFolderEvent.EVENT_DRAG_START, tab, displayPos);
350
    }
365
    }
351
366
(-)Eclipse UI/org/eclipse/ui/internal/presentations/util/PresentablePartFolder.java (+3 lines)
Lines 58-63 Link Here
58
		}
58
		}
59
59
60
		public void controlResized(ControlEvent e) {
60
		public void controlResized(ControlEvent e) {
61
            if (e.widget == contentProxy) {
62
                layoutContent();
63
            }
61
		}
64
		}
62
		
65
		
63
	};
66
	};
(-)Eclipse UI/org/eclipse/ui/internal/presentations/util/ProxyControl.java (-8 / +7 lines)
Lines 23-29 Link Here
23
import org.eclipse.swt.widgets.Event;
23
import org.eclipse.swt.widgets.Event;
24
import org.eclipse.swt.widgets.Layout;
24
import org.eclipse.swt.widgets.Layout;
25
import org.eclipse.swt.widgets.Listener;
25
import org.eclipse.swt.widgets.Listener;
26
import org.eclipse.ui.internal.dnd.DragUtil;
27
import org.eclipse.ui.internal.dnd.SwtUtil;
26
import org.eclipse.ui.internal.dnd.SwtUtil;
28
import org.eclipse.ui.internal.layout.SizeCache;
27
import org.eclipse.ui.internal.layout.SizeCache;
29
28
Lines 111-118 Link Here
111
110
112
        public void handleEvent(Event event) {
111
        public void handleEvent(Event event) {
113
            if (target != null) {
112
            if (target != null) {
114
                visible = control.getVisible();
113
//                visible = control.getVisible();
115
                target.setVisible(visible);
114
//                target.setVisible(visible);
116
            }
115
            }
117
        }
116
        }
118
	    
117
	    
Lines 129-137 Link Here
129
		}
128
		}
130
129
131
		public void controlResized(ControlEvent e) {
130
		public void controlResized(ControlEvent e) {
132
		    //if (e.widget == control) {
131
		    if (e.widget == control) {
133
		     //   ProxyControl.this.layout();
132
		        //ProxyControl.this.layout();
134
		    //}
133
		    }
135
		}
134
		}
136
		
135
		
137
	};
136
	};
Lines 252-259 Link Here
252
		Rectangle displayBounds = Geometry.toDisplay(control.getParent(), control.getBounds());
251
		Rectangle displayBounds = Geometry.toDisplay(control.getParent(), control.getBounds());
253
		
252
		
254
		// Clip the bounds of the target so that it doesn't go outside the dummy control's parent
253
		// Clip the bounds of the target so that it doesn't go outside the dummy control's parent
255
		Rectangle clippingRegion = DragUtil.getDisplayBounds(control.getParent());
254
		//Rectangle clippingRegion = DragUtil.getDisplayBounds(control.getParent());
256
		displayBounds = displayBounds.intersection(clippingRegion);
255
		//displayBounds = displayBounds.intersection(clippingRegion);
257
		
256
		
258
		// Compute the bounds of the target, in the local coordinate system of its parent
257
		// Compute the bounds of the target, in the local coordinate system of its parent
259
		Rectangle targetBounds = Geometry.toControl(getTarget().getParent(), displayBounds);
258
		Rectangle targetBounds = Geometry.toControl(getTarget().getParent(), displayBounds);
(-)Eclipse UI/org/eclipse/ui/internal/presentations/util/ReplaceDragHandler.java (-9 / +7 lines)
Lines 43-51 Link Here
43
            int dragStart) {
43
            int dragStart) {
44
44
45
        // Determine which tab we're currently dragging over
45
        // Determine which tab we're currently dragging over
46
        Point localPos = tabFolder.getControl().toControl(location);
46
        //Point localPos = tabFolder.getControl().toControl(location);
47
47
48
        AbstractTabItem tabUnderPointer = tabFolder.getItem(localPos);
48
        AbstractTabItem tabUnderPointer = tabFolder.getItem(location);
49
49
50
        // This drop target only deals with tabs... if we're not dragging over
50
        // This drop target only deals with tabs... if we're not dragging over
51
        // a tab, exit.
51
        // a tab, exit.
Lines 54-60 Link Here
54
54
55
            // If we're dragging over the title area, treat this as a drop in the last
55
            // If we're dragging over the title area, treat this as a drop in the last
56
            // tab position.
56
            // tab position.
57
            if (titleArea.contains(localPos)) {
57
            if (titleArea.contains(location)) {
58
                int dragOverIndex = tabFolder.getItemCount();
58
                int dragOverIndex = tabFolder.getItemCount();
59
                AbstractTabItem lastTab = tabFolder.getItem(dragOverIndex - 1);
59
                AbstractTabItem lastTab = tabFolder.getItem(dragOverIndex - 1);
60
60
Lines 72-88 Link Here
72
                if (dragStart >= 0) {
72
                if (dragStart >= 0) {
73
                    dragOverIndex--;
73
                    dragOverIndex--;
74
74
75
                    return new StackDropResult(Geometry.toDisplay(tabFolder
75
                    return new StackDropResult(lastTabBounds, new Integer(
76
                            .getControl(), lastTabBounds), new Integer(
77
                            dragOverIndex));
76
                            dragOverIndex));
78
                }
77
                }
79
78
80
                // Make the drag-over rectangle look like a tab at the end of the tab region.
79
                // Make the drag-over rectangle look like a tab at the end of the tab region.
81
                // We don't actually know how wide the tab will be when it's dropped, so just
80
                // We don't actually know how wide the tab will be when it's dropped, so just
82
                // make it 3 times wider than it is tall.
81
                // make it 3 times wider than it is tall.
83
                Rectangle dropRectangle = Geometry.toDisplay(tabFolder
82
                Rectangle dropRectangle = titleArea;
84
                        .getControl(), titleArea);
85
83
84
                dropRectangle.x = lastTabBounds.x + lastTabBounds.width;
86
                dropRectangle.width = 3 * dropRectangle.height;
85
                dropRectangle.width = 3 * dropRectangle.height;
87
                return new StackDropResult(dropRectangle, new Integer(
86
                return new StackDropResult(dropRectangle, new Integer(
88
                        dragOverIndex));
87
                        dragOverIndex));
Lines 110-117 Link Here
110
            return null;
109
            return null;
111
        }
110
        }
112
111
113
        return new StackDropResult(Geometry.toDisplay(tabFolder.getControl(),
112
        return new StackDropResult(tabBounds, new DragCookie(tabFolder
114
                tabUnderPointer.getBounds()), new DragCookie(tabFolder
115
                .indexOf(tabUnderPointer)));
113
                .indexOf(tabUnderPointer)));
116
    }
114
    }
117
115
(-)Eclipse (+35 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2004 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.widgets.Composite;
14
import org.eclipse.ui.internal.presentations.util.StandardViewSystemMenu;
15
import org.eclipse.ui.internal.presentations.util.TabbedStackPresentation;
16
import org.eclipse.ui.presentations.IStackPresentationSite;
17
import org.eclipse.ui.presentations.StackPresentation;
18
import org.eclipse.ui.presentations.WorkbenchPresentationFactory;
19
20
/**
21
 * @since 3.1
22
 */
23
public class DetachedViewPresentationFactory extends WorkbenchPresentationFactory {
24
25
    /*
26
     * (non-Javadoc)
27
     * 
28
     * @see org.eclipse.ui.presentations.AbstractPresentationFactory
29
     */
30
    public StackPresentation createViewPresentation(Composite parent,
31
            IStackPresentationSite site) {
32
        return new TabbedStackPresentation(site, new DetachedViewTabFolder(parent), new StandardViewSystemMenu(site));
33
    }
34
35
}
(-)Eclipse (+410 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2004 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.jface.util.Geometry;
14
import org.eclipse.swt.SWT;
15
import org.eclipse.swt.custom.CTabFolder;
16
import org.eclipse.swt.custom.CTabFolder2Adapter;
17
import org.eclipse.swt.custom.CTabFolderEvent;
18
import org.eclipse.swt.custom.CTabItem;
19
import org.eclipse.swt.custom.ViewForm;
20
import org.eclipse.swt.events.DisposeEvent;
21
import org.eclipse.swt.events.DisposeListener;
22
import org.eclipse.swt.events.MouseAdapter;
23
import org.eclipse.swt.events.MouseEvent;
24
import org.eclipse.swt.graphics.Cursor;
25
import org.eclipse.swt.graphics.Image;
26
import org.eclipse.swt.graphics.Point;
27
import org.eclipse.swt.graphics.Rectangle;
28
import org.eclipse.swt.widgets.Composite;
29
import org.eclipse.swt.widgets.Control;
30
import org.eclipse.swt.widgets.Event;
31
import org.eclipse.swt.widgets.Listener;
32
import org.eclipse.swt.widgets.ToolBar;
33
import org.eclipse.swt.widgets.ToolItem;
34
import org.eclipse.swt.widgets.Widget;
35
import org.eclipse.ui.IPropertyListener;
36
import org.eclipse.ui.internal.IWorkbenchGraphicConstants;
37
import org.eclipse.ui.internal.WorkbenchImages;
38
import org.eclipse.ui.internal.WorkbenchMessages;
39
import org.eclipse.ui.internal.dnd.DragUtil;
40
import org.eclipse.ui.internal.layout.CellLayout;
41
import org.eclipse.ui.internal.layout.LayoutUtil;
42
import org.eclipse.ui.internal.layout.Row;
43
import org.eclipse.ui.internal.layout.SizeCache;
44
import org.eclipse.ui.internal.presentations.util.AbstractTabFolder;
45
import org.eclipse.ui.internal.presentations.util.AbstractTabItem;
46
import org.eclipse.ui.internal.presentations.util.PartInfo;
47
import org.eclipse.ui.internal.presentations.util.ProxyControl;
48
import org.eclipse.ui.internal.presentations.util.TabFolderEvent;
49
import org.eclipse.ui.internal.util.Util;
50
51
/**
52
 * 
53
 * 
54
 * 
55
 * @since 3.1
56
 */
57
public class DetachedViewTabFolder extends AbstractTabFolder {
58
59
    private Composite control;
60
    private CTabFolder folder;
61
    private Control viewToolBar;
62
    private ViewForm viewForm;
63
    private ProxyControl toolbarProxy;
64
    private Composite topLeftControl;
65
    private SizeCache toolbarCache;
66
    private Cursor dragCursor;
67
    
68
    private static final String FULL_TITLE = "part_title"; //$NON-NLS-1$
69
    
70
    // CTabFolder listener
71
    private CTabFolder2Adapter expandListener = new CTabFolder2Adapter() {
72
        /*
73
         * (non-Javadoc)
74
         * 
75
         * @see org.eclipse.swt.custom.CTabFolder2Adapter#close(org.eclipse.swt.custom.CTabFolderEvent)
76
         */
77
        public void close(CTabFolderEvent event) {
78
            event.doit = false;
79
            fireEvent(TabFolderEvent.EVENT_CLOSE, getTab(event.item));
80
        }
81
82
        public void showList(CTabFolderEvent event) {
83
            event.doit = false;
84
            fireEvent(TabFolderEvent.EVENT_SHOW_LIST);
85
        }
86
87
    };
88
    
89
    
90
    private Listener selectionListener = new Listener() {
91
        public void handleEvent(Event e) {
92
            fireEvent(TabFolderEvent.EVENT_TAB_SELECTED, getTab(e.item));
93
        }
94
    };
95
    
96
    private IPropertyListener systemToolbarListener = new IPropertyListener() {
97
98
        public void propertyChanged(Object source, int propId) {
99
            Point location;
100
            
101
            if (propId == TabFolderEvent.EVENT_PANE_MENU) {
102
                location = getPaneMenuLocation();
103
            } else {
104
                location = new Point(0,0);
105
            }
106
            
107
            fireEvent(propId, getSelection(), location);
108
        }
109
        
110
    };
111
112
    private DisposeListener tabDisposeListener = new DisposeListener() {
113
        public void widgetDisposed(DisposeEvent e)
114
        {
115
            if (e.widget == control) {
116
                disposed();
117
            }
118
        }  
119
    };
120
    
121
    public DetachedViewTabFolder(Composite parent) {
122
        control = new Composite(parent, SWT.NONE);
123
        control.addDisposeListener(tabDisposeListener);
124
        CellLayout layout = new CellLayout(1)
125
            .setDefaultRow(Row.fixed())
126
            .setDefaultColumn(Row.growing())
127
            .setRow(0, Row.growing())
128
            .setSpacing(0, 0)
129
            .setMargins(0, 0);
130
        control.setLayout(layout);
131
        dragCursor = parent.getDisplay().getSystemCursor(SWT.CURSOR_SIZEALL);
132
        
133
        viewForm = new ViewForm(control, SWT.FLAT);
134
        attachListeners(viewForm, false);
135
        
136
        topLeftControl = new Composite(viewForm, SWT.NONE);
137
        topLeftControl.setLayout(new CellLayout(0).setDefaultColumn(Row.fixed()).setSpacing(0,0).setMargins(0,0));
138
        topLeftControl.setCursor(dragCursor);
139
        attachListeners(topLeftControl, false);
140
        toolbarProxy = new ProxyControl(topLeftControl);
141
        viewForm.setTopLeft(topLeftControl);
142
       
143
        toolbarCache = new SizeCache();
144
        
145
        folder = new CTabFolder(control, SWT.BOTTOM);
146
        folder.setMinimizeVisible(false);
147
        folder.setMaximizeVisible(false);
148
        folder.setUnselectedCloseVisible(true);
149
        folder.setUnselectedImageVisible(true);
150
        folder.addListener(SWT.Selection, selectionListener);
151
        folder.addCTabFolder2Listener(expandListener);
152
        attachListeners(folder, false);
153
        
154
        // Initialize view menu dropdown
155
        {            
156
            ToolBar actualToolBar = new ToolBar(viewForm, SWT.FLAT | SWT.NO_BACKGROUND);
157
            viewToolBar = actualToolBar;
158
            
159
            ToolItem pullDownButton = new ToolItem(actualToolBar, SWT.PUSH);
160
            Image hoverImage = WorkbenchImages
161
                    .getImage(IWorkbenchGraphicConstants.IMG_LCL_RENDERED_VIEW_MENU);
162
            pullDownButton.setDisabledImage(hoverImage);
163
            pullDownButton.setImage(hoverImage);
164
            pullDownButton.setToolTipText(WorkbenchMessages.Menu); 
165
            actualToolBar.addMouseListener(new MouseAdapter() {
166
                public void mouseDown(MouseEvent e) {
167
                    fireEvent(TabFolderEvent.EVENT_PANE_MENU, getSelection(), getPaneMenuLocation());
168
                }
169
            });
170
        }
171
        
172
        viewForm.setTopRight(viewToolBar);
173
    }
174
175
    protected void disposed() {
176
177
    }
178
179
    /* (non-Javadoc)
180
     * @see org.eclipse.ui.internal.presentations.util.AbstractTabFolder#computeSize(int, int)
181
     */
182
    public Point computeSize(int widthHint, int heightHint) {
183
        return new Point(50, 50);
184
    }
185
186
    /* (non-Javadoc)
187
     * @see org.eclipse.ui.internal.presentations.util.AbstractTabFolder#add(int)
188
     */
189
    public AbstractTabItem add(int index, int flags) {
190
        DetachedViewTabItem item = new DetachedViewTabItem(this, index, flags);
191
        item.getWidget().setData(item);
192
        item.getWidget().addDisposeListener(tabDisposeListener);
193
        
194
        if (folder.getItemCount() == 2) {
195
            layout(true);
196
        }
197
        
198
        return item;
199
    }
200
    
201
    /* (non-Javadoc)
202
     * @see org.eclipse.ui.internal.presentations.util.AbstractTabFolder#layout(boolean)
203
     */
204
    public void layout(boolean flushCache) {
205
        
206
        Rectangle oldBounds = viewForm.getBounds();
207
        
208
        CellLayout layout = (CellLayout)control.getLayout();
209
        if (folder.getItemCount() < 2) {
210
            layout.setRow(1, Row.fixed(0));
211
        } else {
212
            layout.setRow(1, Row.fixed(folder.getTabHeight() + 2));
213
        }
214
        
215
        super.layout(flushCache);
216
        
217
        control.layout(flushCache);
218
        
219
        Rectangle newBounds = viewForm.getBounds();
220
        
221
        if (Util.equals(oldBounds, newBounds)) {
222
            viewForm.layout(flushCache);
223
        }
224
    }
225
    
226
    /* (non-Javadoc)
227
     * @see org.eclipse.ui.internal.presentations.util.AbstractTabFolder#getClientArea()
228
     */
229
    public Rectangle getClientArea() {
230
        Control content = viewForm.getContent();
231
        
232
        if (content == null) {
233
            return new Rectangle(0,0,0,0);
234
        }
235
        
236
        return Geometry.toControl(control, DragUtil.getDisplayBounds(content));
237
    }
238
239
    /* (non-Javadoc)
240
     * @see org.eclipse.ui.internal.presentations.util.AbstractTabFolder#getItems()
241
     */
242
    public AbstractTabItem[] getItems() {
243
        CTabItem[] items = folder.getItems();
244
        
245
        AbstractTabItem[] result = new AbstractTabItem[items.length];
246
        
247
        for (int i = 0; i < result.length; i++) {
248
            result[i] = getTab(items[i]);
249
        }
250
        
251
        return result;
252
    }
253
    
254
    /**
255
     * @param item
256
     * @return
257
     * @since 3.1
258
     */
259
    private AbstractTabItem getTab(Widget item) {
260
        return (AbstractTabItem)item.getData();
261
    }
262
263
    /* (non-Javadoc)
264
     * @see org.eclipse.ui.internal.presentations.util.AbstractTabFolder#setSelection(org.eclipse.ui.internal.presentations.util.Widget)
265
     */
266
    public void setSelection(AbstractTabItem toSelect) {
267
        if (toSelect == null) {
268
            return;
269
        }
270
        
271
        DetachedViewTabItem tab = (DetachedViewTabItem) toSelect;
272
        folder.setSelection((CTabItem)tab.getWidget());
273
    }
274
275
    /* (non-Javadoc)
276
     * @see org.eclipse.ui.internal.presentations.util.AbstractTabFolder#setSelectedInfo(org.eclipse.ui.internal.presentations.util.PartInfo)
277
     */
278
    public void setSelectedInfo(PartInfo info) {
279
    }
280
    /* (non-Javadoc)
281
     * @see org.eclipse.ui.internal.presentations.util.AbstractTabFolder#getToolbarParent()
282
     */
283
    public Composite getToolbarParent() {
284
        return viewForm;
285
    }
286
287
    /* (non-Javadoc)
288
     * @see org.eclipse.ui.internal.presentations.util.AbstractTabFolder#getTabArea()
289
     */
290
    public Rectangle getTabArea() {
291
        return Geometry.toDisplay(folder.getParent(), folder.getBounds());
292
    }
293
    
294
    /* (non-Javadoc)
295
     * @see org.eclipse.ui.internal.presentations.util.AbstractTabFolder#setToolbar(org.eclipse.swt.widgets.Control)
296
     */
297
    public void setToolbar(Control toolbarControl) {
298
        
299
        if (toolbarControl == getToolbar()) {
300
            return;
301
        }
302
        
303
        if (toolbarControl != null) {
304
            toolbarCache.setControl(toolbarControl);
305
            toolbarProxy.setTarget(toolbarCache);
306
            LayoutUtil.resize(toolbarProxy.getControl());
307
308
            toolbarProxy.layout();
309
            //toolbarControl.moveAbove(null);
310
//            if (!toolbarControl.getVisible()) {
311
//                System.out.println("not visible"); //$NON-NLS-1$
312
//            }
313
//            
314
//            
315
//            Rectangle rect = DragUtil.getDisplayBounds(toolbarControl);
316
//            Rectangle proxyRect = DragUtil.getDisplayBounds(toolbarProxy.getControl());
317
//            if (!proxyRect.equals(rect)) {
318
//                System.out.println("wrong bounds"); //$NON-NLS-1$
319
//            }
320
        } else {
321
            toolbarCache.setControl(null);
322
            toolbarProxy.setTarget(null);
323
        }
324
        
325
        super.setToolbar(toolbarControl);
326
    }
327
    
328
    public Control getControl() {
329
        return control;
330
    }
331
    
332
    /* (non-Javadoc)
333
     * @see org.eclipse.ui.internal.presentations.util.AbstractTabFolder#isOnBorder(org.eclipse.swt.graphics.Point)
334
     */
335
    public boolean isOnBorder(Point globalPos) {
336
        Point localPos = getControl().toControl(globalPos);
337
        
338
        Rectangle clientArea = getClientArea();
339
        return localPos.y > clientArea.y && localPos.y < clientArea.y + clientArea.height; 
340
    }
341
    
342
    public AbstractTabItem getSelection() {
343
        CTabItem sel = folder.getSelection();
344
        
345
        if (sel == null) {
346
            return null;
347
        }
348
        
349
        return getTab(sel);
350
    }
351
    
352
    /* (non-Javadoc)
353
     * @see org.eclipse.ui.internal.presentations.util.AbstractTabFolder#getContentParent()
354
     */
355
    public Composite getContentParent() {
356
        return viewForm;
357
    }
358
    
359
    /* (non-Javadoc)
360
     * @see org.eclipse.ui.internal.presentations.util.AbstractTabFolder#setContent(org.eclipse.swt.widgets.Control)
361
     */
362
    public void setContent(Control newContent) {
363
        viewForm.setContent(newContent);
364
    }
365
    
366
    /**
367
     * @return
368
     * @since 3.1
369
     */
370
    public CTabFolder getTabFolder() {
371
        return folder;
372
    }
373
    
374
    protected void handleDragStarted(Point displayPos, Event e) {
375
        if (isOnBorder(displayPos)) {
376
            return;
377
        }
378
        
379
        AbstractTabItem tab = null;
380
        
381
        if (DragUtil.getDisplayBounds(viewForm).contains(displayPos)) {
382
            tab = getSelection();
383
        } else {
384
            tab = getItem(displayPos); 
385
        }
386
        
387
        fireEvent(TabFolderEvent.EVENT_DRAG_START, tab, displayPos);
388
    }
389
390
    public Point getPaneMenuLocation() {
391
        Point toolbarSize = viewToolBar.getSize();
392
        
393
        return viewToolBar.toDisplay(0,toolbarSize.y);
394
    }
395
    
396
    public void enablePaneMenu(boolean enabled) {
397
        if (enabled) {
398
            viewToolBar.setVisible(true);
399
        } else {
400
            viewToolBar.setVisible(false);
401
        }
402
    }
403
404
    public void itemRemoved() {
405
        if (folder.getItemCount() == 1 && !control.isDisposed() && !viewForm.isDisposed()) {
406
            layout(true);
407
        }
408
    }
409
410
}
(-)Eclipse (+19 lines)
Added Link Here
1
package org.eclipse.ui.internal.presentations.defaultpresentation;
2
3
4
public class DetachedViewTabItem extends DefaultTabItem {
5
6
    private DetachedViewTabFolder folder;
7
    
8
    public DetachedViewTabItem(DetachedViewTabFolder folder, int index, int flags) {
9
        super(folder.getTabFolder(), index, flags);
10
        
11
        this.folder = folder;
12
    }
13
14
    public void dispose() {
15
        super.dispose();
16
        
17
        folder.itemRemoved();
18
    }
19
}

Return to bug 58003