|
Lines 26-33
Link Here
|
| 26 |
import org.eclipse.jface.dialogs.ErrorDialog; |
26 |
import org.eclipse.jface.dialogs.ErrorDialog; |
| 27 |
import org.eclipse.jface.dialogs.MessageDialog; |
27 |
import org.eclipse.jface.dialogs.MessageDialog; |
| 28 |
import org.eclipse.jface.preference.IPreferenceStore; |
28 |
import org.eclipse.jface.preference.IPreferenceStore; |
|
|
29 |
import org.eclipse.jface.util.Geometry; |
| 29 |
import org.eclipse.osgi.util.NLS; |
30 |
import org.eclipse.osgi.util.NLS; |
| 30 |
import org.eclipse.swt.SWT; |
31 |
import org.eclipse.swt.SWT; |
|
|
32 |
import org.eclipse.swt.graphics.Point; |
| 31 |
import org.eclipse.swt.graphics.Rectangle; |
33 |
import org.eclipse.swt.graphics.Rectangle; |
| 32 |
import org.eclipse.swt.widgets.Composite; |
34 |
import org.eclipse.swt.widgets.Composite; |
| 33 |
import org.eclipse.swt.widgets.Control; |
35 |
import org.eclipse.swt.widgets.Control; |
|
Lines 43-48
Link Here
|
| 43 |
import org.eclipse.ui.IViewSite; |
45 |
import org.eclipse.ui.IViewSite; |
| 44 |
import org.eclipse.ui.IWorkbenchPart; |
46 |
import org.eclipse.ui.IWorkbenchPart; |
| 45 |
import org.eclipse.ui.IWorkbenchPartReference; |
47 |
import org.eclipse.ui.IWorkbenchPartReference; |
|
|
48 |
import org.eclipse.ui.IWorkbenchPreferenceConstants; |
| 46 |
import org.eclipse.ui.PartInitException; |
49 |
import org.eclipse.ui.PartInitException; |
| 47 |
import org.eclipse.ui.PlatformUI; |
50 |
import org.eclipse.ui.PlatformUI; |
| 48 |
import org.eclipse.ui.WorkbenchException; |
51 |
import org.eclipse.ui.WorkbenchException; |
|
Lines 50-57
Link Here
|
| 50 |
import org.eclipse.ui.internal.dnd.DragUtil; |
53 |
import org.eclipse.ui.internal.dnd.DragUtil; |
| 51 |
import org.eclipse.ui.internal.intro.IIntroConstants; |
54 |
import org.eclipse.ui.internal.intro.IIntroConstants; |
| 52 |
import org.eclipse.ui.internal.layout.ITrimManager; |
55 |
import org.eclipse.ui.internal.layout.ITrimManager; |
|
|
56 |
import org.eclipse.ui.internal.layout.IWindowTrim; |
| 53 |
import org.eclipse.ui.internal.misc.StatusUtil; |
57 |
import org.eclipse.ui.internal.misc.StatusUtil; |
| 54 |
import org.eclipse.ui.internal.presentations.PresentablePart; |
|
|
| 55 |
import org.eclipse.ui.internal.registry.ActionSetRegistry; |
58 |
import org.eclipse.ui.internal.registry.ActionSetRegistry; |
| 56 |
import org.eclipse.ui.internal.registry.IActionSetDescriptor; |
59 |
import org.eclipse.ui.internal.registry.IActionSetDescriptor; |
| 57 |
import org.eclipse.ui.internal.registry.IWorkbenchRegistryConstants; |
60 |
import org.eclipse.ui.internal.registry.IWorkbenchRegistryConstants; |
|
Lines 59-64
Link Here
|
| 59 |
import org.eclipse.ui.internal.registry.PerspectiveExtensionReader; |
62 |
import org.eclipse.ui.internal.registry.PerspectiveExtensionReader; |
| 60 |
import org.eclipse.ui.internal.registry.PerspectiveRegistry; |
63 |
import org.eclipse.ui.internal.registry.PerspectiveRegistry; |
| 61 |
import org.eclipse.ui.internal.registry.StickyViewDescriptor; |
64 |
import org.eclipse.ui.internal.registry.StickyViewDescriptor; |
|
|
65 |
import org.eclipse.ui.internal.util.PrefUtil; |
| 62 |
import org.eclipse.ui.views.IStickyViewDescriptor; |
66 |
import org.eclipse.ui.views.IStickyViewDescriptor; |
| 63 |
import org.eclipse.ui.views.IViewDescriptor; |
67 |
import org.eclipse.ui.views.IViewDescriptor; |
| 64 |
import org.eclipse.ui.views.IViewRegistry; |
68 |
import org.eclipse.ui.views.IViewRegistry; |
|
Lines 88-96
Link Here
|
| 88 |
private ArrayList perspectiveShortcuts; |
92 |
private ArrayList perspectiveShortcuts; |
| 89 |
|
93 |
|
| 90 |
private ArrayList fastViews; |
94 |
private ArrayList fastViews; |
| 91 |
private List globalFastViews; |
|
|
| 92 |
private boolean globalFVBsaved = false; |
| 93 |
private ArrayList fastViewBars; |
| 94 |
|
95 |
|
| 95 |
private Map mapIDtoViewLayoutRec; |
96 |
private Map mapIDtoViewLayoutRec; |
| 96 |
|
97 |
|
|
Lines 143-176
Link Here
|
| 143 |
alwaysOnActionSets = new ArrayList(2); |
144 |
alwaysOnActionSets = new ArrayList(2); |
| 144 |
alwaysOffActionSets = new ArrayList(2); |
145 |
alwaysOffActionSets = new ArrayList(2); |
| 145 |
fastViews = new ArrayList(2); |
146 |
fastViews = new ArrayList(2); |
| 146 |
globalFastViews = new ArrayList(2); |
|
|
| 147 |
fastViewBars = new ArrayList(2); |
| 148 |
mapIDtoViewLayoutRec = new HashMap(); |
147 |
mapIDtoViewLayoutRec = new HashMap(); |
| 149 |
} |
148 |
} |
| 150 |
|
149 |
|
| 151 |
/** |
150 |
/** |
| 152 |
* Sets the fast view attribute. |
151 |
* Sets the fast view attribute. Note: The page is expected to update action |
| 153 |
* Note: The page is expected to update action bars. |
152 |
* bars. |
| 154 |
*/ |
153 |
*/ |
| 155 |
public void addFastView(IViewReference ref) { |
154 |
public void addFastView(IViewReference ref) { |
| 156 |
ViewPane pane = (ViewPane) ((WorkbenchPartReference) ref).getPane(); |
155 |
addFastView(ref, true); |
| 157 |
if (!isFastView(ref)) { |
156 |
} |
| 158 |
// Only remove the part from the presentation if it |
157 |
|
| 159 |
// is actually in the presentation. |
158 |
/** |
| 160 |
if (presentation.hasPlaceholder(ref.getId(), ref.getSecondaryId()) |
159 |
* Sets the fast view attribute. Note: The page is expected to update action |
| 161 |
|| pane.getContainer() != null) { |
160 |
* bars. |
| 162 |
presentation.removePart(pane); |
161 |
*/ |
| 163 |
} |
162 |
public void addFastView(IViewReference ref, boolean handleLayout) { |
| 164 |
// We are drag-enabling the pane because it has been disabled |
163 |
ViewPane pane = (ViewPane) ((WorkbenchPartReference) ref).getPane(); |
| 165 |
// when it was removed from the perspective presentation. |
164 |
if (!isFastView(ref)) { |
| 166 |
fastViews.add(ref); |
165 |
if (handleLayout) { |
| 167 |
pane.setFast(true); |
166 |
// Only remove the part from the presentation if it |
| 168 |
Control ctrl = pane.getControl(); |
167 |
// is actually in the presentation. |
| 169 |
if (ctrl != null) { |
168 |
if (presentation.hasPlaceholder(ref.getId(), ref.getSecondaryId()) |
|
|
169 |
|| pane.getContainer() != null) { |
| 170 |
presentation.removePart(pane); |
| 171 |
} |
| 172 |
} |
| 173 |
|
| 174 |
// We are drag-enabling the pane because it has been disabled |
| 175 |
// when it was removed from the perspective presentation. |
| 176 |
fastViews.add(ref); |
| 177 |
pane.setFast(true); |
| 178 |
Control ctrl = pane.getControl(); |
| 179 |
if (ctrl != null) { |
| 170 |
ctrl.setEnabled(false); // Remove focus support. |
180 |
ctrl.setEnabled(false); // Remove focus support. |
| 171 |
} |
181 |
} |
| 172 |
} |
182 |
} |
| 173 |
} |
183 |
} |
| 174 |
|
184 |
|
| 175 |
/** |
185 |
/** |
| 176 |
* Moves a part forward in the Z order of a perspective so it is visible. |
186 |
* Moves a part forward in the Z order of a perspective so it is visible. |
|
Lines 319-470
Link Here
|
| 319 |
return array; |
329 |
return array; |
| 320 |
} |
330 |
} |
| 321 |
|
331 |
|
| 322 |
public void closeTrimGroup(FastViewBar groupBar) { |
|
|
| 323 |
groupBar.restoreGroup(); |
| 324 |
|
| 325 |
WorkbenchWindow wbw = (WorkbenchWindow)page.getWorkbenchWindow(); |
| 326 |
ITrimManager tbm = wbw.getTrimManager(); |
| 327 |
tbm.removeTrim(groupBar); |
| 328 |
groupBar.getControl().setVisible(false); |
| 329 |
groupBar.dispose(); |
| 330 |
|
| 331 |
fastViewBars.remove(groupBar); |
| 332 |
|
| 333 |
tbm.forceLayout(); |
| 334 |
} |
| 335 |
|
| 336 |
private String getUniqueGroupId() { |
| 337 |
// Get a unique id |
| 338 |
boolean found = false; |
| 339 |
int count = 0; |
| 340 |
String id = ""; //$NON-NLS-1$ |
| 341 |
while (!found) { |
| 342 |
id = getDesc().getId() + " (" + count + ")"; //$NON-NLS-1$//$NON-NLS-2$ |
| 343 |
boolean matchFound = false; |
| 344 |
for (Iterator fvbIter = fastViewBars.iterator(); fvbIter.hasNext();) { |
| 345 |
FastViewBar fvb = (FastViewBar) fvbIter.next(); |
| 346 |
if (fvb.getId().equals(id)) { |
| 347 |
matchFound = true; |
| 348 |
break; |
| 349 |
} |
| 350 |
} |
| 351 |
|
| 352 |
if (matchFound) |
| 353 |
count++; |
| 354 |
else |
| 355 |
found = true; |
| 356 |
} |
| 357 |
|
| 358 |
return id; |
| 359 |
} |
| 360 |
|
| 361 |
private int calcStackSide (ViewStack stack) { |
| 362 |
// Where is the stack in relation to the EditorArea? |
| 363 |
Rectangle stackBounds = stack.getBounds(); |
| 364 |
Rectangle editorAreaBounds = editorArea.getBounds(); |
| 365 |
|
| 366 |
if ((stackBounds.x+stackBounds.width) < editorAreaBounds.x) |
| 367 |
return SWT.LEFT; |
| 368 |
if (stackBounds.x > (editorAreaBounds.x+editorAreaBounds.width)) |
| 369 |
return SWT.RIGHT; |
| 370 |
if ((stackBounds.y+stackBounds.height) < editorAreaBounds.y) |
| 371 |
return SWT.TOP; |
| 372 |
if (stackBounds.y > (editorAreaBounds.y+editorAreaBounds.height)) |
| 373 |
return SWT.BOTTOM; |
| 374 |
|
| 375 |
return SWT.BOTTOM; // shouldn't be able to get here... |
| 376 |
} |
| 377 |
|
| 378 |
public void moveToTrim(List stacks, int style) { |
| 379 |
if (stacks == null || stacks.size() == 0) |
| 380 |
return; |
| 381 |
|
| 382 |
Shell shell = ((ViewStack)stacks.get(0)).getShell(); |
| 383 |
RectangleAnimation animation = new RectangleAnimation(shell, null, null); |
| 384 |
|
| 385 |
// Capture the area the stack currently occupies (and its image) |
| 386 |
for (Iterator stackIter = stacks.iterator(); stackIter.hasNext();) { |
| 387 |
ViewStack stack = (ViewStack) stackIter.next(); |
| 388 |
animation.addStartRect(DragUtil.getDisplayBounds(stack.getControl())); |
| 389 |
} |
| 390 |
|
| 391 |
// Iterate through all the stacks, moveing each to the trim |
| 392 |
List newFVBs = new ArrayList(stacks.size()); |
| 393 |
for (Iterator stackIter = stacks.iterator(); stackIter.hasNext();) { |
| 394 |
ViewStack stack = (ViewStack) stackIter.next(); |
| 395 |
|
| 396 |
// Place the stack on the correct side |
| 397 |
int side = calcStackSide(stack); |
| 398 |
FastViewBar fvb = createFastViewBar(getUniqueGroupId(), style, side); |
| 399 |
newFVBs.add(fvb); |
| 400 |
|
| 401 |
// Add all the views in the stack to teh new FVB |
| 402 |
ArrayList refs = new ArrayList(); |
| 403 |
List parts = stack.getPresentableParts(); |
| 404 |
for (Iterator partIter = parts.iterator(); partIter.hasNext();) { |
| 405 |
PresentablePart part = (PresentablePart) partIter.next(); |
| 406 |
if (part.getPane().getPartReference() instanceof ViewReference) { |
| 407 |
refs.add(part.getPane().getPartReference()); |
| 408 |
} |
| 409 |
} |
| 410 |
fvb.setViewRefs(refs); |
| 411 |
|
| 412 |
// Set the display orientation based on the stack's geometry |
| 413 |
Rectangle stackBounds = stack.getBounds(); |
| 414 |
int orientation = (stackBounds.width > stackBounds.height) ? SWT.HORIZONTAL : SWT.VERTICAL; |
| 415 |
fvb.setOrientation(orientation); |
| 416 |
|
| 417 |
// Move the views 'into' the new group |
| 418 |
fvb.collapseGroup(); |
| 419 |
|
| 420 |
} |
| 421 |
|
| 422 |
// Force a layout |
| 423 |
WorkbenchWindow wbw = (WorkbenchWindow)page.getWorkbenchWindow(); |
| 424 |
ITrimManager tbm = wbw.getTrimManager(); |
| 425 |
tbm.forceLayout(); |
| 426 |
|
| 427 |
// Now that the layout is finished we can add the 'end' rects for the animation |
| 428 |
for (Iterator fvbIter = newFVBs.iterator(); fvbIter.hasNext();) { |
| 429 |
FastViewBar fvb = (FastViewBar) fvbIter.next(); |
| 430 |
animation.addEndRect(DragUtil.getDisplayBounds(fvb.getControl())); |
| 431 |
} |
| 432 |
|
| 433 |
animation.schedule(); |
| 434 |
} |
| 435 |
|
| 436 |
public void restoreZoomGroups() { |
| 437 |
List toClose = new ArrayList(); |
| 438 |
|
| 439 |
// Get the groups to close in another list and... |
| 440 |
for (Iterator fvbIter = fastViewBars.iterator(); fvbIter.hasNext();) { |
| 441 |
FastViewBar fvb = (FastViewBar) fvbIter.next(); |
| 442 |
if (fvb.testStyleBit(FastViewBar.ZOOM_GROUP)) |
| 443 |
toClose.add(fvb); |
| 444 |
} |
| 445 |
|
| 446 |
// ... close them |
| 447 |
for (Iterator closeIter = toClose.iterator(); closeIter.hasNext();) { |
| 448 |
FastViewBar fvb = (FastViewBar) closeIter.next(); |
| 449 |
fvb.closeGroup(); |
| 450 |
} |
| 451 |
} |
| 452 |
|
| 453 |
private FastViewBar createFastViewBar(String id, int style, int side) { |
| 454 |
// Create the FVB on the given side |
| 455 |
WorkbenchWindow wbw = (WorkbenchWindow)page.getWorkbenchWindow(); |
| 456 |
FastViewBar newFVB = new FastViewBar(wbw, style, id); |
| 457 |
newFVB.createControl(wbw.getShell()); |
| 458 |
newFVB.dock(side); |
| 459 |
newFVB.getControl().setVisible(true); |
| 460 |
ITrimManager tbm = wbw.getTrimManager(); |
| 461 |
tbm.addTrim(side, newFVB); |
| 462 |
|
| 463 |
fastViewBars.add(newFVB); |
| 464 |
|
| 465 |
return newFVB; |
| 466 |
} |
| 467 |
|
| 468 |
/** |
332 |
/** |
| 469 |
* Returns the new wizard shortcuts associated with this perspective. |
333 |
* Returns the new wizard shortcuts associated with this perspective. |
| 470 |
* |
334 |
* |
|
Lines 936-1029
Link Here
|
| 936 |
/** |
800 |
/** |
| 937 |
* activate. |
801 |
* activate. |
| 938 |
*/ |
802 |
*/ |
| 939 |
protected void onActivate() { |
803 |
protected void onActivate() { |
| 940 |
|
804 |
// Update editor area state. |
| 941 |
// Update editor area state. |
805 |
if (editorArea.getControl() != null) { |
| 942 |
if (editorArea.getControl() != null) { |
806 |
editorArea.setVisible(isEditorAreaVisible()); |
| 943 |
editorArea.setVisible(isEditorAreaVisible()); |
807 |
} |
| 944 |
} |
808 |
|
|
|
809 |
// update the 'global' FVB |
| 810 |
FastViewBar fvb = ((WorkbenchWindow) page.getWorkbenchWindow()) |
| 811 |
.getFastViewBar(); |
| 812 |
if (fvb != null) { |
| 813 |
fvb.setViewRefs(fastViews); |
| 814 |
} |
| 815 |
|
| 816 |
// Update fast views. |
| 817 |
// Make sure the control for the fastviews are create so they can |
| 818 |
// be activated. |
| 819 |
for (int i = 0; i < fastViews.size(); i++) { |
| 820 |
ViewPane pane = getPane((IViewReference) fastViews.get(i)); |
| 821 |
if (pane != null) { |
| 822 |
Control ctrl = pane.getControl(); |
| 823 |
if (ctrl == null) { |
| 824 |
pane.createControl(getClientComposite()); |
| 825 |
ctrl = pane.getControl(); |
| 826 |
} |
| 827 |
ctrl.setEnabled(false); // Remove focus support. |
| 828 |
} |
| 829 |
} |
| 945 |
|
830 |
|
| 946 |
// Update fast views. |
831 |
// Set the visibility of all fast view pins |
| 947 |
// Make sure the control for the fastviews are create so they can |
832 |
setAllPinsVisible(true); |
| 948 |
// be activated. |
|
|
| 949 |
for (int i = 0; i < fastViews.size(); i++) { |
| 950 |
ViewPane pane = getPane((IViewReference) fastViews.get(i)); |
| 951 |
if (pane != null) { |
| 952 |
Control ctrl = pane.getControl(); |
| 953 |
if (ctrl == null) { |
| 954 |
pane.createControl(getClientComposite()); |
| 955 |
ctrl = pane.getControl(); |
| 956 |
} |
| 957 |
ctrl.setEnabled(false); // Remove focus support. |
| 958 |
} |
| 959 |
} |
| 960 |
|
| 961 |
// update the 'global' FVB |
| 962 |
FastViewBar fvb = ((WorkbenchWindow)page.getWorkbenchWindow()).getFastViewBar(); |
| 963 |
if (fvb != null) { |
| 964 |
fvb.setViewRefs(globalFastViews); |
| 965 |
globalFVBsaved = false; |
| 966 |
} |
| 967 |
|
833 |
|
| 968 |
// Show the trim groups |
834 |
// Show the layout |
| 969 |
WorkbenchWindow wbw = (WorkbenchWindow)page.getWorkbenchWindow(); |
835 |
presentation.activate(getClientComposite()); |
| 970 |
ITrimManager tbm = wbw.getTrimManager(); |
836 |
|
| 971 |
if (tbm != null) { |
837 |
// Trim Stack Support |
| 972 |
for (Iterator fvbIter = fastViewBars.iterator(); fvbIter.hasNext();) { |
838 |
IPreferenceStore preferenceStore = PrefUtil.getAPIPreferenceStore(); |
| 973 |
fvb = (FastViewBar) fvbIter.next(); |
839 |
boolean useNewMinMax = preferenceStore.getBoolean(IWorkbenchPreferenceConstants.ENABLE_NEW_MIN_MAX); |
| 974 |
fvb.update(false); |
840 |
if (useNewMinMax) { |
| 975 |
tbm.setTrimVisible(fvb, true); |
841 |
// We 'stall' the creation of trim elements until the first activation |
| 976 |
} |
842 |
createInitialTrim(); |
| 977 |
|
843 |
|
|
|
844 |
// Show Trim parts -after- activation |
| 845 |
presentation.getLayout().setTrimVisible(true); |
| 846 |
|
| 847 |
// The editor area's trim stack's visibility is the inverse |
| 848 |
// Of the actual editor area |
| 849 |
WorkbenchWindow wbw = (WorkbenchWindow) page.getWorkbenchWindow(); |
| 850 |
ITrimManager tbm = wbw.getTrimManager(); |
| 851 |
IWindowTrim eaTrim = tbm.getTrim(editorArea.getID()); |
| 852 |
if (eaTrim != null) { |
| 853 |
tbm.setTrimVisible(eaTrim, !isEditorAreaVisible()); |
| 854 |
} |
| 855 |
|
| 978 |
// if we're done then force an update...optimize out if possible |
856 |
// if we're done then force an update...optimize out if possible |
| 979 |
tbm.forceLayout(); |
857 |
tbm.forceLayout(); |
| 980 |
} |
858 |
} |
| 981 |
|
|
|
| 982 |
setAllPinsVisible(true); |
| 983 |
presentation.activate(getClientComposite()); |
| 984 |
|
859 |
|
| 985 |
if (shouldHideEditorsOnActivate) { |
860 |
if (shouldHideEditorsOnActivate) { |
| 986 |
// We do this here to ensure that createPartControl is called on the top editor |
861 |
// We do this here to ensure that createPartControl is called on the |
| 987 |
// before it is hidden. See bug 20166. |
862 |
// top editor |
| 988 |
hideEditorArea(); |
863 |
// before it is hidden. See bug 20166. |
| 989 |
shouldHideEditorsOnActivate = false; |
864 |
hideEditorArea(); |
| 990 |
} |
865 |
shouldHideEditorsOnActivate = false; |
| 991 |
} |
866 |
} |
|
|
867 |
} |
| 992 |
|
868 |
|
| 993 |
/** |
869 |
/** |
|
|
870 |
* Create any trim necessary to support the current |
| 871 |
* layout state |
| 872 |
*/ |
| 873 |
private void createInitialTrim() { |
| 874 |
WorkbenchWindow wbw = (WorkbenchWindow) page.getWorkbenchWindow(); |
| 875 |
ITrimManager tbm = wbw.getTrimManager(); |
| 876 |
|
| 877 |
LayoutPart[] children = presentation.getLayout().getChildren(); |
| 878 |
for (int i = 0; i < children.length; i++) { |
| 879 |
if (children[i].getTrimState() == LayoutPart.TRIMSTATE_IN_TRIM |
| 880 |
|| children[i].getTrimState() == LayoutPart.TRIMSTATE_ZOOMEDTOTRIM) { |
| 881 |
IWindowTrim partTrim = tbm.getTrim(children[i].getID()); |
| 882 |
if (partTrim == null) { |
| 883 |
children[i].createInitialTrim(); |
| 884 |
} |
| 885 |
} |
| 886 |
} |
| 887 |
} |
| 888 |
|
| 889 |
/** |
| 994 |
* deactivate. |
890 |
* deactivate. |
| 995 |
*/ |
891 |
*/ |
| 996 |
protected void onDeactivate() { |
892 |
protected void onDeactivate() { |
| 997 |
presentation.deactivate(); |
893 |
presentation.deactivate(); |
| 998 |
setActiveFastView(null); |
894 |
setActiveFastView(null); |
| 999 |
setAllPinsVisible(false); |
895 |
setAllPinsVisible(false); |
| 1000 |
|
896 |
|
| 1001 |
// remember the list of 'global' fast views |
897 |
// Update fast views. |
| 1002 |
WorkbenchWindow wbw = (WorkbenchWindow)page.getWorkbenchWindow(); |
898 |
for (int i = 0; i < fastViews.size(); i++) { |
| 1003 |
FastViewBar globalFVB = wbw.getFastViewBar(); |
899 |
ViewPane pane = getPane((IViewReference) fastViews.get(i)); |
| 1004 |
if (globalFVB != null) { |
900 |
if (pane != null) { |
| 1005 |
globalFastViews = new ArrayList(globalFVB.getViewRefs()); |
901 |
Control ctrl = pane.getControl(); |
| 1006 |
globalFVBsaved = true; |
902 |
if (ctrl != null) { |
| 1007 |
} |
|
|
| 1008 |
|
| 1009 |
// Update fast views. |
| 1010 |
for (int i = 0; i < fastViews.size(); i++) { |
| 1011 |
ViewPane pane = getPane((IViewReference) fastViews.get(i)); |
| 1012 |
if (pane != null) { |
| 1013 |
Control ctrl = pane.getControl(); |
| 1014 |
if (ctrl != null) { |
| 1015 |
ctrl.setEnabled(true); // Add focus support. |
903 |
ctrl.setEnabled(true); // Add focus support. |
| 1016 |
} |
904 |
} |
| 1017 |
} |
905 |
} |
| 1018 |
} |
|
|
| 1019 |
|
| 1020 |
// Hide the trim groups |
| 1021 |
ITrimManager tbm = wbw.getTrimManager(); |
| 1022 |
for (Iterator fvbIter = fastViewBars.iterator(); fvbIter.hasNext();) { |
| 1023 |
FastViewBar fvb = (FastViewBar) fvbIter.next(); |
| 1024 |
tbm.setTrimVisible(fvb, false); |
| 1025 |
} |
906 |
} |
| 1026 |
} |
907 |
|
|
|
908 |
// Trim Stack Support |
| 909 |
IPreferenceStore preferenceStore = PrefUtil.getAPIPreferenceStore(); |
| 910 |
boolean useNewMinMax = preferenceStore.getBoolean(IWorkbenchPreferenceConstants.ENABLE_NEW_MIN_MAX); |
| 911 |
if (useNewMinMax) { |
| 912 |
// OK, adjust the trim to hide any view stacks that |
| 913 |
// are -currently- showing in the trim |
| 914 |
presentation.getLayout().setTrimVisible(false); |
| 915 |
} |
| 916 |
} |
| 1027 |
|
917 |
|
| 1028 |
/** |
918 |
/** |
| 1029 |
* Notifies that a part has been activated. |
919 |
* Notifies that a part has been activated. |
|
Lines 1043-1072
Link Here
|
| 1043 |
public void performedShowIn(String partId) { |
933 |
public void performedShowIn(String partId) { |
| 1044 |
showInTimes.put(partId, new Long(System.currentTimeMillis())); |
934 |
showInTimes.put(partId, new Long(System.currentTimeMillis())); |
| 1045 |
} |
935 |
} |
| 1046 |
|
936 |
|
| 1047 |
/** |
937 |
/** |
| 1048 |
* Sets the fast view attribute. |
938 |
* Sets the fast view attribute. Note: The page is expected to update action |
| 1049 |
* Note: The page is expected to update action bars. |
939 |
* bars. |
| 1050 |
*/ |
940 |
*/ |
| 1051 |
public void removeFastView(IViewReference ref) { |
941 |
public void removeFastView(IViewReference ref) { |
| 1052 |
ViewPane pane = getPane(ref); |
942 |
removeFastView(ref, true); |
| 1053 |
if (isFastView(ref)) { |
943 |
} |
| 1054 |
if (activeFastView == ref) { |
944 |
|
|
|
945 |
/** |
| 946 |
* Sets the fast view attribute. Note: The page is expected to update action |
| 947 |
* bars. |
| 948 |
*/ |
| 949 |
public void removeFastView(IViewReference ref, boolean handleLayout) { |
| 950 |
ViewPane pane = getPane(ref); |
| 951 |
if (isFastView(ref)) { |
| 952 |
if (activeFastView == ref) { |
| 1055 |
setActiveFastView(null); |
953 |
setActiveFastView(null); |
| 1056 |
} |
954 |
} |
| 1057 |
fastViews.remove(ref); |
955 |
fastViews.remove(ref); |
| 1058 |
pane.setFast(false); |
956 |
pane.setFast(false); |
| 1059 |
Control ctrl = pane.getControl(); |
957 |
Control ctrl = pane.getControl(); |
| 1060 |
if (ctrl != null) { |
958 |
if (ctrl != null) { |
| 1061 |
ctrl.setEnabled(true); // Modify focus support. |
959 |
ctrl.setEnabled(true); // Modify focus support. |
| 1062 |
} |
960 |
} |
| 1063 |
// We are disabling the pane because it will be enabled when it |
961 |
|
| 1064 |
// is added to the presentation. When a pane is enabled a drop |
962 |
if (handleLayout) { |
| 1065 |
// listener is added to it, and we do not want to have multiple |
963 |
// We are disabling the pane because it will be enabled when it |
| 1066 |
// listeners for a pane |
964 |
// is added to the presentation. When a pane is enabled a drop |
| 1067 |
presentation.addPart(pane); |
965 |
// listener is added to it, and we do not want to have multiple |
| 1068 |
} |
966 |
// listeners for a pane |
| 1069 |
} |
967 |
presentation.addPart(pane); |
|
|
968 |
} |
| 969 |
} |
| 970 |
} |
| 1070 |
|
971 |
|
| 1071 |
/** |
972 |
/** |
| 1072 |
* Fills a presentation with layout data. |
973 |
* Fills a presentation with layout data. |
|
Lines 1093-1105
Link Here
|
| 1093 |
IMemento views[] = memento.getChildren(IWorkbenchConstants.TAG_VIEW); |
994 |
IMemento views[] = memento.getChildren(IWorkbenchConstants.TAG_VIEW); |
| 1094 |
result.merge(createReferences(views)); |
995 |
result.merge(createReferences(views)); |
| 1095 |
|
996 |
|
| 1096 |
// Restore the list of fast views |
|
|
| 1097 |
memento = memento.getChild(IWorkbenchConstants.TAG_FAST_VIEWS); |
997 |
memento = memento.getChild(IWorkbenchConstants.TAG_FAST_VIEWS); |
| 1098 |
if (memento != null) { |
998 |
if (memento != null) { |
| 1099 |
views = memento.getChildren(IWorkbenchConstants.TAG_VIEW); |
999 |
views = memento.getChildren(IWorkbenchConstants.TAG_VIEW); |
| 1100 |
result.merge(createReferences(views)); |
1000 |
result.merge(createReferences(views)); |
| 1101 |
} |
1001 |
} |
| 1102 |
|
|
|
| 1103 |
return result; |
1002 |
return result; |
| 1104 |
} |
1003 |
} |
| 1105 |
|
1004 |
|
|
Lines 1299-1354
Link Here
|
| 1299 |
} |
1198 |
} |
| 1300 |
} |
1199 |
} |
| 1301 |
|
1200 |
|
| 1302 |
// Restore the list of 'global' fast views |
|
|
| 1303 |
globalFastViews = new ArrayList(); |
| 1304 |
IMemento globalFastViewsMem = memento.getChild(IWorkbenchConstants.TAG_GLOBAL_FAST_VIEWS); |
| 1305 |
if (globalFastViewsMem != null) { |
| 1306 |
IMemento[] globalRefs = globalFastViewsMem.getChildren(IWorkbenchConstants.TAG_VIEW); |
| 1307 |
for (int i = 0; i < globalRefs.length; i++) { |
| 1308 |
String viewId = globalRefs[i].getID(); |
| 1309 |
String secondaryId = ViewFactory.extractSecondaryId(viewId); |
| 1310 |
if (secondaryId != null) { |
| 1311 |
viewId = ViewFactory.extractPrimaryId(viewId); |
| 1312 |
} |
| 1313 |
|
| 1314 |
// Resolve the ref |
| 1315 |
IViewReference ref = viewFactory.getView(viewId, secondaryId); |
| 1316 |
globalFastViews.add(ref); |
| 1317 |
} |
| 1318 |
} |
| 1319 |
else { |
| 1320 |
// Old format, all fast views are 'global' |
| 1321 |
globalFastViews = new ArrayList(fastViews); |
| 1322 |
} |
| 1323 |
|
| 1324 |
// Restore the trim groups |
| 1325 |
IMemento groupsMem = memento.getChild(IWorkbenchConstants.TAG_FAST_GROUPS); |
| 1326 |
if (groupsMem != null) { |
| 1327 |
IMemento[] group = groupsMem.getChildren(IWorkbenchConstants.TAG_FAST_VIEW_DATA); |
| 1328 |
for (int i = 0; i < group.length; i++) { |
| 1329 |
String id = group[i].getString(IWorkbenchConstants.TAG_ID); |
| 1330 |
FastViewBar fvb = createFastViewBar(id, FastViewBar.GROUP_FVB, SWT.BOTTOM); |
| 1331 |
fvb.restoreState(group[i]); |
| 1332 |
|
| 1333 |
IMemento viewsMem = group[i].getChild(IWorkbenchConstants.TAG_VIEWS); |
| 1334 |
IMemento[] fvMems = viewsMem.getChildren(IWorkbenchConstants.TAG_VIEW); |
| 1335 |
ArrayList viewRefs = new ArrayList(fvMems.length); |
| 1336 |
for (int j = 0; j < fvMems.length; j++) { |
| 1337 |
String viewId = fvMems[j].getID(); |
| 1338 |
String secondaryId = ViewFactory.extractSecondaryId(viewId); |
| 1339 |
if (secondaryId != null) { |
| 1340 |
viewId = ViewFactory.extractPrimaryId(viewId); |
| 1341 |
} |
| 1342 |
|
| 1343 |
// Resolve the ref |
| 1344 |
IViewReference ref = viewFactory.getView(viewId, secondaryId); |
| 1345 |
viewRefs.add(ref); |
| 1346 |
} |
| 1347 |
|
| 1348 |
fvb.setViewRefs(viewRefs); |
| 1349 |
} |
| 1350 |
} |
| 1351 |
|
| 1352 |
HashSet knownActionSetIds = new HashSet(); |
1201 |
HashSet knownActionSetIds = new HashSet(); |
| 1353 |
|
1202 |
|
| 1354 |
// Load the always on action sets. |
1203 |
// Load the always on action sets. |
|
Lines 1646-1652
Link Here
|
| 1646 |
.getKey(ref)); |
1495 |
.getKey(ref)); |
| 1647 |
} |
1496 |
} |
| 1648 |
|
1497 |
|
| 1649 |
// Save the set of all fast Views |
|
|
| 1650 |
if (fastViews.size() > 0) { |
1498 |
if (fastViews.size() > 0) { |
| 1651 |
IMemento childMem = memento |
1499 |
IMemento childMem = memento |
| 1652 |
.createChild(IWorkbenchConstants.TAG_FAST_VIEWS); |
1500 |
.createChild(IWorkbenchConstants.TAG_FAST_VIEWS); |
|
Lines 1662-1685
Link Here
|
| 1662 |
} |
1510 |
} |
| 1663 |
} |
1511 |
} |
| 1664 |
|
1512 |
|
| 1665 |
// Save the set of all 'global' fast Views for this perspective |
|
|
| 1666 |
// update the list of 'global' fast views |
| 1667 |
WorkbenchWindow wbw = (WorkbenchWindow)page.getWorkbenchWindow(); |
| 1668 |
FastViewBar globalFVB = wbw.getFastViewBar(); |
| 1669 |
if (globalFVB != null && !globalFVBsaved) { |
| 1670 |
globalFastViews = new ArrayList(globalFVB.getViewRefs()); |
| 1671 |
globalFVBsaved = true; |
| 1672 |
} |
| 1673 |
|
| 1674 |
IMemento globalFVBMem = memento |
| 1675 |
.createChild(IWorkbenchConstants.TAG_GLOBAL_FAST_VIEWS); |
| 1676 |
itr = globalFastViews.iterator(); |
| 1677 |
while (itr.hasNext()) { |
| 1678 |
IViewReference ref = (IViewReference) itr.next(); |
| 1679 |
String id = ViewFactory.getKey(ref); |
| 1680 |
globalFVBMem.createChild(IWorkbenchConstants.TAG_VIEW, id); |
| 1681 |
} |
| 1682 |
|
| 1683 |
// Save the view layout recs. |
1513 |
// Save the view layout recs. |
| 1684 |
for (Iterator i = mapIDtoViewLayoutRec.keySet().iterator(); i.hasNext();) { |
1514 |
for (Iterator i = mapIDtoViewLayoutRec.keySet().iterator(); i.hasNext();) { |
| 1685 |
String compoundId = (String) i.next(); |
1515 |
String compoundId = (String) i.next(); |
|
Lines 1707-1730
Link Here
|
| 1707 |
} |
1537 |
} |
| 1708 |
} |
1538 |
} |
| 1709 |
|
1539 |
|
| 1710 |
// Save the list of group FVB's |
|
|
| 1711 |
IMemento fvbMem = memento.createChild(IWorkbenchConstants.TAG_FAST_GROUPS); |
| 1712 |
for (Iterator fvbIter = fastViewBars.iterator(); fvbIter.hasNext();) { |
| 1713 |
FastViewBar fvb = (FastViewBar) fvbIter.next(); |
| 1714 |
IMemento fastViewBarMem = fvbMem.createChild(IWorkbenchConstants.TAG_FAST_VIEW_DATA); |
| 1715 |
fastViewBarMem.putString(IWorkbenchConstants.TAG_ID, fvb.getId()); |
| 1716 |
fvb.saveState(fastViewBarMem); |
| 1717 |
|
| 1718 |
// Store the view references for this FVB |
| 1719 |
List viewRefs = fvb.getViewRefs(); |
| 1720 |
IMemento viewsMem = fastViewBarMem.createChild(IWorkbenchConstants.TAG_VIEWS); |
| 1721 |
for (Iterator fvIter = viewRefs.iterator(); fvIter.hasNext();) { |
| 1722 |
IViewReference ref = (IViewReference) fvIter.next(); |
| 1723 |
String id = ViewFactory.getKey(ref); |
| 1724 |
viewsMem.createChild(IWorkbenchConstants.TAG_VIEW, id); |
| 1725 |
} |
| 1726 |
} |
| 1727 |
|
| 1728 |
if (errors > 0) { |
1540 |
if (errors > 0) { |
| 1729 |
String message = WorkbenchMessages.Perspective_multipleErrors; |
1541 |
String message = WorkbenchMessages.Perspective_multipleErrors; |
| 1730 |
if (errors == 1) { |
1542 |
if (errors == 1) { |
|
Lines 1834-1866
Link Here
|
| 1834 |
} |
1646 |
} |
| 1835 |
} |
1647 |
} |
| 1836 |
|
1648 |
|
| 1837 |
public FastViewBar getFVBForRef(IViewReference ref) { |
|
|
| 1838 |
for (Iterator fvbIter = fastViewBars.iterator(); fvbIter.hasNext();) { |
| 1839 |
FastViewBar fvb = (FastViewBar) fvbIter.next(); |
| 1840 |
if (fvb.hasViewRef(ref)) |
| 1841 |
return fvb; |
| 1842 |
} |
| 1843 |
|
| 1844 |
return null; |
| 1845 |
} |
| 1846 |
/** |
1649 |
/** |
| 1847 |
* Sets the selection for the shortcut bar icon representing the givevn fast view. |
1650 |
* Sets the selection for the shortcut bar icon representing the givevn fast view. |
| 1848 |
*/ |
1651 |
*/ |
| 1849 |
private void setFastViewIconSelection(IViewReference ref, boolean selected) { |
1652 |
private void setFastViewIconSelection(IViewReference ref, boolean selected) { |
| 1850 |
WorkbenchWindow window = (WorkbenchWindow) page.getWorkbenchWindow(); |
1653 |
// First, is it in a Trim Stack? |
| 1851 |
FastViewBar bar = getFVBForRef(ref); |
1654 |
ViewStackTrimPart ts = getTrimStackForRef(ref); |
| 1852 |
if (bar == null) |
1655 |
if (ts != null) { |
| 1853 |
bar = window.getFastViewBar(); |
1656 |
ts.setIconSelection(ref, selected); |
| 1854 |
|
1657 |
return; |
| 1855 |
if (bar != null) { |
1658 |
} |
| 1856 |
if (selected) { |
1659 |
|
| 1857 |
bar.setSelection(ref); |
1660 |
WorkbenchWindow window = (WorkbenchWindow) page.getWorkbenchWindow(); |
| 1858 |
} else { |
1661 |
FastViewBar bar = window.getFastViewBar(); |
| 1859 |
if (ref == bar.getSelection()) { |
1662 |
if (bar != null) { |
| 1860 |
bar.setSelection(null); |
1663 |
if (selected) { |
| 1861 |
} |
1664 |
bar.setSelection(ref); |
| 1862 |
} |
1665 |
} else { |
| 1863 |
} |
1666 |
if (ref == bar.getSelection()) { |
|
|
1667 |
bar.setSelection(null); |
| 1668 |
} |
| 1669 |
} |
| 1670 |
} |
| 1864 |
} |
1671 |
} |
| 1865 |
|
1672 |
|
| 1866 |
/** |
1673 |
/** |
|
Lines 1909-1914
Link Here
|
| 1909 |
editorHolder = null; |
1716 |
editorHolder = null; |
| 1910 |
} |
1717 |
} |
| 1911 |
|
1718 |
|
|
|
1719 |
private ViewStackTrimPart getTrimStackForRef(IViewReference ref) { |
| 1720 |
// Is it in a minimized stack? |
| 1721 |
List trimParts = presentation.getLayout().getTrimForParts(); |
| 1722 |
for (Iterator trimIter = trimParts.iterator(); trimIter.hasNext();) { |
| 1723 |
IWindowTrim trim = (IWindowTrim) trimIter.next(); |
| 1724 |
if (trim instanceof ViewStackTrimPart) { |
| 1725 |
if (((ViewStackTrimPart) trim).hasViewRef(ref)) |
| 1726 |
return (ViewStackTrimPart) trim; |
| 1727 |
} |
| 1728 |
} |
| 1729 |
|
| 1730 |
return null; |
| 1731 |
} |
| 1732 |
|
| 1912 |
/** |
1733 |
/** |
| 1913 |
* Shows a fast view. |
1734 |
* Shows a fast view. |
| 1914 |
* @return whether the view was successfully shown |
1735 |
* @return whether the view was successfully shown |
|
Lines 1926-1940
Link Here
|
| 1926 |
|
1747 |
|
| 1927 |
saveFastViewWidthRatio(); |
1748 |
saveFastViewWidthRatio(); |
| 1928 |
|
1749 |
|
| 1929 |
WorkbenchWindow window = (WorkbenchWindow) page.getWorkbenchWindow(); |
1750 |
|
| 1930 |
FastViewBar bar = getFVBForRef(ref); |
1751 |
// Determine the display orientation |
| 1931 |
if (bar == null) |
1752 |
int side; |
| 1932 |
bar = window.getFastViewBar(); |
1753 |
ViewStackTrimPart ts = getTrimStackForRef(ref); |
| 1933 |
|
1754 |
if (ts != null) { |
| 1934 |
if (bar == null) { |
1755 |
side = ts.getViewSide(); |
| 1935 |
return false; |
1756 |
} else { |
| 1936 |
} |
1757 |
WorkbenchWindow window = (WorkbenchWindow) page |
| 1937 |
int side = bar.getViewSide(ref); |
1758 |
.getWorkbenchWindow(); |
|
|
1759 |
FastViewBar bar = window.getFastViewBar(); |
| 1760 |
|
| 1761 |
if (bar == null) { |
| 1762 |
return false; |
| 1763 |
} |
| 1764 |
|
| 1765 |
side = bar.getViewSide(ref); |
| 1766 |
} |
| 1938 |
|
1767 |
|
| 1939 |
fastViewPane.showView(getClientComposite(), pane, side, |
1768 |
fastViewPane.showView(getClientComposite(), pane, side, |
| 1940 |
getFastViewWidthRatio(ref)); |
1769 |
getFastViewWidthRatio(ref)); |
|
Lines 1971-1978
Link Here
|
| 1971 |
int openViewMode = store.getInt(IPreferenceConstants.OPEN_VIEW_MODE); |
1800 |
int openViewMode = store.getInt(IPreferenceConstants.OPEN_VIEW_MODE); |
| 1972 |
|
1801 |
|
| 1973 |
if (openViewMode == IPreferenceConstants.OVM_FAST) { |
1802 |
if (openViewMode == IPreferenceConstants.OVM_FAST) { |
| 1974 |
FastViewBar fvb = ((WorkbenchWindow)pane.getWorkbenchWindow()).getFastViewBar(); |
1803 |
showFastView(ref); |
| 1975 |
fvb.adoptView(ref, -1, true, true); |
1804 |
addFastView(ref); |
| 1976 |
} else if (openViewMode == IPreferenceConstants.OVM_FLOAT |
1805 |
} else if (openViewMode == IPreferenceConstants.OVM_FLOAT |
| 1977 |
&& presentation.canDetach()) { |
1806 |
&& presentation.canDetach()) { |
| 1978 |
presentation.addDetachedPart(pane); |
1807 |
presentation.addDetachedPart(pane); |
|
Lines 2171-2174
Link Here
|
| 2171 |
return fastViewPane; |
2000 |
return fastViewPane; |
| 2172 |
} |
2001 |
} |
| 2173 |
|
2002 |
|
|
|
2003 |
// Trim Stack Support |
| 2004 |
|
| 2005 |
/** |
| 2006 |
* Hack to get around 'addFastView' issues |
| 2007 |
* |
| 2008 |
* @param ref |
| 2009 |
*/ |
| 2010 |
public void addFastViewHack(IViewReference ref) { |
| 2011 |
//addFastView(ref, false); |
| 2012 |
} |
| 2013 |
|
| 2014 |
/** |
| 2015 |
* Hack to get around 'addFastView' issues |
| 2016 |
* |
| 2017 |
* @param ref |
| 2018 |
*/ |
| 2019 |
public void removeFastViewHack(IViewReference ref) { |
| 2020 |
//removeFastView(ref, false); |
| 2021 |
} |
| 2022 |
|
| 2023 |
/** |
| 2024 |
* Moves any parts that support trim representation into the trim |
| 2025 |
* |
| 2026 |
* @param parts The parts to (potentially) move to the trim |
| 2027 |
* @param restoreOnUnzoom 'true' iff we want the parts to |
| 2028 |
* automatically restore on an 'unzoom'. |
| 2029 |
*/ |
| 2030 |
public void movePartsToTrim(List parts, boolean restoreOnUnzoom) { |
| 2031 |
if (parts == null || parts.size() == 0) |
| 2032 |
return; |
| 2033 |
|
| 2034 |
Shell shell = page.getWorkbenchWindow().getShell(); |
| 2035 |
RectangleAnimation animation = new RectangleAnimation(shell, null, null); |
| 2036 |
|
| 2037 |
// Capture the area the stack currently occupies (and its image) |
| 2038 |
for (Iterator stackIter = parts.iterator(); stackIter.hasNext();) { |
| 2039 |
LayoutPart part = (LayoutPart) stackIter.next(); |
| 2040 |
if (part.getControl() != null) |
| 2041 |
animation.addStartRect(DragUtil.getDisplayBounds(part |
| 2042 |
.getControl())); |
| 2043 |
} |
| 2044 |
|
| 2045 |
// Gain access to the trim manager |
| 2046 |
WorkbenchWindow wbw = (WorkbenchWindow) page.getWorkbenchWindow(); |
| 2047 |
ITrimManager tbm = wbw.getTrimManager(); |
| 2048 |
|
| 2049 |
// Iterate through all the parts, moving each to the trim |
| 2050 |
int newTrimState = restoreOnUnzoom ? LayoutPart.TRIMSTATE_ZOOMEDTOTRIM |
| 2051 |
: LayoutPart.TRIMSTATE_IN_TRIM; |
| 2052 |
|
| 2053 |
// We hide the editor container last so its position can be used |
| 2054 |
// to calculate the correct side for other trim |
| 2055 |
boolean moveEditorAreaToTrim = false; |
| 2056 |
|
| 2057 |
List newTrimParts = new ArrayList(); |
| 2058 |
for (Iterator stackIter = parts.iterator(); stackIter.hasNext();) { |
| 2059 |
LayoutPart part = (LayoutPart) stackIter.next(); |
| 2060 |
|
| 2061 |
// for now be careful and only manipulate 'known' part types |
| 2062 |
// should generalize... |
| 2063 |
if (part instanceof ViewStack) { |
| 2064 |
part.setTrimState(newTrimState); |
| 2065 |
IWindowTrim partTrim = tbm.getTrim(part.getID()); |
| 2066 |
if (partTrim != null) { |
| 2067 |
newTrimParts.add(partTrim); |
| 2068 |
} |
| 2069 |
} else if (part instanceof EditorSashContainer) { |
| 2070 |
moveEditorAreaToTrim = true; |
| 2071 |
} |
| 2072 |
} |
| 2073 |
|
| 2074 |
if (moveEditorAreaToTrim) { |
| 2075 |
editorArea.setTrimState(newTrimState); |
| 2076 |
hideEditorArea(); |
| 2077 |
|
| 2078 |
IWindowTrim partTrim = tbm.getTrim(editorArea.getID()); |
| 2079 |
if (partTrim != null) { |
| 2080 |
newTrimParts.add(partTrim); |
| 2081 |
} |
| 2082 |
} |
| 2083 |
|
| 2084 |
// Force a layout if necessary |
| 2085 |
if (newTrimParts.size() == 0) |
| 2086 |
return; |
| 2087 |
|
| 2088 |
// OK, we're good to go |
| 2089 |
tbm.forceLayout(); |
| 2090 |
|
| 2091 |
// Now that the layout is finished we can add the 'end' rects for the |
| 2092 |
// animation |
| 2093 |
for (Iterator tsIter = newTrimParts.iterator(); tsIter.hasNext();) { |
| 2094 |
TrimPart ts = (TrimPart) tsIter.next(); |
| 2095 |
animation.addEndRect(DragUtil.getDisplayBounds(ts.getControl())); |
| 2096 |
} |
| 2097 |
|
| 2098 |
animation.schedule(); |
| 2099 |
} |
| 2100 |
|
| 2101 |
/** |
| 2102 |
* Restores a part in the trim to the actual layout |
| 2103 |
* @param part The part to restore |
| 2104 |
*/ |
| 2105 |
public void restoreTrimPart(LayoutPart part) { |
| 2106 |
// Remove any current fastview |
| 2107 |
setActiveFastView(null); |
| 2108 |
|
| 2109 |
// Set the part's state to place it back in the layout |
| 2110 |
part.setTrimState(LayoutPart.TRIMSTATE_NORMAL); |
| 2111 |
|
| 2112 |
if (part == editorArea) |
| 2113 |
showEditorArea(); |
| 2114 |
|
| 2115 |
WorkbenchWindow wbw = (WorkbenchWindow) page.getWorkbenchWindow(); |
| 2116 |
ITrimManager tbm = wbw.getTrimManager(); |
| 2117 |
tbm.forceLayout(); |
| 2118 |
} |
| 2119 |
|
| 2120 |
/** |
| 2121 |
* Determine the correct side to initially dock a new |
| 2122 |
* trim part on. We do this by checking its rect against |
| 2123 |
* the editor area. |
| 2124 |
* |
| 2125 |
* @param stackBounds The bounds of the stack we want to create trim for |
| 2126 |
* @return the SWT side to dock the trim element on |
| 2127 |
*/ |
| 2128 |
public int calcStackSide(Rectangle stackBounds) { |
| 2129 |
// Where is the stack in relation to the EditorArea? |
| 2130 |
Rectangle editorAreaBounds = editorArea.getBounds(); |
| 2131 |
|
| 2132 |
// Is this the Editor Area |
| 2133 |
if (editorAreaBounds.equals(stackBounds)) |
| 2134 |
return SWT.TOP; |
| 2135 |
|
| 2136 |
Point stackCenter = Geometry.centerPoint(stackBounds); |
| 2137 |
Point editorAreaCenter = Geometry.centerPoint(editorAreaBounds); |
| 2138 |
|
| 2139 |
int dx = editorAreaCenter.x - stackCenter.x; |
| 2140 |
int dy = editorAreaCenter.y - stackCenter.y; |
| 2141 |
|
| 2142 |
if (Math.abs(dx) > Math.abs(dy)) { |
| 2143 |
return (dx > 0) ? SWT.LEFT : SWT.RIGHT; |
| 2144 |
} |
| 2145 |
|
| 2146 |
return (dy > 0) ? SWT.TOP : SWT.BOTTOM; |
| 2147 |
} |
| 2148 |
|
| 2149 |
/** |
| 2150 |
* Restore any parts that are showing in the trim as |
| 2151 |
* a result of a 'zoom' operation |
| 2152 |
*/ |
| 2153 |
public void restoreZoomedParts() { |
| 2154 |
// Remove any current fastview |
| 2155 |
setActiveFastView(null); |
| 2156 |
|
| 2157 |
// Is the editotr 'zoomed'? |
| 2158 |
boolean editorZoomed = (editorHolder != null && |
| 2159 |
editorArea.getTrimState() == LayoutPart.TRIMSTATE_ZOOMEDTOTRIM); |
| 2160 |
|
| 2161 |
// have the layout restore the parts |
| 2162 |
boolean needsLayout = presentation.getLayout().restoreZoomedTrimParts(); |
| 2163 |
if (needsLayout) { |
| 2164 |
// Force a layout |
| 2165 |
WorkbenchWindow wbw = (WorkbenchWindow) page.getWorkbenchWindow(); |
| 2166 |
ITrimManager tbm = wbw.getTrimManager(); |
| 2167 |
tbm.forceLayout(); |
| 2168 |
} |
| 2169 |
|
| 2170 |
if (editorZoomed) { |
| 2171 |
editorArea.setTrimState(LayoutPart.TRIMSTATE_NORMAL); |
| 2172 |
showEditorArea(); |
| 2173 |
} |
| 2174 |
} |
| 2174 |
} |
2175 |
} |