Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 52703 Details for
Bug 153957
[FastViews] Create Multiple FVB's
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
Patch for code committed into M3
patch(FastMinMax-M3).txt (text/plain), 85.08 KB, created by
Eric Moffatt
on 2006-10-25 16:17:07 EDT
(
hide
)
Description:
Patch for code committed into M3
Filename:
MIME Type:
Creator:
Eric Moffatt
Created:
2006-10-25 16:17:07 EDT
Size:
85.08 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.ui.workbench >Index: Eclipse UI/org/eclipse/ui/internal/EditorSashContainer.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/EditorSashContainer.java,v >retrieving revision 1.17 >diff -u -r1.17 EditorSashContainer.java >--- Eclipse UI/org/eclipse/ui/internal/EditorSashContainer.java 8 May 2006 20:55:36 -0000 1.17 >+++ Eclipse UI/org/eclipse/ui/internal/EditorSashContainer.java 25 Oct 2006 20:17:44 -0000 >@@ -25,6 +25,7 @@ > import org.eclipse.swt.widgets.Control; > import org.eclipse.ui.IMemento; > import org.eclipse.ui.PlatformUI; >+import org.eclipse.ui.internal.layout.ITrimManager; > import org.eclipse.ui.internal.presentations.PresentationSerializer; > import org.eclipse.ui.presentations.StackPresentation; > >@@ -307,7 +308,13 @@ > } > mapIDtoPart.put(partID, workbook); > } >- return result; >+ >+ // Trim Stack Support >+ Integer trimState = memento.getInteger(IWorkbenchConstants.TAG_PART_TRIMSTATE); >+ if (trimState != null && trimState.intValue() != LayoutPart.TRIMSTATE_NORMAL) >+ setTrimState(trimState.intValue()); >+ >+ return result; > } > > /** >@@ -353,6 +360,11 @@ > .getRatio()); > } > } >+ >+ // Trim Stack Support >+ if (getTrimState() != LayoutPart.TRIMSTATE_NORMAL) >+ memento.putInteger(IWorkbenchConstants.TAG_PART_TRIMSTATE, getTrimState()); >+ > return result; > } > >@@ -531,4 +543,54 @@ > } > return new Status(IStatus.OK, PlatformUI.PLUGIN_ID, 0, "", null); //$NON-NLS-1$ > } >+ >+ // Trim Stack Support >+ public void setTrimState(int newTrimState) { >+ if (newTrimState == getTrimState()) >+ return; >+ >+ // Remember the new state >+ int oldTrimState = getTrimState(); >+ >+ // set the new one >+ super.setTrimState(newTrimState); >+ >+ WorkbenchWindow wbw = (WorkbenchWindow) getWorkbenchWindow(); >+ if (wbw == null) >+ return; >+ >+ // Access workbench context >+ Perspective persp = page.getActivePerspective(); >+ ITrimManager tbm = wbw.getTrimManager(); >+ EditorAreaTrimPart viewStackTrim = (EditorAreaTrimPart) tbm.getTrim(getID()); >+ >+ // NOTE: The part visibility is handled by the Perspective >+ // for legacy reasons. All this does is show/hide the trim... >+ >+ // Are we moving the View Stack -to- the trim? >+ if (oldTrimState == LayoutPart.TRIMSTATE_NORMAL) { >+ // Is it already in the trim? >+ if (viewStackTrim == null) { >+ // If it's not already in the trim...create it >+ int side = SWT.BOTTOM; >+ if (persp != null) >+ side = persp.calcStackSide(getBounds()); >+ >+ viewStackTrim = new EditorAreaTrimPart(wbw, this); >+ viewStackTrim.dock(side); >+ tbm.addTrim(side, viewStackTrim); >+ } >+ >+ tbm.setTrimVisible(viewStackTrim, true); >+ } >+ >+ // Are we restoring the View Stack -from- the trim? >+ if (newTrimState == LayoutPart.TRIMSTATE_NORMAL) { >+ if (viewStackTrim == null) >+ return; >+ >+ // hide the trim widget >+ tbm.setTrimVisible(viewStackTrim, false); >+ } >+ } > } >Index: Eclipse UI/org/eclipse/ui/internal/IWorkbenchConstants.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/IWorkbenchConstants.java,v >retrieving revision 1.73 >diff -u -r1.73 IWorkbenchConstants.java >--- Eclipse UI/org/eclipse/ui/internal/IWorkbenchConstants.java 15 Sep 2006 13:41:35 -0000 1.73 >+++ Eclipse UI/org/eclipse/ui/internal/IWorkbenchConstants.java 25 Oct 2006 20:17:44 -0000 >@@ -118,6 +118,8 @@ > > public static final String TAG_PART_NAME = "partName"; //$NON-NLS-1$ > >+ public static final String TAG_PART_TRIMSTATE = "inTrim"; //$NON-NLS-1$ >+ > public static final String TAG_RELATIVE = "relative"; //$NON-NLS-1$ > > public static final String TAG_RELATIONSHIP = "relationship"; //$NON-NLS-1$ >Index: Eclipse UI/org/eclipse/ui/internal/ViewSashContainer.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/ViewSashContainer.java,v >retrieving revision 1.12 >diff -u -r1.12 ViewSashContainer.java >--- Eclipse UI/org/eclipse/ui/internal/ViewSashContainer.java 8 May 2006 20:55:38 -0000 1.12 >+++ Eclipse UI/org/eclipse/ui/internal/ViewSashContainer.java 25 Oct 2006 20:17:45 -0000 >@@ -10,7 +10,10 @@ > *******************************************************************************/ > package org.eclipse.ui.internal; > >+import java.util.ArrayList; > import java.util.HashMap; >+import java.util.Iterator; >+import java.util.List; > import java.util.Map; > > import org.eclipse.core.runtime.IStatus; >@@ -19,6 +22,8 @@ > import org.eclipse.swt.widgets.Control; > import org.eclipse.ui.IMemento; > import org.eclipse.ui.PlatformUI; >+import org.eclipse.ui.internal.layout.ITrimManager; >+import org.eclipse.ui.internal.layout.IWindowTrim; > > /** > * Represents the top level container. >@@ -197,9 +202,10 @@ > } > } > >- // If this is a folder save the contents. >+ // If this is a folder (ViewStack) save the contents. > if (folder != null) { > childMem.putString(IWorkbenchConstants.TAG_FOLDER, "true");//$NON-NLS-1$ >+ > IMemento folderMem = childMem > .createChild(IWorkbenchConstants.TAG_FOLDER); > result.add(folder.saveState(folderMem)); >@@ -304,4 +310,66 @@ > > super.replace(oldChild, newChild); > } >+ >+ // Trim Stack Support >+ >+ /** >+ * Restore any parts that are in the trim due >+ * to a zoom (maximize) operation >+ */ >+ public boolean restoreZoomedTrimParts() { >+ boolean needsLayout = false; >+ LayoutPart[] children = getChildren(); >+ for (int i = 0; i < children.length; i++) { >+ if (children[i].getTrimState() == LayoutPart.TRIMSTATE_ZOOMEDTOTRIM) { >+ // All parts in the trim must have placeholders >+ if (children[i] instanceof PartPlaceholder) { >+ // restore the part from the trim >+ PartPlaceholder ph = (PartPlaceholder) children[i]; >+ ph.setTrimState(LayoutPart.TRIMSTATE_NORMAL); >+ needsLayout = true; >+ } >+ } >+ } >+ >+ return needsLayout; >+ } >+ >+ /** >+ * @return A list containibg all trim representing a LayoutPart >+ */ >+ public List getTrimForParts() { >+ List trim = new ArrayList(); >+ >+ // If a part is in the trim then get the trim element using the part's >+ // id >+ WorkbenchWindow wbw = (WorkbenchWindow) page.getWorkbenchWindow(); >+ ITrimManager tbm = wbw.getTrimManager(); >+ LayoutPart[] children = getChildren(); >+ for (int i = 0; i < children.length; i++) { >+ if (children[i].getTrimState() == LayoutPart.TRIMSTATE_IN_TRIM >+ || children[i].getTrimState() == LayoutPart.TRIMSTATE_ZOOMEDTOTRIM) { >+ IWindowTrim partTrim = tbm.getTrim(children[i].getID()); >+ if (partTrim != null) >+ trim.add(partTrim); >+ } >+ } >+ >+ return trim; >+ } >+ >+ /** >+ * Show any trim representing parts of this layout >+ * @param visible true to show the trim, false to hide it >+ */ >+ public void setTrimVisible(boolean visible) { >+ List partTrim = getTrimForParts(); >+ WorkbenchWindow wbw = (WorkbenchWindow) page.getWorkbenchWindow(); >+ ITrimManager tbm = wbw.getTrimManager(); >+ for (Iterator trimPartIter = partTrim.iterator(); trimPartIter >+ .hasNext();) { >+ IWindowTrim trimForPart = (IWindowTrim) trimPartIter.next(); >+ tbm.setTrimVisible(trimForPart, visible); >+ } >+ } > } >Index: Eclipse UI/org/eclipse/ui/internal/LayoutPart.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/LayoutPart.java,v >retrieving revision 1.49 >diff -u -r1.49 LayoutPart.java >--- Eclipse UI/org/eclipse/ui/internal/LayoutPart.java 8 May 2006 20:55:36 -0000 1.49 >+++ Eclipse UI/org/eclipse/ui/internal/LayoutPart.java 25 Oct 2006 20:17:44 -0000 >@@ -34,6 +34,13 @@ > > public static final String PROP_VISIBILITY = "PROP_VISIBILITY"; //$NON-NLS-1$ > >+ // Trim Stack Support >+ public final static int TRIMSTATE_NORMAL = 0; // 'normal'...in the presentation >+ public final static int TRIMSTATE_IN_TRIM = 1; // 'minimized'...in the trim but wont restore on an unzoom >+ public final static int TRIMSTATE_ZOOMEDTOTRIM = 2; // 'zoomed'...in the trim as a result of a 'zoom' on some other part >+ >+ protected int trimState = TRIMSTATE_NORMAL; >+ > /** > * Number of times deferUpdates(true) has been called without a corresponding > * deferUpdates(false) >@@ -485,4 +492,33 @@ > */ > public void testInvariants() { > } >+ >+ // Trim Stack Support >+ >+ /** >+ * @return Returns the trimState. >+ */ >+ public int getTrimState() { >+ return trimState; >+ } >+ >+ /** >+ * @param trimState The trimState to set. >+ */ >+ public void setTrimState(int trimState) { >+ this.trimState = trimState; >+ } >+ >+ /** >+ * Causes a layout part to refresh its state. >+ * This is called by the Perspective to cause >+ * any necessary trim to be constructed on activation >+ */ >+ public void createInitialTrim() { >+ if (trimState != LayoutPart.TRIMSTATE_NORMAL) { >+ int curState = getTrimState(); >+ trimState = LayoutPart.TRIMSTATE_NORMAL; >+ setTrimState(curState); >+ } >+ } > } >Index: Eclipse UI/org/eclipse/ui/internal/IWorkbenchGraphicConstants.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/IWorkbenchGraphicConstants.java,v >retrieving revision 1.33 >diff -u -r1.33 IWorkbenchGraphicConstants.java >--- Eclipse UI/org/eclipse/ui/internal/IWorkbenchGraphicConstants.java 24 Oct 2006 18:21:40 -0000 1.33 >+++ Eclipse UI/org/eclipse/ui/internal/IWorkbenchGraphicConstants.java 25 Oct 2006 20:17:44 -0000 >@@ -53,10 +53,12 @@ > > //Fast view enabled and disabled icons > public final static String IMG_ETOOL_NEW_FASTVIEW = "IMG_ETOOL_NEW_FASTVIEW"; //$NON-NLS-1$ >- public final static String IMG_ETOOL_RESTORE_FASTVIEW = "IMG_ETOOL_RESTORE_FASTVIEW"; //$NON-NLS-1$ >- > public final static String IMG_DTOOL_NEW_FASTVIEW = "IMG_DTOOL_NEW_FASTVIEW"; //$NON-NLS-1$ > >+ // TrimStack buttons >+ public final static String IMG_ETOOL_RESTORE_TRIMPART = "IMG_ETOOL_RESTORE_TRIMPART"; //$NON-NLS-1$ >+ public final static String IMG_ETOOL_EDITOR_TRIMPART = "IMG_ETOOL_EDITOR_TRIMPART"; //$NON-NLS-1$ >+ > // local toolbars > > public final static String IMG_LCL_CLOSE_VIEW = "IMG_LCL_CLOSE_VIEW"; //$NON-NLS-1$ >Index: Eclipse UI/org/eclipse/ui/internal/PartStack.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/PartStack.java,v >retrieving revision 1.76 >diff -u -r1.76 PartStack.java >--- Eclipse UI/org/eclipse/ui/internal/PartStack.java 14 Sep 2006 19:30:23 -0000 1.76 >+++ Eclipse UI/org/eclipse/ui/internal/PartStack.java 25 Oct 2006 20:17:45 -0000 >@@ -908,6 +908,11 @@ > String activeTabID = memento > .getString(IWorkbenchConstants.TAG_ACTIVE_PAGE_ID); > >+ // Trim Stack Support >+ Integer trimState = memento.getInteger(IWorkbenchConstants.TAG_PART_TRIMSTATE); >+ if (trimState != null && trimState.intValue() != LayoutPart.TRIMSTATE_NORMAL) >+ setTrimState(trimState.intValue()); >+ > // Read the page elements. > IMemento[] children = memento.getChildren(IWorkbenchConstants.TAG_PAGE); > if (children != null) { >@@ -1011,6 +1016,10 @@ > memento.putString(IWorkbenchConstants.TAG_ACTIVE_PAGE_ID, requestedCurrent > .getCompoundId()); > } >+ >+ // Trim Stack Support >+ if (getTrimState() != LayoutPart.TRIMSTATE_NORMAL) >+ memento.putInteger(IWorkbenchConstants.TAG_PART_TRIMSTATE, getTrimState()); > > Iterator iter = children.iterator(); > while (iter.hasNext()) { >@@ -1171,7 +1180,7 @@ > // Make a one element list to pass on > List stacks = new ArrayList(); > stacks.add(this); >- persp.moveToTrim(stacks, FastViewBar.GROUP_FVB); >+ persp.movePartsToTrim(stacks, false); > return; > } > >@@ -1485,4 +1494,17 @@ > ((IPropertyListener) listeners[i]).propertyChanged(this, id); > } > } >+ >+ // TrimStack Support >+ >+ /** >+ * Explicitly sets the presentation state. This is used by the >+ * new min/max code to force the CTabFolder to show the proper >+ * state without going through the 'setState' code (which causes >+ * nasty side-effects. >+ * @param newState The state to set the presentation to >+ */ >+ public void setPresentationState(int newState) { >+ presentationSite.setPresentationState(newState); >+ } > } >Index: Eclipse UI/org/eclipse/ui/internal/FastViewBar.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/FastViewBar.java,v >retrieving revision 1.57 >diff -u -r1.57 FastViewBar.java >--- Eclipse UI/org/eclipse/ui/internal/FastViewBar.java 17 Oct 2006 18:28:38 -0000 1.57 >+++ Eclipse UI/org/eclipse/ui/internal/FastViewBar.java 25 Oct 2006 20:17:44 -0000 >@@ -182,10 +182,8 @@ > ViewPane pane = (ViewPane) iter.next(); > IViewReference ref = pane.getViewReference(); > >- // Only allow one reference in an FVB per perspective >- FastViewBar curFVB = getPage().getActivePerspective().getFVBForRef(ref); >- if (curFVB == null && window.getFastViewBar().hasViewRef(ref)) >- curFVB = window.getFastViewBar(); >+ // Drop only occurs on the global fast view bar >+ FastViewBar curFVB = window.getFastViewBar(); > > if (curFVB != null) { > curFVB.removeViewRef(ref); >@@ -483,7 +481,7 @@ > // Construct an item to act as a 'menu button' (a la the PerspectiveSwitcher) > restoreItem = new ToolItem(menuTB, SWT.PUSH, 0); > >- Image tbImage = WorkbenchImages.getImage(IWorkbenchGraphicConstants.IMG_ETOOL_RESTORE_FASTVIEW); >+ Image tbImage = WorkbenchImages.getImage(IWorkbenchGraphicConstants.IMG_ETOOL_RESTORE_TRIMPART); > restoreItem.setImage(tbImage); > > String menuTip = WorkbenchMessages.StandardSystemToolbar_Restore; >@@ -1160,8 +1158,8 @@ > * Restore all refs and close the group > */ > public void closeGroup() { >- Perspective persp = window.getActiveWorkbenchPage().getActivePerspective(); >- persp.closeTrimGroup(this); >+// Perspective persp = window.getActiveWorkbenchPage().getActivePerspective(); >+// persp.closeTrimGroup(this); > } > > /** >Index: Eclipse UI/org/eclipse/ui/internal/ContainerPlaceholder.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/ContainerPlaceholder.java,v >retrieving revision 1.11 >diff -u -r1.11 ContainerPlaceholder.java >--- Eclipse UI/org/eclipse/ui/internal/ContainerPlaceholder.java 8 May 2006 20:55:34 -0000 1.11 >+++ Eclipse UI/org/eclipse/ui/internal/ContainerPlaceholder.java 25 Oct 2006 20:17:44 -0000 >@@ -149,4 +149,22 @@ > public boolean childIsZoomed(LayoutPart toTest) { > return false; > } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.ui.internal.LayoutPart#setTrimState(int) >+ */ >+ public void setTrimState(int newTrimState) { >+ if (realContainer != null) >+ getRealContainer().setTrimState(newTrimState); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.ui.internal.LayoutPart#getTrimState() >+ */ >+ public int getTrimState() { >+ if (realContainer != null) >+ return getRealContainer().getTrimState(); >+ >+ return super.getTrimState(); >+ } > } >Index: Eclipse UI/org/eclipse/ui/internal/WorkbenchImages.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/WorkbenchImages.java,v >retrieving revision 1.54 >diff -u -r1.54 WorkbenchImages.java >--- Eclipse UI/org/eclipse/ui/internal/WorkbenchImages.java 24 Oct 2006 18:21:40 -0000 1.54 >+++ Eclipse UI/org/eclipse/ui/internal/WorkbenchImages.java 25 Oct 2006 20:17:45 -0000 >@@ -225,11 +225,14 @@ > > declareImage(IWorkbenchGraphicConstants.IMG_ETOOL_NEW_FASTVIEW, > PATH_ETOOL + "new_fastview.gif", true); //$NON-NLS-1$ >- declareImage(IWorkbenchGraphicConstants.IMG_ETOOL_RESTORE_FASTVIEW, >- PATH_ETOOL + "fastview_restore.gif", true); //$NON-NLS-1$ > declareImage(IWorkbenchGraphicConstants.IMG_DTOOL_NEW_FASTVIEW, > PATH_DTOOL + "new_fastview.gif", true); //$NON-NLS-1$ > >+ declareImage(IWorkbenchGraphicConstants.IMG_ETOOL_RESTORE_TRIMPART, >+ PATH_ETOOL + "fastview_restore.gif", true); //$NON-NLS-1$ >+ declareImage(IWorkbenchGraphicConstants.IMG_ETOOL_EDITOR_TRIMPART, >+ PATH_ETOOL + "editor_area.gif", true); //$NON-NLS-1$ >+ > declareImage(ISharedImages.IMG_TOOL_FORWARD, PATH_ELOCALTOOL > + "forward_nav.gif", true); //$NON-NLS-1$ > declareImage(ISharedImages.IMG_TOOL_FORWARD_HOVER, PATH_ELOCALTOOL >Index: Eclipse UI/org/eclipse/ui/internal/FastGroupTrimButton.java >=================================================================== >RCS file: Eclipse UI/org/eclipse/ui/internal/FastGroupTrimButton.java >diff -N Eclipse UI/org/eclipse/ui/internal/FastGroupTrimButton.java >--- Eclipse UI/org/eclipse/ui/internal/FastGroupTrimButton.java 15 Aug 2006 20:26:15 -0000 1.1 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,269 +0,0 @@ >-/******************************************************************************* >- * Copyright (c) 2006 IBM Corporation and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * >- * Contributors: >- * IBM Corporation - initial API and implementation >- *******************************************************************************/ >-package org.eclipse.ui.internal; >- >-import org.eclipse.swt.SWT; >-import org.eclipse.swt.events.MouseEvent; >-import org.eclipse.swt.events.MouseListener; >-import org.eclipse.swt.events.MouseMoveListener; >-import org.eclipse.swt.events.MouseTrackListener; >-import org.eclipse.swt.events.PaintEvent; >-import org.eclipse.swt.events.PaintListener; >-import org.eclipse.swt.graphics.Color; >-import org.eclipse.swt.graphics.GC; >-import org.eclipse.swt.graphics.Rectangle; >-import org.eclipse.swt.widgets.Canvas; >-import org.eclipse.swt.widgets.Composite; >-import org.eclipse.swt.widgets.Control; >- >-/** >- * Implements the 'group' handling for trim groups >- * >- * @since 3.2 >- * >- */ >-public class FastGroupTrimButton { >- private Canvas button; >- private FastViewBar fvb; >- private int side; >- private Color btnColor; >- >- private Rectangle closeRect; >- private Rectangle restoreRect; >- private Rectangle collapseRect; >- >- private static final int CTRL_AREA_NONE = 0; >- private static final int CTRL_AREA_CLOSE = 1; >- private static final int CTRL_AREA_RESTORE = 2; >- private static final int CTRL_AREA_COLLAPSE = 3; >- >- private int curCtrlArea = CTRL_AREA_NONE; >- private boolean inControl = false; >- private String toolTip; >- >- public FastGroupTrimButton(Composite parent, FastViewBar fvb) { >- this.fvb = fvb; >- >- if (fvb != null) >- side = fvb.getSide(); >- else >- side = SWT.BOTTOM; >- >- btnColor = parent.getDisplay().getSystemColor(SWT.COLOR_BLACK); >- >- button = new Canvas(parent, SWT.NONE); >- button.addPaintListener(new PaintListener() { >- public void paintControl(PaintEvent e) { >- e.gc.setForeground(btnColor); >- paintButtons(e); >- } >- }); >- >- button.addMouseTrackListener(new MouseTrackListener() { >- public void mouseEnter(MouseEvent e) { >- inControl = true; >- // Provide 'track' feedback? >- } >- public void mouseExit(MouseEvent e) { >- inControl = false; >- // remove 'track' feedback? >- } >- public void mouseHover(MouseEvent e) { >- button.setToolTipText(toolTip); >- } >- }); >- >- button.addMouseMoveListener(new MouseMoveListener() { >- public void mouseMove(MouseEvent e) { >- if (closeRect.contains(e.x,e.y)) { >- curCtrlArea = CTRL_AREA_CLOSE; >- toolTip = "Close Group"; //$NON-NLS-1$ >- } >- else if (restoreRect.contains(e.x,e.y)) { >- curCtrlArea = CTRL_AREA_RESTORE; >- toolTip = "Restore Group"; //$NON-NLS-1$ >- } >- else if (collapseRect.contains(e.x,e.y)) { >- curCtrlArea = CTRL_AREA_COLLAPSE; >- toolTip = "Collapse Group"; //$NON-NLS-1$ >- } >- else >- curCtrlArea = CTRL_AREA_NONE; >- } >- }); >- button.addMouseListener(new MouseListener() { >- public void mouseDoubleClick(MouseEvent e) {} >- public void mouseUp(MouseEvent e) {} >- public void mouseDown(MouseEvent e) { >- if (inControl && curCtrlArea != CTRL_AREA_NONE) { >- switch (curCtrlArea) { >- case CTRL_AREA_CLOSE: >- FastGroupTrimButton.this.fvb.closeGroup(); >- break; >- case CTRL_AREA_COLLAPSE: >- FastGroupTrimButton.this.fvb.collapseGroup(); >- break; >- case CTRL_AREA_RESTORE: >- FastGroupTrimButton.this.fvb.restoreGroup(); >- break; >- } >- } >- } >- }); >- } >- >- public void setSize(int size) { >- button.setSize(size, size); >- } >- >- protected void paintButtons(PaintEvent e) { >- Rectangle bb = button.getBounds(); >- setButtonRects(bb); >- >- paintClose(e.gc); >- paintRestore(e.gc); >- paintCollapse(e.gc); >- } >- >- private void paintCollapse(GC gc) { >- switch(side) { >- case SWT.BOTTOM: >- drawDownArrow(gc, collapseRect); >- break; >- case SWT.TOP: >- drawUpArrow(gc, collapseRect); >- break; >- case SWT.LEFT: >- drawLeftArrow(gc, collapseRect); >- break; >- case SWT.RIGHT: >- drawRightArrow(gc, collapseRect); >- break; >- } >- } >- >- private void paintRestore(GC gc) { >- switch(side) { >- case SWT.BOTTOM: >- drawUpArrow(gc, restoreRect); >- break; >- case SWT.TOP: >- drawDownArrow(gc, restoreRect); >- break; >- case SWT.LEFT: >- drawRightArrow(gc, restoreRect); >- break; >- case SWT.RIGHT: >- drawLeftArrow(gc, restoreRect); >- break; >- } >- } >- >- private void paintClose(GC gc) { >- int border = 2; >- gc.drawLine(closeRect.x+border, closeRect.y+border, (closeRect.x+closeRect.width)-border, (closeRect.y+closeRect.height)-border); >- gc.drawLine((closeRect.x+closeRect.width)-border, closeRect.y+border, closeRect.x+border, (closeRect.y+closeRect.height)-border); >-// int minX = closeRect.x + 2; >-// int maxX = (closeRect.x+closeRect.width) - 2; >-// int stopMax = maxX; >-// int y = (closeRect.y + (closeRect.height)/2) - ((maxX-minX)/2); >-// >-// while (minX <= stopMax) { >-// gc.drawLine(minX, y, minX, y); >-// gc.drawLine(maxX, y, maxX, y); >-// minX++; maxX--; y++; >-// } >- } >- >- private void drawDownArrow(GC gc, Rectangle rect) { >- int y = rect.y + 1; >- int minX = rect.x + 2; >- int maxX = (rect.x+rect.width) - 2; >- >- while (minX <= maxX) { >- gc.drawLine(minX, y, maxX, y); >- y++; >- gc.drawLine(minX, y, maxX, y); >- minX++; maxX--; y++; >- } >- } >- >- private void drawRightArrow(GC gc, Rectangle rect) { >- int x = rect.x + 1; >- int minY = rect.y + 2; >- int maxY = (rect.y+rect.height) - 2; >- >- while (minY <= maxY) { >- gc.drawLine(x, minY, x, maxY); >- x++; >- gc.drawLine(x, minY, x, maxY); >- minY++; maxY--; x++; >- } >- } >- >- private void drawUpArrow(GC gc, Rectangle rect) { >- int y = (rect.y+rect.height) - 1; >- int minX = rect.x + 2; >- int maxX = (rect.x+rect.width) - 2; >- >- while (minX <= maxX) { >- gc.drawLine(minX, y, maxX, y); >- y--; >- gc.drawLine(minX, y, maxX, y); >- minX++; maxX--; y--; >- } >- } >- >- private void drawLeftArrow(GC gc, Rectangle rect) { >- int x = (rect.x+rect.width) - 1; >- int minY = rect.y + 2; >- int maxY = (rect.y+rect.height) - 2; >- >- while (minY <= maxY) { >- gc.drawLine(x, minY, x, maxY); >- x--; >- gc.drawLine(x, minY, x, maxY); >- minY++; maxY--; x--; >- } >- } >- >- private void setButtonRects(Rectangle bb) { >- int hw = bb.width/2; >- int hh = bb.height/2; >- >- switch (side) { >- case SWT.BOTTOM: >- closeRect = new Rectangle(bb.x, bb.y+(bb.height/4), hw, hh); >- restoreRect = new Rectangle(bb.x+hw, bb.y, hw, hh); >- collapseRect = new Rectangle(bb.x+hw, bb.y+hh, hw, hh); >- break; >- case SWT.TOP: >- closeRect = new Rectangle(bb.x, bb.y+(bb.height/4), hw, hh); >- collapseRect = new Rectangle(bb.x+hw, bb.y, hw, hh); >- restoreRect = new Rectangle(bb.x+hw, bb.y+hh, hw, hh); >- break; >- case SWT.LEFT: >- closeRect = new Rectangle(bb.x+(bb.width/4), bb.y, hw, hh); >- collapseRect = new Rectangle(bb.x, bb.y+hh, hw, hh); >- restoreRect = new Rectangle(bb.x+hw, bb.y+hh, hw, hh); >- break; >- case SWT.RIGHT: >- closeRect = new Rectangle(bb.x+(bb.width/4), bb.y, hw, hh); >- restoreRect = new Rectangle(bb.x, bb.y+hh, hw, hh); >- collapseRect = new Rectangle(bb.x+hw, bb.y+hh, hw, hh); >- break; >- } >- } >- >- public Control getControl() { >- return button; >- } >-} >Index: Eclipse UI/org/eclipse/ui/internal/EditorSiteDragAndDropServiceImpl.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/EditorSiteDragAndDropServiceImpl.java,v >retrieving revision 1.1 >diff -u -r1.1 EditorSiteDragAndDropServiceImpl.java >--- Eclipse UI/org/eclipse/ui/internal/EditorSiteDragAndDropServiceImpl.java 2 Oct 2006 18:42:11 -0000 1.1 >+++ Eclipse UI/org/eclipse/ui/internal/EditorSiteDragAndDropServiceImpl.java 25 Oct 2006 20:17:44 -0000 >@@ -24,8 +24,6 @@ > import org.eclipse.swt.widgets.Control; > import org.eclipse.ui.PlatformUI; > import org.eclipse.ui.dnd.IDragAndDropService; >-import org.eclipse.ui.internal.WorkbenchWindow; >-import org.eclipse.ui.internal.WorkbenchWindowConfigurer; > import org.eclipse.ui.services.IDisposable; > > /** >Index: Eclipse UI/org/eclipse/ui/internal/PartSashContainer.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/PartSashContainer.java,v >retrieving revision 1.52 >diff -u -r1.52 PartSashContainer.java >--- Eclipse UI/org/eclipse/ui/internal/PartSashContainer.java 14 Sep 2006 19:30:23 -0000 1.52 >+++ Eclipse UI/org/eclipse/ui/internal/PartSashContainer.java 25 Oct 2006 20:17:45 -0000 >@@ -35,6 +35,7 @@ > import org.eclipse.ui.internal.dnd.IDropTarget; > import org.eclipse.ui.internal.dnd.SwtUtil; > import org.eclipse.ui.internal.util.PrefUtil; >+import org.eclipse.ui.presentations.IStackPresentationSite; > > /** > * Abstract container that groups various layout >@@ -57,7 +58,7 @@ > private LayoutPart zoomedPart; > > // 'Smart' zoom >- private boolean smartZoomed = false; >+ private LayoutPart smartZoomedPart = null; > > protected WorkbenchPage page; > >@@ -853,51 +854,51 @@ > this.parent.setBounds(r); > } > >- private void smartZoomIn(LayoutPart part, Perspective persp) { >- // HACK!! since we aren't changing the 'state' maximize always >- // get called; 'unzoom' if necessary >- if (smartZoomed) { >- // Restore the editor area if necessary >- persp.showEditorArea(); >- >- // Restore (close) and groups created during a zoom >- persp.restoreZoomGroups(); >- >- // we're 'unzoomed' >- smartZoomed = false; >- >- // Remember that we need to trigger a layout >- layoutDirty = true; >- >- return; >- } >+ private void smartZoomIn(LayoutPart zoomingPart, Perspective persp) { >+ // Prevent recursion >+ if (smartZoomedPart != null) >+ return; > > // 'Smart'(?) zoom...'minimize' all view stacks except the > // one we're zooming. If we're zooming the editor then -all- > // view stacks get minimized > LayoutPart[] children = getChildren(); >- List stacks = new ArrayList(); >+ List trimParts = new ArrayList(); > for (int i = 0; i < children.length; i++) { >- LayoutPart child = children[i]; >- // Close the editor stack unless it's the 'zooming' part >- if (child instanceof EditorSashContainer && child != part) { >- persp.hideEditorArea(); >- } >- else if (child instanceof ViewStack) { >- if (child != part) { >- stacks.add(child); >- } >- } >+ if (children[i] != zoomingPart) >+ trimParts.add(children[i]); > } > >- persp.moveToTrim(stacks, FastViewBar.GROUP_FVB | FastViewBar.ZOOM_GROUP); >+ persp.movePartsToTrim(trimParts, true); > > // We're -not- really zoomed, don't lie > zoomedPart = null; > > // ...but we're 'zoomed' >- smartZoomed = true; >+ smartZoomedPart = zoomingPart; > >+ if (smartZoomedPart instanceof PartStack) { >+ ((PartStack)smartZoomedPart).setPresentationState(IStackPresentationSite.STATE_MAXIMIZED); >+ } >+ // Remember that we need to trigger a layout >+ layoutDirty = true; >+ } >+ >+ private void smartZoomOut(Perspective persp) { >+ // Prevent recursion >+ if (smartZoomedPart == null) >+ return; >+ >+ // we're 'unzoomed' >+ LayoutPart zoomedPartCache = smartZoomedPart; >+ smartZoomedPart = null; >+ >+ // Restore (close) trim parts created during a zoom >+ persp.restoreZoomedParts(); >+ >+ if (zoomedPartCache instanceof PartStack) { >+ ((PartStack)zoomedPartCache).setPresentationState(IStackPresentationSite.STATE_RESTORED); >+ } > // Remember that we need to trigger a layout > layoutDirty = true; > } >@@ -1024,6 +1025,15 @@ > * Note: Method assumes we are active. > */ > private void zoomOut() { >+ // 'Smart'? Zoom out >+ Perspective persp = this.getPage().getActivePerspective(); >+ IPreferenceStore preferenceStore = PrefUtil.getAPIPreferenceStore(); >+ boolean useNewMinMax = preferenceStore.getBoolean(IWorkbenchPreferenceConstants.ENABLE_NEW_MIN_MAX); >+ if (useNewMinMax) { >+ smartZoomOut(persp); >+ return; >+ } >+ > // Sanity check. > if (!isZoomed()) { > return; >Index: Eclipse UI/org/eclipse/ui/internal/WorkbenchMessages.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/WorkbenchMessages.java,v >retrieving revision 1.71 >diff -u -r1.71 WorkbenchMessages.java >--- Eclipse UI/org/eclipse/ui/internal/WorkbenchMessages.java 19 Oct 2006 17:46:20 -0000 1.71 >+++ Eclipse UI/org/eclipse/ui/internal/WorkbenchMessages.java 25 Oct 2006 20:17:45 -0000 >@@ -567,7 +567,7 @@ > public static String StandardSystemToolbar_Maximize; > public static String StandardSystemToolbar_Restore; > >- public static String ViewPane_moveToTrim; >+ public static String EditorArea_Tooltip; > public static String ViewPane_fastView; > public static String ViewPane_minimizeView; > public static String ViewPane_moveView; >Index: Eclipse UI/org/eclipse/ui/internal/ViewStack.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/ViewStack.java,v >retrieving revision 1.20 >diff -u -r1.20 ViewStack.java >--- Eclipse UI/org/eclipse/ui/internal/ViewStack.java 6 Sep 2006 14:02:08 -0000 1.20 >+++ Eclipse UI/org/eclipse/ui/internal/ViewStack.java 25 Oct 2006 20:17:45 -0000 >@@ -12,7 +12,13 @@ > *******************************************************************************/ > package org.eclipse.ui.internal; > >+import java.util.Iterator; >+import java.util.List; >+ > import org.eclipse.jface.action.IMenuManager; >+import org.eclipse.swt.SWT; >+import org.eclipse.ui.IViewReference; >+import org.eclipse.ui.internal.layout.ITrimManager; > import org.eclipse.ui.internal.presentations.PresentablePart; > import org.eclipse.ui.internal.presentations.PresentationFactoryUtil; > import org.eclipse.ui.internal.presentations.SystemMenuDetach; >@@ -154,4 +160,90 @@ > public StackPresentation getTestPresentation() { > return getPresentation(); > } >+ >+ >+ // Trim Stack Support >+ >+ public void setTrimState(int newTrimState) { >+ if (newTrimState == getTrimState()) >+ return; >+ >+ // Remember the new state >+ int oldTrimState = getTrimState(); >+ >+ // set the new one >+ super.setTrimState(newTrimState); >+ >+ WorkbenchWindow wbw = (WorkbenchWindow) getWorkbenchWindow(); >+ if (wbw == null) >+ return; >+ >+ // Access workbench context >+ Perspective persp = page.getActivePerspective(); >+ ITrimManager tbm = wbw.getTrimManager(); >+ ViewStackTrimPart viewStackTrim = (ViewStackTrimPart) tbm.getTrim(getID()); >+ >+ // Are we moving the View Stack -to- the trim? >+ if (oldTrimState == LayoutPart.TRIMSTATE_NORMAL) { >+ // Remove the real stack from the presentation >+ ContainerPlaceholder ph = null; >+ ph = new ContainerPlaceholder(getID()); >+ ph.setRealContainer(this); >+ getContainer().replace(this, ph); >+ page.refreshActiveView(); >+ >+ // Is it already in the trim? >+ if (viewStackTrim == null) { >+ // If it's not already in the trim...create it >+ int side = SWT.BOTTOM; >+ if (persp != null) >+ side = persp.calcStackSide(getBounds()); >+ >+ viewStackTrim = new ViewStackTrimPart(wbw, ph); >+ viewStackTrim.dock(side); >+ tbm.addTrim(side, viewStackTrim); >+ } >+ >+ // Refresh the trim's state and show it >+ viewStackTrim.setPlaceholder(ph); >+ viewStackTrim.refresh(); >+ >+ // Make the views 'fast' >+ if (persp != null) { >+ List refs = viewStackTrim.getViewRefs(); >+ for (Iterator refIter = refs.iterator(); refIter >+ .hasNext();) { >+ IViewReference ref = (IViewReference) refIter.next(); >+ persp.addFastViewHack(ref); >+ } >+ } >+ tbm.setTrimVisible(viewStackTrim, true); >+ } >+ >+ // Are we restoring the View Stack -from- the trim? >+ if (newTrimState == LayoutPart.TRIMSTATE_NORMAL) { >+ if (viewStackTrim == null) >+ return; >+ >+ // Make the views un-'fast' >+ if (persp != null) { >+ List refs = viewStackTrim.getViewRefs(); >+ for (Iterator refIter = refs.iterator(); refIter >+ .hasNext();) { >+ IViewReference ref = (IViewReference) refIter.next(); >+ persp.removeFastViewHack(ref); >+ } >+ } >+ >+ // hide the trim widget >+ tbm.setTrimVisible(viewStackTrim, false); >+ >+ // Restore the real container >+ ContainerPlaceholder ph = viewStackTrim.getPlaceholder(); >+ ILayoutContainer container = ph.getContainer(); >+ LayoutPart ps = ph.getRealContainer(); >+ ph.setRealContainer(null); >+ container.replace(ph, ps); >+ } >+ } > } >Index: Eclipse UI/org/eclipse/ui/internal/messages.properties >=================================================================== >RCS file: /home/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/messages.properties,v >retrieving revision 1.328 >diff -u -r1.328 messages.properties >--- Eclipse UI/org/eclipse/ui/internal/messages.properties 19 Oct 2006 17:46:20 -0000 1.328 >+++ Eclipse UI/org/eclipse/ui/internal/messages.properties 25 Oct 2006 20:17:46 -0000 >@@ -563,7 +563,7 @@ > StandardSystemToolbar_Maximize = Maximize > StandardSystemToolbar_Restore = Restore > >-ViewPane_moveToTrim = &Move to Trim >+EditorArea_Tooltip = Editor Area > ViewPane_fastView = &Fast View > ViewPane_minimizeView= Mi&nimize > ViewPane_moveView=&View >Index: Eclipse UI/org/eclipse/ui/internal/Perspective.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/Perspective.java,v >retrieving revision 1.126 >diff -u -r1.126 Perspective.java >--- Eclipse UI/org/eclipse/ui/internal/Perspective.java 6 Sep 2006 14:02:08 -0000 1.126 >+++ Eclipse UI/org/eclipse/ui/internal/Perspective.java 25 Oct 2006 20:17:45 -0000 >@@ -26,8 +26,10 @@ > import org.eclipse.jface.dialogs.ErrorDialog; > import org.eclipse.jface.dialogs.MessageDialog; > import org.eclipse.jface.preference.IPreferenceStore; >+import org.eclipse.jface.util.Geometry; > import org.eclipse.osgi.util.NLS; > import org.eclipse.swt.SWT; >+import org.eclipse.swt.graphics.Point; > import org.eclipse.swt.graphics.Rectangle; > import org.eclipse.swt.widgets.Composite; > import org.eclipse.swt.widgets.Control; >@@ -43,6 +45,7 @@ > import org.eclipse.ui.IViewSite; > import org.eclipse.ui.IWorkbenchPart; > import org.eclipse.ui.IWorkbenchPartReference; >+import org.eclipse.ui.IWorkbenchPreferenceConstants; > import org.eclipse.ui.PartInitException; > import org.eclipse.ui.PlatformUI; > import org.eclipse.ui.WorkbenchException; >@@ -50,8 +53,8 @@ > import org.eclipse.ui.internal.dnd.DragUtil; > import org.eclipse.ui.internal.intro.IIntroConstants; > import org.eclipse.ui.internal.layout.ITrimManager; >+import org.eclipse.ui.internal.layout.IWindowTrim; > import org.eclipse.ui.internal.misc.StatusUtil; >-import org.eclipse.ui.internal.presentations.PresentablePart; > import org.eclipse.ui.internal.registry.ActionSetRegistry; > import org.eclipse.ui.internal.registry.IActionSetDescriptor; > import org.eclipse.ui.internal.registry.IWorkbenchRegistryConstants; >@@ -59,6 +62,7 @@ > import org.eclipse.ui.internal.registry.PerspectiveExtensionReader; > import org.eclipse.ui.internal.registry.PerspectiveRegistry; > import org.eclipse.ui.internal.registry.StickyViewDescriptor; >+import org.eclipse.ui.internal.util.PrefUtil; > import org.eclipse.ui.views.IStickyViewDescriptor; > import org.eclipse.ui.views.IViewDescriptor; > import org.eclipse.ui.views.IViewRegistry; >@@ -88,9 +92,6 @@ > private ArrayList perspectiveShortcuts; > > private ArrayList fastViews; >- private List globalFastViews; >- private boolean globalFVBsaved = false; >- private ArrayList fastViewBars; > > private Map mapIDtoViewLayoutRec; > >@@ -143,34 +144,43 @@ > alwaysOnActionSets = new ArrayList(2); > alwaysOffActionSets = new ArrayList(2); > fastViews = new ArrayList(2); >- globalFastViews = new ArrayList(2); >- fastViewBars = new ArrayList(2); > mapIDtoViewLayoutRec = new HashMap(); > } > >- /** >- * Sets the fast view attribute. >- * Note: The page is expected to update action bars. >- */ >- public void addFastView(IViewReference ref) { >- ViewPane pane = (ViewPane) ((WorkbenchPartReference) ref).getPane(); >- if (!isFastView(ref)) { >- // Only remove the part from the presentation if it >- // is actually in the presentation. >- if (presentation.hasPlaceholder(ref.getId(), ref.getSecondaryId()) >- || pane.getContainer() != null) { >- presentation.removePart(pane); >- } >- // We are drag-enabling the pane because it has been disabled >- // when it was removed from the perspective presentation. >- fastViews.add(ref); >- pane.setFast(true); >- Control ctrl = pane.getControl(); >- if (ctrl != null) { >+ /** >+ * Sets the fast view attribute. Note: The page is expected to update action >+ * bars. >+ */ >+ public void addFastView(IViewReference ref) { >+ addFastView(ref, true); >+ } >+ >+ /** >+ * Sets the fast view attribute. Note: The page is expected to update action >+ * bars. >+ */ >+ public void addFastView(IViewReference ref, boolean handleLayout) { >+ ViewPane pane = (ViewPane) ((WorkbenchPartReference) ref).getPane(); >+ if (!isFastView(ref)) { >+ if (handleLayout) { >+ // Only remove the part from the presentation if it >+ // is actually in the presentation. >+ if (presentation.hasPlaceholder(ref.getId(), ref.getSecondaryId()) >+ || pane.getContainer() != null) { >+ presentation.removePart(pane); >+ } >+ } >+ >+ // We are drag-enabling the pane because it has been disabled >+ // when it was removed from the perspective presentation. >+ fastViews.add(ref); >+ pane.setFast(true); >+ Control ctrl = pane.getControl(); >+ if (ctrl != null) { > ctrl.setEnabled(false); // Remove focus support. > } >- } >- } >+ } >+ } > > /** > * Moves a part forward in the Z order of a perspective so it is visible. >@@ -319,152 +329,6 @@ > return array; > } > >- public void closeTrimGroup(FastViewBar groupBar) { >- groupBar.restoreGroup(); >- >- WorkbenchWindow wbw = (WorkbenchWindow)page.getWorkbenchWindow(); >- ITrimManager tbm = wbw.getTrimManager(); >- tbm.removeTrim(groupBar); >- groupBar.getControl().setVisible(false); >- groupBar.dispose(); >- >- fastViewBars.remove(groupBar); >- >- tbm.forceLayout(); >- } >- >- private String getUniqueGroupId() { >- // Get a unique id >- boolean found = false; >- int count = 0; >- String id = ""; //$NON-NLS-1$ >- while (!found) { >- id = getDesc().getId() + " (" + count + ")"; //$NON-NLS-1$//$NON-NLS-2$ >- boolean matchFound = false; >- for (Iterator fvbIter = fastViewBars.iterator(); fvbIter.hasNext();) { >- FastViewBar fvb = (FastViewBar) fvbIter.next(); >- if (fvb.getId().equals(id)) { >- matchFound = true; >- break; >- } >- } >- >- if (matchFound) >- count++; >- else >- found = true; >- } >- >- return id; >- } >- >- private int calcStackSide (ViewStack stack) { >- // Where is the stack in relation to the EditorArea? >- Rectangle stackBounds = stack.getBounds(); >- Rectangle editorAreaBounds = editorArea.getBounds(); >- >- if ((stackBounds.x+stackBounds.width) < editorAreaBounds.x) >- return SWT.LEFT; >- if (stackBounds.x > (editorAreaBounds.x+editorAreaBounds.width)) >- return SWT.RIGHT; >- if ((stackBounds.y+stackBounds.height) < editorAreaBounds.y) >- return SWT.TOP; >- if (stackBounds.y > (editorAreaBounds.y+editorAreaBounds.height)) >- return SWT.BOTTOM; >- >- return SWT.BOTTOM; // shouldn't be able to get here... >- } >- >- public void moveToTrim(List stacks, int style) { >- if (stacks == null || stacks.size() == 0) >- return; >- >- Shell shell = ((ViewStack)stacks.get(0)).getShell(); >- RectangleAnimation animation = new RectangleAnimation(shell, null, null); >- >- // Capture the area the stack currently occupies (and its image) >- for (Iterator stackIter = stacks.iterator(); stackIter.hasNext();) { >- ViewStack stack = (ViewStack) stackIter.next(); >- animation.addStartRect(DragUtil.getDisplayBounds(stack.getControl())); >- } >- >- // Iterate through all the stacks, moveing each to the trim >- List newFVBs = new ArrayList(stacks.size()); >- for (Iterator stackIter = stacks.iterator(); stackIter.hasNext();) { >- ViewStack stack = (ViewStack) stackIter.next(); >- >- // Place the stack on the correct side >- int side = calcStackSide(stack); >- FastViewBar fvb = createFastViewBar(getUniqueGroupId(), style, side); >- newFVBs.add(fvb); >- >- // Add all the views in the stack to teh new FVB >- ArrayList refs = new ArrayList(); >- List parts = stack.getPresentableParts(); >- for (Iterator partIter = parts.iterator(); partIter.hasNext();) { >- PresentablePart part = (PresentablePart) partIter.next(); >- if (part.getPane().getPartReference() instanceof ViewReference) { >- refs.add(part.getPane().getPartReference()); >- } >- } >- fvb.setViewRefs(refs); >- >- // Set the display orientation based on the stack's geometry >- Rectangle stackBounds = stack.getBounds(); >- int orientation = (stackBounds.width > stackBounds.height) ? SWT.HORIZONTAL : SWT.VERTICAL; >- fvb.setOrientation(orientation); >- >- // Move the views 'into' the new group >- fvb.collapseGroup(); >- >- } >- >- // Force a layout >- WorkbenchWindow wbw = (WorkbenchWindow)page.getWorkbenchWindow(); >- ITrimManager tbm = wbw.getTrimManager(); >- tbm.forceLayout(); >- >- // Now that the layout is finished we can add the 'end' rects for the animation >- for (Iterator fvbIter = newFVBs.iterator(); fvbIter.hasNext();) { >- FastViewBar fvb = (FastViewBar) fvbIter.next(); >- animation.addEndRect(DragUtil.getDisplayBounds(fvb.getControl())); >- } >- >- animation.schedule(); >- } >- >- public void restoreZoomGroups() { >- List toClose = new ArrayList(); >- >- // Get the groups to close in another list and... >- for (Iterator fvbIter = fastViewBars.iterator(); fvbIter.hasNext();) { >- FastViewBar fvb = (FastViewBar) fvbIter.next(); >- if (fvb.testStyleBit(FastViewBar.ZOOM_GROUP)) >- toClose.add(fvb); >- } >- >- // ... close them >- for (Iterator closeIter = toClose.iterator(); closeIter.hasNext();) { >- FastViewBar fvb = (FastViewBar) closeIter.next(); >- fvb.closeGroup(); >- } >- } >- >- private FastViewBar createFastViewBar(String id, int style, int side) { >- // Create the FVB on the given side >- WorkbenchWindow wbw = (WorkbenchWindow)page.getWorkbenchWindow(); >- FastViewBar newFVB = new FastViewBar(wbw, style, id); >- newFVB.createControl(wbw.getShell()); >- newFVB.dock(side); >- newFVB.getControl().setVisible(true); >- ITrimManager tbm = wbw.getTrimManager(); >- tbm.addTrim(side, newFVB); >- >- fastViewBars.add(newFVB); >- >- return newFVB; >- } >- > /** > * Returns the new wizard shortcuts associated with this perspective. > * >@@ -936,94 +800,120 @@ > /** > * activate. > */ >- protected void onActivate() { >- >- // Update editor area state. >- if (editorArea.getControl() != null) { >- editorArea.setVisible(isEditorAreaVisible()); >- } >+ protected void onActivate() { >+ // Update editor area state. >+ if (editorArea.getControl() != null) { >+ editorArea.setVisible(isEditorAreaVisible()); >+ } >+ >+ // update the 'global' FVB >+ FastViewBar fvb = ((WorkbenchWindow) page.getWorkbenchWindow()) >+ .getFastViewBar(); >+ if (fvb != null) { >+ fvb.setViewRefs(fastViews); >+ } >+ >+ // Update fast views. >+ // Make sure the control for the fastviews are create so they can >+ // be activated. >+ for (int i = 0; i < fastViews.size(); i++) { >+ ViewPane pane = getPane((IViewReference) fastViews.get(i)); >+ if (pane != null) { >+ Control ctrl = pane.getControl(); >+ if (ctrl == null) { >+ pane.createControl(getClientComposite()); >+ ctrl = pane.getControl(); >+ } >+ ctrl.setEnabled(false); // Remove focus support. >+ } >+ } > >- // Update fast views. >- // Make sure the control for the fastviews are create so they can >- // be activated. >- for (int i = 0; i < fastViews.size(); i++) { >- ViewPane pane = getPane((IViewReference) fastViews.get(i)); >- if (pane != null) { >- Control ctrl = pane.getControl(); >- if (ctrl == null) { >- pane.createControl(getClientComposite()); >- ctrl = pane.getControl(); >- } >- ctrl.setEnabled(false); // Remove focus support. >- } >- } >- >- // update the 'global' FVB >- FastViewBar fvb = ((WorkbenchWindow)page.getWorkbenchWindow()).getFastViewBar(); >- if (fvb != null) { >- fvb.setViewRefs(globalFastViews); >- globalFVBsaved = false; >- } >+ // Set the visibility of all fast view pins >+ setAllPinsVisible(true); > >- // Show the trim groups >- WorkbenchWindow wbw = (WorkbenchWindow)page.getWorkbenchWindow(); >- ITrimManager tbm = wbw.getTrimManager(); >- if (tbm != null) { >- for (Iterator fvbIter = fastViewBars.iterator(); fvbIter.hasNext();) { >- fvb = (FastViewBar) fvbIter.next(); >- fvb.update(false); >- tbm.setTrimVisible(fvb, true); >- } >+ // Show the layout >+ presentation.activate(getClientComposite()); >+ >+ // Trim Stack Support >+ IPreferenceStore preferenceStore = PrefUtil.getAPIPreferenceStore(); >+ boolean useNewMinMax = preferenceStore.getBoolean(IWorkbenchPreferenceConstants.ENABLE_NEW_MIN_MAX); >+ if (useNewMinMax) { >+ // We 'stall' the creation of trim elements until the first activation >+ createInitialTrim(); > >+ // Show Trim parts -after- activation >+ presentation.getLayout().setTrimVisible(true); >+ >+ // The editor area's trim stack's visibility is the inverse >+ // Of the actual editor area >+ WorkbenchWindow wbw = (WorkbenchWindow) page.getWorkbenchWindow(); >+ ITrimManager tbm = wbw.getTrimManager(); >+ IWindowTrim eaTrim = tbm.getTrim(editorArea.getID()); >+ if (eaTrim != null) { >+ tbm.setTrimVisible(eaTrim, !isEditorAreaVisible()); >+ } >+ > // if we're done then force an update...optimize out if possible > tbm.forceLayout(); > } >- >- setAllPinsVisible(true); >- presentation.activate(getClientComposite()); > >- if (shouldHideEditorsOnActivate) { >- // We do this here to ensure that createPartControl is called on the top editor >- // before it is hidden. See bug 20166. >- hideEditorArea(); >- shouldHideEditorsOnActivate = false; >- } >- } >+ if (shouldHideEditorsOnActivate) { >+ // We do this here to ensure that createPartControl is called on the >+ // top editor >+ // before it is hidden. See bug 20166. >+ hideEditorArea(); >+ shouldHideEditorsOnActivate = false; >+ } >+ } > > /** >+ * Create any trim necessary to support the current >+ * layout state >+ */ >+ private void createInitialTrim() { >+ WorkbenchWindow wbw = (WorkbenchWindow) page.getWorkbenchWindow(); >+ ITrimManager tbm = wbw.getTrimManager(); >+ >+ LayoutPart[] children = presentation.getLayout().getChildren(); >+ for (int i = 0; i < children.length; i++) { >+ if (children[i].getTrimState() == LayoutPart.TRIMSTATE_IN_TRIM >+ || children[i].getTrimState() == LayoutPart.TRIMSTATE_ZOOMEDTOTRIM) { >+ IWindowTrim partTrim = tbm.getTrim(children[i].getID()); >+ if (partTrim == null) { >+ children[i].createInitialTrim(); >+ } >+ } >+ } >+ } >+ >+ /** > * deactivate. > */ >- protected void onDeactivate() { >- presentation.deactivate(); >- setActiveFastView(null); >- setAllPinsVisible(false); >- >- // remember the list of 'global' fast views >- WorkbenchWindow wbw = (WorkbenchWindow)page.getWorkbenchWindow(); >- FastViewBar globalFVB = wbw.getFastViewBar(); >- if (globalFVB != null) { >- globalFastViews = new ArrayList(globalFVB.getViewRefs()); >- globalFVBsaved = true; >- } >- >- // Update fast views. >- for (int i = 0; i < fastViews.size(); i++) { >- ViewPane pane = getPane((IViewReference) fastViews.get(i)); >- if (pane != null) { >- Control ctrl = pane.getControl(); >- if (ctrl != null) { >+ protected void onDeactivate() { >+ presentation.deactivate(); >+ setActiveFastView(null); >+ setAllPinsVisible(false); >+ >+ // Update fast views. >+ for (int i = 0; i < fastViews.size(); i++) { >+ ViewPane pane = getPane((IViewReference) fastViews.get(i)); >+ if (pane != null) { >+ Control ctrl = pane.getControl(); >+ if (ctrl != null) { > ctrl.setEnabled(true); // Add focus support. > } >- } >- } >- >- // Hide the trim groups >- ITrimManager tbm = wbw.getTrimManager(); >- for (Iterator fvbIter = fastViewBars.iterator(); fvbIter.hasNext();) { >- FastViewBar fvb = (FastViewBar) fvbIter.next(); >- tbm.setTrimVisible(fvb, false); >+ } > } >- } >+ >+ // Trim Stack Support >+ IPreferenceStore preferenceStore = PrefUtil.getAPIPreferenceStore(); >+ boolean useNewMinMax = preferenceStore.getBoolean(IWorkbenchPreferenceConstants.ENABLE_NEW_MIN_MAX); >+ if (useNewMinMax) { >+ // OK, adjust the trim to hide any view stacks that >+ // are -currently- showing in the trim >+ presentation.getLayout().setTrimVisible(false); >+ } >+ } > > /** > * Notifies that a part has been activated. >@@ -1043,30 +933,41 @@ > public void performedShowIn(String partId) { > showInTimes.put(partId, new Long(System.currentTimeMillis())); > } >- >- /** >- * Sets the fast view attribute. >- * Note: The page is expected to update action bars. >- */ >- public void removeFastView(IViewReference ref) { >- ViewPane pane = getPane(ref); >- if (isFastView(ref)) { >- if (activeFastView == ref) { >+ >+ /** >+ * Sets the fast view attribute. Note: The page is expected to update action >+ * bars. >+ */ >+ public void removeFastView(IViewReference ref) { >+ removeFastView(ref, true); >+ } >+ >+ /** >+ * Sets the fast view attribute. Note: The page is expected to update action >+ * bars. >+ */ >+ public void removeFastView(IViewReference ref, boolean handleLayout) { >+ ViewPane pane = getPane(ref); >+ if (isFastView(ref)) { >+ if (activeFastView == ref) { > setActiveFastView(null); > } >- fastViews.remove(ref); >- pane.setFast(false); >- Control ctrl = pane.getControl(); >- if (ctrl != null) { >+ fastViews.remove(ref); >+ pane.setFast(false); >+ Control ctrl = pane.getControl(); >+ if (ctrl != null) { > ctrl.setEnabled(true); // Modify focus support. > } >- // We are disabling the pane because it will be enabled when it >- // is added to the presentation. When a pane is enabled a drop >- // listener is added to it, and we do not want to have multiple >- // listeners for a pane >- presentation.addPart(pane); >- } >- } >+ >+ if (handleLayout) { >+ // We are disabling the pane because it will be enabled when it >+ // is added to the presentation. When a pane is enabled a drop >+ // listener is added to it, and we do not want to have multiple >+ // listeners for a pane >+ presentation.addPart(pane); >+ } >+ } >+ } > > /** > * Fills a presentation with layout data. >@@ -1093,13 +994,11 @@ > IMemento views[] = memento.getChildren(IWorkbenchConstants.TAG_VIEW); > result.merge(createReferences(views)); > >- // Restore the list of fast views > memento = memento.getChild(IWorkbenchConstants.TAG_FAST_VIEWS); > if (memento != null) { > views = memento.getChildren(IWorkbenchConstants.TAG_VIEW); > result.merge(createReferences(views)); > } >- > return result; > } > >@@ -1299,56 +1198,6 @@ > } > } > >- // Restore the list of 'global' fast views >- globalFastViews = new ArrayList(); >- IMemento globalFastViewsMem = memento.getChild(IWorkbenchConstants.TAG_GLOBAL_FAST_VIEWS); >- if (globalFastViewsMem != null) { >- IMemento[] globalRefs = globalFastViewsMem.getChildren(IWorkbenchConstants.TAG_VIEW); >- for (int i = 0; i < globalRefs.length; i++) { >- String viewId = globalRefs[i].getID(); >- String secondaryId = ViewFactory.extractSecondaryId(viewId); >- if (secondaryId != null) { >- viewId = ViewFactory.extractPrimaryId(viewId); >- } >- >- // Resolve the ref >- IViewReference ref = viewFactory.getView(viewId, secondaryId); >- globalFastViews.add(ref); >- } >- } >- else { >- // Old format, all fast views are 'global' >- globalFastViews = new ArrayList(fastViews); >- } >- >- // Restore the trim groups >- IMemento groupsMem = memento.getChild(IWorkbenchConstants.TAG_FAST_GROUPS); >- if (groupsMem != null) { >- IMemento[] group = groupsMem.getChildren(IWorkbenchConstants.TAG_FAST_VIEW_DATA); >- for (int i = 0; i < group.length; i++) { >- String id = group[i].getString(IWorkbenchConstants.TAG_ID); >- FastViewBar fvb = createFastViewBar(id, FastViewBar.GROUP_FVB, SWT.BOTTOM); >- fvb.restoreState(group[i]); >- >- IMemento viewsMem = group[i].getChild(IWorkbenchConstants.TAG_VIEWS); >- IMemento[] fvMems = viewsMem.getChildren(IWorkbenchConstants.TAG_VIEW); >- ArrayList viewRefs = new ArrayList(fvMems.length); >- for (int j = 0; j < fvMems.length; j++) { >- String viewId = fvMems[j].getID(); >- String secondaryId = ViewFactory.extractSecondaryId(viewId); >- if (secondaryId != null) { >- viewId = ViewFactory.extractPrimaryId(viewId); >- } >- >- // Resolve the ref >- IViewReference ref = viewFactory.getView(viewId, secondaryId); >- viewRefs.add(ref); >- } >- >- fvb.setViewRefs(viewRefs); >- } >- } >- > HashSet knownActionSetIds = new HashSet(); > > // Load the always on action sets. >@@ -1646,7 +1495,6 @@ > .getKey(ref)); > } > >- // Save the set of all fast Views > if (fastViews.size() > 0) { > IMemento childMem = memento > .createChild(IWorkbenchConstants.TAG_FAST_VIEWS); >@@ -1662,24 +1510,6 @@ > } > } > >- // Save the set of all 'global' fast Views for this perspective >- // update the list of 'global' fast views >- WorkbenchWindow wbw = (WorkbenchWindow)page.getWorkbenchWindow(); >- FastViewBar globalFVB = wbw.getFastViewBar(); >- if (globalFVB != null && !globalFVBsaved) { >- globalFastViews = new ArrayList(globalFVB.getViewRefs()); >- globalFVBsaved = true; >- } >- >- IMemento globalFVBMem = memento >- .createChild(IWorkbenchConstants.TAG_GLOBAL_FAST_VIEWS); >- itr = globalFastViews.iterator(); >- while (itr.hasNext()) { >- IViewReference ref = (IViewReference) itr.next(); >- String id = ViewFactory.getKey(ref); >- globalFVBMem.createChild(IWorkbenchConstants.TAG_VIEW, id); >- } >- > // Save the view layout recs. > for (Iterator i = mapIDtoViewLayoutRec.keySet().iterator(); i.hasNext();) { > String compoundId = (String) i.next(); >@@ -1707,24 +1537,6 @@ > } > } > >- // Save the list of group FVB's >- IMemento fvbMem = memento.createChild(IWorkbenchConstants.TAG_FAST_GROUPS); >- for (Iterator fvbIter = fastViewBars.iterator(); fvbIter.hasNext();) { >- FastViewBar fvb = (FastViewBar) fvbIter.next(); >- IMemento fastViewBarMem = fvbMem.createChild(IWorkbenchConstants.TAG_FAST_VIEW_DATA); >- fastViewBarMem.putString(IWorkbenchConstants.TAG_ID, fvb.getId()); >- fvb.saveState(fastViewBarMem); >- >- // Store the view references for this FVB >- List viewRefs = fvb.getViewRefs(); >- IMemento viewsMem = fastViewBarMem.createChild(IWorkbenchConstants.TAG_VIEWS); >- for (Iterator fvIter = viewRefs.iterator(); fvIter.hasNext();) { >- IViewReference ref = (IViewReference) fvIter.next(); >- String id = ViewFactory.getKey(ref); >- viewsMem.createChild(IWorkbenchConstants.TAG_VIEW, id); >- } >- } >- > if (errors > 0) { > String message = WorkbenchMessages.Perspective_multipleErrors; > if (errors == 1) { >@@ -1834,33 +1646,28 @@ > } > } > >- public FastViewBar getFVBForRef(IViewReference ref) { >- for (Iterator fvbIter = fastViewBars.iterator(); fvbIter.hasNext();) { >- FastViewBar fvb = (FastViewBar) fvbIter.next(); >- if (fvb.hasViewRef(ref)) >- return fvb; >- } >- >- return null; >- } > /** > * Sets the selection for the shortcut bar icon representing the givevn fast view. > */ > private void setFastViewIconSelection(IViewReference ref, boolean selected) { >- WorkbenchWindow window = (WorkbenchWindow) page.getWorkbenchWindow(); >- FastViewBar bar = getFVBForRef(ref); >- if (bar == null) >- bar = window.getFastViewBar(); >- >- if (bar != null) { >- if (selected) { >- bar.setSelection(ref); >- } else { >- if (ref == bar.getSelection()) { >- bar.setSelection(null); >- } >- } >- } >+ // First, is it in a Trim Stack? >+ ViewStackTrimPart ts = getTrimStackForRef(ref); >+ if (ts != null) { >+ ts.setIconSelection(ref, selected); >+ return; >+ } >+ >+ WorkbenchWindow window = (WorkbenchWindow) page.getWorkbenchWindow(); >+ FastViewBar bar = window.getFastViewBar(); >+ if (bar != null) { >+ if (selected) { >+ bar.setSelection(ref); >+ } else { >+ if (ref == bar.getSelection()) { >+ bar.setSelection(null); >+ } >+ } >+ } > } > > /** >@@ -1909,6 +1716,20 @@ > editorHolder = null; > } > >+ private ViewStackTrimPart getTrimStackForRef(IViewReference ref) { >+ // Is it in a minimized stack? >+ List trimParts = presentation.getLayout().getTrimForParts(); >+ for (Iterator trimIter = trimParts.iterator(); trimIter.hasNext();) { >+ IWindowTrim trim = (IWindowTrim) trimIter.next(); >+ if (trim instanceof ViewStackTrimPart) { >+ if (((ViewStackTrimPart) trim).hasViewRef(ref)) >+ return (ViewStackTrimPart) trim; >+ } >+ } >+ >+ return null; >+ } >+ > /** > * Shows a fast view. > * @return whether the view was successfully shown >@@ -1926,15 +1747,23 @@ > > saveFastViewWidthRatio(); > >- WorkbenchWindow window = (WorkbenchWindow) page.getWorkbenchWindow(); >- FastViewBar bar = getFVBForRef(ref); >- if (bar == null) >- bar = window.getFastViewBar(); >- >- if (bar == null) { >- return false; >- } >- int side = bar.getViewSide(ref); >+ >+ // Determine the display orientation >+ int side; >+ ViewStackTrimPart ts = getTrimStackForRef(ref); >+ if (ts != null) { >+ side = ts.getViewSide(); >+ } else { >+ WorkbenchWindow window = (WorkbenchWindow) page >+ .getWorkbenchWindow(); >+ FastViewBar bar = window.getFastViewBar(); >+ >+ if (bar == null) { >+ return false; >+ } >+ >+ side = bar.getViewSide(ref); >+ } > > fastViewPane.showView(getClientComposite(), pane, side, > getFastViewWidthRatio(ref)); >@@ -1971,8 +1800,8 @@ > int openViewMode = store.getInt(IPreferenceConstants.OPEN_VIEW_MODE); > > if (openViewMode == IPreferenceConstants.OVM_FAST) { >- FastViewBar fvb = ((WorkbenchWindow)pane.getWorkbenchWindow()).getFastViewBar(); >- fvb.adoptView(ref, -1, true, true); >+ showFastView(ref); >+ addFastView(ref); > } else if (openViewMode == IPreferenceConstants.OVM_FLOAT > && presentation.canDetach()) { > presentation.addDetachedPart(pane); >@@ -2171,4 +2000,176 @@ > return fastViewPane; > } > >+ // Trim Stack Support >+ >+ /** >+ * Hack to get around 'addFastView' issues >+ * >+ * @param ref >+ */ >+ public void addFastViewHack(IViewReference ref) { >+ //addFastView(ref, false); >+ } >+ >+ /** >+ * Hack to get around 'addFastView' issues >+ * >+ * @param ref >+ */ >+ public void removeFastViewHack(IViewReference ref) { >+ //removeFastView(ref, false); >+ } >+ >+ /** >+ * Moves any parts that support trim representation into the trim >+ * >+ * @param parts The parts to (potentially) move to the trim >+ * @param restoreOnUnzoom 'true' iff we want the parts to >+ * automatically restore on an 'unzoom'. >+ */ >+ public void movePartsToTrim(List parts, boolean restoreOnUnzoom) { >+ if (parts == null || parts.size() == 0) >+ return; >+ >+ Shell shell = page.getWorkbenchWindow().getShell(); >+ RectangleAnimation animation = new RectangleAnimation(shell, null, null); >+ >+ // Capture the area the stack currently occupies (and its image) >+ for (Iterator stackIter = parts.iterator(); stackIter.hasNext();) { >+ LayoutPart part = (LayoutPart) stackIter.next(); >+ if (part.getControl() != null) >+ animation.addStartRect(DragUtil.getDisplayBounds(part >+ .getControl())); >+ } >+ >+ // Gain access to the trim manager >+ WorkbenchWindow wbw = (WorkbenchWindow) page.getWorkbenchWindow(); >+ ITrimManager tbm = wbw.getTrimManager(); >+ >+ // Iterate through all the parts, moving each to the trim >+ int newTrimState = restoreOnUnzoom ? LayoutPart.TRIMSTATE_ZOOMEDTOTRIM >+ : LayoutPart.TRIMSTATE_IN_TRIM; >+ >+ // We hide the editor container last so its position can be used >+ // to calculate the correct side for other trim >+ boolean moveEditorAreaToTrim = false; >+ >+ List newTrimParts = new ArrayList(); >+ for (Iterator stackIter = parts.iterator(); stackIter.hasNext();) { >+ LayoutPart part = (LayoutPart) stackIter.next(); >+ >+ // for now be careful and only manipulate 'known' part types >+ // should generalize... >+ if (part instanceof ViewStack) { >+ part.setTrimState(newTrimState); >+ IWindowTrim partTrim = tbm.getTrim(part.getID()); >+ if (partTrim != null) { >+ newTrimParts.add(partTrim); >+ } >+ } else if (part instanceof EditorSashContainer) { >+ moveEditorAreaToTrim = true; >+ } >+ } >+ >+ if (moveEditorAreaToTrim) { >+ editorArea.setTrimState(newTrimState); >+ hideEditorArea(); >+ >+ IWindowTrim partTrim = tbm.getTrim(editorArea.getID()); >+ if (partTrim != null) { >+ newTrimParts.add(partTrim); >+ } >+ } >+ >+ // Force a layout if necessary >+ if (newTrimParts.size() == 0) >+ return; >+ >+ // OK, we're good to go >+ tbm.forceLayout(); >+ >+ // Now that the layout is finished we can add the 'end' rects for the >+ // animation >+ for (Iterator tsIter = newTrimParts.iterator(); tsIter.hasNext();) { >+ TrimPart ts = (TrimPart) tsIter.next(); >+ animation.addEndRect(DragUtil.getDisplayBounds(ts.getControl())); >+ } >+ >+ animation.schedule(); >+ } >+ >+ /** >+ * Restores a part in the trim to the actual layout >+ * @param part The part to restore >+ */ >+ public void restoreTrimPart(LayoutPart part) { >+ // Remove any current fastview >+ setActiveFastView(null); >+ >+ // Set the part's state to place it back in the layout >+ part.setTrimState(LayoutPart.TRIMSTATE_NORMAL); >+ >+ if (part == editorArea) >+ showEditorArea(); >+ >+ WorkbenchWindow wbw = (WorkbenchWindow) page.getWorkbenchWindow(); >+ ITrimManager tbm = wbw.getTrimManager(); >+ tbm.forceLayout(); >+ } >+ >+ /** >+ * Determine the correct side to initially dock a new >+ * trim part on. We do this by checking its rect against >+ * the editor area. >+ * >+ * @param stackBounds The bounds of the stack we want to create trim for >+ * @return the SWT side to dock the trim element on >+ */ >+ public int calcStackSide(Rectangle stackBounds) { >+ // Where is the stack in relation to the EditorArea? >+ Rectangle editorAreaBounds = editorArea.getBounds(); >+ >+ // Is this the Editor Area >+ if (editorAreaBounds.equals(stackBounds)) >+ return SWT.TOP; >+ >+ Point stackCenter = Geometry.centerPoint(stackBounds); >+ Point editorAreaCenter = Geometry.centerPoint(editorAreaBounds); >+ >+ int dx = editorAreaCenter.x - stackCenter.x; >+ int dy = editorAreaCenter.y - stackCenter.y; >+ >+ if (Math.abs(dx) > Math.abs(dy)) { >+ return (dx > 0) ? SWT.LEFT : SWT.RIGHT; >+ } >+ >+ return (dy > 0) ? SWT.TOP : SWT.BOTTOM; >+ } >+ >+ /** >+ * Restore any parts that are showing in the trim as >+ * a result of a 'zoom' operation >+ */ >+ public void restoreZoomedParts() { >+ // Remove any current fastview >+ setActiveFastView(null); >+ >+ // Is the editotr 'zoomed'? >+ boolean editorZoomed = (editorHolder != null && >+ editorArea.getTrimState() == LayoutPart.TRIMSTATE_ZOOMEDTOTRIM); >+ >+ // have the layout restore the parts >+ boolean needsLayout = presentation.getLayout().restoreZoomedTrimParts(); >+ if (needsLayout) { >+ // Force a layout >+ WorkbenchWindow wbw = (WorkbenchWindow) page.getWorkbenchWindow(); >+ ITrimManager tbm = wbw.getTrimManager(); >+ tbm.forceLayout(); >+ } >+ >+ if (editorZoomed) { >+ editorArea.setTrimState(LayoutPart.TRIMSTATE_NORMAL); >+ showEditorArea(); >+ } >+ } > } >Index: Eclipse UI/org/eclipse/ui/internal/EditorAreaTrimPart.java >=================================================================== >RCS file: Eclipse UI/org/eclipse/ui/internal/EditorAreaTrimPart.java >diff -N Eclipse UI/org/eclipse/ui/internal/EditorAreaTrimPart.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ Eclipse UI/org/eclipse/ui/internal/EditorAreaTrimPart.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,53 @@ >+/******************************************************************************* >+ * Copyright (c) 2006 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ ******************************************************************************/ >+ >+package org.eclipse.ui.internal; >+ >+import org.eclipse.swt.SWT; >+import org.eclipse.swt.events.SelectionEvent; >+import org.eclipse.swt.events.SelectionListener; >+import org.eclipse.swt.graphics.Image; >+import org.eclipse.swt.widgets.ToolItem; >+ >+/** >+ * A trim element representing the EditorArea >+ * >+ * @since 3.3 >+ * >+ */ >+public class EditorAreaTrimPart extends TrimPart { >+ >+ public EditorAreaTrimPart(WorkbenchWindow window, EditorSashContainer editorArea) { >+ super(window, editorArea); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.ui.internal.TrimPart#addItems() >+ */ >+ protected void addItems() { >+ // Since we dont have fast view behaviour for ediors we >+ // simply restore the editor area on selection >+ ToolItem editorAreaItem = new ToolItem(toolBar, SWT.PUSH, toolBar.getItemCount()); >+ Image tbImage = WorkbenchImages.getImage(IWorkbenchGraphicConstants.IMG_ETOOL_EDITOR_TRIMPART); >+ editorAreaItem.setImage(tbImage); >+ String menuTip = WorkbenchMessages.EditorArea_Tooltip; >+ editorAreaItem.setToolTipText(menuTip); >+ editorAreaItem.addSelectionListener(new SelectionListener() { >+ public void widgetDefaultSelected(SelectionEvent e) { >+ restorePart(); >+ } >+ public void widgetSelected(SelectionEvent e) { >+ restorePart(); >+ } >+ }); >+ } >+ >+} >Index: Eclipse UI/org/eclipse/ui/internal/ViewStackTrimPart.java >=================================================================== >RCS file: Eclipse UI/org/eclipse/ui/internal/ViewStackTrimPart.java >diff -N Eclipse UI/org/eclipse/ui/internal/ViewStackTrimPart.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ Eclipse UI/org/eclipse/ui/internal/ViewStackTrimPart.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,253 @@ >+/******************************************************************************* >+ * Copyright (c) 2006 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ ******************************************************************************/ >+ >+package org.eclipse.ui.internal; >+ >+import java.util.ArrayList; >+import java.util.Iterator; >+import java.util.List; >+ >+import org.eclipse.jface.util.Geometry; >+import org.eclipse.swt.SWT; >+import org.eclipse.swt.events.SelectionEvent; >+import org.eclipse.swt.events.SelectionListener; >+import org.eclipse.swt.graphics.Point; >+import org.eclipse.swt.graphics.Rectangle; >+import org.eclipse.swt.widgets.ToolItem; >+import org.eclipse.ui.IViewReference; >+import org.eclipse.ui.IWorkbenchPartReference; >+import org.eclipse.ui.internal.presentations.PresentablePart; >+import org.eclipse.ui.internal.presentations.util.TabbedStackPresentation; >+import org.eclipse.ui.presentations.IPresentablePart; >+ >+/** >+ * A trim element representing a ViewStack in the trim. >+ * <p> >+ * The placeholder must be non-null and its >+ * 'real' container must be a <code>ViewStack</code>. >+ * </p> >+ * >+ * @since 3.3 >+ * >+ */ >+public class ViewStackTrimPart extends TrimPart { >+ ContainerPlaceholder placeHolder; >+ ViewStack stack; >+ >+ // The orientation of the fast view pane when showing a view >+ int paneOrientation; >+ >+ /** >+ * Construct a new trim element for the given ViewStack >+ * >+ * @param window The window hosting the trim >+ * @param placeHolder The placeholder who's real container is >+ * the ViewStack being represented. >+ */ >+ public ViewStackTrimPart(WorkbenchWindow window, ContainerPlaceholder placeHolder) { >+ super(window, placeHolder.getRealContainer()); >+ >+ setPlaceholder(placeHolder); >+ >+ // Set the display orientation based on the stack's geometry >+ Rectangle stackBounds = stack.getBounds(); >+ paneOrientation = (stackBounds.width > stackBounds.height) ? SWT.HORIZONTAL : SWT.VERTICAL; >+ } >+ >+ /** >+ * Sets the current placeholder. This is used by the ViewStack >+ * when its trim state changes, causing it to create a new placeholder. >+ * >+ * @param placeHolder the current placeholder >+ */ >+ public void setPlaceholder(ContainerPlaceholder placeHolder) { >+ this.placeHolder = placeHolder; >+ this.stack = (ViewStack) placeHolder.getRealContainer(); >+ } >+ >+ /** >+ * Add a button for every view reference in the stack being >+ * represented. >+ */ >+ protected void addItems() { >+ List orderedViews = getTrueViewOrder(); >+ if (orderedViews.size() == 0) >+ return; >+ >+ // Add a button for each view reference in the stack >+ for (Iterator iterator = orderedViews.iterator(); iterator.hasNext();) { >+ IViewReference ref = (IViewReference) iterator.next(); >+ >+ // Set up the item's 'look' >+ ToolItem viewButton = new ToolItem(toolBar, SWT.CHECK); >+ viewButton.setImage(ref.getTitleImage()); >+ viewButton.setToolTipText(ref.getTitle()); >+ viewButton.addSelectionListener(new SelectionListener() { >+ public void widgetDefaultSelected(SelectionEvent e) { >+ showView(e); >+ } >+ public void widgetSelected(SelectionEvent e) { >+ showView(e); >+ } >+ }); >+ >+ viewButton.setData(ref); >+ } >+ } >+ >+ /** >+ * Returns the 'side' to place the current fast view on. This should >+ * really be changed... >+ * >+ * @return The side (calc'd a la the FastViewBar:getViewSide method) >+ */ >+ public int getPaneOrientation() { >+ // determine where the bar is in relation to the workbench window >+ Rectangle tsBounds = getControl().getBounds(); >+ Rectangle wbBounds = getControl().getShell().getBounds(); >+ >+ if (paneOrientation == SWT.HORIZONTAL) { >+ if (curSide == SWT.LEFT || curSide == SWT.RIGHT) { >+ // is the trim bar nearer to the top or the bottom? >+ if (Geometry.centerPoint(tsBounds).y < Geometry.centerPoint(wbBounds).y) >+ return SWT.TOP; >+ >+ return SWT.BOTTOM; >+ } >+ >+ return curSide; >+ } >+ >+ // Vertical >+ if (curSide == SWT.TOP || curSide == SWT.BOTTOM) { >+ // is the trim bar nearer to the left or the right? >+ if (Geometry.centerPoint(tsBounds).x < Geometry.centerPoint(wbBounds).x) >+ return SWT.LEFT; >+ >+ return SWT.RIGHT; >+ } >+ >+ return curSide; >+ } >+ >+ /** >+ * Show the selected view as a fast view. >+ * >+ * @param e The event causing the view to be shown >+ * >+ */ >+ protected void showView(SelectionEvent e) { >+ Perspective persp = window.getActiveWorkbenchPage().getActivePerspective(); >+ ToolItem item = (ToolItem) e.getSource(); >+ IViewReference ref = (IViewReference) item.getData(); >+ persp.toggleFastView(ref); >+ } >+ >+ /** >+ * @return a List of <code>IViewReference</code> >+ * sorted into the order in which they appear in the >+ * visual stack. >+ */ >+ private List getTrueViewOrder() { >+ List orderedViews = new ArrayList(); >+ if (stack.getPresentation() instanceof TabbedStackPresentation) { >+ TabbedStackPresentation tsp = (TabbedStackPresentation) stack.getPresentation(); >+ >+ // KLUDGE!! uses a 'testing only' API >+ IPresentablePart[] parts = tsp.getPartList(); >+ for (int i = 0; i < parts.length; i++) { >+ if (parts[i] instanceof PresentablePart) { >+ PresentablePart part = (PresentablePart) parts[i]; >+ IWorkbenchPartReference ref = part.getPane().getPartReference(); >+ if (ref instanceof IViewReference) >+ orderedViews.add(ref); >+ } >+ } >+ } >+ >+ return orderedViews; >+ } >+ >+ /** >+ * @param refToFind The reference being checked for >+ * @return true if this stack owns the reference. >+ */ >+ public boolean hasViewRef(IViewReference refToFind) { >+ ToolItem[] items = toolBar.getItems(); >+ for (int i = 0; i < items.length; i++) { >+ IViewReference ref = (IViewReference) items[i].getData(); >+ if (ref == refToFind) >+ return true; >+ } >+ >+ return false; >+ } >+ >+ /** >+ * @return The list of all view references in the stack >+ */ >+ public List getViewRefs() { >+ List refs = new ArrayList(toolBar.getItemCount()); >+ ToolItem[] items = toolBar.getItems(); >+ for (int i = 0; i < items.length; i++) { >+ Object data = items[i].getData(); >+ if (data instanceof IViewReference) >+ refs.add(data); >+ } >+ >+ return refs; >+ } >+ >+ /** >+ * @return The side that the fast view pane should be attached to >+ * based on the position of the trim element. >+ */ >+ public int getViewSide() { >+ if (paneOrientation == SWT.HORIZONTAL) { >+ if (curSide == SWT.TOP || curSide == SWT.BOTTOM) >+ return curSide; >+ >+ return SWT.TOP; >+ } >+ >+ // Vertical >+ if (curSide == SWT.LEFT || curSide == SWT.RIGHT) >+ return curSide; >+ >+ // Are we on the left or right 'end' of the trim area? >+ Point trimCenter = Geometry.centerPoint(getControl().getBounds()); >+ Point shellCenter = Geometry.centerPoint(getControl().getShell().getClientArea()); >+ return (trimCenter.x < shellCenter.x) ? SWT.LEFT : SWT.RIGHT; >+ } >+ >+ /** >+ * @return the current placeholder >+ */ >+ public ContainerPlaceholder getPlaceholder() { >+ return placeHolder; >+ } >+ >+ /** >+ * This is used by the Perspective to match the icon's >+ * state to the state of the active fast view. >+ * >+ * @param refToSet The view reference to set the state of >+ * @param selected The new state for the icon >+ */ >+ public void setIconSelection(IViewReference refToSet, boolean selected) { >+ ToolItem[] items = toolBar.getItems(); >+ for (int i = 0; i < items.length; i++) { >+ IViewReference ref = (IViewReference) items[i].getData(); >+ if (ref == refToSet) >+ items[i].setSelection(selected); >+ } >+ } >+} >Index: Eclipse UI/org/eclipse/ui/internal/TrimPart.java >=================================================================== >RCS file: Eclipse UI/org/eclipse/ui/internal/TrimPart.java >diff -N Eclipse UI/org/eclipse/ui/internal/TrimPart.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ Eclipse UI/org/eclipse/ui/internal/TrimPart.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,180 @@ >+/******************************************************************************* >+ * Copyright (c) 2006 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ ******************************************************************************/ >+ >+package org.eclipse.ui.internal; >+ >+import org.eclipse.swt.SWT; >+import org.eclipse.swt.events.SelectionEvent; >+import org.eclipse.swt.events.SelectionListener; >+import org.eclipse.swt.graphics.Image; >+import org.eclipse.swt.graphics.Point; >+import org.eclipse.swt.widgets.Control; >+import org.eclipse.swt.widgets.ToolBar; >+import org.eclipse.swt.widgets.ToolItem; >+import org.eclipse.ui.internal.layout.IWindowTrim; >+ >+/** >+ * This is the base class to use to represent a LayoutPart when >+ * it is being displayed in the trim. >+ * <p> >+ * It manages the life-cycle of the control and its contents but >+ * requres that subclasses populate the ToolBar with its own items >+ * and the logic to control them. >+ * >+ * @since 3.3 >+ * >+ */ >+public abstract class TrimPart implements IWindowTrim { >+ // State >+ protected WorkbenchWindow window; >+ protected LayoutPart part; >+ >+ // Trim State >+ protected ToolBar toolBar = null; >+ protected int curSide; >+ >+ // Abstract methods for subclass's life-cycle >+ >+ /** >+ * Add the items appropiate for the particular >+ * subclass. >+ */ >+ protected abstract void addItems(); >+ >+ /** >+ * Constructs a trim element for some LayoutPart >+ * >+ * @param window The window hosting this trim element >+ * @param part The LayoutPart being represented >+ */ >+ public TrimPart(WorkbenchWindow window, LayoutPart part) { >+ this.window = window; >+ this.part = part; >+ } >+ >+ // TrimPart Life-cycle >+ >+ /** >+ * Put the stack back into the presentation >+ */ >+ protected void restorePart() { >+ Perspective persp = window.getActiveWorkbenchPage().getActivePerspective(); >+ >+ if (part != null) >+ persp.restoreTrimPart(part); >+ } >+ >+ /** >+ * Clear items added by the subclass. The subclass should >+ * add a dispose listener if it needs to clean up... >+ */ >+ private void clearContributions() { >+ // Clear all items -except- the restore button >+ ToolItem[] items = toolBar.getItems(); >+ for (int i = 1; i < items.length; i++) { >+ items[i].dispose(); >+ } >+ } >+ >+ /** >+ * Cycle the contents of the part in order to pick >+ * up any changes in the actual part that the trim >+ * is representing. >+ */ >+ public void refresh() { >+ clearContributions(); >+ addItems(); >+ } >+ >+ // IWindowTrim handling >+ >+ /** >+ * Create the Toolbar >+ */ >+ private void createControl() { >+ int orientation = (curSide == SWT.TOP || curSide == SWT.BOTTOM) ? >+ SWT.HORIZONTAL : SWT.VERTICAL; >+ toolBar = new ToolBar(window.getShell(), orientation); >+ >+ // Construct the 'restore' button >+ ToolItem restoreItem = new ToolItem(toolBar, SWT.PUSH, 0); >+ Image tbImage = WorkbenchImages.getImage(IWorkbenchGraphicConstants.IMG_ETOOL_RESTORE_TRIMPART); >+ restoreItem.setImage(tbImage); >+ String menuTip = WorkbenchMessages.StandardSystemToolbar_Restore; >+ restoreItem.setToolTipText(menuTip); >+ restoreItem.addSelectionListener(new SelectionListener() { >+ public void widgetDefaultSelected(SelectionEvent e) { >+ restorePart(); >+ } >+ public void widgetSelected(SelectionEvent e) { >+ restorePart(); >+ } >+ }); >+ >+ // refresh the bar's contents >+ addItems(); >+ } >+ >+ private void dispose() { >+ if (toolBar != null) >+ toolBar.dispose(); >+ toolBar = null; >+ } >+ >+ public void dock(int dropSide) { >+ curSide = dropSide; >+ >+ // Re-create the toolBar >+ dispose(); >+ createControl(); >+ } >+ >+ public Control getControl() { >+ return toolBar; >+ } >+ >+ public String getDisplayName() { >+ return part.getID(); >+ } >+ >+ public int getHeightHint() { >+ Point cs = toolBar.computeSize(SWT.DEFAULT, SWT.DEFAULT); >+ return cs.y; >+ } >+ >+ public String getId() { >+ return part.getID(); >+ } >+ >+ public int getValidSides() { >+ return SWT.TOP | SWT.BOTTOM | SWT.LEFT | SWT.RIGHT; >+ } >+ >+ public int getWidthHint() { >+ return toolBar.computeSize(SWT.DEFAULT, SWT.DEFAULT).x; >+ } >+ >+ public void handleClose() { >+ } >+ >+ public boolean isCloseable() { >+ return false; >+ } >+ >+ public boolean isResizeable() { >+ return false; >+ } >+ >+ public int getCurrentSide() { >+ return curSide; >+ } >+ >+}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 153957
:
47949
|
47960
|
48255
| 52703 |
72416