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 72060 | Differences between
and this patch

Collapse All | Expand All

(-)Eclipse UI/org/eclipse/ui/internal/ContainerPlaceholder.java (-142 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2004 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials 
4
 * are made available under the terms of the Common Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/cpl-v10.html
7
 * 
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.ui.internal;
12
13
public class ContainerPlaceholder extends PartPlaceholder implements
14
        ILayoutContainer {
15
    private static int nextId = 0;
16
17
    private ILayoutContainer realContainer;
18
19
    /**
20
     * ContainerPlaceholder constructor comment.
21
     * @param id java.lang.String
22
     * @param label java.lang.String
23
     */
24
    public ContainerPlaceholder(String id) {
25
        super(((id == null) ? "Container Placeholder " + nextId++ : id)); //$NON-NLS-1$
26
    }
27
28
    /**
29
     * add method comment.
30
     */
31
    public void add(LayoutPart child) {
32
        if (!(child instanceof PartPlaceholder))
33
            return;
34
        realContainer.add(child);
35
    }
36
37
    /**
38
     * See ILayoutContainer::allowBorder
39
     */
40
    public boolean allowsBorder() {
41
        return true;
42
    }
43
44
    /**
45
     * getChildren method comment.
46
     */
47
    public LayoutPart[] getChildren() {
48
        return realContainer.getChildren();
49
    }
50
51
    /**
52
     * getFocus method comment.
53
     */
54
    public LayoutPart getFocus() {
55
        return null;
56
    }
57
58
    /**
59
     * getFocus method comment.
60
     */
61
    public LayoutPart getRealContainer() {
62
        return (LayoutPart) realContainer;
63
    }
64
65
    /**
66
     * isChildVisible method comment.
67
     */
68
    public boolean isChildVisible(LayoutPart child) {
69
        return false;
70
    }
71
72
    /**
73
     * remove method comment.
74
     */
75
    public void remove(LayoutPart child) {
76
        if (!(child instanceof PartPlaceholder))
77
            return;
78
        realContainer.remove(child);
79
    }
80
81
    /**
82
     * replace method comment.
83
     */
84
    public void replace(LayoutPart oldChild, LayoutPart newChild) {
85
        if (!(oldChild instanceof PartPlaceholder)
86
                && !(newChild instanceof PartPlaceholder))
87
            return;
88
        realContainer.replace(oldChild, newChild);
89
    }
90
91
    /**
92
     * setChildVisible method comment.
93
     */
94
    public void setChildVisible(LayoutPart child, boolean visible) {
95
    }
96
97
    /**
98
     * setFocus method comment.
99
     */
100
    public void setFocus(LayoutPart child) {
101
    }
102
103
    public void setRealContainer(ILayoutContainer container) {
104
105
        if (container == null) {
106
            // set the parent container of the children back to the real container
107
            if (realContainer != null) {
108
                LayoutPart[] children = realContainer.getChildren();
109
                if (children != null) {
110
                    for (int i = 0, length = children.length; i < length; i++) {
111
                        children[i].setContainer(realContainer);
112
                    }
113
                }
114
            }
115
        } else {
116
            // replace the real container with this place holder
117
            LayoutPart[] children = container.getChildren();
118
            if (children != null) {
119
                for (int i = 0, length = children.length; i < length; i++) {
120
                    children[i].setContainer(this);
121
                }
122
            }
123
        }
124
125
        this.realContainer = container;
126
    }
127
128
    public void findSashes(LayoutPart part, PartPane.Sashes sashes) {
129
        ILayoutContainer container = getContainer();
130
131
        if (container != null) {
132
            container.findSashes(this, sashes);
133
        }
134
    }
135
136
    /* (non-Javadoc)
137
     * @see org.eclipse.ui.internal.ILayoutContainer#allowsAutoFocus()
138
     */
139
    public boolean allowsAutoFocus() {
140
        return false;
141
    }
142
}
(-)Eclipse UI/org/eclipse/ui/internal/DetachedPlaceHolder.java (-141 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2004 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials 
4
 * are made available under the terms of the Common Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/cpl-v10.html
7
 * 
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.ui.internal;
12
13
import java.util.ArrayList;
14
15
import org.eclipse.swt.graphics.Rectangle;
16
import org.eclipse.ui.IMemento;
17
18
public class DetachedPlaceHolder extends PartPlaceholder implements
19
        ILayoutContainer {
20
    ArrayList children = new ArrayList();
21
22
    Rectangle bounds;
23
24
    /**
25
     * DetachedPlaceHolder constructor comment.
26
     * @param id java.lang.String
27
     */
28
    public DetachedPlaceHolder(String id, Rectangle bounds) {
29
        super(id);
30
        this.bounds = bounds;
31
    }
32
33
    /**
34
     * Add a child to the container.
35
     */
36
    public void add(LayoutPart newPart) {
37
        if (!(newPart instanceof PartPlaceholder))
38
            return;
39
        children.add(newPart);
40
    }
41
42
    /**
43
     * Return true if the container allows its
44
     * parts to show a border if they choose to,
45
     * else false if the container does not want
46
     * its parts to show a border.
47
     */
48
    public boolean allowsBorder() {
49
        return false;
50
    }
51
52
    public Rectangle getBounds() {
53
        return bounds;
54
    }
55
56
    /**
57
     * Returns a list of layout children.
58
     */
59
    public LayoutPart[] getChildren() {
60
        LayoutPart result[] = new LayoutPart[children.size()];
61
        children.toArray(result);
62
        return result;
63
    }
64
65
    /**
66
     * Remove a child from the container.
67
     */
68
    public void remove(LayoutPart part) {
69
        children.remove(part);
70
    }
71
72
    /**
73
     * Replace one child with another
74
     */
75
    public void replace(LayoutPart oldPart, LayoutPart newPart) {
76
        remove(oldPart);
77
        add(newPart);
78
    }
79
80
    /**
81
     * @see IPersistablePart
82
     */
83
    public void restoreState(IMemento memento) {
84
        // Read the bounds.
85
        Integer bigInt;
86
        bigInt = memento.getInteger(IWorkbenchConstants.TAG_X);
87
        int x = bigInt.intValue();
88
        bigInt = memento.getInteger(IWorkbenchConstants.TAG_Y);
89
        int y = bigInt.intValue();
90
        bigInt = memento.getInteger(IWorkbenchConstants.TAG_WIDTH);
91
        int width = bigInt.intValue();
92
        bigInt = memento.getInteger(IWorkbenchConstants.TAG_HEIGHT);
93
        int height = bigInt.intValue();
94
95
        bounds = new Rectangle(x, y, width, height);
96
97
        // Restore the placeholders.
98
        IMemento childrenMem[] = memento
99
                .getChildren(IWorkbenchConstants.TAG_VIEW);
100
        for (int i = 0; i < childrenMem.length; i++) {
101
            PartPlaceholder holder = new PartPlaceholder(childrenMem[i]
102
                    .getString(IWorkbenchConstants.TAG_ID));
103
            holder.setContainer(this);
104
            children.add(holder);
105
        }
106
    }
107
108
    /**
109
     * @see IPersistablePart
110
     */
111
    public void saveState(IMemento memento) {
112
        // Save the bounds.
113
        memento.putInteger(IWorkbenchConstants.TAG_X, bounds.x);
114
        memento.putInteger(IWorkbenchConstants.TAG_Y, bounds.y);
115
        memento.putInteger(IWorkbenchConstants.TAG_WIDTH, bounds.width);
116
        memento.putInteger(IWorkbenchConstants.TAG_HEIGHT, bounds.height);
117
118
        // Save the views.
119
        for (int i = 0; i < children.size(); i++) {
120
            IMemento childMem = memento
121
                    .createChild(IWorkbenchConstants.TAG_VIEW);
122
            LayoutPart child = (LayoutPart) children.get(i);
123
            childMem.putString(IWorkbenchConstants.TAG_ID, child.getID());
124
        }
125
    }
126
127
    public void findSashes(LayoutPart part, PartPane.Sashes sashes) {
128
        ILayoutContainer container = getContainer();
129
130
        if (container != null) {
131
            container.findSashes(this, sashes);
132
        }
133
    }
134
135
    /* (non-Javadoc)
136
     * @see org.eclipse.ui.internal.ILayoutContainer#allowsAutoFocus()
137
     */
138
    public boolean allowsAutoFocus() {
139
        return false;
140
    }
141
}
(-)Eclipse UI/org/eclipse/ui/internal/DetachedWindow.java (-48 / +133 lines)
Lines 30-40 Link Here
30
import org.eclipse.ui.IMemento;
30
import org.eclipse.ui.IMemento;
31
import org.eclipse.ui.IWorkbenchPage;
31
import org.eclipse.ui.IWorkbenchPage;
32
import org.eclipse.ui.contexts.IWorkbenchContextSupport;
32
import org.eclipse.ui.contexts.IWorkbenchContextSupport;
33
import org.eclipse.ui.internal.PartPane.Sashes;
33
import org.eclipse.ui.help.WorkbenchHelp;
34
import org.eclipse.ui.help.WorkbenchHelp;
35
import org.eclipse.ui.internal.presentations.PresentationFactoryUtil;
34
36
35
public class DetachedWindow extends Window {
37
public class DetachedWindow extends Window implements 
38
	ILayoutContainer{
36
39
37
    private ViewStack folder;
40
    private DetachedViewStack folder;
38
41
39
    private WorkbenchPage page;
42
    private WorkbenchPage page;
40
43
Lines 42-48 Link Here
42
    private String title;
45
    private String title;
43
46
44
    private Rectangle bounds;
47
    private Rectangle bounds;
45
48
    
49
    private boolean shellCreationAllowed = false;
50
    
46
    /**
51
    /**
47
     * Create a new FloatingWindow.
52
     * Create a new FloatingWindow.
48
     */
53
     */
Lines 51-69 Link Here
51
        setShellStyle( //SWT.CLOSE | SWT.MIN | SWT.MAX | 
56
        setShellStyle( //SWT.CLOSE | SWT.MIN | SWT.MAX | 
52
        SWT.RESIZE);
57
        SWT.RESIZE);
53
        this.page = workbenchPage;
58
        this.page = workbenchPage;
54
        folder = new ViewStack(page, false);
59
        folder = new DetachedViewStack(page, false, PresentationFactoryUtil.ROLE_VIEW);
60
    	folder.setContainer(this);
55
    }
61
    }
56
62
    
57
    /**
63
    /**
58
     * Adds a visual part to this window.
64
     * Adds a visual part to this window.
59
     * Supports reparenting.
65
     * Supports reparenting.
60
     */
66
     */
61
    public void add(ViewPane part) {
67
    public void add(LayoutPart newPart) {
62
63
        Shell shell = getShell();
68
        Shell shell = getShell();
64
        if (shell != null)
69
65
            part.reparent(shell);
70
        if (shellCreationAllowed){
66
        folder.add(part);
71
            open();
72
            shell = getShell();
73
        }
74
        if(shell != null)
75
	    	newPart.reparent(shell);
76
77
	    folder.add(newPart);
78
    }
79
    
80
    /* (non-Javadoc)
81
     * @see org.eclipse.ui.internal.ILayoutContainer#allowsAutoFocus()
82
     */
83
    public boolean allowsAutoFocus() {
84
        return false;
85
    }
86
    
87
    /**
88
     * Allows this window to spawn it's shell as required. This is disabled by
89
     * default because creating shells before the Perspective has been activated
90
     * causes unpredictable behaviour. This is toggled on perspective activation 
91
     * and deactivation.
92
     * 
93
     * @param b
94
     */
95
    /*package*/ void allowShellCreation(boolean b) {
96
    	shellCreationAllowed = b;
67
    }
97
    }
68
98
69
    public boolean belongsToWorkbenchPage(IWorkbenchPage workbenchPage) {
99
    public boolean belongsToWorkbenchPage(IWorkbenchPage workbenchPage) {
Lines 109-114 Link Here
109
    protected void configureShell(Shell shell) {
139
    protected void configureShell(Shell shell) {
110
        if (title != null)
140
        if (title != null)
111
            shell.setText(title);
141
            shell.setText(title);
142
        shell.setVisible(false);
112
        shell.addListener(SWT.Resize, new Listener() {
143
        shell.addListener(SWT.Resize, new Listener() {
113
            public void handleEvent(Event event) {
144
            public void handleEvent(Event event) {
114
                Shell shell = (Shell) event.widget;
145
                Shell shell = (Shell) event.widget;
Lines 144-153 Link Here
144
        // Return tab folder control.
175
        // Return tab folder control.
145
        return folder.getControl();
176
        return folder.getControl();
146
    }
177
    }
147
178
    
179
    /* (non-Javadoc)
180
     * @see org.eclipse.ui.internal.ILayoutContainer#findSashes(org.eclipse.ui.internal.LayoutPart, org.eclipse.ui.internal.PartPane.Sashes)
181
     */
182
    public void findSashes(LayoutPart toFind, Sashes result) {
183
        //do nothing        
184
    }
185
    
148
    public LayoutPart[] getChildren() {
186
    public LayoutPart[] getChildren() {
149
        return folder.getChildren();
187
        return folder.getChildren();
150
    }
188
    }
189
    
190
    /* (non-Javadoc)
191
     * @see org.eclipse.jface.window.Window#getConstrainedShellSize(org.eclipse.swt.graphics.Rectangle)
192
     */
193
    protected Rectangle getConstrainedShellBounds(Rectangle preferredSize) {
194
        // As long as the initial position is somewhere on the display, don't mess with it.
195
        if (intersectsAnyMonitor(getShell().getDisplay(), preferredSize)) {
196
            return preferredSize;
197
        }
198
199
        return super.getConstrainedShellBounds(preferredSize);
200
    }
201
    
202
	/* (non-Javadoc)
203
	 * @see org.eclipse.ui.internal.ILayoutContainer#getContainer()
204
	 */
205
	public ILayoutContainer getContainer() {
206
		return null;
207
	}
208
	
209
    /* (non-Javadoc)
210
     * @see org.eclipse.ui.internal.IWorkbenchDragDropPart#getControl()
211
     */
212
    public Control getControl() {
213
        return folder.getControl();
214
    }
151
215
152
    public WorkbenchPage getWorkbenchPage() {
216
    public WorkbenchPage getWorkbenchPage() {
153
        return this.page;
217
        return this.page;
Lines 175-180 Link Here
175
    }
239
    }
176
240
177
    /**
241
    /**
242
     * 
243
     * Returns true iff the given rectangle is located in the client area of any
244
     * monitor.
245
     * 
246
     * @param someRectangle a rectangle in display coordinates (not null)
247
     * @return true iff the given point can be seen on any monitor
248
     */
249
    private static boolean intersectsAnyMonitor(Display display,
250
            Rectangle someRectangle) {
251
        Monitor[] monitors = display.getMonitors();
252
253
        for (int idx = 0; idx < monitors.length; idx++) {
254
            Monitor mon = monitors[idx];
255
256
            if (mon.getClientArea().intersects(someRectangle)) {
257
                return true;
258
            }
259
        }
260
261
        return false;
262
    }    
263
    
264
    public void remove(LayoutPart part) {
265
        folder.remove(part);        
266
    }
267
268
    /* (non-Javadoc)
269
     * @see org.eclipse.ui.internal.ILayoutContainer#resizeChild(org.eclipse.ui.internal.LayoutPart)
270
     */
271
    public void resizeChild(LayoutPart childThatChanged) {
272
        //do nothing        
273
    }
274
275
    
276
    /**
178
     * @see IPersistablePart
277
     * @see IPersistablePart
179
     */
278
     */
180
    public void restoreState(IMemento memento) {
279
    public void restoreState(IMemento memento) {
Lines 191-196 Link Here
191
        int width = bigInt.intValue();
290
        int width = bigInt.intValue();
192
        bigInt = memento.getInteger(IWorkbenchConstants.TAG_HEIGHT);
291
        bigInt = memento.getInteger(IWorkbenchConstants.TAG_HEIGHT);
193
        int height = bigInt.intValue();
292
        int height = bigInt.intValue();
293
        bigInt = memento.getInteger(IWorkbenchConstants.TAG_FLOAT);
294
        //float tag @since 3.1 - old workbench.xmls won't have it
295
        int floatint = 0;
296
        if(bigInt != null) {
297
        	floatint = bigInt.intValue();
298
        	folder.setFloatingState(floatint == 1);
299
        }
194
300
195
        // Set the bounds.
301
        // Set the bounds.
196
        bounds = new Rectangle(x, y, width, height);
302
        bounds = new Rectangle(x, y, width, height);
Lines 198-204 Link Here
198
            getShell().setText(title);
304
            getShell().setText(title);
199
            getShell().setBounds(bounds);
305
            getShell().setBounds(bounds);
200
        }
306
        }
201
307
        
308
        
309
        
202
        // Create the folder.
310
        // Create the folder.
203
        IMemento childMem = memento.getChild(IWorkbenchConstants.TAG_FOLDER);
311
        IMemento childMem = memento.getChild(IWorkbenchConstants.TAG_FOLDER);
204
        if (childMem != null)
312
        if (childMem != null)
Lines 221-271 Link Here
221
        memento.putInteger(IWorkbenchConstants.TAG_Y, bounds.y);
329
        memento.putInteger(IWorkbenchConstants.TAG_Y, bounds.y);
222
        memento.putInteger(IWorkbenchConstants.TAG_WIDTH, bounds.width);
330
        memento.putInteger(IWorkbenchConstants.TAG_WIDTH, bounds.width);
223
        memento.putInteger(IWorkbenchConstants.TAG_HEIGHT, bounds.height);
331
        memento.putInteger(IWorkbenchConstants.TAG_HEIGHT, bounds.height);
332
        memento.putInteger(IWorkbenchConstants.TAG_FLOAT, 
333
        		folder.isFloating() ? 1 : 0);
224
334
225
        // Save the views.	
335
        // Save the views.	
226
        IMemento childMem = memento.createChild(IWorkbenchConstants.TAG_FOLDER);
336
        IMemento childMem = memento.createChild(IWorkbenchConstants.TAG_FOLDER);
227
        folder.saveState(childMem);
337
        folder.saveState(childMem);
228
    }
338
    }
229
339
   
340
    public void setFloatingState(boolean state) {
341
        folder.setFloatingState(state);
342
    }
343
    
230
    /* (non-Javadoc)
344
    /* (non-Javadoc)
231
     * @see org.eclipse.ui.internal.IWorkbenchDragDropPart#getControl()
345
     * @see org.eclipse.ui.internal.ILayoutContainer#setZoomed(boolean)
232
     */
346
     */
233
    public Control getControl() {
347
    public void setZoomed(boolean isZoomed) {
234
        return folder.getControl();
348
        folder.setZoomed(isZoomed);
349
        
235
    }
350
    }
236
351
237
    /**
352
    public boolean shouldOpenOnActivate() {
238
     * 
353
    	return !(folder.getHidden());
239
     * Returns true iff the given rectangle is located in the client area of any
240
     * monitor.
241
     * 
242
     * @param someRectangle a rectangle in display coordinates (not null)
243
     * @return true iff the given point can be seen on any monitor
244
     */
245
    private static boolean intersectsAnyMonitor(Display display,
246
            Rectangle someRectangle) {
247
        Monitor[] monitors = display.getMonitors();
248
249
        for (int idx = 0; idx < monitors.length; idx++) {
250
            Monitor mon = monitors[idx];
251
252
            if (mon.getClientArea().intersects(someRectangle)) {
253
                return true;
254
            }
255
        }
256
257
        return false;
258
    }
354
    }
259
355
260
    /* (non-Javadoc)
261
     * @see org.eclipse.jface.window.Window#getConstrainedShellSize(org.eclipse.swt.graphics.Rectangle)
262
     */
263
    protected Rectangle getConstrainedShellBounds(Rectangle preferredSize) {
264
        // As long as the initial position is somewhere on the display, don't mess with it.
265
        if (intersectsAnyMonitor(getShell().getDisplay(), preferredSize)) {
266
            return preferredSize;
267
        }
268
269
        return super.getConstrainedShellBounds(preferredSize);
270
    }
271
}
356
}
(-)Eclipse UI/org/eclipse/ui/internal/EditorStack.java (-1 / +2 lines)
Lines 46-56 Link Here
46
    private SystemMenuSize sizeItem = new SystemMenuSize(null);
46
    private SystemMenuSize sizeItem = new SystemMenuSize(null);
47
47
48
    private SystemMenuPinEditor pinEditorItem = new SystemMenuPinEditor(null);
48
    private SystemMenuPinEditor pinEditorItem = new SystemMenuPinEditor(null);
49
49
    
50
    public EditorStack(EditorSashContainer editorArea, WorkbenchPage page) {
50
    public EditorStack(EditorSashContainer editorArea, WorkbenchPage page) {
51
        super(PresentationFactoryUtil.ROLE_EDITOR); //$NON-NLS-1$
51
        super(PresentationFactoryUtil.ROLE_EDITOR); //$NON-NLS-1$
52
        this.editorArea = editorArea;
52
        this.editorArea = editorArea;
53
        setID(this.toString());
53
        setID(this.toString());
54
        hidden = false;
54
        // Each folder has a unique ID so relative positioning is unambiguous.
55
        // Each folder has a unique ID so relative positioning is unambiguous.
55
        // save off a ref to the page
56
        // save off a ref to the page
56
        //@issue is it okay to do this??
57
        //@issue is it okay to do this??
(-)Eclipse UI/org/eclipse/ui/internal/FastViewBar.java (-5 / +73 lines)
Lines 45-50 Link Here
45
import org.eclipse.ui.IWorkbenchPart;
45
import org.eclipse.ui.IWorkbenchPart;
46
import org.eclipse.ui.IWorkbenchPreferenceConstants;
46
import org.eclipse.ui.IWorkbenchPreferenceConstants;
47
import org.eclipse.ui.PlatformUI;
47
import org.eclipse.ui.PlatformUI;
48
import org.eclipse.ui.internal.PartPane.Sashes;
48
import org.eclipse.ui.internal.dnd.AbstractDropTarget;
49
import org.eclipse.ui.internal.dnd.AbstractDropTarget;
49
import org.eclipse.ui.internal.dnd.DragUtil;
50
import org.eclipse.ui.internal.dnd.DragUtil;
50
import org.eclipse.ui.internal.dnd.IDragOverListener;
51
import org.eclipse.ui.internal.dnd.IDragOverListener;
Lines 65-71 Link Here
65
 * 
66
 * 
66
 * @see org.eclipse.ui.internal.FastViewPane
67
 * @see org.eclipse.ui.internal.FastViewPane
67
 */
68
 */
68
public class FastViewBar implements IWindowTrim {
69
public class FastViewBar implements IWindowTrim, ILayoutContainer{
69
    private ToolBarManager fastViewBar;
70
    private ToolBarManager fastViewBar;
70
71
71
    private Menu fastViewBarMenu;
72
    private Menu fastViewBarMenu;
Lines 405-413 Link Here
405
                    LayoutPart[] children = folder.getChildren();
406
                    LayoutPart[] children = folder.getChildren();
406
407
407
                    for (int idx = 0; idx < children.length; idx++) {
408
                    for (int idx = 0; idx < children.length; idx++) {
408
                        if (!(children[idx] instanceof PartPlaceholder)) {
409
                    	viewList.add(children[idx]);
409
                            viewList.add(children[idx]);
410
                        }
411
                    }
410
                    }
412
411
413
                    return createDropTarget(viewList, targetItem);
412
                    return createDropTarget(viewList, targetItem);
Lines 626-632 Link Here
626
                            Rectangle startBounds = Geometry.toDisplay(item
625
                            Rectangle startBounds = Geometry.toDisplay(item
627
                                    .getParent(), bounds);
626
                                    .getParent(), bounds);
628
627
629
                            page.removeFastView(selectedView);
628
                            page.reattachFastView(selectedView);
630
629
631
                            IWorkbenchPart toActivate = selectedView
630
                            IWorkbenchPart toActivate = selectedView
632
                                    .getPart(true);
631
                                    .getPart(true);
Lines 963-967 Link Here
963
                    next.getInteger(IWorkbenchConstants.TAG_POSITION));
962
                    next.getInteger(IWorkbenchConstants.TAG_POSITION));
964
        }
963
        }
965
    }
964
    }
965
966
	/* (non-Javadoc)
967
	 * @see org.eclipse.ui.internal.ILayoutContainer#add(org.eclipse.ui.internal.LayoutPart)
968
	 */
969
	public void add(LayoutPart newPart) {
970
		ViewPane pane = (ViewPane)newPart;
971
		pane.doMakeFast();
972
	}
973
974
	/* (non-Javadoc)
975
	 * @see org.eclipse.ui.internal.ILayoutContainer#getChildren()
976
	 */
977
	public LayoutPart[] getChildren() {
978
		IViewReference[] refs = getPage().getFastViews();
979
		
980
		LayoutPart[] parts = new LayoutPart[refs.length];
981
		for (int i = 0; i < refs.length; i++) {
982
			IViewReference ref = refs[i];
983
			
984
			parts[i] = ((WorkbenchPartReference)ref).getPane();
985
		}
986
		
987
		return parts;
988
	}
989
990
	/* (non-Javadoc)
991
	 * @see org.eclipse.ui.internal.ILayoutContainer#getContainer()
992
	 */
993
	public ILayoutContainer getContainer() {
994
		return null;
995
	}
996
997
	/* (non-Javadoc)
998
	 * @see org.eclipse.ui.internal.ILayoutContainer#remove(org.eclipse.ui.internal.LayoutPart)
999
	 */
1000
	public void remove(LayoutPart toRemove) {
1001
		ViewPane pane = (ViewPane)toRemove;
1002
		getPage().removeFastView(pane.getViewReference());
1003
	}
1004
1005
	/* (non-Javadoc)
1006
	 * @see org.eclipse.ui.internal.ILayoutContainer#findSashes(org.eclipse.ui.internal.LayoutPart, org.eclipse.ui.internal.PartPane.Sashes)
1007
	 */
1008
	public void findSashes(LayoutPart toFind, Sashes result) {
1009
		// no-op
1010
		
1011
	}
1012
1013
	/* (non-Javadoc)
1014
	 * @see org.eclipse.ui.internal.ILayoutContainer#allowsAutoFocus()
1015
	 */
1016
	public boolean allowsAutoFocus() {
1017
		return false;
1018
	}
1019
1020
	/* (non-Javadoc)
1021
	 * @see org.eclipse.ui.internal.ILayoutContainer#setZoomed(boolean)
1022
	 */
1023
	public void setZoomed(boolean isZoomed) {
1024
		// no-op
1025
		
1026
	}
1027
1028
	/* (non-Javadoc)
1029
	 * @see org.eclipse.ui.internal.ILayoutContainer#resizeChild(org.eclipse.ui.internal.LayoutPart)
1030
	 */
1031
	public void resizeChild(LayoutPart childThatChanged) {
1032
		//TODO: trigger a layout in the FastViewPane
1033
	}
966
1034
967
}
1035
}
(-)Eclipse UI/org/eclipse/ui/internal/FolderLayout.java (-6 / +2 lines)
Lines 50-62 Link Here
50
        if (!pageLayout.checkValidPlaceholderId(viewId)) {
50
        if (!pageLayout.checkValidPlaceholderId(viewId)) {
51
            return;
51
            return;
52
        }
52
        }
53
        
54
        pageLayout.addPlaceholder(viewId, folder);
53
55
54
        // Create the placeholder.
55
        PartPlaceholder newPart = new PartPlaceholder(viewId);
56
        linkPartToPageLayout(viewId, newPart);
57
58
        // Add it to the folder layout.
59
        folder.add(newPart);
60
    }
56
    }
61
57
62
    /* (non-Javadoc)
58
    /* (non-Javadoc)
(-)Eclipse UI/org/eclipse/ui/internal/ILayoutContainer.java (-5 / +5 lines)
Lines 22-35 Link Here
22
    public LayoutPart[] getChildren();
22
    public LayoutPart[] getChildren();
23
23
24
    /**
24
    /**
25
     * Remove a child from the container.
25
     * Returns the container's container, or null if none.
26
     */
26
     */
27
    public void remove(LayoutPart part);
27
    public ILayoutContainer getContainer();
28
28
    
29
    /**
29
    /**
30
     * Replace one child with another
30
     * Remove a child from the container.
31
     */
31
     */
32
    public void replace(LayoutPart oldPart, LayoutPart newPart);
32
    public void remove(LayoutPart part);
33
33
34
    public void findSashes(LayoutPart toFind, PartPane.Sashes result);
34
    public void findSashes(LayoutPart toFind, PartPane.Sashes result);
35
35
(-)Eclipse UI/org/eclipse/ui/internal/IWorkbenchConstants.java (+4 lines)
Lines 152-157 Link Here
152
    public static final String TAG_MINIMIZED = "minimized"; //$NON-NLS-1$
152
    public static final String TAG_MINIMIZED = "minimized"; //$NON-NLS-1$
153
153
154
    public static final String TAG_MAXIMIZED = "maximized"; //$NON-NLS-1$
154
    public static final String TAG_MAXIMIZED = "maximized"; //$NON-NLS-1$
155
    
156
    public static final String TAG_FASTVIEWBAR = "fastviewbar"; //$NON-NLS-1$
155
157
156
    public static final String TAG_FOLDER = "folder"; //$NON-NLS-1$
158
    public static final String TAG_FOLDER = "folder"; //$NON-NLS-1$
157
159
Lines 160-165 Link Here
160
    public static final String TAG_PART = "part"; //$NON-NLS-1$
162
    public static final String TAG_PART = "part"; //$NON-NLS-1$
161
163
162
    public static final String TAG_PART_NAME = "partName"; //$NON-NLS-1$
164
    public static final String TAG_PART_NAME = "partName"; //$NON-NLS-1$
165
    
166
    public static final String TAG_PLACEHOLDERS = "placeholders"; //$NON-NLS-1$
163
167
164
    public static final String TAG_RELATIVE = "relative"; //$NON-NLS-1$
168
    public static final String TAG_RELATIVE = "relative"; //$NON-NLS-1$
165
169
(-)Eclipse UI/org/eclipse/ui/internal/LayoutTree.java (-1 / +4 lines)
Lines 467-473 Link Here
467
     * Returns true if this tree has visible parts otherwise returns false.
467
     * Returns true if this tree has visible parts otherwise returns false.
468
     */
468
     */
469
    public boolean isVisible() {
469
    public boolean isVisible() {
470
        return !(part instanceof PartPlaceholder);
470
    	if(part instanceof PartStack) {
471
    		return !(((PartStack)part).getHidden());
472
    	}
473
        return true;
471
    }
474
    }
472
475
473
    /**
476
    /**
(-)Eclipse UI/org/eclipse/ui/internal/PageLayout.java (-76 / +76 lines)
Lines 79-84 Link Here
79
79
80
    private Map mapIDtoViewLayoutRec = new HashMap(10);
80
    private Map mapIDtoViewLayoutRec = new HashMap(10);
81
81
82
    private Map mapPlaceholderIDToFolder = new HashMap(3);
83
82
    private ArrayList newWizardActionIds = new ArrayList(3);
84
    private ArrayList newWizardActionIds = new ArrayList(3);
83
85
84
    private ArrayList perspectiveActionIds = new ArrayList(3);
86
    private ArrayList perspectiveActionIds = new ArrayList(3);
Lines 116-135 Link Here
116
     * Adds the editor to a layout.
118
     * Adds the editor to a layout.
117
     */
119
     */
118
    private void addEditorArea() {
120
    private void addEditorArea() {
119
        try {
121
        // Create the part.
120
            // Create the part.
122
        LayoutPart newPart = editorFolder;
121
            LayoutPart newPart = createView(ID_EDITOR_AREA);
122
            if (newPart == null)
123
                // this should never happen as long as newID is the editor ID.
124
                return;
125
123
126
            setRefPart(ID_EDITOR_AREA, newPart);
124
        setRefPart(ID_EDITOR_AREA, newPart);
127
125
128
            // Add it to the layout.
126
        // Add it to the layout.
129
            rootLayoutContainer.add(newPart);
127
        rootLayoutContainer.add(newPart);
130
        } catch (PartInitException e) {
131
            WorkbenchPlugin.log(e.getMessage());
132
        }
133
    }
128
    }
134
129
135
    /**
130
    /**
Lines 198-204 Link Here
198
     * @since 3.0
193
     * @since 3.0
199
     */
194
     */
200
    ViewLayoutRec getViewLayoutRec(String id, boolean create) {
195
    ViewLayoutRec getViewLayoutRec(String id, boolean create) {
201
        Assert.isTrue(getRefPart(id) != null || isFastViewId(id));
196
        Assert.isTrue(getRefPart(id) != null || isFastViewId(id)
197
        		|| getPlaceholderFolder(id) != null);
202
198
203
        ViewLayoutRec rec = (ViewLayoutRec) mapIDtoViewLayoutRec.get(id);
199
        ViewLayoutRec rec = (ViewLayoutRec) mapIDtoViewLayoutRec.get(id);
204
        if (rec == null && create) {
200
        if (rec == null && create) {
Lines 229-237 Link Here
229
    /**
225
    /**
230
     * Add the layout part to the page's layout
226
     * Add the layout part to the page's layout
231
     */
227
     */
232
    private void addPart(LayoutPart newPart, String partId, int relationship,
228
    private void addPart(ViewStack newPart, String partId, int relationship,
233
            float ratio, String refId) {
229
            float ratio, String refId) {
234
230
231
    	setFolderPart(partId, newPart);
235
        setRefPart(partId, newPart);
232
        setRefPart(partId, newPart);
236
233
237
        // If the referenced part is inside a folder,
234
        // If the referenced part is inside a folder,
Lines 274-285 Link Here
274
            return;
271
            return;
275
        }
272
        }
276
273
277
        // Create the placeholder.
274
        // New style placeholder. We add an invisible stack and map the
278
        PartPlaceholder newPart = new PartPlaceholder(viewId);
275
        // part to it. 
279
        addPart(newPart, viewId, relationship, ratio, refId);
276
        int appearance = PresentationFactoryUtil.ROLE_VIEW;
277
        ViewStack newFolder = new ViewStack(rootLayoutContainer.page,
278
                true, appearance);
279
        setFolderPart(viewId, newFolder);
280
        addPart(newFolder, viewId, relationship, ratio, refId);
281
        
282
        mapIDtoFolder.put(viewId, newFolder);
283
        mapPlaceholderIDToFolder.put(viewId, newFolder);
284
285
        
280
        // force creation of the view layout rec
286
        // force creation of the view layout rec
281
        getViewLayoutRec(viewId, true);
287
        getViewLayoutRec(viewId, true);
282
    }
288
    }
289
    
290
    /**
291
     * Used by FolderLayout to programmatically create a placeholder before
292
     * the Perspective has been created. 
293
     * @param viewId
294
     * @param inner
295
     */
296
    /* protected */ void addPlaceholder(String viewId, ILayoutContainer inner) {
297
298
    	mapPlaceholderIDToFolder.put(viewId, inner);
299
    }
283
300
284
    /**
301
    /**
285
     * Checks whether the given id is a valid placeholder id.
302
     * Checks whether the given id is a valid placeholder id.
Lines 416-433 Link Here
416
    public IPlaceholderFolderLayout createPlaceholderFolder(String folderId,
433
    public IPlaceholderFolderLayout createPlaceholderFolder(String folderId,
417
            int relationship, float ratio, String refId) {
434
            int relationship, float ratio, String refId) {
418
        if (checkPartInLayout(folderId))
435
        if (checkPartInLayout(folderId))
419
            return new PlaceholderFolderLayout(this,
436
            return new FolderLayout(this,
420
                    (ContainerPlaceholder) getRefPart(folderId));
437
            		(ViewStack) getRefPart(folderId), viewFactory);
421
438
422
        // Create the folder.
439
        // Create the folder.
423
        ContainerPlaceholder folder = new ContainerPlaceholder(null);
440
        ViewStack folder = new ViewStack(rootLayoutContainer.page);
424
        folder.setContainer(rootLayoutContainer);
441
        folder.setContainer(rootLayoutContainer);
425
        folder.setRealContainer(new ViewStack(rootLayoutContainer.page));
426
        folder.setID(folderId);
442
        folder.setID(folderId);
427
        addPart(folder, folderId, relationship, ratio, refId);
443
        addPart(folder, folderId, relationship, ratio, refId);
428
444
429
        // Create a wrapper.
445
        // Create a wrapper.
430
        return new PlaceholderFolderLayout(this, folder);
446
        return new FolderLayout(this, folder, viewFactory);
431
    }
447
    }
432
448
433
    /**
449
    /**
Lines 438-453 Link Here
438
     * created because of activity filtering.
454
     * created because of activity filtering.
439
     * @throws PartInitException thrown if there is a problem creating the part.
455
     * @throws PartInitException thrown if there is a problem creating the part.
440
     */
456
     */
441
    private LayoutPart createView(String partID) throws PartInitException {
457
    private PartPane createView(String partID) throws PartInitException {
442
        if (partID.equals(ID_EDITOR_AREA)) {
458
        IViewDescriptor viewDescriptor = viewFactory.getViewRegistry()
443
            return editorFolder;
459
                .find(partID);
444
        } else {
460
        if (WorkbenchActivityHelper.filterItem(viewDescriptor))
445
            IViewDescriptor viewDescriptor = viewFactory.getViewRegistry()
461
            return null;
446
                    .find(partID);
462
        return LayoutHelper.createView(getViewFactory(), partID);
447
            if (WorkbenchActivityHelper.filterItem(viewDescriptor))
448
                return null;
449
            return LayoutHelper.createView(getViewFactory(), partID);
450
        }
451
    }
463
    }
452
464
453
    /**
465
    /**
Lines 521-532 Link Here
521
    }
533
    }
522
534
523
    /**
535
    /**
536
     * @return the map containing part IDs onto stacks. Used exclusively
537
     * by PartSashContainer. 
538
     */
539
    /* package */ Map getPlaceholderMapInner() {
540
    	return mapPlaceholderIDToFolder;
541
    }
542
    
543
    /**
524
     * @return the part for a given ID.
544
     * @return the part for a given ID.
525
     */
545
     */
526
    /*package*/
546
    /*package*/
527
    LayoutPart getRefPart(String partID) {
547
    LayoutPart getRefPart(String partID) {
528
        return (LayoutPart) mapIDtoPart.get(partID);
548
        return (LayoutPart) mapIDtoPart.get(partID);
529
    }
549
    }
550
    
551
    /**
552
     * @return the placeholder folder for a given ID.
553
     */
554
    private LayoutPart getPlaceholderFolder(String partID) {
555
        return (LayoutPart) mapPlaceholderIDToFolder.get(partID);
556
    }
530
557
531
    /**
558
    /**
532
     * @return the top level layout container.
559
     * @return the top level layout container.
Lines 631-648 Link Here
631
     * Map the folder part containing the given view ID.
658
     * Map the folder part containing the given view ID.
632
     * 
659
     * 
633
     * @param viewId the part ID.
660
     * @param viewId the part ID.
634
     * @param container the <code>ContainerPlaceholder</code>.
635
     */
636
    /*package*/
637
    void setFolderPart(String viewId, ContainerPlaceholder container) {
638
        LayoutPart tabFolder = container.getRealContainer();
639
        mapIDtoFolder.put(viewId, tabFolder);
640
    }
641
642
    /**
643
     * Map the folder part containing the given view ID.
644
     * 
645
     * @param viewId the part ID.
646
     * @param folder the <code>ViewStack</code>.
661
     * @param folder the <code>ViewStack</code>.
647
     */
662
     */
648
    /*package*/
663
    /*package*/
Lines 669-675 Link Here
669
     * @param viewId the view ID.
684
     * @param viewId the view ID.
670
     * @param refId the reference ID.
685
     * @param refId the reference ID.
671
     */
686
     */
672
    private void stackPart(LayoutPart newPart, String viewId, String refId) {
687
    private void stackPart(PartPane newPart, String viewId, String refId) {
673
        setRefPart(viewId, newPart);
688
        setRefPart(viewId, newPart);
674
        // force creation of the view layout rec
689
        // force creation of the view layout rec
675
        getViewLayoutRec(viewId, true);
690
        getViewLayoutRec(viewId, true);
Lines 677-705 Link Here
677
        // If ref part is in a folder than just add the
692
        // If ref part is in a folder than just add the
678
        // new view to that folder.
693
        // new view to that folder.
679
        ViewStack folder = getFolderPart(refId);
694
        ViewStack folder = getFolderPart(refId);
680
        if (folder != null) {
695
        if (folder == null) {
681
            folder.add(newPart);
696
    	folder = new ViewStack(rootLayoutContainer.page);
682
            setFolderPart(viewId, folder);
697
        // If ref part is not found then just do add.
683
            return;
698
    	WorkbenchPlugin.log(WorkbenchMessages.format(
684
        }
699
            "PageLayout.missingRefPart", new Object[] { refId })); //$NON-NLS-1$
685
700
        rootLayoutContainer.add(folder);
686
        // If the ref part is in the page layout then create
687
        // a new folder and add the new view.
688
        LayoutPart refPart = getRefPart(refId);
689
        if (refPart != null) {
690
            ViewStack newFolder = new ViewStack(rootLayoutContainer.page);
691
            rootLayoutContainer.replace(refPart, newFolder);
692
            newFolder.add(refPart);
693
            newFolder.add(newPart);
694
            setFolderPart(refId, newFolder);
695
            setFolderPart(viewId, newFolder);
696
            return;
697
        }
701
        }
698
702
699
        // If ref part is not found then just do add.
703
        folder.add(newPart);
700
        WorkbenchPlugin.log(WorkbenchMessages.format(
704
        setFolderPart(viewId, folder);
701
                "PageLayout.missingRefPart", new Object[] { refId })); //$NON-NLS-1$
702
        rootLayoutContainer.add(newPart);
703
    }
705
    }
704
706
705
    // stackPlaceholder(String, String) added by dan_rubel@instantiations.com
707
    // stackPlaceholder(String, String) added by dan_rubel@instantiations.com
Lines 713-727 Link Here
713
        if (checkPartInLayout(viewId))
715
        if (checkPartInLayout(viewId))
714
            return;
716
            return;
715
717
716
        // Create the placeholder.
718
        // Try to stack on a visible view. 
717
        PartPlaceholder newPart = new PartPlaceholder(viewId);
719
        ILayoutContainer folder = getFolderPart(refId);
718
720
        if(folder != null && folder instanceof PartStack) {
719
        LayoutPart refPart = getRefPart(refId);
721
        	mapPlaceholderIDToFolder.put(viewId, folder);
720
        if (refPart != null) {
722
        	setFolderPart(viewId, (ViewStack)folder);
721
            newPart.setContainer(refPart.getContainer());
723
        	return;
722
        }
724
        }   
723
724
        stackPart(newPart, viewId, refId);
725
    }
725
    }
726
726
727
    // stackView(String, String) modified by dan_rubel@instantiations.com
727
    // stackView(String, String) modified by dan_rubel@instantiations.com
Lines 737-743 Link Here
737
737
738
        // Create the new part.
738
        // Create the new part.
739
        try {
739
        try {
740
            LayoutPart newPart = createView(viewId);
740
            PartPane newPart = createView(viewId);
741
            if (newPart == null) {
741
            if (newPart == null) {
742
                stackPlaceholder(viewId, refId);
742
                stackPlaceholder(viewId, refId);
743
                LayoutHelper.addViewActivator(this, viewId);
743
                LayoutHelper.addViewActivator(this, viewId);
(-)Eclipse UI/org/eclipse/ui/internal/PartPane.java (-7 lines)
Lines 543-555 Link Here
543
    }
543
    }
544
544
545
    /**
545
    /**
546
     * Pin this part.
547
     */
548
    protected void doDock() {
549
        // do nothing
550
    }
551
552
    /**
553
     * Set the busy state of the pane.
546
     * Set the busy state of the pane.
554
     */
547
     */
555
    public void setBusy(boolean isBusy) {
548
    public void setBusy(boolean isBusy) {
(-)Eclipse UI/org/eclipse/ui/internal/PartSashContainer.java (-24 / +54 lines)
Lines 59-64 Link Here
59
59
60
    private SashContainerDropTarget dropTarget;
60
    private SashContainerDropTarget dropTarget;
61
61
62
    private PlaceholderMap placeholderMap = new PlaceholderMap();
63
62
    protected static class RelationshipInfo {
64
    protected static class RelationshipInfo {
63
        protected LayoutPart part;
65
        protected LayoutPart part;
64
66
Lines 214-221 Link Here
214
    public void add(LayoutPart child) {
216
    public void add(LayoutPart child) {
215
        if (child == null)
217
        if (child == null)
216
            return;
218
            return;
217
219
        
218
        addEnhanced(child, SWT.RIGHT, 0.5f, findBottomRight());
220
        //check for a placeholder first
221
        ILayoutContainer stack = placeholderMap.get(child.getCompoundId());
222
        if(stack != null){
223
            if (!(stack instanceof ViewStack)) {
224
                child.reparent(getParent());
225
            }
226
            stack.add(child);
227
            return;
228
        }
229
        
230
		
231
		LayoutPart relative = findBottomRight();
232
		if (relative != null && relative instanceof PartStack) {
233
			((PartStack)relative).add(child);
234
		} else {
235
			addEnhanced(child, SWT.RIGHT, 0.5f, findBottomRight());
236
		}
237
        
219
    }
238
    }
220
239
221
    /**
240
    /**
Lines 353-359 Link Here
353
                    || info.relationship == IPageLayout.TOP;
372
                    || info.relationship == IPageLayout.TOP;
354
            LayoutPartSash sash = new LayoutPartSash(this, vertical);
373
            LayoutPartSash sash = new LayoutPartSash(this, vertical);
355
            sash.setSizes(info.left, info.right);
374
            sash.setSizes(info.left, info.right);
356
            if ((parent != null) && !(child instanceof PartPlaceholder))
375
            if (parent != null)
357
                sash.createControl(parent);
376
                sash.createControl(parent);
358
            root = root.insert(child, left, sash, info.relative);
377
            root = root.insert(child, left, sash, info.relative);
359
        }
378
        }
Lines 403-408 Link Here
403
        addChild(newRelationshipInfo);
422
        addChild(newRelationshipInfo);
404
        flushLayout();
423
        flushLayout();
405
    }
424
    }
425
    
426
    public void addPlaceholder(String compoundID, ILayoutContainer stack) {
427
    	placeholderMap.put(compoundID, stack);
428
    }   
406
429
407
    /**
430
    /**
408
     * See ILayoutContainer#allowBorder
431
     * See ILayoutContainer#allowBorder
Lines 537-543 Link Here
537
            return null;
560
            return null;
538
        return root.findBottomRight();
561
        return root.findBottomRight();
539
    }
562
    }
540
563
    
564
    protected String[] getPlaceholdersFor(ILayoutContainer c) {
565
    	return placeholderMap.getPlaceholdersFor(c);
566
    }
567
    
568
    public boolean hasPlaceholders(ILayoutContainer c){
569
    	return placeholderMap.hasPlaceholderFor(c);
570
    }
571
    
541
    /**
572
    /**
542
     * @see LayoutPart#getBounds
573
     * @see LayoutPart#getBounds
543
     */
574
     */
Lines 545-558 Link Here
545
        return this.parent.getBounds();
576
        return this.parent.getBounds();
546
    }
577
    }
547
578
548
//    // getMinimumHeight() added by cagatayk@acm.org 
549
//    /**
550
//     * @see LayoutPart#getMinimumHeight()
551
//     */
552
//    public int computeMinimumSize(boolean width, int knownHeight) {
553
//        return getLayoutTree().computeMinimumSize(width, knownHeight);
554
//    }
555
556
    /**
579
    /**
557
     * @see ILayoutContainer#getChildren
580
     * @see ILayoutContainer#getChildren
558
     */
581
     */
Lines 631-637 Link Here
631
    public void remove(LayoutPart child) {
654
    public void remove(LayoutPart child) {
632
        if (isZoomed())
655
        if (isZoomed())
633
            zoomOut();
656
            zoomOut();
634
657
        
658
        if(child instanceof PartPane) {	
659
        	addPlaceholder(child.getCompoundId(), child.getContainer());
660
        	child.getContainer().remove(child);
661
        	return;
662
        }
663
        
635
        if (!isChild(child))
664
        if (!isChild(child))
636
            return;
665
            return;
637
666
Lines 647-652 Link Here
647
            flushLayout();
676
            flushLayout();
648
        }
677
        }
649
    }
678
    }
679
    
680
	 /**
681
	 * Removes a placeholder from this container's mapping. Note that this
682
	 * should only be called when the part is being relocated and we don't
683
	 * want to leave an empty container around that will never be used. 
684
	 * @param compoundId
685
	 */
686
	 public void removePlaceholder(String compoundId) {
687
	 	placeholderMap.remove(compoundId);
688
	 }
650
689
651
	/* (non-Javadoc)
690
	/* (non-Javadoc)
652
	 * @see org.eclipse.ui.internal.LayoutPart#forceLayout()
691
	 * @see org.eclipse.ui.internal.LayoutPart#forceLayout()
Lines 655-661 Link Here
655
		layoutDirty = true;
694
		layoutDirty = true;
656
		super.flushLayout();
695
		super.flushLayout();
657
		
696
		
658
		if (layoutDirty) {
697
		if (layoutDirty && parent != null) {
659
			resizeSashes(parent.getClientArea());
698
			resizeSashes(parent.getClientArea());
660
		}
699
		}
661
	}
700
	}
Lines 1011-1026 Link Here
1011
            return 0;
1050
            return 0;
1012
        }
1051
        }
1013
1052
1014
        LayoutPart[] children = container.getChildren();
1053
        return container.getChildren().length;
1015
1016
        int count = 0;
1017
        for (int idx = 0; idx < children.length; idx++) {
1018
            if (!(children[idx] instanceof PartPlaceholder)) {
1019
                count++;
1020
            }
1021
        }
1022
1023
        return count;
1024
    }
1054
    }
1025
1055
1026
    protected float getDockingRatio(LayoutPart dragged, LayoutPart target) {
1056
    protected float getDockingRatio(LayoutPart dragged, LayoutPart target) {
(-)Eclipse UI/org/eclipse/ui/internal/PartStack.java (-137 / +148 lines)
Lines 61-70 Link Here
61
    // inactiveCurrent is only used when restoring the persisted state of
61
    // inactiveCurrent is only used when restoring the persisted state of
62
    // perspective on startup.
62
    // perspective on startup.
63
    private LayoutPart current;
63
    private LayoutPart current;
64
    
65
    private String currentId;
64
66
65
    private boolean ignoreSelectionChanges = false;
67
    private boolean ignoreSelectionChanges = false;
68
    
69
    /**
70
     * Indicates that this stack is hidden (ie: this is the value last passed to setHidden).
71
     * A "hidden" stack is one which should not appear in the layout because it contains no
72
     * children. This does not necessarily correspond with "visible" -- that is, a non-empty
73
     * stack in an inactive perspective may be invisible but non-hidden. 
74
     * 
75
     * Currently, this is set explicitly by the owner through a call to setHidden,
76
     * but it should probably be updated automatically when the first child is added or the
77
     * last child is removed.
78
     */
79
    protected boolean hidden = true; 
66
80
67
    protected IMemento savedPresentationState = null;
81
    protected IMemento savedPresentationState = null;
82
    
83
    /**
84
     * If createControl(...) has been called, this points to the parent composite. Set to null
85
     * otherwise. Basically, this either points to the composite where this stack is allowed
86
     * to create its controls or is null if the stack is not supposed to have any controls (ie:
87
     * dispose() has been called)
88
     */
89
    protected Composite savedParent = null;
68
90
69
    private DefaultStackPresentationSite presentationSite = new DefaultStackPresentationSite() {
91
    private DefaultStackPresentationSite presentationSite = new DefaultStackPresentationSite() {
70
92
Lines 232-239 Link Here
232
                    "null children are not allowed in PartStack"); //$NON-NLS-1$
254
                    "null children are not allowed in PartStack"); //$NON-NLS-1$
233
255
234
            // This object can only contain placeholders or PartPanes
256
            // This object can only contain placeholders or PartPanes
235
            Assert.isTrue(child instanceof PartPlaceholder
257
            Assert.isTrue( //child instanceof PartPlaceholder ||
236
                    || child instanceof PartPane,
258
                     child instanceof PartPane,
237
                    "PartStack can only contain PartPlaceholders or PartPanes"); //$NON-NLS-1$
259
                    "PartStack can only contain PartPlaceholders or PartPanes"); //$NON-NLS-1$
238
260
239
            // Ensure that all the PartPanes have an associated presentable part 
261
            // Ensure that all the PartPanes have an associated presentable part 
Lines 246-281 Link Here
246
            // Ensure that the child's backpointer points to this stack
268
            // Ensure that the child's backpointer points to this stack
247
            ILayoutContainer childContainer = child.getContainer();
269
            ILayoutContainer childContainer = child.getContainer();
248
270
249
            // Disable tests for placeholders -- PartPlaceholder backpointers don't
271
            if (isDisposed()) {
250
            // obey the usual rules -- they sometimes point to a container placeholder
272
251
            // for this stack instead of the real stack.
273
                // Currently, we allow null backpointers if the widgetry is disposed.
252
            if (!(child instanceof PartPlaceholder)) {
274
                // However, it is never valid for the child to have a parent other than
253
275
                // this object
254
                if (isDisposed()) {
276
                if (childContainer != null) {
255
256
                    // Currently, we allow null backpointers if the widgetry is disposed.
257
                    // However, it is never valid for the child to have a parent other than
258
                    // this object
259
                    if (childContainer != null) {
260
                        Assert
261
                                .isTrue(childContainer == this,
262
                                        "PartStack has a child that thinks it has a different parent"); //$NON-NLS-1$
263
                    }
264
                } else {
265
                    // If the widgetry exists, the child's backpointer must point to us
266
                    Assert
277
                    Assert
267
                            .isTrue(childContainer == this,
278
                            .isTrue(childContainer == this,
268
                                    "PartStack has a child that thinks it has a different parent"); //$NON-NLS-1$
279
                                    "PartStack has a child that thinks it has a different parent"); //$NON-NLS-1$
269
280
                }
270
                    // If this child has focus, then ensure that it is selected and that we have
281
            } else {
271
                    // the active appearance.
282
                // If the widgetry exists, the child's backpointer must point to us
272
283
                Assert
273
                    if (SwtUtil.isChild(child.getControl(), focusControl)) {
284
                        .isTrue(childContainer == this,
274
                        Assert.isTrue(child == current,
285
                                "PartStack has a child that thinks it has a different parent"); //$NON-NLS-1$
275
                                "The part with focus is not the selected part"); //$NON-NLS-1$
286
276
                        //  focus check commented out since it fails when focus workaround in LayoutPart.setVisible is not present       			
287
                // If this child has focus, then ensure that it is selected and that we have
277
                        //        			Assert.isTrue(getActive() == StackPresentation.AS_ACTIVE_FOCUS);
288
                // the active appearance.
278
                    }
289
290
                if (SwtUtil.isChild(child.getControl(), focusControl)) {
291
                    Assert.isTrue(child == current,
292
                            "The part with focus is not the selected part"); //$NON-NLS-1$
293
                    //  focus check commented out since it fails when focus workaround in LayoutPart.setVisible is not present       			
294
                    //        			Assert.isTrue(getActive() == StackPresentation.AS_ACTIVE_FOCUS);
279
                }
295
                }
280
            }
296
            }
281
297
Lines 326-332 Link Here
326
        for (int idx = 0; idx < children.length; idx++) {
342
        for (int idx = 0; idx < children.length; idx++) {
327
343
328
            LayoutPart next = children[idx];
344
            LayoutPart next = children[idx];
329
            if (!(next instanceof PartPlaceholder)) {
330
                if (idx > 0) {
345
                if (idx > 0) {
331
                    buf.append(", "); //$NON-NLS-1$
346
                    buf.append(", "); //$NON-NLS-1$
332
                }
347
                }
Lines 338-344 Link Here
338
                next.describeLayout(buf);
353
                next.describeLayout(buf);
339
354
340
                visibleChildren++;
355
                visibleChildren++;
341
            }
342
        }
356
        }
343
357
344
        buf.append(")"); //$NON-NLS-1$
358
        buf.append(")"); //$NON-NLS-1$
Lines 348-353 Link Here
348
     * See IVisualContainer#add
362
     * See IVisualContainer#add
349
     */
363
     */
350
    public void add(LayoutPart child) {
364
    public void add(LayoutPart child) {
365
    	Assert.isTrue(child instanceof PartPane);
366
    	
351
        children.add(child);
367
        children.add(child);
352
        showPart(child, null);
368
        showPart(child, null);
353
    }
369
    }
Lines 421-440 Link Here
421
    }
437
    }
422
438
423
    public void createControl(Composite parent) {
439
    public void createControl(Composite parent) {
424
        if (!isDisposed()) {
440
        savedParent = parent;
425
            return;
441
        
426
        }
442
        createControl();
427
443
    }
444
    
445
    /**
446
     * Creates the controls if we are not hidden and the parent has previously called
447
     * createControl. This is a NOP otherwise.
448
     */
449
    private void createControl() {
450
    	if (!isDisposed() || savedParent == null) {
451
    		return;
452
    	} 	
428
        AbstractPresentationFactory factory = getFactory();
453
        AbstractPresentationFactory factory = getFactory();
429
454
430
        PresentationSerializer serializer = new PresentationSerializer(
455
        PresentationSerializer serializer = new PresentationSerializer(
431
                getPresentableParts());
456
                getPresentableParts());
432
457
433
        StackPresentation presentation = PresentationFactoryUtil
458
        StackPresentation presentation = PresentationFactoryUtil
434
                .createPresentation(factory, appearance, parent,
459
                .createPresentation(factory, appearance, savedParent,
435
                        presentationSite, serializer, savedPresentationState);
460
                        presentationSite, serializer, savedPresentationState);
436
461
437
        createControl(parent, presentation);
462
        createControl(savedParent, presentation);
438
    }
463
    }
439
464
440
    public void createControl(Composite parent, StackPresentation presentation) {
465
    public void createControl(Composite parent, StackPresentation presentation) {
Lines 509-519 Link Here
509
        ctrl.setData(this);
534
        ctrl.setData(this);
510
535
511
        updateActions();
536
        updateActions();
512
537
        
513
        // We should not have a placeholder selected once we've created the widgetry
538
        if (current == null) {
514
        if (current instanceof PartPlaceholder) {
539
        	updateContainerVisibleTab();
515
            current = null;
516
            updateContainerVisibleTab();
517
        }
540
        }
518
541
519
        refreshPresentationSelection();
542
        refreshPresentationSelection();
Lines 551-563 Link Here
551
    /**
574
    /**
552
     * See LayoutPart#dispose
575
     * See LayoutPart#dispose
553
     */
576
     */
554
    public void dispose() {
577
    public final void dispose() {
578
    	// Note that the real disposal is done in doDispose.
579
    	savedParent = null;
580
    	doDispose();
581
    }
582
583
    /**
584
     * Internal disposal method. This disposes the widgets and does the real cleanup.
585
     * The public dispose() is called when the parent wants to dispose this stack, but
586
     * is never invoked within this object. This method is also used internally to wipe 
587
     * out the widgets when the stack becomes hidden. Note: in order for the stack to
588
     * have widgets, the parent must have called createControl(...) AND the stack must not
589
     * be hidden.
590
     */
591
    protected void doDispose() {
555
592
556
        if (isDisposed())
593
        if (isDisposed())
557
            return;
594
            return;
558
595
559
        savePresentationState();
596
        savePresentationState();
560
561
        presentationSite.dispose();
597
        presentationSite.dispose();
562
598
563
        Iterator iter = children.iterator();
599
        Iterator iter = children.iterator();
Lines 691-696 Link Here
691
        return null;
727
        return null;
692
    }
728
    }
693
729
730
    /**
731
     * Gets the current visibility of the PartStack.
732
     */
733
    public boolean getHidden() {
734
	    	return hidden;
735
    }
736
694
    private void presentationSelectionChanged(IPresentablePart newSelection) {
737
    private void presentationSelectionChanged(IPresentablePart newSelection) {
695
        // Ignore selection changes that occur as a result of removing a part
738
        // Ignore selection changes that occur as a result of removing a part
696
        if (ignoreSelectionChanges) {
739
        if (ignoreSelectionChanges) {
Lines 744-749 Link Here
744
        if (child == current) {
787
        if (child == current) {
745
            updateContainerVisibleTab();
788
            updateContainerVisibleTab();
746
        }
789
        }
790
        
791
        updateVisibility();
747
    }
792
    }
748
793
749
    /**
794
    /**
Lines 766-805 Link Here
766
        }
811
        }
767
    }
812
    }
768
813
769
    /**
814
    /* (non-Javadoc)
770
     * See IVisualContainer#replace
771
     */
772
    public void replace(LayoutPart oldChild, LayoutPart newChild) {
773
        // commented out but left for future reference - we're using this
774
        // as the cookie for the part presentation but this will
775
        // almost always be null (oldChilds being PartPlaceholders)
776
        // even if they aren't null, we don't handle 
777
        // IPresentableParts as cookies
778
        //
779
        // IPresentablePart oldPart = oldChild.getPresentablePart();
780
        IPresentablePart newPart = newChild.getPresentablePart();
781
782
        int idx = children.indexOf(oldChild);
783
        int numPlaceholders = 0;
784
        //subtract the number of placeholders still existing in the list 
785
        //before this one - they wont have parts.
786
        for (int i = 0; i < idx; i++) {
787
            if (children.get(i) instanceof PartPlaceholder)
788
                numPlaceholders++;
789
        }
790
        Integer cookie = new Integer(idx - numPlaceholders);
791
        children.add(idx, newChild);
792
793
        showPart(newChild, cookie);
794
795
        if (oldChild == current && !(newChild instanceof PartPlaceholder)) {
796
            setSelection(newChild);
797
        }
798
799
        remove(oldChild);
800
    }
801
802
	/* (non-Javadoc)
803
	 * @see org.eclipse.ui.internal.LayoutPart#computePreferredSize(boolean, int, int, int)
815
	 * @see org.eclipse.ui.internal.LayoutPart#computePreferredSize(boolean, int, int, int)
804
	 */
816
	 */
805
	public int computePreferredSize(boolean width, int availableParallel,
817
	public int computePreferredSize(boolean width, int availableParallel,
Lines 813-818 Link Here
813
     * @see org.eclipse.ui.internal.LayoutPart#getSizeFlags(boolean)
825
     * @see org.eclipse.ui.internal.LayoutPart#getSizeFlags(boolean)
814
     */
826
     */
815
    public int getSizeFlags(boolean horizontal) {
827
    public int getSizeFlags(boolean horizontal) {
828
    	StackPresentation presentation = getPresentation();
829
    	if (presentation == null) {
830
    		return 0;
831
    	}
832
    	
816
        return getPresentation().getSizeFlags(horizontal);
833
        return getPresentation().getSizeFlags(horizontal);
817
    }
834
    }
818
    
835
    
Lines 821-852 Link Here
821
     */
838
     */
822
    public IStatus restoreState(IMemento memento) {
839
    public IStatus restoreState(IMemento memento) {
823
        // Read the active tab.
840
        // Read the active tab.
824
        String activeTabID = memento
841
        currentId = memento
825
                .getString(IWorkbenchConstants.TAG_ACTIVE_PAGE_ID);
842
                .getString(IWorkbenchConstants.TAG_ACTIVE_PAGE_ID);
826
843
827
        // Read the page elements.
828
        IMemento[] children = memento.getChildren(IWorkbenchConstants.TAG_PAGE);
829
        if (children != null) {
830
            // Loop through the page elements.
831
            for (int i = 0; i < children.length; i++) {
832
                // Get the info details.
833
                IMemento childMem = children[i];
834
                String partID = childMem
835
                        .getString(IWorkbenchConstants.TAG_CONTENT);
836
837
                // Create the part.
838
                LayoutPart part = new PartPlaceholder(partID);
839
                part.setContainer(this);
840
                add(part);
841
                //1FUN70C: ITPUI:WIN - Shouldn't set Container when not active
842
                //part.setContainer(this);
843
                if (partID.equals(activeTabID)) {
844
                    // Mark this as the active part.
845
                    current = part;
846
                }
847
            }
848
        }
849
850
        Integer expanded = memento.getInteger(IWorkbenchConstants.TAG_EXPANDED);
844
        Integer expanded = memento.getInteger(IWorkbenchConstants.TAG_EXPANDED);
851
        setState((expanded == null || expanded.intValue() != IStackPresentationSite.STATE_MINIMIZED) ? IStackPresentationSite.STATE_RESTORED
845
        setState((expanded == null || expanded.intValue() != IStackPresentationSite.STATE_MINIMIZED) ? IStackPresentationSite.STATE_RESTORED
852
                : IStackPresentationSite.STATE_MINIMIZED);
846
                : IStackPresentationSite.STATE_MINIMIZED);
Lines 886-908 Link Here
886
            memento.putString(IWorkbenchConstants.TAG_ACTIVE_PAGE_ID, current
880
            memento.putString(IWorkbenchConstants.TAG_ACTIVE_PAGE_ID, current
887
                    .getCompoundId());
881
                    .getCompoundId());
888
882
889
        Iterator iter = children.iterator();
890
        while (iter.hasNext()) {
891
            LayoutPart next = (LayoutPart) iter.next();
892
893
            IMemento childMem = memento
894
                    .createChild(IWorkbenchConstants.TAG_PAGE);
895
896
            IPresentablePart part = next.getPresentablePart();
897
            String tabText = "LabelNotFound"; //$NON-NLS-1$ 
898
            if (part != null) {
899
                tabText = part.getName();
900
            }
901
            childMem.putString(IWorkbenchConstants.TAG_LABEL, tabText);
902
            childMem.putString(IWorkbenchConstants.TAG_CONTENT, next
903
                    .getCompoundId());
904
        }
905
906
        memento
883
        memento
907
                .putInteger(
884
                .putInteger(
908
                        IWorkbenchConstants.TAG_EXPANDED,
885
                        IWorkbenchConstants.TAG_EXPANDED,
Lines 1014-1036 Link Here
1014
991
1015
        int oldState = presentationSite.getState();
992
        int oldState = presentationSite.getState();
1016
993
1017
        if (current != null) {
994
        
1018
            if (newState == IStackPresentationSite.STATE_MAXIMIZED) {
995
        if (newState == IStackPresentationSite.STATE_MAXIMIZED) {
1019
                PartPane pane = getVisiblePart();
996
            PartPane pane = getVisiblePart();
1020
                if (pane != null) {
997
            if (pane != null) {
1021
                    pane.doZoom();
998
                pane.doZoom();
1022
                }
999
            }
1023
            } else {
1000
        } else {
1024
                presentationSite.setPresentationState(newState);
1001
          	presentationSite.setPresentationState(newState);
1025
1026
                WorkbenchPage page = getPage();
1027
                if (page != null) {
1028
                    if (page.isZoomed()) {
1029
                        page.zoomOut();
1030
                    }
1031
1002
1032
                    flushLayout();
1003
            WorkbenchPage page = getPage();
1004
            if (page != null) {
1005
                if (page.isZoomed()) {
1006
                    page.zoomOut();
1033
                }
1007
                }
1008
1009
                flushLayout();
1034
            }
1010
            }
1035
        }
1011
        }
1036
1012
Lines 1055-1060 Link Here
1055
        }
1031
        }
1056
    }
1032
    }
1057
1033
1034
    private void setHidden(boolean isHidden) {
1035
    	if (isHidden == hidden) {
1036
    		return;
1037
    	}
1038
    	
1039
    	hidden = isHidden;	 
1040
    	
1041
    	if(isHidden) {
1042
    		doDispose();
1043
    	}
1044
    	else {
1045
    		createControl();
1046
    	}
1047
    	flushLayout();
1048
    } 
1049
    
1050
    
1058
    /**
1051
    /**
1059
     * Makes the given part visible in the presentation
1052
     * Makes the given part visible in the presentation
1060
     * 
1053
     * 
Lines 1062-1067 Link Here
1062
     */
1055
     */
1063
    private void showPart(LayoutPart part, Object cookie) {
1056
    private void showPart(LayoutPart part, Object cookie) {
1064
1057
1058
        if(hidden) {
1059
        	setHidden(false);
1060
        }
1061
    	
1065
        if (isDisposed()) {
1062
        if (isDisposed()) {
1066
            return;
1063
            return;
1067
        }
1064
        }
Lines 1075-1083 Link Here
1075
        }
1072
        }
1076
1073
1077
        presentationSite.getPresentation().addPart(presentablePart, cookie);
1074
        presentationSite.getPresentation().addPart(presentablePart, cookie);
1078
1075
                
1079
        if (current == null) {
1076
        if(current == null) {
1080
            setSelection(part);
1077
        	setSelection(part);
1078
        }
1079
        else if(Util.equals(currentId, part.getCompoundId())) {
1080
        	setSelection(part);
1081
        	currentId = null;
1081
        }
1082
        }
1082
    }
1083
    }
1083
1084
Lines 1127-1132 Link Here
1127
        }
1128
        }
1128
1129
1129
        setSelection(selPart);
1130
        setSelection(selPart);
1131
    }
1132
    
1133
    private void updateVisibility() {
1134
    	if(children.size() == 0) {
1135
    		Window window = getWindow();
1136
    		setHidden(true);
1137
    		if(window instanceof DetachedWindow) {
1138
    			window.close();
1139
    		}
1140
    	}
1130
    }
1141
    }
1131
1142
1132
    /**
1143
    /**
(-)Eclipse UI/org/eclipse/ui/internal/Perspective.java (-39 / +52 lines)
Lines 18-23 Link Here
18
import java.util.Iterator;
18
import java.util.Iterator;
19
import java.util.List;
19
import java.util.List;
20
import java.util.Map;
20
import java.util.Map;
21
import java.util.Set;
21
22
22
import org.eclipse.core.runtime.CoreException;
23
import org.eclipse.core.runtime.CoreException;
23
import org.eclipse.core.runtime.IStatus;
24
import org.eclipse.core.runtime.IStatus;
Lines 65-71 Link Here
65
66
66
    protected LayoutPart editorArea;
67
    protected LayoutPart editorArea;
67
68
68
    private PartPlaceholder editorHolder;
69
    private boolean editorVisible = true;
69
70
70
    private ViewFactory viewFactory;
71
    private ViewFactory viewFactory;
71
72
Lines 87-92 Link Here
87
88
88
    private boolean fixed;
89
    private boolean fixed;
89
90
91
    private PlaceholderMap placeholders = new PlaceholderMap();
92
    
90
    private ArrayList showInPartIds;
93
    private ArrayList showInPartIds;
91
94
92
    private HashMap showInTimes = new HashMap();
95
    private HashMap showInTimes = new HashMap();
Lines 140-160 Link Here
140
    public void addFastView(IViewReference ref) {
143
    public void addFastView(IViewReference ref) {
141
        ViewPane pane = (ViewPane) ((WorkbenchPartReference) ref).getPane();
144
        ViewPane pane = (ViewPane) ((WorkbenchPartReference) ref).getPane();
142
        if (!isFastView(ref)) {
145
        if (!isFastView(ref)) {
143
            // Only remove the part from the presentation if it
146
        	if(pane.getContainer() != null) {
144
            // is actually in the presentation.
147
        		presentation.removePart(pane);
145
            if (presentation.hasPlaceholder(ref.getId(), ref.getSecondaryId())
148
        	}
146
                    || pane.getContainer() != null)
149
        	
147
                presentation.removePart(pane);
148
            // We are drag-enabling the pane because it has been disabled
150
            // We are drag-enabling the pane because it has been disabled
149
            // when it was removed from the perspective presentation.
151
            // when it was removed from the perspective presentation.
150
            fastViews.add(ref);
152
            fastViews.add(ref);
151
            pane.setFast(true);
153
            pane.setFast(true);
154
            
155
            pane.setContainer(((WorkbenchWindow)page.getWorkbenchWindow()).getFastViewBar());
156
            
152
            Control ctrl = pane.getControl();
157
            Control ctrl = pane.getControl();
153
            if (ctrl != null)
158
            if (ctrl != null)
154
                ctrl.setEnabled(false); // Remove focus support.
159
                ctrl.setEnabled(false); // Remove focus support.
155
        }
160
        }
156
    }
161
    }
157
162
163
    public void addPlaceholder(String compoundID, ILayoutContainer cont) {
164
    	placeholders.put(compoundID, cont);
165
    }
166
    
158
    /**
167
    /**
159
     * Moves a part forward in the Z order of a perspective so it is visible.
168
     * Moves a part forward in the Z order of a perspective so it is visible.
160
     *
169
     *
Lines 239-244 Link Here
239
        mapIDtoViewLayoutRec.clear();
248
        mapIDtoViewLayoutRec.clear();
240
    }
249
    }
241
250
251
    /* package */ ILayoutContainer findContainer(String id){
252
    	return placeholders.get(id);
253
    }
254
    
242
    /**
255
    /**
243
     * Finds the view with the given ID that is open in this page, or <code>null</code>
256
     * Finds the view with the given ID that is open in this page, or <code>null</code>
244
     * if not found.
257
     * if not found.
Lines 288-293 Link Here
288
        return page.getClientComposite();
301
        return page.getClientComposite();
289
    }
302
    }
290
303
304
    /* package */ String[] getAssociatedParts(ILayoutContainer c){
305
    	return placeholders.getPlaceholdersFor(c);
306
    }
307
    
291
    /**
308
    /**
292
     * Returns the perspective.
309
     * Returns the perspective.
293
     */
310
     */
Lines 456-464 Link Here
456
473
457
        // Replace the editor area with a placeholder so we
474
        // Replace the editor area with a placeholder so we
458
        // know where to put it back on show editor area request.
475
        // know where to put it back on show editor area request.
459
        editorHolder = new PartPlaceholder(editorArea.getID());
476
        presentation.getLayout().removeEditorArea(); 
460
        presentation.getLayout().replace(editorArea, editorHolder);
477
        
461
462
        // Disable the entire editor area so if an editor had
478
        // Disable the entire editor area so if an editor had
463
        // keyboard focus it will let it go.
479
        // keyboard focus it will let it go.
464
        if (editorArea.getControl() != null)
480
        if (editorArea.getControl() != null)
Lines 496-501 Link Here
496
        // Remove the view from the current presentation.
512
        // Remove the view from the current presentation.
497
        if (isFastView(ref)) {
513
        if (isFastView(ref)) {
498
            fastViews.remove(ref);
514
            fastViews.remove(ref);
515
            addPlaceholder(((LayoutPart)pane).getCompoundId(),
516
            	((WorkbenchWindow)page.getWorkbenchWindow()).getFastViewBar());
499
            if (pane != null)
517
            if (pane != null)
500
                pane.setFast(false); //force an update of the toolbar
518
                pane.setFast(false); //force an update of the toolbar
501
            if (activeFastView == ref)
519
            if (activeFastView == ref)
Lines 515-521 Link Here
515
     * Return whether the editor area is visible or not.
533
     * Return whether the editor area is visible or not.
516
     */
534
     */
517
    protected boolean isEditorAreaVisible() {
535
    protected boolean isEditorAreaVisible() {
518
        return editorHolder == null;
536
        return editorVisible;
519
    }
537
    }
520
538
521
    /**
539
    /**
Lines 671-676 Link Here
671
                                    IPageLayout.RIGHT, .75f,
689
                                    IPageLayout.RIGHT, .75f,
672
                                    IPageLayout.ID_EDITOR_AREA);
690
                                    IPageLayout.ID_EDITOR_AREA);
673
                stickyFolderRight.addPlaceholder(id);
691
                stickyFolderRight.addPlaceholder(id);
692
                addPlaceholder(id, container);
674
                break;
693
                break;
675
            case IPageLayout.LEFT:
694
            case IPageLayout.LEFT:
676
                if (stickyFolderLeft == null)
695
                if (stickyFolderLeft == null)
Lines 678-683 Link Here
678
                            IStickyViewDescriptor.STICKY_FOLDER_LEFT,
697
                            IStickyViewDescriptor.STICKY_FOLDER_LEFT,
679
                            IPageLayout.LEFT, .25f, IPageLayout.ID_EDITOR_AREA);
698
                            IPageLayout.LEFT, .25f, IPageLayout.ID_EDITOR_AREA);
680
                stickyFolderLeft.addPlaceholder(id);
699
                stickyFolderLeft.addPlaceholder(id);
700
                addPlaceholder(id, container);
681
                break;
701
                break;
682
            case IPageLayout.TOP:
702
            case IPageLayout.TOP:
683
                if (stickyFolderTop == null)
703
                if (stickyFolderTop == null)
Lines 685-690 Link Here
685
                            IStickyViewDescriptor.STICKY_FOLDER_TOP,
705
                            IStickyViewDescriptor.STICKY_FOLDER_TOP,
686
                            IPageLayout.TOP, .25f, IPageLayout.ID_EDITOR_AREA);
706
                            IPageLayout.TOP, .25f, IPageLayout.ID_EDITOR_AREA);
687
                stickyFolderTop.addPlaceholder(id);
707
                stickyFolderTop.addPlaceholder(id);
708
                addPlaceholder(id, container);
688
                break;
709
                break;
689
            case IPageLayout.BOTTOM:
710
            case IPageLayout.BOTTOM:
690
                if (stickyFolderBottom == null)
711
                if (stickyFolderBottom == null)
Lines 693-698 Link Here
693
                            IPageLayout.BOTTOM, .75f,
714
                            IPageLayout.BOTTOM, .75f,
694
                            IPageLayout.ID_EDITOR_AREA);
715
                            IPageLayout.ID_EDITOR_AREA);
695
                stickyFolderBottom.addPlaceholder(id);
716
                stickyFolderBottom.addPlaceholder(id);
717
                addPlaceholder(id, container);
696
                break;
718
                break;
697
            }
719
            }
698
720
Lines 710-715 Link Here
710
        // Retrieve view layout info stored in the page layout.
732
        // Retrieve view layout info stored in the page layout.
711
        mapIDtoViewLayoutRec.putAll(layout.getIDtoViewLayoutRecMap());
733
        mapIDtoViewLayoutRec.putAll(layout.getIDtoViewLayoutRecMap());
712
734
735
        Map innerPlaceholders = layout.getPlaceholderMapInner();
736
        Set keys = innerPlaceholders.keySet();
737
        Iterator iter = keys.iterator();
738
        while (iter.hasNext()) {
739
            Object key = iter.next();
740
            placeholders.put((String)key, container);
741
            container.addPlaceholder((String)key,
742
            		(ILayoutContainer)innerPlaceholders.get(key));
743
        }
744
    
745
        
713
        // Create action sets.
746
        // Create action sets.
714
        createInitialActionSets(layout.getActionSets());
747
        createInitialActionSets(layout.getActionSets());
715
        alwaysOnActionSets.addAll(visibleActionSets);
748
        alwaysOnActionSets.addAll(visibleActionSets);
Lines 728-734 Link Here
728
        presentation = new PerspectiveHelper(page, container, this);
761
        presentation = new PerspectiveHelper(page, container, this);
729
762
730
        // Hide editor area if requested by factory
763
        // Hide editor area if requested by factory
731
        if (!layout.isEditorAreaVisible())
764
        if (!layout.isEditorAreaVisible()) 
732
            hideEditorArea();
765
            hideEditorArea();
733
766
734
    }
767
    }
Lines 829-839 Link Here
829
            Control ctrl = pane.getControl();
862
            Control ctrl = pane.getControl();
830
            if (ctrl != null)
863
            if (ctrl != null)
831
                ctrl.setEnabled(true); // Modify focus support.
864
                ctrl.setEnabled(true); // Modify focus support.
832
            // We are disabling the pane because it will be enabled when it
833
            // is added to the presentation. When a pane is enabled a drop
834
            // listener is added to it, and we do not want to have multiple
835
            // listeners for a pane
836
            presentation.addPart(pane);
837
        }
865
        }
838
    }
866
    }
839
867
Lines 942-949 Link Here
942
                .getChild(IWorkbenchConstants.TAG_LAYOUT)));
970
                .getChild(IWorkbenchConstants.TAG_LAYOUT)));
943
971
944
        // Add the editor workbook. Do not hide it now.
972
        // Add the editor workbook. Do not hide it now.
945
        pres.replacePlaceholderWithPart(editorArea);
973
        mainLayout.addEditorArea(editorArea);
946
974
        editorVisible = true;
975
        
947
        // Add the visible views.
976
        // Add the visible views.
948
        IMemento[] views = memento.getChildren(IWorkbenchConstants.TAG_VIEW);
977
        IMemento[] views = memento.getChildren(IWorkbenchConstants.TAG_VIEW);
949
978
Lines 959-965 Link Here
959
            // skip the intro as it is restored higher up in workbench.
988
            // skip the intro as it is restored higher up in workbench.
960
            if (id.equals(IIntroConstants.INTRO_VIEW_ID))
989
            if (id.equals(IIntroConstants.INTRO_VIEW_ID))
961
                continue;
990
                continue;
962
991
            
963
            // Create and open the view.
992
            // Create and open the view.
964
            IViewReference viewRef = viewFactory.getView(id, secondaryId);
993
            IViewReference viewRef = viewFactory.getView(id, secondaryId);
965
            WorkbenchPartReference ref = (WorkbenchPartReference) viewRef;
994
            WorkbenchPartReference ref = (WorkbenchPartReference) viewRef;
Lines 977-1000 Link Here
977
                ref.setPane(vp);
1006
                ref.setPane(vp);
978
            }
1007
            }
979
            page.addPart(ref);
1008
            page.addPart(ref);
980
            boolean willPartBeVisible = pres.willPartBeVisible(ref.getId(),
1009
            pres.addPart(ref.getPane());
981
                    secondaryId);
982
            if (willPartBeVisible) {
983
                IStatus restoreStatus = viewFactory.restoreView(viewRef);
984
                result.add(restoreStatus);
985
                if (restoreStatus.getSeverity() == IStatus.OK) {
986
                    IViewPart view = (IViewPart) ref.getPart(true);
987
                    if (view != null) {
988
                        ViewSite site = (ViewSite) view.getSite();
989
                        ViewPane pane = (ViewPane) site.getPane();
990
                        pres.replacePlaceholderWithPart(pane);
991
                    }
992
                } else {
993
                    page.removePart(ref);
994
                }
995
            } else {
996
                pres.replacePlaceholderWithPart(ref.getPane());
997
            }
998
        }
1010
        }
999
1011
1000
        // Load the fast views
1012
        // Load the fast views
Lines 1650-1657 Link Here
1650
        setEditorAreaVisible(true);
1662
        setEditorAreaVisible(true);
1651
1663
1652
        // Replace the part holder with the editor area.
1664
        // Replace the part holder with the editor area.
1653
        presentation.getLayout().replace(editorHolder, editorArea);
1665
        presentation.getLayout().addEditorArea(editorArea);
1654
        editorHolder = null;
1666
        
1655
    }
1667
    }
1656
1668
1657
    private void setEditorAreaVisible(boolean visible) {
1669
    private void setEditorAreaVisible(boolean visible) {
Lines 1665-1670 Link Here
1665
                pane.setVisible(visible);
1677
                pane.setVisible(visible);
1666
        }
1678
        }
1667
        editorArea.setVisible(visible);
1679
        editorArea.setVisible(visible);
1680
        editorVisible = visible;
1668
    }
1681
    }
1669
1682
1670
    /**
1683
    /**
(-)Eclipse UI/org/eclipse/ui/internal/PerspectiveHelper.java (-418 / +196 lines)
Lines 51-62 Link Here
51
51
52
    private ViewSashContainer mainLayout;
52
    private ViewSashContainer mainLayout;
53
53
54
    private Perspective perspective;
55
    
54
    private IWorkbenchPartReference zoomPart;
56
    private IWorkbenchPartReference zoomPart;
55
57
56
    private ArrayList detachedWindowList = new ArrayList(1);
58
    private ArrayList detachedWindowList = new ArrayList(1);
57
59
58
    private ArrayList detachedPlaceHolderList = new ArrayList(1);
59
60
    private boolean detachable = false;
60
    private boolean detachable = false;
61
61
62
    private boolean active = false;
62
    private boolean active = false;
Lines 75-80 Link Here
75
        public IDropTarget drag(Control currentControl, Object draggedObject,
75
        public IDropTarget drag(Control currentControl, Object draggedObject,
76
                Point position, final Rectangle dragRectangle) {
76
                Point position, final Rectangle dragRectangle) {
77
77
78
            // If we're dragging a floating detached window
79
            if (draggedObject instanceof DetachedWindow) {
80
                final DetachedWindow window = (DetachedWindow)draggedObject;
81
                return new AbstractDropTarget() {
82
                    public void drop() {
83
                        window.getShell().setLocation(dragRectangle.x,
84
                                dragRectangle.y);
85
                    }
86
87
                    public Cursor getCursor() {
88
                        return DragCursors.getCursor(DragCursors.OFFSCREEN);
89
                    }
90
                };
91
            }
92
            
78
            if (!(draggedObject instanceof ViewPane || draggedObject instanceof ViewStack)) {
93
            if (!(draggedObject instanceof ViewPane || draggedObject instanceof ViewStack)) {
79
                return null;
94
                return null;
80
            }
95
            }
Lines 190-199 Link Here
190
     * Constructs a new object.
205
     * Constructs a new object.
191
     */
206
     */
192
    public PerspectiveHelper(WorkbenchPage workbenchPage,
207
    public PerspectiveHelper(WorkbenchPage workbenchPage,
193
            ViewSashContainer mainLayout) {
208
            ViewSashContainer mainLayout, Perspective perspective) {
194
        this.page = workbenchPage;
209
        this.page = workbenchPage;
195
        this.mainLayout = mainLayout;
210
        this.mainLayout = mainLayout;
196
211
        this.perspective = perspective;
197
        // Determine if reparenting is allowed by checking if some arbitrary
212
        // Determine if reparenting is allowed by checking if some arbitrary
198
        // Composite supports reparenting. This is used to determine if
213
        // Composite supports reparenting. This is used to determine if
199
        // detached views should be enabled.
214
        // detached views should be enabled.
Lines 227-239 Link Here
227
            part.reparent(parent);
242
            part.reparent(parent);
228
        }
243
        }
229
        mainLayout.createControl(parent);
244
        mainLayout.createControl(parent);
230
245
        
231
        // Open the detached windows.
246
        // Open the detached windows.
232
        for (int i = 0, length = detachedWindowList.size(); i < length; i++) {
247
        for (int i = 0, length = detachedWindowList.size(); i < length; i++) {
233
            DetachedWindow dwindow = (DetachedWindow) detachedWindowList.get(i);
248
            DetachedWindow dwindow = (DetachedWindow) detachedWindowList.get(i);
234
            dwindow.open();
249
            if(dwindow.shouldOpenOnActivate()) {
250
            	dwindow.open();
251
            }
252
            dwindow.allowShellCreation(true);
235
        }
253
        }
236
254
        
237
        enableAllDrag();
255
        enableAllDrag();
238
        //enableAllDrop();
256
        //enableAllDrop();
239
257
Lines 251-348 Link Here
251
            zoomOut();
269
            zoomOut();
252
270
253
        // Look for a placeholder.
271
        // Look for a placeholder.
254
        PartPlaceholder placeholder = null;
272
        ILayoutContainer newPlaceholder = (ILayoutContainer)(
255
        LayoutPart testPart = null;
273
                perspective.findContainer(part.getCompoundId()));
256
        String primaryId = part.getID();
274
        
257
        String secondaryId = null;
275
        if (newPlaceholder == null) {
258
276
        	part.reparent(mainLayout.getParent());
259
        if (part instanceof ViewPane) {
277
        	newPlaceholder = mainLayout;
260
            ViewPane pane = (ViewPane) part;
261
            IViewReference ref = (IViewReference) pane.getPartReference();
262
            secondaryId = ref.getSecondaryId();
263
        }
264
        if (secondaryId != null)
265
            testPart = findPart(primaryId, secondaryId);
266
        else
267
            testPart = findPart(primaryId);
268
269
        // validate the testPart
270
        if (testPart != null && testPart instanceof PartPlaceholder)
271
            placeholder = (PartPlaceholder) testPart;
272
273
        // If there is no placeholder do a simple add. Otherwise, replace the
274
        // placeholder if its not a pattern matching placholder
275
        if (placeholder == null) {
276
            part.reparent(mainLayout.getParent());
277
            LayoutPart relative = mainLayout.findBottomRight();
278
            if (relative != null && relative instanceof PartStack) {
279
                mainLayout.stack(part, (PartStack) relative);
280
            } else {
281
                mainLayout.add(part);
282
            }
283
        } else {
284
            ILayoutContainer container = placeholder.getContainer();
285
            if (container != null) {
286
287
                if (container instanceof DetachedPlaceHolder) {
288
                    //Create a detached window add the part on it.
289
                    DetachedPlaceHolder holder = (DetachedPlaceHolder) container;
290
                    detachedPlaceHolderList.remove(holder);
291
                    container.remove(testPart);
292
                    DetachedWindow window = new DetachedWindow(page);
293
                    detachedWindowList.add(window);
294
                    window.create();
295
                    part.createControl(window.getShell());
296
                    // Open window.
297
                    window.getShell().setBounds(holder.getBounds());
298
                    window.open();
299
                    // add part to detached window.
300
                    ViewPane pane = (ViewPane) part;
301
                    window.getShell().setText(
302
                            pane.getPartReference().getTitle());
303
                    window.add(pane);
304
                    LayoutPart otherChildren[] = holder.getChildren();
305
                    for (int i = 0; i < otherChildren.length; i++)
306
                        part.getContainer().add(otherChildren[i]);
307
                } else {
308
309
                    // reconsistute parent if necessary
310
                    if (container instanceof ContainerPlaceholder) {
311
                        ContainerPlaceholder containerPlaceholder = (ContainerPlaceholder) container;
312
                        ILayoutContainer parentContainer = containerPlaceholder
313
                                .getContainer();
314
                        container = (ILayoutContainer) containerPlaceholder
315
                                .getRealContainer();
316
                        if (container instanceof LayoutPart) {
317
                            parentContainer.replace(containerPlaceholder,
318
                                    (LayoutPart) container);
319
                        }
320
                        containerPlaceholder.setRealContainer(null);
321
                    }
322
323
                    // reparent part.
324
                    if (!(container instanceof ViewStack)) {
325
                        // We don't need to reparent children of PartTabFolders since they will automatically
326
                        // reparent their children when they become visible. This if statement used to be 
327
                        // part of an else branch. Investigate if it is still necessary.
328
                        part.reparent(mainLayout.getParent());
329
                    }
330
331
                    // see if we should replace the placeholder
332
                    if (placeholder.hasWildCard()) {
333
                        if (container instanceof PartSashContainer)
334
                            ((PartSashContainer) container)
335
                                    .addChildForPlaceholder(part, placeholder);
336
                        else
337
                            container.add(part);
338
                    } else
339
                        container.replace(placeholder, part);
340
                }
341
            }
342
        }
278
        }
343
279
        
344
        // enable direct manipulation
280
        newPlaceholder.add(part);
345
        //enableDrop(part);
281
    }
282
    
283
    
284
    /**
285
     * Attaches a part that was previously detached to the mainLayout. 
286
     * 
287
     * @param ref
288
     */
289
    public void attachPart(IViewReference ref) {
290
		if(isZoomed())
291
			zoomOut();
292
		ViewPane pane = (ViewPane)((WorkbenchPartReference)ref).getPane();	
293
		derefPart(pane);
294
		perspective.addPlaceholder(pane.getCompoundId(), mainLayout);
295
		addPart(pane);
296
		bringPartToTop(pane);
297
		pane.setFocus();
346
    }
298
    }
347
299
348
    /**
300
    /**
Lines 385-392 Link Here
385
            return false;
337
            return false;
386
338
387
        ILayoutContainer container = part.getContainer();
339
        ILayoutContainer container = part.getContainer();
388
        if (container != null && container instanceof ContainerPlaceholder)
389
            return false;
390
340
391
        if (container != null && container instanceof ViewStack) {
341
        if (container != null && container instanceof ViewStack) {
392
            ViewStack folder = (ViewStack) container;
342
            ViewStack folder = (ViewStack) container;
Lines 398-430 Link Here
398
    }
348
    }
399
349
400
    /**
350
    /**
401
     * Returns true is not in a tab folder or if it is the top one in a tab
402
     * folder.
403
     */
404
    public boolean willPartBeVisible(String partId) {
405
        return willPartBeVisible(partId, null);
406
    }
407
408
    public boolean willPartBeVisible(String partId, String secondaryId) {
409
        LayoutPart part = findPart(partId, secondaryId);
410
        if (part == null)
411
            return false;
412
        ILayoutContainer container = part.getContainer();
413
        if (container != null && container instanceof ContainerPlaceholder)
414
            container = (ILayoutContainer) ((ContainerPlaceholder) container)
415
                    .getRealContainer();
416
417
        if (container != null && container instanceof ViewStack) {
418
            ViewStack folder = (ViewStack) container;
419
            if (folder.getVisiblePart() == null)
420
                return false;
421
            return part.getCompoundId().equals(
422
                    folder.getVisiblePart().getCompoundId());
423
        }
424
        return true;
425
    }
426
427
    /**
428
     * Open the tracker to allow the user to move the specified part using
351
     * Open the tracker to allow the user to move the specified part using
429
     * keyboard.
352
     * keyboard.
430
     */
353
     */
Lines 434-495 Link Here
434
    }
357
    }
435
358
436
    /**
359
    /**
437
     * Answer a list of the PartPlaceholder objects.
438
     */
439
    private PartPlaceholder[] collectPlaceholders() {
440
        // Scan the main window.
441
        PartPlaceholder[] results = collectPlaceholders(mainLayout
442
                .getChildren());
443
444
        // Scan each detached window.
445
        if (detachable) {
446
            for (int i = 0, length = detachedWindowList.size(); i < length; i++) {
447
                DetachedWindow win = (DetachedWindow) detachedWindowList.get(i);
448
                PartPlaceholder[] moreResults = collectPlaceholders(win
449
                        .getChildren());
450
                if (moreResults.length > 0) {
451
                    int newLength = results.length + moreResults.length;
452
                    PartPlaceholder[] newResults = new PartPlaceholder[newLength];
453
                    System.arraycopy(results, 0, newResults, 0, results.length);
454
                    System.arraycopy(moreResults, 0, newResults,
455
                            results.length, moreResults.length);
456
                    results = newResults;
457
                }
458
            }
459
        }
460
        return results;
461
    }
462
463
    /**
464
     * Answer a list of the PartPlaceholder objects.
465
     */
466
    private PartPlaceholder[] collectPlaceholders(LayoutPart[] parts) {
467
        PartPlaceholder[] result = new PartPlaceholder[0];
468
469
        for (int i = 0, length = parts.length; i < length; i++) {
470
            LayoutPart part = parts[i];
471
            if (part instanceof ILayoutContainer) {
472
                // iterate through sub containers to find sub-parts
473
                PartPlaceholder[] newParts = collectPlaceholders(((ILayoutContainer) part)
474
                        .getChildren());
475
                PartPlaceholder[] newResult = new PartPlaceholder[result.length
476
                        + newParts.length];
477
                System.arraycopy(result, 0, newResult, 0, result.length);
478
                System.arraycopy(newParts, 0, newResult, result.length,
479
                        newParts.length);
480
                result = newResult;
481
            } else if (part instanceof PartPlaceholder) {
482
                PartPlaceholder[] newResult = new PartPlaceholder[result.length + 1];
483
                System.arraycopy(result, 0, newResult, 0, result.length);
484
                newResult[result.length] = (PartPlaceholder) part;
485
                result = newResult;
486
            }
487
        }
488
489
        return result;
490
    }
491
492
    /**
493
     * Answer a list of the view panes.
360
     * Answer a list of the view panes.
494
     */
361
     */
495
    public void collectViewPanes(List result) {
362
    public void collectViewPanes(List result) {
Lines 552-557 Link Here
552
        // Dispose the detached windows
419
        // Dispose the detached windows
553
        for (int i = 0, length = detachedWindowList.size(); i < length; i++) {
420
        for (int i = 0, length = detachedWindowList.size(); i < length; i++) {
554
            DetachedWindow window = (DetachedWindow) detachedWindowList.get(i);
421
            DetachedWindow window = (DetachedWindow) detachedWindowList.get(i);
422
            window.allowShellCreation(false);
555
            window.close();
423
            window.close();
556
        }
424
        }
557
425
Lines 604-616 Link Here
604
     */
472
     */
605
    /* package */void derefPart(LayoutPart part) {
473
    /* package */void derefPart(LayoutPart part) {
606
474
607
        if (part instanceof ViewPane) {
608
            page.removeFastView(((ViewPane) part).getViewReference());
609
        }
610
611
        // Get vital part stats before reparenting.
475
        // Get vital part stats before reparenting.
612
        Window oldWindow = part.getWindow();
476
        Window oldWindow = part.getWindow();
613
        ILayoutContainer oldContainer = part.getContainer();
477
        ILayoutContainer oldContainer = part.getContainer();
478
    	
479
        if (part instanceof ViewPane) {
480
        	if(page.isFastView(((ViewPane) part).getViewReference())) {
481
        		page.removeFastView(((ViewPane) part).getViewReference());
482
        		oldWindow = part.getWindow();
483
        		oldContainer = part.getContainer();
484
        	}
485
        }
614
486
615
        // Reparent the part back to the main window
487
        // Reparent the part back to the main window
616
        part.reparent(mainLayout.getParent());
488
        part.reparent(mainLayout.getParent());
Lines 620-699 Link Here
620
            return;
492
            return;
621
493
622
        oldContainer.remove(part);
494
        oldContainer.remove(part);
623
495
        
624
        LayoutPart[] children = oldContainer.getChildren();
496
        if (part instanceof ViewPane && oldContainer instanceof ViewStack) {
625
        if (oldWindow instanceof WorkbenchWindow) {
497
            LayoutPart parent = (LayoutPart) oldContainer;
626
            boolean hasChildren = (children != null) && (children.length > 0);
498
        	if (parent.getContainer() == mainLayout) {
627
            if (hasChildren) {
499
        		mainLayout.removePlaceholder(part.getCompoundId());
628
                // make sure one is at least visible
500
        	}
629
                int childVisible = 0;
630
                for (int i = 0; i < children.length; i++)
631
                    if (children[i].getControl() != null)
632
                        childVisible++;
633
634
                // none visible, then reprarent and remove container
635
                if (oldContainer instanceof ViewStack) {
636
                    ViewStack folder = (ViewStack) oldContainer;
637
                    if (childVisible == 0) {
638
                        ILayoutContainer parentContainer = folder
639
                                .getContainer();
640
                        for (int i = 0; i < children.length; i++) {
641
                            folder.remove(children[i]);
642
                            parentContainer.add(children[i]);
643
                        }
644
                        hasChildren = false;
645
                    } else if (childVisible == 1) {
646
                        LayoutTree layout = mainLayout.getLayoutTree();
647
                        layout = layout.find(folder);
648
                        layout.setBounds(layout.getBounds());
649
                    }
650
                }
651
            }
652
653
            if (!hasChildren) {
654
                // There are no more children in this container, so get rid of
655
                // it
656
                if (oldContainer instanceof LayoutPart) {
657
                    LayoutPart parent = (LayoutPart) oldContainer;
658
                    ILayoutContainer parentContainer = parent.getContainer();
659
                    if (parentContainer != null) {
660
                        parentContainer.remove(parent);
661
                        parent.dispose();
662
                    }
663
                }
664
            }
665
        } else if (oldWindow instanceof DetachedWindow) {
666
            if (children == null || children.length == 0) {
667
                // There are no more children in this container, so get rid of
668
                // it
669
                // Turn on redraw again just in case it was off.
670
                oldWindow.getShell().setRedraw(true);
671
                oldWindow.close();
672
                detachedWindowList.remove(oldWindow);
673
            } else {
674
                // There are children. If none are visible hide detached
675
                // window.
676
                boolean allInvisible = true;
677
                for (int i = 0, length = children.length; i < length; i++) {
678
                    if (!(children[i] instanceof PartPlaceholder)) {
679
                        allInvisible = false;
680
                        break;
681
                    }
682
                }
683
                if (allInvisible) {
684
                    DetachedPlaceHolder placeholder = new DetachedPlaceHolder(
685
                            "", //$NON-NLS-1$
686
                            oldWindow.getShell().getBounds());
687
                    for (int i = 0, length = children.length; i < length; i++) {
688
                        oldContainer.remove(children[i]);
689
                        children[i].setContainer(placeholder);
690
                        placeholder.add(children[i]);
691
                    }
692
                    detachedPlaceHolderList.add(placeholder);
693
                    oldWindow.close();
694
                    detachedWindowList.remove(oldWindow);
695
                }
696
            }
697
        }
501
        }
698
502
699
    }
503
    }
Lines 736-742 Link Here
736
            for (int i = 0; i < children.length; i++) {
540
            for (int i = 0; i < children.length; i++) {
737
                if (children[i] instanceof ViewPane) {
541
                if (children[i] instanceof ViewPane) {
738
                    // remove the part from its current container
542
                    // remove the part from its current container
739
                    derefPart(children[i]);
543
                	removePart(children[i]);
740
                    // add part to detached window.
544
                    // add part to detached window.
741
                    ViewPane pane = (ViewPane) children[i];
545
                    ViewPane pane = (ViewPane) children[i];
742
                    window.getShell().setText(
546
                    window.getShell().setText(
Lines 752-784 Link Here
752
            parentWidget.setRedraw(true);
556
            parentWidget.setRedraw(true);
753
        } else {
557
        } else {
754
            // remove the part from its current container
558
            // remove the part from its current container
755
            derefPart(part);
559
        	removePart(part);
756
            // add part to detached window.
560
            // add part to detached window.
757
            ViewPane pane = (ViewPane) part;
561
            ViewPane pane = (ViewPane) part;
758
            window.getShell().setText(pane.getPartReference().getTitle());
562
            window.getShell().setText(pane.getPartReference().getTitle());
759
            window.add(pane);
563
            window.add(part);
760
            part.setFocus();
564
            part.setFocus();
761
        }
565
        }
762
566
763
    }
567
    }
568
    
569
    /**
570
     * Detached a part from the mainLayout. Presently this does not use placeholders
571
     * since the current implementation is not robust enough to remember a view's position
572
     * in more than one root container. For now the view is simply derefed and will dock
573
     * in the default position when attachPart is called. 
574
     * 
575
     * By default parts detached this way are set to float on top of the workbench
576
     * without docking. It is assumed that people that want to drag a part back onto
577
     * the WorkbenchWindow will detach it via drag and drop. 
578
     * 
579
     * @param ref
580
     */
581
    public void detachPart(IViewReference ref) {
582
		ViewPane pane = (ViewPane)((WorkbenchPartReference)ref).getPane();
583
    	if (canDetach() && pane != null) {
584
    		Rectangle bounds = pane.getParentBounds();
585
    	    detach(pane, bounds.x ,bounds.y);
586
        	((DetachedWindow)pane.getWindow()).setFloatingState(true);
587
    	}
588
    }
764
589
765
    /**
590
    /**
766
     * Create a detached window containing a part.
591
     * Create a detached window containing a part.
767
     */
592
     */
768
    public void addDetachedPart(LayoutPart part) {
593
    public void addDetachedPart(LayoutPart part) {
594
        // Calculate detached window size.
595
        Rectangle bounds = parentWidget.getShell().getBounds();
596
        bounds.x = bounds.x + (bounds.width - 300) / 2;
597
        bounds.y = bounds.y + (bounds.height - 300) / 2;
598
        
599
        addDetachedPart(part, bounds);
600
601
        // enable direct manipulation
602
        //enableDrop(part);
603
    }
604
    
605
    public void addDetachedPart(LayoutPart part, Rectangle bounds) {
769
        // Detaching is disabled on some platforms ..
606
        // Detaching is disabled on some platforms ..
770
        if (!detachable) {
607
        if (!detachable) {
771
            addPart(part);
608
            addPart(part);
772
            return;
609
            return;
773
        }
610
        }
774
611
        
775
        // Calculate detached window size.
776
        int width = 300;
777
        int height = 300;
778
        Rectangle bounds = parentWidget.getShell().getBounds();
779
        int x = bounds.x + (bounds.width - width) / 2;
780
        int y = bounds.y + (bounds.height - height) / 2;
781
782
        // Create detached window.
612
        // Create detached window.
783
        DetachedWindow window = new DetachedWindow(page);
613
        DetachedWindow window = new DetachedWindow(page);
784
        detachedWindowList.add(window);
614
        detachedWindowList.add(window);
Lines 791-805 Link Here
791
        window.add(pane);
621
        window.add(pane);
792
622
793
        // Open window.
623
        // Open window.
794
        window.getShell().setBounds(x, y, width, height);
624
        window.getShell().setBounds(bounds.x, bounds.y, bounds.width, bounds.height);
795
        window.open();
625
        window.open();
796
626
797
        part.setFocus();
627
        part.setFocus();
798
628
        
799
        // enable direct manipulation
800
        //enableDrop(part);
801
    }
629
    }
802
630
    
803
    /**
631
    /**
804
     * disableDragging.
632
     * disableDragging.
805
     */
633
     */
Lines 852-866 Link Here
852
            if (part != null)
680
            if (part != null)
853
                return part;
681
                return part;
854
        }
682
        }
855
        for (int i = 0; i < detachedPlaceHolderList.size(); i++) {
856
            DetachedPlaceHolder holder = (DetachedPlaceHolder) detachedPlaceHolderList
857
                    .get(i);
858
            part = (secondaryId != null) ? findPart(primaryId, secondaryId,
859
                    holder.getChildren(), matchingParts) : findPart(primaryId,
860
                    holder.getChildren(), matchingParts);
861
            if (part != null)
862
                return part;
863
        }
864
683
865
        // sort the matching parts
684
        // sort the matching parts
866
        if (matchingParts.size() > 0) {
685
        if (matchingParts.size() > 0) {
Lines 985-996 Link Here
985
     * @since 3.0
804
     * @since 3.0
986
     */
805
     */
987
    public boolean hasPlaceholder(String primaryId, String secondaryId) {
806
    public boolean hasPlaceholder(String primaryId, String secondaryId) {
988
        LayoutPart testPart;
807
    	ILayoutContainer testCont;
989
        if (secondaryId == null)
808
    	if (secondaryId == null)
990
            testPart = findPart(primaryId);
809
    		testCont = perspective.findContainer(primaryId); 
991
        else
810
        else
992
            testPart = findPart(primaryId, secondaryId);
811
        	testCont = perspective
993
        return (testPart != null && testPart instanceof PartPlaceholder);
812
				.findContainer(primaryId + ViewFactory.ID_SEP + secondaryId);
813
    	return (testCont != null);
994
    }
814
    }
995
815
996
    /**
816
    /**
Lines 1000-1018 Link Here
1000
        return mainLayout;
820
        return mainLayout;
1001
    }
821
    }
1002
822
1003
    ///**
1004
    // * Returns the zoomed part.
1005
    // * <p>
1006
    // * If the zoomed part is an editor, it will be the
1007
    // * editor which caused the workbook it is in to be zoomed. It may not be
1008
    // the
1009
    // * visible editor. The zoomed part will always be an editor in the zoomed
1010
    // * workbench.
1011
    // * </p>
1012
    // */
1013
    ///*package*/ IWorkbenchPart getZoomPart() {
1014
    //	return zoomPart;
1015
    //}
1016
    /**
823
    /**
1017
     * Gets the active state.
824
     * Gets the active state.
1018
     */
825
     */
Lines 1082-1087 Link Here
1082
    }
889
    }
1083
890
1084
    /**
891
    /**
892
     * Returns an immediate child of this perspective helper that directly or indirectly
893
     * contains the given pane. Returns null if none. 
894
     * 
895
     * @param toFind
896
     * @return
897
     */
898
    protected ILayoutContainer getLocation(PartPane toFind) {
899
    	ILayoutContainer container;
900
    	if(toFind == null || toFind.getContainer() == null) {
901
    		return mainLayout;
902
    	}
903
    	for (container = toFind.getContainer(); container.getContainer() != null;
904
    		container = container.getContainer()) {
905
    		//do nothing
906
    	}
907
    	
908
    	return container;
909
    }
910
911
    /**
1085
     * Remove all references to a part.
912
     * Remove all references to a part.
1086
     */
913
     */
1087
    public void removePart(LayoutPart part) {
914
    public void removePart(LayoutPart part) {
Lines 1096-1199 Link Here
1096
        // Replace part with a placeholder
923
        // Replace part with a placeholder
1097
        ILayoutContainer container = part.getContainer();
924
        ILayoutContainer container = part.getContainer();
1098
        if (container != null) {
925
        if (container != null) {
1099
            String placeHolderId = part.getPlaceHolderId();
926
        	if(container instanceof PartStack && part instanceof PartPane) {
1100
            container.replace(part, new PartPlaceholder(placeHolderId));
927
        			ILayoutContainer rootContainer = getLocation((PartPane)part);
1101
928
        			if (rootContainer != null) {
1102
            // If the parent is root we're done. Do not try to replace
929
        				perspective.addPlaceholder(part.getCompoundId(), rootContainer);
1103
            // it with placeholder.
930
        				rootContainer.remove(part);
1104
            if (container == mainLayout)
931
        			}
1105
                return;
932
        	}
1106
933
        	
1107
            // If the parent is empty replace it with a placeholder.
934
        	if(container instanceof FastViewBar) {
1108
            LayoutPart[] children = container.getChildren();
935
        		container.remove(part);
1109
            if (children != null) {
936
        	}
1110
                boolean allInvisible = true;
1111
                for (int i = 0, length = children.length; i < length; i++) {
1112
                    if (!(children[i] instanceof PartPlaceholder)) {
1113
                        allInvisible = false;
1114
                        break;
1115
                    }
1116
                }
1117
                if (allInvisible && (container instanceof LayoutPart)) {
1118
                    // what type of window are we in?
1119
                    LayoutPart cPart = (LayoutPart) container;
1120
                    Window oldWindow = cPart.getWindow();
1121
                    if (oldWindow instanceof WorkbenchWindow) {
1122
                        // PR 1GDFVBY: ViewStack not disposed when page
1123
                        // closed.
1124
                        if (container instanceof ViewStack)
1125
                            ((ViewStack) container).dispose();
1126
1127
                        // replace the real container with a
1128
                        // ContainerPlaceholder
1129
                        ILayoutContainer parentContainer = cPart.getContainer();
1130
                        ContainerPlaceholder placeholder = new ContainerPlaceholder(
1131
                                cPart.getID());
1132
                        placeholder.setRealContainer(container);
1133
                        parentContainer.replace(cPart, placeholder);
1134
                    } else if (oldWindow instanceof DetachedWindow) {
1135
                        DetachedPlaceHolder placeholder = new DetachedPlaceHolder(
1136
                                "", oldWindow.getShell().getBounds()); //$NON-NLS-1$
1137
                        for (int i = 0, length = children.length; i < length; i++) {
1138
                            children[i].getContainer().remove(children[i]);
1139
                            children[i].setContainer(placeholder);
1140
                            placeholder.add(children[i]);
1141
                        }
1142
                        detachedPlaceHolderList.add(placeholder);
1143
                        oldWindow.close();
1144
                        detachedWindowList.remove(oldWindow);
1145
                    }
1146
                }
1147
            }
1148
        }
937
        }
1149
    }
938
    }
1150
939
1151
    /**
1152
     * Add a part to the presentation.
1153
     * 
1154
     * Note: unlike all other LayoutParts, PartPlaceholders will still point to
1155
     * their parent container even when it is inactive. This method relies on this
1156
     * fact to locate the parent.
1157
     */
1158
    public void replacePlaceholderWithPart(LayoutPart part) {
1159
        // If part added / removed always zoom out.
1160
        if (isZoomed())
1161
            zoomOut();
1162
940
1163
        // Look for a PartPlaceholder that will tell us how to position this
941
    private void restorePlaceholderBranch(IMemento rootMemento, ILayoutContainer container) {
1164
        // object
942
        IMemento placeholders = rootMemento.getChild(IWorkbenchConstants.TAG_PLACEHOLDERS);
1165
        PartPlaceholder[] placeholders = collectPlaceholders();
943
        if(placeholders != null) {
1166
        for (int i = 0, length = placeholders.length; i < length; i++) {
944
	        IMemento[] fPlaceholders = placeholders.getChildren(IWorkbenchConstants.TAG_PAGE);
1167
            if (placeholders[i].getCompoundId().equals(part.getCompoundId())) {
945
	        for(int i = 0; i < fPlaceholders.length; i++){
1168
                // found a matching placeholder which we can replace with the
946
	            perspective.addPlaceholder(fPlaceholders[i].getString
1169
                // new View
947
	                (IWorkbenchConstants.TAG_CONTENT), container);
1170
                ILayoutContainer container = placeholders[i].getContainer();
948
	        }
1171
                if (container != null) {
1172
                    if (container instanceof ContainerPlaceholder) {
1173
                        // One of the children is now visible so replace the
1174
                        // ContainerPlaceholder with the real container
1175
                        ContainerPlaceholder containerPlaceholder = (ContainerPlaceholder) container;
1176
                        ILayoutContainer parentContainer = containerPlaceholder
1177
                                .getContainer();
1178
                        container = (ILayoutContainer) containerPlaceholder
1179
                                .getRealContainer();
1180
                        if (container instanceof LayoutPart) {
1181
                            parentContainer.replace(containerPlaceholder,
1182
                                    (LayoutPart) container);
1183
                        }
1184
                        containerPlaceholder.setRealContainer(null);
1185
                    }
1186
                    container.replace(placeholders[i], part);
1187
                    return;
1188
                }
1189
            }
1190
        }
949
        }
1191
1192
        // If there was no placeholder then the editor workbook is not in the
1193
        // workbench.
1194
        // That's OK. Just return.
1195
    }
950
    }
1196
951
    
1197
    /**
952
    /**
1198
     * @see IPersistablePart
953
     * @see IPersistablePart
1199
     */
954
     */
Lines 1202-1208 Link Here
1202
        IMemento childMem = memento
957
        IMemento childMem = memento
1203
                .getChild(IWorkbenchConstants.TAG_MAIN_WINDOW);
958
                .getChild(IWorkbenchConstants.TAG_MAIN_WINDOW);
1204
        IStatus r = mainLayout.restoreState(childMem);
959
        IStatus r = mainLayout.restoreState(childMem);
1205
960
        restorePlaceholderBranch(childMem, mainLayout);
961
                 
1206
        // Restore each floating window.
962
        // Restore each floating window.
1207
        if (detachable) {
963
        if (detachable) {
1208
            IMemento detachedWindows[] = memento
964
            IMemento detachedWindows[] = memento
Lines 1211-1229 Link Here
1211
                DetachedWindow win = new DetachedWindow(page);
967
                DetachedWindow win = new DetachedWindow(page);
1212
                detachedWindowList.add(win);
968
                detachedWindowList.add(win);
1213
                win.restoreState(detachedWindows[nX]);
969
                win.restoreState(detachedWindows[nX]);
1214
            }
970
                restorePlaceholderBranch(detachedWindows[nX], win);
1215
            IMemento childrenMem[] = memento
1216
                    .getChildren(IWorkbenchConstants.TAG_HIDDEN_WINDOW);
1217
            for (int i = 0, length = childrenMem.length; i < length; i++) {
1218
                DetachedPlaceHolder holder = new DetachedPlaceHolder(
1219
                        "", new Rectangle(0, 0, 0, 0)); //$NON-NLS-1$
1220
                holder.restoreState(childrenMem[i]);
1221
                detachedPlaceHolderList.add(holder);
1222
            }
971
            }
1223
        }
972
        }
973
        
974
        // restore the fast view bar placeholders 
975
        childMem = memento
976
        	.getChild(IWorkbenchConstants.TAG_FASTVIEWBAR);
977
        if(childMem != null) {
978
            restorePlaceholderBranch(childMem, ((WorkbenchWindow)page.getWorkbenchWindow()).getFastViewBar());
979
        }
1224
        return r;
980
        return r;
1225
981
1226
    }
982
    }
983
    
984
    private void savePlaceholderBranch(IMemento rootMemento, ILayoutContainer container) {
985
        //make placeholders for all the visible views
986
        LayoutPart[] parts = container.getChildren();
987
        for(int n = 0; n < parts.length; n++) {
988
        	if(parts[n] instanceof ViewStack) {
989
        		LayoutPart[] folderParts = ((ViewStack)parts[n]).getChildren();
990
        		for(int m = 0; m < folderParts.length; m++) {
991
        			perspective.addPlaceholder(folderParts[m].getCompoundId(), container);
992
        		}
993
        	}
994
        	else if (container instanceof DetachedWindow) {
995
        	    perspective.addPlaceholder(parts[n].getCompoundId(), container);
996
        	}
997
        }
998
        
999
        String[] placeholders = perspective.getAssociatedParts(container);
1000
        IMemento placeholderMem = rootMemento.createChild(IWorkbenchConstants.TAG_PLACEHOLDERS);
1001
        for(int i = 0; i < placeholders.length; i++){
1002
            IMemento phChild = placeholderMem.createChild(IWorkbenchConstants.TAG_PAGE);
1003
            phChild.putString(IWorkbenchConstants.TAG_CONTENT, placeholders[i]);          
1004
        }
1005
    }
1227
1006
1228
    /**
1007
    /**
1229
     * @see IPersistablePart
1008
     * @see IPersistablePart
Lines 1233-1238 Link Here
1233
        IMemento childMem = memento
1012
        IMemento childMem = memento
1234
                .createChild(IWorkbenchConstants.TAG_MAIN_WINDOW);
1013
                .createChild(IWorkbenchConstants.TAG_MAIN_WINDOW);
1235
        IStatus r = mainLayout.saveState(childMem);
1014
        IStatus r = mainLayout.saveState(childMem);
1015
        savePlaceholderBranch(childMem, mainLayout);
1236
1016
1237
        if (detachable) {
1017
        if (detachable) {
1238
            // Persist each detached window.
1018
            // Persist each detached window.
Lines 1242-1256 Link Here
1242
                childMem = memento
1022
                childMem = memento
1243
                        .createChild(IWorkbenchConstants.TAG_DETACHED_WINDOW);
1023
                        .createChild(IWorkbenchConstants.TAG_DETACHED_WINDOW);
1244
                window.saveState(childMem);
1024
                window.saveState(childMem);
1245
            }
1025
                savePlaceholderBranch(childMem, window);
1246
            for (int i = 0, length = detachedPlaceHolderList.size(); i < length; i++) {
1247
                DetachedPlaceHolder holder = (DetachedPlaceHolder) detachedPlaceHolderList
1248
                        .get(i);
1249
                childMem = memento
1250
                        .createChild(IWorkbenchConstants.TAG_HIDDEN_WINDOW);
1251
                holder.saveState(childMem);
1252
            }
1026
            }
1253
        }
1027
        }
1028
        
1029
        //Save the fastviewbar
1030
        childMem = memento
1031
        	.createChild(IWorkbenchConstants.TAG_FASTVIEWBAR);
1032
        savePlaceholderBranch(childMem, ((WorkbenchWindow)page.getWorkbenchWindow()).getFastViewBar());
1033
        
1254
        return r;
1034
        return r;
1255
    }
1035
    }
1256
1036
Lines 1275-1284 Link Here
1275
                    //TODO: Remove once all views are in ViewStack
1055
                    //TODO: Remove once all views are in ViewStack
1276
                    //TODO: See Bug 48794
1056
                    //TODO: See Bug 48794
1277
                    ViewStack parent = (ViewStack) parentContainer;
1057
                    ViewStack parent = (ViewStack) parentContainer;
1278
                    Perspective persp = page.getActivePerspective();
1058
                    if (perspective != null && ref instanceof IViewReference
1279
                    if (persp != null && ref instanceof IViewReference
1280
                            && page.isFastView((IViewReference) ref)) {
1059
                            && page.isFastView((IViewReference) ref)) {
1281
                        persp.hideFastViewSash();
1060
                        perspective.hideFastViewSash();
1282
                    }
1061
                    }
1283
                    mainLayout.zoomIn(parent);
1062
                    mainLayout.zoomIn(parent);
1284
                    pane.setZoomed(true);
1063
                    pane.setZoomed(true);
Lines 1324-1333 Link Here
1324
            parentWidget.setRedraw(false);
1103
            parentWidget.setRedraw(false);
1325
            mainLayout.zoomOut();
1104
            mainLayout.zoomOut();
1326
            pane.setZoomed(false);
1105
            pane.setZoomed(false);
1327
            Perspective persp = page.getActivePerspective();
1106
            if (perspective != null && zoomPart instanceof IViewReference
1328
            if (persp != null && zoomPart instanceof IViewReference
1329
                    && page.isFastView((IViewReference) zoomPart)) {
1107
                    && page.isFastView((IViewReference) zoomPart)) {
1330
                persp.showFastView((IViewReference) zoomPart);
1108
                perspective.showFastView((IViewReference) zoomPart);
1331
            }
1109
            }
1332
            parentWidget.setRedraw(true);
1110
            parentWidget.setRedraw(true);
1333
        } else if (pane instanceof EditorPane) {
1111
        } else if (pane instanceof EditorPane) {
(-)Eclipse UI/org/eclipse/ui/internal/PlaceholderFolderLayout.java (-65 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2004 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials 
4
 * are made available under the terms of the Common Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/cpl-v10.html
7
 * 
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.ui.internal;
12
13
import org.eclipse.ui.IPlaceholderFolderLayout;
14
15
/**
16
 * This layout is used to define the initial set of placeholders
17
 * in a placeholder.
18
 * <p>
19
 * Views are added to the placeholder by ID. This id is used to identify 
20
 * a view descriptor in the view registry, and this descriptor is used to 
21
 * instantiate the IViewPart.
22
 * </p>
23
 */
24
public class PlaceholderFolderLayout implements IPlaceholderFolderLayout {
25
    private PageLayout pageLayout;
26
27
    private ContainerPlaceholder placeholder;
28
29
    public PlaceholderFolderLayout(PageLayout pageLayout,
30
            ContainerPlaceholder folder) {
31
        super();
32
        this.placeholder = folder;
33
        this.pageLayout = pageLayout;
34
    }
35
36
    /**
37
     * @see IPlaceholderFolderLayout
38
     */
39
    public void addPlaceholder(String viewId) {
40
        if (!pageLayout.checkValidPlaceholderId(viewId)) {
41
            return;
42
        }
43
44
        // Create the placeholder.
45
        LayoutPart newPart = new PartPlaceholder(viewId);
46
47
        linkPartToPageLayout(viewId, newPart);
48
49
        // Add it to the placeholder layout.
50
        placeholder.add(newPart);
51
    }
52
53
    /**
54
     * Inform the page layout of the new part created
55
     * and the placeholder the part belongs to.
56
     */
57
    private void linkPartToPageLayout(String viewId, LayoutPart newPart) {
58
        pageLayout.setRefPart(viewId, newPart);
59
        // force creation of the view layout rec
60
        pageLayout.getViewLayoutRec(viewId, true);
61
62
        pageLayout.setFolderPart(viewId, placeholder);
63
        newPart.setContainer(placeholder);
64
    }
65
}
(-)Eclipse UI/org/eclipse/ui/internal/ViewSashContainer.java (-11 / +64 lines)
Lines 18-29 Link Here
18
import org.eclipse.swt.widgets.Composite;
18
import org.eclipse.swt.widgets.Composite;
19
import org.eclipse.swt.widgets.Control;
19
import org.eclipse.swt.widgets.Control;
20
import org.eclipse.ui.IMemento;
20
import org.eclipse.ui.IMemento;
21
import org.eclipse.ui.IPageLayout;
21
import org.eclipse.ui.PlatformUI;
22
import org.eclipse.ui.PlatformUI;
23
import org.eclipse.ui.internal.util.Util;
22
24
23
/**
25
/**
24
 * Represents the top level container.
26
 * Represents the top level container.
25
 */
27
 */
26
public class ViewSashContainer extends PartSashContainer {
28
public class ViewSashContainer extends PartSashContainer {
29
	
30
	private LayoutPart editorHolder;
31
	
32
	private LayoutPart editorArea;
33
	
27
    public ViewSashContainer(WorkbenchPage page) {
34
    public ViewSashContainer(WorkbenchPage page) {
28
        super("root layout container", page);//$NON-NLS-1$
35
        super("root layout container", page);//$NON-NLS-1$
29
    }
36
    }
Lines 131-147 Link Here
131
138
132
            // Create the part.
139
            // Create the part.
133
            LayoutPart part = null;
140
            LayoutPart part = null;
134
            if (strFolder == null)
141
            if (strFolder == null) {
135
                part = new PartPlaceholder(partID);
142
            	if(partID.equals(IPageLayout.ID_EDITOR_AREA)) {
143
            	//Old style placeholder only used by editor. Okay.
144
            		part = new PartPlaceholder(partID);
145
            	}
146
            	else {
147
                //This branch only gets excercised when running a old style placeholder
148
            	//workbench. This converts the old placeholder to a new one. 
149
                    ViewStack folder = new ViewStack(page);
150
                    addPlaceholder(partID, folder);
151
                    part = folder;
152
153
            	}
154
            }
136
            else {
155
            else {
137
                ViewStack folder = new ViewStack(page);
156
                ViewStack folder = new ViewStack(page);
138
                folder.setID(partID);
157
                folder.setID(partID);
158
                IMemento[] placeholders = childMem
159
            		.getChildren(IWorkbenchConstants.TAG_FOLDER);
160
                for(int j = 0; j < placeholders.length; j++){
161
	                IMemento[] folderPlaceholders = placeholders[j]
162
	                        .getChildren(IWorkbenchConstants.TAG_PAGE);
163
	                for(int k = 0; k < folderPlaceholders.length; k++){
164
	                    addPlaceholder(folderPlaceholders[k].getString
165
	                            (IWorkbenchConstants.TAG_CONTENT), folder);
166
                	}
167
            	}
168
                
139
                result.add(folder.restoreState(childMem
169
                result.add(folder.restoreState(childMem
140
                        .getChild(IWorkbenchConstants.TAG_FOLDER)));
170
                        .getChild(IWorkbenchConstants.TAG_FOLDER)));
141
                ContainerPlaceholder placeholder = new ContainerPlaceholder(
171
                part = folder;
142
                        partID);
143
                placeholder.setRealContainer(folder);
144
                part = placeholder;
145
            }
172
            }
146
            // 1FUN70C: ITPUI:WIN - Shouldn't set Container when not active
173
            // 1FUN70C: ITPUI:WIN - Shouldn't set Container when not active
147
            part.setContainer(this);
174
            part.setContainer(this);
Lines 162-167 Link Here
162
                }
189
                }
163
            }
190
            }
164
            mapIDtoPart.put(partID, part);
191
            mapIDtoPart.put(partID, part);
192
            if(Util.equals(part.getCompoundId(),IPageLayout.ID_EDITOR_AREA)) {
193
            	editorHolder = part;
194
            }
165
        }
195
        }
166
        return result;
196
        return result;
167
    }
197
    }
Lines 210-220 Link Here
210
            ViewStack folder = null;
240
            ViewStack folder = null;
211
            if (info.part instanceof ViewStack) {
241
            if (info.part instanceof ViewStack) {
212
                folder = (ViewStack) info.part;
242
                folder = (ViewStack) info.part;
213
            } else if (info.part instanceof ContainerPlaceholder) {
214
                LayoutPart part = ((ContainerPlaceholder) info.part)
215
                        .getRealContainer();
216
                if (part instanceof ViewStack)
217
                    folder = (ViewStack) part;
218
            }
243
            }
219
244
220
            // If this is a folder save the contents.
245
            // If this is a folder save the contents.
Lines 222-227 Link Here
222
                childMem.putString(IWorkbenchConstants.TAG_FOLDER, "true");//$NON-NLS-1$
247
                childMem.putString(IWorkbenchConstants.TAG_FOLDER, "true");//$NON-NLS-1$
223
                IMemento folderMem = childMem
248
                IMemento folderMem = childMem
224
                        .createChild(IWorkbenchConstants.TAG_FOLDER);
249
                        .createChild(IWorkbenchConstants.TAG_FOLDER);
250
                
251
                //make placeholders for all the visible views
252
                LayoutPart[] parts = folder.getChildren();
253
                for(int n = 0; n < parts.length; n++) {
254
                	addPlaceholder(parts[n].getCompoundId(), folder);
255
                }
256
                
257
                //Add all the invisible views in the folder
258
                if(hasPlaceholders(folder)){
259
                	String[] placeholders = getPlaceholdersFor(folder);
260
                	for (int j = 0; j < placeholders.length; j++) {
261
						String id = placeholders[j];
262
						
263
                        IMemento phChild = folderMem
264
                    		.createChild(IWorkbenchConstants.TAG_PAGE);
265
                        phChild.putString(IWorkbenchConstants.TAG_CONTENT, id);
266
					}
267
                }
268
225
                result.add(folder.saveState(folderMem));
269
                result.add(folder.saveState(folderMem));
226
            }
270
            }
227
        }
271
        }
Lines 310-315 Link Here
310
        }
354
        }
311
355
312
        super.addChild(info);
356
        super.addChild(info);
357
    }
358
    
359
    protected void addEditorArea(LayoutPart editorArea) {
360
    	this.editorArea = editorArea;
361
    	replace(editorHolder, editorArea);	
362
    }
363
    
364
    protected void removeEditorArea() {
365
    	replace(editorArea, editorHolder);
313
    }
366
    }
314
367
315
    /* (non-Javadoc)
368
    /* (non-Javadoc)
(-)Eclipse UI/org/eclipse/ui/internal/ViewStack.java (+9 lines)
Lines 14-19 Link Here
14
14
15
import org.eclipse.jface.action.IMenuManager;
15
import org.eclipse.jface.action.IMenuManager;
16
import org.eclipse.ui.internal.presentations.PresentationFactoryUtil;
16
import org.eclipse.ui.internal.presentations.PresentationFactoryUtil;
17
import org.eclipse.ui.internal.presentations.SystemMenuDetach;
17
import org.eclipse.ui.internal.presentations.SystemMenuFastView;
18
import org.eclipse.ui.internal.presentations.SystemMenuFastView;
18
import org.eclipse.ui.internal.presentations.SystemMenuSize;
19
import org.eclipse.ui.internal.presentations.SystemMenuSize;
19
import org.eclipse.ui.internal.presentations.UpdatingActionContributionItem;
20
import org.eclipse.ui.internal.presentations.UpdatingActionContributionItem;
Lines 41-50 Link Here
41
    private SystemMenuSize sizeItem = new SystemMenuSize(null);
42
    private SystemMenuSize sizeItem = new SystemMenuSize(null);
42
43
43
    private SystemMenuFastView fastViewAction;
44
    private SystemMenuFastView fastViewAction;
45
    
44
46
47
    private SystemMenuDetach detachViewAction;
48
    
45
    public void addSystemActions(IMenuManager menuManager) {
49
    public void addSystemActions(IMenuManager menuManager) {
46
        appendToGroupIfPossible(menuManager,
50
        appendToGroupIfPossible(menuManager,
47
                "misc", new UpdatingActionContributionItem(fastViewAction)); //$NON-NLS-1$
51
                "misc", new UpdatingActionContributionItem(fastViewAction)); //$NON-NLS-1$
52
        appendToGroupIfPossible(menuManager,
53
        		"misc", new UpdatingActionContributionItem(detachViewAction)); //$NON-NLS-1$
48
        sizeItem = new SystemMenuSize((PartPane) getVisiblePart());
54
        sizeItem = new SystemMenuSize((PartPane) getVisiblePart());
49
        appendToGroupIfPossible(menuManager, "size", sizeItem); //$NON-NLS-1$
55
        appendToGroupIfPossible(menuManager, "size", sizeItem); //$NON-NLS-1$
50
    }
56
    }
Lines 67-72 Link Here
67
73
68
        this.allowStateChanges = allowsStateChanges;
74
        this.allowStateChanges = allowsStateChanges;
69
        fastViewAction = new SystemMenuFastView(getPresentationSite());
75
        fastViewAction = new SystemMenuFastView(getPresentationSite());
76
        detachViewAction = new SystemMenuDetach(getPresentationSite());
70
    }
77
    }
71
78
72
    protected WorkbenchPage getPage() {
79
    protected WorkbenchPage getPage() {
Lines 94-99 Link Here
94
        }
101
        }
95
102
96
        fastViewAction.setPane(pane);
103
        fastViewAction.setPane(pane);
104
105
        detachViewAction.setPane(pane);
97
        sizeItem.setPane(pane);
106
        sizeItem.setPane(pane);
98
    }
107
    }
99
108
(-)Eclipse UI/org/eclipse/ui/internal/WorkbenchPage.java (-2 / +13 lines)
Lines 2354-2363 Link Here
2354
                pane);
2354
                pane);
2355
    }
2355
    }
2356
2356
2357
    public void reattachFastView(IViewReference ref) {
2358
        Perspective persp = getActivePerspective();
2359
        if (persp == null)
2360
            return;
2361
    	
2362
    	removeFastView(ref);
2363
		WorkbenchPartReference viewRef = (WorkbenchPartReference) ref;
2364
		
2365
		persp.getPresentation().addPart(viewRef.getPane());
2366
    }
2367
    
2357
    /**
2368
    /**
2358
     * Removes a fast view.
2369
     * Removes a fast view.
2359
     */
2370
     */
2360
    public void removeFastView(IViewReference ref) {
2371
    /* package */ void removeFastView(IViewReference ref) {
2361
        Perspective persp = getActivePerspective();
2372
        Perspective persp = getActivePerspective();
2362
        if (persp == null)
2373
        if (persp == null)
2363
            return;
2374
            return;
Lines 2662-2668 Link Here
2662
        if (persp == null)
2673
        if (persp == null)
2663
            return;
2674
            return;
2664
        IPerspectiveDescriptor oldDesc = persp.getDesc();
2675
        IPerspectiveDescriptor oldDesc = persp.getDesc();
2665
2676
        
2666
        // Always unzoom.
2677
        // Always unzoom.
2667
        if (isZoomed())
2678
        if (isZoomed())
2668
            zoomOut();
2679
            zoomOut();
(-)Eclipse (+105 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2004 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials 
4
 * are made available under the terms of the Common Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/cpl-v10.html
7
 * 
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.ui.internal;
12
13
import java.util.ArrayList;
14
import java.util.HashMap;
15
import java.util.Iterator;
16
import java.util.Map;
17
import java.util.Set;
18
19
/**
20
 * Holds a map of placeholder IDs onto ILayoutContainers. Placeholder IDs may contain
21
 * the * wildcard for the primary or secondary ID.
22
 * 
23
 * @since 3.1
24
 */
25
public class PlaceholderMap {
26
	private Map map = new HashMap(5);
27
	
28
	public PlaceholderMap() {
29
		
30
	}
31
	
32
	public void put(String compoundId, ILayoutContainer stack) {
33
		map.put(compoundId, stack);
34
	}
35
	
36
	public ILayoutContainer get(String id) {
37
        ILayoutContainer found = (ILayoutContainer)map.get(id);
38
        
39
		if(found != null)
40
			return found;
41
			
42
		//there's no exact match, check for wildcard matches in order of 
43
		//similarity
44
		
45
		String secondaryId = ViewFactory.extractSecondaryId(id);
46
		
47
		if(secondaryId != null) {
48
			id = ViewFactory.extractPrimaryId(id);
49
		}
50
		
51
		found = (ILayoutContainer)map
52
			.get(id + ViewFactory.ID_SEP + PartPlaceholder.WILD_CARD);
53
		if(found != null)
54
			return found;
55
		
56
		
57
		found = (ILayoutContainer)map
58
			.get(PartPlaceholder.WILD_CARD + ViewFactory.ID_SEP + secondaryId);
59
		if(found != null)
60
			return found;	    
61
		
62
		found = (ILayoutContainer)map
63
			.get(PartPlaceholder.WILD_CARD);
64
		return found; 
65
	}
66
	
67
	public String[] getPlaceholdersFor(ILayoutContainer c) {
68
        ArrayList found = new ArrayList();
69
        if(map.containsValue(c)){
70
	        Set keys = map.keySet();
71
	        Iterator iter = keys.iterator();
72
	        while (iter.hasNext()) {
73
	            Object key = iter.next();
74
	            if(map.get(key) == c){
75
	                found.add(key);
76
	            }
77
	        }
78
        }
79
        
80
        return (String[]) found.toArray(new String[found.size()]); 
81
	}
82
	
83
	public boolean hasPlaceholderFor(ILayoutContainer c) {
84
		return map.containsValue(c);
85
	}
86
	
87
	public void remove(String placeholderId) {
88
		map.remove(placeholderId);
89
	}
90
	
91
	public void removePlaceholdersFor(ILayoutContainer c) {
92
		String[] placeholders = getPlaceholdersFor(c);
93
		
94
		for (int i = 0; i < placeholders.length; i++) {
95
			String string = placeholders[i];
96
			
97
			remove(string);
98
		}
99
	}
100
	
101
	public void clear() {
102
		map.clear();
103
	}
104
	
105
}

Return to bug 72060