Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Webster2011-07-11 17:09:30 +0000
committerPaul Webster2011-08-25 14:21:50 +0000
commit8da5094955b5e652fa06c25df3a9ea76fe0afe53 (patch)
tree904a3c9cab2f56eb067abc0325e984351fe998f4
parent819b73200486ff8a51490729e8f534200cae38ae (diff)
downloadeclipse.platform.ui-8da5094955b5e652fa06c25df3a9ea76fe0afe53.tar.gz
eclipse.platform.ui-8da5094955b5e652fa06c25df3a9ea76fe0afe53.tar.xz
eclipse.platform.ui-8da5094955b5e652fa06c25df3a9ea76fe0afe53.zip
Bug 351720 - R4_development branch of org.eclipse.ui.workbench has files from the original 3.x bundle
Delete all of the files that are not in the compatibility workbench, right before the merge.
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/ActionPresentation.java222
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/ApplicationMenuManager.java83
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/ContainerPlaceholder.java152
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/DefaultAnimationFeedback.java138
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/DetachedPlaceHolder.java151
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/DetachedWindow.java528
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/EditorAreaHelper.java335
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/EditorAreaTrimToolBar.java128
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/EditorManager.java1769
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/EditorPane.java219
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/EditorSashContainer.java638
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/EditorStack.java367
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/FastViewBar.java982
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/FastViewBarContextMenuContribution.java128
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/FastViewDnDHandler.java352
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/FastViewManager.java1086
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/FastViewPane.java641
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/FolderLayout.java118
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/ILayoutContainer.java91
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/IStickyViewManager.java36
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/LayoutHelper.java168
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/LayoutPart.java488
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/LayoutPartSash.java315
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/LayoutTree.java614
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/LayoutTreeNode.java675
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/MultiEditorInnerPane.java117
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/PageLayout.java1013
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/PartList.java370
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/PartPlaceholder.java54
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/PartSashContainer.java1436
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/PartStack.java1804
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/Perspective.java2706
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/PerspectiveHelper.java1524
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/PlaceholderFolderLayout.java91
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/PluginActionSetBuilder.java779
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/PluginActionSetReader.java87
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/RectangleAnimation.java252
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/StickyViewManager.java155
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/StickyViewManager32.java142
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/ViewFactory.java425
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/ViewLayout.java73
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/ViewLayoutRec.java32
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/ViewPane.java639
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/ViewSashContainer.java318
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/ViewStack.java230
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/ViewStackTrimToolBar.java224
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/WWinPartService.java247
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/WorkbenchPagePartList.java82
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/commands/Parameter.java256
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/dialogs/CustomizePerspectiveDialog.java3378
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/handlers/AbstractSaveHandler.java86
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/handlers/CloseAllSavedHandler.java136
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/handlers/DirtyStateTracker.java166
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/handlers/DynamicHelpHandler.java35
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/handlers/HandlerAuthority.java674
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/handlers/HandlerService.java285
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/handlers/HandlerServiceFactory.java84
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/handlers/HelpContentsHandler.java35
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/handlers/HelpSearchHandler.java35
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/handlers/IntroHandler.java75
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/handlers/LockToolBarHandler.java50
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/handlers/NestableHandlerService.java104
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/handlers/ResetPerspectiveHandler.java93
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/handlers/SaveAllHandler.java88
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/handlers/SaveAsHandler.java67
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/handlers/SaveHandler.java96
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/handlers/SavePerspectiveHandler.java113
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/handlers/SlaveHandlerService.java288
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/handlers/SpyHandler.java156
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/keys/OutOfOrderListener.java107
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/keys/OutOfOrderVerifyListener.java107
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/menus/AbstractMenuAdditionCacheEntry.java47
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/menus/ContributionRoot.java119
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/menus/IMenuActivation.java26
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/menus/IMenuLabelProvider.java27
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/menus/InternalMenuService.java72
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/menus/MenuActivation.java48
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/menus/MenuServiceFactory.java58
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/menus/ProxyMenuAdditionCacheEntry.java94
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/menus/SlaveMenuService.java206
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/menus/TrimAdditionCacheEntry.java274
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/menus/TrimBarManager2.java502
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/menus/TrimContributionManager.java326
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/AbstractTableInformationControl.java684
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/BasicPartList.java355
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/DefaultActionBarPresentationFactory.java65
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/ISelfUpdatingAction.java25
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/NativePresentationFactory.java59
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/NativeStackPresentation.java548
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/PaneFolder.java892
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/PaneFolderButtonListener.java46
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/PresentablePart.java419
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/PresentationFactoryUtil.java67
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/PresentationSerializer.java65
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/SystemMenuClose.java63
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/SystemMenuCloseAll.java44
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/SystemMenuCloseOthers.java62
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/SystemMenuDetach.java68
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/SystemMenuFastView.java129
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/SystemMenuFastViewOrientation.java120
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/SystemMenuMaximize.java28
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/SystemMenuMinimize.java28
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/SystemMenuMove.java66
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/SystemMenuMoveFolder.java43
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/SystemMenuMovePane.java44
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/SystemMenuPinEditor.java70
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/SystemMenuRestore.java26
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/SystemMenuSize.java42
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/SystemMenuSizeFastView.java49
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/SystemMenuStateChange.java52
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/UpdatingActionContributionItem.java51
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/classic/WorkbenchPresentationFactoryClassic.java80
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/defaultpresentation/DefaultMultiTabListener.java43
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/defaultpresentation/DefaultPartList.java79
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/defaultpresentation/DefaultSimpleTabListener.java43
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/defaultpresentation/DefaultTabFolder.java544
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/defaultpresentation/DefaultTabFolderColors.java48
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/defaultpresentation/DefaultTabItem.java241
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/defaultpresentation/DefaultThemeListener.java144
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/defaultpresentation/EmptyTabFolder.java173
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/defaultpresentation/EmptyTabItem.java56
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/defaultpresentation/NativePresentationFactory.java58
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/defaultpresentation/NativeTabFolder.java365
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/defaultpresentation/NativeTabItem.java52
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/util/AbstractTabFolder.java409
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/util/AbstractTabItem.java32
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/util/EnhancedFillLayout.java56
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/util/IPresentablePartList.java30
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/util/ISystemMenu.java29
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/util/LeftToRightTabOrder.java122
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/util/PartInfo.java48
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/util/PresentablePartFolder.java418
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/util/ProxyControl.java287
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/util/ReplaceDragHandler.java128
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/util/StandardEditorSystemMenu.java72
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/util/StandardSystemToolbar.java304
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/util/StandardViewSystemMenu.java104
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/util/TabDragHandler.java35
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/util/TabFolderEvent.java77
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/util/TabFolderListener.java18
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/util/TabOrder.java66
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/util/TabbedStackPresentation.java597
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/util/WidgetTabItem.java51
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/progress/TaskBarProgressManager.java350
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/registry/PerspectiveExtensionReader.java373
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/registry/PerspectiveRegistryReader.java64
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/registry/ViewRegistryReader.java110
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/services/EvaluationAuthority.java298
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/testing/ContributionInfoMessages.java47
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/testing/PluginContributionAdapterFactory.java96
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/testing/messages.properties29
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/tweaklets/Workbench3xImplementation.java58
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/tweaklets/WorkbenchImplementation.java71
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/presentations/PresentationUtil.java173
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/presentations/WorkbenchPresentationFactory.java153
155 files changed, 0 insertions, 42378 deletions
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/ActionPresentation.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/ActionPresentation.java
deleted file mode 100644
index 46e3219dde8..00000000000
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/ActionPresentation.java
+++ /dev/null
@@ -1,222 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2009 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.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.dynamichelpers.IExtensionTracker;
-import org.eclipse.ui.SubActionBars;
-import org.eclipse.ui.internal.provisional.application.IActionBarConfigurer2;
-import org.eclipse.ui.internal.registry.IActionSet;
-import org.eclipse.ui.internal.registry.IActionSetDescriptor;
-
-/**
- * Manage the configurable actions for one window.
- */
-public class ActionPresentation {
- private WorkbenchWindow window;
-
- private HashMap mapDescToRec = new HashMap(3);
-
- private HashMap invisibleBars = new HashMap(3);
-
- private class SetRec {
- public SetRec(IActionSet set,
- SubActionBars bars) {
- this.set = set;
- this.bars = bars;
- }
-
- public IActionSet set;
-
- public SubActionBars bars;
- }
-
- /**
- * ActionPresentation constructor comment.
- */
- public ActionPresentation(WorkbenchWindow window) {
- super();
- this.window = window;
- }
-
- /**
- * Remove all action sets.
- */
- public void clearActionSets() {
- // Get all of the action sets -- both visible and invisible.
- final List oldList = new ArrayList();
- oldList.addAll(mapDescToRec.keySet());
- oldList.addAll(invisibleBars.keySet());
-
- Iterator iter = oldList.iterator();
- while (iter.hasNext()) {
- IActionSetDescriptor desc = (IActionSetDescriptor) iter.next();
- removeActionSet(desc);
- }
- }
-
- /**
- * Destroy an action set.
- */
- public void removeActionSet(IActionSetDescriptor desc) {
- SetRec rec = (SetRec) mapDescToRec.remove(desc);
- if (rec == null) {
- rec = (SetRec) invisibleBars.remove(desc);
- }
- if (rec != null) {
- IActionSet set = rec.set;
- SubActionBars bars = rec.bars;
- if (bars != null) {
- bars.dispose();
- }
- if (set != null) {
- set.dispose();
- }
- }
- }
-
- /**
- * Sets the list of visible action set.
- */
- public void setActionSets(IActionSetDescriptor[] newArray) {
- // Convert array to list.
- HashSet newList = new HashSet();
-
- for (int i = 0; i < newArray.length; i++) {
- IActionSetDescriptor descriptor = newArray[i];
-
- newList.add(descriptor);
- }
- List oldList = new ArrayList(mapDescToRec.keySet());
-
- // Remove obsolete actions.
- Iterator iter = oldList.iterator();
- while (iter.hasNext()) {
- IActionSetDescriptor desc = (IActionSetDescriptor) iter.next();
- if (!newList.contains(desc)) {
- SetRec rec = (SetRec) mapDescToRec.get(desc);
- if (rec != null) {
- mapDescToRec.remove(desc);
- IActionSet set = rec.set;
- SubActionBars bars = rec.bars;
- if (bars != null) {
- SetRec invisibleRec = new SetRec(set, bars);
- invisibleBars.put(desc, invisibleRec);
- bars.deactivate();
- }
- }
- }
- }
-
- // Add new actions.
- ArrayList sets = new ArrayList();
-
- for (int i = 0; i < newArray.length; i++) {
- IActionSetDescriptor desc = newArray[i];
-
- if (!mapDescToRec.containsKey(desc)) {
- try {
- SetRec rec;
- // If the action bars and sets have already been created
- // then
- // reuse those action sets
- if (invisibleBars.containsKey(desc)) {
- rec = (SetRec) invisibleBars.get(desc);
- if (rec.bars != null) {
- rec.bars.activate();
- }
- invisibleBars.remove(desc);
- } else {
- IActionSet set = desc.createActionSet();
- SubActionBars bars = new ActionSetActionBars(window
- .getActionBars(), window,
- (IActionBarConfigurer2) window.getWindowConfigurer()
- .getActionBarConfigurer(), desc.getId());
- rec = new SetRec(set, bars);
- set.init(window, bars);
- sets.add(set);
-
- // only register against the tracker once - check for
- // other registrations against the provided extension
- Object[] existingRegistrations = window
- .getExtensionTracker().getObjects(
- desc.getConfigurationElement()
- .getDeclaringExtension());
- if (existingRegistrations.length == 0
- || !containsRegistration(existingRegistrations,
- desc)) {
- //register the set with the page tracker
- //this will be cleaned up by WorkbenchWindow listener
- window.getExtensionTracker().registerObject(
- desc.getConfigurationElement().getDeclaringExtension(),
- desc, IExtensionTracker.REF_WEAK);
- }
- }
- mapDescToRec.put(desc, rec);
- } catch (CoreException e) {
- WorkbenchPlugin
- .log("Unable to create ActionSet: " + desc.getId(), e);//$NON-NLS-1$
- }
- }
- }
- // We process action sets in two passes for coolbar purposes. First we
- // process base contributions
- // (i.e., actions that the action set contributes to its toolbar), then
- // we process adjunct contributions
- // (i.e., actions that the action set contributes to other toolbars).
- // This type of processing is
- // necessary in order to maintain group order within a coolitem.
- PluginActionSetBuilder.processActionSets(sets, window);
-
- iter = sets.iterator();
- while (iter.hasNext()) {
- PluginActionSet set = (PluginActionSet) iter.next();
- set.getBars().activate();
- }
- }
-
- /**
- * Return whether the array contains the given action set.
- *
- * @param existingRegistrations the array to check
- * @param set the set to look for
- * @return whether the set is in the array
- * @since 3.1
- */
- private boolean containsRegistration(Object[] existingRegistrations, IActionSetDescriptor set) {
- for (int i = 0; i < existingRegistrations.length; i++) {
- if (existingRegistrations[i] == set) {
- return true;
- }
- }
- return false;
- }
-
- /**
- */
- public IActionSet[] getActionSets() {
- Collection setRecCollection = mapDescToRec.values();
- IActionSet result[] = new IActionSet[setRecCollection.size()];
- int i = 0;
- for (Iterator iterator = setRecCollection.iterator(); iterator
- .hasNext(); i++) {
- result[i] = ((SetRec) iterator.next()).set;
- }
- return result;
- }
-}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/ApplicationMenuManager.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/ApplicationMenuManager.java
deleted file mode 100644
index 2aa0a0376a7..00000000000
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/ApplicationMenuManager.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 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.jface.action.IContributionItem;
-import org.eclipse.jface.action.MenuManager;
-import org.eclipse.swt.widgets.Decorations;
-import org.eclipse.swt.widgets.Item;
-import org.eclipse.swt.widgets.Menu;
-
-/**
- * @since 3.7
- *
- */
-class ApplicationMenuManager extends MenuManager{
-
- private final Menu appMenu;
- private boolean disposing;
-
- public ApplicationMenuManager(Menu appMenu) {
- this.appMenu = appMenu;
- }
-
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.action.MenuManager#createMenuBar(org.eclipse.swt.widgets.Decorations)
- */
- public Menu createMenuBar(Decorations parent) {
- return appMenu;
- }
-
- protected boolean menuExist() {
- // our menu always exist,
- // except disposing - if not dispose will be called on this menu
- return !disposing;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.action.MenuManager#getMenuItemCount()
- */
- protected int getMenuItemCount() {
- return appMenu.getItemCount();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.action.MenuManager#getMenuItem(int)
- */
- protected Item getMenuItem(int index) {
- return appMenu.getItem(index);
- }
- /* (non-Javadoc)
- * @see org.eclipse.jface.action.MenuManager#getMenuItems()
- */
- protected Item[] getMenuItems() {
- return appMenu.getItems();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.action.MenuManager#doItemFill(org.eclipse.jface.action.IContributionItem, int)
- */
- protected void doItemFill(IContributionItem ci, int index) {
- ci.fill(appMenu, index);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.action.MenuManager#dispose()
- */
- public void dispose() {
- disposing = true;
- super.dispose();
- disposing = false;
- }
-}
-
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/ContainerPlaceholder.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/ContainerPlaceholder.java
deleted file mode 100644
index 921c3a395b2..00000000000
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/ContainerPlaceholder.java
+++ /dev/null
@@ -1,152 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 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;
-
-public class ContainerPlaceholder extends PartPlaceholder implements
- ILayoutContainer {
- private static int nextId = 0;
-
- private ILayoutContainer realContainer;
-
- /**
- * ContainerPlaceholder constructor comment.
- * @param id java.lang.String
- * @param label java.lang.String
- */
- public ContainerPlaceholder(String id) {
- super(((id == null) ? "Container Placeholder " + nextId++ : id)); //$NON-NLS-1$
- }
-
- /**
- * add method comment.
- */
- public void add(LayoutPart child) {
- if (!(child instanceof PartPlaceholder)) {
- return;
- }
- realContainer.add(child);
- }
-
- /**
- * See ILayoutContainer::allowBorder
- */
- public boolean allowsBorder() {
- return true;
- }
-
- /**
- * getChildren method comment.
- */
- public LayoutPart[] getChildren() {
- return realContainer.getChildren();
- }
-
- /**
- * getFocus method comment.
- */
- public LayoutPart getFocus() {
- return null;
- }
-
- /**
- * getFocus method comment.
- */
- public LayoutPart getRealContainer() {
- return (LayoutPart) realContainer;
- }
-
- /**
- * isChildVisible method comment.
- */
- public boolean isChildVisible(LayoutPart child) {
- return false;
- }
-
- /**
- * remove method comment.
- */
- public void remove(LayoutPart child) {
- if (!(child instanceof PartPlaceholder)) {
- return;
- }
- realContainer.remove(child);
- }
-
- /**
- * replace method comment.
- */
- public void replace(LayoutPart oldChild, LayoutPart newChild) {
- if (!(oldChild instanceof PartPlaceholder)
- && !(newChild instanceof PartPlaceholder)) {
- return;
- }
- realContainer.replace(oldChild, newChild);
- }
-
- /**
- * setChildVisible method comment.
- */
- public void setChildVisible(LayoutPart child, boolean visible) {
- }
-
- /**
- * setFocus method comment.
- */
- public void setFocus(LayoutPart child) {
- }
-
- public void setRealContainer(ILayoutContainer container) {
-
- if (container == null) {
- // set the parent container of the children back to the real container
- if (realContainer != null) {
- LayoutPart[] children = realContainer.getChildren();
- if (children != null) {
- for (int i = 0, length = children.length; i < length; i++) {
- children[i].setContainer(realContainer);
- }
- }
- }
- } else {
- // replace the real container with this place holder
- LayoutPart[] children = container.getChildren();
- if (children != null) {
- for (int i = 0, length = children.length; i < length; i++) {
- children[i].setContainer(this);
- }
- }
- }
-
- this.realContainer = container;
- }
-
- public void findSashes(LayoutPart part, PartPane.Sashes sashes) {
- ILayoutContainer container = getContainer();
-
- if (container != null) {
- container.findSashes(this, sashes);
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.internal.ILayoutContainer#allowsAutoFocus()
- */
- public boolean allowsAutoFocus() {
- return false;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.internal.ILayoutContainer#isZoomed(org.eclipse.ui.internal.LayoutPart)
- */
- public boolean childIsZoomed(LayoutPart toTest) {
- return false;
- }
-}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/DefaultAnimationFeedback.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/DefaultAnimationFeedback.java
deleted file mode 100644
index b962aed99ab..00000000000
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/DefaultAnimationFeedback.java
+++ /dev/null
@@ -1,138 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2010 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.graphics.Color;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.graphics.Region;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
-
-/**
- * @since 3.3
- *
- */
-public class DefaultAnimationFeedback {
- private static final int LINE_WIDTH = 1;
-
- private Display display;
- private Shell theShell;
- private Region shellRegion;
-
- private List startRects = new ArrayList();
- private List endRects = new ArrayList();
-
- public DefaultAnimationFeedback() {}
-
- /**
- * @param parentShell
- */
- public void initialize(Shell parentShell, Rectangle startRect, Rectangle endRect) {
- addStartRect(startRect);
- addEndRect(endRect);
-
- theShell = new Shell(parentShell, SWT.NO_TRIM | SWT.ON_TOP);
- display = theShell.getDisplay();
- Color color = display.getSystemColor(SWT.COLOR_WIDGET_FOREGROUND);
- theShell.setBackground(color);
-
- // Ensure that the background won't show on the initial display
- shellRegion = new Region(display);
- theShell.setRegion(shellRegion);
- }
-
- public void addStartRect(Rectangle rect) {
- if (rect != null) {
- startRects.add(rect);
- }
- }
-
- public void addEndRect(Rectangle rect) {
- if (rect != null) {
- endRects.add(rect);
- }
- }
-
- public List getStartRects() {
- return startRects;
- }
-
- public List getEndRects() {
- return endRects;
- }
-
- public void renderStep(double amount) {
- if (shellRegion != null) {
- shellRegion.dispose();
- shellRegion = new Region(display);
- }
-
- // Iterate across the set of start/end rects
- Iterator startIter = startRects.iterator();
- Iterator endIter = endRects.iterator();
- while (startIter.hasNext()) {
- Rectangle start = (Rectangle) startIter.next();
- Rectangle end = (Rectangle) endIter.next();
-
- // Get the bounds of the interpolated rect
- Rectangle curRect = RectangleAnimation.interpolate(start, end, amount);
-
- Rectangle rect = Geometry.toControl(theShell, curRect);
- shellRegion.add(rect);
- rect.x += LINE_WIDTH;
- rect.y += LINE_WIDTH;
- rect.width = Math.max(0, rect.width - 2 * LINE_WIDTH);
- rect.height = Math.max(0, rect.height - 2 * LINE_WIDTH);
-
- shellRegion.subtract(rect);
- }
-
- theShell.setRegion(shellRegion);
-
- display.update();
- }
-
- /**
- *
- */
- public void dispose() {
- theShell.setVisible(false);
- theShell.dispose();
- shellRegion.dispose();
- }
-
- /**
- * Perform any initialization you want to have happen -before- the
- * amination starts
- */
- public void jobInit() {
- // Compute the shell's bounds
- Rectangle shellBounds = Geometry.copy((Rectangle) startRects.get(0));
- Iterator startIter = startRects.iterator();
- Iterator endIter = endRects.iterator();
- while (startIter.hasNext()) {
- shellBounds.add((Rectangle) startIter.next());
- shellBounds.add((Rectangle) endIter.next());
- }
- theShell.setBounds(shellBounds);
-
- // Making the shell visible will be slow on old video cards, so only start
- // the timer once it is visible.
- theShell.setVisible(true);
- }
-}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/DetachedPlaceHolder.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/DetachedPlaceHolder.java
deleted file mode 100644
index 29042b641fa..00000000000
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/DetachedPlaceHolder.java
+++ /dev/null
@@ -1,151 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 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 org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.ui.IMemento;
-
-/**
- * DetachedPlaceHolder is the placeholder for detached views.
- *
- */
-public class DetachedPlaceHolder extends PartPlaceholder implements
- ILayoutContainer {
- ArrayList children = new ArrayList();
-
- Rectangle bounds;
-
- /**
- * DetachedPlaceHolder constructor comment.
- * @param id java.lang.String
- * @param bounds the size of the placeholder
- */
- public DetachedPlaceHolder(String id, Rectangle bounds) {
- super(id);
- this.bounds = bounds;
- }
-
- /**
- * Add a child to the container.
- */
- public void add(LayoutPart newPart) {
- if (!(newPart instanceof PartPlaceholder)) {
- return;
- }
- children.add(newPart);
- }
-
- /**
- * Return true if the container allows its
- * parts to show a border if they choose to,
- * else false if the container does not want
- * its parts to show a border.
- * @return boolean
- */
- public boolean allowsBorder() {
- return false;
- }
-
- public Rectangle getBounds() {
- return bounds;
- }
-
- /**
- * Returns a list of layout children.
- */
- public LayoutPart[] getChildren() {
- LayoutPart result[] = new LayoutPart[children.size()];
- children.toArray(result);
- return result;
- }
-
- /**
- * Remove a child from the container.
- */
- public void remove(LayoutPart part) {
- children.remove(part);
- }
-
- /**
- * Replace one child with another
- */
- public void replace(LayoutPart oldPart, LayoutPart newPart) {
- remove(oldPart);
- add(newPart);
- }
-
-
- /**
- * Restore the state from the memento.
- * @param memento
- */
- public void restoreState(IMemento memento) {
- // Read the bounds.
- Integer bigInt;
- bigInt = memento.getInteger(IWorkbenchConstants.TAG_X);
- int x = bigInt.intValue();
- bigInt = memento.getInteger(IWorkbenchConstants.TAG_Y);
- int y = bigInt.intValue();
- bigInt = memento.getInteger(IWorkbenchConstants.TAG_WIDTH);
- int width = bigInt.intValue();
- bigInt = memento.getInteger(IWorkbenchConstants.TAG_HEIGHT);
- int height = bigInt.intValue();
-
- bounds = new Rectangle(x, y, width, height);
-
- // Restore the placeholders.
- IMemento childrenMem[] = memento
- .getChildren(IWorkbenchConstants.TAG_VIEW);
- for (int i = 0; i < childrenMem.length; i++) {
- PartPlaceholder holder = new PartPlaceholder(childrenMem[i]
- .getString(IWorkbenchConstants.TAG_ID));
- holder.setContainer(this);
- children.add(holder);
- }
- }
-
- /**
- * Save state to the memento.
- * @param memento
- */
- public void saveState(IMemento memento) {
- // Save the bounds.
- memento.putInteger(IWorkbenchConstants.TAG_X, bounds.x);
- memento.putInteger(IWorkbenchConstants.TAG_Y, bounds.y);
- memento.putInteger(IWorkbenchConstants.TAG_WIDTH, bounds.width);
- memento.putInteger(IWorkbenchConstants.TAG_HEIGHT, bounds.height);
-
- // Save the views.
- for (int i = 0; i < children.size(); i++) {
- IMemento childMem = memento
- .createChild(IWorkbenchConstants.TAG_VIEW);
- LayoutPart child = (LayoutPart) children.get(i);
- childMem.putString(IWorkbenchConstants.TAG_ID, child.getID());
- }
- }
-
- public void findSashes(LayoutPart part, PartPane.Sashes sashes) {
- ILayoutContainer container = getContainer();
-
- if (container != null) {
- container.findSashes(this, sashes);
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.internal.ILayoutContainer#allowsAutoFocus()
- */
- public boolean allowsAutoFocus() {
- return false;
- }
-}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/DetachedWindow.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/DetachedWindow.java
deleted file mode 100644
index 09f401ec6ac..00000000000
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/DetachedWindow.java
+++ /dev/null
@@ -1,528 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 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
- * Stefan Xenos, IBM; Chris Torrence, ITT Visual Information Solutions - bug 51580
- *******************************************************************************/
-
-package org.eclipse.ui.internal;
-
-import java.util.ArrayList;
-import java.util.Enumeration;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Vector;
-
-import org.eclipse.jface.util.Geometry;
-import org.eclipse.jface.window.Window;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.ShellAdapter;
-import org.eclipse.swt.events.ShellEvent;
-import org.eclipse.swt.events.ShellListener;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.Listener;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.IMemento;
-import org.eclipse.ui.IPropertyListener;
-import org.eclipse.ui.ISaveablePart;
-import org.eclipse.ui.IViewPart;
-import org.eclipse.ui.IViewReference;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.IWorkbenchPartConstants;
-import org.eclipse.ui.IWorkbenchPartReference;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.contexts.IContextService;
-import org.eclipse.ui.internal.dnd.DragUtil;
-import org.eclipse.ui.internal.dnd.IDragOverListener;
-import org.eclipse.ui.internal.dnd.IDropTarget;
-import org.eclipse.ui.internal.presentations.PresentationFactoryUtil;
-import org.eclipse.ui.internal.presentations.util.AbstractTabFolder;
-import org.eclipse.ui.internal.presentations.util.TabFolderEvent;
-import org.eclipse.ui.internal.presentations.util.TabFolderListener;
-import org.eclipse.ui.internal.presentations.util.TabbedStackPresentation;
-import org.eclipse.ui.presentations.StackDropResult;
-
-
-/**
- * TODO: Drag from detached to fast view bar back to detached causes NPE
- *
- * @since 3.1
- */
-public class DetachedWindow implements IDragOverListener {
-
- public static final int INFINITE = Integer.MAX_VALUE;
-
- private PartStack folder;
-
- private WorkbenchPage page;
-
- private Rectangle bounds = new Rectangle(0,0,0,0);
-
- private Shell windowShell;
-
- private boolean hideViewsOnClose = true;
-
- private ShellListener shellListener = new ShellAdapter() {
- public void shellClosed(ShellEvent e) {
- // only continue to close if the handleClose
- // wasn't canceled
- e.doit = handleClose();
- }
- };
-
- private Listener resizeListener = new Listener() {
- public void handleEvent(Event event) {
- Shell shell = (Shell) event.widget;
- folder.setBounds(shell.getClientArea());
- }
- };
-
- private Listener activationListener = new Listener() {
- public void handleEvent(Event event) {
- switch (event.type) {
- case SWT.Activate:
- page.window.liftRestrictions();
- break;
- case SWT.Deactivate:
- page.window.imposeRestrictions();
- break;
- }
- }
- };
-
- private IPropertyListener propertyListener = new IPropertyListener() {
- public void propertyChanged(Object source, int propId) {
- if (propId == PartStack.PROP_SELECTION) {
- activePartChanged(getPartReference(folder.getSelection()));
- }
- }
- };
-
- private IWorkbenchPartReference activePart;
-
- private IPropertyListener partPropertyListener = new IPropertyListener() {
- public void propertyChanged(Object source, int propId) {
- if (propId == IWorkbenchPartConstants.PROP_TITLE) {
- updateTitle();
- }
- }
- };
-
- /**
- * Create a new FloatingWindow.
- */
- public DetachedWindow(WorkbenchPage workbenchPage) {
- this.page = workbenchPage;
-
- folder = new ViewStack(page, false, PresentationFactoryUtil.ROLE_VIEW, null);
- folder.addListener(propertyListener);
- }
-
- protected void activePartChanged(IWorkbenchPartReference partReference) {
- if (activePart == partReference) {
- return;
- }
-
- if (activePart != null) {
- activePart.removePropertyListener(partPropertyListener);
- }
- activePart = partReference;
- if (partReference != null) {
- partReference.addPropertyListener(partPropertyListener);
- }
- updateTitle();
- }
-
- private void updateTitle() {
- if (activePart != null) {
- // Uncomment to set the shell title to match the title of the active part
-// String text = activePart.getTitle();
-//
-// if (!text.equals(s.getText())) {
-// s.setText(text);
-// }
- }
- }
-
- /**
- * Ensure that the shell's minimum size is equal to the minimum size
- * of the first part added to the shell.
- */
- private void updateMinimumSize() {
- // We can only do this for 'Tabbed' stacked presentations.
- if (folder.getPresentation() instanceof TabbedStackPresentation) {
- TabbedStackPresentation stack = (TabbedStackPresentation) folder.getPresentation();
-
- if (stack.getPartList().length == 1) {
- // Get the minimum space required for the part
- int width = stack.computePreferredSize(true, INFINITE, INFINITE, 0);
- int height = stack.computePreferredSize(false, INFINITE, INFINITE, 0);
-
- // Take the current shell 'trim' into account
- int shellHeight = windowShell.getBounds().height - windowShell.getClientArea().height;
- int shellWidth = windowShell.getBounds().width - windowShell.getClientArea().width;
-
- windowShell.setMinimumSize(width + shellWidth, height + shellHeight);
- }
- }
- }
-
- private static IWorkbenchPartReference getPartReference(PartPane pane) {
-
- if (pane == null) {
- return null;
- }
-
- return pane.getPartReference();
- }
-
- public Shell getShell() {
- return windowShell;
- }
-
- public void create() {
- windowShell = ((WorkbenchWindow)page.getWorkbenchWindow()).getDetachedWindowPool().allocateShell(shellListener);
- windowShell.setData(this);
- windowShell.setText(""); //$NON-NLS-1$
- DragUtil.addDragTarget(windowShell, this);
- hideViewsOnClose = true;
- if (bounds.isEmpty()) {
- Point center = Geometry.centerPoint(page.getWorkbenchWindow().getShell().getBounds());
- Point size = new Point(300, 200);
- Point upperLeft = Geometry.subtract(center, Geometry.divide(size, 2));
-
- bounds = Geometry.createRectangle(upperLeft, size);
- }
-
- // Force the rect into the current display
- Rectangle dispBounds = getShell().getDisplay().getBounds();
- if (bounds.width > dispBounds.width)
- bounds.width = dispBounds.width;
- if (bounds.height > dispBounds.height)
- bounds.height = dispBounds.height;
- if (bounds.x+bounds.width > dispBounds.width)
- bounds.x = dispBounds.width - bounds.width;
- if (bounds.y+bounds.height > dispBounds.height)
- bounds.y = dispBounds.height - bounds.height;
-
- getShell().setBounds(bounds);
-
- configureShell(windowShell);
-
- createContents(windowShell);
- windowShell.layout(true);
- folder.setBounds(windowShell.getClientArea());
- }
-
-
- /**
- * Adds a visual part to this window.
- * Supports reparenting.
- */
- public void add(ViewPane part) {
-
- Shell shell = getShell();
- if (shell != null) {
- part.reparent(shell);
- }
- folder.add(part);
- updateMinimumSize();
- }
-
- public boolean belongsToWorkbenchPage(IWorkbenchPage workbenchPage) {
- return (this.page == workbenchPage);
- }
-
- public boolean close() {
- hideViewsOnClose = false;
- Shell shell = getShell();
- if (shell != null) {
- shell.close();
- }
- return true;
- }
-
- /**
- * Closes this window and disposes its shell.
- */
- private boolean handleClose() {
-
- if (hideViewsOnClose) {
- List views = new ArrayList();
- collectViewPanes(views, getChildren());
-
- // Save any drty views
- if (!handleSaves(views)) {
- return false; // User canceled the save
- }
-
- // OK, go on with the closing
- Iterator itr = views.iterator();
- while (itr.hasNext()) {
- ViewPane child = (ViewPane) itr.next();
-
- // Only close if closable...
- if (child.isCloseable()) {
- page.hideView(child.getViewReference());
-
- // Was the close cancelled?
- if (child.container != null)
- return false;
- } else {
- page.attachView(child.getViewReference());
- }
- }
- }
-
- if (folder != null) {
- folder.dispose();
- }
-
- if (windowShell != null) {
- windowShell.removeListener(SWT.Resize, resizeListener);
- windowShell.removeListener(SWT.Activate, activationListener);
- windowShell.removeListener(SWT.Deactivate, activationListener);
- DragUtil.removeDragTarget(windowShell, this);
- bounds = windowShell.getBounds();
-
- // Unregister this detached view as a window (for key bindings).
- final IContextService contextService = (IContextService) getWorkbenchPage().getWorkbenchWindow().getWorkbench().getService(IContextService.class);
- contextService.unregisterShell(windowShell);
-
- windowShell.setData(null);
- windowShell = null;
- }
-
- return true;
- }
-
- /**
- * Prompts for and handles the saving of dirty, saveable views
- * @param views The list of ViewPanes
- * @return <code>true</code> unless the user cancels the save(s)
- */
- private boolean handleSaves(List views) {
- List dirtyViews = new ArrayList();
- for (Iterator iterator = views.iterator(); iterator.hasNext();) {
- ViewPane pane = (ViewPane) iterator.next();
- IViewReference ref = pane.getViewReference();
- IViewPart part = ref.getView(false);
- if (part instanceof ISaveablePart) {
- ISaveablePart saveable = (ISaveablePart)part;
- if (saveable.isDirty() && saveable.isSaveOnCloseNeeded()) {
- dirtyViews.add(part);
- }
- }
- }
-
- // If there are any prompt to save -before- any closing happens
- // FIXME: This code will result in a double prompt if the user
- // decides not to save a particular view at this stage they'll
- // get a second one from the 'hideView' call...
- if (dirtyViews.size() > 0) {
- IWorkbenchWindow window = page.getWorkbenchWindow();
- boolean success = EditorManager.saveAll(dirtyViews, true, true, false, window);
- if (!success) {
- return false; // the user canceled.
- }
- }
-
- return true;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.internal.dnd.IDragOverListener#drag(org.eclipse.swt.widgets.Control, java.lang.Object, org.eclipse.swt.graphics.Point, org.eclipse.swt.graphics.Rectangle)
- */
- public IDropTarget drag(Control currentControl, Object draggedObject,
- Point position, Rectangle dragRectangle) {
-
- if (!(draggedObject instanceof PartPane)) {
- return null;
- }
-
- final PartPane sourcePart = (PartPane) draggedObject;
-
- if (sourcePart.getWorkbenchWindow() != page.getWorkbenchWindow()) {
- return null;
- }
-
- // Only handle the event if the source part is acceptable to the particular PartStack
- IDropTarget target = null;
- if (folder.allowsDrop(sourcePart)) {
- target = folder.getDropTarget(draggedObject, position);
-
- if (target == null) {
- Rectangle displayBounds = DragUtil.getDisplayBounds(folder.getControl());
- if (displayBounds.contains(position)) {
- target = folder.createDropTarget(sourcePart, new StackDropResult(displayBounds, null));
- } else {
- return null;
- }
- }
- }
-
- return target;
- }
-
- /**
- * Answer a list of the view panes.
- */
- private void collectViewPanes(List result, LayoutPart[] parts) {
- for (int i = 0, length = parts.length; i < length; i++) {
- LayoutPart part = parts[i];
- if (part instanceof ViewPane) {
- result.add(part);
- }
- }
- }
-
- /**
- * This method will be called to initialize the given Shell's layout
- */
- protected void configureShell(Shell shell) {
- updateTitle();
- shell.addListener(SWT.Resize, resizeListener);
- shell.addListener(SWT.Activate, activationListener);
- shell.addListener(SWT.Deactivate, activationListener);
-
- // Register this detached view as a window (for key bindings).
- final IContextService contextService = (IContextService) getWorkbenchPage()
- .getWorkbenchWindow().getWorkbench().getService(IContextService.class);
- contextService.registerShell(shell,
- IContextService.TYPE_WINDOW);
-
- page.getWorkbenchWindow().getWorkbench().getHelpSystem().setHelp(shell,
- IWorkbenchHelpContextIds.DETACHED_WINDOW);
- }
-
- /**
- * Override this method to create the widget tree that is used as the window's contents.
- */
- protected Control createContents(Composite parent) {
- // Create the tab folder.
- folder.createControl(parent);
-
- // Reparent each view in the tab folder.
- Vector detachedChildren = new Vector();
- collectViewPanes(detachedChildren, getChildren());
- Enumeration itr = detachedChildren.elements();
- while (itr.hasMoreElements()) {
- LayoutPart part = (LayoutPart) itr.nextElement();
- part.reparent(parent);
- }
-
- if (folder.getPresentation() instanceof TabbedStackPresentation) {
- TabbedStackPresentation stack = (TabbedStackPresentation) folder.getPresentation();
- AbstractTabFolder tabFolder = stack.getTabFolder();
- tabFolder.addListener(new TabFolderListener() {
- public void handleEvent(TabFolderEvent e) {
- switch (e.type) {
- case TabFolderEvent.EVENT_CLOSE: {
- updateMinimumSize();
- break;
- }
- case TabFolderEvent.EVENT_PREFERRED_SIZE: {
- updateMinimumSize();
- break;
- }
- }
- }
- });
- }
-
- // Return tab folder control.
- return folder.getControl();
- }
-
- public LayoutPart[] getChildren() {
- return folder.getChildren();
- }
-
- public WorkbenchPage getWorkbenchPage() {
- return this.page;
- }
-
- /**
- * @see IPersistablePart
- */
- public void restoreState(IMemento memento) {
- // Read the bounds.
- Integer bigInt;
- bigInt = memento.getInteger(IWorkbenchConstants.TAG_X);
- int x = bigInt.intValue();
- bigInt = memento.getInteger(IWorkbenchConstants.TAG_Y);
- int y = bigInt.intValue();
- bigInt = memento.getInteger(IWorkbenchConstants.TAG_WIDTH);
- int width = bigInt.intValue();
- bigInt = memento.getInteger(IWorkbenchConstants.TAG_HEIGHT);
- int height = bigInt.intValue();
- bigInt = memento.getInteger(IWorkbenchConstants.TAG_FLOAT);
-
- // Set the bounds.
- bounds = new Rectangle(x, y, width, height);
- if (getShell() != null) {
- getShell().setBounds(bounds);
- }
-
- // Create the folder.
- IMemento childMem = memento.getChild(IWorkbenchConstants.TAG_FOLDER);
- if (childMem != null) {
- folder.restoreState(childMem);
- }
- }
-
- /**
- * @see IPersistablePart
- */
- public void saveState(IMemento memento) {
- if (getShell() != null) {
- bounds = getShell().getBounds();
- }
-
- // Save the bounds.
- memento.putInteger(IWorkbenchConstants.TAG_X, bounds.x);
- memento.putInteger(IWorkbenchConstants.TAG_Y, bounds.y);
- memento.putInteger(IWorkbenchConstants.TAG_WIDTH, bounds.width);
- memento.putInteger(IWorkbenchConstants.TAG_HEIGHT, bounds.height);
-
- // Save the views.
- IMemento childMem = memento.createChild(IWorkbenchConstants.TAG_FOLDER);
- folder.saveState(childMem);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.internal.IWorkbenchDragDropPart#getControl()
- */
- public Control getControl() {
- return folder.getControl();
- }
-
- /**
- * Opens the detached window.
- */
- public int open() {
-
- if (getShell() == null) {
- create();
- }
-
- Rectangle bounds = getShell().getBounds();
- getShell().setVisible(true);
-
- if (!bounds.equals(getShell().getBounds())) {
- getShell().setBounds(bounds);
- }
-
- return Window.OK;
- }
-
-}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/EditorAreaHelper.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/EditorAreaHelper.java
deleted file mode 100644
index 326894b5877..00000000000
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/EditorAreaHelper.java
+++ /dev/null
@@ -1,335 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 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.core.runtime.IStatus;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IEditorReference;
-import org.eclipse.ui.IMemento;
-import org.eclipse.ui.IPageLayout;
-import org.eclipse.ui.part.AbstractMultiEditor;
-
-/**
- * EditorAreaHelper is a wrapper for PartTabworkbook.
- */
-public class EditorAreaHelper {
-
- //private ArrayList editorTable = new ArrayList(4);
-
- private EditorSashContainer editorArea;
-
- /**
- * Creates a new EditorAreaHelper.
- */
- public EditorAreaHelper(WorkbenchPage page) {
- this.editorArea = new EditorSashContainer(IPageLayout.ID_EDITOR_AREA,
- page, page.getClientComposite());
-
- this.editorArea.createControl(page.getClientComposite());
- this.editorArea.setActive(true);
- }
-
- /**
- * Displays a list of open editors
- */
- public void displayEditorList() {
- EditorStack activeWorkbook = editorArea.getActiveWorkbook();
- if (activeWorkbook != null) {
- activeWorkbook.showPartList();
- }
- }
-
- /**
- * Closes an editor.
- *
- * @param part the editor to close
- */
- public void closeEditor(IEditorReference ref) {
- EditorPane pane = (EditorPane) ((WorkbenchPartReference) ref).getPane();
- closeEditor(pane);
- }
-
- /**
- * Closes an editor.
- *
- * @param part the editor to close
- */
- public void closeEditor(IEditorPart part) {
- EditorPane pane = (EditorPane) ((PartSite) part.getEditorSite())
- .getPane();
- closeEditor(pane);
- }
-
- /**
- * Closes an editor.
- *
- * @param part the editor to close
- */
- private void closeEditor(EditorPane pane) {
- if (pane != null) {
- if (!(pane instanceof MultiEditorInnerPane)) {
- editorArea.removeEditor(pane);
- }
- }
- }
-
- /**
- * Deref a given part. Deconstruct its container as required.
- * Do not remove drag listeners.
- */
- public static void derefPart(LayoutPart part) {
-
- // Get vital part stats before reparenting.
- ILayoutContainer oldContainer = part.getContainer();
-
- // Reparent the part back to the main window
- //part.reparent(editorArea.getParent());
- // Update container.
- if (oldContainer == null) {
- return;
- }
- oldContainer.remove(part);
- LayoutPart[] children = oldContainer.getChildren();
- if (children == null || children.length == 0) {
- // There are no more children in this container, so get rid of it
- if (oldContainer instanceof LayoutPart) {
- LayoutPart parent = (LayoutPart) oldContainer;
- ILayoutContainer parentContainer = parent.getContainer();
- if (parentContainer != null) {
- parentContainer.remove(parent);
- parent.dispose();
- }
- }
- }
- }
-
- /**
- * Dispose of the editor presentation.
- */
- public void dispose() {
- if (editorArea != null) {
- editorArea.setActive(false);
- editorArea.dispose();
- }
- }
-
- /**
- * @see IEditorPresentation
- */
- public String getActiveEditorWorkbookID() {
- return editorArea.getActiveWorkbookID();
- }
-
- public EditorStack getActiveWorkbook() {
- return editorArea.getActiveWorkbook();
- }
-
- /**
- * Returns the editor area.
- */
- public LayoutPart getLayoutPart() {
- return editorArea;
- }
-
- /**
- * Returns the active editor in this perspective. If the editors appear
- * in a workbook this will be the visible editor. If the editors are
- * scattered around the workbench this will be the most recent editor
- * to hold focus.
- *
- * @return the active editor, or <code>null</code> if no editor is active
- */
- public IEditorReference getVisibleEditor() {
- EditorStack activeWorkbook = editorArea.getActiveWorkbook();
- EditorPane pane = (EditorPane)activeWorkbook.getSelection();
- if (pane != null) {
- IEditorReference result = pane.getEditorReference();
- IEditorPart editorPart = (IEditorPart) result.getPart(false);
- if ((editorPart != null) && (editorPart instanceof AbstractMultiEditor)) {
- editorPart = ((AbstractMultiEditor) editorPart).getActiveEditor();
- EditorSite site = (EditorSite) editorPart.getSite();
- result = (IEditorReference) site.getPartReference();
- }
- return result;
- }
- return null;
- }
-
- public void moveEditor(IEditorPart part, int position) {
- /*EditorPane pane = (EditorPane)*/ ((EditorSite) part.getSite()).getPane();
- //TODO commented this out during presentations works
- //pane.getWorkbook().reorderTab(pane, position);
- }
-
-
-
- public boolean containsEditor(EditorReference ref) {
- IEditorReference refs[] = editorArea.getPage().getEditorReferences();
- for (int i = 0; i < refs.length; i++) {
- if (ref == refs[i]) {
- return true;
- }
- }
- return false;
- }
- /**
- * Main entry point for adding an editor. Adds the editor to the layout in the given
- * stack, and notifies the workbench page when done.
- *
- * @param ref editor to add
- * @param workbookId workbook that will contain the editor (or null if the editor
- * should be added to the default workbook)
- */
- public void addEditor(EditorReference ref, String workbookId, boolean notifyPage) {
- if (containsEditor(ref)) {
- return;
- }
-
- if (!(ref.getPane() instanceof MultiEditorInnerPane)) {
-
- EditorStack stack = null;
-
- if (workbookId != null) {
- stack = getWorkbookFromID(workbookId);
- }
-
- if (stack == null) {
- stack = getActiveWorkbook();
- }
-
- addToLayout((EditorPane)ref.getPane(), stack);
- }
-
- if (notifyPage) {
- editorArea.getPage().partAdded(ref);
- }
- }
-
- private void addToLayout(EditorPane pane, EditorStack stack) {
- //EditorStack stack = editorArea.getActiveWorkbook();
- pane.setWorkbook(stack);
-
- editorArea.addEditor(pane, stack);
- }
-
-
- /**
- * @see IPersistablePart
- */
- public IStatus restoreState(IMemento memento) {
- // Restore the editor area workbooks layout/relationship
- return editorArea.restoreState(memento);
- }
-
- /**
- * Restore the presentation
- * @param areaMem
- * @return
- */
- public IStatus restorePresentationState(IMemento areaMem) {
- return editorArea.restorePresentationState(areaMem);
- }
-
- /**
- * @see IPersistablePart
- */
- public IStatus saveState(IMemento memento) {
- // Save the editor area workbooks layout/relationship
- return editorArea.saveState(memento);
- }
-
- /**
- * @see IEditorPresentation
- */
- public void setActiveEditorWorkbookFromID(String id) {
- editorArea.setActiveWorkbookFromID(id);
- }
-
- /**
- * Brings an editor to the front and optionally gives it focus.
- *
- * @param part the editor to make visible
- * @param setFocus whether to give the editor focus
- * @return true if the visible editor was changed, false if not.
- */
- public boolean setVisibleEditor(IEditorReference ref, boolean setFocus) {
- IEditorReference visibleEditor = getVisibleEditor();
- if (ref != visibleEditor) {
- IEditorPart part = (IEditorPart) ref.getPart(true);
- EditorPane pane = null;
- if (part != null) {
- pane = (EditorPane) ((PartSite) part.getEditorSite()).getPane();
- }
- if (pane != null) {
- if (pane instanceof MultiEditorInnerPane) {
- EditorPane parentPane = ((MultiEditorInnerPane) pane)
- .getParentPane();
- EditorStack activeWorkbook = parentPane.getWorkbook();
- PartPane activePane = activeWorkbook.getSelection();
- if (activePane != parentPane) {
- parentPane.getWorkbook().setSelection(parentPane);
- } else {
- return false;
- }
- } else {
- pane.getWorkbook().setSelection(pane);
- }
- if (setFocus) {
- part.setFocus();
- }
- return true;
- }
- }
- return false;
- }
-
-
-
- /**
- * Method getWorkbooks.
- * @return ArrayList
- */
- public ArrayList getWorkbooks() {
- return editorArea.getEditorWorkbooks();
- }
-
- public IEditorReference[] getEditors() {
- List result = new ArrayList();
- List workbooks = editorArea.getEditorWorkbooks();
-
- for (Iterator iter = workbooks.iterator(); iter.hasNext();) {
- PartStack stack = (PartStack) iter.next();
-
- LayoutPart[] children = stack.getChildren();
-
- for (int i = 0; i < children.length; i++) {
- LayoutPart part = children[i];
-
- result.add(((PartPane)part).getPartReference());
- }
- }
-
- return (IEditorReference[]) result.toArray(new IEditorReference[result.size()]);
- }
-
- public EditorStack getWorkbookFromID(String workbookId) {
- return editorArea.getWorkbookFromID(workbookId);
- }
-
- public void updateStackButtons() {
- editorArea.updateStackButtons();
- }
-}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/EditorAreaTrimToolBar.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/EditorAreaTrimToolBar.java
deleted file mode 100644
index 3d802c6afa4..00000000000
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/EditorAreaTrimToolBar.java
+++ /dev/null
@@ -1,128 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2010 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.jface.action.ContributionItem;
-import org.eclipse.jface.action.IContributionItem;
-import org.eclipse.jface.action.ToolBarManager;
-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.ToolBar;
-import org.eclipse.swt.widgets.ToolItem;
-import org.eclipse.ui.IPageLayout;
-import org.eclipse.ui.IViewReference;
-import org.eclipse.ui.internal.layout.TrimToolBarBase;
-import org.eclipse.ui.presentations.IStackPresentationSite;
-
-public class EditorAreaTrimToolBar extends TrimToolBarBase {
- private boolean restoreOnUnzoom = false;
-
- // The orientation of the fast view pane when showing a view
- private int paneOrientation;
-
- public EditorAreaTrimToolBar(WorkbenchWindow wbw) {
- super(IPageLayout.ID_EDITOR_AREA, SWT.TOP, wbw);
- dock(SWT.TOP);
- }
-
- /**
- * Put the stack back into the presentation
- */
- protected void restoreToPresentation() {
- Perspective persp = wbw.getActiveWorkbenchPage().getActivePerspective();
- persp.setEditorAreaState(IStackPresentationSite.STATE_RESTORED);
- }
-
- public void initToolBarManager(final ToolBarManager mgr) {
- // Set up the ToolBar with a restore button
- IContributionItem restoreContrib = new ContributionItem() {
- public void fill(ToolBar parent, int index) {
- ToolItem restoreItem = new ToolItem(mgr.getControl(), SWT.PUSH, index);
- 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) {
- restoreToPresentation();
- }
- public void widgetSelected(SelectionEvent e) {
- restoreToPresentation();
- }
- });
- }
- };
- mgr.add(restoreContrib);
-
- // Set up the ToolBar with a button represing the Editor Area
- IContributionItem eaContrib = new ContributionItem() {
- public void fill(ToolBar parent, int index) {
- ToolItem editorAreaItem = new ToolItem(mgr.getControl(), SWT.PUSH, index);
- 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) {
- restoreToPresentation();
- }
- public void widgetSelected(SelectionEvent e) {
- restoreToPresentation();
- }
- });
- }
- };
- mgr.add(eaContrib);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.internal.layout.TrimToolBarBase#hookControl(org.eclipse.swt.widgets.ToolBar)
- */
- public void hookControl(ToolBarManager mgr) {
- // Hook a drop Listener to the control
- // NOTE: the drop target is self-managing...it
- // both hooks the new target and removes it on dispose
- new FastViewDnDHandler(id, mgr, wbw);
- }
-
- /**
- * Sets whether or not the stack gets restored on an unzoom
- * operation.
- *
- * @param restoreOnUnzoom
- */
- public void setRestoreOnUnzoom(boolean restoreOnUnzoom) {
- this.restoreOnUnzoom = restoreOnUnzoom;
- }
-
- public boolean restoreOnUnzoom() {
- return restoreOnUnzoom;
- }
-
- /**
- * @param ref
- * @param selected
- */
- public void setIconSelection(IViewReference ref, boolean selected) {
- ToolItem item = ShowFastViewContribution.getItem(tbMgr.getControl(), ref);
- if (item != null)
- item.setSelection(selected);
- }
-
- /**
- * @return Returns the paneOrientation.
- */
- public int getPaneOrientation() {
- return paneOrientation;
- }
-}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/EditorManager.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/EditorManager.java
deleted file mode 100644
index 9fdd5f8ede1..00000000000
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/EditorManager.java
+++ /dev/null
@@ -1,1769 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2011 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
- * Nikolay Botev - bug 240651
- * Markus Schorn - Bug 341327
- *******************************************************************************/
-package org.eclipse.ui.internal;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.ListIterator;
-import java.util.Map;
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.IHandler;
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.IExtension;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.MultiStatus;
-import org.eclipse.core.runtime.SafeRunner;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.SubProgressMonitor;
-import org.eclipse.core.runtime.dynamichelpers.IExtensionChangeHandler;
-import org.eclipse.core.runtime.dynamichelpers.IExtensionTracker;
-import org.eclipse.jface.dialogs.DialogSettings;
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.jface.dialogs.IDialogSettings;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.internal.provisional.action.ICoolBarManager2;
-import org.eclipse.jface.operation.IRunnableContext;
-import org.eclipse.jface.operation.IRunnableWithProgress;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.resource.ImageRegistry;
-import org.eclipse.jface.resource.JFaceResources;
-import org.eclipse.jface.util.IPropertyChangeListener;
-import org.eclipse.jface.util.PropertyChangeEvent;
-import org.eclipse.jface.util.SafeRunnable;
-import org.eclipse.jface.viewers.ArrayContentProvider;
-import org.eclipse.jface.window.IShellProvider;
-import org.eclipse.jface.window.Window;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.BusyIndicator;
-import org.eclipse.swt.program.Program;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.ActiveShellExpression;
-import org.eclipse.ui.IEditorActionBarContributor;
-import org.eclipse.ui.IEditorDescriptor;
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.IEditorLauncher;
-import org.eclipse.ui.IEditorMatchingStrategy;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IEditorReference;
-import org.eclipse.ui.IEditorRegistry;
-import org.eclipse.ui.IEditorSite;
-import org.eclipse.ui.IMemento;
-import org.eclipse.ui.IPathEditorInput;
-import org.eclipse.ui.IPersistableEditor;
-import org.eclipse.ui.IPersistableElement;
-import org.eclipse.ui.ISaveablePart;
-import org.eclipse.ui.ISaveablePart2;
-import org.eclipse.ui.ISaveablesLifecycleListener;
-import org.eclipse.ui.ISaveablesSource;
-import org.eclipse.ui.IViewPart;
-import org.eclipse.ui.IWorkbenchCommandConstants;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.IWorkbenchPart3;
-import org.eclipse.ui.IWorkbenchPartReference;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.Saveable;
-import org.eclipse.ui.dialogs.EditorSelectionDialog;
-import org.eclipse.ui.dialogs.ListSelectionDialog;
-import org.eclipse.ui.handlers.IHandlerActivation;
-import org.eclipse.ui.handlers.IHandlerService;
-import org.eclipse.ui.internal.StartupThreading.StartupRunnable;
-import org.eclipse.ui.internal.dialogs.EventLoopProgressMonitor;
-import org.eclipse.ui.internal.editorsupport.ComponentSupport;
-import org.eclipse.ui.internal.misc.ExternalEditor;
-import org.eclipse.ui.internal.misc.StatusUtil;
-import org.eclipse.ui.internal.misc.UIStats;
-import org.eclipse.ui.internal.part.NullEditorInput;
-import org.eclipse.ui.internal.progress.ProgressManagerUtil;
-import org.eclipse.ui.internal.registry.EditorDescriptor;
-import org.eclipse.ui.internal.registry.EditorRegistry;
-import org.eclipse.ui.internal.tweaklets.TabBehaviour;
-import org.eclipse.ui.internal.tweaklets.Tweaklets;
-import org.eclipse.ui.internal.util.PrefUtil;
-import org.eclipse.ui.internal.util.Util;
-import org.eclipse.ui.model.WorkbenchPartLabelProvider;
-import org.eclipse.ui.part.AbstractMultiEditor;
-import org.eclipse.ui.part.MultiEditor;
-import org.eclipse.ui.part.MultiEditorInput;
-import org.eclipse.ui.statushandlers.StatusManager;
-
-/**
- * Manage a group of element editors. Prevent the creation of two editors on the
- * same element.
- *
- * 06/12/00 - DS - Given the ambiguous editor input type, the manager delegates
- * a number of responsibilities to the editor itself.
- *
- * <ol>
- * <li>The editor should determine its own title.</li>
- * <li>The editor should listen to resource deltas and close itself if the
- * input is deleted. It may also choose to stay open if the editor has dirty
- * state.</li>
- * <li>The editor should persist its own state plus editor input.</li>
- * </ol>
- */
-public class EditorManager implements IExtensionChangeHandler {
- EditorAreaHelper editorPresentation;
-
- WorkbenchWindow window;
-
- WorkbenchPage page;
-
- private Map actionCache = new HashMap();
-
- private static final String PIN_EDITOR_KEY = "PIN_EDITOR"; //$NON-NLS-1$
-
- private static final String PIN_EDITOR = "ovr16/pinned_ovr.gif"; //$NON-NLS-1$
-
- // When the user removes or adds the close editors automatically preference
- // the icon should be removed or added accordingly
- private IPropertyChangeListener editorPropChangeListnener = null;
-
- // Handler for the pin editor keyboard shortcut
- private IHandlerActivation pinEditorHandlerActivation = null;
-
- // determines if a prompt is shown when opening large files
- private long maxFileSize = 0;
- private boolean checkDocumentSize;
-
- static final String RESOURCES_TO_SAVE_MESSAGE = WorkbenchMessages.EditorManager_saveResourcesMessage;
-
- static final String SAVE_RESOURCES_TITLE = WorkbenchMessages.EditorManager_saveResourcesTitle;
-
- /**
- * EditorManager constructor comment.
- */
- public EditorManager(WorkbenchWindow window, WorkbenchPage workbenchPage,
- EditorAreaHelper pres) {
- Assert.isNotNull(window);
- Assert.isNotNull(workbenchPage);
- Assert.isNotNull(pres);
- this.window = window;
- this.page = workbenchPage;
- this.editorPresentation = pres;
-
- initMaxFileSize();
- page.getExtensionTracker().registerHandler(this, null);
- }
-
- private void initMaxFileSize() {
- IPreferenceStore preferenceStore = PrefUtil.getInternalPreferenceStore();
- maxFileSize = preferenceStore.getLong(IPreferenceConstants.LARGE_DOC_SIZE_FOR_EDITORS);
- checkDocumentSize = maxFileSize != 0;
- }
-
- /**
- * Check to determine if the editor resources are no longer needed removes
- * property change listener for editors removes pin editor keyboard shortcut
- * handler disposes cached images and clears the cached images hash table
- */
- void checkDeleteEditorResources() {
- // get the current number of editors
- IEditorReference[] editors = page.getEditorReferences();
- // If there are no editors
- if (editors.length == 0) {
- if (editorPropChangeListnener != null) {
- // remove property change listener for editors
- IPreferenceStore prefStore = WorkbenchPlugin.getDefault()
- .getPreferenceStore();
- prefStore
- .removePropertyChangeListener(editorPropChangeListnener);
- editorPropChangeListnener = null;
- }
- if (pinEditorHandlerActivation != null) {
- // remove pin editor keyboard shortcut handler
- final IHandlerService handlerService = (IHandlerService) window.getWorkbench().getService(IHandlerService.class);
- handlerService.deactivateHandler(pinEditorHandlerActivation);
- pinEditorHandlerActivation = null;
- }
- }
- }
-
- /**
- * Check to determine if the property change listener for editors should be
- * created
- */
- void checkCreateEditorPropListener() {
- if (editorPropChangeListnener == null) {
- // Add a property change listener for closing editors automatically
- // preference
- // Add or remove the pin icon accordingly
- editorPropChangeListnener = new IPropertyChangeListener() {
- public void propertyChange(PropertyChangeEvent event) {
- if (event.getProperty().equals(
- IPreferenceConstants.REUSE_EDITORS_BOOLEAN)) {
- IEditorReference[] editors = getEditors();
- for (int i = 0; i < editors.length; i++) {
- ((EditorReference) editors[i]).pinStatusUpdated();
- }
- }
- }
- };
- WorkbenchPlugin.getDefault().getPreferenceStore()
- .addPropertyChangeListener(editorPropChangeListnener);
- }
- }
-
- /**
- * Check to determine if the handler for the pin editor keyboard shortcut
- * should be created.
- */
- void checkCreatePinEditorShortcutKeyHandler() {
- if (pinEditorHandlerActivation == null) {
- final Shell shell = window.getShell();
- final IHandler pinEditorHandler = new AbstractHandler() {
- public final Object execute(final ExecutionEvent event) {
- // check if the "Close editors automatically" preference is
- // set
- IPreferenceStore store = WorkbenchPlugin.getDefault().getPreferenceStore();
- if (store
- .getBoolean(IPreferenceConstants.REUSE_EDITORS_BOOLEAN)
- || ((TabBehaviour)Tweaklets.get(TabBehaviour.KEY)).alwaysShowPinAction()) {
-
- IWorkbenchPartReference ref = editorPresentation
- .getVisibleEditor();
- if (ref instanceof WorkbenchPartReference) {
- WorkbenchPartReference concreteRef = (WorkbenchPartReference) ref;
-
- concreteRef.setPinned(concreteRef.isPinned());
- }
- }
- return null;
- }
- };
-
- // Assign the handler for the pin editor keyboard shortcut.
- final IHandlerService handlerService = (IHandlerService) window.getWorkbench().getService(IHandlerService.class);
- pinEditorHandlerActivation = handlerService.activateHandler(
- IWorkbenchCommandConstants.WINDOW_PIN_EDITOR, pinEditorHandler,
- new ActiveShellExpression(shell));
- }
- }
-
- /**
- * Method to create the editor's pin ImageDescriptor
- *
- * @return the single image descriptor for the editor's pin icon
- */
- ImageDescriptor getEditorPinImageDesc() {
- ImageRegistry registry = JFaceResources.getImageRegistry();
- ImageDescriptor pinDesc = registry.getDescriptor(PIN_EDITOR_KEY);
- // Avoid registering twice
- if (pinDesc == null) {
- pinDesc = WorkbenchImages.getWorkbenchImageDescriptor(PIN_EDITOR);
- registry.put(PIN_EDITOR_KEY, pinDesc);
-
- }
- return pinDesc;
- }
-
- /**
- * Answer a list of dirty editors.
- */
- private List collectDirtyEditors() {
- List result = new ArrayList(3);
- IEditorReference[] editors = page.getEditorReferences();
- for (int i = 0; i < editors.length; i++) {
- IEditorPart part = (IEditorPart) editors[i].getPart(false);
- if (part != null && part.isDirty()) {
- result.add(part);
- }
-
- }
- return result;
- }
-
- /**
- * Returns whether the manager contains an editor.
- */
- public boolean containsEditor(IEditorReference ref) {
- IEditorReference[] editors = page.getEditorReferences();
- for (int i = 0; i < editors.length; i++) {
- if (ref == editors[i]) {
- return true;
- }
- }
- return false;
- }
-
- /*
- * Creates the action bars for an editor. Editors of the same type should
- * share a single editor action bar, so this implementation may return an
- * existing action bar vector.
- */
- private EditorActionBars createEditorActionBars(EditorDescriptor desc,
- final IEditorSite site) {
- // Get the editor type.
- String type = desc.getId();
-
- // If an action bar already exists for this editor type return it.
- EditorActionBars actionBars = (EditorActionBars) actionCache.get(type);
- if (actionBars != null) {
- actionBars.addRef();
- return actionBars;
- }
-
- // Create a new action bar set.
- actionBars = new EditorActionBars(page, site.getWorkbenchWindow(), type);
- actionBars.addRef();
- actionCache.put(type, actionBars);
-
- // Read base contributor.
- IEditorActionBarContributor contr = desc.createActionBarContributor();
- if (contr != null) {
- actionBars.setEditorContributor(contr);
- contr.init(actionBars, page);
- }
-
- // Read action extensions.
- EditorActionBuilder builder = new EditorActionBuilder();
- contr = builder.readActionExtensions(desc);
- if (contr != null) {
- actionBars.setExtensionContributor(contr);
- contr.init(actionBars, page);
- }
-
- // Return action bars.
- return actionBars;
- }
-
- /*
- * Creates the action bars for an editor.
- */
- private EditorActionBars createEmptyEditorActionBars(final IEditorSite site) {
- // Get the editor type.
- String type = String.valueOf(System.currentTimeMillis());
-
- // Create a new action bar set.
- // Note: It is an empty set.
- EditorActionBars actionBars = new EditorActionBars(page, site.getWorkbenchWindow(), type);
- actionBars.addRef();
- actionCache.put(type, actionBars);
-
- // Return action bars.
- return actionBars;
- }
-
- /*
- * Dispose
- */
- void disposeEditorActionBars(EditorActionBars actionBars) {
- actionBars.removeRef();
- if (actionBars.getRef() <= 0) {
- String type = actionBars.getEditorType();
- Object obj = actionCache.get(type);
- if (actionBars == obj) {
- actionCache.remove(type);
- }
- // refresh the cool bar manager before disposing of a cool item
- ICoolBarManager2 coolBar = (ICoolBarManager2) window.getCoolBarManager2();
- if (coolBar != null) {
- coolBar.refresh();
- }
- actionBars.dispose();
- }
- }
-
- /**
- * Returns an open editor matching the given editor input. If none match,
- * returns <code>null</code>.
- *
- * @param input
- * the editor input
- * @return the matching editor, or <code>null</code> if no match found
- */
- public IEditorPart findEditor(IEditorInput input) {
- return findEditor(null, input, IWorkbenchPage.MATCH_INPUT);
- }
-
- /**
- * Returns an open editor matching the given editor input and/or editor id,
- * as specified by matchFlags. If none match, returns <code>null</code>.
- *
- * @param editorId
- * the editor id
- * @param input
- * the editor input
- * @param matchFlags
- * flags specifying which aspects to match
- * @return the matching editor, or <code>null</code> if no match found
- * @since 3.1
- */
- public IEditorPart findEditor(String editorId, IEditorInput input,
- int matchFlags) {
- IEditorReference[] refs = findEditors(input, editorId, matchFlags);
- if (refs.length == 0) {
- return null;
- }
- return refs[0].getEditor(true);
- }
-
- /**
- * Returns the open editor references matching the given editor input and/or
- * editor id, as specified by matchFlags. If none match, returns an empty
- * array.
- *
- * @param editorId
- * the editor id
- * @param input
- * the editor input
- * @param matchFlags
- * flags specifying which aspects to match
- * @return the matching editor, or an empty array if no match found
- * @since 3.1
- */
- public IEditorReference[] findEditors(IEditorInput input, String editorId,
- int matchFlags) {
- if (matchFlags == IWorkbenchPage.MATCH_NONE) {
- return new IEditorReference[0];
- }
- List result = new ArrayList();
- ArrayList othersList = new ArrayList(Arrays.asList(page
- .getEditorReferences()));
- if (!othersList.isEmpty()) {
- IEditorReference active = page.getActiveEditorReference();
- if (active != null) {
- othersList.remove(active);
- ArrayList activeList = new ArrayList(1);
- activeList.add(active);
- findEditors(activeList, input, editorId, matchFlags, result);
- }
- findEditors(othersList, input, editorId, matchFlags, result);
- }
- return (IEditorReference[]) result.toArray(new IEditorReference[result
- .size()]);
- }
-
- /**
- * Populates a list with open editor(s) matching the given editor id and/or editor input.
- *
- * @param editorId
- * the editor id
- * @param input
- * the editor input
- * @param editorList
- * a mutable list containing the references for the editors to
- * check (warning: items may be removed)
- * @param result
- * the list to which matching editor references should be added
- * @since 3.1
- */
- private void findEditors(List editorList, IEditorInput input,
- String editorId, int matchFlags, List result) {
- if (matchFlags == IWorkbenchPage.MATCH_NONE) {
- return;
- }
-
- // Phase 0: Remove editors whose ids don't match (if matching by id)
- if (((matchFlags & IWorkbenchPage.MATCH_ID) != 0) && editorId != null) {
- for (Iterator i = editorList.iterator(); i.hasNext();) {
- EditorReference editor = (EditorReference) i.next();
- if (!editorId.equals(editor.getId())) {
- i.remove();
- }
- }
- }
-
- // If not matching on editor input, just return the remaining editors.
- // In practice, this case is never used.
- if ((matchFlags & IWorkbenchPage.MATCH_INPUT) == 0) {
- result.addAll(editorList);
- return;
- }
-
- // Phase 1: check editors that have their own matching strategy
- for (Iterator i = editorList.iterator(); i.hasNext();) {
- EditorReference editor = (EditorReference) i.next();
- IEditorDescriptor desc = editor.getDescriptor();
- if (desc != null) {
- IEditorMatchingStrategy matchingStrategy = desc
- .getEditorMatchingStrategy();
- if (matchingStrategy != null) {
- i.remove(); // We're handling this one here, so remove it
- // from the list.
- if (matchingStrategy.matches(editor, input)) {
- result.add(editor);
- }
- }
- }
- }
-
- // Phase 2: check materialized editors (without their own matching
- // strategy)
- for (Iterator i = editorList.iterator(); i.hasNext();) {
- IEditorReference editor = (IEditorReference) i.next();
- IEditorPart part = (IEditorPart) editor.getPart(false);
- if (part != null) {
- i.remove(); // We're handling this one here, so remove it from
- // the list.
- if (part.getEditorInput() != null
- && part.getEditorInput().equals(input)) {
- result.add(editor);
- }
- }
- }
-
- // Phase 3: check unmaterialized editors for input equality,
- // delaying plug-in activation further by only restoring the editor
- // input
- // if the editor reference's factory id and name match.
- String name = input.getName();
- IPersistableElement persistable = input.getPersistable();
- if (name == null || persistable == null) {
- return;
- }
- String id = persistable.getFactoryId();
- if (id == null) {
- return;
- }
- for (Iterator i = editorList.iterator(); i.hasNext();) {
- EditorReference editor = (EditorReference) i.next();
- if (name.equals(editor.getName())
- && id.equals(editor.getFactoryId())) {
- IEditorInput restoredInput;
- try {
- restoredInput = editor.getEditorInput();
- if (Util.equals(restoredInput, input)) {
- result.add(editor);
- }
- } catch (PartInitException e1) {
- WorkbenchPlugin.log(e1);
- }
- }
- }
- }
-
- /**
- * Returns the SWT Display.
- */
- private Display getDisplay() {
- return window.getShell().getDisplay();
- }
-
- /**
- * Answer the number of editors.
- */
- public int getEditorCount() {
- return page.getEditorReferences().length;
- }
-
- /*
- * Answer the editor registry.
- */
- private IEditorRegistry getEditorRegistry() {
- return WorkbenchPlugin.getDefault().getEditorRegistry();
- }
-
- /*
- * See IWorkbenchPage.
- */
- public IEditorPart[] getDirtyEditors() {
- List dirtyEditors = collectDirtyEditors();
- return (IEditorPart[]) dirtyEditors
- .toArray(new IEditorPart[dirtyEditors.size()]);
- }
-
- /*
- * See IWorkbenchPage.
- */
- public IEditorReference[] getEditors() {
- return page.getEditorReferences();
- }
-
- /*
- * See IWorkbenchPage#getFocusEditor
- */
- public IEditorPart getVisibleEditor() {
- IEditorReference ref = editorPresentation.getVisibleEditor();
- if (ref == null) {
- return null;
- }
- return (IEditorPart) ref.getPart(true);
- }
-
- /**
- * Answer true if save is needed in any one of the editors.
- */
- public boolean isSaveAllNeeded() {
- IEditorReference[] editors = page.getEditorReferences();
- for (int i = 0; i < editors.length; i++) {
- IEditorReference ed = editors[i];
- if (ed.isDirty()) {
- return true;
- }
- }
- return false;
- }
-
- /*
- * Prompt the user to save the reusable editor. Return false if a new editor
- * should be opened.
- */
- private IEditorReference findReusableEditor(EditorDescriptor desc) {
- return ((TabBehaviour)Tweaklets.get(TabBehaviour.KEY)).findReusableEditor(page);
- }
-
- /**
- * @param editorId
- * the editor part id
- * @param input
- * the input
- * @param setVisible
- * if this is to be created visible ... not used
- * @param editorState
- * an {@link IMemento} &lt;editorState&gt; for persistable
- * editors. Can be <code>null</code>.
- * @return a created editor reference
- * @throws PartInitException
- */
- public IEditorReference openEditor(String editorId, IEditorInput input,
- boolean setVisible, IMemento editorState) throws PartInitException {
- if (editorId == null || input == null) {
- throw new IllegalArgumentException();
- }
-
- IEditorDescriptor desc = getEditorRegistry().findEditor(editorId);
- if (desc != null && !desc.isOpenExternal() && isLargeDocument(input)) {
- desc = getAlternateEditor();
- if (desc == null) {
- // the user pressed cancel in the editor selection dialog
- return null;
- }
- }
-
- if (desc == null) {
- throw new PartInitException(NLS.bind(
- WorkbenchMessages.EditorManager_unknownEditorIDMessage,
- editorId));
- }
-
- IEditorReference result = openEditorFromDescriptor((EditorDescriptor) desc, input,
- editorState);
-
- return result;
- }
-
- /*
- * Open a new editor
- */
- public IEditorReference openEditorFromDescriptor(EditorDescriptor desc,
- IEditorInput input, IMemento editorState) throws PartInitException {
- IEditorReference result = null;
- if (desc.isInternal()) {
- result = reuseInternalEditor(desc, input);
- if (result == null) {
- result = new EditorReference(this, input, desc, editorState);
- }
- } else if (desc.getId()
- .equals(IEditorRegistry.SYSTEM_INPLACE_EDITOR_ID)) {
- if (ComponentSupport.inPlaceEditorSupported()) {
- result = new EditorReference(this, input, desc);
- }
- } else if (desc.getId().equals(
- IEditorRegistry.SYSTEM_EXTERNAL_EDITOR_ID)) {
- IPathEditorInput pathInput = getPathEditorInput(input);
- if (pathInput != null) {
- result = openSystemExternalEditor(pathInput.getPath());
- } else {
- throw new PartInitException(
- WorkbenchMessages.EditorManager_systemEditorError);
- }
- } else if (desc.isOpenExternal()) {
- result = openExternalEditor(desc, input);
- } else {
- // this should never happen
- throw new PartInitException(NLS.bind(
- WorkbenchMessages.EditorManager_invalidDescriptor, desc
- .getId()));
- }
-
- if (result != null) {
- createEditorTab((EditorReference) result, ""); //$NON-NLS-1$
- }
-
- Workbench wb = (Workbench) window.getWorkbench();
- wb.getEditorHistory().add(input, desc);
- return result;
- }
-
- /**
- * Open a specific external editor on an file based on the descriptor.
- */
- private IEditorReference openExternalEditor(final EditorDescriptor desc,
- IEditorInput input) throws PartInitException {
- final CoreException ex[] = new CoreException[1];
-
- final IPathEditorInput pathInput = getPathEditorInput(input);
- if (pathInput != null && pathInput.getPath() != null) {
- BusyIndicator.showWhile(getDisplay(), new Runnable() {
- public void run() {
- try {
- if (desc.getLauncher() != null) {
- // open using launcher
- Object launcher = WorkbenchPlugin.createExtension(
- desc.getConfigurationElement(), "launcher"); //$NON-NLS-1$
- ((IEditorLauncher) launcher).open(pathInput
- .getPath());
- } else {
- // open using command
- ExternalEditor oEditor = new ExternalEditor(
- pathInput.getPath(), desc);
- oEditor.open();
- }
- } catch (CoreException e) {
- ex[0] = e;
- }
- }
- });
- } else {
- throw new PartInitException(NLS.bind(
- WorkbenchMessages.EditorManager_errorOpeningExternalEditor,
- desc.getFileName(), desc.getId()));
- }
-
- if (ex[0] != null) {
- throw new PartInitException(NLS.bind(
- WorkbenchMessages.EditorManager_errorOpeningExternalEditor,
- desc.getFileName(), desc.getId()), ex[0]);
- }
-
- // we do not have an editor part for external editors
- return null;
- }
-
- /**
- * Create the part and reference for each inner editor.
- *
- * @param ref
- * the AbstractMultiEditor reference
- * @param part
- * the part
- * @param input
- * the AbstractMultiEditor input
- * @return the array of inner references to store in the AbstractMultiEditor reference
- */
- IEditorReference[] openMultiEditor(final IEditorReference ref,
- final AbstractMultiEditor part, final MultiEditorInput input)
- throws PartInitException {
-
- String[] editorArray = input.getEditors();
- IEditorInput[] inputArray = input.getInput();
-
- // find all descriptors
- EditorDescriptor[] descArray = new EditorDescriptor[editorArray.length];
- IEditorReference refArray[] = new IEditorReference[editorArray.length];
- IEditorPart partArray[] = new IEditorPart[editorArray.length];
-
- IEditorRegistry reg = getEditorRegistry();
- for (int i = 0; i < editorArray.length; i++) {
- EditorDescriptor innerDesc = (EditorDescriptor) reg
- .findEditor(editorArray[i]);
- if (innerDesc == null) {
- throw new PartInitException(NLS.bind(
- WorkbenchMessages.EditorManager_unknownEditorIDMessage,
- editorArray[i]));
- }
- descArray[i] = innerDesc;
- InnerEditor innerRef = new InnerEditor(ref, part, inputArray[i],
- descArray[i]);
- refArray[i] = innerRef;
- partArray[i] = innerRef.getEditor(true);
- }
- part.setChildren(partArray);
- return refArray;
- }
-
- /*
- * Opens an editor part.
- */
- private void createEditorTab(final EditorReference ref,
- final String workbookId) throws PartInitException {
-
- editorPresentation.addEditor(ref, workbookId, true);
-
- }
-
- /*
- * Create the site and initialize it with its action bars.
- */
- EditorSite createSite(final IEditorReference ref, final IEditorPart part,
- final EditorDescriptor desc, final IEditorInput input)
- throws PartInitException {
- EditorSite site = new EditorSite(ref, part, page, desc);
- if (desc != null) {
- site.setActionBars(createEditorActionBars(desc, site));
- } else {
- site.setActionBars(createEmptyEditorActionBars(site));
- }
- final String label = part.getTitle(); // debugging only
- try {
- try {
- UIStats.start(UIStats.INIT_PART, label);
- part.init(site, input);
- } finally {
- UIStats.end(UIStats.INIT_PART, part, label);
- }
-
- // Sanity-check the site
- if (part.getSite() != site || part.getEditorSite() != site) {
- throw new PartInitException(NLS.bind(
- WorkbenchMessages.EditorManager_siteIncorrect, desc
- .getId()));
- }
-
- } catch (Exception e) {
- disposeEditorActionBars((EditorActionBars) site.getActionBars());
- site.dispose();
- if (e instanceof PartInitException) {
- throw (PartInitException) e;
- }
-
- throw new PartInitException(
- WorkbenchMessages.EditorManager_errorInInit, e);
- }
-
- return site;
- }
-
- /*
- * See IWorkbenchPage.
- */
- private IEditorReference reuseInternalEditor(EditorDescriptor desc,
- IEditorInput input) throws PartInitException {
-
- Assert.isNotNull(desc, "descriptor must not be null"); //$NON-NLS-1$
- Assert.isNotNull(input, "input must not be null"); //$NON-NLS-1$
-
- IEditorReference reusableEditorRef = findReusableEditor(desc);
- if (reusableEditorRef != null) {
- return ((TabBehaviour) Tweaklets.get(TabBehaviour.KEY))
- .reuseInternalEditor(page, this, editorPresentation, desc,
- input, reusableEditorRef);
- }
- return null;
- }
-
- IEditorPart createPart(final EditorDescriptor desc)
- throws PartInitException {
- try {
- IEditorPart result = desc.createEditor();
- IConfigurationElement element = desc.getConfigurationElement();
- if (element != null) {
- page.getExtensionTracker().registerObject(
- element.getDeclaringExtension(), result,
- IExtensionTracker.REF_WEAK);
- }
- return result;
- } catch (CoreException e) {
- throw new PartInitException(StatusUtil.newStatus(
- desc.getPluginID(),
- WorkbenchMessages.EditorManager_instantiationError, e));
- }
- }
-
- /**
- * Open a system external editor on the input path.
- */
- private IEditorReference openSystemExternalEditor(final IPath location)
- throws PartInitException {
- if (location == null) {
- throw new IllegalArgumentException();
- }
-
- final boolean result[] = { false };
- BusyIndicator.showWhile(getDisplay(), new Runnable() {
- public void run() {
- if (location != null) {
- result[0] = Program.launch(location.toOSString());
- }
- }
- });
-
- if (!result[0]) {
- throw new PartInitException(NLS.bind(
- WorkbenchMessages.EditorManager_unableToOpenExternalEditor,
- location));
- }
-
- // We do not have an editor part for external editors
- return null;
- }
-
- ImageDescriptor findImage(EditorDescriptor desc, IPath path) {
- if (desc == null) {
- // @issue what should be the default image?
- return ImageDescriptor.getMissingImageDescriptor();
- }
-
- if (desc.isOpenExternal() && path != null) {
- return PlatformUI.getWorkbench().getEditorRegistry()
- .getImageDescriptor(path.toOSString());
- }
-
- return desc.getImageDescriptor();
- }
-
- /**
- * @see org.eclipse.ui.IPersistable
- */
- public IStatus restoreState(IMemento memento) {
- // Restore the editor area workbooks layout/relationship
- final MultiStatus result = new MultiStatus(PlatformUI.PLUGIN_ID,
- IStatus.OK,
- WorkbenchMessages.EditorManager_problemsRestoringEditors, null);
- final String activeWorkbookID[] = new String[1];
- final ArrayList visibleEditors = new ArrayList(5);
- final IEditorReference activeEditor[] = new IEditorReference[1];
-
- IMemento areaMem = memento.getChild(IWorkbenchConstants.TAG_AREA);
- if (areaMem != null) {
- result.add(editorPresentation.restoreState(areaMem));
- activeWorkbookID[0] = areaMem
- .getString(IWorkbenchConstants.TAG_ACTIVE_WORKBOOK);
- }
-
- // Loop through the editors.
-
- IMemento[] editorMems = memento
- .getChildren(IWorkbenchConstants.TAG_EDITOR);
- for (int x = 0; x < editorMems.length; x++) {
- // for dynamic UI - call restoreEditorState to replace code which is
- // commented out
- restoreEditorState(editorMems[x], visibleEditors, activeEditor,
- result);
- }
-
- // restore the presentation
- if (areaMem != null) {
- result.add(editorPresentation.restorePresentationState(areaMem));
- }
- try {
- StartupThreading.runWithThrowable(new StartupRunnable(){
-
- public void runWithException() throws Throwable {
- // Update each workbook with its visible editor.
- for (int i = 0; i < visibleEditors.size(); i++) {
- setVisibleEditor((IEditorReference) visibleEditors.get(i),
- false);
- }
-
- // Update the active workbook
- if (activeWorkbookID[0] != null) {
- editorPresentation
- .setActiveEditorWorkbookFromID(activeWorkbookID[0]);
- }
-
- if (activeEditor[0] != null) {
- IWorkbenchPart editor = activeEditor[0].getPart(true);
-
- if (editor != null) {
- page.activate(editor);
- }
- }
- }});
- }
- catch (Throwable t) {
- // The exception is already logged.
- result
- .add(new Status(
- IStatus.ERROR,
- PlatformUI.PLUGIN_ID,
- 0,
- WorkbenchMessages.EditorManager_exceptionRestoringEditor,
- t));
- }
-
- return result;
- }
-
- /**
- * Save all of the editors in the workbench. Return true if successful.
- * Return false if the user has canceled the command.
- * @param confirm true if the user should be prompted before the save
- * @param closing true if the page is being closed
- * @param addNonPartSources true if saveables from non-part sources should be saved too.
- * @return false if the user canceled or an error occurred while saving
- */
- public boolean saveAll(boolean confirm, boolean closing, boolean addNonPartSources) {
- // Get the list of dirty editors and views. If it is
- // empty just return.
- ISaveablePart[] parts = page.getDirtyParts();
- if (parts.length == 0) {
- return true;
- }
- // saveAll below expects a mutable list
- List dirtyParts = new ArrayList(parts.length);
- for (int i = 0; i < parts.length; i++) {
- dirtyParts.add(parts[i]);
- }
-
- // If confirmation is required ..
- return saveAll(dirtyParts, confirm, closing, addNonPartSources, window);
- }
-
- /**
- * Saves the given dirty editors and views, optionally prompting the user.
- *
- * @param dirtyParts
- * the dirty views and editors
- * @param confirm
- * <code>true</code> to prompt whether to save, <code>false</code>
- * to save without prompting
- * @param closing
- * <code>true</code> if the parts are being closed,
- * <code>false</code> if just being saved without closing
- * @param addNonPartSources true if non-part sources should be saved too
- * @param window
- * the window to use as the parent for the dialog that prompts to
- * save multiple dirty editors and views
- * @return <code>true</code> on success, <code>false</code> if the user
- * canceled the save or an error occurred while saving
- */
- public static boolean saveAll(List dirtyParts, boolean confirm, boolean closing,
- boolean addNonPartSources, final IWorkbenchWindow window) {
- return saveAll(dirtyParts, confirm, closing, addNonPartSources, window, window);
- }
-
- /**
- * Saves the given dirty editors and views, optionally prompting the user.
- *
- * @param dirtyParts
- * the dirty views and editors
- * @param confirm
- * <code>true</code> to prompt whether to save,
- * <code>false</code> to save without prompting
- * @param closing
- * <code>true</code> if the parts are being closed,
- * <code>false</code> if just being saved without closing
- * @param addNonPartSources
- * true if non-part sources should be saved too
- * @param runnableContext
- * the context in which to run long-running operations
- * @param shellProvider
- * providing the shell to use as the parent for the dialog that
- * prompts to save multiple dirty editors and views
- * @return <code>true</code> on success, <code>false</code> if the user
- * canceled the save
- */
- public static boolean saveAll(List dirtyParts, final boolean confirm, final boolean closing,
- boolean addNonPartSources, final IRunnableContext runnableContext, final IShellProvider shellProvider) {
- // clone the input list
- dirtyParts = new ArrayList(dirtyParts);
-
- if (closing) {
- // if the parts are going to be closed, then we only save those that
- // need to be saved when closed, see bug 272070
- for (Iterator it = dirtyParts.iterator(); it.hasNext();) {
- ISaveablePart saveablePart = (ISaveablePart) it.next();
- if (!saveablePart.isSaveOnCloseNeeded()) {
- it.remove();
- }
- }
- }
-
- List modelsToSave;
- if (confirm) {
- boolean saveable2Processed = false;
- // Process all parts that implement ISaveablePart2.
- // These parts are removed from the list after saving
- // them. We then need to restore the workbench to
- // its previous state, for now this is just last
- // active perspective.
- // Note that the given parts may come from multiple
- // windows, pages and perspectives.
- ListIterator listIterator = dirtyParts.listIterator();
-
- WorkbenchPage currentPage = null;
- Perspective currentPageOriginalPerspective = null;
- while (listIterator.hasNext()) {
- IWorkbenchPart part = (IWorkbenchPart) listIterator.next();
- if (part instanceof ISaveablePart2) {
- WorkbenchPage page = (WorkbenchPage) part.getSite()
- .getPage();
- if (!Util.equals(currentPage, page)) {
- if (currentPage != null
- && currentPageOriginalPerspective != null) {
- if (!currentPageOriginalPerspective
- .equals(currentPage.getActivePerspective())) {
- currentPage
- .setPerspective(currentPageOriginalPerspective
- .getDesc());
- }
- }
- currentPage = page;
- currentPageOriginalPerspective = page
- .getActivePerspective();
- }
- if (confirm) {
- if (part instanceof IViewPart) {
- Perspective perspective = page
- .getFirstPerspectiveWithView((IViewPart) part);
- if (perspective != null) {
- page.setPerspective(perspective.getDesc());
- }
- }
- // show the window containing the page?
- IWorkbenchWindow partsWindow = page
- .getWorkbenchWindow();
- if (partsWindow != partsWindow.getWorkbench()
- .getActiveWorkbenchWindow()) {
- Shell shell = partsWindow.getShell();
- if (shell.getMinimized()) {
- shell.setMinimized(false);
- }
- shell.setActive();
- }
- page.bringToTop(part);
- }
- // try to save the part
- int choice = SaveableHelper.savePart((ISaveablePart2) part,
- page.getWorkbenchWindow(), confirm);
- if (choice == ISaveablePart2.CANCEL) {
- // If the user cancels, don't restore the previous
- // workbench state, as that will
- // be an unexpected switch from the current state.
- return false;
- } else if (choice != ISaveablePart2.DEFAULT) {
- saveable2Processed = true;
- listIterator.remove();
- }
- }
- }
-
- // try to restore the workbench to its previous state
- if (currentPage != null && currentPageOriginalPerspective != null) {
- if (!currentPageOriginalPerspective.equals(currentPage
- .getActivePerspective())) {
- currentPage.setPerspective(currentPageOriginalPerspective
- .getDesc());
- }
- }
-
- // if processing a ISaveablePart2 caused other parts to be
- // saved, remove them from the list presented to the user.
- if (saveable2Processed) {
- listIterator = dirtyParts.listIterator();
- while (listIterator.hasNext()) {
- ISaveablePart part = (ISaveablePart) listIterator.next();
- if (!part.isDirty()) {
- listIterator.remove();
- }
- }
- }
-
- modelsToSave = convertToSaveables(dirtyParts, closing, addNonPartSources);
-
- // If nothing to save, return.
- if (modelsToSave.isEmpty()) {
- return true;
- }
- boolean canceled = SaveableHelper.waitForBackgroundSaveJobs(modelsToSave);
- if (canceled) {
- return false;
- }
- // Use a simpler dialog if there's only one
- if (modelsToSave.size() == 1) {
- Saveable model = (Saveable) modelsToSave.get(0);
- String message = NLS.bind(WorkbenchMessages.EditorManager_saveChangesQuestion, model.getName());
- // Show a dialog.
- String[] buttons = new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL };
- MessageDialog d = new MessageDialog(shellProvider.getShell(),
- WorkbenchMessages.Save_Resource, null, message,
- MessageDialog.QUESTION, buttons, 0) {
- protected int getShellStyle() {
- return super.getShellStyle() | SWT.SHEET;
- }
- };
-
- int choice = SaveableHelper.testGetAutomatedResponse();
- if (SaveableHelper.testGetAutomatedResponse() == SaveableHelper.USER_RESPONSE) {
- choice = d.open();
- }
-
- // Branch on the user choice.
- // The choice id is based on the order of button labels
- // above.
- switch (choice) {
- case ISaveablePart2.YES: // yes
- break;
- case ISaveablePart2.NO: // no
- return true;
- default:
- case ISaveablePart2.CANCEL: // cancel
- return false;
- }
- }
- else {
- ListSelectionDialog dlg = new ListSelectionDialog(
- shellProvider.getShell(), modelsToSave,
- new ArrayContentProvider(),
- new WorkbenchPartLabelProvider(), RESOURCES_TO_SAVE_MESSAGE) {
- protected int getShellStyle() {
- return super.getShellStyle() | SWT.SHEET;
- }
- };
- dlg.setInitialSelections(modelsToSave.toArray());
- dlg.setTitle(SAVE_RESOURCES_TITLE);
-
- // this "if" statement aids in testing.
- if (SaveableHelper.testGetAutomatedResponse()==SaveableHelper.USER_RESPONSE) {
- int result = dlg.open();
- //Just return false to prevent the operation continuing
- if (result == IDialogConstants.CANCEL_ID) {
- return false;
- }
-
- modelsToSave = Arrays.asList(dlg.getResult());
- }
- }
- }
- else {
- modelsToSave = convertToSaveables(dirtyParts, closing, addNonPartSources);
- }
-
- // If the editor list is empty return.
- if (modelsToSave.isEmpty()) {
- return true;
- }
-
- // Create save block.
- final List finalModels = modelsToSave;
- IRunnableWithProgress progressOp = new IRunnableWithProgress() {
- public void run(IProgressMonitor monitor) {
- IProgressMonitor monitorWrap = new EventLoopProgressMonitor(
- monitor);
- monitorWrap.beginTask(WorkbenchMessages.Saving_Modifications, finalModels.size());
- for (Iterator i = finalModels.iterator(); i.hasNext();) {
- Saveable model = (Saveable) i.next();
- // handle case where this model got saved as a result of saving another
- if (!model.isDirty()) {
- monitor.worked(1);
- continue;
- }
- SaveableHelper.doSaveModel(model, new SubProgressMonitor(monitorWrap, 1), shellProvider, closing || confirm);
- if (monitorWrap.isCanceled()) {
- break;
- }
- }
- monitorWrap.done();
- }
- };
-
- // Do the save.
- return SaveableHelper.runProgressMonitorOperation(
- WorkbenchMessages.Save_All, progressOp, runnableContext, shellProvider);
- }
-
- /**
- * For each part (view or editor) in the given list, attempts to convert it
- * to one or more saveable models. Duplicate models are removed. If closing
- * is true, then models that will remain open in parts other than the given
- * parts are removed.
- *
- * @param parts
- * the parts (list of IViewPart or IEditorPart)
- * @param closing
- * whether the parts are being closed
- * @param addNonPartSources
- * whether non-part sources should be added (true for the Save
- * All action, see bug 139004)
- * @return the dirty models
- */
- private static List convertToSaveables(List parts, boolean closing, boolean addNonPartSources) {
- ArrayList result = new ArrayList();
- HashSet seen = new HashSet();
- for (Iterator i = parts.iterator(); i.hasNext();) {
- IWorkbenchPart part = (IWorkbenchPart) i.next();
- Saveable[] saveables = getSaveables(part);
- for (int j = 0; j < saveables.length; j++) {
- Saveable saveable = saveables[j];
- if (saveable.isDirty() && !seen.contains(saveable)) {
- seen.add(saveable);
- if (!closing
- || closingLastPartShowingModel(saveable, parts, part
- .getSite().getPage())) {
- result.add(saveable);
- }
- }
- }
- }
- if (addNonPartSources) {
- SaveablesList saveablesList = (SaveablesList) PlatformUI
- .getWorkbench().getService(
- ISaveablesLifecycleListener.class);
- ISaveablesSource[] nonPartSources = saveablesList
- .getNonPartSources();
- for (int i = 0; i < nonPartSources.length; i++) {
- Saveable[] saveables = nonPartSources[i].getSaveables();
- for (int j = 0; j < saveables.length; j++) {
- Saveable saveable = saveables[j];
- if (saveable.isDirty() && !seen.contains(saveable)) {
- seen.add(saveable);
- result.add(saveable);
- }
- }
- }
- }
- return result;
- }
-
- /**
- * Returns the saveable models provided by the given part.
- * If the part does not provide any models, a default model
- * is returned representing the part.
- *
- * @param part the workbench part
- * @return the saveable models
- */
- private static Saveable[] getSaveables(IWorkbenchPart part) {
- if (part instanceof ISaveablesSource) {
- ISaveablesSource source = (ISaveablesSource) part;
- return source.getSaveables();
- }
- return new Saveable[] { new DefaultSaveable(part) };
- }
-
- /**
- * Returns true if, in the given page, no more parts will reference the
- * given model if the given parts are closed.
- *
- * @param model
- * the model
- * @param closingParts
- * the parts being closed (list of IViewPart or IEditorPart)
- * @param page
- * the page
- * @return <code>true</code> if no more parts in the page will reference
- * the given model, <code>false</code> otherwise
- */
- private static boolean closingLastPartShowingModel(Saveable model,
- List closingParts, IWorkbenchPage page) {
- HashSet closingPartsWithSameModel = new HashSet();
- for (Iterator i = closingParts.iterator(); i.hasNext();) {
- IWorkbenchPart part = (IWorkbenchPart) i.next();
- Saveable[] models = getSaveables(part);
- if (Arrays.asList(models).contains(model)) {
- closingPartsWithSameModel.add(part);
- }
- }
- IWorkbenchPartReference[] pagePartRefs = ((WorkbenchPage) page).getAllParts();
- HashSet pagePartsWithSameModels = new HashSet();
- for (int i = 0; i < pagePartRefs.length; i++) {
- IWorkbenchPartReference partRef = pagePartRefs[i];
- IWorkbenchPart part = partRef.getPart(false);
- if (part != null) {
- Saveable[] models = getSaveables(part);
- if (Arrays.asList(models).contains(model)) {
- pagePartsWithSameModels.add(part);
- }
- }
- }
- for (Iterator i = closingPartsWithSameModel.iterator(); i.hasNext();) {
- IWorkbenchPart part = (IWorkbenchPart) i.next();
- pagePartsWithSameModels.remove(part);
- }
- return pagePartsWithSameModels.isEmpty();
- }
-
- /*
- * Saves the workbench part.
- */
- public boolean savePart(final ISaveablePart saveable, IWorkbenchPart part,
- boolean confirm) {
- return SaveableHelper.savePart(saveable, part, window, confirm);
- }
-
- /**
- * @see IPersistablePart
- */
- public IStatus saveState(final IMemento memento) {
-
- final MultiStatus result = new MultiStatus(PlatformUI.PLUGIN_ID,
- IStatus.OK,
- WorkbenchMessages.EditorManager_problemsSavingEditors, null);
-
- // Save the editor area workbooks layout/relationship
- IMemento editorAreaMem = memento
- .createChild(IWorkbenchConstants.TAG_AREA);
- result.add(editorPresentation.saveState(editorAreaMem));
-
- // Save the active workbook id
- editorAreaMem.putString(IWorkbenchConstants.TAG_ACTIVE_WORKBOOK,
- editorPresentation.getActiveEditorWorkbookID());
-
- // Get each workbook
- ArrayList workbooks = editorPresentation.getWorkbooks();
-
- for (Iterator iter = workbooks.iterator(); iter.hasNext();) {
- EditorStack workbook = (EditorStack) iter.next();
-
- // Use the list of editors found in EditorStack; fix for 24091
- EditorPane editorPanes[] = workbook.getEditors();
-
- for (int i = 0; i < editorPanes.length; i++) {
- // Save each open editor.
- IEditorReference editorReference = editorPanes[i]
- .getEditorReference();
- EditorReference e = (EditorReference) editorReference;
- final IEditorPart editor = editorReference.getEditor(false);
- if (editor == null) {
- if (e.getMemento() != null) {
- IMemento editorMem = memento
- .createChild(IWorkbenchConstants.TAG_EDITOR);
- editorMem.putMemento(e.getMemento());
- }
- continue;
- }
-
- // for dynamic UI - add the next line to replace the subsequent
- // code which is commented out
- saveEditorState(memento, e, result);
- }
- }
- return result;
- }
-
- /**
- * Shows an editor. If <code>setFocus == true</code> then give it focus,
- * too.
- *
- * @return true if the active editor was changed, false if not.
- */
- public boolean setVisibleEditor(IEditorReference newEd, boolean setFocus) {
- return editorPresentation.setVisibleEditor(newEd, setFocus);
- }
-
- private IPathEditorInput getPathEditorInput(IEditorInput input) {
- if (input instanceof IPathEditorInput) {
- return (IPathEditorInput) input;
- }
-
- return (IPathEditorInput) Util.getAdapter(input, IPathEditorInput.class);
- }
-
- /**
- * An editor reference that is actually contained within another editor
- * reference.
- */
- class InnerEditor extends EditorReference {
-
- private IEditorReference outerEditor;
-
- private AbstractMultiEditor outerEditorPart;
-
- public InnerEditor(IEditorReference outerEditor,
- AbstractMultiEditor outerEditorPart, IEditorInput input,
- EditorDescriptor desc) {
- super(EditorManager.this, input, desc);
- this.outerEditor = outerEditor;
- this.outerEditorPart = outerEditorPart;
- }
-
- /**
- * @return Returns the parent editor reference that this reference is a
- * child of.
- */
- public IEditorReference getOuterEditor() {
- return outerEditor;
- }
-
- protected void doDisposePart() {
- this.outerEditorPart = null;
- super.doDisposePart();
- }
-
- protected PartPane createPane() {
- // MultiEditor backwards compatibility
- return new MultiEditorInnerPane(
- (EditorPane) ((EditorReference) outerEditor).getPane(),
- this, page, editorPresentation.getActiveWorkbook(),
- outerEditorPart instanceof MultiEditor);
- }
-
- protected Composite getPaneControlContainer() {
- // MultiEditor backwards compatibility
- if (outerEditorPart instanceof MultiEditor) {
- return super.getPaneControlContainer();
- }
- return outerEditorPart.getInnerEditorContainer(this);
- }
-
- }
-
- /*
- * Made public for Mylar in 3.3 - see bug 138666. Can be made private once
- * we have real API for this.
- */
- public void restoreEditorState(IMemento editorMem,
- ArrayList visibleEditors, IEditorReference[] activeEditor,
- MultiStatus result) {
- // String strFocus = editorMem.getString(IWorkbenchConstants.TAG_FOCUS);
- // boolean visibleEditor = "true".equals(strFocus); //$NON-NLS-1$
- final EditorReference e = new EditorReference(this, editorMem);
-
- // if the editor is not visible, ensure it is put in the correct
- // workbook. PR 24091
-
- final String workbookID = editorMem
- .getString(IWorkbenchConstants.TAG_WORKBOOK);
-
- try {
- StartupThreading.runWithPartInitExceptions(new StartupRunnable () {
-
- public void runWithException() throws Throwable {
- createEditorTab(e, workbookID);
- }});
-
- } catch (PartInitException ex) {
- result.add(ex.getStatus());
- }
-
- String strActivePart = editorMem
- .getString(IWorkbenchConstants.TAG_ACTIVE_PART);
- if ("true".equals(strActivePart)) { //$NON-NLS-1$
- activeEditor[0] = e;
- }
-
- String strFocus = editorMem.getString(IWorkbenchConstants.TAG_FOCUS);
- boolean visibleEditor = "true".equals(strFocus); //$NON-NLS-1$
- if (visibleEditor) {
- visibleEditors.add(e);
- }
- }
-
- // for dynamic UI
- protected void saveEditorState(IMemento mem, IEditorReference ed,
- MultiStatus res) {
- final EditorReference editorRef = (EditorReference) ed;
- final IEditorPart editor = ed.getEditor(false);
- final IMemento memento = mem;
- final MultiStatus result = res;
- if (!(editor.getEditorSite() instanceof EditorSite)) {
- return;
- }
- final EditorSite site = (EditorSite) editor.getEditorSite();
- if (site.getPane() instanceof MultiEditorInnerPane) {
- return;
- }
-
- SafeRunner.run(new SafeRunnable() {
- public void run() {
- // Get the input.
- IEditorInput input = editor.getEditorInput();
- if (!input.exists()) {
- return;
- }
- IPersistableElement persistable = input.getPersistable();
- if (persistable == null) {
- return;
- }
-
- // Save editor.
- IMemento editorMem = memento
- .createChild(IWorkbenchConstants.TAG_EDITOR);
- editorMem.putString(IWorkbenchConstants.TAG_TITLE, editorRef
- .getTitle());
- editorMem.putString(IWorkbenchConstants.TAG_NAME, editorRef
- .getName());
- editorMem.putString(IWorkbenchConstants.TAG_ID, editorRef
- .getId());
- editorMem.putString(IWorkbenchConstants.TAG_TOOLTIP, editorRef
- .getTitleToolTip());
-
- editorMem.putString(IWorkbenchConstants.TAG_PART_NAME,
- editorRef.getPartName());
-
- if (editor instanceof IWorkbenchPart3) {
- Map properties = ((IWorkbenchPart3) editor)
- .getPartProperties();
- if (!properties.isEmpty()) {
- IMemento propBag = editorMem
- .createChild(IWorkbenchConstants.TAG_PROPERTIES);
- Iterator i = properties.entrySet().iterator();
- while (i.hasNext()) {
- Map.Entry entry = (Map.Entry) i.next();
- IMemento p = propBag.createChild(
- IWorkbenchConstants.TAG_PROPERTY,
- (String) entry.getKey());
- p.putTextData((String) entry.getValue());
- }
- }
- }
-
- if (editorRef.isPinned()) {
- editorMem.putString(IWorkbenchConstants.TAG_PINNED, "true"); //$NON-NLS-1$
- }
-
- EditorPane editorPane = (EditorPane) ((EditorSite) editor
- .getEditorSite()).getPane();
- editorMem.putString(IWorkbenchConstants.TAG_WORKBOOK,
- editorPane.getWorkbook().getID());
-
- if (editor == page.getActiveEditor()) {
- editorMem.putString(IWorkbenchConstants.TAG_ACTIVE_PART,
- "true"); //$NON-NLS-1$
- }
-
- if (editorPane == editorPane.getWorkbook().getSelection()) {
- editorMem.putString(IWorkbenchConstants.TAG_FOCUS, "true"); //$NON-NLS-1$
- }
-
- if (input instanceof IPathEditorInput) {
- IPath path = ((IPathEditorInput) input).getPath();
- if (path != null) {
- editorMem.putString(IWorkbenchConstants.TAG_PATH, path
- .toString());
- }
- }
-
- // Save input.
- IMemento inputMem = editorMem
- .createChild(IWorkbenchConstants.TAG_INPUT);
- inputMem.putString(IWorkbenchConstants.TAG_FACTORY_ID,
- persistable.getFactoryId());
- persistable.saveState(inputMem);
-
- // any editors that want to persist state
- if (editor instanceof IPersistableEditor) {
- IMemento editorState = editorMem
- .createChild(IWorkbenchConstants.TAG_EDITOR_STATE);
- ((IPersistableEditor) editor).saveState(editorState);
- }
- }
-
- public void handleException(Throwable e) {
- result
- .add(new Status(
- IStatus.ERROR,
- PlatformUI.PLUGIN_ID,
- 0,
- NLS
- .bind(
- WorkbenchMessages.EditorManager_unableToSaveEditor,
- editorRef.getTitle()), e));
- }
- });
- }
-
- // for dynamic UI
- public IMemento getMemento(IEditorReference e) {
- if (e instanceof EditorReference) {
- return ((EditorReference) e).getMemento();
- }
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.core.runtime.dynamicHelpers.IExtensionChangeHandler#removeExtension(org.eclipse.core.runtime.IExtension,
- * java.lang.Object[])
- */
- public void removeExtension(IExtension source, Object[] objects) {
- for (int i = 0; i < objects.length; i++) {
- if (objects[i] instanceof IEditorPart) {
- // close the editor and clean up the editor history
-
- IEditorPart editor = (IEditorPart) objects[i];
- IEditorInput input = editor.getEditorInput();
- page.closeEditor(editor, true);
- ((Workbench) window.getWorkbench()).getEditorHistory().remove(
- input);
- }
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.core.runtime.dynamicHelpers.IExtensionChangeHandler#addExtension(org.eclipse.core.runtime.dynamicHelpers.IExtensionTracker,
- * org.eclipse.core.runtime.IExtension)
- */
- public void addExtension(IExtensionTracker tracker, IExtension extension) {
- // Nothing to do
- }
-
- /**
- * @return
- */
- /*package*/ IEditorReference openEmptyTab() {
- IEditorInput input = new NullEditorInput();
- EditorDescriptor desc = (EditorDescriptor) ((EditorRegistry) getEditorRegistry())
- .findEditor(EditorRegistry.EMPTY_EDITOR_ID);
- EditorReference result = new EditorReference(this, input, desc);
- try {
- createEditorTab(result, ""); //$NON-NLS-1$
- return result;
- } catch (PartInitException e) {
- StatusManager.getManager().handle(
- StatusUtil.newStatus(WorkbenchPlugin.PI_WORKBENCH, e));
- }
- return null;
- }
-
- public static boolean useIPersistableEditor() {
- IPreferenceStore store = WorkbenchPlugin.getDefault()
- .getPreferenceStore();
- return store.getBoolean(IPreferenceConstants.USE_IPERSISTABLE_EDITORS);
- }
-
- private static IEditorDescriptor getAlternateEditor() {
- Shell shell = ProgressManagerUtil.getDefaultParent();
- EditorSelectionDialog dialog = new EditorSelectionDialog(shell) {
- protected IDialogSettings getDialogSettings() {
- IDialogSettings result = new DialogSettings("EditorSelectionDialog"); //$NON-NLS-1$
- result.put(EditorSelectionDialog.STORE_ID_INTERNAL_EXTERNAL, true);
- return result;
- }
- };
- dialog.setMessage(WorkbenchMessages.EditorManager_largeDocumentWarning);
-
- if (dialog.open() == Window.OK)
- return dialog.getSelectedEditor();
- return null;
- }
-
- boolean isLargeDocument(IEditorInput editorInput) {
-
- if (!checkDocumentSize)
- return false;
-
- if (!(editorInput instanceof IPathEditorInput))
- return false; // we know nothing about it
-
- try {
- IPath path = ((IPathEditorInput) editorInput).getPath();
- File file = new File(path.toOSString());
- return file.length() > maxFileSize;
- } catch (Exception e) {
- // ignore exceptions
- return false;
- }
- }
-}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/EditorPane.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/EditorPane.java
deleted file mode 100644
index 5535ea9a687..00000000000
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/EditorPane.java
+++ /dev/null
@@ -1,219 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 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.core.runtime.Assert;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Menu;
-import org.eclipse.swt.widgets.MenuItem;
-import org.eclipse.ui.IEditorReference;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.internal.tweaklets.TabBehaviour;
-import org.eclipse.ui.internal.tweaklets.Tweaklets;
-import org.eclipse.ui.presentations.StackPresentation;
-
-/**
- * An EditorPane is a subclass of PartPane offering extended
- * behavior for workbench editors.
- */
-public class EditorPane extends PartPane {
- private EditorStack workbook;
-
-
- /**
- * Constructs an editor pane for an editor part.
- * @param ref
- * @param page
- * @param workbook
- */
- public EditorPane(IEditorReference ref, WorkbenchPage page,
- EditorStack workbook) {
- super(ref, page);
- this.workbook = workbook;
- }
-
- /**
- * Editor panes do not need a title bar. The editor
- * title and close icon are part of the tab containing
- * the editor. Tools and menus are added directly into
- * the workbench toolbar and menu bar.
- */
- protected void createTitleBar() {
- // do nothing
- }
-
- /**
- * @see PartPane#doHide()
- */
- public void doHide() {
- getPage().closeEditor(getEditorReference(), true);
- }
-
- /**
- * Answer the editor part child.
- * @return {@link IEditorReference}
- */
- public IEditorReference getEditorReference() {
- return (IEditorReference) getPartReference();
- }
-
- /**
- * Answer the SWT widget style.
- */
- int getStyle() {
- return SWT.NONE;
- }
-
- /**
- * Answer the editor workbook container
- * @return {@link EditorStack}
- */
- public EditorStack getWorkbook() {
- return workbook;
- }
-
- /**
- * Notify the workbook page that the part pane has
- * been activated by the user.
- */
- public void requestActivation() {
- // By clearing the active workbook if its not the one
- // associated with the editor, we reduce draw flicker
- if (!workbook.isActiveWorkbook()) {
- workbook.getEditorArea().setActiveWorkbook(null, false);
- }
-
- super.requestActivation();
- }
-
- /**
- * Set the editor workbook container
- * @param editorWorkbook
- */
- public void setWorkbook(EditorStack editorWorkbook) {
- workbook = editorWorkbook;
- }
-
- /* (non-Javadoc)
- * Method declared on PartPane.
- */
- /* package */void shellActivated() {
- //this.workbook.drawGradient();
- }
-
- /* (non-Javadoc)
- * Method declared on PartPane.
- */
- /* package */void shellDeactivated() {
- //this.workbook.drawGradient();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.internal.LayoutPart#setFocus()
- */
- public void setFocus() {
- super.setFocus();
-
- workbook.becomeActiveWorkbook(true);
- }
-
- /**
- * Indicate focus in part.
- */
- public void showFocus(boolean inFocus) {
- if (inFocus) {
- this.workbook.becomeActiveWorkbook(true);
- } else {
- this.workbook
- .setActive(this.workbook.isActiveWorkbook() ? StackPresentation.AS_ACTIVE_NOFOCUS
- : StackPresentation.AS_INACTIVE);
- }
- }
-
- /**
- * Add the pin menu item on the editor system menu.
- * @param parent
- */
- protected void addPinEditorItem(Menu parent) {
- IPreferenceStore store = WorkbenchPlugin.getDefault().getPreferenceStore();
- boolean reuseEditor = store
- .getBoolean(IPreferenceConstants.REUSE_EDITORS_BOOLEAN)
- || ((TabBehaviour)Tweaklets.get(TabBehaviour.KEY)).alwaysShowPinAction();
- if (!reuseEditor) {
- return;
- }
-
- final WorkbenchPartReference ref = (WorkbenchPartReference)getPartReference();
-
- final MenuItem item = new MenuItem(parent, SWT.CHECK);
- item.setText(WorkbenchMessages.EditorPane_pinEditor);
- item.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- IWorkbenchPart part = getPartReference().getPart(true);
- if (part == null) {
- // this should never happen
- item.setSelection(false);
- item.setEnabled(false);
- } else {
- ref.setPinned(item.getSelection());
- }
- }
- });
- item.setEnabled(true);
- item.setSelection(ref.isPinned());
- }
-
- /**
- * Update the title attributes for the pane.
- */
- public void updateTitles() {
- // TODO commented during presentation refactor workbook.updateEditorTab(getEditorReference());
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.internal.LayoutPart#testInvariants()
- */
- public void testInvariants() {
- super.testInvariants();
-
- if (getContainer() != null) {
- Assert.isTrue(getContainer() == workbook);
- }
- }
-
-
- /**
- * Get the name of editor.
- * @return String
- */
- public String getName() {
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.internal.PartPane#getToolBar()
- */
- public Control getToolBar() {
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.internal.PartPane#isCloseable()
- */
- public boolean isCloseable() {
- return true;
- }
-
-}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/EditorSashContainer.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/EditorSashContainer.java
deleted file mode 100644
index cfdf0dbd428..00000000000
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/EditorSashContainer.java
+++ /dev/null
@@ -1,638 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2009 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.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.MultiStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.dnd.DND;
-import org.eclipse.swt.dnd.DropTarget;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.ui.IMemento;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.internal.StartupThreading.StartupRunnable;
-import org.eclipse.ui.internal.presentations.PresentationSerializer;
-import org.eclipse.ui.presentations.IStackPresentationSite;
-import org.eclipse.ui.presentations.StackPresentation;
-
-/**
- * Represents the area set aside for editor workbooks.
- * This container only accepts EditorStack and PartSash
- * as layout parts.
- *
- * Note no views are allowed within this container.
- */
-public class EditorSashContainer extends PartSashContainer {
-
- static final String DEFAULT_WORKBOOK_ID = "DefaultEditorWorkbook";//$NON-NLS-1$
-
- private ArrayList editorWorkbooks = new ArrayList(3);
-
- private EditorStack activeEditorWorkbook;
-
- private DropTarget dropTarget;
-
- public EditorSashContainer(String editorId, WorkbenchPage page, Composite parent) {
- super(editorId, page, parent);
-
- createDefaultWorkbook();
- }
-
-
- /**
- * Add an editor to the active workbook.
- */
- public void addEditor(EditorPane pane, EditorStack stack) {
- //EditorStack workbook = getActiveWorkbook();
- stack.add(pane);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.internal.PartSashContainer#addChild(org.eclipse.ui.internal.PartSashContainer.RelationshipInfo)
- */
- protected void addChild(RelationshipInfo info) {
- super.addChild(info);
-
- updateStackButtons();
- }
-
- /**
- * Hides the min/max buttons for all editor stacks
- * -except- for the upper/left one.
- */
- public void updateStackButtons() {
- // This is applicable only when the new
- // min/max behaviour is being used
- Perspective persp = getPage().getActivePerspective();
- if (!Perspective.useNewMinMax(persp))
- return;
-
- // Find the upper Right editor stack
- LayoutPart[] stacks = getChildren();
- EditorStack winner = getUpperRightEditorStack(stacks);
-
- // Now hide the buttons for all but the upper right stack
- for (int i = 0; i < stacks.length; i++) {
- if (!(stacks[i] instanceof EditorStack))
- continue;
- ((EditorStack)stacks[i]).showMinMax(stacks[i] == winner);
- }
-
- // Force the stack's presentation state to match its perspective
- persp.refreshEditorAreaVisibility();
- }
-
- /**
- * @param stacks
- * @return the EditorStack in the upper right position
- */
- public EditorStack getUpperRightEditorStack(LayoutPart[] stacks) {
- if (stacks == null)
- stacks = getChildren();
-
- // Find the upper Right editor stack
- EditorStack winner = null;
- Rectangle winnerRect = null;
-
- for (int i = 0; i < stacks.length; i++) {
- if (!(stacks[i] instanceof EditorStack))
- continue;
-
- EditorStack stack = (EditorStack) stacks[i];
- Rectangle bb = stack.getBounds();
- if (winnerRect == null ||
- bb.y < winnerRect.y ||
- (bb.y == winnerRect.y && bb.x > winnerRect.x)) {
- winner = stack;
- winnerRect = bb;
- }
- }
-
- return winner;
- }
-
- /**
- * Notification that a child layout part has been
- * added to the container. Subclasses may override
- * this method to perform any container specific
- * work.
- */
- protected void childAdded(LayoutPart child) {
- super.childAdded(child);
-
- if (child instanceof EditorStack) {
- editorWorkbooks.add(child);
- }
- }
-
- /**
- * Notification that a child layout part has been
- * removed from the container. Subclasses may override
- * this method to perform any container specific
- * work.
- */
- protected void childRemoved(LayoutPart child) {
- super.childRemoved(child);
-
- if (child instanceof EditorStack) {
- editorWorkbooks.remove(child);
- if (activeEditorWorkbook == child) {
- setActiveWorkbook(null, false);
- }
-
- updateStackButtons();
- }
- }
-
- protected EditorStack createDefaultWorkbook() {
- EditorStack newWorkbook = EditorStack.newEditorWorkbook(this, page);
- newWorkbook.setID(DEFAULT_WORKBOOK_ID);
- add(newWorkbook);
- return newWorkbook;
- }
-
- /**
- * Subclasses override this method to specify
- * the composite to use to parent all children
- * layout parts it contains.
- */
- protected Composite createParent(Composite parentWidget) {
- return new Composite(parentWidget, SWT.NONE);
- }
-
- /**
- * Dispose of the editor area.
- */
- public void dispose() {
- // Free editor workbooks.
- editorWorkbooks.clear();
-
- // Free rest.
- super.dispose();
- }
-
- /**
- * Subclasses override this method to dispose
- * of any swt resources created during createParent.
- */
- protected void disposeParent() {
- this.parent.dispose();
- }
-
- /**
- * Return the editor workbook which is active.
- */
- public EditorStack getActiveWorkbook() {
- if (activeEditorWorkbook == null) {
- if (editorWorkbooks.size() < 1) {
- setActiveWorkbook(createDefaultWorkbook(), false);
- } else {
- setActiveWorkbook((EditorStack) editorWorkbooks.get(0), false);
- }
- }
-
- return activeEditorWorkbook;
- }
-
- /**
- * Return the editor workbook id which is active.
- */
- public String getActiveWorkbookID() {
- return getActiveWorkbook().getID();
- }
-
- /**
- * Return the all the editor workbooks.
- */
- public ArrayList getEditorWorkbooks() {
- return (ArrayList) editorWorkbooks.clone();
- }
-
- /**
- * Return the all the editor workbooks.
- */
- public int getEditorWorkbookCount() {
- return editorWorkbooks.size();
- }
-
- /**
- * Return true is the workbook specified
- * is the active one.
- */
- protected boolean isActiveWorkbook(EditorStack workbook) {
- return activeEditorWorkbook == workbook;
- }
-
- /**
- * Find the sashs around the specified part.
- */
- public void findSashes(LayoutPart pane, PartPane.Sashes sashes) {
- //Find the sashes around the current editor and
- //then the sashes around the editor area.
- super.findSashes(pane, sashes);
-
- ILayoutContainer container = getContainer();
- if (container != null) {
- container.findSashes(this, sashes);
- }
- }
-
- /**
- * Remove all the editors
- */
- public void removeAllEditors() {
- EditorStack currentWorkbook = getActiveWorkbook();
-
- // Iterate over a copy so the original can be modified.
- Iterator workbooks = ((ArrayList) editorWorkbooks.clone()).iterator();
- while (workbooks.hasNext()) {
- EditorStack workbook = (EditorStack) workbooks.next();
- workbook.removeAll();
- if (workbook != currentWorkbook) {
- remove(workbook);
- workbook.dispose();
- }
- }
- }
-
- /**
- * Remove an editor from its' workbook.
- */
- public void removeEditor(EditorPane pane) {
- EditorStack workbook = pane.getWorkbook();
- if (workbook == null) {
- return;
- }
- workbook.remove(pane);
-
- // remove the editor workbook if empty
- if (workbook.getItemCount() < 1 /* && editorWorkbooks.size() > 1*/) {
- // If the user closes the last editor and the editor area
- // is maximized, restore it
- Perspective persp = getPage().getActivePerspective();
- if (Perspective.useNewMinMax(persp)) {
- if (persp.getPresentation().getMaximizedStack() instanceof EditorStack)
- persp.getPresentation().getMaximizedStack().
- setState(IStackPresentationSite.STATE_RESTORED);
- }
-
- remove(workbook);
- workbook.dispose();
- }
- }
-
- /**
- * @see IPersistablePart
- */
- public IStatus restoreState(IMemento memento) {
- MultiStatus result = new MultiStatus(
- PlatformUI.PLUGIN_ID,
- IStatus.OK,
- WorkbenchMessages.RootLayoutContainer_problemsRestoringPerspective, null);
-
- // Remove the default editor workbook that is
- // initialy created with the editor area.
- if (children != null) {
- StartupThreading.runWithoutExceptions(new StartupRunnable() {
-
- public void runWithException() throws Throwable {
- EditorStack defaultWorkbook = null;
- for (int i = 0; i < children.size(); i++) {
- LayoutPart child = (LayoutPart) children.get(i);
- if (child.getID() == DEFAULT_WORKBOOK_ID) {
- defaultWorkbook = (EditorStack) child;
- if (defaultWorkbook.getItemCount() > 0) {
- defaultWorkbook = null;
- }
- }
- }
- if (defaultWorkbook != null) {
- remove(defaultWorkbook);
- defaultWorkbook.dispose();
- }
- }});
-
- }
-
- // Restore the relationship/layout
- IMemento[] infos = memento.getChildren(IWorkbenchConstants.TAG_INFO);
- final Map mapIDtoPart = new HashMap(infos.length);
-
- for (int i = 0; i < infos.length; i++) {
- // Get the info details.
- IMemento childMem = infos[i];
- final String partID = childMem.getString(IWorkbenchConstants.TAG_PART);
- final String relativeID = childMem
- .getString(IWorkbenchConstants.TAG_RELATIVE);
- int relationship = 0;
- int left = 0, right = 0;
- float ratio = 0.5f;
- if (relativeID != null) {
- relationship = childMem.getInteger(
- IWorkbenchConstants.TAG_RELATIONSHIP).intValue();
- Float ratioFloat = childMem
- .getFloat(IWorkbenchConstants.TAG_RATIO);
- Integer leftInt = childMem
- .getInteger(IWorkbenchConstants.TAG_RATIO_LEFT);
- Integer rightInt = childMem
- .getInteger(IWorkbenchConstants.TAG_RATIO_RIGHT);
- if (leftInt != null && rightInt != null) {
- left = leftInt.intValue();
- right = rightInt.intValue();
- } else if (ratioFloat != null) {
- ratio = ratioFloat.floatValue();
- }
- }
-
- final EditorStack workbook [] = new EditorStack[1];
- StartupThreading.runWithoutExceptions(new StartupRunnable() {
-
- public void runWithException() throws Throwable {
- // Create the part.
- workbook[0] = EditorStack.newEditorWorkbook(EditorSashContainer.this, page);
- workbook[0].setID(partID);
- // 1FUN70C: ITPUI:WIN - Shouldn't set Container when not active
- workbook[0].setContainer(EditorSashContainer.this);
- }});
-
-
- IMemento workbookMemento = childMem
- .getChild(IWorkbenchConstants.TAG_FOLDER);
- if (workbookMemento != null) {
- result.add(workbook[0].restoreState(workbookMemento));
- }
-
- final int myLeft = left, myRight = right, myRelationship = relationship;
- final float myRatio = ratio;
- StartupThreading.runWithoutExceptions(new StartupRunnable() {
-
- public void runWithException() throws Throwable {
- // Add the part to the layout
- if (relativeID == null) {
- add(workbook[0]);
- } else {
- LayoutPart refPart = (LayoutPart) mapIDtoPart.get(relativeID);
- if (refPart != null) {
- //$TODO pass in left and right
- if (myLeft == 0 || myRight == 0) {
- add(workbook[0], myRelationship, myRatio, refPart);
- } else {
- add(workbook[0], myRelationship, myLeft, myRight, refPart);
- }
- } else {
- WorkbenchPlugin
- .log("Unable to find part for ID: " + relativeID);//$NON-NLS-1$
- }
- }
- }});
-
- mapIDtoPart.put(partID, workbook[0]);
- }
-
- return result;
- }
-
- /**
- * @see IPersistablePart
- */
- public IStatus saveState(IMemento memento) {
- RelationshipInfo[] relationships = computeRelation();
- MultiStatus result = new MultiStatus(
- PlatformUI.PLUGIN_ID,
- IStatus.OK,
- WorkbenchMessages.RootLayoutContainer_problemsSavingPerspective, null);
-
- for (int i = 0; i < relationships.length; i++) {
- // Save the relationship info ..
- // private LayoutPart part;
- // private int relationship;
- // private float ratio;
- // private LayoutPart relative;
- RelationshipInfo info = relationships[i];
- IMemento childMem = memento
- .createChild(IWorkbenchConstants.TAG_INFO);
- childMem.putString(IWorkbenchConstants.TAG_PART, info.part.getID());
-
- EditorStack stack = (EditorStack) info.part;
- if (stack != null) {
- IMemento folderMem = childMem
- .createChild(IWorkbenchConstants.TAG_FOLDER);
- result.add(stack.saveState(folderMem));
- }
-
- if (info.relative != null) {
- childMem.putString(IWorkbenchConstants.TAG_RELATIVE,
- info.relative.getID());
- childMem.putInteger(IWorkbenchConstants.TAG_RELATIONSHIP,
- info.relationship);
- childMem.putInteger(IWorkbenchConstants.TAG_RATIO_LEFT,
- info.left);
- childMem.putInteger(IWorkbenchConstants.TAG_RATIO_RIGHT,
- info.right);
- // Note: "ratio" is not used in newer versions of Eclipse, which use "left"
- // and "right" (above) instead
- childMem.putFloat(IWorkbenchConstants.TAG_RATIO, info
- .getRatio());
- }
- }
-
- return result;
- }
-
- /**
- * Set the editor workbook which is active.
- */
- public void setActiveWorkbook(EditorStack newWorkbook, boolean hasFocus) {
- if (newWorkbook != null) {
- if (newWorkbook.isDisposed()) {
- return;
- }
- if (!editorWorkbooks.contains(newWorkbook)) {
- return;
- }
- }
- EditorStack oldWorkbook = activeEditorWorkbook;
- activeEditorWorkbook = newWorkbook;
-
- if (oldWorkbook != null && oldWorkbook != newWorkbook) {
- oldWorkbook.setActive(StackPresentation.AS_INACTIVE);
- }
-
- if (newWorkbook != null) {
- if (hasFocus) {
- newWorkbook.setActive(StackPresentation.AS_ACTIVE_FOCUS);
- } else {
- newWorkbook.setActive(StackPresentation.AS_ACTIVE_NOFOCUS);
- }
- }
-
- updateTabList();
- }
-
- /**
- * Set the editor workbook which is active.
- */
- public void setActiveWorkbookFromID(String id) {
- for (int i = 0; i < editorWorkbooks.size(); i++) {
- EditorStack workbook = (EditorStack) editorWorkbooks.get(i);
- if (workbook.getID().equals(id)) {
- setActiveWorkbook(workbook, false);
- }
- }
- }
-
- public EditorStack getWorkbookFromID(String id) {
- for (int i = 0; i < editorWorkbooks.size(); i++) {
- EditorStack workbook = (EditorStack) editorWorkbooks.get(i);
- if (workbook.getID().equals(id)) {
- return workbook;
- }
- }
-
- return null;
- }
-
- /**
- * Updates the editor area's tab list to include the active
- * editor and its tab.
- */
- public void updateTabList() {
- Composite parent = getParent();
- if (parent != null) { // parent may be null on startup
- EditorStack wb = getActiveWorkbook();
- if (wb == null) {
- parent.setTabList(new Control[0]);
- } else {
- parent.setTabList(wb.getTabList());
- }
- }
- }
-
- /**
- * @see org.eclipse.ui.internal.LayoutPart#createControl(org.eclipse.swt.widgets.Composite)
- */
- public void createControl(Composite parent) {
- super.createControl(parent);
-
- //let the user drop files/editor input on the editor area
- addDropSupport();
- }
-
- private void addDropSupport() {
- if (dropTarget == null) {
- WorkbenchWindowConfigurer winConfigurer = ((WorkbenchWindow) page
- .getWorkbenchWindow()).getWindowConfigurer();
-
- dropTarget = new DropTarget(getControl(), DND.DROP_DEFAULT
- | DND.DROP_COPY | DND.DROP_LINK);
- dropTarget.setTransfer(winConfigurer.getTransfers());
- if (winConfigurer.getDropTargetListener() != null) {
- dropTarget.addDropListener(winConfigurer
- .getDropTargetListener());
- }
- }
- }
-
- /* package */DropTarget getDropTarget() {
- return dropTarget;
- }
-
- /**
- * @see org.eclipse.ui.internal.LayoutPart#getImportance()
- */
- public boolean isCompressible() {
- //Added for bug 19524
- return true;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.internal.PartSashContainer#isStackType(org.eclipse.ui.internal.LayoutPart)
- */
- public boolean isStackType(LayoutPart toTest) {
- return (toTest instanceof EditorStack);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.internal.PartSashContainer#isPaneType(org.eclipse.ui.internal.LayoutPart)
- */
- public boolean isPaneType(LayoutPart toTest) {
- return (toTest instanceof EditorPane);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.internal.PartSashContainer#createStack(org.eclipse.ui.internal.LayoutPart)
- */
- protected PartStack createStack() {
- EditorStack newWorkbook = EditorStack.newEditorWorkbook(this, page);
-
- return newWorkbook;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.internal.PartSashContainer#setVisiblePart(org.eclipse.ui.internal.ILayoutContainer, org.eclipse.ui.internal.LayoutPart)
- */
- protected void setVisiblePart(ILayoutContainer container,
- LayoutPart visiblePart) {
- EditorStack refPart = (EditorStack) container;
-
- refPart.becomeActiveWorkbook(true);
- refPart.setSelection(visiblePart);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.internal.PartSashContainer#getVisiblePart(org.eclipse.ui.internal.ILayoutContainer)
- */
- protected LayoutPart getVisiblePart(ILayoutContainer container) {
- EditorStack refPart = (EditorStack) container;
-
- return refPart.getSelection();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.internal.PartSashContainer#pickPartToZoom()
- */
- public LayoutPart pickPartToZoom() {
- return getActiveWorkbook();
- }
-
- /**
- * Restore the presentation state. Loop over the workbooks, create the appropriate serializer and pass to the presentation.
- *
- * @param areaMem the memento containing presentation
- * @return the restoration status
- */
- public IStatus restorePresentationState(IMemento areaMem) {
- for (Iterator i = getEditorWorkbooks().iterator(); i.hasNext();) {
- final EditorStack workbook = (EditorStack) i.next();
- final IMemento memento = workbook.getSavedPresentationState();
- if (memento == null) {
- continue;
- }
- final PresentationSerializer serializer = new PresentationSerializer(
- workbook.getPresentableParts());
- StartupThreading.runWithoutExceptions(new StartupRunnable(){
-
- public void runWithException() throws Throwable {
- workbook.getPresentation().restoreState(serializer, memento);
- }});
-
- }
- return Status.OK_STATUS;
- }
-}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/EditorStack.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/EditorStack.java
deleted file mode 100644
index 934b28344cf..00000000000
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/EditorStack.java
+++ /dev/null
@@ -1,367 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 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
- * Cagatay Kavukcuoglu <cagatayk@acm.org> - Fix for bug 10025 - Resizing views
- * should not use height ratios
- *******************************************************************************/
-
-package org.eclipse.ui.internal;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.ui.IEditorReference;
-import org.eclipse.ui.IMemento;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.internal.presentations.PresentablePart;
-import org.eclipse.ui.internal.presentations.PresentationFactoryUtil;
-import org.eclipse.ui.internal.presentations.SystemMenuPinEditor;
-import org.eclipse.ui.internal.presentations.SystemMenuSize;
-import org.eclipse.ui.internal.presentations.UpdatingActionContributionItem;
-import org.eclipse.ui.internal.presentations.util.TabbedStackPresentation;
-import org.eclipse.ui.internal.util.Util;
-import org.eclipse.ui.presentations.IPresentablePart;
-import org.eclipse.ui.presentations.IStackPresentationSite;
-import org.eclipse.ui.presentations.StackPresentation;
-
-/**
- * Represents a tab folder of editors. This layout part container only accepts
- * EditorPane parts.
- *
- * TODO: Make PartStack non-abstract and delete this class. The differences between
- * editors and views should be handled by the presentation or the editors/views themselves.
- */
-public class EditorStack extends PartStack {
-
- private EditorSashContainer editorArea;
-
- private WorkbenchPage page;
-
- private SystemMenuSize sizeItem = new SystemMenuSize(null);
-
- private SystemMenuPinEditor pinEditorItem = new SystemMenuPinEditor(null);
-
- public EditorStack(EditorSashContainer editorArea, WorkbenchPage page) {
- super(PresentationFactoryUtil.ROLE_EDITOR);
- this.editorArea = editorArea;
- setID(this.toString());
- // Each folder has a unique ID so relative positioning is unambiguous.
- // save off a ref to the page
- //@issue is it okay to do this??
- //I think so since a ViewStack is
- //not used on more than one page.
- this.page = page;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.internal.PartStack#getPage()
- */
- protected WorkbenchPage getPage() {
- return page;
- }
-
- public void addSystemActions(IMenuManager menuManager) {
- pinEditorItem = new SystemMenuPinEditor((EditorPane) getSelection());
- appendToGroupIfPossible(menuManager,
- "misc", new UpdatingActionContributionItem(pinEditorItem)); //$NON-NLS-1$
- sizeItem = new SystemMenuSize(getSelection());
- appendToGroupIfPossible(menuManager, "size", sizeItem); //$NON-NLS-1$
- }
-
- public boolean isMoveable(IPresentablePart part) {
- return true;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.presentations.IStackPresentationSite#supportsState(int)
- */
- public boolean supportsState(int state) {
- if (page.isFixedLayout()) {
- return false;
- }
-
- return true;
- }
-
- /**
- * Factory method for editor workbooks.
- */
- public static EditorStack newEditorWorkbook(EditorSashContainer editorArea,
- WorkbenchPage page) {
- return new EditorStack(editorArea, page);
- }
-
- protected void add(LayoutPart newChild, Object cookie) {
- super.add(newChild, cookie);
-
- ((EditorPane) newChild).setWorkbook(this);
- }
-
- /**
- * See IVisualContainer#add
- */
- public void add(LayoutPart child) {
- super.add(child);
-
- if (child instanceof EditorPane) {
- ((EditorPane) child).setWorkbook(this);
- }
- }
-
- protected void updateActions(PresentablePart current) {
- EditorPane pane = null;
- if (current != null && current.getPane() instanceof EditorPane) {
- pane = (EditorPane) current.getPane();
- }
-
- sizeItem.setPane(pane);
- pinEditorItem.setPane(pane);
- }
-
- public Control[] getTabList() {
- return getTabList(getSelection());
- }
-
- public void removeAll() {
- LayoutPart[] children = getChildren();
-
- for (int i = 0; i < children.length; i++) {
- remove(children[i]);
- }
- }
-
- public boolean isActiveWorkbook() {
- EditorSashContainer area = getEditorArea();
-
- if (area != null) {
- return area.isActiveWorkbook(this);
- } else {
- return false;
- }
- }
-
- public void becomeActiveWorkbook(boolean hasFocus) {
- EditorSashContainer area = getEditorArea();
-
- if (area != null) {
- area.setActiveWorkbook(this, hasFocus);
- }
- }
-
- public EditorPane[] getEditors() {
- LayoutPart[] children = getChildren();
-
- EditorPane[] panes = new EditorPane[children.length];
- for (int idx = 0; idx < children.length; idx++) {
- panes[idx] = (EditorPane) children[idx];
- }
-
- return panes;
- }
-
- public EditorSashContainer getEditorArea() {
- return editorArea;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.internal.PartStack#canMoveFolder()
- */
- protected boolean canMoveFolder() {
- return true;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.internal.PartStack#derefPart(org.eclipse.ui.internal.LayoutPart)
- */
- protected void derefPart(LayoutPart toDeref) {
- EditorAreaHelper.derefPart(toDeref);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.internal.PartStack#allowsDrop(org.eclipse.ui.internal.PartPane)
- */
- protected boolean allowsDrop(PartPane part) {
- return part instanceof EditorPane;
- }
-
- public void setFocus() {
- super.setFocus();
- becomeActiveWorkbook(true);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.internal.PartStack#close(org.eclipse.ui.presentations.IPresentablePart[])
- */
- protected void close(IPresentablePart[] parts) {
-
- if (parts.length == 1) {
- close(parts[0]);
- return;
- }
-
- IEditorReference[] toClose = new IEditorReference[parts.length];
- for (int idx = 0; idx < parts.length; idx++) {
- EditorPane part = (EditorPane) getPaneFor(parts[idx]);
- toClose[idx] = part.getEditorReference();
- }
-
- WorkbenchPage page = getPage();
-
- if (page != null) {
- page.closeEditors(toClose, true);
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.internal.LayoutPart#testInvariants()
- */
- public void testInvariants() {
- super.testInvariants();
-
- int active = getActive();
-
- if (active == StackPresentation.AS_ACTIVE_FOCUS) {
- Assert.isTrue(isActiveWorkbook());
- } else if (active == StackPresentation.AS_ACTIVE_NOFOCUS) {
- Assert.isTrue(isActiveWorkbook());
- } else if (active == StackPresentation.AS_INACTIVE) {
- Assert.isTrue(!isActiveWorkbook());
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.internal.PartStack#restoreState(org.eclipse.ui.IMemento)
- */
- public IStatus restoreState(IMemento memento) {
- Integer expanded = memento.getInteger(IWorkbenchConstants.TAG_EXPANDED);
- setState((expanded == null || expanded.intValue() != IStackPresentationSite.STATE_MINIMIZED) ? IStackPresentationSite.STATE_RESTORED
- : IStackPresentationSite.STATE_MINIMIZED);
-
- Integer appearance = memento
- .getInteger(IWorkbenchConstants.TAG_APPEARANCE);
- if (appearance != null) {
- this.appearance = appearance.intValue();
- }
-
- // Determine if the presentation has saved any info here
- savedPresentationState = null;
- IMemento[] presentationMementos = memento
- .getChildren(IWorkbenchConstants.TAG_PRESENTATION);
-
- for (int idx = 0; idx < presentationMementos.length; idx++) {
- IMemento child = presentationMementos[idx];
-
- String id = child.getString(IWorkbenchConstants.TAG_ID);
-
- if (Util.equals(id, getFactory().getId())) {
- savedPresentationState = child;
- break;
- }
- }
-
- return new Status(IStatus.OK, PlatformUI.PLUGIN_ID, 0, "", null); //$NON-NLS-1$
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.internal.PartStack#saveState(org.eclipse.ui.IMemento)
- */
- public IStatus saveState(IMemento memento) {
- memento
- .putInteger(
- IWorkbenchConstants.TAG_EXPANDED,
- (getPresentationSite().getState() == IStackPresentationSite.STATE_MINIMIZED) ? IStackPresentationSite.STATE_MINIMIZED
- : IStackPresentationSite.STATE_RESTORED);
-
- memento.putInteger(IWorkbenchConstants.TAG_APPEARANCE, appearance);
-
- savePresentationState();
-
- if (savedPresentationState != null) {
- IMemento presentationState = memento
- .createChild(IWorkbenchConstants.TAG_PRESENTATION);
- presentationState.putMemento(savedPresentationState);
- }
-
- return new Status(IStatus.OK, PlatformUI.PLUGIN_ID, 0, "", null); //$NON-NLS-1$
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.internal.PartStack#setMinimized(boolean)
- */
- public void setMinimized(boolean minimized) {
- // 'Smart' minimize; move the editor area to the trim
- Perspective persp = getPage().getActivePerspective();
- if (Perspective.useNewMinMax(persp)) {
- if (minimized) {
- persp.setEditorAreaState(IStackPresentationSite.STATE_MINIMIZED);
- }
- else {
- // First, if we're maximized then revert
- if (persp.getPresentation().getMaximizedStack() != null) {
- PartStack maxStack = persp.getPresentation().getMaximizedStack();
- if (maxStack instanceof ViewStack) {
- maxStack.setState(IStackPresentationSite.STATE_RESTORED);
- }
- else if (maxStack instanceof EditorStack) {
- // We handle editor max through the perspective since it's
- // shared between pages...
- persp.setEditorAreaState(IStackPresentationSite.STATE_RESTORED);
- }
- }
-
- int curState = persp.getEditorAreaState();
- if (curState == IStackPresentationSite.STATE_MINIMIZED)
- curState = IStackPresentationSite.STATE_RESTORED;
-
- persp.setEditorAreaState(curState);
- }
-
- refreshPresentationState();
- //return;
- }
-
- super.setMinimized(minimized);
- }
-
- /**
- * Changes the editor stack's state to the given one -without-
- * side-effects. This is used when switching perspectives because
- * the Editor Area is perspective based but is shared between all
- * perspectives...
- *
- * @param newState The new state to set the editor stack to
- */
- public void setStateLocal(int newState) {
- if (newState == getState())
- return;
-
- //isMinimized = getState() == IStackPresentationSite.STATE_MINIMIZED;
- setMinimized(newState == IStackPresentationSite.STATE_MINIMIZED);
- presentationSite.setPresentationState(newState);
- }
-
- /**
- * Cause the folder to hide or show its
- * Minimize and Maximize affordances.
- *
- * @param show
- * <code>true</code> - the min/max buttons are visible.
- * @since 3.3
- */
- public void showMinMax(boolean show) {
- StackPresentation pres = getPresentation();
- if (pres == null)
- return;
-
- if (pres instanceof TabbedStackPresentation)
- ((TabbedStackPresentation)pres).showMinMax(show);
- }
-}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/FastViewBar.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/FastViewBar.java
deleted file mode 100644
index cebe308b96d..00000000000
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/FastViewBar.java
+++ /dev/null
@@ -1,982 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2008 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
- * Kiryl Kazakevich, Intel - bug 88359
- *******************************************************************************/
-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;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.jface.action.IContributionItem;
-import org.eclipse.jface.action.MenuManager;
-import org.eclipse.jface.action.ToolBarManager;
-import org.eclipse.jface.util.Geometry;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.accessibility.AccessibleAdapter;
-import org.eclipse.swt.accessibility.AccessibleEvent;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.graphics.Cursor;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.Listener;
-import org.eclipse.swt.widgets.Menu;
-import org.eclipse.swt.widgets.ToolBar;
-import org.eclipse.swt.widgets.ToolItem;
-import org.eclipse.ui.IMemento;
-import org.eclipse.ui.IViewReference;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.IWorkbenchPreferenceConstants;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.internal.dnd.AbstractDropTarget;
-import org.eclipse.ui.internal.dnd.DragUtil;
-import org.eclipse.ui.internal.dnd.IDragOverListener;
-import org.eclipse.ui.internal.dnd.IDropTarget;
-import org.eclipse.ui.internal.layout.CellData;
-import org.eclipse.ui.internal.layout.CellLayout;
-import org.eclipse.ui.internal.layout.IWindowTrim;
-import org.eclipse.ui.internal.layout.LayoutUtil;
-import org.eclipse.ui.internal.layout.Row;
-import org.eclipse.ui.internal.util.PrefUtil;
-import org.eclipse.ui.presentations.PresentationUtil;
-import org.osgi.framework.Bundle;
-
-/**
- * Represents the fast view bar.
- *
- * <p>The set of fastviews are obtained from the WorkbenchWindow that
- * is passed into the constructor. The set of fastviews may be refreshed to
- * match the state of the perspective by calling the update(...) method.</p>
- *
- * @see org.eclipse.ui.internal.FastViewPane
- */
-public class FastViewBar implements IWindowTrim {
- public static String FASTVIEWBAR_ID = "org.eclise.ui.internal.FastViewBar"; //$NON-NLS-1$
-
- private ToolBarManager fastViewBar;
- private MenuManager fastViewBarMenuManager;
- private MenuManager showViewMenuMgr;
- private FastViewBarContextMenuContribution contextContributionItem;
-
- private WorkbenchWindow window;
- private IViewReference selection;
-
- // "New Fast View" 'Button' fields
- private MenuManager newFastViewMenuMgr;
- private Composite fvbComposite;
- private ToolBar menuTB;
- private ToolItem menuItem;
- private CellData toolBarData;
-
- private static final int HIDDEN_WIDTH = 5;
-
-
- private int oldLength = 0;
-
- private ViewDropTarget dropTarget;
-
- private Listener dragListener = new Listener() {
- public void handleEvent(Event event) {
- Point position = DragUtil.getEventLoc(event);
-
- IViewReference ref = getViewAt(position);
-
- if (ref == null) {
- startDraggingFastViewBar(position, false);
- } else {
- startDraggingFastView(ref, position, false);
- }
- }
- };
-
- // Map of string view IDs onto Booleans (true iff horizontally aligned)
- private Map viewOrientation = new HashMap();
-
- private Listener addMenuListener = new Listener() {
- public void handleEvent(Event event) {
- Point loc = new Point(event.x, event.y);
- if (event.type == SWT.MenuDetect) {
- showAddFastViewPopup(loc);
- }
- }
- };
-
- private Listener menuListener = new Listener() {
- public void handleEvent(Event event) {
- Point loc = new Point(event.x, event.y);
- if (event.type == SWT.MenuDetect) {
- showFastViewBarPopup(loc);
- }
- }
- };
- private int fCurrentSide = SWT.DEFAULT;
-
- private boolean hasNewFastViewDisabled = false;
-
- class ViewDropTarget extends AbstractDropTarget {
- List panes;
-
- ToolItem position;
-
- /**
- * @param panesToDrop
- * the list of ViewPanes to drop at the given position
- * @param position
- * the tool item denoting the position
- */
- public ViewDropTarget(List panesToDrop, ToolItem position) {
- setTarget(panesToDrop, position);
- }
-
- public void setTarget(List panesToDrop, ToolItem position) {
- panes = panesToDrop;
- this.position = position;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.internal.dnd.IDropTarget#drop()
- */
- public void drop() {
- IViewReference view = getViewFor(position);
-
- Iterator iter = panes.iterator();
- while (iter.hasNext()) {
- ViewPane pane = (ViewPane) iter.next();
- IViewReference ref = pane.getViewReference();
- getPerspective().getFastViewManager().addViewReference(FASTVIEWBAR_ID, getIndex(view), ref, true);
-// getPage().addFastView(pane.getViewReference());
-// getPage().getActivePerspective().moveFastView(
-// pane.getViewReference(), view);
- }
- update(true);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.internal.dnd.IDropTarget#getCursor()
- */
- public Cursor getCursor() {
- return DragCursors.getCursor(DragCursors.FASTVIEW);
- }
-
- public Rectangle getSnapRectangle() {
- if (position == null) {
- // As long as the toolbar is not empty, highlight the place
- // where this view will appear (we
- // may have compressed it to save space when empty, so the actual
- // icon location may not be over the toolbar when it is empty)
- if (getToolBar().getItemCount() > 0) {
- return getLocationOfNextIcon();
- }
- // If the toolbar is empty, highlight the entire toolbar
- return DragUtil.getDisplayBounds(getControl());
- }
-
- return Geometry.toDisplay(getToolBar(), position.getBounds());
- }
- }
-
- /**
- * Constructs a new fast view bar for the given workbench window.
- *
- * @param theWindow
- */
- public FastViewBar(WorkbenchWindow theWindow) {
- window = theWindow;
-
- hasNewFastViewDisabled = PrefUtil.getAPIPreferenceStore().getBoolean(
- IWorkbenchPreferenceConstants.DISABLE_NEW_FAST_VIEW);
-
- // Construct the context menu for the fast view bar area
- fastViewBarMenuManager = new MenuManager();
- contextContributionItem = new FastViewBarContextMenuContribution(this);
- fastViewBarMenuManager.add(contextContributionItem);
-
- if (!hasNewFastViewDisabled) {
- // Add "New Fast View" submenu
- showViewMenuMgr = new MenuManager(WorkbenchMessages.FastViewBar_show_view, "showView"); //$NON-NLS-1$
- IContributionItem showViewMenu = new ShowViewMenu(window, ShowViewMenu.class.getName(), true);
- showViewMenuMgr.add(showViewMenu);
- fastViewBarMenuManager.add(showViewMenuMgr);
-
- // Construct the context menu for the "New Fast View" 'button'
- newFastViewMenuMgr = new MenuManager(WorkbenchMessages.FastViewBar_show_view, "showView"); //$NON-NLS-1$
- showViewMenu = new ShowViewMenu(window, ShowViewMenu.class.getName(), true);
- newFastViewMenuMgr.add(showViewMenu);
- }
- }
-
- /**
- * Returns the platform's idea of where the fast view bar should be docked in a fresh
- * workspace. This value is meaningless after a workspace has been setup, since the
- * fast view bar state is then persisted in the workbench. This preference is just
- * used for applications that want the initial docking location to be somewhere other
- * than bottom.
- * @return the initial side to dock on
- */
- public static int getInitialSide() {
- String loc = PrefUtil.getAPIPreferenceStore().getString(
- IWorkbenchPreferenceConstants.INITIAL_FAST_VIEW_BAR_LOCATION);
-
- if (IWorkbenchPreferenceConstants.BOTTOM.equals(loc)) {
- return SWT.BOTTOM;
- }
- if (IWorkbenchPreferenceConstants.LEFT.equals(loc)) {
- return SWT.LEFT;
- }
- if (IWorkbenchPreferenceConstants.RIGHT.equals(loc)) {
- return SWT.RIGHT;
- }
-
- Bundle bundle = Platform.getBundle(PlatformUI.PLUGIN_ID);
- if (bundle != null) {
- IStatus status = new Status(
- IStatus.WARNING,
- PlatformUI.PLUGIN_ID,
- IStatus.WARNING,
- "Invalid value for " //$NON-NLS-1$
- + PlatformUI.PLUGIN_ID
- + "/" //$NON-NLS-1$
- + IWorkbenchPreferenceConstants.INITIAL_FAST_VIEW_BAR_LOCATION
- + " preference. Value \"" + loc //$NON-NLS-1$
- + "\" should be one of \"" //$NON-NLS-1$
- + IWorkbenchPreferenceConstants.LEFT + "\", \"" //$NON-NLS-1$
- + IWorkbenchPreferenceConstants.BOTTOM
- + "\", or \"" //$NON-NLS-1$
- + IWorkbenchPreferenceConstants.RIGHT + "\".", null); //$NON-NLS-1$
- Platform.getLog(bundle).log(status);
- }
-
- // use bottom as the default-default
- return SWT.BOTTOM;
- }
-
- public void setOrientation(IViewReference refToSet, int newState) {
- if (newState == getOrientation(refToSet)) {
- return;
- }
-
- viewOrientation.put(refToSet.getId(), new Integer(newState));
- Perspective persp = getPerspective();
-
- if (persp != null) {
- IViewReference ref = persp.getActiveFastView();
- if (ref != null) {
- persp.setActiveFastView(null);
- }
- persp.setActiveFastView(refToSet);
- }
- }
-
- /**
- * Returns the active workbench page or null if none
- */
- private WorkbenchPage getPage() {
- if (window == null) {
- return null;
- }
-
- return window.getActiveWorkbenchPage();
- }
-
- /**
- * Returns the current perspective or null if none
- */
- private Perspective getPerspective() {
-
- WorkbenchPage page = getPage();
-
- if (page == null) {
- return null;
- }
-
- return page.getActivePerspective();
- }
-
- /**
- * Creates the underlying SWT fvbComposite for the fast view bar. Will add exactly
- * one new fvbComposite to the given composite. Makes no assumptions about the layout
- * being used in the parent composite.
- *
- * @param parent enclosing SWT composite
- */
- public void createControl(Composite parent) {
- fvbComposite = new Composite(parent, SWT.NONE) {
- public Point computeSize(int wHint, int hHint, boolean changed) {
- Point size = super.computeSize(wHint, hHint, changed);
- if (Geometry.isHorizontal(getSide())) {
- if (size.y < TrimUtil.TRIM_DEFAULT_HEIGHT) {
- size.y = TrimUtil.TRIM_DEFAULT_HEIGHT;
- }
- } else {
- if (size.x < TrimUtil.TRIM_DEFAULT_HEIGHT) {
- size.x = TrimUtil.TRIM_DEFAULT_HEIGHT;
- }
- }
- return size;
- }};
- String tip = WorkbenchMessages.FastViewBar_0;
- fvbComposite.setToolTipText(tip);
-
- fvbComposite.addListener(SWT.MenuDetect, menuListener);
- PresentationUtil.addDragListener(fvbComposite, dragListener);
-
- createChildControls();
- }
-
- /**
- * Create the contents of the fast view bar. The top-level fvbComposite (created by createControl) is a
- * composite that is created once over the lifetime of the fast view bar. This method creates the
- * rest of the widgetry inside that composite. The controls created by this method will be
- * destroyed and recreated if the fast view bar is docked to a different side of the window.
- */
- protected void createChildControls() {
- int newSide = getSide();
- int orientation = Geometry.isHorizontal(newSide) ? SWT.HORIZONTAL
- : SWT.VERTICAL;
-
- // Create a ControlLayout apropriate for the new orientation
- CellLayout controlLayout;
- if (Geometry.isHorizontal(newSide)) {
- controlLayout = new CellLayout(0)
- .setMargins(0, 0)
- .setDefaultRow(Row.growing())
- .setDefaultColumn(Row.fixed())
- .setColumn(1, Row.growing());
- } else {
- controlLayout = new CellLayout(1)
- .setMargins(0, 3)
- .setDefaultColumn(Row.growing())
- .setDefaultRow(Row.fixed())
- .setRow(1, Row.growing());
- }
-
- // Set up the composite for the new orientation
- fvbComposite.setLayout(controlLayout);
-
- if (!hasNewFastViewDisabled) {
- // Create a toolbar to show an 'Add FastView' menu 'button'
- menuTB = new ToolBar(fvbComposite, SWT.FLAT | orientation);
-
- // Construct an item to act as a 'menu button' (a la the PerspectiveSwitcher)
- menuItem = new ToolItem(menuTB, SWT.PUSH, 0);
-
- Image tbImage = WorkbenchImages.getImage(IWorkbenchGraphicConstants.IMG_ETOOL_NEW_FASTVIEW);
- menuItem.setImage(tbImage);
-
- final String menuTip = WorkbenchMessages.FastViewBar_0;
- menuItem.setToolTipText(menuTip);
- //new ToolItem(menuTB, SWT.SEPARATOR, 1);
-
- menuTB.getAccessible().addAccessibleListener(new AccessibleAdapter() {
- public void getName(AccessibleEvent e) {
- e.result = menuTip;
- }
- });
-
- // Now that the ToolBar is populated calculate its size...
- Point size = menuTB.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
- menuTB.setBounds(0, 0, size.x, size.y);
-
- // Bring up the 'Add Fast View' menu on a left -or- right button click
- // Right click (context menu)
- menuItem.addListener(SWT.MenuDetect, addMenuListener);
- menuTB.addListener(SWT.MenuDetect, addMenuListener);
-
- // Left Click...
- menuItem.addSelectionListener(new SelectionListener() {
- public void widgetSelected(SelectionEvent e) {
- Rectangle bb = DragUtil.getDisplayBounds(menuTB);
- showAddFastViewPopup(new Point(bb.x,bb.y+bb.height));
- }
-
- public void widgetDefaultSelected(SelectionEvent e) {
- }
-
- });
-
- // try to get the layout correct...
- toolBarData = new CellData();
- toolBarData.align(SWT.FILL, SWT.FILL);
- menuTB.setLayoutData(toolBarData);
- }
-
- // Construct the ToolBar containing the 'Fast' views
- fastViewBar = new ToolBarManager(SWT.FLAT | SWT.WRAP | orientation);
- fastViewBar.add(new ShowFastViewContribution(window));
-
- fastViewBar.createControl(fvbComposite);
-
- getToolBar().addListener(SWT.MenuDetect, menuListener);
-
- IDragOverListener fastViewDragTarget = new IDragOverListener() {
-
- public IDropTarget drag(Control currentControl,
- Object draggedObject, Point position,
- Rectangle dragRectangle) {
- ToolItem targetItem = getToolItem(position);
- if (draggedObject instanceof ViewPane) {
- ViewPane pane = (ViewPane) draggedObject;
-
- // Can't drag views between windows
- if (pane.getWorkbenchWindow() != window) {
- return null;
- }
-
- List newList = new ArrayList(1);
- newList.add(draggedObject);
-
- return createDropTarget(newList, targetItem);
- }
- if (draggedObject instanceof ViewStack) {
- ViewStack folder = (ViewStack) draggedObject;
-
- if (folder.getWorkbenchWindow() != window) {
- return null;
- }
-
- List viewList = new ArrayList(folder.getItemCount());
- LayoutPart[] children = folder.getChildren();
-
- for (int idx = 0; idx < children.length; idx++) {
- if (!(children[idx] instanceof PartPlaceholder)) {
- viewList.add(children[idx]);
- }
- }
-
- return createDropTarget(viewList, targetItem);
- }
-
- return null;
- }
-
- };
-
- toolBarData = new CellData();
- toolBarData.align(SWT.FILL, SWT.FILL);
-
- getToolBar().setLayoutData(toolBarData);
- PresentationUtil.addDragListener(getToolBar(), dragListener);
- DragUtil.addDragTarget(getControl(), fastViewDragTarget);
-
- update(true);
- }
-
- /**
- * Creates and returns a drop target with the given properties. To save object allocation,
- * the same instance is saved and reused wherever possible.
- *
- * @param targetItem
- * @param viewList
- * @since 3.1
- */
- private IDropTarget createDropTarget(List viewList, ToolItem targetItem) {
- if (dropTarget == null) {
- dropTarget = new ViewDropTarget(viewList, targetItem);
- } else {
- dropTarget.setTarget(viewList, targetItem);
- }
- return dropTarget;
- }
-
- /**
- * Begins dragging a particular fast view
- *
- * @param ref
- * @param position
- */
- protected void startDraggingFastView(IViewReference ref, Point position,
- boolean usingKeyboard) {
- ViewPane pane = (ViewPane) ((WorkbenchPartReference) ref).getPane();
-
- ToolItem item = itemFor(pane.getViewReference());
-
- Rectangle dragRect = Geometry.toDisplay(getToolBar(), item.getBounds());
-
- startDrag(((WorkbenchPartReference) ref).getPane(), dragRect, position,
- usingKeyboard);
- }
-
- private void startDrag(Object toDrag, Rectangle dragRect, Point position,
- boolean usingKeyboard) {
-
- Perspective persp = getPerspective();
-
- WorkbenchPage page = getPage();
-
- IViewReference oldFastView = null;
- if (persp != null) {
- oldFastView = persp.getActiveFastView();
-
- if (page != null) {
- page.hideFastView();
- }
- }
-
- if (page != null && page.isZoomed()) {
- page.zoomOut();
- }
-
- boolean success = DragUtil.performDrag(toDrag, dragRect, position,
- !usingKeyboard);
-
- // If the drag was cancelled, reopen the old fast view
- if (!success && oldFastView != null && page != null) {
- page.toggleFastView(oldFastView);
- }
- }
-
- /**
- * Begins dragging the fast view bar
- *
- * @param position initial mouse position
- * @param usingKeyboard true iff the bar is being dragged using the keyboard
- */
- protected void startDraggingFastViewBar(Point position,
- boolean usingKeyboard) {
- Rectangle dragRect = DragUtil.getDisplayBounds(fvbComposite);
-
- startDrag(this, dragRect, position, usingKeyboard);
- }
-
- /**
- * Returns the toolbar for the fastview bar.
- */
- private ToolBar getToolBar() {
- return fastViewBar.getControl();
- }
-
- private IViewReference getViewFor(ToolItem item) {
- if (item == null) {
- return null;
- }
-
- return (IViewReference) item
- .getData(ShowFastViewContribution.FAST_VIEW);
- }
-
- /**
- * Returns the view at the given position, or null if none
- *
- * @param position to test, in display coordinates
- * @return the view at the given position or null if none
- */
- private IViewReference getViewAt(Point position) {
- return getViewFor(getToolItem(position));
- }
-
- /**
- * Returns the toolbar item at the given position, in display coordinates
- * @param position
- */
- private ToolItem getToolItem(Point position) {
- ToolBar toolbar = getToolBar();
- Point local = toolbar.toControl(position);
- return toolbar.getItem(local);
- }
-
- /**
- * Shows the popup menu for an item in the fast view bar.
- */
- private void showFastViewBarPopup(Point pt) {
- // Get the tool item under the mouse.
-
- ToolBar toolBar = getToolBar();
-
- Menu menu = fastViewBarMenuManager.createContextMenu(toolBar);
-
- IViewReference selectedView = getViewAt(pt);
- contextContributionItem.setTarget(selectedView);
-
- menu.setLocation(pt.x, pt.y);
- menu.setVisible(true);
- }
-
- /**
- * Shows the popup menu for an item in the fast view bar.
- */
- private void showAddFastViewPopup(Point pt) {
- Menu menu = newFastViewMenuMgr.createContextMenu(menuTB);
- menu.setLocation(pt.x, pt.y);
- menu.setVisible(true);
- }
-
- public int getOrientation(IViewReference ref) {
- return isHorizontal(ref) ? SWT.HORIZONTAL : SWT.VERTICAL;
- }
-
- /**
- * Returns the underlying SWT fvbComposite for the fast view bar, or null if
- * createControl has not yet been invoked. The caller must not make any
- * assumptions about the type of Control that is returned.
- *
- * @return the underlying SWT fvbComposite for the fast view bar
- */
- public Control getControl() {
- return fvbComposite;
- }
-
- public void dispose() {
- fastViewBarMenuManager.dispose();
-
- disposeChildControls();
- }
-
- protected void disposeChildControls() {
- fastViewBar.dispose();
- fastViewBar = null;
-
- if (menuItem != null) {
- menuItem.dispose();
- menuTB.dispose();
- }
-
- oldLength = 0;
- }
-
-
- /**
- * Refreshes the contents to match the fast views in the window's
- * current perspective.
- *
- * @param force
- */
- public void update(boolean force) {
- fastViewBar.update(force);
- ToolItem[] items = fastViewBar.getControl().getItems();
-
- updateLayoutData();
-
- for (int idx = 0; idx < items.length; idx++) {
- IViewReference view = getViewFor(items[idx]);
-
- viewOrientation.put(view.getId(), new Integer(
- isHorizontal(view) ? SWT.HORIZONTAL : SWT.VERTICAL));
- }
-
- // Resize the FVB to its new size
- fvbComposite.setSize(fvbComposite.computeSize(SWT.DEFAULT, SWT.DEFAULT));
- }
-
- private void updateLayoutData() {
- ToolItem[] items = fastViewBar.getControl().getItems();
- boolean isHorizontal = Geometry.isHorizontal(getSide());
- boolean shouldExpand = items.length > 0;
-
- Point hint = new Point(32, shouldExpand ? SWT.DEFAULT : HIDDEN_WIDTH);
-
- if (!isHorizontal) {
- Geometry.flipXY(hint);
- }
-
- if (shouldExpand) {
- toolBarData.setHint(CellData.MINIMUM, hint);
- } else {
- toolBarData.setHint(CellData.OVERRIDE, hint);
- }
-
- if (items.length != oldLength) {
- LayoutUtil.resize(fvbComposite);
- oldLength = items.length;
- }
- }
-
- /**
- * Returns the currently selected fastview
- *
- * @return the currently selected fastview or null if none
- */
- public IViewReference getSelection() {
- return selection;
- }
-
- /**
- * Sets the currently selected fastview.
- *
- * @param selected the currently selected fastview, or null if none
- */
- public void setSelection(IViewReference selected) {
-
- ToolItem[] items = fastViewBar.getControl().getItems();
- for (int i = 0; i < items.length; i++) {
- ToolItem item = items[i];
- item.setSelection(getView(item) == selected);
- }
-
- selection = selected;
- }
-
- /**
- * Returns the view associated with the given toolbar item
- *
- * @param item
- */
- private IViewReference getView(ToolItem item) {
- return (IViewReference) item
- .getData(ShowFastViewContribution.FAST_VIEW);
- }
-
- private int getIndex(IViewReference toFind) {
- ToolItem[] items = fastViewBar.getControl().getItems();
- for (int i = 0; i < items.length; i++) {
- if (items[i].getData(ShowFastViewContribution.FAST_VIEW) == toFind) {
- return i;
- }
- }
-
- return items.length;
- }
-
- private ToolItem getItem(int idx) {
- ToolItem[] items = fastViewBar.getControl().getItems();
- if (idx >= items.length) {
- return null;
- }
-
- return items[idx];
- }
-
- /**
- * Returns the toolbar item associated with the given view
- *
- * @param toFind
- */
- private ToolItem itemFor(IViewReference toFind) {
- return getItem(getIndex(toFind));
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.internal.IWindowTrim#getValidSides()
- */
- public int getValidSides() {
- return SWT.TOP | SWT.LEFT | SWT.RIGHT | SWT.BOTTOM;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.internal.IWindowTrim#docked(int)
- */
- public void dock(int side) {
- fCurrentSide = side;
- disposeChildControls();
- createChildControls();
- }
-
- /**
- * Get the current side.
- * @return SWT.BOTTOM or SWT.RIGHT or SWT.LEFT
- */
- public int getSide() {
- if (fCurrentSide==SWT.DEFAULT) {
- fCurrentSide = getInitialSide();
- }
- return fCurrentSide;
- }
-
-
- private boolean isHorizontal(IViewReference ref) {
- Integer orientation = (Integer) viewOrientation.get(ref.getId());
- boolean horizontalBar = Geometry.isHorizontal(getSide());
- boolean horizontal = horizontalBar;
- if (orientation != null) {
- horizontal = orientation.intValue() == SWT.HORIZONTAL;
- } else {
- horizontal = false;
- }
-
- return horizontal;
- }
-
- public int getViewSide(IViewReference ref) {
- boolean horizontal = isHorizontal(ref);
-
- if (horizontal) {
- return (getSide() == SWT.BOTTOM) ? SWT.BOTTOM : SWT.TOP;
- }
-
- return (getSide() == SWT.RIGHT) ? SWT.RIGHT : SWT.LEFT;
- }
-
- public void saveState(IMemento memento) {
- memento.putInteger(IWorkbenchConstants.TAG_FAST_VIEW_SIDE, getSide());
-
- Iterator iter = viewOrientation.keySet().iterator();
- while (iter.hasNext()) {
- String next = (String) iter.next();
- IMemento orientation = memento
- .createChild(IWorkbenchConstants.TAG_FAST_VIEW_ORIENTATION);
-
- orientation.putString(IWorkbenchConstants.TAG_VIEW, next);
- orientation.putInteger(IWorkbenchConstants.TAG_POSITION,
- ((Integer) viewOrientation.get(next)).intValue());
- }
-
- }
-
- /**
- * Returns the approximate location where the next fast view icon will be
- * drawn (display coordinates)
- *
- * @return the rectangle
- */
- public Rectangle getLocationOfNextIcon() {
- ToolBar control = getToolBar();
-
- Rectangle result = control.getBounds();
- Point size = control.computeSize(SWT.DEFAULT, SWT.DEFAULT, false);
- result.height = size.y;
- result.width = size.x;
-
- boolean horizontal = Geometry.isHorizontal(getSide());
- if (control.getItemCount() == 0) {
- Geometry.setDimension(result, horizontal, 0);
- }
-
- int hoverSide = horizontal ? SWT.RIGHT : SWT.BOTTOM;
-
- result = Geometry.getExtrudedEdge(result, -Geometry.getDimension(
- result, !horizontal), hoverSide);
-
- return Geometry.toDisplay(control.getParent(), result);
- }
-
- public void restoreState(IMemento memento) {
- Integer bigInt;
- bigInt = memento.getInteger(IWorkbenchConstants.TAG_FAST_VIEW_SIDE);
- if (bigInt != null) {
- dock(bigInt.intValue());
- }
-
- IMemento[] orientations = memento
- .getChildren(IWorkbenchConstants.TAG_FAST_VIEW_ORIENTATION);
- for (int i = 0; i < orientations.length; i++) {
- IMemento next = orientations[i];
-
- viewOrientation.put(next.getString(IWorkbenchConstants.TAG_VIEW),
- next.getInteger(IWorkbenchConstants.TAG_POSITION));
- }
- }
-
- public WorkbenchWindow getWindow() {
- return window;
- }
-
- public void restoreView(IViewReference selectedView) {
- if (selectedView != null) {
- WorkbenchPage page = window.getActiveWorkbenchPage();
- if (page != null) {
- int idx = getIndex(selectedView);
- ToolItem item = getItem(idx);
- Rectangle bounds = item.getBounds();
- Rectangle startBounds = Geometry.toDisplay(item
- .getParent(), bounds);
-
- Perspective persp = getPerspective();
- if (persp != null) {
- persp.getFastViewManager().removeViewReference(selectedView, true, true);
- }
-
- IWorkbenchPart toActivate = selectedView
- .getPart(true);
- if (toActivate != null) {
- page.activate(toActivate);
- }
-
- ViewPane pane = (ViewPane) ((WorkbenchPartReference) selectedView)
- .getPane();
-
- // animate the view's relocation
- AnimationEngine.createTweakedAnimation(window.getShell(), 400, startBounds, pane.getParentBounds());
- }
- }
- }
-
- /**
- * @return The list of all view references in the stack
- */
- public List getViewRefs() {
- List refs = new ArrayList(fastViewBar.getControl().getItemCount());
- ToolItem[] items = fastViewBar.getControl().getItems();
- for (int i = 0; i < items.length; i++) {
- Object data = items[i].getData(ShowFastViewContribution.FAST_VIEW);
- if (data != null)
- refs.add(data);
- }
-
- return refs;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.internal.IWindowTrim#isCloseable()
- */
- public boolean isCloseable() {
- return false;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.internal.IWindowTrim#handleClose()
- */
- public void handleClose() {
- // nothing to do...
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.internal.IWindowTrim#getId()
- */
- public String getId() {
- return "org.eclise.ui.internal.FastViewBar"; //$NON-NLS-1$
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.internal.IWindowTrim#getDisplayName()
- */
- public String getDisplayName() {
- return WorkbenchMessages.TrimCommon_FastView_TrimName;
- }
-
- /**
- * Returns the context menu contribution item. This is for
- * internal UI testing only.
- *
- * @return the context menu contribution item
- * @since 3.1.1
- */
- public FastViewBarContextMenuContribution testContextMenu() {
- return contextContributionItem;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.IWindowTrim#getWidthHint()
- */
- public int getWidthHint() {
- return SWT.DEFAULT;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.IWindowTrim#getHeightHint()
- */
- public int getHeightHint() {
- return SWT.DEFAULT;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.IWindowTrim#isResizeable()
- */
- public boolean isResizeable() {
- return false;
- }
-}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/FastViewBarContextMenuContribution.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/FastViewBarContextMenuContribution.java
deleted file mode 100644
index 077d392c001..00000000000
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/FastViewBarContextMenuContribution.java
+++ /dev/null
@@ -1,128 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 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.jface.action.ContributionItem;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.widgets.Menu;
-import org.eclipse.swt.widgets.MenuItem;
-import org.eclipse.ui.IViewReference;
-
-public class FastViewBarContextMenuContribution extends ContributionItem {
- private MenuItem orientationItem;
- private MenuItem restoreItem;
- private MenuItem closeItem;
- private FastViewBar bar;
- private RadioMenu radioButtons;
- private IViewReference selectedView;
- private IntModel currentOrientation = new IntModel(SWT.VERTICAL);
-
- private IChangeListener orientationChangeListener = new IChangeListener() {
- public void update(boolean changed) {
- if (changed && selectedView != null) {
- bar.setOrientation(selectedView, currentOrientation.get());
- }
- }
- };
-
- public FastViewBarContextMenuContribution(FastViewBar bar) {
- this.bar = bar;
- currentOrientation.addChangeListener(orientationChangeListener);
- }
-
- public void fill(Menu menu, int index) {
- // TODO Auto-generated method stub
- super.fill(menu, index);
-
-
- orientationItem = new MenuItem(menu, SWT.CASCADE, index++);
- {
- orientationItem.setText(WorkbenchMessages.FastViewBar_view_orientation);
-
- Menu orientationSwtMenu = new Menu(orientationItem);
- RadioMenu orientationMenu = new RadioMenu(orientationSwtMenu,
- currentOrientation);
- orientationMenu
- .addMenuItem(
- WorkbenchMessages.FastViewBar_horizontal, new Integer(SWT.HORIZONTAL));
- orientationMenu
- .addMenuItem(
- WorkbenchMessages.FastViewBar_vertical, new Integer(SWT.VERTICAL));
-
- orientationItem.setMenu(orientationSwtMenu);
- }
-
- restoreItem = new MenuItem(menu, SWT.CHECK, index++);
- restoreItem.setText(WorkbenchMessages.ViewPane_fastView);
- restoreItem.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- bar.restoreView(selectedView);
- }
- });
-
- closeItem = new MenuItem(menu, SWT.NONE, index++);
- closeItem.setText(WorkbenchMessages.WorkbenchWindow_close);
- closeItem.addSelectionListener(new SelectionAdapter() {
-
- public void widgetSelected(SelectionEvent e) {
- if (selectedView != null) {
- WorkbenchPage page = bar.getWindow().getActiveWorkbenchPage();
- if (page != null) {
- page.hideView(selectedView);
- }
- }
- }
- });
-
-
- // Set menu item enablement etc based on whether a view is selected
- WorkbenchPage page = bar.getWindow().getActiveWorkbenchPage();
-
- if (selectedView != null) {
- restoreItem.setEnabled(page!=null && page.isMoveable(selectedView));
- } else {
- restoreItem.setEnabled(false);
- }
- restoreItem.setSelection(true);
-
- if (selectedView != null) {
- closeItem
- .setEnabled(page != null && page.isCloseable(selectedView));
- } else {
- closeItem.setEnabled(false);
- }
-
- orientationItem.setEnabled(selectedView != null);
- if (selectedView != null) {
- // Set the new orientation, but avoid re-sending the event to our own
- // listener
- currentOrientation.set(bar.getOrientation(selectedView),
- orientationChangeListener);
- }
- }
-
- public void setTarget(IViewReference selectedView) {
- this.selectedView = selectedView;
- }
-
- public boolean isDynamic() {
- return true;
- }
-
- public void dispose() {
- if (radioButtons != null) {
- radioButtons.dispose();
- }
- super.dispose();
- }
-}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/FastViewDnDHandler.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/FastViewDnDHandler.java
deleted file mode 100644
index dd4113ae572..00000000000
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/FastViewDnDHandler.java
+++ /dev/null
@@ -1,352 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2009 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.action.ToolBarManager;
-import org.eclipse.jface.util.Geometry;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.DisposeEvent;
-import org.eclipse.swt.events.DisposeListener;
-import org.eclipse.swt.graphics.Cursor;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.Listener;
-import org.eclipse.swt.widgets.ToolBar;
-import org.eclipse.swt.widgets.ToolItem;
-import org.eclipse.ui.IViewReference;
-import org.eclipse.ui.internal.dnd.AbstractDropTarget;
-import org.eclipse.ui.internal.dnd.DragUtil;
-import org.eclipse.ui.internal.dnd.IDragOverListener;
-import org.eclipse.ui.internal.dnd.IDropTarget;
-import org.eclipse.ui.presentations.PresentationUtil;
-
-/**
- * @since 3.3
- *
- */
-public class FastViewDnDHandler implements IDragOverListener {
- private String id;
- private ToolBarManager tbm;
- private WorkbenchWindow wbw;
- private ViewDropTarget dropTarget = null;
-
- private Listener dragListener = new Listener() {
- public void handleEvent(Event event) {
- Point position = DragUtil.getEventLoc(event);
-
- ToolBar toolbar = tbm.getControl();
- Point local = toolbar.toControl(position);
- ToolItem item = toolbar.getItem(local);
- IViewReference ref = (IViewReference) item
- .getData(ShowFastViewContribution.FAST_VIEW);
-
- if (ref != null) {
- startDraggingFastView(ref, position, false);
- }
- }
- };
-
- class ViewDropTarget extends AbstractDropTarget {
- List panes;
- ToolItem curItem;
-
- /**
- * @param panesToDrop the list of ViewPanes to drop at the given position
- */
- public ViewDropTarget(List panesToDrop, ToolItem position) {
- setTarget(panesToDrop, position);
- }
-
- public void setTarget(List panesToDrop, ToolItem position) {
- panes = panesToDrop;
- this.curItem = position;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.internal.dnd.IDropTarget#drop()
- */
- public void drop() {
- if (curItem == null)
- return;
-
- Perspective persp = wbw.getActiveWorkbenchPage().getActivePerspective();
- FastViewManager fvm = persp.getFastViewManager();
-
- int insertIndex = tbm.getControl().indexOf(curItem);
- Iterator iter = panes.iterator();
- while (iter.hasNext()) {
- ViewPane pane = (ViewPane) iter.next();
- IViewReference ref = pane.getViewReference();
- adoptRef(ref);
- fvm.addViewReference(id, insertIndex++, ref, !iter.hasNext());
- }
- }
-
- private void adoptRef(IViewReference ref) {
- Perspective persp = wbw.getActiveWorkbenchPage()
- .getActivePerspective();
- PerspectiveHelper helper = persp.getPresentation();
- ContainerPlaceholder ourContainerPlaceholder = (ContainerPlaceholder) helper
- .findPart(id, null);
- LayoutPart refPart = helper.findPart(ref.getId(), ref
- .getSecondaryId());
- ILayoutContainer refContainer = refPart.container;
- if (refContainer != ourContainerPlaceholder) {
- // remove the old part... if it's represented by a
- // placeholder then just remove it...
- if (refPart instanceof PartPlaceholder) {
- if (refContainer instanceof ContainerPlaceholder) {
- // just remove the placeholder
- ViewStack realContainer = (ViewStack) ((ContainerPlaceholder) refContainer)
- .getRealContainer();
- realContainer.remove(refPart);
- }
- else if (refContainer instanceof ViewStack) {
- refContainer.remove(refPart);
- }
- }
- else {
- // If its a real view ref then defref it...
- helper.derefPart(refPart);
- }
- PartPlaceholder newPlaceholder = new PartPlaceholder(ref
- .getId());
- ourContainerPlaceholder.add(newPlaceholder);
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.internal.dnd.IDropTarget#getCursor()
- */
- public Cursor getCursor() {
- return DragCursors.getCursor(DragCursors.FASTVIEW);
- }
-
- public Rectangle getSnapRectangle() {
- if (curItem == null) {
- // As long as the toolbar is not empty, highlight the place
- // where this view will appear (we
- // may have compressed it to save space when empty, so the actual
- // icon location may not be over the toolbar when it is empty)
- if (tbm.getControl().getItemCount() > 0) {
- return getLocationOfNextIcon();
- }
- // If the toolbar is empty, highlight the entire toolbar
- return DragUtil.getDisplayBounds(tbm.getControl());
- }
-
- return Geometry.toDisplay(tbm.getControl(), curItem.getBounds());
- }
- }
-
- /**
- *
- */
- public FastViewDnDHandler(String id, final ToolBarManager tbm, WorkbenchWindow wbw) {
- this.id = id;
- this.tbm = tbm;
- this.wbw = wbw;
-
- // Hook the 'drop' listener to the control
- DragUtil.addDragTarget(tbm.getControl(), this);
- PresentationUtil.addDragListener(tbm.getControl(), dragListener);
-
- // Clean up on dispose
- tbm.getControl().addDisposeListener(new DisposeListener() {
- public void widgetDisposed(DisposeEvent e) {
- DragUtil.removeDragTarget((Control)(e.widget), FastViewDnDHandler.this);
- PresentationUtil.removeDragListener(tbm.getControl(), dragListener);
- }
- });
- }
-
- /**
- * Returns the toolbar item at the given position, in display coordinates
- * @param position
- */
- private ToolItem getToolItem(Point position) {
- ToolBar toolbar = tbm.getControl();
- Point local = toolbar.toControl(position);
- return toolbar.getItem(local);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.internal.dnd.IDragOverListener#drag(org.eclipse.swt.widgets.Control, java.lang.Object, org.eclipse.swt.graphics.Point, org.eclipse.swt.graphics.Rectangle)
- */
- public IDropTarget drag(Control currentControl, Object draggedObject,
- Point position, Rectangle dragRectangle) {
- // If we're trying to drop onto a 'standalone' stack, don't...
- if (isStandaloneStack())
- return null;
-
- ToolItem targetItem = getToolItem(position);
- if (draggedObject instanceof ViewPane) {
- ViewPane pane = (ViewPane) draggedObject;
-
- // Can't drag views between pages
- if (pane.getPage() != wbw.getActivePage()) {
- return null;
- }
-
- List newList = new ArrayList(1);
- newList.add(draggedObject);
-
- return createDropTarget(newList, targetItem);
- }
- if (draggedObject instanceof ViewStack) {
- ViewStack folder = (ViewStack) draggedObject;
-
- if (folder.getWorkbenchWindow() != wbw) {
- return null;
- }
-
- List viewList = new ArrayList(folder.getItemCount());
- LayoutPart[] children = folder.getChildren();
-
- for (int idx = 0; idx < children.length; idx++) {
- if (!(children[idx] instanceof PartPlaceholder)) {
- viewList.add(children[idx]);
- }
- }
-
- return createDropTarget(viewList, targetItem);
- }
-
- return null;
- }
- /**
- * Tests the view references associated with the stack and
- * returns <code>true</code> if any view is a stand-alone view
- *
- * @return <code>true</code> is any view is stand-alone
- */
- private boolean isStandaloneStack() {
- Perspective persp = wbw.getActiveWorkbenchPage().getActivePerspective();
- List fvs = persp.getFastViewManager().getFastViews(id);
- for (Iterator iterator = fvs.iterator(); iterator.hasNext();) {
- IViewReference ref = (IViewReference) iterator.next();
- if (persp.isStandaloneView(ref))
- return true;
- }
-
- return false;
- }
-
- private IDropTarget createDropTarget(List viewList, ToolItem targetItem) {
- if (dropTarget == null) {
- dropTarget = new ViewDropTarget(viewList, targetItem);
- } else {
- dropTarget.setTarget(viewList, targetItem);
- }
- return dropTarget;
- }
-
- /**
- * Returns the approximate location where the next fastview icon
- * will be drawn (display coordinates)
- */
- public Rectangle getLocationOfNextIcon() {
- ToolBar control = tbm.getControl();
-
- Rectangle result = control.getBounds();
- Point size = control.computeSize(SWT.DEFAULT, SWT.DEFAULT, false);
- result.height = size.y;
- result.width = size.x;
-
- boolean horizontal = (control.getStyle() & SWT.VERTICAL) == 0;
- if (control.getItemCount() == 0) {
- Geometry.setDimension(result, horizontal, 0);
- }
-
- int hoverSide = horizontal ? SWT.RIGHT : SWT.BOTTOM;
-
- result = Geometry.getExtrudedEdge(result, -Geometry.getDimension(
- result, !horizontal), hoverSide);
-
- return Geometry.toDisplay(control.getParent(), result);
- }
-
- /**
- * Returns the index of the ToolItem fronting the view ref
- * @param toFind the view reference to find the index of
- * @return the index or -1 if not found
- */
- private int getIndex(IViewReference toFind) {
- ToolItem[] items = tbm.getControl().getItems();
- for (int i = 0; i < items.length; i++) {
- if (items[i].getData(ShowFastViewContribution.FAST_VIEW) == toFind) {
- return i;
- }
- }
-
- return -1;
- }
-
- /**
- * Begins dragging a particular fast view
- *
- * @param ref
- * @param position
- */
- protected void startDraggingFastView(IViewReference ref, Point position,
- boolean usingKeyboard) {
- int index = getIndex(ref);
- if (index == -1)
- return;
-
- ToolItem item = tbm.getControl().getItem(index);
- Rectangle dragRect = Geometry.toDisplay(tbm.getControl(), item.getBounds());
- startDrag(((WorkbenchPartReference) ref).getPane(), dragRect, position,
- usingKeyboard);
- }
-
- private void startDrag(Object toDrag, Rectangle dragRect, Point position,
- boolean usingKeyboard) {
- WorkbenchPage page = wbw.getActiveWorkbenchPage();
- Perspective persp = page.getActivePerspective();
-
- // Prevent dragging non-movable refs out of a minimized stack
- if (toDrag instanceof ViewPane) {
- ViewPane pane = (ViewPane) toDrag;
- if (!persp.isMoveable(pane.getViewReference()))
- return;
- }
-
- IViewReference oldFastView = null;
- if (persp != null) {
- oldFastView = persp.getActiveFastView();
-
- if (page != null) {
- page.hideFastView();
- }
- }
-
- if (page.isPageZoomed()) {
- page.zoomOut();
- }
-
- boolean success = DragUtil.performDrag(toDrag, dragRect, position,
- !usingKeyboard);
-
- // If the drag was cancelled, reopen the old fast view
- if (!success && oldFastView != null && page != null) {
- page.toggleFastView(oldFastView);
- }
- }
-}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/FastViewManager.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/FastViewManager.java
deleted file mode 100644
index 33f0244998e..00000000000
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/FastViewManager.java
+++ /dev/null
@@ -1,1086 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2010 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
- * Carlos Devoto carlos.devoto@compuware.com Bug 213645
- * Markus Alexander Kuppe, Versant Corporation - bug #215797
- * Semion Chichelnitsky (semion@il.ibm.com) - bug 278064
- *******************************************************************************/
-
-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.MultiStatus;
-import org.eclipse.jface.util.Geometry;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.ui.IMemento;
-import org.eclipse.ui.IPerspectiveDescriptor;
-import org.eclipse.ui.IPerspectiveListener2;
-import org.eclipse.ui.IViewReference;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.IWorkbenchPartReference;
-import org.eclipse.ui.internal.StartupThreading.StartupRunnable;
-import org.eclipse.ui.internal.layout.IWindowTrim;
-import org.eclipse.ui.internal.layout.LayoutUtil;
-import org.eclipse.ui.internal.layout.TrimLayout;
-import org.eclipse.ui.internal.presentations.PresentablePart;
-import org.eclipse.ui.internal.presentations.util.TabbedStackPresentation;
-import org.eclipse.ui.internal.tweaklets.Animations;
-import org.eclipse.ui.internal.tweaklets.Tweaklets;
-import org.eclipse.ui.internal.util.Util;
-import org.eclipse.ui.presentations.IPresentablePart;
-import org.eclipse.ui.presentations.IStackPresentationSite;
-
-/**
- * Manage all Fast views for a particular perspective. As of 3.3 fast views
- * appear in more than one manner (legacy FVB and Trim Stacks). The manager is
- * responsible for providing a single implementation for the methods relating to
- * fast views regardless of their UI presentation.
- *
- * @since 3.3
- *
- */
-public class FastViewManager {
- private Perspective perspective;
- private WorkbenchPage page;
- private WorkbenchWindow wbw;
- private TrimLayout tbm;
-
- /**
- * Maps a String to a list of IViewReferences. The string represents the
- * 'id' of either the legacy FBV or the ViewStack id of some stack which may
- * have elements in the trim.
- * <p>
- * NOTE: For TrimStacks, the order of the view ref's in the contained list
- * is the order in which they will appear in the tab folder when the stack
- * un-minimizes.
- * </p>
- */
- private Map idToFastViewsMap = new HashMap();
-
- /**
- * Batch update management
- */
- private boolean deferringUpdates = false;
-
- /**
- * animation whose life-cycle spans a
- * 'deferUpdates' cycle.
- */
- private AnimationEngine batchAnimation = null;
-
- /**
- * Used for non-deferred animations
- */
- private AnimationEngine oneShotAnimation = null;
- //private RectangleAnimation oneShotAnimation = null;
-
- private IPerspectiveListener2 perspListener = new IPerspectiveListener2() {
- public void perspectiveActivated(IWorkbenchPage page,
- IPerspectiveDescriptor perspective) {
- // Only listen for changes in -this- perspective
- if (FastViewManager.this.perspective.getDesc() == perspective)
- handlePerspectiveActivation(page, perspective);
- }
-
- public void perspectiveChanged(IWorkbenchPage changedPage,
- IPerspectiveDescriptor perspective,
- IWorkbenchPartReference partRef, String changeId) {
- // Only listen for changes in -this- perspective
- if (FastViewManager.this.perspective.getDesc() == perspective)
- handlePerspectiveChange(changedPage, perspective, partRef,
- changeId);
- }
-
- public void perspectiveChanged(IWorkbenchPage changedPage,
- IPerspectiveDescriptor perspective, String changeId) {
- // Only listen for changes in -this- perspective
- if (FastViewManager.this.perspective.getDesc() == perspective)
- handlePerspectiveChange(changedPage, perspective, changeId);
- }
- };
-
- /**
- * Creates a new manager for a particular perspective
- *
- * @param perspective
- * @param page
- */
- public FastViewManager(Perspective perspective, WorkbenchPage page) {
- this.perspective = perspective;
- this.page = page;
-
- // Access the trim manager for this window
- wbw = (WorkbenchWindow) page.getWorkbenchWindow();
- tbm = (TrimLayout) wbw.getTrimManager();
- }
-
- protected void handlePerspectiveActivation(IWorkbenchPage activatingPage,
- IPerspectiveDescriptor activatingPerspective) {
- // If this perspective is activating then update the
- // legacy FVB to show this perspective's refs
- if (activatingPage == page
- && perspective.getDesc() == activatingPerspective)
- updateTrim(FastViewBar.FASTVIEWBAR_ID);
- }
-
- protected void handlePerspectiveChange(IWorkbenchPage changedPage,
- IPerspectiveDescriptor changedPerspective,
- IWorkbenchPartReference partRef, String changeId) {
- // Only handle changes for our perspective
- if (changedPage != page && perspective.getDesc() != changedPerspective)
- return;
-
- if (changeId.equals(IWorkbenchPage.CHANGE_VIEW_HIDE)) {
- if (partRef instanceof ViewReference) {
- ViewReference ref = (ViewReference) partRef;
- if (ref.getPane().getContainer() instanceof ViewStack) {
- int viewCount = 0;
- LayoutPart[] children = ref.getPane().getContainer().getChildren();
- for (int i = 0; i < children.length; i++) {
- if (children[i] instanceof ViewPane && children[i] != ref.getPane())
- viewCount++;
- }
-
- if (viewCount == 0)
- ref.getPane().getStack().setState(IStackPresentationSite.STATE_RESTORED);
- }
- }
- }
-
- if (changeId.equals(IWorkbenchPage.CHANGE_FAST_VIEW_REMOVE)) {
- // Remove the view from any FV list that it may be in
- // Do this here since the view's controls may be about
- // to be disposed...
- removeViewReference((IViewReference) partRef, false, true);
- }
- }
-
- protected void handlePerspectiveChange(IWorkbenchPage changedPage,
- IPerspectiveDescriptor changedPerspective, String changeId) {
- }
-
- /**
- * @return The list of current fast views associated with the given id or
- * the complete list of fastviews if the id == null.
- */
- public List getFastViews(String forId) {
- List fvs = new ArrayList();
-
- Iterator mapIter = idToFastViewsMap.keySet().iterator();
- while (mapIter.hasNext()) {
- String id = (String) mapIter.next();
- if (forId == null || forId.equals(id)) {
- List fvList = (List) idToFastViewsMap.get(id);
- for (Iterator fvIter = fvList.iterator(); fvIter.hasNext();) {
- fvs.add(fvIter.next());
- }
- }
- }
-
- return fvs;
- }
-
- /**
- * Casues the given {@link IViewReference} to be added to the list
- * identified by the 'id' parameter. The reference is added at the specified
- * index or at the end if the index is -1. If there was a previous entry for
- * this ref it will be removed so that only the ref will only ever be in one
- * list at a time.
- * <p>
- * NOTE: The trim life-cycle is managed at the stack level so there -must-
- * be an entry in the map and a corresponding trim element before calling
- * this method,
- * </p>
- * <p>
- * The page/perspective are updated to make the view a fastview if
- * necessary.
- * </p>
- *
- * @param id
- * The id of the {@link IWindowTrim} that is to show the ref
- * @param index
- * The index to insert the ref at
- * @param ref
- * The {@link IViewReference} to add
- * @param update
- * cause the trim to update if <code>true</code>
- */
- public void addViewReference(String id, int index, IViewReference ref,
- boolean update) {
- if (id == null || ref == null)
- return;
-
- List fvList = (List) idToFastViewsMap.get(id);
- if (fvList == null) {
- // Not in the model yet, add it
- fvList = new ArrayList();
- idToFastViewsMap.put(id, fvList);
- }
-
- // bounds checking
- if (index < 0 || index > fvList.size())
- index = fvList.size();
-
- // Is it already in a list?
- String curLocation = getIdForRef(ref);
- if (curLocation != null) {
- // is it the same list that it's being added to?
- if (id.equals(curLocation)) {
- int curIndex = fvList.indexOf(ref);
- if (index == curIndex)
- return; // No-Op
-
- // If we're inserting after where we
- // were then decrement the index to
- // account for the removal of the old ref
- if (index > curIndex)
- index--;
- }
-
- // Remove it...
- removeViewReference(ref, false, true);
- } else {
- // It's not a fastview, make it one
- makeFast(ref, true, false);
- }
-
- fvList.add(index, ref);
-
- // Note that the update call will create and show the ViewStackTrimToolbar
- // if necessary
- if (update)
- updateTrim(id);
- }
-
- /**
- * Create the Trim element for the stack containing the given reference
- *
- * @param suggestedSide
- * @param paneOrientation
- * @param ref
- * The {@link IViewReference} whose stack needs trim creation.
- */
- private ViewStackTrimToolBar getTrimForViewStack(String id,
- int suggestedSide, int paneOrientation) {
- // Do we already have one??
- ViewStackTrimToolBar trim = (ViewStackTrimToolBar) tbm.getTrim(id);
- if (trim == null) {
- int cachedSide = tbm.getPreferredArea(id);
- if (cachedSide != -1)
- suggestedSide = cachedSide;
-
- IWindowTrim beforeMe = tbm.getPreferredLocation(id);
-
- trim = new ViewStackTrimToolBar(id, suggestedSide,
- paneOrientation, wbw);
- tbm.addTrim(suggestedSide, trim, beforeMe);
- updateTrim(trim.getId());
- }
-
- return trim;
- }
-
- /**
- * Causes the trim element associated with the id to synch itself with the
- * current list of views. This method will create a new ViewStackTrimToolbar
- * if necessary (i.e. on the first call after views have been added to the map)
- * and will also hide the trim element when the number of views in the mapped
- * list goes to zero.
- *
- * @param id
- * The id of the {@link IWindowTrim} to update
- */
- public void updateTrim(String id) {
- // Get the trim part from the trim manager
- IWindowTrim trim = tbm.getTrim(id);
-
- // If it's not there there's not much we can do
- if (trim == null)
- return;
-
- // If there are no fast views for the bar then hide it
- List fvs = (List) idToFastViewsMap.get(id);
- boolean hideEmptyFVB = WorkbenchPlugin.getDefault()
- .getPreferenceStore().getBoolean(IPreferenceConstants.FVB_HIDE);
- if ((fvs == null || fvs.size() == 0)
- && (!FastViewBar.FASTVIEWBAR_ID.equals(id) || hideEmptyFVB)) {
- if (trim.getControl().getVisible()) {
- tbm.setTrimVisible(trim, false);
- tbm.forceLayout();
- }
- return;
- }
-
- // Ensure that the trim is displayed
- if (!trim.getControl().getVisible()) {
- tbm.setTrimVisible(trim, true);
- }
-
- if (trim instanceof FastViewBar) {
- FastViewBar fvb = (FastViewBar) trim;
- fvb.update(true);
- } else if (trim instanceof ViewStackTrimToolBar) {
- ViewStackTrimToolBar vstb = (ViewStackTrimToolBar) trim;
- vstb.update(true);
- vstb.getControl().pack();
- LayoutUtil.resize(trim.getControl());
- }
-
- tbm.forceLayout();
- }
-
- /**
- * Remove the view reference from its existing location
- *
- * @param ref
- * The {@link IViewReference} to remove
- */
- public void removeViewReference(IViewReference ref, boolean makeUnfast, boolean update) {
- String id = getIdForRef(ref);
-
- if (id != null) {
- // Remove the ref
- List fvList = (List) idToFastViewsMap.get(id);
- fvList.remove(ref);
-
- if (makeUnfast)
- makeFast(ref, false, false);
-
- if (update)
- updateTrim(id);
- }
- }
-
- /**
- *
- * @param ref
- * @param makeFast
- * @param activate
- */
- private void makeFast(IViewReference ref, boolean makeFast, boolean activate) {
- if (ref == null || page == null)
- return;
-
- if (makeFast) {
- page.makeFastView(ref);
- } else {
- page.removeFastView(ref);
-
- if (activate) {
- IWorkbenchPart toActivate = ref.getPart(true);
- if (toActivate != null) {
- page.activate(toActivate);
- }
- }
- }
- }
-
- /**
- * @param ref
- * The IViewRference to check
- * @return true iff the ref is in -any- list
- */
- boolean isFastView(IViewReference ref) {
- return getIdForRef(ref) != null;
- }
-
- /**
- * @param ref
- * The IViewRference to check
- * @return The id of the trim bar currently showing the reference or
- * <code>null</code> if it's not in any list
- */
- public String getIdForRef(IViewReference ref) {
- Iterator mapIter = idToFastViewsMap.keySet().iterator();
- while (mapIter.hasNext()) {
- String id = (String) mapIter.next();
- List fvList = (List) idToFastViewsMap.get(id);
- if (fvList.contains(ref))
- return id;
- }
-
- return null;
- }
-
- /**
- * @return The side that the fast view pane should be attached to based on
- * the position of the trim element containing the ref.
- */
- public int getViewSide(IViewReference ref) {
- IWindowTrim trim = getTrimForRef(ref);
- if (trim == null)
- return SWT.BOTTOM;
-
- int curSide = SWT.BOTTOM;
- int paneOrientation = SWT.BOTTOM;
-
- if (trim instanceof ViewStackTrimToolBar) {
- curSide = ((ViewStackTrimToolBar) trim).getCurrentSide();
- paneOrientation = ((ViewStackTrimToolBar) trim)
- .getPaneOrientation();
- } else if (trim instanceof FastViewBar) {
- curSide = ((FastViewBar) trim).getSide();
- paneOrientation = ((FastViewBar) trim).getOrientation(ref);
- }
-
- // Get trim layout info
- Point trimCenter = Geometry.centerPoint(trim.getControl().getBounds());
- Point shellCenter = Geometry.centerPoint(trim.getControl().getShell()
- .getClientArea());
-
- // Horizontal has to snap to either TOP or BOTTOM...
- if (paneOrientation == SWT.HORIZONTAL) {
- if (curSide == SWT.TOP || curSide == SWT.BOTTOM)
- return curSide;
-
- // Are we on the top or bottom 'end' of the trim area?
- return (trimCenter.y < shellCenter.y) ? SWT.TOP : SWT.BOTTOM;
- }
-
- if (paneOrientation == SWT.VERTICAL) {
- if (curSide == SWT.LEFT || curSide == SWT.RIGHT)
- return curSide;
-
- // Are we on the left or right 'end' of the trim area?
- return (trimCenter.x < shellCenter.x) ? SWT.LEFT : SWT.RIGHT;
- }
-
- return SWT.BOTTOM;
- }
-
- /**
- * Return the trim element showing the given reference
- *
- * @param ref
- * The reference to find
- * @return the IWindowTrim showing the ref
- */
- private IWindowTrim getTrimForRef(IViewReference ref) {
- String id = getIdForRef(ref);
- if (id == null)
- return null; // Not in trim
-
- return tbm.getTrim(id);
- }
-
- /**
- * @return a List of <code>IViewReference</code> sorted into the order in
- * which they appear in the visual stack.
- */
- private List getTrueViewOrder(ViewStack stack) {
- List orderedViews = new ArrayList();
- IPresentablePart[] parts = null;
- if (stack.getPresentation() instanceof TabbedStackPresentation) {
- TabbedStackPresentation tsp = (TabbedStackPresentation) stack
- .getPresentation();
- // KLUDGE!! uses a 'testing only' API to get the parts in their 'visible' order
- parts = tsp.getPartList();
- }
-
- // If we didn't get the parts from the tab list then try the presentable part API
- // ViewStack's declared 'no title' fail the call above, returning an empty array
- if (parts == null || parts.length == 0){
- // We'll have to process the parts in the order given...
- // This is certain to fail on drag re-ordering of the
- // icons in the trim since we have no API to inform the
- // custom presentation
- List partList = stack.getPresentableParts();
- parts = (IPresentablePart[]) partList.toArray(new IPresentablePart[partList.size()]);
- }
-
- // Now, process the parts...
- 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;
- }
-
- public void moveToTrim(ViewStack vs, boolean restoreOnUnzoom) {
- // Don't do anything when initializing...
- if (vs.getBounds().width == 0)
- return; // indicates that we're startin up
-
- // If we're part of a 'maximize' operation then use the cached
- // bounds...
- Rectangle stackBounds = perspective.getPresentation().getCachedBoundsFor(vs.getID());
-
- // OK, no cache means that we use the current stack position
- if (stackBounds == null)
- stackBounds = vs.getBounds();
-
- int paneOrientation = (stackBounds.width > stackBounds.height) ? SWT.HORIZONTAL
- : SWT.VERTICAL;
-
- // Remember the tab that was selected when we minimized
- String selId = ""; //$NON-NLS-1$
- PartPane selectedTab = vs.getSelection();
- if (selectedTab != null)
- selId = selectedTab.getCompoundId();
-
- vs.deferUpdates(true);
-
- // animate the minimize
- RectangleAnimationFeedbackBase animation = (RectangleAnimationFeedbackBase) getDeferrableAnimation().getFeedback();
- animation.addStartRect(vs.getControl());
-
- //long startTick = System.currentTimeMillis();
- // Update the model first
- List toMove = getTrueViewOrder(vs);
- if (toMove.isEmpty()) {
- // We are dealing with an empty durable ViewStack; hide it!
- vs.dispose();
- ILayoutContainer parentContainer = vs.getContainer();
- ContainerPlaceholder placeholder = new ContainerPlaceholder(vs
- .getID());
- placeholder.setRealContainer(vs);
- parentContainer.replace(vs, placeholder);
-
- } else {
- for (Iterator viewIter = toMove.iterator(); viewIter.hasNext();) {
- IViewReference ref = (IViewReference) viewIter.next();
- addViewReference(vs.getID(), -1, ref, false);
- }
- }
- vs.deferUpdates(false);
-
- // Find (or create) the trim stack to move to
- ViewStackTrimToolBar vstb = getTrimForViewStack(vs.getID(), perspective
- .calcStackSide(stackBounds), paneOrientation);
- vstb.setRestoreOnUnzoom(restoreOnUnzoom);
- vstb.setSelectedTabId(selId);
- if (toMove.isEmpty()) {
- // We are dealing with an empty durable ViewStack; show the trim!
- IWindowTrim trim = vstb;
-
- // Ensure that the trim is displayed
- if (!trim.getControl().getVisible()) {
- tbm.setTrimVisible(trim, true);
- }
-
- if (trim instanceof FastViewBar) {
- FastViewBar fvb = (FastViewBar) trim;
- fvb.update(true);
- } else if (trim instanceof ViewStackTrimToolBar) {
- vstb.update(true);
- vstb.getControl().pack();
- LayoutUtil.resize(trim.getControl());
- }
- tbm.forceLayout();
- } else {
- updateTrim(vstb.getId());
- }
-
- //System.out.println("minimize time: " + (System.currentTimeMillis()-startTick)); //$NON-NLS-1$
- if (vstb != null) {
- animation.addEndRect(vstb.getControl());
- scheduleDeferrableAnimation();
- }
- }
-
- /**
- * Restore the trim element representing a ViewStack back into the
- * presentation.
- *
- * @param viewStackTrimToolBar
- * The trim version to restore
- */
- public void restoreToPresentation(String id) {
- ViewStackTrimToolBar vstb = getViewStackTrimToolbar(id);
-
- // The IntroPart uses the old min/max behavior; ensure that
- // we were really a minimized trim stack
- if (vstb == null)
- return;
-
- // remove any showing fast view
- page.hideFastView();
-
- // The stored id may be 'compound' if it's a multi-instance
- // view; split out the secondary id (if any)
- String selectedTabId = vstb.getSelectedTabId();
- String[] idParts = Util.split(selectedTabId, ':');
- String secondaryId = null;
- if (idParts[0].length() != selectedTabId.length())
- secondaryId = idParts[1];
-
- List fvs = getFastViews(id);
-
- // Check for 'durable' folders
- boolean isDurable = false;
- if (perspective.getDesc() != null) {
- isDurable = page.window.getWindowAdvisor().isDurableFolder(
- perspective.getDesc().getId(), id);
- }
- if (fvs.isEmpty() && isDurable) {
- // We are dealing with a durable view stack that is currently empty, so execute special logic to restore it from the minimized state
- LayoutPart part = perspective.getPresentation().findPart(id, null);
- if (part instanceof ContainerPlaceholder) {
- ContainerPlaceholder containerPlaceholder = (ContainerPlaceholder) part;
- ILayoutContainer parentContainer = containerPlaceholder
- .getContainer();
- ILayoutContainer container = (ILayoutContainer) containerPlaceholder
- .getRealContainer();
- if (container instanceof LayoutPart) {
- parentContainer.replace(containerPlaceholder,
- (LayoutPart) container);
- }
- containerPlaceholder.setRealContainer(null);
- IWindowTrim trim = tbm.getTrim(id);
-
- // If it's not there there's not much we can do
- if (trim == null)
- return;
-
- // Hide the trim
- if (trim.getControl().getVisible()) {
- tbm.setTrimVisible(trim, false);
- tbm.forceLayout();
- }
- }
- return;
- }
-
- for (Iterator fvIter = fvs.iterator(); fvIter.hasNext();) {
- IViewReference ref = (IViewReference) fvIter.next();
- removeViewReference(ref, true, !fvIter.hasNext());
- }
-
- // Restore the correct tab to the 'top'
- LayoutPart stack = perspective.getPresentation().findPart(id, null);
- if (stack instanceof PartStack) {
- LayoutPart selTab = perspective.getPresentation().findPart(idParts[0], secondaryId);
- if (selTab instanceof PartPane && selTab instanceof ViewPane) {
- ((PartStack)stack).setSelection(selTab);
-
- // activate the view if we're not doing a compound operation
- if (!deferringUpdates)
- ((ViewPane)selTab).requestActivation();
- }
- }
-
- // Hide the Trim
- updateTrim(id);
- }
-
- /**
- * Restore all fact view stacks created as part of a zoom
- */
- public void restoreZoomedViewStacks() {
- Iterator mapIter = idToFastViewsMap.keySet().iterator();
- while (mapIter.hasNext()) {
- String id = (String) mapIter.next();
- IWindowTrim trim = tbm.getTrim(id);
- if (trim != null && trim instanceof ViewStackTrimToolBar) {
- ViewStackTrimToolBar vstb = (ViewStackTrimToolBar) trim;
- if (vstb.restoreOnUnzoom())
- restoreToPresentation(vstb.getId());
- }
- }
- }
-
- /**
- * @param ref
- * Sets the ref of the icon
- * @param selected
- * the selection state of the icon
- */
- public void setFastViewIconSelection(IViewReference ref, boolean selected) {
- String id = getIdForRef(ref);
- IWindowTrim trim = tbm.getTrim(id);
- if (trim instanceof ViewStackTrimToolBar) {
- ViewStackTrimToolBar vstb = (ViewStackTrimToolBar) trim;
- vstb.setIconSelection(ref, selected);
- } else if (trim instanceof FastViewBar) {
- FastViewBar fvb = (FastViewBar) trim;
- if (selected) {
- fvb.setSelection(ref);
- } else {
- if (ref == fvb.getSelection()) {
- fvb.setSelection(null);
- }
- }
- }
-
- }
-
- /**
- * Activate the manager. Called from the Perspecive's 'onActivate'
- */
- public void activate() {
- wbw.addPerspectiveListener(perspListener);
- setTrimStackVisibility(true);
- }
-
- /**
- * Activate the manager. Called from the Perspecive's 'onActivate'
- */
- public void deActivate() {
- wbw.removePerspectiveListener(perspListener);
- setTrimStackVisibility(false);
- }
-
- /**
- * Restore any trim stacks. This method is used when the presentation
- * is switched back to 3.0; if we aren't using the new min/max story
- * then we shouldn't -have- any trim stacks.
- */
- public boolean restoreAllTrimStacks() {
- boolean stacksWereRestored = false;
-
- Iterator mapIter = idToFastViewsMap.keySet().iterator();
- while (mapIter.hasNext()) {
- String id = (String) mapIter.next();
-
- // Skip the legacy FstViewBar
- if (id.equals(FastViewBar.FASTVIEWBAR_ID))
- continue;
-
- // Restore the views
- List fvs = getFastViews(id);
- for (Iterator fvIter = fvs.iterator(); fvIter.hasNext();) {
- IViewReference ref = (IViewReference) fvIter.next();
- removeViewReference(ref, true, !fvIter.hasNext());
- }
-
- // Blow the trim away
- IWindowTrim trim = tbm.getTrim(id);
- if (trim != null && trim instanceof ViewStackTrimToolBar) {
- tbm.removeTrim(trim);
- trim.getControl().dispose();
-
- stacksWereRestored = true;
- }
- }
-
- tbm.forceLayout();
-
- return stacksWereRestored;
- }
-
- /**
- * Show all non-empty trim stacks. Create the stack if necessary
- */
- private void setTrimStackVisibility(boolean visible) {
- Iterator mapIter = idToFastViewsMap.keySet().iterator();
- while (mapIter.hasNext()) {
- String id = (String) mapIter.next();
- List fvs = getFastViews(id);
-
- // Never show 'empty' stacks
- if (visible && fvs.size() == 0)
- continue;
-
- IWindowTrim trim = tbm.getTrim(id);
- if (trim != null && trim instanceof ViewStackTrimToolBar) {
- ((ViewStackTrimToolBar)trim).update(true);
- tbm.setTrimVisible(trim, visible);
- }
- }
- }
-
- public void saveState(IMemento memento) {
- // Output legacy fastviews
- FastViewBar fvb = wbw.getFastViewBar();
- if (fvb != null) {
- List fvRefs = getFastViews(FastViewBar.FASTVIEWBAR_ID);
- if (fvRefs.size() > 0) {
- IMemento childMem = memento
- .createChild(IWorkbenchConstants.TAG_FAST_VIEWS);
- Iterator itr = fvRefs.iterator();
- while (itr.hasNext()) {
- IViewReference ref = (IViewReference) itr.next();
- boolean restorable = page.getViewFactory()
- .getViewRegistry().find(ref.getId()).isRestorable();
- if(restorable) {
- IMemento viewMemento = childMem
- .createChild(IWorkbenchConstants.TAG_VIEW);
- String id = ViewFactory.getKey(ref);
- viewMemento.putString(IWorkbenchConstants.TAG_ID, id);
- float ratio = perspective.getFastViewWidthRatio(ref);
- viewMemento.putFloat(IWorkbenchConstants.TAG_RATIO, ratio);
- }
- }
- }
- }
-
- // Write all the current (non-empty) bars
- IMemento barsMemento = memento
- .createChild(IWorkbenchConstants.TAG_FAST_VIEW_BARS);
-
- Iterator mapIter = idToFastViewsMap.keySet().iterator();
- while (mapIter.hasNext()) {
- String id = (String) mapIter.next();
-
- // Legacy FV's are stored above...
- if (FastViewBar.FASTVIEWBAR_ID.equals(id))
- continue;
-
- List fvs = getFastViews(id);
- if (fvs.size() > 0) {
- IMemento barMemento = barsMemento
- .createChild(IWorkbenchConstants.TAG_FAST_VIEW_BAR);
- barMemento.putString(IWorkbenchConstants.TAG_ID, id);
-
- // Orientation / restore
- ViewStackTrimToolBar vstb = (ViewStackTrimToolBar) tbm
- .getTrim(id);
- if (vstb != null) {
- barMemento.putInteger(
- IWorkbenchConstants.TAG_FAST_VIEW_SIDE,
- vstb.getCurrentSide());
-
- barMemento.putInteger(
- IWorkbenchConstants.TAG_FAST_VIEW_ORIENTATION,
- vstb.getPaneOrientation());
-
- int boolVal = vstb.restoreOnUnzoom() ? 1 : 0;
- barMemento.putInteger(IWorkbenchConstants.TAG_FAST_VIEW_STYLE, boolVal);
-
- barMemento.putString(IWorkbenchConstants.TAG_FAST_VIEW_SEL_ID, vstb.getSelectedTabId());
- }
-
- IMemento viewsMem = barMemento
- .createChild(IWorkbenchConstants.TAG_FAST_VIEWS);
- Iterator itr = fvs.iterator();
- while (itr.hasNext()) {
- IMemento refMem = viewsMem
- .createChild(IWorkbenchConstants.TAG_VIEW);
- IViewReference ref = (IViewReference) itr.next();
-
- // id
- String viewId = ViewFactory.getKey(ref);
- refMem.putString(IWorkbenchConstants.TAG_ID, viewId);
-
- // width ratio
- float ratio = perspective.getFastViewWidthRatio(ref);
- refMem.putFloat(IWorkbenchConstants.TAG_RATIO, ratio);
- }
- }
- }
- }
-
- public void restoreState(IMemento memento, MultiStatus result) {
- // Load the fast views
- IMemento fastViewsMem = memento
- .getChild(IWorkbenchConstants.TAG_FAST_VIEWS);
-
- // -Replace- the current list with the one from the store
- List refsList = new ArrayList();
- idToFastViewsMap.put(FastViewBar.FASTVIEWBAR_ID, refsList);
-
- if (fastViewsMem != null) {
- IMemento[] views = fastViewsMem
- .getChildren(IWorkbenchConstants.TAG_VIEW);
- for (int x = 0; x < views.length; x++) {
- // Get the view details.
- IMemento childMem = views[x];
- IViewReference ref = perspective.restoreFastView(childMem,
- result);
- if (ref != null)
- refsList.add(ref);
- }
- }
-
- // Load the Trim Stack info
- IMemento barsMem = memento
- .getChild(IWorkbenchConstants.TAG_FAST_VIEW_BARS);
-
- // It's not there for old workspaces
- if (barsMem == null)
- return;
-
- IMemento[] bars = barsMem
- .getChildren(IWorkbenchConstants.TAG_FAST_VIEW_BAR);
- for (int i = 0; i < bars.length; i++) {
- final String id = bars[i].getString(IWorkbenchConstants.TAG_ID);
- fastViewsMem = bars[i].getChild(IWorkbenchConstants.TAG_FAST_VIEWS);
-
- // -Replace- the current list with the one from the store
- refsList = new ArrayList();
- idToFastViewsMap.put(id, refsList);
-
- if (fastViewsMem != null) {
- IMemento[] views = fastViewsMem
- .getChildren(IWorkbenchConstants.TAG_VIEW);
- result.merge(perspective.createReferences(views));
-
- // Create the trim area for the trim stack
- // Only create the TB if there are views in it
- if (views.length > 0) {
- final int side = bars[i].getInteger(
- IWorkbenchConstants.TAG_FAST_VIEW_SIDE)
- .intValue();
- final int orientation = bars[i].getInteger(
- IWorkbenchConstants.TAG_FAST_VIEW_ORIENTATION)
- .intValue();
- int boolVal = bars[i].getInteger(
- IWorkbenchConstants.TAG_FAST_VIEW_STYLE).intValue();
- final boolean restoreOnUnzoom = (boolVal > 0);
-
- final String selId = bars[i].getString(IWorkbenchConstants.TAG_FAST_VIEW_SEL_ID);
-
- // Create the stack
- StartupThreading.runWithoutExceptions(new StartupRunnable() {
- public void runWithException() throws Throwable {
- ViewStackTrimToolBar vstb = getTrimForViewStack(id, side, orientation);
- vstb.setRestoreOnUnzoom(restoreOnUnzoom);
- if (selId != null)
- vstb.setSelectedTabId(selId);
- }
- });
- }
-
- for (int x = 0; x < views.length; x++) {
- // Get the view details.
- IMemento childMem = views[x];
- IViewReference ref = perspective.restoreFastView(childMem,
- result);
- if (ref != null)
- refsList.add(ref);
- }
- }
- }
- }
-
- /**
- * Returns the trim element for the given id if it exists. This
- * will not be <code>null</code> if there are entries in the
- * 'idToFastViewsMap' for this id.
- *
- * @param id The id of the view stack to get the trim toolbar for.
- */
- public ViewStackTrimToolBar getViewStackTrimToolbar(String id) {
- return (ViewStackTrimToolBar) tbm.getTrim(id);
- }
-
- public void printFVModel() {
- Iterator mapIter = idToFastViewsMap.keySet().iterator();
- while (mapIter.hasNext()) {
- String id = (String) mapIter.next();
- List fvList = (List) idToFastViewsMap.get(id);
- System.out.println("FastView: " + id + " count = " + fvList.size()); //$NON-NLS-1$//$NON-NLS-2$
- for (Iterator fvIter = fvList.iterator(); fvIter.hasNext();) {
- IViewReference ref = (IViewReference) fvIter.next();
- System.out.println(" Ref: " + ref.getId()); //$NON-NLS-1$
- }
- }
- }
-
- /**
- * Informs the manager that a batch operation has started
- * (say 'maximize', where many stacks will change state).
- *
- * @param defer
- * true when starting a batch operation
- * false when ending the operation
- */
- public void deferUpdates(boolean defer) {
- if (defer == deferringUpdates)
- return;
-
- deferringUpdates = defer;
- deferAnimations(deferringUpdates);
- }
-
- /**
- * When 'defer' is true we create a RectangleAnimation object
- * to be used for any desired feedback. When ending it
- * schedules the animation and resets.
- *
- * @param defer
- * true when starting a batch operation
- * false when ending the operation
- */
- private void deferAnimations(boolean defer) {
- if (defer) {
- RectangleAnimationFeedbackBase feedback = ((Animations) Tweaklets
- .get(Animations.KEY)).createFeedback(wbw.getShell());
- batchAnimation = new AnimationEngine(feedback, 400);
- return;
- }
-
- if (batchAnimation != null)
- batchAnimation.schedule();
- batchAnimation = null;
- }
-
- /**
- * Returns the animation object appropriate for the deferred state
- * @return Either a 'one-shot' or a 'batch' animation object
- */
- private AnimationEngine getDeferrableAnimation() {
- if (deferringUpdates)
- return batchAnimation;
-
- // Create a 'one-shot' animation
- RectangleAnimationFeedbackBase feedback = ((Animations) Tweaklets
- .get(Animations.KEY)).createFeedback(wbw.getShell());
- oneShotAnimation = new AnimationEngine(feedback, 400);
- return oneShotAnimation;
- }
-
- private void scheduleDeferrableAnimation() {
- if (deferringUpdates)
- return;
-
- // We can only schedule the 'one-shot' animations
- // the batch ones are sheduled at batch end
- if (oneShotAnimation != null)
- oneShotAnimation.schedule();
- oneShotAnimation = null;
- }
-
- /**
- * Returns the 'bottom/right' trim stack. This is used to
- * match the old behavior when opening a new view that has no placeholder
- * in the case where there WB is maximized.
- *
- * @return The 'bottom/right' trim stack or null if there are no
- * defined trim stacks
- */
- public ViewStackTrimToolBar getBottomRightTrimStack() {
- ViewStackTrimToolBar blTrimStack = null;
- Point blPt = new Point(0,0);
-
- Iterator mapIter = idToFastViewsMap.keySet().iterator();
- while (mapIter.hasNext()) {
- String id = (String) mapIter.next();
-
- // Skip the legacy FstViewBar
- if (id.equals(FastViewBar.FASTVIEWBAR_ID))
- continue;
-
- if (getFastViews(id).size() > 0) {
- // if we have views in the model then 'vstt' will not be null
- ViewStackTrimToolBar vstt = getViewStackTrimToolbar(id);
- Point loc = vstt.getControl().getLocation();
- if (loc.y > blPt.y || (loc.y == blPt.y && loc.x > blPt.x)) {
- blPt = loc;
- blTrimStack = vstt;
- }
- }
- }
-
- return blTrimStack;
- }
-}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/FastViewPane.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/FastViewPane.java
deleted file mode 100644
index 8610f761cc3..00000000000
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/FastViewPane.java
+++ /dev/null
@@ -1,641 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2008 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
- * Chris Gross chris.gross@us.ibm.com Bug 107443
- * Matthew Hatem Matthew_Hatem@notesdev.ibm.com Bug 189953
- *******************************************************************************/
-package org.eclipse.ui.internal;
-
-import org.eclipse.jface.action.ContributionItem;
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.jface.util.Geometry;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.FocusAdapter;
-import org.eclipse.swt.events.FocusEvent;
-import org.eclipse.swt.events.KeyAdapter;
-import org.eclipse.swt.events.KeyEvent;
-import org.eclipse.swt.events.KeyListener;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.Listener;
-import org.eclipse.swt.widgets.Sash;
-import org.eclipse.swt.widgets.ToolBar;
-import org.eclipse.ui.ISizeProvider;
-import org.eclipse.ui.IViewReference;
-import org.eclipse.ui.IWorkbenchPartReference;
-import org.eclipse.ui.internal.dnd.DragUtil;
-import org.eclipse.ui.internal.presentations.PresentablePart;
-import org.eclipse.ui.internal.presentations.SystemMenuFastView;
-import org.eclipse.ui.internal.presentations.SystemMenuFastViewOrientation;
-import org.eclipse.ui.internal.presentations.SystemMenuSizeFastView;
-import org.eclipse.ui.internal.presentations.UpdatingActionContributionItem;
-import org.eclipse.ui.presentations.AbstractPresentationFactory;
-import org.eclipse.ui.presentations.IPresentablePart;
-import org.eclipse.ui.presentations.IStackPresentationSite;
-import org.eclipse.ui.presentations.StackPresentation;
-
-/**
- * Handles the presentation of an active fastview. A fast view pane docks to one side of a
- * parent composite, and is capable of displaying a single view. The view may be resized.
- * Displaying a new view will hide any view currently being displayed in the pane.
- *
- * Currently, the fast view pane does not own or contain the view. It only controls the view's
- * position and visibility.
- *
- * @see org.eclipse.ui.internal.FastViewBar
- */
-public class FastViewPane {
- private int side = SWT.LEFT;
-
- private PresentablePart currentPane;
-
- private Composite clientComposite;
-
- private int minSize = 10;
-
- private int size;
-
- private Sash sash;
-
- private AbstractPresentationFactory presFactory;
-
- // Traverse listener -- listens to ESC and closes the active fastview
- private Listener escapeListener = new Listener() {
- public void handleEvent(Event event) {
- if (event.character == SWT.ESC) {
- if (currentPane != null) {
- currentPane.getPane().getPage().hideFastView();
- }
- }
- }
- };
-
- private DefaultStackPresentationSite site = new DefaultStackPresentationSite() {
- /* (non-Javadoc)
- * @see org.eclipse.ui.internal.skins.IPresentationSite#setState(int)
- */
- public void setState(int newState) {
- super.setState(newState);
- PartPane pane = currentPane.getPane();
- switch (newState) {
- case IStackPresentationSite.STATE_MINIMIZED:
-
- pane.getPage().hideFastView();
- break;
- case IStackPresentationSite.STATE_MAXIMIZED:
- pane.setZoomed(true);
- sash.setVisible(false);
- this.getPresentation().setBounds(getBounds());
- break;
- case IStackPresentationSite.STATE_RESTORED:
- pane.setZoomed(false);
- sash.setVisible(true);
- this.getPresentation().setBounds(getBounds());
- break;
- default:
- }
- }
-
- public void flushLayout() {
-
- }
-
- public void close(IPresentablePart part) {
- if (!isCloseable(part)) {
- return;
- }
- IWorkbenchPartReference ref = currentPane.getPane().getPartReference();
- if (ref instanceof IViewReference) {
- currentPane.getPane().getPage().hideView((IViewReference)ref);
- }
- }
-
- public void close(IPresentablePart[] parts) {
- for (int idx = 0; idx < parts.length; idx++) {
- close(parts[idx]);
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.internal.skins.IPresentationSite#dragStart(org.eclipse.ui.internal.skins.IPresentablePart, boolean)
- */
- public void dragStart(IPresentablePart beingDragged,
- Point initialPosition, boolean keyboard) {
- dragStart(initialPosition, keyboard);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.internal.skins.IPresentationSite#dragStart(boolean)
- */
- public void dragStart(Point initialPosition, boolean keyboard) {
- if (!isPartMoveable()) {
- return;
- }
-
- PartPane pane = currentPane.getPane();
-
- Control control = this.getPresentation().getControl();
-
- Rectangle bounds = Geometry.toDisplay(clientComposite, control
- .getBounds());
-
- WorkbenchPage page = pane.getPage();
-
- page.hideFastView();
- if (page.isZoomed()) {
- page.zoomOut();
- }
-
- DragUtil.performDrag(pane, bounds, initialPosition, !keyboard);
- }
-
- public IPresentablePart getSelectedPart() {
- return currentPane;
- }
-
- public void addSystemActions(IMenuManager menuManager) {
- ViewStackTrimToolBar vstt = getTrim();
-
- appendToGroupIfPossible(menuManager,
- "misc", new SystemMenuFastViewOrientation(currentPane.getPane(), vstt)); //$NON-NLS-1$
-
- // Only add the 'Fast View' menu entry if the
- // pane is showing a 'legacy' fast view
- if (vstt == null) {
- appendToGroupIfPossible(menuManager,
- "misc", new UpdatingActionContributionItem(fastViewAction)); //$NON-NLS-1$
- }
-
- appendToGroupIfPossible(menuManager,
- "size", new SystemMenuSizeFastView(FastViewPane.this)); //$NON-NLS-1$
- }
-
- /**
- * Returns the ViewStackTrimToolBar which has caused the FV to be shown. If
- * <code>null</code> then we can assume it was the legacy FastViewBar.
- */
- private ViewStackTrimToolBar getTrim() {
- if (currentPane == null || currentPane.getPane() == null)
- return null;
-
- ViewStackTrimToolBar trim = null;
-
- PartPane pane = currentPane.getPane();
- if (pane instanceof ViewPane) {
- ViewPane vp = (ViewPane) pane;
- Perspective persp = vp.getPage().getActivePerspective();
- IViewReference viewRef = vp.getViewReference();
- FastViewManager fvm = persp.getFastViewManager();
-
- String trimId = null;
- if (fvm != null)
- trimId = fvm.getIdForRef(viewRef);
-
- if (trimId != null && !trimId.equals(FastViewBar.FASTVIEWBAR_ID))
- trim = fvm.getViewStackTrimToolbar(trimId);
- }
-
- return trim;
- }
-
- public boolean isPartMoveable(IPresentablePart toMove) {
- return isPartMoveable();
- }
-
- public boolean isStackMoveable() {
- // a fast view stack is moveable iff its part is moveable
- return isPartMoveable();
- }
-
- private boolean isPartMoveable() {
- if (currentPane == null) {
- return false;
- }
- Perspective perspective = currentPane.getPane().getPage()
- .getActivePerspective();
- if (perspective == null) {
- // Shouldn't happen -- can't have a FastViewPane without a perspective
- return false;
- }
-
- IWorkbenchPartReference ref = currentPane.getPane().getPartReference();
-
- if (ref instanceof IViewReference) {
- return perspective.isMoveable((IViewReference)ref);
- }
- return true;
- }
-
- public boolean supportsState(int newState) {
- if (currentPane == null) {
- return false;
- }
- if (currentPane.getPane().getPage().isFixedLayout()) {
- return false;
- }
- return true;
- }
-
- public IPresentablePart[] getPartList() {
- return new IPresentablePart[] {getSelectedPart()};
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.presentations.IStackPresentationSite#getProperty(java.lang.String)
- */
- public String getProperty(String id) {
- // fast views stacks do not get arbitrary user properties.
- return null;
- }
- };
-
- private SystemMenuFastView fastViewAction = new SystemMenuFastView(site);
-
- private static void appendToGroupIfPossible(IMenuManager m, String groupId,
- ContributionItem item) {
- try {
- m.appendToGroup(groupId, item);
- } catch (IllegalArgumentException e) {
- m.add(item);
- }
- }
-
- private Listener mouseDownListener = new Listener() {
- public void handleEvent(Event event) {
- if (event.widget instanceof Control) {
- Control control = (Control) event.widget;
-
- if (control.getShell() != clientComposite.getShell()) {
- return;
- }
-
- if (event.widget instanceof ToolBar) {
- // Ignore mouse down on actual tool bar buttons
- Point pt = new Point(event.x, event.y);
- ToolBar toolBar = (ToolBar) event.widget;
- if (toolBar.getItem(pt) != null) {
- return;
- }
- }
-
- Point loc = DragUtil.getEventLoc(event);
-
- // 'Extrude' the rect -before- converting to Display coords
- // to avoid Right-to-Left issues
- Rectangle bounds = clientComposite.getBounds();
- if (site.getState() != IStackPresentationSite.STATE_MAXIMIZED) {
- bounds = Geometry.getExtrudedEdge(bounds, size + getSashSize(), side);
- }
-
- // Now map the bounds to display coords
- bounds = clientComposite.getDisplay().map(clientComposite, null, bounds);
-
- if (!bounds.contains(loc)) {
- site.setState(IStackPresentationSite.STATE_MINIMIZED);
- }
- }
- }
- };
-
- public void moveSash() {
- final KeyListener listener = new KeyAdapter() {
- public void keyPressed(KeyEvent e) {
- if (e.character == SWT.ESC || e.character == '\r') {
- currentPane.setFocus();
- }
- }
- };
- sash.addFocusListener(new FocusAdapter() {
- public void focusGained(FocusEvent e) {
- sash.setBackground(sash.getDisplay().getSystemColor(
- SWT.COLOR_LIST_SELECTION));
- sash.addKeyListener(listener);
- }
-
- public void focusLost(FocusEvent e) {
- sash.setBackground(null);
- sash.removeKeyListener(listener);
- }
- });
- sash.setFocus();
- }
-
- private Listener resizeListener = new Listener() {
- public void handleEvent(Event event) {
- if (event.type == SWT.Resize && currentPane != null) {
- setSize(size);
- }
- }
- };
-
- private SelectionAdapter selectionListener = new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
-
- if (currentPane != null) {
- Rectangle bounds = clientComposite.getClientArea();
- Point location = new Point(e.x, e.y);
- int distanceFromEdge = Geometry.getDistanceFromEdge(bounds,
- location, side);
-
- if (!(side == SWT.TOP || side == SWT.LEFT)) {
- distanceFromEdge -= getSashSize();
- }
-
- setSize(distanceFromEdge);
-
- if (e.detail != SWT.DRAG) {
- updateFastViewSashBounds();
- // getPresentation().getControl().moveAbove(null);
- // currentPane.moveAbove(null);
- // sash.moveAbove(null);
- //currentPane.getControl().redraw();
- sash.redraw();
- }
- }
- }
- };
-
- private void setSize(int size) {
-
- if (size < minSize) {
- size = minSize;
- }
- this.size = size;
-
- StackPresentation presentation = getPresentation();
- if (presentation == null || presentation.getControl().isDisposed()) {
- return;
- }
- getPresentation().setBounds(getBounds());
- updateFastViewSashBounds();
- }
-
- /**
- * Returns the current fastview size ratio. Returns 0.0 if there is no fastview visible.
- */
- public float getCurrentRatio() {
- if (currentPane == null) {
- return 0.0f;
- }
-
- boolean isVertical = !Geometry.isHorizontal(side);
- Rectangle clientArea = clientComposite.getClientArea();
-
- int clientSize = Geometry.getDimension(clientArea, isVertical);
-
- return (float) size / (float) clientSize;
- }
-
- private Rectangle getClientArea() {
- return clientComposite.getClientArea();
- }
-
- private Rectangle getBounds() {
- Rectangle bounds = getClientArea();
-
- if (site.getState() == IStackPresentationSite.STATE_MAXIMIZED) {
- return bounds;
- }
-
- boolean horizontal = Geometry.isHorizontal(side);
-
- int available = Geometry.getDimension(bounds, !horizontal);
-
- return Geometry.getExtrudedEdge(bounds, Math.min(
- FastViewPane.this.size, available), side);
- }
-
- /**
- * Displays the given view as a fastview. The view will be docked to the edge of the
- * given composite until it is subsequently hidden by a call to hideFastView.
- *
- * @param newClientComposite
- * @param pane
- * @param newSide
- */
- public void showView(Composite newClientComposite, ViewPane pane,
- int newSide, float sizeRatio) {
- side = newSide;
-
- if (currentPane != null) {
- hideView();
- }
-
- currentPane = new PresentablePart(pane, newClientComposite);
-
- fastViewAction.setPane(currentPane);
- clientComposite = newClientComposite;
-
- clientComposite.addListener(SWT.Resize, resizeListener);
-
- // Create the control first
- Control ctrl = pane.getControl();
- if (ctrl == null) {
- pane.createControl(clientComposite);
- ctrl = pane.getControl();
- }
-
- ctrl.addListener(SWT.Traverse, escapeListener);
-
- // Temporarily use the same appearance as docked views .. eventually, fastviews will
- // be independently pluggable.
- AbstractPresentationFactory factory = getPresentationFactory();
- StackPresentation presentation = factory.createViewPresentation(
- newClientComposite, site);
-
- site.setPresentation(presentation);
- site.setPresentationState(IStackPresentationSite.STATE_RESTORED);
- presentation.addPart(currentPane, null);
- presentation.selectPart(currentPane);
- presentation.setActive(StackPresentation.AS_ACTIVE_FOCUS);
- presentation.setVisible(true);
-
- boolean horizontalResize = Geometry.isHorizontal(side);
-
- minSize = presentation.computePreferredSize(horizontalResize,
- ISizeProvider.INFINITE,
- Geometry.getDimension(getClientArea(), horizontalResize),
- 0);
-
- // Show pane fast.
- ctrl.setEnabled(true); // Add focus support.
- Composite parent = ctrl.getParent();
-
- boolean horizontal = Geometry.isHorizontal(side);
-
- // Create a sash of the correct style using the factory
- int style = AbstractPresentationFactory.SASHTYPE_FLOATING;
- if (horizontal)
- style |= AbstractPresentationFactory.SASHORIENTATION_HORIZONTAL;
- else
- style |= AbstractPresentationFactory.SASHORIENTATION_VERTICAL;
- sash = factory.createSash(parent, style);
-
- sash.addSelectionListener(selectionListener);
-
- Rectangle clientArea = newClientComposite.getClientArea();
-
- getPresentation().getControl().moveAbove(null);
- currentPane.getPane().moveAbove(null);
- sash.moveAbove(null);
-
- setSize((int) (Geometry.getDimension(clientArea, !horizontal) * sizeRatio));
-
- Display display = sash.getDisplay();
-
- display.addFilter(SWT.MouseDown, mouseDownListener);
-
- pane.setFocus();
- }
-
- /**
- * Updates the position of the resize sash.
- */
- private void updateFastViewSashBounds() {
- Rectangle bounds = getBounds();
-
- int oppositeSide = Geometry.getOppositeSide(side);
- Rectangle newBounds = Geometry.getExtrudedEdge(bounds, -getSashSize(),
- oppositeSide);
-
- Rectangle oldBounds = sash.getBounds();
-
- if (!newBounds.equals(oldBounds)) {
- sash.setBounds(newBounds);
- }
- }
-
- /**
- * Disposes of any active widgetry being used for the fast view pane. Does not dispose
- * of the view itself.
- */
- public void dispose() {
- hideView();
- }
-
- private StackPresentation getPresentation() {
- return site.getPresentation();
- }
-
- /**
- * Hides the sash for the fastview if it is currently visible. This method may not be
- * required anymore, and might be removed from the public interface.
- */
- public void hideFastViewSash() {
- if (sash != null) {
- sash.setVisible(false);
- }
- }
-
- /**
- * Hides the currently visible fastview.
- */
- public void hideView() {
-
- if (clientComposite != null) {
- Display display = clientComposite.getDisplay();
-
- display.removeFilter(SWT.MouseDown, mouseDownListener);
- }
-
- if (currentPane == null) {
- return;
- }
-
- fastViewAction.setPane(null);
-
- //unzoom before hiding
- currentPane.getPane().setZoomed(false);
-
- if (sash != null) {
- sash.dispose();
- sash = null;
- }
-
- clientComposite.removeListener(SWT.Resize, resizeListener);
-
- // Get pane.
- // Hide the right side sash first
- //hideFastViewSash();
- Control ctrl = currentPane.getControl();
-
- ctrl.removeListener(SWT.Traverse, escapeListener);
-
- // Hide it completely.
- getPresentation().setVisible(false);
- site.dispose();
- //currentPane.setFastViewSash(null);
- ctrl.setEnabled(false); // Remove focus support.
-
- currentPane.dispose();
- currentPane = null;
- }
-
- /**
- * @return Returns the currently visible fastview or null if none
- */
- public ViewPane getCurrentPane() {
- if (currentPane != null && currentPane.getPane() instanceof ViewPane) {
- return (ViewPane)currentPane.getPane();
- }
-
- return null;
- }
-
- public void setState(int newState) {
- site.setState(newState);
- }
-
- public int getState() {
- return site.getState();
- }
-
- /**
- *
- */
- public void showSystemMenu() {
- getPresentation().showSystemMenu();
- }
-
- /**
- *
- */
- public void showPaneMenu() {
- getPresentation().showPaneMenu();
- }
-
- private int getSashSize() {
- AbstractPresentationFactory factory = getPresentationFactory();
-
- // Set up the correct 'style' bits
- int style = AbstractPresentationFactory.SASHTYPE_FLOATING;
- if (Geometry.isHorizontal(side))
- style |= AbstractPresentationFactory.SASHORIENTATION_HORIZONTAL;
- else
- style |= AbstractPresentationFactory.SASHORIENTATION_VERTICAL;
-
- int size = factory.getSashSize(style);
-
- return size;
- }
-
- private AbstractPresentationFactory getPresentationFactory() {
- if (presFactory == null) {
- presFactory = ((WorkbenchWindow) currentPane.getPane().getWorkbenchWindow())
- .getWindowConfigurer().getPresentationFactory();
- }
- return presFactory;
- }
-}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/FolderLayout.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/FolderLayout.java
deleted file mode 100644
index c0859de9e93..00000000000
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/FolderLayout.java
+++ /dev/null
@@ -1,118 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 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
- * Chris Gross chris.gross@us.ibm.com Bug 107443
- *******************************************************************************/
-package org.eclipse.ui.internal;
-
-import org.eclipse.ui.IFolderLayout;
-import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.activities.WorkbenchActivityHelper;
-import org.eclipse.ui.views.IViewDescriptor;
-
-/**
- * This layout is used to define the initial set of views and placeholders
- * in a folder.
- * <p>
- * Views are added to the folder by ID. This id is used to identify
- * a view descriptor in the view registry, and this descriptor is used to
- * instantiate the <code>IViewPart</code>.
- * </p>
- */
-public class FolderLayout implements IFolderLayout {
- private ViewStack folder;
-
- private PageLayout pageLayout;
-
- private ViewFactory viewFactory;
-
- /**
- * Create an instance of a <code>FolderLayout</code> belonging to a
- * <code>PageLayout</code>.
- */
- public FolderLayout(PageLayout pageLayout, ViewStack folder,
- ViewFactory viewFactory) {
- super();
- this.folder = folder;
- this.viewFactory = viewFactory;
- this.pageLayout = pageLayout;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.IPlaceholderFolderLayout#addPlaceholder(java.lang.String)
- */
- public void addPlaceholder(String viewId) {
- if (!pageLayout.checkValidPlaceholderId(viewId)) {
- return;
- }
-
- // Create the placeholder.
- PartPlaceholder newPart = new PartPlaceholder(viewId);
- linkPartToPageLayout(viewId, newPart);
-
- // Add it to the folder layout.
- folder.add(newPart);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.IFolderLayout#addView(java.lang.String)
- */
- public void addView(String viewId) {
- if (pageLayout.checkPartInLayout(viewId)) {
- return;
- }
-
- try {
- IViewDescriptor descriptor = viewFactory.getViewRegistry().find(
- ViewFactory.extractPrimaryId(viewId));
- if (descriptor == null) {
- throw new PartInitException("View descriptor not found: " + viewId); //$NON-NLS-1$
- }
- if (WorkbenchActivityHelper.filterItem(descriptor)) {
- //create a placeholder instead.
- addPlaceholder(viewId);
- LayoutHelper.addViewActivator(pageLayout, viewId);
- } else {
-
- ViewPane newPart = LayoutHelper.createView(pageLayout
- .getViewFactory(), viewId);
- linkPartToPageLayout(viewId, newPart);
- folder.add(newPart);
- }
- } catch (PartInitException e) {
- // cannot safely open the dialog so log the problem
- WorkbenchPlugin.log(getClass(), "addView(String)", e); //$NON-NLS-1$
- }
- }
-
- /**
- * Inform the page layout of the new part created
- * and the folder the part belongs to.
- */
- private void linkPartToPageLayout(String viewId, LayoutPart newPart) {
- pageLayout.setRefPart(viewId, newPart);
- pageLayout.setFolderPart(viewId, folder);
- // force creation of the view layout rec
- pageLayout.getViewLayoutRec(viewId, true);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.IPlaceholderFolderLayout#getProperty(java.lang.String)
- */
- public String getProperty(String id) {
- return folder.getProperty(id);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.IPlaceholderFolderLayout#setProperty(java.lang.String, java.lang.String)
- */
- public void setProperty(String id, String value) {
- folder.setProperty(id,value);
- }
-}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/ILayoutContainer.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/ILayoutContainer.java
deleted file mode 100644
index 6e14102d3f4..00000000000
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/ILayoutContainer.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2005 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;
-
-public interface ILayoutContainer {
- public boolean allowsAdd(LayoutPart toAdd);
-
- /**
- * Add a child to the container.
- */
- public void add(LayoutPart newPart);
-
- /**
- * Returns a list of layout children.
- */
- public LayoutPart[] getChildren();
-
- /**
- * Remove a child from the container.
- */
- public void remove(LayoutPart part);
-
- /**
- * Replace one child with another
- */
- public void replace(LayoutPart oldPart, LayoutPart newPart);
-
- public void findSashes(LayoutPart toFind, PartPane.Sashes result);
-
- /**
- * When a layout part closes, focus will return to the previously active part.
- * This method determines whether the parts in this container should participate
- * in this behavior. If this method returns true, its parts may automatically be
- * given focus when another part is closed.
- *
- * @return true iff the parts in this container may be given focus when the active
- * part is closed
- */
- public boolean allowsAutoFocus();
-
- /**
- * Called by child parts to request a zoom in, given an immediate child
- *
- * @param toZoom
- * @since 3.1
- */
- public void childRequestZoomIn(LayoutPart toZoom);
-
- /**
- * Called by child parts to request a zoom out
- *
- * @since 3.1
- */
- public void childRequestZoomOut();
-
- /**
- * Returns true iff the given child is obscured due to the fact that the container is zoomed into
- * another part.
- *
- * @param toTest
- * @return
- * @since 3.1
- */
- public boolean childObscuredByZoom(LayoutPart toTest);
-
- /**
- * Returns true iff we are zoomed into the given part, given an immediate child of this container.
- *
- * @param toTest
- * @return
- * @since 3.1
- */
- public boolean childIsZoomed(LayoutPart toTest);
-
- /**
- * Called when the preferred size of the given child has changed, requiring a
- * layout to be triggered.
- *
- * @param childThatChanged the child that triggered the new layout
- */
- public void resizeChild(LayoutPart childThatChanged);
-
-}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/IStickyViewManager.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/IStickyViewManager.java
deleted file mode 100644
index 59d75ee3bff..00000000000
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/IStickyViewManager.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 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.Set;
-
-import org.eclipse.ui.IMemento;
-
-/**
- * @since 3.3
- *
- */
-interface IStickyViewManager {
-
- void remove(String perspectiveId);
-
- void add(String perspectiveId, Set stickyViewSet);
-
- void clear();
-
- void update(Perspective oldPersp, Perspective newPersp);
-
- void save(IMemento memento);
-
- void restore(IMemento memento);
-
-}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/LayoutHelper.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/LayoutHelper.java
deleted file mode 100644
index ae34c17296d..00000000000
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/LayoutHelper.java
+++ /dev/null
@@ -1,168 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 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.ui.IPerspectiveDescriptor;
-import org.eclipse.ui.IPerspectiveListener;
-import org.eclipse.ui.IPluginContribution;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.activities.IIdentifier;
-import org.eclipse.ui.activities.IIdentifierListener;
-import org.eclipse.ui.activities.IWorkbenchActivitySupport;
-import org.eclipse.ui.activities.IdentifierEvent;
-import org.eclipse.ui.activities.WorkbenchActivityHelper;
-import org.eclipse.ui.views.IViewDescriptor;
-
-/**
- * Helper methods that the internal layout classes (<code>PageLayout</code> and
- * <code>FolderLayout</code>) utilize for activities support and view creation.
- *
- * @since 3.0
- */
-class LayoutHelper {
-
- /**
- * Not intended to be instantiated.
- */
- private LayoutHelper() {
- //no-op
- }
-
- /**
- * Creates a series of listeners that will activate the provided view on the
- * provided page layout when <code>IIdenfier</code> enablement changes. The
- * rules for this activation are as follows: <p>
- * <ul>
- * <li> if the identifier becomes enabled and the perspective of the page
- * layout is the currently active perspective in its window, then activate
- * the views immediately.
- * <li> if the identifier becomes enabled and the perspective of the page
- * layout is not the currently active perspecitve in its window, then add an
- * <code>IPerspectiveListener</code> to the window and activate the views
- * when the perspective becomes active.
- *
- * @param pageLayout <code>PageLayout</code>.
- * @param viewId the view id to activate upon <code>IIdentifier</code> enablement.
- */
- public static final void addViewActivator(PageLayout pageLayout,
- final String viewId) {
- if (viewId == null) {
- return;
- }
-
- ViewFactory viewFactory = pageLayout.getViewFactory();
-
- final IWorkbenchPage partPage = viewFactory.getWorkbenchPage();
- if (partPage == null) {
- return;
- }
-
- final IPerspectiveDescriptor partPerspective = pageLayout
- .getDescriptor();
-
- IWorkbenchActivitySupport support = PlatformUI.getWorkbench()
- .getActivitySupport();
-
- IViewDescriptor descriptor = viewFactory.getViewRegistry().find(viewId);
- if (!(descriptor instanceof IPluginContribution)) {
- return;
- }
-
- IIdentifier identifier = support.getActivityManager().getIdentifier(
- WorkbenchActivityHelper
- .createUnifiedId((IPluginContribution) descriptor));
-
- identifier.addIdentifierListener(new IIdentifierListener() {
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.activities.IIdentifierListener#identifierChanged(org.eclipse.ui.activities.IdentifierEvent)
- */
- public void identifierChanged(IdentifierEvent identifierEvent) {
- if (identifierEvent.hasEnabledChanged()) {
- IIdentifier thisIdentifier = identifierEvent
- .getIdentifier();
- if (thisIdentifier.isEnabled()) {
- // show view
- thisIdentifier.removeIdentifierListener(this);
- IWorkbenchPage activePage = partPage
- .getWorkbenchWindow().getActivePage();
- if (partPage == activePage
- && partPerspective == activePage
- .getPerspective()) {
- // show immediately.
- try {
- partPage.showView(viewId);
- } catch (PartInitException e) {
- WorkbenchPlugin.log(getClass(), "identifierChanged", e); //$NON-NLS-1$
- }
- } else { // show when the perspective becomes active
- partPage.getWorkbenchWindow()
- .addPerspectiveListener(
- new IPerspectiveListener() {
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.IPerspectiveListener#perspectiveActivated(org.eclipse.ui.IWorkbenchPage, org.eclipse.ui.IPerspectiveDescriptor)
- */
- public void perspectiveActivated(
- IWorkbenchPage page,
- IPerspectiveDescriptor newPerspective) {
- if (partPerspective == newPerspective) {
- partPage
- .getWorkbenchWindow()
- .removePerspectiveListener(
- this);
- try {
- page
- .showView(viewId);
- } catch (PartInitException e) {
- WorkbenchPlugin.log(getClass(), "perspectiveActivated", e); //$NON-NLS-1$
- }
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.IPerspectiveListener#perspectiveChanged(org.eclipse.ui.IWorkbenchPage, org.eclipse.ui.IPerspectiveDescriptor, java.lang.String)
- */
- public void perspectiveChanged(
- IWorkbenchPage page,
- IPerspectiveDescriptor perspective,
- String changeId) {
- // no-op
- }
- });
- }
- }
- }
- }
- });
- }
-
- /**
- * Create the view. If it's already been been created in the provided
- * factory, return the shared instance.
- *
- * @param factory the <code>ViewFactory</code> to use.
- * @param viewID the view id to use.
- * @return the new <code>ViewPane</code>.
- * @throws PartInitException thrown if there is a problem creating the view.
- */
- public static final ViewPane createView(ViewFactory factory, String viewId)
- throws PartInitException {
- WorkbenchPartReference ref = (WorkbenchPartReference) factory
- .createView(ViewFactory.extractPrimaryId(viewId), ViewFactory
- .extractSecondaryId(viewId));
- ViewPane newPart = (ViewPane) ref.getPane();
- return newPart;
- }
-
-}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/LayoutPart.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/LayoutPart.java
deleted file mode 100644
index bf05797b50a..00000000000
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/LayoutPart.java
+++ /dev/null
@@ -1,488 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 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
- * Cagatay Kavukcuoglu <cagatayk@acm.org>
- * - Fix for bug 10025 - Resizing views should not use height ratios
- *******************************************************************************/
-package org.eclipse.ui.internal;
-
-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;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.ISizeProvider;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.internal.dnd.IDropTarget;
-import org.eclipse.ui.internal.dnd.SwtUtil;
-
-/**
- * A presentation part is used to build the presentation for the
- * workbench. Common subclasses are pane and folder.
- */
-abstract public class LayoutPart implements ISizeProvider {
- protected ILayoutContainer container;
-
- protected String id;
-
- public static final String PROP_VISIBILITY = "PROP_VISIBILITY"; //$NON-NLS-1$
-
- /**
- * Number of times deferUpdates(true) has been called without a corresponding
- * deferUpdates(false)
- */
- private int deferCount = 0;
-
- /**
- * PresentationPart constructor comment.
- */
- public LayoutPart(String id) {
- super();
- this.id = id;
- }
-
- /**
- * When a layout part closes, focus will return to a previously active part.
- * This method determines whether this part should be considered for activation
- * when another part closes. If a group of parts are all closing at the same time,
- * they will all return false from this method while closing to ensure that the
- * parent does not activate a part that is in the process of closing. Parts will
- * also return false from this method if they are minimized, closed fast views,
- * obscured by zoom, etc.
- *
- * @return true iff the parts in this container may be given focus when the active
- * part is closed
- */
- public boolean allowsAutoFocus() {
- if (container != null) {
- return container.allowsAutoFocus();
- }
- return true;
- }
-
-
- /**
- * Creates the SWT control
- */
- abstract public void createControl(Composite parent);
-
- /**
- * Disposes the SWT control
- */
- public void dispose() {
- }
-
- /**
- * Gets the presentation bounds.
- */
- public Rectangle getBounds() {
- return new Rectangle(0, 0, 0, 0);
- }
-
- /**
- * Gets the parent for this part.
- * <p>
- * In general, this is non-null if the object has been added to a container and the
- * container's widgetry exists. The exception to this rule is PartPlaceholders
- * created when restoring a ViewStack using restoreState, which point to the
- * ViewStack even if its widgetry doesn't exist yet. Returns null in the remaining
- * cases.
- * </p>
- * <p>
- * TODO: change the semantics of this method to always point to the parent container,
- * regardless of whether its widgetry exists. Locate and refactor code that is currently
- * depending on the special cases.
- * </p>
- */
- public ILayoutContainer getContainer() {
- return container;
- }
-
- /**
- * Get the part control. This method may return null.
- */
- abstract public Control getControl();
-
- /**
- * Gets the ID for this part.
- */
- public String getID() {
- return id;
- }
-
- /**
- * Returns the compound ID for this part.
- * The compound ID is of the form: primaryId [':' + secondaryId]
- *
- * @return the compound ID for this part.
- */
- public String getCompoundId() {
- return getID();
- }
-
- public boolean isCompressible() {
- return false;
- }
-
- /**
- * Gets the presentation size.
- */
- public Point getSize() {
- Rectangle r = getBounds();
- Point ptSize = new Point(r.width, r.height);
- return ptSize;
- }
-
- /**
- * @see org.eclipse.ui.presentations.StackPresentation#getSizeFlags(boolean)
- *
- * @since 3.1
- */
- public int getSizeFlags(boolean horizontal) {
- return SWT.MIN;
- }
-
- /**
- * @see org.eclipse.ui.presentations.StackPresentation#computePreferredSize(boolean, int, int, int)
- *
- * @since 3.1
- */
- public int computePreferredSize(boolean width, int availableParallel, int availablePerpendicular, int preferredParallel) {
-
- return preferredParallel;
- }
-
- public IDropTarget getDropTarget(Object draggedObject, Point displayCoordinates) {
- return null;
- }
-
- public boolean isDocked() {
- Shell s = getShell();
- if (s == null) {
- return false;
- }
-
- return s.getData() instanceof IWorkbenchWindow;
- }
-
- public Shell getShell() {
- Control ctrl = getControl();
- if (!SwtUtil.isDisposed(ctrl)) {
- return ctrl.getShell();
- }
- return null;
- }
-
- /**
- * Returns the workbench window window for a part.
- *
- * @return the workbench window, or <code>null</code> if there's no window
- * associated with this part.
- */
- public IWorkbenchWindow getWorkbenchWindow() {
- Shell s = getShell();
- if (s==null) {
- return null;
- }
- Object data = s.getData();
- if (data instanceof IWorkbenchWindow) {
- return (IWorkbenchWindow)data;
- } else if (data instanceof DetachedWindow) {
- return ((DetachedWindow) data).getWorkbenchPage()
- .getWorkbenchWindow();
- }
-
- return null;
-
- }
-
- /**
- * Move the control over another one.
- */
- public void moveAbove(Control refControl) {
- }
-
- /**
- * Reparent a part.
- */
- public void reparent(Composite newParent) {
- Control control = getControl();
- if ((control == null) || (control.getParent() == newParent)) {
- return;
- }
-
- if (control.isReparentable()) {
- // make control small in case it is not resized with other controls
- //control.setBounds(0, 0, 0, 0);
- // By setting the control to disabled before moving it,
- // we ensure that the focus goes away from the control and its children
- // and moves somewhere else
- boolean enabled = control.getEnabled();
- control.setEnabled(false);
- control.setParent(newParent);
- control.setEnabled(enabled);
- control.moveAbove(null);
- }
- }
-
- /**
- * Returns true if this part was set visible. This returns whatever was last passed into
- * setVisible, but does not necessarily indicate that the part can be seen (ie: one of its
- * ancestors may be invisible)
- */
- public boolean getVisible() {
- Control ctrl = getControl();
- if (!SwtUtil.isDisposed(ctrl)) {
- return ctrl.getVisible();
- }
- return false;
- }
-
- /**
- * Returns true if this part can be seen. Returns false if the part or any of its ancestors
- * are invisible.
- */
- public boolean isVisible() {
- Control ctrl = getControl();
- if (ctrl != null && !ctrl.isDisposed()) {
- return ctrl.isVisible();
- }
- return false;
- }
-
- /**
- * Shows the receiver if <code>visible</code> is true otherwise hide it.
- */
- public void setVisible(boolean makeVisible) {
- Control ctrl = getControl();
- if (!SwtUtil.isDisposed(ctrl)) {
- if (makeVisible == ctrl.getVisible()) {
- return;
- }
-
- if (!makeVisible && isFocusAncestor(ctrl)) {
- // Workaround for Bug 60970 [EditorMgmt] setActive() called on an editor when it does not have focus.
- // Force focus on the shell so that when ctrl is hidden,
- // SWT does not try to send focus elsewhere, which may cause
- // some other part to be activated, which affects the part
- // activation order and can cause flicker.
- ctrl.getShell().forceFocus();
- }
-
- ctrl.setVisible(makeVisible);
- }
- }
-
- /**
- * Returns <code>true</code> if the given control or any of its descendents has focus.
- */
- private boolean isFocusAncestor(Control ctrl) {
- Control f = ctrl.getDisplay().getFocusControl();
- while (f != null && f != ctrl) {
- f = f.getParent();
- }
- return f == ctrl;
- }
-
- /**
- * Sets the presentation bounds.
- */
- public void setBounds(Rectangle r) {
- Control ctrl = getControl();
- if (!SwtUtil.isDisposed(ctrl)) {
- ctrl.setBounds(r);
- }
- }
-
- /**
- * Sets the parent for this part.
- */
- public void setContainer(ILayoutContainer container) {
-
- this.container = container;
-
- if (container != null) {
- setZoomed(container.childIsZoomed(this));
- }
- }
-
- /**
- * Sets focus to this part.
- */
- public void setFocus() {
- }
-
- /**
- * Sets the part ID.
- */
- public void setID(String str) {
- id = str;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.internal.IWorkbenchDragDropPart#getPart()
- */
- public LayoutPart getPart() {
- return this;
- }
-
- public void childRequestZoomIn(LayoutPart toZoom) {
-
- }
-
- public void childRequestZoomOut() {
-
- }
-
- public final void requestZoomOut() {
- ILayoutContainer container = getContainer();
- if (container != null) {
- container.childRequestZoomOut();
- }
- }
-
- public final void requestZoomIn() {
- ILayoutContainer container = getContainer();
- if (container != null) {
- container.childRequestZoomIn(this);
- }
- }
-
- public final boolean isObscuredByZoom() {
- ILayoutContainer container = getContainer();
-
- if (container != null) {
- return container.childObscuredByZoom(this);
- }
-
- return false;
- }
-
- public boolean childObscuredByZoom(LayoutPart toTest) {
- return false;
- }
-
- public boolean childIsZoomed(LayoutPart childToTest) {
- return false;
- }
-
- public void setZoomed(boolean isZoomed) {
-
- }
-
- /**
- * deferUpdates(true) disables widget updates until a corresponding call to
- * deferUpdates(false). Exactly what gets deferred is the decision
- * of each LayoutPart, however the part may only defer operations in a manner
- * that does not affect the final result.
- * That is, the state of the receiver after the final call to deferUpdates(false)
- * must be exactly the same as it would have been if nothing had been deferred.
- *
- * @param shouldDefer true iff events should be deferred
- */
- public final void deferUpdates(boolean shouldDefer) {
- if (shouldDefer) {
- if (deferCount == 0) {
- startDeferringEvents();
- }
- deferCount++;
- } else {
- if (deferCount > 0) {
- deferCount--;
- if (deferCount == 0) {
- handleDeferredEvents();
- }
- }
- }
- }
-
- /**
- * This is called when deferUpdates(true) causes UI events for this
- * part to be deferred. Subclasses can overload to initialize any data
- * structures that they will use to collect deferred events.
- */
- protected void startDeferringEvents() {
-
- }
-
- /**
- * Immediately processes all UI events which were deferred due to a call to
- * deferUpdates(true). This is called when the last call is made to
- * deferUpdates(false). Subclasses should overload this method if they
- * defer some or all UI processing during deferUpdates.
- */
- protected void handleDeferredEvents() {
-
- }
-
- /**
- * Subclasses can call this method to determine whether UI updates should
- * be deferred. Returns true iff there have been any calls to deferUpdates(true)
- * without a corresponding call to deferUpdates(false). Any operation which is
- * deferred based on the result of this method should be performed later within
- * handleDeferredEvents().
- *
- * @return true iff updates should be deferred.
- */
- protected final boolean isDeferred() {
- return deferCount > 0;
- }
-
- /**
- * Writes a description of the layout to the given string buffer.
- * This is used for drag-drop test suites to determine if two layouts are the
- * same. Like a hash code, the description should compare as equal iff the
- * layouts are the same. However, it should be user-readable in order to
- * help debug failed tests. Although these are english readable strings,
- * they do not need to be translated.
- *
- * @param buf
- */
- public void describeLayout(StringBuffer buf) {
-
- }
-
- /**
- * Returns an id representing this part, suitable for use in a placeholder.
- *
- * @since 3.0
- */
- public String getPlaceHolderId() {
- return getID();
- }
-
- public void resizeChild(LayoutPart childThatChanged) {
-
- }
-
- public void flushLayout() {
- ILayoutContainer container = getContainer();
- if (getContainer() != null) {
- container.resizeChild(this);
- }
- }
-
- /**
- * Returns true iff the given part can be added to this ILayoutContainer
- * @param toAdd
- * @return
- * @since 3.1
- */
- public boolean allowsAdd(LayoutPart toAdd) {
- return false;
- }
-
- /**
- * Tests the integrity of this object. Throws an exception if the object's state
- * is not internally consistent. For use in test suites.
- */
- public void testInvariants() {
- }
-}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/LayoutPartSash.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/LayoutPartSash.java
deleted file mode 100644
index 0a3c855570d..00000000000
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/LayoutPartSash.java
+++ /dev/null
@@ -1,315 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 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
- * Randy Hudson <hudsonr@us.ibm.com>
- * - Fix for bug 19524 - Resizing WorkbenchWindow resizes views
- * Cagatay Kavukcuoglu <cagatayk@acm.org>
- * - Fix for bug 10025 - Resizing views should not use height ratios
- * Matthew Hatem Matthew_Hatem@notesdev.ibm.com Bug 189953
- *******************************************************************************/
-package org.eclipse.ui.internal;
-
-import org.eclipse.jface.util.Geometry;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Sash;
-import org.eclipse.ui.presentations.AbstractPresentationFactory;
-
-class LayoutPartSash extends LayoutPart {
-
- private Sash sash;
- private boolean enabled = false;
-
- private PartSashContainer rootContainer;
-
- private int style;
-
- private LayoutPartSash preLimit;
-
- private LayoutPartSash postLimit;
-
- SelectionListener selectionListener;
-
- private int left = 300, right = 300;
-
- private Rectangle bounds = new Rectangle(0,0,0,0);
-
- private AbstractPresentationFactory presFactory;
-
- /**
- * Stores whether or not the sash is visible. (This is expected to have a meaningful
- * value even if the underlying control doesn't exist).
- */
- private boolean isVisible;
-
- LayoutPartSash(PartSashContainer rootContainer, int style) {
- super(null);
- this.style = style;
- this.rootContainer = rootContainer;
-
- selectionListener = new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- checkDragLimit(e);
-
- if (e.detail != SWT.DRAG) {
- LayoutPartSash.this.widgetSelected(e.x, e.y, e.width,
- e.height);
- }
- }
- };
- }
-
- // checkDragLimit contains changes by cagatayk@acm.org
- private void checkDragLimit(SelectionEvent event) {
- LayoutTree root = rootContainer.getLayoutTree();
- LayoutTreeNode node = root.findSash(this);
- Rectangle nodeBounds = node.getBounds();
- Rectangle eventRect = new Rectangle(event.x, event.y, event.width, event.height);
-
- boolean vertical = (style == SWT.VERTICAL);
-
- // If a horizontal sash, flip the coordinate system so that we
- // can handle horizontal and vertical sashes without special cases
- if (!vertical) {
- Geometry.flipXY(nodeBounds);
- Geometry.flipXY(eventRect);
- }
-
- int eventX = eventRect.x;
- int left = Math.max(0, eventX - nodeBounds.x);
- left = Math.min(left, nodeBounds.width - getSashSize());
- int right = nodeBounds.width - left - getSashSize();
-
- LayoutTreeNode.ChildSizes sizes = node.computeChildSizes(nodeBounds.width, nodeBounds.height, left, right, nodeBounds.width);
-
- eventRect.x = nodeBounds.x + sizes.left;
-
- // If it's a horizontal sash, restore eventRect to its original coordinate system
- if (!vertical) {
- Geometry.flipXY(eventRect);
- }
-
- event.x = eventRect.x;
- event.y = eventRect.y;
- }
-
- /**
- * Creates the control. As an optimization, creation of the control is deferred if
- * the control is invisible.
- */
- public void createControl(Composite parent) {
- // Defer creation of the control until it becomes visible
- if (isVisible) {
- doCreateControl();
- }
- }
-
- /**
- * Creates the underlying SWT control.
- *
- * @since 3.1
- */
- private void doCreateControl() {
- if (sash == null) {
- // ask the presentation factory to create the sash
- AbstractPresentationFactory factory = getPresentationFactory();
-
- int sashStyle = AbstractPresentationFactory.SASHTYPE_NORMAL | style;
- sash = factory.createSash(this.rootContainer.getParent(), sashStyle);
-
- sash.addSelectionListener(selectionListener);
- sash.setEnabled(enabled);
- sash.setBounds(bounds);
- }
- }
-
- public void setBounds(Rectangle r) {
- super.setBounds(r);
-
- bounds = r;
- }
-
- /**
- * Makes the sash visible or invisible. Note: as an optimization, the actual widget is destroyed when the
- * sash is invisible.
- */
- public void setVisible(boolean visible) {
- if (visible == isVisible) {
- return;
- }
-
- if (visible) {
- doCreateControl();
- } else {
- dispose();
- }
-
- super.setVisible(visible);
-
- isVisible = visible;
- }
-
- public boolean isVisible() {
- return isVisible;
- }
-
- /**
- * See LayoutPart#dispose
- */
- public void dispose() {
-
- if (sash != null) {
- bounds = sash.getBounds();
- sash.dispose();
- }
- sash = null;
- }
-
- /**
- * Gets the presentation bounds.
- */
- public Rectangle getBounds() {
- if (sash == null) {
- return bounds;
- }
-
- return sash.getBounds();
- }
-
- /**
- * Returns the part control.
- */
- public Control getControl() {
- return sash;
- }
-
- /**
- *
- */
- public String getID() {
- return null;
- }
-
- LayoutPartSash getPostLimit() {
- return postLimit;
- }
-
- LayoutPartSash getPreLimit() {
- return preLimit;
- }
-
- int getLeft() {
- return left;
- }
-
- int getRight() {
- return right;
- }
-
- boolean isHorizontal() {
- return ((style & SWT.HORIZONTAL) == SWT.HORIZONTAL);
- }
-
- boolean isVertical() {
- return ((style & SWT.VERTICAL) == SWT.VERTICAL);
- }
-
- void setPostLimit(LayoutPartSash newPostLimit) {
- postLimit = newPostLimit;
- }
-
- void setPreLimit(LayoutPartSash newPreLimit) {
- preLimit = newPreLimit;
- }
-
- void setRatio(float newRatio) {
- int total = left + right;
- int newLeft = (int) (total * newRatio);
- setSizes(newLeft, total - newLeft);
- }
-
- void setSizes(int left, int right) {
- if (left < 0 || right < 0) {
- return;
- }
-
- if (left == this.left && right == this.right) {
- return;
- }
-
- this.left = left;
- this.right = right;
-
- flushCache();
- }
-
- private void flushCache() {
- LayoutTree root = rootContainer.getLayoutTree();
-
- if (root != null) {
- LayoutTreeNode node = root.findSash(this);
- if (node != null) {
- node.flushCache();
- }
- }
- }
-
- private void widgetSelected(int x, int y, int width, int height) {
- if (!enabled) {
- return;
- }
-
- LayoutTree root = rootContainer.getLayoutTree();
- LayoutTreeNode node = root.findSash(this);
- Rectangle nodeBounds = node.getBounds();
- //Recompute ratio
- x -= nodeBounds.x;
- y -= nodeBounds.y;
- if (style == SWT.VERTICAL) {
- setSizes(x, nodeBounds.width - x - getSashSize());
- } else {
- setSizes(y, nodeBounds.height - y - getSashSize());
- }
-
- node.setBounds(nodeBounds);
- }
-
- /**
- * @param resizable
- * @since 3.1
- */
- public void setEnabled(boolean resizable) {
- this.enabled = resizable;
- if (sash != null) {
- sash.setEnabled(enabled);
- }
- }
-
- /* package */ int getSashSize() {
- AbstractPresentationFactory factory = getPresentationFactory();
- int sashStyle = AbstractPresentationFactory.SASHTYPE_NORMAL | style;
- int size = factory.getSashSize(sashStyle);
- return size;
- }
-
- private AbstractPresentationFactory getPresentationFactory() {
- if (presFactory == null) {
- WorkbenchWindow wbw = (WorkbenchWindow)rootContainer.getPage().getWorkbenchWindow();
- WorkbenchWindowConfigurer configurer = wbw.getWindowConfigurer();
- presFactory = configurer.getPresentationFactory();
- }
- return presFactory;
- }
-
-}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/LayoutTree.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/LayoutTree.java
deleted file mode 100644
index 80529bb3f03..00000000000
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/LayoutTree.java
+++ /dev/null
@@ -1,614 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 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
- * Randy Hudson <hudsonr@us.ibm.com>
- * - Fix for bug 19524 - Resizing WorkbenchWindow resizes Views
- * Cagatay Kavukcuoglu <cagatayk@acm.org>
- * - Fix for bug 10025 - Resizing views should not use height ratios
- *******************************************************************************/
-package org.eclipse.ui.internal;
-
-import java.util.ArrayList;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.jface.util.Geometry;
-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.ui.ISizeProvider;
-
-/**
- * Implementation of a tree where the node is always a sash
- * and it always has two children. If a children is removed
- * the sash, i.e. the node, is removed as well and its other children
- * placed on its parent.
- */
-public class LayoutTree implements ISizeProvider {
- /* The parent of this tree or null if it is the root */
- LayoutTreeNode parent;
-
- /* Any LayoutPart if this is a leaf or a LayoutSashPart if it is a node */
- LayoutPart part;
-
- // Cached information
- private int cachedMinimumWidthHint = SWT.DEFAULT;
- private int cachedMinimumWidth = SWT.DEFAULT;
- private int cachedMinimumHeightHint = SWT.DEFAULT;
- private int cachedMinimumHeight = SWT.DEFAULT;
- private int cachedMaximumWidthHint = SWT.DEFAULT;
- private int cachedMaximumWidth = SWT.DEFAULT;
- private int cachedMaximumHeightHint = SWT.DEFAULT;
- private int cachedMaximumHeight = SWT.DEFAULT;
-
- // Cached size flags
- private boolean sizeFlagsDirty = true;
- private int widthSizeFlags = 0;
- private int heightSizeFlags = 0;
-
- // Cache statistics. For use in benchmarks and test suites only!
- public static int minCacheHits;
- public static int minCacheMisses;
- public static int maxCacheHits;
- public static int maxCacheMisses;
-
- private boolean forceLayout = true;
- private Rectangle currentBounds = new Rectangle(0,0,0,0);
-
- /**
- * Initialize this tree with its part.
- */
- public LayoutTree(LayoutPart part) {
- this.part = part;
- }
-
- /**
- * Add the relation ship between the children in the list
- * and returns the left children.
- */
- public LayoutPart computeRelation(ArrayList relations) {
- return part;
- }
-
- /**
- * Locates the part that intersects the given point
- *
- * @param toFind
- * @return
- */
- public LayoutPart findPart(Point toFind) {
- return part;
- }
-
- /**
- * Dispose all Sashs in this tree
- */
- public void disposeSashes() {
- }
-
- /**
- * Find a LayoutPart in the tree and return its sub-tree. Returns
- * null if the child is not found.
- */
- public LayoutTree find(LayoutPart child) {
- if (part != child) {
- return null;
- }
- return this;
- }
-
- /**
- * Find the Left,Right,Top and Botton
- * sashes around this tree and set them
- * in <code>sashes</code>
- */
- public void findSashes(PartPane.Sashes sashes) {
- if (getParent() == null) {
- return;
- }
- getParent().findSashes(this, sashes);
- }
-
- /**
- * Find the part that is in the bottom rigth possition.
- */
- public LayoutPart findBottomRight() {
- return part;
- }
-
- /**
- * Find a sash in the tree and return its sub-tree. Returns
- * null if the sash is not found.
- */
- public LayoutTreeNode findSash(LayoutPartSash sash) {
- return null;
- }
-
- /**
- * Return the bounds of this tree which is the rectangle that
- * contains all Controls in this tree.
- */
- public final Rectangle getBounds() {
- return Geometry.copy(currentBounds);
- }
-
- /**
- * Subtracts two integers. If a is INFINITE, this is treated as
- * positive infinity.
- *
- * @param a a positive integer or INFINITE indicating positive infinity
- * @param b a positive integer (may not be INFINITE)
- * @return a - b, or INFINITE if a == INFINITE
- * @since 3.1
- */
- public static int subtract(int a, int b) {
- Assert.isTrue(b >= 0 && b < INFINITE);
-
- return add(a, -b);
- }
-
- /**
- * Adds two positive integers. Treates INFINITE as positive infinity.
- *
- * @param a a positive integer
- * @param b a positive integer
- * @return a + b, or INFINITE if a or b are positive infinity
- * @since 3.1
- */
- public static int add(int a, int b) {
- if (a == INFINITE || b == INFINITE) {
- return INFINITE;
- }
-
- return a + b;
- }
-
- /**
- * Asserts that toCheck is a positive integer less than INFINITE / 2 or equal
- * to INFINITE. Many of the methods of this class use positive integers as sizes,
- * with INFINITE indicating positive infinity. This picks up accidental addition or
- * subtraction from infinity.
- *
- * @param toCheck integer to validate
- * @since 3.1
- */
- public static void assertValidSize(int toCheck) {
- Assert.isTrue(toCheck >= 0 && (toCheck == INFINITE || toCheck < INFINITE / 2));
- }
-
- /**
- * Computes the preferred size for this object. The interpretation of the result depends on the flags returned
- * by getSizeFlags(). If the caller is looking for a maximum or minimum size, this delegates to computeMinimumSize
- * or computeMaximumSize in order to benefit from caching optimizations. Otherwise, it delegates to
- * doComputePreferredSize. Subclasses should overload one of doComputeMinimumSize, doComputeMaximumSize, or
- * doComputePreferredSize to specialize the return value.
- *
- * @see LayoutPart#computePreferredSize(boolean, int, int, int)
- */
- public final int computePreferredSize(boolean width, int availableParallel, int availablePerpendicular, int preferredParallel) {
- assertValidSize(availableParallel);
- assertValidSize(availablePerpendicular);
- assertValidSize(preferredParallel);
-
- if (!isVisible()) {
- return 0;
- }
-
- if (availableParallel == 0) {
- return 0;
- }
-
- if (preferredParallel == 0) {
- return Math.min(availableParallel, computeMinimumSize(width, availablePerpendicular));
- } else if (preferredParallel == INFINITE && availableParallel == INFINITE) {
- return computeMaximumSize(width, availablePerpendicular);
- }
-
- // Optimization: if this subtree doesn't have any size preferences beyond its minimum and maximum
- // size, simply return the preferred size
- if (!hasSizeFlag(width, SWT.FILL)) {
- return preferredParallel;
- }
-
- int result = doComputePreferredSize(width, availableParallel, availablePerpendicular, preferredParallel);
-
- return result;
- }
-
- /**
- * Returns the size flags for this tree.
- *
- * @see org.eclipse.ui.presentations.StackPresentation#getSizeFlags(boolean)
- *
- * @param b indicates whether the caller wants the flags for computing widths (=true) or heights (=false)
- * @return a bitwise combiniation of flags with the same meaning as StackPresentation.getSizeFlags(boolean)
- */
- protected int doGetSizeFlags(boolean width) {
- return part.getSizeFlags(width);
- }
-
- /**
- * Subclasses should overload this method instead of computePreferredSize(boolean, int, int, int)
- *
- * @see org.eclipse.ui.presentations.StackPresentation#computePreferredSize(boolean, int, int, int)
- *
- * @since 3.1
- */
- protected int doComputePreferredSize(boolean width, int availableParallel, int availablePerpendicular, int preferredParallel) {
- int result = Math.min(availableParallel,
- part.computePreferredSize(width, availableParallel, availablePerpendicular, preferredParallel));
-
- assertValidSize(result);
- return result;
- }
-
- /**
- * Returns the minimum size for this subtree. Equivalent to calling
- * computePreferredSize(width, INFINITE, availablePerpendicular, 0).
- * Returns a cached value if possible or defers to doComputeMinimumSize otherwise.
- * Subclasses should overload doComputeMinimumSize if they want to specialize the
- * return value.
- *
- * @param width true iff computing the minimum width, false iff computing the minimum height
- * @param availablePerpendicular available space (pixels) perpendicular to the dimension
- * being computed. This is a height when computing a width, or a width when computing a height.
- *
- * @see LayoutPart#computePreferredSize(boolean, int, int, int)
- */
- public final int computeMinimumSize(boolean width, int availablePerpendicular) {
- assertValidSize(availablePerpendicular);
-
- // Optimization: if this subtree has no minimum size, then always return 0 as its
- // minimum size.
- if (!hasSizeFlag(width, SWT.MIN)) {
- return 0;
- }
-
- // If this subtree doesn't contain any wrapping controls (ie: they don't care
- // about their perpendicular size) then force the perpendicular
- // size to be INFINITE. This ensures that we will get a cache hit
- // every time for non-wrapping controls.
- if (!hasSizeFlag(width, SWT.WRAP)) {
- availablePerpendicular = INFINITE;
- }
-
- if (width) {
- // Check if we have a cached width measurement (we can only return a cached
- // value if we computed it for the same height)
- if (cachedMinimumWidthHint == availablePerpendicular) {
- minCacheHits++;
- return cachedMinimumWidth;
- }
-
- // Recompute the minimum width and store it in the cache
-
- minCacheMisses++;
-
- int result = doComputeMinimumSize(width, availablePerpendicular);
- cachedMinimumWidth = result;
- cachedMinimumWidthHint = availablePerpendicular;
- return result;
-
- } else {
- // Check if we have a cached height measurement (we can only return a cached
- // value if we computed it for the same width)
- if (cachedMinimumHeightHint == availablePerpendicular) {
- minCacheHits++;
- return cachedMinimumHeight;
- }
-
- // Recompute the minimum width and store it in the cache
- minCacheMisses++;
-
- int result = doComputeMinimumSize(width, availablePerpendicular);
- cachedMinimumHeight = result;
- cachedMinimumHeightHint = availablePerpendicular;
- return result;
- }
- }
-
- /**
- * For use in benchmarks and test suites only. Displays cache utilization statistics for all
- * LayoutTree instances.
- *
- * @since 3.1
- */
- public static void printCacheStatistics() {
- System.out.println("minimize cache " + minCacheHits + " / " + (minCacheHits + minCacheMisses) + " hits " + //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- minCacheHits * 100 / (minCacheHits + minCacheMisses) + "%"); //$NON-NLS-1$
- System.out.println("maximize cache " + maxCacheHits + " / " + (maxCacheHits + maxCacheMisses) + " hits" + //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- maxCacheHits * 100 / (maxCacheHits + maxCacheMisses) + "%"); //$NON-NLS-1$
- }
-
- public int doComputeMinimumSize(boolean width, int availablePerpendicular) {
- int result = doComputePreferredSize(width, INFINITE, availablePerpendicular, 0);
- assertValidSize(result);
- return result;
- }
-
- public final int computeMaximumSize(boolean width, int availablePerpendicular) {
- assertValidSize(availablePerpendicular);
-
- // Optimization: if this subtree has no maximum size, then always return INFINITE as its
- // maximum size.
- if (!hasSizeFlag(width, SWT.MAX)) {
- return INFINITE;
- }
-
- // If this subtree doesn't contain any wrapping controls (ie: they don't care
- // about their perpendicular size) then force the perpendicular
- // size to be INFINITE. This ensures that we will get a cache hit
- // every time.
- if (!hasSizeFlag(width, SWT.WRAP)) {
- availablePerpendicular = INFINITE;
- }
-
- if (width) {
- // Check if we have a cached width measurement (we can only return a cached
- // value if we computed it for the same height)
- if (cachedMaximumWidthHint == availablePerpendicular) {
- maxCacheHits++;
- return cachedMaximumWidth;
- }
-
- maxCacheMisses++;
-
- // Recompute the maximum width and store it in the cache
- int result = doComputeMaximumSize(width, availablePerpendicular);
- cachedMaximumWidth = result;
- cachedMaximumWidthHint = availablePerpendicular;
- return result;
-
- } else {
- // Check if we have a cached height measurement
- if (cachedMaximumHeightHint == availablePerpendicular) {
- maxCacheHits++;
- return cachedMaximumHeight;
- }
-
- maxCacheMisses++;
-
- // Recompute the maximum height and store it in the cache
- int result = doComputeMaximumSize(width, availablePerpendicular);
- cachedMaximumHeight = result;
- cachedMaximumHeightHint = availablePerpendicular;
- return result;
- }
- }
-
- protected int doComputeMaximumSize(boolean width, int availablePerpendicular) {
- return doComputePreferredSize(width, INFINITE, availablePerpendicular, INFINITE);
- }
-
- /**
- * Called to flush any cached information in this tree and its parents.
- */
- public void flushNode() {
-
- // Clear cached sizes
- cachedMinimumWidthHint = SWT.DEFAULT;
- cachedMinimumWidth = SWT.DEFAULT;
- cachedMinimumHeightHint = SWT.DEFAULT;
- cachedMinimumHeight = SWT.DEFAULT;
- cachedMaximumWidthHint = SWT.DEFAULT;
- cachedMaximumWidth = SWT.DEFAULT;
- cachedMaximumHeightHint = SWT.DEFAULT;
- cachedMaximumHeight = SWT.DEFAULT;
-
- // Flags may have changed. Ensure that they are recomputed the next time around
- sizeFlagsDirty = true;
-
- // The next setBounds call should trigger a layout even if set to the same bounds since
- // one of the children has changed.
- forceLayout = true;
- }
-
- /**
- * Flushes all cached information about this node and all of its children.
- * This should be called if something may have caused all children to become
- * out of synch with their cached information (for example, if a lot of changes
- * may have happened without calling flushCache after each change)
- *
- * @since 3.1
- */
- public void flushChildren() {
- flushNode();
- }
-
- /**
- * Flushes all cached information about this node and all of its ancestors.
- * This should be called when a single child changes.
- *
- * @since 3.1
- */
- public final void flushCache() {
- flushNode();
-
- if (parent != null) {
- parent.flushCache();
- }
- }
-
- public final int getSizeFlags(boolean width) {
- if (sizeFlagsDirty) {
- widthSizeFlags = doGetSizeFlags(true);
- heightSizeFlags = doGetSizeFlags(false);
- sizeFlagsDirty = false;
- }
-
- return width ? widthSizeFlags : heightSizeFlags;
- }
-
- /**
- * Returns the parent of this tree or null if it is the root.
- */
- public LayoutTreeNode getParent() {
- return parent;
- }
-
- /**
- * Inserts a new child on the tree. The child will be placed beside
- * the <code>relative</code> child. Returns the new root of the tree.
- */
- public LayoutTree insert(LayoutPart child, boolean left,
- LayoutPartSash sash, LayoutPart relative) {
- LayoutTree relativeChild = find(relative);
- LayoutTreeNode node = new LayoutTreeNode(sash);
- if (relativeChild == null) {
- //Did not find the relative part. Insert beside the root.
- node.setChild(left, child);
- node.setChild(!left, this);
- return node;
- } else {
- LayoutTreeNode oldParent = relativeChild.getParent();
- node.setChild(left, child);
- node.setChild(!left, relativeChild);
- if (oldParent == null) {
- //It was the root. Return a new root.
- return node;
- }
- oldParent.replaceChild(relativeChild, node);
- return this;
- }
- }
-
- /**
- * Returns true if this tree can be compressed and expanded.
- * @return true if springy
- */
- public boolean isCompressible() {
- //Added for bug 19524
- return part.isCompressible();
- }
-
- /**
- * Returns true if this tree has visible parts otherwise returns false.
- */
- public boolean isVisible() {
- return !(part instanceof PartPlaceholder);
- }
-
- /**
- * Recompute the ratios in this tree.
- */
- public void recomputeRatio() {
- }
-
- /**
- * Find a child in the tree and remove it and its parent.
- * The other child of its parent is placed on the parent's parent.
- * Returns the new root of the tree.
- */
- public LayoutTree remove(LayoutPart child) {
- LayoutTree tree = find(child);
- if (tree == null) {
- return this;
- }
- LayoutTreeNode oldParent = tree.getParent();
- if (oldParent == null) {
- //It was the root and the only child of this tree
- return null;
- }
- if (oldParent.getParent() == null) {
- return oldParent.remove(tree);
- }
-
- oldParent.remove(tree);
- return this;
- }
-
- /**
- * Sets the bounds of this node. If the bounds have changed or any children have
- * changed then the children will be recursively layed out. This implementation
- * filters out redundant calls and delegates to doSetBounds to layout the children.
- * Subclasses should overload doSetBounds to lay out their children.
- *
- * @param bounds new bounds of the tree
- */
- public final void setBounds(Rectangle bounds) {
- if (!bounds.equals(currentBounds) || forceLayout) {
- currentBounds = Geometry.copy(bounds);
-
- doSetBounds(currentBounds);
- forceLayout = false;
- }
- }
-
- /**
- * Resize the parts on this tree to fit in <code>bounds</code>.
- */
- protected void doSetBounds(Rectangle bounds) {
- part.setBounds(bounds);
- }
-
- /**
- * Set the parent of this tree.
- */
- void setParent(LayoutTreeNode parent) {
- this.parent = parent;
- }
-
- /**
- * Set the part of this leaf
- */
- void setPart(LayoutPart part) {
- this.part = part;
- flushCache();
- }
-
- /**
- * Returns a string representation of this object.
- */
- public String toString() {
- return "(" + part.toString() + ")";//$NON-NLS-2$//$NON-NLS-1$
- }
-
- /**
- * Creates SWT controls owned by the LayoutTree (ie: the sashes). Does not affect the
- * LayoutParts that are being arranged by the LayoutTree.
- *
- * @param parent
- * @since 3.1
- */
- public void createControl(Composite parent) {
- }
-
- /**
- * Writes a description of the layout to the given string buffer.
- * This is used for drag-drop test suites to determine if two layouts are the
- * same. Like a hash code, the description should compare as equal iff the
- * layouts are the same. However, it should be user-readable in order to
- * help debug failed tests. Although these are english readable strings,
- * they should not be translated or equality tests will fail.
- * <p>
- * This is only intended for use by test suites.
- * </p>
- *
- * @param buf
- */
- public void describeLayout(StringBuffer buf) {
- part.describeLayout(buf);
- }
-
- /**
- * This is a shorthand method that checks if the tree contains the
- * given size flag. For example, hasSizeFlag(false, SWT.MIN) returns
- * true iff the receiver enforces a minimum height, or
- * hasSizeFlag(true, SWT.WRAP) returns true iff the receiver needs to
- * know its height when computing its preferred width.
- *
- * @param vertical
- * @return
- * @since 3.1
- */
- public final boolean hasSizeFlag(boolean width, int flag) {
- return (getSizeFlags(width) & flag) != 0;
- }
-
-}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/LayoutTreeNode.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/LayoutTreeNode.java
deleted file mode 100644
index dced4816b94..00000000000
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/LayoutTreeNode.java
+++ /dev/null
@@ -1,675 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 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
- * Randy Hudson <hudsonr@us.ibm.com>
- * - Fix for bug 19524 - Resizing WorkbenchWindow resizes Views
- * Cagatay Kavukcuoglu <cagatayk@acm.org>
- * - Fix for bug 10025 - Resizing views should not use height ratios
- * Matthew Hatem Matthew_Hatem@notesdev.ibm.com Bug 189953
- *******************************************************************************/
-package org.eclipse.ui.internal;
-
-import java.util.ArrayList;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.jface.util.Geometry;
-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.Sash;
-import org.eclipse.ui.IPageLayout;
-
-/**
- * Implementation of a tree node. The node represents a
- * sash and it always has two children.
- */
-public class LayoutTreeNode extends LayoutTree {
-
- static class ChildSizes {
- int left;
- int right;
- boolean resizable = true;
-
- public ChildSizes (int l, int r, boolean resize) {
- left = l;
- right = r;
- resizable = resize;
- }
- }
-
- /* The node children witch may be another node or a leaf */
- private LayoutTree children[] = new LayoutTree[2];
-
- /**
- * Initialize this tree with its sash.
- */
- public LayoutTreeNode(LayoutPartSash sash) {
- super(sash);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.internal.LayoutTree#flushChildren()
- */
- public void flushChildren() {
- super.flushChildren();
-
- children[0].flushChildren();
- children[1].flushChildren();
- }
-
- /**
- * Traverses the tree to find the part that intersects the given point
- *
- * @param toFind
- * @return the part that intersects the given point
- */
- public LayoutPart findPart(Point toFind) {
- if (!children[0].isVisible()) {
- if (!children[1].isVisible()) {
- return null;
- }
-
- return children[1].findPart(toFind);
- } else {
- if (!children[1].isVisible()) {
- return children[0].findPart(toFind);
- }
- }
-
- LayoutPartSash sash = getSash();
-
- Rectangle bounds = sash.getBounds();
-
- if (sash.isVertical()) {
- if (toFind.x < bounds.x + (bounds.width / 2)) {
- return children[0].findPart(toFind);
- }
- return children[1].findPart(toFind);
- } else {
- if (toFind.y < bounds.y + (bounds.height / 2)) {
- return children[0].findPart(toFind);
- }
- return children[1].findPart(toFind);
- }
- }
-
- /**
- * Add the relation ship between the children in the list
- * and returns the left children.
- */
- public LayoutPart computeRelation(ArrayList relations) {
- PartSashContainer.RelationshipInfo r = new PartSashContainer.RelationshipInfo();
- r.relative = children[0].computeRelation(relations);
- r.part = children[1].computeRelation(relations);
- r.left = getSash().getLeft();
- r.right = getSash().getRight();
- r.relationship = getSash().isVertical() ? IPageLayout.RIGHT
- : IPageLayout.BOTTOM;
- relations.add(0, r);
- return r.relative;
- }
-
- /**
- * Dispose all Sashs in this tree
- */
- public void disposeSashes() {
- children[0].disposeSashes();
- children[1].disposeSashes();
- getSash().dispose();
- }
-
- /**
- * Find a LayoutPart in the tree and return its sub-tree. Returns
- * null if the child is not found.
- */
- public LayoutTree find(LayoutPart child) {
- LayoutTree node = children[0].find(child);
- if (node != null) {
- return node;
- }
- node = children[1].find(child);
- return node;
- }
-
- /**
- * Find the part that is in the bottom right position.
- */
- public LayoutPart findBottomRight() {
- if (children[1].isVisible()) {
- return children[1].findBottomRight();
- }
- return children[0].findBottomRight();
- }
-
- /**
- * Go up in the tree finding a parent that is common of both children.
- * Return the subtree.
- */
- public LayoutTreeNode findCommonParent(LayoutPart child1, LayoutPart child2) {
- return findCommonParent(child1, child2, false, false);
- }
-
- /**
- * Go up in the tree finding a parent that is common of both children.
- * Return the subtree.
- */
- LayoutTreeNode findCommonParent(LayoutPart child1, LayoutPart child2,
- boolean foundChild1, boolean foundChild2) {
- if (!foundChild1) {
- foundChild1 = find(child1) != null;
- }
- if (!foundChild2) {
- foundChild2 = find(child2) != null;
- }
- if (foundChild1 && foundChild2) {
- return this;
- }
- if (parent == null) {
- return null;
- }
- return parent
- .findCommonParent(child1, child2, foundChild1, foundChild2);
- }
-
- /**
- * Find a sash in the tree and return its sub-tree. Returns
- * null if the sash is not found.
- */
- public LayoutTreeNode findSash(LayoutPartSash sash) {
- if (this.getSash() == sash) {
- return this;
- }
- LayoutTreeNode node = children[0].findSash(sash);
- if (node != null) {
- return node;
- }
- node = children[1].findSash(sash);
- if (node != null) {
- return node;
- }
- return null;
- }
-
- /**
- * Sets the elements in the array of sashes with the
- * Left,Rigth,Top and Botton sashes. The elements
- * may be null depending whether there is a shash
- * beside the <code>part</code>
- */
- void findSashes(LayoutTree child, PartPane.Sashes sashes) {
- Sash sash = (Sash) getSash().getControl();
- boolean leftOrTop = children[0] == child;
- if (sash != null) {
- LayoutPartSash partSash = getSash();
- //If the child is in the left, the sash
- //is in the rigth and so on.
- if (leftOrTop) {
- if (partSash.isVertical()) {
- if (sashes.right == null) {
- sashes.right = sash;
- }
- } else {
- if (sashes.bottom == null) {
- sashes.bottom = sash;
- }
- }
- } else {
- if (partSash.isVertical()) {
- if (sashes.left == null) {
- sashes.left = sash;
- }
- } else {
- if (sashes.top == null) {
- sashes.top = sash;
- }
- }
- }
- }
- if (getParent() != null) {
- getParent().findSashes(this, sashes);
- }
- }
-
- /**
- * Returns the sash of this node.
- */
- public LayoutPartSash getSash() {
- return (LayoutPartSash) part;
- }
-
- private int getSashSize() {
- return getSash().getSashSize();
- }
-
- /**
- * Returns true if this tree has visible parts otherwise returns false.
- */
- public boolean isVisible() {
- return children[0].isVisible() || children[1].isVisible();
- }
-
- /**
- * Remove the child and this node from the tree
- */
- LayoutTree remove(LayoutTree child) {
- getSash().dispose();
- if (parent == null) {
- //This is the root. Return the other child to be the new root.
- if (children[0] == child) {
- children[1].setParent(null);
- return children[1];
- }
- children[0].setParent(null);
- return children[0];
- }
-
- LayoutTreeNode oldParent = parent;
- if (children[0] == child) {
- oldParent.replaceChild(this, children[1]);
- } else {
- oldParent.replaceChild(this, children[0]);
- }
- return oldParent;
- }
-
- /**
- * Replace a child with a new child and sets the new child's parent.
- */
- void replaceChild(LayoutTree oldChild, LayoutTree newChild) {
- if (children[0] == oldChild) {
- children[0] = newChild;
- } else if (children[1] == oldChild) {
- children[1] = newChild;
- }
- newChild.setParent(this);
- if (!children[0].isVisible() || !children[0].isVisible()) {
- getSash().dispose();
- }
-
- flushCache();
- }
-
- /**
- * Go up from the subtree and return true if all the sash are
- * in the direction specified by <code>isVertical</code>
- */
- public boolean sameDirection(boolean isVertical, LayoutTreeNode subTree) {
- boolean treeVertical = getSash().isVertical();
- if (treeVertical != isVertical) {
- return false;
- }
- while (subTree != null) {
- if (this == subTree) {
- return true;
- }
- if (subTree.children[0].isVisible()
- && subTree.children[1].isVisible()) {
- if (subTree.getSash().isVertical() != isVertical) {
- return false;
- }
- }
- subTree = subTree.getParent();
- }
- return true;
- }
-
- public int doComputePreferredSize(boolean width, int availableParallel, int availablePerpendicular, int preferredParallel) {
- assertValidSize(availablePerpendicular);
- assertValidSize(availableParallel);
- assertValidSize(preferredParallel);
-
- // If one child is invisible, defer to the other child
- if (!children[0].isVisible()) {
- return children[1].computePreferredSize(width, availableParallel, availablePerpendicular, preferredParallel);
- }
-
- if (!children[1].isVisible()) {
- return children[0].computePreferredSize(width, availableParallel, availablePerpendicular, preferredParallel);
- }
-
- if (availableParallel == 0) {
- return 0;
- }
-
- // If computing the dimension perpendicular to our sash
- if (width == getSash().isVertical()) {
- // Compute the child sizes
- ChildSizes sizes = computeChildSizes(availableParallel, availablePerpendicular,
- getSash().getLeft(), getSash().getRight(), preferredParallel);
-
- // Return the sum of the child sizes plus the sash size
- return add(sizes.left, add(sizes.right, getSashSize()));
- } else {
- // Computing the dimension parallel to the sash. We will compute and return the preferred size
- // of whichever child is closest to the ideal size.
-
- ChildSizes sizes;
- // First compute the dimension of the child sizes perpendicular to the sash
- sizes = computeChildSizes(availablePerpendicular, availableParallel,
- getSash().getLeft(), getSash().getRight(), availablePerpendicular);
-
- // Use this information to compute the dimension of the child sizes parallel to the sash.
- // Return the preferred size of whichever child is largest
- int leftSize = children[0].computePreferredSize(width, availableParallel, sizes.left, preferredParallel);
-
- // Compute the preferred size of the right child
- int rightSize = children[1].computePreferredSize(width, availableParallel, sizes.right, preferredParallel);
-
- // Return leftSize or rightSize: whichever one is largest
- int result = rightSize;
- if (leftSize > rightSize) {
- result = leftSize;
- }
-
- assertValidSize(result);
-
- return result;
- }
- }
-
- /**
- * Computes the pixel sizes of this node's children, given the available
- * space for this node. Note that "width" and "height" actually refer
- * to the distance perpendicular and parallel to the sash respectively.
- * That is, their meaning is reversed when computing a horizontal sash.
- *
- * @param width the pixel width of a vertical node, or the pixel height
- * of a horizontal node (INFINITE if unbounded)
- * @param height the pixel height of a vertical node, or the pixel width
- * of a horizontal node (INFINITE if unbounded)
- * @return a struct describing the pixel sizes of the left and right children
- * (this is a width for horizontal nodes and a height for vertical nodes)
- */
- ChildSizes computeChildSizes(int width, int height, int left, int right, int preferredWidth) {
- Assert.isTrue(children[0].isVisible());
- Assert.isTrue(children[1].isVisible());
- assertValidSize(width);
- assertValidSize(height);
- assertValidSize(preferredWidth);
- Assert.isTrue(left >= 0);
- Assert.isTrue(right >= 0);
- Assert.isTrue(preferredWidth >= 0);
- Assert.isTrue(preferredWidth <= width);
- boolean vertical = getSash().isVertical();
-
- if (width <= getSashSize()) {
- return new ChildSizes(0,0, false);
- }
-
- if (width == INFINITE) {
- if (preferredWidth == INFINITE) {
- return new ChildSizes(children[0].computeMaximumSize(vertical, height),
- children[1].computeMaximumSize(vertical, height), false);
- }
-
- if (preferredWidth == 0) {
- return new ChildSizes(children[0].computeMinimumSize(vertical, height),
- children[1].computeMinimumSize(vertical, height), false);
- }
- }
-
- int total = left + right;
-
- // Use all-or-none weighting
- double wLeft = left, wRight = right;
- switch (getCompressionBias()) {
- case -1:
- wLeft = 0.0;
- break;
- case 1:
- wRight = 0.0;
- break;
- default:
- break;
- }
- double wTotal = wLeft + wRight;
-
- // Subtract the SASH_WIDTH from preferredWidth and width. From here on, we'll deal with the
- // width available to the controls and neglect the space used by the sash.
- preferredWidth = Math.max(0, subtract(preferredWidth, getSashSize()));
- width = Math.max(0, subtract(width, getSashSize()));
-
- int redistribute = subtract(preferredWidth, total);
-
- // Compute the minimum and maximum sizes for each child
- int leftMinimum = children[0].computeMinimumSize(vertical, height);
- int rightMinimum = children[1].computeMinimumSize(vertical, height);
- int leftMaximum = children[0].computeMaximumSize(vertical, height);
- int rightMaximum = children[1].computeMaximumSize(vertical, height);
-
- // Keep track of the available space for each child, given the minimum size of the other child
- int leftAvailable = Math.min(leftMaximum, Math.max(0, subtract(width, rightMinimum)));
- int rightAvailable = Math.min(rightMaximum, Math.max(0, subtract(width, leftMinimum)));
-
- // Figure out the ideal size of the left child
- int idealLeft = Math.max(leftMinimum, Math.min(preferredWidth,
- left + (int) Math.round(redistribute * wLeft / wTotal)));
-
- // If the right child can't use all its available space, let the left child fill it in
- idealLeft = Math.max(idealLeft, preferredWidth - rightAvailable);
- // Ensure the left child doesn't get larger than its available space
- idealLeft = Math.min(idealLeft, leftAvailable);
-
- // Check if the left child would prefer to be a different size
- idealLeft = children[0].computePreferredSize(vertical, leftAvailable, height, idealLeft);
-
- // Ensure that the left child is larger than its minimum size
- idealLeft = Math.max(idealLeft, leftMinimum);
- idealLeft = Math.min(idealLeft, leftAvailable);
-
- // Compute the right child width
- int idealRight = Math.max(rightMinimum, preferredWidth - idealLeft);
-
- rightAvailable = Math.max(0, Math.min(rightAvailable, subtract(width, idealLeft)));
- idealRight = Math.min(idealRight, rightAvailable);
- idealRight = children[1].computePreferredSize(vertical, rightAvailable, height, idealRight);
- idealRight = Math.max(idealRight, rightMinimum);
-
- return new ChildSizes(idealLeft, idealRight, leftMaximum > leftMinimum
- && rightMaximum > rightMinimum
- && leftMinimum + rightMinimum < width);
- }
-
- protected int doGetSizeFlags(boolean width) {
- if (!children[0].isVisible()) {
- return children[1].getSizeFlags(width);
- }
-
- if (!children[1].isVisible()) {
- return children[0].getSizeFlags(width);
- }
-
- int leftFlags = children[0].getSizeFlags(width);
- int rightFlags = children[1].getSizeFlags(width);
-
- return ((leftFlags | rightFlags) & ~SWT.MAX) | (leftFlags & rightFlags & SWT.MAX);
- }
-
- /**
- * Resize the parts on this tree to fit in <code>bounds</code>.
- */
- public void doSetBounds(Rectangle bounds) {
- if (!children[0].isVisible()) {
- children[1].setBounds(bounds);
- getSash().setVisible(false);
- return;
- }
- if (!children[1].isVisible()) {
- children[0].setBounds(bounds);
- getSash().setVisible(false);
- return;
- }
-
- bounds = Geometry.copy(bounds);
-
- boolean vertical = getSash().isVertical();
-
- // If this is a horizontal sash, flip coordinate systems so
- // that we can eliminate special cases
- if (!vertical) {
- Geometry.flipXY(bounds);
- }
-
- ChildSizes childSizes = computeChildSizes(bounds.width, bounds.height, getSash().getLeft(), getSash().getRight(), bounds.width);
-
- getSash().setVisible(true);
- getSash().setEnabled(childSizes.resizable);
-
- Rectangle leftBounds = new Rectangle(bounds.x, bounds.y, childSizes.left, bounds.height);
- Rectangle sashBounds = new Rectangle(leftBounds.x + leftBounds.width, bounds.y, this.getSashSize(), bounds.height);
- Rectangle rightBounds = new Rectangle(sashBounds.x + sashBounds.width, bounds.y, childSizes.right, bounds.height);
-
- if (!vertical) {
- Geometry.flipXY(leftBounds);
- Geometry.flipXY(sashBounds);
- Geometry.flipXY(rightBounds);
- }
-
- getSash().setBounds(sashBounds);
- children[0].setBounds(leftBounds);
- children[1].setBounds(rightBounds);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.internal.LayoutTree#createControl(org.eclipse.swt.widgets.Composite)
- */
- public void createControl(Composite parent) {
- children[0].createControl(parent);
- children[1].createControl(parent);
- getSash().createControl(parent);
-
- super.createControl(parent);
- }
-
- //Added by hudsonr@us.ibm.com - bug 19524
-
- public boolean isCompressible() {
- return children[0].isCompressible() || children[1].isCompressible();
- }
-
- /**
- * Returns 0 if there is no bias. Returns -1 if the first child should be of
- * fixed size, and the second child should be compressed. Returns 1 if the
- * second child should be of fixed size.
- * @return the bias
- */
- public int getCompressionBias() {
- boolean left = children[0].isCompressible();
- boolean right = children[1].isCompressible();
- if (left == right) {
- return 0;
- }
- if (right) {
- return -1;
- }
- return 1;
- }
-
- boolean isLeftChild(LayoutTree toTest) {
- return children[0] == toTest;
- }
-
- LayoutTree getChild(boolean left) {
- int index = left ? 0 : 1;
- return (children[index]);
- }
-
- /**
- * Sets a child in this node
- */
- void setChild(boolean left, LayoutPart part) {
- LayoutTree child = new LayoutTree(part);
- setChild(left, child);
- flushCache();
- }
-
- /**
- * Sets a child in this node
- */
- void setChild(boolean left, LayoutTree child) {
- int index = left ? 0 : 1;
- children[index] = child;
- child.setParent(this);
- flushCache();
- }
-
- /**
- * Returns a string representation of this object.
- */
- public String toString() {
- String s = "<null>\n";//$NON-NLS-1$
- if (part.getControl() != null) {
- s = "<@" + part.getControl().hashCode() + ">\n";//$NON-NLS-2$//$NON-NLS-1$
- }
- String result = "["; //$NON-NLS-1$
- if (children[0].getParent() != this) {
- result = result + "{" + children[0] + "}" + s;//$NON-NLS-2$//$NON-NLS-1$
- } else {
- result = result + children[0] + s;
- }
-
- if (children[1].getParent() != this) {
- result = result + "{" + children[1] + "}]";//$NON-NLS-2$//$NON-NLS-1$
- } else {
- result = result + children[1] + "]";//$NON-NLS-1$
- }
- return result;
- }
-
- /**
- * Create the sashes if the children are visible
- * and dispose it if they are not.
- */
-// public void updateSashes(Composite parent) {
-// if (parent == null)
-// return;
-// children[0].updateSashes(parent);
-// children[1].updateSashes(parent);
-// if (children[0].isVisible() && children[1].isVisible())
-// getSash().createControl(parent);
-// else
-// getSash().dispose();
-// }
-
- /**
- * Writes a description of the layout to the given string buffer.
- * This is used for drag-drop test suites to determine if two layouts are the
- * same. Like a hash code, the description should compare as equal iff the
- * layouts are the same. However, it should be user-readable in order to
- * help debug failed tests. Although these are english readable strings,
- * they should not be translated or equality tests will fail.
- *
- * @param buf
- */
- public void describeLayout(StringBuffer buf) {
- if (!(children[0].isVisible())) {
- if (!children[1].isVisible()) {
- return;
- }
-
- children[1].describeLayout(buf);
- return;
- }
-
- if (!children[1].isVisible()) {
- children[0].describeLayout(buf);
- return;
- }
-
- buf.append("("); //$NON-NLS-1$
- children[0].describeLayout(buf);
-
- buf.append(getSash().isVertical() ? "|" : "-"); //$NON-NLS-1$ //$NON-NLS-2$
-
- children[1].describeLayout(buf);
- buf.append(")"); //$NON-NLS-1$
- }
-
-}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/MultiEditorInnerPane.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/MultiEditorInnerPane.java
deleted file mode 100644
index 4a218003538..00000000000
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/MultiEditorInnerPane.java
+++ /dev/null
@@ -1,117 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 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
- * Nikolay Botev - bug 240651
- *******************************************************************************/
-package org.eclipse.ui.internal;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.Listener;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IEditorReference;
-import org.eclipse.ui.part.AbstractMultiEditor;
-import org.eclipse.ui.part.MultiEditor;
-
-/**
- * Implements a pane of each editor inside a AbstractMultiEditor.
- */
-public class MultiEditorInnerPane extends EditorPane {
-
- EditorPane parentPane;
-
- /**
- * true if the parent editor is an instance of MultiEditor, which requires
- * operation in MultiEditor backwards compatibility mode
- */
- boolean multiEditorCompatibilityMode;
-
- /**
- * Constructor for MultiEditorInnerPane.
- */
- public MultiEditorInnerPane(EditorPane pane, IEditorReference ref,
- WorkbenchPage page, EditorStack workbook, boolean multiEditor) {
- super(ref, page, workbook);
- parentPane = pane;
- multiEditorCompatibilityMode = multiEditor;
- }
-
- AbstractMultiEditor getMultiEditor() {
- return (AbstractMultiEditor) parentPane.getPartReference()
- .getPart(true);
- }
-
- public void createControl(Composite parent) {
- super.createControl(parent);
- if (!multiEditorCompatibilityMode) {
- Control control = getControl();
- control.addListener(SWT.Activate, new Listener() {
- public void handleEvent(Event event) {
- if (event.type == SWT.Activate) {
- IEditorPart part = (IEditorPart) MultiEditorInnerPane.this.getEditorReference().getPart(
- true);
- AbstractMultiEditor multiEditor = getMultiEditor();
- multiEditor.activateEditor(part);
- multiEditor.setFocus();
- }
- }
- });
- // Inner editor panes should be visible by default
- control.setVisible(true);
- }
- }
-
- /**
- * Returns the outer editor.
- */
- public EditorPane getParentPane() {
- return parentPane;
- }
-
- /**
- * Update the gradient on the inner editor title bar
- */
- private void updateGradient() {
- AbstractMultiEditor abstractMultiEditor = getMultiEditor();
- if (abstractMultiEditor != null && multiEditorCompatibilityMode) {
- IEditorPart part = (IEditorPart) this.getEditorReference().getPart(
- true);
- if (part != null) {
- ((MultiEditor) abstractMultiEditor).updateGradient(part);
- }
- }
- }
-
- /**
- * Indicate focus in part.
- */
- public void showFocus(boolean inFocus) {
- super.showFocus(inFocus);
- updateGradient();
- }
-
- /* (non-Javadoc)
- * Method declared on PartPane.
- */
- /* package */void shellDeactivated() {
- super.shellDeactivated();
- updateGradient();
- }
-
- /* (non-Javadoc)
- * Method declared on PartPane.
- */
- /* package */void shellActivated() {
- super.shellActivated();
- updateGradient();
- }
-
-}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/PageLayout.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/PageLayout.java
deleted file mode 100644
index 8ce52829053..00000000000
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/PageLayout.java
+++ /dev/null
@@ -1,1013 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2009 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
- * Dan Rubel <dan_rubel@instantiations.com>
- * - Fix for bug 11490 - define hidden view (placeholder for view) in plugin.xml
- * Ted Stockwell <emorning@yahoo.com>
- * - Fix for bug 63595 - IPageLayout.addFastView regression (3.0M8 to 3.0M9)
- * Chris Gross <schtoo@schtoo.com>
- * - Fix for 99155 - allow standalone view placeholders
- * Chris Gross chris.gross@us.ibm.com Bug 107443
- *******************************************************************************/
-package org.eclipse.ui.internal;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.swt.SWT;
-import org.eclipse.ui.IFolderLayout;
-import org.eclipse.ui.IPageLayout;
-import org.eclipse.ui.IPerspectiveDescriptor;
-import org.eclipse.ui.IPlaceholderFolderLayout;
-import org.eclipse.ui.IViewLayout;
-import org.eclipse.ui.IViewReference;
-import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.activities.WorkbenchActivityHelper;
-import org.eclipse.ui.internal.presentations.PresentationFactoryUtil;
-import org.eclipse.ui.internal.registry.ActionSetRegistry;
-import org.eclipse.ui.internal.registry.IActionSetDescriptor;
-import org.eclipse.ui.internal.registry.ViewRegistry;
-import org.eclipse.ui.views.IViewDescriptor;
-import org.eclipse.ui.views.IViewRegistry;
-
-/**
- * This factory is used to define the initial layout of a part sash container.
- * <p>
- * Design notes: The design of <code>IPageLayout</code> is a reflection of
- * three requirements:
- * <ol>
- * <li>A mechanism is required to define the initial layout for a page. </li>
- * <li>The views and editors within a page will be persisted between
- * sessions.</li>
- * <li>The view and editor lifecycle for (1) and (2) should be identical.</li>
- * </ol>
- * </p>
- * <p>
- * In reflection of these requirements, the following strategy has been
- * implemented for layout definition.
- * <ol>
- * <li>A view extension is added to the workbench registry for the view.
- * This extension defines the extension id and extension class. </li>
- * <li>A view is added to a page by invoking one of the add methods
- * in <code>IPageLayout</code>. The type of view is passed as an
- * extension id, rather than a handle. The page layout will map
- * the extension id to a view class, create an instance of the class,
- * and then add the view to the page.</li>
- * </ol>
- * </p>
- */
-public class PageLayout implements IPageLayout {
- private ArrayList actionSets = new ArrayList(3);
-
- private IPerspectiveDescriptor descriptor;
-
- private LayoutPart editorFolder;
-
- private boolean editorVisible = true;
-
- private boolean fixed;
-
- private ArrayList fastViews = new ArrayList(3);
-
- private Map mapIDtoFolder = new HashMap(10);
-
- private Map mapIDtoPart = new HashMap(10);
-
- private Map mapIDtoViewLayoutRec = new HashMap(10);
-
- private Map mapFolderToFolderLayout = new HashMap(10);
-
- private ArrayList newWizardShortcuts = new ArrayList(3);
-
- private ArrayList perspectiveShortcuts = new ArrayList(3);
-
- private ViewSashContainer rootLayoutContainer;
-
- private ArrayList showInPartIds = new ArrayList(3);
-
- private ArrayList showViewShortcuts = new ArrayList(3);
-
- private ViewFactory viewFactory;
-
- private List minimizedStacks = new ArrayList();
-
- private Collection hiddenMenuItemIds = new ArrayList();
-
- private Collection hiddenToolBarItemIds = new ArrayList();
-
-
- /**
- * Constructs a new PageLayout for other purposes.
- */
- public PageLayout() {
- //no-op
- }
-
- /**
- * Constructs a new PageLayout for the normal case of creating a new
- * perspective.
- */
- public PageLayout(ViewSashContainer container, ViewFactory viewFactory,
- LayoutPart editorFolder, IPerspectiveDescriptor descriptor) {
- super();
- this.viewFactory = viewFactory;
- this.rootLayoutContainer = container;
- this.editorFolder = editorFolder;
- this.descriptor = descriptor;
- prefill();
- }
-
- /**
- * Adds the editor to a layout.
- */
- private void addEditorArea() {
- try {
- // Create the part.
- LayoutPart newPart = createView(ID_EDITOR_AREA);
- if (newPart == null) {
- // this should never happen as long as newID is the editor ID.
- return;
- }
-
- setRefPart(ID_EDITOR_AREA, newPart);
-
- // Add it to the layout.
- rootLayoutContainer.add(newPart);
- } catch (PartInitException e) {
- WorkbenchPlugin.log(getClass(), "addEditorArea()", e); //$NON-NLS-1$
- }
- }
-
- /**
- * Adds an action set to the page.
- *
- * @param actionSetID Identifies the action set extension to use. It must
- * exist within the workbench registry.
- */
- public void addActionSet(String actionSetID) {
- if (!actionSets.contains(actionSetID)) {
- actionSets.add(actionSetID);
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.IPageLayout#addFastView(java.lang.String)
- */
- public void addFastView(String id) {
- addFastView(id, INVALID_RATIO);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.IPageLayout#addFastView(java.lang.String, float)
- */
- public void addFastView(String id, float ratio) {
- if (checkPartInLayout(id)) {
- return;
- }
- if (id != null) {
- try {
- IViewDescriptor viewDescriptor = viewFactory.getViewRegistry()
- .find(ViewFactory.extractPrimaryId(id));
- if (!WorkbenchActivityHelper.filterItem(viewDescriptor)) {
- IViewReference ref = viewFactory.createView(ViewFactory
- .extractPrimaryId(id), ViewFactory
- .extractSecondaryId(id));
- fastViews.add(ref);
-
- // force creation of the view layout rec
- ViewLayoutRec rec = getViewLayoutRec(id, true);
-
- // remember the ratio, if valid
- if (ratio >= IPageLayout.RATIO_MIN
- && ratio <= IPageLayout.RATIO_MAX) {
- rec.fastViewWidthRatio = ratio;
- }
- }
- } catch (PartInitException e) {
- WorkbenchPlugin.log(getClass(), "addFastView", e); //$NON-NLS-1$
- }
- }
- }
-
- /**
- * Check to see if the partId represents a fast view's id.
- *
- * @param partId
- * The part's id.
- * @return true if the partId is a fast view id.
- */
- private boolean isFastViewId(String partId) {
- for (int i = 0; i < fastViews.size(); i++) {
- IViewReference ref = (IViewReference) fastViews.get(i);
- String secondaryId = ref.getSecondaryId();
- String refId = (secondaryId == null ? ref.getId() : ref.getId()
- + ":" + secondaryId); //$NON-NLS-1$
- if (refId.equals(partId)) {
- return true;
- }
- }
- return false;
- }
-
- /**
- * Returns the view layout record for the given view id, or null if not
- * found. If create is true, the record is created if it doesn't already
- * exist.
- *
- * @since 3.0
- */
- ViewLayoutRec getViewLayoutRec(String id, boolean create) {
- ViewLayoutRec rec = (ViewLayoutRec) mapIDtoViewLayoutRec.get(id);
- if (rec == null && create) {
- rec = new ViewLayoutRec();
- // set up the view layout appropriately if the page layout is fixed
- if (isFixed()) {
- rec.isCloseable = false;
- rec.isMoveable = false;
- }
- mapIDtoViewLayoutRec.put(id, rec);
- }
- return rec;
- }
-
- /**
- * Adds a creation wizard to the File New menu.
- * The id must name a new wizard extension contributed to the
- * workbench's extension point (named <code>"org.eclipse.ui.newWizards"</code>).
- *
- * @param id the wizard id
- */
- public void addNewWizardShortcut(String id) {
- if (!newWizardShortcuts.contains(id)) {
- newWizardShortcuts.add(id);
- }
- }
-
- /**
- * Add the layout part to the page's layout
- */
- private void addPart(LayoutPart newPart, String partId, int relationship,
- float ratio, String refId) {
-
- setRefPart(partId, newPart);
-
- // If the referenced part is inside a folder,
- // then use the folder as the reference part.
- LayoutPart refPart = getFolderPart(refId);
- if (refPart == null) {
- refPart = getRefPart(refId);
- }
-
- // Add it to the layout.
- if (refPart != null) {
- ratio = normalizeRatio(ratio);
- rootLayoutContainer.add(newPart, getPartSashConst(relationship),
- ratio, refPart);
- } else {
- WorkbenchPlugin.log(NLS.bind(WorkbenchMessages.PageLayout_missingRefPart, refId ));
- rootLayoutContainer.add(newPart);
- }
- }
-
- /**
- * Adds a perspective shortcut to the Perspective menu.
- * The id must name a perspective extension contributed to the
- * workbench's extension point (named <code>"org.eclipse.ui.perspectives"</code>).
- *
- * @param id the perspective id
- */
- public void addPerspectiveShortcut(String id) {
- if (!perspectiveShortcuts.contains(id)) {
- perspectiveShortcuts.add(id);
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.IPageLayout#addPlaceholder(java.lang.String, int, float, java.lang.String)
- */
- public void addPlaceholder(String viewId, int relationship, float ratio,
- String refId) {
- if (!checkValidPlaceholderId(viewId)) {
- return;
- }
-
- // Create the placeholder.
- PartPlaceholder newPart = new PartPlaceholder(viewId);
- addPart(newPart, viewId, relationship, ratio, refId);
- // force creation of the view layout rec
- getViewLayoutRec(viewId, true);
- }
-
- /**
- * Checks whether the given id is a valid placeholder id.
- * A placeholder id may be simple or compound, and can optionally contain a wildcard.
- *
- * @param id the placeholder id
- * @return <code>true</code> if the given id is a valid placeholder id, <code>false</code> otherwise
- */
- boolean checkValidPlaceholderId(String id) {
- // Check that view is not already in layout.
- // This check is done even if the id has a wildcard, since it's incorrect to create
- // multiple placeholders with the same id, wildcard or not.
- if (checkPartInLayout(id)) {
- return false;
- }
-
- // check that primary view id is valid, but only if it has no wildcard
- String primaryId = ViewFactory.extractPrimaryId(id);
- if (!ViewFactory.hasWildcard(primaryId)) {
- IViewRegistry reg = WorkbenchPlugin.getDefault().getViewRegistry();
- IViewDescriptor desc = reg.find(primaryId);
- if (desc == null) {
- // cannot safely open the dialog so log the problem
- WorkbenchPlugin.log("Unable to find view with id: " + primaryId + ", when creating perspective " + getDescriptor().getId()); //$NON-NLS-1$ //$NON-NLS-2$
- return false;
- }
- }
-
- return true;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.IPageLayout#addShowInPart(java.lang.String)
- */
- public void addShowInPart(String id) {
- if (!showInPartIds.contains(id)) {
- showInPartIds.add(id);
- }
- }
-
- /**
- * Adds a view to the Show View menu. The id must name a view extension
- * contributed to the workbench's extension point (named <code>"org.eclipse.ui.views"</code>).
- *
- * @param id the view id
- */
- public void addShowViewShortcut(String id) {
- if (!showViewShortcuts.contains(id)) {
- showViewShortcuts.add(id);
- }
- }
-
- /**
- * Adds an id to the collection of menu item ids that should be hidden in this perspective.
- * The given id should be one that represents an existing menu item.
- *
- * @param id the menu item id
- */
- public void addHiddenMenuItemId(String id) {
- if (!hiddenMenuItemIds.contains(id)) {
- hiddenMenuItemIds.add(id);
- }
- }
-
- /**
- * Adds an id to the collection of toolbar item ids that should be hidden in this perspective.
- * The given id should be one that represents an existing toolbar item.
- *
- * @param id the toolbar item id
- */
- public void addHiddenToolBarItemId(String id) {
- if (!hiddenToolBarItemIds.contains(id)) {
- hiddenToolBarItemIds.add(id);
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.IPageLayout#addView(java.lang.String, int, float, java.lang.String)
- */
- public void addView(String viewId, int relationship, float ratio,
- String refId) {
- addView(viewId, relationship, ratio, refId, false, false, true);
- }
-
- /**
- * Convenience method to allow setting the initial minimized
- * state if a new stack is created. Used by the 'perspectiveExtension'
- * reader.
- *
- * @since 3.3
- */
- public void addView(String viewId, int relationship, float ratio,
- String refId, boolean minimized) {
- addView(viewId, relationship, ratio, refId, minimized, false, true);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.IPageLayout#addView(java.lang.String, int, float, java.lang.String)
- */
- private void addView(String viewId, int relationship, float ratio,
- String refId, boolean minimized, boolean standalone, boolean showTitle) {
- if (checkPartInLayout(viewId)) {
- return;
- }
-
- try {
- // Create the part.
- LayoutPart newPart = createView(viewId);
- if (newPart == null) {
- addPlaceholder(viewId, relationship, ratio, refId);
- LayoutHelper.addViewActivator(this, viewId);
- } else {
- int appearance = PresentationFactoryUtil.ROLE_VIEW;
- if (standalone) {
- if (showTitle) {
- appearance = PresentationFactoryUtil.ROLE_STANDALONE;
- } else {
- appearance = PresentationFactoryUtil.ROLE_STANDALONE_NOTITLE;
- }
- }
-
- ViewStack newFolder = new ViewStack(rootLayoutContainer.page,
- true, appearance, null);
- newFolder.add(newPart);
- setFolderPart(viewId, newFolder);
- addPart(newFolder, viewId, relationship, ratio, refId);
- // force creation of the view layout rec
- getViewLayoutRec(viewId, true);
-
- // Capture any minimized stacks
- if (minimized) {
- // Remember the minimized stacks so we can
- // move them to the trim when the Perspective
- // activates...
- minimizedStacks.add(newFolder);
- }
- }
- } catch (PartInitException e) {
- WorkbenchPlugin.log(getClass(), "addView", e); //$NON-NLS-1$
- }
- }
-
- public List getMinimizedStacks() {
- return minimizedStacks;
- }
-
- /**
- * Verify that the part is already present in the layout
- * and cannot be added again. Log a warning message.
- */
- /*package*/
- boolean checkPartInLayout(String partId) {
- if (getRefPart(partId) != null || isFastViewId(partId)) {
- WorkbenchPlugin.log(NLS.bind(WorkbenchMessages.PageLayout_duplicateRefPart,partId ));
- return true;
- }
-
- return false;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.IPageLayout#createFolder(java.lang.String, int, float, java.lang.String)
- */
- public IFolderLayout createFolder(String folderId, int relationship,
- float ratio, String refId) {
- if (checkPartInLayout(folderId)) {
- ViewStack folder = (ViewStack) getRefPart(folderId);
-
- return (IFolderLayout) mapFolderToFolderLayout.get(folder);
- }
-
- // Create the folder.
- ViewStack folder = new ViewStack(rootLayoutContainer.page);
- folder.setID(folderId);
-
- if (getDescriptor() != null
- && viewFactory.getWorkbenchPage().window.getWindowAdvisor()
- .isDurableFolder(getDescriptor().getId(), folderId)) {
- folder.setDurable(true);
- }
-
- addPart(folder, folderId, relationship, ratio, refId);
-
- // Create a wrapper.
- FolderLayout layout = new FolderLayout(this, folder, viewFactory);
-
- mapFolderToFolderLayout.put(folder,layout);
-
- return layout;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.IPageLayout#createPlaceholderFolder(java.lang.String, int, float, java.lang.String)
- */
- public IPlaceholderFolderLayout createPlaceholderFolder(String folderId,
- int relationship, float ratio, String refId) {
- if (checkPartInLayout(folderId)) {
- ContainerPlaceholder folder = (ContainerPlaceholder) getRefPart(folderId);
-
- return (IPlaceholderFolderLayout) mapFolderToFolderLayout.get(folder);
- }
-
- // Create the folder.
- ContainerPlaceholder folder = new ContainerPlaceholder(null);
- folder.setContainer(rootLayoutContainer);
- folder.setRealContainer(new ViewStack(rootLayoutContainer.page));
- folder.setID(folderId);
- addPart(folder, folderId, relationship, ratio, refId);
-
- // Create a wrapper.
- IPlaceholderFolderLayout layout = new PlaceholderFolderLayout(this, folder);
-
- mapFolderToFolderLayout.put(folder,layout);
-
- return layout;
- }
-
- /**
- * Create a new <code>LayoutPart</code>.
- *
- * @param partID the id of the part to create.
- * @return the <code>LayoutPart</code>, or <code>null</code> if it should not be
- * created because of activity filtering.
- * @throws PartInitException thrown if there is a problem creating the part.
- */
- private LayoutPart createView(String partID) throws PartInitException {
- if (partID.equals(ID_EDITOR_AREA)) {
- return editorFolder;
- }
- IViewDescriptor viewDescriptor = null;
-
- IViewRegistry viewRegistry = viewFactory.getViewRegistry();
- String primaryId = ViewFactory.extractPrimaryId(partID);
-
- if (viewRegistry instanceof ViewRegistry) {
- viewDescriptor = ((ViewRegistry) viewRegistry).findInternal(primaryId);
- if (viewDescriptor != null && WorkbenchActivityHelper.restrictUseOf(viewDescriptor)) {
- return null;
- }
- } else {
- viewDescriptor = viewRegistry.find(primaryId);
- }
- if (WorkbenchActivityHelper.filterItem(viewDescriptor)) {
- return null;
- }
- return LayoutHelper.createView(getViewFactory(), partID);
- }
-
- /**
- * @return the action set list for the page. This is <code>List</code> of
- * <code>String</code>s.
- */
- public ArrayList getActionSets() {
- return actionSets;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.IPageLayout#getDescriptor()
- */
- public IPerspectiveDescriptor getDescriptor() {
- return descriptor;
- }
-
- /**
- * @return an identifier for the editor area. The editor area is
- * automatically added to each layout before any other part. It should be
- * used as a reference part for other views.
- */
- public String getEditorArea() {
- return ID_EDITOR_AREA;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.IPageLayout#getEditorReuseThreshold()
- */
- public int getEditorReuseThreshold() {
- return -1;
- }
-
- /**
- * @return <code>ArrayList</code>
- */
- public ArrayList getFastViews() {
- return fastViews;
- }
-
- /**
- * @return the folder part containing the given view ID or <code>null</code>
- * if none (i.e. part of the page layout instead of a folder layout).
- */
- private ViewStack getFolderPart(String viewId) {
- return (ViewStack) mapIDtoFolder.get(viewId);
- }
-
- /**
- * @return the new wizard shortcuts associated with the page. This is a <code>List</code> of
- * <code>String</code>s.
- */
- public ArrayList getNewWizardShortcuts() {
- return newWizardShortcuts;
- }
-
- /**
- * @return the part sash container const for a layout value.
- */
- private int getPartSashConst(int nRelationship) {
- return nRelationship;
- }
-
- /**
- * @return the perspective shortcuts associated with the page. This is a <code>List</code> of
- * <code>String</code>s.
- */
- public ArrayList getPerspectiveShortcuts() {
- return perspectiveShortcuts;
- }
-
- /**
- * @return the part for a given ID.
- */
- /*package*/
- LayoutPart getRefPart(String partID) {
- return (LayoutPart) mapIDtoPart.get(partID);
- }
-
- /**
- * @return the top level layout container.
- */
- public ViewSashContainer getRootLayoutContainer() {
- return rootLayoutContainer;
- }
-
- /**
- * @return the ids of the parts to list in the Show In... prompter. This is
- * a <code>List</code> of <code>String</code>s.
- */
- public ArrayList getShowInPartIds() {
- return showInPartIds;
- }
-
- /**
- * @return the show view shortcuts associated with the page. This is a <code>List</code> of
- * <code>String</code>s.
- */
- public ArrayList getShowViewShortcuts() {
- return showViewShortcuts;
- }
-
- /**
- * @return the collection of menu item ids that should be hidden. This is a <code>List</code> of
- * <code>String</code>s.
- */
- public Collection getHiddenMenuItems() {
- return hiddenMenuItemIds;
- }
-
- /**
- * @return the collection of toolbar item ids that should be hidden. This is a <code>List</code> of
- * <code>String</code>s.
- */
- public Collection getHiddenToolBarItems() {
- return hiddenToolBarItemIds;
- }
-
- /**
- * @return the <code>ViewFactory</code> for this <code>PageLayout</code>.
- * @since 3.0
- */
- /* package */
- ViewFactory getViewFactory() {
- return viewFactory;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.IPageLayout#isEditorAreaVisible()
- */
- public boolean isEditorAreaVisible() {
- return editorVisible;
- }
-
- /**
- * Trim the ratio so that direct manipulation of parts is easy.
- *
- * @param in the initial ratio.
- * @return the normalized ratio.
- */
- private float normalizeRatio(float in) {
- if (in < RATIO_MIN) {
- in = RATIO_MIN;
- }
- if (in > RATIO_MAX) {
- in = RATIO_MAX;
- }
- return in;
- }
-
- /**
- * Prefill the layout with required parts.
- */
- private void prefill() {
- addEditorArea();
-
- // Add default action sets.
- ActionSetRegistry reg = WorkbenchPlugin.getDefault()
- .getActionSetRegistry();
- IActionSetDescriptor[] array = reg.getActionSets();
- int count = array.length;
- for (int nX = 0; nX < count; nX++) {
- IActionSetDescriptor desc = array[nX];
- if (desc.isInitiallyVisible()) {
- addActionSet(desc.getId());
- }
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.IPageLayout#setEditorAreaVisible(boolean)
- */
- public void setEditorAreaVisible(boolean showEditorArea) {
- editorVisible = showEditorArea;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.IPageLayout#setEditorReuseThreshold(int)
- */
- public void setEditorReuseThreshold(int openEditors) {
- //no-op
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.IPageLayout#setFixed(boolean)
- */
- public void setFixed(boolean fixed) {
- this.fixed = fixed;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.IPageLayout#getFixed()
- */
- public boolean isFixed() {
- return fixed;
- }
-
- /**
- * Map the folder part containing the given view ID.
- *
- * @param viewId the part ID.
- * @param container the <code>ContainerPlaceholder</code>.
- */
- /*package*/
- void setFolderPart(String viewId, ContainerPlaceholder container) {
- LayoutPart tabFolder = container.getRealContainer();
- mapIDtoFolder.put(viewId, tabFolder);
- }
-
- /**
- * Map the folder part containing the given view ID.
- *
- * @param viewId the part ID.
- * @param folder the <code>ViewStack</code>.
- */
- /*package*/
- void setFolderPart(String viewId, ViewStack folder) {
- mapIDtoFolder.put(viewId, folder);
- }
-
- /**
- * Map an ID to a part.
- *
- * @param partId the part ID.
- * @param part the <code>LayoutPart</code>.
- */
- /*package*/
- void setRefPart(String partID, LayoutPart part) {
- mapIDtoPart.put(partID, part);
- }
-
- // stackPart(Layoutpart, String, String) added by dan_rubel@instantiations.com
- /**
- * Stack a part on top of another.
- *
- * @param newPart the new part.
- * @param viewId the view ID.
- * @param refId the reference ID.
- */
- private void stackPart(LayoutPart newPart, String viewId, String refId) {
- setRefPart(viewId, newPart);
- // force creation of the view layout rec
- getViewLayoutRec(viewId, true);
-
- // If ref part is in a folder than just add the
- // new view to that folder.
- ViewStack folder = getFolderPart(refId);
- if (folder != null) {
- folder.add(newPart);
- setFolderPart(viewId, folder);
- return;
- }
-
- // If the ref part is in the page layout then create
- // a new folder and add the new view.
- LayoutPart refPart = getRefPart(refId);
- if (refPart != null && (refPart instanceof PartPane || refPart instanceof PartPlaceholder)) {
- ViewStack newFolder = new ViewStack(rootLayoutContainer.page);
- rootLayoutContainer.replace(refPart, newFolder);
- newFolder.add(refPart);
- newFolder.add(newPart);
- setFolderPart(refId, newFolder);
- setFolderPart(viewId, newFolder);
- return;
- }
-
- // If ref part is not found then just do add.
- WorkbenchPlugin.log(NLS.bind(WorkbenchMessages.PageLayout_missingRefPart, refId ));
- rootLayoutContainer.add(newPart);
- }
-
- // stackPlaceholder(String, String) added by dan_rubel@instantiations.com
- /**
- * Stack a placeholder on top of another.
- *
- * @param viewId the view ID.
- * @param refId the reference ID.
- */
- public void stackPlaceholder(String viewId, String refId) {
- if (checkPartInLayout(viewId)) {
- return;
- }
-
- // Create the placeholder.
- PartPlaceholder newPart = new PartPlaceholder(viewId);
-
- LayoutPart refPart = getRefPart(refId);
- if (refPart != null) {
- newPart.setContainer(refPart.getContainer());
- }
-
- stackPart(newPart, viewId, refId);
- }
-
- // stackView(String, String) modified by dan_rubel@instantiations.com
- /**
- * Stack one view on top of another.
- *
- * @param viewId the view ID.
- * @param refId the reference ID.
- */
- public void stackView(String viewId, String refId) {
- if (checkPartInLayout(viewId)) {
- return;
- }
-
- // Create the new part.
- try {
- LayoutPart newPart = createView(viewId);
- if (newPart == null) {
- stackPlaceholder(viewId, refId);
- LayoutHelper.addViewActivator(this, viewId);
- } else {
- stackPart(newPart, viewId, refId);
- }
- } catch (PartInitException e) {
- WorkbenchPlugin.log(getClass(), "stackView", e); //$NON-NLS-1$
- }
- }
-
- /**
- * Converts SWT position constants into layout position constants.
- *
- * @param swtConstant one of SWT.TOP, SWT.BOTTOM, SWT.LEFT, or SWT.RIGHT
- * @return one of IPageLayout.TOP, IPageLayout.BOTTOM, IPageLayout.LEFT, IPageLayout.RIGHT, or -1 indicating an
- * invalid input
- *
- * @since 3.0
- */
- public static int swtConstantToLayoutPosition(int swtConstant) {
- switch (swtConstant) {
- case SWT.TOP:
- return IPageLayout.TOP;
- case SWT.BOTTOM:
- return IPageLayout.BOTTOM;
- case SWT.RIGHT:
- return IPageLayout.RIGHT;
- case SWT.LEFT:
- return IPageLayout.LEFT;
- }
-
- return -1;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.IPageLayout#addStandaloneView(java.lang.String, boolean, int, float, java.lang.String)
- * @since 3.0
- */
- public void addStandaloneView(String viewId, boolean showTitle,
- int relationship, float ratio, String refId) {
- addView(viewId, relationship, ratio, refId, false, true, showTitle);
- ViewLayoutRec rec = getViewLayoutRec(viewId, true);
- rec.isStandalone = true;
- rec.showTitle = showTitle;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.IPageLayout#addStandaloneViewPlaceholder(java.lang.String, int, float, java.lang.String, boolean)
- */
- public void addStandaloneViewPlaceholder(String viewId, int relationship,
- float ratio, String refId, boolean showTitle) {
-
- String stackId = viewId + ".standalonefolder"; //$NON-NLS-1$
-
- // Check to see if the view is already in the layout
- if (!checkValidPlaceholderId(viewId)) {
- return;
- }
-
- // Create the folder.
- ContainerPlaceholder folder = new ContainerPlaceholder(null);
- folder.setContainer(rootLayoutContainer);
- int appearance = PresentationFactoryUtil.ROLE_STANDALONE;
- if (!showTitle) {
- appearance = PresentationFactoryUtil.ROLE_STANDALONE_NOTITLE;
- }
- folder.setRealContainer(new ViewStack(rootLayoutContainer.page, true,
- appearance, null));
- folder.setID(stackId);
- addPart(folder, stackId, relationship, ratio, refId);
-
- // Create a wrapper.
- PlaceholderFolderLayout placeHolder = new PlaceholderFolderLayout(this,
- folder);
-
- // Add the standalone view immediately
- placeHolder.addPlaceholder(viewId);
-
- ViewLayoutRec rec = getViewLayoutRec(viewId, true);
- rec.isStandalone = true;
- rec.showTitle = showTitle;
- }
-
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.IPageLayout#getViewLayout(java.lang.String)
- * @since 3.0
- */
- public IViewLayout getViewLayout(String viewId) {
- ViewLayoutRec rec = getViewLayoutRec(viewId, true);
- if (rec == null) {
- return null;
- }
- return new ViewLayout(this, rec);
- }
-
- /**
- * @since 3.0
- */
- public Map getIDtoViewLayoutRecMap() {
- return mapIDtoViewLayoutRec;
- }
-
- /**
- * Removes any existing placeholder with the given id.
- *
- * @param id the id for the placeholder
- * @since 3.1
- */
- public void removePlaceholder(String id) {
- LayoutPart part = getRefPart(id);
- if (part instanceof PartPlaceholder) {
- ViewStack stack = getFolderPart(id);
- if (stack != null) {
- stack.remove(part);
- }
- else {
- rootLayoutContainer.remove(part);
- }
- mapIDtoPart.remove(id);
- mapIDtoFolder.remove(id);
- mapIDtoViewLayoutRec.remove(id);
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.IPageLayout#getFolderForView(java.lang.String)
- */
- public IPlaceholderFolderLayout getFolderForView(String viewId)
- {
- if (!mapIDtoFolder.containsKey(viewId))
- return null;
-
- ViewStack folder = (ViewStack) mapIDtoFolder.get(viewId);
- IPlaceholderFolderLayout layout = null;
- if (!mapFolderToFolderLayout.containsKey(folder))
- {
- layout = new FolderLayout(this, folder, viewFactory);
- mapFolderToFolderLayout.put(folder, layout);
- }
- else
- {
- layout = (IPlaceholderFolderLayout)mapFolderToFolderLayout.get(folder);
- }
- return layout;
- }
-}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/PartList.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/PartList.java
deleted file mode 100644
index d0999c4618e..00000000000
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/PartList.java
+++ /dev/null
@@ -1,370 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2008 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.core.runtime.Assert;
-import org.eclipse.jface.dialogs.IPageChangeProvider;
-import org.eclipse.jface.dialogs.IPageChangedListener;
-import org.eclipse.jface.dialogs.PageChangedEvent;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IEditorReference;
-import org.eclipse.ui.IPropertyListener;
-import org.eclipse.ui.ISaveablesLifecycleListener;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.IWorkbenchPartConstants;
-import org.eclipse.ui.IWorkbenchPartReference;
-import org.eclipse.ui.IWorkbenchPartSite;
-import org.eclipse.ui.part.AbstractMultiEditor;
-
-public abstract class PartList {
- private IWorkbenchPartReference activePartReference;
-
- private IEditorReference activeEditorReference;
-
- // private List parts = new ArrayList();
-
- private IPropertyListener listener = new IPropertyListener() {
- public void propertyChanged(Object source, int propId) {
- WorkbenchPartReference ref = (WorkbenchPartReference) source;
-
- switch (propId) {
- case WorkbenchPartReference.INTERNAL_PROPERTY_OPENED:
- partOpened(ref);
- break;
- case WorkbenchPartReference.INTERNAL_PROPERTY_CLOSED:
- partClosed(ref);
- break;
- case WorkbenchPartReference.INTERNAL_PROPERTY_VISIBLE: {
- if (ref.getVisible()) {
- partVisible(ref);
- } else {
- partHidden(ref);
- }
- break;
- }
- case IWorkbenchPartConstants.PROP_INPUT: {
- partInputChanged(ref);
- break;
- }
- }
- }
- };
-
- private IPageChangedListener partPageListener = new IPageChangedListener() {
- public void pageChanged(PageChangedEvent event) {
- firePageChanged(event);
- }
- };
-
- public IWorkbenchPartReference getActivePartReference() {
- return activePartReference;
- }
-
-
- public IEditorReference getActiveEditorReference() {
- return activeEditorReference;
- }
-
- public IEditorPart getActiveEditor() {
- return activeEditorReference == null ? null : activeEditorReference
- .getEditor(false);
- }
-
- public IWorkbenchPart getActivePart() {
- return activePartReference == null ? null : activePartReference
- .getPart(false);
- }
-
- public void addPart(WorkbenchPartReference ref) {
- Assert.isNotNull(ref);
-
- ref.addInternalPropertyListener(listener);
-
- // parts.add(ref);
- firePartAdded(ref);
-
- // If this part is already open, fire the "part opened" event
- // immediately
- if (ref.getPart(false) != null) {
- partOpened(ref);
- }
-
- // If this part is already visible, fire the visibility event
- // immediately
- if (ref.getVisible()) {
- partVisible(ref);
- }
- }
-
- /**
- * Sets the active part.
- *
- * @param ref
- */
- public void setActivePart(IWorkbenchPartReference ref) {
- if (ref == activePartReference) {
- return;
- }
-
- IWorkbenchPartReference oldPart = activePartReference;
-
- // A part can't be activated until it is added
- // Assert.isTrue(ref == null || parts.contains(ref));
-
- if (ref != null) {
- IWorkbenchPart part = ref.getPart(true);
- Assert.isNotNull(part);
- if (part instanceof AbstractMultiEditor) {
- IWorkbenchPartSite site = ((AbstractMultiEditor) part)
- .getActiveEditor().getSite();
- if (site instanceof PartSite) {
- ref = ((PartSite) site).getPane().getPartReference();
- }
- }
- }
-
- activePartReference = ref;
-
- fireActivePartChanged(oldPart, ref);
- }
-
- public void setActiveEditor(IEditorReference ref) {
- if (ref == activeEditorReference) {
- return;
- }
-
- // A part can't be activated until it is added
- // Assert.isTrue(ref == null || parts.contains(ref));
-
- if (ref != null) {
- IWorkbenchPart part = ref.getPart(true);
- Assert.isNotNull(part);
- if (part instanceof AbstractMultiEditor) {
- IWorkbenchPartSite site = ((AbstractMultiEditor) part)
- .getActiveEditor().getSite();
- if (site instanceof PartSite) {
- ref = (IEditorReference) ((PartSite) site).getPane()
- .getPartReference();
- }
- }
- }
-
- activeEditorReference = ref;
-
- fireActiveEditorChanged(ref);
- }
-
- /**
- * In order to remove a part, it must first be deactivated.
- */
- public void removePart(WorkbenchPartReference ref) {
- Assert.isNotNull(ref);
- // It is an error to remove a part that isn't in the list
- // Assert.isTrue(parts.contains(ref));
- // We're not allowed to remove the active part. We must deactivate it
- // first.
- Assert.isTrue(ref != activePartReference);
- // We're not allowed to remove the active editor. We must deactivate it
- // first.
- Assert.isTrue(ref != activeEditorReference);
-
- if (ref.getVisible()) {
- ref.setVisible(false);
- }
-
- // If this part is currently open, fire the "part closed" event before
- // removal
- if (ref.getPart(false) != null) {
- partClosed(ref);
- }
-
- ref.removeInternalPropertyListener(listener);
-
- firePartRemoved(ref);
- }
-
- private void partInputChanged(WorkbenchPartReference ref) {
- firePartInputChanged(ref);
- }
-
- private void partHidden(WorkbenchPartReference ref) {
- // Part should not be null
- Assert.isNotNull(ref);
- // This event should only be fired if the part is actually visible
- Assert.isTrue(!ref.getVisible());
- // We shouldn't be receiving events from parts until they are in the
- // list
- // Assert.isTrue(parts.contains(ref));
-
- firePartHidden(ref);
- }
-
- private void partOpened(WorkbenchPartReference ref) {
- Assert.isNotNull(ref);
-
- IWorkbenchPart actualPart = ref.getPart(false);
- // We're firing the event that says "the part was just created"... so
- // there better be a part there.
- Assert.isNotNull(actualPart);
- // Must be called after the part is inserted into the part list
- // Assert.isTrue(parts.contains(ref));
- // The active part must be opened before it is activated, so we should
- // never get an
- // open event for a part that is already active. (This either indicates
- // that a redundant
- // open event was fired or that a closed part was somehow activated)
- Assert.isTrue(activePartReference != ref);
- // The active editor must be opened before it is activated, so we should
- // never get an
- // open event for an editor that is already active. (This either
- // indicates that a redundant
- // open event was fired or that a closed editor was somehow activated)
- Assert.isTrue(activeEditorReference != ref);
-
- SaveablesList modelManager = (SaveablesList) actualPart
- .getSite().getService(ISaveablesLifecycleListener.class);
- modelManager.postOpen(actualPart);
- if (actualPart instanceof IPageChangeProvider) {
- ((IPageChangeProvider) actualPart)
- .addPageChangedListener(partPageListener);
- }
-
- // Fire the "part opened" event
- firePartOpened(ref);
- }
-
- /**
- * Called when a concrete part is about to be destroyed. This is called
- * BEFORE disposal happens, so the part should still be accessable from the
- * part reference.
- *
- * @param ref
- */
- private void partClosed(WorkbenchPartReference ref) {
- Assert.isNotNull(ref);
-
- IWorkbenchPart actualPart = ref.getPart(false);
- // Called before the part is disposed, so the part should still be
- // there.
- Assert.isNotNull(actualPart);
- // Must be called before the part is actually removed from the part list
- // Assert.isTrue(parts.contains(ref));
- // Not allowed to close the active part. The part must be deactivated
- // before it may
- // be closed.
- Assert.isTrue(activePartReference != ref);
- // Not allowed to close the active editor. The editor must be
- // deactivated before it may
- // be closed.
- Assert.isTrue(activeEditorReference != ref);
-
- if (actualPart instanceof IPageChangeProvider) {
- ((IPageChangeProvider) actualPart)
- .removePageChangedListener(partPageListener);
- }
-
- firePartClosed(ref);
- }
-
- private void partVisible(WorkbenchPartReference ref) {
- // Part should not be null
- Assert.isNotNull(ref);
- // This event should only be fired if the part is actually visible
- Assert.isTrue(ref.getVisible());
- // We shouldn't be receiving events from parts until they are in the
- // list
- // Assert.isTrue(parts.contains(ref));
- // Part must be open before it can be made visible
- Assert.isNotNull(ref.getPart(false));
-
- firePartVisible(ref);
- }
-
- /**
- * Fire the event indicating that a part reference was just realized. That
- * is, the concrete IWorkbenchPart has been attached to the part reference.
- *
- * @param part
- * the reference that was create
- */
- protected abstract void firePartOpened(IWorkbenchPartReference part);
-
- /**
- * Fire the event indicating that a part reference was just realized. That
- * is, the concrete IWorkbenchPart has been attached to the part reference.
- *
- * @param part
- * the reference that was create
- */
- protected abstract void firePartClosed(IWorkbenchPartReference part);
-
- /**
- * Indicates that a new part reference was added to the list.
- *
- * @param part
- */
- protected abstract void firePartAdded(IWorkbenchPartReference part);
-
- /**
- * Indicates that a part reference was removed from the list
- *
- * @param part
- */
- protected abstract void firePartRemoved(IWorkbenchPartReference part);
-
- /**
- * Indicates that the active editor changed
- *
- * @param part
- * active part reference or null if none
- */
- protected abstract void fireActiveEditorChanged(IWorkbenchPartReference ref);
-
- /**
- * Indicates that the active part has changed
- *
- * @param part
- * active part reference or null if none
- */
- protected abstract void fireActivePartChanged(
- IWorkbenchPartReference oldPart, IWorkbenchPartReference newPart);
-
- /**
- * Indicates that the part has been made visible
- *
- * @param ref
- */
- protected abstract void firePartVisible(IWorkbenchPartReference ref);
-
- /**
- * Indicates that the part has been hidden
- *
- * @param ref
- */
- protected abstract void firePartHidden(IWorkbenchPartReference ref);
-
- /**
- * Indicates that the part input has changed
- *
- * @param ref
- */
- protected abstract void firePartInputChanged(IWorkbenchPartReference ref);
-
- protected abstract void firePartBroughtToTop(IWorkbenchPartReference ref);
-
- /**
- * Fire a page changed event for any IPartListener2 that also
- * implement IPageChangedListener.
- *
- * @param event the page change event, which conatins the source.
- */
- protected abstract void firePageChanged(PageChangedEvent event);
-}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/PartPlaceholder.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/PartPlaceholder.java
deleted file mode 100644
index dbf1a1ce207..00000000000
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/PartPlaceholder.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 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.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-
-/**
- * A PlaceHolder is a non-visible stand-in for a layout part.
- */
-public class PartPlaceholder extends LayoutPart {
-
- /**
- * Placeholder ids may contain wildcards. This is the wildcard string.
- *
- * @since 3.0
- */
- public static String WILD_CARD = "*"; //$NON-NLS-1$
-
- public PartPlaceholder(String id) {
- super(id);
- }
-
- /**
- * Creates the SWT control
- */
- public void createControl(Composite parent) {
- // do nothing
- }
-
- /**
- * Get the part control. This method may return null.
- */
- public Control getControl() {
- return null;
- }
-
- /**
- * Returns whether this placeholder has a wildcard.
- *
- * @since 3.0
- */
- public boolean hasWildCard() {
- return getID().indexOf(WILD_CARD) != -1;
- }
-}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/PartSashContainer.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/PartSashContainer.java
deleted file mode 100644
index 947c28921ef..00000000000
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/PartSashContainer.java
+++ /dev/null
@@ -1,1436 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2009 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
- * Cagatay Kavukcuoglu <cagatayk@acm.org>
- * - Fix for bug 10025 - Resizing views should not use height ratios
- * Chris Gross chris.gross@us.ibm.com Bug 107443
- *******************************************************************************/
-package org.eclipse.ui.internal;
-
-import java.util.ArrayList;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.jface.util.Geometry;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.ControlAdapter;
-import org.eclipse.swt.events.ControlEvent;
-import org.eclipse.swt.events.ControlListener;
-import org.eclipse.swt.graphics.Cursor;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.ui.IPageLayout;
-import org.eclipse.ui.IViewReference;
-import org.eclipse.ui.internal.dnd.AbstractDropTarget;
-import org.eclipse.ui.internal.dnd.DragUtil;
-import org.eclipse.ui.internal.dnd.IDragOverListener;
-import org.eclipse.ui.internal.dnd.IDropTarget;
-import org.eclipse.ui.internal.dnd.SwtUtil;
-
-/**
- * Abstract container that groups various layout
- * parts (possibly other containers) together as
- * a unit. Manages the placement and size of these
- * layout part based on the location of sashes within
- * the container.
- */
-public abstract class PartSashContainer extends LayoutPart implements
- ILayoutContainer, IDragOverListener {
-
- protected Composite parent;
-
- protected ControlListener resizeListener;
-
- protected LayoutTree root;
-
- private Composite parentWidget;
-
- private LayoutPart zoomedPart;
-
- protected WorkbenchPage page;
-
- boolean active = false;
- boolean layoutDirty = false;
-
- /* Array of LayoutPart */
- protected ArrayList children = new ArrayList();
-
- private SashContainerDropTarget dropTarget;
-
- protected static class RelationshipInfo {
- protected LayoutPart part;
-
- protected LayoutPart relative;
-
- protected int relationship;
-
- /**
- * Preferred size for the left child (this would be the size, in pixels of the child
- * at the time the sash was last moved)
- */
- protected int left;
-
- /**
- * Preferred size for the right child (this would be the size, in pixels of the child
- * at the time the sash was last moved)
- */
- protected int right;
-
- /**
- * Computes the "ratio" for this container. That is, the ratio of the left side over
- * the sum of left + right. This is only used for serializing PartSashContainers in
- * a form that can be read by old versions of Eclipse. This can be removed if this
- * is no longer required.
- *
- * @return the pre-Eclipse 3.0 sash ratio
- */
- public float getRatio() {
- int total = left + right;
- if (total > 0) {
- return (float) left / (float) total;
- }
-
- return 0.5f;
- }
- }
-
- private class SashContainerDropTarget extends AbstractDropTarget {
- private int side;
-
- private int cursor;
-
- private LayoutPart targetPart;
-
- private LayoutPart sourcePart;
-
- public SashContainerDropTarget(LayoutPart sourcePart, int side, int cursor, LayoutPart targetPart) {
- this.setTarget(sourcePart, side, cursor, targetPart);
- }
-
- public void setTarget(LayoutPart sourcePart, int side, int cursor, LayoutPart targetPart) {
- this.side = side;
- this.targetPart = targetPart;
- this.sourcePart = sourcePart;
- this.cursor = cursor;
- }
-
- public void drop() {
- if (side != SWT.NONE) {
- LayoutPart visiblePart = sourcePart;
-
- if (sourcePart instanceof PartStack) {
- visiblePart = getVisiblePart((PartStack) sourcePart);
- }
-
- dropObject(getVisibleParts(sourcePart), visiblePart,
- targetPart, side);
- }
- }
-
- public Cursor getCursor() {
- return DragCursors.getCursor(DragCursors
- .positionToDragCursor(cursor));
- }
-
- public Rectangle getSnapRectangle() {
- Rectangle targetBounds;
-
- if (targetPart != null) {
- targetBounds = DragUtil.getDisplayBounds(targetPart
- .getControl());
- } else {
- targetBounds = DragUtil.getDisplayBounds(getParent());
- }
-
- if (side == SWT.CENTER || side == SWT.NONE) {
- return targetBounds;
- }
-
- int distance = Geometry.getDimension(targetBounds, !Geometry
- .isHorizontal(side));
-
- return Geometry.getExtrudedEdge(targetBounds,
- (int) (distance * getDockingRatio(sourcePart, targetPart)),
- side);
- }
- }
-
- public PartSashContainer(String id, final WorkbenchPage page, Composite parentWidget) {
- super(id);
- this.page = page;
- this.parentWidget = parentWidget;
- resizeListener = new ControlAdapter() {
- public void controlResized(ControlEvent e) {
- resizeSashes();
- }
- };
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.internal.ILayoutContainer#obscuredByZoom(org.eclipse.ui.internal.LayoutPart)
- */
- public boolean childObscuredByZoom(LayoutPart toTest) {
- LayoutPart zoomPart = getZoomedPart();
-
- if (zoomPart != null && toTest != zoomPart) {
- return true;
- }
- return isObscuredByZoom();
- }
-
- /**
- * Given an object associated with a drag (a PartPane or PartStack), this returns
- * the actual PartPanes being dragged.
- *
- * @param pane
- * @return
- */
- private PartPane[] getVisibleParts(LayoutPart pane) {
- if (pane instanceof PartPane) {
- return new PartPane[] { (PartPane) pane };
- } else if (pane instanceof PartStack) {
- PartStack stack = (PartStack) pane;
-
- LayoutPart[] children = stack.getChildren();
- ArrayList result = new ArrayList(children.length);
- for (int idx = 0; idx < children.length; idx++) {
- LayoutPart next = children[idx];
- if (next instanceof PartPane) {
- result.add(next);
- }
- }
-
- return (PartPane[]) result.toArray(new PartPane[result.size()]);
- }
-
- return new PartPane[0];
- }
-
- /**
- * Find the sashs around the specified part.
- */
- public void findSashes(LayoutPart pane, PartPane.Sashes sashes) {
- if (root == null) {
- return;
- }
- LayoutTree part = root.find(pane);
- if (part == null) {
- return;
- }
- part.findSashes(sashes);
- }
-
- /**
- * Add a part.
- */
- public void add(LayoutPart child) {
- if (child == null) {
- return;
- }
-
- addEnhanced(child, SWT.RIGHT, 0.5f, findBottomRight());
- }
-
- /**
- * Add a new part relative to another. This should be used in place of <code>add</code>.
- * It differs as follows:
- * <ul>
- * <li>relationships are specified using SWT direction constants</li>
- * <li>the ratio applies to the newly added child -- not the upper-left child</li>
- * </ul>
- *
- * @param child new part to add to the layout
- * @param swtDirectionConstant one of SWT.TOP, SWT.BOTTOM, SWT.LEFT, or SWT.RIGHT
- * @param ratioForNewPart a value between 0.0 and 1.0 specifying how much space will be allocated for the newly added part
- * @param relative existing part indicating where the new child should be attached
- * @since 3.0
- */
- void addEnhanced(LayoutPart child, int swtDirectionConstant,
- float ratioForNewPart, LayoutPart relative) {
- int relativePosition = PageLayout
- .swtConstantToLayoutPosition(swtDirectionConstant);
-
- float ratioForUpperLeftPart;
-
- if (relativePosition == IPageLayout.RIGHT
- || relativePosition == IPageLayout.BOTTOM) {
- ratioForUpperLeftPart = 1.0f - ratioForNewPart;
- } else {
- ratioForUpperLeftPart = ratioForNewPart;
- }
-
- add(child, relativePosition, ratioForUpperLeftPart, relative);
- }
-
- /**
- * Add a part relative to another. For compatibility only. New code should use
- * addEnhanced, above.
- *
- * @param child the new part to add
- * @param relationship one of PageLayout.TOP, PageLayout.BOTTOM, PageLayout.LEFT, or PageLayout.RIGHT
- * @param ratio a value between 0.0 and 1.0, indicating how much space will be allocated to the UPPER-LEFT pane
- * @param relative part where the new part will be attached
- */
- public void add(LayoutPart child, int relationship, float ratio,
- LayoutPart relative) {
- boolean isHorizontal = (relationship == IPageLayout.LEFT || relationship == IPageLayout.RIGHT);
-
- LayoutTree node = null;
- if (root != null && relative != null) {
- node = root.find(relative);
- }
-
- Rectangle bounds;
- if (getParent() == null) {
- Control control = getPage().getClientComposite();
- if (control != null && !control.isDisposed()) {
- bounds = control.getBounds();
- } else {
- bounds = new Rectangle(0, 0, 800, 600);
- }
- bounds.x = 0;
- bounds.y = 0;
- } else {
- bounds = getBounds();
- }
-
- int totalSize = measureTree(bounds, node, isHorizontal);
-
- int left = (int) (totalSize * ratio);
- int right = totalSize - left;
-
- add(child, relationship, left, right, relative);
- }
-
- static int measureTree(Rectangle outerBounds, LayoutTree toMeasure,
- boolean horizontal) {
- if (toMeasure == null) {
- return Geometry.getDimension(outerBounds, horizontal);
- }
-
- LayoutTreeNode parent = toMeasure.getParent();
- if (parent == null) {
- return Geometry.getDimension(outerBounds, horizontal);
- }
-
- if (parent.getSash().isHorizontal() == horizontal) {
- return measureTree(outerBounds, parent, horizontal);
- }
-
- boolean isLeft = parent.isLeftChild(toMeasure);
-
- LayoutTree otherChild = parent.getChild(!isLeft);
- if (otherChild.isVisible()) {
- int left = parent.getSash().getLeft();
- int right = parent.getSash().getRight();
- int childSize = isLeft ? left : right;
-
- int bias = parent.getCompressionBias();
-
- // Normalize bias: 1 = we're fixed, -1 = other child is fixed
- if (isLeft) {
- bias = -bias;
- }
-
- if (bias == 1) {
- // If we're fixed, return the fixed size
- return childSize;
- } else if (bias == -1) {
-
- // If the other child is fixed, return the size of the parent minus the fixed size of the
- // other child
- return measureTree(outerBounds, parent, horizontal)
- - (left + right - childSize);
- }
-
- // Ensure we don't get a 'divide by zero'
- if ((left+right) == 0)
- return 0;
-
- // Else return the size of the parent, scaled appropriately
- return measureTree(outerBounds, parent, horizontal) * childSize
- / (left + right);
- }
-
- return measureTree(outerBounds, parent, horizontal);
- }
-
- protected void addChild(RelationshipInfo info) {
- LayoutPart child = info.part;
-
- children.add(child);
-
- if (root == null) {
- root = new LayoutTree(child);
- } else {
- //Add the part to the tree.
- int vertical = (info.relationship == IPageLayout.LEFT || info.relationship == IPageLayout.RIGHT) ? SWT.VERTICAL
- : SWT.HORIZONTAL;
- boolean left = info.relationship == IPageLayout.LEFT
- || info.relationship == IPageLayout.TOP;
- LayoutPartSash sash = new LayoutPartSash(this, vertical);
- sash.setSizes(info.left, info.right);
- if ((parent != null) && !(child instanceof PartPlaceholder)) {
- sash.createControl(parent);
- }
- root = root.insert(child, left, sash, info.relative);
- }
-
- childAdded(child);
-
- if (active) {
- child.createControl(parent);
- child.setVisible(true);
- child.setContainer(this);
- resizeChild(child);
- }
-
- }
-
- /**
- * Adds the child using ratio and position attributes
- * from the specified placeholder without replacing
- * the placeholder
- *
- * FIXME: I believe there is a bug in computeRelation()
- * when a part is positioned relative to the editorarea.
- * We end up with a null relative and 0.0 for a ratio.
- */
- void addChildForPlaceholder(LayoutPart child, LayoutPart placeholder) {
- RelationshipInfo newRelationshipInfo = new RelationshipInfo();
- newRelationshipInfo.part = child;
- if (root != null) {
- newRelationshipInfo.relationship = IPageLayout.RIGHT;
- newRelationshipInfo.relative = root.findBottomRight();
- newRelationshipInfo.left = 200;
- newRelationshipInfo.right = 200;
- }
-
- // find the relationship info for the placeholder
- RelationshipInfo[] relationships = computeRelation();
- for (int i = 0; i < relationships.length; i++) {
- RelationshipInfo info = relationships[i];
- if (info.part == placeholder) {
- newRelationshipInfo.left = info.left;
- newRelationshipInfo.right = info.right;
- newRelationshipInfo.relationship = info.relationship;
- newRelationshipInfo.relative = info.relative;
- }
- }
-
- addChild(newRelationshipInfo);
- flushLayout();
- }
-
- /**
- * See ILayoutContainer#allowBorder
- */
- public boolean allowsBorder() {
- return true;
- }
-
- /**
- * Notification that a child layout part has been
- * added to the container. Subclasses may override
- * this method to perform any container specific
- * work.
- */
- protected void childAdded(LayoutPart child) {
- if (isDeferred()) {
- child.deferUpdates(true);
- }
- }
-
- /**
- * Notification that a child layout part has been
- * removed from the container. Subclasses may override
- * this method to perform any container specific
- * work.
- */
- protected void childRemoved(LayoutPart child) {
- if (isDeferred()) {
- child.deferUpdates(false);
- }
- }
-
- /**
- * Returns an array with all the relation ship between the
- * parts.
- */
- public RelationshipInfo[] computeRelation() {
- LayoutTree treeRoot = root;
- ArrayList list = new ArrayList();
- if (treeRoot == null) {
- return new RelationshipInfo[0];
- }
- RelationshipInfo r = new RelationshipInfo();
- r.part = treeRoot.computeRelation(list);
- list.add(0, r);
- RelationshipInfo[] result = new RelationshipInfo[list.size()];
- list.toArray(result);
- return result;
- }
-
- public void setActive(boolean isActive) {
- if (isActive == active) {
- return;
- }
-
- active = isActive;
-
- ArrayList children = (ArrayList) this.children.clone();
- for (int i = 0, length = children.size(); i < length; i++) {
- LayoutPart child = (LayoutPart) children.get(i);
-
- if (child instanceof PartStack) {
- PartStack stack = (PartStack) child;
- stack.setActive(isActive);
- }
- }
-
- if (isActive) {
-
- createControl(parentWidget);
-
- parent.addControlListener(resizeListener);
-
- DragUtil.addDragTarget(parent, this);
- DragUtil.addDragTarget(parent.getShell(), this);
-
- //ArrayList children = (ArrayList) this.children.clone();
- for (int i = 0, length = children.size(); i < length; i++) {
- LayoutPart child = (LayoutPart) children.get(i);
- child.setContainer(this);
- child.setVisible(zoomedPart == null || child == zoomedPart);
- if (!(child instanceof PartStack)) {
- if (root != null) {
- LayoutTree node = root.find(child);
- if (node != null) {
- node.flushCache();
- }
- }
- }
- }
-
- if (root != null) {
- //root.flushChildren();
- if (!isZoomed()) {
- root.createControl(parent);
- }
- }
-
- resizeSashes();
- } else {
- DragUtil.removeDragTarget(parent, this);
- DragUtil.removeDragTarget(parent.getShell(), this);
-
- // remove all Listeners
- if (resizeListener != null && parent != null) {
- parent.removeControlListener(resizeListener);
- }
-
- if (children != null) {
- for (int i = 0, length = children.size(); i < length; i++) {
- LayoutPart child = (LayoutPart) children.get(i);
- child.setContainer(null);
- if (child instanceof PartStack) {
- child.setVisible(false);
- }
- }
- }
-
- disposeSashes();
-
- //dispose();
- }
- }
-
- /**
- * @see LayoutPart#getControl
- */
- public void createControl(Composite parentWidget) {
- if (this.parent != null) {
- return;
- }
-
- parent = createParent(parentWidget);
-
- ArrayList children = (ArrayList) this.children.clone();
- for (int i = 0, length = children.size(); i < length; i++) {
- LayoutPart child = (LayoutPart) children.get(i);
- child.createControl(parent);
- }
-
- }
-
- /**
- * Subclasses override this method to specify
- * the composite to use to parent all children
- * layout parts it contains.
- */
- protected abstract Composite createParent(Composite parentWidget);
-
- /**
- * @see LayoutPart#dispose
- */
- public void dispose() {
- if (parent == null) {
- return;
- }
-
- if (children != null) {
- for (int i = 0, length = children.size(); i < length; i++) {
- LayoutPart child = (LayoutPart) children.get(i);
-
- // In PartSashContainer dispose really means deactivate, so we
- // only dispose PartTabFolders.
- if (child instanceof PartStack) {
- child.dispose();
- }
- }
- }
- disposeParent();
- this.parent = null;
- }
-
- /**
- * Subclasses override this method to dispose
- * of any swt resources created during createParent.
- */
- protected abstract void disposeParent();
-
- /**
- * Dispose all sashs used in this perspective.
- */
- public void disposeSashes() {
- if (root != null) {
- root.disposeSashes();
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.internal.LayoutPart#setVisible(boolean)
- */
- public void setVisible(boolean makeVisible) {
-
- if (makeVisible == getVisible()) {
- return;
- }
-
- if (!SwtUtil.isDisposed(this.parent)) {
- this.parent.setEnabled(makeVisible);
- }
- super.setVisible(makeVisible);
-
- ArrayList children = (ArrayList) this.children.clone();
- for (int i = 0, length = children.size(); i < length; i++) {
- LayoutPart child = (LayoutPart) children.get(i);
- child.setVisible(makeVisible && (zoomedPart == null || child == zoomedPart));
- }
- }
-
- /**
- * Return the most bottom right part or null if none.
- */
- public LayoutPart findBottomRight() {
- if (root == null) {
- return null;
- }
- return root.findBottomRight();
- }
-
- /**
- * @see LayoutPart#getBounds
- */
- public Rectangle getBounds() {
- return this.parent.getBounds();
- }
-
- /**
- * @see ILayoutContainer#getChildren
- */
- public LayoutPart[] getChildren() {
- LayoutPart[] result = new LayoutPart[children.size()];
- children.toArray(result);
- return result;
- }
-
- /**
- * @see LayoutPart#getControl
- */
- public Control getControl() {
- return this.parent;
- }
-
- public LayoutTree getLayoutTree() {
- return root;
- }
-
- /**
- * For themes.
- *
- * @return the current WorkbenchPage.
- */
- public WorkbenchPage getPage() {
- return page;
- }
-
- /**
- * Returns the composite used to parent all the
- * layout parts contained within.
- */
- public Composite getParent() {
- return parent;
- }
-
- protected boolean isChild(LayoutPart part) {
- return children.indexOf(part) >= 0;
- }
-
- /**
- * Returns whether this container is zoomed.
- */
- public boolean isZoomed() {
- return (zoomedPart != null);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.internal.LayoutPart#forceLayout(org.eclipse.ui.internal.LayoutPart)
- */
- public void resizeChild(LayoutPart childThatChanged) {
- if (root != null) {
- LayoutTree tree = root.find(childThatChanged);
-
- if (tree != null) {
- tree.flushCache();
- }
- }
-
- flushLayout();
-
- }
-
- /**
- * Remove a part.
- */
- public void remove(LayoutPart child) {
- if (child == getZoomedPart()) {
- childRequestZoomOut();
- }
-
- if (!isChild(child)) {
- return;
- }
-
- children.remove(child);
- if (root != null) {
- root = root.remove(child);
- }
- childRemoved(child);
-
- if (active) {
- child.setVisible(false);
- child.setContainer(null);
- flushLayout();
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.internal.LayoutPart#forceLayout()
- */
- public void flushLayout() {
- layoutDirty = true;
- super.flushLayout();
-
- if (layoutDirty) {
- resizeSashes();
- }
- }
-
- /**
- * Replace one part with another.
- */
- public void replace(LayoutPart oldChild, LayoutPart newChild) {
-
- if (!isChild(oldChild)) {
- return;
- }
-
- if (oldChild == getZoomedPart()) {
- if (newChild instanceof PartPlaceholder) {
- childRequestZoomOut();
- } else {
- zoomedPart.setZoomed(false);
- zoomedPart = newChild;
- zoomedPart.setZoomed(true);
- }
- }
-
- children.remove(oldChild);
- children.add(newChild);
-
- childAdded(newChild);
-
- if (root != null) {
- LayoutTree leaf = null;
-
- leaf = root.find(oldChild);
- if (leaf != null) {
- leaf.setPart(newChild);
- }
- }
-
- childRemoved(oldChild);
- if (active) {
- oldChild.setVisible(false);
- oldChild.setContainer(null);
- newChild.createControl(parent);
- newChild.setContainer(this);
- newChild.setVisible(zoomedPart == null || zoomedPart == newChild);
- resizeChild(newChild);
- }
- }
-
- private void resizeSashes() {
- layoutDirty = false;
- if (!active) {
- return;
- }
-
- if (isZoomed()) {
- getZoomedPart().setBounds(parent.getClientArea());
- } else {
- if (root != null) {
- root.setBounds(parent.getClientArea());
- }
- }
- }
-
- /**
- * Returns the maximum size that can be utilized by this part if the given width and
- * height are available. Parts can overload this if they have a quantized set of preferred
- * sizes.
- *
- * @param width available horizontal space (pixels)
- * @return returns a new point where point.x is <= availableWidth and point.y is <= availableHeight
- */
- public int computePreferredSize(boolean width, int availableParallel, int availablePerpendicular, int preferredParallel) {
- if (isZoomed()) {
- return getZoomedPart().computePreferredSize(width, availableParallel, availablePerpendicular, preferredParallel);
- }
-
- if (root != null) {
- return root.computePreferredSize(width, availableParallel, availablePerpendicular, preferredParallel);
- }
-
- return preferredParallel;
- }
-
- public int getSizeFlags(boolean width) {
- if (isZoomed()) {
- return getZoomedPart().getSizeFlags(width);
- }
-
- if (root != null) {
- return root.getSizeFlags(width);
- }
-
- return 0;
- }
-
- /**
- * @see LayoutPart#setBounds
- */
- public void setBounds(Rectangle r) {
- this.parent.setBounds(r);
- }
-
- /**
- * Zoom in on a particular layout part.
- *
- * The implementation of zoom is quite simple. When zoom occurs we create
- * a zoom root which only contains the zoom part. We store the old
- * root in unzoomRoot and then active the zoom root. When unzoom occurs
- * we restore the unzoomRoot and dispose the zoom root.
- *
- * Note: Method assumes we are active.
- */
- private void zoomIn(LayoutPart part) {
- // Sanity check.
- if (isZoomed()) {
- return;
- }
-
- // Hide the sashes
- root.disposeSashes();
-
- // Make all parts invisible except for the zoomed part
- LayoutPart[] children = getChildren();
- for (int i = 0; i < children.length; i++) {
- LayoutPart child = children[i];
- child.setVisible(child == part);
- }
-
- zoomedPart = part;
-
- // Notify the part that it has been zoomed
- part.setZoomed(true);
-
- // Remember that we need to trigger a layout
- layoutDirty = true;
- }
-
- /**
- * Returns the currently zoomed part or null if none
- *
- * @return the currently zoomed part or null if none
- * @since 3.1
- */
- public LayoutPart getZoomedPart() {
- return zoomedPart;
- }
-
- public void childRequestZoomIn(LayoutPart toZoom) {
- if (!SwtUtil.isDisposed(this.parent)) {
- this.parent.setRedraw(false);
- }
- try {
- zoomIn(toZoom);
-
- requestZoomIn();
-
- if (layoutDirty) {
- resizeSashes();
- }
- } finally {
- if (!SwtUtil.isDisposed(this.parent)) {
- this.parent.setRedraw(true);
- }
- }
- }
-
- public void childRequestZoomOut() {
- if (!SwtUtil.isDisposed(this.parent)) {
- this.parent.setRedraw(false);
- }
- try {
- zoomOut();
-
- requestZoomOut();
-
- if (layoutDirty) {
- resizeSashes();
- }
- } finally {
- if (!SwtUtil.isDisposed(this.parent)) {
- this.parent.setRedraw(true);
- }
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.internal.LayoutPart#setZoomed(boolean)
- */
- public void setZoomed(boolean isZoomed) {
- if (!isZoomed) {
- zoomOut();
- } else {
- if (!isZoomed()) {
- LayoutPart toZoom = pickPartToZoom();
-
- if (toZoom != null) {
- zoomIn(toZoom);
- }
- }
- }
- super.setZoomed(isZoomed);
- }
-
- public LayoutPart pickPartToZoom() {
- return findBottomRight();
- }
-
- /**
- * Zoom out.
- *
- * See zoomIn for implementation details.
- *
- * Note: Method assumes we are active.
- */
- private void zoomOut() {
- // Sanity check.
- if (!isZoomed()) {
- return;
- }
-
- LayoutPart zoomedPart = this.zoomedPart;
- this.zoomedPart = null;
- // Inform the part that it is no longer zoomed
- zoomedPart.setZoomed(false);
-
- // Make all children visible
- LayoutPart[] children = getChildren();
- for (int i = 0; i < children.length; i++) {
- LayoutPart child = children[i];
-
- child.setVisible(true);
- }
-
- // Recreate the sashes
- root.createControl(getParent());
-
- // Ensure that the part being un-zoomed will have its size refreshed.
- LayoutTree node = root.find(zoomedPart);
- node.flushCache();
-
- layoutDirty = true;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.internal.dnd.IDragOverListener#drag(org.eclipse.swt.widgets.Control, java.lang.Object, org.eclipse.swt.graphics.Point, org.eclipse.swt.graphics.Rectangle)
- */
- public IDropTarget drag(Control currentControl, Object draggedObject,
- Point position, Rectangle dragRectangle) {
- if (!(draggedObject instanceof LayoutPart)) {
- return null;
- }
-
- final LayoutPart sourcePart = (LayoutPart) draggedObject;
-
- if (!isStackType(sourcePart) && !isPaneType(sourcePart)) {
- return null;
- }
-
- boolean differentWindows = sourcePart.getWorkbenchWindow() != getWorkbenchWindow();
-
- // Special check for views that haven't been shown yet. Since they don't have
- // controls checking for their WBW results in a 'null' (but their 'page' is set
- if (sourcePart instanceof ViewPane) {
- differentWindows = ((ViewPane)sourcePart).getPage() != getPage();
- }
-
- boolean editorDropOK = ((sourcePart instanceof EditorPane) &&
- sourcePart.getWorkbenchWindow().getWorkbench() ==
- getWorkbenchWindow().getWorkbench());
- if (differentWindows && !editorDropOK) {
- return null;
- }
-
- Rectangle containerBounds = DragUtil.getDisplayBounds(parent);
- LayoutPart targetPart = null;
- ILayoutContainer sourceContainer = isStackType(sourcePart) ? (ILayoutContainer) sourcePart
- : sourcePart.getContainer();
-
- // If this container has no visible children
- if (getVisibleChildrenCount(this) == 0) {
- return createDropTarget(sourcePart, SWT.CENTER, SWT.CENTER, null);
- }
-
- if (containerBounds.contains(position)) {
-
- if (root != null) {
- targetPart = root.findPart(parent.toControl(position));
- }
-
- if (targetPart != null) {
- final Control targetControl = targetPart.getControl();
-
- final Rectangle targetBounds = DragUtil
- .getDisplayBounds(targetControl);
-
- int side = Geometry.getClosestSide(targetBounds, position);
- int distance = Geometry.getDistanceFromEdge(targetBounds, position, side);
-
- // is the source coming from a standalone part
- boolean standalone = (isStackType(sourcePart)
- && ((PartStack) sourcePart).isStandalone())
- || (isPaneType(sourcePart)
- && ((PartPane) sourcePart).getStack()!=null
- && ((PartPane) sourcePart).getStack().isStandalone());
-
- // Only allow dropping onto an existing stack from different windows
- if (differentWindows && targetPart instanceof EditorStack) {
- IDropTarget target = targetPart.getDropTarget(draggedObject, position);
- return target;
- }
-
- // Reserve the 5 pixels around the edge of the part for the drop-on-edge cursor
- if (distance >= 5 && !standalone) {
- // Otherwise, ask the part if it has any special meaning for this drop location
- IDropTarget target = targetPart.getDropTarget(draggedObject, position);
- if (target != null) {
- return target;
- }
- }
-
- if (distance > 30 && isStackType(targetPart) && !standalone) {
- if (targetPart instanceof ILayoutContainer) {
- ILayoutContainer targetContainer = (ILayoutContainer)targetPart;
- if (targetContainer.allowsAdd(sourcePart)) {
- side = SWT.CENTER;
- }
- }
- }
-
- // If the part doesn't want to override this drop location then drop on the edge
-
- // A "pointless drop" would be one that will put the dragged object back where it started.
- // Note that it should be perfectly valid to drag an object back to where it came from -- however,
- // the drop should be ignored.
-
- boolean pointlessDrop = isZoomed();
-
- if (sourcePart == targetPart) {
- pointlessDrop = true;
- }
-
- if ((sourceContainer != null)
- && (sourceContainer == targetPart)
- && getVisibleChildrenCount(sourceContainer) <= 1) {
- pointlessDrop = true;
- }
-
- if (side == SWT.CENTER
- && sourcePart.getContainer() == targetPart) {
- pointlessDrop = true;
- }
-
- int cursor = side;
-
- if (pointlessDrop) {
- side = SWT.NONE;
- cursor = SWT.CENTER;
- }
-
- return createDropTarget(sourcePart, side, cursor, targetPart);
- }
- } else {
- // We only allow dropping into a stack, not creating one
- if (differentWindows)
- return null;
-
- int side = Geometry.getClosestSide(containerBounds, position);
-
- boolean pointlessDrop = isZoomed();
-
- if ((isStackType(sourcePart) && sourcePart.getContainer() == this)
- || (sourcePart.getContainer() != null
- && isPaneType(sourcePart)
- && getVisibleChildrenCount(sourcePart.getContainer()) <= 1)
- && ((LayoutPart)sourcePart.getContainer()).getContainer() == this) {
- if (root == null || getVisibleChildrenCount(this) <= 1) {
- pointlessDrop = true;
- }
- }
-
- int cursor = Geometry.getOppositeSide(side);
-
- if (pointlessDrop) {
- side = SWT.NONE;
- }
-
- return createDropTarget(sourcePart, side, cursor, null);
- }
-
- return null;
- }
-
- /**
- * @param sourcePart
- * @param targetPart
- * @param side
- * @param cursor
- * @return
- * @since 3.1
- */
- private SashContainerDropTarget createDropTarget(final LayoutPart sourcePart, int side, int cursor, LayoutPart targetPart) {
- if (dropTarget == null) {
- dropTarget = new SashContainerDropTarget(sourcePart, side, cursor,
- targetPart);
- } else {
- dropTarget.setTarget(sourcePart, side, cursor, targetPart);
- }
- return dropTarget;
- }
-
- /**
- * Returns true iff this PartSashContainer allows its parts to be stacked onto the given
- * container.
- *
- * @param container
- * @return
- */
- public abstract boolean isStackType(LayoutPart toTest);
-
- public abstract boolean isPaneType(LayoutPart toTest);
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.internal.PartSashContainer#dropObject(org.eclipse.ui.internal.LayoutPart, org.eclipse.ui.internal.LayoutPart, int)
- */
- protected void dropObject(PartPane[] toDrop, LayoutPart visiblePart,
- LayoutPart targetPart, int side) {
- getControl().setRedraw(false);
-
- // Targetpart is null if there isn't a part under the cursor (all the parts are
- // hidden or the container is empty). In this case, the actual side doesn't really
- // since we'll be the only visible container and will fill the entire space. However,
- // we can't leave it as SWT.CENTER since we can't stack if we don't have something
- // to stack on. In this case, we pick SWT.BOTTOM -- this will insert the new pane
- // below any currently-hidden parts.
- if (targetPart == null && side == SWT.CENTER) {
- side = SWT.BOTTOM;
- }
-
- if (side == SWT.CENTER) {
- if (isStackType(targetPart)) {
- PartStack stack = (PartStack) targetPart;
- for (int idx = 0; idx < toDrop.length; idx++) {
- PartPane next = toDrop[idx];
- stack(next, stack);
- }
- }
- } else {
- PartStack newPart = createStack();
-
- // if the toDrop array has 1 item propogate the stack
- // appearance
- if (toDrop.length == 1 && toDrop[0].getStack()!=null) {
- toDrop[0].getStack().copyAppearanceProperties(newPart);
- }
-
- for (int idx = 0; idx < toDrop.length; idx++) {
- PartPane next = toDrop[idx];
- stack(next, newPart);
- }
-
- addEnhanced(newPart, side, getDockingRatio(newPart, targetPart),
- targetPart);
- }
-
- if (visiblePart != null) {
- setVisiblePart(visiblePart.getContainer(), visiblePart);
- }
-
- getControl().setRedraw(true);
-
- if (visiblePart != null) {
- visiblePart.setFocus();
- }
- }
-
- protected abstract PartStack createStack();
-
- public void stack(LayoutPart newPart, ILayoutContainer container) {
- getControl().setRedraw(false);
-
- // Only deref the part if it is being referenced in -this- perspective
- Perspective persp = page.getActivePerspective();
- PerspectiveHelper pres = (persp != null) ? persp.getPresentation() : null;
- if (pres != null && newPart instanceof ViewPane) {
- ViewPane vp = (ViewPane) newPart;
- IViewReference vRef = vp.getViewReference();
- LayoutPart fpp = pres.findPart(vRef.getId(), vRef.getSecondaryId());
-
- // 'findPart' won't find fast views that don't exist in the main presentation
- if (fpp != null || persp.isFastView(vRef)) {
- // Remove the part from old container.
- derefPart(newPart);
- }
- }
- else {
- // Remove the part from old container.
- derefPart(newPart);
- }
-
- // Reparent part and add it to the workbook
- newPart.reparent(getParent());
- container.add(newPart);
- getControl().setRedraw(true);
-
- }
-
- /**
- * @param container
- * @param visiblePart
- */
- protected abstract void setVisiblePart(ILayoutContainer container,
- LayoutPart visiblePart);
-
- /**
- * @param container
- * @return
- */
- protected abstract LayoutPart getVisiblePart(ILayoutContainer container);
-
- /**
- * @param sourcePart
- */
- protected void derefPart(LayoutPart sourcePart) {
- ILayoutContainer container = sourcePart.getContainer();
- if (container != null) {
- container.remove(sourcePart);
- }
-
- if (container instanceof LayoutPart) {
- if (isStackType((LayoutPart) container)) {
- PartStack stack = (PartStack) container;
- if (stack.getChildren().length == 0) {
- remove(stack);
- stack.dispose();
- }
- }
- }
- }
-
- protected int getVisibleChildrenCount(ILayoutContainer container) {
- // Treat null as an empty container
- if (container == null) {
- return 0;
- }
-
- LayoutPart[] children = container.getChildren();
-
- int count = 0;
- for (int idx = 0; idx < children.length; idx++) {
- if (!(children[idx] instanceof PartPlaceholder)) {
- count++;
- }
- }
-
- return count;
- }
-
- protected float getDockingRatio(LayoutPart dragged, LayoutPart target) {
- return 0.5f;
- }
-
- /**
- * Writes a description of the layout to the given string buffer.
- * This is used for drag-drop test suites to determine if two layouts are the
- * same. Like a hash code, the description should compare as equal iff the
- * layouts are the same. However, it should be user-readable in order to
- * help debug failed tests. Although these are english readable strings,
- * they should not be translated or equality tests will fail.
- *
- * @param buf
- */
- public void describeLayout(StringBuffer buf) {
- if (root == null) {
- return;
- }
-
- if (isZoomed()) {
- buf.append("zoomed "); //$NON-NLS-1$
- root.describeLayout(buf);
- } else {
- buf.append("layout "); //$NON-NLS-1$
- root.describeLayout(buf);
- }
- }
-
- /**
- * Adds a new child to the container relative to some part
- *
- * @param child
- * @param relationship
- * @param left preferred pixel size of the left/top child
- * @param right preferred pixel size of the right/bottom child
- * @param relative relative part
- */
- void add(LayoutPart child, int relationship, int left, int right,
- LayoutPart relative) {
-
- if (child == null) {
- return;
- }
- if (relative != null && !isChild(relative)) {
- return;
- }
- if (relationship < IPageLayout.LEFT
- || relationship > IPageLayout.BOTTOM) {
- relationship = IPageLayout.LEFT;
- }
-
- // store info about relative positions
- RelationshipInfo info = new RelationshipInfo();
- info.part = child;
- info.relationship = relationship;
- info.left = left;
- info.right = right;
- info.relative = relative;
- addChild(info);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.internal.ILayoutContainer#isZoomed(org.eclipse.ui.internal.LayoutPart)
- */
- public boolean childIsZoomed(LayoutPart toTest) {
- return toTest == getZoomedPart();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.internal.ILayoutContainer#allowsAutoFocus()
- */
- public boolean allowsAutoFocus() {
- return true;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.internal.LayoutPart#startDeferringEvents()
- */
- protected void startDeferringEvents() {
- super.startDeferringEvents();
-
- LayoutPart[] deferredChildren = (LayoutPart[]) children.toArray(new LayoutPart[children.size()]);
- for (int i = 0; i < deferredChildren.length; i++) {
- LayoutPart child = deferredChildren[i];
-
- child.deferUpdates(true);
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.internal.LayoutPart#handleDeferredEvents()
- */
- protected void handleDeferredEvents() {
- super.handleDeferredEvents();
-
- LayoutPart[] deferredChildren = (LayoutPart[]) children.toArray(new LayoutPart[children.size()]);
- for (int i = 0; i < deferredChildren.length; i++) {
- LayoutPart child = deferredChildren[i];
-
- child.deferUpdates(false);
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.internal.LayoutPart#testInvariants()
- */
- public void testInvariants() {
- super.testInvariants();
-
- // If we have a parent container, ensure that we are displaying the zoomed appearance iff
- // our parent is zoomed in on us
- if (getContainer() != null) {
- Assert.isTrue((getZoomedPart() != null) == (getContainer().childIsZoomed(this)));
- }
-
- LayoutPart[] childArray = getChildren();
-
- for (int idx = 0; idx < childArray.length; idx++) {
- childArray[idx].testInvariants();
- }
-
- // If we're zoomed, ensure that we're actually zoomed into one of our children
- if (isZoomed()) {
- Assert.isTrue(children.contains(zoomedPart));
- }
- }
-}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/PartStack.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/PartStack.java
deleted file mode 100644
index 972da4f3a03..00000000000
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/PartStack.java
+++ /dev/null
@@ -1,1804 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2010 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
- * Chris Gross chris.gross@us.ibm.com Bug 107443
- *******************************************************************************/
-package org.eclipse.ui.internal;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.ListenerList;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.jface.action.ContributionItem;
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.util.Geometry;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.swt.graphics.Cursor;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.IMemento;
-import org.eclipse.ui.IPersistable;
-import org.eclipse.ui.IPropertyListener;
-import org.eclipse.ui.IWorkbenchPartReference;
-import org.eclipse.ui.IWorkbenchPreferenceConstants;
-import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.XMLMemento;
-import org.eclipse.ui.internal.StartupThreading.StartupRunnable;
-import org.eclipse.ui.internal.dnd.AbstractDropTarget;
-import org.eclipse.ui.internal.dnd.DragUtil;
-import org.eclipse.ui.internal.dnd.IDropTarget;
-import org.eclipse.ui.internal.dnd.SwtUtil;
-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.presentations.PresentablePart;
-import org.eclipse.ui.internal.presentations.PresentationFactoryUtil;
-import org.eclipse.ui.internal.presentations.PresentationSerializer;
-import org.eclipse.ui.internal.util.PrefUtil;
-import org.eclipse.ui.internal.util.Util;
-import org.eclipse.ui.presentations.AbstractPresentationFactory;
-import org.eclipse.ui.presentations.IPresentablePart;
-import org.eclipse.ui.presentations.IStackPresentationSite;
-import org.eclipse.ui.presentations.StackDropResult;
-import org.eclipse.ui.presentations.StackPresentation;
-
-/**
- * Implements the common behavior for stacks of Panes (ie: EditorStack and ViewStack)
- * This layout container has PartPanes as children and belongs to a PartSashContainer.
- *
- * @since 3.0
- */
-public abstract class PartStack extends LayoutPart implements ILayoutContainer {
-
- public static final int PROP_SELECTION = 0x42;
-
- private List children = new ArrayList(3);
- private boolean isActive = true;
- private ArrayList presentableParts = new ArrayList();
-
- private Map properties = new HashMap();
-
- protected int appearance = PresentationFactoryUtil.ROLE_VIEW;
-
- /**
- * Stores the last value passed to setSelection. If UI updates are being deferred,
- * this may be significantly different from the other current pointers. Once UI updates
- * are re-enabled, the stack will update the presentation selection to match the requested
- * current pointer.
- */
- private LayoutPart requestedCurrent;
-
- /**
- * Stores the current part for the stack. Whenever the outside world asks a PartStack
- * for the current part, this is what gets returned. This pointer is only updated after
- * the presentation selection has been restored and the stack has finished updating its
- * internal state. If the stack is still in the process of updating the presentation,
- * it will still point to the previous part until the presentation is up-to-date.
- */
- private LayoutPart current;
-
- /**
- * Stores the presentable part sent to the presentation. Whenever the presentation
- * asks for the current part, this is what gets returned. This is updated before sending
- * the part to the presentation, and it is not updated while UI updates are disabled.
- * When UI updates are enabled, the stack first makes presentationCurrent match
- * requestedCurrent. Once the presentation is displaying the correct part, the "current"
- * pointer on PartStack is updated.
- */
- private PresentablePart presentationCurrent;
-
- private boolean ignoreSelectionChanges = false;
-
- protected IMemento savedPresentationState = null;
-
- protected DefaultStackPresentationSite presentationSite = new DefaultStackPresentationSite() {
-
- public void close(IPresentablePart part) {
- PartStack.this.close(part);
- }
-
- public void close(IPresentablePart[] parts) {
- PartStack.this.close(parts);
- }
-
- public void dragStart(IPresentablePart beingDragged,
- Point initialLocation, boolean keyboard) {
- PartStack.this.dragStart(beingDragged, initialLocation, keyboard);
- }
-
- public void dragStart(Point initialLocation, boolean keyboard) {
- PartStack.this.dragStart(null, initialLocation, keyboard);
- }
-
- public boolean isPartMoveable(IPresentablePart part) {
- return PartStack.this.isMoveable(part);
- }
-
- public void selectPart(IPresentablePart toSelect) {
- PartStack.this.presentationSelectionChanged(toSelect);
- }
-
- public boolean supportsState(int state) {
- return PartStack.this.supportsState(state);
- }
-
- public void setState(int newState) {
- PartStack.this.setState(newState);
- }
-
- public IPresentablePart getSelectedPart() {
- return PartStack.this.getSelectedPart();
- }
-
- public void addSystemActions(IMenuManager menuManager) {
- PartStack.this.addSystemActions(menuManager);
- }
-
- public boolean isStackMoveable() {
- return canMoveFolder();
- }
-
- public void flushLayout() {
- PartStack.this.flushLayout();
- }
-
- public IPresentablePart[] getPartList() {
- List parts = getPresentableParts();
-
- return (IPresentablePart[]) parts.toArray(new IPresentablePart[parts.size()]);
- }
-
- public String getProperty(String id) {
- return PartStack.this.getProperty(id);
- }
- };
-
- private static final class PartStackDropResult extends AbstractDropTarget {
- private PartPane pane;
-
- // Result of the presentation's dragOver method or null if we are stacking over the
- // client area of the pane.
- private StackDropResult dropResult;
- private PartStack stack;
-
- /**
- * Resets the target of this drop result (allows the same drop result object to be
- * reused)
- *
- * @param stack
- * @param pane
- * @param result result of the presentation's dragOver method, or null if we are
- * simply stacking anywhere.
- * @since 3.1
- */
- public void setTarget(PartStack stack, PartPane pane, StackDropResult result) {
- this.pane = pane;
- this.dropResult = result;
- this.stack = stack;
- }
-
- public void drop() {
- // If we're dragging a pane over itself do nothing
- //if (dropResult.getInsertionPoint() == pane.getPresentablePart()) { return; };
-
- Object cookie = null;
- if (dropResult != null) {
- cookie = dropResult.getCookie();
- }
-
- // Handle cross window drops by opening a new editor
- if (pane instanceof EditorPane) {
- if (pane.getWorkbenchWindow() != stack.getWorkbenchWindow()) {
- EditorPane editor = (EditorPane) pane;
- try {
- IEditorInput input = editor.getEditorReference().getEditorInput();
-
- // Close the old editor and capture the actual closed state incase of a 'cancel'
- boolean editorClosed = editor.getPage().closeEditor(editor.getEditorReference(), true);
-
- // Only open open the new editor if the old one closed
- if (editorClosed)
- stack.getPage().openEditor(input, editor.getEditorReference().getId());
- return;
- } catch (PartInitException e) {
- e.printStackTrace();
- }
-
- }
- }
-
- if (pane.getContainer() != stack) {
- // Moving from another stack
- stack.derefPart(pane);
- pane.reparent(stack.getParent());
- stack.add(pane, cookie);
- stack.setSelection(pane);
- pane.setFocus();
- } else if (cookie != null) {
- // Rearranging within this stack
- stack.getPresentation().movePart(stack.getPresentablePart(pane), cookie);
- }
- }
-
- public Cursor getCursor() {
- return DragCursors.getCursor(DragCursors.CENTER);
- }
-
- public Rectangle getSnapRectangle() {
- if (dropResult == null) {
- return DragUtil.getDisplayBounds(stack.getControl());
- }
- return dropResult.getSnapRectangle();
- }
- }
-
- private static final PartStackDropResult dropResult = new PartStackDropResult();
-
- protected boolean isMinimized;
-
- private ListenerList listeners = new ListenerList();
-
- /**
- * Custom presentation factory to use for this stack, or null to
- * use the default
- */
- private AbstractPresentationFactory factory;
-
- private boolean smartZoomed = false;
- private boolean doingUnzoom = false;
-
- protected abstract boolean isMoveable(IPresentablePart part);
-
- protected abstract void addSystemActions(IMenuManager menuManager);
-
- protected abstract boolean supportsState(int newState);
-
- protected abstract boolean canMoveFolder();
-
- protected abstract void derefPart(LayoutPart toDeref);
-
- protected abstract boolean allowsDrop(PartPane part);
-
- protected static void appendToGroupIfPossible(IMenuManager m,
- String groupId, ContributionItem item) {
- try {
- m.appendToGroup(groupId, item);
- } catch (IllegalArgumentException e) {
- m.add(item);
- }
- }
-
- /**
- * Creates a new PartStack, given a constant determining which presentation to use
- *
- * @param appearance one of the PresentationFactoryUtil.ROLE_* constants
- */
- public PartStack(int appearance) {
- this(appearance, null);
- }
-
- /**
- * Creates a new part stack that uses the given custom presentation factory
- * @param appearance
- * @param factory custom factory to use (or null to use the default)
- */
- public PartStack(int appearance, AbstractPresentationFactory factory) {
- super("PartStack"); //$NON-NLS-1$
-
- this.appearance = appearance;
- this.factory = factory;
- }
-
- /**
- * Adds a property listener to this stack. The listener will receive a PROP_SELECTION
- * event whenever the result of getSelection changes
- *
- * @param listener
- */
- public void addListener(IPropertyListener listener) {
- listeners.add(listener);
- }
-
- public void removeListener(IPropertyListener listener) {
- listeners.remove(listener);
- }
-
- protected final boolean isStandalone() {
- return (appearance == PresentationFactoryUtil.ROLE_STANDALONE
- || appearance == PresentationFactoryUtil.ROLE_STANDALONE_NOTITLE);
- }
-
- /**
- * Returns the currently selected IPresentablePart, or null if none
- *
- * @return
- */
- protected IPresentablePart getSelectedPart() {
- return presentationCurrent;
- }
-
- protected IStackPresentationSite getPresentationSite() {
- return presentationSite;
- }
-
- /**
- * Tests the integrity of this object. Throws an exception if the object's state
- * is invalid. For use in test suites.
- */
- public void testInvariants() {
- Control focusControl = Display.getCurrent().getFocusControl();
-
- boolean currentFound = false;
-
- LayoutPart[] children = getChildren();
-
- for (int idx = 0; idx < children.length; idx++) {
- LayoutPart child = children[idx];
-
- // No null children allowed
- Assert.isNotNull(child,
- "null children are not allowed in PartStack"); //$NON-NLS-1$
-
- // This object can only contain placeholders or PartPanes
- Assert.isTrue(child instanceof PartPlaceholder
- || child instanceof PartPane,
- "PartStack can only contain PartPlaceholders or PartPanes"); //$NON-NLS-1$
-
- // Ensure that all the PartPanes have an associated presentable part
- IPresentablePart part = getPresentablePart(child);
- if (child instanceof PartPane) {
- Assert.isNotNull(part,
- "All PartPanes must have a non-null IPresentablePart"); //$NON-NLS-1$
- }
-
- // Ensure that the child's backpointer points to this stack
- ILayoutContainer childContainer = child.getContainer();
-
- // Disable tests for placeholders -- PartPlaceholder backpointers don't
- // obey the usual rules -- they sometimes point to a container placeholder
- // for this stack instead of the real stack.
- if (!(child instanceof PartPlaceholder)) {
-
- if (isDisposed()) {
-
- // Currently, we allow null backpointers if the widgetry is disposed.
- // However, it is never valid for the child to have a parent other than
- // this object
- if (childContainer != null) {
- Assert
- .isTrue(childContainer == this,
- "PartStack has a child that thinks it has a different parent"); //$NON-NLS-1$
- }
- } else {
- // If the widgetry exists, the child's backpointer must point to us
- Assert
- .isTrue(childContainer == this,
- "PartStack has a child that thinks it has a different parent"); //$NON-NLS-1$
-
- // If this child has focus, then ensure that it is selected and that we have
- // the active appearance.
-
- if (SwtUtil.isChild(child.getControl(), focusControl)) {
- Assert.isTrue(child == current,
- "The part with focus is not the selected part"); //$NON-NLS-1$
- // focus check commented out since it fails when focus workaround in LayoutPart.setVisible is not present
- // Assert.isTrue(getActive() == StackPresentation.AS_ACTIVE_FOCUS);
- }
- }
- }
-
- // Ensure that "current" points to a valid child
- if (child == current) {
- currentFound = true;
- }
-
- // Test the child's internal state
- child.testInvariants();
- }
-
- // If we have at least one child, ensure that the "current" pointer points to one of them
- if (!isDisposed() && getPresentableParts().size() > 0) {
- Assert.isTrue(currentFound);
-
- if (!isDisposed()) {
- StackPresentation presentation = getPresentation();
-
- // If the presentation controls have focus, ensure that we have the active appearance
- if (SwtUtil.isChild(presentation.getControl(), focusControl)) {
- Assert
- .isTrue(
- getActive() == StackPresentation.AS_ACTIVE_FOCUS,
- "The presentation has focus but does not have the active appearance"); //$NON-NLS-1$
- }
- }
- }
-
- // Check to that we're displaying the zoomed icon iff we're actually maximized
- Assert.isTrue((getState() == IStackPresentationSite.STATE_MAXIMIZED)
- == (getContainer() != null && getContainer().childIsZoomed(this)));
-
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.internal.LayoutPart#describeLayout(java.lang.StringBuffer)
- */
- public void describeLayout(StringBuffer buf) {
- int activeState = getActive();
- if (activeState == StackPresentation.AS_ACTIVE_FOCUS) {
- buf.append("active "); //$NON-NLS-1$
- } else if (activeState == StackPresentation.AS_ACTIVE_NOFOCUS) {
- buf.append("active_nofocus "); //$NON-NLS-1$
- }
-
- buf.append("("); //$NON-NLS-1$
-
- LayoutPart[] children = ((ILayoutContainer) this).getChildren();
-
- for (int idx = 0; idx < children.length; idx++) {
-
- LayoutPart next = children[idx];
- if (!(next instanceof PartPlaceholder)) {
- if (idx > 0) {
- buf.append(", "); //$NON-NLS-1$
- }
-
- if (next == requestedCurrent) {
- buf.append("*"); //$NON-NLS-1$
- }
-
- next.describeLayout(buf);
- }
- }
-
- buf.append(")"); //$NON-NLS-1$
- }
-
- /**
- * See IVisualContainer#add
- */
- public void add(LayoutPart child) {
- add(child, null);
- }
-
- /**
- * Add a part at a particular position
- */
- protected void add(LayoutPart newChild, Object cookie) {
- children.add(newChild);
-
- // Fix for bug 78470:
- if(!(newChild.getContainer() instanceof ContainerPlaceholder)) {
- newChild.setContainer(this);
- }
-
- showPart(newChild, cookie);
- }
-
- public boolean allowsAdd(LayoutPart toAdd) {
- return !isStandalone();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.internal.ILayoutContainer#allowsAutoFocus()
- */
- public boolean allowsAutoFocus() {
- if (presentationSite.getState() == IStackPresentationSite.STATE_MINIMIZED) {
- return false;
- }
-
- return super.allowsAutoFocus();
- }
-
- /**
- * @param parts
- */
- protected void close(IPresentablePart[] parts) {
- for (int idx = 0; idx < parts.length; idx++) {
- IPresentablePart part = parts[idx];
-
- close(part);
- }
- }
-
- /**
- * @param part
- */
- protected void close(IPresentablePart part) {
- if (!presentationSite.isCloseable(part)) {
- return;
- }
-
- LayoutPart layoutPart = getPaneFor(part);
-
- if (layoutPart != null && layoutPart instanceof PartPane) {
- PartPane viewPane = (PartPane) layoutPart;
-
- viewPane.doHide();
- }
- }
-
- public boolean isDisposed() {
- return getPresentation() == null;
- }
-
- protected AbstractPresentationFactory getFactory() {
-
- if (factory != null) {
- return factory;
- }
-
- return ((WorkbenchWindow) getPage()
- .getWorkbenchWindow()).getWindowConfigurer()
- .getPresentationFactory();
- }
-
- public void createControl(Composite parent) {
- if (!isDisposed()) {
- return;
- }
-
- AbstractPresentationFactory factory = getFactory();
-
- PresentationSerializer serializer = new PresentationSerializer(
- getPresentableParts());
-
- StackPresentation presentation = PresentationFactoryUtil
- .createPresentation(factory, appearance, parent,
- presentationSite, serializer, savedPresentationState);
-
- createControl(parent, presentation);
- getControl().moveBelow(null);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.internal.LayoutPart#getDropTarget(java.lang.Object, org.eclipse.swt.graphics.Point)
- */
- public IDropTarget getDropTarget(Object draggedObject, Point position) {
-
- if (!(draggedObject instanceof PartPane)) {
- return null;
- }
-
- final PartPane pane = (PartPane) draggedObject;
- if (isStandalone()
- || !allowsDrop(pane)) {
- return null;
- }
-
- // Don't allow views to be dragged between windows
- boolean differentWindows = pane.getWorkbenchWindow() != getWorkbenchWindow();
- boolean editorDropOK = ((pane instanceof EditorPane) &&
- pane.getWorkbenchWindow().getWorkbench() ==
- getWorkbenchWindow().getWorkbench());
- if (differentWindows && !editorDropOK) {
- return null;
- }
-
- StackDropResult dropResult = getPresentation().dragOver(
- getControl(), position);
-
- if (dropResult == null) {
- return null;
- }
-
- return createDropTarget(pane, dropResult);
- }
-
- public void setActive(boolean isActive) {
-
- this.isActive = isActive;
- // Add all visible children to the presentation
- Iterator iter = children.iterator();
- while (iter.hasNext()) {
- LayoutPart part = (LayoutPart) iter.next();
-
- part.setContainer(isActive ? this : null);
- }
-
- for (Iterator iterator = presentableParts.iterator(); iterator.hasNext();) {
- PresentablePart next = (PresentablePart) iterator.next();
-
- next.enableInputs(isActive);
- next.enableOutputs(isActive);
- }
- }
-
- public void createControl(Composite parent, StackPresentation presentation) {
-
- Assert.isTrue(isDisposed());
-
- if (presentationSite.getPresentation() != null) {
- return;
- }
-
- presentationSite.setPresentation(presentation);
-
- // Add all visible children to the presentation
- // Use a copy of the current set of children to avoid a ConcurrentModificationException
- // if a part is added to the same stack while iterating over the children (bug 78470)
- LayoutPart[] childParts = (LayoutPart[]) children.toArray(new LayoutPart[children.size()]);
- for (int i = 0; i < childParts.length; i++) {
- LayoutPart part = childParts[i];
- showPart(part, null);
- }
-
- if (savedPresentationState!=null) {
- PresentationSerializer serializer = new PresentationSerializer(
- getPresentableParts());
- presentation.restoreState(serializer, savedPresentationState);
- }
-
- Control ctrl = getPresentation().getControl();
-
- ctrl.setData(this);
-
- // We should not have a placeholder selected once we've created the widgetry
- if (requestedCurrent instanceof PartPlaceholder) {
- requestedCurrent = null;
- updateContainerVisibleTab();
- }
-
- refreshPresentationSelection();
- }
-
- public IDropTarget createDropTarget(PartPane pane, StackDropResult result) {
- dropResult.setTarget(this, pane, result);
- return dropResult;
- }
-
- /**
- * Saves the current state of the presentation to savedPresentationState, if the
- * presentation exists.
- */
- protected void savePresentationState() {
- if (isDisposed()) {
- return;
- }
-
- {// Save the presentation's state before disposing it
- XMLMemento memento = XMLMemento
- .createWriteRoot(IWorkbenchConstants.TAG_PRESENTATION);
- memento.putString(IWorkbenchConstants.TAG_ID, getFactory().getId());
-
- PresentationSerializer serializer = new PresentationSerializer(
- getPresentableParts());
-
- getPresentation().saveState(serializer, memento);
-
- // Store the memento in savedPresentationState
- savedPresentationState = memento;
- }
- }
-
- /**
- * See LayoutPart#dispose
- */
- public void dispose() {
-
- if (isDisposed()) {
- return;
- }
-
- savePresentationState();
-
- presentationSite.dispose();
-
- for (Iterator iter = presentableParts.iterator(); iter.hasNext();) {
- PresentablePart part = (PresentablePart) iter.next();
-
- part.dispose();
- }
- presentableParts.clear();
-
- presentationCurrent = null;
- current = null;
- fireInternalPropertyChange(PROP_SELECTION);
- }
-
- public void findSashes(LayoutPart part, PartPane.Sashes sashes) {
- ILayoutContainer container = getContainer();
-
- if (container != null) {
- container.findSashes(this, sashes);
- }
- }
-
- /**
- * Gets the presentation bounds.
- */
- public Rectangle getBounds() {
- if (getPresentation() == null) {
- return new Rectangle(0, 0, 0, 0);
- }
-
- return getPresentation().getControl().getBounds();
- }
-
- /**
- * See IVisualContainer#getChildren
- */
- public LayoutPart[] getChildren() {
- return (LayoutPart[]) children.toArray(new LayoutPart[children.size()]);
- }
-
- public Control getControl() {
- StackPresentation presentation = getPresentation();
-
- if (presentation == null) {
- return null;
- }
-
- return presentation.getControl();
- }
-
- /**
- * Answer the number of children.
- */
- public int getItemCount() {
- if (isDisposed()) {
- return children.size();
- }
- return getPresentableParts().size();
- }
-
- /**
- * Returns the LayoutPart for the given IPresentablePart, or null if the given
- * IPresentablePart is not in this stack. Returns null if given a null argument.
- *
- * @param part to locate or null
- * @return
- */
- protected LayoutPart getPaneFor(IPresentablePart part) {
- if (part == null || !(part instanceof PresentablePart)) {
- return null;
- }
-
- return ((PresentablePart)part).getPane();
- }
-
- /**
- * Get the parent control.
- */
- public Composite getParent() {
- return getControl().getParent();
- }
-
- /**
- * Returns a list of IPresentablePart
- *
- * @return
- */
- public List getPresentableParts() {
- return presentableParts;
- }
-
- private PresentablePart getPresentablePart(LayoutPart pane) {
- for (Iterator iter = presentableParts.iterator(); iter.hasNext();) {
- PresentablePart part = (PresentablePart) iter.next();
-
- if (part.getPane() == pane) {
- return part;
- }
- }
-
- return null;
- }
-
- protected StackPresentation getPresentation() {
- return presentationSite.getPresentation();
- }
-
- /**
- * Returns the visible child.
- * @return the currently visible part, or null if none
- */
- public PartPane getSelection() {
- if (current instanceof PartPane) {
- return (PartPane) current;
- }
- return null;
- }
-
- private void presentationSelectionChanged(IPresentablePart newSelection) {
- // Ignore selection changes that occur as a result of removing a part
- if (ignoreSelectionChanges) {
- return;
- }
- LayoutPart newPart = getPaneFor(newSelection);
-
- // This method should only be called on objects that are already in the layout
- Assert.isNotNull(newPart);
-
- if (newPart != requestedCurrent) {
- setSelection(newPart);
- }
-
- newPart.setFocus();
- }
-
- /**
- * See IVisualContainer#remove
- */
- public void remove(LayoutPart child) {
- PresentablePart presentablePart = getPresentablePart(child);
-
- // Need to remove it from the list of children before notifying the presentation
- // since it may setVisible(false) on the part, leading to a partHidden notification,
- // during which findView must not find the view being removed. See bug 60039.
- children.remove(child);
-
- StackPresentation presentation = getPresentation();
-
- if (presentablePart != null && presentation != null) {
- ignoreSelectionChanges = true;
- presentableParts .remove(presentablePart);
- presentation.removePart(presentablePart);
- presentablePart.dispose();
- ignoreSelectionChanges = false;
- }
-
- if (!isDisposed()) {
- child.setContainer(null);
- }
-
- if (child == requestedCurrent) {
- updateContainerVisibleTab();
- }
- }
-
- /**
- * Reparent a part. Also reparent visible children...
- */
- public void reparent(Composite newParent) {
-
- Control control = getControl();
- if ((control == null) || (control.getParent() == newParent) || !control.isReparentable()) {
- return;
- }
-
- super.reparent(newParent);
-
- Iterator iter = children.iterator();
- while (iter.hasNext()) {
- LayoutPart next = (LayoutPart) iter.next();
- next.reparent(newParent);
- }
- }
-
- /**
- * See IVisualContainer#replace
- */
- public void replace(LayoutPart oldChild, LayoutPart newChild) {
- int idx = children.indexOf(oldChild);
- int numPlaceholders = 0;
- //subtract the number of placeholders still existing in the list
- //before this one - they wont have parts.
- for (int i = 0; i < idx; i++) {
- if (children.get(i) instanceof PartPlaceholder) {
- numPlaceholders++;
- }
- }
- Integer cookie = new Integer(idx - numPlaceholders);
- children.add(idx, newChild);
-
- showPart(newChild, cookie);
-
- if (oldChild == requestedCurrent && !(newChild instanceof PartPlaceholder)) {
- setSelection(newChild);
- }
-
- remove(oldChild);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.internal.LayoutPart#computePreferredSize(boolean, int, int, int)
- */
- public int computePreferredSize(boolean width, int availableParallel,
- int availablePerpendicular, int preferredParallel) {
-
- return getPresentation().computePreferredSize(width, availableParallel,
- availablePerpendicular, preferredParallel);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.internal.LayoutPart#getSizeFlags(boolean)
- */
- public int getSizeFlags(boolean horizontal) {
- StackPresentation presentation = getPresentation();
-
- if (presentation != null) {
- return presentation.getSizeFlags(horizontal);
- }
-
- return 0;
- }
-
- /**
- * @see IPersistable
- */
- public IStatus restoreState(IMemento memento) {
- // Read the active tab.
- String activeTabID = memento
- .getString(IWorkbenchConstants.TAG_ACTIVE_PAGE_ID);
-
- // Read the page elements.
- IMemento[] children = memento.getChildren(IWorkbenchConstants.TAG_PAGE);
- if (children != null) {
- // Loop through the page elements.
- for (int i = 0; i < children.length; i++) {
- // Get the info details.
- IMemento childMem = children[i];
- String partID = childMem
- .getString(IWorkbenchConstants.TAG_CONTENT);
-
- // Create the part.
- LayoutPart part = new PartPlaceholder(partID);
- part.setContainer(this);
- add(part);
- //1FUN70C: ITPUI:WIN - Shouldn't set Container when not active
- //part.setContainer(this);
- if (partID.equals(activeTabID)) {
- setSelection(part);
- // Mark this as the active part.
- //current = part;
- }
- }
- }
-
- IPreferenceStore preferenceStore = PrefUtil.getAPIPreferenceStore();
- boolean useNewMinMax = preferenceStore.getBoolean(IWorkbenchPreferenceConstants.ENABLE_NEW_MIN_MAX);
- final Integer expanded = memento.getInteger(IWorkbenchConstants.TAG_EXPANDED);
- if (useNewMinMax && expanded != null) {
- StartupThreading.runWithoutExceptions(new StartupRunnable() {
- public void runWithException() throws Throwable {
- setState((expanded == null || expanded.intValue() != IStackPresentationSite.STATE_MINIMIZED) ? IStackPresentationSite.STATE_RESTORED
- : IStackPresentationSite.STATE_MINIMIZED);
- }
- });
- }
- else {
- setState((expanded == null || expanded.intValue() != IStackPresentationSite.STATE_MINIMIZED) ? IStackPresentationSite.STATE_RESTORED
- : IStackPresentationSite.STATE_MINIMIZED);
- }
-
- Integer appearance = memento
- .getInteger(IWorkbenchConstants.TAG_APPEARANCE);
- if (appearance != null) {
- this.appearance = appearance.intValue();
- }
-
- // Determine if the presentation has saved any info here
- savedPresentationState = null;
- IMemento[] presentationMementos = memento
- .getChildren(IWorkbenchConstants.TAG_PRESENTATION);
-
- for (int idx = 0; idx < presentationMementos.length; idx++) {
- IMemento child = presentationMementos[idx];
-
- String id = child.getString(IWorkbenchConstants.TAG_ID);
-
- if (Util.equals(id, getFactory().getId())) {
- savedPresentationState = child;
- break;
- }
- }
-
- IMemento propertiesState = memento.getChild(IWorkbenchConstants.TAG_PROPERTIES);
- if (propertiesState != null) {
- IMemento[] props = propertiesState.getChildren(IWorkbenchConstants.TAG_PROPERTY);
- for (int i = 0; i < props.length; i++) {
- properties.put(props[i].getID(), props[i].getTextData());
- }
- }
-
-
- return Status.OK_STATUS;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.internal.LayoutPart#setVisible(boolean)
- */
- public void setVisible(boolean makeVisible) {
- Control ctrl = getControl();
-
- boolean useShortcut = makeVisible || !isActive;
-
- if (!SwtUtil.isDisposed(ctrl) && useShortcut) {
- if (makeVisible == ctrl.getVisible()) {
- return;
- }
- }
-
- if (makeVisible) {
- for (Iterator iterator = presentableParts.iterator(); iterator.hasNext();) {
- PresentablePart next = (PresentablePart) iterator.next();
-
- next.enableInputs(isActive);
- next.enableOutputs(isActive);
- }
- }
-
- super.setVisible(makeVisible);
-
- StackPresentation presentation = getPresentation();
-
- if (presentation != null) {
- presentation.setVisible(makeVisible);
- }
-
- if (!makeVisible) {
- for (Iterator iterator = presentableParts.iterator(); iterator.hasNext();) {
- PresentablePart next = (PresentablePart) iterator.next();
-
- next.enableInputs(false);
- }
- }
- }
-
- /**
- * @see IPersistable
- */
- public IStatus saveState(IMemento memento) {
-
- // Save the active tab.
- if (requestedCurrent != null) {
- memento.putString(IWorkbenchConstants.TAG_ACTIVE_PAGE_ID, requestedCurrent
- .getCompoundId());
- }
-
- // Write out the presentable parts (in order)
- Set cachedIds = new HashSet();
- Iterator ppIter = getPresentableParts().iterator();
- while (ppIter.hasNext()) {
- PresentablePart presPart = (PresentablePart) ppIter.next();
-
- IMemento childMem = memento
- .createChild(IWorkbenchConstants.TAG_PAGE);
- PartPane part = presPart.getPane();
- String tabText = part.getPartReference().getPartName();
-
- childMem.putString(IWorkbenchConstants.TAG_LABEL, tabText);
- childMem.putString(IWorkbenchConstants.TAG_CONTENT, presPart.getPane().getPlaceHolderId());
-
- // Cache the id so we don't write it out later
- cachedIds.add(presPart.getPane().getPlaceHolderId());
- }
-
- Iterator iter = children.iterator();
- while (iter.hasNext()) {
- LayoutPart next = (LayoutPart) iter.next();
-
- PartPane part = null;
- if (next instanceof PartPane) {
- // Have we already written it out?
- if (cachedIds.contains(((PartPane)next).getPlaceHolderId()))
- continue;
-
- part = (PartPane)next;
- }
-
- IMemento childMem = memento
- .createChild(IWorkbenchConstants.TAG_PAGE);
-
- String tabText = "LabelNotFound"; //$NON-NLS-1$
- if (part != null) {
- tabText = part.getPartReference().getPartName();
- }
- childMem.putString(IWorkbenchConstants.TAG_LABEL, tabText);
- childMem.putString(IWorkbenchConstants.TAG_CONTENT, next
- .getCompoundId());
- }
-
- IPreferenceStore preferenceStore = PrefUtil.getAPIPreferenceStore();
- boolean useNewMinMax = preferenceStore.getBoolean(IWorkbenchPreferenceConstants.ENABLE_NEW_MIN_MAX);
- if (useNewMinMax) {
- memento.putInteger(IWorkbenchConstants.TAG_EXPANDED, presentationSite.getState());
- }
- else {
- memento
- .putInteger(
- IWorkbenchConstants.TAG_EXPANDED,
- (presentationSite.getState() == IStackPresentationSite.STATE_MINIMIZED) ? IStackPresentationSite.STATE_MINIMIZED
- : IStackPresentationSite.STATE_RESTORED);
- }
-
- memento.putInteger(IWorkbenchConstants.TAG_APPEARANCE, appearance);
-
- savePresentationState();
-
- if (savedPresentationState != null) {
- IMemento presentationState = memento
- .createChild(IWorkbenchConstants.TAG_PRESENTATION);
- presentationState.putMemento(savedPresentationState);
- }
-
- if (!properties.isEmpty()) {
- IMemento propertiesState = memento.createChild(IWorkbenchConstants.TAG_PROPERTIES);
- Set ids = properties.keySet();
- for (Iterator iterator = ids.iterator(); iterator.hasNext();) {
- String id = (String)iterator.next();
-
- if (properties.get(id) == null) continue;
-
- IMemento prop = propertiesState.createChild(IWorkbenchConstants.TAG_PROPERTY, id);
- prop.putTextData((String)properties.get(id));
- }
- }
-
-
- return Status.OK_STATUS;
- }
-
- protected WorkbenchPage getPage() {
- WorkbenchWindow window = (WorkbenchWindow) getWorkbenchWindow();
-
- if (window == null) {
- return null;
- }
-
- return (WorkbenchPage) window.getActivePage();
- }
-
- /**
- * Set the active appearence on the tab folder.
- *
- * @param active
- */
- public void setActive(int activeState) {
-
- if (activeState == StackPresentation.AS_ACTIVE_FOCUS && isMinimized) {
- setMinimized(false);
- }
-
- presentationSite.setActive(activeState);
- }
-
- public int getActive() {
- return presentationSite.getActive();
- }
-
- /**
- * Sets the presentation bounds.
- */
- public void setBounds(Rectangle r) {
-
- if (getPresentation() != null) {
- getPresentation().setBounds(r);
- }
- }
-
- public void setSelection(LayoutPart part) {
- if (part == requestedCurrent) {
- return;
- }
-
- requestedCurrent = part;
-
- refreshPresentationSelection();
- }
-
- /**
- * Subclasses should override this method to update the enablement state of their
- * actions
- */
- protected abstract void updateActions(PresentablePart current);
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.internal.LayoutPart#handleDeferredEvents()
- */
- protected void handleDeferredEvents() {
- super.handleDeferredEvents();
-
- refreshPresentationSelection();
- }
-
- private void refreshPresentationSelection() {
- // If deferring UI updates, exit.
- if (isDeferred()) {
- return;
- }
-
- // If the presentation is already displaying the desired part, then there's nothing
- // to do.
- if (current == requestedCurrent) {
- return;
- }
-
- StackPresentation presentation = getPresentation();
- if (presentation != null) {
-
- presentationCurrent = getPresentablePart(requestedCurrent);
-
- if (!isDisposed()) {
- updateActions(presentationCurrent);
- }
-
- if (presentationCurrent != null && presentation != null) {
- requestedCurrent.createControl(getParent());
- if (requestedCurrent.getControl().getParent() != getControl()
- .getParent()) {
- requestedCurrent.reparent(getControl().getParent());
- }
-
-
- presentation.selectPart(presentationCurrent);
-
- }
-
- // Update the return value of getVisiblePart
- current = requestedCurrent;
- fireInternalPropertyChange(PROP_SELECTION);
- }
- }
-
- public int getState() {
- return presentationSite.getState();
- }
-
- /**
- * Sets the minimized state for this stack. The part may call this method to
- * minimize or restore itself. The minimized state only affects the view
- * when unzoomed in the 3.0 presentation (in 3.3 it's handled by the
- * ViewStack directly and works as expected).
- */
- public void setMinimized(boolean minimized) {
- if (minimized != isMinimized) {
- isMinimized = minimized;
-
- refreshPresentationState();
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.internal.ILayoutContainer#obscuredByZoom(org.eclipse.ui.internal.LayoutPart)
- */
- public boolean childObscuredByZoom(LayoutPart toTest) {
- return isObscuredByZoom();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.internal.LayoutPart#requestZoom(org.eclipse.ui.internal.LayoutPart)
- */
- public void childRequestZoomIn(LayoutPart toZoom) {
- super.childRequestZoomIn(toZoom);
-
- requestZoomIn();
- }
- /* (non-Javadoc)
- * @see org.eclipse.ui.internal.LayoutPart#requestZoomOut()
- */
- public void childRequestZoomOut() {
- super.childRequestZoomOut();
-
- requestZoomOut();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.internal.ILayoutContainer#isZoomed(org.eclipse.ui.internal.LayoutPart)
- */
- public boolean childIsZoomed(LayoutPart toTest) {
- return isZoomed();
- }
-
- /**
- * This is a hack that allows us to preserve the old
- * min/max behavior for the stack containing the IntroPart.
- * This is required to have the initial Intro (Welcome)
- * pane to show correctly but will induce strange
- * effects should a user re-locate the part to
- * stacks other that its initial one...
- *
- * @return true if the stack contains the intro
- * as a ViewPane (not if it's only a placeholder)
- */
- private boolean isIntroInStack() {
- LayoutPart[] kids = getChildren();
- for (int i = 0; i < kids.length; i++) {
- if (kids[i] instanceof ViewPane) {
- ViewPane vp = (ViewPane) kids[i];
- if (vp.getID().equals(IIntroConstants.INTRO_VIEW_ID))
- return true;
- }
- }
- return false;
- }
-
- private void smartZoom() {
- WorkbenchWindow wbw = (WorkbenchWindow) getPage().getWorkbenchWindow();
- if (wbw == null || wbw.getShell() == null)
- return;
-
- Perspective perspective = getPage().getActivePerspective();
- FastViewManager fvm = perspective.getFastViewManager();
-
- fvm.deferUpdates(true);
-
- // Cache the layout bounds
- perspective.getPresentation().updateBoundsMap();
-
- LayoutPart[] children = perspective.getPresentation().getLayout().getChildren();
- for (int i = 0; i < children.length; i++) {
- if (children[i] != this) {
- if (children[i] instanceof ViewStack) {
- ((ViewStack) children[i]).setMinimized(true);
- ViewStackTrimToolBar vstb = fvm
- .getViewStackTrimToolbar(children[i]
- .getID());
- vstb.setRestoreOnUnzoom(true);
- }
- else if (children[i] instanceof EditorSashContainer && !(this instanceof EditorStack)) {
- perspective.setEditorAreaState(IStackPresentationSite.STATE_MINIMIZED);
- perspective.setEditorAreaRestoreOnUnzoom(true);
- }
- }
- }
-
- // If the editor area has changed state tell the perspective
- if (this instanceof EditorStack)
- perspective.setEditorAreaState(IStackPresentationSite.STATE_MAXIMIZED);
-
- // Clear the boundsMap
- perspective.getPresentation().resetBoundsMap();
-
- // We're done batching...
- fvm.deferUpdates(false);
-
- perspective.getPresentation().setMaximizedStack(this);
- smartZoomed = true;
- }
-
- protected void smartUnzoom() {
- // Prevent recursion through 'setMinimized'
- if (doingUnzoom)
- return;
- doingUnzoom = true;
-
- WorkbenchWindow wbw = (WorkbenchWindow) getPage().getWorkbenchWindow();
- if (wbw == null || wbw.getShell() == null)
- return;
-
- ITrimManager tbm = wbw.getTrimManager();
- Perspective perspective = getPage().getActivePerspective();
- FastViewManager fvm = perspective.getFastViewManager();
-
- ILayoutContainer root = getContainer();
-
- // We go up one more level when maximizing an editor stack
- // so that we 'zoom' the editor area
- boolean restoringEditorArea = false;
- if (root instanceof EditorSashContainer) {
- root = ((EditorSashContainer) root).getContainer();
- restoringEditorArea = true;
- }
-
- // This is a compound operation
- fvm.deferUpdates(true);
-
- LayoutPart[] children = root.getChildren();
- for (int i = 0; i < children.length; i++) {
- if (children[i] != this) {
- IWindowTrim trim = tbm.getTrim(children[i].getID());
- if (trim == null)
- continue;
-
- if (trim instanceof ViewStackTrimToolBar) {
- ViewStackTrimToolBar vstb = (ViewStackTrimToolBar) trim;
- if (vstb.restoreOnUnzoom()
- && children[i] instanceof ContainerPlaceholder) {
- // In the current presentation its a
- // container placeholder
- ViewStack realStack = (ViewStack) ((ContainerPlaceholder) children[i])
- .getRealContainer();
- realStack.setMinimized(false);
-
- vstb.setRestoreOnUnzoom(false);
- }
- } else if (trim instanceof EditorAreaTrimToolBar) {
- if (perspective.getEditorAreaRestoreOnUnzoom())
- perspective.setEditorAreaState(IStackPresentationSite.STATE_RESTORED);
- }
- }
- }
-
- // If the editor area has changed state tell the perspective
- if (restoringEditorArea)
- perspective.setEditorAreaState(IStackPresentationSite.STATE_RESTORED);
-
- perspective.getPresentation().setMaximizedStack(null);
-
- fvm.deferUpdates(false);
- smartZoomed = false;
-
- doingUnzoom = false;
- }
-
- protected void setState(final int newState) {
- final int oldState = presentationSite.getState();
- if (!supportsState(newState) || newState == oldState) {
- return;
- }
-
- final WorkbenchWindow wbw = (WorkbenchWindow) getPage().getWorkbenchWindow();
- if (wbw == null || wbw.getShell() == null || wbw.getActiveWorkbenchPage() == null)
- return;
-
- WorkbenchPage page = wbw.getActiveWorkbenchPage();
- if (page == null)
- return;
-
- boolean useNewMinMax = Perspective.useNewMinMax(page.getActivePerspective());
-
- // we have to fiddle with the zoom behavior to satisfy Intro req's
- // by using the old zoom behavior for its stack
- if (newState == IStackPresentationSite.STATE_MAXIMIZED)
- useNewMinMax = useNewMinMax && !isIntroInStack();
- else if (newState == IStackPresentationSite.STATE_RESTORED) {
- PartStack maxStack = page.getActivePerspective().getPresentation().getMaximizedStack();
- useNewMinMax = useNewMinMax && (maxStack == this || maxStack instanceof EditorStack);
- }
-
- if (useNewMinMax) {
- StartupThreading.runWithoutExceptions(new StartupRunnable() {
- public void runWithException() throws Throwable {
- wbw.getPageComposite().setRedraw(false);
- try {
- if (newState == IStackPresentationSite.STATE_MAXIMIZED) {
- smartZoom();
- } else if (oldState == IStackPresentationSite.STATE_MAXIMIZED) {
- smartUnzoom();
- }
-
- if (newState == IStackPresentationSite.STATE_MINIMIZED) {
- setMinimized(true);
- }
- } finally {
- wbw.getPageComposite().setRedraw(true);
-
- // Force a redraw (fixes Mac refresh)
- wbw.getShell().redraw();
- }
-
- setPresentationState(newState);
- }
- });
- } else {
- boolean minimized = (newState == IStackPresentationSite.STATE_MINIMIZED);
- setMinimized(minimized);
-
- if (newState == IStackPresentationSite.STATE_MAXIMIZED) {
- requestZoomIn();
- } else if (oldState == IStackPresentationSite.STATE_MAXIMIZED) {
- requestZoomOut();
-
- if (newState == IStackPresentationSite.STATE_MINIMIZED)
- setMinimized(true);
- }
- }
- }
-
-
- /**
- * Called by the workbench page to notify this part that it has been zoomed or unzoomed.
- * The PartStack should not call this method itself -- it must request zoom changes by
- * talking to the WorkbenchPage.
- */
- public void setZoomed(boolean isZoomed) {
-
- super.setZoomed(isZoomed);
-
- LayoutPart[] children = getChildren();
-
- for (int i = 0; i < children.length; i++) {
- LayoutPart next = children[i];
-
- next.setZoomed(isZoomed);
- }
-
- refreshPresentationState();
- }
-
- public boolean isZoomed() {
- ILayoutContainer container = getContainer();
-
- if (container != null) {
- return container.childIsZoomed(this);
- }
-
- return false;
- }
-
- protected void refreshPresentationState() {
- if (isZoomed() || smartZoomed) {
- presentationSite.setPresentationState(IStackPresentationSite.STATE_MAXIMIZED);
- } else {
-
- boolean wasMinimized = (presentationSite.getState() == IStackPresentationSite.STATE_MINIMIZED);
-
- if (isMinimized) {
- presentationSite.setPresentationState(IStackPresentationSite.STATE_MINIMIZED);
- } else {
- presentationSite.setPresentationState(IStackPresentationSite.STATE_RESTORED);
- }
-
- if (isMinimized != wasMinimized) {
- flushLayout();
-
- if (isMinimized) {
- WorkbenchPage page = getPage();
-
- if (page != null) {
- page.refreshActiveView();
- }
- }
- }
- }
- }
-
- /**
- * Makes the given part visible in the presentation.
- * @param part the part to add to the stack
- * @param cookie other information
- */
- private void showPart(LayoutPart part, Object cookie) {
-
- if (isDisposed()) {
- return;
- }
-
- if ((part instanceof PartPlaceholder)) {
- part.setContainer(this);
- return;
- }
-
- if (!(part instanceof PartPane)) {
- WorkbenchPlugin.log(NLS.bind(
- WorkbenchMessages.PartStack_incorrectPartInFolder, part
- .getID()));
- return;
- }
-
- PartPane pane = (PartPane)part;
-
- PresentablePart presentablePart = new PresentablePart(pane, getControl().getParent());
- presentableParts.add(presentablePart);
-
- if (isActive) {
- part.setContainer(this);
-
- // The active part should always be enabled
- if (part.getControl() != null)
- part.getControl().setEnabled(true);
- }
-
- presentationSite.getPresentation().addPart(presentablePart, cookie);
-
- if (requestedCurrent == null) {
- setSelection(part);
- }
-
- if (childObscuredByZoom(part)) {
- presentablePart.enableInputs(false);
- }
- }
-
- /**
- * Update the container to show the correct visible tab based on the
- * activation list.
- */
- private void updateContainerVisibleTab() {
- LayoutPart[] parts = getChildren();
-
- if (parts.length < 1) {
- setSelection(null);
- return;
- }
-
- PartPane selPart = null;
- int topIndex = 0;
- WorkbenchPage page = getPage();
-
- if (page != null) {
- IWorkbenchPartReference sortedPartsArray[] = page.getSortedParts();
- List sortedParts = Arrays.asList(sortedPartsArray);
- for (int i = 0; i < parts.length; i++) {
- if (parts[i] instanceof PartPane) {
- IWorkbenchPartReference part = ((PartPane) parts[i])
- .getPartReference();
- int index = sortedParts.indexOf(part);
- if (index >= topIndex) {
- topIndex = index;
- selPart = (PartPane) parts[i];
- }
- }
- }
-
- }
-
- if (selPart == null) {
- List presentableParts = getPresentableParts();
- if (presentableParts.size() != 0) {
- IPresentablePart part = (IPresentablePart) getPresentableParts()
- .get(0);
-
- selPart = (PartPane) getPaneFor(part);
- }
- }
-
- setSelection(selPart);
- }
-
- /**
- *
- */
- public void showSystemMenu() {
- getPresentation().showSystemMenu();
- }
-
- public void showPaneMenu() {
- getPresentation().showPaneMenu();
- }
-
- public void showPartList() {
- getPresentation().showPartList();
- }
-
- public Control[] getTabList(LayoutPart part) {
- if (part != null) {
- IPresentablePart presentablePart = getPresentablePart(part);
- StackPresentation presentation = getPresentation();
-
- if (presentablePart != null && presentation != null) {
- return presentation.getTabList(presentablePart);
- }
- }
-
- return new Control[0];
- }
-
- /**
- *
- * @param beingDragged
- * @param initialLocation
- * @param keyboard
- */
- private void dragStart(IPresentablePart beingDragged, Point initialLocation,
- boolean keyboard) {
- if (beingDragged == null) {
- paneDragStart((LayoutPart)null, initialLocation, keyboard);
- } else {
- if (presentationSite.isPartMoveable(beingDragged)) {
- LayoutPart pane = getPaneFor(beingDragged);
-
- if (pane != null) {
- paneDragStart(pane, initialLocation, keyboard);
- }
- }
- }
- }
-
- public void paneDragStart(LayoutPart pane, Point initialLocation,
- boolean keyboard) {
- if (pane == null) {
- if (canMoveFolder()) {
- if (presentationSite.getState() == IStackPresentationSite.STATE_MAXIMIZED) {
- // Calculate where the initial location was BEFORE the 'restore'...as a percentage
- Rectangle bounds = Geometry.toDisplay(getParent(), getPresentation().getControl().getBounds());
- float xpct = (initialLocation.x - bounds.x) / (float)(bounds.width);
- float ypct = (initialLocation.y - bounds.y) / (float)(bounds.height);
-
- // Only restore if we're dragging views/view stacks
- if (this instanceof ViewStack)
- setState(IStackPresentationSite.STATE_RESTORED);
-
- // Now, adjust the initial location to be within the bounds of the restored rect
- bounds = Geometry.toDisplay(getParent(), getPresentation().getControl().getBounds());
- initialLocation.x = (int) (bounds.x + (xpct * bounds.width));
- initialLocation.y = (int) (bounds.y + (ypct * bounds.height));
- }
-
- DragUtil.performDrag(PartStack.this, Geometry
- .toDisplay(getParent(), getPresentation().getControl()
- .getBounds()), initialLocation, !keyboard);
- }
- } else {
- if (presentationSite.getState() == IStackPresentationSite.STATE_MAXIMIZED) {
- // Calculate where the initial location was BEFORE the 'restore'...as a percentage
- Rectangle bounds = Geometry.toDisplay(getParent(), getPresentation().getControl().getBounds());
- float xpct = (initialLocation.x - bounds.x) / (float)(bounds.width);
- float ypct = (initialLocation.y - bounds.y) / (float)(bounds.height);
-
- // Only restore if we're dragging views/view stacks
- if (this instanceof ViewStack)
- setState(IStackPresentationSite.STATE_RESTORED);
-
- // Now, adjust the initial location to be within the bounds of the restored rect
- // See bug 100908
- bounds = Geometry.toDisplay(getParent(), getPresentation().getControl().getBounds());
- initialLocation.x = (int) (bounds.x + (xpct * bounds.width));
- initialLocation.y = (int) (bounds.y + (ypct * bounds.height));
- }
-
- DragUtil.performDrag(pane, Geometry.toDisplay(getParent(),
- getPresentation().getControl().getBounds()),
- initialLocation, !keyboard);
- }
- }
-
- /**
- * @return Returns the savedPresentationState.
- */
- public IMemento getSavedPresentationState() {
- return savedPresentationState;
- }
-
- private void fireInternalPropertyChange(int id) {
- Object listeners[] = this.listeners.getListeners();
- for (int i = 0; i < listeners.length; i++) {
- ((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);
- }
-
- //
- // Support for passing perspective layout properties to the presentation
-
-
- public String getProperty(String id) {
- return (String)properties.get(id);
- }
-
- public void setProperty(String id, String value) {
- if (value==null) {
- properties.remove(id);
- } else {
- properties.put(id, value);
- }
- }
-
- /**
- * Copies all appearance related data from this stack to the given stack.
- */
- public void copyAppearanceProperties(PartStack copyTo) {
- copyTo.appearance = this.appearance;
- if (!properties.isEmpty()) {
- Set ids = properties.keySet();
- for (Iterator iterator = ids.iterator(); iterator.hasNext();) {
- String id = (String)iterator.next();
- copyTo.setProperty(id, (String)properties.get(id));
- }
- }
- }
-}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/Perspective.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/Perspective.java
deleted file mode 100644
index 2dc6adc3b8a..00000000000
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/Perspective.java
+++ /dev/null
@@ -1,2706 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2010 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
- * Markus Alexander Kuppe, Versant GmbH - bug 215797
- * Sascha Zak - bug 282874
- *******************************************************************************/
-
-package org.eclipse.ui.internal;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.MultiStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.jface.action.IContributionItem;
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.jface.action.SubContributionItem;
-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;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.IMemento;
-import org.eclipse.ui.IPageLayout;
-import org.eclipse.ui.IPerspectiveDescriptor;
-import org.eclipse.ui.IPerspectiveFactory;
-import org.eclipse.ui.IPlaceholderFolderLayout;
-import org.eclipse.ui.IViewLayout;
-import org.eclipse.ui.IViewPart;
-import org.eclipse.ui.IViewReference;
-import org.eclipse.ui.IViewSite;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.IWorkbenchPartReference;
-import org.eclipse.ui.IWorkbenchPreferenceConstants;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.WorkbenchException;
-import org.eclipse.ui.XMLMemento;
-import org.eclipse.ui.contexts.IContextService;
-import org.eclipse.ui.internal.StartupThreading.StartupRunnable;
-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.layout.TrimLayout;
-import org.eclipse.ui.internal.misc.StatusUtil;
-import org.eclipse.ui.internal.registry.ActionSetRegistry;
-import org.eclipse.ui.internal.registry.IActionSetDescriptor;
-import org.eclipse.ui.internal.registry.IWorkbenchRegistryConstants;
-import org.eclipse.ui.internal.registry.PerspectiveDescriptor;
-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.presentations.AbstractPresentationFactory;
-import org.eclipse.ui.presentations.IStackPresentationSite;
-import org.eclipse.ui.statushandlers.StatusManager;
-import org.eclipse.ui.views.IStickyViewDescriptor;
-import org.eclipse.ui.views.IViewDescriptor;
-import org.eclipse.ui.views.IViewRegistry;
-
-/**
- * The ViewManager is a factory for workbench views.
- */
-public class Perspective {
- protected PerspectiveDescriptor descriptor;
-
- protected WorkbenchPage page;
-
- // Editor Area management
- protected LayoutPart editorArea;
- protected PartPlaceholder editorHolder;
- protected boolean editorHidden = false;
- protected boolean editorAreaRestoreOnUnzoom = false;
- protected int editorAreaState = IStackPresentationSite.STATE_RESTORED;
-
- private ViewFactory viewFactory;
-
- protected ArrayList alwaysOnActionSets;
-
- protected ArrayList alwaysOffActionSets;
-
- protected ArrayList newWizardShortcuts;
-
- protected ArrayList showViewShortcuts;
-
- protected ArrayList perspectiveShortcuts;
-
- /** IDs of menu items the user has chosen to hide */
- protected Collection hideMenuIDs;
-
- /** IDs of toolbar items the user has chosen to hide */
- protected Collection hideToolBarIDs;
-
- //private List fastViews;
- protected FastViewManager fastViewManager = null;
-
- private Map mapIDtoViewLayoutRec;
-
- protected boolean fixed;
-
- protected ArrayList showInPartIds;
-
- protected HashMap showInTimes = new HashMap();
-
- private IViewReference activeFastView;
-
- protected IMemento memento;
-
- protected PerspectiveHelper presentation;
-
- final static private String VERSION_STRING = "0.016";//$NON-NLS-1$
-
- private FastViewPane fastViewPane = new FastViewPane();
-
- // fields used by fast view resizing via a sash
- private static final int FASTVIEW_HIDE_STEPS = 5;
-
- /**
- * Reference to the part that was previously active
- * when this perspective was deactivated.
- */
- private IWorkbenchPartReference oldPartRef = null;
-
- protected boolean shouldHideEditorsOnActivate = false;
-
- protected PageLayout layout;
-
- /**
- * ViewManager constructor comment.
- */
- public Perspective(PerspectiveDescriptor desc, WorkbenchPage page)
- throws WorkbenchException {
- this(page);
- descriptor = desc;
- if (desc != null) {
- createPresentation(desc);
- }
- }
-
- /**
- * ViewManager constructor comment.
- */
- protected Perspective(WorkbenchPage page) throws WorkbenchException {
- this.page = page;
- this.editorArea = page.getEditorPresentation().getLayoutPart();
- this.viewFactory = page.getViewFactory();
- alwaysOnActionSets = new ArrayList(2);
- alwaysOffActionSets = new ArrayList(2);
- hideMenuIDs = new HashSet();
- hideToolBarIDs = new HashSet();
-
- // We'll only make a FastView Manager if there's a
- // Trim manager in the WorkbenchWindow
- IWorkbenchWindow wbw = page.getWorkbenchWindow();
- if (wbw instanceof WorkbenchWindow) {
- if (((WorkbenchWindow)wbw).getTrimManager() != null)
- fastViewManager = new FastViewManager(this, page);
- }
-
- mapIDtoViewLayoutRec = new HashMap();
- }
-
- /**
- * Sets the fast view attribute. Note: The page is expected to update action
- * bars.
- */
- public void makeFastView(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.
- 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.
- *
- * @param part the part to bring to move forward
- * @return true if the part was brought to top, false if not.
- */
- public boolean bringToTop(IViewReference ref) {
- if (isFastView(ref)) {
- setActiveFastView(ref);
- return true;
- } else {
- return presentation.bringPartToTop(getPane(ref));
- }
- }
-
- /**
- * Returns whether a view exists within the perspective.
- */
- public boolean containsView(IViewPart view) {
- IViewSite site = view.getViewSite();
- IViewReference ref = findView(site.getId(), site.getSecondaryId());
- if (ref == null) {
- return false;
- }
- return (view == ref.getPart(false));
- }
-
- /**
- * Create the initial list of action sets.
- */
- protected void createInitialActionSets(List outputList, List stringList) {
- ActionSetRegistry reg = WorkbenchPlugin.getDefault()
- .getActionSetRegistry();
- Iterator iter = stringList.iterator();
- while (iter.hasNext()) {
- String id = (String) iter.next();
- IActionSetDescriptor desc = reg.findActionSet(id);
- if (desc != null) {
- outputList.add(desc);
- } else {
- WorkbenchPlugin.log("Unable to find Action Set: " + id);//$NON-NLS-1$
- }
- }
- }
-
- /**
- * Create a presentation for a perspective.
- */
- private void createPresentation(PerspectiveDescriptor persp)
- throws WorkbenchException {
- if (persp.hasCustomDefinition()) {
- loadCustomPersp(persp);
- } else {
- loadPredefinedPersp(persp);
- }
- }
-
- /**
- * Dispose the perspective and all views contained within.
- */
- public void dispose() {
- // Get rid of presentation.
- if (presentation == null) {
- disposeViewRefs();
- return;
- }
-
- presentation.deactivate();
- presentation.dispose();
-
- fastViewPane.dispose();
-
- // Release each view.
- IViewReference refs[] = getViewReferences();
- for (int i = 0, length = refs.length; i < length; i++) {
- getViewFactory().releaseView(refs[i]);
- }
-
- mapIDtoViewLayoutRec.clear();
- }
-
- private void disposeViewRefs() {
- if (memento == null) {
- return;
- }
- IMemento views[] = memento.getChildren(IWorkbenchConstants.TAG_VIEW);
- for (int x = 0; x < views.length; x++) {
- // Get the view details.
- IMemento childMem = views[x];
- String id = childMem.getString(IWorkbenchConstants.TAG_ID);
- // skip creation of the intro reference - it's handled elsewhere.
- if (id.equals(IIntroConstants.INTRO_VIEW_ID)) {
- continue;
- }
-
- String secondaryId = ViewFactory.extractSecondaryId(id);
- if (secondaryId != null) {
- id = ViewFactory.extractPrimaryId(id);
- }
- // Create and open the view.
-
- if (!"true".equals(childMem.getString(IWorkbenchConstants.TAG_REMOVED))) { //$NON-NLS-1$
- IViewReference ref = viewFactory.getView(id, secondaryId);
- if (ref != null) {
- viewFactory.releaseView(ref);
- }
- }
-
- }
- }
-
- /**
- * Finds the view with the given ID that is open in this page, or
- * <code>null</code> if not found.
- *
- * @param viewId
- * the view ID
- */
- public IViewReference findView(String viewId) {
- return findView(viewId, null);
- }
-
- /**
- * Finds the view with the given id and secondary id that is open in this page,
- * or <code>null</code> if not found.
- *
- * @param viewId the view ID
- * @param secondaryId the secondary ID
- */
- public IViewReference findView(String id, String secondaryId) {
- IViewReference refs[] = getViewReferences();
- for (int i = 0; i < refs.length; i++) {
- IViewReference ref = refs[i];
- if (id.equals(ref.getId())
- && (secondaryId == null ? ref.getSecondaryId() == null
- : secondaryId.equals(ref.getSecondaryId()))) {
- return ref;
- }
- }
- return null;
- }
-
- /**
- * Returns the window's client composite widget
- * which views and editor area will be parented.
- */
- public Composite getClientComposite() {
- return page.getClientComposite();
- }
-
- /**
- * Returns the perspective.
- */
- public IPerspectiveDescriptor getDesc() {
- return descriptor;
- }
-
- /**
- * Returns the bounds of the given fast view.
- */
- /*package*/Rectangle getFastViewBounds(IViewReference ref) {
- // Copy the bounds of the page composite
- Rectangle bounds = page.getClientComposite().getBounds();
- // get the width ratio of the fast view
- float ratio = getFastViewWidthRatio(ref);
- // Compute the actual width of the fast view.
- bounds.width = (int) (ratio * getClientComposite().getSize().x);
- return bounds;
- }
-
- /**
- * Returns the docked views.
- */
- public IViewReference[] getFastViews() {
- if (fastViewManager == null)
- return new IViewReference[0];
-
- List trueFVBRefs = fastViewManager.getFastViews(FastViewBar.FASTVIEWBAR_ID);
- IViewReference array[] = new IViewReference[trueFVBRefs.size()];
- trueFVBRefs.toArray(array);
- return array;
- }
-
- /**
- * Returns the new wizard shortcuts associated with this perspective.
- *
- * @return an array of new wizard identifiers
- */
- public String[] getNewWizardShortcuts() {
- return (String[]) newWizardShortcuts.toArray(new String[newWizardShortcuts.size()]);
- }
-
- /**
- * Returns the pane for a view reference.
- */
- protected ViewPane getPane(IViewReference ref) {
- return (ViewPane) ((WorkbenchPartReference) ref).getPane();
- }
-
- /**
- * Returns the perspective shortcuts associated with this perspective.
- *
- * @return an array of perspective identifiers
- */
- public String[] getPerspectiveShortcuts() {
- return (String[]) perspectiveShortcuts.toArray(new String[perspectiveShortcuts.size()]);
- }
-
- /**
- * Returns the presentation.
- */
- public PerspectiveHelper getPresentation() {
- return presentation;
- }
-
- /**
- * Retrieves the fast view width ratio for the given view.
- * If the ratio is not known, the default ratio for the view is assigned and returned.
- */
- public float getFastViewWidthRatio(IViewReference ref) {
- ViewLayoutRec rec = getViewLayoutRec(ref, true);
- if (rec.fastViewWidthRatio == IPageLayout.INVALID_RATIO) {
- IViewRegistry reg = WorkbenchPlugin.getDefault().getViewRegistry();
- IViewDescriptor desc = reg.find(ref.getId());
- rec.fastViewWidthRatio =
- (desc != null
- ? desc.getFastViewWidthRatio()
- : IPageLayout.DEFAULT_FASTVIEW_RATIO);
- }
- return rec.fastViewWidthRatio;
- }
-
- /**
- * Returns the ids of the parts to list in the Show In... dialog.
- * This is a List of Strings.
- */
- public ArrayList getShowInPartIds() {
- return showInPartIds;
- }
-
- /**
- * Returns the time at which the last Show In was performed
- * for the given target part, or 0 if unknown.
- */
- public long getShowInTime(String partId) {
- Long t = (Long) showInTimes.get(partId);
- return t == null ? 0L : t.longValue();
- }
-
- /**
- * Returns the show view shortcuts associated with this perspective.
- *
- * @return an array of view identifiers
- */
- public String[] getShowViewShortcuts() {
- return (String[]) showViewShortcuts.toArray(new String[showViewShortcuts.size()]);
- }
-
- /**
- * Returns the view factory.
- */
- public ViewFactory getViewFactory() {
- return viewFactory;
- }
-
- /**
- * See IWorkbenchPage.
- */
- public IViewReference[] getViewReferences() {
- // Get normal views.
- if (presentation == null) {
- return new IViewReference[0];
- }
-
- List panes = new ArrayList(5);
- presentation.collectViewPanes(panes);
-
- List fastViews = (fastViewManager != null) ?
- fastViewManager.getFastViews(null)
- : new ArrayList();
- IViewReference[] resultArray = new IViewReference[panes.size()
- + fastViews.size()];
-
- // Copy fast views.
- int nView = 0;
- for (int i = 0; i < fastViews.size(); i++) {
- resultArray[nView] = (IViewReference) fastViews.get(i);
- ++nView;
- }
-
- // Copy normal views.
- for (int i = 0; i < panes.size(); i++) {
- ViewPane pane = (ViewPane) panes.get(i);
- resultArray[nView] = pane.getViewReference();
- ++nView;
- }
-
- return resultArray;
- }
-
-
- /**
- * Hide the editor area if visible
- */
- protected void hideEditorArea() {
- if (!isEditorAreaVisible()) {
- return;
- }
-
- // Show the editor in the appropriate location
- if (useNewMinMax(this)) {
- // If it's the currently maximized part we have to restore first
- if (getPresentation().getMaximizedStack() instanceof EditorStack) {
- getPresentation().getMaximizedStack().setState(IStackPresentationSite.STATE_RESTORED);
- }
-
- boolean isMinimized = editorAreaState == IStackPresentationSite.STATE_MINIMIZED;
- if (!isMinimized)
- hideEditorAreaLocal();
- else
- setEditorAreaTrimVisibility(false);
- }
- else {
- hideEditorAreaLocal();
- }
-
- editorHidden = true;
- }
-
- /**
- * Hide the editor area if visible
- */
- protected void hideEditorAreaLocal() {
- if (editorHolder != null) {
- return;
- }
-
- // Replace the editor area with a placeholder so we
- // know where to put it back on show editor area request.
- editorHolder = new PartPlaceholder(editorArea.getID());
- presentation.getLayout().replace(editorArea, editorHolder);
- }
-
- /**
- * Hides a fast view. The view shrinks equally <code>steps</code> times
- * before disappearing completely.
- */
- private void hideFastView(IViewReference ref, int steps) {
- setFastViewIconSelection(ref, false);
-
- // Note: We always do at least one step of the animation.
- // Note: This doesn't take into account the overhead of doing
- if (ref == activeFastView) {
- saveFastViewWidthRatio();
- fastViewPane.hideView();
- }
- }
-
- /**
- * Hides the fast view sash for zooming in a fast view.
- */
- void hideFastViewSash() {
- fastViewPane.hideFastViewSash();
- }
-
- public boolean hideView(IViewReference ref) {
- // If the view is locked just return.
- ViewPane pane = getPane(ref);
-
- // Remove the view from the current presentation.
- if (isFastView(ref)) {
- if (pane != null) {
- pane.setFast(false); //force an update of the toolbar
- }
- if (activeFastView == ref) {
- setActiveFastView(null);
- }
- if (pane != null && pane.getControl() != null) {
- pane.getControl().setEnabled(true);
- }
-
- // Remove the view from the set of fast views
- if (fastViewManager != null)
- fastViewManager.removeViewReference(ref, false, true);
- } else {
- presentation.removePart(pane);
- }
-
- // Dispose view if ref count == 0.
- getViewFactory().releaseView(ref);
- return true;
- }
-
- /*
- * Return whether the editor area is visible or not.
- */
- protected boolean isEditorAreaVisible() {
- return !editorHidden;
- }
-
- /**
- * Returns true if a view is fast.
- */
- public boolean isFastView(IViewReference ref) {
- if (fastViewManager == null)
- return false;
-
- return fastViewManager.isFastView(ref);
- }
-
- /**
- * Returns the view layout rec for the given view reference,
- * or null if not found. If create is true, it creates the record
- * if not already created.
- */
- public ViewLayoutRec getViewLayoutRec(IViewReference ref, boolean create) {
- ViewLayoutRec result = getViewLayoutRec(ViewFactory.getKey(ref), create);
- if (result == null && create==false) {
- result = getViewLayoutRec(ref.getId(), false);
- }
- return result;
- }
-
- /**
- * Returns the view layout record for the given view id
- * or null if not found. If create is true, it creates the record
- * if not already created.
- */
- private ViewLayoutRec getViewLayoutRec(String viewId, boolean create) {
- ViewLayoutRec rec = (ViewLayoutRec) mapIDtoViewLayoutRec.get(viewId);
- if (rec == null && create) {
- rec = new ViewLayoutRec();
- mapIDtoViewLayoutRec.put(viewId, rec);
- }
- return rec;
- }
-
- /**
- * Returns true if a layout or perspective is fixed.
- */
- public boolean isFixedLayout() {
- //@issue is there a difference between a fixed
- //layout and a fixed perspective?? If not the API
- //may need some polish, WorkbenchPage, PageLayout
- //and Perspective all have isFixed methods.
- //PageLayout and Perspective have their own fixed
- //attribute, we are assuming they are always in sync.
- //WorkbenchPage delegates to the perspective.
- return fixed;
- }
-
- /**
- * Returns true if a view is standalone.
- *
- * @since 3.0
- */
- public boolean isStandaloneView(IViewReference ref) {
- ViewLayoutRec rec = getViewLayoutRec(ref, false);
- return rec != null && rec.isStandalone;
- }
-
- /**
- * Returns whether the title for a view should
- * be shown. This applies only to standalone views.
- *
- * @since 3.0
- */
- public boolean getShowTitleView(IViewReference ref) {
- ViewLayoutRec rec = getViewLayoutRec(ref, false);
- return rec != null && rec.showTitle;
- }
-
- /**
- * Creates a new presentation from a persistence file.
- * Note: This method should not modify the current state of the perspective.
- */
- private void loadCustomPersp(PerspectiveDescriptor persp) {
- //get the layout from the registry
- PerspectiveRegistry perspRegistry = (PerspectiveRegistry) WorkbenchPlugin
- .getDefault().getPerspectiveRegistry();
- try {
- IMemento memento = perspRegistry.getCustomPersp(persp.getId());
- // Restore the layout state.
- MultiStatus status = new MultiStatus(
- PlatformUI.PLUGIN_ID,
- IStatus.OK,
- NLS.bind(WorkbenchMessages.Perspective_unableToRestorePerspective, persp.getLabel()),
- null);
- status.merge(restoreState(memento));
- status.merge(restoreState());
- if (status.getSeverity() != IStatus.OK) {
- unableToOpenPerspective(persp, status);
- }
- } catch (IOException e) {
- unableToOpenPerspective(persp, null);
- } catch (WorkbenchException e) {
- unableToOpenPerspective(persp, e.getStatus());
- }
- }
-
- private void unableToOpenPerspective(PerspectiveDescriptor persp,
- IStatus status) {
- PerspectiveRegistry perspRegistry = (PerspectiveRegistry) WorkbenchPlugin
- .getDefault().getPerspectiveRegistry();
- perspRegistry.deletePerspective(persp);
- // If this is a predefined perspective, we will not be able to delete
- // the perspective (we wouldn't want to). But make sure to delete the
- // customized portion.
- persp.deleteCustomDefinition();
- String title = WorkbenchMessages.Perspective_problemRestoringTitle;
- String msg = WorkbenchMessages.Perspective_errorReadingState;
- if (status == null) {
- MessageDialog.openError((Shell) null, title, msg);
- } else {
- ErrorDialog.openError((Shell) null, title, msg, status);
- }
- }
-
- /**
- * Create a presentation for a perspective.
- * Note: This method should not modify the current state of the perspective.
- */
- protected void loadPredefinedPersp(PerspectiveDescriptor persp)
- throws WorkbenchException {
- // Create layout engine.
- IPerspectiveFactory factory = null;
- try {
- factory = persp.createFactory();
- } catch (CoreException e) {
- throw new WorkbenchException(NLS.bind(WorkbenchMessages.Perspective_unableToLoad, persp.getId() ));
- }
-
- /*
- * IPerspectiveFactory#createFactory() can return null
- */
- if (factory == null) {
- throw new WorkbenchException(NLS.bind(WorkbenchMessages.Perspective_unableToLoad, persp.getId() ));
- }
-
-
- // Create layout factory.
- ViewSashContainer container = new ViewSashContainer(page, getClientComposite());
- layout = new PageLayout(container, getViewFactory(),
- editorArea, descriptor);
- layout.setFixed(descriptor.getFixed());
-
- // add the placeholders for the sticky folders and their contents
- IPlaceholderFolderLayout stickyFolderRight = null, stickyFolderLeft = null, stickyFolderTop = null, stickyFolderBottom = null;
-
- IStickyViewDescriptor[] descs = WorkbenchPlugin.getDefault()
- .getViewRegistry().getStickyViews();
- for (int i = 0; i < descs.length; i++) {
- IStickyViewDescriptor stickyViewDescriptor = descs[i];
- String id = stickyViewDescriptor.getId();
- switch (stickyViewDescriptor.getLocation()) {
- case IPageLayout.RIGHT:
- if (stickyFolderRight == null) {
- stickyFolderRight = layout
- .createPlaceholderFolder(
- StickyViewDescriptor.STICKY_FOLDER_RIGHT,
- IPageLayout.RIGHT, .75f,
- IPageLayout.ID_EDITOR_AREA);
- }
- stickyFolderRight.addPlaceholder(id);
- break;
- case IPageLayout.LEFT:
- if (stickyFolderLeft == null) {
- stickyFolderLeft = layout.createPlaceholderFolder(
- StickyViewDescriptor.STICKY_FOLDER_LEFT,
- IPageLayout.LEFT, .25f, IPageLayout.ID_EDITOR_AREA);
- }
- stickyFolderLeft.addPlaceholder(id);
- break;
- case IPageLayout.TOP:
- if (stickyFolderTop == null) {
- stickyFolderTop = layout.createPlaceholderFolder(
- StickyViewDescriptor.STICKY_FOLDER_TOP,
- IPageLayout.TOP, .25f, IPageLayout.ID_EDITOR_AREA);
- }
- stickyFolderTop.addPlaceholder(id);
- break;
- case IPageLayout.BOTTOM:
- if (stickyFolderBottom == null) {
- stickyFolderBottom = layout.createPlaceholderFolder(
- StickyViewDescriptor.STICKY_FOLDER_BOTTOM,
- IPageLayout.BOTTOM, .75f,
- IPageLayout.ID_EDITOR_AREA);
- }
- stickyFolderBottom.addPlaceholder(id);
- break;
- }
-
- //should never be null as we've just added the view above
- IViewLayout viewLayout = layout.getViewLayout(id);
- viewLayout.setCloseable(stickyViewDescriptor.isCloseable());
- viewLayout.setMoveable(stickyViewDescriptor.isMoveable());
- }
-
- // Run layout engine.
- factory.createInitialLayout(layout);
- PerspectiveExtensionReader extender = new PerspectiveExtensionReader();
- extender.extendLayout(page.getExtensionTracker(), descriptor.getId(), layout);
-
- // Retrieve view layout info stored in the page layout.
- mapIDtoViewLayoutRec.putAll(layout.getIDtoViewLayoutRecMap());
-
- // Create action sets.
- List temp = new ArrayList();
- createInitialActionSets(temp, layout.getActionSets());
-
- IContextService service = null;
- if (page != null) {
- service = (IContextService) page.getWorkbenchWindow().getService(
- IContextService.class);
- }
- try {
- if (service!=null) {
- service.deferUpdates(true);
- }
- for (Iterator iter = temp.iterator(); iter.hasNext();) {
- IActionSetDescriptor descriptor = (IActionSetDescriptor) iter
- .next();
- addAlwaysOn(descriptor);
- }
- } finally {
- if (service!=null) {
- service.deferUpdates(false);
- }
- }
- newWizardShortcuts = layout.getNewWizardShortcuts();
- showViewShortcuts = layout.getShowViewShortcuts();
- perspectiveShortcuts = layout.getPerspectiveShortcuts();
- showInPartIds = layout.getShowInPartIds();
- hideMenuIDs = layout.getHiddenMenuItems();
- hideToolBarIDs = layout.getHiddenToolBarItems();
-
- // Retrieve fast views
- if (fastViewManager != null) {
- ArrayList fastViews = layout.getFastViews();
- for (Iterator fvIter = fastViews.iterator(); fvIter.hasNext();) {
- IViewReference ref = (IViewReference) fvIter.next();
- fastViewManager.addViewReference(FastViewBar.FASTVIEWBAR_ID, -1, ref,
- !fvIter.hasNext());
- }
- }
-
- // Is the layout fixed
- fixed = layout.isFixed();
-
- // Create presentation.
- presentation = new PerspectiveHelper(page, container, this);
-
- // Hide editor area if requested by factory
- if (!layout.isEditorAreaVisible()) {
- hideEditorArea();
- }
-
- }
-
- private void removeAlwaysOn(IActionSetDescriptor descriptor) {
- if (descriptor == null) {
- return;
- }
- if (!alwaysOnActionSets.contains(descriptor)) {
- return;
- }
-
- alwaysOnActionSets.remove(descriptor);
- if (page != null) {
- page.perspectiveActionSetChanged(this, descriptor, ActionSetManager.CHANGE_HIDE);
- }
- }
-
- protected void addAlwaysOff(IActionSetDescriptor descriptor) {
- if (descriptor == null) {
- return;
- }
- if (alwaysOffActionSets.contains(descriptor)) {
- return;
- }
- alwaysOffActionSets.add(descriptor);
- if (page != null) {
- page.perspectiveActionSetChanged(this, descriptor, ActionSetManager.CHANGE_MASK);
- }
- removeAlwaysOn(descriptor);
- }
-
- protected void addAlwaysOn(IActionSetDescriptor descriptor) {
- if (descriptor == null) {
- return;
- }
- if (alwaysOnActionSets.contains(descriptor)) {
- return;
- }
- alwaysOnActionSets.add(descriptor);
- if (page != null) {
- page.perspectiveActionSetChanged(this, descriptor, ActionSetManager.CHANGE_SHOW);
- }
- removeAlwaysOff(descriptor);
- }
-
- private void removeAlwaysOff(IActionSetDescriptor descriptor) {
- if (descriptor == null) {
- return;
- }
- if (!alwaysOffActionSets.contains(descriptor)) {
- return;
- }
- alwaysOffActionSets.remove(descriptor);
- if (page != null) {
- page.perspectiveActionSetChanged(this, descriptor, ActionSetManager.CHANGE_UNMASK);
- }
- }
-
- /**
- * activate.
- */
- protected void onActivate() {
- // Trim Stack Support
- boolean useNewMinMax = Perspective.useNewMinMax(this);
- boolean hideEditorArea = shouldHideEditorsOnActivate || (editorHidden && editorHolder == null);
-
- // Update editor area state.
- if (editorArea.getControl() != null) {
- boolean visible = isEditorAreaVisible();
- boolean inTrim = editorAreaState == IStackPresentationSite.STATE_MINIMIZED;
-
- // Funky check: Intro uses the old zoom behaviour when maximized. Make sure we don't show the
- // editor if it's supposed to be hidden because the intro is maximized. Note that
- // 'childObscuredByZoom' will only respond 'true' when using the old behaviour.
- boolean introMaxed = getPresentation().getLayout().childObscuredByZoom(editorArea);
-
- // We have to set the editor area's stack state -before-
- // activating the presentation since it's used there to determine
- // size of the resulting stack
- if (useNewMinMax && !hideEditorArea && !introMaxed) {
- refreshEditorAreaVisibility();
- }
-
- editorArea.setVisible(visible && !inTrim && !introMaxed);
- }
-
- // Update fast views.
- // Make sure the control for the fastviews are created so they can
- // be activated.
- if (fastViewManager != null) {
- List fastViews = fastViewManager.getFastViews(null);
- 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.
- }
- }
- }
-
- // Set the visibility of all fast view pins
- setAllPinsVisible(true);
-
- // Show the layout
- presentation.activate(getClientComposite());
-
- // Ensure that the action bars pick up local overrides
- final IMenuManager windowManager = page.getActionBars()
- .getMenuManager();
- allowUpdates(windowManager);
- windowManager.update(false);
-
- if (useNewMinMax) {
- fastViewManager.activate();
-
- // Move any minimized extension stacks to the trim
- if (layout != null) {
- // Turn aimations off
- IPreferenceStore preferenceStore = PrefUtil.getAPIPreferenceStore();
- boolean useAnimations = preferenceStore
- .getBoolean(IWorkbenchPreferenceConstants.ENABLE_ANIMATIONS);
- preferenceStore.setValue(IWorkbenchPreferenceConstants.ENABLE_ANIMATIONS, false);
-
- List minStacks = layout.getMinimizedStacks();
- for (Iterator msIter = minStacks.iterator(); msIter.hasNext();) {
- ViewStack vs = (ViewStack) msIter.next();
- vs.setMinimized(true);
- }
-
- // Restore the animation pref
- preferenceStore.setValue(IWorkbenchPreferenceConstants.ENABLE_ANIMATIONS, useAnimations);
-
- // this is a one-off deal...set during the extension reading
- minStacks.clear();
- layout = null;
- }
- }
- else {
- // Update the FVB only if not using the new min/max
- WorkbenchWindow wbw = (WorkbenchWindow) page.getWorkbenchWindow();
- if (wbw != null) {
- ITrimManager tbm = wbw.getTrimManager();
- if (tbm != null) {
- IWindowTrim fvb = tbm.getTrim(FastViewBar.FASTVIEWBAR_ID);
- if (fvb instanceof FastViewBar) {
- ((FastViewBar)fvb).update(true);
- }
- }
- }
- }
-
- // If we are -not- using the new min/max then ensure that there
- // are no stacks in the trim. This can happen when a user switches
- // back to the 3.0 presentation...
- if (!Perspective.useNewMinMax(this) && fastViewManager != null) {
- boolean stacksWereRestored = fastViewManager.restoreAllTrimStacks();
- setEditorAreaTrimVisibility(false);
-
- // Restore any 'maximized' view stack since we've restored
- // the minimized stacks
- if (stacksWereRestored && presentation.getMaximizedStack() instanceof ViewStack) {
- ViewStack vs = (ViewStack) presentation.getMaximizedStack();
- vs.setPresentationState(IStackPresentationSite.STATE_RESTORED);
- presentation.setMaximizedStack(null);
- }
- }
-
- // We hide the editor area -after- the presentation activates
- if (hideEditorArea) {
- // We do this here to ensure that createPartControl is called on the
- // top editor
- // before it is hidden. See bug 20166.
- hideEditorArea();
- shouldHideEditorsOnActivate = false;
-
- // this is an override so it should handle both states
- if (useNewMinMax)
- setEditorAreaTrimVisibility(editorAreaState == IStackPresentationSite.STATE_MINIMIZED);
- }
-
- // Fix perspectives whose contributing bundle has gone away
- fixOrphan();
-
- // Ensure that the new perspective's layout is correct
- if (page.window != null && page.window.getTrimManager() != null)
- page.window.getTrimManager().forceLayout();
- }
-
- /**
- * Mark the menu manager as dirty, and process all the children. Actual
- * updates of the widgets are deferred until menus are actually shown.
- *
- * @param menuManager
- * the manager to process.
- */
- private void allowUpdates(IMenuManager menuManager) {
- menuManager.markDirty();
- final IContributionItem[] items = menuManager.getItems();
- for (int i = 0; i < items.length; i++) {
- if (items[i] instanceof IMenuManager) {
- allowUpdates((IMenuManager) items[i]);
- } else if (items[i] instanceof SubContributionItem) {
- final IContributionItem innerItem = ((SubContributionItem) items[i])
- .getInnerItem();
- if (innerItem instanceof IMenuManager) {
- allowUpdates((IMenuManager) innerItem);
- }
- }
- }
- }
-
- /**
- * An 'orphan' perspective is one that was originally created through a
- * contribution but whose contributing bundle is no longer available. In
- * order to allow it to behave correctly within the environment (for Close,
- * Reset...) we turn it into a 'custom' perspective on its first activation.
- */
- private void fixOrphan() {
- PerspectiveRegistry reg = (PerspectiveRegistry) PlatformUI
- .getWorkbench().getPerspectiveRegistry();
- IPerspectiveDescriptor regDesc = reg.findPerspectiveWithId(descriptor
- .getId());
- if (regDesc == null) {
- String msg = "Perspective " + descriptor.getLabel() + " has been made into a local copy"; //$NON-NLS-1$//$NON-NLS-2$
- IStatus status = StatusUtil.newStatus(IStatus.WARNING, msg, null);
- StatusManager.getManager().handle(status, StatusManager.LOG);
-
- String newDescId = NLS.bind(
- WorkbenchMessages.Perspective_localCopyLabel, descriptor
- .getLabel());
- while (reg.findPerspectiveWithId(newDescId) != null) {
- newDescId = NLS.bind(WorkbenchMessages.Perspective_localCopyLabel, newDescId);
- }
- PerspectiveDescriptor newDesc = reg.createPerspective(newDescId, descriptor);
- page.savePerspectiveAs(newDesc);
- }
- }
-
- /**
- * deactivate.
- */
- protected void onDeactivate() {
- setActiveFastView(null);
- presentation.deactivate();
- setAllPinsVisible(false);
-
- // Update fast views.
- if (fastViewManager != null) {
- List fastViews = fastViewManager.getFastViews(null);
- 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.
- }
- }
- }
-
- fastViewManager.deActivate();
- }
-
- // Ensure that the editor area trim is hidden as well
- setEditorAreaTrimVisibility(false);
- }
-
- /**
- * Notifies that a part has been activated.
- */
- public void partActivated(IWorkbenchPart activePart) {
- // If a fastview is open close it.
- if (activeFastView != null
- && activeFastView.getPart(false) != activePart) {
- setActiveFastView(null);
- }
- }
-
- /**
- * The user successfully performed a Show In... action on the specified part.
- * Update the history.
- */
- 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) {
- 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 (activeFastView == ref) {
- setActiveFastView(null);
- }
-
- pane.setFast(false);
- Control ctrl = pane.getControl();
- if (ctrl != null) {
- ctrl.setEnabled(true); // Modify focus support.
- }
-
- 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.
- * Note: This method should not modify the current state of the perspective.
- */
- public IStatus restoreState(IMemento memento) {
- MultiStatus result = new MultiStatus(
- PlatformUI.PLUGIN_ID,
- IStatus.OK,
- WorkbenchMessages.Perspective_problemsRestoringPerspective, null);
-
- // Create persp descriptor.
- descriptor = new PerspectiveDescriptor(null, null, null);
- result.add(descriptor.restoreState(memento));
- PerspectiveDescriptor desc = (PerspectiveDescriptor) WorkbenchPlugin
- .getDefault().getPerspectiveRegistry().findPerspectiveWithId(
- descriptor.getId());
- if (desc != null) {
- descriptor = desc;
- }
-
- this.memento = memento;
- // Add the visible views.
- IMemento views[] = memento.getChildren(IWorkbenchConstants.TAG_VIEW);
- result.merge(createReferences(views));
-
- memento = memento.getChild(IWorkbenchConstants.TAG_FAST_VIEWS);
- if (memento != null) {
- views = memento.getChildren(IWorkbenchConstants.TAG_VIEW);
- result.merge(createReferences(views));
- }
- return result;
- }
-
- IStatus createReferences(IMemento views[]) {
- MultiStatus result = new MultiStatus(PlatformUI.PLUGIN_ID, IStatus.OK,
- WorkbenchMessages.Perspective_problemsRestoringViews, null);
-
- for (int x = 0; x < views.length; x++) {
- // Get the view details.
- IMemento childMem = views[x];
- String id = childMem.getString(IWorkbenchConstants.TAG_ID);
- // skip creation of the intro reference - it's handled elsewhere.
- if (id.equals(IIntroConstants.INTRO_VIEW_ID)) {
- continue;
- }
-
- String secondaryId = ViewFactory.extractSecondaryId(id);
- if (secondaryId != null) {
- id = ViewFactory.extractPrimaryId(id);
- }
- // Create and open the view.
- try {
- if (!"true".equals(childMem.getString(IWorkbenchConstants.TAG_REMOVED))) { //$NON-NLS-1$
- viewFactory.createView(id, secondaryId);
- }
- } catch (PartInitException e) {
- childMem.putString(IWorkbenchConstants.TAG_REMOVED, "true"); //$NON-NLS-1$
- result.add(StatusUtil.newStatus(IStatus.ERROR,
- e.getMessage() == null ? "" : e.getMessage(), //$NON-NLS-1$
- e));
- }
- }
- return result;
- }
-
- /**
- * Fills a presentation with layout data.
- * Note: This method should not modify the current state of the perspective.
- */
- public IStatus restoreState() {
- if (this.memento == null) {
- return Status.OK_STATUS;
- }
-
- MultiStatus result = new MultiStatus(
- PlatformUI.PLUGIN_ID,
- IStatus.OK,
- WorkbenchMessages.Perspective_problemsRestoringPerspective, null);
-
- IMemento memento = this.memento;
- this.memento = null;
-
- final IMemento boundsMem = memento.getChild(IWorkbenchConstants.TAG_WINDOW);
- if (boundsMem != null) {
- final Rectangle r = new Rectangle(0, 0, 0, 0);
- r.x = boundsMem.getInteger(IWorkbenchConstants.TAG_X).intValue();
- r.y = boundsMem.getInteger(IWorkbenchConstants.TAG_Y).intValue();
- r.height = boundsMem.getInteger(IWorkbenchConstants.TAG_HEIGHT)
- .intValue();
- r.width = boundsMem.getInteger(IWorkbenchConstants.TAG_WIDTH)
- .intValue();
- StartupThreading.runWithoutExceptions(new StartupRunnable() {
-
- public void runWithException() throws Throwable {
- if (page.getWorkbenchWindow().getPages().length == 0) {
- page.getWorkbenchWindow().getShell().setBounds(r);
- }
- }
- });
-
- }
-
- // Create an empty presentation..
- final PerspectiveHelper [] presArray = new PerspectiveHelper[1];
- StartupThreading.runWithoutExceptions(new StartupRunnable() {
-
- public void runWithException() throws Throwable {
- ViewSashContainer mainLayout = new ViewSashContainer(page, getClientComposite());
- presArray[0] = new PerspectiveHelper(page, mainLayout, Perspective.this);
- }});
- final PerspectiveHelper pres = presArray[0];
-
- // Read the layout.
- result.merge(pres.restoreState(memento
- .getChild(IWorkbenchConstants.TAG_LAYOUT)));
-
- StartupThreading.runWithoutExceptions(new StartupRunnable() {
-
- public void runWithException() throws Throwable {
- // Add the editor workbook. Do not hide it now.
- pres.replacePlaceholderWithPart(editorArea);
- }});
-
- // Add the visible views.
- IMemento[] views = memento.getChildren(IWorkbenchConstants.TAG_VIEW);
-
- for (int x = 0; x < views.length; x++) {
- // Get the view details.
- IMemento childMem = views[x];
- String id = childMem.getString(IWorkbenchConstants.TAG_ID);
- String secondaryId = ViewFactory.extractSecondaryId(id);
- if (secondaryId != null) {
- id = ViewFactory.extractPrimaryId(id);
- }
-
- // skip the intro as it is restored higher up in workbench.
- if (id.equals(IIntroConstants.INTRO_VIEW_ID)) {
- continue;
- }
-
- // Create and open the view.
- IViewReference viewRef = viewFactory.getView(id, secondaryId);
- WorkbenchPartReference ref = (WorkbenchPartReference) viewRef;
-
- // report error
- if (ref == null) {
- String key = ViewFactory.getKey(id, secondaryId);
- result.add(new Status(IStatus.ERROR, PlatformUI.PLUGIN_ID, 0,
- NLS.bind(WorkbenchMessages.Perspective_couldNotFind, key ), null));
- continue;
- }
- boolean willPartBeVisible = pres.willPartBeVisible(ref.getId(),
- secondaryId);
- if (willPartBeVisible) {
- IViewPart view = (IViewPart) ref.getPart(true);
- if (view != null) {
- ViewSite site = (ViewSite) view.getSite();
- ViewPane pane = (ViewPane) site.getPane();
- pres.replacePlaceholderWithPart(pane);
- }
- } else {
- pres.replacePlaceholderWithPart(ref.getPane());
- }
- }
-
- // Load the fast views
- if (fastViewManager != null)
- fastViewManager.restoreState(memento, result);
-
- // Load the view layout recs
- IMemento[] recMementos = memento
- .getChildren(IWorkbenchConstants.TAG_VIEW_LAYOUT_REC);
- for (int i = 0; i < recMementos.length; i++) {
- IMemento recMemento = recMementos[i];
- String compoundId = recMemento
- .getString(IWorkbenchConstants.TAG_ID);
- if (compoundId != null) {
- ViewLayoutRec rec = getViewLayoutRec(compoundId, true);
- if (IWorkbenchConstants.FALSE.equals(recMemento
- .getString(IWorkbenchConstants.TAG_CLOSEABLE))) {
- rec.isCloseable = false;
- }
- if (IWorkbenchConstants.FALSE.equals(recMemento
- .getString(IWorkbenchConstants.TAG_MOVEABLE))) {
- rec.isMoveable = false;
- }
- if (IWorkbenchConstants.TRUE.equals(recMemento
- .getString(IWorkbenchConstants.TAG_STANDALONE))) {
- rec.isStandalone = true;
- rec.showTitle = !IWorkbenchConstants.FALSE
- .equals(recMemento
- .getString(IWorkbenchConstants.TAG_SHOW_TITLE));
- }
- }
- }
-
- final IContextService service = (IContextService)page.getWorkbenchWindow().getService(IContextService.class);
- try { // one big try block, don't kill me here
- // defer context events
- if (service != null) {
- service.deferUpdates(true);
- }
-
- HashSet knownActionSetIds = new HashSet();
-
- // Load the always on action sets.
- IMemento[] actions = memento
- .getChildren(IWorkbenchConstants.TAG_ALWAYS_ON_ACTION_SET);
- for (int x = 0; x < actions.length; x++) {
- String actionSetID = actions[x]
- .getString(IWorkbenchConstants.TAG_ID);
- final IActionSetDescriptor d = WorkbenchPlugin.getDefault()
- .getActionSetRegistry().findActionSet(actionSetID);
- if (d != null) {
- StartupThreading
- .runWithoutExceptions(new StartupRunnable() {
- public void runWithException() throws Throwable {
- addAlwaysOn(d);
- }
- });
-
- knownActionSetIds.add(actionSetID);
- }
- }
-
- // Load the always off action sets.
- actions = memento
- .getChildren(IWorkbenchConstants.TAG_ALWAYS_OFF_ACTION_SET);
- for (int x = 0; x < actions.length; x++) {
- String actionSetID = actions[x]
- .getString(IWorkbenchConstants.TAG_ID);
- final IActionSetDescriptor d = WorkbenchPlugin.getDefault()
- .getActionSetRegistry().findActionSet(actionSetID);
- if (d != null) {
- StartupThreading
- .runWithoutExceptions(new StartupRunnable() {
- public void runWithException() throws Throwable {
- addAlwaysOff(d);
- }
- });
- knownActionSetIds.add(actionSetID);
- }
- }
-
- // Load "show view actions".
- actions = memento
- .getChildren(IWorkbenchConstants.TAG_SHOW_VIEW_ACTION);
- showViewShortcuts = new ArrayList(actions.length);
- for (int x = 0; x < actions.length; x++) {
- String id = actions[x].getString(IWorkbenchConstants.TAG_ID);
- showViewShortcuts.add(id);
- }
-
- // Load "show in times".
- actions = memento.getChildren(IWorkbenchConstants.TAG_SHOW_IN_TIME);
- for (int x = 0; x < actions.length; x++) {
- String id = actions[x].getString(IWorkbenchConstants.TAG_ID);
- String timeStr = actions[x]
- .getString(IWorkbenchConstants.TAG_TIME);
- if (id != null && timeStr != null) {
- try {
- long time = Long.parseLong(timeStr);
- showInTimes.put(id, new Long(time));
- } catch (NumberFormatException e) {
- // skip this one
- }
- }
- }
-
- // Load "show in parts" from registry, not memento
- showInPartIds = getShowInIdsFromRegistry();
-
- // Load "new wizard actions".
- actions = memento
- .getChildren(IWorkbenchConstants.TAG_NEW_WIZARD_ACTION);
- newWizardShortcuts = new ArrayList(actions.length);
- for (int x = 0; x < actions.length; x++) {
- String id = actions[x].getString(IWorkbenchConstants.TAG_ID);
- newWizardShortcuts.add(id);
- }
-
- // Load "perspective actions".
- actions = memento
- .getChildren(IWorkbenchConstants.TAG_PERSPECTIVE_ACTION);
- perspectiveShortcuts = new ArrayList(actions.length);
- for (int x = 0; x < actions.length; x++) {
- String id = actions[x].getString(IWorkbenchConstants.TAG_ID);
- perspectiveShortcuts.add(id);
- }
-
- // Load hidden menu item ids
- actions = memento.getChildren(IWorkbenchConstants.TAG_HIDE_MENU);
- hideMenuIDs = new HashSet();
- for (int x = 0; x < actions.length; x++) {
- String id = actions[x].getString(IWorkbenchConstants.TAG_ID);
- hideMenuIDs.add(id);
- }
- actions = memento.getChildren(IWorkbenchConstants.TAG_HIDE_TOOLBAR);
- hideToolBarIDs = new HashSet();
- for (int x = 0; x < actions.length; x++) {
- String id = actions[x].getString(IWorkbenchConstants.TAG_ID);
- hideToolBarIDs.add(id);
- }
-
- ArrayList extActionSets = getPerspectiveExtensionActionSets();
- for (int i = 0; i < extActionSets.size(); i++) {
- String actionSetID = (String) extActionSets.get(i);
- if (knownActionSetIds.contains(actionSetID)) {
- continue;
- }
- final IActionSetDescriptor d = WorkbenchPlugin.getDefault()
- .getActionSetRegistry().findActionSet(actionSetID);
- if (d != null) {
- StartupThreading
- .runWithoutExceptions(new StartupRunnable() {
- public void runWithException() throws Throwable {
- addAlwaysOn(d);
- }
- });
- knownActionSetIds.add(d.getId());
- }
- }
-
- // Add the visible set of action sets to our knownActionSetIds
- // Now go through the registry to ensure we pick up any new action
- // sets
- // that have been added but not yet considered by this perspective.
- ActionSetRegistry reg = WorkbenchPlugin.getDefault()
- .getActionSetRegistry();
- IActionSetDescriptor[] array = reg.getActionSets();
- int count = array.length;
- for (int i = 0; i < count; i++) {
- IActionSetDescriptor desc = array[i];
- if ((!knownActionSetIds.contains(desc.getId()))
- && (desc.isInitiallyVisible())) {
- addActionSet(desc);
- }
- }
- } finally {
- // restart context changes
- if (service != null) {
- StartupThreading.runWithoutExceptions(new StartupRunnable() {
- public void runWithException() throws Throwable {
- service.deferUpdates(false);
- }
- });
- }
- }
-
- // Save presentation.
- presentation = pres;
-
- // Hide the editor area if needed. Need to wait for the
- // presentation to be fully setup first.
- Integer areaVisible = memento
- .getInteger(IWorkbenchConstants.TAG_AREA_VISIBLE);
- // Rather than hiding the editors now we must wait until after their
- // controls
- // are created. This ensures that if an editor is instantiated,
- // createPartControl
- // is also called. See bug 20166.
- shouldHideEditorsOnActivate = (areaVisible != null && areaVisible
- .intValue() == 0);
-
- // Restore the trim state of the editor area
- IPreferenceStore preferenceStore = PrefUtil.getAPIPreferenceStore();
- boolean useNewMinMax = preferenceStore.getBoolean(IWorkbenchPreferenceConstants.ENABLE_NEW_MIN_MAX);
- if (useNewMinMax) {
- Integer trimStateInt = memento.getInteger(IWorkbenchConstants.TAG_AREA_TRIM_STATE);
- if (trimStateInt != null) {
- editorAreaState = trimStateInt.intValue() & 0x3; // low order two bits contain the state
- editorAreaRestoreOnUnzoom = (trimStateInt.intValue() & 4) != 0;
- }
- }
-
- // restore the fixed state
- Integer isFixed = memento.getInteger(IWorkbenchConstants.TAG_FIXED);
- fixed = (isFixed != null && isFixed.intValue() == 1);
-
- return result;
- }
-
- /**
- * Restores a fast view to its corrent presentation structure.
- * This method is pubilc because the FastViewManager uses it to
- * reconstruct it minimized stacks on startup.
- *
- * @param fvMemento The mement containing the fast view info
- * @param result The result status
- * @return The reference to the restored view
- */
- public IViewReference restoreFastView(IMemento fvMemento, MultiStatus result) {
- String viewID = fvMemento.getString(IWorkbenchConstants.TAG_ID);
- String secondaryId = ViewFactory.extractSecondaryId(viewID);
- if (secondaryId != null) {
- viewID = ViewFactory.extractPrimaryId(viewID);
- }
-
- IViewReference viewRef = getViewFactory().getView(viewID, secondaryId);
- if (viewRef == null) {
- String key = ViewFactory.getKey(viewID, secondaryId);
- WorkbenchPlugin
- .log("Could not create view: '" + key + "'."); //$NON-NLS-1$ //$NON-NLS-2$
- result
- .add(new Status(
- IStatus.ERROR,
- PlatformUI.PLUGIN_ID,
- 0,
- NLS.bind(WorkbenchMessages.Perspective_couldNotFind, key ),
- null));
- return null;
- }
-
- // Restore fast view width ratio
- Float ratio = fvMemento.getFloat(IWorkbenchConstants.TAG_RATIO);
- if (ratio == null) {
- Integer viewWidth = fvMemento
- .getInteger(IWorkbenchConstants.TAG_WIDTH);
- if (viewWidth == null) {
- ratio = new Float(IPageLayout.DEFAULT_FASTVIEW_RATIO);
- } else {
- ratio = new Float((float) viewWidth.intValue()
- / (float) getClientComposite().getSize().x);
- }
- }
- ViewLayoutRec rec = getViewLayoutRec(viewRef, true);
- rec.fastViewWidthRatio = ratio.floatValue();
-
- return viewRef;
- }
-
- /**
- * Returns the ActionSets read from perspectiveExtensions in the registry.
- */
- protected ArrayList getPerspectiveExtensionActionSets() {
- PerspectiveExtensionReader reader = new PerspectiveExtensionReader();
- reader
- .setIncludeOnlyTags(new String[] { IWorkbenchRegistryConstants.TAG_ACTION_SET });
- PageLayout layout = new PageLayout();
- reader.extendLayout(null, descriptor.getOriginalId(), layout);
- return layout.getActionSets();
- }
-
- /**
- * Returns the Show In... part ids read from the registry.
- */
- protected ArrayList getShowInIdsFromRegistry() {
- PerspectiveExtensionReader reader = new PerspectiveExtensionReader();
- reader
- .setIncludeOnlyTags(new String[] { IWorkbenchRegistryConstants.TAG_SHOW_IN_PART });
- PageLayout layout = new PageLayout();
- reader.extendLayout(null, descriptor.getOriginalId(), layout);
- return layout.getShowInPartIds();
- }
-
- /**
- * Save the layout.
- */
- public void saveDesc() {
- saveDescAs(descriptor);
- }
-
- /**
- * Save the layout.
- */
- public void saveDescAs(IPerspectiveDescriptor desc) {
- PerspectiveDescriptor realDesc = (PerspectiveDescriptor) desc;
- //get the layout from the registry
- PerspectiveRegistry perspRegistry = (PerspectiveRegistry) WorkbenchPlugin
- .getDefault().getPerspectiveRegistry();
- // Capture the layout state.
- XMLMemento memento = XMLMemento.createWriteRoot("perspective");//$NON-NLS-1$
- IStatus status = saveState(memento, realDesc, false);
- if (status.getSeverity() == IStatus.ERROR) {
- ErrorDialog.openError((Shell) null, WorkbenchMessages.Perspective_problemSavingTitle,
- WorkbenchMessages.Perspective_problemSavingMessage,
- status);
- return;
- }
- //save it to the preference store
- try {
- perspRegistry.saveCustomPersp(realDesc, memento);
- descriptor = realDesc;
- } catch (IOException e) {
- perspRegistry.deletePerspective(realDesc);
- MessageDialog.openError((Shell) null, WorkbenchMessages.Perspective_problemSavingTitle,
- WorkbenchMessages.Perspective_problemSavingMessage);
- }
- }
-
- /**
- * Save the layout.
- */
- public IStatus saveState(IMemento memento) {
- MultiStatus result = new MultiStatus(
- PlatformUI.PLUGIN_ID,
- IStatus.OK,
- WorkbenchMessages.Perspective_problemsSavingPerspective, null);
-
- result.merge(saveState(memento, descriptor, true));
-
- return result;
- }
-
- /**
- * Save the layout.
- */
- private IStatus saveState(IMemento memento, PerspectiveDescriptor p,
- boolean saveInnerViewState) {
- MultiStatus result = new MultiStatus(
- PlatformUI.PLUGIN_ID,
- IStatus.OK,
- WorkbenchMessages.Perspective_problemsSavingPerspective, null);
-
- if (this.memento != null) {
- memento.putMemento(this.memento);
- return result;
- }
-
- // Save the version number.
- memento.putString(IWorkbenchConstants.TAG_VERSION, VERSION_STRING);
- result.add(p.saveState(memento));
- if (!saveInnerViewState) {
- Rectangle bounds = page.getWorkbenchWindow().getShell().getBounds();
- IMemento boundsMem = memento
- .createChild(IWorkbenchConstants.TAG_WINDOW);
- boundsMem.putInteger(IWorkbenchConstants.TAG_X, bounds.x);
- boundsMem.putInteger(IWorkbenchConstants.TAG_Y, bounds.y);
- boundsMem.putInteger(IWorkbenchConstants.TAG_HEIGHT, bounds.height);
- boundsMem.putInteger(IWorkbenchConstants.TAG_WIDTH, bounds.width);
- }
-
-
- // Save the "always on" action sets.
- Iterator itr = alwaysOnActionSets.iterator();
- while (itr.hasNext()) {
- IActionSetDescriptor desc = (IActionSetDescriptor) itr.next();
- IMemento child = memento
- .createChild(IWorkbenchConstants.TAG_ALWAYS_ON_ACTION_SET);
- child.putString(IWorkbenchConstants.TAG_ID, desc.getId());
- }
-
- // Save the "always off" action sets.
- itr = alwaysOffActionSets.iterator();
- while (itr.hasNext()) {
- IActionSetDescriptor desc = (IActionSetDescriptor) itr.next();
- IMemento child = memento
- .createChild(IWorkbenchConstants.TAG_ALWAYS_OFF_ACTION_SET);
- child.putString(IWorkbenchConstants.TAG_ID, desc.getId());
- }
-
- // Save "show view actions"
- itr = showViewShortcuts.iterator();
- while (itr.hasNext()) {
- String str = (String) itr.next();
- IMemento child = memento
- .createChild(IWorkbenchConstants.TAG_SHOW_VIEW_ACTION);
- child.putString(IWorkbenchConstants.TAG_ID, str);
- }
-
- // Save "show in times"
- itr = showInTimes.keySet().iterator();
- while (itr.hasNext()) {
- String id = (String) itr.next();
- Long time = (Long) showInTimes.get(id);
- IMemento child = memento
- .createChild(IWorkbenchConstants.TAG_SHOW_IN_TIME);
- child.putString(IWorkbenchConstants.TAG_ID, id);
- child.putString(IWorkbenchConstants.TAG_TIME, time.toString());
- }
-
- // Save "new wizard actions".
- itr = newWizardShortcuts.iterator();
- while (itr.hasNext()) {
- String str = (String) itr.next();
- IMemento child = memento
- .createChild(IWorkbenchConstants.TAG_NEW_WIZARD_ACTION);
- child.putString(IWorkbenchConstants.TAG_ID, str);
- }
-
- // Save "perspective actions".
- itr = perspectiveShortcuts.iterator();
- while (itr.hasNext()) {
- String str = (String) itr.next();
- IMemento child = memento
- .createChild(IWorkbenchConstants.TAG_PERSPECTIVE_ACTION);
- child.putString(IWorkbenchConstants.TAG_ID, str);
- }
-
- // Save hidden menu item ids
- itr = hideMenuIDs.iterator();
- while(itr.hasNext()) {
- String str = (String) itr.next();
- IMemento child = memento.createChild(IWorkbenchConstants.TAG_HIDE_MENU);
- child.putString(IWorkbenchConstants.TAG_ID, str);
- }
- itr = hideToolBarIDs.iterator();
- while(itr.hasNext()) {
- String str = (String) itr.next();
- IMemento child = memento.createChild(IWorkbenchConstants.TAG_HIDE_TOOLBAR);
- child.putString(IWorkbenchConstants.TAG_ID, str);
- }
-
- // Get visible views.
- List viewPanes = new ArrayList(5);
- presentation.collectViewPanes(viewPanes);
-
- // Save the views.
- itr = viewPanes.iterator();
- int errors = 0;
- while (itr.hasNext()) {
- ViewPane pane = (ViewPane) itr.next();
- IViewReference ref = pane.getViewReference();
- IViewDescriptor desc = page.getViewFactory().getViewRegistry()
- .find(ref.getId());
- if (desc != null && desc.isRestorable()) {
- IMemento viewMemento = memento
- .createChild(IWorkbenchConstants.TAG_VIEW);
- viewMemento.putString(IWorkbenchConstants.TAG_ID, ViewFactory
- .getKey(ref));
- }
- }
-
- // save all fastview state
- if (fastViewManager != null)
- fastViewManager.saveState(memento);
-
- // Save the view layout recs.
- for (Iterator i = mapIDtoViewLayoutRec.keySet().iterator(); i.hasNext();) {
- String compoundId = (String) i.next();
- ViewLayoutRec rec = (ViewLayoutRec) mapIDtoViewLayoutRec
- .get(compoundId);
- if (rec != null
- && (!rec.isCloseable || !rec.isMoveable || rec.isStandalone)) {
- IMemento layoutMemento = memento
- .createChild(IWorkbenchConstants.TAG_VIEW_LAYOUT_REC);
- layoutMemento.putString(IWorkbenchConstants.TAG_ID, compoundId);
- if (!rec.isCloseable) {
- layoutMemento.putString(IWorkbenchConstants.TAG_CLOSEABLE,
- IWorkbenchConstants.FALSE);
- }
- if (!rec.isMoveable) {
- layoutMemento.putString(IWorkbenchConstants.TAG_MOVEABLE,
- IWorkbenchConstants.FALSE);
- }
- if (rec.isStandalone) {
- layoutMemento.putString(IWorkbenchConstants.TAG_STANDALONE,
- IWorkbenchConstants.TRUE);
- layoutMemento.putString(IWorkbenchConstants.TAG_SHOW_TITLE,
- String.valueOf(rec.showTitle));
- }
- }
- }
-
- if (errors > 0) {
- String message = WorkbenchMessages.Perspective_multipleErrors;
- if (errors == 1) {
- message = WorkbenchMessages.Perspective_oneError;
- }
- MessageDialog.openError(null,
- WorkbenchMessages.Error, message);
- }
-
- // Save the layout.
- IMemento childMem = memento.createChild(IWorkbenchConstants.TAG_LAYOUT);
- result.add(presentation.saveState(childMem));
-
- // Save the editor visibility state
- if (isEditorAreaVisible()) {
- memento.putInteger(IWorkbenchConstants.TAG_AREA_VISIBLE, 1);
- } else {
- memento.putInteger(IWorkbenchConstants.TAG_AREA_VISIBLE, 0);
- }
-
- // Save the trim state of the editor area if using the new min/max
- IPreferenceStore preferenceStore = PrefUtil.getAPIPreferenceStore();
- boolean useNewMinMax = preferenceStore.getBoolean(IWorkbenchPreferenceConstants.ENABLE_NEW_MIN_MAX);
- if (useNewMinMax) {
- int trimState = editorAreaState;
- trimState |= editorAreaRestoreOnUnzoom ? 4 : 0;
- memento.putInteger(IWorkbenchConstants.TAG_AREA_TRIM_STATE, trimState);
- }
-
- // Save the fixed state
- if (fixed) {
- memento.putInteger(IWorkbenchConstants.TAG_FIXED, 1);
- } else {
- memento.putInteger(IWorkbenchConstants.TAG_FIXED, 0);
- }
-
- return result;
- }
-
- public void turnOnActionSets(IActionSetDescriptor[] newArray) {
- for (int i = 0; i < newArray.length; i++) {
- IActionSetDescriptor descriptor = newArray[i];
-
- addAlwaysOn(descriptor);
- }
- }
-
- public void turnOffActionSets(IActionSetDescriptor[] toDisable) {
- for (int i = 0; i < toDisable.length; i++) {
- IActionSetDescriptor descriptor = toDisable[i];
-
- turnOffActionSet(descriptor);
- }
- }
-
- public void turnOffActionSet(IActionSetDescriptor toDisable) {
- addAlwaysOff(toDisable);
- }
-
- /**
- * Return the active fast view or null if there are no
- * fast views or if there are all minimized.
- */
- public IViewReference getActiveFastView() {
- return activeFastView;
- }
-
- /**
- * Sets the active fast view. If a different fast view is already open,
- * it shrinks equally <code>steps</code> times before disappearing
- * completely. Then, <code>view</code> becomes active and is shown.
- */
- /*package*/void setActiveFastView(IViewReference ref, int steps) {
- if (activeFastView == ref) {
- return;
- }
-
- if (activeFastView != null) {
- ViewPane pane = getPane(activeFastView);
- if (pane != null) {
- if (pane.isZoomed()) {
- pane.setZoomed(false);
- }
- hideFastView(activeFastView, steps);
- }
- }
- activeFastView = ref;
- try {
- if (activeFastView != null) {
- if (!showFastView(activeFastView)) {
- activeFastView = null;
- }
- }
- } catch (RuntimeException e) {
- activeFastView = null;
- }
- }
-
- /**
- * Sets the active fast view.
- */
- /*package*/void setActiveFastView(IViewReference ref) {
- setActiveFastView(ref, FASTVIEW_HIDE_STEPS);
- }
-
- /**
- * Sets the visibility of all fast view pins.
- */
- protected void setAllPinsVisible(boolean visible) {
- if (fastViewManager == null)
- return;
-
- Iterator iter = fastViewManager.getFastViews(null).iterator();
- while (iter.hasNext()) {
- ViewPane pane = getPane((IViewReference) iter.next());
- if (pane != null) {
- pane.setFast(visible);
- }
- }
- }
-
- /**
- * Sets the selection for the shortcut bar icon representing the givevn fast view.
- */
- private void setFastViewIconSelection(IViewReference ref, boolean selected) {
- if (fastViewManager == null)
- return;
-
- fastViewManager.setFastViewIconSelection(ref, selected);
- }
-
- /**
- * Sets the new wizard actions for the page.
- * This is List of Strings.
- */
- public void setNewWizardActionIds(ArrayList newList) {
- newWizardShortcuts = newList;
- }
-
- /**
- * Sets the perspective actions for this page.
- * This is List of Strings.
- */
- public void setPerspectiveActionIds(ArrayList list) {
- perspectiveShortcuts = list;
- }
-
- /**
- * Sets the ids of the parts to list in the Show In... prompter.
- * This is a List of Strings.
- */
- public void setShowInPartIds(ArrayList list) {
- showInPartIds = list;
- }
-
- /**
- * Sets the ids of the views to list in the Show View shortcuts.
- * This is a List of Strings.
- */
- public void setShowViewActionIds(ArrayList list) {
- showViewShortcuts = list;
- }
-
-
- /**
- * Show the editor area if not visible
- */
- protected void showEditorArea() {
- if (isEditorAreaVisible()) {
- return;
- }
-
- editorHidden = false;
-
- // Show the editor in the appropriate location
- if (useNewMinMax(this)) {
- boolean isMinimized = editorAreaState == IStackPresentationSite.STATE_MINIMIZED;
- if (!isMinimized) {
- // If the editor area is going to show then we have to restore
- if (getPresentation().getMaximizedStack() != null)
- getPresentation().getMaximizedStack().setState(IStackPresentationSite.STATE_RESTORED);
-
- showEditorAreaLocal();
- }
- else
- setEditorAreaTrimVisibility(true);
- }
- else {
- showEditorAreaLocal();
- }
- }
-
- /**
- * Show the editor area if not visible
- */
- protected void showEditorAreaLocal() {
- if (editorHolder == null || editorHidden) {
- return;
- }
-
- // Replace the part holder with the editor area.
- presentation.getLayout().replace(editorHolder, editorArea);
- editorHolder = null;
- }
-
- private EditorAreaTrimToolBar getEditorAreaTrim(boolean createIfNecessary) {
- WorkbenchWindow wbw = (WorkbenchWindow) page.getWorkbenchWindow();
- ITrimManager tbm = wbw.getTrimManager();
- if (tbm == null)
- return null;
-
- // Create if necesary
- EditorAreaTrimToolBar editorAreaTrim = (EditorAreaTrimToolBar) tbm.getTrim(IPageLayout.ID_EDITOR_AREA);
- if (editorAreaTrim == null && createIfNecessary) {
- int suggestedSide = SWT.RIGHT;
- int cachedSide = ((TrimLayout)tbm).getPreferredArea(IPageLayout.ID_EDITOR_AREA);
- if (cachedSide != -1)
- suggestedSide = cachedSide;
-
- IWindowTrim beforeMe = ((TrimLayout)tbm).getPreferredLocation(IPageLayout.ID_EDITOR_AREA);
-
- // Gain access to the trim manager
- editorAreaTrim = new EditorAreaTrimToolBar(wbw);
- editorAreaTrim.dock(suggestedSide);
- tbm.addTrim(suggestedSide, editorAreaTrim, beforeMe);
- }
-
- return editorAreaTrim;
- }
-
- public void setEditorAreaState(int newState) {
- if (newState == editorAreaState)
- return;
-
- editorAreaState = newState;
-
- // reset the restore flag if we're not minimized
- if (newState != IStackPresentationSite.STATE_MINIMIZED)
- editorAreaRestoreOnUnzoom = false;
-
- refreshEditorAreaVisibility();
- }
-
- public int getEditorAreaState() {
- return editorAreaState;
- }
-
- /**
- *
- */
- public void refreshEditorAreaVisibility() {
- // Nothing shows up if the editor area isn't visible at all
- if (editorHidden) {
- hideEditorAreaLocal();
- setEditorAreaTrimVisibility(false);
- return;
- }
-
- EditorStack editorStack = ((EditorSashContainer) editorArea).getUpperRightEditorStack(null);
- if (editorStack == null)
- return;
-
- // Make sure that the other editor stack all match *this* presentation
- // state
- LayoutPart[] stacks = ((EditorSashContainer) editorArea).getChildren();
- for (int i = 0; i < stacks.length; i++) {
- if (stacks[i] instanceof EditorStack && stacks[i] != editorStack) {
- EditorStack es = (EditorStack) stacks[i];
- es.setPresentationState(editorAreaState);
- }
- }
-
- // Whatever we're doing, make the current editor stack match it
- editorStack.setStateLocal(editorAreaState);
-
- // Override the visibility of the EA's min.max buttons based on the
- // 'fixed' state
- editorStack.showMinMax(!isFixedLayout());
-
- // If it's minimized then it's in the trim
- if (editorAreaState == IStackPresentationSite.STATE_MINIMIZED) {
- // Hide the editor area and show its trim
- hideEditorAreaLocal();
- setEditorAreaTrimVisibility(true);
- }
- else {
- // Show the editor area and hide its trim
- setEditorAreaTrimVisibility(false);
- showEditorAreaLocal();
-
- if (editorAreaState == IStackPresentationSite.STATE_MAXIMIZED)
- getPresentation().setMaximizedStack(editorStack);
- }
- }
-
- protected EditorAreaTrimToolBar setEditorAreaTrimVisibility(boolean visible) {
- WorkbenchWindow wbw = (WorkbenchWindow) page.getWorkbenchWindow();
- ITrimManager tbm = wbw.getTrimManager();
- if (tbm == null)
- return null;
-
- // Only create the trim element if it's going to be visible
- EditorAreaTrimToolBar editorAreaTrim = getEditorAreaTrim(visible);
- if (editorAreaTrim == null)
- return null;
-
- tbm.setTrimVisible(editorAreaTrim, visible);
- tbm.forceLayout();
-
- return editorAreaTrim;
- }
-
- /**
- * Shows a fast view.
- * @return whether the view was successfully shown
- */
- boolean showFastView(IViewReference ref) {
- if (fastViewManager == null)
- return false;
-
- // Make sure the part is restored.
- IWorkbenchPart refPart = ref.getPart(true);
- if (refPart == null) {
- return false;
- }
-
- ViewPane pane = getPane(ref);
- if (pane == null) {
- return false;
- }
-
- saveFastViewWidthRatio();
-
- // Special check to ensure that a 'minimized' intro view shows
- // as 'standby'
- if (ref.getId().equals("org.eclipse.ui.internal.introview")) { //$NON-NLS-1$
- if (refPart instanceof ViewIntroAdapterPart) {
- ((ViewIntroAdapterPart)refPart).setStandby(true);
- }
- }
-
- // Determine the display orientation
- int side = fastViewManager.getViewSide(ref);
- fastViewPane.showView(getClientComposite(), pane, side,
- getFastViewWidthRatio(ref));
-
- setFastViewIconSelection(ref, true);
-
- return true;
- }
-
- private void saveFastViewWidthRatio() {
- ViewPane pane = fastViewPane.getCurrentPane();
- if (pane != null) {
- ViewLayoutRec rec = getViewLayoutRec(pane.getViewReference(), true);
- rec.fastViewWidthRatio = fastViewPane.getCurrentRatio();
- }
- }
-
- /**
- * Resolves a view's id into its reference, creating the
- * view if necessary.
- *
- * @param viewId The primary id of the view (must not be
- * <code>null</code>
- * @param secondaryId The secondary id of a multiple-instance view
- * (may be <code>null</code>).
- *
- * @return The reference to the specified view. This may be null if the
- * view fails to create (i.e. thrown a PartInitException)
- */
- public IViewReference getViewReference(String viewId, String secondaryId) {
- IViewReference ref = page.findViewReference(viewId, secondaryId);
- if (ref == null) {
- ViewFactory factory = getViewFactory();
- try {
- ref = factory.createView(viewId, secondaryId);
- } catch (PartInitException e) {
- IStatus status = StatusUtil.newStatus(IStatus.ERROR,
- e.getMessage() == null ? "" : e.getMessage(), //$NON-NLS-1$
- e);
- StatusUtil.handleStatus(status, "Failed to create view: id=" + viewId, //$NON-NLS-1$
- StatusManager.LOG);
- }
- }
- return ref;
- }
-
- /**
- * Shows the view with the given id and secondary id.
- */
- public IViewPart showView(String viewId, String secondaryId)
- throws PartInitException {
- ViewFactory factory = getViewFactory();
- IViewReference ref = factory.createView(viewId, secondaryId);
- IViewPart part = (IViewPart) ref.getPart(true);
- if (part == null) {
- throw new PartInitException(NLS.bind(WorkbenchMessages.ViewFactory_couldNotCreate, ref.getId()));
- }
- ViewSite site = (ViewSite) part.getSite();
- ViewPane pane = (ViewPane) site.getPane();
-
- IPreferenceStore store = WorkbenchPlugin.getDefault()
- .getPreferenceStore();
- int openViewMode = store.getInt(IPreferenceConstants.OPEN_VIEW_MODE);
-
- if (openViewMode == IPreferenceConstants.OVM_FAST &&
- fastViewManager != null) {
- fastViewManager.addViewReference(FastViewBar.FASTVIEWBAR_ID, -1, ref, true);
- setActiveFastView(ref);
- } else if (openViewMode == IPreferenceConstants.OVM_FLOAT
- && presentation.canDetach()) {
- presentation.addDetachedPart(pane);
- } else {
- if (useNewMinMax(this)) {
- // Is this view going to show in the trim?
- LayoutPart vPart = presentation.findPart(viewId, secondaryId);
-
- // Determine if there is a trim stack that should get the view
- String trimId = null;
-
- // If we can locate the correct trim stack then do so
- if (vPart != null) {
- String id = null;
- ILayoutContainer container = vPart.getContainer();
- if (container instanceof ContainerPlaceholder)
- id = ((ContainerPlaceholder)container).getID();
- else if (container instanceof ViewStack)
- id = ((ViewStack)container).getID();
- else if (container instanceof DetachedPlaceHolder) {
- // Views in a detached window don't participate in the
- // minimize behavior so just revert to the default
- // behavior
- presentation.addPart(pane);
- return part;
- }
-
- // Is this place-holder in the trim?
- if (id != null && fastViewManager.getFastViews(id).size() > 0) {
- trimId = id;
- }
- }
-
- // No explicit trim found; If we're maximized then we either have to find an
- // arbitrary stack...
- if (trimId == null
- && presentation.getMaximizedStack() != null) {
- if (vPart == null) {
- ViewStackTrimToolBar blTrimStack = fastViewManager.getBottomRightTrimStack();
- if (blTrimStack != null) {
- // OK, we've found a trim stack to add it to...
- trimId = blTrimStack.getId();
-
- // Since there was no placeholder we have to add one
- LayoutPart blPart = presentation.findPart(trimId, null);
- if (blPart instanceof ContainerPlaceholder) {
- ContainerPlaceholder cph = (ContainerPlaceholder) blPart;
- if (cph.getRealContainer() instanceof ViewStack) {
- ViewStack vs = (ViewStack) cph.getRealContainer();
-
- // Create a 'compound' id if this is a multi-instance part
- String compoundId = ref.getId();
- if (ref.getSecondaryId() != null)
- compoundId = compoundId + ':' + ref.getSecondaryId();
-
- // Add the new placeholder
- vs.add(new PartPlaceholder(compoundId));
- }
- }
- }
- }
- }
-
- // If we have a trim stack located then add the view to it
- if (trimId != null) {
- fastViewManager.addViewReference(trimId, -1, ref, true);
- }
- else {
- boolean inMaximizedStack = vPart != null && vPart.getContainer() == presentation.getMaximizedStack();
-
- // Do the default behavior
- presentation.addPart(pane);
-
- // Now, if we're maximized then we have to minimize the new stack
- if (presentation.getMaximizedStack() != null && !inMaximizedStack) {
- vPart = presentation.findPart(viewId, secondaryId);
- if (vPart != null && vPart.getContainer() instanceof ViewStack) {
- ViewStack vs = (ViewStack)vPart.getContainer();
- vs.setState(IStackPresentationSite.STATE_MINIMIZED);
-
- // setting the state to minimized will create the trim toolbar
- // so we don't need a null pointer check here...
- fastViewManager.getViewStackTrimToolbar(vs.getID()).setRestoreOnUnzoom(true);
- }
- }
- }
- }
- else {
- presentation.addPart(pane);
- }
- }
-
- // Ensure that the newly showing part is enabled
- if (pane != null && pane.getControl() != null)
- pane.getControl().setEnabled(true);
-
- return part;
- }
-
- /**
- * Toggles the visibility of a fast view. If the view is active it
- * is deactivated. Otherwise, it is activated.
- */
- public void toggleFastView(IViewReference ref) {
- if (ref == activeFastView) {
- setActiveFastView(null);
- } else {
- setActiveFastView(ref);
- }
- }
-
- /**
- * Returns the old part reference.
- * Returns null if there was no previously active part.
- *
- * @return the old part reference or <code>null</code>
- */
- public IWorkbenchPartReference getOldPartRef() {
- return oldPartRef;
- }
-
- /**
- * Sets the old part reference.
- *
- * @param oldPartRef The old part reference to set, or <code>null</code>
- */
- public void setOldPartRef(IWorkbenchPartReference oldPartRef) {
- this.oldPartRef = oldPartRef;
- }
-
- //for dynamic UI
- protected void addActionSet(IActionSetDescriptor newDesc) {
- IContextService service = (IContextService)page.getWorkbenchWindow().getService(IContextService.class);
- try {
- service.deferUpdates(true);
- for (int i = 0; i < alwaysOnActionSets.size(); i++) {
- IActionSetDescriptor desc = (IActionSetDescriptor) alwaysOnActionSets
- .get(i);
- if (desc.getId().equals(newDesc.getId())) {
- removeAlwaysOn(desc);
- removeAlwaysOff(desc);
- break;
- }
- }
- addAlwaysOn(newDesc);
- } finally {
- service.deferUpdates(false);
- }
- }
-
- // for dynamic UI
- /* package */void removeActionSet(String id) {
- IContextService service = (IContextService)page.getWorkbenchWindow().getService(IContextService.class);
- try {
- service.deferUpdates(true);
- for (int i = 0; i < alwaysOnActionSets.size(); i++) {
- IActionSetDescriptor desc = (IActionSetDescriptor) alwaysOnActionSets
- .get(i);
- if (desc.getId().equals(id)) {
- removeAlwaysOn(desc);
- break;
- }
- }
-
- for (int i = 0; i < alwaysOffActionSets.size(); i++) {
- IActionSetDescriptor desc = (IActionSetDescriptor) alwaysOffActionSets
- .get(i);
- if (desc.getId().equals(id)) {
- removeAlwaysOff(desc);
- break;
- }
- }
- } finally {
- service.deferUpdates(false);
- }
- }
-
- void removeActionSet(IActionSetDescriptor toRemove) {
- removeAlwaysOn(toRemove);
- removeAlwaysOff(toRemove);
- }
-
- public void setFastViewState(IViewReference ref, int newState) {
- // If the current pane is null then the FV is not open
- if (fastViewManager != null) {
- String id = fastViewManager.getIdForRef(ref);
- if (id != null && id != FastViewBar.FASTVIEWBAR_ID) {
- if (newState == IStackPresentationSite.STATE_MINIMIZED)
- return; // No-op
-
- // So it's either RESTORED or MAXIMIZED so we have to restore
- // the stack
- fastViewManager.restoreToPresentation(id);
-
- // If it's MAXIMIZED we then have to MAXIMIZE the stack
- if (newState == IStackPresentationSite.STATE_MAXIMIZED) {
- // Recurse back to the page now that the stack is restored
- page.setState(ref, newState);
- }
-
- return;
- }
- }
-
- // Fast View is open, change its state
- if (fastViewPane.getCurrentPane() != null)
- fastViewPane.setState(newState);
- }
-
- public void setFastViewState(int newState) {
- fastViewPane.setState(newState);
- }
-
- public int getFastViewState() {
- return fastViewPane.getState();
- }
-
- /**
- * Returns whether the given view is closeable in this perspective.
- *
- * @since 3.0
- */
- public boolean isCloseable(IViewReference reference) {
- ViewLayoutRec rec = getViewLayoutRec(reference, false);
- if (rec != null) {
- return rec.isCloseable;
- }
- return true;
- }
-
- /**
- * Returns whether the given view is moveable in this perspective.
- *
- * @since 3.0
- */
- public boolean isMoveable(IViewReference reference) {
- ViewLayoutRec rec = getViewLayoutRec(reference, false);
- if (rec != null) {
- return rec.isMoveable;
- }
- return true;
- }
-
- /**
- * Writes a description of the layout to the given string buffer.
- * This is used for drag-drop test suites to determine if two layouts are the
- * same. Like a hash code, the description should compare as equal iff the
- * layouts are the same. However, it should be user-readable in order to
- * help debug failed tests. Although these are english readable strings,
- * they should not be translated or equality tests will fail.
- * <p>
- * This is only intended for use by test suites.
- * </p>
- *
- * @param buf
- */
- public void describeLayout(StringBuffer buf) {
- IViewReference[] fastViews = getFastViews();
-
- if (fastViews.length != 0) {
- buf.append("fastviews ("); //$NON-NLS-1$
- for (int idx = 0; idx < fastViews.length; idx++) {
- IViewReference ref = fastViews[idx];
-
- if (idx > 0) {
- buf.append(", "); //$NON-NLS-1$
- }
-
- buf.append(ref.getPartName());
- }
- buf.append("), "); //$NON-NLS-1$
- }
-
- getPresentation().describeLayout(buf);
- }
-
- /**
- * Sanity-checks the LayoutParts in this perspective. Throws an Assertation exception
- * if an object's internal state is invalid.
- */
- public void testInvariants() {
- getPresentation().getLayout().testInvariants();
- }
-
- public IActionSetDescriptor[] getAlwaysOnActionSets() {
- return (IActionSetDescriptor[]) alwaysOnActionSets.toArray(new IActionSetDescriptor[alwaysOnActionSets.size()]);
- }
-
- public IActionSetDescriptor[] getAlwaysOffActionSets() {
- return (IActionSetDescriptor[]) alwaysOffActionSets.toArray(new IActionSetDescriptor[alwaysOffActionSets.size()]);
- }
-
- /* package */ FastViewPane getFastViewPane() {
- return fastViewPane;
- }
-
-
- /**
- * Restores a part in the trim to the actual layout
- * @param part The part to restore
- */
- public void restoreTrimPart(LayoutPart part) {
- if (fastViewManager == null)
- return;
-
- // Remove any current fastview
- setActiveFastView(null);
-
- // Set the part's state to place it back in the layout
- if (part instanceof ViewStack) {
- ViewStack vs = (ViewStack) part;
- fastViewManager.restoreToPresentation(vs.getID());
- }
-
- if (part == editorArea) {
- setEditorAreaState(IStackPresentationSite.STATE_RESTORED);
- editorAreaRestoreOnUnzoom = false;
- }
- }
-
- /**
- * 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;
- }
-
- if (dy > 0) {
- return (dx > 0) ? SWT.LEFT : SWT.RIGHT;
- }
-
- return SWT.BOTTOM;
- }
-
- /**
- * Restore any parts that are showing in the trim as
- * a result of a 'zoom' operation
- */
- public void restoreZoomedParts() {
- if (fastViewManager == null)
- return;
-
- // Remove any current fastview
- setActiveFastView(null);
-
- // have the layout restore the parts
- fastViewManager.restoreZoomedViewStacks();
-
- if (editorAreaRestoreOnUnzoom) {
- restoreTrimPart(editorArea);
- }
- }
-
- /**
- * @return Returns the fastViewManager.
- */
- public FastViewManager getFastViewManager() {
- return fastViewManager;
- }
-
- /**
- * Sets the restore on unzoom state for the editor area
- * @param restore the new state
- */
- public void setEditorAreaRestoreOnUnzoom(boolean restore) {
- editorAreaRestoreOnUnzoom = restore;
- }
-
- /**
- * @return the restore on unzoom state
- */
- public boolean getEditorAreaRestoreOnUnzoom() {
- return editorAreaRestoreOnUnzoom;
- }
-
- /**
- * Used to restrict the use of the new min/max behavior to envoronments
- * in which it has a chance of working...
- *
- * @param activePerspective We pass this in as an arg so others won't have
- * to check it for 'null' (which is one of the failure cases)
- *
- */
- public static boolean useNewMinMax(Perspective activePerspective) {
- // We need to have an active perspective
- if (activePerspective == null)
- return false;
-
- // We need to have a trim manager (if we don't then we
- // don't create a FastViewManager because it'd be useless)
- if (activePerspective.getFastViewManager() == null)
- return false;
-
- // Make sure we don't NPE anyplace
- WorkbenchWindow wbw = (WorkbenchWindow) activePerspective.page.getWorkbenchWindow();
- if (wbw == null)
- return false;
-
- WorkbenchWindowConfigurer configurer = wbw.getWindowConfigurer();
- if (configurer == null)
- return false;
-
- AbstractPresentationFactory factory = configurer.getPresentationFactory();
- if (factory == null)
- return false;
-
- // Ok, we should be good to go, return the pref
- IPreferenceStore preferenceStore = PrefUtil.getAPIPreferenceStore();
- boolean useNewMinMax = preferenceStore.getBoolean(IWorkbenchPreferenceConstants.ENABLE_NEW_MIN_MAX);
- return useNewMinMax;
- }
-
- /** @return a Collection of IDs of items to be hidden from the menu bar */
- public Collection getHiddenMenuItems() {
- return hideMenuIDs;
- }
-
- /** @return a Collection of IDs of items to be hidden from the tool bar */
- public Collection getHiddenToolbarItems() {
- return hideToolBarIDs;
- }
-
- public void updateActionBars() {
- page.getActionBars().getMenuManager().updateAll(true);
- page.resetToolBarLayout();
- }
-
-}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/PerspectiveHelper.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/PerspectiveHelper.java
deleted file mode 100644
index 3c5d25e80b6..00000000000
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/PerspectiveHelper.java
+++ /dev/null
@@ -1,1524 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2009 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
- * Carlos Devoto carlos.devoto@compuware.com Bug 213645
- * Marco Maccaferri, maccasoft.com - patch for defect 222750
- *******************************************************************************/
-
-package org.eclipse.ui.internal;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Vector;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Cursor;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.IMemento;
-import org.eclipse.ui.IViewReference;
-import org.eclipse.ui.IWorkbenchPartReference;
-import org.eclipse.ui.IWorkbenchPreferenceConstants;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.internal.dnd.AbstractDropTarget;
-import org.eclipse.ui.internal.dnd.DragUtil;
-import org.eclipse.ui.internal.dnd.IDragOverListener;
-import org.eclipse.ui.internal.dnd.IDropTarget;
-import org.eclipse.ui.internal.misc.Policy;
-import org.eclipse.ui.internal.misc.StringMatcher;
-import org.eclipse.ui.presentations.IStackPresentationSite;
-
-/**
- * A perspective presentation is a collection of parts with a layout. Each part
- * is parented to a main window, so you can create more than one presentation
- * on a set of parts and change the layout just by activating / deactivating a
- * presentation.
- *
- * In addition, the user can change the position of any part by mouse
- * manipulation (drag & drop). If a part is removed, we leave a placeholder
- * behind to indicate where it goes should the part be added back.
- */
-public class PerspectiveHelper {
- private WorkbenchPage page;
-
- protected Perspective perspective;
-
- protected Composite parentWidget;
-
- private ViewSashContainer mainLayout;
-
- private PartStack maximizedStack;
-
- /**
- * If there is a ViewStack maximized on shutdown the id is
- * cached and restored into this field on 'restoreState'.
- * This is then used to bash the ViewStack's presentation state
- * into the correct value on activation (the startup life-cycle
- * is such that we have to use this 'latch' because the window
- * state isn't valid until the activate happens.
- */
- private String maximizedStackId;
-
- private ArrayList detachedWindowList = new ArrayList(1);
-
- private ArrayList detachedPlaceHolderList = new ArrayList(1);
-
- /**
- * Maps a stack's id to its current bounds
- * this is used to capture the current bounds of all
- * stacks -before- starting a maximize (since the
- * iterative 'minimize' calls cause the intial stack's
- * bounds to change.
- */
- private Map boundsMap = new HashMap();
-
- private boolean detachable = false;
-
- protected boolean active = false;
-
- // key is the LayoutPart object, value is the PartDragDrop object
- //private IPartDropListener partDropListener;
-
- private static final int MIN_DETACH_WIDTH = 150;
-
- private static final int MIN_DETACH_HEIGHT = 250;
-
- protected ActualDropTarget dropTarget;
-
- private IDragOverListener dragTarget = new IDragOverListener() {
-
- public IDropTarget drag(Control currentControl, Object draggedObject,
- Point position, final Rectangle dragRectangle) {
-
- if (!(draggedObject instanceof ViewPane || draggedObject instanceof ViewStack)) {
- return null;
- }
- final LayoutPart part = (LayoutPart) draggedObject;
-
- // Views that haven't been shown yet have no 'control' which causes
- // 'getWorkbenchWindow' to return 'null' so check explicitly
- if (part instanceof ViewPane) {
- if (((ViewPane)part).getPage() != page)
- return null;
- }
- else if (part.getWorkbenchWindow() != page.getWorkbenchWindow()) {
- return null;
- }
-
- if (dropTarget == null) {
- dropTarget = new ActualDropTarget(part, dragRectangle);
- } else {
- dropTarget.setTarget(part, dragRectangle);
- }
-
- return dropTarget;
- }
-
- };
-
- private final class ActualDropTarget extends AbstractDropTarget {
- private LayoutPart part;
-
- private Rectangle dragRectangle;
-
- private ActualDropTarget(LayoutPart part, Rectangle dragRectangle) {
- super();
- setTarget(part, dragRectangle);
- }
-
- /**
- * @param part
- * @param dragRectangle
- * @since 3.1
- */
- private void setTarget(LayoutPart part, Rectangle dragRectangle) {
- this.part = part;
- this.dragRectangle = dragRectangle;
- }
-
- public void drop() {
-
- Shell shell = part.getShell();
- if (shell.getData() instanceof DetachedWindow) {
- // only one tab folder in a detach window, so do window
- // move
- if (part instanceof ViewStack) {
- shell.setLocation(dragRectangle.x,
- dragRectangle.y);
- return;
- }
- // if only one view in tab folder then do a window move
- ILayoutContainer container = part.getContainer();
- if (container instanceof ViewStack) {
- if (((ViewStack) container).getItemCount() == 1) {
- shell.setLocation(dragRectangle.x,
- dragRectangle.y);
- return;
- }
- }
- }
-
- // If layout is modified always zoom out.
- if (isZoomed()) {
- zoomOut();
- }
- // do a normal part detach
- detach(part, dragRectangle.x, dragRectangle.y);
- }
-
- public Cursor getCursor() {
- return DragCursors.getCursor(DragCursors.OFFSCREEN);
- }
- }
-
- private class MatchingPart implements Comparable {
- LayoutPart part;
-
- boolean hasWildcard;
-
- int len;
-
- MatchingPart(String pid, String sid, LayoutPart part) {
- this.part = part;
- this.len = (pid == null ? 0 : pid.length())
- + (sid == null ? 0 : sid.length());
- this.hasWildcard = (pid != null && pid
- .indexOf(PartPlaceholder.WILD_CARD) != -1)
- || (sid != null && sid.indexOf(PartPlaceholder.WILD_CARD) != -1);
- }
-
- public int compareTo(Object a) {
- // specific ids always outweigh ids with wildcards
- MatchingPart ma = (MatchingPart) a;
- if (this.hasWildcard && !ma.hasWildcard) {
- return -1;
- }
- if (!this.hasWildcard && ma.hasWildcard) {
- return 1;
- }
- // if both are specific or both have wildcards, simply compare based on length
- return ma.len - this.len;
- }
- }
-
-
- /**
- * Constructs a new object.
- */
- public PerspectiveHelper(WorkbenchPage workbenchPage,
- ViewSashContainer mainLayout, Perspective perspective) {
- this.page = workbenchPage;
- this.mainLayout = mainLayout;
- this.perspective = perspective;
-
- // Views can be detached if the feature is enabled (true by default,
- // use the plug-in customization file to disable), and if the platform
- // supports detaching.
-
- final IPreferenceStore store = PlatformUI.getPreferenceStore();
- this.detachable = store.getBoolean(IWorkbenchPreferenceConstants.ENABLE_DETACHED_VIEWS);
-
- if (this.detachable) {
- // Check if some arbitrary Composite supports reparenting. If it
- // doesn't, views cannot be detached.
-
- Composite client = workbenchPage.getClientComposite();
- if (client == null) {
- // The workbench page is not initialized. I don't think this can happen,
- // but if it does, silently set detachable to false.
- this.detachable = false;
- } else {
- Composite testChild = new Composite(client, SWT.NONE);
- this.detachable = testChild.isReparentable();
- testChild.dispose();
- }
- }
- }
-
- /**
- * Show the presentation.
- */
- public void activate(Composite parent) {
-
- if (active) {
- return;
- }
-
- parentWidget = parent;
-
- // Activate main layout
- // make sure all the views have been properly parented
- Vector children = new Vector();
- collectViewPanes(children, mainLayout.getChildren());
- Enumeration itr = children.elements();
- while (itr.hasMoreElements()) {
- LayoutPart part = (LayoutPart) itr.nextElement();
- part.reparent(parent);
- }
- mainLayout.createControl(parent);
- mainLayout.setActive(true);
-
- // Open the detached windows.
- for (int i = 0, length = detachedWindowList.size(); i < length; i++) {
- DetachedWindow dwindow = (DetachedWindow) detachedWindowList.get(i);
- dwindow.open();
- }
-
- enableAllDrag();
-
- // Ensure that the maximized stack's presentation state is correct
- if (maximizedStackId != null) {
- LayoutPart part = findPart(maximizedStackId);
- if (part instanceof PartStack) {
- maximizedStack = (PartStack) part;
- maximizedStackId = null;
- }
- }
-
- // NOTE: we only handle ViewStacks here; Editor Stacks are handled by the
- // perspective
- if (maximizedStack instanceof ViewStack) {
- maximizedStack.setPresentationState(IStackPresentationSite.STATE_MAXIMIZED);
- }
-
- active = true;
- }
-
- private String tmpViewId = null;
- private Exception tmpStackTrace = null;
-
- /**
- * Adds a part to the presentation. If a placeholder exists for the part
- * then swap the part in. Otherwise, add the part in the bottom right
- * corner of the presentation.
- */
- public void addPart(LayoutPart part) {
-
- // Look for a placeholder.
- PartPlaceholder placeholder = null;
- LayoutPart testPart = null;
- String primaryId = part.getID();
- String secondaryId = null;
-
- IViewReference ref = null;
- if (part instanceof ViewPane) {
- ViewPane pane = (ViewPane) part;
- ref = (IViewReference) pane.getPartReference();
- secondaryId = ref.getSecondaryId();
- }
- if (secondaryId != null) {
- testPart = findPart(primaryId, secondaryId);
- } else {
- testPart = findPart(primaryId);
- }
-
- // validate the testPart
- if (testPart != null && testPart instanceof PartPlaceholder) {
- placeholder = (PartPlaceholder) testPart;
- }
-
- // If there is no placeholder do a simple add. Otherwise, replace the
- // placeholder if its not a pattern matching placholder
- if (placeholder == null) {
- part.reparent(mainLayout.getParent());
- LayoutPart relative = mainLayout.findBottomRight();
- if (relative != null && relative instanceof ILayoutContainer) {
- ILayoutContainer stack = (ILayoutContainer)relative;
- if (stack.allowsAdd(part)) {
- mainLayout.stack(part, stack);
- } else {
- mainLayout.add(part);
- }
- } else {
- mainLayout.add(part);
- }
- } else {
- ILayoutContainer container = placeholder.getContainer();
- if (container != null) {
- if (container instanceof DetachedPlaceHolder) {
- //Create a detached window add the part on it.
- DetachedPlaceHolder holder = (DetachedPlaceHolder) container;
- detachedPlaceHolderList.remove(holder);
- container.remove(testPart);
- DetachedWindow window = new DetachedWindow(page);
- detachedWindowList.add(window);
- window.create();
- part.createControl(window.getShell());
- // Open window.
- window.getShell().setBounds(holder.getBounds());
- window.open();
- // add part to detached window.
- ViewPane pane = (ViewPane) part;
- window.add(pane);
- LayoutPart otherChildren[] = holder.getChildren();
- for (int i = 0; i < otherChildren.length; i++) {
- part.getContainer().add(otherChildren[i]);
- }
- } else {
- // show parent if necessary
- if (container instanceof ContainerPlaceholder) {
- ContainerPlaceholder containerPlaceholder = (ContainerPlaceholder) container;
- ILayoutContainer parentContainer = containerPlaceholder
- .getContainer();
- if (parentContainer == null) {
- if (Policy.DEBUG_PERSPECTIVES) {
- WorkbenchPlugin.log(
- "Previous ContainerPlaceholder for " + tmpViewId, //$NON-NLS-1$
- tmpStackTrace);
- tmpViewId = null;
- tmpStackTrace = new Exception();
- tmpStackTrace.fillInStackTrace();
- WorkbenchPlugin.log(
- "Current ContainerPlaceholder with null parent for " //$NON-NLS-1$
- + primaryId + ":" + secondaryId, tmpStackTrace); //$NON-NLS-1$
- tmpStackTrace = null;
- }
- return;
- }
- if (Policy.DEBUG_PERSPECTIVES) {
- tmpViewId = primaryId + ":" + secondaryId; //$NON-NLS-1$
- tmpStackTrace = new Exception();
- tmpStackTrace.fillInStackTrace();
- }
- container = (ILayoutContainer) containerPlaceholder
- .getRealContainer();
- if (container instanceof LayoutPart) {
- parentContainer.replace(containerPlaceholder,
- (LayoutPart) container);
- }
- containerPlaceholder.setRealContainer(null);
- }
-
- // reparent part.
- if (!(container instanceof ViewStack)) {
- // We don't need to reparent children of PartTabFolders since they will automatically
- // reparent their children when they become visible. This if statement used to be
- // part of an else branch. Investigate if it is still necessary.
- part.reparent(mainLayout.getParent());
- }
-
- // see if we should replace the placeholder
- if (placeholder.hasWildCard()) {
- if (container instanceof PartSashContainer) {
- ((PartSashContainer) container)
- .addChildForPlaceholder(part, placeholder);
- } else {
- container.add(part);
- }
- } else {
- container.replace(placeholder, part);
- }
- }
- }
- }
- }
-
- /**
- * Attaches a part that was previously detached to the mainLayout.
- *
- * @param ref
- */
- public void attachPart(IViewReference ref) {
- ViewPane pane = (ViewPane)((WorkbenchPartReference)ref).getPane();
-
- // Restore any maximized part before re-attaching.
- // Note that 'getMaximizedStack != null' implies 'useNewMinMax'
- if (getMaximizedStack() != null) {
- getMaximizedStack().setState(IStackPresentationSite.STATE_RESTORED);
- }
-
- derefPart(pane);
- addPart(pane);
- bringPartToTop(pane);
- pane.setFocus();
- }
-
- /**
- * Return whether detachable parts can be supported.
- */
- public boolean canDetach() {
- return detachable;
- }
-
- /**
- * Bring a part forward so it is visible.
- *
- * @return true if the part was brought to top, false if not.
- */
- public boolean bringPartToTop(LayoutPart part) {
- ILayoutContainer container = part.getContainer();
- if (container != null && container instanceof PartStack) {
- PartStack folder = (PartStack) container;
- if (folder.getSelection() != part) {
- folder.setSelection(part);
- return true;
- }
- }
- return false;
- }
-
- /**
- * Returns true if the given part is visible.
- * A part is visible if it's top-level (not in a tab folder) or if it is the top one
- * in a tab folder.
- */
- public boolean isPartVisible(IWorkbenchPartReference partRef) {
- LayoutPart foundPart;
- if (partRef instanceof IViewReference) {
- foundPart = findPart(partRef.getId(), ((IViewReference) partRef).getSecondaryId());
- } else {
- foundPart = findPart(partRef.getId());
- }
- if (foundPart == null) {
- return false;
- }
- if (foundPart instanceof PartPlaceholder) {
- return false;
- }
-
- ILayoutContainer container = foundPart.getContainer();
-
- if (container instanceof ContainerPlaceholder) {
- return false;
- }
-
- if (container instanceof ViewStack) {
- ViewStack folder = (ViewStack) container;
- PartPane visiblePart = folder.getSelection();
- if (visiblePart == null) {
- return false;
- }
- return partRef.equals(visiblePart.getPartReference());
- }
- return true;
- }
-
- /**
- * Returns true is not in a tab folder or if it is the top one in a tab
- * folder.
- */
- public boolean willPartBeVisible(String partId) {
- return willPartBeVisible(partId, null);
- }
-
- public boolean willPartBeVisible(String partId, String secondaryId) {
- LayoutPart part = findPart(partId, secondaryId);
- if (part == null) {
- return false;
- }
- ILayoutContainer container = part.getContainer();
- if (container != null && container instanceof ContainerPlaceholder) {
- container = (ILayoutContainer) ((ContainerPlaceholder) container)
- .getRealContainer();
- }
-
- if (container != null && container instanceof ViewStack) {
- ViewStack folder = (ViewStack) container;
- if (folder.getSelection() == null) {
- return false;
- }
- return part.getCompoundId().equals(
- folder.getSelection().getCompoundId());
- }
- return true;
- }
-
- /**
- * Answer a list of the PartPlaceholder objects.
- */
- private PartPlaceholder[] collectPlaceholders() {
- // Scan the main window.
- PartPlaceholder[] results = collectPlaceholders(mainLayout
- .getChildren());
-
- // Scan each detached window.
- if (detachable) {
- for (int i = 0, length = detachedWindowList.size(); i < length; i++) {
- DetachedWindow win = (DetachedWindow) detachedWindowList.get(i);
- PartPlaceholder[] moreResults = collectPlaceholders(win
- .getChildren());
- if (moreResults.length > 0) {
- int newLength = results.length + moreResults.length;
- PartPlaceholder[] newResults = new PartPlaceholder[newLength];
- System.arraycopy(results, 0, newResults, 0, results.length);
- System.arraycopy(moreResults, 0, newResults,
- results.length, moreResults.length);
- results = newResults;
- }
- }
- }
- return results;
- }
-
- /**
- * Answer a list of the PartPlaceholder objects.
- */
- private PartPlaceholder[] collectPlaceholders(LayoutPart[] parts) {
- PartPlaceholder[] result = new PartPlaceholder[0];
-
- for (int i = 0, length = parts.length; i < length; i++) {
- LayoutPart part = parts[i];
- if (part instanceof ILayoutContainer) {
- // iterate through sub containers to find sub-parts
- PartPlaceholder[] newParts = collectPlaceholders(((ILayoutContainer) part)
- .getChildren());
- PartPlaceholder[] newResult = new PartPlaceholder[result.length
- + newParts.length];
- System.arraycopy(result, 0, newResult, 0, result.length);
- System.arraycopy(newParts, 0, newResult, result.length,
- newParts.length);
- result = newResult;
- } else if (part instanceof PartPlaceholder) {
- PartPlaceholder[] newResult = new PartPlaceholder[result.length + 1];
- System.arraycopy(result, 0, newResult, 0, result.length);
- newResult[result.length] = (PartPlaceholder) part;
- result = newResult;
- }
- }
-
- return result;
- }
-
- /**
- * Answer a list of the view panes.
- */
- public void collectViewPanes(List result) {
- // Scan the main window.
- collectViewPanes(result, mainLayout.getChildren());
-
- // Scan each detached window.
- if (detachable) {
- for (int i = 0, length = detachedWindowList.size(); i < length; i++) {
- DetachedWindow win = (DetachedWindow) detachedWindowList.get(i);
- collectViewPanes(result, win.getChildren());
- }
- }
- }
-
- /**
- * Answer a list of the view panes.
- */
- private void collectViewPanes(List result, LayoutPart[] parts) {
- for (int i = 0, length = parts.length; i < length; i++) {
- LayoutPart part = parts[i];
- if (part instanceof ViewPane) {
- result.add(part);
- } else if (part instanceof ILayoutContainer) {
- collectViewPanes(result, ((ILayoutContainer) part)
- .getChildren());
- }
- }
- }
-
- /**
- * Hide the presentation.
- */
- public void deactivate() {
- if (!active) {
- return;
- }
-
- disableAllDrag();
-
- // Reparent all views to the main window
- Composite parent = mainLayout.getParent();
- Vector children = new Vector();
- collectViewPanes(children, mainLayout.getChildren());
-
- for (int i = 0, length = detachedWindowList.size(); i < length; i++) {
- DetachedWindow window = (DetachedWindow) detachedWindowList.get(i);
- collectViewPanes(children, window.getChildren());
- }
-
- // *** Do we even need to do this if detached windows not supported?
- Enumeration itr = children.elements();
- while (itr.hasMoreElements()) {
- LayoutPart part = (LayoutPart) itr.nextElement();
- part.reparent(parent);
- }
-
- // Dispose main layout.
-
- mainLayout.setActive(false);
-
- // Dispose the detached windows
- for (int i = 0, length = detachedWindowList.size(); i < length; i++) {
- DetachedWindow window = (DetachedWindow) detachedWindowList.get(i);
- window.close();
- }
-
- active = false;
- }
-
- public void dispose() {
- mainLayout.dispose();
- mainLayout.disposeSashes();
- }
-
- /**
- * Writes a description of the layout to the given string buffer.
- * This is used for drag-drop test suites to determine if two layouts are the
- * same. Like a hash code, the description should compare as equal iff the
- * layouts are the same. However, it should be user-readable in order to
- * help debug failed tests. Although these are english readable strings,
- * they should not be translated or equality tests will fail.
- * <p>
- * This is only intended for use by test suites.
- * </p>
- *
- * @param buf
- */
- public void describeLayout(StringBuffer buf) {
-
- if (detachable) {
- if(detachedWindowList.size() != 0){
- buf.append("detachedWindows ("); //$NON-NLS-1$
-
- for (int i = 0, length = detachedWindowList.size(); i < length; i++) {
- DetachedWindow window = (DetachedWindow) detachedWindowList.get(i);
- LayoutPart[] children = window.getChildren();
- if(children.length != 0){
- buf.append("dWindow ("); //$NON-NLS-1$
- for(int j = 0; j < children.length; j++){
- buf.append(((ViewPane)children[j]).getViewReference().getPartName());
- if(j < (children.length - 1)) {
- buf.append(", "); //$NON-NLS-1$
- }
- }
- buf.append(")"); //$NON-NLS-1$
- }
-
- }
- buf.append("), "); //$NON-NLS-1$
- }
- }
-
- getLayout().describeLayout(buf);
- }
-
- /**
- * Deref a given part. Deconstruct its container as required. Do not remove
- * drag listeners.
- */
- /* package */void derefPart(LayoutPart part) {
- if (part instanceof ViewPane) {
- IViewReference ref = ((ViewPane) part).getViewReference();
- if (perspective.isFastView(ref)) {
- // Special check: if it's a fast view then it's actual ViewStack
- // may only contain placeholders and the stack is represented in
- // the presentation by a container placeholder...make sure the
- // PartPlaceHolder for 'ref' is removed from the ViewStack
- String id = perspective.getFastViewManager().getIdForRef(ref);
- LayoutPart parentPart = findPart(id, null);
- if (parentPart instanceof ContainerPlaceholder) {
- ViewStack vs = (ViewStack) ((ContainerPlaceholder)parentPart).getRealContainer();
- LayoutPart[] kids = vs.getChildren();
- for (int i = 0; i < kids.length; i++) {
- if (kids[i] instanceof PartPlaceholder) {
- if (ref.getId().equals(kids[i].id))
- vs.remove(kids[i]);
- }
- }
- }
- perspective.getFastViewManager().removeViewReference(ref, true, true);
- }
- }
-
- // Get vital part stats before reparenting.
- ILayoutContainer oldContainer = part.getContainer();
- boolean wasDocked = part.isDocked();
- Shell oldShell = part.getShell();
-
- // Reparent the part back to the main window
- part.reparent(mainLayout.getParent());
-
- // Update container.
- if (oldContainer == null) {
- return;
- }
-
- oldContainer.remove(part);
-
- LayoutPart[] children = oldContainer.getChildren();
- if (wasDocked) {
- boolean hasChildren = (children != null) && (children.length > 0);
- if (hasChildren) {
- // make sure one is at least visible
- int childVisible = 0;
- for (int i = 0; i < children.length; i++) {
- if (children[i].getControl() != null) {
- childVisible++;
- }
- }
-
- // none visible, then reprarent and remove container
- if (oldContainer instanceof ViewStack) {
- ViewStack folder = (ViewStack) oldContainer;
-
- // Is the part in the trim?
- boolean inTrim = false;
- // Safety check...there may be no FastViewManager
- if (perspective.getFastViewManager() != null)
- inTrim = perspective.getFastViewManager().getFastViews(folder.getID()).size() > 0;
-
- if (childVisible == 0 && !inTrim) {
- ILayoutContainer parentContainer = folder.getContainer();
- hasChildren = folder.getChildren().length > 0;
-
- // We maintain the stack as a place-holder if it has children
- // (which at this point would represent view place-holders)
- if (hasChildren) {
- folder.dispose();
-
- // replace the real container with a ContainerPlaceholder
- ContainerPlaceholder placeholder = new ContainerPlaceholder(folder.getID());
- placeholder.setRealContainer(folder);
- parentContainer.replace(folder, placeholder);
- }
- } else if (childVisible == 1) {
- LayoutTree layout = mainLayout.getLayoutTree();
- layout = layout.find(folder);
- layout.setBounds(layout.getBounds());
- }
- }
- }
-
- if (!hasChildren && !(oldContainer instanceof ViewStack && ((ViewStack)oldContainer).getDurable())) {
- // There are no more children in this container, so get rid of
- // it (but only if the container is not a durable ViewStack)
- if (oldContainer instanceof LayoutPart) {
- LayoutPart parent = (LayoutPart) oldContainer;
- ILayoutContainer parentContainer = parent.getContainer();
- if (parentContainer != null) {
- parentContainer.remove(parent);
- parent.dispose();
- }
- }
- }
- } else if (!wasDocked) {
- if (children == null || children.length == 0) {
- // There are no more children in this container, so get rid of
- // it
- // Turn on redraw again just in case it was off.
- //oldShell.setRedraw(true);
- DetachedWindow w = (DetachedWindow)oldShell.getData();
- oldShell.close();
- detachedWindowList.remove(w);
- } else {
- // There are children. If none are visible hide detached
- // window.
- boolean allInvisible = true;
- for (int i = 0, length = children.length; i < length; i++) {
- if (!(children[i] instanceof PartPlaceholder)) {
- allInvisible = false;
- break;
- }
- }
- if (allInvisible) {
- DetachedPlaceHolder placeholder = new DetachedPlaceHolder(
- "", //$NON-NLS-1$
- oldShell.getBounds());
- for (int i = 0, length = children.length; i < length; i++) {
- oldContainer.remove(children[i]);
- children[i].setContainer(placeholder);
- placeholder.add(children[i]);
- }
- detachedPlaceHolderList.add(placeholder);
- DetachedWindow w = (DetachedWindow)oldShell.getData();
- oldShell.close();
- detachedWindowList.remove(w);
- }
- }
- }
-
- }
-
- /**
- * Create a detached window containing a part.
- */
- private void detach(LayoutPart source, int x, int y) {
-
- // Detaching is disabled on some platforms ..
- if (!detachable) {
- return;
- }
-
- LayoutPart part = source.getPart();
- // Calculate detached window size.
- Point size = part.getSize();
- if (size.x == 0 || size.y == 0) {
- ILayoutContainer container = part.getContainer();
- if (container instanceof LayoutPart) {
- size = ((LayoutPart) container).getSize();
- }
- }
- int width = Math.max(size.x, MIN_DETACH_WIDTH);
- int height = Math.max(size.y, MIN_DETACH_HEIGHT);
-
- // Create detached window.
- DetachedWindow window = new DetachedWindow(page);
- detachedWindowList.add(window);
-
- // Open window.
- window.create();
- window.getShell().setBounds(x, y, width, height);
- window.open();
-
- if (part instanceof ViewStack) {
- window.getShell().setRedraw(false);
- parentWidget.setRedraw(false);
- LayoutPart visiblePart = ((ViewStack) part).getSelection();
- LayoutPart children[] = ((ViewStack) part).getChildren();
- for (int i = 0; i < children.length; i++) {
- if (children[i] instanceof ViewPane) {
- // remove the part from its current container
- derefPart(children[i]);
- // add part to detached window.
- ViewPane pane = (ViewPane) children[i];
- window.add(pane);
- }
- }
- if (visiblePart != null) {
- bringPartToTop(visiblePart);
- visiblePart.setFocus();
- }
- window.getShell().setRedraw(true);
- parentWidget.setRedraw(true);
- } else {
- // remove the part from its current container
- derefPart(part);
- // add part to detached window.
- ViewPane pane = (ViewPane) part;
- window.add(pane);
- part.setFocus();
- }
-
- }
-
- /**
- * Detached a part from the mainLayout. Presently this does not use placeholders
- * since the current implementation is not robust enough to remember a view's position
- * in more than one root container. For now the view is simply derefed and will dock
- * in the default position when attachPart is called.
- *
- * By default parts detached this way are set to float on top of the workbench
- * without docking. It is assumed that people that want to drag a part back onto
- * the WorkbenchWindow will detach it via drag and drop.
- *
- * @param ref
- */
- public void detachPart(IViewReference ref) {
- ViewPane pane = (ViewPane)((WorkbenchPartReference)ref).getPane();
- if (canDetach() && pane != null) {
- if (getMaximizedStack() != null)
- getMaximizedStack().setState(IStackPresentationSite.STATE_RESTORED);
-
- Rectangle bounds = pane.getParentBounds();
- detach(pane, bounds.x ,bounds.y);
- }
- }
-
- /**
- * Create a detached window containing a part.
- */
- public void addDetachedPart(LayoutPart part) {
- // Calculate detached window size.
- Rectangle bounds = parentWidget.getShell().getBounds();
- bounds.x = bounds.x + (bounds.width - 300) / 2;
- bounds.y = bounds.y + (bounds.height - 300) / 2;
-
- addDetachedPart(part, bounds);
- }
-
- public void addDetachedPart(LayoutPart part, Rectangle bounds) {
- // Detaching is disabled on some platforms ..
- if (!detachable) {
- addPart(part);
- return;
- }
-
- // Create detached window.
- DetachedWindow window = new DetachedWindow(page);
- detachedWindowList.add(window);
- window.create();
-
- // add part to detached window.
- part.createControl(window.getShell());
- ViewPane pane = (ViewPane) part;
- window.add(pane);
-
- // Open window.
- window.getShell().setBounds(bounds.x, bounds.y, bounds.width, bounds.height);
- window.open();
-
- part.setFocus();
-
- }
-
- /**
- * disableDragging.
- */
- private void disableAllDrag() {
- DragUtil.removeDragTarget(null, dragTarget);
- }
-
- /**
- * enableDragging.
- */
- private void enableAllDrag() {
- DragUtil.addDragTarget(null, dragTarget);
- }
-
- /**
- * Find the first part with a given ID in the presentation.
- * Wild cards now supported.
- */
- private LayoutPart findPart(String id) {
- return findPart(id, null);
- }
-
- /**
- * Find the first part that matches the specified
- * primary and secondary id pair. Wild cards
- * are supported.
- */
- public LayoutPart findPart(String primaryId, String secondaryId) {
- // check main window.
- ArrayList matchingParts = new ArrayList();
- LayoutPart part = (secondaryId != null) ? findPart(primaryId,
- secondaryId, mainLayout.getChildren(), matchingParts)
- : findPart(primaryId, mainLayout.getChildren(), matchingParts);
- if (part != null) {
- return part;
- }
-
- // check each detached windows.
- for (int i = 0, length = detachedWindowList.size(); i < length; i++) {
- DetachedWindow window = (DetachedWindow) detachedWindowList.get(i);
- part = (secondaryId != null) ? findPart(primaryId, secondaryId,
- window.getChildren(), matchingParts) : findPart(primaryId,
- window.getChildren(), matchingParts);
- if (part != null) {
- return part;
- }
- }
- for (int i = 0; i < detachedPlaceHolderList.size(); i++) {
- DetachedPlaceHolder holder = (DetachedPlaceHolder) detachedPlaceHolderList
- .get(i);
- part = (secondaryId != null) ? findPart(primaryId, secondaryId,
- holder.getChildren(), matchingParts) : findPart(primaryId,
- holder.getChildren(), matchingParts);
- if (part != null) {
- return part;
- }
- }
-
- // sort the matching parts
- if (matchingParts.size() > 0) {
- Collections.sort(matchingParts);
- MatchingPart mostSignificantPart = (MatchingPart) matchingParts
- .get(0);
- if (mostSignificantPart != null) {
- return mostSignificantPart.part;
- }
- }
-
- // Not found.
- return null;
- }
-
- /**
- * Find the first part with a given ID in the presentation.
- */
- private LayoutPart findPart(String id, LayoutPart[] parts,
- ArrayList matchingParts) {
- for (int i = 0, length = parts.length; i < length; i++) {
- LayoutPart part = parts[i];
- // check for part equality, parts with secondary ids fail
- if (part.getID().equals(id)) {
- if (part instanceof ViewPane) {
- ViewPane pane = (ViewPane) part;
- IViewReference ref = (IViewReference) pane
- .getPartReference();
- if (ref.getSecondaryId() != null) {
- continue;
- }
- }
- return part;
- }
- // check pattern matching placeholders
- else if (part instanceof PartPlaceholder
- && ((PartPlaceholder) part).hasWildCard()) {
- StringMatcher sm = new StringMatcher(part.getID(), true, false);
- if (sm.match(id)) {
- matchingParts
- .add(new MatchingPart(part.getID(), null, part));
- }
- } else if (part instanceof EditorSashContainer) {
- // Skip.
- } else if (part instanceof ILayoutContainer) {
- part = findPart(id, ((ILayoutContainer) part).getChildren(),
- matchingParts);
- if (part != null) {
- return part;
- }
- }
- }
- return null;
- }
-
- /**
- * Find the first part that matches the specified
- * primary and secondary id pair. Wild cards
- * are supported.
- */
- private LayoutPart findPart(String primaryId, String secondaryId,
- LayoutPart[] parts, ArrayList matchingParts) {
- for (int i = 0, length = parts.length; i < length; i++) {
- LayoutPart part = parts[i];
- // check containers first
- if (part instanceof ILayoutContainer) {
- LayoutPart testPart = findPart(primaryId, secondaryId,
- ((ILayoutContainer) part).getChildren(), matchingParts);
- if (testPart != null) {
- return testPart;
- }
- }
- // check for view part equality
- if (part instanceof ViewPane) {
- ViewPane pane = (ViewPane) part;
- IViewReference ref = (IViewReference) pane.getPartReference();
- if (ref.getId().equals(primaryId)
- && ref.getSecondaryId() != null
- && ref.getSecondaryId().equals(secondaryId)) {
- return part;
- }
- }
- // check placeholders
- else if ((parts[i] instanceof PartPlaceholder)) {
- String id = part.getID();
-
- // optimization: don't bother parsing id if it has no separator -- it can't match
- String phSecondaryId = ViewFactory.extractSecondaryId(id);
- if (phSecondaryId == null) {
- // but still need to check for wildcard case
- if (id.equals(PartPlaceholder.WILD_CARD)) {
- matchingParts.add(new MatchingPart(id, null, part));
- }
- continue;
- }
-
- String phPrimaryId = ViewFactory.extractPrimaryId(id);
- // perfect matching pair
- if (phPrimaryId.equals(primaryId)
- && phSecondaryId.equals(secondaryId)) {
- return part;
- }
- // check for partial matching pair
- StringMatcher sm = new StringMatcher(phPrimaryId, true, false);
- if (sm.match(primaryId)) {
- sm = new StringMatcher(phSecondaryId, true, false);
- if (sm.match(secondaryId)) {
- matchingParts.add(new MatchingPart(phPrimaryId,
- phSecondaryId, part));
- }
- }
- } else if (part instanceof EditorSashContainer) {
- // Skip.
- }
- }
- return null;
- }
-
- /**
- * Returns true if a placeholder exists for a given ID.
- */
- public boolean hasPlaceholder(String id) {
- return hasPlaceholder(id, null);
- }
-
- /**
- * Returns true if a placeholder exists for a given ID.
- * @since 3.0
- */
- public boolean hasPlaceholder(String primaryId, String secondaryId) {
- LayoutPart testPart;
- if (secondaryId == null) {
- testPart = findPart(primaryId);
- } else {
- testPart = findPart(primaryId, secondaryId);
- }
- return (testPart != null && testPart instanceof PartPlaceholder);
- }
-
- /**
- * Returns the layout container.
- */
- public ViewSashContainer getLayout() {
- return mainLayout;
- }
-
- /**
- * Gets the active state.
- */
- public boolean isActive() {
- return active;
- }
-
- /**
- * Returns whether the presentation is zoomed.
- *
- * <strong>NOTE:</strong> As of 3.3 this method should always return 'false'
- * when using the new min/max behavior. It is only used for
- * legacy 'zoom' handling.
- */
- public boolean isZoomed() {
- return mainLayout.getZoomedPart() != null;
- }
-
- /**
- * @return The currently maxmized stack (if any)
- */
- public PartStack getMaximizedStack() {
- return maximizedStack;
- }
-
- /**
- * Sets the currently maximized stack. Used for query
- * and 'unZoom' purposes in the 3.3 presentation.
- *
- * @param stack The newly maximized stack
- */
- public void setMaximizedStack(PartStack stack) {
- if (stack == maximizedStack)
- return;
-
- maximizedStack = stack;
- }
-
- /**
- * Returns the ratio that should be used when docking the given source
- * part onto the given target
- *
- * @param source newly added part
- * @param target existing part being dragged over
- * @return the final size of the source part (wrt the current size of target)
- * after it is docked
- */
- public static float getDockingRatio(LayoutPart source, LayoutPart target) {
- if ((source instanceof ViewPane || source instanceof ViewStack)
- && target instanceof EditorSashContainer) {
- return 0.25f;
- }
- return 0.5f;
- }
-
- /**
- * Returns whether changes to a part will affect zoom. There are a few
- * conditions for this .. - we are zoomed. - the part is contained in the
- * main window. - the part is not the zoom part - the part is not a fast
- * view - the part and the zoom part are not in the same editor workbook
- * - the part and the zoom part are not in the same view stack.
- */
- public boolean partChangeAffectsZoom(LayoutPart pane) {
- return pane.isObscuredByZoom();
- }
-
- /**
- * Remove all references to a part.
- */
- public void removePart(LayoutPart part) {
-
- // Reparent the part back to the main window
- Composite parent = mainLayout.getParent();
- part.reparent(parent);
-
- // Replace part with a placeholder
- ILayoutContainer container = part.getContainer();
- if (container != null) {
- String placeHolderId = part.getPlaceHolderId();
- container.replace(part, new PartPlaceholder(placeHolderId));
-
- // If the parent is root we're done. Do not try to replace
- // it with placeholder.
- if (container == mainLayout) {
- return;
- }
-
- // If the parent is empty replace it with a placeholder.
- LayoutPart[] children = container.getChildren();
- if (children != null) {
- boolean allInvisible = true;
- if (container instanceof ViewStack && !((ViewStack) container).isMinimized && ((ViewStack) container).getDurable()) {
- allInvisible = false;
- } else {
- for (int i = 0, length = children.length; i < length; i++) {
- if (!(children[i] instanceof PartPlaceholder)) {
- allInvisible = false;
- break;
- }
- }
- }
- if (allInvisible && (container instanceof LayoutPart)) {
- // what type of window are we in?
- LayoutPart cPart = (LayoutPart) container;
- //Window oldWindow = cPart.getWindow();
- boolean wasDocked = cPart.isDocked();
- Shell oldShell = cPart.getShell();
- if (wasDocked) {
-
- // PR 1GDFVBY: ViewStack not disposed when page
- // closed.
- if (container instanceof ViewStack) {
- ((ViewStack) container).dispose();
- }
-
- // replace the real container with a
- // ContainerPlaceholder
- ILayoutContainer parentContainer = cPart.getContainer();
- ContainerPlaceholder placeholder = new ContainerPlaceholder(
- cPart.getID());
- placeholder.setRealContainer(container);
- parentContainer.replace(cPart, placeholder);
-
- } else {
- DetachedPlaceHolder placeholder = new DetachedPlaceHolder(
- "", oldShell.getBounds()); //$NON-NLS-1$
- for (int i = 0, length = children.length; i < length; i++) {
- children[i].getContainer().remove(children[i]);
- children[i].setContainer(placeholder);
- placeholder.add(children[i]);
- }
- detachedPlaceHolderList.add(placeholder);
- DetachedWindow w = (DetachedWindow)oldShell.getData();
- oldShell.close();
- detachedWindowList.remove(w);
- }
- }
- }
- }
- }
-
- /**
- * Add a part to the presentation.
- *
- * Note: unlike all other LayoutParts, PartPlaceholders will still point to
- * their parent container even when it is inactive. This method relies on this
- * fact to locate the parent.
- */
- public void replacePlaceholderWithPart(LayoutPart part) {
-
- // Look for a PartPlaceholder that will tell us how to position this
- // object
- PartPlaceholder[] placeholders = collectPlaceholders();
- for (int i = 0, length = placeholders.length; i < length; i++) {
- if (placeholders[i].getCompoundId().equals(part.getCompoundId())) {
- // found a matching placeholder which we can replace with the
- // new View
- ILayoutContainer container = placeholders[i].getContainer();
- if (container != null) {
- if (container instanceof ContainerPlaceholder) {
- // One of the children is now visible so replace the
- // ContainerPlaceholder with the real container
- ContainerPlaceholder containerPlaceholder = (ContainerPlaceholder) container;
- ILayoutContainer parentContainer = containerPlaceholder
- .getContainer();
- container = (ILayoutContainer) containerPlaceholder
- .getRealContainer();
- if (container instanceof LayoutPart) {
- parentContainer.replace(containerPlaceholder,
- (LayoutPart) container);
- }
- containerPlaceholder.setRealContainer(null);
- }
- container.replace(placeholders[i], part);
- return;
- }
- }
- }
-
- }
-
- /**
- * @see org.eclipse.ui.IPersistable
- */
- public IStatus restoreState(IMemento memento) {
- // Restore main window.
- IMemento childMem = memento
- .getChild(IWorkbenchConstants.TAG_MAIN_WINDOW);
- IStatus r = mainLayout.restoreState(childMem);
-
- // Restore each floating window.
- if (detachable) {
- IMemento detachedWindows[] = memento
- .getChildren(IWorkbenchConstants.TAG_DETACHED_WINDOW);
- for (int nX = 0; nX < detachedWindows.length; nX++) {
- DetachedWindow win = new DetachedWindow(page);
- detachedWindowList.add(win);
- win.restoreState(detachedWindows[nX]);
- }
- IMemento childrenMem[] = memento
- .getChildren(IWorkbenchConstants.TAG_HIDDEN_WINDOW);
- for (int i = 0, length = childrenMem.length; i < length; i++) {
- DetachedPlaceHolder holder = new DetachedPlaceHolder(
- "", new Rectangle(0, 0, 0, 0)); //$NON-NLS-1$
- holder.restoreState(childrenMem[i]);
- detachedPlaceHolderList.add(holder);
- }
- }
-
- // Get the cached id of the currently maximized stack
- maximizedStackId = childMem.getString(IWorkbenchConstants.TAG_MAXIMIZED);
-
- return r;
- }
-
- /**
- * @see org.eclipse.ui.IPersistable
- */
- public IStatus saveState(IMemento memento) {
- // Persist main window.
- IMemento childMem = memento
- .createChild(IWorkbenchConstants.TAG_MAIN_WINDOW);
- IStatus r = mainLayout.saveState(childMem);
-
- if (detachable) {
- // Persist each detached window.
- for (int i = 0, length = detachedWindowList.size(); i < length; i++) {
- DetachedWindow window = (DetachedWindow) detachedWindowList
- .get(i);
- childMem = memento
- .createChild(IWorkbenchConstants.TAG_DETACHED_WINDOW);
- window.saveState(childMem);
- }
- for (int i = 0, length = detachedPlaceHolderList.size(); i < length; i++) {
- DetachedPlaceHolder holder = (DetachedPlaceHolder) detachedPlaceHolderList
- .get(i);
- childMem = memento
- .createChild(IWorkbenchConstants.TAG_HIDDEN_WINDOW);
- holder.saveState(childMem);
- }
- }
-
- // Write out the id of the maximized (View) stack (if any)
- // NOTE: we only write this out if it's a ViewStack since the
- // Editor Area is handled by the perspective
- if (maximizedStack instanceof ViewStack) {
- childMem.putString(IWorkbenchConstants.TAG_MAXIMIZED, maximizedStack.getID());
- }
- else if (maximizedStackId != null) {
- // Maintain the cache if the perspective has never been activated
- childMem.putString(IWorkbenchConstants.TAG_MAXIMIZED, maximizedStackId);
- }
-
- return r;
- }
-
- /**
- * Zoom in on a particular layout part.
- */
- public void zoomIn(IWorkbenchPartReference ref) {
- PartPane pane = ((WorkbenchPartReference) ref).getPane();
-
-
- parentWidget.setRedraw(false);
- try {
- pane.requestZoomIn();
- } finally {
- parentWidget.setRedraw(true);
- }
- }
-
- /**
- * Zoom out.
- */
- public void zoomOut() {
- // New 3.3 behavior
- if (Perspective.useNewMinMax(perspective)) {
- if (maximizedStack != null)
- maximizedStack.setState(IStackPresentationSite.STATE_RESTORED);
- return;
- }
-
- LayoutPart zoomPart = mainLayout.getZoomedPart();
- if (zoomPart != null) {
- zoomPart.requestZoomOut();
- }
- }
-
- /**
- * Forces the perspective to have no zoomed or minimized parts.
- * This is used when switching to the 3.3 presentation...
- */
- public void forceNoZoom() {
- // Ensure that nobody's zoomed
- zoomOut();
-
- // Now, walk the layout ensuring that nothing is minimized
- LayoutPart[] kids = mainLayout.getChildren();
- for (int i = 0; i < kids.length; i++) {
- if (kids[i] instanceof ViewStack) {
- ((ViewStack)kids[i]).setMinimized(false);
- }
- else if (kids[i] instanceof EditorSashContainer) {
- LayoutPart[] editorStacks = ((EditorSashContainer)kids[i]).getChildren();
- for (int j = 0; j < editorStacks.length; j++) {
- if (editorStacks[j] instanceof EditorStack) {
- ((EditorStack)editorStacks[j]).setMinimized(false);
- }
- }
- }
- }
- }
-
- /**
- * Captures the current bounds of all ViewStacks and the editor
- * area and puts them into an ID -> Rectangle map. This info is
- * used to cache the bounds so that we can correctly place minimized
- * stacks during a 'maximized' operation (where the iterative min's
- * affect the current layout while being performed.
- */
- public void updateBoundsMap() {
- boundsMap.clear();
-
- // Walk the layout gathering the current bounds of each stack
- // and the editor area
- LayoutPart[] kids = mainLayout.getChildren();
- for (int i = 0; i < kids.length; i++) {
- if (kids[i] instanceof ViewStack) {
- ViewStack vs = (ViewStack)kids[i];
- boundsMap.put(vs.getID(), vs.getBounds());
- }
- else if (kids[i] instanceof EditorSashContainer) {
- EditorSashContainer esc = (EditorSashContainer)kids[i];
- boundsMap.put(esc.getID(), esc.getBounds());
- }
- }
- }
-
- /**
- * Resets the bounds map so that it won't interfere with normal minimize
- * operayions
- */
- public void resetBoundsMap() {
- boundsMap.clear();
- }
-
- public Rectangle getCachedBoundsFor(String id) {
- return (Rectangle) boundsMap.get(id);
- }
-}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/PlaceholderFolderLayout.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/PlaceholderFolderLayout.java
deleted file mode 100644
index d374ee63cbe..00000000000
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/PlaceholderFolderLayout.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 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
- * Chris Gross chris.gross@us.ibm.com Bug 107443
- *******************************************************************************/
-package org.eclipse.ui.internal;
-
-import org.eclipse.ui.IPlaceholderFolderLayout;
-
-/**
- * This layout is used to define the initial set of placeholders
- * in a placeholder.
- * <p>
- * Views are added to the placeholder by ID. This id is used to identify
- * a view descriptor in the view registry, and this descriptor is used to
- * instantiate the IViewPart.
- * </p>
- */
-public class PlaceholderFolderLayout implements IPlaceholderFolderLayout {
- private PageLayout pageLayout;
-
- private ContainerPlaceholder placeholder;
-
- public PlaceholderFolderLayout(PageLayout pageLayout,
- ContainerPlaceholder folder) {
- super();
- this.placeholder = folder;
- this.pageLayout = pageLayout;
- }
-
- /**
- * @see IPlaceholderFolderLayout
- */
- public void addPlaceholder(String viewId) {
- if (!pageLayout.checkValidPlaceholderId(viewId)) {
- return;
- }
-
- // Create the placeholder.
- LayoutPart newPart = new PartPlaceholder(viewId);
-
- linkPartToPageLayout(viewId, newPart);
-
- // Add it to the placeholder layout.
- placeholder.add(newPart);
- }
-
- /**
- * Inform the page layout of the new part created
- * and the placeholder the part belongs to.
- */
- private void linkPartToPageLayout(String viewId, LayoutPart newPart) {
- pageLayout.setRefPart(viewId, newPart);
- // force creation of the view layout rec
- pageLayout.getViewLayoutRec(viewId, true);
-
- pageLayout.setFolderPart(viewId, placeholder);
- newPart.setContainer(placeholder);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.IPlaceholderFolderLayout#getProperty(java.lang.String)
- */
- public String getProperty(String id) {
- LayoutPart folder = placeholder.getRealContainer();
- if (folder instanceof PartStack) {
- PartStack stack = (PartStack)folder;
- return stack.getProperty(id);
- }
- //throw not supported?
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.IPlaceholderFolderLayout#setProperty(java.lang.String, java.lang.String)
- */
- public void setProperty(String id, String value) {
- LayoutPart folder = placeholder.getRealContainer();
- if (folder instanceof PartStack) {
- PartStack stack = (PartStack)folder;
- stack.setProperty(id,value);
- }
- //throw not supported?
- }
-}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/PluginActionSetBuilder.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/PluginActionSetBuilder.java
deleted file mode 100644
index 04175e462eb..00000000000
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/PluginActionSetBuilder.java
+++ /dev/null
@@ -1,779 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2009 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 org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.dynamichelpers.IExtensionTracker;
-import org.eclipse.jface.action.AbstractGroupMarker;
-import org.eclipse.jface.action.ActionContributionItem;
-import org.eclipse.jface.action.GroupMarker;
-import org.eclipse.jface.action.IContributionItem;
-import org.eclipse.jface.action.IContributionManager;
-import org.eclipse.jface.action.ICoolBarManager;
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.jface.action.IToolBarManager;
-import org.eclipse.jface.action.Separator;
-import org.eclipse.jface.internal.provisional.action.IToolBarContributionItem;
-import org.eclipse.ui.IActionBars;
-import org.eclipse.ui.IWorkbenchActionConstants;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.internal.registry.ActionSetRegistry;
-import org.eclipse.ui.internal.registry.IWorkbenchRegistryConstants;
-import org.eclipse.ui.services.IDisposable;
-
-/**
- * This builder reads the actions for an action set from the registry.
- */
-public class PluginActionSetBuilder extends PluginActionBuilder {
-
- private PluginActionSet actionSet;
-
- private IWorkbenchWindow window;
-
- private ArrayList adjunctContributions = new ArrayList(0);
-
- /**
- * Used by the workbench window extension handler to unhook action sets from
- * their associated window.
- *
- * @since 3.1
- */
- public static class Binding implements IDisposable {
- PluginActionSetBuilder builder;
- PluginActionSet set;
- IWorkbenchWindow window;
- IExtensionTracker tracker;
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.services.IDisposable#dispose()
- */
- public void dispose() {
- if (tracker != null) {
- tracker.unregisterObject(set.getConfigElement()
- .getDeclaringExtension(), this);
- tracker = null;
- }
- }
- }
-
- /**
- * Constructs a new builder.
- */
- public PluginActionSetBuilder() {
- }
-
- /**
- * Read the actions within a config element. Called by customize perspective
- *
- * @param set the action set
- * @param window the window to contribute to
- */
- public void buildMenuAndToolBarStructure(PluginActionSet set,
- IWorkbenchWindow window) {
- this.actionSet = set;
- this.window = window;
- cache = null;
- currentContribution = null;
- targetID = null;
- targetContributionTag = IWorkbenchRegistryConstants.TAG_ACTION_SET;
-
- readElements(new IConfigurationElement[] { set.getConfigElement() });
-
- if (cache != null) {
- for (int i = 0; i < cache.size(); i++) {
- ActionSetContribution contribution = (ActionSetContribution) cache
- .get(i);
- contribution.contribute(actionSet.getBars(), true, true);
- if (contribution.isAdjunctContributor()) {
- adjunctContributions.add(contribution);
- }
- }
- }
- for (int i = 0; i < adjunctContributions.size(); i++) {
- ActionSetContribution contribution = (ActionSetContribution) adjunctContributions
- .get(i);
- ActionSetActionBars bars = actionSet.getBars();
- for (int j = 0; j < contribution.adjunctActions.size(); j++) {
- ActionDescriptor adjunctAction = (ActionDescriptor) contribution.adjunctActions
- .get(j);
- contribution
- .contributeAdjunctCoolbarAction(adjunctAction, bars);
- }
- }
-
- registerBinding(set);
- }
-
- /* (non-Javadoc)
- * Method declared on PluginActionBuilder.
- */
- protected ActionDescriptor createActionDescriptor(
- IConfigurationElement element) {
- // As of 2.1, the "pulldown" attribute was deprecated and replaced by
- // the attribute "style". See doc for more details.
- boolean pullDownStyle = false;
- String style = element.getAttribute(IWorkbenchRegistryConstants.ATT_STYLE);
- if (style != null) {
- pullDownStyle = style.equals(ActionDescriptor.STYLE_PULLDOWN);
- } else {
- String pulldown = element.getAttribute(ActionDescriptor.STYLE_PULLDOWN);
- pullDownStyle = pulldown != null && pulldown.equals("true"); //$NON-NLS-1$
- }
-
- ActionDescriptor desc = null;
- if (pullDownStyle) {
- desc = new ActionDescriptor(element,
- ActionDescriptor.T_WORKBENCH_PULLDOWN, window);
- } else {
- desc = new ActionDescriptor(element, ActionDescriptor.T_WORKBENCH,
- window);
- }
- WWinPluginAction action = (WWinPluginAction) desc.getAction();
- action.setActionSetId(actionSet.getDesc().getId());
- actionSet.addPluginAction(action);
- return desc;
- }
-
- /* (non-Javadoc)
- * Method declared on PluginActionBuilder.
- */
- protected BasicContribution createContribution() {
- return new ActionSetContribution(actionSet.getDesc().getId(), window);
- }
-
- /**
- * Returns the insertion point for a new contribution item. Clients should
- * use this item as a reference point for insertAfter.
- *
- * @param startId the reference id for insertion
- * @param sortId the sorting id for the insertion. If null then the item
- * will be inserted at the end of all action sets.
- * @param mgr the target menu manager.
- * @param startVsEnd if <code>true</code> the items are added at the start of
- * action with the same id; else they are added to the end
- * @return the insertion point, or null if not found.
- */
- public static IContributionItem findInsertionPoint(String startId,
- String sortId, IContributionManager mgr, boolean startVsEnd) {
- // Get items.
- IContributionItem[] items = mgr.getItems();
-
- // Find the reference item.
- int insertIndex = 0;
- while (insertIndex < items.length) {
- if (startId.equals(items[insertIndex].getId())) {
- break;
- }
- ++insertIndex;
- }
- if (insertIndex >= items.length) {
- return null;
- }
-
- // Calculate startVsEnd comparison value.
- int compareMetric = 0;
- if (startVsEnd) {
- compareMetric = 1;
- }
-
- // Find the insertion point for the new item.
- // We do this by iterating through all of the previous
- // action set contributions define within the current group.
- for (int nX = insertIndex + 1; nX < items.length; nX++) {
- IContributionItem item = items[nX];
- if (item.isSeparator() || item.isGroupMarker()) {
- // Fix for bug report 18357
- break;
- }
- if (item instanceof IActionSetContributionItem) {
- if (sortId != null) {
- String testId = ((IActionSetContributionItem) item)
- .getActionSetId();
- if (sortId.compareTo(testId) < compareMetric) {
- break;
- }
- }
- insertIndex = nX;
- } else {
- break;
- }
- }
- // Return item.
- return items[insertIndex];
- }
-
- /**
- */
- /* package */static void processActionSets(ArrayList pluginActionSets,
- WorkbenchWindow window) {
- // Process the action sets in two passes. On the first pass the pluginActionSetBuilder
- // will process base contributions and cache adjunct contributions. On the second
- // pass the adjunct contributions will be processed.
- PluginActionSetBuilder[] builders = new PluginActionSetBuilder[pluginActionSets
- .size()];
- for (int i = 0; i < pluginActionSets.size(); i++) {
- PluginActionSet set = (PluginActionSet) pluginActionSets.get(i);
- PluginActionSetBuilder builder = new PluginActionSetBuilder();
- builder.readActionExtensions(set, window);
- builders[i] = builder;
- }
- for (int i = 0; i < builders.length; i++) {
- PluginActionSetBuilder builder = builders[i];
- builder.processAdjunctContributions();
- }
- }
-
- /**
- */
- protected void processAdjunctContributions() {
- // Contribute the adjunct contributions.
- for (int i = 0; i < adjunctContributions.size(); i++) {
- ActionSetContribution contribution = (ActionSetContribution) adjunctContributions
- .get(i);
- ActionSetActionBars bars = actionSet.getBars();
- for (int j = 0; j < contribution.adjunctActions.size(); j++) {
- ActionDescriptor adjunctAction = (ActionDescriptor) contribution.adjunctActions
- .get(j);
- contribution
- .contributeAdjunctCoolbarAction(adjunctAction, bars);
- }
- }
- }
-
- /**
- * Read the actions within a config element.
- */
- protected void readActionExtensions(PluginActionSet set,
- IWorkbenchWindow window) {
- this.actionSet = set;
- this.window = window;
- cache = null;
- currentContribution = null;
- targetID = null;
- targetContributionTag = IWorkbenchRegistryConstants.TAG_ACTION_SET;
-
- readElements(new IConfigurationElement[] { set.getConfigElement() });
-
- if (cache != null) {
- // for dynamic UI - save cache for future removal lf actionset extensions
- // Don't call addCache -- it's broken, and is only used for dynamic plugin removal,
- // which the workbench doesn't currently support.
- // See bug 66374 for more details.
- // WorkbenchPlugin.getDefault().getActionSetRegistry().addCache(set.getDesc().getId(), cache);
- for (int i = 0; i < cache.size(); i++) {
- ActionSetContribution contribution = (ActionSetContribution) cache
- .get(i);
- contribution.contribute(actionSet.getBars(), true, true);
- if (contribution.isAdjunctContributor()) {
- adjunctContributions.add(contribution);
- }
- }
-
- registerBinding(set);
-
- } else {
- WorkbenchPlugin
- .log("Action Set is empty: " + set.getDesc().getId()); //$NON-NLS-1$
- }
- }
-
- private void registerBinding(final PluginActionSet set) {
- final IExtensionTracker tracker = window.getExtensionTracker();
-
- // register the new binding
- final Binding binding = new Binding();
- binding.builder = this;
- binding.set = set;
- binding.window = window;
- binding.tracker = tracker;
- tracker.registerObject(
- set.getConfigElement().getDeclaringExtension(), binding,
- IExtensionTracker.REF_STRONG);
- set.setBuilder(binding);
- }
-
- /**
- * Helper class to collect the menus and actions defined within a
- * contribution element.
- */
- private static class ActionSetContribution extends BasicContribution {
- private String actionSetId;
-
- private WorkbenchWindow window;
-
- protected ArrayList adjunctActions = new ArrayList(0);
-
- /**
- * Create a new instance of <code>ActionSetContribution</code>.
- *
- * @param id the id
- * @param window the window to contribute to
- */
- public ActionSetContribution(String id, IWorkbenchWindow window) {
- super();
- actionSetId = id;
- this.window = (WorkbenchWindow) window;
- }
-
- /**
- * This implementation inserts the group into the action set additions group.
- */
- protected void addGroup(IContributionManager mgr, String name) {
- IContributionItem refItem = findInsertionPoint(
- IWorkbenchActionConstants.MB_ADDITIONS, actionSetId, mgr,
- true);
- // Insert the new group marker.
- ActionSetSeparator group = new ActionSetSeparator(name, actionSetId);
- if (refItem == null) {
- mgr.add(group);
- } else {
- mgr.insertAfter(refItem.getId(), group);
- }
- }
-
- /**
- * Contributes submenus and/or actions into the provided menu and tool bar
- * managers.
- *
- * @param bars the action bars to contribute to
- * @param menuAppendIfMissing append to the menubar if missing
- * @param toolAppendIfMissing append to the toolbar if missing
- */
- public void contribute(IActionBars bars, boolean menuAppendIfMissing,
- boolean toolAppendIfMissing) {
-
- IMenuManager menuMgr = bars.getMenuManager();
- IToolBarManager toolBarMgr = bars.getToolBarManager();
- if (menus != null && menuMgr != null) {
- for (int i = 0; i < menus.size(); i++) {
- IConfigurationElement menuElement = (IConfigurationElement) menus
- .get(i);
- contributeMenu(menuElement, menuMgr, menuAppendIfMissing);
- }
- }
-
- if (actions != null) {
- for (int i = 0; i < actions.size(); i++) {
- ActionDescriptor ad = (ActionDescriptor) actions.get(i);
- if (menuMgr != null) {
- contributeMenuAction(ad, menuMgr, menuAppendIfMissing);
- }
- if (toolBarMgr != null) {
- if (bars instanceof ActionSetActionBars) {
- contributeCoolbarAction(ad,
- (ActionSetActionBars) bars);
- } else {
- contributeToolbarAction(ad, toolBarMgr,
- toolAppendIfMissing);
- }
- }
- }
- }
- }
-
- /**
- * Contributes action from the action descriptor into the cool bar manager.
- */
- protected void contributeAdjunctCoolbarAction(ActionDescriptor ad,
- ActionSetActionBars bars) {
- String toolBarId = ad.getToolbarId();
- String toolGroupId = ad.getToolbarGroupId();
-
- String contributingId = bars.getActionSetId();
- ICoolBarManager coolBarMgr = bars.getCoolBarManager();
- if (coolBarMgr == null) {
- return;
- }
-
- PluginAction action = ad.getAction();
- ActionContributionItem actionContribution = new PluginActionCoolBarContributionItem(
- action);
- actionContribution.setMode(ad.getMode());
-
- bars.addAdjunctContribution(actionContribution);
-
- // create a coolitem for the toolbar id if it does not yet exist
- IToolBarManager toolBarManager = bars.getToolBarManager(toolBarId);
-
- // Check to see if the group already exists
- IContributionItem groupMarker = toolBarManager.find(toolGroupId);
- // Add a group marker if one does not exist
- if (groupMarker == null) {
- toolBarManager.add(new Separator(toolGroupId));
- }
- IContributionItem refItem = findAlphabeticalOrder(toolGroupId,
- contributingId, toolBarManager);
- if (refItem != null && refItem.getId() != null) {
- toolBarManager.insertAfter(refItem.getId(), actionContribution);
- } else {
- toolBarManager.add(actionContribution);
- }
- toolBarManager.update(false);
-
- }
-
- /**
- * Contributes action from the action descriptor into the cool bar manager.
- */
- protected void contributeCoolbarAction(ActionDescriptor ad,
- ActionSetActionBars bars) {
- String toolBarId = ad.getToolbarId();
- String toolGroupId = ad.getToolbarGroupId();
- if (toolBarId == null && toolGroupId == null) {
- return;
- }
-
- String contributingId = bars.getActionSetId();
-
- if (toolBarId == null || toolBarId.equals("")) { //$NON-NLS-1$
- // the item is being added to the coolitem for its action set
- toolBarId = contributingId;
- }
-
- if (!toolBarId.equals(contributingId)) {
- // adding to another action set, validate the id
- if (!isValidCoolItemId(toolBarId, window)) {
- // toolbarid not valid, add the item to the coolitem for its action set
- toolBarId = contributingId;
- } else {
- adjunctActions.add(ad);
- return;
- }
- }
-
- // Create the action
- PluginAction action = ad.getAction();
- ActionContributionItem actionContribution = new PluginActionCoolBarContributionItem(
- action);
- actionContribution.setMode(ad.getMode());
-
- // retreive the toolbar from the action bars.
- IToolBarManager toolBar = bars.getToolBarManager(toolBarId);
-
- // Check to see if the group already exists
- IContributionItem groupMarker = toolBar.find(toolGroupId);
- // Add a group marker if one does not exist
- if (groupMarker == null) {
- // @issue should this be a GroupMarker?
- toolBar.add(new Separator(toolGroupId));
- }
- toolBar.prependToGroup(toolGroupId, actionContribution);
- toolBar.update(false);
-
- }
-
- /**
- * Checks to see if the cool item id is in the given window.
- */
- private boolean isValidCoolItemId(String id, WorkbenchWindow window) {
- ActionSetRegistry registry = WorkbenchPlugin.getDefault()
- .getActionSetRegistry();
- if (registry.findActionSet(id) != null) {
- return true;
- }
- if (window != null) {
- return window.isWorkbenchCoolItemId(id);
- }
- return false;
- }
-
- /* (non-Javadoc)
- * Method declared on Basic Contribution.
- */
- protected void insertMenuGroup(IMenuManager menu,
- AbstractGroupMarker marker) {
- if (actionSetId != null) {
- IContributionItem[] items = menu.getItems();
- // Loop thru all the current groups looking for the first
- // group whose id > than the current action set id. Insert
- // current marker just before this item then.
- for (int i = 0; i < items.length; i++) {
- IContributionItem item = items[i];
- if (item.isSeparator() || item.isGroupMarker()) {
- if (item instanceof IActionSetContributionItem) {
- String testId = ((IActionSetContributionItem) item)
- .getActionSetId();
- if (actionSetId.compareTo(testId) < 0) {
- menu.insertBefore(items[i].getId(), marker);
- return;
- }
- }
- }
- }
- }
-
- menu.add(marker);
- }
-
- private IContributionItem findAlphabeticalOrder(String startId,
- String itemId, IContributionManager mgr) {
- IContributionItem[] items = mgr.getItems();
- int insertIndex = 0;
-
- // look for starting point
- while (insertIndex < items.length) {
- IContributionItem item = items[insertIndex];
- if (startId != null && startId.equals(item.getId())) {
- break;
- }
- ++insertIndex;
- }
-
- // Find the index that this item should be inserted in
- for (int i = insertIndex + 1; i < items.length; i++) {
- IContributionItem item = items[i];
- if (item.isGroupMarker()) {
- break;
- }
-
- String testId = null;
- if (item instanceof PluginActionCoolBarContributionItem) {
- testId = ((PluginActionCoolBarContributionItem) item)
- .getActionSetId();
- }
- if (testId == null) {
- break;
- }
-
- if (itemId != null && testId != null) {
- if (itemId.compareTo(testId) < 1) {
- break;
- }
- }
- insertIndex = i;
- }
- if (insertIndex >= items.length) {
- return null;
- }
- return items[insertIndex];
- }
-
- /**
- * Returns whether the contributor is an adjunct contributor.
- *
- * @return whether the contributor is an adjunct contributor
- */
- public boolean isAdjunctContributor() {
- return adjunctActions.size() > 0;
- }
-
- /* (non-Javadoc)
- * Method declared on Basic Contribution.
- */
- protected void insertAfter(IContributionManager mgr, String refId,
- IContributionItem item) {
- IContributionItem refItem = findInsertionPoint(refId, actionSetId,
- mgr, true);
- if (refItem != null) {
- mgr.insertAfter(refItem.getId(), item);
- } else {
- WorkbenchPlugin
- .log("Reference item " + refId + " not found for action " + item.getId()); //$NON-NLS-1$ //$NON-NLS-2$
- }
- }
-
- //for dynamic UI
- protected void revokeContribution(WorkbenchWindow window,
- IActionBars bars, String id) {
- revokeActionSetFromMenu(window.getMenuManager(), id);
- // IMenuManager menuMgr = bars.getMenuManager();
- // if (menuMgr != null)
- // revokeActionSetFromMenu(menuMgr, id);
-
- revokeActionSetFromCoolbar(window.getCoolBarManager2(), id);
- // IToolBarManager toolBarMgr = bars.getToolBarManager();
- // if (toolBarMgr != null && toolBarMgr instanceof CoolItemToolBarManager)
- // revokeActionSetFromToolbar(toolBarMgr, id);
- }
-
- //for dynamic UI
- protected void revokeAdjunctCoolbarAction(ActionDescriptor ad,
- ActionSetActionBars bars) {
- String toolBarId = ad.getToolbarId();
-// String toolGroupId = ad.getToolbarGroupId();
-//
-// String contributingId = bars.getActionSetId();
- ICoolBarManager coolBarMgr = bars.getCoolBarManager();
- // ((CoolItemToolBarManager)bars.getToolBarManager()).getParentManager();
- PluginAction action = ad.getAction();
- PluginActionCoolBarContributionItem actionContribution = new PluginActionCoolBarContributionItem(
- action);
- actionContribution.setMode(ad.getMode());
-
- bars.removeAdjunctContribution(actionContribution);
-
- // remove a coolitem for the toolbar id if it exists
- IContributionItem cbItem = coolBarMgr.find(toolBarId);
- if (cbItem != null) {
- coolBarMgr.remove(cbItem);
- }
-
- // activeManager = cbItem.getToolBarManager();
- // activeManager.remove(contributingId);
- // IContributionItem groupMarker = activeManager.find(toolGroupId);
- // if (groupMarker != null) {
- // int idx = activeManager.indexOf(toolGroupId);
- // IContributionItem[] items = activeManager.getItems();
- // if (items.length == idx+1 ||
- // ((items.length > idx && items[idx+1] instanceof Separator)))
- // if (activeManager.find(toolGroupId) != null)
- // activeManager.remove(toolGroupId);
- // }
- // activeManager.addAdjunctItemToGroup(toolGroupId, contributingId, actionContribution);
- }
-
- //for dynamic UI
- private void revokeActionSetFromMenu(IMenuManager menuMgr,
- String actionsetId) {
- IContributionItem[] items = menuMgr.getItems();
- ArrayList itemsToRemove = new ArrayList();
- String id;
- for (int i = 0; i < items.length; i++) {
- if (items[i] instanceof IMenuManager) {
- revokeActionSetFromMenu((IMenuManager) items[i],
- actionsetId);
- } else if (items[i] instanceof ActionSetContributionItem) {
- id = ((ActionSetContributionItem) items[i])
- .getActionSetId();
- if (actionsetId.equals(id)) {
- itemsToRemove.add(items[i]);
- }
- } else if (items[i] instanceof Separator) {
- id = ((Separator) items[i]).getId();
- if (actionsetId.equals(id)) {
- itemsToRemove.add(items[i]);
- }
- } else if (items[i] instanceof GroupMarker) {
- id = ((GroupMarker) items[i]).getId();
- if (actionsetId.equals(id)) {
- itemsToRemove.add(items[i]);
- }
- }
- }
- Iterator iter = itemsToRemove.iterator();
- while (iter.hasNext()) {
- IContributionItem item = (IContributionItem) iter.next();
- menuMgr.remove(item);
- }
- menuMgr.update(true);
- }
-
- // for dynamic UI
- private void revokeActionSetFromCoolbar(ICoolBarManager coolbarMgr,
- String actionsetId) {
- IContributionItem[] items = coolbarMgr.getItems();
- ArrayList itemsToRemove = new ArrayList();
- String id;
- for (int i = 0; i < items.length; i++) {
- id = items[i].getId();
- if (actionsetId.equals(id)) {
- itemsToRemove.add(items[i]);
- continue;
- }
- if (items[i] instanceof IToolBarManager) {
- revokeActionSetFromToolbar((IToolBarManager) items[i],
- actionsetId);
- } else if (items[i] instanceof IToolBarContributionItem) {
- id = ((IToolBarContributionItem) items[i]).getId();
- if (actionsetId.equals(id)) {
- itemsToRemove.add(items[i]);
- }
- } else if (items[i] instanceof GroupMarker) {
- id = ((GroupMarker) items[i]).getId();
- if (actionsetId.equals(id)) {
- itemsToRemove.add(items[i]);
- }
- }
- }
- Iterator iter = itemsToRemove.iterator();
- while (iter.hasNext()) {
- coolbarMgr.remove((IContributionItem) iter.next());
- }
- coolbarMgr.update(true);
- }
-
- // for dynamic UI
- private void revokeActionSetFromToolbar(IToolBarManager toolbarMgr,
- String actionsetId) {
- IContributionItem[] items = toolbarMgr.getItems();
- ArrayList itemsToRemove = new ArrayList();
- String id;
- for (int i = 0; i < items.length; i++) {
- id = items[i].getId();
- if (id.equals(actionsetId)) {
- itemsToRemove.add(items[i]);
- continue;
- }
- if (items[i] instanceof PluginActionCoolBarContributionItem) {
- id = ((PluginActionCoolBarContributionItem) items[i])
- .getActionSetId();
- if (actionsetId.equals(id)) {
- itemsToRemove.add(items[i]);
- }
- } else if (items[i] instanceof ActionContributionItem) {
- id = ((ActionContributionItem) items[i]).getId();
- if (actionsetId.equals(id)) {
- itemsToRemove.add(items[i]);
- }
- } else if (items[i] instanceof GroupMarker) {
- id = ((GroupMarker) items[i]).getId();
- if (actionsetId.equals(id)) {
- itemsToRemove.add(items[i]);
- }
- }
- }
- Iterator iter = itemsToRemove.iterator();
- while (iter.hasNext()) {
- toolbarMgr.remove((IContributionItem) iter.next());
- }
- toolbarMgr.update(true);
- }
- }
-
-
- /**
- * Remove the given action set from the window.
- *
- * @param set the set to remove
- * @param window the window to remove from
- */
- protected void removeActionExtensions(PluginActionSet set,
- IWorkbenchWindow window) {
- this.actionSet = set;
- this.window = window;
- currentContribution = null;
- targetID = null;
- targetContributionTag = IWorkbenchRegistryConstants.TAG_ACTION_SET;
- String id = set.getDesc().getId();
-
- if (cache != null) {
- for (int i = 0; i < cache.size(); i++) {
- ActionSetContribution contribution = (ActionSetContribution) cache
- .get(i);
- contribution.revokeContribution((WorkbenchWindow) window,
- actionSet.getBars(), id);
- if (contribution.isAdjunctContributor()) {
- for (int j = 0; j < contribution.adjunctActions.size(); j++) {
- ActionDescriptor adjunctAction = (ActionDescriptor) contribution.adjunctActions
- .get(j);
- contribution.revokeAdjunctCoolbarAction(adjunctAction,
- actionSet.getBars());
- }
- }
- }
- }
- }
-}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/PluginActionSetReader.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/PluginActionSetReader.java
deleted file mode 100644
index af11ec75894..00000000000
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/PluginActionSetReader.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2005 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.List;
-
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.ui.internal.decorators.LightweightActionDescriptor;
-import org.eclipse.ui.internal.registry.ActionSetDescriptor;
-import org.eclipse.ui.internal.registry.IWorkbenchRegistryConstants;
-import org.eclipse.ui.internal.registry.RegistryReader;
-
-/**
- * Read the actions for an plugin action set.
- *
- * [Issue: There is some overlap with the class
- * PluginActionSetBuilder which should be reviewed
- * at a later time and maybe merged together]
- */
-public class PluginActionSetReader extends RegistryReader {
- private List cache = new ArrayList();
-
- /**
- * PluginActionSetReader constructor comment.
- */
- public PluginActionSetReader() {
- super();
- }
-
- /**
- * This factory method returns a new ActionDescriptor for the
- * configuration element.
- */
- protected LightweightActionDescriptor createActionDescriptor(
- IConfigurationElement element) {
- return new LightweightActionDescriptor(element);
- }
-
- /**
- * Return all the action descriptor within the set.
- *
- * @param actionSet the set
- * @return the descriptors
- */
- public LightweightActionDescriptor[] readActionDescriptors(
- ActionSetDescriptor actionSet) {
- readElements(new IConfigurationElement[] { actionSet.getConfigurationElement() });
- LightweightActionDescriptor[] actions = new LightweightActionDescriptor[cache
- .size()];
- cache.toArray(actions);
- return actions;
- }
-
- /**
- * @see RegistryReader
- */
- protected boolean readElement(IConfigurationElement element) {
- String tag = element.getName();
- if (tag.equals(IWorkbenchRegistryConstants.TAG_ACTION_SET)) {
- readElementChildren(element);
- return true;
- }
- if (tag.equals(IWorkbenchRegistryConstants.TAG_OBJECT_CONTRIBUTION)) {
- // This builder is sometimes used to read the popup menu
- // extension point. Ignore all object contributions.
- return true;
- }
- if (tag.equals(IWorkbenchRegistryConstants.TAG_MENU)) {
- return true; // just cache the element - don't go into it
- }
- if (tag.equals(IWorkbenchRegistryConstants.TAG_ACTION)) {
- cache.add(createActionDescriptor(element));
- return true; // just cache the action - don't go into
- }
-
- return false;
- }
-}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/RectangleAnimation.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/RectangleAnimation.java
deleted file mode 100644
index fdd26bf25d2..00000000000
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/RectangleAnimation.java
+++ /dev/null
@@ -1,252 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2010 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.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.jobs.Job;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.util.Geometry;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.IWorkbenchPreferenceConstants;
-import org.eclipse.ui.internal.util.PrefUtil;
-
-/**
- * This job creates an animated rectangle that moves from a source rectangle to
- * a target in a fixed amount of time. To begin the animation, instantiate this
- * object then call schedule().
- *
- * @since 3.0
- */
-public class RectangleAnimation extends Job {
- private static class AnimationFeedbackFactory {
- public static DefaultAnimationFeedback createAnimationRenderer(Shell parentShell) {
- return new DefaultAnimationFeedback();
- }
- }
-
- // Constants
- public static final int TICK_TIMER = 1;
- public static final int FRAME_COUNT = 2;
-
- // Animation Parameters
- private Display display;
-
- private boolean enableAnimations;
- private int timingStyle = TICK_TIMER;
- private int duration;
-
- // Control State
- private DefaultAnimationFeedback feedbackRenderer;
- private long frameCount;
- private long startTime;
- private long curTime;
- private long prevTime;
-
- // Macros
- private boolean done() { return amount() >= 1.0; }
-
- public static Rectangle interpolate(Rectangle start, Rectangle end,
- double amount) {
- double initialWeight = 1.0 - amount;
-
- Rectangle result = new Rectangle((int) (start.x * initialWeight + end.x
- * amount), (int) (start.y * initialWeight + end.y * amount),
- (int) (start.width * initialWeight + end.width * amount),
- (int) (start.height * initialWeight + end.height * amount));
-
- return result;
- }
-
- // Animation Step
- private Runnable animationStep = new Runnable() {
-
- public void run() {
- // Capture time
- prevTime = curTime;
- curTime = System.currentTimeMillis();
-
- // Has the system timer 'ticked'?
- if (curTime != prevTime) {
- clockTick();
- }
-
- if (isUpdateStep()) {
- updateDisplay();
- frameCount++;
- }
- }
-
- };
-
- /**
- * Creates an animation that will morph the start rectangle to the end rectangle in the
- * given number of milliseconds. The animation will take the given number of milliseconds to
- * complete.
- *
- * Note that this is a Job, so you must invoke schedule() before the animation will begin
- *
- * @param whereToDraw specifies the composite where the animation will be drawn. Note that
- * although the start and end rectangles can accept any value in display coordinates, the
- * actual animation will be clipped to the boundaries of this composite. For this reason,
- * it is good to select a composite that encloses both the start and end rectangles.
- * @param start initial rectangle (display coordinates)
- * @param end final rectangle (display coordinates)
- * @param duration number of milliseconds over which the animation will run
- */
- public RectangleAnimation(Shell parentShell, Rectangle start,
- Rectangle end, int duration) {
- super(WorkbenchMessages.RectangleAnimation_Animating_Rectangle);
-
- // if animations aren't on this is a NO-OP
- IPreferenceStore preferenceStore = PrefUtil.getAPIPreferenceStore();
- enableAnimations = preferenceStore.getBoolean(IWorkbenchPreferenceConstants.ENABLE_ANIMATIONS);
-
- if (!enableAnimations) {
- return;
- }
-
- // Capture paraeters
- display = parentShell.getDisplay();
- this.duration = duration;
-
- // Don't show the job in monitors
- setSystem(true);
-
- // Pick the renderer (could be a preference...)
- feedbackRenderer = AnimationFeedbackFactory.createAnimationRenderer(parentShell);
-
- // Set it up
- feedbackRenderer.initialize(parentShell, start, end);
-
- // Set the animation's initial state
- //long totalFrames = (long) ((duration / 1000.0) * framesPerSec);
- curTime = startTime = System.currentTimeMillis();
- }
-
- public RectangleAnimation(Shell parentShell, Rectangle start, Rectangle end) {
- this(parentShell, start, end, 400);
- }
-
- public void addStartRect(Rectangle rect) {
- if (feedbackRenderer != null)
- feedbackRenderer.addStartRect(rect);
- }
-
- public void addEndRect(Rectangle rect) {
- if (feedbackRenderer != null)
- feedbackRenderer.addEndRect(rect);
- }
-
- public void addStartRect(Control ctrl) {
- Rectangle ctrlBounds = ctrl.getBounds();
- Rectangle startRect = Geometry.toDisplay(ctrl.getParent(), ctrlBounds);
- addStartRect(startRect);
- }
-
- public void addEndRect(Control ctrl) {
- Rectangle ctrlBounds = ctrl.getBounds();
- Rectangle endRect = Geometry.toDisplay(ctrl.getParent(), ctrlBounds);
- addEndRect(endRect);
- }
-
- /**
- *
- */
- protected void clockTick() {
- }
-
- /**
- * @return
- */
- protected boolean isUpdateStep() {
- switch (timingStyle) {
- case TICK_TIMER:
- return prevTime != curTime;
-
- case FRAME_COUNT:
- return true;
- }
-
- return false;
- }
-
- private double amount() {
- double amount = 0.0;
-
- switch (timingStyle) {
- case TICK_TIMER:
- amount = (double) (curTime - startTime) / (double) duration;
- break;
-
- case FRAME_COUNT:
- amount = (double)frameCount / (double)duration;
- }
-
- if (amount > 1.0)
- amount = 1.0;
-
- return amount;
- }
-
- /**
- *
- */
- protected void updateDisplay() {
- feedbackRenderer.renderStep(amount());
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.core.runtime.jobs.Job#run(org.eclipse.core.runtime.IProgressMonitor)
- */
- protected IStatus run(IProgressMonitor monitor) {
-
- // We use preference value to indicate that the animation should be skipped on this platform.
- if (!enableAnimations || feedbackRenderer == null) {
- return Status.OK_STATUS;
- }
-
- // Do we have anything to animate ?
- boolean isEmpty = feedbackRenderer.getStartRects().size() == 0;
- if (isEmpty) {
- return Status.OK_STATUS;
- }
-
- // We're starting, initialize
- display.syncExec(new Runnable() {
- public void run() {
- feedbackRenderer.jobInit();
- }
- });
-
- // Only start the animation timer -after- we've initialized
- curTime = startTime = System.currentTimeMillis();
-
- while (!done()) {
- display.syncExec(animationStep);
- // Don't pin the CPU
- Thread.yield();
- }
-
- // We're done, clean up
- display.syncExec(new Runnable() {
- public void run() {
- feedbackRenderer.dispose();
- }
- });
-
- return Status.OK_STATUS;
- }
-}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/StickyViewManager.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/StickyViewManager.java
deleted file mode 100644
index 8fe8fd6a215..00000000000
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/StickyViewManager.java
+++ /dev/null
@@ -1,155 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2009 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.Set;
-
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.ui.IMemento;
-import org.eclipse.ui.IViewReference;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.IWorkbenchPreferenceConstants;
-import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.internal.util.PrefUtil;
-import org.eclipse.ui.views.IStickyViewDescriptor;
-import org.eclipse.ui.views.IViewRegistry;
-
-/**
- * @since 3.3
- *
- */
-public class StickyViewManager implements IStickyViewManager {
-
- private IWorkbenchPage page;
-
- public StickyViewManager(IWorkbenchPage page) {
- this.page = page;
- }
-
-
- public static IStickyViewManager getInstance(IWorkbenchPage page) {
- IStickyViewManager stickyViewMan;
- IPreferenceStore preferenceStore = PrefUtil.getAPIPreferenceStore();
- boolean enable32Behavior = preferenceStore
- .getBoolean(IWorkbenchPreferenceConstants.ENABLE_32_STICKY_CLOSE_BEHAVIOR);
- if (enable32Behavior)
- stickyViewMan = new StickyViewManager32(page);
- else
- stickyViewMan = new StickyViewManager(page);
-
- return stickyViewMan;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.internal.IStickyViewManager#add(java.lang.String,
- * java.util.Set)
- */
- public void add(String perspectiveId, Set stickyViewSet) {
- // do nothing
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.internal.IStickyViewManager#clear()
- */
- public void clear() {
- // do nothing
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.internal.IStickyViewManager#remove(java.lang.String)
- */
- public void remove(String perspectiveId) {
- // do nothing
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.internal.IStickyViewManager#restore(org.eclipse.ui.IMemento)
- */
- public void restore(IMemento memento) {
- // do nothing
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.internal.IStickyViewManager#save(org.eclipse.ui.IMemento)
- */
- public void save(IMemento memento) {
- // do nothing
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.internal.IStickyViewManager#update(org.eclipse.ui.internal.Perspective,
- * org.eclipse.ui.internal.Perspective)
- */
- public void update(Perspective oldPersp, Perspective newPersp) {
- if (oldPersp == null || newPersp == null) {
- return;
- }
- IViewRegistry viewReg = WorkbenchPlugin.getDefault().getViewRegistry();
- IStickyViewDescriptor[] stickyDescs = viewReg.getStickyViews();
- IViewReference[] oldPerspectiveViewReferences = oldPersp
- .getViewReferences();
- IViewReference[] newPerspectiveViewReferences = newPersp
- .getViewReferences();
- for (int i = 0; i < stickyDescs.length; i++) {
- final String viewId = stickyDescs[i].getId();
- try {
- for (int j = 0; j < oldPerspectiveViewReferences.length; j++) {
- String oldViewId = oldPerspectiveViewReferences[j].getId();
- // check to see if a sticky view was shown in the previous
- // perspective
- if (viewId.equals(oldViewId)) {
- String oldViewSecondaryId = oldPerspectiveViewReferences[j]
- .getSecondaryId();
- // materialize the same one in the new perspective
- page.showView(viewId, oldViewSecondaryId,
- IWorkbenchPage.VIEW_CREATE);
- }
- }
-
- for (int j = 0; j < newPerspectiveViewReferences.length; j++) {
- String newViewId = newPerspectiveViewReferences[j].getId();
- // check if a sticky view is being shown in the new
- // perspective
- if (viewId.equals(newViewId)) {
- String newViewSecondaryId = newPerspectiveViewReferences[j]
- .getSecondaryId();
- // if the original perspective didn't have it, that
- // means this sticky view has been hidden, hide it in
- // the new perspective also
- if (oldPersp.findView(newViewId, newViewSecondaryId) == null) {
- page.hideView(newPerspectiveViewReferences[j]);
- }
- }
- }
- } catch (PartInitException e) {
- WorkbenchPlugin
- .log(
- "Could not open view :" + viewId, new Status(IStatus.ERROR, WorkbenchPlugin.PI_WORKBENCH, IStatus.ERROR, "Could not open view :" + viewId, e)); //$NON-NLS-1$ //$NON-NLS-2$
- }
- }
- }
-
-}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/StickyViewManager32.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/StickyViewManager32.java
deleted file mode 100644
index b6e7b74ac9a..00000000000
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/StickyViewManager32.java
+++ /dev/null
@@ -1,142 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 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.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Set;
-
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.ui.IMemento;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.views.IStickyViewDescriptor;
-import org.eclipse.ui.views.IViewRegistry;
-
-/**
- * @since 3.3
- *
- */
-class StickyViewManager32 implements IStickyViewManager {
-
- // a mapping of perspectives to a set of stickyviews that have been activated in that perspective.
- // this map is persisted across sessions
- private Map stickyPerspectives = new HashMap(7);
-
- private IWorkbenchPage page;
-
- public StickyViewManager32(IWorkbenchPage page) {
- this.page = page;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.internal.IStickyViewManager#remove(java.lang.String)
- */
- public void remove(String pespectiveId) {
- stickyPerspectives.remove(pespectiveId);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.internal.IStickyViewManager#add(java.lang.String, java.util.Set)
- */
- public void add(String pespectiveId, Set stickyViewList) {
- stickyPerspectives.put(pespectiveId, stickyViewList);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.internal.IStickyViewManager#clear()
- */
- public void clear() {
- stickyPerspectives.clear();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.internal.IStickyViewManager#update(org.eclipse.ui.IWorkbenchPage, org.eclipse.ui.internal.Perspective, org.eclipse.ui.internal.Perspective)
- */
- public void update(Perspective oldPersp, Perspective newPersp) {
- if (newPersp != null && oldPersp != null) {
- Set activatedStickyViewsInThisPerspective = (Set) stickyPerspectives
- .get(newPersp.getDesc().getId());
- if (activatedStickyViewsInThisPerspective == null) {
- activatedStickyViewsInThisPerspective = new HashSet(7);
- stickyPerspectives.put(newPersp.getDesc().getId(),
- activatedStickyViewsInThisPerspective);
- }
- IViewRegistry viewReg = WorkbenchPlugin.getDefault()
- .getViewRegistry();
- IStickyViewDescriptor[] stickyDescs = viewReg.getStickyViews();
- for (int i = 0; i < stickyDescs.length; i++) {
- final String viewId = stickyDescs[i].getId();
- try {
- // show a sticky view if it was in the last perspective and hasn't already been activated in this one
- if (oldPersp.findView(viewId) != null
- && !activatedStickyViewsInThisPerspective
- .contains(viewId)) {
- page.showView(viewId, null, IWorkbenchPage.VIEW_CREATE);
- activatedStickyViewsInThisPerspective.add(viewId);
- }
- } catch (PartInitException e) {
- WorkbenchPlugin
- .log(
- "Could not open view :" + viewId, new Status(IStatus.ERROR, WorkbenchPlugin.PI_WORKBENCH, IStatus.ERROR, "Could not open view :" + viewId, e)); //$NON-NLS-1$ //$NON-NLS-2$
- }
- }
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.internal.IStickyViewManager#save(org.eclipse.ui.IMemento)
- */
- public void save(IMemento memento) {
- IMemento stickyState = memento.createChild(IWorkbenchConstants.TAG_STICKY_STATE);
- Iterator itr = stickyPerspectives.entrySet().iterator();
- while (itr.hasNext()) {
- Map.Entry entry = (Map.Entry) itr.next();
- String perspectiveId = (String) entry.getKey();
- Set activatedViewIds = (Set) entry.getValue();
- IMemento perspectiveState = stickyState.createChild(
- IWorkbenchConstants.TAG_PERSPECTIVE, perspectiveId);
- for (Iterator i = activatedViewIds.iterator(); i.hasNext();) {
- String viewId = (String) i.next();
- perspectiveState.createChild(IWorkbenchConstants.TAG_VIEW,
- viewId);
- }
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.internal.IStickyViewManager#restore(org.eclipse.ui.IMemento)
- */
- public void restore(IMemento memento) {
- // restore the sticky activation state
- IMemento stickyState = memento
- .getChild(IWorkbenchConstants.TAG_STICKY_STATE);
-
- if (stickyState != null) {
- IMemento[] stickyPerspMems = stickyState
- .getChildren(IWorkbenchConstants.TAG_PERSPECTIVE);
- for (int i = 0; i < stickyPerspMems.length; i++) {
- String perspectiveId = stickyPerspMems[i].getID();
- Set viewState = new HashSet(7);
- stickyPerspectives.put(perspectiveId, viewState);
- IMemento[] viewStateMementos = stickyPerspMems[i]
- .getChildren(IWorkbenchConstants.TAG_VIEW);
- for (int j = 0; j < viewStateMementos.length; j++) {
- viewState.add(viewStateMementos[j].getID());
- }
- }
- }
- }
-}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/ViewFactory.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/ViewFactory.java
deleted file mode 100644
index b55a4e5e6a7..00000000000
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/ViewFactory.java
+++ /dev/null
@@ -1,425 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2009 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
- * Markus Alexander Kuppe, Versant Corporation - bug #215797
- * Sascha Zak - bug 282874
- *******************************************************************************/
-package org.eclipse.ui.internal;
-
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.core.runtime.IExtension;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.MultiStatus;
-import org.eclipse.core.runtime.SafeRunner;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.dynamichelpers.IExtensionChangeHandler;
-import org.eclipse.core.runtime.dynamichelpers.IExtensionTracker;
-import org.eclipse.jface.util.SafeRunnable;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.ui.IMemento;
-import org.eclipse.ui.IViewPart;
-import org.eclipse.ui.IViewReference;
-import org.eclipse.ui.IWorkbenchPart3;
-import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.views.IViewDescriptor;
-import org.eclipse.ui.views.IViewRegistry;
-
-/**
- * The ViewFactory is used to control the creation and disposal of views.
- * It implements a reference counting strategy so that one view can be shared
- * by more than one client.
- */
-public class ViewFactory implements IExtensionChangeHandler {
-
- private ReferenceCounter counter;
-
- private HashMap mementoTable = new HashMap();
-
- WorkbenchPage page;
-
- IViewRegistry viewReg;
-
- /**
- * Separates a view's primary id from its secondary id in view key strings.
- */
- static final String ID_SEP = ":"; //$NON-NLS-1$
-
- /**
- * Returns a string representing a view with the given id and (optional) secondary id,
- * suitable for use as a key in a map.
- *
- * @param id primary id of the view
- * @param secondaryId secondary id of the view or <code>null</code>
- * @return the key
- */
- static String getKey(String id, String secondaryId) {
- return secondaryId == null ? id : id + ID_SEP + secondaryId;
- }
-
- /**
- * Returns a string representing the given view reference, suitable for use as a key in a map.
- *
- * @param viewRef the view reference
- * @return the key
- */
- static String getKey(IViewReference viewRef) {
- return getKey(viewRef.getId(), viewRef.getSecondaryId());
- }
-
- /**
- * Extracts ths primary id portion of a compound id.
- * @param compoundId a compound id of the form: primaryId [':' secondaryId]
- * @return the primary id
- */
- static String extractPrimaryId(String compoundId) {
- int i = compoundId.lastIndexOf(ID_SEP);
- if (i == -1) {
- return compoundId;
- }
- return compoundId.substring(0, i);
- }
-
- /**
- * Extracts ths secondary id portion of a compound id.
- * @param compoundId a compound id of the form: primaryId [':' secondaryId]
- * @return the secondary id, or <code>null</code> if none
- */
- static String extractSecondaryId(String compoundId) {
- int i = compoundId.lastIndexOf(ID_SEP);
- if (i == -1) {
- return null;
- }
- return compoundId.substring(i + 1);
- }
-
- /**
- * Returns whether the given view id contains a wildcard. Wildcards cannot
- * be used in regular view ids, only placeholders.
- *
- * @param viewId the view id
- * @return <code>true</code> if the given view id contains a wildcard,
- * <code>false</code> otherwise
- *
- * @since 3.1
- */
- static boolean hasWildcard(String viewId) {
- return viewId.indexOf(PartPlaceholder.WILD_CARD) >= 0;
- }
-
- /**
- * Constructs a new view factory.
- */
- public ViewFactory(WorkbenchPage page, IViewRegistry reg) {
- super();
- this.page = page;
- this.viewReg = reg;
- counter = new ReferenceCounter();
- page.getExtensionTracker().registerHandler(this, null);
- }
-
- /**
- * Creates an instance of a view defined by id.
- *
- * This factory implements reference counting. The first call to this
- * method will return a new view. Subsequent calls will return the
- * first view with an additional reference count. The view is
- * disposed when releaseView is called an equal number of times
- * to getView.
- */
- public IViewReference createView(final String id) throws PartInitException {
- return createView(id, null);
- }
-
- /**
- * Creates an instance of a view defined by id and secondary id.
- *
- * This factory implements reference counting. The first call to this
- * method will return a new view. Subsequent calls will return the
- * first view with an additional reference count. The view is
- * disposed when releaseView is called an equal number of times
- * to createView.
- */
- public IViewReference createView(String id, String secondaryId)
- throws PartInitException {
- IViewDescriptor desc = viewReg.find(id);
- // ensure that the view id is valid
- if (desc == null) {
- throw new PartInitException(NLS.bind(WorkbenchMessages.ViewFactory_couldNotCreate, id ));
- }
- // ensure that multiple instances are allowed if a secondary id is given
- if (secondaryId != null) {
- if (!desc.getAllowMultiple()) {
- throw new PartInitException(NLS.bind(WorkbenchMessages.ViewFactory_noMultiple, id));
- }
- }
- String key = getKey(id, secondaryId);
- IViewReference ref = (IViewReference) counter.get(key);
- if (ref == null) {
- IMemento memento = (IMemento) mementoTable.get(key);
- ref = new ViewReference(this, id, secondaryId, memento);
- mementoTable.remove(key);
- counter.put(key, ref);
- getWorkbenchPage().partAdded((ViewReference)ref);
- } else {
- counter.addRef(key);
- }
- return ref;
- }
-
- /**
- * Returns the set of views being managed by this factory
- *
- * @return the set of views being managed by this factory
- */
- public IViewReference[] getViewReferences() {
- List values = counter.values();
-
- return (IViewReference[]) values.toArray(new IViewReference[values.size()]);
- }
-
- /**
- * Returns the view with the given id, or <code>null</code> if not found.
- */
- public IViewReference getView(String id) {
- return getView(id, null);
- }
-
- /**
- * Returns the view with the given id and secondary id, or <code>null</code> if not found.
- */
- public IViewReference getView(String id, String secondaryId) {
- String key = getKey(id, secondaryId);
- return (IViewReference) counter.get(key);
- }
-
- /**
- * @return the <code>IViewRegistry</code> used by this factory.
- * @since 3.0
- */
- public IViewRegistry getViewRegistry() {
- return viewReg;
- }
-
- /**
- * Returns a list of views which are open.
- */
- public IViewReference[] getViews() {
- List list = counter.values();
- IViewReference[] array = new IViewReference[list.size()];
- list.toArray(array);
- return array;
- }
-
- /**
- * @return the <code>WorkbenchPage</code> used by this factory.
- * @since 3.0
- */
- public WorkbenchPage getWorkbenchPage() {
- return page;
- }
-
- /**
- *
- * @param viewRef
- * @return the current reference count for the given view
- */
- public int getReferenceCount(IViewReference viewRef) {
- String key = getKey(viewRef);
- IViewReference ref = (IViewReference) counter.get(key);
- return ref==null ? 0 : counter.getRef(key);
- }
-
- /**
- * Releases an instance of a view.
- *
- * This factory does reference counting. For more info see
- * getView.
- */
- public void releaseView(IViewReference viewRef) {
- String key = getKey(viewRef);
- IViewReference ref = (IViewReference) counter.get(key);
- if (ref == null) {
- return;
- }
- int count = counter.removeRef(key);
- if (count <= 0) {
- getWorkbenchPage().partRemoved((ViewReference)ref);
- }
- }
-
- /**
- * Restore view states.
- *
- * @param memento the <code>IMemento</code> to restore from.
- * @return <code>IStatus</code>
- */
- public IStatus restoreState(IMemento memento) {
- IMemento mem[] = memento.getChildren(IWorkbenchConstants.TAG_VIEW);
- for (int i = 0; i < mem.length; i++) {
- //for dynamic UI - add the next line to replace subsequent code that is commented out
- restoreViewState(mem[i]);
- }
- return Status.OK_STATUS;
- }
-
- /**
- * Save view states.
- *
- * @param memento the <code>IMemento</code> to save to.
- * @return <code>IStatus</code>
- */
- public IStatus saveState(IMemento memento) {
- final MultiStatus result = new MultiStatus(PlatformUI.PLUGIN_ID,
- IStatus.OK, WorkbenchMessages.ViewFactory_problemsSavingViews, null);
-
- final IViewReference refs[] = getViews();
- for (int i = 0; i < refs.length; i++) {
- IViewDescriptor desc = viewReg.find(refs[i].getId());
- if (desc != null && desc.isRestorable()) {
- //for dynamic UI - add the following line to replace subsequent code which is commented out
- saveViewState(memento, refs[i], result);
- }
- }
- return result;
- }
-
- // for dynamic UI
- public IMemento saveViewState(IMemento memento, IViewReference ref,
- MultiStatus res) {
- final MultiStatus result = res;
- final IMemento viewMemento = memento
- .createChild(IWorkbenchConstants.TAG_VIEW);
- viewMemento.putString(IWorkbenchConstants.TAG_ID, ViewFactory
- .getKey(ref));
- if (ref instanceof ViewReference) {
- viewMemento.putString(IWorkbenchConstants.TAG_PART_NAME,
- ((ViewReference) ref).getPartName());
- }
- final IViewReference viewRef = ref;
- final IViewPart view = (IViewPart) ref.getPart(false);
- if (view != null) {
- SafeRunner.run(new SafeRunnable() {
- public void run() {
- if (view instanceof IWorkbenchPart3) {
- Map properties = ((IWorkbenchPart3) view)
- .getPartProperties();
- if (!properties.isEmpty()) {
- IMemento propBag = viewMemento
- .createChild(IWorkbenchConstants.TAG_PROPERTIES);
- Iterator i = properties.entrySet().iterator();
- while (i.hasNext()) {
- Map.Entry entry = (Map.Entry) i.next();
- IMemento p = propBag.createChild(
- IWorkbenchConstants.TAG_PROPERTY,
- (String) entry.getKey());
- p.putTextData((String) entry.getValue());
- }
- }
- }
- view.saveState(viewMemento
- .createChild(IWorkbenchConstants.TAG_VIEW_STATE));
- }
-
- public void handleException(Throwable e) {
- result
- .add(new Status(
- IStatus.ERROR,
- PlatformUI.PLUGIN_ID,
- 0,
- NLS.bind(WorkbenchMessages.ViewFactory_couldNotSave, viewRef.getTitle() ),
- e));
- }
- });
- } else {
- IMemento mem = null;
- IMemento props = null;
-
- // if we've created the reference once, any previous workbench
- // state memento is there. After once, there is no previous
- // session state, so it should be null.
- if (ref instanceof ViewReference) {
- mem = ((ViewReference) ref).getMemento();
- if (mem!=null) {
- props = mem.getChild(IWorkbenchConstants.TAG_PROPERTIES);
- }
- if (mem!=null) {
- mem = mem.getChild(IWorkbenchConstants.TAG_VIEW_STATE);
- }
- }
- if (props != null) {
- viewMemento.createChild(IWorkbenchConstants.TAG_PROPERTIES)
- .putMemento(props);
- }
- if (mem != null) {
- IMemento child = viewMemento
- .createChild(IWorkbenchConstants.TAG_VIEW_STATE);
- child.putMemento(mem);
- }
- }
- return viewMemento;
- }
-
- // for dynamic UI
- public void restoreViewState(IMemento memento) {
- String compoundId = memento.getString(IWorkbenchConstants.TAG_ID);
- mementoTable.put(compoundId, memento);
- }
-
- IMemento getViewState(String key) {
- IMemento memento = (IMemento) mementoTable.get(key);
-
- if (memento == null) {
- return null;
- }
-
- return memento.getChild(IWorkbenchConstants.TAG_VIEW_STATE);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.core.runtime.dynamicHelpers.IExtensionChangeHandler#removeExtension(org.eclipse.core.runtime.IExtension, java.lang.Object[])
- */
- public void removeExtension(IExtension source, Object[] objects) {
- for (int i = 0; i < objects.length; i++) {
- if (objects[i] instanceof IViewPart) {
- IViewPart part = (IViewPart) objects[i];
- // String primaryViewId = part.getViewSite().getId();
- // String secondaryViewId = part.getViewSite().getSecondaryId();
- // IViewReference viewRef = page.findViewReference(
- // primaryViewId, secondaryViewId);
- // IPerspectiveDescriptor[] descs =
- // page.getOpenedPerspectives();
- // Perspective active = page.getActivePerspective();
- // for (int i = 0; i < descs.length; i++) {
- // Perspective nextPerspective = page.findPerspective(descs[i]);
- //
- // if (nextPerspective == null || active == nextPerspective)
- // continue;
- //
- // page.hideView(nextPerspective, viewRef);
- // }
- page.hideView(part);
- }
-
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.core.runtime.dynamicHelpers.IExtensionChangeHandler#addExtension(org.eclipse.core.runtime.dynamicHelpers.IExtensionTracker, org.eclipse.core.runtime.IExtension)
- */
- public void addExtension(IExtensionTracker tracker,IExtension extension) {
- //Do nothing
- }
-
-}
-
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/ViewLayout.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/ViewLayout.java
deleted file mode 100644
index 676fb6f54a6..00000000000
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/ViewLayout.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 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.core.runtime.Assert;
-import org.eclipse.ui.IViewLayout;
-
-/**
- * Implementation of IViewLayout.
- * This is an API facade on the internal ViewLayoutRec.
- *
- * @since 3.0
- */
-public class ViewLayout implements IViewLayout {
- private ViewLayoutRec rec;
-
- public ViewLayout(PageLayout pageLayout, ViewLayoutRec rec) {
- Assert.isNotNull(pageLayout);
- Assert.isNotNull(rec);
- this.rec = rec;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.IViewLayout#getShowTitle()
- */
- public boolean getShowTitle() {
- return rec.showTitle;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.IViewLayout#isCloseable()
- */
- public boolean isCloseable() {
- return rec.isCloseable;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.IViewLayout#isMoveable()
- */
- public boolean isMoveable() {
- return rec.isMoveable;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.IViewLayout#isStandalone()
- */
- public boolean isStandalone() {
- return rec.isStandalone;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.IViewLayout#setCloseable(boolean)
- */
- public void setCloseable(boolean closeable) {
- rec.isCloseable = closeable;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.IViewLayout#setMoveable(boolean)
- */
- public void setMoveable(boolean moveable) {
- rec.isMoveable = moveable;
- }
-
-}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/ViewLayoutRec.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/ViewLayoutRec.java
deleted file mode 100644
index 7b0aa773015..00000000000
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/ViewLayoutRec.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 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
- * Dan Rubel <dan_rubel@instantiations.com>
- * - Fix for bug 11490 - define hidden view (placeholder for view) in plugin.xml
- *******************************************************************************/
-package org.eclipse.ui.internal;
-
-import org.eclipse.ui.IPageLayout;
-
-/**
- * Encapsulates the perspective layout information for a view.
- *
- * @since 3.0
- */
-public class ViewLayoutRec {
- boolean isCloseable = true;
-
- boolean isMoveable = true;
-
- boolean isStandalone = false;
-
- boolean showTitle = true;
-
- float fastViewWidthRatio = IPageLayout.INVALID_RATIO;
-}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/ViewPane.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/ViewPane.java
deleted file mode 100644
index 99f88c2b440..00000000000
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/ViewPane.java
+++ /dev/null
@@ -1,639 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2011 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
- * Cagatay Kavukcuoglu <cagatayk@acm.org>
- * - Fix for bug 10025 - Resizing views should not use height ratios
- *******************************************************************************/
-package org.eclipse.ui.internal;
-
-
-import org.eclipse.jface.action.IContributionItem;
-import org.eclipse.jface.action.MenuManager;
-import org.eclipse.jface.internal.provisional.action.IToolBarManager2;
-import org.eclipse.jface.util.IPropertyChangeListener;
-import org.eclipse.jface.util.PropertyChangeEvent;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.MouseAdapter;
-import org.eclipse.swt.events.MouseEvent;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Menu;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.ToolBar;
-import org.eclipse.ui.IViewReference;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.internal.dnd.DragUtil;
-import org.eclipse.ui.internal.provisional.presentations.IActionBarPresentationFactory;
-import org.eclipse.ui.presentations.IPresentablePart;
-import org.eclipse.ui.presentations.StackPresentation;
-
-/**
- * Provides a wrapper for the view's widgetry.
- *
- * TODO: Delete ViewPane and EditorPane, and make PartPane non-abstract.
- */
-public class ViewPane extends PartPane {
-
- // create initially toolbarless bar manager so that actions may be added in the
- // init method of the view.
- private IToolBarManager2 isvToolBarMgr = null;
-
- private MenuManager isvMenuMgr;
-
- boolean hasFocus;
-
- /**
- * Indicates whether a toolbar button is shown for the view local menu.
- */
- private boolean hadViewMenu = false;
-
- /**
- * Toolbar manager for the ISV toolbar.
- */
- private class ISVPropListener implements IPropertyChangeListener {
- private Control toolBar;
-
- /**
- * Constructor
- * @param toolBar
- */
- public ISVPropListener (Control toolBar) {
- this.toolBar = toolBar;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent)
- */
- public void propertyChange(PropertyChangeEvent event) {
- String property = event.getProperty();
- Integer newValue = (Integer)event.getNewValue();
- if (IToolBarManager2.PROP_LAYOUT.equals(property)) {
- toolBarResized(toolBar, newValue != null ? newValue.intValue() : 0);
- if (toolBar instanceof Composite) {
- ((Composite)toolBar).layout();
- } else {
- toolBar.getParent().layout();
- }
- }
- }
- }
-
- /**
- * Menu manager for view local menu.
- */
- class PaneMenuManager extends MenuManager {
- public PaneMenuManager() {
- super("View Local Menu"); //$NON-NLS-1$
- }
-
- protected void update(boolean force, boolean recursive) {
- super.update(force, recursive);
-
- boolean hasMenu = false;
- IContributionItem[] items = getItems();
- for (int i = 0; i < items.length; i++) {
- if (items[i].isVisible() && !items[i].isSeparator() && !items[i].isGroupMarker()) {
- // only show the menu if we have visible items that aren't separators or group markers
- hasMenu = true;
- break;
- }
- }
-
- if (hasMenu != hadViewMenu) {
- hadViewMenu = hasMenu;
- firePropertyChange(IPresentablePart.PROP_PANE_MENU);
- }
- }
- }
-
- /**
- * Constructs a view pane for a view part.
- */
- public ViewPane(IViewReference ref, WorkbenchPage page) {
- super(ref, page);
- IActionBarPresentationFactory actionBarPresentation = ((WorkbenchWindow) page
- .getWorkbenchWindow()).getActionBarPresentationFactory();
-
- isvToolBarMgr = actionBarPresentation.createViewToolBarManager();
- }
-
- /**
- * Create control. Add the title bar.
- */
- public void createControl(Composite parent) {
- // Only do this once.
- if (getControl() != null && !getControl().isDisposed()) {
- return;
- }
-
- super.createControl(parent);
- }
-
- /**
- * Create a title bar for the pane.
- * - the view icon and title to the far left
- * - the view toolbar appears in the middle.
- * - the view pulldown menu, pin button, and close button to the far right.
- */
- protected void createTitleBar() {
- // Only do this once.
-
- updateTitles();
-
- // Listen to title changes.
- getPartReference().addPropertyListener(this);
-
- createToolBars();
-
- }
-
- private void toolBarResized(Control toolBar, int newSize) {
-
- Control toolbar = isvToolBarMgr.getControl2();
- if (toolbar != null) {
- Control ctrl = getControl();
-
- boolean visible = ctrl != null && ctrl.isVisible()
- && toolbarIsVisible();
-
- if (toolbar.isVisible() != visible)
- toolbar.setVisible(visible);
- }
-
- firePropertyChange(IPresentablePart.PROP_TOOLBAR);
- }
-
- /**
- *
- */
- private void createToolBars() {
- Composite parentControl = control;
-
- // ISV toolbar.
- // // 1GD0ISU: ITPUI:ALL - Dbl click on view tool cause zoom
- final Control isvToolBar = isvToolBarMgr.createControl2(parentControl.getParent());
- isvToolBar.setVisible(false);
-
- isvToolBarMgr.addPropertyChangeListener(new ISVPropListener(isvToolBar));
-
- isvToolBar.addMouseListener(new MouseAdapter() {
- public void mouseDoubleClick(MouseEvent event) {
- if (event.widget instanceof ToolBar) {
-
- if (((ToolBar)event.widget).getItem(new Point(event.x, event.y)) == null) {
- doZoom();
- }
- }
- }
- });
-
-
- isvToolBar.addListener(SWT.Activate, this);
- isvToolBar.moveAbove(control);
- }
-
- public void dispose() {
- super.dispose();
-
- /* Bug 42684. The ViewPane instance has been disposed, but an attempt is
- * then made to remove focus from it. This happens because the ViewPane is
- * still viewed as the active part. In general, when disposed, the control
- * containing the titleLabel will also disappear (disposing of the
- * titleLabel). As a result, the reference to titleLabel should be dropped.
- */
- if (isvMenuMgr != null) {
- isvMenuMgr.dispose();
- }
- if (isvToolBarMgr != null) {
- isvToolBarMgr.dispose();
- }
- }
-
- /**
- * @see PartPane#doHide
- */
- public void doHide() {
- getPage().hideView(getViewReference());
- }
-
- /*package*/Rectangle getParentBounds() {
- Control ctrl = getControl();
-
- if (getContainer() != null && getContainer() instanceof LayoutPart) {
- LayoutPart part = (LayoutPart) getContainer();
-
- if (part.getControl() != null) {
- ctrl = part.getControl();
- }
- }
-
- return DragUtil.getDisplayBounds(ctrl);
- }
-
- /**
- * Make this view pane a fast view
- */
- public void doMakeFast() {
- WorkbenchWindow window = (WorkbenchWindow) getPage()
- .getWorkbenchWindow();
-
- FastViewBar fastViewBar = window.getFastViewBar();
- if (fastViewBar == null || getPage().getActivePerspective() == null)
- return;
-
- Shell shell = window.getShell();
-
- // Animate the operation
- AnimationEngine.createTweakedAnimation(shell, 400, getParentBounds(),
- fastViewBar.getLocationOfNextIcon());
-
- FastViewManager fvm = getPage().getActivePerspective().getFastViewManager();
- fvm.addViewReference(FastViewBar.FASTVIEWBAR_ID, -1, getViewReference(), true);
- }
-
- public void doRemoveFast() {
- if (getPage().getActivePerspective() == null)
- return;
-
- Shell shell = getControl().getShell();
-
- Rectangle initialBounds = getParentBounds();
-
- FastViewManager fvm = getPage().getActivePerspective().getFastViewManager();
- fvm.removeViewReference(getViewReference(), true, true);
-
- IWorkbenchPart toActivate = getViewReference().getPart(true);
- if (toActivate != null) {
- getPage().activate(toActivate);
- }
-
- Rectangle finalBounds = getParentBounds();
-
- // Animate the operation
- AnimationEngine.createTweakedAnimation(shell, 400, initialBounds, finalBounds);
- }
-
- /**
- * Pin the view.
- */
- protected void doDock() {
- Perspective persp = getPage().getActivePerspective();
- if (persp != null) {
- persp.getFastViewManager().removeViewReference(getViewReference(), true, true);
- }
- }
-
- public void doDetach() {
- getPage().detachView(getViewReference());
- }
-
- public void doAttach() {
- getPage().attachView(getViewReference());
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.internal.LayoutPart#getCompoundId()
- */
- public String getCompoundId() {
- IViewReference ref = getViewReference();
- if (ref != null) {
- return ViewFactory.getKey(ref);
- }
-
- return super.getCompoundId();
- }
-
- /**
- * Returns the drag control.
- */
- public Control getDragHandle() {
- return control;
- }
-
- /**
- * @see ViewActionBars
- */
- public MenuManager getMenuManager() {
- if (isvMenuMgr == null) {
- isvMenuMgr = new PaneMenuManager();
- }
- return isvMenuMgr;
- }
-
- /**
- * Returns the tab list to use when this part is active.
- * Includes the view and its tab (if applicable), in the appropriate order.
- */
- public Control[] getTabList() {
- Control c = getControl();
- if (getContainer() instanceof ViewStack) {
- ViewStack tf = (ViewStack) getContainer();
- return tf.getTabList(this);
- }
- return new Control[] { c };
- }
-
- /**
- * @see ViewActionBars
- */
- public IToolBarManager2 getToolBarManager() {
- return isvToolBarMgr;
- }
-
- /**
- * Answer the view part child.
- */
- public IViewReference getViewReference() {
- return (IViewReference) getPartReference();
- }
-
- /**
- * Sets the fast view state. If this view is a fast view then
- * various controls like pin and minimize are added to the
- * system bar.
- */
- public void setFast(boolean b) {
- }
-
- /* (non-Javadoc)
- * Method declared on PartPane.
- */
- /* package */
- void shellActivated() {
- }
-
- /* (non-Javadoc)
- * Method declared on PartPane.
- */
- /* package */
- void shellDeactivated() {
- }
-
- /**
- * Set the active border.
- * @param active
- */
- void setActive(boolean active) {
- hasFocus = active;
-
- if (getContainer() instanceof PartStack) {
- ((PartStack) getContainer())
- .setActive(active ? StackPresentation.AS_ACTIVE_FOCUS
- : StackPresentation.AS_INACTIVE);
- }
- }
-
- /**
- * Indicate focus in part.
- */
- public void showFocus(boolean inFocus) {
- setActive(inFocus);
- }
-
- /**
- * Return true if this view is a fast view.
- */
- private boolean isFastView() {
- return page.isFastView(getViewReference());
- }
-
- /**
- * Return true if the view may be moved.
- */
- boolean isMoveable() {
- return !page.isFixedLayout();
- }
-
- /**
- * Returns whether there should be a view menu or not. There should not be a
- * view menu if there is no menu manager or the manager itself has no
- * visible items that are not separators or group markers.
- */
- public boolean hasViewMenu() {
- return isvMenuMgr != null && hadViewMenu;
- }
-
- public void showViewMenu(Point location) {
- if (!hasViewMenu()) {
- return;
- }
-
- // If this is a fast view, it may have been minimized. Do nothing in this case.
- if (isFastView() && (page.getActiveFastView() != getViewReference())) {
- return;
- }
-
- Menu aMenu = isvMenuMgr.createContextMenu(getControl().getParent());
- aMenu.setLocation(location.x, location.y);
- aMenu.setVisible(true);
- }
-
- public String toString() {
-
- return getClass().getName() + "@" + Integer.toHexString(hashCode()); //$NON-NLS-1$
- }
-
- /**
- * @see ViewActionBars
- */
- public void updateActionBars() {
- if (isvMenuMgr != null) {
- isvMenuMgr.update(false);
- }
- if (isvToolBarMgr != null) {
- isvToolBarMgr.update(false);
- }
-
- }
-
- /**
- * Update the title attributes.
- */
- public void updateTitles() {
- firePropertyChange(IPresentablePart.PROP_TITLE);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.internal.PartPane#addSizeMenuItem(org.eclipse.swt.widgets.Menu)
- */
- public void addSizeMenuItem(Menu menu, int index) {
- if (isMoveable()) {
- super.addSizeMenuItem(menu, index);
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.internal.PartPane#doZoom()
- */
- protected void doZoom() {
- if (isMoveable()) {
- super.doZoom();
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.internal.LayoutPart#setContainer(org.eclipse.ui.internal.ILayoutContainer)
- */
- public void setContainer(ILayoutContainer container) {
- ILayoutContainer oldContainer = getContainer();
- if (hasFocus) {
- if (oldContainer != null && oldContainer instanceof PartStack) {
- ((PartStack) oldContainer)
- .setActive(StackPresentation.AS_INACTIVE);
- }
-
- if (container != null && container instanceof PartStack) {
- ((PartStack) container)
- .setActive(StackPresentation.AS_ACTIVE_FOCUS);
- }
- }
-
- super.setContainer(container);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.internal.LayoutPart#reparent(org.eclipse.swt.widgets.Composite)
- */
- public void reparent(Composite newParent) {
- super.reparent(newParent);
-
- if (isvToolBarMgr != null) {
- Control bar = isvToolBarMgr.getControl2();
- if (bar != null) {
- bar.setParent(newParent);
- bar.moveAbove(control);
- }
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.internal.LayoutPart#moveAbove(org.eclipse.swt.widgets.Control)
- */
- public void moveAbove(Control refControl) {
- super.moveAbove(refControl);
-
- Control toolbar = internalGetToolbar();
-
- if (toolbar != null) {
- toolbar.moveAbove(control);
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.internal.LayoutPart#setVisible(boolean)
- */
- public void setVisible(boolean makeVisible) {
- super.setVisible(makeVisible);
-
- Control toolbar = internalGetToolbar();
-
- if (toolbar != null) {
- boolean visible = makeVisible && toolbarIsVisible();
- toolbar.setVisible(visible);
- }
- }
-
- public boolean toolbarIsVisible() {
- IToolBarManager2 toolbarManager = getToolBarManager();
-
- if (toolbarManager == null) {
- return false;
- }
-
- Control control = toolbarManager.getControl2();
-
- if (control == null || control.isDisposed()) {
- return false;
- }
-
- return toolbarManager.getItemCount() > 0;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.internal.PartPane#showHighlight()
- */
- public void showHighlight() {
- firePropertyChange(IPresentablePart.PROP_HIGHLIGHT_IF_BACK);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.internal.LayoutPart#getPlaceHolderId()
- */
- public String getPlaceHolderId() {
- return ViewFactory.getKey(getViewReference());
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.internal.PartPane#getToolBar()
- */
- public Control getToolBar() {
-
- if (!toolbarIsVisible()) {
- return null;
- }
-
- return internalGetToolbar();
- }
-
- private Control internalGetToolbar() {
- if (isvToolBarMgr == null) {
- return null;
- }
-
- return isvToolBarMgr.getControl2();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.internal.PartPane#isCloseable()
- */
- public boolean isCloseable() {
- Perspective perspective = page.getActivePerspective();
- if (perspective == null) {
- // Shouldn't happen -- can't have a ViewStack without a
- // perspective
- return true;
- }
- return perspective.isCloseable(getViewReference());
- }
-
- public void showSystemMenu() {
- if (isFastView()) {
- Perspective perspective = page.getActivePerspective();
- if (perspective != null) {
- perspective.getFastViewPane().showSystemMenu();
- }
- } else {
- super.showSystemMenu();
- }
- }
-
- public void showPaneMenu() {
- if (isFastView()) {
- Perspective perspective = page.getActivePerspective();
- if (perspective != null) {
- perspective.getFastViewPane().showPaneMenu();
- }
- } else {
- super.showPaneMenu();
- }
- }
-
- public void removeContributions() {
- super.removeContributions();
-
- if (isvMenuMgr != null) {
- isvMenuMgr.removeAll();
- }
- if (isvToolBarMgr != null) {
- isvToolBarMgr.removeAll();
- }
- }
-}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/ViewSashContainer.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/ViewSashContainer.java
deleted file mode 100644
index f4e31cf4635..00000000000
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/ViewSashContainer.java
+++ /dev/null
@@ -1,318 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 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.HashMap;
-import java.util.Map;
-
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.MultiStatus;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.ui.IMemento;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.internal.StartupThreading.StartupRunnable;
-
-/**
- * Represents the top level container.
- */
-public class ViewSashContainer extends PartSashContainer {
- public ViewSashContainer(WorkbenchPage page, Composite parent) {
- super("root layout container", page, parent);//$NON-NLS-1$
- }
-
- /**
- * Gets root container for this part.
- */
- public ViewSashContainer getRootContainer() {
- return this;
- }
-
- /**
- * Subclasses override this method to specify
- * the composite to use to parent all children
- * layout parts it contains.
- */
- protected Composite createParent(Composite parentWidget) {
- return parentWidget;
- }
-
- /**
- * Subclasses override this method to dispose
- * of any swt resources created during createParent.
- */
- protected void disposeParent() {
- // do nothing
- }
-
- /**
- * Get the part control. This method may return null.
- */
- public Control getControl() {
- return this.parent;
- }
-
- /**
- * @see IPersistablePart
- */
- public IStatus restoreState(IMemento memento) {
- MultiStatus result = new MultiStatus(
- PlatformUI.PLUGIN_ID,
- IStatus.OK,
- WorkbenchMessages.RootLayoutContainer_problemsRestoringPerspective, null);
-
- // Read the info elements.
- IMemento[] children = memento.getChildren(IWorkbenchConstants.TAG_INFO);
-
- // Create a part ID to part hashtable.
- final Map mapIDtoPart = new HashMap(children.length);
-
- // Loop through the info elements.
- for (int i = 0; i < children.length; i++) {
- // Get the info details.
- IMemento childMem = children[i];
- String partID = childMem.getString(IWorkbenchConstants.TAG_PART);
- final String relativeID = childMem
- .getString(IWorkbenchConstants.TAG_RELATIVE);
- int relationship = 0;
- float ratio = 0.0f;
- int left = 0, right = 0;
- if (relativeID != null) {
- relationship = childMem.getInteger(
- IWorkbenchConstants.TAG_RELATIONSHIP).intValue();
-
- // Note: the ratio is used for reading pre-3.0 eclipse workspaces. It should be ignored
- // if "left" and "right" are available.
- Float ratioFloat = childMem
- .getFloat(IWorkbenchConstants.TAG_RATIO);
- Integer leftInt = childMem
- .getInteger(IWorkbenchConstants.TAG_RATIO_LEFT);
- Integer rightInt = childMem
- .getInteger(IWorkbenchConstants.TAG_RATIO_RIGHT);
- if (leftInt != null && rightInt != null) {
- left = leftInt.intValue();
- right = rightInt.intValue();
- } else {
- if (ratioFloat != null) {
- ratio = ratioFloat.floatValue();
- }
- }
- }
- String strFolder = childMem
- .getString(IWorkbenchConstants.TAG_FOLDER);
-
- // Create the part.
- LayoutPart part = null;
- if (strFolder == null) {
- part = new PartPlaceholder(partID);
- } else {
- ViewStack folder = new ViewStack(page);
- folder.setID(partID);
- result.add(folder.restoreState(childMem
- .getChild(IWorkbenchConstants.TAG_FOLDER)));
- ContainerPlaceholder placeholder = new ContainerPlaceholder(
- partID);
- placeholder.setRealContainer(folder);
- part = placeholder;
- }
- // 1FUN70C: ITPUI:WIN - Shouldn't set Container when not active
- part.setContainer(this);
-
- final int myLeft = left, myRight= right, myRelationship = relationship;
- final float myRatio = ratio;
- final LayoutPart myPart = part;
-
- StartupThreading.runWithoutExceptions(new StartupRunnable() {
-
- public void runWithException() throws Throwable {
- // Add the part to the layout
- if (relativeID == null) {
- add(myPart);
- } else {
- LayoutPart refPart = (LayoutPart) mapIDtoPart.get(relativeID);
- if (refPart != null) {
- if (myLeft != 0) {
- add(myPart, myRelationship, myLeft, myRight, refPart);
- } else {
- add(myPart, myRelationship, myRatio, refPart);
- }
- } else {
- WorkbenchPlugin
- .log("Unable to find part for ID: " + relativeID);//$NON-NLS-1$
- }
- }
- }});
-
- mapIDtoPart.put(partID, part);
- }
- return result;
- }
-
- /**
- * @see IPersistablePart
- */
- public IStatus saveState(IMemento memento) {
- RelationshipInfo[] relationships = computeRelation();
-
- MultiStatus result = new MultiStatus(
- PlatformUI.PLUGIN_ID,
- IStatus.OK,
- WorkbenchMessages.RootLayoutContainer_problemsSavingPerspective, null);
-
- // Loop through the relationship array.
- for (int i = 0; i < relationships.length; i++) {
- // Save the relationship info ..
- // private LayoutPart part;
- // private int relationship;
- // private float ratio;
- // private LayoutPart relative;
- RelationshipInfo info = relationships[i];
- IMemento childMem = memento
- .createChild(IWorkbenchConstants.TAG_INFO);
- childMem.putString(IWorkbenchConstants.TAG_PART, info.part.getID());
- if (info.relative != null) {
- childMem.putString(IWorkbenchConstants.TAG_RELATIVE,
- info.relative.getID());
- childMem.putInteger(IWorkbenchConstants.TAG_RELATIONSHIP,
- info.relationship);
- childMem.putInteger(IWorkbenchConstants.TAG_RATIO_LEFT,
- info.left);
- childMem.putInteger(IWorkbenchConstants.TAG_RATIO_RIGHT,
- info.right);
-
- // The ratio is only needed for saving workspaces that can be read by old versions
- // of Eclipse. It is not used in newer versions of Eclipse, which use the "left"
- // and "right" attributes instead.
- childMem.putFloat(IWorkbenchConstants.TAG_RATIO, info
- .getRatio());
- }
-
- // Is this part a folder or a placeholder for one?
- ViewStack folder = null;
- if (info.part instanceof ViewStack) {
- folder = (ViewStack) info.part;
- } else if (info.part instanceof ContainerPlaceholder) {
- LayoutPart part = ((ContainerPlaceholder) info.part)
- .getRealContainer();
- if (part instanceof ViewStack) {
- folder = (ViewStack) part;
- }
- }
-
- // 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));
- }
- }
- return result;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.internal.PartSashContainer#getDockingRatio(org.eclipse.ui.internal.LayoutPart, org.eclipse.ui.internal.LayoutPart)
- */
- protected float getDockingRatio(LayoutPart dragged, LayoutPart target) {
- if (isStackType(target)) {
- return super.getDockingRatio(dragged, target);
- } else {
- return 0.25f;
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.internal.PartSashContainer#isStackType(org.eclipse.ui.internal.LayoutPart)
- */
- public boolean isStackType(LayoutPart toTest) {
- return (toTest instanceof ViewStack);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.internal.PartSashContainer#isPaneType(org.eclipse.ui.internal.LayoutPart)
- */
- public boolean isPaneType(LayoutPart toTest) {
- return (toTest instanceof ViewPane);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.internal.PartSashContainer#createStack(org.eclipse.ui.internal.LayoutPart)
- */
- protected PartStack createStack() {
- ViewStack result = new ViewStack(page);
- return result;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.internal.PartSashContainer#setVisiblePart(org.eclipse.ui.internal.ILayoutContainer, org.eclipse.ui.internal.LayoutPart)
- */
- protected void setVisiblePart(ILayoutContainer container,
- LayoutPart visiblePart) {
- if (container instanceof ViewStack) {
- ViewStack tabFolder = (ViewStack) container;
-
- tabFolder.setSelection(visiblePart);
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.internal.PartSashContainer#getVisiblePart(org.eclipse.ui.internal.ILayoutContainer)
- */
- protected LayoutPart getVisiblePart(ILayoutContainer container) {
- return ((ViewStack) container).getSelection();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.internal.PartSashContainer#derefPart(org.eclipse.ui.internal.LayoutPart)
- */
- protected void derefPart(LayoutPart sourcePart) {
- page.getActivePerspective().getPresentation().derefPart(sourcePart);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.internal.PartSashContainer#addChild(org.eclipse.ui.internal.PartSashContainer.RelationshipInfo)
- */
- protected void addChild(RelationshipInfo info) {
- LayoutPart child = info.part;
-
- // Nasty hack: ensure that all views end up inside a tab folder.
- // Since the view title is provided by the tab folder, this ensures
- // that views don't get created without a title tab.
- if (child instanceof ViewPane) {
- ViewStack folder = new ViewStack(page);
- folder.add(child);
- info.part = folder;
- }
-
- super.addChild(info);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.internal.ILayoutContainer#replace(org.eclipse.ui.internal.LayoutPart, org.eclipse.ui.internal.LayoutPart)
- */
- public void replace(LayoutPart oldChild, LayoutPart newChild) {
- if (!isChild(oldChild)) {
- return;
- }
-
- // Nasty hack: ensure that all views end up inside a tab folder.
- // Since the view title is provided by the tab folder, this ensures
- // that views don't get created without a title tab.
- if (newChild instanceof ViewPane) {
- ViewStack folder = new ViewStack(page);
- folder.add(newChild);
- newChild = folder;
- }
-
- super.replace(oldChild, newChild);
- }
-}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/ViewStack.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/ViewStack.java
deleted file mode 100644
index a9ad8cf7a35..00000000000
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/ViewStack.java
+++ /dev/null
@@ -1,230 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2009 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
- * Cagatay Kavukcuoglu <cagatayk@acm.org>
- * - Fix for bug 10025 - Resizing views should not use height ratios
- * Carlos Devoto carlos.devoto@compuware.com Bug 213645
- *******************************************************************************/
-package org.eclipse.ui.internal;
-
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.ui.internal.presentations.PresentablePart;
-import org.eclipse.ui.internal.presentations.PresentationFactoryUtil;
-import org.eclipse.ui.internal.presentations.SystemMenuDetach;
-import org.eclipse.ui.internal.presentations.SystemMenuFastView;
-import org.eclipse.ui.internal.presentations.SystemMenuSize;
-import org.eclipse.ui.internal.presentations.UpdatingActionContributionItem;
-import org.eclipse.ui.presentations.AbstractPresentationFactory;
-import org.eclipse.ui.presentations.IPresentablePart;
-import org.eclipse.ui.presentations.IStackPresentationSite;
-import org.eclipse.ui.presentations.StackPresentation;
-
-/**
- * Manages a set of ViewPanes that are docked into the workbench window. The container for a ViewStack
- * is always a PartSashContainer (or null), and its children are always either PartPlaceholders or ViewPanes.
- * This contains the real behavior and state for stacks of views, although the widgets for the tabs are contributed
- * using a StackPresentation.
- *
- * TODO: eliminate ViewStack and EditorStack. PartStack should be general enough to handle editors
- * and views without any specialization for editors and views. The differences should be in the
- * presentation and in the PartPanes themselves.
- *
- * TODO: eliminate PartPlaceholder. Placeholders should not be children of the ViewStack.
- *
- */
-public class ViewStack extends PartStack {
-
- private boolean allowStateChanges;
-
- private WorkbenchPage page;
-
- private SystemMenuSize sizeItem = new SystemMenuSize(null);
-
- private SystemMenuFastView fastViewAction;
-
- private SystemMenuDetach detachViewAction;
-
- private boolean durable = false;
-
- public void addSystemActions(IMenuManager menuManager) {
- appendToGroupIfPossible(menuManager,
- "misc", new UpdatingActionContributionItem(fastViewAction)); //$NON-NLS-1$
- appendToGroupIfPossible(menuManager,
- "misc", new UpdatingActionContributionItem(detachViewAction)); //$NON-NLS-1$
- sizeItem = new SystemMenuSize(getSelection());
- appendToGroupIfPossible(menuManager, "size", sizeItem); //$NON-NLS-1$
- }
-
- public ViewStack(WorkbenchPage page) {
- this(page, true);
- }
-
- public ViewStack(WorkbenchPage page, boolean allowsStateChanges) {
- this(page, allowsStateChanges, PresentationFactoryUtil.ROLE_VIEW, null);
- }
-
- public ViewStack(WorkbenchPage page, boolean allowsStateChanges,
- int appearance, AbstractPresentationFactory factory) {
- super(appearance, factory);
-
- this.page = page;
- setID(this.toString());
- // Each folder has a unique ID so relative positioning is unambiguous.
-
- this.allowStateChanges = allowsStateChanges;
- fastViewAction = new SystemMenuFastView(getPresentationSite());
- detachViewAction = new SystemMenuDetach(getPresentationSite());
- }
-
- protected WorkbenchPage getPage() {
- return page;
- }
-
- protected boolean canMoveFolder() {
- Perspective perspective = page.getActivePerspective();
-
- if (perspective == null) {
- // Shouldn't happen -- can't have a ViewStack without a
- // perspective
- return false;
- }
-
- // We need to search if one of the presentations is not moveable
- // if that's the case the whole folder should not be moveable
- IStackPresentationSite presenationSite;
-
- if( (presenationSite = getPresentationSite()) != null ) {
- IPresentablePart[] parts = presenationSite.getPartList();
- for( int i = 0; i < parts.length; i++ ) {
- if( !presenationSite.isPartMoveable(parts[i]) ) {
- return false;
- }
- }
- }
-
- return !perspective.isFixedLayout();
- }
-
- protected void updateActions(PresentablePart current) {
- ViewPane pane = null;
-
- if (current != null && current.getPane() instanceof ViewPane) {
- pane = (ViewPane) current.getPane();
- }
-
- fastViewAction.setPane(current);
- detachViewAction.setPane(pane);
- sizeItem.setPane(pane);
- }
-
- /**
- * Sets the minimized state for this stack. The part may call this method to
- * minimize or restore itself. The minimized state only affects the view
- * when unzoomed.
- *
- * This implementation is specific to the 3.3 presentation's
- * min/max story; otherwise it just forwards the call.
- */
- public void setMinimized(boolean minimized) {
- // 'Smart' minimize; move the stack to the trim
- Perspective persp = getPage().getActivePerspective();
- if (Perspective.useNewMinMax(persp)) {
- FastViewManager fvm = persp.getFastViewManager();
- if (minimized) {
- // Need to temporarily set the durability attribute to false or we won't be able to minimized the folder
- boolean tempDurable = durable;
- durable = false;
- fvm.moveToTrim(this, false);
- // Restore the durability attribute to its previous value
- durable = tempDurable;
- } else {
- // First, if we're maximized then revert
- if (persp.getPresentation().getMaximizedStack() != null) {
- PartStack maxStack = persp.getPresentation().getMaximizedStack();
- if (maxStack != null) {
- maxStack.setState(IStackPresentationSite.STATE_RESTORED);
- }
- }
-
- fvm.restoreToPresentation(getID());
- }
- }
-
- super.setMinimized(minimized);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.internal.PartStack#isMoveable(org.eclipse.ui.presentations.IPresentablePart)
- */
- protected boolean isMoveable(IPresentablePart part) {
- ViewPane pane = (ViewPane) getPaneFor(part);
- Perspective perspective = page.getActivePerspective();
- if (perspective == null) {
- // Shouldn't happen -- can't have a ViewStack without a
- // perspective
- return true;
- }
- return perspective.isMoveable(pane.getViewReference());
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.internal.PartStack#supportsState(int)
- */
- protected boolean supportsState(int newState) {
- if (page.isFixedLayout()) {
- return false;
- }
- return allowStateChanges;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.internal.PartStack#derefPart(org.eclipse.ui.internal.LayoutPart)
- */
- protected void derefPart(LayoutPart toDeref) {
- page.getActivePerspective().getPresentation().derefPart(toDeref);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.internal.PartStack#allowsDrop(org.eclipse.ui.internal.PartPane)
- */
- protected boolean allowsDrop(PartPane part) {
- return part instanceof ViewPane;
- }
-
- /**
- * Get the presentation for testing purposes. This is for testing
- * purposes <b>ONLY</b>.
- *
- * @return the presentation in use for this view stack
- * @since 3.2
- */
- public StackPresentation getTestPresentation() {
- return getPresentation();
- }
-
- /**
- * Set the durability attribute for this stack. The stack's durability determines
- * whether or not the stack remains visible after its last child is closed.
- *
- * @param durable If true, the stack remains visible after its last child is closed
- */
- public void setDurable(boolean durable) {
- this.durable = durable;
- }
-
- /**
- * Get the durability attribute for this stack. The stack's durability determines
- * whether or not the stack remains visible after its last child is closed.
- *
- * @return true, if the stack remains visible when its last child is closed; false otherwise
- */
- public boolean getDurable () {
- return this.durable;
- }
-}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/ViewStackTrimToolBar.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/ViewStackTrimToolBar.java
deleted file mode 100644
index 21fb3893e32..00000000000
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/ViewStackTrimToolBar.java
+++ /dev/null
@@ -1,224 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 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.jface.action.ContributionItem;
-import org.eclipse.jface.action.IContributionItem;
-import org.eclipse.jface.action.IMenuListener;
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.jface.action.MenuManager;
-import org.eclipse.jface.action.ToolBarManager;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.widgets.Menu;
-import org.eclipse.swt.widgets.MenuItem;
-import org.eclipse.swt.widgets.ToolBar;
-import org.eclipse.swt.widgets.ToolItem;
-import org.eclipse.ui.IViewReference;
-import org.eclipse.ui.internal.layout.TrimToolBarBase;
-
-/**
- * @since 3.3
- *
- */
-public class ViewStackTrimToolBar extends TrimToolBarBase {
- private boolean restoreOnUnzoom = false;
-
- // The orientation of the fast view pane when showing a view
- private int paneOrientation;
-
- // The id of the part that was showing when we minimized
- private String selectedTabId;
-
- public ViewStackTrimToolBar(String id, int curSide, int paneOrientation, WorkbenchWindow wbw) {
- super(id, curSide, wbw);
-
- this.paneOrientation = paneOrientation;
- dock(curSide);
- }
-
- /**
- * Put the stack back into the presentation
- */
- protected void restoreToPresentation() {
- Perspective persp = wbw.getActiveWorkbenchPage().getActivePerspective();
- //FastViewManager fvMgr = persp.getFastViewManager();
-
- LayoutPart part = persp.getPresentation().findPart(getId(), null);
- if (part instanceof ContainerPlaceholder) {
- ViewStack stack = (ViewStack) ((ContainerPlaceholder)part).getRealContainer();
- stack.setMinimized(false);
- }
- //fvMgr.restoreToPresentation(getId());
- }
-
- public void initToolBarManager(final ToolBarManager mgr) {
- // Set up the ToolBar with a restore button
- IContributionItem restoreContrib = new ContributionItem() {
- public void fill(ToolBar parent, int index) {
- ToolItem restoreItem = new ToolItem(mgr.getControl(), SWT.PUSH, index);
- 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) {
- restoreToPresentation();
- }
- public void widgetSelected(SelectionEvent e) {
- restoreToPresentation();
- }
- });
- }
- };
- mgr.add(restoreContrib);
-
- ShowFastViewContribution sfvc = new ShowFastViewContribution(wbw, getId());
- mgr.add(sfvc);
-
- // Add context menu items
- mgr.setContextMenuManager(new MenuManager());
- MenuManager menuMgr = mgr.getContextMenuManager();
-
- final IContributionItem closeContrib = new ContributionItem() {
- public void fill(Menu parent, int index) {
- MenuItem closeItem = new MenuItem(parent, SWT.NONE, index++);
- closeItem.setText(WorkbenchMessages.WorkbenchWindow_close);
- closeItem.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- IViewReference selectedView = null;
- if (contextToolItem != null) {
- selectedView = (IViewReference) contextToolItem.getData(ShowFastViewContribution.FAST_VIEW);
- }
-
- if (selectedView != null) {
- WorkbenchPage page = wbw.getActiveWorkbenchPage();
- if (page != null) {
- page.hideView(selectedView);
- }
- }
- }
- });
- }
- };
-
- // We have to manage the visiblity this way...?
- menuMgr.addMenuListener(new IMenuListener() {
- public void menuAboutToShow(IMenuManager manager) {
- IViewReference selectedView = null;
- if (contextToolItem != null) {
- selectedView = (IViewReference) contextToolItem.getData(ShowFastViewContribution.FAST_VIEW);
- }
-
- // Only show the 'close' item if we've clicked on a view
- Perspective persp = wbw.getActiveWorkbenchPage().getActivePerspective();
- closeContrib.setVisible(selectedView != null && persp.isCloseable(selectedView));
- manager.update(true);
- }
- });
-
- menuMgr.add(closeContrib);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.internal.layout.TrimToolBarBase#hookControl(org.eclipse.swt.widgets.ToolBar)
- */
- public void hookControl(ToolBarManager mgr) {
- // Hook a drop Listener to the control
- // NOTE: the drop target is self-managing...it
- // both hooks the new target and removes it on dispose
- new FastViewDnDHandler(id, mgr, wbw);
- }
-
- /**
- * Sets whether or not the stack gets restored on an unzoom
- * operation.
- *
- * @param restoreOnUnzoom
- */
- public void setRestoreOnUnzoom(boolean restoreOnUnzoom) {
- this.restoreOnUnzoom = restoreOnUnzoom;
- }
-
- public boolean restoreOnUnzoom() {
- return restoreOnUnzoom;
- }
-
- /**
- * @param ref
- * @param selected
- */
- public void setIconSelection(IViewReference ref, boolean selected) {
- ToolItem item = ShowFastViewContribution.getItem(tbMgr.getControl(), ref);
- if (item != null) {
- item.setSelection(selected);
-
- if (selected) {
- selectedTabId = ref.getId();
-
- // Create a 'compound' id if this is a multi-instance part
- if (ref.getSecondaryId() != null)
- selectedTabId = selectedTabId + ':' + ref.getSecondaryId();
- }
- }
- }
-
- /**
- * @return Returns the paneOrientation.
- */
- public int getPaneOrientation() {
- return paneOrientation;
- }
-
- /**
- * Cache the tba that was on top when we were minimized
- * @param selectedTab The id of the PartPane for the tab
- */
- public void setSelectedTabId(String id) {
- selectedTabId = id;
- }
-
- /**
- * @return The id of the layout part representing the 'top' tab
- */
- public String getSelectedTabId() {
- return selectedTabId;
- }
-
- /**
- * @param newOrientation The new orientation for the fact view display
- * @param wbw The currently active WorkbenchWindow
- */
- public void setOrientation(int newOrientation, WorkbenchWindow wbw) {
- if (newOrientation == paneOrientation)
- return;
-
- paneOrientation = newOrientation;
-
- // If there's a fast view showing, toggle it to pick up the change
- if (wbw.getActivePage() instanceof WorkbenchPage) {
- WorkbenchPage wbp = (WorkbenchPage) wbw.getActivePage();
- Perspective persp = wbp.getActivePerspective();
- if (persp != null) {
- IViewReference curRef = persp.getActiveFastView();
- if (curRef != null) {
- persp.setActiveFastView(null);
- persp.setActiveFastView(curRef);
- }
- }
-
- }
-
- }
-}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/WWinPartService.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/WWinPartService.java
deleted file mode 100644
index a5bfea323c8..00000000000
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/WWinPartService.java
+++ /dev/null
@@ -1,247 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2010 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.jface.dialogs.IPageChangedListener;
-import org.eclipse.jface.dialogs.PageChangedEvent;
-import org.eclipse.ui.IPartListener;
-import org.eclipse.ui.IPartListener2;
-import org.eclipse.ui.IPartService;
-import org.eclipse.ui.ISelectionService;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.IWorkbenchPartReference;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.internal.misc.UIListenerLogging;
-
-/**
- * A part service for a workbench window.
- */
-public class WWinPartService implements IPartService {
- private PartService partService = new PartService(UIListenerLogging.WINDOW_PARTLISTENER_EVENTS,
- UIListenerLogging.WINDOW_PARTLISTENER2_EVENTS);
-
- private WindowSelectionService selectionService;
-
- private IWorkbenchPage activePage;
-
- private class WWinListener implements IPartListener2, IPageChangedListener {
- public void partActivated(IWorkbenchPartReference ref) {
- updateActivePart();
- }
-
- public void partBroughtToTop(IWorkbenchPartReference ref) {
- partService.firePartBroughtToTop(ref);
- }
-
- public void partClosed(IWorkbenchPartReference ref) {
- partService.firePartClosed(ref);
- }
-
- public void partDeactivated(IWorkbenchPartReference ref) {
- updateActivePart();
- }
-
- public void partOpened(IWorkbenchPartReference ref) {
- partService.firePartOpened(ref);
- }
-
- public void partHidden(IWorkbenchPartReference ref) {
- partService.firePartHidden(ref);
- }
-
- public void partVisible(IWorkbenchPartReference ref) {
- partService.firePartVisible(ref);
- }
-
- public void partInputChanged(IWorkbenchPartReference ref) {
- partService.firePartInputChanged(ref);
- }
-
- public void pageChanged(PageChangedEvent event) {
- partService.firePageChanged(event);
- }
- }
- private IPartListener2 partListner = new WWinListener();
-
- /**
- * Creates a new part service for a workbench window.
- *
- * @param window
- * the workbench window
- */
- public WWinPartService(IWorkbenchWindow window) {
- selectionService = new WindowSelectionService(window);
- }
-
- /*
- * (non-Javadoc)
- * Method declared on IPartService
- */
- public void addPartListener(IPartListener l) {
- partService.addPartListener(l);
- }
-
- /*
- * (non-Javadoc)
- * Method declared on IPartService
- */
- public void addPartListener(IPartListener2 l) {
- partService.addPartListener(l);
- }
-
- /*
- * (non-Javadoc)
- * Method declared on IPartService
- */
- public void removePartListener(IPartListener l) {
- partService.removePartListener(l);
- }
-
- /*
- * (non-Javadoc)
- * Method declared on IPartService
- */
- public void removePartListener(IPartListener2 l) {
- partService.removePartListener(l);
- }
-
- /*
- * (non-Javadoc)
- * Method declared on IPartService
- */
- public IWorkbenchPart getActivePart() {
- return partService.getActivePart();
- }
-
- private void updateActivePart() {
- IWorkbenchPartReference activeRef = null;
- IWorkbenchPart activePart = null;
-
- if (activePage != null) {
- activePart = activePage.getActivePart();
- activeRef = activePage.getActivePartReference();
- }
-
- partService.setActivePart(activeRef);
- selectionService.setActivePart(activePart);
- }
-
- /*
- * (non-Javadoc)
- * Method declared on IPartService
- */
- public IWorkbenchPartReference getActivePartReference() {
- return partService.getActivePartReference();
- }
-
- /*
- * Returns the selection service.
- */
- ISelectionService getSelectionService() {
- return selectionService;
- }
-
- /*
- * Notifies that a page has been activated.
- */
- void pageActivated(IWorkbenchPage newPage) {
- // Optimize.
- if (newPage == activePage) {
- return;
- }
-
- // Fire events in the following order:
-
- // 1. For each open part in the new page, open it and then (if applicable) make it visible
- // 2. Deactivate old active part
- // 3. Activate the new active part
- // 4. For each open part in the old page, make it invisible then close it
-
- // Hook listener on the new page.
- if (newPage != null) {
- IWorkbenchPartReference[] refs = ((WorkbenchPage)newPage).getOpenParts();
-
- for (int i = 0; i < refs.length; i++) {
- IWorkbenchPartReference reference = refs[i];
-
- partService.firePartOpened(reference);
-
- IWorkbenchPart part = reference.getPart(false);
- if (part != null && newPage.isPartVisible(part)) {
- partService.firePartVisible(reference);
- }
- }
-
- partService.setActivePart(newPage.getActivePartReference());
- selectionService.setActivePart(newPage.getActivePart());
- } else {
- partService.setActivePart(null);
- selectionService.setActivePart(null);
- }
-
- // Unhook listener from the old page.
- reset();
-
- // Update active page.
- activePage = newPage;
-
- if (newPage != null) {
- newPage.addPartListener(partListner);
- }
-
- }
-
- /*
- * Notifies that a page has been closed
- */
- void pageClosed(IWorkbenchPage page) {
- // Unhook listener from the old page.
- if (page == activePage) {
- reset();
- }
- }
-
- /*
- * Notifies that a page has been opened.
- */
- void pageOpened(IWorkbenchPage page) {
- pageActivated(page);
- }
-
- /*
- * Resets the part service. The active page, part and selection are
- * dereferenced.
- */
- private void reset() {
- IWorkbenchPage tempPage = activePage;
- activePage = null;
- if (tempPage != null) {
- WorkbenchPage page = (WorkbenchPage)tempPage;
-
- IWorkbenchPartReference[] refs = page.getOpenParts();
-
- for (int i = 0; i < refs.length; i++) {
- IWorkbenchPartReference reference = refs[i];
-
- if (page.isPartVisible(reference)) {
- partService.firePartHidden(reference);
- }
-
- partService.firePartClosed(reference);
- }
-
- tempPage.removePartListener(partListner);
- }
-
- }
-
-}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/WorkbenchPagePartList.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/WorkbenchPagePartList.java
deleted file mode 100644
index 279c87382ca..00000000000
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/WorkbenchPagePartList.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2008 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.jface.dialogs.PageChangedEvent;
-import org.eclipse.ui.IPartService;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.IWorkbenchPartReference;
-import org.eclipse.ui.internal.misc.UIListenerLogging;
-
-public class WorkbenchPagePartList extends PartList {
-
- private PageSelectionService selectionService;
-
- private PartService partService = new PartService(UIListenerLogging.PAGE_PARTLISTENER_EVENTS,
- UIListenerLogging.PAGE_PARTLISTENER2_EVENTS);
-
- public WorkbenchPagePartList(PageSelectionService selectionService) {
- this.selectionService = selectionService;
- }
-
- public IPartService getPartService() {
- return partService;
- }
-
- protected void firePartOpened(IWorkbenchPartReference part) {
- partService.firePartOpened(part);
- }
-
- protected void firePartClosed(IWorkbenchPartReference part) {
- partService.firePartClosed(part);
- }
-
- protected void firePartAdded(IWorkbenchPartReference part) {
- // TODO: There is no listener for workbench page additions yet
- }
-
- protected void firePartRemoved(IWorkbenchPartReference part) {
- // TODO: There is no listener for workbench page removals yet
- }
-
- protected void fireActiveEditorChanged(IWorkbenchPartReference ref) {
- if (ref != null) {
- firePartBroughtToTop(ref);
- }
- }
-
- protected void fireActivePartChanged(IWorkbenchPartReference oldRef, IWorkbenchPartReference newRef) {
- partService.setActivePart(newRef);
-
- IWorkbenchPart realPart = newRef == null? null : newRef.getPart(false);
- selectionService.setActivePart(realPart);
- }
-
- protected void firePartHidden(IWorkbenchPartReference ref) {
- partService.firePartHidden(ref);
- }
-
- protected void firePartVisible(IWorkbenchPartReference ref) {
- partService.firePartVisible(ref);
- }
-
- protected void firePartInputChanged(IWorkbenchPartReference ref) {
- partService.firePartInputChanged(ref);
- }
-
- public void firePartBroughtToTop(IWorkbenchPartReference ref) {
- partService.firePartBroughtToTop(ref);
- }
-
- protected void firePageChanged(PageChangedEvent event) {
- partService.firePageChanged(event);
- }
-}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/commands/Parameter.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/commands/Parameter.java
deleted file mode 100644
index 129f93ed262..00000000000
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/commands/Parameter.java
+++ /dev/null
@@ -1,256 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 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.commands;
-
-import org.eclipse.core.commands.IParameter;
-import org.eclipse.core.commands.IParameterValues;
-import org.eclipse.core.commands.ITypedParameter;
-import org.eclipse.core.commands.ParameterType;
-import org.eclipse.core.commands.ParameterValuesException;
-import org.eclipse.core.commands.common.HandleObject;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.ui.internal.util.Util;
-
-/**
- * <p>
- * A parameter for a command. A parameter identifies a type of information that
- * the command might accept. For example, a "Show View" command might accept the
- * id of a view for display. This parameter also identifies possible values, for
- * display in the user interface.
- * </p>
- * <p>
- * Parameters are mutable, and can change as the command changes. Notifications
- * will not be sent if the parameter itself changes. Listeners can be attached
- * to the command.
- * </p>
- *
- * @since 3.1
- */
-public final class Parameter implements IParameter, ITypedParameter {
-
- /**
- * The name of the configuration element attribute contain the values. This
- * is used to retrieve the executable extension
- * <code>IParameterValues</code>.
- */
- private static final String ATTRIBUTE_VALUES = "values"; //$NON-NLS-1$
-
- /**
- * The constant integer hash code value meaning the hash code has not yet
- * been computed.
- */
- private static final int HASH_CODE_NOT_COMPUTED = -1;
-
- /**
- * A factor for computing the hash code for all schemes.
- */
- private static final int HASH_FACTOR = 89;
-
- /**
- * The seed for the hash code for all schemes.
- */
- private static final int HASH_INITIAL = HandleObject.class.getName()
- .hashCode();
-
- /**
- * The hash code for this object. This value is computed lazily, and marked
- * as invalid when one of the values on which it is based changes.
- */
- private transient int hashCode = HASH_CODE_NOT_COMPUTED;
-
- /**
- * The identifier for this object. This identifier should be unique across
- * all objects of the same type and should never change. This value will
- * never be <code>null</code>.
- */
- protected final String id;
-
- /**
- * The non-externalized name of this parameter. The name is used as the in a
- * name-value parameter map. This value will never be <code>null</code>.
- */
- private final String name;
-
- /**
- * Whether the parameter is optional (as opposed to required).
- */
- private final boolean optional;
-
- /**
- * The type for this parameter. This value may be <code>null</code> if the
- * parameter is not typed.
- */
- private final ParameterType parameterType;
-
- /**
- * The string representation of this object. This string is for debugging
- * purposes only, and is not meant to be displayed to the user. This value
- * is computed lazily, and is cleared if one of its dependent values
- * changes.
- */
- protected transient String string = null;
-
- /**
- * The actual <code>IParameterValues</code> implementation. This is lazily
- * loaded from the <code>valuesConfigurationElement</code>, to avoid
- * unnecessary class-loading.
- */
- private transient IParameterValues values = null;
-
- /**
- * The configuration element providing the executable extension that will
- * implement <code>IParameterValues</code>. This value will not be
- * <code>null</code>.
- */
- private final IConfigurationElement valuesConfigurationElement;
-
- /**
- * Constructs a new instance of <code>Parameter</code> with all of its
- * values pre-defined.
- *
- * @param id
- * The identifier for this parameter; must not be
- * <code>null</code>.
- * @param name
- * The name for this parameter; must not be <code>null</code>.
- * @param values
- * The values for this parameter; must not be <code>null</code>.
- * @param parameterType
- * the type for this parameter; may be <code>null</code> if the
- * parmeter doesn't declare type.
- * @param optional
- * Whether this parameter is optional (as opposed to required).
- * @param commandService
- * The command service from which parameter types can be
- * retrieved; must not be <code>null</code>.
- */
- public Parameter(final String id, final String name,
- final IConfigurationElement values,
- final ParameterType parameterType, final boolean optional) {
- if (id == null) {
- throw new NullPointerException(
- "Cannot create a parameter with a null id"); //$NON-NLS-1$
- }
-
- if (name == null) {
- throw new NullPointerException(
- "The name of a parameter cannot be null."); //$NON-NLS-1$
- }
-
- if (values == null) {
- throw new NullPointerException(
- "The values for a parameter cannot be null."); //$NON-NLS-1$
- }
-
- this.id = id;
- this.name = name;
- this.valuesConfigurationElement = values;
- this.parameterType = parameterType;
- this.optional = optional;
- }
-
- /**
- * Tests whether this object is equal to another object. A parameter is only
- * equal to another parameter with the same properties.
- *
- * @param object
- * The object with which to compare; may be <code>null</code>.
- * @return <code>true</code> if the objects are equal; <code>false</code>
- * otherwise.
- */
- public final boolean equals(final Object object) {
- if (this == object) {
- return true;
- }
-
- if (!(object instanceof Parameter)) {
- return false;
- }
-
- final Parameter parameter = (Parameter) object;
- if (!Util.equals(id, parameter.id)) {
- return false;
- }
- if (!Util.equals(name, parameter.name)) {
- return false;
- }
- if (!Util.equals(values, parameter.values)) {
- return false;
- }
-
- return Util.equals(optional, parameter.optional);
- }
-
- public final String getId() {
- return id;
- }
-
- public final String getName() {
- return name;
- }
-
- public final ParameterType getParameterType() {
- return parameterType;
- }
-
- public final IParameterValues getValues() throws ParameterValuesException {
- if (values == null) {
- try {
- values = (IParameterValues) valuesConfigurationElement
- .createExecutableExtension(ATTRIBUTE_VALUES);
- } catch (final CoreException e) {
- throw new ParameterValuesException(
- "Problem creating parameter values", e); //$NON-NLS-1$
- } catch (final ClassCastException e) {
- throw new ParameterValuesException(
- "Parameter values were not an instance of IParameterValues", e); //$NON-NLS-1$
- }
- }
-
- return values;
- }
-
- public final int hashCode() {
- if (hashCode == HASH_CODE_NOT_COMPUTED) {
- hashCode = HASH_INITIAL * HASH_FACTOR + Util.hashCode(id);
- if (hashCode == HASH_CODE_NOT_COMPUTED) {
- hashCode++;
- }
- }
- return hashCode;
- }
-
- public final boolean isOptional() {
- return optional;
- }
-
- public final String toString() {
- if (string == null) {
- final StringBuffer buffer = new StringBuffer();
-
- buffer.append("Parameter("); //$NON-NLS-1$
- buffer.append(id);
- buffer.append(',');
- buffer.append(name);
- buffer.append(',');
- buffer.append(values);
- buffer.append(',');
- buffer.append(optional);
- buffer.append(')');
-
- string = buffer.toString();
- }
-
- return string;
- }
-}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/dialogs/CustomizePerspectiveDialog.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/dialogs/CustomizePerspectiveDialog.java
deleted file mode 100644
index 2ae24c72d30..00000000000
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/dialogs/CustomizePerspectiveDialog.java
+++ /dev/null
@@ -1,3378 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2010 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.dialogs;
-
-import java.net.URL;
-import java.text.MessageFormat;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.LinkedHashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import org.eclipse.core.commands.Command;
-import org.eclipse.core.commands.ParameterizedCommand;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.jface.action.ActionContributionItem;
-import org.eclipse.jface.action.ContributionManager;
-import org.eclipse.jface.action.CoolBarManager;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.action.IContributionItem;
-import org.eclipse.jface.action.IContributionManager;
-import org.eclipse.jface.action.ICoolBarManager;
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.jface.action.IStatusLineManager;
-import org.eclipse.jface.action.IToolBarManager;
-import org.eclipse.jface.action.MenuManager;
-import org.eclipse.jface.action.StatusLineManager;
-import org.eclipse.jface.action.SubContributionItem;
-import org.eclipse.jface.action.ToolBarManager;
-import org.eclipse.jface.bindings.Binding;
-import org.eclipse.jface.bindings.BindingManager;
-import org.eclipse.jface.dialogs.TrayDialog;
-import org.eclipse.jface.internal.provisional.action.IToolBarContributionItem;
-import org.eclipse.jface.internal.provisional.action.ToolBarContributionItem2;
-import org.eclipse.jface.layout.GridDataFactory;
-import org.eclipse.jface.preference.PreferenceDialog;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.resource.JFaceResources;
-import org.eclipse.jface.viewers.AbstractTreeViewer;
-import org.eclipse.jface.viewers.ArrayContentProvider;
-import org.eclipse.jface.viewers.CheckStateChangedEvent;
-import org.eclipse.jface.viewers.CheckboxTableViewer;
-import org.eclipse.jface.viewers.CheckboxTreeViewer;
-import org.eclipse.jface.viewers.ComboViewer;
-import org.eclipse.jface.viewers.ICheckStateListener;
-import org.eclipse.jface.viewers.ICheckStateProvider;
-import org.eclipse.jface.viewers.IColorProvider;
-import org.eclipse.jface.viewers.ILabelProviderListener;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.ITableLabelProvider;
-import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.jface.viewers.StructuredViewer;
-import org.eclipse.jface.viewers.TableViewer;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jface.viewers.ViewerCell;
-import org.eclipse.jface.viewers.ViewerFilter;
-import org.eclipse.jface.window.ToolTip;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.SashForm;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.Font;
-import org.eclipse.swt.graphics.FontData;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.Resource;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Combo;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.CoolBar;
-import org.eclipse.swt.widgets.CoolItem;
-import org.eclipse.swt.widgets.Decorations;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Link;
-import org.eclipse.swt.widgets.Menu;
-import org.eclipse.swt.widgets.MenuItem;
-import org.eclipse.swt.widgets.MessageBox;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.TabFolder;
-import org.eclipse.swt.widgets.TabItem;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.swt.widgets.TableColumn;
-import org.eclipse.swt.widgets.TableItem;
-import org.eclipse.swt.widgets.ToolBar;
-import org.eclipse.swt.widgets.ToolItem;
-import org.eclipse.swt.widgets.Tree;
-import org.eclipse.ui.IActionBars2;
-import org.eclipse.ui.IPerspectiveDescriptor;
-import org.eclipse.ui.IPerspectiveRegistry;
-import org.eclipse.ui.IWorkbenchCommandConstants;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.actions.ActionFactory;
-import org.eclipse.ui.actions.OpenPerspectiveAction;
-import org.eclipse.ui.activities.WorkbenchActivityHelper;
-import org.eclipse.ui.application.ActionBarAdvisor;
-import org.eclipse.ui.application.IWorkbenchWindowConfigurer;
-import org.eclipse.ui.commands.ICommandService;
-import org.eclipse.ui.dialogs.PreferencesUtil;
-import org.eclipse.ui.internal.ActionSetActionBars;
-import org.eclipse.ui.internal.ActionSetContributionItem;
-import org.eclipse.ui.internal.IWorkbenchHelpContextIds;
-import org.eclipse.ui.internal.Perspective;
-import org.eclipse.ui.internal.PluginActionCoolBarContributionItem;
-import org.eclipse.ui.internal.PluginActionSet;
-import org.eclipse.ui.internal.PluginActionSetBuilder;
-import org.eclipse.ui.internal.WorkbenchMessages;
-import org.eclipse.ui.internal.WorkbenchPage;
-import org.eclipse.ui.internal.WorkbenchPlugin;
-import org.eclipse.ui.internal.WorkbenchWindow;
-import org.eclipse.ui.internal.actions.NewWizardShortcutAction;
-import org.eclipse.ui.internal.dialogs.TreeManager.CheckListener;
-import org.eclipse.ui.internal.dialogs.TreeManager.TreeItem;
-import org.eclipse.ui.internal.intro.IIntroConstants;
-import org.eclipse.ui.internal.keys.BindingService;
-import org.eclipse.ui.internal.provisional.application.IActionBarConfigurer2;
-import org.eclipse.ui.internal.registry.ActionSetDescriptor;
-import org.eclipse.ui.internal.registry.ActionSetRegistry;
-import org.eclipse.ui.internal.registry.IActionSetDescriptor;
-import org.eclipse.ui.internal.util.BundleUtility;
-import org.eclipse.ui.internal.util.Util;
-import org.eclipse.ui.keys.IBindingService;
-import org.eclipse.ui.menus.CommandContributionItem;
-import org.eclipse.ui.menus.IMenuService;
-import org.eclipse.ui.menus.MenuUtil;
-import org.eclipse.ui.model.WorkbenchViewerComparator;
-import org.eclipse.ui.part.PageBook;
-import org.eclipse.ui.services.IServiceLocator;
-import org.eclipse.ui.views.IViewCategory;
-import org.eclipse.ui.views.IViewDescriptor;
-import org.eclipse.ui.views.IViewRegistry;
-import org.eclipse.ui.wizards.IWizardCategory;
-import org.eclipse.ui.wizards.IWizardDescriptor;
-
-/**
- * Dialog to allow users the ability to customize the perspective. This includes
- * customizing menus and toolbars by adding, removing, or re-arranging commands
- * or groups of commands.
- *
- */
-public class CustomizePerspectiveDialog extends TrayDialog {
-
- private static final String TOOLBAR_ICON = "$nl$/icons/full/obj16/toolbar.gif"; //$NON-NLS-1$
- private static final String SUBMENU_ICON = "$nl$/icons/full/obj16/submenu.gif"; //$NON-NLS-1$
- private static final String MENU_ICON = "$nl$/icons/full/obj16/menu.gif"; //$NON-NLS-1$
- private static final String WARNING_ICON = "$nl$/icons/full/obj16/warn_tsk.gif"; //$NON-NLS-1$
-
- private static final String SHORTCUT_CONTRIBUTION_ITEM_ID_OPEN_PERSPECTIVE = "openPerspective"; //$NON-NLS-1$
- private static final String SHORTCUT_CONTRIBUTION_ITEM_ID_SHOW_VIEW = "showView"; //$NON-NLS-1$
-
- private static final String KEYS_PREFERENCE_PAGE_ID = "org.eclipse.ui.preferencePages.Keys"; //$NON-NLS-1$
-
- private static final String NEW_LINE = System.getProperty("line.separator"); //$NON-NLS-1$
-
- private static final int MIN_TOOLTIP_WIDTH = 160;
-
- private WorkbenchWindow window;
-
- private Perspective perspective;
-
- private TabFolder tabFolder;
-
- private final static int TAB_WIDTH_IN_DLUS = 490;
-
- private final static int TAB_HEIGHT_IN_DLUS = 230;
-
- private final String shortcutMenuColumnHeaders[] = {
- WorkbenchMessages.ActionSetSelection_menuColumnHeader,
- WorkbenchMessages.ActionSetSelection_descriptionColumnHeader };
-
- private int[] shortcutMenuColumnWidths = { 125, 300 };
-
- ImageDescriptor menuImageDescriptor = null;
-
- ImageDescriptor submenuImageDescriptor = null;
-
- ImageDescriptor toolbarImageDescriptor = null;
-
- ImageDescriptor warningImageDescriptor = null;
-
- private TreeManager treeManager;
-
- private DisplayItem menuItems;
-
- private DisplayItem toolBarItems;
-
- private Category shortcuts;
-
- private DisplayItem wizards;
-
- private DisplayItem perspectives;
-
- private DisplayItem views;
-
- private Map idToActionSet = new HashMap();
-
- private final List actionSets = new ArrayList();
-
- private IWorkbenchWindowConfigurer configurer;
-
- private TabItem actionSetTab;
-
- private CheckboxTableViewer actionSetAvailabilityTable;
-
- private CheckboxTreeViewer menuStructureViewer1;
-
- private CheckboxTreeViewer menuStructureViewer2;
-
- private CheckboxTreeViewer toolbarStructureViewer1;
-
- private CheckboxTreeViewer toolbarStructureViewer2;
-
- private Set toDispose;
-
- private CustomizeActionBars customizeActionBars;
-
- private Font tooltipHeading;
-
- /**
- * A Listener for a list of command groups, that updates the viewer and
- * filter who are dependent on the action set selection.
- *
- * @since 3.5
- */
- private static final class ActionSetSelectionChangedListener implements
- ISelectionChangedListener {
- private final TreeViewer filterViewer;
- private final ActionSetFilter filter;
-
- public ActionSetSelectionChangedListener(TreeViewer viewer,
- ActionSetFilter menuStructureFilterByActionSet) {
- this.filterViewer = viewer;
- this.filter = menuStructureFilterByActionSet;
- }
-
- public void selectionChanged(SelectionChangedEvent event) {
- Object element = ((IStructuredSelection) event.getSelection())
- .getFirstElement();
- filter.setActionSet((ActionSet) element);
- filterViewer.refresh();
- filterViewer.expandAll();
- }
- }
-
- /**
- * A filter which will only show action sets which contribute items in the
- * given tree structure.
- *
- * @since 3.5
- */
- private static final class ShowUsedActionSetsFilter extends ViewerFilter {
- private DisplayItem rootItem;
-
- public ShowUsedActionSetsFilter(DisplayItem rootItem) {
- this.rootItem = rootItem;
- }
-
- public boolean select(Viewer viewer, Object parentElement,
- Object element) {
- return (includeInSetStructure(rootItem, (ActionSet) element));
- }
- }
-
- /**
- * Represents a menu item or a tool bar item.
- *
- * @since 3.5
- */
- private class DisplayItem extends TreeItem {
- /** The logic item represented */
- private IContributionItem item;
-
- /** The action set this item belongs to (optional) */
- private ActionSet actionSet;
-
- public DisplayItem(String label, IContributionItem item) {
- treeManager.super(label == null ? null : DialogUtil
- .removeAccel(removeShortcut(label)));
- this.item = item;
- }
-
- public void setActionSet(ActionSet actionSet) {
- this.actionSet = actionSet;
- if (actionSet != null)
- actionSet.addItem(this);
- }
-
- public ActionSet getActionSet() {
- return actionSet;
- }
-
- public IContributionItem getIContributionItem() {
- return item;
- }
- }
-
- /**
- * Represents a menu item whose content is dynamic. Contains a list of the
- * current items being displayed.
- *
- * @since 3.5
- */
- private class DynamicContributionItem extends DisplayItem {
- private List preview;
-
- public DynamicContributionItem(IContributionItem item) {
- super(WorkbenchMessages.HideItems_dynamicItemName, item);
- preview = new ArrayList();
- }
-
- public void addCurrentItem(MenuItem item) {
- preview.add(item);
- }
-
- public List getCurrentItems() {
- return preview;
- }
- }
-
- /**
- * @param descriptor
- * @param window
- * @return the appropriate {@link IContributionItem} for the given wizard
- */
- private static ActionContributionItem getIContributionItem(
- IWizardDescriptor descriptor, IWorkbenchWindow window) {
- IAction action = new NewWizardShortcutAction(window, descriptor);
- return new ActionContributionItem(action);
- }
-
- /**
- * @param descriptor
- * @param window
- * @return the appropriate {@link IContributionItem} for the given
- * perspective
- */
- private static ActionContributionItem getIContributionItem(
- IPerspectiveDescriptor descriptor, IWorkbenchWindow window) {
- IAction action = new OpenPerspectiveAction(window, descriptor, null);
- return new ActionContributionItem(action);
- }
-
- /**
- * @param window
- * @return the appropriate {@link IContributionItem} for showing views
- */
- private static ActionContributionItem getIContributionItem(
- IWorkbenchWindow window) {
- IAction action = ActionFactory.SHOW_VIEW_MENU.create(window);
- return new ActionContributionItem(action);
- }
-
- /**
- * Represents a menu item which needs to be shown in the Shortcuts tab.
- *
- * @since 3.5
- */
- private class ShortcutItem extends DisplayItem {
- /** The description to show in the table */
- private String description;
-
- /** The category this shortcut is in (should be set) */
- private Category category;
-
- private Object descriptor;
-
- public ShortcutItem(String label, IWizardDescriptor descriptor) {
- super(label, CustomizePerspectiveDialog.getIContributionItem(
- descriptor, window));
- this.descriptor = descriptor;
- }
-
- public ShortcutItem(String label, IPerspectiveDescriptor descriptor) {
- super(label, CustomizePerspectiveDialog.getIContributionItem(
- descriptor, window));
- this.descriptor = descriptor;
- }
-
- public ShortcutItem(String label, IViewDescriptor descriptor) {
- super(label, CustomizePerspectiveDialog
- .getIContributionItem(window));
- this.descriptor = descriptor;
- }
-
- public Object getDescriptor() {
- return descriptor;
- }
-
- public void setDescription(String description) {
- this.description = description;
- }
-
- public String getDescription() {
- return description;
- }
-
- public void setCategory(Category category) {
- this.category = category;
- }
-
- public Category getCategory() {
- return category;
- }
- }
-
- /**
- * Represents a category in the shortcuts menu. Since categories can have a
- * tree-structure, the functionality provided by the TreeManager and
- * TreeItem classes is used, however the logic for visibility changes and
- * gray states is more sophisticated.
- *
- * @since 3.5
- */
- private class Category extends TreeItem {
-
- /** ShortcutItems which are contributed in this Category */
- private List contributionItems;
-
- public Category(String label) {
- treeManager.super(label == null ? null : DialogUtil
- .removeAccel(removeShortcut(label)));
- this.contributionItems = new ArrayList();
- }
-
- public List getContributionItems() {
- return contributionItems;
- }
-
- /**
- * Adds another ShortcutItem to this Category's list of ShortcutItems
- * and creates a pseudo-child/parent relationship.
- *
- * @param item
- * the item to add
- */
- public void addShortcutItem(ShortcutItem item) {
- contributionItems.add(item);
- item.setCategory(this);
- }
-
- /**
- * While the child/parent state in the Category hierarchy is
- * automatically maintained, the pseudo-child/parent relationship must
- * be explicitly updated. This method will update Categories if their
- * states need to change as a result of their ShortcutItems.
- */
- public void update() {
- for (Iterator i = contributionItems.iterator(); i.hasNext();) {
- DisplayItem item = (DisplayItem) i.next();
- if (item.getState()) {
- this.setCheckState(true);
- return;
- }
- }
-
- this.setCheckState(false);
- }
-
- /**
- * Changes the state of all pseudo-descendant ShortcutItems, causing the
- * effective state of this Category and all its sub-Categories to match.
- *
- * @param state
- * The state to set this branch to.
- */
- public void setItemsState(boolean state) {
- for (Iterator i = contributionItems.iterator(); i.hasNext();) {
- DisplayItem item = (DisplayItem) i.next();
- item.setCheckState(state);
- }
- for (Iterator i = getChildren().iterator(); i.hasNext();) {
- Category category = (Category) i.next();
- category.setItemsState(state);
- }
- }
- }
-
- /**
- * Represents an action set, under which ContributionItems exist. There is
- * no inherent hierarchy in action sets - they exist independent of one
- * another, simply contribution menu items and tool bar items.
- *
- * @since 3.5
- */
- private class ActionSet {
- /** The descriptor which describes the action set represented */
- private ActionSetDescriptor descriptor;
-
- /** ContributionItems contributed by this action set */
- private List contributionItems;
-
- private boolean active;
-
- private boolean wasChanged = false;
-
- public ActionSet(ActionSetDescriptor descriptor, boolean active) {
- this.descriptor = descriptor;
- this.active = active;
- this.contributionItems = new ArrayList();
- }
-
- public void addItem(DisplayItem item) {
- contributionItems.add(item);
- }
-
- public String toString() {
- return descriptor.getLabel();
- }
-
- public boolean isActive() {
- return active;
- }
-
- public boolean wasChanged() {
- return wasChanged;
- }
-
- public void setActive(boolean active) {
- boolean wasActive = this.active;
- this.active = active;
- if (!active) {
- for (Iterator i = contributionItems.iterator(); i.hasNext();) {
- DisplayItem item = (DisplayItem) i.next();
- item.setCheckState(false);
- }
- }
- if (wasActive != active) {
- actionSetAvailabilityChanged();
- }
-
- wasChanged = true;
- }
- }
-
- /**
- * A label provider to include the description field of ShortcutItems in the
- * table.
- *
- * @since 3.5
- */
- private class ShortcutLabelProvider extends
- TreeManager.TreeItemLabelProvider implements ITableLabelProvider {
- public Image getColumnImage(Object element, int columnIndex) {
- if (columnIndex == 0)
- return this.getImage(element);
- return null;
- }
-
- public String getColumnText(Object element, int columnIndex) {
- if (columnIndex == 1)
- return ((ShortcutItem) element).getDescription();
- return this.getText(element);
- }
-
- public void addListener(ILabelProviderListener listener) {
- }
-
- public boolean isLabelProperty(Object element, String property) {
- return false;
- }
-
- public void removeListener(ILabelProviderListener listener) {
- }
- }
-
- /**
- * Provides the check logic for the categories viewer in the shortcuts tab.
- * Categories have a dual concept of children - their proper children
- * (sub-Categories, as in the wizards), and the actual elements they
- * contribute to the menu system. The check state must take this into
- * account.
- *
- * @since 3.5
- */
- private static class CategoryCheckProvider implements ICheckStateProvider {
- public boolean isChecked(Object element) {
- Category category = (Category) element;
-
- if (category.getChildren().isEmpty()
- && category.getContributionItems().isEmpty())
- return false;
-
- // To be checked, any sub-Category can be checked.
- for (Iterator i = category.getChildren().iterator(); i.hasNext();) {
- Category child = (Category) i.next();
- if (isChecked(child))
- return true;
- }
-
- // To be checked, any ShortcutItem can be checked.
- for (Iterator i = category.getContributionItems().iterator(); i
- .hasNext();) {
- DisplayItem item = (DisplayItem) i.next();
- if (item.getState())
- return true;
- }
-
- return false;
- }
-
- public boolean isGrayed(Object element) {
- boolean hasChecked = false;
- boolean hasUnchecked = false;
- Category category = (Category) element;
-
- // Search in sub-Categories and ShortcutItems for one that is
- // checked and one that is unchecked.
-
- for (Iterator i = category.getChildren().iterator(); i.hasNext();) {
- Category child = (Category) i.next();
- if (isGrayed(child))
- return true;
- if (isChecked(child))
- hasChecked = true;
- else
- hasUnchecked = true;
- if (hasChecked && hasUnchecked)
- return true;
- }
-
- for (Iterator i = category.getContributionItems().iterator(); i
- .hasNext();) {
- DisplayItem item = (DisplayItem) i.next();
- if (item.getState())
- hasChecked = true;
- else
- hasUnchecked = true;
- if (hasChecked && hasUnchecked)
- return true;
- }
-
- return false;
- }
- }
-
- /**
- * A tooltip which, given a model element, will display its icon (if there
- * is one), name, and a description (if there is one).
- *
- * @since 3.5
- */
- private abstract class NameAndDescriptionToolTip extends ToolTip {
- public NameAndDescriptionToolTip(Control control, int style) {
- super(control, style, false);
- }
-
- protected abstract Object getModelElement(Event event);
-
- /**
- * Adds logic to only show a tooltip if a meaningful item is under the
- * cursor.
- */
- protected boolean shouldCreateToolTip(Event event) {
- return super.shouldCreateToolTip(event)
- && getModelElement(event) != null;
- }
-
- protected Composite createToolTipContentArea(Event event,
- Composite parent) {
- Object modelElement = getModelElement(event);
-
- Image iconImage = null;
- String nameString = null;
-
- if (modelElement instanceof DisplayItem) {
- iconImage = ((DisplayItem) modelElement).getImage();
- nameString = ((DisplayItem) modelElement).getLabel();
- } else if (modelElement instanceof ActionSet) {
- nameString = ((ActionSet) modelElement).descriptor.getLabel();
- }
-
- // Create the content area
- Composite composite = new Composite(parent, SWT.NONE);
- composite.setBackground(parent.getDisplay().getSystemColor(
- SWT.COLOR_INFO_BACKGROUND));
- composite.setLayout(new GridLayout(2, false));
-
- // The title area with the icon (if there is one) and label.
- Label title = createEntry(composite, iconImage, nameString);
- title.setFont(tooltipHeading);
- GridDataFactory.createFrom((GridData)title.getLayoutData())
- .hint(SWT.DEFAULT, SWT.DEFAULT)
- .minSize(MIN_TOOLTIP_WIDTH, 1)
- .applyTo(title);
-
- // The description (if there is one)
- String descriptionString = getDescription(modelElement);
- if (descriptionString != null) {
- createEntry(composite, null, descriptionString);
- }
-
- // Other Content to add
- addContent(composite, modelElement);
-
- return composite;
- }
-
- /**
- * Adds a line of information to <code>parent</code>. If
- * <code>icon</code> is not <code>null</code>, an icon is placed on the
- * left, and then a label with <code>text</code>.
- *
- * @param parent
- * the composite to add the entry to
- * @param icon
- * the icon to place next to the text. <code>null</code> for
- * none.
- * @param text
- * the text to display
- * @return the created label
- */
- protected Label createEntry(Composite parent, Image icon, String text) {
- if (icon != null) {
- Label iconLabel = new Label(parent, SWT.NONE);
- iconLabel.setImage(icon);
- iconLabel.setBackground(parent.getDisplay().getSystemColor(
- SWT.COLOR_INFO_BACKGROUND));
- iconLabel.setData(new GridData());
- }
-
- Label textLabel = new Label(parent, SWT.WRAP);
-
- if(icon == null) {
- GridDataFactory.generate(textLabel, 2, 1);
- } else {
- GridDataFactory.generate(textLabel, 1, 1);
- }
-
- textLabel.setText(text);
- textLabel.setBackground(parent.getDisplay().getSystemColor(
- SWT.COLOR_INFO_BACKGROUND));
- return textLabel;
- }
-
- /**
- * Adds a line of information to <code>parent</code>. If
- * <code>icon</code> is not <code>null</code>, an icon is placed on the
- * left, and then a label with <code>text</code>, which supports using
- * anchor tags to creates links
- *
- * @param parent
- * the composite to add the entry to
- * @param icon
- * the icon to place next to the text. <code>null</code> for
- * none.
- * @param text
- * the text to display
- * @return the created link
- */
- protected Link createEntryWithLink(Composite parent, Image icon,
- String text) {
- if (icon != null) {
- Label iconLabel = new Label(parent, SWT.NONE);
- iconLabel.setImage(icon);
- iconLabel.setBackground(parent.getDisplay().getSystemColor(
- SWT.COLOR_INFO_BACKGROUND));
- iconLabel.setData(new GridData());
- }
-
- Link textLink = new Link(parent, SWT.WRAP);
-
- if(icon == null) {
- GridDataFactory.generate(textLink, 2, 1);
- }
-
- textLink.setText(text);
- textLink.setBackground(parent.getDisplay().getSystemColor(
- SWT.COLOR_INFO_BACKGROUND));
- return textLink;
- }
-
- protected void addContent(Composite destination, Object modelElement) {
- }
- }
-
- /**
- * A tooltip with useful information based on the type of ContributionItem
- * the cursor hovers over in a Table.
- *
- * @since 3.5
- */
- private class TableToolTip extends NameAndDescriptionToolTip {
- private Table table;
-
- public TableToolTip(Table table) {
- super(table, RECREATE);
- this.table = table;
- }
-
- protected Object getModelElement(Event event) {
- TableItem tableItem = table.getItem(new Point(event.x, event.y));
- if (tableItem == null)
- return null;
- return tableItem.getData();
- }
- }
-
- /**
- * A tooltip with useful information based on the type of ContributionItem
- * the cursor hovers over in a Tree. In addition to the content provided by
- * the {@link NameAndDescriptionToolTip} this includes action set
- * information and key binding data.
- *
- * @since 3.5
- */
- private class ItemDetailToolTip extends NameAndDescriptionToolTip {
- private Tree tree;
- private boolean showActionSet;
- private boolean showKeyBindings;
- private ViewerFilter filter;
- private TreeViewer v;
-
- /**
- * @param tree
- * The tree for the tooltip to hover over
- */
- private ItemDetailToolTip(TreeViewer v, Tree tree, boolean showActionSet,
- boolean showKeyBindings, ViewerFilter filter) {
- super(tree,NO_RECREATE);
- this.tree = tree;
- this.v = v;
- this.showActionSet = showActionSet;
- this.showKeyBindings = showKeyBindings;
- this.filter = filter;
- this.setHideOnMouseDown(false);
- }
-
- public Point getLocation(Point tipSize, Event event) {
- // try to position the tooltip at the bottom of the cell
- ViewerCell cell = v.getCell(new Point(event.x, event.y));
-
- if( cell != null ) {
- return tree.toDisplay(event.x,cell.getBounds().y+cell.getBounds().height);
- }
-
- return super.getLocation(tipSize, event);
- }
-
- protected Object getToolTipArea(Event event) {
- // Ensure that the tooltip is hidden when the cell is left
- return v.getCell(new Point(event.x, event.y));
- }
-
- protected void addContent(Composite destination, Object modelElement) {
- final DisplayItem item = (DisplayItem) modelElement;
-
- // Show any relevant action set info
- if (showActionSet) {
- String text = null;
- Image image = null;
-
- if(isEffectivelyAvailable(item, filter)) {
- if(item.actionSet != null) {
- //give information on which command group the item is in
-
- final String actionSetName = item.getActionSet().descriptor
- .getLabel();
-
- text = NLS.bind(
- WorkbenchMessages.HideItems_itemInActionSet,
- actionSetName);
- }
- } else {
- //give feedback on why item is unavailable
-
- image = warningImageDescriptor.createImage();
-
- if(item.getChildren().isEmpty()) {
- //i.e. is a leaf
-
- final String actionSetName = item.getActionSet().
- descriptor.getLabel();
-
- text = NLS.bind(
- WorkbenchMessages.HideItems_itemInUnavailableActionSet,
- actionSetName);
-
- } else {
- //i.e. has children
-
- Set actionGroup = new LinkedHashSet();
- collectDescendantCommandGroups(actionGroup, item,
- filter);
-
- if (actionGroup.size() == 1) {
- //i.e. only one child
- ActionSet actionSet = (ActionSet) actionGroup.
- iterator().next();
- text = NLS.bind(
- WorkbenchMessages.HideItems_unavailableChildCommandGroup,
- actionSet.descriptor.getId(),
- actionSet.descriptor.getLabel());
- } else {
- //i.e. multiple children
- String commandGroupList = null;
-
- for (Iterator i = actionGroup.iterator(); i.hasNext();) {
- ActionSet actionSet = (ActionSet) i.next();
-
- // For each action set, make a link for it, set
- // the href to its id
- String commandGroupLink = MessageFormat.format(
- "<a href=\"{0}\">{1}</a>", //$NON-NLS-1$
- new Object[] { actionSet.descriptor.getId(),
- actionSet.descriptor.getLabel() });
-
- if (commandGroupList == null)
- commandGroupList = commandGroupLink;
- else
- commandGroupList = Util.createList(
- commandGroupList, commandGroupLink);
- }
-
- commandGroupList = NLS.bind(
- "{0}{1}", new Object[] { NEW_LINE, commandGroupList }); //$NON-NLS-1$
- text = NLS.bind(
- WorkbenchMessages.HideItems_unavailableChildCommandGroups,
- commandGroupList);
- }
- }
- }
-
- if(text != null) {
- Link link = createEntryWithLink(destination, image, text);
- link.addSelectionListener(new SelectionListener() {
- public void widgetDefaultSelected(SelectionEvent e) {
- widgetSelected(e);
- }
-
- public void widgetSelected(SelectionEvent e) {
- ActionSet actionSet = (ActionSet) idToActionSet
- .get(e.text);
- if (actionSet == null) {
- hide();
- viewActionSet(item);
- } else {
- hide();
- viewActionSet(actionSet);
- }
- }
- });
- }
- }
-
- // Show key binding info
- if (showKeyBindings && getCommandID(item) != null) {
- // See if there is a command associated with the command id
- ICommandService commandService = (ICommandService) window
- .getService(ICommandService.class);
- Command command = commandService.getCommand(getCommandID(item));
-
- if (command != null && command.isDefined()) {
- // Find the bindings and list them as a string
- Binding[] bindings = getKeyBindings(item);
- String keybindings = keyBindingsAsString(bindings);
-
- String text = null;
-
- // Is it possible for this item to be visible?
- final boolean available = (item.getActionSet() == null)
- || (item.getActionSet().isActive());
-
- if (bindings.length > 0) {
- if (available)
- text = NLS.bind(
- WorkbenchMessages.HideItems_keyBindings,
- keybindings);
- else
- text = NLS
- .bind(
- WorkbenchMessages.HideItems_keyBindingsActionSetUnavailable,
- keybindings);
- } else {
- if (available)
- text = WorkbenchMessages.HideItems_noKeyBindings;
- else
- text = WorkbenchMessages.HideItems_noKeyBindingsActionSetUnavailable;
- }
-
- // Construct link to go to the preferences page for key
- // bindings
- final Object highlight;
- if (bindings.length == 0) {
- Map parameters = new HashMap();
-
- // If item is a shortcut, need to add a parameter to go
- // to
- // the correct item
- if (item instanceof ShortcutItem) {
- if (isNewWizard(item)) {
- parameters.put(
- IWorkbenchCommandConstants.FILE_NEW_PARM_WIZARDID,
- getParamID(item));
- } else if (isShowPerspective(item)) {
- parameters
- .put(
- IWorkbenchCommandConstants.PERSPECTIVES_SHOW_PERSPECTIVE_PARM_ID,
- getParamID(item));
- } else if (isShowView(item)) {
- parameters.put(
- IWorkbenchCommandConstants.VIEWS_SHOW_VIEW_PARM_ID,
- getParamID(item));
- }
- }
-
- ParameterizedCommand pc = ParameterizedCommand
- .generateCommand(command, parameters);
- highlight = pc;
- } else {
- highlight = bindings[0];
- }
-
- Link bindingLink = createEntryWithLink(destination, null,
- text);
-
- bindingLink.addSelectionListener(new SelectionListener() {
- public void widgetDefaultSelected(SelectionEvent e) {
- widgetDefaultSelected(e);
- }
-
- public void widgetSelected(SelectionEvent e) {
- PreferenceDialog dialog = PreferencesUtil
- .createPreferenceDialogOn(getShell(),
- KEYS_PREFERENCE_PAGE_ID,
- new String[0], highlight);
- hide();
- dialog.open();
- }
- });
- }
- }
-
- // Show dynamic menu item info
- if (item instanceof DynamicContributionItem) {
- DynamicContributionItem dynamic = ((DynamicContributionItem) item);
- StringBuffer text = new StringBuffer();
- final List currentItems = dynamic.getCurrentItems();
-
- if (currentItems.size() > 0) {
- // Create a list of the currently displayed items
- text.append(WorkbenchMessages.HideItems_dynamicItemList);
- for (Iterator i = currentItems.iterator(); i.hasNext();) {
- MenuItem menuItem = (MenuItem) i.next();
- text.append(NEW_LINE).append("- ") //$NON-NLS-1$
- .append(menuItem.getText());
- }
- } else {
- text
- .append(WorkbenchMessages.HideItems_dynamicItemEmptyList);
- }
- createEntry(destination, null, text.toString());
- }
- }
-
- protected Object getModelElement(Event event) {
- org.eclipse.swt.widgets.TreeItem treeItem = tree.getItem(new Point(
- event.x, event.y));
- if (treeItem == null)
- return null;
- return treeItem.getData();
- }
- }
-
- /**
- * Filters out contribution items which are not in a given action set.
- *
- * @since 3.5
- */
- private static class ActionSetFilter extends ViewerFilter {
- private ActionSet actionSet;
-
- public void setActionSet(ActionSet actionSet) {
- this.actionSet = actionSet;
- }
-
- public boolean select(Viewer viewer, Object parentElement,
- Object element) {
- if (!(element instanceof DisplayItem))
- return false;
- if (actionSet == null)
- return false;
- return includeInSetStructure((DisplayItem) element, actionSet);
- }
- }
-
- /**
- * A check provider which calculates checked state based on leaf states in
- * the tree (as opposed to children in a model).
- *
- * @since 3.5
- */
- private static class FilteredTreeCheckProvider implements
- ICheckStateProvider {
- private ITreeContentProvider contentProvider;
- private ViewerFilter filter;
-
- public FilteredTreeCheckProvider(ITreeContentProvider contentProvider,
- ViewerFilter filter) {
- this.contentProvider = contentProvider;
- this.filter = filter;
- }
-
- public boolean isChecked(Object element) {
- TreeItem treeItem = (TreeItem) element;
- return getLeafStates(treeItem, contentProvider, filter) != TreeManager.CHECKSTATE_UNCHECKED;
- }
-
- public boolean isGrayed(Object element) {
- TreeItem treeItem = (TreeItem) element;
- return getLeafStates(treeItem, contentProvider, filter) == TreeManager.CHECKSTATE_GRAY;
- }
- }
-
- /**
- * A check listener to bring about the expected change in a model based on a
- * check event in a filtered viewer. Since the checked state of a parent in
- * a filtered viewer is not based on its model state, but rather its leafs'
- * states, when a non-leaf element's check state changes, its model state
- * does not necessarily change, but its leafs' model states do.
- *
- * @since 3.5
- */
- private static class FilteredViewerCheckListener implements
- ICheckStateListener {
- private ITreeContentProvider contentProvider;
- private ViewerFilter filter;
-
- public FilteredViewerCheckListener(
- ITreeContentProvider contentProvider, ViewerFilter filter) {
- this.contentProvider = contentProvider;
- this.filter = filter;
- }
-
- public void checkStateChanged(CheckStateChangedEvent event) {
- setAllLeafs((DisplayItem) event.getElement(), event
- .getChecked(), contentProvider, filter);
- }
- }
-
- /**
- * On a model change, update a filtered listener. While the check listener
- * provided by the model will take care of the elements which change, since
- * we simulate our own check state of parents, the parents may need to be
- * updated.
- *
- * @since 3.5
- */
- private final class FilteredModelCheckListener implements CheckListener {
- private final ActionSetFilter filter;
- private final StructuredViewer viewer;
-
- private FilteredModelCheckListener(ActionSetFilter filter,
- StructuredViewer viewer) {
- this.filter = filter;
- this.viewer = viewer;
- }
-
- public void checkChanged(TreeItem changedItem) {
- TreeItem item = changedItem;
- boolean update = false;
-
- // Force an update on all parents.
- while (item != null) {
- update = update || filter.select(null, null, item);
- if (update) {
- viewer.update(item, null);
- }
- item = item.getParent();
- }
- }
- }
-
- /**
- * A check listener which, upon changing the check state of a contribution
- * item, checks if that item is eligible to be checked (i.e. it is in an
- * available action set), and if not, informs the user of the illegal
- * operation. If the operation is legal, the event is forwarded to the check
- * listener to actually perform a useful action.
- *
- * @since 3.5
- */
- private class UnavailableContributionItemCheckListener implements
- ICheckStateListener {
- private CheckboxTreeViewer viewer;
- private ICheckStateListener originalListener;
-
- /**
- * @param viewer
- * the viewer being listened to
- * @param originalListener
- * the listener to invoke upon a legal action
- */
- public UnavailableContributionItemCheckListener(
- CheckboxTreeViewer viewer, ICheckStateListener originalListener) {
- this.viewer = viewer;
- this.originalListener = originalListener;
- }
-
- public void checkStateChanged(CheckStateChangedEvent event) {
- DisplayItem item = (DisplayItem) event.getElement();
- ViewerFilter[] filters = viewer.getFilters();
- boolean isEffectivelyAvailable = isEffectivelyAvailable(item, filters.length > 0 ? filters[0] : null);
-
- if (isEffectivelyAvailable) {
- // legal action - invoke the listener which will do actual work
- originalListener.checkStateChanged(event);
- return;
- }
-
- boolean isAvailable = isAvailable(item);
- viewer.update(event.getElement(), null);
-
- if (isAvailable) {
- // the case where this item is unavailable because of its
- // children
- if (viewer.getExpandedState(item)) {
- MessageBox mb = new MessageBox(viewer.getControl()
- .getShell(), SWT.OK | SWT.ICON_WARNING | SWT.SHEET);
- mb
- .setText(WorkbenchMessages.HideItemsCannotMakeVisible_dialogTitle);
- mb
- .setMessage(NLS
- .bind(
- WorkbenchMessages.HideItemsCannotMakeVisible_unavailableChildrenText,
- item.getLabel()));
- mb.open();
- } else {
- MessageBox mb = new MessageBox(viewer.getControl()
- .getShell(), SWT.OK | SWT.ICON_WARNING | SWT.SHEET);
- mb
- .setText(WorkbenchMessages.HideItemsCannotMakeVisible_dialogTitle);
- mb
- .setMessage(NLS
- .bind(
- WorkbenchMessages.HideItemsCannotMakeVisible_unavailableChildrenText,
- item.getLabel()));
- mb.open();
- }
- } else {
- // the case where this item is unavailable because it belongs to
- // an unavailable action set
- MessageBox mb = new MessageBox(viewer.getControl().getShell(),
- SWT.YES | SWT.NO | SWT.ICON_WARNING | SWT.SHEET);
- mb
- .setText(WorkbenchMessages.HideItemsCannotMakeVisible_dialogTitle);
- final String errorExplanation = NLS
- .bind(
- WorkbenchMessages.HideItemsCannotMakeVisible_unavailableCommandGroupText,
- item.getLabel(), item.getActionSet());
- final String message = NLS
- .bind(
- "{0}{1}{1}{2}", new Object[] { errorExplanation, NEW_LINE, WorkbenchMessages.HideItemsCannotMakeVisible_switchToCommandGroupTab }); //$NON-NLS-1$
- mb.setMessage(message);
- if (mb.open() == SWT.YES) {
- viewActionSet(item);
- }
- }
- }
- }
-
- /**
- * A label provider which takes the default label provider in the
- * TreeManager, and adds on functionality to gray out text and icons of
- * contribution items whose action sets are unavailable.
- *
- * @since 3.5
- *
- */
- private class GrayOutUnavailableLabelProvider extends
- TreeManager.TreeItemLabelProvider implements IColorProvider {
- private Display display;
- private ViewerFilter filter;
-
- public GrayOutUnavailableLabelProvider(Display display, ViewerFilter filter) {
- this.display = display;
- this.filter = filter;
- }
-
- public Color getBackground(Object element) {
- return null;
- }
-
- public Color getForeground(Object element) {
- if (!isEffectivelyAvailable((DisplayItem) element, filter)) {
- return display.getSystemColor(SWT.COLOR_GRAY);
- }
- return null;
- }
-
- public Image getImage(Object element) {
- Image actual = super.getImage(element);
-
- if (element instanceof DisplayItem && actual != null) {
- DisplayItem item = (DisplayItem) element;
- if (!isEffectivelyAvailable(item, filter)) {
- ImageDescriptor original = ImageDescriptor
- .createFromImage(actual);
- ImageDescriptor disable = ImageDescriptor.createWithFlags(
- original, SWT.IMAGE_DISABLE);
- Image newImage = disable.createImage();
- toDispose.add(newImage);
- return newImage;
- }
- }
-
- return actual;
- }
- }
-
- /**
- * The proxy IActionBarConfigurer that gets passed to the application's
- * ActionBarAdvisor. This is used to construct a representation of the
- * window's hardwired menus and toolbars in order to display their structure
- * properly in the preview panes.
- *
- * @since 3.5
- */
- public class CustomizeActionBars implements IActionBarConfigurer2,
- IActionBars2 {
-
- IWorkbenchWindowConfigurer configurer;
-
- /**
- * Fake action bars to use to build the menus and toolbar contributions
- * for the workbench. We cannot use the actual workbench action bars,
- * since doing so would make the action set items visible.
- */
- private MenuManager menuManager = new MenuManager();
- private CoolBarManager coolBarManager = new CoolBarManager();
- private StatusLineManager statusLineManager = new StatusLineManager();
-
- /**
- * Create a new instance of this class.
- *
- * @param configurer
- * the configurer
- */
- public CustomizeActionBars(IWorkbenchWindowConfigurer configurer) {
- this.configurer = configurer;
- }
-
- public IWorkbenchWindowConfigurer getWindowConfigurer() {
- return configurer;
- }
-
- public IMenuManager getMenuManager() {
- return menuManager;
- }
-
- public IStatusLineManager getStatusLineManager() {
- return statusLineManager;
- }
-
- public ICoolBarManager getCoolBarManager() {
- return coolBarManager;
- }
-
- public IToolBarManager getToolBarManager() {
- return null;
- }
-
- public void setGlobalActionHandler(String actionID, IAction handler) {
- }
-
- public void updateActionBars() {
- }
-
- public void clearGlobalActionHandlers() {
- }
-
- public IAction getGlobalActionHandler(String actionId) {
- return null;
- }
-
- public void registerGlobalAction(IAction action) {
- }
-
- /**
- * Clean up the action bars.
- */
- public void dispose() {
- coolBarManager.dispose();
- menuManager.dispose();
- statusLineManager.dispose();
- }
-
- public final IServiceLocator getServiceLocator() {
- return configurer.getWindow();
- }
-
- public IToolBarContributionItem createToolBarContributionItem(
- IToolBarManager toolBarManager, String id) {
- return new ToolBarContributionItem2(toolBarManager, id);
- }
-
- public IToolBarManager createToolBarManager() {
- return new ToolBarManager();
- }
- }
-
- /**
- * Create an instance of this Dialog.
- *
- * @param configurer
- * the configurer
- * @param persp
- * the perspective
- */
- public CustomizePerspectiveDialog(IWorkbenchWindowConfigurer configurer,
- Perspective persp) {
- super(configurer.getWindow().getShell());
- this.treeManager = new TreeManager();
- this.configurer = configurer;
- perspective = persp;
- window = (WorkbenchWindow) configurer.getWindow();
-
- toDispose = new HashSet();
-
- initializeIcons();
-
- initializeActionSetInput();
- loadMenuAndToolbarStructure();
- }
-
- protected void configureShell(Shell shell) {
- super.configureShell(shell);
- String title = perspective.getDesc().getLabel();
-
- title = NLS.bind(WorkbenchMessages.ActionSetSelection_customize, title);
- shell.setText(title);
- window.getWorkbench().getHelpSystem().setHelp(shell,
- IWorkbenchHelpContextIds.ACTION_SET_SELECTION_DIALOG);
- }
-
- protected Control createDialogArea(Composite parent) {
- // Create a font for titles in the tooltips
- FontData[] defaultFont = JFaceResources.getDefaultFont().getFontData();
- FontData boldFontData = new FontData(defaultFont[0].getName(),
- defaultFont[0].getHeight(), SWT.BOLD);
- tooltipHeading = new Font(parent.getDisplay(), boldFontData);
-
- Composite composite = (Composite) super.createDialogArea(parent);
-
- // tab folder
- tabFolder = new TabFolder(composite, SWT.NONE);
-
- GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
- gd.widthHint = convertHorizontalDLUsToPixels(TAB_WIDTH_IN_DLUS);
- gd.heightHint = convertVerticalDLUsToPixels(TAB_HEIGHT_IN_DLUS);
- tabFolder.setLayoutData(gd);
-
- // Tool Bar Item Hiding Page
- TabItem tab = new TabItem(tabFolder, SWT.NONE);
- tab.setText(WorkbenchMessages.HideToolBarItems_toolBarItemsTab);
- tab.setControl(createToolBarVisibilityPage(tabFolder));
-
- // Menu Item Hiding Page
- tab = new TabItem(tabFolder, SWT.NONE);
- tab.setControl(createMenuVisibilityPage(tabFolder));
- tab.setText(WorkbenchMessages.HideMenuItems_menuItemsTab);
-
- // Action Set Availability Page
- actionSetTab = new TabItem(tabFolder, SWT.NONE);
- actionSetTab
- .setText(WorkbenchMessages.ActionSetSelection_actionSetsTab);
- actionSetTab.setControl(createActionSetAvailabilityPage(tabFolder));
-
- // Shortcuts Page
- if (showShortcutTab()) {
- TabItem item1 = new TabItem(tabFolder, SWT.NONE);
- item1.setText(WorkbenchMessages.Shortcuts_shortcutTab);
- item1.setControl(createShortCutsPage(tabFolder));
- }
-
- applyDialogFont(tabFolder);
-
- return composite;
- }
-
- private Composite createShortCutsPage(Composite parent) {
- GridData data;
-
- Composite menusComposite = new Composite(parent, SWT.NONE);
- GridLayout layout = new GridLayout();
- menusComposite.setLayout(layout);
-
- // Select... label
- Label label = new Label(menusComposite, SWT.WRAP);
- label.setText(NLS.bind(
- WorkbenchMessages.Shortcuts_selectShortcutsLabel, perspective
- .getDesc().getLabel()));
- data = new GridData(SWT.FILL, SWT.CENTER, true, false);
- label.setLayoutData(data);
-
- Label sep = new Label(menusComposite, SWT.HORIZONTAL | SWT.SEPARATOR);
- sep.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
-
- SashForm sashComposite = new SashForm(menusComposite, SWT.HORIZONTAL);
- data = new GridData(SWT.FILL, SWT.FILL, true, true);
- sashComposite.setLayoutData(data);
-
- // Menus List
- Composite menusGroup = new Composite(sashComposite, SWT.NONE);
- layout = new GridLayout();
- layout.marginHeight = 0;
- layout.marginWidth = 0;
- menusGroup.setLayout(layout);
- menusGroup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
-
- label = new Label(menusGroup, SWT.WRAP);
- label.setText(WorkbenchMessages.Shortcuts_availableMenus);
- label.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
-
- Combo menusCombo = new Combo(menusGroup, SWT.READ_ONLY);
- menusCombo
- .setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
- ComboViewer menusViewer = new ComboViewer(menusCombo);
- menusViewer.setContentProvider(TreeManager.getTreeContentProvider());
- menusViewer.setLabelProvider(TreeManager.getLabelProvider());
-
- // Categories Tree
- label = new Label(menusGroup, SWT.WRAP);
- label.setText(WorkbenchMessages.Shortcuts_availableCategories);
- label.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
-
- final CheckboxTreeViewer menuCategoriesViewer = new CheckboxTreeViewer(
- menusGroup);
- menuCategoriesViewer.getControl().setLayoutData(
- new GridData(SWT.FILL, SWT.FILL, true, true));
- menuCategoriesViewer.setLabelProvider(TreeManager.getLabelProvider());
- menuCategoriesViewer.setContentProvider(TreeManager
- .getTreeContentProvider());
- menuCategoriesViewer.setComparator(new WorkbenchViewerComparator());
- menuCategoriesViewer.setCheckStateProvider(new CategoryCheckProvider());
- menuCategoriesViewer.addCheckStateListener(new ICheckStateListener() {
- public void checkStateChanged(CheckStateChangedEvent event) {
- Category category = (Category) event.getElement();
- category.setItemsState(event.getChecked());
- updateCategoryAndParents(menuCategoriesViewer, category);
- }
- });
-
- treeManager.addListener(new CheckListener() {
- public void checkChanged(TreeItem changedItem) {
- if (changedItem instanceof Category) {
- menuCategoriesViewer.update(changedItem, null);
- } else if (changedItem instanceof ShortcutItem) {
- ShortcutItem item = (ShortcutItem) changedItem;
- if (item.getCategory() != null) {
- item.getCategory().update();
- updateCategoryAndParents(menuCategoriesViewer, item
- .getCategory());
- }
- }
- }
- });
-
- // Menu items list
- Composite menuItemsGroup = new Composite(sashComposite, SWT.NONE);
- layout = new GridLayout();
- layout.marginHeight = 0;
- layout.marginWidth = 0;
- menuItemsGroup.setLayout(layout);
- menuItemsGroup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true,
- true));
-
- label = new Label(menuItemsGroup, SWT.WRAP);
- label.setText(WorkbenchMessages.Shortcuts_allShortcuts);
- label.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
-
- final CheckboxTableViewer menuItemsViewer = CheckboxTableViewer
- .newCheckList(menuItemsGroup, SWT.BORDER | SWT.H_SCROLL
- | SWT.V_SCROLL);
- Table menuTable = menuItemsViewer.getTable();
- menuTable.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
- menuItemsViewer.setLabelProvider(new ShortcutLabelProvider());
- menuItemsViewer.setCheckStateProvider(TreeManager
- .getCheckStateProvider());
- menuItemsViewer.addCheckStateListener(treeManager
- .getViewerCheckStateListener());
- treeManager.getCheckListener(menuItemsViewer);
-
- menuItemsViewer
- .setContentProvider(new TreeManager.TreeItemContentProvider() {
- public Object[] getChildren(Object parentElement) {
- if (parentElement instanceof Category)
- return ((Category) parentElement)
- .getContributionItems().toArray();
- return super.getChildren(parentElement);
- }
- });
- menuItemsViewer.setComparator(new WorkbenchViewerComparator());
-
- // update menuCategoriesViewer, and menuItemsViewer on a change to
- // menusViewer
- menusViewer
- .addSelectionChangedListener(new ISelectionChangedListener() {
- public void selectionChanged(SelectionChangedEvent event) {
- Category category = (Category) ((IStructuredSelection) event
- .getSelection()).getFirstElement();
- menuCategoriesViewer.setInput(category);
- menuItemsViewer.setInput(category);
- if (category.getChildren().size() != 0) {
- setSelectionOn(menuCategoriesViewer, category
- .getChildren().get(0));
- }
- }
- });
-
- // update menuItemsViewer on a change to menuCategoriesViewer
- menuCategoriesViewer
- .addSelectionChangedListener(new ISelectionChangedListener() {
- public void selectionChanged(SelectionChangedEvent event) {
- Category category = (Category) ((IStructuredSelection) event
- .getSelection()).getFirstElement();
- menuItemsViewer.setInput(category);
- }
- });
-
- menuTable.setHeaderVisible(true);
- int[] columnWidths = new int[shortcutMenuColumnWidths.length];
- for (int i = 0; i < shortcutMenuColumnWidths.length; i++) {
- columnWidths[i] = convertHorizontalDLUsToPixels(shortcutMenuColumnWidths[i]);
- }
- for (int i = 0; i < shortcutMenuColumnHeaders.length; i++) {
- TableColumn tc = new TableColumn(menuTable, SWT.NONE, i);
- tc.setResizable(true);
- tc.setText(shortcutMenuColumnHeaders[i]);
- tc.setWidth(columnWidths[i]);
- }
- sashComposite.setWeights(new int[] { 30, 70 });
-
- menusViewer.setInput(shortcuts);
-
- if (shortcuts.getChildren().size() > 0) {
- setSelectionOn(menusViewer, shortcuts.getChildren().get(0));
- }
-
- return menusComposite;
- }
-
- private Composite createActionSetAvailabilityPage(Composite parent) {
- GridData data;
-
- Composite actionSetsComposite = new Composite(parent, SWT.NONE);
- GridLayout layout = new GridLayout();
- actionSetsComposite.setLayout(layout);
-
- // Select... label
- Label label = new Label(actionSetsComposite, SWT.WRAP);
- label.setText(NLS.bind(
- WorkbenchMessages.ActionSetSelection_selectActionSetsLabel,
- perspective.getDesc().getLabel()));
- data = new GridData(SWT.FILL, SWT.CENTER, true, false);
- label.setLayoutData(data);
-
- Label sep = new Label(actionSetsComposite, SWT.HORIZONTAL
- | SWT.SEPARATOR);
- sep.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
-
- SashForm sashComposite = new SashForm(actionSetsComposite,
- SWT.HORIZONTAL);
- data = new GridData(SWT.FILL, SWT.FILL, true, true);
- sashComposite.setLayoutData(data);
-
- // Action Set List Composite
- Composite actionSetGroup = new Composite(sashComposite, SWT.NONE);
- layout = new GridLayout();
- layout.marginHeight = 0;
- layout.marginWidth = 0;
- actionSetGroup.setLayout(layout);
- actionSetGroup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true,
- true));
-
- label = new Label(actionSetGroup, SWT.WRAP);
- label.setText(WorkbenchMessages.ActionSetSelection_availableActionSets);
- label.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
-
- final CheckboxTableViewer actionSetsViewer = CheckboxTableViewer
- .newCheckList(actionSetGroup, SWT.BORDER | SWT.H_SCROLL
- | SWT.V_SCROLL);
- actionSetAvailabilityTable = actionSetsViewer;
- actionSetsViewer.getTable().setLayoutData(
- new GridData(SWT.FILL, SWT.FILL, true, true));
- actionSetsViewer.setLabelProvider(new LabelProvider());
- actionSetsViewer.setContentProvider(new ArrayContentProvider());
- actionSetsViewer.setComparator(new WorkbenchViewerComparator());
- actionSetsViewer.setCheckStateProvider(new ICheckStateProvider() {
- public boolean isChecked(Object element) {
- return ((ActionSet) element).isActive();
- }
-
- public boolean isGrayed(Object element) {
- return false;
- }
- });
- actionSetsViewer.setInput(actionSets.toArray());
-
- Table table = actionSetsViewer.getTable();
- new TableToolTip(table);
-
- final ActionSet[] selectedActionSet = { null };
-
- // Filter to show only branches necessary for the selected action set.
- final ViewerFilter setFilter = new ViewerFilter() {
- public boolean select(Viewer viewer, Object parentElement,
- Object element) {
- if (selectedActionSet[0] == null)
- return false;
- return includeInSetStructure((DisplayItem) element,
- selectedActionSet[0]);
- }
- };
-
- // Updates the check state of action sets
- actionSetsViewer.addCheckStateListener(new ICheckStateListener() {
- public void checkStateChanged(CheckStateChangedEvent event) {
- final ActionSet actionSet = (ActionSet) event.getElement();
- if (event.getChecked()) {
- actionSet.setActive(true);
- for (Iterator i = actionSet.contributionItems.iterator(); i
- .hasNext();) {
- DisplayItem item = (DisplayItem) i.next();
- item.setCheckState(true);
- }
- } else {
- actionSet.setActive(false);
- }
- }
- });
-
- // Menu and toolbar composite
- Composite actionGroup = new Composite(sashComposite, SWT.NONE);
- layout = new GridLayout();
- layout.numColumns = 2;
- layout.makeColumnsEqualWidth = true;
- layout.marginHeight = 0;
- layout.marginWidth = 0;
- layout.horizontalSpacing = 0;
- actionGroup.setLayout(layout);
- actionGroup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
-
- Composite menubarGroup = new Composite(actionGroup, SWT.NONE);
- layout = new GridLayout();
- layout.marginHeight = 0;
- layout.marginWidth = 0;
- menubarGroup.setLayout(layout);
- menubarGroup
- .setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
-
- label = new Label(menubarGroup, SWT.WRAP);
- label.setText(WorkbenchMessages.ActionSetSelection_menubarActions);
- label.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
-
- final TreeViewer actionSetMenuViewer = new TreeViewer(menubarGroup);
- actionSetMenuViewer.setAutoExpandLevel(AbstractTreeViewer.ALL_LEVELS);
- actionSetMenuViewer.getControl().setLayoutData(
- new GridData(SWT.FILL, SWT.FILL, true, true));
- actionSetMenuViewer.setUseHashlookup(true);
- actionSetMenuViewer.setContentProvider(TreeManager
- .getTreeContentProvider());
- actionSetMenuViewer.setLabelProvider(TreeManager.getLabelProvider());
- actionSetMenuViewer.addFilter(setFilter);
- actionSetMenuViewer.setInput(menuItems);
-
- Tree tree = actionSetMenuViewer.getTree();
- new ItemDetailToolTip(actionSetMenuViewer, tree, false, true, setFilter);
-
- Composite toolbarGroup = new Composite(actionGroup, SWT.NONE);
- layout = new GridLayout();
- layout.marginHeight = 0;
- layout.marginWidth = 0;
- toolbarGroup.setLayout(layout);
- toolbarGroup
- .setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
-
- label = new Label(toolbarGroup, SWT.WRAP);
- label.setText(WorkbenchMessages.ActionSetSelection_toolbarActions);
- label.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
-
- final TreeViewer actionSetToolbarViewer = new TreeViewer(toolbarGroup);
- actionSetToolbarViewer
- .setAutoExpandLevel(AbstractTreeViewer.ALL_LEVELS);
- actionSetToolbarViewer.getControl().setLayoutData(
- new GridData(SWT.FILL, SWT.FILL, true, true));
- actionSetToolbarViewer.setContentProvider(TreeManager
- .getTreeContentProvider());
- actionSetToolbarViewer.setLabelProvider(TreeManager.getLabelProvider());
- actionSetToolbarViewer.addFilter(setFilter);
- actionSetToolbarViewer.setInput(toolBarItems);
-
- tree = actionSetToolbarViewer.getTree();
- new ItemDetailToolTip(actionSetToolbarViewer, tree, false, true, setFilter);
-
- // Updates the menu item and toolbar items tree viewers when the
- // selection changes
- actionSetsViewer
- .addSelectionChangedListener(new ISelectionChangedListener() {
- public void selectionChanged(SelectionChangedEvent event) {
- selectedActionSet[0] = (ActionSet) ((IStructuredSelection) event
- .getSelection()).getFirstElement();
- actionSetMenuViewer.setInput(menuItems);
- actionSetToolbarViewer.setInput(toolBarItems);
- }
- });
-
- sashComposite.setWeights(new int[] { 30, 70 });
-
- return actionSetsComposite;
- }
-
- /**
- * Creates the page used to allow users to choose menu items to hide.
- */
- private Composite createMenuVisibilityPage(Composite parent) {
- GridData data;
-
- Composite hideMenuItemsComposite = new Composite(parent, SWT.NONE);
- GridLayout layout = new GridLayout();
- hideMenuItemsComposite.setLayout(layout);
-
- // Label for entire tab
- Label label = new Label(hideMenuItemsComposite, SWT.WRAP);
- label.setText(WorkbenchMessages.HideMenuItems_chooseMenuItemsLabel);
- data = new GridData(SWT.FILL, SWT.CENTER, true, false);
- label.setLayoutData(data);
-
- Label sep = new Label(hideMenuItemsComposite, SWT.HORIZONTAL
- | SWT.SEPARATOR);
- sep.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
-
- // Main contents of tab
- final PageBook book = new PageBook(hideMenuItemsComposite, SWT.NONE);
- data = new GridData(GridData.FILL_BOTH);
- book.setLayoutData(data);
-
- // Simple view: just the menu structure
- final Composite simpleComposite = createItemStructureGroup(book,
- WorkbenchMessages.HideMenuItems_menuStructure);
- menuStructureViewer1 = initStructureViewer(simpleComposite,
- new TreeManager.ViewerCheckStateListener(), null);
-
- // Update the viewer when the model changes
- treeManager.getCheckListener(menuStructureViewer1); // To update ctv on
- // model changes
-
- // Simply grab the checkstate out of the model
- menuStructureViewer1.setCheckStateProvider(TreeManager
- .getCheckStateProvider());
-
- // Init with input
- menuStructureViewer1.setInput(menuItems);
-
- // Advanced view: action set with filtered menu structure
- final SashForm advancedComposite = new SashForm(book, SWT.HORIZONTAL);
- data = new GridData(SWT.FILL, SWT.FILL, true, true);
- advancedComposite.setLayoutData(data);
-
- // Action set list
- final TableViewer actionSetViewer = initActionSetViewer(createActionSetGroup(advancedComposite));
-
- // Filter to only show action sets which have useful menu items
- actionSetViewer.addFilter(new ShowUsedActionSetsFilter(menuItems));
-
- // Init with input
- actionSetViewer.setInput(actionSets.toArray());
-
- // Filter to only show items in the current action set
- final ActionSetFilter menuStructureFilterByActionSet = new ActionSetFilter();
-
- final Composite menuStructureComposite = createItemStructureGroup(
- advancedComposite,
- WorkbenchMessages.HideMenuItems_menuStructure);
- final ICheckStateListener menuStructureFilter = new FilteredViewerCheckListener(
- TreeManager.getTreeContentProvider(),
- menuStructureFilterByActionSet);
- menuStructureViewer2 = initStructureViewer(menuStructureComposite,
- menuStructureFilter, menuStructureFilterByActionSet);
-
- treeManager.addListener(new FilteredModelCheckListener(
- menuStructureFilterByActionSet, menuStructureViewer2));
-
- menuStructureViewer2.addFilter(menuStructureFilterByActionSet);
-
- // Update filter when a new action set is selected
- actionSetViewer
- .addSelectionChangedListener(new ActionSetSelectionChangedListener(
- menuStructureViewer2, menuStructureFilterByActionSet));
-
- // Check state provider to emulate standard SWT
- // behaviour on visual tree
- menuStructureViewer2
- .setCheckStateProvider(new FilteredTreeCheckProvider(
- TreeManager.getTreeContentProvider(),
- menuStructureFilterByActionSet));
-
- // Init input
- menuStructureViewer2.setInput(menuItems);
-
- // Override any attempts to set an item to visible
- // which exists in an unavailable action set
- treeManager.addListener(new CheckListener() {
- public void checkChanged(TreeItem changedItem) {
- if (!(changedItem instanceof DisplayItem))
- return;
- if (!changedItem.getState())
- return;
- if (isAvailable((DisplayItem) changedItem))
- return;
- changedItem.setCheckState(false);
- }
- });
-
- final Button showCommandGroupFilterButton = new Button(
- hideMenuItemsComposite, SWT.CHECK);
- showCommandGroupFilterButton
- .setText(WorkbenchMessages.HideItems_turnOnActionSets);
- showCommandGroupFilterButton
- .addSelectionListener(new SelectionListener() {
- public void widgetDefaultSelected(SelectionEvent e) {
- }
-
- public void widgetSelected(SelectionEvent e) {
- if (showCommandGroupFilterButton.getSelection()) {
- Object o = ((StructuredSelection) menuStructureViewer1
- .getSelection()).getFirstElement();
- ActionSet initSelectAS = null;
- DisplayItem initSelectCI = null;
- if (o instanceof DisplayItem) {
- initSelectCI = ((DisplayItem) o);
- initSelectAS = initSelectCI.getActionSet();
- }
- if (initSelectAS == null) {
- initSelectAS = (ActionSet) actionSetViewer
- .getElementAt(0);
- }
- setSelectionOn(actionSetViewer, initSelectAS);
- actionSetViewer.reveal(initSelectAS);
- if (initSelectCI != null) {
- setSelectionOn(menuStructureViewer2,
- initSelectCI);
- menuStructureViewer2.reveal(initSelectCI);
- }
- book.showPage(advancedComposite);
- } else {
- book.showPage(simpleComposite);
- }
- }
- });
-
- book.showPage(simpleComposite);
- advancedComposite.setWeights(new int[] { 30, 70 });
-
- return hideMenuItemsComposite;
- }
-
- /**
- * Creates the page used to allow users to choose menu items to hide.
- */
- private Composite createToolBarVisibilityPage(Composite parent) {
- GridData data;
-
- Composite hideToolbarItemsComposite = new Composite(parent, SWT.NONE);
- GridLayout layout = new GridLayout();
- hideToolbarItemsComposite.setLayout(layout);
-
- // Label for entire tab
- Label label = new Label(hideToolbarItemsComposite, SWT.WRAP);
- label
- .setText(WorkbenchMessages.HideToolBarItems_chooseToolBarItemsLabel);
- data = new GridData(SWT.FILL, SWT.CENTER, true, false);
- label.setLayoutData(data);
-
- Label sep = new Label(hideToolbarItemsComposite, SWT.HORIZONTAL
- | SWT.SEPARATOR);
- sep.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
-
- // Main contents of tab
- final PageBook book = new PageBook(hideToolbarItemsComposite, SWT.NONE);
- data = new GridData(GridData.FILL_BOTH);
- book.setLayoutData(data);
-
- // Simple view: just the toolbar structure
- final Composite simpleComposite = createItemStructureGroup(book,
- WorkbenchMessages.HideToolBarItems_toolBarStructure);
- toolbarStructureViewer1 = initStructureViewer(simpleComposite,
- new TreeManager.ViewerCheckStateListener(), null);
-
- // Update the viewer when the model changes
- treeManager.getCheckListener(toolbarStructureViewer1); // To update ctv
- // on model
- // changes
-
- // Simply grab the check state out of the model
- toolbarStructureViewer1.setCheckStateProvider(TreeManager
- .getCheckStateProvider());
-
- // Init with input
- toolbarStructureViewer1.setInput(toolBarItems);
-
- // Advanced view: action set with filtered toolbar structure
- final SashForm advancedComposite = new SashForm(book, SWT.HORIZONTAL);
- data = new GridData(SWT.FILL, SWT.FILL, true, true);
- advancedComposite.setLayoutData(data);
-
- // Action set list
- final TableViewer actionSetViewer = initActionSetViewer(createActionSetGroup(advancedComposite));
-
- // Filter to only show action sets which have useful toolbar items
- actionSetViewer.addFilter(new ShowUsedActionSetsFilter(toolBarItems));
-
- // Init with input
- actionSetViewer.setInput(actionSets.toArray());
-
- // Filter to only show items in the current action set
- final ActionSetFilter toolbarStructureFilterByActionSet = new ActionSetFilter();
-
- final Composite toolbarStructureComposite = createItemStructureGroup(
- advancedComposite,
- WorkbenchMessages.HideToolBarItems_toolBarStructure);
- final ICheckStateListener toolbarStructureFilter = new FilteredViewerCheckListener(
- TreeManager.getTreeContentProvider(),
- toolbarStructureFilterByActionSet);
- toolbarStructureViewer2 = initStructureViewer(
- toolbarStructureComposite, toolbarStructureFilter,
- toolbarStructureFilterByActionSet);
-
- toolbarStructureViewer2.addFilter(toolbarStructureFilterByActionSet);
-
- treeManager.addListener(new FilteredModelCheckListener(
- toolbarStructureFilterByActionSet, toolbarStructureViewer2));
-
- // Update filter when a new action set is selected
- actionSetViewer
- .addSelectionChangedListener(new ActionSetSelectionChangedListener(
- toolbarStructureViewer2,
- toolbarStructureFilterByActionSet));
-
- // Check state provider to emulate standard SWT
- // behaviour on visual tree
- toolbarStructureViewer2
- .setCheckStateProvider(new FilteredTreeCheckProvider(
- TreeManager.getTreeContentProvider(),
- toolbarStructureFilterByActionSet));
-
- // Init input
- toolbarStructureViewer2.setInput(toolBarItems);
-
- // Override any attempts to set an item to visible
- // which exists in an unavailable action set
- treeManager.addListener(new CheckListener() {
- public void checkChanged(TreeItem changedItem) {
- if (!(changedItem instanceof DisplayItem))
- return;
- if (!changedItem.getState())
- return;
- if (isAvailable((DisplayItem) changedItem))
- return;
- changedItem.setCheckState(false);
- }
- });
-
- final Button showCommandGroupFilterButton = new Button(
- hideToolbarItemsComposite, SWT.CHECK);
- showCommandGroupFilterButton
- .setText(WorkbenchMessages.HideItems_turnOnActionSets);
- showCommandGroupFilterButton
- .addSelectionListener(new SelectionListener() {
- public void widgetDefaultSelected(SelectionEvent e) {
- }
-
- public void widgetSelected(SelectionEvent e) {
- if (showCommandGroupFilterButton.getSelection()) {
- Object o = ((StructuredSelection) toolbarStructureViewer1
- .getSelection()).getFirstElement();
- ActionSet initSelectAS = null;
- DisplayItem initSelectCI = null;
- if (o instanceof DisplayItem) {
- initSelectCI = ((DisplayItem) o);
- initSelectAS = initSelectCI.getActionSet();
- }
- if (initSelectAS == null) {
- initSelectAS = (ActionSet) actionSetViewer
- .getElementAt(0);
- }
- setSelectionOn(actionSetViewer, initSelectAS);
- actionSetViewer.reveal(initSelectAS);
- if (initSelectCI != null) {
- setSelectionOn(toolbarStructureViewer2,
- initSelectCI);
- toolbarStructureViewer2.reveal(initSelectCI);
- }
- book.showPage(advancedComposite);
- } else {
- book.showPage(simpleComposite);
- }
- }
- });
-
- book.showPage(simpleComposite);
- advancedComposite.setWeights(new int[] { 30, 70 });
-
- return hideToolbarItemsComposite;
- }
-
- /**
- * Creates a table to display action sets.
- *
- * @param parent
- * @return a viewer to display action sets
- */
- private TableViewer initActionSetViewer(Composite parent) {
- // List of categories
- final TableViewer actionSetViewer = new TableViewer(parent, SWT.BORDER
- | SWT.H_SCROLL | SWT.V_SCROLL);
- actionSetViewer.getTable().setLayoutData(
- new GridData(GridData.FILL_BOTH));
- actionSetViewer.setLabelProvider(new LabelProvider());
- actionSetViewer.setComparator(new WorkbenchViewerComparator());
- actionSetViewer.setContentProvider(new ArrayContentProvider());
-
- // Tooltip on tree items
- Table table = actionSetViewer.getTable();
- new TableToolTip(table);
- return actionSetViewer;
- }
-
- /**
- * Creates a CheckboxTreeViewer to display menu or toolbar structure.
- *
- * @param parent
- * @param checkStateListener
- * the listener which listens to the viewer for check changes
- * @param filter the filter used in the viewer (null for none)
- * @return A viewer within <code>parent</code> which will show menu or
- * toolbar structure. It comes setup, only missing a
- * CheckStateProvider and its input.
- */
- private CheckboxTreeViewer initStructureViewer(Composite parent,
- ICheckStateListener checkStateListener, ViewerFilter filter) {
- CheckboxTreeViewer ctv = new CheckboxTreeViewer(parent, SWT.BORDER
- | SWT.H_SCROLL | SWT.V_SCROLL);
- ctv.getControl().setLayoutData(new GridData(GridData.FILL_BOTH));
- ctv.setUseHashlookup(true);
- ctv.setContentProvider(TreeManager.getTreeContentProvider());
- // use an UnavailableContributionItemCheckListener to filter check
- // events: if it is legal, forward it to the actual checkStateListener,
- // if not, inform the user
- ctv.addCheckStateListener(new UnavailableContributionItemCheckListener(
- ctv, checkStateListener));
- ctv.setLabelProvider(new GrayOutUnavailableLabelProvider(parent
- .getDisplay(), filter));
- new ItemDetailToolTip(ctv, ctv.getTree(), true, true, filter);
- return ctv;
- }
-
- /**
- * Creates a composite to put a tree viewer in to display menu or toolbar
- * items.
- */
- private static Composite createItemStructureGroup(
- final Composite composite, String labelText) {
- GridLayout layout;
- Label label;
- layout = new GridLayout();
- Composite menubarGroup = new Composite(composite, SWT.NONE);
- layout.marginHeight = 0;
- layout.marginWidth = 0;
- menubarGroup.setLayout(layout);
- menubarGroup
- .setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
-
- label = new Label(menubarGroup, SWT.WRAP);
- label.setText(labelText);
- label.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
-
- return menubarGroup;
- }
-
- /**
- * Creates a composite to put a viewer in to display action sets.
- */
- private static Composite createActionSetGroup(final Composite composite) {
- GridLayout layout;
- Label label;
- Composite actionSetGroup = new Composite(composite, SWT.NONE);
- layout = new GridLayout();
- layout.marginHeight = 0;
- layout.marginWidth = 0;
- actionSetGroup.setLayout(layout);
- actionSetGroup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true,
- true));
-
- label = new Label(actionSetGroup, SWT.WRAP);
- label.setText(WorkbenchMessages.HideItems_commandGroupTitle);
- label.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
-
- return actionSetGroup;
- }
-
- /**
- * Set the selection on a structured viewer.
- *
- * @param viewer
- * @param selected
- */
- private void setSelectionOn(Viewer viewer, final Object selected) {
- viewer.setSelection(new StructuredSelection(selected), true);
- }
-
- /**
- * Searches deeply to see if <code>item</code> is a node in a branch
- * containing a ContributionItem contributed by <code>set</code>.
- *
- * @param item
- * the item in question
- * @param set
- * the action set to look for
- * @return true iff <code>item</code> is required in build a tree including
- * elements in <code>set</code>
- */
- private static boolean includeInSetStructure(DisplayItem item,
- ActionSet set) {
- if (item.actionSet != null && item.actionSet.equals(set))
- return true;
- for (Iterator i = item.getChildren().iterator(); i.hasNext();) {
- DisplayItem child = (DisplayItem) i.next();
- if (includeInSetStructure(child, set))
- return true;
- }
- return false;
- }
-
- /**
- * @param item
- * @return true iff the item is available - i.e. if it belongs to an action
- * set, that that action set is available
- */
- private static boolean isAvailable(DisplayItem item) {
- if (item.getActionSet() == null)
- return true;
- if (item.getActionSet().isActive())
- return true;
- for (Iterator i = item.getChildren().iterator(); i.hasNext();) {
- DisplayItem child = (DisplayItem) i.next();
- if (isAvailable(child))
- return true;
- }
- return false;
- }
-
- /**
- * @param item
- * @return true iff the item will show up in a menu or tool bar structure -
- * i.e. it is available, or has a child which is available thus must
- * be displayed in order to display the child
- */
- private static boolean isEffectivelyAvailable(DisplayItem item, ViewerFilter filter) {
- if (!isAvailable(item))
- return false;
- final List children = item.getChildren();
- if (children.isEmpty())
- return true;
- for (Iterator i = children.iterator(); i.hasNext();) {
- DisplayItem child = (DisplayItem) i.next();
- if(filter != null && !filter.select(null, null, child))
- continue;
- if (isAvailable(child)) {
- return true;
- }
- }
- for (Iterator i = children.iterator(); i.hasNext();) {
- DisplayItem child = (DisplayItem) i.next();
- if(filter != null && !filter.select(null, null, child))
- continue;
- if (isEffectivelyAvailable(child, filter)) {
- return true;
- }
- }
- return false;
- }
-
- /**
- * @param collection
- * a collection, into which all command groups (action sets)
- * which contribute <code>item</code> or its descendants will be
- * placed
- * @param item the item to collect descendants of
- * @param filter the filter currently being used
- * @param item
- */
- private static void collectDescendantCommandGroups(Collection collection,
- DisplayItem item, ViewerFilter filter) {
- List children = item.getChildren();
- for (Iterator i = children.iterator(); i.hasNext();) {
- DisplayItem child = (DisplayItem) i.next();
- if ((filter == null || filter.select(null, null, child))
- && child.getActionSet() != null) {
- collection.add(child.getActionSet());
- }
- collectDescendantCommandGroups(collection, child, filter);
- }
- }
-
- /**
- * Gets the keybindings associated with a ContributionItem.
- */
- private Binding[] getKeyBindings(DisplayItem item) {
- IBindingService bindingService = (IBindingService) window
- .getService(IBindingService.class);
-
- if (!(bindingService instanceof BindingService))
- return new Binding[0];
-
- String id = getCommandID(item);
- String param = getParamID(item);
-
- BindingManager bindingManager = ((BindingService) bindingService)
- .getBindingManager();
-
- Collection allBindings = bindingManager
- .getActiveBindingsDisregardingContextFlat();
-
- List foundBindings = new ArrayList(2);
-
- for (Iterator i = allBindings.iterator(); i.hasNext();) {
- Binding binding = (Binding) i.next();
- if (binding.getParameterizedCommand() == null)
- continue;
- if (binding.getParameterizedCommand().getId() == null)
- continue;
- if (binding.getParameterizedCommand().getId().equals(id)) {
- if (param == null) {
- // We found it!
- foundBindings.add(binding);
- } else {
- // command parameters are only used in the shortcuts
- Map m = binding.getParameterizedCommand().getParameterMap();
- String key = null;
- if (isNewWizard(item)) {
- key = IWorkbenchCommandConstants.FILE_NEW_PARM_WIZARDID;
- } else if (isShowView(item)) {
- key = IWorkbenchCommandConstants.VIEWS_SHOW_VIEW_PARM_ID;
- } else if (isShowPerspective(item)) {
- key = IWorkbenchCommandConstants.PERSPECTIVES_SHOW_PERSPECTIVE_PARM_ID;
- }
-
- if (key != null) {
- if (param.equals(m.get(key))) {
- foundBindings.add(binding);
- }
- }
- }
- }
- }
-
- Binding[] bindings = (Binding[]) foundBindings
- .toArray(new Binding[foundBindings.size()]);
-
- return bindings;
- }
-
- /**
- * @param bindings
- * @return a String representing the key bindings in <code>bindings</code>
- */
- private String keyBindingsAsString(Binding[] bindings) {
- String keybindings = null;
- for (int i = 0; i < bindings.length; i++) {
- // Unfortunately, bindings may be reported more than once:
- // check to see if this one has already been recorded.
- boolean alreadyRecorded = false;
- for (int j = 0; j < i && !alreadyRecorded; j++) {
- if (bindings[i].getTriggerSequence().equals(
- bindings[j].getTriggerSequence())) {
- alreadyRecorded = true;
- }
- }
- if (!alreadyRecorded) {
- String keybinding = bindings[i].getTriggerSequence().format();
- if (i == 0) {
- keybindings = keybinding;
- } else {
- keybindings = Util.createList(keybindings, keybinding);
- }
- }
- }
- return keybindings;
- }
-
- /**
- * On a change to availability, updates the appropriate widgets.
- */
- private void actionSetAvailabilityChanged() {
- menuStructureViewer1.refresh();
- menuStructureViewer2.refresh();
- toolbarStructureViewer1.refresh();
- toolbarStructureViewer2.refresh();
- }
-
- private void initializeActionSetInput() {
- // Just get the action sets at this point. Do not load the action set
- // until it is actually selected in the dialog.
- ActionSetRegistry reg = WorkbenchPlugin.getDefault()
- .getActionSetRegistry();
- IActionSetDescriptor[] sets = reg.getActionSets();
- IActionSetDescriptor[] actionSetDescriptors = ((WorkbenchPage) window
- .getActivePage()).getActionSets();
- List initiallyAvailableActionSets = Arrays.asList(actionSetDescriptors);
-
- for (int i = 0; i < sets.length; i++) {
- ActionSetDescriptor actionSetDesc = (ActionSetDescriptor) sets[i];
- if (WorkbenchActivityHelper.filterItem(actionSetDesc)) {
- continue;
- }
- ActionSet actionSet = new ActionSet(actionSetDesc,
- initiallyAvailableActionSets.contains(actionSetDesc));
- idToActionSet.put(actionSetDesc.getId(), actionSet);
- actionSets.add(actionSet);
- }
- }
-
- private void initializeIcons() {
- String iconPath = MENU_ICON;
- URL url = BundleUtility.find(PlatformUI.PLUGIN_ID, iconPath);
- menuImageDescriptor = ImageDescriptor.createFromURL(url);
-
- iconPath = SUBMENU_ICON;
- url = BundleUtility.find(PlatformUI.PLUGIN_ID, iconPath);
- submenuImageDescriptor = ImageDescriptor.createFromURL(url);
-
- iconPath = TOOLBAR_ICON;
- url = BundleUtility.find(PlatformUI.PLUGIN_ID, iconPath);
- toolbarImageDescriptor = ImageDescriptor.createFromURL(url);
-
- iconPath = WARNING_ICON;
- url = BundleUtility.find(PlatformUI.PLUGIN_ID, iconPath);
- warningImageDescriptor = ImageDescriptor.createFromURL(url);
- }
-
- private void initializeNewWizardsMenu(DisplayItem menu,
- Category parentCategory, IWizardCategory element, List activeIds) {
- Category category = new Category(element.getLabel());
- parentCategory.addChild(category);
-
- Object[] wizards = element.getWizards();
- for (int i = 0; i < wizards.length; i++) {
- WorkbenchWizardElement wizard = (WorkbenchWizardElement) wizards[i];
-
- ShortcutItem item = new ShortcutItem(wizard.getLabel(), wizard);
- item.setLabel(wizard.getLabel());
- item.setDescription(wizard.getDescription());
- if (wizard.getImageDescriptor() != null) {
- item.setImageDescriptor(wizard.getImageDescriptor());
- }
- item.setCheckState(activeIds.contains(wizard.getId()));
- menu.addChild(item);
- category.addShortcutItem(item);
- }
- // @issue should not pass in null
- IWizardCategory[] children = element.getCategories();
- for (int i = 0; i < children.length; i++) {
- initializeNewWizardsMenu(menu, category, children[i], activeIds);
- }
- }
-
- private void initializeNewWizardsMenu(DisplayItem menu) {
- Category rootForNewWizards = new Category(
- WorkbenchMessages.ActionSetDialogInput_wizardCategory);
- shortcuts.addChild(rootForNewWizards);
-
- IWizardCategory wizardCollection = WorkbenchPlugin.getDefault()
- .getNewWizardRegistry().getRootCategory();
- IWizardCategory[] wizardCategories = wizardCollection.getCategories();
- List activeIDs = Arrays.asList(perspective.getNewWizardShortcuts());
-
- for (int i = 0; i < wizardCategories.length; i++) {
- IWizardCategory element = wizardCategories[i];
- if (WorkbenchActivityHelper.filterItem(element)) {
- continue;
- }
-
- initializeNewWizardsMenu(menu, rootForNewWizards, element,
- activeIDs);
- }
- }
-
- private void initializePerspectivesMenu(DisplayItem menu) {
- Category rootForPerspectives = new Category(
- WorkbenchMessages.ActionSetDialogInput_perspectiveCategory);
- shortcuts.addChild(rootForPerspectives);
-
- IPerspectiveRegistry perspReg = WorkbenchPlugin.getDefault()
- .getPerspectiveRegistry();
- IPerspectiveDescriptor[] persps = perspReg.getPerspectives();
-
- List activeIds = Arrays.asList(perspective.getPerspectiveShortcuts());
-
- for (int i = 0; i < persps.length; i++) {
- IPerspectiveDescriptor perspective = persps[i];
- if (WorkbenchActivityHelper.filterItem(perspective)) {
- continue;
- }
-
- ShortcutItem child = new ShortcutItem(perspective.getLabel(),
- perspective);
- child.setImageDescriptor(perspective.getImageDescriptor());
- child.setDescription(perspective.getDescription());
- child.setCheckState(activeIds.contains(perspective.getId()));
- menu.addChild(child);
-
- rootForPerspectives.addShortcutItem(child);
- }
- }
-
- private void initializeViewsMenu(DisplayItem menu) {
- Category rootForViews = new Category(
- WorkbenchMessages.ActionSetDialogInput_viewCategory);
-
- shortcuts.addChild(rootForViews);
-
- IViewRegistry viewReg = WorkbenchPlugin.getDefault().getViewRegistry();
- IViewCategory[] categories = viewReg.getCategories();
-
- List activeIds = Arrays.asList(perspective.getShowViewShortcuts());
-
- for (int i = 0; i < categories.length; i++) {
- IViewCategory category = categories[i];
- if (WorkbenchActivityHelper.filterItem(category)) {
- continue;
- }
-
- Category viewCategory = new Category(category.getLabel());
- rootForViews.addChild(viewCategory);
-
- IViewDescriptor[] views = category.getViews();
-
- if (views != null) {
- for (int j = 0; j < views.length; j++) {
- IViewDescriptor view = views[j];
- if (view.getId().equals(IIntroConstants.INTRO_VIEW_ID)) {
- continue;
- }
- if (WorkbenchActivityHelper.filterItem(view)) {
- continue;
- }
-
- ShortcutItem child = new ShortcutItem(view.getLabel(), view);
- child.setImageDescriptor(view.getImageDescriptor());
- child.setDescription(view.getDescription());
- child.setCheckState(activeIds.contains(view.getId()));
- menu.addChild(child);
- viewCategory.addShortcutItem(child);
- }
- }
- }
- }
-
- /**
- * Loads the current perspective's menu structure and also loads which menu
- * items are visible and not.
- */
- private void loadMenuAndToolbarStructure() {
- WorkbenchWindow workbenchWindow = (WorkbenchWindow) PlatformUI
- .getWorkbench().getActiveWorkbenchWindow();
-
- customizeActionBars = new CustomizeActionBars(configurer);
-
- // Fill fake action bars with static menu information.
- window.fillActionBars(customizeActionBars, ActionBarAdvisor.FILL_PROXY
- | ActionBarAdvisor.FILL_MENU_BAR
- | ActionBarAdvisor.FILL_COOL_BAR);
-
- // 3.3 start
- final IMenuService menuService = (IMenuService) window
- .getService(IMenuService.class);
- menuService.populateContributionManager(
- (ContributionManager) customizeActionBars.getMenuManager(),
- MenuUtil.MAIN_MENU);
- ICoolBarManager coolbar = customizeActionBars.getCoolBarManager();
- if (coolbar != null) {
- menuService.populateContributionManager(
- (ContributionManager) coolbar, MenuUtil.MAIN_TOOLBAR);
- }
- // 3.3 end
-
- // Populate the action bars with the action sets' data
- for (Iterator i = actionSets.iterator(); i.hasNext();) {
- ActionSet actionSet = (ActionSet) i.next();
- ActionSetDescriptor descriptor = actionSet.descriptor;
- PluginActionSet pluginActionSet = buildMenusAndToolbarsFor(
- customizeActionBars, descriptor);
-
- if (pluginActionSet != null) {
- pluginActionSet.dispose();
- }
- }
-
- // Make all menu items visible so they are included in the list.
- customizeActionBars.menuManager.setVisible(true);
-
- makeAllContributionsVisible(customizeActionBars.menuManager);
-
- // Get the menu from the action bars
- Menu menu = customizeActionBars.menuManager
- .createMenuBar((Decorations) workbenchWindow.getShell());
-
- CoolBar cb = customizeActionBars.coolBarManager
- .createControl(workbenchWindow.getShell());
- cb.equals(cb);
-
- // Ensure the menu is completely built by updating the menu manager.
- // (This method call requires a menu already be created)
- customizeActionBars.menuManager.updateAll(true);
- customizeActionBars.coolBarManager.update(true);
-
- shortcuts = new Category(""); //$NON-NLS-1$
- toolBarItems = createToolBarStructure(cb);
- menuItems = createMenuStructure(menu);
- }
-
- private PluginActionSet buildMenusAndToolbarsFor(
- CustomizeActionBars customizeActionBars,
- ActionSetDescriptor actionSetDesc) {
- String id = actionSetDesc.getId();
- ActionSetActionBars bars = new ActionSetActionBars(customizeActionBars,
- window, customizeActionBars, id);
- bars.getMenuManager().setVisible(true);
- PluginActionSetBuilder builder = new PluginActionSetBuilder();
- PluginActionSet actionSet = null;
- try {
- actionSet = (PluginActionSet) actionSetDesc.createActionSet();
- actionSet.init(null, bars);
- } catch (CoreException ex) {
- WorkbenchPlugin.log(
- "Unable to create action set " + actionSetDesc.getId(), ex); //$NON-NLS-1$
- return null;
- }
- builder.buildMenuAndToolBarStructure(actionSet, window);
- return actionSet;
- }
-
- private static String getCommandID(DisplayItem item) {
- Object object = item.getIContributionItem();
-
- if (item instanceof ShortcutItem && isShowView(item)) {
- return IWorkbenchCommandConstants.VIEWS_SHOW_VIEW;
- }
-
- return getIDFromIContributionItem(object);
- }
-
- /**
- * Given an object, tries to find an id which will uniquely identify it.
- *
- * @param object
- * an instance of {@link IContributionItem},
- * {@link IPerspectiveDescriptor}, {@link IViewDescriptor} or
- * {@link WorkbenchWizardElement}.
- * @return an id
- * @throws IllegalArgumentException
- * if object is not one of the listed types
- */
- public static String getIDFromIContributionItem(Object object) {
- if (object instanceof ActionContributionItem) {
- ActionContributionItem item = (ActionContributionItem) object;
- IAction action = item.getAction();
- if (action == null)
- return null;
- if (action instanceof NewWizardShortcutAction) {
- return IWorkbenchCommandConstants.FILE_NEW;
- }
- if (action instanceof OpenPerspectiveAction) {
- return IWorkbenchCommandConstants.PERSPECTIVES_SHOW_PERSPECTIVE;
- }
- String id = action.getActionDefinitionId();
- if (id != null) {
- return id;
- }
- return action.getId();
- }
- if (object instanceof ActionSetContributionItem) {
- ActionSetContributionItem item = (ActionSetContributionItem) object;
- IContributionItem subitem = item.getInnerItem();
- return getIDFromIContributionItem(subitem);
- }
- if (object instanceof CommandContributionItem) {
- CommandContributionItem item = (CommandContributionItem) object;
- ParameterizedCommand command = item.getCommand();
- if (command == null) {
- return null;
- }
- return command.getId();
- }
- if (object instanceof IPerspectiveDescriptor) {
- return ((IPerspectiveDescriptor) object).getId();
- }
- if (object instanceof IViewDescriptor) {
- return ((IViewDescriptor) object).getId();
- }
- if (object instanceof WorkbenchWizardElement) {
- return ((WorkbenchWizardElement) object).getLocalId();
- }
- if (object instanceof IContributionItem) {
- String id = ((IContributionItem) object).getId();
- if (id != null)
- return id;
- return object.getClass().getName();
- }
- return null; //couldn't determine the id
- }
-
- private static String getDescription(Object object) {
- if (object instanceof DisplayItem) {
- DisplayItem item = (DisplayItem) object;
-
- if (isNewWizard(item)) {
- ShortcutItem shortcut = (ShortcutItem) item;
- IWizardDescriptor descriptor = (IWizardDescriptor) shortcut
- .getDescriptor();
- return descriptor.getDescription();
- }
-
- if (isShowPerspective(item)) {
- ShortcutItem shortcut = (ShortcutItem) item;
- IPerspectiveDescriptor descriptor = (IPerspectiveDescriptor) shortcut
- .getDescriptor();
- return descriptor.getDescription();
- }
-
- if (isShowView(item)) {
- ShortcutItem shortcut = (ShortcutItem) item;
- IViewDescriptor descriptor = (IViewDescriptor) shortcut
- .getDescriptor();
- return descriptor.getDescription();
- }
-
- if (item instanceof DynamicContributionItem) {
- return WorkbenchMessages.HideItems_dynamicItemDescription;
- }
-
- IContributionItem contrib = item.getIContributionItem();
- return getDescription(contrib);
- }
-
- if (object instanceof ActionSet) {
- ActionSet actionSet = (ActionSet) object;
- return actionSet.descriptor.getDescription();
- }
-
- return null;
- }
-
- private static String getDescription(IContributionItem item) {
- if (item instanceof ActionContributionItem) {
- ActionContributionItem aci = (ActionContributionItem) item;
- IAction action = aci.getAction();
- if (action == null)
- return null;
- return action.getDescription();
- }
- if (item instanceof ActionSetContributionItem) {
- ActionSetContributionItem asci = (ActionSetContributionItem) item;
- IContributionItem subitem = asci.getInnerItem();
- return getDescription(subitem);
- }
- return null;
- }
-
- private static String getParamID(DisplayItem object) {
- if (object instanceof ShortcutItem) {
- ShortcutItem shortcutItem = (ShortcutItem) object;
-
- if (isNewWizard(shortcutItem)) {
- ActionContributionItem item = (ActionContributionItem) object
- .getIContributionItem();
- NewWizardShortcutAction nwsa = (NewWizardShortcutAction) item
- .getAction();
- return nwsa.getLocalId();
- }
-
- if (isShowPerspective(shortcutItem)) {
- ActionContributionItem item = (ActionContributionItem) object
- .getIContributionItem();
- OpenPerspectiveAction opa = (OpenPerspectiveAction) item
- .getAction();
- return opa.getLocalId();
- }
-
- if (isShowView(shortcutItem)) {
- IViewDescriptor descriptor = (IViewDescriptor) shortcutItem
- .getDescriptor();
- return descriptor.getId();
- }
- }
-
- return null;
- }
-
- private static boolean isNewWizard(DisplayItem item) {
- if (!(item instanceof ShortcutItem))
- return false;
- return ((ShortcutItem) item).getDescriptor() instanceof IWizardDescriptor;
- }
-
- private static boolean isShowPerspective(DisplayItem item) {
- if (!(item instanceof ShortcutItem))
- return false;
- return ((ShortcutItem) item).getDescriptor() instanceof IPerspectiveDescriptor;
- }
-
- private static boolean isShowView(DisplayItem item) {
- if (!(item instanceof ShortcutItem))
- return false;
- return ((ShortcutItem) item).getDescriptor() instanceof IViewDescriptor;
- }
-
- private static String getActionSetID(IContributionItem item) {
- if (item instanceof ActionSetContributionItem) {
- ActionSetContributionItem asci = (ActionSetContributionItem) item;
- return asci.getActionSetId();
- }
- if (item instanceof PluginActionCoolBarContributionItem) {
- PluginActionCoolBarContributionItem pacbci = (PluginActionCoolBarContributionItem) item;
- return pacbci.getActionSetId();
- }
- return null;
- }
-
- /**
- * Causes all items under the manager to be visible, so they can be read.
- *
- * @param manager
- */
- private static void makeAllContributionsVisible(IContributionManager manager) {
- IContributionItem[] items = manager.getItems();
-
- for (int i = 0; i < items.length; i++) {
- makeContributionVisible(items[i]);
- }
- }
-
- /**
- * Makes all items under the item to be visible, so they can be read.
- *
- * @param item
- */
- private static void makeContributionVisible(IContributionItem item) {
- item.setVisible(true);
-
- if (item instanceof IContributionManager) {
- makeAllContributionsVisible((IContributionManager) item);
- }
- if (item instanceof SubContributionItem) {
- makeContributionVisible(((SubContributionItem) item).getInnerItem());
- }
- }
-
- private DisplayItem createMenuStructure(Menu menu) {
- DisplayItem root = new DisplayItem("", null); //$NON-NLS-1$
- createMenuEntries(menu, root, true);
- return root;
- }
-
- private void createMenuEntries(Menu menu, DisplayItem parent,
- boolean trackDynamics) {
- if (menu == null)
- return;
- MenuItem[] menuItems = menu.getItems();
-
- Map findDynamics = new HashMap();
- DynamicContributionItem dynamicEntry = null;
-
- if (trackDynamics && menu.getParentItem() != null) {
- //Search for any dynamic menu entries which will be handled later
- Object data = menu.getParentItem().getData();
- if (data instanceof IContributionManager) {
- IContributionManager manager = (IContributionManager) data;
- IContributionItem[] items = manager.getItems();
- for (int i = 0; i < items.length; i++) {
- if (items[i].isDynamic()) {
- findDynamics.put(i > 0 ? items[i - 1] : null, items[i]);
- }
- }
-
- //If there is an item with no preceeding item, set it up to be
- //added first.
- if (findDynamics.containsKey(null)) {
- IContributionItem item = (IContributionItem) findDynamics
- .get(null);
- dynamicEntry = new DynamicContributionItem(item);
- parent.addChild(dynamicEntry);
- }
- }
- }
-
- for (int i = 0; i < menuItems.length; i++) {
- if (!menuItems[i].getText().equals("")) { //$NON-NLS-1$
- IContributionItem contributionItem =
- (IContributionItem) menuItems[i].getData();
- if (dynamicEntry != null
- && contributionItem.equals(dynamicEntry
- .getIContributionItem())) {
- //If the last item added is the item meant to go before the
- //given dynamic entry, add the dynamic entry so it is in the
- //correct order.
- dynamicEntry.addCurrentItem(menuItems[i]);
- } else {
- DisplayItem menuEntry = new DisplayItem(
- menuItems[i].getText(), contributionItem);
-
- Image image = menuItems[i].getImage();
- if (image != null) {
- menuEntry.setImageDescriptor(ImageDescriptor
- .createFromImage(image));
- }
- menuEntry.setActionSet((ActionSet) idToActionSet
- .get(getActionSetID(contributionItem)));
- parent.addChild(menuEntry);
-
- if (ActionFactory.NEW.getId()
- .equals(((IContributionItem) menuItems[i].getData())
- .getId())) {
- initializeNewWizardsMenu(menuEntry);
- wizards = menuEntry;
- } else if (SHORTCUT_CONTRIBUTION_ITEM_ID_OPEN_PERSPECTIVE
- .equals(((IContributionItem) menuItems[i].getData())
- .getId())) {
- initializePerspectivesMenu(menuEntry);
- perspectives = menuEntry;
- } else if (SHORTCUT_CONTRIBUTION_ITEM_ID_SHOW_VIEW
- .equals(((IContributionItem) menuItems[i].getData())
- .getId())) {
- initializeViewsMenu(menuEntry);
- views = menuEntry;
- } else {
- createMenuEntries(menuItems[i].getMenu(), menuEntry,
- trackDynamics);
- }
-
- if (menuEntry.getChildren().isEmpty()) {
- menuEntry
- .setCheckState(getMenuItemIsVisible(menuEntry));
- }
-
- if (image == null) {
- if (parent != null && parent.getParent() == null) {
- menuEntry.setImageDescriptor(menuImageDescriptor);
- } else if (menuEntry.getChildren().size() > 0) {
- menuEntry
- .setImageDescriptor(submenuImageDescriptor);
- }
- }
- }
- if (trackDynamics
- && findDynamics.containsKey(menuItems[i].getData())) {
- IContributionItem item = (IContributionItem) findDynamics
- .get(menuItems[i].getData());
- dynamicEntry = new DynamicContributionItem(item);
- dynamicEntry
- .setCheckState(getMenuItemIsVisible(dynamicEntry));
- parent.addChild(dynamicEntry);
- }
- }
- }
- }
-
- private boolean getMenuItemIsVisible(DisplayItem item) {
- return isAvailable(item)
- && !(perspective.getHiddenMenuItems()
- .contains(getCommandID(item)));
- }
-
- private boolean getToolbarItemIsVisible(DisplayItem item) {
- return isAvailable(item)
- && !(perspective.getHiddenToolbarItems()
- .contains(getCommandID(item)));
- }
-
- /**
- * Causes a viewer to update the state of a category and all its ancestors.
- *
- * @param viewer
- * @param category
- */
- private void updateCategoryAndParents(StructuredViewer viewer,
- Category category) {
- while (category.getParent() != shortcuts) {
- viewer.update(category, null);
- category = (Category) category.getParent();
- }
- }
-
- private DisplayItem createToolBarStructure(CoolBar coolbar) {
- DisplayItem root = new DisplayItem(null, null); // Create a
- // root
- createToolbarEntries(coolbar, root);
- return root;
- }
-
- private void createToolbarEntries(CoolBar coolbar, DisplayItem parent) {
- if (coolbar == null)
- return;
- CoolItem[] items = coolbar.getItems();
- List entries = new ArrayList(items.length);
-
- for (int i = 0; i < items.length; i++) {
- IContributionItem contributionItem = (IContributionItem) items[i]
- .getData();
- String text;
- if (contributionItem instanceof IToolBarContributionItem) {
- IToolBarContributionItem item = (IToolBarContributionItem) contributionItem;
- text = window.getToolbarLabel(item.getId());
- if (text == null || text.equals("")) //$NON-NLS-1$
- text = items[i].getText();
-
- } else {
- text = items[i].getText();
- }
- DisplayItem toolBarEntry = new DisplayItem(text,
- contributionItem);
- if (items[i].getImage() == null) {
- toolBarEntry.setImageDescriptor(toolbarImageDescriptor);
- }
- toolBarEntry.setActionSet((ActionSet) idToActionSet
- .get(getActionSetID(contributionItem)));
- parent.addChild(toolBarEntry);
-
- Control control = items[i].getControl();
-
- if (control instanceof ToolBar) {
- ToolItem[] toolitems = ((ToolBar) control).getItems();
- createToolbarEntries(toolitems, toolBarEntry);
- }
-
- entries.add(toolBarEntry);
- }
- }
-
- private void createToolbarEntries(ToolItem[] toolitems,
- DisplayItem parent) {
- if (toolitems == null)
- return;
-
- for (int i = 0; i < toolitems.length; i++) {
- IContributionItem contributionItem = (IContributionItem) toolitems[i]
- .getData();
- if (contributionItem.isGroupMarker()
- || contributionItem.isSeparator()) {
- continue;
- }
- DisplayItem toolBarEntry = new DisplayItem(toolitems[i]
- .getToolTipText(), contributionItem);
- Image image = toolitems[i].getImage();
- if (image != null) {
- toolBarEntry.setImageDescriptor(ImageDescriptor
- .createFromImage(image));
- }
- toolBarEntry.setActionSet((ActionSet) idToActionSet
- .get(getActionSetID(contributionItem)));
- contributionItem.setVisible(true);// force parents to update
- toolBarEntry.setCheckState(getToolbarItemIsVisible(toolBarEntry));
- parent.addChild(toolBarEntry);
- }
- }
-
- /**
- * Returns whether the shortcut tab should be shown.
- *
- * @return <code>true</code> if the shortcut tab should be shown, and
- * <code>false</code> otherwise
- * @since 3.0
- */
- private boolean showShortcutTab() {
- return window.containsSubmenu(WorkbenchWindow.NEW_WIZARD_SUBMENU)
- || window
- .containsSubmenu(WorkbenchWindow.OPEN_PERSPECTIVE_SUBMENU)
- || window.containsSubmenu(WorkbenchWindow.SHOW_VIEW_SUBMENU);
- }
-
- private ArrayList getVisibleIDs(TreeItem root) {
- if (root == null) {
- return new ArrayList();
- }
- ArrayList ids = new ArrayList(root.getChildren().size());
- for (Iterator i = root.getChildren().iterator(); i.hasNext();) {
- DisplayItem object = (DisplayItem) i.next();
- if (object instanceof ShortcutItem && object.getState()) {
- ids.add(getParamID(object));
- }
- }
- return ids;
- }
-
- private void getChangedIds(DisplayItem item, List invisible, List visible) {
- if (item instanceof ShortcutItem)
- return;
-
- if (item == wizards || item == perspectives || item == views) {
- // We always want the top-level wizard/perspective/view shortcuts to
- // be visible, see bug 293448
- return;
- } else if (item.getChildren().size() > 0) {
- if (item.isChangedByUser()) {
- String id = getCommandID(item);
- if (item.getState())
- visible.add(id);
- else
- invisible.add(id);
- }
- for (Iterator i = item.getChildren().iterator(); i.hasNext();) {
- getChangedIds((DisplayItem) i.next(), invisible, visible);
- }
- } else if (item.isChangedByUser()) {
- String id = getCommandID(item);
- if (item.getState())
- visible.add(id);
- else
- invisible.add(id);
- }
- }
-
- private boolean updateHiddenElements(DisplayItem items, Collection currentHidden) {
- boolean hasChanges = false;
-
- List changedAndVisible = new ArrayList();
- List changedAndInvisible = new ArrayList();
- getChangedIds(items, changedAndInvisible, changedAndVisible);
-
- // Remove explicitly 'visible' elements from the current list
- for (Iterator iterator = changedAndVisible.iterator(); iterator.hasNext();) {
- Object id = iterator.next();
- if (currentHidden.contains(id)) {
- hasChanges = true;
- currentHidden.remove(id);
- }
- }
-
- // Add explicitly 'hidden' elements to the current list
- for (Iterator iterator = changedAndInvisible.iterator(); iterator.hasNext();) {
- Object id = iterator.next();
- if (!currentHidden.contains(id)) {
- hasChanges = true;
- currentHidden.add(id);
- }
- }
-
- return hasChanges;
- }
-
- protected void okPressed() {
- // Shortcuts
- if (showShortcutTab()) {
- perspective.setNewWizardActionIds(getVisibleIDs(wizards));
- perspective.setPerspectiveActionIds(getVisibleIDs(perspectives));
- perspective.setShowViewActionIds(getVisibleIDs(views));
- }
-
- // Determine if anything has changed and, if so, update the menu & tb's
- boolean requiresUpdate = false;
-
- // Action Sets
- ArrayList toAdd = new ArrayList();
- ArrayList toRemove = new ArrayList();
-
- for (Iterator i = actionSets.iterator(); i.hasNext();) {
- ActionSet actionSet = (ActionSet) i.next();
- if (!actionSet.wasChanged())
- continue;
-
- // Something has changed
- requiresUpdate = true;
-
- if (actionSet.isActive()) {
- toAdd.add(actionSet.descriptor);
- } else {
- toRemove.add(actionSet.descriptor);
- }
- }
-
- perspective.turnOnActionSets((IActionSetDescriptor[]) toAdd
- .toArray(new IActionSetDescriptor[toAdd.size()]));
- perspective.turnOffActionSets((IActionSetDescriptor[]) toRemove
- .toArray(new IActionSetDescriptor[toRemove.size()]));
-
- // Menu and Toolbar Items
- requiresUpdate |= updateHiddenElements(menuItems, perspective.getHiddenMenuItems());
- requiresUpdate |= updateHiddenElements(toolBarItems, perspective.getHiddenToolbarItems());
-
- if (requiresUpdate) {
- perspective.updateActionBars();
- }
-
- super.okPressed();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.dialogs.TrayDialog#close()
- */
- public boolean close() {
- tooltipHeading.dispose();
-
- for (Iterator i = toDispose.iterator(); i.hasNext();) {
- Resource resource = (Resource) i.next();
- resource.dispose();
- }
-
- treeManager.dispose();
- customizeActionBars.dispose();
-
- return super.close();
- }
-
- private String removeShortcut(String label) {
- if (label == null) {
- return label;
- }
- int end = label.lastIndexOf('@');
- if (end >= 0) {
- label = label.substring(0, end);
- }
-
- end = label.lastIndexOf('\t');
- if (end >= 0) {
- label = label.substring(0, end);
- }
-
- return label;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.dialogs.Dialog#applyDialogFont()
- */
- protected boolean applyDialogFont() {
- return false;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.dialogs.Dialog#isResizable()
- */
- protected boolean isResizable() {
- return true;
- }
-
- private void viewActionSet(final DisplayItem item) {
- viewActionSet(item.getActionSet());
- }
-
- /**
- * @param item
- */
- private void viewActionSet(final ActionSet actionSet) {
- tabFolder.setSelection(actionSetTab);
- actionSetAvailabilityTable.reveal(actionSet);
- setSelectionOn(actionSetAvailabilityTable, actionSet);
- actionSetAvailabilityTable.getControl().setFocus();
- }
-
- /**
- * Determines the state <code>item</code> should be (checked, gray or
- * unchecked) based only on the leafs underneath it (unless it is indeed a
- * leaf).
- *
- * @param item
- * the item to find the state of
- * @param provider
- * the content provider which will provide <code>item</code>'s
- * children
- * @param filter
- * the filter that will only select elements in the currently
- * chosen action set
- * @return {@link TreeManager#CHECKSTATE_CHECKED},
- * {@link TreeManager#CHECKSTATE_GRAY} or
- * {@link TreeManager#CHECKSTATE_UNCHECKED}
- */
- private static int getLeafStates(TreeItem item,
- ITreeContentProvider provider, ViewerFilter filter) {
- Object[] children = provider.getChildren(item);
-
- boolean checkedFound = false;
- boolean uncheckedFound = false;
-
- for (int i = 0; i < children.length; i++) {
- if (filter.select(null, null, children[i])) {
- TreeItem child = (TreeItem) children[i];
- switch (getLeafStates(child, provider, filter)) {
- case TreeManager.CHECKSTATE_CHECKED: {
- checkedFound = true;
- break;
- }
- case TreeManager.CHECKSTATE_GRAY: {
- checkedFound = uncheckedFound = true;
- break;
- }
- case TreeManager.CHECKSTATE_UNCHECKED: {
- uncheckedFound = true;
- break;
- }
- }
- if (checkedFound && uncheckedFound) {
- return TreeManager.CHECKSTATE_GRAY;
- }
- }
- }
-
- if (!checkedFound && !uncheckedFound)
- return item.getState() ? TreeManager.CHECKSTATE_CHECKED
- : TreeManager.CHECKSTATE_UNCHECKED;
- return checkedFound ? TreeManager.CHECKSTATE_CHECKED
- : TreeManager.CHECKSTATE_UNCHECKED;
- }
-
- /**
- * Sets all leafs under a {@link DisplayItem} to either visible or
- * invisible. This is for use with the action set trees, where the only
- * state used is that of leafs, and the rest is rolled up to the parents.
- * Thus, this method effectively sets the state of the entire branch.
- *
- * @param item
- * the item whose leafs underneath (or itself, if it is a leaf)
- * to <code>value</code>
- * @param value
- * <code>true</code>for visible, <code>false</code> for invisible
- * @param provider
- * the content provider which will provide <code>item</code>'s
- * children
- * @param filter
- * the filter that will only select elements in the currently
- * chosen action set
- */
- private static void setAllLeafs(DisplayItem item, boolean value,
- ITreeContentProvider provider, ViewerFilter filter) {
- Object[] children = provider.getChildren(item);
- boolean isLeaf = true;
-
- for (int i = 0; i < children.length; i++) {
- isLeaf = false;
- if (filter.select(null, null, children[i])) {
- DisplayItem child = (DisplayItem) children[i];
- setAllLeafs(child, value, provider, filter);
- }
- }
-
- if (isLeaf) {
- item.setCheckState(value);
- }
- }
-}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/handlers/AbstractSaveHandler.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/handlers/AbstractSaveHandler.java
deleted file mode 100644
index 61d3e507686..00000000000
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/handlers/AbstractSaveHandler.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 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.handlers;
-
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.expressions.EvaluationResult;
-import org.eclipse.core.expressions.Expression;
-import org.eclipse.core.expressions.ExpressionInfo;
-import org.eclipse.core.expressions.IEvaluationContext;
-import org.eclipse.ui.ISaveablePart;
-import org.eclipse.ui.ISources;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.handlers.HandlerUtil;
-import org.eclipse.ui.internal.AbstractEvaluationHandler;
-import org.eclipse.ui.internal.InternalHandlerUtil;
-import org.eclipse.ui.internal.util.Util;
-
-/**
- * @since 3.7
- *
- */
-public abstract class AbstractSaveHandler extends AbstractEvaluationHandler {
-
- protected static DirtyStateTracker dirtyStateTracker;
- private Expression enabledWhen;
-
- public AbstractSaveHandler() {
- if (dirtyStateTracker == null)
- dirtyStateTracker = new DirtyStateTracker();
- }
-
- protected Expression getEnabledWhenExpression() {
- if (enabledWhen == null) {
- enabledWhen = new Expression() {
- public EvaluationResult evaluate(IEvaluationContext context) {
- return AbstractSaveHandler.this.evaluate(context);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.core.expressions.Expression#collectExpressionInfo(org.eclipse.core.expressions.ExpressionInfo)
- */
- public void collectExpressionInfo(ExpressionInfo info) {
- info.addVariableNameAccess(ISources.ACTIVE_PART_NAME);
- }
- };
- }
- return enabledWhen;
- }
-
- protected abstract EvaluationResult evaluate(IEvaluationContext context);
-
- protected ISaveablePart getSaveablePart(IEvaluationContext context) {
- IWorkbenchPart activePart = InternalHandlerUtil.getActivePart(context);
-
- if (activePart instanceof ISaveablePart)
- return (ISaveablePart) activePart;
-
- return InternalHandlerUtil.getActiveEditor(context);
- }
-
- protected ISaveablePart getSaveablePart(ExecutionEvent event) {
-
- IWorkbenchPart activePart = HandlerUtil.getActivePart(event);
- if (activePart instanceof ISaveablePart) {
- return (ISaveablePart) activePart;
- }
-
- ISaveablePart part = (ISaveablePart) Util.getAdapter(activePart, ISaveablePart.class);
- if (part != null)
- return part;
-
- return HandlerUtil.getActiveEditor(event);
- }
-
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/handlers/CloseAllSavedHandler.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/handlers/CloseAllSavedHandler.java
deleted file mode 100644
index f7637bdeec6..00000000000
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/handlers/CloseAllSavedHandler.java
+++ /dev/null
@@ -1,136 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 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.handlers;
-
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.expressions.EvaluationResult;
-import org.eclipse.core.expressions.Expression;
-import org.eclipse.core.expressions.ExpressionInfo;
-import org.eclipse.core.expressions.IEvaluationContext;
-import org.eclipse.ui.IEditorReference;
-import org.eclipse.ui.ISources;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.internal.AbstractEvaluationHandler;
-import org.eclipse.ui.internal.InternalHandlerUtil;
-import org.eclipse.ui.internal.WorkbenchPage;
-import org.eclipse.ui.internal.util.Util;
-
-
-/**
- *
- * @author Prakash G.R.
- * @since 3.7
- *
- */
-public class CloseAllSavedHandler extends AbstractEvaluationHandler {
-
- private Expression enabledWhen;
- private IWorkbenchPage page;
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.eclipse.ui.internal.AbstractEvaluationHandler#getEnabledWhenExpression
- * ()
- */
- protected Expression getEnabledWhenExpression() {
- if (enabledWhen == null) {
- enabledWhen = new Expression() {
- public EvaluationResult evaluate(IEvaluationContext context) {
- return CloseAllSavedHandler.this.evaluate(context);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.eclipse.core.expressions.Expression#collectExpressionInfo
- * (org.eclipse.core.expressions.ExpressionInfo)
- */
- public void collectExpressionInfo(ExpressionInfo info) {
- // We use active part, so that we get evaluated for the part
- // events
- info.addVariableNameAccess(ISources.ACTIVE_PART_NAME);
- }
- };
- }
- return enabledWhen;
- }
-
- private EvaluationResult evaluate(IEvaluationContext context) {
-
- IWorkbenchWindow window = InternalHandlerUtil.getActiveWorkbenchWindow(context);
-
- setWindow(window);
-
- return window != null && window.getActivePage() != null ? EvaluationResult.TRUE
- : EvaluationResult.FALSE;
- }
-
- /**
- * @param window
- */
- private void setWindow(IWorkbenchWindow window) {
-
- if (Util.equals(page, window.getActivePage()))
- return;
-
- page = window.getActivePage();
-
- update();
- }
-
- /**
- * @return Returns the page.
- */
- public IWorkbenchPage getActivePage() {
- return page;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.
- * ExecutionEvent)
- */
- public Object execute(ExecutionEvent event) {
- IWorkbenchPage page = getActivePage();
- if (page != null) {
- ((WorkbenchPage) page).closeAllSavedEditors();
- }
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.internal.handlers.AbstractPageEventHandler#update()
- */
- protected void update() {
- IWorkbenchPage page = getActivePage();
- if (page == null) {
- setEnabled(false);
- return;
- }
- IEditorReference editors[] = page.getEditorReferences();
- for (int i = 0; i < editors.length; i++) {
- if (!editors[i].isDirty()) {
- setEnabled(true);
- return;
- }
- }
- setEnabled(false);
- }
-
-}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/handlers/DirtyStateTracker.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/handlers/DirtyStateTracker.java
deleted file mode 100644
index 6d68da659b8..00000000000
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/handlers/DirtyStateTracker.java
+++ /dev/null
@@ -1,166 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 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.handlers;
-
-import org.eclipse.ui.IPartListener;
-import org.eclipse.ui.IPropertyListener;
-import org.eclipse.ui.ISaveablePart;
-import org.eclipse.ui.ISources;
-import org.eclipse.ui.IWindowListener;
-import org.eclipse.ui.IWorkbench;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.internal.Workbench;
-import org.eclipse.ui.services.IEvaluationService;
-
-/**
- * @since 3.7
- *
- */
-public class DirtyStateTracker implements IPartListener, IWindowListener,
- IPropertyListener {
-
- private final IWorkbench workbench;
-
- public DirtyStateTracker() {
-
- workbench = Workbench.getInstance();
- workbench.addWindowListener(this);
- IWorkbenchWindow window = workbench.getActiveWorkbenchWindow();
- register(window);
- }
-
- public void update() {
- IEvaluationService service = (IEvaluationService) workbench
- .getService(IEvaluationService.class);
- service.requestEvaluation(ISources.ACTIVE_PART_NAME);
- }
-
- /**
- * @param window
- */
- private void register(IWorkbenchWindow window) {
- if (window == null)
- return;
- window.getPartService().addPartListener(this);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.eclipse.ui.IPartListener#partActivated(org.eclipse.ui.IWorkbenchPart)
- */
- public void partActivated(IWorkbenchPart part) {
- if (part instanceof ISaveablePart) {
- part.addPropertyListener(this);
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.eclipse.ui.IPartListener#partBroughtToTop(org.eclipse.ui.IWorkbenchPart
- * )
- */
- public void partBroughtToTop(IWorkbenchPart part) {
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.eclipse.ui.IPartListener#partClosed(org.eclipse.ui.IWorkbenchPart)
- */
- public void partClosed(IWorkbenchPart part) {
- if (part instanceof ISaveablePart) {
- part.removePropertyListener(this);
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.eclipse.ui.IPartListener#partDeactivated(org.eclipse.ui.IWorkbenchPart
- * )
- */
- public void partDeactivated(IWorkbenchPart part) {
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.eclipse.ui.IPartListener#partOpened(org.eclipse.ui.IWorkbenchPart)
- */
- public void partOpened(IWorkbenchPart part) {
- if (part instanceof ISaveablePart) {
- part.addPropertyListener(this);
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.IWindowListener#windowActivated(org.eclipse.ui.
- * IWorkbenchWindow)
- */
- public void windowActivated(IWorkbenchWindow window) {
- register(window);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.IWindowListener#windowDeactivated(org.eclipse.ui.
- * IWorkbenchWindow)
- */
- public void windowDeactivated(IWorkbenchWindow window) {
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.eclipse.ui.IWindowListener#windowClosed(org.eclipse.ui.IWorkbenchWindow
- * )
- */
- public void windowClosed(IWorkbenchWindow window) {
- window.getPartService().removePartListener(this);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.eclipse.ui.IWindowListener#windowOpened(org.eclipse.ui.IWorkbenchWindow
- * )
- */
- public void windowOpened(IWorkbenchWindow window) {
- register(window);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.IPropertyListener#propertyChanged(java.lang.Object,
- * int)
- */
- public void propertyChanged(Object source, int propID) {
- if (source instanceof ISaveablePart && propID == ISaveablePart.PROP_DIRTY) {
- update();
- }
- }
-
-}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/handlers/DynamicHelpHandler.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/handlers/DynamicHelpHandler.java
deleted file mode 100644
index 9be51d4759e..00000000000
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/handlers/DynamicHelpHandler.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 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.handlers;
-
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.swt.custom.BusyIndicator;
-import org.eclipse.ui.PlatformUI;
-
-/**
- * @author Prakash G.R.
- * @since 3.7
- *
- */
-public class DynamicHelpHandler extends AbstractHandler {
-
- public Object execute(ExecutionEvent event) {
-
- BusyIndicator.showWhile(null, new Runnable() {
- public void run() {
- PlatformUI.getWorkbench().getHelpSystem().displayDynamicHelp();
- }
- });
- return null;
- }
-
-}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/handlers/HandlerAuthority.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/handlers/HandlerAuthority.java
deleted file mode 100644
index 78affcdd947..00000000000
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/handlers/HandlerAuthority.java
+++ /dev/null
@@ -1,674 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2009 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.handlers;
-
-import java.io.BufferedWriter;
-import java.io.IOException;
-import java.io.StringWriter;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Set;
-import java.util.SortedSet;
-import java.util.TreeSet;
-
-import org.eclipse.core.commands.Command;
-import org.eclipse.core.commands.IHandler;
-import org.eclipse.core.commands.util.Tracing;
-import org.eclipse.core.expressions.EvaluationContext;
-import org.eclipse.core.expressions.EvaluationResult;
-import org.eclipse.core.expressions.Expression;
-import org.eclipse.core.expressions.IEvaluationContext;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.MultiStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.jface.util.IPropertyChangeListener;
-import org.eclipse.jface.util.PropertyChangeEvent;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.ISourceProvider;
-import org.eclipse.ui.ISources;
-import org.eclipse.ui.commands.ICommandService;
-import org.eclipse.ui.handlers.IHandlerActivation;
-import org.eclipse.ui.internal.WorkbenchPlugin;
-import org.eclipse.ui.internal.misc.Policy;
-import org.eclipse.ui.internal.services.EvaluationResultCacheComparator;
-import org.eclipse.ui.internal.services.EvaluationService;
-import org.eclipse.ui.internal.services.IEvaluationResultCache;
-import org.eclipse.ui.services.IEvaluationService;
-import org.eclipse.ui.services.IServiceLocator;
-import org.eclipse.ui.services.ISourceProviderService;
-
-/**
- * <p>
- * A central authority for resolving conflicts between handlers. This authority
- * listens to a variety of incoming sources, and updates the underlying commands
- * if changes in the active handlers occur.
- * </p>
- * <p>
- * This authority encapsulates all of the handler conflict resolution mechanisms
- * for the workbench. A conflict occurs if two or more handlers are assigned to
- * the same command identifier. To resolve this conflict, the authority
- * considers which source the handler came from.
- * </p>
- *
- * @since 3.1
- */
-final class HandlerAuthority {
-
- /**
- * Whether the workbench command support should kick into debugging mode.
- * This causes the unresolvable handler conflicts to be printed to the
- * console.
- */
- private static final boolean DEBUG = Policy.DEBUG_HANDLERS;
-
- /**
- * Whether the performance information should be printed about the
- * performance of the handler authority.
- */
- private static final boolean DEBUG_PERFORMANCE = Policy.DEBUG_HANDLERS_PERFORMANCE;
-
- /**
- * Whether the workbench command support should kick into verbose debugging
- * mode. This causes the resolvable handler conflicts to be printed to the
- * console.
- */
- private static final boolean DEBUG_VERBOSE = Policy.DEBUG_HANDLERS
- && Policy.DEBUG_HANDLERS_VERBOSE;
-
- /**
- * The command identifier to which the verbose output should be restricted.
- */
- private static final String DEBUG_VERBOSE_COMMAND_ID = Policy.DEBUG_HANDLERS_VERBOSE_COMMAND_ID;
-
- /**
- * The component name to print when displaying tracing information.
- */
- private static final String TRACING_COMPONENT = "HANDLERS"; //$NON-NLS-1$
-
- private static final String[] SELECTION_VARIABLES = {
- ISources.ACTIVE_CURRENT_SELECTION_NAME,
- ISources.ACTIVE_FOCUS_CONTROL_ID_NAME,
- ISources.ACTIVE_FOCUS_CONTROL_NAME,
- ISources.ACTIVE_MENU_EDITOR_INPUT_NAME, ISources.ACTIVE_MENU_NAME,
- ISources.ACTIVE_MENU_SELECTION_NAME };
-
- /**
- * The command service that should be updated when the handlers are
- * changing. This value is never <code>null</code>.
- */
- private final ICommandService commandService;
-
- /**
- * This is a map of handler activations (<code>SortedSet</code> of
- * <code>IHandlerActivation</code>) sorted by command identifier (<code>String</code>).
- * If there is only one handler activation for a command, then the
- * <code>SortedSet</code> is replaced by a <code>IHandlerActivation</code>.
- * If there is no activation, the entry should be removed entirely.
- */
- private final Map handlerActivationsByCommandId = new HashMap();
-
- private Set previousLogs = new HashSet();
-
- private IServiceLocator locator;
-
- private Collection changedCommandIds = new HashSet();
-
- private IPropertyChangeListener serviceListener;
-
- /**
- * Constructs a new instance of <code>HandlerAuthority</code>.
- *
- * @param commandService
- * The command service from which commands can be retrieved (to
- * update their handlers); must not be <code>null</code>.
- * @param locator
- * the appropriate service locator
- */
- HandlerAuthority(final ICommandService commandService,
- final IServiceLocator locator) {
- if (commandService == null) {
- throw new NullPointerException(
- "The handler authority needs a command service"); //$NON-NLS-1$
- }
-
- this.commandService = commandService;
- this.locator = locator;
- }
-
- private IEvaluationService evalService = null;
-
- private IEvaluationService getEvaluationService() {
- if (evalService == null) {
- evalService = (IEvaluationService) locator
- .getService(IEvaluationService.class);
- evalService.addServiceListener(getServiceListener());
- }
- return evalService;
- }
-
- private IPropertyChangeListener getServiceListener() {
- if (serviceListener == null) {
- serviceListener = new IPropertyChangeListener() {
- public void propertyChange(PropertyChangeEvent event) {
- if (IEvaluationService.PROP_NOTIFYING.equals(event
- .getProperty())) {
- if (event.getNewValue() instanceof Boolean) {
- boolean startNotifying = ((Boolean) event
- .getNewValue()).booleanValue();
- if (startNotifying) {
- changedCommandIds.clear();
- } else {
- processChangedCommands();
- }
- }
- }
- }
- };
- }
- return serviceListener;
- }
-
- public void dispose() {
- if (serviceListener != null) {
- getEvaluationService().removeServiceListener(serviceListener);
- serviceListener = null;
- }
- }
-
- /**
- * Activates a handler on the workbench. This will add it to a master list.
- * If conflicts exist, they will be resolved based on the source priority.
- * If conflicts still exist, then no handler becomes active.
- *
- * @param activation
- * The activation; must not be <code>null</code>.
- */
- final void activateHandler(final IHandlerActivation activation) {
- final HandlerActivation handler = (HandlerActivation) activation;
-
- // First we update the handlerActivationsByCommandId map.
- final String commandId = handler.getCommandId();
- MultiStatus conflicts = new MultiStatus("org.eclipse.ui.workbench", 0, //$NON-NLS-1$
- "A handler conflict occurred. This may disable some commands.", //$NON-NLS-1$
- null);
- final Object value = handlerActivationsByCommandId.get(commandId);
- if (value instanceof SortedSet) {
- final SortedSet handlerActivations = (SortedSet) value;
- if (!handlerActivations.contains(handler)) {
- handlerActivations.add(handler);
- if (handler.getExpression() != null) {
- HandlerPropertyListener l = new HandlerPropertyListener(
- handler);
- handler.setReference(getEvaluationService()
- .addEvaluationListener(handler.getExpression(), l,
- handler.getCommandId()));
- }
- updateCommand(commandId, resolveConflicts(commandId,
- handlerActivations, conflicts));
- }
- } else if (value instanceof IHandlerActivation) {
- if (value != handler) {
- final SortedSet handlerActivations = new TreeSet(
- new EvaluationResultCacheComparator());
- handlerActivations.add(value);
- handlerActivations.add(handler);
- if (handler.getExpression() != null) {
- HandlerPropertyListener l = new HandlerPropertyListener(
- handler);
- handler.setReference(getEvaluationService()
- .addEvaluationListener(handler.getExpression(), l,
- handler.getCommandId()));
- }
- handlerActivationsByCommandId
- .put(commandId, handlerActivations);
- updateCommand(commandId, resolveConflicts(commandId,
- handlerActivations, conflicts));
- }
- } else {
- handlerActivationsByCommandId.put(commandId, handler);
- if (handler.getExpression() != null) {
- HandlerPropertyListener l = new HandlerPropertyListener(handler);
- handler.setReference(getEvaluationService()
- .addEvaluationListener(handler.getExpression(), l,
- handler.getCommandId()));
- }
- updateCommand(commandId, (evaluate(handler) ? handler : null));
- }
-
- if (conflicts.getSeverity() != IStatus.OK) {
- WorkbenchPlugin.log(conflicts);
- }
- }
-
- /**
- * Removes an activation for a handler on the workbench. This will remove it
- * from the master list, and update the appropriate command, if necessary.
- *
- * @param activation
- * The activation; must not be <code>null</code>.
- */
- final void deactivateHandler(final IHandlerActivation activation) {
- final HandlerActivation handler = (HandlerActivation) activation;
-
- // First we update the handlerActivationsByCommandId map.
- final String commandId = handler.getCommandId();
- MultiStatus conflicts = new MultiStatus("org.eclipse.ui.workbench", 0, //$NON-NLS-1$
- "A handler conflict occurred. This may disable some commands.", //$NON-NLS-1$
- null);
- final Object value = handlerActivationsByCommandId.get(commandId);
- if (value instanceof SortedSet) {
- final SortedSet handlerActivations = (SortedSet) value;
- if (handlerActivations.contains(handler)) {
- handlerActivations.remove(handler);
- if (handler.getReference() != null) {
- getEvaluationService().removeEvaluationListener(
- handler.getReference());
- handler.setReference(null);
- handler.setListener(null);
- }
- if (handlerActivations.isEmpty()) {
- handlerActivationsByCommandId.remove(commandId);
- updateCommand(commandId, null);
-
- } else if (handlerActivations.size() == 1) {
- final IHandlerActivation remainingActivation = (IHandlerActivation) handlerActivations
- .iterator().next();
- handlerActivationsByCommandId.put(commandId,
- remainingActivation);
- updateCommand(
- commandId,
- (evaluate(remainingActivation) ? remainingActivation
- : null));
-
- } else {
- updateCommand(commandId, resolveConflicts(commandId,
- handlerActivations, conflicts));
- }
- }
- } else if (value instanceof IHandlerActivation) {
- if (value == handler) {
- if (handler.getReference() != null) {
- getEvaluationService().removeEvaluationListener(
- handler.getReference());
- handler.setReference(null);
- handler.setListener(null);
- }
-
- handlerActivationsByCommandId.remove(commandId);
- updateCommand(commandId, null);
- }
- }
- if (conflicts.getSeverity() != IStatus.OK) {
- WorkbenchPlugin.log(conflicts);
- }
- }
-
- /**
- * Resolves conflicts between multiple handlers for the same command
- * identifier. This tries to select the best activation based on the source
- * priority. For the sake of comparison, activations with the same handler
- * are considered equivalent (i.e., non-conflicting).
- *
- * @param commandId
- * The identifier of the command for which the conflicts should
- * be detected; must not be <code>null</code>. This is only
- * used for debugging purposes.
- * @param activations
- * All of the possible handler activations for the given command
- * identifier; must not be <code>null</code>.
- * @return The best matching handler activation. If none can be found (e.g.,
- * because of unresolvable conflicts), then this returns
- * <code>null</code>.
- */
- private final IHandlerActivation resolveConflicts(final String commandId,
- final SortedSet activations, MultiStatus conflicts) {
- // If we don't have any, then there is no match.
- if (activations.isEmpty()) {
- return null;
- }
-
- // Cycle over the activations, remembered the current best.
- final Iterator activationItr = activations.iterator();
- IHandlerActivation bestActivation = null;
- IHandlerActivation currentActivation = null;
- boolean conflict = false;
- while (activationItr.hasNext()) {
- currentActivation = (IHandlerActivation) activationItr.next();
- if (!evaluate(currentActivation)) {
- continue; // only consider potentially active handlers
- }
-
- // Check to see if we haven't found a potentially active handler yet
- if ((DEBUG_VERBOSE)
- && ((DEBUG_VERBOSE_COMMAND_ID == null) || (DEBUG_VERBOSE_COMMAND_ID
- .equals(commandId)))) {
- Tracing.printTrace(TRACING_COMPONENT,
- " resolveConflicts: eval: " + currentActivation); //$NON-NLS-1$
- }
- if (bestActivation == null) {
- bestActivation = currentActivation;
- conflict = false;
- continue;
- }
-
- // Compare the two handlers.
- final int comparison = bestActivation.compareTo(currentActivation);
- if (comparison < 0) {
- bestActivation = currentActivation;
- conflict = false;
-
- } else if (comparison == 0) {
- if (currentActivation.getHandler() != bestActivation
- .getHandler()) {
- conflict = true;
- break;
- }
-
- } else {
- break;
- }
- }
-
- // If we are logging information, now is the time to do it.
- if (DEBUG) {
- if (conflict) {
- Tracing.printTrace(TRACING_COMPONENT,
- "Unresolved conflict detected for '" //$NON-NLS-1$
- + commandId + '\'');
- } else if ((bestActivation != null)
- && (DEBUG_VERBOSE)
- && ((DEBUG_VERBOSE_COMMAND_ID == null) || (DEBUG_VERBOSE_COMMAND_ID
- .equals(commandId)))) {
- Tracing
- .printTrace(TRACING_COMPONENT,
- "Resolved conflict detected. The following activation won: "); //$NON-NLS-1$
- Tracing.printTrace(TRACING_COMPONENT, " " + bestActivation); //$NON-NLS-1$
- }
- }
-
- // Return the current best.
- if (conflict) {
- if (previousLogs.add(commandId)) {
- final StringWriter sw = new StringWriter();
- final BufferedWriter buffer = new BufferedWriter(sw);
- try {
- buffer.write("Conflict for \'"); //$NON-NLS-1$
- buffer.write(commandId);
- buffer.write("\':"); //$NON-NLS-1$
- buffer.newLine();
- buffer.write(bestActivation.toString());
- buffer.newLine();
- buffer.write(currentActivation.toString());
- buffer.flush();
- } catch (IOException e) {
- // should never get this.
- }
-
- IStatus s = new Status(IStatus.WARNING,
- "org.eclipse.ui.workbench", //$NON-NLS-1$
- sw.toString());
- conflicts.add(s);
- }
- return null;
- }
- return bestActivation;
- }
-
- /**
- * Carries out the actual source change notification. It assumed that by the
- * time this method is called, <code>context</code> is up-to-date with the
- * current state of the application.
- *
- * @param sourcePriority
- * A bit mask of all the source priorities that have changed.
- */
- protected final void sourceChanged(final int sourcePriority) {
- // we don't do this anymore ... we just keep walking.
- }
-
- /**
- * Updates the command with the given handler activation.
- *
- * @param commandId
- * The identifier of the command which should be updated; must
- * not be <code>null</code>.
- * @param activation
- * The activation to use; may be <code>null</code> if the
- * command should have a <code>null</code> handler.
- */
- private final void updateCommand(final String commandId,
- final IHandlerActivation activation) {
- final Command command = commandService.getCommand(commandId);
- if (activation == null) {
- command.setHandler(null);
- } else {
- command.setHandler(activation.getHandler());
- commandService.refreshElements(commandId, null);
- }
- }
-
- /**
- * Currently this is a an internal method to help locate a handler.
- * <p>
- * DO NOT CALL THIS METHOD.
- * </p>
- *
- * @param commandId
- * the command id to check
- * @param context
- * the context to use for activations
- * @since 3.3
- */
- public final IHandler findHandler(String commandId,
- IEvaluationContext context) {
- Object o = handlerActivationsByCommandId.get(commandId);
- if (o instanceof IHandlerActivation) {
- IHandlerActivation activation = (IHandlerActivation) o;
- try {
- if (eval(context, activation)) {
- return activation.getHandler();
- }
- } catch (CoreException e) {
- // the evalution failed
- }
- } else if (o instanceof SortedSet) {
- SortedSet activations = (SortedSet) o;
- IHandlerActivation lastActivation = null;
- IHandlerActivation currentActivation = null;
- Iterator i = activations.iterator();
- while (i.hasNext() && lastActivation == null) {
- IHandlerActivation activation = (IHandlerActivation) i.next();
- try {
- if (eval(context, activation)) {
- lastActivation = currentActivation;
- currentActivation = activation;
- }
- } catch (CoreException e) {
- // OK, this one is out of the running
- }
- }
- if (currentActivation != null) {
- if (lastActivation == null) {
- return currentActivation.getHandler();
- }
- if (lastActivation.getSourcePriority() != currentActivation
- .getSourcePriority()) {
- return lastActivation.getHandler();
- }
- }
- }
- return null;
- }
-
- /**
- * Evaluate the expression for the handler and bypass the result cache.
- * <p>
- * DO NOT CALL THIS METHOD.
- * </p>
- *
- * @param context
- * @param activation
- * @return <code>true</code> if the handler expression can evaluate to
- * true.
- * @throws CoreException
- * @since 3.3
- */
- private boolean eval(IEvaluationContext context,
- IHandlerActivation activation) throws CoreException {
- Expression expression = activation.getExpression();
- if (expression == null) {
- return true;
- }
- return expression.evaluate(context) == EvaluationResult.TRUE;
- }
-
- public IEvaluationContext createContextSnapshot(boolean includeSelection) {
- IEvaluationContext tmpContext = getCurrentState();
-
- EvaluationContext context = null;
- if (includeSelection) {
- context = new EvaluationContext(null, tmpContext
- .getDefaultVariable());
- for (int i = 0; i < SELECTION_VARIABLES.length; i++) {
- copyVariable(context, tmpContext, SELECTION_VARIABLES[i]);
- }
- } else {
- context = new EvaluationContext(null, Collections.EMPTY_LIST);
- }
-
- ISourceProviderService sp = (ISourceProviderService) locator
- .getService(ISourceProviderService.class);
- ISourceProvider[] providers = sp.getSourceProviders();
- for (int i = 0; i < providers.length; i++) {
- String[] names = providers[i].getProvidedSourceNames();
- for (int j = 0; j < names.length; j++) {
- if (!isSelectionVariable(names[j])) {
- copyVariable(context, tmpContext, names[j]);
- }
- }
- }
-
- return context;
- }
-
- private boolean isSelectionVariable(String name) {
- for (int i = 0; i < SELECTION_VARIABLES.length; i++) {
- if (SELECTION_VARIABLES[i].equals(name)) {
- return true;
- }
- }
- return false;
- }
-
- private void copyVariable(IEvaluationContext context,
- IEvaluationContext tmpContext, String var) {
- Object o = tmpContext.getVariable(var);
- if (o != null) {
- context.addVariable(var, o);
- }
- }
-
- private class HandlerPropertyListener implements IPropertyChangeListener {
- private HandlerActivation handler;
-
- public HandlerPropertyListener(final HandlerActivation activation) {
- handler = activation;
- handler.setListener(this);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent)
- */
- public void propertyChange(PropertyChangeEvent event) {
- if (handler.getCommandId().equals(event.getProperty())) {
- boolean val = false;
- if (event.getNewValue() instanceof Boolean) {
- val = ((Boolean) event.getNewValue()).booleanValue();
- }
- handler.setResult(val);
- changedCommandIds.add(handler.getCommandId());
- }
- }
- }
-
- private void processChangedCommands() {
- // If tracing, then track how long it takes to process the activations.
- long startTime = 0L;
- if (DEBUG_PERFORMANCE) {
- startTime = System.currentTimeMillis();
- }
-
- MultiStatus conflicts = new MultiStatus("org.eclipse.ui.workbench", 0, //$NON-NLS-1$
- "A handler conflict occurred. This may disable some commands.", //$NON-NLS-1$
- null);
-
- /*
- * For every command identifier with a changed activation, we resolve
- * conflicts and trigger an update.
- */
- String[] changedIds = (String[]) changedCommandIds.toArray(new String[changedCommandIds.size()]);
- changedCommandIds.clear();
- for (int i = 0; i < changedIds.length; i++) {
-
- final String commandId = changedIds[i];
- final Object value = handlerActivationsByCommandId.get(commandId);
- if (value instanceof IHandlerActivation) {
- final IHandlerActivation activation = (IHandlerActivation) value;
- updateCommand(commandId, (evaluate(activation) ? activation
- : null));
- } else if (value instanceof SortedSet) {
- final IHandlerActivation activation = resolveConflicts(
- commandId, (SortedSet) value, conflicts);
- updateCommand(commandId, activation);
- } else {
- updateCommand(commandId, null);
- }
- }
- if (conflicts.getSeverity() != IStatus.OK) {
- WorkbenchPlugin.log(conflicts);
- }
-
- // If tracing performance, then print the results.
- if (DEBUG_PERFORMANCE) {
- final long elapsedTime = System.currentTimeMillis() - startTime;
- final int size = changedCommandIds.size();
- if (size > 0) {
- Tracing.printTrace(TRACING_COMPONENT, size
- + " command ids changed in " + elapsedTime + "ms"); //$NON-NLS-1$ //$NON-NLS-2$
- }
- }
- }
-
- protected final boolean evaluate(final IEvaluationResultCache expression) {
- final IEvaluationContext contextWithDefaultVariable = getCurrentState();
- return expression.evaluate(contextWithDefaultVariable);
- }
-
- public final IEvaluationContext getCurrentState() {
- return getEvaluationService().getCurrentState();
- }
-
- public void updateShellKludge() {
- ((EvaluationService) getEvaluationService()).updateShellKludge();
- }
-
- public void updateShellKludge(Shell shell) {
- ((EvaluationService) getEvaluationService()).updateShellKludge(shell);
- }
-}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/handlers/HandlerService.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/handlers/HandlerService.java
deleted file mode 100644
index 260b4e7ed9b..00000000000
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/handlers/HandlerService.java
+++ /dev/null
@@ -1,285 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2008 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.handlers;
-
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Iterator;
-
-import org.eclipse.core.commands.Command;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.commands.IHandler;
-import org.eclipse.core.commands.IHandler2;
-import org.eclipse.core.commands.NotEnabledException;
-import org.eclipse.core.commands.NotHandledException;
-import org.eclipse.core.commands.ParameterizedCommand;
-import org.eclipse.core.commands.common.NotDefinedException;
-import org.eclipse.core.expressions.Expression;
-import org.eclipse.core.expressions.IEvaluationContext;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.ISourceProvider;
-import org.eclipse.ui.commands.ICommandService;
-import org.eclipse.ui.handlers.IHandlerActivation;
-import org.eclipse.ui.handlers.IHandlerService;
-import org.eclipse.ui.internal.misc.Policy;
-import org.eclipse.ui.services.IEvaluationService;
-import org.eclipse.ui.services.IServiceLocator;
-
-/**
- * <p>
- * Provides services related to activating and deactivating handlers within the
- * workbench.
- * </p>
- *
- * @since 3.1
- */
-public final class HandlerService implements IHandlerService {
-
- static {
- Command.DEBUG_HANDLERS = Policy.DEBUG_HANDLERS_VERBOSE;
- Command.DEBUG_HANDLERS_COMMAND_ID = Policy.DEBUG_HANDLERS_VERBOSE_COMMAND_ID;
- }
-
- /**
- * The command service for this handler service. This value is never
- * <code>null</code>.
- */
- private final ICommandService commandService;
-
- /**
- * The central authority for determining which handler we should use.
- */
- private final HandlerAuthority handlerAuthority;
-
- /**
- * The class providing persistence for this service.
- */
- private final HandlerPersistence handlerPersistence;
-
- /**
- * Constructs a new instance of <code>CommandService</code> using a
- * command manager.
- *
- * @param commandService
- * The command service to use; must not be <code>null</code>.
- * @param evaluationService
- * The evaluation service to use; must not be <code>null</code>.
- * @param locator
- * an appropriate service locator
- */
- public HandlerService(final ICommandService commandService,
- final IEvaluationService evaluationService, IServiceLocator locator) {
- if (commandService == null) {
- throw new NullPointerException(
- "A handler service requires a command service"); //$NON-NLS-1$
- }
- this.commandService = commandService;
- this.handlerAuthority = new HandlerAuthority(commandService, locator);
- this.handlerPersistence = new HandlerPersistence(this,
- evaluationService);
- }
-
- public final IHandlerActivation activateHandler(
- final IHandlerActivation childActivation) {
- final String commandId = childActivation.getCommandId();
- final IHandler handler = childActivation.getHandler();
- final Expression expression = childActivation.getExpression();
- final int depth = childActivation.getDepth() + 1;
- final IHandlerActivation localActivation = new HandlerActivation(
- commandId, handler, expression, depth, this);
- handlerAuthority.activateHandler(localActivation);
- return localActivation;
- }
-
- public final IHandlerActivation activateHandler(final String commandId,
- final IHandler handler) {
- return activateHandler(commandId, handler, null);
- }
-
- public final IHandlerActivation activateHandler(final String commandId,
- final IHandler handler, final Expression expression) {
- return activateHandler(commandId, handler, expression, false);
- }
-
- public final IHandlerActivation activateHandler(final String commandId,
- final IHandler handler, final Expression expression,
- final boolean global) {
- final IHandlerActivation activation = new HandlerActivation(commandId,
- handler, expression, IHandlerActivation.ROOT_DEPTH, this);
- handlerAuthority.activateHandler(activation);
- return activation;
- }
-
- public final IHandlerActivation activateHandler(final String commandId,
- final IHandler handler, final Expression expression,
- final int sourcePriority) {
- return activateHandler(commandId, handler, expression);
- }
-
- public final void addSourceProvider(final ISourceProvider provider) {
- // no-op
- }
-
- public final ExecutionEvent createExecutionEvent(final Command command,
- final Event event) {
- return new ExecutionEvent(command, Collections.EMPTY_MAP, event,
- getCurrentState());
- }
-
- public ExecutionEvent createExecutionEvent(
- final ParameterizedCommand command, final Event event) {
- return new ExecutionEvent(command.getCommand(), command
- .getParameterMap(), event, getCurrentState());
- }
-
- public final void deactivateHandler(final IHandlerActivation activation) {
- if (activation.getHandlerService() == this) {
- handlerAuthority.deactivateHandler(activation);
- }
- }
-
- public final void deactivateHandlers(final Collection activations) {
- final Iterator activationItr = activations.iterator();
- while (activationItr.hasNext()) {
- final IHandlerActivation activation = (IHandlerActivation) activationItr
- .next();
- deactivateHandler(activation);
- }
- }
-
- public final void dispose() {
- handlerAuthority.dispose();
- handlerPersistence.dispose();
- }
-
- public final Object executeCommand(final ParameterizedCommand command,
- final Event trigger) throws ExecutionException,
- NotDefinedException, NotEnabledException, NotHandledException {
- return command.executeWithChecks(trigger, getCurrentState());
- }
-
- public final Object executeCommand(final String commandId,
- final Event trigger) throws ExecutionException,
- NotDefinedException, NotEnabledException, NotHandledException {
- final Command command = commandService.getCommand(commandId);
- final ExecutionEvent event = new ExecutionEvent(command,
- Collections.EMPTY_MAP, trigger, getCurrentState());
- return command.executeWithChecks(event);
- }
-
- public final IEvaluationContext getCurrentState() {
- return handlerAuthority.getCurrentState();
- }
-
- public final void readRegistry() {
- handlerPersistence.read();
- }
-
- public final void removeSourceProvider(final ISourceProvider provider) {
- // this is a no-op
- }
-
- public final void setHelpContextId(final IHandler handler,
- final String helpContextId) {
- commandService.setHelpContextId(handler, helpContextId);
- }
-
- /**
- * <p>
- * Bug 95792. A mechanism by which the key binding architecture can force an
- * update of the handlers (based on the active shell) before trying to
- * execute a command. This mechanism is required for GTK+ only.
- * </p>
- * <p>
- * DO NOT CALL THIS METHOD.
- * </p>
- */
- public final void updateShellKludge() {
- handlerAuthority.updateShellKludge();
- }
-
- /**
- * <p>
- * Bug 95792. A mechanism by which the key binding architecture can force an
- * update of the handlers (based on the active shell) before trying to
- * execute a command. This mechanism is required for GTK+ only.
- * </p>
- * <p>
- * DO NOT CALL THIS METHOD.
- * </p>
- *
- * @param shell
- * The shell that should be considered active; must not be
- * <code>null</code>.
- */
- public final void updateShellKludge(final Shell shell) {
- handlerAuthority.updateShellKludge(shell);
- }
-
- /**
- * Currently this is a an internal method to help locate a handler.
- * <p>
- * DO NOT CALL THIS METHOD.
- * </p>
- *
- * @param commandId
- * the command id to check
- * @param context
- * the context to use for activations
- * @return the correct IHandler or <code>null</code>
- * @since 3.3
- */
- public final IHandler findHandler(String commandId,
- IEvaluationContext context) {
- return handlerAuthority.findHandler(commandId, context);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.handlers.IHandlerService#createContextSnapshot(boolean)
- */
- public IEvaluationContext createContextSnapshot(boolean includeSelection) {
- return handlerAuthority.createContextSnapshot(includeSelection);
- }
-
- public final Object executeCommandInContext(
- final ParameterizedCommand command, final Event trigger,
- IEvaluationContext context) throws ExecutionException,
- NotDefinedException, NotEnabledException, NotHandledException {
- IHandler oldHandler = command.getCommand().getHandler();
-
- IHandler handler = findHandler(command.getId(), context);
- if (handler instanceof IHandler2) {
- ((IHandler2) handler).setEnabled(context);
- }
- try {
- command.getCommand().setHandler(handler);
-
- return command.executeWithChecks(trigger, context);
- } finally {
- command.getCommand().setHandler(oldHandler);
- if (handler instanceof IHandler2) {
- ((IHandler2) handler).setEnabled(getCurrentState());
- }
- }
- }
-
- /**
- * @return Returns the handlerPersistence.
- */
- public HandlerPersistence getHandlerPersistence() {
- return handlerPersistence;
- }
-}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/handlers/HandlerServiceFactory.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/handlers/HandlerServiceFactory.java
deleted file mode 100644
index a39f70f5e5a..00000000000
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/handlers/HandlerServiceFactory.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 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.handlers;
-
-import org.eclipse.core.expressions.Expression;
-import org.eclipse.ui.IWorkbench;
-import org.eclipse.ui.IWorkbenchPartSite;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.commands.ICommandService;
-import org.eclipse.ui.handlers.IHandlerService;
-import org.eclipse.ui.internal.expressions.ActivePartExpression;
-import org.eclipse.ui.internal.expressions.WorkbenchWindowExpression;
-import org.eclipse.ui.internal.services.IWorkbenchLocationService;
-import org.eclipse.ui.services.AbstractServiceFactory;
-import org.eclipse.ui.services.IEvaluationService;
-import org.eclipse.ui.services.IServiceLocator;
-
-/**
- * @since 3.4
- *
- */
-public class HandlerServiceFactory extends AbstractServiceFactory {
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.eclipse.ui.services.AbstractServiceFactory#create(java.lang.Class,
- * org.eclipse.ui.services.IServiceLocator,
- * org.eclipse.ui.services.IServiceLocator)
- */
- public Object create(Class serviceInterface, IServiceLocator parentLocator,
- IServiceLocator locator) {
- if (!IHandlerService.class.equals(serviceInterface)) {
- return null;
- }
- IWorkbenchLocationService wls = (IWorkbenchLocationService) locator
- .getService(IWorkbenchLocationService.class);
- final IWorkbench wb = wls.getWorkbench();
- if (wb == null) {
- return null;
- }
-
- Object parent = parentLocator.getService(serviceInterface);
- if (parent == null) {
- ICommandService commands = (ICommandService) locator
- .getService(ICommandService.class);
- IEvaluationService evals = (IEvaluationService) locator
- .getService(IEvaluationService.class);
- HandlerService handlerService = new HandlerService(commands, evals,
- locator);
- handlerService.readRegistry();
- return handlerService;
- }
-
- final IWorkbenchWindow window = wls.getWorkbenchWindow();
- final IWorkbenchPartSite site = wls.getPartSite();
- if (site == null) {
- Expression exp = new WorkbenchWindowExpression(window);
- return new SlaveHandlerService((IHandlerService) parent, exp);
- }
-
- if (parent instanceof SlaveHandlerService) {
- Expression parentExp = ((SlaveHandlerService) parent)
- .getDefaultExpression();
- if (parentExp instanceof ActivePartExpression) {
- return new NestableHandlerService((IHandlerService) parent,
- parentExp);
- }
- }
-
- Expression exp = new ActivePartExpression(site.getPart());
- return new SlaveHandlerService((IHandlerService) parent, exp);
- }
-}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/handlers/HelpContentsHandler.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/handlers/HelpContentsHandler.java
deleted file mode 100644
index ef3fa088607..00000000000
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/handlers/HelpContentsHandler.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 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.handlers;
-
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.swt.custom.BusyIndicator;
-import org.eclipse.ui.PlatformUI;
-
-/**
- * @author Prakash G.R.
- * @since 3.7
- *
- */
-public class HelpContentsHandler extends AbstractHandler {
-
- public Object execute(ExecutionEvent event) {
-
- BusyIndicator.showWhile(null, new Runnable() {
- public void run() {
- PlatformUI.getWorkbench().getHelpSystem().displayHelp();
- }
- });
- return null;
- }
-
-}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/handlers/HelpSearchHandler.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/handlers/HelpSearchHandler.java
deleted file mode 100644
index 6975a748984..00000000000
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/handlers/HelpSearchHandler.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 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.handlers;
-
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.swt.custom.BusyIndicator;
-import org.eclipse.ui.PlatformUI;
-
-/**
- * @author Prakash G.R.
- * @since 3.7
- *
- */
-public class HelpSearchHandler extends AbstractHandler {
-
- public Object execute(ExecutionEvent event) {
-
- BusyIndicator.showWhile(null, new Runnable() {
- public void run() {
- PlatformUI.getWorkbench().getHelpSystem().displaySearch();
- }
- });
- return null;
- }
-
-}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/handlers/IntroHandler.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/handlers/IntroHandler.java
deleted file mode 100644
index f9421b4327e..00000000000
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/handlers/IntroHandler.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 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.handlers;
-
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.handlers.HandlerUtil;
-import org.eclipse.ui.internal.Workbench;
-import org.eclipse.ui.internal.intro.IntroDescriptor;
-import org.eclipse.ui.internal.intro.IntroMessages;
-
-/**
- *
- * @author Prakash G.R.
- *
- * @since 3.7
- *
- */
-public class IntroHandler extends AbstractHandler {
-
- private Workbench workbench;
- private IntroDescriptor introDescriptor;
-
- public IntroHandler() {
- workbench = (Workbench) PlatformUI.getWorkbench();
- introDescriptor = workbench.getIntroDescriptor();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.
- * ExecutionEvent)
- */
- public Object execute(ExecutionEvent event) {
-
- if (introDescriptor == null) {
- MessageDialog.openWarning(HandlerUtil.getActiveShell(event),
- IntroMessages.Intro_missing_product_title,
- IntroMessages.Intro_missing_product_message);
- } else {
- IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindow(event);
- workbench.getIntroManager().showIntro(window, false);
- }
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.core.commands.AbstractHandler#isEnabled()
- */
- public boolean isEnabled() {
-
- boolean enabled = false;
- IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
- if (window != null) {
- enabled = window.getPages().length > 0;
- }
- return enabled;
- }
-
-}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/handlers/LockToolBarHandler.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/handlers/LockToolBarHandler.java
deleted file mode 100644
index 4fcb5d24b46..00000000000
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/handlers/LockToolBarHandler.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 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.handlers;
-
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.jface.action.ICoolBarManager;
-import org.eclipse.ui.handlers.HandlerUtil;
-import org.eclipse.ui.internal.WorkbenchWindow;
-
-/**
- *
- * @author Prakash G.R.
- *
- * @since 3.7
- *
- */
-public class LockToolBarHandler extends AbstractHandler {
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.
- * ExecutionEvent)
- */
- public Object execute(ExecutionEvent event) throws ExecutionException {
-
- WorkbenchWindow workbenchWindow = (WorkbenchWindow) HandlerUtil
- .getActiveWorkbenchWindow(event);
- if (workbenchWindow != null) {
- ICoolBarManager coolBarManager = workbenchWindow.getCoolBarManager2();
- if (coolBarManager != null) {
- boolean oldValue = HandlerUtil.toggleCommandState(event.getCommand());
- coolBarManager.setLockLayout(!oldValue);
- }
- }
- return null;
- }
-
-}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/handlers/NestableHandlerService.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/handlers/NestableHandlerService.java
deleted file mode 100644
index 4576a75865a..00000000000
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/handlers/NestableHandlerService.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2009 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.handlers;
-
-import java.util.Iterator;
-
-import org.eclipse.core.expressions.Expression;
-import org.eclipse.ui.handlers.IHandlerActivation;
-import org.eclipse.ui.handlers.IHandlerService;
-import org.eclipse.ui.internal.services.INestable;
-
-/**
- * <p>
- * A handler service which delegates almost all responsibility to the parent
- * service. It is capable of being nested inside a component that is not
- * recognizable by the "sources" event mechanism. This means that the handlers
- * must be activated and deactivated manually.
- * </p>
- * <p>
- * This class is not intended for use outside of the
- * <code>org.eclipse.ui.workbench</code> plug-in.
- * </p>
- *
- * @since 3.2
- */
-public final class NestableHandlerService extends SlaveHandlerService implements
- INestable {
-
- /**
- * Whether the component with which this service is associated is active.
- */
- private boolean active = false;
-
- /**
- * Constructs a new instance.
- *
- * @param parentHandlerService
- * The parent handler service for this slave; must not be
- * <code>null</code>.
- * @param defaultExpression
- * The default expression to use if none is provided. This is
- * primarily used for conflict resolution. This value may be
- * <code>null</code>.
- */
- public NestableHandlerService(final IHandlerService parentHandlerService,
- final Expression defaultExpression) {
- super(parentHandlerService, defaultExpression);
- }
-
- public final void activate() {
- if (active) {
- return;
- }
-
- final Iterator localActivationItr = localActivationsToParentActivations
- .keySet().iterator();
- while (localActivationItr.hasNext()) {
- final Object object = localActivationItr.next();
- if (object instanceof IHandlerActivation) {
- final IHandlerActivation localActivation = (IHandlerActivation) object;
- super.doActivation(localActivation);
- }
- }
-
- active = true;
- }
-
- protected final IHandlerActivation doActivation(
- final IHandlerActivation localActivation) {
- if (active) {
- return super.doActivation(localActivation);
- }
- localActivationsToParentActivations.put(localActivation, null);
- return localActivation;
- }
-
- public final void deactivate() {
- if (!active) {
- return;
- }
-
- deactivateHandlers(parentActivations);
- parentActivations.clear();
-
- final Iterator localActivationItr = localActivationsToParentActivations
- .keySet().iterator();
- while (localActivationItr.hasNext()) {
- final Object object = localActivationItr.next();
- localActivationsToParentActivations.put(object, null);
- }
-
- active = false;
- }
-}
-
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/handlers/ResetPerspectiveHandler.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/handlers/ResetPerspectiveHandler.java
deleted file mode 100644
index 9b5a06358ef..00000000000
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/handlers/ResetPerspectiveHandler.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2011 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.handlers;
-
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.dialogs.MessageDialogWithToggle;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.swt.SWT;
-import org.eclipse.ui.IPerspectiveDescriptor;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.handlers.HandlerUtil;
-import org.eclipse.ui.internal.WorkbenchMessages;
-import org.eclipse.ui.internal.WorkbenchPage;
-import org.eclipse.ui.internal.registry.PerspectiveDescriptor;
-import org.eclipse.ui.internal.registry.PerspectiveRegistry;
-
-/**
- *
- * @author Prakash G.R.
- *
- * @since 3.7
- *
- */
-public class ResetPerspectiveHandler extends AbstractHandler {
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.
- * ExecutionEvent)
- */
- public Object execute(ExecutionEvent event) {
-
- IWorkbenchWindow activeWorkbenchWindow = HandlerUtil.getActiveWorkbenchWindow(event);
- if (activeWorkbenchWindow != null) {
- WorkbenchPage page = (WorkbenchPage) activeWorkbenchWindow.getActivePage();
- if (page != null) {
- IPerspectiveDescriptor descriptor = page.getPerspective();
- if (descriptor != null) {
- boolean offerRevertToBase = false;
- if (descriptor instanceof PerspectiveDescriptor) {
- PerspectiveDescriptor desc = (PerspectiveDescriptor) descriptor;
- offerRevertToBase = desc.isPredefined() && desc.hasCustomDefinition();
- }
-
- if (offerRevertToBase) {
- String message = NLS.bind(WorkbenchMessages.RevertPerspective_message,
- descriptor.getLabel());
- boolean toggleState = false;
- MessageDialogWithToggle dialog = MessageDialogWithToggle.open(
- MessageDialog.QUESTION, activeWorkbenchWindow.getShell(),
- WorkbenchMessages.RevertPerspective_title, message,
- WorkbenchMessages.RevertPerspective_option,
- toggleState, null, null, SWT.SHEET);
- if (dialog.getReturnCode() == IDialogConstants.YES_ID) {
- if (dialog.getToggleState()) {
- PerspectiveRegistry reg = (PerspectiveRegistry) PlatformUI
- .getWorkbench().getPerspectiveRegistry();
- reg.revertPerspective(descriptor);
- }
- page.resetPerspective();
- }
- } else {
- String message = NLS.bind(WorkbenchMessages.ResetPerspective_message,
- descriptor.getLabel());
- boolean result = MessageDialog.open(MessageDialog.QUESTION,
- activeWorkbenchWindow.getShell(),
- WorkbenchMessages.ResetPerspective_title, message, SWT.SHEET);
- if (result) {
- page.resetPerspective();
- }
- }
- }
- }
- }
-
- return null;
- }
-}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/handlers/SaveAllHandler.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/handlers/SaveAllHandler.java
deleted file mode 100644
index 06deb1dff70..00000000000
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/handlers/SaveAllHandler.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 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.handlers;
-
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.expressions.EvaluationResult;
-import org.eclipse.core.expressions.IEvaluationContext;
-import org.eclipse.ui.ISaveablesLifecycleListener;
-import org.eclipse.ui.ISaveablesSource;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.Saveable;
-import org.eclipse.ui.handlers.HandlerUtil;
-import org.eclipse.ui.internal.InternalHandlerUtil;
-import org.eclipse.ui.internal.SaveablesList;
-import org.eclipse.ui.internal.WorkbenchPage;
-
-/**
- * Saves all active editors
- * <p>
- * Replacement for SaveAllAction
- * </p>
- *
- * @since 3.7
- *
- */
-public class SaveAllHandler extends AbstractSaveHandler {
-
- public SaveAllHandler() {
- registerEnablement();
- }
-
- public Object execute(ExecutionEvent event) throws ExecutionException {
- IWorkbenchWindow window = HandlerUtil
- .getActiveWorkbenchWindowChecked(event);
- IWorkbenchPage page = window.getActivePage();
- if (page != null) {
- ((WorkbenchPage) page).saveAllEditors(false, true);
- }
-
- return null;
- }
-
- protected EvaluationResult evaluate(IEvaluationContext context) {
-
- IWorkbenchWindow window = InternalHandlerUtil.getActiveWorkbenchWindow(context);
- // no window? not active
- if (window == null)
- return EvaluationResult.FALSE;
- WorkbenchPage page = (WorkbenchPage) window.getActivePage();
-
- // no page? not active
- if (page == null)
- return EvaluationResult.FALSE;
-
- // if at least one dirty part, then we are active
- if (page.getDirtyParts().length > 0)
- return EvaluationResult.TRUE;
-
- // Since Save All also saves saveables from non-part sources,
- // look if any such saveables exist and are dirty.
- SaveablesList saveablesList = (SaveablesList) window.getWorkbench().getService(
- ISaveablesLifecycleListener.class);
- ISaveablesSource[] nonPartSources = saveablesList.getNonPartSources();
- for (int i = 0; i < nonPartSources.length; i++) {
- Saveable[] saveables = nonPartSources[i].getSaveables();
- for (int j = 0; j < saveables.length; j++) {
- if (saveables[j].isDirty()) {
- return EvaluationResult.TRUE;
- }
- }
- }
-
- // if nothing, then we are not active
- return EvaluationResult.FALSE;
- }
-
-}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/handlers/SaveAsHandler.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/handlers/SaveAsHandler.java
deleted file mode 100644
index 38cdff2123a..00000000000
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/handlers/SaveAsHandler.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 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.handlers;
-
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.expressions.EvaluationResult;
-import org.eclipse.core.expressions.IEvaluationContext;
-import org.eclipse.ui.ISaveablePart;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.internal.InternalHandlerUtil;
-import org.eclipse.ui.internal.WorkbenchPage;
-
-/**
- * <p>
- * Replacement for SaveAsAction
- * </p>
- *
- * @since 3.7
- *
- */
-public class SaveAsHandler extends AbstractSaveHandler {
-
- public SaveAsHandler() {
- registerEnablement();
- }
-
- public Object execute(ExecutionEvent event) {
-
- ISaveablePart saveablePart = getSaveablePart(event);
-
- if (saveablePart != null)
- saveablePart.doSaveAs();
-
- return null;
- }
-
- protected EvaluationResult evaluate(IEvaluationContext context) {
-
- IWorkbenchWindow window = InternalHandlerUtil.getActiveWorkbenchWindow(context);
- // no window? not active
- if (window == null)
- return EvaluationResult.FALSE;
- WorkbenchPage page = (WorkbenchPage) window.getActivePage();
-
- // no page? not active
- if (page == null)
- return EvaluationResult.FALSE;
-
- // get saveable part
- ISaveablePart saveablePart = getSaveablePart(context);
- if (saveablePart == null)
- return EvaluationResult.FALSE;
-
- // if its availble, return whatever it says
- return saveablePart.isSaveAsAllowed() ? EvaluationResult.TRUE : EvaluationResult.FALSE;
- }
-
-}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/handlers/SaveHandler.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/handlers/SaveHandler.java
deleted file mode 100644
index 0214be70776..00000000000
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/handlers/SaveHandler.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 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.handlers;
-
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.expressions.EvaluationResult;
-import org.eclipse.core.expressions.IEvaluationContext;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.ISaveablePart;
-import org.eclipse.ui.ISaveablesSource;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.handlers.HandlerUtil;
-import org.eclipse.ui.internal.InternalHandlerUtil;
-import org.eclipse.ui.internal.SaveableHelper;
-import org.eclipse.ui.internal.WorkbenchPage;
-
-/**
- * <p>
- * Replacement for SaveAction
- * </p>
- *
- * @since 3.7
- *
- */
-public class SaveHandler extends AbstractSaveHandler {
-
- public SaveHandler() {
- registerEnablement();
- }
-
- public Object execute(ExecutionEvent event) {
-
- ISaveablePart saveablePart = getSaveablePart(event);
-
- // no saveable
- if (saveablePart == null)
- return null;
-
- // if editor
- if (saveablePart instanceof IEditorPart) {
- IEditorPart editorPart = (IEditorPart) saveablePart;
- IWorkbenchPage page = editorPart.getSite().getPage();
- page.saveEditor(editorPart, false);
- return null;
- }
-
- // if view
- IWorkbenchPart activePart = HandlerUtil.getActivePart(event);
- WorkbenchPage page = (WorkbenchPage) activePart.getSite().getPage();
- page.savePart(saveablePart, activePart, false);
-
- return null;
-
- }
-
- protected EvaluationResult evaluate(IEvaluationContext context) {
-
- IWorkbenchWindow window = InternalHandlerUtil.getActiveWorkbenchWindow(context);
- // no window? not active
- if (window == null)
- return EvaluationResult.FALSE;
- WorkbenchPage page = (WorkbenchPage) window.getActivePage();
-
- // no page? not active
- if (page == null)
- return EvaluationResult.FALSE;
-
- // get saveable part
- ISaveablePart saveablePart = getSaveablePart(context);
- if (saveablePart == null)
- return EvaluationResult.FALSE;
-
- if (saveablePart instanceof ISaveablesSource) {
- ISaveablesSource modelSource = (ISaveablesSource) saveablePart;
- if (SaveableHelper.needsSave(modelSource))
- return EvaluationResult.TRUE;
- return EvaluationResult.FALSE;
- }
-
- if (saveablePart != null && saveablePart.isDirty())
- return EvaluationResult.TRUE;
-
- return EvaluationResult.FALSE;
- }
-}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/handlers/SavePerspectiveHandler.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/handlers/SavePerspectiveHandler.java
deleted file mode 100644
index e35d6b15c6f..00000000000
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/handlers/SavePerspectiveHandler.java
+++ /dev/null
@@ -1,113 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 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.handlers;
-
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.ui.IPerspectiveDescriptor;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.handlers.HandlerUtil;
-import org.eclipse.ui.internal.WorkbenchMessages;
-import org.eclipse.ui.internal.WorkbenchPage;
-import org.eclipse.ui.internal.WorkbenchPlugin;
-import org.eclipse.ui.internal.dialogs.SavePerspectiveDialog;
-import org.eclipse.ui.internal.registry.PerspectiveDescriptor;
-import org.eclipse.ui.internal.registry.PerspectiveRegistry;
-
-/**
- *
- * @author Prakash G.R.
- *
- * @since 3.7
- *
- */
-public class SavePerspectiveHandler extends AbstractHandler {
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.
- * ExecutionEvent)
- */
- public Object execute(ExecutionEvent event) {
-
- IWorkbenchWindow activeWorkbenchWindow = HandlerUtil.getActiveWorkbenchWindow(event);
- if (activeWorkbenchWindow != null) {
- WorkbenchPage page = (WorkbenchPage) activeWorkbenchWindow.getActivePage();
- if (page != null) {
- PerspectiveDescriptor descriptor = (PerspectiveDescriptor) page.getPerspective();
- if (descriptor != null) {
- if (descriptor.isSingleton()) {
- saveSingleton(page);
- } else {
- saveNonSingleton(page, descriptor);
- }
- }
- }
- }
- return null;
- }
-
- /**
- * Save a singleton over itself.
- */
- private void saveSingleton(IWorkbenchPage page) {
- String[] buttons = new String[] { IDialogConstants.OK_LABEL, IDialogConstants.CANCEL_LABEL };
- MessageDialog d = new MessageDialog(page.getWorkbenchWindow().getShell(),
- WorkbenchMessages.SavePerspective_overwriteTitle, null,
- WorkbenchMessages.SavePerspective_singletonQuestion, MessageDialog.QUESTION,
- buttons, 0);
- if (d.open() == 0) {
- page.savePerspective();
- }
- }
-
- /**
- * Save a singleton over the user selection.
- */
- private void saveNonSingleton(IWorkbenchPage page, PerspectiveDescriptor oldDesc) {
- // Get reg.
- PerspectiveRegistry reg = (PerspectiveRegistry) WorkbenchPlugin.getDefault()
- .getPerspectiveRegistry();
-
- // Get persp name.
- SavePerspectiveDialog dlg = new SavePerspectiveDialog(page.getWorkbenchWindow().getShell(),
- reg);
- // Look up the descriptor by id again to ensure it is still valid.
- IPerspectiveDescriptor description = reg.findPerspectiveWithId(oldDesc.getId());
- dlg.setInitialSelection(description);
- if (dlg.open() != IDialogConstants.OK_ID) {
- return;
- }
-
- // Create descriptor.
- PerspectiveDescriptor newDesc = (PerspectiveDescriptor) dlg.getPersp();
- if (newDesc == null) {
- String name = dlg.getPerspName();
- newDesc = reg.createPerspective(name, (PerspectiveDescriptor) description);
- if (newDesc == null) {
- MessageDialog.openError(dlg.getShell(),
- WorkbenchMessages.SavePerspective_errorTitle,
- WorkbenchMessages.SavePerspective_errorMessage);
- return;
- }
- }
-
- // Save state.
- page.savePerspectiveAs(newDesc);
- }
-
-}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/handlers/SlaveHandlerService.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/handlers/SlaveHandlerService.java
deleted file mode 100644
index 507aef4dac9..00000000000
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/handlers/SlaveHandlerService.java
+++ /dev/null
@@ -1,288 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2009 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.handlers;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-
-import org.eclipse.core.commands.Command;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.commands.IHandler;
-import org.eclipse.core.commands.NotEnabledException;
-import org.eclipse.core.commands.NotHandledException;
-import org.eclipse.core.commands.ParameterizedCommand;
-import org.eclipse.core.commands.common.NotDefinedException;
-import org.eclipse.core.expressions.Expression;
-import org.eclipse.core.expressions.IEvaluationContext;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.ui.ISourceProvider;
-import org.eclipse.ui.handlers.IHandlerActivation;
-import org.eclipse.ui.handlers.IHandlerService;
-import org.eclipse.ui.internal.expressions.AndExpression;
-
-/**
- * A handler service which delegates almost all responsibility to the parent
- * service. It is only responsible for disposing of locally activated handlers
- * when it is disposed.
- * <p>
- * This class is not intended for use outside of the
- * <code>org.eclipse.ui.workbench</code> plug-in.
- * </p>
- *
- * @since 3.2
- */
-public class SlaveHandlerService implements IHandlerService {
-
- /**
- * The default expression to use when
- * {@link #activateHandler(String, IHandler)} is called. Handlers
- * contributed using that method will only be active when this service is
- * active. However, this expression will be used for conflict resolution.
- */
- protected final Expression defaultExpression;
-
- /**
- * A collection of source providers. The listeners are not
- * activated/deactivated, but they will be removed when this service is
- * disposed.
- */
- private Collection fSourceProviders = new ArrayList();
-
- /**
- * A map of the local activation to the parent activations. If this service
- * is inactive, then all parent activations are <code>null</code>.
- * Otherwise, they point to the corresponding activation in the parent
- * service.
- */
- protected final Map localActivationsToParentActivations = new HashMap();
-
- /**
- * The parent handler service to which all requests are ultimately routed.
- * This value is never <code>null</code>.
- */
- protected final IHandlerService parent;
-
- /**
- * The activations registered with the parent handler service. This value is
- * never <code>null</code>.
- */
- protected final Set parentActivations = new HashSet();
-
- /**
- * Constructs a new instance.
- *
- * @param parentHandlerService
- * The parent handler service for this slave; must not be
- * <code>null</code>.
- * @param defaultExpression
- * The default expression to use if none is provided. This is
- * primarily used for conflict resolution. This value may be
- * <code>null</code>.
- */
- public SlaveHandlerService(final IHandlerService parentHandlerService,
- final Expression defaultExpression) {
- if (parentHandlerService == null) {
- throw new NullPointerException(
- "The parent handler service cannot be null"); //$NON-NLS-1$
- }
-
- this.defaultExpression = defaultExpression;
- this.parent = parentHandlerService;
- }
-
- public final IHandlerActivation activateHandler(
- final IHandlerActivation childActivation) {
- final String commandId = childActivation.getCommandId();
- final IHandler handler = childActivation.getHandler();
- final Expression childExpression = childActivation.getExpression();
- Expression expression = defaultExpression;
- if (childExpression != null && defaultExpression != null) {
- final AndExpression andExpression = new AndExpression();
- andExpression.add(childExpression);
- andExpression.add(defaultExpression);
- expression = andExpression;
- } else if (childExpression != null) {
- expression = childExpression;
- }
- final int depth = childActivation.getDepth() + 1;
- final IHandlerActivation localActivation = new HandlerActivation(
- commandId, handler, expression, depth, this);
-
- return doActivation(localActivation);
- }
-
- public final IHandlerActivation activateHandler(final String commandId,
- final IHandler handler) {
- final IHandlerActivation localActivation = new HandlerActivation(
- commandId, handler, defaultExpression,
- IHandlerActivation.ROOT_DEPTH, this);
- return doActivation(localActivation);
- }
-
- public final IHandlerActivation activateHandler(final String commandId,
- final IHandler handler, final Expression expression) {
- return activateHandler(commandId, handler, expression, false);
- }
-
- public final IHandlerActivation activateHandler(final String commandId,
- final IHandler handler, final Expression expression,
- final boolean global) {
- if (global) {
- final IHandlerActivation activation = parent.activateHandler(
- commandId, handler, expression, global);
- parentActivations.add(activation);
- return activation;
- }
-
- Expression aExpression = defaultExpression;
- if (expression != null && defaultExpression != null) {
- final AndExpression andExpression = new AndExpression();
- andExpression.add(expression);
- andExpression.add(defaultExpression);
- aExpression = andExpression;
- } else if (expression != null) {
- aExpression = expression;
- }
- final IHandlerActivation localActivation = new HandlerActivation(
- commandId, handler, aExpression,
- IHandlerActivation.ROOT_DEPTH, this);
- return doActivation(localActivation);
- }
-
- public final IHandlerActivation activateHandler(final String commandId,
- final IHandler handler, final Expression expression,
- final int sourcePriorities) {
- return activateHandler(commandId, handler, expression);
- }
-
- public final void addSourceProvider(final ISourceProvider provider) {
- if (!fSourceProviders.contains(provider)) {
- fSourceProviders.add(provider);
- }
- parent.addSourceProvider(provider);
- }
-
- public final ExecutionEvent createExecutionEvent(final Command command,
- final Event event) {
- return parent.createExecutionEvent(command, event);
- }
-
- public final ExecutionEvent createExecutionEvent(
- final ParameterizedCommand command, final Event event) {
- return parent.createExecutionEvent(command, event);
- }
-
- public final void deactivateHandler(final IHandlerActivation activation) {
- final IHandlerActivation parentActivation;
- if (localActivationsToParentActivations.containsKey(activation)) {
- parentActivation = (IHandlerActivation) localActivationsToParentActivations
- .remove(activation);
- } else {
- parentActivation = activation;
- }
-
- if (parentActivation != null) {
- parent.deactivateHandler(parentActivation);
- parentActivations.remove(parentActivation);
- }
- }
-
- public final void deactivateHandlers(final Collection activations) {
- Object[] array = activations.toArray();
- for (int i = 0; i < array.length; i++) {
- deactivateHandler((IHandlerActivation) array[i]);
- array[i] = null;
- }
- }
-
- public final void dispose() {
- parent.deactivateHandlers(parentActivations);
- parentActivations.clear();
- localActivationsToParentActivations.clear();
-
- // Remove any "resource", like listeners, that were associated
- // with this service.
- if (!fSourceProviders.isEmpty()) {
- Object[] array = fSourceProviders.toArray();
- for (int i = 0; i < array.length; i++) {
- removeSourceProvider((ISourceProvider) array[i]);
- }
- fSourceProviders.clear();
- }
- }
-
- protected IHandlerActivation doActivation(
- final IHandlerActivation localActivation) {
- final IHandlerActivation parentActivation;
- parentActivation = parent.activateHandler(localActivation);
- parentActivations.add(parentActivation);
- localActivationsToParentActivations.put(localActivation,
- parentActivation);
- return localActivation;
- }
-
- public final Object executeCommand(final ParameterizedCommand command,
- final Event event) throws ExecutionException, NotDefinedException,
- NotEnabledException, NotHandledException {
- return parent.executeCommand(command, event);
- }
-
- public final Object executeCommand(final String commandId, final Event event)
- throws ExecutionException, NotDefinedException,
- NotEnabledException, NotHandledException {
- return parent.executeCommand(commandId, event);
- }
-
- public final IEvaluationContext getCurrentState() {
- return parent.getCurrentState();
- }
-
- public final void readRegistry() {
- parent.readRegistry();
- }
-
- public final void removeSourceProvider(final ISourceProvider provider) {
- fSourceProviders.remove(provider);
- parent.removeSourceProvider(provider);
- }
-
- public final void setHelpContextId(final IHandler handler,
- final String helpContextId) {
- parent.setHelpContextId(handler, helpContextId);
- }
-
- Expression getDefaultExpression() {
- return defaultExpression;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.handlers.IHandlerService#createContextSnapshot(boolean)
- */
- public IEvaluationContext createContextSnapshot(boolean includeSelection) {
- return parent.createContextSnapshot(includeSelection);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.handlers.IHandlerService#executeCommandInContext(org.eclipse.core.commands.ParameterizedCommand, org.eclipse.swt.widgets.Event, org.eclipse.core.expressions.IEvaluationContext)
- */
- public Object executeCommandInContext(ParameterizedCommand command,
- Event event, IEvaluationContext context) throws ExecutionException,
- NotDefinedException, NotEnabledException, NotHandledException {
- return parent.executeCommandInContext(command, event, context);
- }
-}
-
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/handlers/SpyHandler.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/handlers/SpyHandler.java
deleted file mode 100644
index 1d929b982a7..00000000000
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/handlers/SpyHandler.java
+++ /dev/null
@@ -1,156 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 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.handlers;
-
-import org.eclipse.ui.internal.testing.ContributionInfoMessages;
-
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.jface.layout.GridLayoutFactory;
-import org.eclipse.jface.window.ToolTip;
-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;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.swt.widgets.TableItem;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.swt.widgets.Tree;
-import org.eclipse.swt.widgets.TreeItem;
-import org.eclipse.ui.handlers.HandlerUtil;
-import org.eclipse.ui.internal.util.Util;
-import org.eclipse.ui.testing.ContributionInfo;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.FrameworkUtil;
-
-/**
- * @since 3.6
- *
- */
-public class SpyHandler extends AbstractHandler {
-
- public Object execute(ExecutionEvent event) {
- Shell shell = HandlerUtil.getActiveShell(event);
- if (shell != null) {
- Control control = shell.getDisplay().getFocusControl();
- if (control != null) {
- showTooltip(control);
- }
- }
- return null;
- }
-
- protected void showTooltip(Control control) {
- ContributionInfo contributionInfo = null;
- Point offset = new Point(0, 0);
- while (control != null) {
- if (control instanceof Table) {
- Table table = (Table) control;
- if (table.getSelectionCount() == 1) {
- TableItem tableItem = table.getSelection()[0];
- contributionInfo = getContributionInfo(tableItem.getData(),
- ContributionInfoMessages.ContributionInfo_TableItem);
- if (contributionInfo != null) {
- Rectangle bounds = tableItem.getBounds();
- offset = new Point(bounds.x, bounds.y);
- break;
- }
- }
- } else if (control instanceof Tree) {
- Tree tree = (Tree) control;
- if (tree.getSelectionCount() == 1) {
- TreeItem treeItem = tree.getSelection()[0];
- contributionInfo = getContributionInfo(treeItem.getData(),
- ContributionInfoMessages.ContributionInfo_TreeItem);
- if (contributionInfo != null) {
- Rectangle bounds = treeItem.getBounds();
- offset = new Point(bounds.x, bounds.y);
- break;
- }
- }
- }
- String optionalElementType;
-
- // "force" a contribution info if we are at a shell
- if (control instanceof Shell)
- optionalElementType = ContributionInfoMessages.ContributionInfo_Window;
- else
- optionalElementType = null;
-
- contributionInfo = getContributionInfo(control.getData(), optionalElementType);
-
- if (contributionInfo != null) {
- break;
- }
- control = control.getParent();
- }
- if (contributionInfo == null) {
- return;
- }
- doShowTooltip(control, offset, contributionInfo);
- }
-
- /**
- * @param control
- * @param offset
- * @param contributionInfo
- */
- protected void doShowTooltip(Control control, Point offset,
- final ContributionInfo contributionInfo) {
- ToolTip toolTip = new ToolTip(control, ToolTip.NO_RECREATE, true) {
-
- protected Composite createToolTipContentArea(Event event, Composite parent) {
- // Create the content area
- Composite composite = new Composite(parent, SWT.NONE);
- composite.setBackground(parent.getDisplay().getSystemColor(
- SWT.COLOR_INFO_BACKGROUND));
- Text text = new Text(composite, SWT.READ_ONLY);
- text.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_INFO_BACKGROUND));
- String info = NLS.bind(ContributionInfoMessages.ContributionInfo_ContributedBy,
- contributionInfo.getElementType(), contributionInfo.getBundleId());
- text.setText(info);
- GridLayoutFactory.fillDefaults().margins(2, 2).generateLayout(composite);
- return composite;
- }
- };
- toolTip.setHideOnMouseDown(false);
- toolTip.setHideDelay(3000);
- toolTip.show(offset);
- }
-
- /**
- * Returns a ContributionInfo for the given data object (typically, a data
- * object associated with a widget). If the data object is a
- * ContributionInfo, return it. If it can be adapted to ContributionInfo,
- * return the result of the adaptation. Otherwise, if a non-null
- * 'optionalElementType' string is given, return a contribution info based
- * on it and the bundle that contains the given object's class.
- */
- ContributionInfo getContributionInfo(Object data, String optionalElementType) {
- if (data instanceof ContributionInfo) {
- return (ContributionInfo) data;
- }
- ContributionInfo result = (ContributionInfo) Util.getAdapter(data, ContributionInfo.class);
- if (optionalElementType != null && result == null && data != null) {
- Bundle bundle = FrameworkUtil.getBundle(data.getClass());
- if (bundle != null) {
- result = new ContributionInfo(bundle.getSymbolicName(),
- optionalElementType != null ? optionalElementType
- : ContributionInfoMessages.ContributionInfo_Unknown, null);
- }
- }
- return result;
- }
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/keys/OutOfOrderListener.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/keys/OutOfOrderListener.java
deleted file mode 100644
index b18a2b991cb..00000000000
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/keys/OutOfOrderListener.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 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.keys;
-
-import java.util.List;
-
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.Listener;
-import org.eclipse.swt.widgets.Widget;
-
-/**
- * A listener that makes sure that global key bindings are processed if no other
- * listeners do any useful work.
- *
- * @since 3.0
- */
-public class OutOfOrderListener implements Listener {
- /**
- * The time at which this listener was last registered to an event. This is
- * the <code>event.time</code> value.
- *
- * @since 3.1
- */
- private int active = Integer.MIN_VALUE;
-
- /**
- * The keyboard interface to which the event should be passed if it is not
- * eaten.
- */
- private final WorkbenchKeyboard keyboard;
-
- /**
- * Constructs a new instance of <code>OutOfOrderListener</code> with a
- * reference to the keyboard interface which should be allowed to process
- * uneaten events.
- *
- * @param workbenchKeyboard
- * The keyboard interface for the workbench capable of processing
- * key bindings; must not be <code>null</code>.
- */
- public OutOfOrderListener(WorkbenchKeyboard workbenchKeyboard) {
- keyboard = workbenchKeyboard;
- }
-
- /**
- * Handles the key down event on a widget by passing uneaten events to the
- * key binding architecture. This is used to allow special keys to reach the
- * widget first -- before being processed by the key binding architecture.
- *
- * @param event
- * The event to process; must not be <code>null</code>
- */
- public void handleEvent(Event event) {
- // Always remove myself as a listener.
- final Widget widget = event.widget;
- if ((widget != null) && (!widget.isDisposed())) {
- widget.removeListener(event.type, this);
- }
-
- /*
- * If the event is still up for grabs, then re-route through the global
- * key filter.
- */
- if (event.doit) {
- List keyStrokes = WorkbenchKeyboard
- .generatePossibleKeyStrokes(event);
- keyboard.processKeyEvent(keyStrokes, event);
- }
- }
-
- /**
- * Returns whether this listener has been hooked by this event already.
- *
- * @param timeRegistered
- * The <code>event.time</code> for the current event.
- * @return <code>true</code> if this listener is registered for a
- * different event; <code>false</code> otherwise.
- *
- * @since 3.1
- */
- final boolean isActive(final int timeRegistered) {
- return (active == timeRegistered);
- }
-
- /**
- * Sets the event time at which this listener was last registered with a
- * widget.
- *
- * @param timeRegistered
- * The time at which this listener was last registered with a
- * widget.
- *
- * @since 3.1
- */
- final void setActive(final int timeRegistered) {
- active = timeRegistered;
- }
-}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/keys/OutOfOrderVerifyListener.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/keys/OutOfOrderVerifyListener.java
deleted file mode 100644
index 71f9d22b8d4..00000000000
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/keys/OutOfOrderVerifyListener.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 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.keys;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.StyledText;
-import org.eclipse.swt.custom.VerifyKeyListener;
-import org.eclipse.swt.events.VerifyEvent;
-import org.eclipse.swt.widgets.Widget;
-
-/**
- * A listener that makes sure that out-of-order processing occurs if no other
- * verify listeners do any work.
- *
- * @since 3.0
- */
-class OutOfOrderVerifyListener implements VerifyKeyListener {
-
- /**
- * The time at which this listener was last registered to an event. This is
- * the <code>event.time</code> value.
- *
- * @since 3.1
- */
- private int active = Integer.MIN_VALUE;
-
- /**
- * The listener that will be chained in if the verify event has not been
- * eaten yet.
- */
- private OutOfOrderListener chainedListener;
-
- /**
- * Constructs a new instance of <code>OutOfOrderVerifyListener</code> with
- * the listener that will be chained in.
- *
- * @param outOfOrderListener
- * The listener that should be attached to the widget if the
- * verify event is not eaten; must not be <code>null</code>.
- */
- OutOfOrderVerifyListener(OutOfOrderListener outOfOrderListener) {
- chainedListener = outOfOrderListener;
- }
-
- /**
- * Returns whether this listener has been hooked by this event already.
- *
- * @param timeRegistered
- * The <code>event.time</code> for the current event.
- * @return <code>true</code> if this listener is registered for a
- * different event; <code>false</code> otherwise.
- *
- * @since 3.1
- */
- final boolean isActive(final int timeRegistered) {
- return (active == timeRegistered);
- }
-
- /**
- * Sets the event time at which this listener was last registered with a
- * widget.
- *
- * @param timeRegistered
- * The time at which this listener was last registered with a
- * widget.
- *
- * @since 3.1
- */
- final void setActive(final int timeRegistered) {
- active = timeRegistered;
- }
-
- /**
- * Checks whether any other verify listeners have triggered. If not, then it
- * sets up the top-level out-of-order listener.
- *
- * @param event
- * The verify event after it has been processed by all other
- * verify listeners; must not be <code>null</code>.
- */
- public void verifyKey(VerifyEvent event) {
- // Always remove the listener.
- final Widget widget = event.widget;
- if ((widget instanceof StyledText) && (!widget.isDisposed())) {
- ((StyledText) widget).removeVerifyKeyListener(this);
- }
-
- /*
- * If the event is still up for grabs, then re-route through the global
- * key filter.
- */
- if (event.doit) {
- widget.addListener(SWT.Modify, new CancelOnModifyListener(
- chainedListener));
- widget.addListener(SWT.KeyDown, chainedListener);
- }
- }
-}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/menus/AbstractMenuAdditionCacheEntry.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/menus/AbstractMenuAdditionCacheEntry.java
deleted file mode 100644
index c00f422559d..00000000000
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/menus/AbstractMenuAdditionCacheEntry.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 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.menus;
-
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.ui.menus.AbstractContributionFactory;
-
-/**
- * Base class for factories derived from extensions.
- *
- * @since 3.5
- */
-public abstract class AbstractMenuAdditionCacheEntry extends
- AbstractContributionFactory {
-
- private IConfigurationElement additionElement;
-
- /**
- * Create a new instance of this class.
- *
- * @param location the location URI
- * @param namespace the namespace
- * @param element the declaring configuration element
- */
- public AbstractMenuAdditionCacheEntry(String location, String namespace, IConfigurationElement element) {
- super(location, namespace);
- this.additionElement = element;
- }
-
- /**
- * Return the configuration element.
- *
- * @return the configuration element
- */
- public final IConfigurationElement getConfigElement() {
- return additionElement;
- }
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/menus/ContributionRoot.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/menus/ContributionRoot.java
deleted file mode 100644
index 70b9e0e1fa8..00000000000
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/menus/ContributionRoot.java
+++ /dev/null
@@ -1,119 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 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.menus;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
-
-import org.eclipse.core.expressions.Expression;
-import org.eclipse.jface.action.ContributionManager;
-import org.eclipse.jface.action.IContributionItem;
-import org.eclipse.ui.internal.expressions.AlwaysEnabledExpression;
-import org.eclipse.ui.menus.AbstractContributionFactory;
-import org.eclipse.ui.menus.IContributionRoot;
-
-/**
- * Default implementation.
- *
- * @since 3.3
- */
-final class ContributionRoot implements
- IContributionRoot {
-
- private List topLevelItems = new ArrayList();
- private List itemsToExpressions = new ArrayList();
- private InternalMenuService menuService;
- Set restriction;
- private ContributionManager mgr;
- private AbstractContributionFactory factory;
-
- public ContributionRoot(InternalMenuService menuService, Set restriction,
- ContributionManager mgr, AbstractContributionFactory factory) {
- this.menuService = menuService;
- this.restriction = restriction;
- this.mgr = mgr;
- this.factory = factory;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.menus.IContributionRoot#addContributionItem(org.eclipse.jface.action.IContributionItem, org.eclipse.core.expressions.Expression, org.eclipse.core.expressions.Expression)
- */
- public void addContributionItem(IContributionItem item,
- Expression visibleWhen) {
- if (item == null)
- throw new IllegalArgumentException();
- topLevelItems.add(item);
- if (visibleWhen == null)
- visibleWhen = AlwaysEnabledExpression.INSTANCE;
-
- menuService.registerVisibleWhen(item, visibleWhen, restriction,
- createIdentifierId(item));
- itemsToExpressions.add(item);
- }
-
- /**
- * Create the activity identifier for this contribution item.
- *
- * @param item the item
- * @return the identifier
- */
- private String createIdentifierId(IContributionItem item) {
- String namespace = factory.getNamespace();
- String identifierID = namespace != null ? namespace + '/'
- + item.getId() : null; // create the activity identifier ID. If
- // this factory doesn't have a namespace
- // it will be null.
- return identifierID;
- }
-
- public List getItems() {
- return topLevelItems;
- }
-
- /**
- * Unregister all visible when expressions from the menu service.
- */
- public void release() {
- for (Iterator itemIter = itemsToExpressions.iterator(); itemIter.hasNext();) {
- IContributionItem item = (IContributionItem) itemIter.next();
- menuService.unregisterVisibleWhen(item, restriction);
- item.dispose();
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.menus.IContributionRoot#registerVisibilityForChild(org.eclipse.jface.action.IContributionItem,
- * org.eclipse.core.expressions.Expression,
- * org.eclipse.core.expressions.Expression)
- */
- public void registerVisibilityForChild(IContributionItem item,
- Expression visibleWhen) {
- if (item == null)
- throw new IllegalArgumentException();
- if (visibleWhen == null)
- visibleWhen = AlwaysEnabledExpression.INSTANCE;
- menuService.registerVisibleWhen(item, visibleWhen, restriction,
- createIdentifierId(item));
- itemsToExpressions.add(item);
- }
-
- /**
- * @return Returns the mgr.
- */
- public ContributionManager getManager() {
- return mgr;
- }
-}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/menus/IMenuActivation.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/menus/IMenuActivation.java
deleted file mode 100644
index a823f7541e7..00000000000
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/menus/IMenuActivation.java
+++ /dev/null
@@ -1,26 +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.menus;
-
-import org.eclipse.jface.action.IContributionItem;
-import org.eclipse.ui.internal.services.IEvaluationResultCache;
-
-/**
- * @since 3.3
- *
- */
-public interface IMenuActivation extends IEvaluationResultCache {
- /**
- * @return the IContributionItem for the cache.
- */
- public IContributionItem getContribution();
-}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/menus/IMenuLabelProvider.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/menus/IMenuLabelProvider.java
deleted file mode 100644
index a3c5382b4c2..00000000000
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/menus/IMenuLabelProvider.java
+++ /dev/null
@@ -1,27 +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.menus;
-
-import org.eclipse.jface.viewers.ILabelProvider;
-
-/**
- * Label provider for menu / toolbar items
- *
- * @since 3.3
- *
- */
-public interface IMenuLabelProvider extends ILabelProvider {
- /**
- * @return The Tooltip to use for this menu item
- */
- public String getToolTip();
-}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/menus/InternalMenuService.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/menus/InternalMenuService.java
deleted file mode 100644
index ba13547c0ff..00000000000
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/menus/InternalMenuService.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 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.menus;
-
-import java.util.List;
-import java.util.Set;
-
-import org.eclipse.core.expressions.Expression;
-import org.eclipse.jface.action.ContributionManager;
-import org.eclipse.jface.action.IContributionItem;
-import org.eclipse.ui.menus.IMenuService;
-import org.eclipse.ui.services.IServiceLocator;
-
-/**
- * Internal baseclass for Workbench and Window menu service implementations.
- * Methods in this class might some day make sense to live in IMenuService.
- *
- * @since 3.3
- *
- */
-public abstract class InternalMenuService implements IMenuService {
-
- /**
- * Ties an expression to {@link IContributionItem#setVisible(boolean)}.
- *
- * @param item
- * the item
- * @param visibleWhen
- * the expression
- * @param restriction
- * the restriction expression
- * @param identifierId
- * the activity identifier id
- */
- public abstract void registerVisibleWhen(final IContributionItem item,
- final Expression visibleWhen, final Set restriction, String identifierID);
-
- /**
- * Removes any expressions bound to
- * {@link IContributionItem#setVisible(boolean)} of the given item
- *
- * @param item
- * the item to unbind
- */
- public abstract void unregisterVisibleWhen(IContributionItem item, final Set restriction);
-
- /**
- * Return a list of {@link MenuAdditionCacheEntry} objects that are
- * contributed at the given uri.
- *
- * @param uri
- * the uri to search on
- * @return the list of items
- */
- public abstract List getAdditionsForURI(MenuLocationURI uri);
-
- public abstract void populateContributionManager(
- IServiceLocator serviceLocatorToUse, Set restriction,
- ContributionManager mgr, String uri, boolean recurse);
-
- public abstract void populateContributionManager(ContributionManager mgr,
- String uri, boolean recurse);
-}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/menus/MenuActivation.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/menus/MenuActivation.java
deleted file mode 100644
index ea61ab33d70..00000000000
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/menus/MenuActivation.java
+++ /dev/null
@@ -1,48 +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.menus;
-
-import org.eclipse.core.expressions.Expression;
-import org.eclipse.jface.action.IContributionItem;
-import org.eclipse.ui.internal.services.EvaluationResultCache;
-
-/**
- * @since 3.3
- *
- */
-public class MenuActivation extends EvaluationResultCache implements
- IMenuActivation {
-
- private IContributionItem fItem;
-
- /**
- * @param item
- * this contribution ite
- * @param visibleWhen
- * when it's visible
- * @param auth
- * the menu authority responsible for this cache
- */
- public MenuActivation(IContributionItem item, Expression visibleWhen) {
- super(visibleWhen);
- fItem = item;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.internal.menus.IMenuActivation#getContribution()
- */
- public IContributionItem getContribution() {
- return fItem;
- }
-}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/menus/MenuServiceFactory.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/menus/MenuServiceFactory.java
deleted file mode 100644
index 1e766c09f22..00000000000
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/menus/MenuServiceFactory.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 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.menus;
-
-import org.eclipse.ui.IWorkbench;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.internal.WorkbenchWindow;
-import org.eclipse.ui.internal.services.IWorkbenchLocationService;
-import org.eclipse.ui.menus.IMenuService;
-import org.eclipse.ui.services.AbstractServiceFactory;
-import org.eclipse.ui.services.IServiceLocator;
-
-/**
- * @since 3.4
- *
- */
-public class MenuServiceFactory extends AbstractServiceFactory {
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.eclipse.ui.services.AbstractServiceFactory#create(java.lang.Class,
- * org.eclipse.ui.services.IServiceLocator,
- * org.eclipse.ui.services.IServiceLocator)
- */
- public Object create(Class serviceInterface, IServiceLocator parentLocator,
- IServiceLocator locator) {
- if (!IMenuService.class.equals(serviceInterface)) {
- return null;
- }
- IWorkbenchLocationService wls = (IWorkbenchLocationService) locator
- .getService(IWorkbenchLocationService.class);
- final IWorkbench wb = wls.getWorkbench();
- if (wb == null) {
- return null;
- }
-
- Object parent = parentLocator.getService(serviceInterface);
- if (parent == null) {
- // we are registering the global services in the Workbench
- return null;
- }
- final IWorkbenchWindow window = wls.getWorkbenchWindow();
- return new SlaveMenuService((InternalMenuService) parent, locator,
- ((WorkbenchWindow)window).getMenuRestrictions());
- }
-
-}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/menus/ProxyMenuAdditionCacheEntry.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/menus/ProxyMenuAdditionCacheEntry.java
deleted file mode 100644
index 9270a0728ba..00000000000
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/menus/ProxyMenuAdditionCacheEntry.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 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.menus;
-
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.SafeRunner;
-import org.eclipse.jface.util.SafeRunnable;
-import org.eclipse.ui.internal.WorkbenchPlugin;
-import org.eclipse.ui.internal.registry.IWorkbenchRegistryConstants;
-import org.eclipse.ui.menus.AbstractContributionFactory;
-import org.eclipse.ui.menus.ExtensionContributionFactory;
-import org.eclipse.ui.menus.IContributionRoot;
-import org.eclipse.ui.services.IServiceLocator;
-
-/**
- * Proxy cache entry that manages access to contributed instances of
- * {@link ExtensionContributionFactory}.
- *
- * @since 3.5
- *
- */
-public class ProxyMenuAdditionCacheEntry extends AbstractMenuAdditionCacheEntry {
-
- private AbstractContributionFactory factory;
- private boolean createFactory = true;
-
- /**
- * Create a new instance of this class.
- *
- * @param location the location URI
- * @param namespace the namespace
- * @param element the defining element
- */
- public ProxyMenuAdditionCacheEntry(String location, String namespace,
- IConfigurationElement element) {
- super(location, namespace, element);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.eclipse.ui.menus.AbstractContributionFactory#createContributionItems
- * (org.eclipse.ui.services.IServiceLocator,
- * org.eclipse.ui.menus.IContributionRoot)
- */
- public void createContributionItems(IServiceLocator serviceLocator,
- IContributionRoot additions) {
- AbstractContributionFactory factory = getFactory();
- if (factory != null)
- factory.createContributionItems(serviceLocator, additions);
- }
-
- /**
- * Return the factory or <code>null</code> if it could not be obtained.
- *
- * @return the factory
- */
- private AbstractContributionFactory getFactory() {
- if (createFactory)
- factory = createFactory();
- return factory;
- }
-
- /**
- * Return the factory or <code>null</code> if it could not be obtained.
- *
- * @return the factory
- */
- private AbstractContributionFactory createFactory() {
- final AbstractContributionFactory[] factory = new AbstractContributionFactory[1];
-
- SafeRunner.run(new SafeRunnable() {
-
- public void run() throws Exception {
- factory[0] = (AbstractContributionFactory) WorkbenchPlugin
- .createExtension(getConfigElement(),
- IWorkbenchRegistryConstants.ATT_CLASS);
-
- }
- });
- createFactory = false;
- return factory[0];
- }
-}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/menus/SlaveMenuService.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/menus/SlaveMenuService.java
deleted file mode 100644
index 231c421a63e..00000000000
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/menus/SlaveMenuService.java
+++ /dev/null
@@ -1,206 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2008 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.menus;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-import java.util.Set;
-
-import org.eclipse.core.expressions.Expression;
-import org.eclipse.core.expressions.IEvaluationContext;
-import org.eclipse.jface.action.ContributionManager;
-import org.eclipse.jface.action.IContributionItem;
-import org.eclipse.ui.ISourceProvider;
-import org.eclipse.ui.menus.AbstractContributionFactory;
-import org.eclipse.ui.services.IServiceLocator;
-
-/**
- * <p>
- * Provides services related to contributing menu elements to a workbench
- * window. Visibility and showing are tracked at the workbench window level.
- * </p>
- * <p>
- * This class is only intended for internal use within the
- * <code>org.eclipse.ui.workbench</code> plug-in.
- * </p>
- *
- * @since 3.2
- */
-public final class SlaveMenuService extends InternalMenuService {
-
- private Collection providers = new ArrayList();
- private Collection factories = new ArrayList();
-
- /**
- * The parent menu service for this window. This parent must track menu
- * definitions and the registry. Must not be <code>null</code>
- */
- private final InternalMenuService parent;
- private IServiceLocator serviceLocator;
- private Set restrictionExpression;
-
- /**
- * Constructs a new instance of <code>MenuService</code> using a menu
- * manager.
- *
- * @param parent
- * The parent menu service for this window. This parent must track menu
- * definitions and the regsitry. Must not be <code>null</code>
- */
- public SlaveMenuService(InternalMenuService parent,
- final IServiceLocator serviceLocator, Set restrictions) {
- restrictionExpression = restrictions;
-
- this.parent = parent;
- this.serviceLocator = serviceLocator;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.eclipse.ui.internal.menus.IMenuService#populateMenu(org.eclipse.jface
- * .action.MenuManager, org.eclipse.ui.internal.menus.MenuLocationURI)
- */
- public void populateContributionManager(ContributionManager mgr, String uri) {
- parent.populateContributionManager(serviceLocator,
- restrictionExpression, mgr, uri, true);
- }
-
- public void populateContributionManager(ContributionManager mgr,
- String uri, boolean recurse) {
- parent.populateContributionManager(serviceLocator,
- restrictionExpression, mgr, uri, recurse);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.internal.menus.IMenuService#getCurrentState()
- */
- public IEvaluationContext getCurrentState() {
- return parent.getCurrentState();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.eclipse.ui.internal.menus.IMenuService#addCacheForURI(org.eclipse
- * .ui.internal.menus.MenuLocationURI,
- * org.eclipse.ui.internal.menus.MenuCacheEntry)
- */
- public void addContributionFactory(AbstractContributionFactory cache) {
- if (!factories.contains(cache)) {
- factories.add(cache);
- }
- parent.addContributionFactory(cache);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.eclipse.ui.internal.menus.IMenuService#releaseMenu(org.eclipse.jface
- * .action.ContributionManager)
- */
- public void releaseContributions(ContributionManager mgr) {
- parent.releaseContributions(mgr);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.eclipse.ui.menus.IMenuService#removeContributionFactory(org.eclipse
- * .ui.menus.AbstractContributionFactory)
- */
- public void removeContributionFactory(AbstractContributionFactory factory) {
- factories.remove(factory);
- parent.removeContributionFactory(factory);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.services.IDisposable#dispose()
- */
- public void dispose() {
- if (!providers.isEmpty()) {
- Object[] array = providers.toArray();
- for (int i = 0; i < array.length; i++) {
- parent.removeSourceProvider((ISourceProvider) array[i]);
- }
- providers.clear();
- }
- if (!factories.isEmpty()) {
- Object[] array = factories.toArray();
- for (int i = 0; i < array.length; i++) {
- parent
- .removeContributionFactory((AbstractContributionFactory) array[i]);
- }
- factories.clear();
- }
- restrictionExpression = null;
- serviceLocator = null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.eclipse.ui.services.IServiceWithSources#addSourceProvider(org.eclipse
- * .ui.ISourceProvider)
- */
- public void addSourceProvider(ISourceProvider provider) {
- if (!providers.contains(provider)) {
- providers.add(provider);
- }
- parent.addSourceProvider(provider);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.eclipse.ui.services.IServiceWithSources#removeSourceProvider(org.
- * eclipse.ui.ISourceProvider)
- */
- public void removeSourceProvider(ISourceProvider provider) {
- providers.remove(provider);
- parent.removeSourceProvider(provider);
- }
-
- public List getAdditionsForURI(MenuLocationURI uri) {
- return parent.getAdditionsForURI(uri);
- }
-
- public void registerVisibleWhen(final IContributionItem item,
- final Expression visibleWhen, final Set restriction,
- String identifierID) {
- parent
- .registerVisibleWhen(item, visibleWhen, restriction,
- identifierID);
- }
-
- public void unregisterVisibleWhen(IContributionItem item, final Set restriction) {
- parent.unregisterVisibleWhen(item, restriction);
- }
-
- public void populateContributionManager(
- IServiceLocator serviceLocatorToUse, Set restriction,
- ContributionManager mgr, String uri, boolean recurse) {
- parent.populateContributionManager(serviceLocatorToUse, restriction,
- mgr, uri, recurse);
- }
-}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/menus/TrimAdditionCacheEntry.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/menus/TrimAdditionCacheEntry.java
deleted file mode 100644
index c18411ac9c6..00000000000
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/menus/TrimAdditionCacheEntry.java
+++ /dev/null
@@ -1,274 +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.menus;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.core.expressions.Expression;
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.IExtensionRegistry;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.jface.action.IContributionItem;
-import org.eclipse.jface.menus.IWidget;
-import org.eclipse.ui.internal.registry.IWorkbenchRegistryConstants;
-import org.eclipse.ui.internal.util.Util;
-import org.eclipse.ui.menus.IMenuService;
-import org.eclipse.ui.menus.IWorkbenchWidget;
-
-/**
- * Handles the top level caching for 3.2 style trim
- * contributions.
- *
- * @since 3.3
- *
- */
-public class TrimAdditionCacheEntry {
- private IConfigurationElement additionElement;
- private MenuLocationURI uri = null;
-
- /**
- * The map contains {@link IWorkbenchWidget} entries
- * for widgets that have failed to load on a previous
- * attempt. Used to prevent multiple retries at
- * loading a widget (which spams the log).
- */
- private Map failedWidgets = new HashMap();
- /**
- * Maps the widget back to it's configurtation element
- */
- private Map widgetToConfigElementMap = new HashMap();
-
-
- // Caches
-
- /**
- * Maps an IContributionItem to its corresponding IConfigurationElement
- */
- Map iciToConfigElementMap = new HashMap();
-
- public TrimAdditionCacheEntry(IConfigurationElement element,
- MenuLocationURI uri, IMenuService service) {
- this.additionElement = element;
- this.uri = uri;
- }
-
- /**
- * Populate the list
- *
- * @param additions
- */
- public void getContributionItems(List additions) {
- additions.clear();
-
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.internal.menus.MenuCacheEntry#generateSubCaches()
- */
- public void generateSubCaches() {
- // TODO Auto-generated method stub
-
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.internal.menus.MenuCacheEntry#getVisibleWhenForItem(org.eclipse.jface.action.IContributionItem)
- */
- public Expression getVisibleWhenForItem(IContributionItem item) {
- // TODO Auto-generated method stub
- return null;
- }
-
- /**
- * @return
- */
- public String getId() {
- return additionElement.getAttribute(IWorkbenchRegistryConstants.ATT_ID);
- }
-
- /**
- * @return <code>true</code> iff the group is positioned at the start
- * (or 'before') the entry that it is relative to. Default is true
- *
- */
- public boolean isAtStart() {
- IConfigurationElement location = additionElement.getChildren(IWorkbenchRegistryConstants.TAG_LOCATION)[0];
- if (location.getChildren(IWorkbenchRegistryConstants.TAG_ORDER).length > 0) {
- IConfigurationElement order = location.getChildren(IWorkbenchRegistryConstants.TAG_ORDER)[0];
-
- String pos = order.getAttribute(IWorkbenchRegistryConstants.ATT_POSITION);
- if (pos != null)
- return (pos.equals("start") | pos.equals("before")); //$NON-NLS-1$//$NON-NLS-2$
- }
- return true;
- }
-
- /**
- * Returns whether or not the defining {@link IConfigurationElement}
- * declares that the widget should use extra space in the 'major'
- * dimension (ie. use extra horizontal space in the status area).
- * The space is equally divided with other elementa in the same
- * trim area that also want to use the extra space.
- *
- * @param widgetElement the {@link IConfigurationElement} declaring this
- * widget.
- *
- * @return <code>true</code> iff the resulting widget should use
- * extra major space
- */
- public boolean fillMajor(IConfigurationElement widgetElement) {
- if (widgetElement.getChildren(IWorkbenchRegistryConstants.TAG_LAYOUT).length==0) {
- return false;
- }
- IConfigurationElement layout = widgetElement.getChildren(IWorkbenchRegistryConstants.TAG_LAYOUT)[0];
- String fillMajorVal = layout.getAttribute(IWorkbenchRegistryConstants.ATT_FILL_MAJOR);
-
- return (fillMajorVal != null && fillMajorVal.equals("true")); //$NON-NLS-1$
- }
-
- /**
- * Returns whether or not the defining {@link IConfigurationElement}
- * declares that the widget should use extra space in the 'minor'
- * dimension (ie. use extra vertical space in the status area)
- *
- * @param widgetElement the {@link IConfigurationElement} declaring this
- * widget.
- *
- * @return <code>true</code> iff the resulting widget should use
- * extra minor space
- */
- public boolean fillMinor(IConfigurationElement widgetElement) {
- if (widgetElement.getChildren(IWorkbenchRegistryConstants.TAG_LAYOUT).length==0) {
- return false;
- }
- IConfigurationElement layout = widgetElement.getChildren(IWorkbenchRegistryConstants.TAG_LAYOUT)[0];
- String fillMinorVal = layout.getAttribute(IWorkbenchRegistryConstants.ATT_FILL_MINOR);
-
- return (fillMinorVal != null && fillMinorVal.equals("true")); //$NON-NLS-1$
- }
-
- /**
- * @return The list of IConfigurationElements representing
- * widgets to be added into this 'group'
- */
- private List getWidgetConfigs() {
- List widgetConfigs = new ArrayList();
-
- // Return to the 'root' of the config tree and gather all elements
- // for this 'group'. Note that while this is sub-optimal
- // performace-wise that there are expected to be -very-
- // few contributions in total (i.e. 10's, not 100's)
- final IExtensionRegistry registry = Platform.getExtensionRegistry();
- final IConfigurationElement[] widgetElements = registry
- .getConfigurationElementsFor(IWorkbenchRegistryConstants.EXTENSION_MENUS);
-
- // Locate all 'widget' additions appropriate for -this- group
- for (int i = 0; i < widgetElements.length; i++) {
- // Only process 'widget' entries
- if (!IWorkbenchRegistryConstants.TAG_WIDGET.equals(widgetElements[i].getName()))
- continue;
-
- // Define the initial URI spec
- if (widgetElements[i].getChildren(IWorkbenchRegistryConstants.TAG_LOCATION).length > 0) {
- IConfigurationElement location = widgetElements[i].getChildren(IWorkbenchRegistryConstants.TAG_LOCATION)[0];
- if (location.getChildren(IWorkbenchRegistryConstants.TAG_BAR).length > 0) {
- IConfigurationElement bar = location.getChildren(IWorkbenchRegistryConstants.TAG_BAR)[0];
-
- // The bar's path represents the 'group' it should go into
- String path = bar.getAttribute(IWorkbenchRegistryConstants.ATT_PATH);
- if (path != null && path.equals(getId()))
- widgetConfigs.add(widgetElements[i]);
- }
- }
- }
-
- return widgetConfigs;
- }
-
- /**
- * Attempts to load -all- widgets for this entry and
- * keeps track of the successful loads only. Only elements
- * who can be successfully loaded will be seen by the
- * builder.
- *
- * @return The list of <code>IWorkbenchWidget</code> entries
- * that have been successfully loaded
- */
- public List getWidgets() {
- List loadedWidgets = new ArrayList();
-
- // Get the widget config elements for this 'group'
- List widgetConfigs = getWidgetConfigs();
- for (Iterator iterator = widgetConfigs.iterator(); iterator
- .hasNext();) {
- IConfigurationElement widgetCE = (IConfigurationElement) iterator.next();
-
- // skip elements that are known to fail
- if (failedWidgets.containsKey(widgetCE))
- continue;
-
- IWorkbenchWidget loadedWidget = loadWidget(widgetCE);
-
- // Either add it to the 'valid' list or mark it
- // as failed
- if (loadedWidget != null) {
- loadedWidgets.add(loadedWidget);
- widgetToConfigElementMap.put(loadedWidget, widgetCE);
- }
- else
- failedWidgets.put(widgetCE, widgetCE);
- }
-
- return loadedWidgets;
- }
-
- /**
- * Attempts to load the executable extension defined within the given
- * configuration element. An error is logged for any widget that fails
- * to load.
- *
- * @param widgetCE The {@link IConfigurationElement} containing the
- * widget's 'class' specification.
- *
- * @return The loaded {@link IWorkbenchWidget} or <code>null</code>
- * if the loading fails
- */
- private IWorkbenchWidget loadWidget(IConfigurationElement widgetCE) {
- return (IWorkbenchWidget) Util.safeLoadExecutableExtension(widgetCE,
- IWorkbenchRegistryConstants.ATT_CLASS,
- IWorkbenchWidget.class);
- }
-
- /**
- * @param widget The {@link IWorkbenchWidget} to get the defining configuration
- * element for.
- *
- * @return The defining {@link IConfigurationElement}
- */
- public IConfigurationElement getElement(IWorkbenchWidget widget) {
- return (IConfigurationElement) widgetToConfigElementMap.get(widget);
- }
-
- /**
- * @param widget
- */
- public void removeWidget(IWidget widget) {
- widgetToConfigElementMap.remove(widget);
- }
-
- public MenuLocationURI getUri() {
- return uri;
- }
-}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/menus/TrimBarManager2.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/menus/TrimBarManager2.java
deleted file mode 100644
index 2ce81679f5d..00000000000
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/menus/TrimBarManager2.java
+++ /dev/null
@@ -1,502 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2007 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.menus;
-
-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.CoreException;
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.jface.menus.IWidget;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.layout.RowLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.ui.internal.WindowTrimProxy;
-import org.eclipse.ui.internal.WorkbenchWindow;
-import org.eclipse.ui.internal.layout.IWindowTrim;
-import org.eclipse.ui.internal.layout.TrimLayout;
-import org.eclipse.ui.internal.misc.StatusUtil;
-import org.eclipse.ui.menus.AbstractWorkbenchTrimWidget;
-import org.eclipse.ui.menus.IMenuService;
-import org.eclipse.ui.menus.IWorkbenchWidget;
-import org.eclipse.ui.statushandlers.StatusManager;
-
-/**
- * <p>
- * An implementation that supports 'trim' elements defined in using the
- * <code>org.eclipse.ui.menus</code> extension point.
- * </p>
- * <p>
- * This class is not intended to be used outside of the
- * <code>org.eclipse.ui.workbench</code> plug-in.
- * </p>
- *
- * @since 3.2
- */
-public class TrimBarManager2 {
-
- /**
- * A List of the URI's representing the trim areas
- */
- private MenuLocationURI[] trimAreaURIs = {
- new MenuLocationURI("toolbar:command1"), //$NON-NLS-1$
- new MenuLocationURI("toolbar:command2"), //$NON-NLS-1$
- new MenuLocationURI("toolbar:vertical1"), //$NON-NLS-1$
- new MenuLocationURI("toolbar:vertical2"), //$NON-NLS-1$
- new MenuLocationURI("toolbar:status"), //$NON-NLS-1$
- };
-
- /**
- * The SWT 'side' corresponding to a URI
- */
- int[] swtSides = { SWT.TOP, SWT.TOP, SWT.LEFT, SWT.RIGHT, SWT.BOTTOM };
- /**
- * The window on which this menu manager exists; never <code>null</code>.
- */
- private STrimBuilder fTrimBuilder;
-
- private WorkbenchMenuService fMenuService;
-
- private boolean fDirty;
-
- /**
- * Constructs a new instance of <code>TrimBarManager</code>.
- *
- * @param window
- * The window on which this menu manager exists; must not be
- * <code>null</code>.
- */
- public TrimBarManager2(final WorkbenchWindow window) {
- if (window == null) {
- throw new IllegalArgumentException("The window cannot be null"); //$NON-NLS-1$
- }
-
- // Remember the parameters
- fMenuService = (WorkbenchMenuService) window.getWorkbench().getService(
- IMenuService.class);
- fTrimBuilder = new STrimBuilder(window);
-
- // New layouts are always 'dirty'
- fDirty = true;
- }
-
- /**
- * Hacked version of the update method that allows the hiding of any trim
- * sited at SWT.TOP. This is because the Intro management wants there to be
- * no trim at the top but can only currently indicate this by using the
- * CoolBar's visibility...
- *
- * @param force
- * @param recursive
- * @param hideTopTrim
- */
- public void update(boolean force, boolean recursive, boolean hideTopTrim) {
- if (force || isDirty()) {
- // Re-render the trim based on the new layout
- fTrimBuilder.build(hideTopTrim);
- setDirty(false);
- }
- }
-
- /**
- * Copied from the <code>MenuManager</code> method...
- *
- * @param force
- * If true then do the update even if not 'dirty'
- * @param recursive
- * Update recursively
- *
- * @see org.eclipse.jface.action.MenuManager#update(boolean, boolean)
- */
- public void update(boolean force, boolean recursive) {
- update(force, recursive, false);
- }
-
- /**
- * Set the dirty state of the layout
- *
- * @param isDirty
- */
- private void setDirty(boolean isDirty) {
- fDirty = isDirty;
- }
-
- /**
- * Returns the 'dirty' state of the layout
- *
- * @return Always returns 'true' for now
- */
- private boolean isDirty() {
- return fDirty;
- }
-
- /**
- * This is a convenience class that maintains the list of the widgets in the
- * group. This allows any position / orientation changes to the group to be
- * passed on to all the widgets for that group.
- *
- * @since 3.2
- *
- */
- private class TrimWidgetProxy extends WindowTrimProxy {
-
- private List widgets;
- private TrimAdditionCacheEntry cacheEntry;
- private int originalSide;
- private int curSide;
-
- private Composite parent;
-
- /**
- * Constructor that takes in any information necessary to implement an
- * IWindowTrim and also has enough state to manage a group with multiple
- * IWidget contributions.
- *
- */
- public TrimWidgetProxy(List widgets, int side, Composite parent,
- TrimAdditionCacheEntry entry, boolean resizeable) {
- super(parent, entry.getId(), entry.getId(), SWT.TOP | SWT.BOTTOM | SWT.LEFT
- | SWT.RIGHT, resizeable);
-
- // Remember our widget structure
- this.widgets = widgets;
- this.curSide = side;
- this.originalSide = side;
- this.parent = parent;
- this.cacheEntry = entry;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.internal.WindowTrimProxy#dock(int)
- */
- public void dock(int newSide) {
- // out with the old...
- for (Iterator iter = widgets.iterator(); iter.hasNext();) {
- IWidget widget = (IWidget) iter.next();
- widget.dispose();
-
- cacheEntry.removeWidget(widget);
- }
-
- // ...in with the new
- for (Iterator iter = widgets.iterator(); iter.hasNext();) {
- IWorkbenchWidget widget = (IWorkbenchWidget) iter.next();
- if (widget instanceof AbstractWorkbenchTrimWidget)
- ((AbstractWorkbenchTrimWidget)widget).fill(parent, curSide, newSide);
- else
- widget.fill(parent);
- }
-
- curSide = newSide;
- parent.layout();
- }
-
- /**
- * Disposes all the widgets contributed into this group and then
- * disposes the group's 'proxy' control
- */
- public void dispose() {
- for (Iterator iter = widgets.iterator(); iter.hasNext();) {
- IWidget widget = (IWidget) iter.next();
- widget.dispose();
-
- // Remove the IWidget from the entry's cache
- cacheEntry.removeWidget(widget);
- }
-
- getControl().dispose();
- }
-
- /**
- * @return The side that the trim was declared to be on
- */
- public int getSide() {
- return originalSide;
- }
-
- /**
- * @return Whether this addition is at the start or end of the
- * containing trim area
- */
- public boolean isAtStart() {
- //Delegate to the cache entry
- return cacheEntry.isAtStart();
- }
- }
-
- /**
- * A convenience class that implements the 'rendering' code necessary to
- * turn the contributions to the 'trim' bar into actual SWT controls.
- *
- * @since 3.2
- *
- */
- private class STrimBuilder {
- /**
- * The WorkbenchWindow that this builder is for
- */
- private WorkbenchWindow fWindow;
-
- /**
- * The list of <code>WindowTrimProxy</code> elements currently
- * rendered in the WorkbenchWindow. Used to support the update mechanism
- * (specifically, it's needed to implement the <code>tearDown</code>
- * method).
- */
- private List curGroups = new ArrayList();
-
- /**
- * Map to cache which trim has already been initialized
- */
- private Map initializedTrim = new HashMap();
-
- /**
- * Construct a trim builder for the given WorkbenchWindow
- *
- * @param window
- * The WorkbenchWindow to render the trim on
- */
- public STrimBuilder(WorkbenchWindow window) {
- fWindow = window;
- }
-
- /**
- * Remove any rendered trim. This method will always be directly
- * followed by a call to the 'build' method to update the contents.
- */
- public void tearDown() {
- // First, remove all trim
- for (Iterator iter = curGroups.iterator(); iter.hasNext();) {
- TrimWidgetProxy proxy = (TrimWidgetProxy) iter.next();
- fWindow.getTrimManager().removeTrim(proxy);
-
- try {
- proxy.dispose();
- } catch (Throwable e) {
- IStatus status = null;
- if (e instanceof CoreException) {
- status = ((CoreException) e).getStatus();
- } else {
- status = StatusUtil
- .newStatus(
- IStatus.ERROR,
- "Internal plug-in widget delegate error on dispose.", e); //$NON-NLS-1$
- }
- StatusUtil
- .handleStatus(
- status,
- "widget delegate failed on dispose: id = " + proxy.getId(), StatusManager.LOG); //$NON-NLS-1$
- }
- }
-
- // Clear out the old list
- curGroups.clear();
- }
-
- /**
- * Construct the trim based on the contributions.
- *
- * @param layout
- * The new layout information
- * @param hideTopTrim
- * <code>true</code> iff we don't want to display trim
- * contributed into the SWT.TOP area. This is because the
- * 'Intro' View hides the CBanner (and so, presumably, also
- * wants to not show any other trim at the top.
- *
- * @param window
- * The widnow to 'render' the trim into
- *
- */
- public void build(boolean hideTopTrim) {
- tearDown();
-
- for (int i = 0; i < trimAreaURIs.length; i++) {
- processAdditions(trimAreaURIs[i], hideTopTrim);
- }
- }
-
- /**
- * @param menuLocationURI
- * @param hideTopTrim
- */
- private void processAdditions(MenuLocationURI trimURI, boolean hideTopTrim) {
- List additions = fMenuService.getAdditionsForURI(trimURI);
- if (additions.size() == 0)
- return;
-
- int swtSide = getSide(trimURI);
-
- // Dont show trim on the top if it's 'hidden'
- if (swtSide == SWT.TOP && hideTopTrim)
- return;
-
- // Each trim addition represents a 'group' into which one or more
- // widgets can be placed...
- for (Iterator iterator = additions.iterator(); iterator.hasNext();) {
- TrimAdditionCacheEntry trimEntry = (TrimAdditionCacheEntry) iterator.next();
- String groupId = trimEntry.getId();
-
- // Get the list of IConfgurationElements representing
- // widgets in this group
- List widgets = trimEntry.getWidgets();
- if (widgets.size() == 0)
- continue;
-
- // Create a 'container' composite for the group
- Composite grpComposite = new Composite(fWindow.getShell(), SWT.NONE);
- grpComposite.setToolTipText(groupId);
-
- // Create the layout for the 'group' container...-no- border margins
- RowLayout rl = new RowLayout();
- rl.marginBottom = rl.marginHeight = rl.marginLeft = rl.marginRight = rl.marginTop = rl.marginWidth = 0;
- grpComposite.setLayout(rl);
-
- // keep track of whether -any- of the widgets are resizeable
- boolean resizeable = false;
-
- for (Iterator widgetIter = widgets.iterator(); widgetIter.hasNext();) {
- IWorkbenchWidget widget = (IWorkbenchWidget) widgetIter.next();
- IConfigurationElement widgetElement = trimEntry.getElement(widget);
- if (widget != null) {
- resizeable |= trimEntry.fillMajor(widgetElement);
- renderTrim(grpComposite, widget, swtSide);
- }
- }
-
- // Create the trim proxy for this group
- TrimWidgetProxy groupTrimProxy = new TrimWidgetProxy(widgets,
- swtSide, grpComposite, trimEntry, resizeable);
- curGroups.add(groupTrimProxy);
-
- // 'Site' the group in its default location
- placeGroup(groupTrimProxy);
- }
- }
-
- private void placeGroup(final TrimWidgetProxy proxy) {
- // Get the placement parameters
- final int side = proxy.getSide();
- boolean atStart = proxy.isAtStart();
-
- // Place the trim before any other trim if it's
- // at the 'start'; otherwise place it at the end
- IWindowTrim beforeMe = null;
- if (atStart) {
- List trim = fWindow.getTrimManager().getAreaTrim(side);
- if (trim.size() > 0)
- beforeMe = (IWindowTrim) trim.get(0);
- }
-
- // Add the group into trim...safely
- try {
- proxy.dock(side); // ensure that the widgets are properly oriented
- TrimLayout tl = (TrimLayout) fWindow.getShell().getLayout();
- tl.addTrim(side, proxy, beforeMe);
- } catch (Throwable e) {
- IStatus status = null;
- if (e instanceof CoreException) {
- status = ((CoreException) e).getStatus();
- } else {
- status = StatusUtil
- .newStatus(
- IStatus.ERROR,
- "Internal plug-in widget delegate error on dock.", e); //$NON-NLS-1$
- }
- StatusUtil.handleStatus(status, "widget delegate failed on dock: id = " + proxy.getId(), //$NON-NLS-1$
- StatusManager.LOG);
- }
- }
-
- /**
- * Render a particular SWidget into a given group
- *
- * @param groupComposite
- * The parent to create the widgets under
- * @param widget
- * The SWidget to render
- * @param side
- */
- private void renderTrim(final Composite groupComposite, IWidget iw,
- final int side) {
- // OK, fill the widget
- if (iw != null) {
- // The -first- time trim is displayed we'll initialize it
- if (iw instanceof IWorkbenchWidget && initializedTrim.get(iw) == null) {
- IWorkbenchWidget iww = (IWorkbenchWidget) iw;
- iww.init(fWindow);
- initializedTrim.put(iw, iw);
- }
-
- if (iw instanceof AbstractWorkbenchTrimWidget)
- ((AbstractWorkbenchTrimWidget)iw).fill(groupComposite, SWT.DEFAULT, side);
- else
- iw.fill(groupComposite);
- }
- }
-
- private int getSide(MenuLocationURI uri) {
- for (int i = 0; i < trimAreaURIs.length; i++) {
- if (trimAreaURIs[i].getRawString().equals(uri.getRawString()))
- return swtSides[i];
- }
- return SWT.BOTTOM;
- }
-
-
- /**
- * Reposition any contributed trim whose id is -not- a 'knownId'. If the
- * id is known then the trim has already been positioned from the stored
- * workbench state. If it isn't then it's a new contribution whose
- * default position may have been trashed by the WorkbenchWindow's
- * 'restoreState' handling.
- *
- * @param knownIds
- * A List of strings containing the ids of any trim that was
- * explicitly positioned during the restore state.
- */
- public void updateLocations(List knownIds) {
- for (Iterator iter = curGroups.iterator(); iter.hasNext();) {
- TrimWidgetProxy proxy = (TrimWidgetProxy) iter.next();
- if (!knownIds.contains(proxy.getId())) {
- placeGroup(proxy);
- }
- }
- }
- }
-
- /**
- * Updates the placement of any contributed trim that is -not- in the
- * 'knownIds' list (which indicates that it has already been placed using
- * cached workspace data.
- *
- * Forward on to the bulder for implementation
- */
- public void updateLocations(List knownIds) {
- fTrimBuilder.updateLocations(knownIds);
- }
-
- /**
- * unhook the menu service.
- */
- public void dispose() {
- fMenuService = null;
- fTrimBuilder = null;
- }
-}
-
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/menus/TrimContributionManager.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/menus/TrimContributionManager.java
deleted file mode 100644
index dd4ba565ed7..00000000000
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/menus/TrimContributionManager.java
+++ /dev/null
@@ -1,326 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2009 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.menus;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.jface.action.ContributionManager;
-import org.eclipse.jface.action.IContributionItem;
-import org.eclipse.jface.action.ToolBarManager;
-import org.eclipse.jface.internal.provisional.action.IToolBarContributionItem;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.ToolBar;
-import org.eclipse.ui.internal.WorkbenchWindow;
-import org.eclipse.ui.internal.layout.IWindowTrim;
-import org.eclipse.ui.internal.layout.TrimLayout;
-import org.eclipse.ui.internal.misc.StatusUtil;
-import org.eclipse.ui.internal.util.Util;
-import org.eclipse.ui.menus.AbstractContributionFactory;
-import org.eclipse.ui.menus.IMenuService;
-import org.eclipse.ui.menus.MenuUtil;
-import org.eclipse.ui.statushandlers.StatusManager;
-
-/**
- * Manage trim contributions added through the 'org.eclipse.ui.menus'
- * extension point.
- *
- * @since 3.3
- *
- */
-public class TrimContributionManager extends ContributionManager {
- private class ToolBarTrimProxy implements IWindowTrim {
- private String id;
- private String uriSpec;
- private WorkbenchMenuService menuService;
- private WorkbenchWindow wbw;
- private ToolBar tb = null;
- private ToolBarManager tbm = null;
-
- ToolBarTrimProxy(String id, WorkbenchWindow wbw) {
- this.id = id;
- uriSpec = "toolbar:" + id; //$NON-NLS-1$
- this.wbw = wbw;
-
- this.menuService = (WorkbenchMenuService) wbw.getWorkbench().getService(
- IMenuService.class);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.internal.layout.IWindowTrim#dock(int)
- */
- public void dock(int dropSide) {
- dispose();
-
- int orientation = SWT.HORIZONTAL;
- if (dropSide == SWT.LEFT || dropSide == SWT.RIGHT)
- orientation = SWT.VERTICAL;
-
- // Create the new control, manager...
- tbm = new ToolBarManager(SWT.FLAT | orientation);
-// menuService.populateContributionManager(tbm, uriSpec);
- menuService.populateContributionManager(wbw, restrictionExpression, tbm, uriSpec, true);
-
- // Set the state for any Control entries
- IContributionItem[] items = tbm.getItems();
- for (int i = 0; i < items.length; i++) {
- if (items[i] instanceof InternalControlContribution) {
- InternalControlContribution wbwcc = (InternalControlContribution) items[i];
- wbwcc.setWorkbenchWindow(wbw);
- wbwcc.setCurSide(dropSide);
- }
- }
-
- // OK, create the ToolBar (causes an 'update(true)'
- tb = tbm.createControl(wbw.getShell());
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.internal.layout.IWindowTrim#getControl()
- */
- public Control getControl() {
- return tb;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.internal.layout.IWindowTrim#getDisplayName()
- */
- public String getDisplayName() {
- return getId();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.internal.layout.IWindowTrim#getHeightHint()
- */
- public int getHeightHint() {
- return SWT.DEFAULT;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.internal.layout.IWindowTrim#getId()
- */
- public String getId() {
- return id;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.internal.layout.IWindowTrim#getValidSides()
- */
- public int getValidSides() {
- return SWT.TOP | SWT.BOTTOM | SWT.LEFT | SWT.RIGHT;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.internal.layout.IWindowTrim#getWidthHint()
- */
- public int getWidthHint() {
- return SWT.DEFAULT;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.internal.layout.IWindowTrim#handleClose()
- */
- public void handleClose() {
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.internal.layout.IWindowTrim#isCloseable()
- */
- public boolean isCloseable() {
- return false;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.internal.layout.IWindowTrim#isResizeable()
- */
- public boolean isResizeable() {
- return false;
- }
-
- /**
- * Dispose any trim element resources
- */
- public void dispose() {
- if (tbm != null) {
- tbm.dispose();
- tbm.removeAll();
- }
- }
- }
-
- /**
- * A List of the URI's representing the trim areas
- */
- private String[] trimAreaURIs = {
- MenuUtil.TRIM_COMMAND1,
- MenuUtil.TRIM_COMMAND2,
- MenuUtil.TRIM_VERTICAL1,
- MenuUtil.TRIM_VERTICAL2,
- MenuUtil.TRIM_STATUS
- };
-
- /**
- * The SWT 'side' corresponding to a URI
- */
- private int[] swtSides = { SWT.TOP, SWT.TOP, SWT.LEFT, SWT.RIGHT, SWT.BOTTOM };
-
- private WorkbenchWindow wbWindow;
- TrimLayout layout;
- private InternalMenuService menuService;
-
- List contributedTrim = new ArrayList();
-
- List contributedLists = new ArrayList();
-
- private Set restrictionExpression;
-
- /**
- * Construct a contribution manager for the given window
- */
- public TrimContributionManager(WorkbenchWindow window) {
- wbWindow = window;
- layout = (TrimLayout) wbWindow.getShell().getLayout();
- menuService = (InternalMenuService) window.getService(
- IMenuService.class);
- restrictionExpression = wbWindow.getMenuRestrictions();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.action.IContributionManager#update(boolean)
- */
- public void update(boolean force) {
- update(force, false);
- }
-
- public void update(boolean force, boolean hideTopTrim) {
- // Remove any contributed trim
- teardown();
-
- // Process the additions for each 'area'
- for (int i = 0; i < trimAreaURIs.length; i++) {
- // IntroBar want to hide the top trim
- if (hideTopTrim && swtSides[i] == SWT.TOP)
- continue;
-
- List contribs = menuService.getAdditionsForURI(new MenuLocationURI(trimAreaURIs[i]));
-
- for (Iterator cacheIter = contribs.iterator(); cacheIter.hasNext();) {
- AbstractContributionFactory cache = (AbstractContributionFactory) cacheIter.next();
- ContributionRoot ciList = new ContributionRoot(menuService,
- restrictionExpression, this, cache);
- cache.createContributionItems(wbWindow, ciList);
-
- // Where should we put this?
- IWindowTrim insertBefore = null;
- MenuLocationURI uri = new MenuLocationURI(cache.getLocation());
- String query = uri.getQuery();
- String[] args = Util.split(query, '=');
- if (args.length == 2) {
- String relative = args[0];
- String relId = args[1];
- insertBefore = layout.getTrim(relId);
- if (MenuUtil.QUERY_AFTER.equals(relative)
- && insertBefore != null) {
- // Get the trim -after- the id'd one
- List areaTrim = layout.getAreaTrim(swtSides[i]);
- for (Iterator iterator = areaTrim.iterator(); iterator
- .hasNext();) {
- IWindowTrim trimElement = (IWindowTrim) iterator
- .next();
- if (insertBefore == trimElement) {
- insertBefore = (IWindowTrim) (iterator
- .hasNext() ? iterator.next() : null);
- }
- }
- }
- }
-
- // If we're adding to the 'command1' area then we're -before-
- // the CoolBar
- if (insertBefore == null && i == 0) {
- insertBefore = layout
- .getTrim("org.eclipse.ui.internal.WorkbenchWindow.topBar"); //$NON-NLS-1$
- }
-
- // save the list for later cleanup of any visibility expressions that were added.
- contributedLists.add(ciList);
- for (Iterator ciIter = ciList.getItems().iterator(); ciIter.hasNext();) {
- IContributionItem ci = (IContributionItem) ciIter.next();
- if (ci instanceof IToolBarContributionItem) {
- // HACK!! Fake this
- ToolBarTrimProxy tbProxy = new ToolBarTrimProxy(ci.getId(), wbWindow);
- tbProxy.dock(swtSides[i]);
-
- layout.addTrim(swtSides[i], tbProxy, insertBefore);
- contributedTrim.add(tbProxy);
- }
- }
- }
- }
- }
-
- private void teardown() {
- // First, remove all trim
- for (Iterator iter = contributedTrim.iterator(); iter.hasNext();) {
- ToolBarTrimProxy proxy = (ToolBarTrimProxy) iter.next();
- layout.removeTrim(proxy);
-
- try {
- proxy.dispose();
- } catch (Throwable e) {
- IStatus status = null;
- if (e instanceof CoreException) {
- status = ((CoreException) e).getStatus();
- } else {
- status = StatusUtil
- .newStatus(
- IStatus.ERROR,
- "Internal plug-in widget delegate error on dispose.", e); //$NON-NLS-1$
- }
- StatusUtil
- .handleStatus(
- status,
- "widget delegate failed on dispose: id = " + proxy.getId(), StatusManager.LOG); //$NON-NLS-1$
- }
- }
-
- // Clear out the old list
- contributedTrim.clear();
-
- // clean up the list of ContributionLists
- for (Iterator iter = contributedLists.iterator(); iter.hasNext();) {
- ContributionRoot list = (ContributionRoot) iter.next();
- list.release();
- }
-
- contributedLists.clear();
- }
-
- /**
- *
- */
- public void dispose() {
- teardown();
- }
-
- /**
- * @param knownIds
- */
- public void updateLocations(List knownIds) {
- // TODO Auto-generated method stub
-
- }
-}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/AbstractTableInformationControl.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/AbstractTableInformationControl.java
deleted file mode 100644
index 73be4e8a76d..00000000000
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/AbstractTableInformationControl.java
+++ /dev/null
@@ -1,684 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2010 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.presentations;
-
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.jface.viewers.ILabelProvider;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.jface.viewers.TableViewer;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jface.viewers.ViewerFilter;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.DisposeListener;
-import org.eclipse.swt.events.FocusListener;
-import org.eclipse.swt.events.KeyEvent;
-import org.eclipse.swt.events.KeyListener;
-import org.eclipse.swt.events.ModifyEvent;
-import org.eclipse.swt.events.ModifyListener;
-import org.eclipse.swt.events.MouseAdapter;
-import org.eclipse.swt.events.MouseEvent;
-import org.eclipse.swt.events.MouseMoveListener;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.events.TraverseEvent;
-import org.eclipse.swt.events.TraverseListener;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.FontMetrics;
-import org.eclipse.swt.graphics.GC;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Item;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Layout;
-import org.eclipse.swt.widgets.Menu;
-import org.eclipse.swt.widgets.MenuItem;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.swt.widgets.TableItem;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.internal.WorkbenchMessages;
-import org.eclipse.ui.internal.misc.StringMatcher;
-import org.eclipse.ui.internal.presentations.defaultpresentation.DefaultTabItem;
-
-/**
- * @since 3.0
- */
-public abstract class AbstractTableInformationControl {
-
- /**
- * The NamePatternFilter selects the elements which match the given string
- * patterns.
- */
- protected class NamePatternFilter extends ViewerFilter {
-
- public NamePatternFilter() {
- //no-op
- }
-
- /*
- * (non-Javadoc) Method declared on ViewerFilter.
- */
- public boolean select(Viewer viewer, Object parentElement,
- Object element) {
- StringMatcher matcher = getMatcher();
- if (matcher == null || !(viewer instanceof TableViewer)) {
- return true;
- }
- TableViewer tableViewer = (TableViewer) viewer;
-
- String matchName = ((ILabelProvider) tableViewer.getLabelProvider())
- .getText(element);
-
- if(matchName == null) {
- return false;
- }
- // A dirty editor's label will start with dirty prefix, this prefix
- // should not be taken in consideration when matching with a pattern
- String prefix = DefaultTabItem.DIRTY_PREFIX;
- if (matchName.startsWith(prefix)) {
- matchName = matchName.substring(prefix.length());
- }
- return matchName != null && matcher.match(matchName);
- }
- }
-
- private static class BorderFillLayout extends Layout {
-
- /** The border widths. */
- final int fBorderSize;
-
- /**
- * Creates a fill layout with a border.
- */
- public BorderFillLayout(int borderSize) {
- if (borderSize < 0) {
- throw new IllegalArgumentException();
- }
- fBorderSize = borderSize;
- }
-
- /*
- * @see org.eclipse.swt.widgets.Layout#computeSize(org.eclipse.swt.widgets.Composite,
- * int, int, boolean)
- */
- protected Point computeSize(Composite composite, int wHint, int hHint,
- boolean flushCache) {
-
- Control[] children = composite.getChildren();
- Point minSize = new Point(0, 0);
-
- if (children != null) {
- for (int i = 0; i < children.length; i++) {
- Point size = children[i].computeSize(wHint, hHint,
- flushCache);
- minSize.x = Math.max(minSize.x, size.x);
- minSize.y = Math.max(minSize.y, size.y);
- }
- }
-
- minSize.x += fBorderSize * 2 + RIGHT_MARGIN;
- minSize.y += fBorderSize * 2;
-
- return minSize;
- }
-
- /*
- * @see org.eclipse.swt.widgets.Layout#layout(org.eclipse.swt.widgets.Composite,
- * boolean)
- */
- protected void layout(Composite composite, boolean flushCache) {
-
- Control[] children = composite.getChildren();
- Point minSize = new Point(composite.getClientArea().width,
- composite.getClientArea().height);
-
- if (children != null) {
- for (int i = 0; i < children.length; i++) {
- Control child = children[i];
- child.setSize(minSize.x - fBorderSize * 2, minSize.y
- - fBorderSize * 2);
- child.setLocation(fBorderSize, fBorderSize);
- }
- }
- }
- }
-
- /** Border thickness in pixels. */
- private static final int BORDER = 1;
-
- /** Right margin in pixels. */
- private static final int RIGHT_MARGIN = 3;
-
- /** The control's shell */
- private Shell fShell;
-
- /** The composite */
- protected Composite fComposite;
-
- /** The control's text widget */
- private Text fFilterText;
-
- /** The control's table widget */
- private TableViewer fTableViewer;
-
- /** The control width constraint */
- //private int fMaxWidth= -1;
- /** The control height constraint */
- //private int fMaxHeight= -1;
- /** The current string matcher */
- private StringMatcher fStringMatcher;
-
- /**
- * Creates an information control with the given shell as parent. The given
- * styles are applied to the shell and the table widget.
- *
- * @param parent
- * the parent shell
- * @param shellStyle
- * the additional styles for the shell
- * @param controlStyle
- * the additional styles for the control
- */
- public AbstractTableInformationControl(Shell parent, int shellStyle,
- int controlStyle) {
- fShell = new Shell(parent, shellStyle);
- Display display = fShell.getDisplay();
- fShell.setBackground(display.getSystemColor(SWT.COLOR_BLACK));
-
- // Composite for filter text and viewer
-
- fComposite = new Composite(fShell, SWT.RESIZE);
- GridLayout layout = new GridLayout(1, false);
- fComposite.setLayout(layout);
- // fComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- createFilterText(fComposite);
-
- fTableViewer = createTableViewer(fComposite, controlStyle);
-
- final Table table = fTableViewer.getTable();
- table.addKeyListener(new KeyListener() {
- public void keyPressed(KeyEvent e) {
- switch (e.keyCode) {
- case SWT.ESC:
- dispose();
- break;
- case SWT.DEL:
- removeSelectedItems();
- e.character = SWT.NONE;
- e.doit = false;
- break;
- case SWT.ARROW_UP:
- if (table.getSelectionIndex() == 0) {
- // on the first item, going up should grant focus to
- // text field
- fFilterText.setFocus();
- }
- break;
- case SWT.ARROW_DOWN:
- if (table.getSelectionIndex() == table.getItemCount() - 1) {
- // on the last item, going down should grant focus to
- // the text field
- fFilterText.setFocus();
- }
- break;
- }
- }
-
- public void keyReleased(KeyEvent e) {
- // do nothing
- }
- });
-
- table.addSelectionListener(new SelectionListener() {
- public void widgetSelected(SelectionEvent e) {
- // do nothing;
- }
-
- public void widgetDefaultSelected(SelectionEvent e) {
- gotoSelectedElement();
- }
- });
-
- /*
- * Bug in GTK, see SWT bug: 62405 Editor drop down performance slow on
- * Linux-GTK on mouse move.
- * Rather then removing the support altogether this feature has been
- * worked around for GTK only as we expect that newer versions of GTK
- * will no longer exhibit this quality and we will be able to have the
- * desired support running on all platforms. See
- * comment https://bugs.eclipse.org/bugs/show_bug.cgi?id=62405#c22
- * TODO: remove this code once bug 62405 is fixed for the mainstream GTK
- * version
- */
- final int ignoreEventCount = Platform.getWS().equals(Platform.WS_GTK) ? 4 : 1;
-
- table.addMouseMoveListener(new MouseMoveListener() {
- TableItem fLastItem = null;
- int lastY = 0;
- int itemHeightdiv4 = table.getItemHeight() / 4;
- int tableHeight = table.getBounds().height;
- Point tableLoc = table.toDisplay(0,0);
- int divCount = 0;
- public void mouseMove(MouseEvent e) {
- if (divCount == ignoreEventCount) {
- divCount = 0;
- }
- if (table.equals(e.getSource()) & ++divCount == ignoreEventCount) {
- Object o = table.getItem(new Point(e.x, e.y));
- if (fLastItem == null ^ o == null) {
- table.setCursor(o == null ? null : table.getDisplay().getSystemCursor(
- SWT.CURSOR_HAND));
- }
- if (o instanceof TableItem && lastY != e.y) {
- lastY = e.y;
- if (!o.equals(fLastItem)) {
- fLastItem = (TableItem) o;
- table.setSelection(new TableItem[] { fLastItem });
- } else if (e.y < itemHeightdiv4) {
- // Scroll up
- Item item = fTableViewer.scrollUp(e.x + tableLoc.x, e.y + tableLoc.y);
- if (item instanceof TableItem) {
- fLastItem = (TableItem) item;
- table.setSelection(new TableItem[] { fLastItem });
- }
- } else if (e.y > tableHeight - itemHeightdiv4) {
- // Scroll down
- Item item = fTableViewer.scrollDown(e.x + tableLoc.x, e.y + tableLoc.y);
- if (item instanceof TableItem) {
- fLastItem = (TableItem) item;
- table.setSelection(new TableItem[] { fLastItem });
- }
- }
- } else if (o == null) {
- fLastItem = null;
- }
- }
- }
- });
-
- table.addMouseListener(new MouseAdapter() {
- public void mouseUp(MouseEvent e) {
- if (table.getSelectionCount() < 1) {
- return;
- }
-
- if (e.button == 1) {
- if (table.equals(e.getSource())) {
- Object o = table.getItem(new Point(e.x, e.y));
- TableItem selection = table.getSelection()[0];
- if (selection.equals(o)) {
- gotoSelectedElement();
- }
- }
- }
- if (e.button == 3) {
- TableItem tItem = fTableViewer.getTable().getItem(
- new Point(e.x, e.y));
- if (tItem != null) {
- Menu menu = new Menu(fTableViewer.getTable());
- MenuItem mItem = new MenuItem(menu, SWT.NONE);
- mItem.setText(WorkbenchMessages.PartPane_close);
- mItem.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(
- SelectionEvent selectionEvent) {
- removeSelectedItems();
- }
- });
- menu.setVisible(true);
- }
- }
- }
- });
-
- fShell.addTraverseListener(new TraverseListener() {
- public void keyTraversed(TraverseEvent e) {
- switch (e.detail) {
- case SWT.TRAVERSE_PAGE_NEXT:
- e.detail = SWT.TRAVERSE_NONE;
- e.doit = true;
- {
- int n = table.getItemCount();
- if (n == 0)
- return;
-
- int i = table.getSelectionIndex() + 1;
- if (i >= n)
- i = 0;
- table.setSelection(i);
- }
- break;
-
- case SWT.TRAVERSE_PAGE_PREVIOUS:
- e.detail = SWT.TRAVERSE_NONE;
- e.doit = true;
- {
- int n = table.getItemCount();
- if (n == 0)
- return;
-
- int i = table.getSelectionIndex() - 1;
- if (i < 0)
- i = n - 1;
- table.setSelection(i);
- }
- break;
- }
- }
- });
-
- int border = ((shellStyle & SWT.NO_TRIM) == 0) ? 0 : BORDER;
- fShell.setLayout(new BorderFillLayout(border));
-
- setInfoSystemColor();
- installFilter();
- }
-
- /**
- * Removes the selected items from the list and closes their corresponding tabs
- * Selects the next item in the list or disposes it if its presentation is disposed
- */
- protected void removeSelectedItems() {
- int selInd = fTableViewer.getTable().getSelectionIndex();
- if (deleteSelectedElements()) {
- return;
- }
- fTableViewer.refresh();
- if (selInd >= fTableViewer.getTable().getItemCount()) {
- selInd = fTableViewer.getTable().getItemCount() - 1;
- }
- if (selInd >= 0) {
- fTableViewer.getTable().setSelection(selInd);
- }
- }
-
- protected abstract TableViewer createTableViewer(Composite parent, int style);
-
- public TableViewer getTableViewer() {
- return fTableViewer;
- }
-
- protected Text createFilterText(Composite parent) {
- fFilterText = new Text(parent, SWT.NONE);
-
- GridData data = new GridData();
- GC gc = new GC(parent);
- gc.setFont(parent.getFont());
- FontMetrics fontMetrics = gc.getFontMetrics();
- gc.dispose();
-
- data.heightHint = org.eclipse.jface.dialogs.Dialog
- .convertHeightInCharsToPixels(fontMetrics, 1);
- data.horizontalAlignment = GridData.FILL;
- data.verticalAlignment = GridData.BEGINNING;
- fFilterText.setLayoutData(data);
-
- fFilterText.addKeyListener(new KeyListener() {
- public void keyPressed(KeyEvent e) {
- switch (e.keyCode) {
- case SWT.CR:
- case SWT.KEYPAD_CR:
- gotoSelectedElement();
- break;
- case SWT.ARROW_DOWN:
- fTableViewer.getTable().setFocus();
- fTableViewer.getTable().setSelection(0);
- break;
- case SWT.ARROW_UP:
- fTableViewer.getTable().setFocus();
- fTableViewer.getTable()
- .setSelection(fTableViewer.getTable().getItemCount() - 1);
- break;
- case SWT.ESC:
- dispose();
- break;
- }
- }
-
- public void keyReleased(KeyEvent e) {
- // do nothing
- }
- });
-
- // Horizontal separator line
- Label separator = new Label(parent, SWT.SEPARATOR | SWT.HORIZONTAL
- | SWT.LINE_DOT);
- separator.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- return fFilterText;
- }
-
- private void setInfoSystemColor() {
- Display display = fShell.getDisplay();
- setForegroundColor(display.getSystemColor(SWT.COLOR_INFO_FOREGROUND));
- setBackgroundColor(display.getSystemColor(SWT.COLOR_INFO_BACKGROUND));
- }
-
- private void installFilter() {
- fFilterText.setText(""); //$NON-NLS-1$
-
- fFilterText.addModifyListener(new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- String text = ((Text) e.widget).getText();
- int length = text.length();
- if (length > 0 && text.charAt(length - 1) != '*') {
- text = text + '*';
- }
- setMatcherString(text);
- }
- });
- }
-
- /**
- * The string matcher has been modified. The default implementation
- * refreshes the view and selects the first macthed element
- */
- protected void stringMatcherUpdated() {
- // refresh viewer to refilter
- fTableViewer.getControl().setRedraw(false);
- fTableViewer.refresh();
- selectFirstMatch();
- fTableViewer.getControl().setRedraw(true);
- }
-
- /**
- * Sets the patterns to filter out for the receiver.
- * <p>
- * The following characters have special meaning: ? => any character * =>
- * any string
- * </p>
- */
- protected void setMatcherString(String pattern) {
- if (pattern.length() == 0) {
- fStringMatcher = null;
- } else {
- boolean ignoreCase = pattern.toLowerCase().equals(pattern);
- fStringMatcher = new StringMatcher(pattern, ignoreCase, false);
- }
- stringMatcherUpdated();
- }
-
- protected StringMatcher getMatcher() {
- return fStringMatcher;
- }
-
- /**
- * Implementers can modify
- */
- protected Object getSelectedElement() {
- return ((IStructuredSelection) fTableViewer.getSelection())
- .getFirstElement();
- }
-
- /**
- * Implementers can modify
- */
- protected IStructuredSelection getSelectedElements() {
- return (IStructuredSelection) fTableViewer.getSelection();
- }
-
- protected abstract void gotoSelectedElement();
-
- /**
- * Delete all selected elements.
- *
- * @return <code>true</code> if there are no elements left after deletion.
- */
- protected abstract boolean deleteSelectedElements();
-
- /**
- * Selects the first element in the table which matches the current filter
- * pattern.
- */
- protected void selectFirstMatch() {
- Table table = fTableViewer.getTable();
- Object element = findElement(table.getItems());
- if (element != null) {
- fTableViewer.setSelection(new StructuredSelection(element), true);
- } else {
- fTableViewer.setSelection(StructuredSelection.EMPTY);
- }
- }
-
- private Object findElement(TableItem[] items) {
- ILabelProvider labelProvider = (ILabelProvider) fTableViewer
- .getLabelProvider();
- for (int i = 0; i < items.length; i++) {
- Object element = items[i].getData();
- if (fStringMatcher == null) {
- return element;
- }
-
- if (element != null) {
- String label = labelProvider.getText(element);
- if(label == null) {
- return null;
- }
- // remove the dirty prefix from the editor's label
- String prefix = DefaultTabItem.DIRTY_PREFIX;
- if (label.startsWith(prefix)) {
- label = label.substring(prefix.length());
- }
- if (fStringMatcher.match(label)) {
- return element;
- }
- }
- }
- return null;
- }
-
- public abstract void setInput(Object information);
-
- protected void inputChanged(Object newInput, Object newSelection) {
- fFilterText.setText(""); //$NON-NLS-1$
- fTableViewer.setInput(newInput);
- selectFirstMatch();
-
- // Resize the table's height accordingly to the new input
- Table viewerTable = fTableViewer.getTable();
- Point tableSize = viewerTable.computeSize(SWT.DEFAULT, SWT.DEFAULT);
- int tableMaxHeight = fComposite.getDisplay().getBounds().height / 2;
- // removes padding if necessary
- int tableHeight = (tableSize.y <= tableMaxHeight) ? tableSize.y
- - viewerTable.getItemHeight() - viewerTable.getItemHeight() / 2
- : tableMaxHeight;
- ((GridData) viewerTable.getLayoutData()).heightHint = tableHeight;
- Point fCompSize = fComposite.computeSize(SWT.DEFAULT, SWT.DEFAULT);
- fComposite.setSize(fCompSize);
- fComposite.getShell().setSize(fCompSize);
- }
-
- public void setVisible(boolean visible) {
- fShell.setVisible(visible);
- }
-
- public void dispose() {
- if (fShell != null) {
- if (!fShell.isDisposed()) {
- fShell.dispose();
- }
- fShell = null;
- fTableViewer = null;
- fComposite = null;
- fFilterText = null;
- }
- }
-
- public boolean hasContents() {
- return fTableViewer != null && fTableViewer.getInput() != null;
- }
-
- public void setSizeConstraints(int maxWidth, int maxHeight) {
- //fMaxWidth= maxWidth;
- //fMaxHeight= maxHeight;
- }
-
- public Point computeSizeHint() {
- return fShell.computeSize(SWT.DEFAULT, SWT.DEFAULT);
- }
-
- public void setLocation(Point location) {
- Rectangle trim = fShell.computeTrim(0, 0, 0, 0);
- Point textLocation = fComposite.getLocation();
- location.x += trim.x - textLocation.x;
- location.y += trim.y - textLocation.y;
- fShell.setLocation(location);
- }
-
- public void setSize(int width, int height) {
- fShell.setSize(width, height);
- }
-
- public void addDisposeListener(DisposeListener listener) {
- fShell.addDisposeListener(listener);
- }
-
- public void removeDisposeListener(DisposeListener listener) {
- fShell.removeDisposeListener(listener);
- }
-
- public void setForegroundColor(Color foreground) {
- fTableViewer.getTable().setForeground(foreground);
- fFilterText.setForeground(foreground);
- fComposite.setForeground(foreground);
- }
-
- public void setBackgroundColor(Color background) {
- fTableViewer.getTable().setBackground(background);
- fFilterText.setBackground(background);
- fComposite.setBackground(background);
- }
-
- public boolean isFocusControl() {
- return fTableViewer.getControl().isFocusControl()
- || fFilterText.isFocusControl();
- }
-
- public void setFocus() {
- fShell.forceFocus();
- fFilterText.setFocus();
- }
-
- public void addFocusListener(FocusListener listener) {
- fShell.addFocusListener(listener);
- }
-
- public void removeFocusListener(FocusListener listener) {
- fShell.removeFocusListener(listener);
- }
-}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/BasicPartList.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/BasicPartList.java
deleted file mode 100644
index 8ec0f131faa..00000000000
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/BasicPartList.java
+++ /dev/null
@@ -1,355 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2009 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.presentations;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-
-import org.eclipse.jface.util.Util;
-import org.eclipse.jface.viewers.ColumnLabelProvider;
-import org.eclipse.jface.viewers.ColumnViewerToolTipSupport;
-import org.eclipse.jface.viewers.ContentViewer;
-import org.eclipse.jface.viewers.IBaseLabelProvider;
-import org.eclipse.jface.viewers.ILabelProvider;
-import org.eclipse.jface.viewers.IStructuredContentProvider;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.TableViewer;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jface.viewers.ViewerComparator;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.Font;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.RGB;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.ui.IWorkbenchPartReference;
-import org.eclipse.ui.internal.presentations.defaultpresentation.DefaultTabItem;
-import org.eclipse.ui.internal.presentations.util.AbstractTabItem;
-import org.eclipse.ui.internal.presentations.util.PresentablePartFolder;
-import org.eclipse.ui.internal.tweaklets.TabBehaviour;
-import org.eclipse.ui.internal.tweaklets.Tweaklets;
-import org.eclipse.ui.presentations.IPresentablePart;
-import org.eclipse.ui.presentations.IStackPresentationSite;
-
-public class BasicPartList extends AbstractTableInformationControl {
-
- private PresentablePartFolder folder;
- private IStackPresentationSite site;
-
- private class BasicStackListContentProvider implements
- IStructuredContentProvider {
-
- /**
- * Constructor for stack list content provider.
- *
- */
- public BasicStackListContentProvider() {
- //no-op
- }
-
- public void dispose() {
- //no-op
- }
-
- public Object[] getElements(Object inputElement) {
- if (folder == null) {
- return new IPresentablePart[0];
- }
-
- return folder.getPartList();
- }
-
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- folder = (PresentablePartFolder) newInput;
- }
- }
-
- private class BasicStackListLabelProvider extends ColumnLabelProvider {
-
- private Font visibleEditorsFont;
- private Font invisibleEditorsFont;
- private Color visibleEditorsColor;
-
- /**
- * Constructor for stack list label provider.
- *
- */
- public BasicStackListLabelProvider() {
- //no-op
- }
-
- public String getText(Object element) {
- IPresentablePart presentablePart = (IPresentablePart) element;
- if (presentablePart.isDirty()) {
- return DefaultTabItem.DIRTY_PREFIX + presentablePart.getName();
- }
-
- return presentablePart.getName();
- }
-
- public Image getImage(Object element) {
- IPresentablePart presentablePart = (IPresentablePart) element;
- return presentablePart.getTitleImage();
- }
-
- public Font getFont(Object element) {
- IPresentablePart presentablePart = (IPresentablePart)element;
-
- AbstractTabItem item = folder.getTab(presentablePart);
- Control control = folder.getTabFolder().getControl();
- // if in single tab mode, do not use the bold font for non-visible tabs
- // if in multiple tab mode, use the bold for non-visible tabs only
- if (item!=null && item.isShowing()) {
- return getVisibleEditorsFont(control.getDisplay(), control.getFont());
- }
-
- return getInvisibleEditorsFont(control.getDisplay(), control.getFont());
- }
-
- private Color getVisibleEditorsColor(Display display, RGB originalForeground, RGB originalBackground) {
- if (visibleEditorsColor == null) {
- visibleEditorsColor = ((TabBehaviour) Tweaklets.get(TabBehaviour.KEY))
- .createVisibleEditorsColor(display, originalForeground, originalBackground);
- }
- return visibleEditorsColor;
- }
-
- private Font getVisibleEditorsFont(Display display, Font font) {
- if (visibleEditorsFont == null) {
- visibleEditorsFont = ((TabBehaviour) Tweaklets.get(TabBehaviour.KEY))
- .createVisibleEditorsFont(display, font);
- }
- return visibleEditorsFont;
- }
-
- private Font getInvisibleEditorsFont(Display display, Font font) {
- if (invisibleEditorsFont == null) {
- invisibleEditorsFont = ((TabBehaviour) Tweaklets.get(TabBehaviour.KEY))
- .createInvisibleEditorsFont(display, font);
- }
- return invisibleEditorsFont;
- }
-
- public void dispose() {
- super.dispose();
- if (visibleEditorsColor != null) {
- visibleEditorsColor.dispose();
- }
- if (visibleEditorsFont != null) {
- visibleEditorsFont.dispose();
- }
- if (invisibleEditorsFont != null) {
- invisibleEditorsFont.dispose();
- }
- }
-
- public Color getForeground(Object element) {
- IPresentablePart presentablePart = (IPresentablePart)element;
-
- AbstractTabItem item = folder.getTab(presentablePart);
- Control control = folder.getTabFolder().getControl();
- if (item!=null && item.isShowing()) {
- return getVisibleEditorsColor(control.getDisplay(), control
- .getForeground().getRGB(), control.getBackground().getRGB());
- }
-
- return null;
- }
-
- public String getToolTipText(Object element) {
- if (element instanceof PresentablePart) {
- PresentablePart part = (PresentablePart) element;
- IWorkbenchPartReference reference = part.getPane()
- .getPartReference();
- return reference.getTitleToolTip();
- }
- return null;
- }
-
- public boolean useNativeToolTip(Object object) {
- return true;
- }
- }
-
- private class BasicStackListViewerComparator extends ViewerComparator {
- /**
- * Constructor for stack list viewer's comparator.
- *
- */
- public BasicStackListViewerComparator() {
- //no-op
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.ViewerComparator#compare(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
- */
- public int compare(Viewer viewer, Object e1, Object e2) {
- int cat1 = category(e1);
- int cat2 = category(e2);
-
- if (cat1 != cat2) {
- return cat1 - cat2;
- }
-
- String name1;
- String name2;
-
- if (viewer == null || !(viewer instanceof ContentViewer)) {
- name1 = e1.toString();
- name2 = e2.toString();
- } else {
- IBaseLabelProvider prov = ((ContentViewer) viewer)
- .getLabelProvider();
- if (prov instanceof ILabelProvider) {
- ILabelProvider lprov = (ILabelProvider) prov;
- name1 = lprov.getText(e1);
- name2 = lprov.getText(e2);
- // ILabelProvider's implementation in BasicStackList calls
- // DefaultEditorPresentation.getLabelText which returns the name of dirty
- // files begining with dirty prefix, sorting should not take dirty prefix in consideration
- String prefix = DefaultTabItem.DIRTY_PREFIX;
- if (name1.startsWith(prefix)) {
- name1 = name1.substring(prefix.length());
- }
- if (name2.startsWith(prefix)) {
- name2 = name2.substring(prefix.length());
- }
- } else {
- name1 = e1.toString();
- name2 = e2.toString();
- }
- }
- if (name1 == null) {
- name1 = "";//$NON-NLS-1$
- }
- if (name2 == null) {
- name2 = "";//$NON-NLS-1$
- }
- return getComparator().compare(name1, name2);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.ViewerComparator#category(java.lang.Object)
- */
- public int category(Object element) {
-
- IPresentablePart part = (IPresentablePart)element;
- AbstractTabItem tabItem = folder.getTab(part);
-
- if (tabItem!=null && tabItem.isShowing()) {
- return 1; // visible
- }
- return 0; // not visible
- }
- }
-
- /**
- * Constructor for BasicPartList.
- *
- * @param parent the parent shell
- * @param shellStyle the SWT style bits used to create the shell
- * @param treeStyle the SWT style bits used to create the tree
- * @param site
- * @param folder
- */
- public BasicPartList(Shell parent, int shellStyle, int treeStyle,
- IStackPresentationSite site, PresentablePartFolder folder) {
- super(parent, shellStyle, treeStyle);
-
- this.site = site;
- this.folder = folder;
- }
-
- protected TableViewer createTableViewer(Composite parent, int style) {
- Table table = new Table(parent, SWT.SINGLE | (style & ~SWT.MULTI));
- table.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING));
- TableViewer tableViewer = new TableViewer(table) {
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.TableViewer#internalRefresh(java.lang.Object)
- */
- protected void internalRefresh(Object element) {
- boolean usingMotif = Util.isMotif();
- try {
- // This avoids a "graphic is disposed" error on Motif by not letting
- // it redraw while we remove entries. Some items in this table are
- // being removed and may have icons which may have already been
- // disposed elsewhere.
- if (usingMotif) {
- getTable().setRedraw(false);
- }
- super.internalRefresh(element);
- } finally {
- if (usingMotif) {
- getTable().setRedraw(true);
- }
- }
- }
- };
- tableViewer.addFilter(new NamePatternFilter());
- tableViewer.setContentProvider(new BasicStackListContentProvider());
- if (((TabBehaviour)Tweaklets.get(TabBehaviour.KEY)).sortEditorListAlphabetically()) {
- tableViewer.setComparator(new BasicStackListViewerComparator());
- }
- tableViewer.setLabelProvider(new BasicStackListLabelProvider());
-
- ColumnViewerToolTipSupport.enableFor(tableViewer);
-
- return tableViewer;
- }
-
- public void setInput(Object information) {
- PresentablePartFolder newFolder = (PresentablePartFolder) information;
- inputChanged(newFolder, newFolder.getCurrent());
- }
-
- protected void gotoSelectedElement() {
- Object selectedElement = getSelectedElement();
-
- //close the shell
- dispose();
-
- if (selectedElement instanceof IPresentablePart) {
- site.selectPart((IPresentablePart)selectedElement);
- }
- }
-
- protected boolean deleteSelectedElements() {
-
- IStructuredSelection structuredSelection = getSelectedElements();
-
- if (structuredSelection != null) {
-
- ArrayList list = new ArrayList(structuredSelection.size());
-
- for (Iterator iterator = structuredSelection.iterator(); iterator
- .hasNext();) {
- IPresentablePart presentablePart = (IPresentablePart) iterator.next();
- list.add(presentablePart);
- }
-
- site.close((IPresentablePart[]) list
- .toArray(new IPresentablePart[list.size()]));
- }
-
- if (folder.isDisposed()) {
- fComposite.dispose();
- return true;
- }
- return false;
-
- }
-}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/DefaultActionBarPresentationFactory.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/DefaultActionBarPresentationFactory.java
deleted file mode 100644
index fad2c062720..00000000000
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/DefaultActionBarPresentationFactory.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 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.presentations;
-
-import org.eclipse.jface.action.IToolBarManager;
-import org.eclipse.jface.internal.provisional.action.CoolBarManager2;
-import org.eclipse.jface.internal.provisional.action.ICoolBarManager2;
-import org.eclipse.jface.internal.provisional.action.IToolBarContributionItem;
-import org.eclipse.jface.internal.provisional.action.IToolBarManager2;
-import org.eclipse.jface.internal.provisional.action.ToolBarContributionItem2;
-import org.eclipse.jface.internal.provisional.action.ToolBarManager2;
-import org.eclipse.swt.SWT;
-import org.eclipse.ui.internal.provisional.presentations.IActionBarPresentationFactory;
-
-/**
- * The intention of this class is to allow for replacing the implementation of
- * the cool bar and tool bars in the workbench.
- * <p>
- * <strong>EXPERIMENTAL</strong>. This class or interface has been added as
- * part of a work in progress. There is a guarantee neither that this API will
- * work nor that it will remain the same. Please do not use this API without
- * consulting with the Platform/UI team.
- * </p>
- *
- * @since 3.2
- */
-public class DefaultActionBarPresentationFactory implements IActionBarPresentationFactory {
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.internal.presentations.IActionBarPresentationFactory#createCoolBarManager()
- */
- public ICoolBarManager2 createCoolBarManager() {
- return new CoolBarManager2(SWT.FLAT);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.internal.presentations.IActionBarPresentationFactory#createToolBarManager()
- */
- public IToolBarManager2 createToolBarManager() {
- return new ToolBarManager2(SWT.FLAT | SWT.RIGHT);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.internal.presentations.IActionBarPresentationFactory#createViewToolBarManager()
- */
- public IToolBarManager2 createViewToolBarManager() {
- return new ToolBarManager2(SWT.FLAT | SWT.RIGHT | SWT.WRAP);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.internal.presentations.IActionBarPresentationFactory#createToolBarContributionItem(org.eclipse.jface.action.IToolBarManager, java.lang.String)
- */
- public IToolBarContributionItem createToolBarContributionItem(
- IToolBarManager toolBarManager, String id) {
- return new ToolBarContributionItem2(toolBarManager, id);
- }
-}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/ISelfUpdatingAction.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/ISelfUpdatingAction.java
deleted file mode 100644
index 4434911901f..00000000000
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/ISelfUpdatingAction.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 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.presentations;
-
-import org.eclipse.jface.action.IAction;
-
-/**
- * @since 3.0
- */
-public interface ISelfUpdatingAction extends IAction {
- /**
- * Refreshes the action.
- */
- public void update();
-
- public boolean shouldBeVisible();
-}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/NativePresentationFactory.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/NativePresentationFactory.java
deleted file mode 100644
index c0efff902bb..00000000000
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/NativePresentationFactory.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 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.presentations;
-
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.ui.presentations.IStackPresentationSite;
-import org.eclipse.ui.presentations.StackPresentation;
-import org.eclipse.ui.presentations.WorkbenchPresentationFactory;
-
-/**
- * A presentation factory using native widgets.
- * <p>
- * EXPERIMENTAL
- * </p>
- *
- * @since 3.0
- */
-public class NativePresentationFactory extends WorkbenchPresentationFactory {
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.presentations.AbstractPresentationFactory
- */
- public StackPresentation createEditorPresentation(Composite parent,
- IStackPresentationSite site) {
- return new NativeStackPresentation(parent, site);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.presentations.AbstractPresentationFactory
- */
- public StackPresentation createViewPresentation(Composite parent,
- IStackPresentationSite site) {
- return new NativeStackPresentation(parent, site);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.presentations.AbstractPresentationFactory
- */
- public StackPresentation createStandaloneViewPresentation(Composite parent,
- IStackPresentationSite site, boolean showTitle) {
- // TODO honour showTitle
- return new NativeStackPresentation(parent, site);
- }
-
-}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/NativeStackPresentation.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/NativeStackPresentation.java
deleted file mode 100644
index ae8591f7588..00000000000
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/NativeStackPresentation.java
+++ /dev/null
@@ -1,548 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2010 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.presentations;
-
-import java.util.ArrayList;
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.jface.action.MenuManager;
-import org.eclipse.jface.util.Geometry;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.DisposeEvent;
-import org.eclipse.swt.events.DisposeListener;
-import org.eclipse.swt.events.MouseAdapter;
-import org.eclipse.swt.events.MouseEvent;
-import org.eclipse.swt.events.MouseListener;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.Listener;
-import org.eclipse.swt.widgets.Menu;
-import org.eclipse.swt.widgets.TabFolder;
-import org.eclipse.swt.widgets.TabItem;
-import org.eclipse.ui.IPropertyListener;
-import org.eclipse.ui.IWorkbenchPreferenceConstants;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.presentations.IPresentablePart;
-import org.eclipse.ui.presentations.IStackPresentationSite;
-import org.eclipse.ui.presentations.PresentationUtil;
-import org.eclipse.ui.presentations.StackDropResult;
-import org.eclipse.ui.presentations.StackPresentation;
-
-/**
- * A stack presentation using native widgets.
- * <p>
- * EXPERIMENTAL
- * </p>
- *
- * @since 3.0
- */
-public class NativeStackPresentation extends StackPresentation {
-
- private TabFolder tabFolder;
-
- private Listener dragListener;
-
- private IPresentablePart current;
-
- private MenuManager systemMenuManager = new MenuManager();
-
- // don't reset this dynamically, so just keep the information static.
- // see bug:
- // 75422 [Presentations] Switching presentation to R21 switches immediately,
- // but only partially
- private static int tabPos = PlatformUI.getPreferenceStore().getInt(
- IWorkbenchPreferenceConstants.VIEW_TAB_POSITION);
-
- private final static String TAB_DATA = NativeStackPresentation.class.getName() + ".partId"; //$NON-NLS-1$
-
- private MouseListener mouseListener = new MouseAdapter() {
- public void mouseDown(MouseEvent e) {
- // // PR#1GDEZ25 - If selection will change in mouse up ignore mouse
- // down.
- // // Else, set focus.
- // TabItem newItem = tabFolder.getItem(new Point(e.x, e.y));
- // if (newItem != null) {
- // TabItem oldItem = tabFolder.getSelection();
- // if (newItem != oldItem)
- // return;
- // }
- if (current != null) {
- current.setFocus();
- }
- }
- };
-
- private Listener menuListener = new Listener() {
- /*
- * (non-Javadoc)
- *
- * @see
- * org.eclipse.swt.widgets.Listener#handleEvent(org.eclipse.swt.widgets
- * .Event)
- */
- public void handleEvent(Event event) {
- Point pos = new Point(event.x, event.y);
- // FIXME: this method needs work
-
- IPresentablePart part = null;
- // TabItem item = tabFolder.getItem(pos);
- // if (item != null) {
- // part = getPartForTab(item);
- // }
-
- showPaneMenu(part, pos);
- }
- };
-
- private Listener selectionListener = new Listener() {
- public void handleEvent(Event e) {
- IPresentablePart item = getPartForTab((TabItem) e.item);
- if (item != null) {
- getSite().selectPart(item);
- // item.setFocus();
- }
- }
- };
-
- private Listener resizeListener = new Listener() {
- public void handleEvent(Event e) {
- setControlSize();
- }
- };
-
- private IPropertyListener childPropertyChangeListener = new IPropertyListener() {
- public void propertyChanged(Object source, int property) {
-
- if (isDisposed()) {
- return;
- }
-
- if (source instanceof IPresentablePart) {
- IPresentablePart part = (IPresentablePart) source;
- childPropertyChanged(part, property);
- }
- }
- };
-
- private DisposeListener tabDisposeListener = new DisposeListener() {
- public void widgetDisposed(DisposeEvent e) {
- if (e.widget instanceof TabItem) {
- TabItem item = (TabItem) e.widget;
- IPresentablePart part = getPartForTab(item);
- part.removePropertyListener(childPropertyChangeListener);
- }
- }
- };
-
- public NativeStackPresentation(Composite parent, IStackPresentationSite stackSite) {
- super(stackSite);
-
- tabFolder = new TabFolder(parent, tabPos);
-
- // listener to switch between visible tabItems
- tabFolder.addListener(SWT.Selection, selectionListener);
-
- // listener to resize visible components
- tabFolder.addListener(SWT.Resize, resizeListener);
-
- // listen for mouse down on tab to set focus.
- tabFolder.addMouseListener(mouseListener);
-
- tabFolder.addListener(SWT.MenuDetect, menuListener);
-
- dragListener = new Listener() {
- public void handleEvent(Event event) {
- // FIXME: this method needs work
-
- // Point localPos = new Point(event.x, event.y);
- // TabItem tabUnderPointer = tabFolder.getItem(localPos);
- // TabItem tabUnderPointer = null;
- //
- // if (tabUnderPointer == null) {
- // return;
- // }
- //
- // IPresentablePart part = getPartForTab(tabUnderPointer);
- //
- // if (getSite().isPartMoveable(part)) {
- // getSite().dragStart(part, tabFolder.toDisplay(localPos),
- // false);
- // }
- }
- };
-
- PresentationUtil.addDragListener(tabFolder, dragListener);
-
- }
-
- /**
- * Returns the index of the tab for the given part, or returns
- * tabFolder.getItemCount() if there is no such tab.
- *
- * @param part
- * part being searched for
- * @return the index of the tab for the given part, or the number of tabs if
- * there is no such tab
- */
- private final int indexOf(IPresentablePart part) {
- if (part == null) {
- return tabFolder.getItemCount();
- }
-
- TabItem[] items = tabFolder.getItems();
-
- for (int idx = 0; idx < items.length; idx++) {
- IPresentablePart tabPart = getPartForTab(items[idx]);
-
- if (part == tabPart) {
- return idx;
- }
- }
-
- return items.length;
- }
-
- /**
- * Returns the tab for the given part, or null if there is no such tab
- *
- * @param part
- * the part being searched for
- * @return the tab for the given part, or null if there is no such tab
- */
- protected final TabItem getTab(IPresentablePart part) {
- TabItem[] items = tabFolder.getItems();
-
- int idx = indexOf(part);
-
- if (idx < items.length) {
- return items[idx];
- }
-
- return null;
- }
-
- /**
- * @param part
- * @param property
- */
- protected void childPropertyChanged(IPresentablePart part, int property) {
- TabItem tab = getTab(part);
- initTab(tab, part);
- }
-
- protected final IPresentablePart getPartForTab(TabItem item) {
- IPresentablePart part = (IPresentablePart) item.getData(TAB_DATA);
- return part;
- }
-
- protected TabFolder getTabFolder() {
- return tabFolder;
- }
-
- public boolean isDisposed() {
- return tabFolder == null || tabFolder.isDisposed();
- }
-
- /**
- * Set the size of a page in the folder.
- */
- private void setControlSize() {
- if (current == null || tabFolder == null) {
- return;
- }
- // Rectangle bounds;
- // @issue as above, the mere presence of a theme should not change the
- // behaviour
- // if ((mapTabToPart.size() > 1)
- // || ((tabThemeDescriptor != null) && (mapTabToPart.size() >= 1)))
- // bounds = calculatePageBounds(tabFolder);
- // else
- // bounds = tabFolder.getBounds();
- current.setBounds(calculatePageBounds(tabFolder));
- // current.moveAbove(tabFolder);
- }
-
- public static Rectangle calculatePageBounds(TabFolder folder) {
- if (folder == null) {
- return new Rectangle(0, 0, 0, 0);
- }
- Rectangle bounds = folder.getBounds();
- Rectangle offset = folder.getClientArea();
- bounds.x += offset.x;
- bounds.y += offset.y;
- bounds.width = offset.width;
- bounds.height = offset.height;
- return bounds;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.internal.skins.Presentation#dispose()
- */
- public void dispose() {
- if (isDisposed()) {
- return;
- }
- PresentationUtil.removeDragListener(tabFolder, dragListener);
-
- // systemMenuManager.dispose();
-
- tabFolder.dispose();
- tabFolder = null;
- }
-
- private TabItem createPartTab(IPresentablePart part, int tabIndex) {
- TabItem tabItem = new TabItem(tabFolder, SWT.NONE, tabIndex);
- tabItem.setData(TAB_DATA, part);
- part.addPropertyListener(childPropertyChangeListener);
- tabItem.addDisposeListener(tabDisposeListener);
- initTab(tabItem, part);
- return tabItem;
- }
-
- /**
- * Initializes a tab for the given part. Sets the text, icon, tool tip, etc.
- * This will also be called whenever a relevant property changes in the part
- * to reflect those changes in the tab. Subclasses may override to change
- * the appearance of tabs for a particular part.
- *
- * @param tabItem
- * tab for the part
- * @param part
- * the part being displayed
- */
- protected void initTab(TabItem tabItem, IPresentablePart part) {
- tabItem.setText(part.getName());
- tabItem.setToolTipText(part.getTitleToolTip());
-
- Image tabImage = part.getTitleImage();
- if (tabImage != tabItem.getImage()) {
- tabItem.setImage(tabImage);
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.eclipse.ui.internal.skins.StackPresentation#addPart(org.eclipse.ui
- * .internal.skins.IPresentablePart,
- * org.eclipse.ui.internal.skins.IPresentablePart)
- */
- public void addPart(IPresentablePart newPart, Object cookie) {
- createPartTab(newPart, tabFolder.getItemCount());
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.eclipse.ui.internal.skins.StackPresentation#removePart(org.eclipse
- * .ui.internal.skins.IPresentablePart)
- */
- public void removePart(IPresentablePart oldPart) {
- TabItem item = getTab(oldPart);
- if (item == null) {
- return;
- }
- oldPart.setVisible(false);
-
- item.dispose();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.eclipse.ui.internal.skins.StackPresentation#selectPart(org.eclipse
- * .ui.internal.skins.IPresentablePart)
- */
- public void selectPart(IPresentablePart toSelect) {
- if (toSelect == current) {
- return;
- }
-
- if (current != null) {
- current.setVisible(false);
- }
-
- current = toSelect;
-
- if (current != null) {
- tabFolder.setSelection(indexOf(current));
- current.setVisible(true);
- setControlSize();
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.eclipse.ui.internal.skins.Presentation#setBounds(org.eclipse.swt.
- * graphics.Rectangle)
- */
- public void setBounds(Rectangle bounds) {
- tabFolder.setBounds(bounds);
- setControlSize();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.internal.skins.Presentation#computeMinimumSize()
- */
- public Point computeMinimumSize() {
- return Geometry.getSize(tabFolder.computeTrim(0, 0, 0, 0));
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.internal.skins.Presentation#setVisible(boolean)
- */
- public void setVisible(boolean isVisible) {
- if (current != null) {
- current.setVisible(isVisible);
- }
- tabFolder.setVisible(isVisible);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.internal.skins.Presentation#setState(int)
- */
- public void setState(int state) {
- // tabFolder.setMinimized(state == IPresentationSite.STATE_MINIMIZED);
- // tabFolder.setMaximized(state == IPresentationSite.STATE_MAXIMIZED);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.internal.skins.Presentation#getSystemMenuManager()
- */
- public IMenuManager getSystemMenuManager() {
- return systemMenuManager;
- }
-
- /**
- * @param part
- * @param point
- */
- protected void showPaneMenu(IPresentablePart part, Point point) {
- systemMenuManager.update(false);
- Menu aMenu = systemMenuManager.createContextMenu(tabFolder.getParent());
- aMenu.setLocation(point.x, point.y);
- aMenu.setVisible(true);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.internal.skins.Presentation#getControl()
- */
- public Control getControl() {
- return tabFolder;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.eclipse.ui.internal.skins.StackPresentation#dragOver(org.eclipse.
- * swt.widgets.Control, org.eclipse.swt.graphics.Point)
- */
- public StackDropResult dragOver(Control currentControl, Point location) {
- // FIXME: this method needs work
-
- // Determine which tab we're currently dragging over
- // Point localPos = tabFolder.toControl(location);
- // final TabItem tabUnderPointer = tabFolder.getItem(localPos);
- // final TabItem tabUnderPointer = null;
-
- // This drop target only deals with tabs... if we're not dragging over
- // a tab, exit.
- // if (tabUnderPointer == null) {
- // return null;
- // }
-
- // return new StackDropResult(Geometry.toDisplay(tabFolder,
- // tabUnderPointer.getBounds()),
- // tabFolder.indexOf(tabUnderPointer));
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.presentations.StackPresentation#showSystemMenu()
- */
- public void showSystemMenu() {
- // TODO Auto-generated method stub
-
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.presentations.StackPresentation#showPaneMenu()
- */
- public void showPaneMenu() {
- // TODO Auto-generated method stub
-
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.eclipse.ui.presentations.StackPresentation#getTabList(IPresentablePart
- * )
- */
- public Control[] getTabList(IPresentablePart part) {
- ArrayList list = new ArrayList();
- if (getControl() != null) {
- list.add(getControl());
- }
- if (part.getToolBar() != null) {
- list.add(part.getToolBar());
- }
- if (part.getControl() != null) {
- list.add(part.getControl());
- }
- return (Control[]) list.toArray(new Control[list.size()]);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.presentations.StackPresentation#getCurrentPart()
- */
- public IPresentablePart getCurrentPart() {
- return current;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.presentations.StackPresentation#setActive(int)
- */
- public void setActive(int newState) {
-
- }
-
-}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/PaneFolder.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/PaneFolder.java
deleted file mode 100644
index 4eea65331b4..00000000000
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/PaneFolder.java
+++ /dev/null
@@ -1,892 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2009 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
- * Semion Chichelnitsky (semion@il.ibm.com) - bug 66889
- *******************************************************************************/
-package org.eclipse.ui.internal.presentations;
-
-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.custom.CTabFolder;
-import org.eclipse.swt.custom.CTabFolder2Adapter;
-import org.eclipse.swt.custom.CTabFolderEvent;
-import org.eclipse.swt.custom.CTabItem;
-import org.eclipse.swt.custom.ViewForm;
-import org.eclipse.swt.events.ControlEvent;
-import org.eclipse.swt.events.ControlListener;
-import org.eclipse.swt.events.DisposeEvent;
-import org.eclipse.swt.events.DisposeListener;
-import org.eclipse.swt.events.MouseAdapter;
-import org.eclipse.swt.events.MouseEvent;
-import org.eclipse.swt.events.MouseListener;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.ui.internal.dnd.SwtUtil;
-import org.eclipse.ui.internal.layout.SizeCache;
-import org.eclipse.ui.internal.presentations.util.ProxyControl;
-import org.eclipse.ui.internal.tweaklets.TabBehaviour;
-import org.eclipse.ui.internal.tweaklets.Tweaklets;
-import org.eclipse.ui.presentations.IStackPresentationSite;
-
-/**
- * This class implements the tab folders that contains can contain two toolbars
- * and status text. Wherever possible, the toolbars are aligned with the tabs.
- * If there is not enough room beside the tabs, the toolbars are aligned with
- * the status text. This is the same tab folder that is used to arrange views
- * and editors in Eclipse.
- * <p>
- * This is closely related to DefaultPartPresentation, but they have different
- * responsibilities. This is essentially a CTabFolder that can manage a toolbar.
- * It should not depend on data structures from the workbench, and its public
- * interface should only use SWT objects or listeners. DefaultPartPresentation
- * uses a PaneFolder to arrange views or editors. Knowledge of higher-level data
- * structures should go there.
- * </p>
- * <p>
- * Although it is not actually a control, the public interface is much like an
- * SWT control. Implementation-wise, this is actually a combination of a
- * CTabFolder and a ViewForm. It encapsulates the details of moving the toolbar
- * between the CTabFolder and the ViewForm, and provides a simpler interface to
- * the ViewForm/CTabFolder.
- * </p>
- * To be consistent with SWT composites, this object can deal with its children
- * being disposed without warning. This is treated like a removal.
- *
- * @since 3.0
- */
-public final class PaneFolder {
- // Tab folder and associated proxy controls
- private CTabFolder tabFolder;
-
- private Control titleAreaProxy;
-
- // View form and associated proxy controls
- private ViewForm viewForm;
-
- private ProxyControl contentProxy;
-
- private ProxyControl viewFormTopLeftProxy;
-
- private ProxyControl viewFormTopRightProxy;
-
- private ProxyControl viewFormTopCenterProxy;
-
- // Cached sizes of the top-right and top-center controls
- private SizeCache topRightCache = new SizeCache();
-
- private SizeCache topCenterCache = new SizeCache();
-
- private SizeCache topLeftCache = new SizeCache();
-
- private boolean putTrimOnTop = true;
-
- // HACK: Sometimes the topright control isn't resized when
- // CTabFolder.setBounds is called.
- // We use the following data structures to detect if this has happened and
- // force a layout when necessary.
- private boolean topRightResized = false;
-
- private boolean useTopRightOptimization = false;
-
- private int lastWidth = 0;
-
- // END OF HACK
-
- private DisposeListener tabFolderDisposeListener = new DisposeListener() {
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.swt.events.DisposeListener#widgetDisposed(org.eclipse.swt.events.DisposeEvent)
- */
- public void widgetDisposed(DisposeEvent e) {
- PaneFolder.this.widgetDisposed();
- }
- };
-
- /**
- * Listens for its children being disposed, and removes them if this happens
- * (although this may indicate a programming error, this behavior is
- * consistent with SWT composites).
- */
- private DisposeListener prematureDisposeListener = new DisposeListener() {
-
- public void widgetDisposed(DisposeEvent e) {
- Control disposedControl = (Control) e.widget;
-
- if (isDisposed()) {
- return;
- }
-
- // Probably unnecessary, but it can't hurt garbage collection
- disposedControl.removeDisposeListener(this);
-
- if (disposedControl == topLeftCache.getControl()) {
- setTopLeft(null);
- }
-
- if (disposedControl == topRightCache.getControl()) {
- setTopRight(null);
- }
-
- if (disposedControl == topCenterCache.getControl()) {
- setTopCenter(null);
- }
- }
-
- };
-
- /**
- * List of PaneFolderButtonListener
- */
- private List buttonListeners = new ArrayList(1);
-
- private int state = IStackPresentationSite.STATE_RESTORED;
-
- /**
- * State of the folder at the last mousedown event. This is used to prevent
- * a mouseup over the minimize or maximize buttons from undoing a state
- * change that was caused by the mousedown.
- */
- private int mousedownState = -1;
-
- /**
- * Location of the last mousedown event. This is used to determine if the
- * mouseup event occured on the same item.
- */
- private Point mousedownPoint = new Point(-1, -1);
-
- /**
- * Time of the last mousedown event. This is used to determine if the
- * mouseup event occurs within a reasonable time.
- */
- private long mousedownTime = 0L;
-
- /**
- * Timeout value for when a pair of mousedown, mouseup events should not be
- * interpreted as a click.
- */
- private static long CLICK_TIME = 1000;
-
- // CTabFolder listener
- private CTabFolder2Adapter expandListener = new CTabFolder2Adapter() {
- public void minimize(CTabFolderEvent event) {
- event.doit = false;
- notifyButtonListeners(IStackPresentationSite.STATE_MINIMIZED);
- }
-
- public void restore(CTabFolderEvent event) {
- event.doit = false;
- notifyButtonListeners(IStackPresentationSite.STATE_RESTORED);
- }
-
- public void maximize(CTabFolderEvent event) {
- event.doit = false;
- notifyButtonListeners(IStackPresentationSite.STATE_MAXIMIZED);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.swt.custom.CTabFolder2Adapter#close(org.eclipse.swt.custom.CTabFolderEvent)
- */
- public void close(CTabFolderEvent event) {
- event.doit = false;
- notifyCloseListeners((CTabItem) event.item);
- }
-
- public void showList(CTabFolderEvent event) {
- notifyShowListeners(event);
- }
-
- };
-
- private MouseListener mouseListener = new MouseAdapter() {
- public void mouseDown(MouseEvent e) {
- mousedownState = getState();
- mousedownPoint = new Point(e.x, e.y);
- mousedownTime = e.time & 0x0FFFFFFFFL;
- }
-
- public void mouseUp(MouseEvent e) {
- if (e.button == 2 && e.count == 1) {
- Point mouseupPoint = new Point(e.x, e.y);
- CTabItem item = tabFolder.getItem(mouseupPoint);
- long mouseupTime = e.time & 0x0FFFFFFFFL;
- if (item != null && (mouseupTime - mousedownTime <= CLICK_TIME)) {
- CTabItem mousedownItem = tabFolder.getItem(mousedownPoint);
- if (mousedownItem == item) {
- notifyCloseListeners(item);
- }
- }
- }
- }
-
- public void mouseDoubleClick(MouseEvent e) {
- }
- };
-
- private boolean showButtons = true;
- private boolean minimizeVisible = false;
- private boolean maximizeVisible = false;
-
- /**
- * Make sure we don't recursively enter the layout() code.
- */
- private boolean inLayout = false;
-
- private int tabPosition;
-
- /**
- * Creates a pane folder. This will create exactly one child control in the
- * given parent.
- *
- * @param parent
- * @param flags
- */
- public PaneFolder(Composite parent, int flags) {
- // Initialize tab folder
- {
- tabFolder = new CTabFolder(parent, flags);
-
- tabFolder.setMRUVisible(((TabBehaviour)Tweaklets.get(TabBehaviour.KEY)).enableMRUTabVisibility());
-
- // Create a proxy control to measure the title area of the tab folder
- titleAreaProxy = new Composite(tabFolder, SWT.NO_BACKGROUND);
- titleAreaProxy.setVisible(false);
- titleAreaProxy.addControlListener(new ControlListener() {
- public void controlMoved(ControlEvent e) {
- topRightResized = true;
- }
-
- public void controlResized(ControlEvent e) {
- topRightResized = true;
-
- // bug 101683 - we need to do a layout of the PaneFolder
- // when the title area proxy is resized.
- if (!inLayout && !PaneFolder.this.isDisposed()
- && viewForm!=null && contentProxy!=null) {
- PaneFolder.this.aboutToResize();
- PaneFolder.this.layout(false);
- }
- }
- });
- tabFolder.setTopRight(titleAreaProxy, SWT.FILL);
-
- tabFolder.addCTabFolder2Listener(expandListener);
-
- tabFolder.addMouseListener(mouseListener);
-
- tabFolder.addDisposeListener(tabFolderDisposeListener);
- }
-
- // Initialize view form
- {
- viewForm = new ViewForm(tabFolder, SWT.NO_BACKGROUND);
-
- // Only attach these to the viewForm when there's actually a control
- // to display
- viewFormTopLeftProxy = new ProxyControl(viewForm);
- viewFormTopCenterProxy = new ProxyControl(viewForm);
- viewFormTopRightProxy = new ProxyControl(viewForm);
-
- contentProxy = new ProxyControl(viewForm);
- viewForm.setContent(contentProxy.getControl());
- }
- }
-
- /**
- * Returns the title area (the empty region to the right of the tabs), in
- * the tab folder's coordinate system.
- *
- * @return the title area (the empty region to the right of the tabs)
- */
- public Rectangle getTitleArea() {
- return titleAreaProxy.getBounds();
- }
-
- /**
- * Return the main control for this pane folder
- *
- * @return
- */
- public Composite getControl() {
- return tabFolder;
- }
-
- public void flushTopCenterSize() {
- topCenterCache.flush();
- viewForm.changed(new Control[] {viewFormTopCenterProxy.getControl()});
- }
-
- public void flushTopLeftSize() {
- topLeftCache.flush();
- viewForm.changed(new Control[] { viewFormTopLeftProxy.getControl() });
- }
-
- /**
- * Sets the top-center control (usually a toolbar), or null if none. Note
- * that the control can have any parent.
- *
- * @param topCenter
- * the top-center control or null if none
- */
- public void setTopCenter(Control topCenter) {
- if (topCenter == topCenterCache.getControl()) {
- return;
- }
-
- removeDisposeListener(topCenterCache.getControl());
-
- topCenterCache.setControl(topCenter);
-
- if (putTrimOnTop) {
- viewFormTopCenterProxy.setTarget(null);
- } else {
- viewFormTopCenterProxy.setTarget(topCenterCache);
- }
-
- viewForm.changed(new Control[] {viewFormTopCenterProxy.getControl()});
-
- if (topCenter != null) {
- topCenter.addDisposeListener(prematureDisposeListener);
-
- if (!putTrimOnTop) {
- if (!viewForm.isDisposed()) {
- viewForm.setTopCenter(viewFormTopCenterProxy.getControl());
- }
- }
- } else {
- if (!putTrimOnTop) {
- if (!viewForm.isDisposed()) {
- viewForm.setTopCenter(null);
- }
- }
- }
- }
-
- /**
- * Sets the top-right control (usually a dropdown), or null if none
- *
- * @param topRight
- */
- public void setTopRight(Control topRight) {
- if (topRightCache.getControl() == topRight) {
- return;
- }
-
- removeDisposeListener(topRightCache.getControl());
-
- topRightCache.setControl(topRight);
-
- if (putTrimOnTop) {
- viewFormTopRightProxy.setTarget(null);
- } else {
- viewFormTopRightProxy.setTarget(topRightCache);
- }
-
- if (topRight != null) {
- topRight.addDisposeListener(prematureDisposeListener);
- if (!putTrimOnTop) {
-
- viewForm.setTopRight(viewFormTopRightProxy.getControl());
- }
- } else {
- if (!putTrimOnTop) {
- viewForm.setTopRight(null);
- }
- }
- }
-
- /**
- * Sets the top-left control (usually a title label), or null if none
- *
- * @param topLeft
- */
- public void setTopLeft(Control topLeft) {
- if (topLeftCache.getControl() == topLeft) {
- return;
- }
-
- removeDisposeListener(topLeftCache.getControl());
-
- topLeftCache.setControl(topLeft);
- // The top-left control always goes directly in the ViewForm
- if (topLeft != null) {
- topLeft.addDisposeListener(prematureDisposeListener);
- viewFormTopLeftProxy.setTarget(topLeftCache);
- viewForm.setTopLeft(viewFormTopLeftProxy.getControl());
- } else {
- viewFormTopLeftProxy.setTarget(null);
- viewForm.setTopLeft(null);
- }
- }
-
- /**
- * Optimization: calling this method immediately before setting the
- * control's bounds will allow for improved caching.
- */
- public void aboutToResize() {
- useTopRightOptimization = true;
- topRightResized = false;
- lastWidth = getControl().getBounds().width;
- }
-
- /**
- * Cause the folder to hide or show its
- * Minimize and Maximize affordances.
- *
- * @param show
- * <code>true</code> - the min/max buttons are visible.
- * @since 3.3
- */
- public void showMinMax(boolean show) {
- showButtons = show;
- setMaximizeVisible(show);
- setMinimizeVisible(show);
- layout(true);
- }
-
- public void layout(boolean flushCache) {
- if (inLayout) {
- return;
- }
-
- inLayout = true;
- try {
-
- viewForm.setLayoutDeferred(true);
-
- tabFolder.setMinimizeVisible(showButtons && minimizeVisible);
- tabFolder.setMaximizeVisible(showButtons && maximizeVisible);
-
- // Flush the cached sizes if necessary
- if (flushCache) {
- topLeftCache.flush();
- topRightCache.flush();
- topCenterCache.flush();
- }
-
- // HACK: Force the tab folder to do a layout, since it doesn't always
- // resize its title area each time setBounds is called.
- if (!(useTopRightOptimization && (topRightResized || lastWidth == getControl()
- .getBounds().width))) {
- // If we can't use the optimization, then we need to force a layout
- // of the tab folder
- tabFolder.setTopRight(titleAreaProxy, SWT.FILL);
- }
- useTopRightOptimization = false;
- // END OF HACK
-
- // Get the bounds relative to the CTabFolder
- Rectangle titleArea = titleAreaProxy.getBounds();
-
- Point topRightSize = topRightCache
- .computeSize(SWT.DEFAULT, SWT.DEFAULT);
- Point topCenterSize = topCenterCache.computeSize(SWT.DEFAULT,
- SWT.DEFAULT);
-
- // Determine if there is enough room for the trim in the title area
- int requiredWidth = topRightSize.x + topCenterSize.x;
- int requiredHeight = Math.max(topRightSize.y, topCenterSize.y);
-
- boolean lastTrimOnTop = putTrimOnTop;
- putTrimOnTop = (titleArea.width >= requiredWidth && titleArea.height >= requiredHeight);
-
- Control topRight = topRightCache.getControl();
- Control topCenter = topCenterCache.getControl();
-
- if (putTrimOnTop) {
- // Try to avoid calling setTop* whenever possible, since this will
- // trigger a layout
- // of the viewForm.
- if (!lastTrimOnTop) {
- // Arrange controls in the title bar
- viewFormTopCenterProxy.setTarget(null);
- viewFormTopRightProxy.setTarget(null);
- viewForm.setTopCenter(null);
- viewForm.setTopRight(null);
- }
-
- Rectangle topRightArea = new Rectangle(titleArea.x
- + titleArea.width - topRightSize.x, titleArea.y
- + (titleArea.height - topRightSize.y) / 2, topRightSize.x,
- topRightSize.y);
-
- if (topRight != null) {
- // Map the coordinates from the tabFolder back to the control's parent
- topRight.setBounds(topRight.getDisplay().map(tabFolder, topRight.getParent(), topRightArea));
- }
-
- if (topCenter != null) {
- Rectangle topCenterArea = new Rectangle(topRightArea.x
- - topCenterSize.x, titleArea.y
- + (titleArea.height - topCenterSize.y) / 2,
- topCenterSize.x, topCenterSize.y);
-
- // Map the coordinates from the tabFolder back to the control's parent
- topCenter.setBounds(topCenter.getDisplay().map(tabFolder, topCenter.getParent(), topCenterArea));
- }
- } else {
- if (topCenter != null) {
- viewFormTopCenterProxy.setTarget(topCenterCache);
- viewForm.setTopCenter(viewFormTopCenterProxy.getControl());
- }
-
- if (topRight != null) {
- viewFormTopRightProxy.setTarget(topRightCache);
- viewForm.setTopRight(viewFormTopRightProxy.getControl());
- }
- }
-
- Rectangle newBounds = tabFolder.getClientArea();
- viewForm.setBounds(newBounds);
- } finally {
- viewForm.setLayoutDeferred(false);
- inLayout = false;
- }
-
- viewFormTopRightProxy.layout();
- viewFormTopLeftProxy.layout();
- viewFormTopCenterProxy.layout();
- }
-
- public Composite getContentParent() {
- return viewForm;
- }
-
- public void setContent(Control newContent) {
- viewForm.setContent(newContent);
- }
-
- /**
- * Returns the current state of the folder (as shown on the button icons)
- *
- * @return one of the IStackPresentationSite.STATE_* constants
- */
- public int getState() {
- return state;
- }
-
- /**
- * @param buttonId
- * one of the IStackPresentationSite.STATE_* constants
- */
- protected void notifyButtonListeners(int buttonId) {
- if (mousedownState == getState()) {
- Iterator iter = buttonListeners.iterator();
-
- while (iter.hasNext()) {
- PaneFolderButtonListener listener = (PaneFolderButtonListener) iter
- .next();
-
- listener.stateButtonPressed(buttonId);
- }
- }
- }
-
- public Control getContent() {
- return viewForm.getContent();
- }
-
- /**
- * Notifies all listeners that the user clicked on the chevron
- *
- * @param tabItem
- */
- protected void notifyShowListeners(CTabFolderEvent event) {
- Iterator iter = buttonListeners.iterator();
-
- while (iter.hasNext()) {
- PaneFolderButtonListener listener = (PaneFolderButtonListener) iter
- .next();
-
- listener.showList(event);
- }
- }
-
- /**
- * Notifies all listeners that the close button was pressed
- *
- * @param tabItem
- */
- protected void notifyCloseListeners(CTabItem tabItem) {
- Iterator iter = buttonListeners.iterator();
-
- while (iter.hasNext()) {
- PaneFolderButtonListener listener = (PaneFolderButtonListener) iter
- .next();
-
- listener.closeButtonPressed(tabItem);
- }
- }
-
- /**
- * Sets the state that will be shown on the CTabFolder's buttons
- *
- * @param state
- * one of the IStackPresentationSite.STATE_* constants
- */
- public void setState(int state) {
- this.state = state;
-
- tabFolder.setMinimized(state == IStackPresentationSite.STATE_MINIMIZED);
- tabFolder.setMaximized(state == IStackPresentationSite.STATE_MAXIMIZED);
- }
-
- public void addButtonListener(PaneFolderButtonListener listener) {
- buttonListeners.add(listener);
- }
-
- public void removeButtonListener(PaneFolderButtonListener listener) {
- buttonListeners.remove(listener);
- }
-
- public void setTabPosition(int newTabPosition) {
- tabPosition = newTabPosition;
- tabFolder.setTabPosition(tabPosition);
- }
-
- public int getTabPosition() {
- return tabPosition;
- }
-
- public boolean isDisposed() {
- return tabFolder == null || tabFolder.isDisposed();
- }
-
- public CTabItem createItem(int style, int index) {
- return new CTabItem(tabFolder, style, index);
- }
-
- public Point computeMinimumSize() {
- Point result = Geometry.getSize(tabFolder.computeTrim(0, 0, 0, 0));
-
- // Add some space for the minimize and maximize buttons plus a tab.
- // Right now this isn't exposed from SWT as API, so we just add 50
- // pixels.
- result.x += 100;
- return result;
- }
-
- /**
- * Removes the dispose listener from the given control, unless the given
- * control is null or disposed.
- *
- * @param oldControl
- * control to detach the dispose listener from
- */
- private void removeDisposeListener(Control oldControl) {
- if (!SwtUtil.isDisposed(oldControl)) {
- oldControl.removeDisposeListener(prematureDisposeListener);
- }
- }
-
- private void widgetDisposed() {
- removeDisposeListener(topCenterCache.getControl());
- topCenterCache.setControl(null);
- removeDisposeListener(topRightCache.getControl());
- topRightCache.setControl(null);
- removeDisposeListener(topLeftCache.getControl());
- topLeftCache.setControl(null);
- }
-
- public Point getChevronLocation() {
- // get the last visible item
- int numItems = tabFolder.getItemCount();
- CTabItem item = null, tempItem = null;
- for (int i = 0; i < numItems; i++) {
- tempItem = tabFolder.getItem(i);
- if (tempItem.isShowing()) {
- item = tempItem;
- }
- }
-
- // if we have no visible tabs, abort.
- if (item == null) {
- return new Point(0, 0);
- }
-
- Rectangle itemBounds = item.getBounds();
- int x = itemBounds.x + itemBounds.width;
- int y = itemBounds.y + itemBounds.height;
- return new Point(x, y);
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // The remainder of the methods in this class redirect directly to
- // CTabFolder methods
-
- public void setSelection(int selection) {
- tabFolder.setSelection(selection);
- }
-
- public void showItem(int selection) {
- tabFolder.showItem(tabFolder.getItem(selection));
- }
-
- /**
- * @param i
- * @param j
- * @param k
- * @param l
- * @return
- */
- public Rectangle computeTrim(int i, int j, int k, int l) {
- return tabFolder.computeTrim(i, j, k, l);
- }
-
- /**
- * @param b
- */
- public void setUnselectedCloseVisible(boolean b) {
- tabFolder.setUnselectedCloseVisible(b);
- }
-
- /**
- * @param fgColor
- */
- public void setSelectionForeground(Color fgColor) {
- tabFolder.setSelectionForeground(fgColor);
- }
-
- /**
- * Set the selection gradient with the activation state.
- * @param bgColors
- * @param percentages
- * @param vertical
- */
- public void setSelectionBackground(Color[] bgColors, int[] percentages,
- boolean vertical) {
- tabFolder.setSelectionBackground(bgColors, percentages, vertical);
- }
-
- public CTabItem getItem(int idx) {
- return tabFolder.getItem(idx);
- }
-
- public int getSelectionIndex() {
- return tabFolder.getSelectionIndex();
- }
-
- public int getTabHeight() {
- return tabFolder.getTabHeight();
- }
-
- public int indexOf(CTabItem toFind) {
- return tabFolder.indexOf(toFind);
- }
-
- public void setTabHeight(int height) {
- tabFolder.setTabHeight(height);
- }
-
- /**
- * @return
- */
- public int getItemCount() {
- return tabFolder.getItemCount();
- }
-
- /**
- * @return
- */
- public CTabItem[] getItems() {
- return tabFolder.getItems();
- }
-
- public CTabItem getItem(Point toGet) {
- return tabFolder.getItem(toGet);
- }
-
- public CTabItem getSelection() {
- return tabFolder.getSelection();
- }
-
- /**
- * @param isVisible
- */
- public void setMinimizeVisible(boolean isVisible) {
- tabFolder.setMinimizeVisible(isVisible);
- minimizeVisible = isVisible;
- }
-
- /**
- * Changes the minimum number of characters to display in a pane folder tab.
- * This control how much information will be displayed to the user.
- *
- * @param count
- * The number of characters to display in the tab folder; this
- * value should be a positive integer.
- * @see org.eclipse.swt.custom.CTabFolder#setMinimumCharacters(int)
- * @since 3.1
- */
- public void setMinimumCharacters(int count) {
- tabFolder.setMinimumCharacters(count);
- }
-
- /**
- * @param isVisible
- */
- public void setMaximizeVisible(boolean isVisible) {
- tabFolder.setMaximizeVisible(isVisible);
- maximizeVisible = isVisible;
- }
-
- /**
- * @param traditionalTab
- */
- public void setSimpleTab(boolean traditionalTab) {
- tabFolder.setSimple(traditionalTab);
- }
-
- /**
- * @param b
- */
- public void setUnselectedImageVisible(boolean b) {
- tabFolder.setUnselectedImageVisible(b);
- }
-
- /**
- * @param b
- */
- public void setSingleTab(boolean b) {
- tabFolder.setSingle(b);
- }
-
- public void hideTitle() {
- tabFolder.setTabHeight(0);
- }
-
- public ViewForm getViewForm() {
- return viewForm;
- }
-
- /**
- * Propogate the visibility change requests to the proxy controls. When
- * their target is null, they no longer get visibility updates. Currently
- * this only propagates the changes to the ProxyControls held by this
- * folder.
- *
- * @param visible
- * <code>true</code> - it's visible.
- * @since 3.2
- */
- public void setVisible(boolean visible) {
- contentProxy.setVisible(visible);
- viewFormTopCenterProxy.setVisible(visible);
- viewFormTopLeftProxy.setVisible(visible);
- viewFormTopRightProxy.setVisible(visible);
- }
-}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/PaneFolderButtonListener.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/PaneFolderButtonListener.java
deleted file mode 100644
index 8225353ae2e..00000000000
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/PaneFolderButtonListener.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 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.presentations;
-
-import org.eclipse.swt.custom.CTabFolderEvent;
-import org.eclipse.swt.custom.CTabItem;
-
-/**
- * This listener receives notifications when the user clicks on one of
- * the buttons (minimize, maximize, or restore) on a pane folder.
- *
- * @since 3.0
- */
-public abstract class PaneFolderButtonListener {
-
- /**
- * Called when the minimize, maximize, or restore buttons are pressed.
- *
- * @param buttonId one of the IStackPresentationSite.STATE_* constants
- */
- public void stateButtonPressed(int buttonId) {
- }
-
- /**
- * Called when a close button is pressed.
- *
- * @param item the tab whose close button was pressed
- */
- public void closeButtonPressed(CTabItem item) {
- }
-
- /**
- *
- * @since 3.0
- */
- public void showList(CTabFolderEvent event) {
- }
-}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/PresentablePart.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/PresentablePart.java
deleted file mode 100644
index 4f12c7f2e8f..00000000000
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/PresentablePart.java
+++ /dev/null
@@ -1,419 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2007 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
- * Stefan Xenos, IBM; Chris Torrence, ITT Visual Information Solutions - bug 51580
- *******************************************************************************/
-package org.eclipse.ui.internal.presentations;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.core.runtime.ListenerList;
-import org.eclipse.jface.util.IPropertyChangeListener;
-import org.eclipse.jface.util.PropertyChangeEvent;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.ui.IPropertyListener;
-import org.eclipse.ui.ISharedImages;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.internal.PartPane;
-import org.eclipse.ui.internal.WorkbenchPartReference;
-import org.eclipse.ui.internal.dnd.SwtUtil;
-import org.eclipse.ui.presentations.IPartMenu;
-import org.eclipse.ui.presentations.IPresentablePart;
-
-/**
- * This is a lightweight adapter that allows PartPanes to be used by a StackPresentation. All methods
- * either redirect directly to PartPane or do trivial type conversions. All listeners registered by
- * the presentation are kept here rather than registering them directly on the PartPane. This allows
- * us to remove all listeners registered by a presentation that has been disposed, offering some
- * protection against memory leaks.
- */
-public class PresentablePart implements IPresentablePart {
-
- private PartPane part;
-
- /**
- * Local listener list -- we use this rather than registering listeners directly on the part
- * in order to protect against memory leaks in badly behaved presentations.
- */
- private List listeners = new ArrayList();
-
- // Lazily initialized. Use getPropertyListenerProxy() to access.
- private IPropertyListener lazyPropertyListenerProxy;
-
- private ListenerList partPropertyChangeListeners = new ListenerList();
-
- private IPropertyChangeListener lazyPartPropertyChangeListener;
-
- // Lazily initialized. Use getMenu() to access
- private IPartMenu viewMenu;
-
- // True iff the "set" methods on this object are talking to the real part (disabled
- // if the part is currently being managed by another presentation stack)
- private boolean enableInputs = true;
-
- // True iff the "get" methods are returning up-to-date info from the real part (disabled
- // for efficency if the presentation is invisible)
- private boolean enableOutputs = true;
- private Rectangle savedBounds = new Rectangle(0,0,0,0);
- private boolean isVisible = false;
-
- // Saved state (only used when the part is inactive)
- private String name = ""; //$NON-NLS-1$
- private String titleStatus = ""; //$NON-NLS-1$
- private boolean isDirty = false;
- private boolean isBusy = false;
- private boolean hasViewMenu = false;
-
- /**
- * Constructor
- *
- * @param part
- */
- public PresentablePart(PartPane part, Composite parent) {
- this.part = part;
- getPane().addPropertyListener(getPropertyListenerProxy());
- getPane().addPartPropertyListener(getPartPropertyListenerProxy());
- }
-
- public PartPane getPane() {
- return part;
- }
-
- private IPropertyListener getPropertyListenerProxy() {
- if (lazyPropertyListenerProxy == null) {
- lazyPropertyListenerProxy = new IPropertyListener() {
- public void propertyChanged(Object source, int propId) {
- firePropertyChange(propId);
- }
- };
- }
-
- return lazyPropertyListenerProxy;
- }
-
- private IPropertyChangeListener getPartPropertyListenerProxy() {
- if (lazyPartPropertyChangeListener == null) {
- lazyPartPropertyChangeListener = new IPropertyChangeListener() {
- public void propertyChange(PropertyChangeEvent event) {
- PropertyChangeEvent e = new PropertyChangeEvent(this,
- event.getProperty(), event.getOldValue(), event.getNewValue());
- firePartPropertyChange(e);
- }
- };
- }
- return lazyPartPropertyChangeListener;
- }
-
- /**
- * Detach this PresentablePart from the real part. No further methods should
- * be invoked on this object.
- */
- public void dispose() {
- // Ensure that the property listener is detached (necessary to prevent leaks)
- getPane().removePropertyListener(getPropertyListenerProxy());
- getPane().removePartPropertyListener(getPartPropertyListenerProxy());
-
- // Null out the various fields to ease garbage collection (optional)
- part = null;
- listeners.clear();
- listeners = null;
- partPropertyChangeListeners.clear();
- partPropertyChangeListeners = null;
- }
-
- public void firePropertyChange(int propertyId) {
- for (int i = 0; i < listeners.size(); i++) {
- ((IPropertyListener) listeners.get(i)).propertyChanged(this, propertyId);
- }
- }
-
- public void addPropertyListener(final IPropertyListener listener) {
- listeners.add(listener);
- }
-
- public void removePropertyListener(final IPropertyListener listener) {
- listeners.remove(listener);
- }
-
- protected void firePartPropertyChange(PropertyChangeEvent event) {
- Object[] l = partPropertyChangeListeners.getListeners();
- for (int i = 0; i < l.length; i++) {
- ((IPropertyChangeListener) l[i]).propertyChange(event);
- }
- }
-
- public void addPartPropertyListener(IPropertyChangeListener listener) {
- partPropertyChangeListeners.add(listener);
- }
-
- public void removePartPropertyListener(IPropertyChangeListener listener) {
- partPropertyChangeListeners.remove(listener);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.presentations.IPresentablePart#setBounds(org.eclipse.swt.graphics.Rectangle)
- */
- public void setBounds(Rectangle bounds) {
- savedBounds = bounds;
- if (enableInputs && !SwtUtil.isDisposed(part.getControl())) {
- part.setBounds(bounds);
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.presentations.IPresentablePart#setVisible(boolean)
- */
- public void setVisible(boolean isVisible) {
- this.isVisible = isVisible;
- if (enableInputs) {
- part.setVisible(isVisible);
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.presentations.IPresentablePart#setFocus()
- */
- public void setFocus() {
- if (!SwtUtil.isDisposed(part.getControl())) {
- if (part.getPage().getActivePart() == part.getPartReference().getPart(false)) {
- part.setFocus();
- } else {
- part.requestActivation();
- }
- }
- }
-
-
- private WorkbenchPartReference getPartReference() {
- return (WorkbenchPartReference) part.getPartReference();
- }
-
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.presentations.IPresentablePart#getName()
- */
- public String getName() {
- if (enableOutputs) {
- return getPartReference().getPartName();
- }
- return name;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.presentations.IPresentablePart#getTitle()
- */
- public String getTitle() {
- return getPartReference().getTitle();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.presentations.IPresentablePart#getTitleStatus()
- */
- public String getTitleStatus() {
- if (enableOutputs) {
- return getPartReference().getContentDescription();
- }
-
- return titleStatus;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.presentations.IPresentablePart#getTitleImage()
- */
- public Image getTitleImage() {
-//
-// return PlatformUI.getWorkbench().getSharedImages().getImage(
-// ISharedImages.IMG_DEF_VIEW);
-//
- if (enableOutputs) {
- return getPartReference().getTitleImage();
- }
-
- return PlatformUI.getWorkbench().getSharedImages().getImage(
- ISharedImages.IMG_DEF_VIEW);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.presentations.IPresentablePart#getTitleToolTip()
- */
- public String getTitleToolTip() {
- return getPartReference().getTitleToolTip();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.presentations.IPresentablePart#isDirty()
- */
- public boolean isDirty() {
- if (enableOutputs) {
- return getPartReference().isDirty();
- }
- return isDirty;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.presentations.IPresentablePart#isBusy()
- */
- public boolean isBusy() {
- if (enableOutputs) {
- return part.isBusy();
- }
- return isBusy;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.presentations.IPresentablePart#getToolBar()
- */
- public Control getToolBar() {
- if (enableOutputs) {
- return getPane().getToolBar();
- }
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.presentations.IPresentablePart#getMenu()
- */
- public IPartMenu getMenu() {
- boolean hasMenu;
-
- if (enableOutputs) {
- hasMenu = part.hasViewMenu();
- } else {
- hasMenu = this.hasViewMenu;
- }
-
- if (!hasMenu) {
- return null;
- }
-
- if (viewMenu == null) {
- viewMenu = new IPartMenu() {
- public void showMenu(Point location) {
- part.showViewMenu(location);
- }
- };
- }
-
- return viewMenu;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.presentations.IPresentablePart#isCloseable()
- */
- public boolean isCloseable() {
- return part.isCloseable();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.presentations.IPresentablePart#getControl()
- */
- public Control getControl() {
- return part.getControl();
- }
-
- public void enableOutputs(boolean isActive) {
- if (isActive == this.enableOutputs) {
- return;
- }
-
- this.enableOutputs = isActive;
-
- if (isActive) {
- if (isBusy != getPane().isBusy()) {
- firePropertyChange(PROP_BUSY);
- }
- if (isDirty != isDirty()) {
- firePropertyChange(PROP_DIRTY);
- }
- if (!name.equals(getName())) {
- firePropertyChange(PROP_PART_NAME);
- }
- if (!titleStatus.equals(getTitleStatus())) {
- firePropertyChange(PROP_CONTENT_DESCRIPTION);
- }
- if (hasViewMenu != getPane().hasViewMenu()) {
- firePropertyChange(PROP_PANE_MENU);
- }
- // Always assume that the toolbar and title has changed (keeping track of this for real
- // would be too expensive)
- firePropertyChange(PROP_TOOLBAR);
- firePropertyChange(PROP_TITLE);
-
- getPane().addPropertyListener(getPropertyListenerProxy());
- } else {
- getPane().removePropertyListener(getPropertyListenerProxy());
-
- WorkbenchPartReference ref = getPartReference();
- isBusy = getPane().isBusy();
- isDirty = ref.isDirty();
- name = ref.getPartName();
- titleStatus = ref.getContentDescription();
- hasViewMenu = getPane().hasViewMenu();
- firePropertyChange(PROP_TITLE);
- firePropertyChange(PROP_TOOLBAR);
- }
- }
-
- public void enableInputs(boolean isActive) {
- if (isActive == this.enableInputs) {
- return;
- }
-
- this.enableInputs = isActive;
-
- if (isActive) {
- if (isActive && !SwtUtil.isDisposed(part.getControl())) {
- part.setBounds(savedBounds);
- }
-
- part.setVisible(isVisible);
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.presentations.IPresentablePart#getPartProperty(java.lang.String)
- */
- public String getPartProperty(String key) {
- return getPartReference().getPartProperty(key);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.ISizeProvider#computePreferredSize(boolean, int, int, int)
- */
- public int computePreferredSize(boolean width, int availableParallel,
- int availablePerpendicular, int preferredResult) {
-
- return getPane().computePreferredSize(width, availableParallel,
- availablePerpendicular, preferredResult);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.ISizeProvider#getSizeFlags(boolean)
- */
- public int getSizeFlags(boolean width) {
- return getPane().getSizeFlags(width);
- }
-
-
-}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/PresentationFactoryUtil.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/PresentationFactoryUtil.java
deleted file mode 100644
index 938c366d52b..00000000000
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/PresentationFactoryUtil.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2005 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.presentations;
-
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.ui.IMemento;
-import org.eclipse.ui.presentations.AbstractPresentationFactory;
-import org.eclipse.ui.presentations.IPresentationSerializer;
-import org.eclipse.ui.presentations.IStackPresentationSite;
-import org.eclipse.ui.presentations.StackPresentation;
-
-/**
- *
- */
-public class PresentationFactoryUtil {
-
- public static final int ROLE_EDITOR = 0x01;
-
- public static final int ROLE_VIEW = 0x02;
-
- public static final int ROLE_STANDALONE = 0x03;
-
- public static final int ROLE_STANDALONE_NOTITLE = 0x04;
-
- public static StackPresentation createPresentation(
- AbstractPresentationFactory factory, int role, Composite parent,
- IStackPresentationSite site, IPresentationSerializer serializer,
- IMemento memento) {
-
- StackPresentation presentation = null;
-
- switch (role) {
- case ROLE_EDITOR:
- presentation = factory.createEditorPresentation(parent, site);
- break;
- case ROLE_STANDALONE:
- presentation = factory.createStandaloneViewPresentation(parent,
- site, true);
- break;
- case ROLE_STANDALONE_NOTITLE:
- presentation = factory.createStandaloneViewPresentation(parent,
- site, false);
- break;
- default:
- presentation = factory.createViewPresentation(parent, site);
- }
-
- //don't initialize editors at creation time - it will not contain any parts
- if (role != ROLE_EDITOR && memento != null && serializer != null) {
- presentation.restoreState(serializer, memento);
- }
-
- return presentation;
- }
-
- private PresentationFactoryUtil() {
-
- }
-}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/PresentationSerializer.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/PresentationSerializer.java
deleted file mode 100644
index aba23e392ab..00000000000
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/PresentationSerializer.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2008 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.presentations;
-
-import java.util.Collections;
-import java.util.List;
-
-import org.eclipse.ui.presentations.IPresentablePart;
-import org.eclipse.ui.presentations.IPresentationSerializer;
-
-/**
- * This class is used to map IPresentableParts onto string IDs
- */
-public class PresentationSerializer implements IPresentationSerializer {
-
- private List parts = Collections.EMPTY_LIST;
-
- public PresentationSerializer(List presentableParts) {
- parts = presentableParts;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.presentations.IPresentationSerializer#getId(org.eclipse.ui.presentations.IPresentablePart)
- */
- public String getId(IPresentablePart part) {
- int index = parts.indexOf(part);
-
- return "" + index; //$NON-NLS-1$
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.presentations.IPresentationSerializer#getPart(java.lang.String)
- */
- public IPresentablePart getPart(String id) {
- try {
- Integer integer = new Integer(id);
- int index = integer.intValue();
-
- if (parts.size()>index) {
- return (IPresentablePart) parts.get(index);
- }
- } catch (NumberFormatException e) {
- }
-
- return null;
- }
-
- /**
- * Prevent this object from being used further. Ensure that none
- * of the methods return anything useful in order to discourage clients
- * from hanging onto references to this object.
- */
- public void dispose() {
- parts = Collections.EMPTY_LIST;
- }
-
-}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/SystemMenuClose.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/SystemMenuClose.java
deleted file mode 100644
index 5cf81961a45..00000000000
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/SystemMenuClose.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2005 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.presentations;
-
-import org.eclipse.jface.action.Action;
-import org.eclipse.ui.internal.WorkbenchMessages;
-import org.eclipse.ui.presentations.IPresentablePart;
-import org.eclipse.ui.presentations.IStackPresentationSite;
-
-/**
- * This convenience class provides a "close" system menu item that closes
- * the currently selected pane in a presentation. Presentations can use
- * this to add a close item to their system menu.
- *
- * @since 3.0
- */
-public final class SystemMenuClose extends Action implements ISelfUpdatingAction {
-
- private IStackPresentationSite site;
- private IPresentablePart part;
-
- public SystemMenuClose(IStackPresentationSite site) {
- this.site = site;
- setText(WorkbenchMessages.PartPane_close);
- }
-
- public void dispose() {
- site = null;
- }
-
- public void run() {
- if (part != null) {
- site.close(new IPresentablePart[] { part });
- }
- }
-
- public void setTarget(IPresentablePart presentablePart) {
- this.part = presentablePart;
- setEnabled(presentablePart != null && site.isCloseable(presentablePart));
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.internal.presentations.ISelfUpdatingAction#update()
- */
- public void update() {
- setTarget(site.getSelectedPart());
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.internal.presentations.ISelfUpdatingAction#shouldBeVisible()
- */
- public boolean shouldBeVisible() {
- return true;
- }
-}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/SystemMenuCloseAll.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/SystemMenuCloseAll.java
deleted file mode 100644
index 817e0da8c4c..00000000000
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/SystemMenuCloseAll.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2005 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.presentations;
-
-import org.eclipse.jface.action.Action;
-import org.eclipse.ui.internal.WorkbenchMessages;
-import org.eclipse.ui.presentations.IPresentablePart;
-import org.eclipse.ui.presentations.IStackPresentationSite;
-
-public class SystemMenuCloseAll extends Action implements ISelfUpdatingAction {
-
- private IStackPresentationSite presentation;
-
- public SystemMenuCloseAll(IStackPresentationSite presentation) {
- this.presentation = presentation;
- setText(WorkbenchMessages.PartPane_closeAll);
- }
-
- public void dispose() {
- presentation = null;
- }
-
- public void run() {
- presentation.close(presentation.getPartList());
- }
-
- public void update() {
- IPresentablePart[] parts = presentation.getPartList();
- setEnabled(parts.length != 0);
- }
-
- public boolean shouldBeVisible() {
- return true;
- }
-
-}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/SystemMenuCloseOthers.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/SystemMenuCloseOthers.java
deleted file mode 100644
index 3e24fc3f778..00000000000
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/SystemMenuCloseOthers.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 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.presentations;
-
-import java.util.Arrays;
-import java.util.LinkedList;
-import java.util.List;
-
-import org.eclipse.jface.action.Action;
-import org.eclipse.ui.internal.WorkbenchMessages;
-import org.eclipse.ui.presentations.IPresentablePart;
-import org.eclipse.ui.presentations.IStackPresentationSite;
-
-public class SystemMenuCloseOthers extends Action implements
- ISelfUpdatingAction {
-
- private IStackPresentationSite stackPresentation;
- private IPresentablePart current;
-
- public SystemMenuCloseOthers(IStackPresentationSite stackPresentation) {
- this.stackPresentation = stackPresentation;
- setText(WorkbenchMessages.PartPane_closeOthers);
- }
-
- public void dispose() {
- stackPresentation = null;
- }
-
- public void run() {
- List others = new LinkedList();
- others.addAll(Arrays.asList(stackPresentation.getPartList()));
- others.remove(current);
- stackPresentation.close((IPresentablePart[]) others
- .toArray(new IPresentablePart[others.size()]));
- }
-
- public void update() {
- setTarget(stackPresentation.getSelectedPart());
- }
-
- public boolean shouldBeVisible() {
- return true;
- }
-
- /**
- * @param currentSelection
- * @since 3.1
- */
- public void setTarget(IPresentablePart current) {
- this.current = current;
- setEnabled(current != null &&
- stackPresentation.getPartList().length > 1);
- }
-}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/SystemMenuDetach.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/SystemMenuDetach.java
deleted file mode 100644
index 1991689b836..00000000000
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/SystemMenuDetach.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 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.presentations;
-
-import org.eclipse.jface.action.Action;
-import org.eclipse.ui.internal.ViewPane;
-import org.eclipse.ui.internal.WorkbenchMessages;
-import org.eclipse.ui.internal.WorkbenchPage;
-import org.eclipse.ui.presentations.IPresentablePart;
-import org.eclipse.ui.presentations.IStackPresentationSite;
-
-public class SystemMenuDetach extends Action implements ISelfUpdatingAction {
-
- private ViewPane viewPane;
- private IStackPresentationSite site;
- private WorkbenchPage page;
-
- public SystemMenuDetach(IStackPresentationSite site) {
- this.site = site;
- setText(WorkbenchMessages.PartPane_detach);
- update();
- }
-
- public void update() {
- IPresentablePart presentablePart = site.getSelectedPart();
- setEnabled(presentablePart != null && site.isPartMoveable(presentablePart));
- if(viewPane != null){
- setChecked(!viewPane.isDocked());
- page = viewPane.getPage();
- }
- }
-
- public boolean shouldBeVisible() {
- if(page != null) {
- return page.getActivePerspective().getPresentation().canDetach();
- }
- return false;
- }
-
- public void dispose() {
- site = null;
- }
-
- public void setPane(ViewPane current){
- viewPane = current;
- update();
- }
-
- public void run() {
- if(site != null){
- if(!isChecked()){
- viewPane.doDetach();
- }
- else{
- viewPane.doAttach();
- }
- }
- }
-
-}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/SystemMenuFastView.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/SystemMenuFastView.java
deleted file mode 100644
index 31455436e54..00000000000
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/SystemMenuFastView.java
+++ /dev/null
@@ -1,129 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2007 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.presentations;
-
-import org.eclipse.jface.action.Action;
-import org.eclipse.ui.IViewReference;
-import org.eclipse.ui.IWorkbenchPartReference;
-import org.eclipse.ui.internal.FastViewBar;
-import org.eclipse.ui.internal.FastViewManager;
-import org.eclipse.ui.internal.Perspective;
-import org.eclipse.ui.internal.ViewPane;
-import org.eclipse.ui.internal.WorkbenchMessages;
-import org.eclipse.ui.internal.WorkbenchWindow;
-import org.eclipse.ui.presentations.IStackPresentationSite;
-
-public class SystemMenuFastView extends Action implements ISelfUpdatingAction {
-
- private PresentablePart viewPane;
-
- private IStackPresentationSite site;
-
- private boolean realFV = true;
-
- public SystemMenuFastView(IStackPresentationSite site) {
- this.site = site;
- setText(WorkbenchMessages.ViewPane_fastView);
- update();
- }
-
- public void setPane(PresentablePart newPane) {
- viewPane = newPane;
- update();
- }
-
- public void update() {
- IViewReference viewRef = getReference();
- if (viewRef == null) {
- setEnabled(false);
- return;
- }
-
- // Are we showing a 'real' fast view or a minimized view ?
- Perspective persp = viewPane.getPane().getPage().getActivePerspective();
- FastViewManager fvm = persp.getFastViewManager();
-
- String trimId = null;
- if (fvm != null)
- trimId = fvm.getIdForRef(viewRef);
- realFV = trimId == null || FastViewBar.FASTVIEWBAR_ID.equals(trimId);
-
- // it's 'restore' if we're not using a real fast view
- if (realFV) {
- setText(WorkbenchMessages.ViewPane_fastView);
- }
- else {
- setText(WorkbenchMessages.StandardSystemToolbar_Restore);
- setChecked(false);
- }
-
- if (!site.isPartMoveable(viewPane)) {
- setEnabled(false);
- } else {
- setEnabled(true);
-
- if (realFV)
- setChecked(persp.isFastView(viewRef));
- }
- }
-
- private IViewReference getReference() {
- IViewReference viewRef = null;
-
- if (viewPane != null) {
- IWorkbenchPartReference ref = viewPane.getPane().getPartReference();
-
- if (ref instanceof IViewReference) {
- viewRef = (IViewReference) ref;
- }
- }
- return viewRef;
- }
-
- public boolean shouldBeVisible() {
- if (viewPane == null || viewPane.getPane().getPage() == null) {
- return false;
- }
-
- WorkbenchWindow workbenchWindow = (WorkbenchWindow) viewPane.getPane().getPage()
- .getWorkbenchWindow();
-
- return workbenchWindow.getShowFastViewBars() && viewPane != null
- && site.isPartMoveable(viewPane);
- }
-
- public void dispose() {
- viewPane = null;
- }
-
- public void run() {
- if (realFV) {
- if (viewPane.getPane() instanceof ViewPane) {
- ViewPane pane = (ViewPane) viewPane.getPane();
-
- if (!isChecked()) {
- pane.doMakeFast();
- } else {
- pane.doRemoveFast();
- }
- }
- }
- else {
- // We're a minimized stack...restore it
- IViewReference viewRef = getReference();
-
- Perspective persp = viewPane.getPane().getPage().getActivePerspective();
- FastViewManager fvm = persp.getFastViewManager();
- String trimId = fvm.getIdForRef(viewRef);
- fvm.restoreToPresentation(trimId);
- }
- }
-}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/SystemMenuFastViewOrientation.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/SystemMenuFastViewOrientation.java
deleted file mode 100644
index 62ed3310a48..00000000000
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/SystemMenuFastViewOrientation.java
+++ /dev/null
@@ -1,120 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2007 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.presentations;
-
-import org.eclipse.jface.action.ContributionItem;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Menu;
-import org.eclipse.swt.widgets.MenuItem;
-import org.eclipse.ui.IViewReference;
-import org.eclipse.ui.IWorkbenchPartReference;
-import org.eclipse.ui.internal.FastViewBar;
-import org.eclipse.ui.internal.IChangeListener;
-import org.eclipse.ui.internal.IntModel;
-import org.eclipse.ui.internal.PartPane;
-import org.eclipse.ui.internal.RadioMenu;
-import org.eclipse.ui.internal.ViewStackTrimToolBar;
-import org.eclipse.ui.internal.WorkbenchMessages;
-import org.eclipse.ui.internal.WorkbenchWindow;
-
-/**
- * @since 3.0
- */
-public class SystemMenuFastViewOrientation extends ContributionItem {
-
- private PartPane viewPane;
-
- private IntModel currentOrientation = new IntModel(SWT.VERTICAL);
-
- private ViewStackTrimToolBar minimizedStack = null;
-
- public SystemMenuFastViewOrientation(PartPane newViewPane) {
- this(newViewPane, null);
- }
-
- /**
- * @param pane
- * @param vstt
- */
- public SystemMenuFastViewOrientation(PartPane newViewPane,
- final ViewStackTrimToolBar vstt) {
- this.viewPane = newViewPane;
- this.minimizedStack = vstt;
-
- currentOrientation.addChangeListener(new IChangeListener() {
- public void update(boolean changed) {
- if (changed) {
- WorkbenchWindow workbenchWindow = (WorkbenchWindow) viewPane
- .getPage().getWorkbenchWindow();
-
- if (vstt == null) {
- FastViewBar bar = workbenchWindow.getFastViewBar();
- if (bar != null && viewPane != null) {
- IWorkbenchPartReference ref = viewPane.getPartReference();
-
- if (ref instanceof IViewReference) {
- bar.setOrientation((IViewReference)ref,
- currentOrientation.get());
- }
- }
- }
- else {
- vstt.setOrientation(currentOrientation.get(), workbenchWindow);
- }
- }
- }
- });
- }
-
- public void dispose() {
- viewPane = null;
- }
-
- public void fill(Menu menu, int index) {
- WorkbenchWindow workbenchWindow = (WorkbenchWindow) viewPane.getPage()
- .getWorkbenchWindow();
-
- IWorkbenchPartReference ref = viewPane.getPartReference();
- if (!(ref instanceof IViewReference))
- return;
-
- if (minimizedStack == null) {
- FastViewBar bar = workbenchWindow.getFastViewBar();
- if (bar != null && viewPane != null) {
- currentOrientation.set(bar.getOrientation((IViewReference)ref));
- }
- }
- else {
- currentOrientation.set(minimizedStack.getPaneOrientation());
- }
-
- MenuItem orientationItem = new MenuItem(menu, SWT.CASCADE, index);
- {
- orientationItem.setText(WorkbenchMessages.FastViewBar_view_orientation);
-
- Menu orientationSwtMenu = new Menu(orientationItem);
- RadioMenu orientationMenu = new RadioMenu(orientationSwtMenu,
- currentOrientation);
- orientationMenu
- .addMenuItem(
- WorkbenchMessages.FastViewBar_horizontal, new Integer(SWT.HORIZONTAL));
- orientationMenu
- .addMenuItem(
- WorkbenchMessages.FastViewBar_vertical, new Integer(SWT.VERTICAL));
-
- orientationItem.setMenu(orientationSwtMenu);
- }
- }
-
- public boolean isDynamic() {
- return true;
- }
-}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/SystemMenuMaximize.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/SystemMenuMaximize.java
deleted file mode 100644
index dab320d1b14..00000000000
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/SystemMenuMaximize.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2005 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.presentations;
-
-import org.eclipse.ui.internal.WorkbenchMessages;
-import org.eclipse.ui.presentations.IStackPresentationSite;
-
-public class SystemMenuMaximize extends SystemMenuStateChange {
-
- /**
- * @param site
- * @param name
- * @param state
- */
- public SystemMenuMaximize(IStackPresentationSite site) {
- super(site, WorkbenchMessages.PartPane_maximize,
- IStackPresentationSite.STATE_MAXIMIZED);
- }
-
-}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/SystemMenuMinimize.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/SystemMenuMinimize.java
deleted file mode 100644
index 37b86ed669b..00000000000
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/SystemMenuMinimize.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2005 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.presentations;
-
-import org.eclipse.ui.internal.WorkbenchMessages;
-import org.eclipse.ui.presentations.IStackPresentationSite;
-
-public class SystemMenuMinimize extends SystemMenuStateChange {
-
- /**
- * @param site
- * @param name
- * @param state
- */
- public SystemMenuMinimize(IStackPresentationSite site) {
- super(site, WorkbenchMessages.ViewPane_minimizeView,
- IStackPresentationSite.STATE_MINIMIZED);
- }
-
-}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/SystemMenuMove.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/SystemMenuMove.java
deleted file mode 100644
index 5a1e6533c08..00000000000
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/SystemMenuMove.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2005 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.presentations;
-
-import org.eclipse.jface.action.MenuManager;
-import org.eclipse.ui.internal.WorkbenchMessages;
-import org.eclipse.ui.presentations.IPresentablePart;
-import org.eclipse.ui.presentations.IStackPresentationSite;
-
-public class SystemMenuMove extends MenuManager {
-
- private IStackPresentationSite stackPresentationSite;
-
- private SystemMenuMovePane movePaneAction;
-
- private SystemMenuMoveFolder moveFolderAction;
- private boolean assumeActivePart = false;
-
- public SystemMenuMove(IStackPresentationSite stackPresentationSite,
- String partName) {
- this(stackPresentationSite, partName, true);
- }
-
- public SystemMenuMove(IStackPresentationSite stackPresentationSite,
- String partName, boolean assumeActivePart) {
- super(WorkbenchMessages.PartPane_move);
- this.stackPresentationSite = stackPresentationSite;
- this.assumeActivePart = assumeActivePart;
-
- movePaneAction = new SystemMenuMovePane(stackPresentationSite);
- movePaneAction.setText(partName);
- moveFolderAction = new SystemMenuMoveFolder(stackPresentationSite);
-
- add(movePaneAction);
- add(moveFolderAction);
- }
-
- public void setTarget(IPresentablePart part) {
- movePaneAction.setTarget(part);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.action.MenuManager#update(boolean, boolean)
- */
- protected void update(boolean force, boolean recursive) {
- if (assumeActivePart) {
- setTarget(stackPresentationSite.getSelectedPart());
- }
-
- moveFolderAction.update();
-
- super.update(force, recursive);
- }
-
- public void update() {
- update(false, false);
- }
-}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/SystemMenuMoveFolder.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/SystemMenuMoveFolder.java
deleted file mode 100644
index 6f7a91fcdd7..00000000000
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/SystemMenuMoveFolder.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2005 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.presentations;
-
-import org.eclipse.jface.action.Action;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.internal.WorkbenchMessages;
-import org.eclipse.ui.presentations.IStackPresentationSite;
-
-/**
- * @since 3.0
- */
-public class SystemMenuMoveFolder extends Action implements ISelfUpdatingAction {
- private IStackPresentationSite site;
-
- public SystemMenuMoveFolder(IStackPresentationSite site) {
- this.site = site;
- setText(WorkbenchMessages.ViewPane_moveFolder);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.action.IAction#run()
- */
- public void run() {
- site.dragStart(Display.getDefault().getCursorLocation(), true);
- }
-
- public void update() {
- setEnabled(site.isStackMoveable());
- }
-
- public boolean shouldBeVisible() {
- return site.isStackMoveable();
- }
-}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/SystemMenuMovePane.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/SystemMenuMovePane.java
deleted file mode 100644
index c363ecb5f3f..00000000000
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/SystemMenuMovePane.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2005 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.presentations;
-
-import org.eclipse.jface.action.Action;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.internal.WorkbenchMessages;
-import org.eclipse.ui.presentations.IPresentablePart;
-import org.eclipse.ui.presentations.IStackPresentationSite;
-
-/**
- * @since 3.0
- */
-public class SystemMenuMovePane extends Action {
-
- IStackPresentationSite site;
- IPresentablePart part;
-
- public SystemMenuMovePane(IStackPresentationSite site) {
- this.site = site;
- setText(WorkbenchMessages.SystemMenuMovePane_PaneName);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.action.IAction#run()
- */
- public void run() {
- site.dragStart(part, Display.getDefault().getCursorLocation(), true);
- }
-
- public void setTarget(IPresentablePart part) {
- this.part = part;
- setEnabled(part != null && site.isPartMoveable(part));
- }
-
-}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/SystemMenuPinEditor.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/SystemMenuPinEditor.java
deleted file mode 100644
index 07b17a3313a..00000000000
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/SystemMenuPinEditor.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2007 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.presentations;
-
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.ui.internal.EditorPane;
-import org.eclipse.ui.internal.IPreferenceConstants;
-import org.eclipse.ui.internal.WorkbenchMessages;
-import org.eclipse.ui.internal.WorkbenchPartReference;
-import org.eclipse.ui.internal.WorkbenchPlugin;
-import org.eclipse.ui.internal.tweaklets.TabBehaviour;
-import org.eclipse.ui.internal.tweaklets.Tweaklets;
-
-public class SystemMenuPinEditor extends Action implements ISelfUpdatingAction {
-
- private EditorPane editorPane;
-
- public SystemMenuPinEditor(EditorPane pane) {
- setText(WorkbenchMessages.EditorPane_pinEditor);
- setPane(pane);
- }
-
- public void dispose() {
- editorPane = null;
- }
-
- public void setPane(EditorPane pane) {
- editorPane = pane;
- update();
- }
-
- public void run() {
- WorkbenchPartReference ref = (WorkbenchPartReference)editorPane.getPartReference();
-
- ref.setPinned(!isChecked());
- }
-
- public void update() {
- if (editorPane == null) {
- setEnabled(false);
- return;
- }
-
- WorkbenchPartReference ref = (WorkbenchPartReference)editorPane.getPartReference();
- setEnabled(true);
- setChecked(ref.isPinned());
- }
-
- public boolean shouldBeVisible() {
- if (editorPane == null) {
- return false;
- }
-
- IPreferenceStore store = WorkbenchPlugin.getDefault().getPreferenceStore();
- boolean reuseEditor = store
- .getBoolean(IPreferenceConstants.REUSE_EDITORS_BOOLEAN)
- | ((TabBehaviour)Tweaklets.get(TabBehaviour.KEY)).alwaysShowPinAction();
- return reuseEditor;
- }
-
-}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/SystemMenuRestore.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/SystemMenuRestore.java
deleted file mode 100644
index ed3552c5e7c..00000000000
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/SystemMenuRestore.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2005 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.presentations;
-
-import org.eclipse.ui.internal.WorkbenchMessages;
-import org.eclipse.ui.presentations.IStackPresentationSite;
-
-public class SystemMenuRestore extends SystemMenuStateChange {
-
- /**
- * @param site
- * @param name
- * @param state
- */
- public SystemMenuRestore(IStackPresentationSite site) {
- super(site, WorkbenchMessages.PartPane_restore, IStackPresentationSite.STATE_RESTORED);
- }
-}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/SystemMenuSize.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/SystemMenuSize.java
deleted file mode 100644
index d7d362d98b8..00000000000
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/SystemMenuSize.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 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.presentations;
-
-import org.eclipse.jface.action.ContributionItem;
-import org.eclipse.swt.widgets.Menu;
-import org.eclipse.ui.internal.PartPane;
-
-public class SystemMenuSize extends ContributionItem {
-
- private PartPane partPane;
-
- public SystemMenuSize(PartPane pane) {
- setPane(pane);
- }
-
- public void setPane(PartPane pane) {
- partPane = pane;
- }
-
- public void dispose() {
- partPane = null;
- }
-
- public void fill(Menu menu, int index) {
- if (partPane != null) {
- partPane.addSizeMenuItem(menu, index);
- }
- }
-
- public boolean isDynamic() {
- return true;
- }
-}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/SystemMenuSizeFastView.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/SystemMenuSizeFastView.java
deleted file mode 100644
index 2ddc0a5947a..00000000000
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/SystemMenuSizeFastView.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2005 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.presentations;
-
-import org.eclipse.jface.action.ContributionItem;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.widgets.Menu;
-import org.eclipse.swt.widgets.MenuItem;
-import org.eclipse.ui.internal.FastViewPane;
-import org.eclipse.ui.internal.WorkbenchMessages;
-
-public class SystemMenuSizeFastView extends ContributionItem {
-
- private FastViewPane fastViewPane;
-
- public SystemMenuSizeFastView(FastViewPane fastViewPane) {
- this.fastViewPane = fastViewPane;
- }
-
- public void dispose() {
- fastViewPane = null;
- }
-
- public void fill(Menu menu, int index) {
- MenuItem item = new MenuItem(menu, SWT.NONE, index);
- item.setText(WorkbenchMessages.PartPane_size);
- item.addSelectionListener(new SelectionAdapter() {
-
- public void widgetSelected(SelectionEvent e) {
- fastViewPane.moveSash();
- }
- });
- item.setEnabled(fastViewPane.getCurrentPane() != null);
- }
-
- public boolean isDynamic() {
- return true;
- }
-}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/SystemMenuStateChange.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/SystemMenuStateChange.java
deleted file mode 100644
index 425fea0afd7..00000000000
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/SystemMenuStateChange.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 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.presentations;
-
-import org.eclipse.jface.action.Action;
-import org.eclipse.ui.presentations.IStackPresentationSite;
-
-/**
- *
- *
- * @since 3.0
- */
-public class SystemMenuStateChange extends Action implements
- ISelfUpdatingAction {
- private IStackPresentationSite site;
-
- private int state;
-
- public SystemMenuStateChange(IStackPresentationSite site, String name,
- int state) {
- this.site = site;
- this.state = state;
-
- setText(name);
- update();
- }
-
- public void dispose() {
- this.site = null;
- }
-
- public void run() {
- site.setState(state);
- }
-
- public void update() {
- setEnabled(site.getState() != state && site.supportsState(state));
- }
-
- public boolean shouldBeVisible() {
- return site.supportsState(state);
- }
-
-}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/UpdatingActionContributionItem.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/UpdatingActionContributionItem.java
deleted file mode 100644
index 8cfc1871fb4..00000000000
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/UpdatingActionContributionItem.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 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.presentations;
-
-import org.eclipse.jface.action.ActionContributionItem;
-
-/**
- * @since 3.0
- */
-public class UpdatingActionContributionItem extends ActionContributionItem {
-
- /**
- * @param action
- */
- public UpdatingActionContributionItem(ISelfUpdatingAction action) {
- super(action);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.action.IContributionItem#isVisible()
- */
- public boolean isVisible() {
- ISelfUpdatingAction action = (ISelfUpdatingAction) getAction();
- return super.isVisible() && action.shouldBeVisible();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.action.IContributionItem#update(java.lang.String)
- */
- public void update(String propertyName) {
- ISelfUpdatingAction action = (ISelfUpdatingAction) getAction();
- action.update();
-
- super.update(propertyName);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.action.IContributionItem#isDynamic()
- */
- public boolean isDynamic() {
- return true;
- }
-}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/classic/WorkbenchPresentationFactoryClassic.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/classic/WorkbenchPresentationFactoryClassic.java
deleted file mode 100644
index 35c3db5dc07..00000000000
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/classic/WorkbenchPresentationFactoryClassic.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 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.presentations.classic;
-
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.ui.IWorkbenchPreferenceConstants;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.internal.presentations.defaultpresentation.DefaultSimpleTabListener;
-import org.eclipse.ui.internal.presentations.defaultpresentation.DefaultTabFolder;
-import org.eclipse.ui.internal.presentations.defaultpresentation.DefaultThemeListener;
-import org.eclipse.ui.internal.presentations.util.PresentablePartFolder;
-import org.eclipse.ui.internal.presentations.util.StandardViewSystemMenu;
-import org.eclipse.ui.internal.presentations.util.TabbedStackPresentation;
-import org.eclipse.ui.presentations.IStackPresentationSite;
-import org.eclipse.ui.presentations.StackPresentation;
-import org.eclipse.ui.presentations.WorkbenchPresentationFactory;
-
-/**
- * The classic presentation factory for the Workbench (the 3.0 look).
- *
- * @since 3.4
- *
- */
-public class WorkbenchPresentationFactoryClassic extends
- WorkbenchPresentationFactory {
-
- private static int viewTabPosition = PlatformUI.getPreferenceStore()
- .getInt(IWorkbenchPreferenceConstants.VIEW_TAB_POSITION);
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.presentations.WorkbenchPresentationFactory#createViewPresentation(org.eclipse.swt.widgets.Composite,
- * org.eclipse.ui.presentations.IStackPresentationSite)
- */
- public StackPresentation createViewPresentation(Composite parent,
- IStackPresentationSite site) {
-
- DefaultTabFolder folder = new DefaultTabFolder(parent, viewTabPosition
- | SWT.BORDER, site
- .supportsState(IStackPresentationSite.STATE_MINIMIZED), site
- .supportsState(IStackPresentationSite.STATE_MAXIMIZED));
-
- final IPreferenceStore store = PlatformUI.getPreferenceStore();
- final int minimumCharacters = store
- .getInt(IWorkbenchPreferenceConstants.VIEW_MINIMUM_CHARACTERS);
- if (minimumCharacters >= 0) {
- folder.setMinimumCharacters(minimumCharacters);
- }
-
- PresentablePartFolder partFolder = new PresentablePartFolder(folder);
-
- folder.setUnselectedCloseVisible(false);
- folder.setUnselectedImageVisible(false);
-
- TabbedStackPresentation result = new TabbedStackPresentation(site,
- partFolder, new StandardViewSystemMenu(site));
-
- DefaultThemeListener themeListener = new DefaultThemeListener(folder,
- result.getTheme());
- result.getTheme().addListener(themeListener);
-
- new DefaultSimpleTabListener(result.getApiPreferences(),
- IWorkbenchPreferenceConstants.SHOW_TRADITIONAL_STYLE_TABS,
- folder);
-
- return result;
- }
-}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/defaultpresentation/DefaultMultiTabListener.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/defaultpresentation/DefaultMultiTabListener.java
deleted file mode 100644
index 397b5a9cb66..00000000000
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/defaultpresentation/DefaultMultiTabListener.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 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.presentations.defaultpresentation;
-
-import org.eclipse.ui.internal.preferences.AbstractBooleanListener;
-import org.eclipse.ui.internal.preferences.IDynamicPropertyMap;
-
-/**
- * @since 3.1
- */
-public final class DefaultMultiTabListener extends AbstractBooleanListener {
-
- private DefaultTabFolder folder;
-
- /**
- * @param map
- * @param propertyId
- * @param defaultValue
- */
- public DefaultMultiTabListener(IDynamicPropertyMap map, String propertyId, DefaultTabFolder folder) {
- super();
-
- this.folder = folder;
-
- attach(map, propertyId, true);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.internal.preferences.AbstractBooleanListener#handleValue(boolean)
- */
- protected void handleValue(boolean b) {
- folder.setSingleTab(!b);
- }
-
-}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/defaultpresentation/DefaultPartList.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/defaultpresentation/DefaultPartList.java
deleted file mode 100644
index 997d6e798cd..00000000000
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/defaultpresentation/DefaultPartList.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2011 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.presentations.defaultpresentation;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.Listener;
-import org.eclipse.swt.widgets.Monitor;
-import org.eclipse.ui.internal.presentations.BasicPartList;
-import org.eclipse.ui.internal.presentations.util.ISystemMenu;
-import org.eclipse.ui.internal.presentations.util.PresentablePartFolder;
-import org.eclipse.ui.presentations.IPresentablePart;
-import org.eclipse.ui.presentations.IStackPresentationSite;
-
-/**
- * @since 3.1
- */
-public class DefaultPartList implements ISystemMenu {
-
- private IStackPresentationSite site;
- private PresentablePartFolder folder;
-
- public DefaultPartList(IStackPresentationSite site, PresentablePartFolder folder) {
- this.site = site;
- this.folder = folder;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.internal.presentations.util.ISystemMenu#show(org.eclipse.swt.widgets.Control, org.eclipse.swt.graphics.Point, org.eclipse.ui.presentations.IPresentablePart)
- */
- public void show(Control control, Point displayCoordinates,
- IPresentablePart currentSelection) {
-
- int shellStyle = SWT.RESIZE | SWT.ON_TOP | SWT.NO_TRIM;
- int tableStyle = SWT.V_SCROLL | SWT.H_SCROLL;
- final BasicPartList editorList = new BasicPartList(control.getShell(),
- shellStyle, tableStyle, site, folder);
- editorList.setInput(folder);
- Point size = editorList.computeSizeHint();
- int x = displayCoordinates.x;
- int y = displayCoordinates.y;
-
- Monitor mon = folder.getTabFolder().getControl().getMonitor();
- Rectangle bounds = mon.getClientArea();
- if (x + size.x > bounds.x + bounds.width) {
- x = bounds.x + bounds.width - size.x;
- }
- if (y + size.y > bounds.y + bounds.height) {
- y = bounds.y + bounds.height - size.y;
- }
- editorList.setLocation(new Point(x, y));
- editorList.setVisible(true);
- editorList.setFocus();
- editorList.getTableViewer().getTable().getShell().addListener(
- SWT.Deactivate, new Listener() {
-
- public void handleEvent(Event event) {
- editorList.setVisible(false);
- }
- }
- );
- }
-
- public void dispose() {
-
- }
-
-}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/defaultpresentation/DefaultSimpleTabListener.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/defaultpresentation/DefaultSimpleTabListener.java
deleted file mode 100644
index ba4c8e08e83..00000000000
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/defaultpresentation/DefaultSimpleTabListener.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 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.presentations.defaultpresentation;
-
-import org.eclipse.ui.internal.preferences.AbstractBooleanListener;
-import org.eclipse.ui.internal.preferences.IDynamicPropertyMap;
-
-/**
- * @since 3.1
- */
-public final class DefaultSimpleTabListener extends AbstractBooleanListener {
-
- private DefaultTabFolder folder;
-
- /**
- * @param map
- * @param propertyId
- * @param defaultValue
- */
- public DefaultSimpleTabListener(IDynamicPropertyMap map, String propertyId, DefaultTabFolder folder) {
- super();
-
- this.folder = folder;
-
- attach(map, propertyId, true);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.internal.preferences.AbstractBooleanListener#handleValue(boolean)
- */
- protected void handleValue(boolean b) {
- folder.setSimpleTabs(b);
- }
-
-}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/defaultpresentation/DefaultTabFolder.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/defaultpresentation/DefaultTabFolder.java
deleted file mode 100644
index 1ea14e8dde8..00000000000
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/defaultpresentation/DefaultTabFolder.java
+++ /dev/null
@@ -1,544 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2009 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
- * Remy Chi Jian Suen <remy.suen@gmail.com> - Bug 145557 [WorkbenchParts] Content description label needs a hover
- * Semion Chichelnitsky <semion@il.ibm.com> - Bug 66889 [ViewMgmt] Package explorer message clipped
- *******************************************************************************/
-package org.eclipse.ui.internal.presentations.defaultpresentation;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.jface.util.Geometry;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.accessibility.AccessibleAdapter;
-import org.eclipse.swt.accessibility.AccessibleEvent;
-import org.eclipse.swt.custom.CTabFolder;
-import org.eclipse.swt.custom.CTabFolderEvent;
-import org.eclipse.swt.custom.CTabItem;
-import org.eclipse.swt.events.MouseAdapter;
-import org.eclipse.swt.events.MouseEvent;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.graphics.Font;
-import org.eclipse.swt.graphics.GC;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Listener;
-import org.eclipse.swt.widgets.ToolBar;
-import org.eclipse.swt.widgets.ToolItem;
-import org.eclipse.ui.internal.IWorkbenchGraphicConstants;
-import org.eclipse.ui.internal.WorkbenchImages;
-import org.eclipse.ui.internal.WorkbenchMessages;
-import org.eclipse.ui.internal.dnd.DragUtil;
-import org.eclipse.ui.internal.presentations.PaneFolder;
-import org.eclipse.ui.internal.presentations.PaneFolderButtonListener;
-import org.eclipse.ui.internal.presentations.util.AbstractTabFolder;
-import org.eclipse.ui.internal.presentations.util.AbstractTabItem;
-import org.eclipse.ui.internal.presentations.util.PartInfo;
-import org.eclipse.ui.internal.presentations.util.TabFolderEvent;
-import org.eclipse.ui.internal.util.Util;
-
-/**
- * @since 3.1
- */
-public class DefaultTabFolder extends AbstractTabFolder {
-
- private PaneFolder paneFolder;
- private Control viewToolBar;
- private Label titleLabel;
-
- private PaneFolderButtonListener buttonListener = new PaneFolderButtonListener() {
- public void stateButtonPressed(int buttonId) {
- fireEvent(TabFolderEvent.stackStateToEventId(buttonId));
- }
-
- /**
- * Called when a close button is pressed.
- *
- * @param item the tab whose close button was pressed
- */
- public void closeButtonPressed(CTabItem item) {
- fireEvent(TabFolderEvent.EVENT_CLOSE, getTab(item));
- }
- /**
- *
- * @since 3.0
- */
- public void showList(CTabFolderEvent event) {
- event.doit = false;
- fireEvent(TabFolderEvent.EVENT_SHOW_LIST);
- }
- };
-
- private Listener selectionListener = new Listener() {
- public void handleEvent(Event e) {
- AbstractTabItem item = getTab((CTabItem) e.item);
-
- if (item != null) {
- fireEvent(TabFolderEvent.EVENT_TAB_SELECTED, item);
- }
- }
- };
-
- private static DefaultTabFolderColors defaultColors = new DefaultTabFolderColors();
-
- private DefaultTabFolderColors[] activeShellColors = {defaultColors, defaultColors, defaultColors};
- private DefaultTabFolderColors[] inactiveShellColors = {defaultColors, defaultColors, defaultColors};
- private boolean shellActive = false;
-
- /**
- * Create a new instance of the receiver
- *
- * @param parent
- * @param flags
- * @param allowMin
- * @param allowMax
- */
- public DefaultTabFolder(Composite parent, int flags, boolean allowMin, boolean allowMax) {
- paneFolder = new PaneFolder(parent, flags | SWT.NO_BACKGROUND);
- paneFolder.addButtonListener(buttonListener);
- paneFolder.setMinimizeVisible(allowMin);
- paneFolder.setMaximizeVisible(allowMax);
- paneFolder.getControl().addListener(SWT.Selection, selectionListener);
- paneFolder.setTopRight(null);
-
- // Initialize view menu dropdown
- {
- ToolBar actualToolBar = new ToolBar(paneFolder.getControl(), SWT.FLAT | SWT.NO_BACKGROUND);
- viewToolBar = actualToolBar;
-
- actualToolBar.getAccessible().addAccessibleListener(new AccessibleAdapter() {
- public void getName(AccessibleEvent e) {
- e.result = WorkbenchMessages.ViewMenu;
- }
- });
-
- ToolItem pullDownButton = new ToolItem(actualToolBar, SWT.PUSH);
- Image hoverImage = WorkbenchImages
- .getImage(IWorkbenchGraphicConstants.IMG_LCL_RENDERED_VIEW_MENU);
- pullDownButton.setDisabledImage(hoverImage);
- pullDownButton.setImage(hoverImage);
- pullDownButton.setToolTipText(WorkbenchMessages.ViewMenu);
- actualToolBar.addMouseListener(new MouseAdapter() {
- public void mouseDown(MouseEvent e) {
- fireEvent(TabFolderEvent.EVENT_PANE_MENU, getSelection(), getPaneMenuLocation());
- }
- });
- pullDownButton.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- fireEvent(TabFolderEvent.EVENT_PANE_MENU, getSelection(), getPaneMenuLocation());
-
- super.widgetSelected(e);
- }
- });
- }
-
- // Initialize content description label
- {
- titleLabel = new Label(paneFolder.getControl(), SWT.NONE);
- titleLabel.moveAbove(null);
- titleLabel.setVisible(false);
- attachListeners(titleLabel, false);
- }
-
- attachListeners(paneFolder.getControl(), false);
- attachListeners(paneFolder.getViewForm(), false);
-
- paneFolder.setTabHeight(computeTabHeight());
-
- viewToolBar.moveAbove(null);
- }
-
- /**
- * Changes the minimum number of characters to display in the pane folder
- * tab. This control how much information will be displayed to the user.
- *
- * @param count
- * The number of characters to display in the tab folder; this
- * value should be a positive integer.
- * @see org.eclipse.swt.custom.CTabFolder#setMinimumCharacters(int)
- * @since 3.1
- */
- public void setMinimumCharacters(int count) {
- paneFolder.setMinimumCharacters(count);
- }
-
- public void setSimpleTabs(boolean simple) {
- paneFolder.setSimpleTab(simple);
- }
-
- /**
- * @param item
- * @return
- * @since 3.1
- */
- protected DefaultTabItem getTab(CTabItem item) {
- return (DefaultTabItem)item.getData();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.internal.presentations.util.AbstractTabFolder#computeSize(int, int)
- */
- public Point computeSize(int widthHint, int heightHint) {
- return paneFolder.computeMinimumSize();
- }
-
- /* package */ PaneFolder getFolder() {
- return paneFolder;
- }
-
- public AbstractTabItem getSelection() {
- return getTab(paneFolder.getSelection());
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.internal.presentations.util.AbstractTabFolder#add(int)
- */
- public AbstractTabItem add(int index, int flags) {
- DefaultTabItem result = new DefaultTabItem((CTabFolder)getFolder().getControl(), index, flags);
-
- result.getWidget().setData(result);
-
- return result;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.internal.presentations.util.AbstractTabFolder#getContentParent()
- */
- public Composite getContentParent() {
- return paneFolder.getContentParent();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.internal.presentations.util.AbstractTabFolder#setContent(org.eclipse.swt.widgets.Control)
- */
- public void setContent(Control newContent) {
- paneFolder.setContent(newContent);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.internal.presentations.util.AbstractTabFolder#getItems()
- */
- public AbstractTabItem[] getItems() {
- CTabItem[] items = paneFolder.getItems();
-
- AbstractTabItem[] result = new AbstractTabItem[items.length];
-
- for (int i = 0; i < result.length; i++) {
- result[i] = getTab(items[i]);
- }
-
- return result;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.internal.presentations.util.AbstractTabFolder#getItemCount()
- */
- public int getItemCount() {
- // Override retrieving all the items when we just want the count.
- return paneFolder.getItemCount();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.internal.presentations.util.AbstractTabFolder#setSelection(org.eclipse.ui.internal.presentations.util.AbstractTabItem)
- */
- public void setSelection(AbstractTabItem toSelect) {
- paneFolder.setSelection(indexOf(toSelect));
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.eclipse.ui.internal.presentations.util.AbstractTabFolder#showItem
- * (org.eclipse.ui.internal.presentations.util.AbstractTabItem)
- */
- public void showItem(AbstractTabItem toSelect) {
- // overrides default
- int index = indexOf(toSelect);
- if (index != -1)
- paneFolder.showItem(index);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.internal.presentations.util.AbstractTabFolder#getToolbarParent()
- */
- public Composite getToolbarParent() {
- return paneFolder.getControl();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.internal.presentations.util.AbstractTabFolder#getControl()
- */
- public Control getControl() {
- return paneFolder.getControl();
- }
-
- public void setUnselectedCloseVisible(boolean visible) {
- paneFolder.setUnselectedCloseVisible(visible);
- }
-
- public void setUnselectedImageVisible(boolean visible) {
- paneFolder.setUnselectedImageVisible(visible);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.internal.presentations.util.AbstractTabFolder#getTabArea()
- */
- public Rectangle getTabArea() {
- return Geometry.toDisplay(paneFolder.getControl(), paneFolder.getTitleArea());
- }
-
- /**
- * @param enabled
- * @since 3.1
- */
- public void enablePaneMenu(boolean enabled) {
- if (enabled) {
- paneFolder.setTopRight(viewToolBar);
- viewToolBar.setVisible(true);
- } else {
- paneFolder.setTopRight(null);
- viewToolBar.setVisible(false);
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.eclipse.ui.internal.presentations.util.AbstractTabFolder#setSelectedInfo
- * (org.eclipse.ui.internal.presentations.util.PartInfo)
- */
- public void setSelectedInfo(PartInfo info) {
- String newTitle = DefaultTabItem
- .escapeAmpersands(info.contentDescription);
-
- if (!Util.equals(titleLabel.getText(), newTitle)) {
- titleLabel.setText(newTitle);
- titleLabel.setToolTipText(newTitle);
- }
-
- if (!info.contentDescription.equals(Util.ZERO_LENGTH_STRING)) {
- paneFolder.flushTopLeftSize();
- paneFolder.setTopLeft(titleLabel);
- titleLabel.setVisible(true);
- } else {
- paneFolder.setTopLeft(null);
- titleLabel.setVisible(false);
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.internal.presentations.util.AbstractTabFolder#getPaneMenuLocation()
- */
- public Point getPaneMenuLocation() {
- Point toolbarSize = viewToolBar.getSize();
-
- return viewToolBar.toDisplay(0,toolbarSize.y);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.internal.presentations.util.AbstractTabFolder#getPartListLocation()
- */
- public Point getPartListLocation() {
- return paneFolder.getControl().toDisplay(paneFolder.getChevronLocation());
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.internal.presentations.util.AbstractTabFolder#getSystemMenuLocation()
- */
- public Point getSystemMenuLocation() {
- Rectangle bounds = DragUtil.getDisplayBounds(paneFolder.getControl());
-
- int idx = paneFolder.getSelectionIndex();
- if (idx > -1) {
- CTabItem item = paneFolder.getItem(idx);
- Rectangle itemBounds = item.getBounds();
-
- bounds.x += itemBounds.x;
- bounds.y += itemBounds.y;
- }
-
- Point location = new Point(bounds.x, bounds.y
- + paneFolder.getTabHeight());
-
- return location;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.internal.presentations.util.AbstractTabFolder#isOnBorder(org.eclipse.swt.graphics.Point)
- */
- public boolean isOnBorder(Point toTest) {
- Control content = paneFolder.getContent();
- if (content != null) {
- Rectangle displayBounds = DragUtil.getDisplayBounds(content);
-
- if (paneFolder.getTabPosition() == SWT.TOP) {
- return toTest.y >= displayBounds.y;
- }
-
- if (toTest.y >= displayBounds.y && toTest.y < displayBounds.y + displayBounds.height) {
- return true;
- }
- }
-
- return super.isOnBorder(toTest);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.internal.presentations.util.AbstractTabFolder#layout(boolean)
- */
- public void layout(boolean flushCache) {
- paneFolder.layout(flushCache);
- super.layout(flushCache);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.internal.presentations.util.AbstractTabFolder#setState(int)
- */
- public void setState(int state) {
- paneFolder.setState(state);
- super.setState(state);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.internal.presentations.util.AbstractTabFolder#setActive(int)
- */
- public void setActive(int activeState) {
- super.setActive(activeState);
- updateColors();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.internal.presentations.util.AbstractTabFolder#setTabPosition(int)
- */
- public void setTabPosition(int tabPosition) {
- paneFolder.setTabPosition(tabPosition);
- super.setTabPosition(tabPosition);
- layout(true);
- }
-
- public void flushToolbarSize() {
- paneFolder.flushTopCenterSize();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.internal.presentations.util.AbstractTabFolder#setToolbar(org.eclipse.swt.widgets.Control)
- */
- public void setToolbar(Control toolbarControl) {
- paneFolder.setTopCenter(toolbarControl);
- super.setToolbar(toolbarControl);
- }
-
- public void setColors(DefaultTabFolderColors colors, int activationState, boolean shellActivationState) {
- Assert.isTrue(activationState < activeShellColors.length);
-
- if (shellActivationState) {
- activeShellColors[activationState] = colors;
- } else {
- inactiveShellColors[activationState] = colors;
- }
-
- if (activationState == getActive() && shellActive == shellActivationState) {
- updateColors();
- }
- }
-
- /**
- *
- * @since 3.1
- */
- public void updateColors() {
- DefaultTabFolderColors currentColors = shellActive ?
- activeShellColors[getActive()]
- : inactiveShellColors[getActive()];
-
- paneFolder.setSelectionForeground(currentColors.foreground);
- paneFolder.setSelectionBackground(currentColors.background, currentColors.percentages, currentColors.vertical);
- }
-
- public void setColors(DefaultTabFolderColors colors, int activationState) {
- setColors(colors, activationState, true);
- setColors(colors, activationState, false);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.internal.presentations.util.AbstractTabFolder#shellActive(boolean)
- */
- public void shellActive(boolean isActive) {
- this.shellActive = isActive;
- super.shellActive(isActive);
-
- updateColors();
- }
-
- /**
- * @param font
- * @since 3.1
- */
- public void setFont(Font font) {
- if (font != paneFolder.getControl().getFont()) {
- paneFolder.getControl().setFont(font);
- layout(true);
- paneFolder.setTabHeight(computeTabHeight());
- }
- }
-
- /**
- * @return the required tab height for this folder.
- */
- protected int computeTabHeight() {
- GC gc = new GC(getControl());
-
- // Compute the tab height
- int tabHeight = Math.max(viewToolBar.computeSize(SWT.DEFAULT,
- SWT.DEFAULT).y, gc.getFontMetrics().getHeight());
-
- gc.dispose();
-
- return tabHeight;
- }
-
- /**
- * @param b
- * @since 3.1
- */
- public void setSingleTab(boolean b) {
- paneFolder.setSingleTab(b);
- AbstractTabItem[] items = getItems();
-
- for (int i = 0; i < items.length; i++) {
- DefaultTabItem item = (DefaultTabItem)items[i];
-
- item.updateTabText();
- }
-
- layout(true);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.internal.presentations.util.AbstractTabFolder#setVisible(boolean)
- */
- public void setVisible(boolean visible) {
- super.setVisible(visible);
- getFolder().setVisible(visible);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.internal.presentations.util.AbstractTabFolder#showMinMax(boolean)
- */
- public void showMinMax(boolean show) {
- paneFolder.showMinMax(show);
- }
-}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/defaultpresentation/DefaultTabFolderColors.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/defaultpresentation/DefaultTabFolderColors.java
deleted file mode 100644
index 8844b297bff..00000000000
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/defaultpresentation/DefaultTabFolderColors.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 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.presentations.defaultpresentation;
-
-import org.eclipse.swt.graphics.Color;
-
-/**
- * @since 3.1
- */
-public final class DefaultTabFolderColors {
- Color foreground;
- int[] percentages;
- Color[] background;
- boolean vertical;
-
- public DefaultTabFolderColors() {
-
- }
-
- public DefaultTabFolderColors(Color fgColor, Color[] bgColors,
- int[] percentages, boolean vertical) {
-
- foreground = fgColor;
- background = bgColors;
- this.percentages = percentages;
- this.vertical = vertical;
- }
-
- public DefaultTabFolderColors setForeground(Color fg) {
- foreground = fg;
- return this;
- }
-
- public DefaultTabFolderColors setBackground(Color[] background, int[] percentages, boolean vertical) {
- this.background = background;
- this.percentages = percentages;
- this.vertical = vertical;
- return this;
- }
-}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/defaultpresentation/DefaultTabItem.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/defaultpresentation/DefaultTabItem.java
deleted file mode 100644
index 3de777edce8..00000000000
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/defaultpresentation/DefaultTabItem.java
+++ /dev/null
@@ -1,241 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2010 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.presentations.defaultpresentation;
-
-import com.ibm.icu.text.MessageFormat;
-import org.eclipse.jface.resource.FontRegistry;
-import org.eclipse.jface.util.Geometry;
-import org.eclipse.swt.custom.CTabFolder;
-import org.eclipse.swt.custom.CTabItem;
-import org.eclipse.swt.graphics.Font;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.internal.IWorkbenchThemeConstants;
-import org.eclipse.ui.internal.WorkbenchMessages;
-import org.eclipse.ui.internal.presentations.util.PartInfo;
-import org.eclipse.ui.internal.presentations.util.WidgetTabItem;
-import org.eclipse.ui.internal.util.Util;
-
-/**
- * @since 3.1
- */
-public class DefaultTabItem extends WidgetTabItem {
-
- public static String DIRTY_PREFIX = "*"; //$NON-NLS-1$
-
- private boolean busy = false;
-
- private boolean bold = false;
-
- private Font lastFont = null;
-
- private String shortName = Util.ZERO_LENGTH_STRING;
-
- private String longName = Util.ZERO_LENGTH_STRING;
-
- public DefaultTabItem(CTabFolder parent, int index, int flags) {
- super(getTab(parent, index, flags));
- updateFont();
- }
-
- /**
- * Get a new tab for the receiver.
- *
- * @return CTabItem
- */
- private static CTabItem getTab(CTabFolder parent, int index, int flags) {
- return new CTabItem(parent, flags, index);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.internal.presentations.util.AbstractTabItem#getBounds()
- */
- public Rectangle getBounds() {
- return Geometry.toDisplay(getItem().getParent(), getItem().getBounds());
- }
-
- public CTabItem getItem() {
- return (CTabItem) getWidget();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.internal.presentations.util.AbstractTabItem#isShowing()
- */
- public boolean isShowing() {
- return getItem().isShowing();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.internal.presentations.util.AbstractTabItem#setInfo(org.eclipse.ui.internal.presentations.util.PartInfo)
- */
- public void setInfo(PartInfo info) {
- CTabItem tabItem = getItem();
-
- shortName = computeShortName(info);
- longName = computeLongName(info);
-
- updateTabText();
-
- if (tabItem.getImage() != info.image) {
- tabItem.setImage(info.image);
- }
-
- String toolTipText = info.toolTip;
-
- if (toolTipText.equals(Util.ZERO_LENGTH_STRING)) {
- toolTipText = null;
- }
-
- if (!Util.equals(toolTipText, tabItem.getToolTipText())) {
- if (toolTipText != null)
- toolTipText = escapeAmpersands(toolTipText);
- tabItem.setToolTipText(toolTipText);
- }
- }
-
- public void updateTabText() {
- CTabItem tabItem = getItem();
-
- String newName = tabItem.getParent().getSingle() ? longName : shortName;
-
- newName = escapeAmpersands(newName);
-
- if (!Util.equals(newName, tabItem.getText())) {
- tabItem.setText(newName);
- }
- }
-
- /**
- * Escapes all the ampersands in the given string such that they can be
- * displayed verbatim in an SWT label rather than treated as accelerators.
- *
- * @param input
- * the string for which to escape the ampersands
- * @return a string where all ampersands are escaped
- * @since 3.1
- */
- public static String escapeAmpersands(String input) {
- StringBuffer title = new StringBuffer(input.length());
- for (int i = 0; i < input.length(); i++) {
- char character = input.charAt(i);
- title.append(character);
- if (character == '&') {
- title.append(character); // escape ampersand
- }
- }
- return title.toString();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.internal.presentations.util.AbstractTabItem#setBold(boolean)
- */
- public void setBold(boolean bold) {
- this.bold = bold;
- super.setBold(bold);
- updateFont();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.internal.presentations.util.AbstractTabItem#setBusy(boolean)
- */
- public void setBusy(boolean busy) {
- this.busy = busy;
- super.setBusy(busy);
- updateFont();
- }
-
- private void updateFont() {
- CTabItem tabItem = getItem();
-
- // Set the font if necessary
- FontRegistry registry = PlatformUI.getWorkbench().getThemeManager()
- .getCurrentTheme().getFontRegistry();
-
- // Determine the parent font. We will set the tab's font
- Font targetFont = null;
-
- if (busy) {
- targetFont = registry
- .getItalic(IWorkbenchThemeConstants.TAB_TEXT_FONT);
- } else {
-
- if (bold) {
- targetFont = registry
- .getBold(IWorkbenchThemeConstants.TAB_TEXT_FONT);
- }
- }
-
- if (lastFont != targetFont) {
- tabItem.setFont(targetFont);
- lastFont = targetFont;
- }
- }
-
- private static String computeShortName(PartInfo info) {
- String text = info.name;
-
- if (info.dirty) {
- text = DIRTY_PREFIX + text;
- }
-
- return text;
- }
-
- private static String computeLongName(PartInfo info) {
- String text = info.name;
-
- String contentDescription = info.contentDescription;
-
- if (contentDescription.equals("")) { //$NON-NLS-1$
-
- String titleTooltip = info.toolTip.trim();
-
- if (titleTooltip.endsWith(info.name)) {
- titleTooltip = titleTooltip.substring(0,
- titleTooltip.lastIndexOf(info.name)).trim();
- }
-
- if (titleTooltip.endsWith("\\")) { //$NON-NLS-1$
- titleTooltip = titleTooltip.substring(0,
- titleTooltip.lastIndexOf("\\")).trim(); //$NON-NLS-1$
- }
-
- if (titleTooltip.endsWith("/")) { //$NON-NLS-1$
- titleTooltip = titleTooltip.substring(0,
- titleTooltip.lastIndexOf("/")).trim(); //$NON-NLS-1$
- }
-
- contentDescription = titleTooltip;
- }
-
- if (!contentDescription.equals("")) { //$NON-NLS-1$
- text = MessageFormat.format(
- WorkbenchMessages.EditorPart_AutoTitleFormat, new String[] {
- text, contentDescription });
- }
-
- if (info.dirty) {
- text = DIRTY_PREFIX + text;
- }
-
- return text;
- }
-}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/defaultpresentation/DefaultThemeListener.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/defaultpresentation/DefaultThemeListener.java
deleted file mode 100644
index 0de06ba7f6a..00000000000
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/defaultpresentation/DefaultThemeListener.java
+++ /dev/null
@@ -1,144 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2007 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.presentations.defaultpresentation;
-
-import org.eclipse.jface.resource.JFaceResources;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.Font;
-import org.eclipse.swt.graphics.RGB;
-import org.eclipse.ui.internal.IWorkbenchThemeConstants;
-import org.eclipse.ui.internal.preferences.AbstractPropertyListener;
-import org.eclipse.ui.internal.preferences.IPropertyMap;
-import org.eclipse.ui.internal.preferences.PropertyUtil;
-import org.eclipse.ui.internal.themes.LightColorFactory;
-import org.eclipse.ui.presentations.StackPresentation;
-
-/**
- * @since 3.1
- */
-public class DefaultThemeListener extends AbstractPropertyListener {
-
- private DefaultTabFolder folder;
- private IPropertyMap theme;
-
- public DefaultThemeListener(DefaultTabFolder folder, IPropertyMap theme) {
- this.folder = folder;
- this.theme = theme;
- }
-
- private Color getColor(String id, Color defaultValue) {
- Color value = (Color)theme.getValue(id, Color.class);
- if (value == null) {
- value = defaultValue;
- }
-
- return value;
- }
-
- private int getInt(String id, int defaultValue) {
- Integer result = ((Integer)theme.getValue(id, Integer.class));
-
- if (result == null) {
- return defaultValue;
- }
-
- return result.intValue();
- }
-
- private boolean getBoolean(String id, boolean defaultValue) {
- Boolean result = ((Boolean)theme.getValue(id, Boolean.class));
-
- if (result == null) {
- return defaultValue;
- }
-
- return result.booleanValue();
- }
-
- /*
- * Update the ACTIVE_TAB_HIGHLIGHT_START color in the color registry.
- * Return true if we're using highlights on tabs, false otherwise.
- * The highlight color is computed based on the ACTIVE_TAB_BG_START.
- * We need to do this here, in the ThemeListener, so that we can catch
- * the change to the ACTIVE_TAB_BG_START begin color and update the
- * highlight color appropriately.
- * @return boolean use highlight color
- */
- private boolean updateHighlightColor() {
- if(! useHighlight())
- return false;
- //get newTabBegin from theme, not from ColorRegistry, which may not have been updated yet
- RGB newTabBegin = getColor(IWorkbenchThemeConstants.ACTIVE_TAB_BG_START, null).getRGB();
- RGB newHighlight = LightColorFactory.createHighlightStartColor(newTabBegin);
- //Registry handles lifecycle of colors so no leakage and if RGB s.equals then no change
- JFaceResources.getColorRegistry().put(IWorkbenchThemeConstants.ACTIVE_TAB_HIGHLIGHT_START, newHighlight);
- return true;
- }
-
- private boolean useHighlight() {
- return PropertyUtil.get(
- this.theme,
- IWorkbenchThemeConstants.ACTIVE_TAB_HIGHLIGHT,
- false);
- }
-
- public void update() {
- Color[] activeFocusBackgroundColors = updateHighlightColor()
- ? new Color[] {
- getColor(IWorkbenchThemeConstants.ACTIVE_TAB_BG_START, null),
- getColor(IWorkbenchThemeConstants.ACTIVE_TAB_BG_END, null),
- JFaceResources.getColorRegistry().get(IWorkbenchThemeConstants.ACTIVE_TAB_HIGHLIGHT_START)
- }
- : new Color[] {
- getColor(IWorkbenchThemeConstants.ACTIVE_TAB_BG_START, null),
- getColor(IWorkbenchThemeConstants.ACTIVE_TAB_BG_END, null)
- };
-
- folder.setColors(new DefaultTabFolderColors(
- getColor(IWorkbenchThemeConstants.ACTIVE_TAB_TEXT_COLOR, null),
- activeFocusBackgroundColors,
- new int[] {
- getInt(IWorkbenchThemeConstants.ACTIVE_TAB_PERCENT, 0) },
- getBoolean(IWorkbenchThemeConstants.ACTIVE_TAB_VERTICAL, true)),
- StackPresentation.AS_ACTIVE_FOCUS, true);
-
- folder.setColors(new DefaultTabFolderColors(
- getColor(IWorkbenchThemeConstants.ACTIVE_NOFOCUS_TAB_TEXT_COLOR, null),
- new Color[] {
- getColor(IWorkbenchThemeConstants.ACTIVE_NOFOCUS_TAB_BG_START, null),
- getColor(IWorkbenchThemeConstants.ACTIVE_NOFOCUS_TAB_BG_END, null)
- },
- new int[] {
- getInt(IWorkbenchThemeConstants.ACTIVE_NOFOCUS_TAB_PERCENT, 0) },
- getBoolean(IWorkbenchThemeConstants.ACTIVE_NOFOCUS_TAB_VERTICAL, true)),
- StackPresentation.AS_ACTIVE_FOCUS, false);
-
- folder.setColors(new DefaultTabFolderColors(
- getColor(IWorkbenchThemeConstants.INACTIVE_TAB_TEXT_COLOR, null),
- new Color[] {
- getColor(IWorkbenchThemeConstants.INACTIVE_TAB_BG_START, null),
- getColor(IWorkbenchThemeConstants.INACTIVE_TAB_BG_END, null) },
- new int[] {
- getInt(IWorkbenchThemeConstants.INACTIVE_TAB_PERCENT, 0) },
- getBoolean(IWorkbenchThemeConstants.INACTIVE_TAB_VERTICAL, true)),
- StackPresentation.AS_INACTIVE);
-
- folder.setColors(new DefaultTabFolderColors(
- getColor(IWorkbenchThemeConstants.INACTIVE_TAB_TEXT_COLOR, null),
- new Color[] {
- getColor(IWorkbenchThemeConstants.INACTIVE_TAB_BG_START, null) },
- new int[0],
- true), StackPresentation.AS_ACTIVE_NOFOCUS);
-
- folder.setFont((Font)theme.getValue(IWorkbenchThemeConstants.TAB_TEXT_FONT, Font.class));
- }
-
-}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/defaultpresentation/EmptyTabFolder.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/defaultpresentation/EmptyTabFolder.java
deleted file mode 100644
index fbf57a0ad44..00000000000
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/defaultpresentation/EmptyTabFolder.java
+++ /dev/null
@@ -1,173 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2005 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.presentations.defaultpresentation;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.PaintEvent;
-import org.eclipse.swt.events.PaintListener;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.ui.internal.presentations.util.AbstractTabFolder;
-import org.eclipse.ui.internal.presentations.util.AbstractTabItem;
-import org.eclipse.ui.internal.presentations.util.EnhancedFillLayout;
-import org.eclipse.ui.internal.presentations.util.PartInfo;
-
-/**
- * Implements the AbstractTabFolder interface, however this object only displays
- * the content of the currently selected part. There are no tabs, no title, no toolbar,
- * etc. There is no means to select a different part, unless it is done programmatically.
- *
- * @since 3.1
- */
-public class EmptyTabFolder extends AbstractTabFolder {
-
- private Composite control;
- private Control childControl;
- private Color borderColor;
-
- public EmptyTabFolder(Composite parent, boolean showborder) {
- control = new Composite(parent, SWT.NONE);
- EnhancedFillLayout layout = new EnhancedFillLayout();
- control.setLayout(layout);
- borderColor = parent.getDisplay().getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW);
- if (showborder) {
- layout.xmargin = 1;
- layout.ymargin = 1;
- control.addPaintListener(new PaintListener() {
- public void paintControl(PaintEvent e) {
- e.gc.setForeground(borderColor);
- Rectangle rect = control.getClientArea();
- rect.width--;
- rect.height--;
- e.gc.drawRectangle(rect);
- }
- });
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.internal.presentations.util.AbstractTabFolder#computeSize(int, int)
- */
- public Point computeSize(int widthHint, int heightHint) {
- if (childControl != null) {
- // Fix for bug 85899 [Perspectives] [RCP]Standalone view does not divide space in
- // proper ratio with reference when added to IPageLayout with showTitle parameter false
- // If the childControl is a content proxy (a Composite with no children -- see PresentablePartFolder constructor),
- // then computeSize returns 64x64, which is inappropriate.
- // Note that this happens even if the Composite has a Layout that returns 0@0.
- // Instead, use the sizes of the margins. This is equivalent to calling control.computeSize(...)
- // if the childControl returned 0@0 for its preferred size.
- if (childControl instanceof Composite) {
- Composite composite = (Composite) childControl;
- if (composite.getChildren().length == 0) {
- EnhancedFillLayout layout = (EnhancedFillLayout) control.getLayout();
- int w = widthHint == SWT.DEFAULT ? layout.xmargin * 2 : widthHint;
- int h = heightHint == SWT.DEFAULT ? layout.ymargin * 2 : heightHint;
- return new Point(w, h);
- }
- }
- return childControl.computeSize(widthHint, heightHint);
- }
- return new Point(0,0);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.internal.presentations.util.AbstractTabFolder#add(int, int)
- */
- public AbstractTabItem add(int index, int flags) {
- return new EmptyTabItem();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.internal.presentations.util.AbstractTabFolder#getContentParent()
- */
- public Composite getContentParent() {
- return control;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.internal.presentations.util.AbstractTabFolder#setContent(org.eclipse.swt.widgets.Control)
- */
- public void setContent(Control newContent) {
- childControl = newContent;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.internal.presentations.util.AbstractTabFolder#getItems()
- */
- public AbstractTabItem[] getItems() {
- return new AbstractTabItem[0];
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.internal.presentations.util.AbstractTabFolder#getSelection()
- */
- public AbstractTabItem getSelection() {
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.internal.presentations.util.AbstractTabFolder#setSelection(org.eclipse.ui.internal.presentations.util.AbstractTabItem)
- */
- public void setSelection(AbstractTabItem toSelect) {
-
- }
-
- public void setToolbar(Control toolbar) {
- if (toolbar != null) {
- toolbar.setVisible(false);
- }
- }
-
- public void layout(boolean flushCache) {
- super.layout(flushCache);
-
- control.layout(flushCache);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.internal.presentations.util.AbstractTabFolder#setSelectedInfo(org.eclipse.ui.internal.presentations.util.PartInfo)
- */
- public void setSelectedInfo(PartInfo info) {
-
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.internal.presentations.util.AbstractTabFolder#enablePaneMenu(boolean)
- */
- public void enablePaneMenu(boolean enabled) {
-
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.internal.presentations.util.AbstractTabFolder#getToolbarParent()
- */
- public Composite getToolbarParent() {
- return control;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.internal.presentations.util.AbstractTabFolder#getControl()
- */
- public Control getControl() {
- return control;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.internal.presentations.util.AbstractTabFolder#getTabArea()
- */
- public Rectangle getTabArea() {
- return new Rectangle(0,0,0,0);
- }
-}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/defaultpresentation/EmptyTabItem.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/defaultpresentation/EmptyTabItem.java
deleted file mode 100644
index 57c25f51274..00000000000
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/defaultpresentation/EmptyTabItem.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2005 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.presentations.defaultpresentation;
-
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.ui.internal.presentations.util.AbstractTabItem;
-import org.eclipse.ui.internal.presentations.util.PartInfo;
-
-/**
- * @since 3.1
- */
-public class EmptyTabItem extends AbstractTabItem {
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.internal.presentations.util.AbstractTabItem#getBounds()
- */
- public Rectangle getBounds() {
- return new Rectangle(0,0,0,0);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.internal.presentations.util.AbstractTabItem#setInfo(org.eclipse.ui.internal.presentations.util.PartInfo)
- */
- public void setInfo(PartInfo info) {
-
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.internal.presentations.util.AbstractTabItem#dispose()
- */
- public void dispose() {
-
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.internal.presentations.util.AbstractTabItem#getData()
- */
- public Object getData() {
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.internal.presentations.util.AbstractTabItem#setData(java.lang.Object)
- */
- public void setData(Object data) {
-
- }
-}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/defaultpresentation/NativePresentationFactory.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/defaultpresentation/NativePresentationFactory.java
deleted file mode 100644
index f04301e02c7..00000000000
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/defaultpresentation/NativePresentationFactory.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2005 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.presentations.defaultpresentation;
-
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.ui.internal.presentations.util.StandardEditorSystemMenu;
-import org.eclipse.ui.internal.presentations.util.StandardViewSystemMenu;
-import org.eclipse.ui.internal.presentations.util.TabbedStackPresentation;
-import org.eclipse.ui.presentations.AbstractPresentationFactory;
-import org.eclipse.ui.presentations.IStackPresentationSite;
-import org.eclipse.ui.presentations.StackPresentation;
-
-/**
- * @since 3.1
- */
-public class NativePresentationFactory extends AbstractPresentationFactory {
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.presentations.AbstractPresentationFactory
- */
- public StackPresentation createEditorPresentation(Composite parent,
- IStackPresentationSite site) {
- return new TabbedStackPresentation(site, new NativeTabFolder(parent), new StandardEditorSystemMenu(site));
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.presentations.AbstractPresentationFactory
- */
- public StackPresentation createViewPresentation(Composite parent,
- IStackPresentationSite site) {
- return new TabbedStackPresentation(site, new NativeTabFolder(parent), new StandardViewSystemMenu(site));
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.presentations.AbstractPresentationFactory
- */
- public StackPresentation createStandaloneViewPresentation(Composite parent,
- IStackPresentationSite site, boolean showTitle) {
- // TODO honour showTitle
- return new TabbedStackPresentation(site, new NativeTabFolder(parent),
- new StandardViewSystemMenu(site));
- }
-
-}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/defaultpresentation/NativeTabFolder.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/defaultpresentation/NativeTabFolder.java
deleted file mode 100644
index cabc30b355c..00000000000
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/defaultpresentation/NativeTabFolder.java
+++ /dev/null
@@ -1,365 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2010 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.presentations.defaultpresentation;
-
-import org.eclipse.jface.util.Geometry;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.CLabel;
-import org.eclipse.swt.custom.ViewForm;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.Listener;
-import org.eclipse.swt.widgets.TabFolder;
-import org.eclipse.swt.widgets.TabItem;
-import org.eclipse.swt.widgets.Widget;
-import org.eclipse.ui.IPropertyListener;
-import org.eclipse.ui.internal.dnd.DragUtil;
-import org.eclipse.ui.internal.layout.SizeCache;
-import org.eclipse.ui.internal.presentations.util.AbstractTabFolder;
-import org.eclipse.ui.internal.presentations.util.AbstractTabItem;
-import org.eclipse.ui.internal.presentations.util.PartInfo;
-import org.eclipse.ui.internal.presentations.util.ProxyControl;
-import org.eclipse.ui.internal.presentations.util.StandardSystemToolbar;
-import org.eclipse.ui.internal.presentations.util.TabFolderEvent;
-import org.eclipse.ui.internal.util.Util;
-
-/**
- * @since 3.1
- */
-public class NativeTabFolder extends AbstractTabFolder {
-
- private TabFolder control;
- private ViewForm viewForm;
- private StandardSystemToolbar systemToolbar;
- private CLabel title;
- private ProxyControl topCenter;
- private SizeCache topCenterCache;
-
- private Listener selectionListener = new Listener() {
- public void handleEvent(Event e) {
- fireEvent(TabFolderEvent.EVENT_TAB_SELECTED, getTab(e.item));
- }
- };
-
- private IPropertyListener systemToolbarListener = new IPropertyListener() {
-
- public void propertyChanged(Object source, int propId) {
- Point location;
-
- if (propId == TabFolderEvent.EVENT_PANE_MENU) {
- location = getPaneMenuLocation();
- } else {
- location = new Point(0, 0);
- }
-
- fireEvent(propId, getSelection(), location);
- }
-
- };
-
- public NativeTabFolder(Composite parent) {
- control = new TabFolder(parent, SWT.BOTTOM);
- control.addListener(SWT.Selection, selectionListener);
- attachListeners(control, false);
-
- viewForm = new ViewForm(control, SWT.FLAT);
- attachListeners(viewForm, false);
- systemToolbar = new StandardSystemToolbar(viewForm, true, false, true, true, true);
- systemToolbar.addListener(systemToolbarListener);
- viewForm.setTopRight(systemToolbar.getControl());
-
- topCenter = new ProxyControl(viewForm);
- topCenterCache = new SizeCache();
-
- title = new CLabel(viewForm, SWT.LEFT);
- attachListeners(title, false);
- viewForm.setTopLeft(title);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.eclipse.ui.internal.presentations.util.AbstractTabFolder#computeSize
- * (int, int)
- */
- public Point computeSize(int widthHint, int heightHint) {
- return new Point(50, 50);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.eclipse.ui.internal.presentations.util.AbstractTabFolder#add(int)
- */
- public AbstractTabItem add(int index, int flags) {
- NativeTabItem item = new NativeTabItem(this, index);
- item.getWidget().setData(item);
-
- return item;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.eclipse.ui.internal.presentations.util.AbstractTabFolder#layout(boolean
- * )
- */
- public void layout(boolean flushCache) {
- super.layout(flushCache);
-
- Rectangle oldBounds = viewForm.getBounds();
- Rectangle newBounds = control.getClientArea();
-
- viewForm.setBounds(newBounds);
-
- if (Util.equals(oldBounds, newBounds)) {
- viewForm.layout(flushCache);
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.internal.presentations.util.AbstractTabFolder#
- * getPaneMenuLocation()
- */
- public Point getPaneMenuLocation() {
- return systemToolbar.getPaneMenuLocation();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.eclipse.ui.internal.presentations.util.AbstractTabFolder#setState
- * (int)
- */
- public void setState(int state) {
- super.setState(state);
-
- systemToolbar.setState(state);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.eclipse.ui.internal.presentations.util.AbstractTabFolder#getClientArea
- * ()
- */
- public Rectangle getClientArea() {
- Control content = viewForm.getContent();
-
- if (content == null) {
- return new Rectangle(0, 0, 0, 0);
- }
-
- return Geometry.toControl(control, DragUtil.getDisplayBounds(content));
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.eclipse.ui.internal.presentations.util.AbstractTabFolder#getItems()
- */
- public AbstractTabItem[] getItems() {
- TabItem[] items = control.getItems();
-
- AbstractTabItem[] result = new AbstractTabItem[items.length];
-
- for (int i = 0; i < result.length; i++) {
- result[i] = getTab(items[i]);
- }
-
- return result;
- }
-
- private AbstractTabItem getTab(Widget item) {
- return (AbstractTabItem) item.getData();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.eclipse.ui.internal.presentations.util.AbstractTabFolder#setSelection
- * (org.eclipse.ui.internal.presentations.util.Widget)
- */
- public void setSelection(AbstractTabItem toSelect) {
- if (toSelect == null) {
- return;
- }
-
- NativeTabItem tab = (NativeTabItem) toSelect;
- control.setSelection(new TabItem[] { (TabItem) tab.getWidget() });
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.eclipse.ui.internal.presentations.util.AbstractTabFolder#setSelectedInfo
- * (org.eclipse.ui.internal.presentations.util.PartInfo)
- */
- public void setSelectedInfo(PartInfo info) {
- if (!Util.equals(title.getText(), info.title)) {
- title.setText(info.title);
- }
- if (title.getImage() != info.image) {
- title.setImage(info.image);
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.eclipse.ui.internal.presentations.util.AbstractTabFolder#getToolbarParent
- * ()
- */
- public Composite getToolbarParent() {
- return viewForm;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.eclipse.ui.internal.presentations.util.AbstractTabFolder#getTabArea()
- */
- public Rectangle getTabArea() {
-
- Rectangle bounds = control.getBounds();
-
- Rectangle clientArea = control.getClientArea();
-
- bounds.x = 0;
- bounds.y = 0;
- Geometry.expand(bounds, 0, 0, -(clientArea.height + clientArea.y), 0);
-
- return Geometry.toDisplay(control.getParent(), bounds);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.eclipse.ui.internal.presentations.util.AbstractTabFolder#setToolbar
- * (org.eclipse.swt.widgets.Control)
- */
- public void setToolbar(Control toolbarControl) {
-
- if (toolbarControl != null) {
- topCenterCache.setControl(toolbarControl);
- topCenter.setTarget(topCenterCache);
- viewForm.setTopCenter(topCenter.getControl());
- } else {
- topCenterCache.setControl(null);
- topCenter.setTarget(null);
- viewForm.setTopCenter(null);
- }
-
- super.setToolbar(toolbarControl);
- }
-
- public Control getControl() {
- return control;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.eclipse.ui.internal.presentations.util.AbstractTabFolder#isOnBorder
- * (org.eclipse.swt.graphics.Point)
- */
- public boolean isOnBorder(Point globalPos) {
- Point localPos = getControl().toControl(globalPos);
-
- Rectangle clientArea = getClientArea();
- return localPos.y > clientArea.y && localPos.y < clientArea.y + clientArea.height;
- }
-
- public AbstractTabItem getSelection() {
- TabItem[] sel = control.getSelection();
-
- if (sel.length == 0) {
- return null;
- }
-
- return getTab(sel[0]);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.eclipse.ui.internal.presentations.util.AbstractTabFolder#getContentParent
- * ()
- */
- public Composite getContentParent() {
- return viewForm;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.eclipse.ui.internal.presentations.util.AbstractTabFolder#setContent
- * (org.eclipse.swt.widgets.Control)
- */
- public void setContent(Control newContent) {
- viewForm.setContent(newContent);
- }
-
- public TabFolder getTabFolder() {
- return control;
- }
-
- void setSelectedTitle(String newTitle) {
- title.setText(newTitle);
- }
-
- /**
- * @param image
- * @since 3.1
- */
- /* protected */void setSelectedImage(Image image) {
- title.setImage(image);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.eclipse.ui.internal.presentations.util.AbstractTabFolder#getItem(
- * org.eclipse.swt.graphics.Point)
- */
- public AbstractTabItem getItem(Point toFind) {
- return getSelection();
- }
-
- /**
- * @param enabled
- * @since 3.1
- */
- public void enablePaneMenu(boolean enabled) {
- systemToolbar.enablePaneMenu(enabled);
- }
-}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/defaultpresentation/NativeTabItem.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/defaultpresentation/NativeTabItem.java
deleted file mode 100644
index 729d35713e7..00000000000
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/defaultpresentation/NativeTabItem.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2005 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.presentations.defaultpresentation;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.widgets.TabItem;
-import org.eclipse.ui.internal.presentations.util.PartInfo;
-import org.eclipse.ui.internal.presentations.util.WidgetTabItem;
-import org.eclipse.ui.internal.util.Util;
-
-/**
- * @since 3.1
- */
-public class NativeTabItem extends WidgetTabItem {
-
- public NativeTabItem(NativeTabFolder parent, int index) {
- super(new TabItem(parent.getTabFolder(), SWT.NONE, index));
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.internal.presentations.util.AbstractTabItem#getBounds()
- */
- public Rectangle getBounds() {
- return new Rectangle(0,0,0,0);
- }
-
- public void setInfo(PartInfo info) {
- TabItem widget = (TabItem) getWidget();
-
- if (!Util.equals(widget.getText(), info.name)) {
- widget.setText(info.name);
- }
- String oldToolTip = Util.safeString(widget.getToolTipText());
-
- if (!Util.equals(info.toolTip, oldToolTip)) {
- String toolTip = info.toolTip;
- if (toolTip.length() == 0) {
- toolTip = null;
- }
- widget.setToolTipText(toolTip);
- }
- }
-}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/util/AbstractTabFolder.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/util/AbstractTabFolder.java
deleted file mode 100644
index 4b119010781..00000000000
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/util/AbstractTabFolder.java
+++ /dev/null
@@ -1,409 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2009 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.presentations.util;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.MouseAdapter;
-import org.eclipse.swt.events.MouseEvent;
-import org.eclipse.swt.events.MouseListener;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.Listener;
-import org.eclipse.ui.presentations.IStackPresentationSite;
-import org.eclipse.ui.presentations.PresentationUtil;
-
-/**
- * @since 3.1
- */
-public abstract class AbstractTabFolder {
-
- private List listeners = new ArrayList(1);
-
- private Control toolbar;
- private int state;
-
- public abstract Point computeSize(int widthHint, int heightHint);
-
- public abstract AbstractTabItem add(int index, int flags);
-
- public abstract Composite getContentParent();
- public abstract void setContent(Control newContent);
-
- public abstract AbstractTabItem[] getItems();
-
- public abstract AbstractTabItem getSelection();
- public abstract void setSelection(AbstractTabItem toSelect);
- public abstract void setSelectedInfo(PartInfo info);
- public abstract void enablePaneMenu(boolean enabled);
- private int activeState = IStackPresentationSite.STATE_RESTORED;
-
- private Listener menuListener = new Listener() {
- /* (non-Javadoc)
- * @see org.eclipse.swt.widgets.Listener#handleEvent(org.eclipse.swt.widgets.Event)
- */
- public void handleEvent(Event event) {
- Point globalPos = new Point(event.x, event.y);
- handleContextMenu(globalPos, event);
- }
- };
-
- private Listener dragListener = new Listener() {
- public void handleEvent(Event e) {
- Point globalPos = ((Control)e.widget).toDisplay(e.x, e.y);
- handleDragStarted(globalPos, e);
- }
- };
-
- private MouseListener mouseListener = new MouseAdapter() {
-
- // If we single-click on an empty space on the toolbar, move focus to the
- // active control
- public void mouseDown(MouseEvent e) {
- Point p = ((Control)e.widget).toDisplay(e.x, e.y);
-
- handleMouseDown(p, e);
- }
-
-
- // If we double-click on the toolbar, maximize the presentation
- public void mouseDoubleClick(MouseEvent e) {
- // only react to the first button
- if (e.button != 1)
- return;
-
- Point p = ((Control)e.widget).toDisplay(e.x, e.y);
- handleDoubleClick(p, e);
- }
- };
-
- public void setActive(int activeState) {
- this.activeState = activeState;
- }
-
- public int getActive() {
- return activeState;
- }
-
- /**
- * Returns the location where the pane menu should be opened when activated
- * by a keyboard shortcut (display coordinates)
- *
- * @return the location for the pane menu (display coordinates)
- * @since 3.1
- */
- public Point getPaneMenuLocation() {
- return getControl().toDisplay(new Point(0,0));
- }
-
- /**
- * Returns the location where the part list should be opened when activated
- * by a keyboard shortcut (display coordinates)
- *
- * @return the location for the part list (display coordinates)
- * @since 3.1
- */
- public Point getPartListLocation() {
- return getSystemMenuLocation();
- }
-
- /**
- * Returns the location where the pane menu should be opened when activated
- * by a keyboard shortcut (display coordinates)
- *
- * @return the location for the pane menu (display coordinates)
- * @since 3.1
- */
- public Point getSystemMenuLocation() {
- return getControl().toDisplay(new Point(0,0));
- }
-
- /**
- * Returns the parent composite that should be used for creating the toolbar.
- * Any control passed into setToolbar must have this composite as its parent.
- *
- * @return the parent composite that should be used for creating the toolbar
- *
- * @since 3.1
- */
- public abstract Composite getToolbarParent();
-
- /**
- * Returns the main control for this folder.
- *
- * @return the main control for the folder
- * @since 3.1
- */
- public abstract Control getControl();
-
- public AbstractTabItem getItem(int idx) {
- return getItems()[idx];
- }
-
- public AbstractTabItem getItem(Point toFind) {
- AbstractTabItem[] items = getItems();
-
- for (int i = 0; i < items.length; i++) {
- AbstractTabItem item = items[i];
-
- if (item.getBounds().contains(toFind)) {
- return item;
- }
- }
-
- return null;
- }
-
- public AbstractTabItem findItem(Object dataToFind) {
- AbstractTabItem[] items = getItems();
-
- for (int i = 0; i < items.length; i++) {
- AbstractTabItem item = items[i];
-
- if (item.getData() == dataToFind) {
- return item;
- }
- }
-
- return null;
- }
-
- /**
- * Returns the index of the given item, or -1 if the given item is
- * not found in this tab folder. Subclasses should override this if
- * the underlying SWT widget has an equivalent method
- *
- * @param item item to find
- * @return the index of the given item or -1
- */
- public int indexOf(AbstractTabItem item) {
- AbstractTabItem[] items = getItems();
-
- for (int idx = 0; idx < items.length; idx++) {
- AbstractTabItem next = items[idx];
-
- if (next == item) {
- return idx;
- }
- }
-
- return -1;
- }
-
- public int getItemCount() {
- return getItems().length;
- }
-
- public void setToolbar(Control toolbarControl) {
- this.toolbar = toolbarControl;
- }
-
- public final Control getToolbar() {
- return toolbar;
- }
-
- /**
- * Sets the current state for the folder
- *
- * @param state one of the IStackPresentationSite.STATE_* constants
- */
- public void setState(int state) {
- this.state = state;
- }
-
- /**
- * Returns the title area for this control (in the control's coordinate system)
- *
- * @return
- */
- public abstract Rectangle getTabArea();
-
- /**
- * Called when the tab folder's shell becomes active or inactive. Subclasses
- * can override this to change the appearance of the tabs based on activation.
- *
- * @param isActive
- */
- public void shellActive(boolean isActive) {
- }
-
- /**
- * Adds the given listener to this AbstractTabFolder
- *
- * @param newListener the listener to add
- */
- public final void addListener(TabFolderListener newListener) {
- listeners.add(newListener);
- }
-
- /**
- * Removes the given listener from this AbstractTabFolder
- *
- * @param toRemove the listener to remove
- */
- public final void removeListener(TabFolderListener toRemove) {
- listeners.remove(toRemove);
- }
-
- public void flushToolbarSize() {
-
- }
-
- protected final void fireEvent(TabFolderEvent e) {
- for (Iterator iter = listeners.iterator(); iter.hasNext();) {
- TabFolderListener next = (TabFolderListener)iter.next();
-
- next.handleEvent(e);
- }
- }
-
- protected final void fireEvent(int id) {
- fireEvent(new TabFolderEvent(id));
- }
-
- protected final void fireEvent(int id, AbstractTabItem w) {
- fireEvent(new TabFolderEvent(id, w, 0, 0));
- }
-
- protected final void fireEvent(int id, AbstractTabItem w, Point pos) {
- fireEvent(new TabFolderEvent(id, w, pos));
- }
-
- public void layout(boolean flushCache) {
- }
-
- public void setTabPosition(int tabPosition) {
- }
-
- public int getTabPosition() {
- return SWT.TOP;
- }
-
- public int getState() {
- return state;
- }
-
- protected void attachListeners(Control theControl, boolean recursive) {
- theControl.addListener(SWT.MenuDetect, menuListener);
- theControl.addMouseListener(mouseListener);
- PresentationUtil.addDragListener(theControl, dragListener);
-
- if (recursive && theControl instanceof Composite) {
- Composite composite = (Composite) theControl;
- Control[] children = composite.getChildren();
-
- for (int i = 0; i < children.length; i++) {
- Control control = children[i];
-
- attachListeners(control, recursive);
- }
- }
- }
-
- protected void detachListeners(Control theControl, boolean recursive) {
- theControl.removeListener(SWT.MenuDetect, menuListener);
- theControl.removeMouseListener(mouseListener);
- PresentationUtil.removeDragListener(theControl, dragListener);
-
- if (recursive && theControl instanceof Composite) {
- Composite composite = (Composite) theControl;
- Control[] children = composite.getChildren();
-
- for (int i = 0; i < children.length; i++) {
- Control control = children[i];
-
- detachListeners(control, recursive);
- }
- }
- }
-
- protected void handleContextMenu(Point displayPos, Event e) {
- if (isOnBorder(displayPos)) {
- return;
- }
-
- AbstractTabItem tab = getItem(displayPos);
-
- fireEvent(TabFolderEvent.EVENT_SYSTEM_MENU, tab, displayPos);
- }
-
- protected void handleMouseDown(Point displayPos, MouseEvent e) {
- fireEvent(TabFolderEvent.EVENT_GIVE_FOCUS_TO_PART);
- }
-
- protected void handleDoubleClick(Point displayPos, MouseEvent e) {
- if (isOnBorder(displayPos)) {
- return;
- }
-
- if (getState() == IStackPresentationSite.STATE_MAXIMIZED) {
- fireEvent(TabFolderEvent.EVENT_RESTORE);
- } else {
- fireEvent(TabFolderEvent.EVENT_MAXIMIZE);
- }
- }
-
- protected void handleDragStarted(Point displayPos, Event e) {
-
- if (isOnBorder(displayPos)) {
- return;
- }
-
- AbstractTabItem tab = getItem(displayPos);
- fireEvent(TabFolderEvent.EVENT_DRAG_START, tab, displayPos);
- }
-
- /**
- * Returns true iff the given point is on the border of the folder.
- * By default, double-clicking, context menus, and drag/drop are disabled
- * on the folder's border.
- *
- * @param toTest a point (display coordinates)
- * @return true iff the point is on the presentation border
- * @since 3.1
- */
- public boolean isOnBorder(Point toTest) {
- return false;
- }
-
- /**
- * Set the folder to visible. This can be extended to propogate the
- * visibility request to other components in the subclass.
- *
- * @param visible
- * <code>true</code> - the folder is visible.
- * @since 3.2
- */
- public void setVisible(boolean visible) {
- getControl().setVisible(visible);
- }
-
- /**
- * Cause the folder to hide or show its
- * Minimize and Maximize affordances.
- *
- * @param show
- * <code>true</code> - the min/max buttons are visible.
- * @since 3.3
- */
- public void showMinMax(boolean show) {
- }
-
- public void showItem(AbstractTabItem toSelect) {
- setSelection(toSelect);
- }
-
-}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/util/AbstractTabItem.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/util/AbstractTabItem.java
deleted file mode 100644
index 434542f82f4..00000000000
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/util/AbstractTabItem.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2005 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.presentations.util;
-
-import org.eclipse.swt.graphics.Rectangle;
-
-/**
- * @since 3.1
- */
-public abstract class AbstractTabItem {
- public abstract Rectangle getBounds();
- public abstract void setInfo(PartInfo info);
- public abstract void dispose();
- public void setBusy(boolean busy) {}
- public void setBold(boolean bold) {}
-
- public abstract Object getData();
- public abstract void setData(Object data);
-
- public boolean isShowing() {
- return true;
- }
-
-}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/util/EnhancedFillLayout.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/util/EnhancedFillLayout.java
deleted file mode 100644
index 80ba115d2c2..00000000000
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/util/EnhancedFillLayout.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2005 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.presentations.util;
-
-import org.eclipse.jface.util.Geometry;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Layout;
-
-/**
- * @since 3.1
- */
-public class EnhancedFillLayout extends Layout {
-
- public int xmargin = 0;
- public int ymargin = 0;
-
- protected Point computeSize(Composite composite, int wHint, int hHint, boolean flushCache) {
- int resultX = 1;
- int resultY = 1;
-
- Control[] children = composite.getChildren();
-
- for (int i = 0; i < children.length; i++) {
- Control control = children[i];
-
- Point sz = control.computeSize(wHint, hHint, flushCache);
-
- resultX = Math.max(resultX, sz.x + 2 * xmargin);
- resultY = Math.max(resultY, sz.y + 2 * ymargin);
- }
-
- return new Point(resultX, resultY);
- }
-
- protected void layout(Composite composite, boolean flushCache) {
- Control[] children = composite.getChildren();
-
- for (int i = 0; i < children.length; i++) {
- Control control = children[i];
- Rectangle area = composite.getClientArea();
- Geometry.expand(area, -xmargin, -xmargin, -ymargin, -ymargin );
- control.setBounds(area);
- }
- }
-}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/util/IPresentablePartList.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/util/IPresentablePartList.java
deleted file mode 100644
index 5ce0aebbe53..00000000000
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/util/IPresentablePartList.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2005 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.presentations.util;
-
-import org.eclipse.ui.presentations.IPresentablePart;
-
-/**
- * @since 3.0
- */
-public interface IPresentablePartList {
- public void insert(IPresentablePart part, int idx);
-
- public void remove(IPresentablePart part);
-
- public void move(IPresentablePart part, int newIndex);
-
- public int size();
-
- public void select(IPresentablePart part);
-
- public IPresentablePart[] getPartList();
-}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/util/ISystemMenu.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/util/ISystemMenu.java
deleted file mode 100644
index 86fa3794ebd..00000000000
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/util/ISystemMenu.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2007 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.presentations.util;
-
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.ui.presentations.IPresentablePart;
-
-/**
- * @since 3.1
- */
-public interface ISystemMenu {
- void show(Control control, Point displayCoordinates, IPresentablePart currentSelection);
-
- /**
- * Disposes of this system menu.
- *
- * @since 3.3
- */
- void dispose();
-}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/util/LeftToRightTabOrder.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/util/LeftToRightTabOrder.java
deleted file mode 100644
index 64c9a8f2e3e..00000000000
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/util/LeftToRightTabOrder.java
+++ /dev/null
@@ -1,122 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2005 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.presentations.util;
-
-import java.util.Arrays;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.ui.IMemento;
-import org.eclipse.ui.internal.IWorkbenchConstants;
-import org.eclipse.ui.presentations.IPresentablePart;
-import org.eclipse.ui.presentations.IPresentationSerializer;
-
-/**
- * @since 3.0
- */
-public class LeftToRightTabOrder extends TabOrder {
-
- private IPresentablePartList list;
-
- public LeftToRightTabOrder(IPresentablePartList list) {
- this.list = list;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.internal.presentations.util.TabOrder#add(org.eclipse.ui.presentations.IPresentablePart)
- */
- public void add(IPresentablePart newPart) {
- list.insert(newPart, list.size());
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.internal.presentations.util.TabOrder#addInitial(org.eclipse.ui.presentations.IPresentablePart)
- */
- public void addInitial(IPresentablePart newPart) {
- add(newPart);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.internal.presentations.util.TabOrder#insert(org.eclipse.ui.presentations.IPresentablePart, int)
- */
- public void insert(IPresentablePart newPart, int index) {
- list.insert(newPart, index);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.internal.presentations.util.TabOrder#remove(org.eclipse.ui.presentations.IPresentablePart)
- */
- public void remove(IPresentablePart removed) {
- list.remove(removed);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.internal.presentations.util.TabOrder#select(org.eclipse.ui.presentations.IPresentablePart)
- */
- public void select(IPresentablePart selected) {
- list.select(selected);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.internal.presentations.util.TabOrder#move(org.eclipse.ui.presentations.IPresentablePart, int)
- */
- public void move(IPresentablePart toMove, int newIndex) {
- list.move(toMove, newIndex);
- }
-
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.internal.presentations.util.TabOrder#getPartList()
- */
- public IPresentablePart[] getPartList() {
- return list.getPartList();
- }
-
- /**
- * Restores a presentation from a previously stored state
- *
- * @param serializer (not null)
- * @param savedState (not null)
- */
- public void restoreState(IPresentationSerializer serializer,
- IMemento savedState) {
- IMemento[] parts = savedState.getChildren(IWorkbenchConstants.TAG_PART);
-
- for (int idx = 0; idx < parts.length; idx++) {
- String id = parts[idx].getString(IWorkbenchConstants.TAG_ID);
-
- if (id != null) {
- IPresentablePart part = serializer.getPart(id);
-
- if (part != null) {
- addInitial(part);
- }
- }
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.presentations.StackPresentation#saveState(org.eclipse.ui.presentations.IPresentationSerializer, org.eclipse.ui.IMemento)
- */
- public void saveState(IPresentationSerializer context, IMemento memento) {
-
- List parts = Arrays.asList(list.getPartList());
-
- Iterator iter = parts.iterator();
- while (iter.hasNext()) {
- IPresentablePart next = (IPresentablePart) iter.next();
-
- IMemento childMem = memento
- .createChild(IWorkbenchConstants.TAG_PART);
- childMem.putString(IWorkbenchConstants.TAG_ID, context.getId(next));
- }
- }
-}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/util/PartInfo.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/util/PartInfo.java
deleted file mode 100644
index cae2ca14384..00000000000
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/util/PartInfo.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2010 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.presentations.util;
-
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.ui.internal.util.Util;
-import org.eclipse.ui.presentations.IPresentablePart;
-
-/**
- * @since 3.1
- */
-public final class PartInfo {
- public String name;
- public String title;
- public String contentDescription;
- public String toolTip;
- public Image image;
- public boolean dirty;
-
- public PartInfo() {
- name = Util.ZERO_LENGTH_STRING;
- title = Util.ZERO_LENGTH_STRING;
- contentDescription = Util.ZERO_LENGTH_STRING;
- toolTip = Util.ZERO_LENGTH_STRING;
- image = null;
- }
-
- public PartInfo(IPresentablePart part) {
- set(part);
- }
-
- public void set(IPresentablePart part) {
- name = part.getName();
- title = part.getTitle();
- contentDescription = part.getTitleStatus();
- image = part.getTitleImage();
- toolTip = part.getTitleToolTip();
- dirty = part.isDirty();
- }
-}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/util/PresentablePartFolder.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/util/PresentablePartFolder.java
deleted file mode 100644
index 22b34d0d757..00000000000
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/util/PresentablePartFolder.java
+++ /dev/null
@@ -1,418 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2009 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
- * Stefan Xenos, IBM - bug 51580
- * Chris Torrence, ITT Visual Information Solutions - bugs 51580 202208
- *******************************************************************************/
-package org.eclipse.ui.internal.presentations.util;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.jface.util.Geometry;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.ControlEvent;
-import org.eclipse.swt.events.ControlListener;
-import org.eclipse.swt.events.DisposeEvent;
-import org.eclipse.swt.events.DisposeListener;
-import org.eclipse.swt.events.ShellAdapter;
-import org.eclipse.swt.events.ShellEvent;
-import org.eclipse.swt.events.ShellListener;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.ui.IPropertyListener;
-import org.eclipse.ui.internal.dnd.DragUtil;
-import org.eclipse.ui.internal.dnd.SwtUtil;
-import org.eclipse.ui.presentations.IPresentablePart;
-import org.eclipse.ui.presentations.IStackPresentationSite;
-
-/**
- * @since 3.1
- */
-public final class PresentablePartFolder implements IPresentablePartList {
- private AbstractTabFolder folder;
- private IPresentablePart current;
- //private ProxyControl toolbarProxy;
- private Control contentProxy;
- private static PartInfo tempPartInfo = new PartInfo();
-
- /**
- * Movement listener. Updates the bounds of the target to match the
- * bounds of the dummy control.
- */
- private ControlListener contentListener = new ControlListener() {
-
- public void controlMoved(ControlEvent e) {
- layoutContent();
- }
-
- public void controlResized(ControlEvent e) {
- }
-
- };
-
- private ShellListener shellListener = new ShellAdapter() {
- public void shellActivated(ShellEvent e) {
- folder.shellActive(true);
- }
-
- public void shellDeactivated(ShellEvent e) {
- folder.shellActive(false);
- }
- };
-
- /**
- * Listener attached to all child parts. It responds to changes in part properties
- */
- private IPropertyListener childPropertyChangeListener = new IPropertyListener() {
- public void propertyChanged(Object source, int property) {
-
- if (source instanceof IPresentablePart) {
- IPresentablePart part = (IPresentablePart) source;
-
- childPropertyChanged(part, property);
- }
- }
- };
-
- /**
- * Dispose listener that is attached to the main control. It triggers cleanup of
- * any listeners. This is required to prevent memory leaks.
- */
- private DisposeListener tabDisposeListener = new DisposeListener() {
- public void widgetDisposed(DisposeEvent e) {
- if (e.widget == folder.getControl()) {
- // If we're disposing the main control...
- disposed();
- }
- }
- };
- private List partList = new ArrayList(4);
-
- public PresentablePartFolder(AbstractTabFolder folder) {
- this.folder = folder;
-
- folder.getControl().getShell().addShellListener(shellListener);
- folder.shellActive(folder.getControl().getDisplay()
- .getActiveShell() == folder.getControl().getShell());
-
- folder.getControl().addDisposeListener(tabDisposeListener);
-
- //toolbarProxy = new ProxyControl(folder.getToolbarParent());
-
- // NOTE: if the shape of contentProxy changes, the fix for bug 85899 in EmptyTabFolder.computeSize may need adjustment.
- contentProxy = new Composite(folder.getContentParent(), SWT.NONE);
- contentProxy.setVisible(false);
- for (Control current = contentProxy; current != folder.getControl().getParent(); current = current.getParent()) {
- current.addControlListener(contentListener);
- }
- folder.setContent(contentProxy);
-
- }
-
- /**
- *
- * @since 3.1
- */
- private void layoutContent() {
- if (current != null) {
- Rectangle clientArea = DragUtil.getDisplayBounds(contentProxy);
-
- current.setBounds(Geometry.toControl(folder.getControl().getParent(), clientArea));
- }
- }
-
- /**
- *
- * @since 3.1
- */
- protected void disposed() {
- folder.getControl().getShell().removeShellListener(shellListener);
- Iterator iter = partList.iterator();
- while(iter.hasNext()) {
- IPresentablePart next = (IPresentablePart)iter.next();
-
- next.removePropertyListener(childPropertyChangeListener);
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.internal.presentations.util.IPresentablePartList#getPartList()
- */
- public IPresentablePart[] getPartList() {
- AbstractTabItem[] items = folder.getItems();
- IPresentablePart[] result = new IPresentablePart[items.length];
-
- for (int i = 0; i < items.length; i++) {
- result[i] = getPartForTab(items[i]);
-
- }
-
- return result;
- }
-
- /**
- * Adds the given presentable part directly into this presentation at the
- * given index. Does nothing if a tab already exists for the given part.
- * This is intended to be called by TabOrder and its subclasses.
- *
- * @param part part to add
- * @param idx index to insert at
- */
- public void insert(IPresentablePart part, int idx) {
- Assert.isTrue(!folder.getControl().isDisposed());
-
- if (getTab(part) != null) {
- if(indexOf(part) != idx)
- move(part, idx);
- return;
- }
-
- idx = Math.min(idx, folder.getItemCount());
-
- AbstractTabItem item;
-
- int style = SWT.NONE;
-
- if (part.isCloseable()) {
- style |= SWT.CLOSE;
- }
-
- item = folder.add(idx, style);
- folder.showItem(item);
- item.setData(part);
-
- initTab(item, part);
-
- part.addPropertyListener(childPropertyChangeListener);
- partList.add(part);
- }
-
- public void remove(IPresentablePart toRemove) {
- if (toRemove == current) {
- select(null);
- }
-
- internalRemove(toRemove);
- }
-
- private void internalRemove(IPresentablePart toRemove) {
- AbstractTabItem item = getTab(toRemove);
- if (item != null) {
- item.dispose();
- }
- if (partList.contains(toRemove)) {
- toRemove.removePropertyListener(childPropertyChangeListener);
- partList.remove(toRemove);
- }
- }
-
- /**
- * Moves the given part to the given index. When this method returns,
- * indexOf(part) will return newIndex.
- *
- * @param part
- * @param newIndex
- */
- public void move(IPresentablePart part, int newIndex) {
- int currentIndex = indexOf(part);
-
- if (currentIndex == newIndex) {
- return;
- }
-
- internalRemove(part);
- insert(part, newIndex);
-
- if (current == part) {
- folder.setSelection(getTab(part));
- }
- }
-
- /**
- * Returns the number of parts in this folder
- */
- public int size() {
- return folder.getItemCount();
- }
-
- public void setBounds(Rectangle bounds) {
- Point minSize = folder.computeSize(bounds.width, SWT.DEFAULT);
-
- if (folder.getState() == IStackPresentationSite.STATE_MINIMIZED && minSize.y < bounds.height) {
- bounds = Geometry.copy(bounds);
- bounds.height = minSize.y;
- }
-
- // Set the tab folder's bounds
- folder.getControl().setBounds(bounds);
-
- layout(false);
- }
-
- public void select(IPresentablePart toSelect) {
-
- if (toSelect == current) {
- return;
- }
-
- if (toSelect != null) {
- toSelect.setVisible(true);
- }
-
- if (current != null) {
- current.setVisible(false);
- setToolbar(null);
- }
-
- current = toSelect;
-
- AbstractTabItem selectedItem = getTab(toSelect);
-
- folder.setSelection(selectedItem);
-
- if (selectedItem != null) {
- // Determine if we need to un-bold this tab
- selectedItem.setBold(false);
- initTab(selectedItem, toSelect);
- } else {
- setToolbar(null);
- }
-
- layout(true);
- }
-
- private void setToolbar(Control newToolbar) {
- if (folder.getToolbar() != newToolbar) {
- folder.setToolbar(newToolbar);
- }
- }
- private boolean isVisible = true;
-
-
- private void childPropertyChanged(IPresentablePart part, int property) {
- AbstractTabItem tab = getTab(part);
-
- switch (property) {
- case IPresentablePart.PROP_HIGHLIGHT_IF_BACK:
- if (tab != null && getCurrent() != part) {//Set bold if it doesn't currently have focus
- tab.setBold(true);
- initTab(tab, part);
- }
- break;
-
- case IPresentablePart.PROP_TOOLBAR:
- if (tab != null && getCurrent() == part) {
- folder.flushToolbarSize();
- }
- //$FALL-THROUGH$
- case IPresentablePart.PROP_CONTENT_DESCRIPTION:
- case IPresentablePart.PROP_PANE_MENU:
- case IPresentablePart.PROP_TITLE:
- if (tab != null) {
- initTab(tab, part);
- if (getCurrent() == part) {
- layout(true);
- }
- }
- break;
- case IPresentablePart.PROP_PREFERRED_SIZE:
- folder.fireEvent(new TabFolderEvent(TabFolderEvent.EVENT_PREFERRED_SIZE, tab, 0, 0 ));
- break;
- default:
- if (tab != null) initTab(tab, part);
- }
- }
-
- protected void initTab(AbstractTabItem item, IPresentablePart part) {
- tempPartInfo.set(part);
- item.setInfo(tempPartInfo);
-
- item.setBusy(part.isBusy());
- if (part == getCurrent()) {
- folder.setSelectedInfo(tempPartInfo);
- folder.enablePaneMenu(part.getMenu() != null);
-
- setToolbar(part.getToolBar());
- }
- }
-
- public boolean isDisposed() {
- return SwtUtil.isDisposed(folder.getControl());
- }
-
- public IPresentablePart getPartForTab(AbstractTabItem tab) {
- Assert.isTrue(!isDisposed());
-
- if (tab == null) {
- return null;
- }
-
- IPresentablePart part = (IPresentablePart) tab.getData();
-
- return part;
- }
-
- /**
- * Returns the tab for the given part, or null if there is no such tab
- *
- * @param part the part being searched for
- * @return the tab for the given part, or null if there is no such tab
- */
- public AbstractTabItem getTab(IPresentablePart part) {
- Assert.isTrue(!isDisposed());
-
- return folder.findItem(part);
- }
-
-
-
- public int indexOf(IPresentablePart part) {
- AbstractTabItem item = getTab(part);
-
- if (item == null) {
- return -1;
- }
-
- return folder.indexOf(item);
- }
-
- public AbstractTabFolder getTabFolder() {
- return folder;
- }
-
- public void setVisible(boolean isVisible) {
- this.isVisible = isVisible;
- getTabFolder().setVisible(isVisible);
- if (isVisible) {
- layout(true);
- }
- }
-
- public void layout(boolean changed) {
- if (!isVisible) {
- // Don't bother with layout if we're not visible
- return;
- }
- // Lay out the tab folder and compute the client area
- folder.layout(changed);
-
- //toolbarProxy.layout();
-
- layoutContent();
- }
-
- public IPresentablePart getCurrent() {
- return current;
- }
-}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/util/ProxyControl.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/util/ProxyControl.java
deleted file mode 100644
index d64ab56d17d..00000000000
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/util/ProxyControl.java
+++ /dev/null
@@ -1,287 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 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.presentations.util;
-
-import org.eclipse.jface.util.Geometry;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.ControlEvent;
-import org.eclipse.swt.events.ControlListener;
-import org.eclipse.swt.events.DisposeEvent;
-import org.eclipse.swt.events.DisposeListener;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.Layout;
-import org.eclipse.swt.widgets.Listener;
-import org.eclipse.ui.internal.dnd.DragUtil;
-import org.eclipse.ui.internal.dnd.SwtUtil;
-import org.eclipse.ui.internal.layout.SizeCache;
-
-/**
- * A ProxyControl is an invisible control whose size and position are linked
- * with some target control. That is, when the dummy control is asked for its
- * preferred size it returns the preferred size of the target. Changing the
- * bounds of the dummy control also changes the bounds of the target. This allows
- * any Composite to lay out a control that isn't one of its children.
- *
- * <p>
- * For example, imagine you have a ViewForm and a ToolBar that share the same parent
- * and you want the ToolBar to be located in the upper-right corner of the ViewForm.
- * If the ToolBar were a child of the ViewForm, this could be done easily by calling
- * viewForm.setTopRight(toolBar). However, this is impossible since ViewForm.setTopRight
- * will only accept a child control. Instead, we create a ProxyControl as a child
- * of the viewForm, and set the toolbar as its target. The ViewForm will treat
- * the ProxyControl just like any other child, but it will actually be arranging the
- * ToolBar.
- * </p>
- * <p>For example:
- * </p>
- * <code>
- * // Create a ViewForm and a ToolBar that are siblings
- * ViewForm viewForm = new ViewForm(parent, SWT.NONE);
- * ToolBar toolBar = new ToolBar(parent, SWT.NONE);
- *
- * // Allow the ViewForm to control the position of the ToolBar by creating
- * // a ProxyControl in the ViewForm that targets the ToolBar.
- * ProxyControl toolBarProxy = new ProxyControl(viewForm);
- * toolBarProxy.setTarget(toolBar);
- * viewForm.setTopRight(toolBarProxy.getControl());
- * </code>
- *
- * <p>
- * This is intended to simplify management of view toolbars in the presentation API.
- * Presentation objects have no control over where the view toolbars are created in
- * the widget hierarchy, but they may wish to control the position of the view toolbars
- * using traditional SWT layouts and composites.
- * </p>
- */
-public class ProxyControl {
-
- /**
- * Invisible dummy control
- */
- private Composite control;
-
- /**
- * Target control (possibly null)
- */
- private Control target = null;
-
- /**
- * Target cache (possibly null)
- */
- private SizeCache targetCache = null;
-
- /**
- * Most specific common ancestor between the target and the proxy controls
- */
- private Control commonAncestor;
-
- /**
- * Visibility state of the proxy control the last time it had a non-null target.
- * Note: when the target is set to null, we force the proxy to become invisible
- * and use this variable to remember the initial state when we get a new non-null
- * target.
- */
- private boolean visible = true;
-
- /**
- * Dispose listener. Breaks the link between the target and the proxy if either
- * control is disposed.
- */
- private DisposeListener disposeListener = new DisposeListener() {
- public void widgetDisposed(DisposeEvent e) {
- if (e.widget == target || e.widget == control) {
- setTargetControl(null);
- }
- }
- };
-
- private Listener visibilityListener = new Listener() {
-
- public void handleEvent(Event event) {
- if (target != null) {
- visible = control.getVisible();
- target.setVisible(visible);
- }
- }
-
- };
-
- /**
- * Allow the visibility of the proxy control to be updated. When the target
- * is not <code>null</code> it's visibility is tied to the listener. But
- * in the case where some action causes the target to be populated while
- * its visibility is <code>false</code>, it won't re-appear until its
- * visibility is set to <code>true</code>.
- *
- * @param visible
- * <code>true</code> - set it to visible
- * @since 3.2
- */
- public void setVisible(boolean visible) {
-// this.visible = visible;
- }
-
- /**
- * Movement listener. Updates the bounds of the target to match the
- * bounds of the dummy control.
- */
- private ControlListener controlListener = new ControlListener() {
-
- public void controlMoved(ControlEvent e) {
- ProxyControl.this.layout();
- }
-
- public void controlResized(ControlEvent e) {
- //if (e.widget == control) {
- // ProxyControl.this.layout();
- //}
- }
-
- };
-
- /**
- * Creates a new ProxyControl as a child of the given parent. This is an invisible dummy
- * control. If given a target, the ProxyControl will update the bounds of the target to
- * match the bounds of the dummy control.
- *
- * @param parent parent composite
- */
- public ProxyControl(Composite parent) {
- // Create the invisible dummy composite
- control = new Composite(parent, SWT.NO_BACKGROUND);
- control.setVisible(false);
-
- // Attach a layout to the dummy composite. This is used to make the preferred
- // size of the dummy match the preferred size of the target.
- control.setLayout(new Layout() {
- protected void layout (Composite composite, boolean flushCache) {
- ProxyControl.this.layout();
- // does nothing. The bounds of the target are updated by the controlListener
- }
-
- protected Point computeSize (Composite composite, int wHint, int hHint, boolean flushCache) {
- if (targetCache == null) {
- if (target != null) {
- return target.computeSize(wHint, hHint, flushCache);
- }
- // Note: If we returned (0,0), SWT would ignore the result and use a default value.
- return new Point(1,1);
- }
-
- return targetCache.computeSize(wHint, hHint);
- }
- });
-
- // Attach listeners to the dummy
- control.addDisposeListener(disposeListener);
- control.addListener(SWT.Show, visibilityListener);
- control.addListener(SWT.Hide, visibilityListener);
- }
-
- /**
- * Sets the control whose position will be managed by this proxy
- *
- * @param target the control, or null if none
- */
- public void setTargetControl(Control target) {
- targetCache = null;
- internalSetTargetControl(target);
- }
-
- private void internalSetTargetControl(Control target) {
- if (this.target != target) {
-
- if (this.target != null) {
- for (Control next = control; next != commonAncestor && next != null; next = next.getParent()) {
- next.removeControlListener(controlListener);
- }
- commonAncestor = null;
-
- // If we already had a target, detach the dispose listener
- // (prevents memory leaks due to listeners)
- if (!this.target.isDisposed()) {
- this.target.removeDisposeListener(disposeListener);
- }
- }
-
- if (this.target == null && target != null) {
- // If we had previously forced the dummy control invisible, restore its visibility
- control.setVisible(visible);
- }
-
- this.target = target;
-
- if (target != null) {
- commonAncestor = SwtUtil.findCommonAncestor(this.target, control);
- for (Control next = control; next != null && next != commonAncestor; next = next.getParent()) {
- next.addControlListener(controlListener);
- }
-
- // Make the new target's visiblity match the visibility of the dummy control
- target.setVisible(control.getVisible());
- // Add a dispose listener. Ensures that the target is cleared
- // if it is ever disposed.
- target.addDisposeListener(disposeListener);
- } else {
- control.setVisible(false);
- }
- }
- }
-
- public void setTarget(SizeCache cache) {
- targetCache = cache;
-
- if (targetCache != null) {
- setTargetControl(cache.getControl());
- } else {
- setTargetControl(null);
- }
- }
-
- /**
- * Returns the proxy control
- *
- * @return the proxy control (not null)
- */
- public Control getControl() {
- return control;
- }
-
- public Control getTarget() {
- return target;
- }
-
- /**
- * Moves the target control on top of the dummy control.
- */
- public void layout() {
- if (getTarget() == null) {
- return;
- }
-
- // Compute the unclipped bounds of the target in display coordinates
- Rectangle displayBounds = Geometry.toDisplay(control.getParent(), control.getBounds());
-
- // Clip the bounds of the target so that it doesn't go outside the dummy control's parent
- Rectangle clippingRegion = DragUtil.getDisplayBounds(control.getParent());
- displayBounds = displayBounds.intersection(clippingRegion);
-
- // Compute the bounds of the target, in the local coordinate system of its parent
- Rectangle targetBounds = Geometry.toControl(getTarget().getParent(), displayBounds);
-
- // Move the target
- getTarget().setBounds(targetBounds);
- }
-}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/util/ReplaceDragHandler.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/util/ReplaceDragHandler.java
deleted file mode 100644
index f43fb1c5eae..00000000000
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/util/ReplaceDragHandler.java
+++ /dev/null
@@ -1,128 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2005 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.presentations.util;
-
-import org.eclipse.jface.util.Geometry;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.ui.internal.dnd.DragUtil;
-import org.eclipse.ui.presentations.StackDropResult;
-
-/**
- * @since 3.0
- */
-public class ReplaceDragHandler extends TabDragHandler {
-
- private final class DragCookie {
- int insertPosition;
-
- public DragCookie(int pos) {
- insertPosition = pos;
- }
- }
-
- private AbstractTabFolder tabFolder;
-
- public ReplaceDragHandler(AbstractTabFolder folder) {
- this.tabFolder = folder;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.internal.presentations.util.TabDragHandler#dragOver(org.eclipse.swt.widgets.Control, org.eclipse.swt.graphics.Point)
- */
- public StackDropResult dragOver(Control currentControl, Point location,
- int dragStart) {
-
- // Determine which tab we're currently dragging over
- //Point localPos = tabFolder.getControl().toControl(location);
-
- AbstractTabItem tabUnderPointer = tabFolder.getItem(location);
-
- // This drop target only deals with tabs... if we're not dragging over
- // a tab, exit.
- if (tabUnderPointer == null) {
- Rectangle titleArea = tabFolder.getTabArea();
-
- // If we're dragging over the title area, treat this as a drop in the last
- // tab position.
- if (titleArea.contains(location) && tabFolder.getItemCount() > 0) {
- int dragOverIndex = tabFolder.getItemCount();
- AbstractTabItem lastTab = tabFolder.getItem(dragOverIndex - 1);
-
- // Can't drag to end unless you can see the end
- if (!lastTab.isShowing()) {
- return null;
- }
-
- // If we are unable to compute the bounds for this tab, then ignore the drop
- Rectangle lastTabBounds = lastTab.getBounds();
- if (lastTabBounds.isEmpty()) {
- return null;
- }
-
- if (dragStart >= 0) {
- dragOverIndex--;
-
- return new StackDropResult(lastTabBounds, new Integer(
- dragOverIndex));
- }
-
- // Make the drag-over rectangle look like a tab at the end of the tab region.
- // We don't actually know how wide the tab will be when it's dropped, so just
- // make it 3 times wider than it is tall.
- Rectangle dropRectangle = titleArea;
-
- dropRectangle.x = lastTabBounds.x + lastTabBounds.width;
- dropRectangle.width = 3 * dropRectangle.height;
- return new StackDropResult(dropRectangle, new Integer(
- dragOverIndex));
-
- } else {
- // If the closest side is the side with the tabs, consider this a stack operation.
- // Otherwise, let the drop fall through to whatever the default behavior is
- Rectangle displayBounds = DragUtil.getDisplayBounds(tabFolder.getControl());
- int closestSide = Geometry.getClosestSide(displayBounds, location);
- if (closestSide == tabFolder.getTabPosition()) {
- return new StackDropResult(displayBounds, null);
- }
-
- return null;
- }
- }
-
- if (!tabUnderPointer.isShowing()) {
- return null;
- }
-
- Rectangle tabBounds = tabUnderPointer.getBounds();
-
- if (tabBounds.isEmpty()) {
- return null;
- }
-
- return new StackDropResult(tabBounds, new DragCookie(tabFolder
- .indexOf(tabUnderPointer)));
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.internal.presentations.util.TabDragHandler#getInsertionPosition(java.lang.Object)
- */
- public int getInsertionPosition(Object cookie) {
- if (cookie instanceof DragCookie) {
- return Math.min(tabFolder.getItemCount(),
- ((DragCookie) cookie).insertPosition);
- }
-
- return tabFolder.getItemCount();
- }
-
-}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/util/StandardEditorSystemMenu.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/util/StandardEditorSystemMenu.java
deleted file mode 100644
index 204407b236c..00000000000
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/util/StandardEditorSystemMenu.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2008 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.presentations.util;
-
-import org.eclipse.jface.action.Separator;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.actions.ActionFactory;
-import org.eclipse.ui.internal.WorkbenchMessages;
-import org.eclipse.ui.internal.presentations.SystemMenuCloseAll;
-import org.eclipse.ui.internal.presentations.SystemMenuCloseOthers;
-import org.eclipse.ui.presentations.IPresentablePart;
-import org.eclipse.ui.presentations.IStackPresentationSite;
-
-/**
- * Implements the standard system menu used by the default presentation.
- * Not intended to be subclassed by clients
- *
- * @since 3.1
- */
-public class StandardEditorSystemMenu extends StandardViewSystemMenu {
-
- private SystemMenuCloseOthers closeOthers;
- private SystemMenuCloseAll closeAll;
- private ActionFactory.IWorkbenchAction openAgain;
-
- /**
- * @param site
- */
- public StandardEditorSystemMenu(IStackPresentationSite site) {
- super(site);
-
- closeOthers = new SystemMenuCloseOthers(site);
- closeAll = new SystemMenuCloseAll(site);
- openAgain = ActionFactory.NEW_EDITOR.create(PlatformUI.getWorkbench().getActiveWorkbenchWindow());
- menuManager.add(closeOthers);
- menuManager.add(closeAll);
- menuManager.add(new Separator());
- menuManager.add(openAgain);
- }
-
- String getMoveMenuText() {
- return WorkbenchMessages.EditorPane_moveEditor;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.internal.presentations.util.ISystemMenu#show(org.eclipse.swt.widgets.Control, org.eclipse.swt.graphics.Point, org.eclipse.ui.presentations.IPresentablePart)
- */
- public void show(Control parent, Point displayCoordinates,
- IPresentablePart currentSelection) {
- closeOthers.setTarget(currentSelection);
- closeAll.update();
- super.show(parent, displayCoordinates, currentSelection);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.internal.presentations.util.StandardViewSystemMenu#dispose()
- */
- public void dispose() {
- openAgain.dispose();
- super.dispose();
- }
-}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/util/StandardSystemToolbar.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/util/StandardSystemToolbar.java
deleted file mode 100644
index adbb5e20996..00000000000
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/util/StandardSystemToolbar.java
+++ /dev/null
@@ -1,304 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2005 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.presentations.util;
-
-import org.eclipse.core.commands.common.EventManager;
-import org.eclipse.jface.action.ContributionItem;
-import org.eclipse.jface.action.ToolBarManager;
-import org.eclipse.jface.util.Geometry;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.MouseAdapter;
-import org.eclipse.swt.events.MouseEvent;
-import org.eclipse.swt.events.MouseListener;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.ToolBar;
-import org.eclipse.swt.widgets.ToolItem;
-import org.eclipse.ui.IPropertyListener;
-import org.eclipse.ui.internal.IWorkbenchGraphicConstants;
-import org.eclipse.ui.internal.WorkbenchImages;
-import org.eclipse.ui.internal.WorkbenchMessages;
-import org.eclipse.ui.presentations.IStackPresentationSite;
-
-/**
- * @since 3.1
- */
-public class StandardSystemToolbar extends EventManager {
- private ToolBarManager toolbarManager;
- private Composite control;
-
- private class SystemMenuContribution extends ContributionItem {
- ToolItem item;
- Image img;
- String text;
- int flags;
-
- public SystemMenuContribution() {
- this(SWT.PUSH);
- }
-
- public SystemMenuContribution(int flags) {
- this.flags = flags;
- }
-
- public void setToolTipText(String text) {
- this.text = text;
- if (item != null) {
- item.setToolTipText(text);
- }
- }
-
- public void setImage(Image img) {
- this.img = img;
-
- if (item != null) {
- item.setImage(img);
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.action.ContributionItem#setVisible(boolean)
- */
- public void setVisible(boolean visible) {
- if (visible != isVisible()) {
- toolbarManager.markDirty();
- }
-
- super.setVisible(visible);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.action.ContributionItem#fill(org.eclipse.swt.widgets.ToolBar, int)
- */
- public void fill(ToolBar parent, int index) {
- if (!isVisible()) {
- return;
- }
-
- item = new ToolItem(parent, flags, index);
- if (img != null) {
- item.setImage(img);
- }
- if (text != null) {
- item.setToolTipText(text);
- }
- item.addSelectionListener(selectionListener);
- }
- }
-
- private class PaneMenu extends SystemMenuContribution {
-
- public PaneMenu() {
- super(SWT.NONE);
- }
-
- public void setToolTipText(String text) {
- super.setToolTipText(text);
- }
-
- public void setImage(Image img) {
-
- super.setImage(img);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.action.ContributionItem#fill(org.eclipse.swt.widgets.ToolBar, int)
- */
- public void fill(ToolBar parent, int index) {
- if (!isVisible()) {
- return;
- }
- super.fill(parent, index);
- }
- }
-
-
- private MouseListener mouseListener = new MouseAdapter() {
- /* (non-Javadoc)
- * @see org.eclipse.swt.events.MouseAdapter#mouseDown(org.eclipse.swt.events.MouseEvent)
- */
- public void mouseDown(MouseEvent e) {
- ToolItem item = toolbarManager.getControl().getItem(new Point(e.x, e.y));
-
- if (item == paneMenu.item && e.button == 1) {
- fireEvent(TabFolderEvent.EVENT_PANE_MENU);
- }
- }
- };
-
- private SystemMenuContribution paneMenu = new PaneMenu();
- private SystemMenuContribution showToolbar = new SystemMenuContribution();
- private SystemMenuContribution min = new SystemMenuContribution();
- private SystemMenuContribution max = new SystemMenuContribution();
- private SystemMenuContribution close = new SystemMenuContribution();
-
- private int state = IStackPresentationSite.STATE_RESTORED;
- private boolean showingToolbar = true;
-
- private SelectionAdapter selectionListener = new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- if (e.widget == paneMenu.item) {
- //fireEvent(TabFolderEvent.EVENT_PANE_MENU);
- } else if (e.widget == showToolbar.item) {
- if (showingToolbar) {
- fireEvent(TabFolderEvent.EVENT_HIDE_TOOLBAR);
- } else {
- fireEvent(TabFolderEvent.EVENT_SHOW_TOOLBAR);
- }
- } else if (e.widget == min.item) {
- if (state == IStackPresentationSite.STATE_MINIMIZED) {
- fireEvent(TabFolderEvent.EVENT_RESTORE);
- } else {
- fireEvent(TabFolderEvent.EVENT_MINIMIZE);
- }
- } else if (e.widget == max.item) {
- if (state == IStackPresentationSite.STATE_MAXIMIZED) {
- fireEvent(TabFolderEvent.EVENT_RESTORE);
- } else {
- fireEvent(TabFolderEvent.EVENT_MAXIMIZE);
- }
- } else if (e.widget == close.item) {
- fireEvent(TabFolderEvent.EVENT_CLOSE);
- }
- }
- };
-
- public StandardSystemToolbar(Composite parent, boolean showPaneMenu,
- boolean showHideToolbar, boolean showMinimize, boolean showMaximize, boolean enableClose) {
-
- control = new Composite(parent, SWT.NONE);
- control.setLayout(new EnhancedFillLayout());
-
- toolbarManager = new ToolBarManager(SWT.FLAT);
- toolbarManager.createControl(control);
- toolbarManager.getControl().addMouseListener(mouseListener);
-
- toolbarManager.add(paneMenu);
- paneMenu.setImage(WorkbenchImages.getImage(IWorkbenchGraphicConstants.IMG_LCL_VIEW_MENU_THIN));
- paneMenu.setVisible(showPaneMenu);
- paneMenu.setToolTipText(WorkbenchMessages.Menu);
-
- toolbarManager.add(showToolbar);
- showToolbar.setImage(WorkbenchImages.getImage(IWorkbenchGraphicConstants.IMG_LCL_HIDE_TOOLBAR_THIN));
- showToolbar.setVisible(showHideToolbar);
-
- toolbarManager.add(min);
- min.setVisible(showMinimize);
-
- toolbarManager.add(max);
- max.setVisible(showMaximize);
-
- toolbarManager.add(close);
- close.setImage(WorkbenchImages.getImage(IWorkbenchGraphicConstants.IMG_LCL_CLOSE_VIEW_THIN));
- close.setVisible(enableClose);
-
- setState(IStackPresentationSite.STATE_RESTORED);
-
- toolbarManager.update(true);
- }
-
- public Point getPaneMenuLocation() {
-
- Rectangle bounds = Geometry.toDisplay(paneMenu.item.getParent(), paneMenu.item.getBounds());
- return new Point(bounds.x, bounds.y + bounds.height);
- }
-
- public void enableClose(boolean enabled) {
- close.setVisible(enabled);
- toolbarManager.update(false);
- }
-
- public void enableMinimize(boolean enabled) {
- min.setVisible(enabled);
- toolbarManager.update(false);
- }
-
- public void enableMaximize(boolean enabled) {
- max.setVisible(enabled);
- toolbarManager.update(false);
- }
-
- public void enableShowToolbar(boolean enabled) {
- showToolbar.setVisible(enabled);
- toolbarManager.update(false);
- }
-
- public void enablePaneMenu(boolean enabled) {
- paneMenu.setVisible(enabled);
- toolbarManager.update(false);
- }
-
- /**
- * Updates the icons on the state buttons to match the given state
- * @param newState
- * @since 3.1
- */
- public void setState(int newState) {
- if (min != null) {
- if (newState == IStackPresentationSite.STATE_MINIMIZED) {
- min.setToolTipText(WorkbenchMessages.StandardSystemToolbar_Restore);
- min.setImage(WorkbenchImages.getImage(IWorkbenchGraphicConstants.IMG_LCL_RESTORE_VIEW_THIN));
- } else {
- min.setToolTipText(WorkbenchMessages.StandardSystemToolbar_Minimize);
- min.setImage(WorkbenchImages.getImage(IWorkbenchGraphicConstants.IMG_LCL_MIN_VIEW_THIN));
- }
- }
- if (max != null) {
- if (newState == IStackPresentationSite.STATE_MAXIMIZED) {
- max.setToolTipText(WorkbenchMessages.StandardSystemToolbar_Restore);
- max.setImage(WorkbenchImages.getImage(IWorkbenchGraphicConstants.IMG_LCL_RESTORE_VIEW_THIN));
- } else {
- max.setToolTipText(WorkbenchMessages.StandardSystemToolbar_Maximize);
- max.setImage(WorkbenchImages.getImage(IWorkbenchGraphicConstants.IMG_LCL_MAX_VIEW_THIN));
- }
- }
-
- state = newState;
- }
-
- public void setToolbarShowing(boolean isShowing) {
- showingToolbar = isShowing;
- if (showToolbar != null) {
- if (isShowing) {
- showToolbar.setImage(WorkbenchImages.getImage(IWorkbenchGraphicConstants.IMG_LCL_HIDE_TOOLBAR_THIN));
- } else {
- showToolbar.setImage(WorkbenchImages.getImage(IWorkbenchGraphicConstants.IMG_LCL_SHOW_TOOLBAR_THIN));
- }
- }
- }
-
- public void addListener(IPropertyListener propertyListener) {
- addListenerObject(propertyListener);
- }
-
- public void removeListener(IPropertyListener propertyListener) {
- removeListenerObject(propertyListener);
- }
-
- public Control getControl() {
- return control;
- }
-
- private void fireEvent(int event) {
- Object[] list = getListeners();
-
- for (int i = 0; i < list.length; i++) {
- IPropertyListener listener = (IPropertyListener)list[i];
-
- listener.propertyChanged(this, event);
- }
- }
-}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/util/StandardViewSystemMenu.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/util/StandardViewSystemMenu.java
deleted file mode 100644
index 49140ea0449..00000000000
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/util/StandardViewSystemMenu.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2007 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.presentations.util;
-
-import org.eclipse.jface.action.GroupMarker;
-import org.eclipse.jface.action.MenuManager;
-import org.eclipse.jface.action.Separator;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Menu;
-import org.eclipse.ui.internal.WorkbenchMessages;
-import org.eclipse.ui.internal.presentations.SystemMenuClose;
-import org.eclipse.ui.internal.presentations.SystemMenuMaximize;
-import org.eclipse.ui.internal.presentations.SystemMenuMinimize;
-import org.eclipse.ui.internal.presentations.SystemMenuMove;
-import org.eclipse.ui.internal.presentations.SystemMenuRestore;
-import org.eclipse.ui.internal.presentations.UpdatingActionContributionItem;
-import org.eclipse.ui.presentations.IPresentablePart;
-import org.eclipse.ui.presentations.IStackPresentationSite;
-
-/**
- * Implements the system context menu that is used by the default presentation. Not
- * intended to be subclassed by clients.
- *
- * @since 3.1
- */
-public class StandardViewSystemMenu implements ISystemMenu {
-
- /* package */ MenuManager menuManager = new MenuManager();
- private SystemMenuRestore restore;
- private SystemMenuMove move;
- private SystemMenuMinimize minimize;
- private SystemMenuMaximize maximize;
- private SystemMenuClose close;
-
- /**
- * Create the standard view menu
- *
- * @param site the site to associate the view with
- */
- public StandardViewSystemMenu(IStackPresentationSite site) {
- restore = new SystemMenuRestore(site);
- move = new SystemMenuMove(site, getMoveMenuText(), false);
- minimize = new SystemMenuMinimize(site);
- maximize = new SystemMenuMaximize(site);
- close = new SystemMenuClose(site);
-
- { // Initialize system menu
- menuManager.add(new GroupMarker("misc")); //$NON-NLS-1$
- menuManager.add(new GroupMarker("restore")); //$NON-NLS-1$
- menuManager.add(new UpdatingActionContributionItem(restore));
-
- menuManager.add(move);
- menuManager.add(new GroupMarker("size")); //$NON-NLS-1$
- menuManager.add(new GroupMarker("state")); //$NON-NLS-1$
- menuManager.add(new UpdatingActionContributionItem(minimize));
-
- menuManager.add(new UpdatingActionContributionItem(maximize));
- menuManager.add(new Separator("close")); //$NON-NLS-1$
- menuManager.add(close);
-
- site.addSystemActions(menuManager);
- } // End of system menu initialization
-
- }
-
- String getMoveMenuText() {
- return WorkbenchMessages.ViewPane_moveView;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.internal.presentations.util.ISystemMenu#show(org.eclipse.swt.graphics.Point, org.eclipse.ui.presentations.IPresentablePart)
- */
- public void show(Control parent, Point displayCoordinates, IPresentablePart currentSelection) {
- restore.update();
- move.setTarget(currentSelection);
- move.update();
- minimize.update();
- maximize.update();
- close.setTarget(currentSelection);
-
- Menu aMenu = menuManager.createContextMenu(parent);
- menuManager.update(true);
- aMenu.setLocation(displayCoordinates.x, displayCoordinates.y);
- aMenu.setVisible(true);
- }
-
- /**
- * Dispose resources associated with this menu
- */
- public void dispose() {
- menuManager.dispose();
- menuManager.removeAll();
- }
-
-}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/util/TabDragHandler.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/util/TabDragHandler.java
deleted file mode 100644
index 9d29445d064..00000000000
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/util/TabDragHandler.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2005 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.presentations.util;
-
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.ui.presentations.StackDropResult;
-
-/**
- * @since 3.0
- */
-public abstract class TabDragHandler {
-
- /**
- * Returns the StackDropResult for the location being dragged over.
- *
- * @param currentControl control being dragged over
- * @param location mouse position (display coordinates)
- * @param initialTab the index of the tab in this stack being dragged,
- * or -1 if dragging a tab from another stack.
- * @return the StackDropResult for this drag location
- */
- public abstract StackDropResult dragOver(Control currentControl,
- Point location, int initialTab);
-
- public abstract int getInsertionPosition(Object cookie);
-}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/util/TabFolderEvent.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/util/TabFolderEvent.java
deleted file mode 100644
index 936e9297135..00000000000
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/util/TabFolderEvent.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2007 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
- * Stefan Xenos, IBM; Chris Torrence, ITT Visual Information Solutions - bug 51580
- *******************************************************************************/
-package org.eclipse.ui.internal.presentations.util;
-
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.ui.presentations.IStackPresentationSite;
-
-/**
- * @since 3.1
- */
-public class TabFolderEvent {
- public static final int EVENT_PANE_MENU = 1;
- public static final int EVENT_HIDE_TOOLBAR = 2;
- public static final int EVENT_SHOW_TOOLBAR = 3;
- public static final int EVENT_RESTORE = 4;
- public static final int EVENT_MINIMIZE = 5;
- public static final int EVENT_CLOSE = 6;
- public static final int EVENT_MAXIMIZE = 7;
- public static final int EVENT_TAB_SELECTED = 8;
- public static final int EVENT_GIVE_FOCUS_TO_PART = 9;
- public static final int EVENT_DRAG_START = 10;
- public static final int EVENT_SHOW_LIST = 11;
- public static final int EVENT_SYSTEM_MENU = 12;
- public static final int EVENT_PREFERRED_SIZE = 13;
-
- public static int eventIdToStackState(int eventId) {
- switch(eventId) {
- case EVENT_RESTORE: return IStackPresentationSite.STATE_RESTORED;
- case EVENT_MINIMIZE: return IStackPresentationSite.STATE_MINIMIZED;
- case EVENT_MAXIMIZE: return IStackPresentationSite.STATE_MAXIMIZED;
- }
-
- return 0;
- }
-
- public static int stackStateToEventId(int stackState) {
- switch(stackState) {
- case IStackPresentationSite.STATE_RESTORED: return EVENT_RESTORE;
- case IStackPresentationSite.STATE_MINIMIZED: return EVENT_MINIMIZE;
- case IStackPresentationSite.STATE_MAXIMIZED: return EVENT_MAXIMIZE;
- }
-
- return 0;
- }
-
- public AbstractTabItem tab;
- public int type;
- public int x;
- public int y;
-
- public TabFolderEvent(int type) {
- this.type = type;
- }
-
- public TabFolderEvent(int type, AbstractTabItem w, int x, int y) {
- this.type = type;
- this.tab = w;
- this.x = x;
- this.y = y;
- }
-
- public TabFolderEvent(int type, AbstractTabItem w, Point pos) {
- this.type = type;
- this.tab = w;
- this.x = pos.x;
- this.y = pos.y;
- }
-}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/util/TabFolderListener.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/util/TabFolderListener.java
deleted file mode 100644
index d62ff52255d..00000000000
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/util/TabFolderListener.java
+++ /dev/null
@@ -1,18 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2005 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.presentations.util;
-
-/**
- * @since 3.1
- */
-public abstract class TabFolderListener {
- public abstract void handleEvent(TabFolderEvent e);
-}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/util/TabOrder.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/util/TabOrder.java
deleted file mode 100644
index 4aa2b32dc59..00000000000
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/util/TabOrder.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2005 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.presentations.util;
-
-import org.eclipse.ui.IMemento;
-import org.eclipse.ui.presentations.IPresentablePart;
-import org.eclipse.ui.presentations.IPresentationSerializer;
-
-/**
- * @since 3.0
- */
-public abstract class TabOrder {
- /**
- * Adds a part due to a user action that opened a part
- *
- * @param newPart part being added
- */
- public abstract void add(IPresentablePart newPart);
-
- /**
- * Adds a part at initialization-time (the part was added as
- * part of a perspective, rather than by a user action)
- *
- * @param newPart the part being added
- */
- public abstract void addInitial(IPresentablePart newPart);
-
- public abstract void restoreState(IPresentationSerializer serializer,
- IMemento savedState);
-
- public abstract void saveState(IPresentationSerializer serializer, IMemento memento);
-
- /**
- * Adds a part at a particular index due to a drag/drop operation.
- *
- * @param added part being added
- * @param index index where the part is added at
- */
- public abstract void insert(IPresentablePart added, int index);
-
- public abstract void move(IPresentablePart toMove, int newIndex);
-
- /**
- * Removes a part
- *
- * @param removed part being removed
- */
- public abstract void remove(IPresentablePart removed);
-
- /**
- * Selects a part
- *
- * @param selected part being selected
- */
- public abstract void select(IPresentablePart selected);
-
- public abstract IPresentablePart[] getPartList();
-}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/util/TabbedStackPresentation.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/util/TabbedStackPresentation.java
deleted file mode 100644
index 416404ddc0e..00000000000
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/util/TabbedStackPresentation.java
+++ /dev/null
@@ -1,597 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 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
- * Stefan Xenos, IBM - bug 51580
- * Chris Torrence, ITT Visual Information Solutions - bugs 51580 202208
- *******************************************************************************/
-package org.eclipse.ui.internal.presentations.util;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.core.runtime.Plugin;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.DisposeEvent;
-import org.eclipse.swt.events.DisposeListener;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.ui.IMemento;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.internal.preferences.IDynamicPropertyMap;
-import org.eclipse.ui.internal.preferences.PreferenceStoreAdapter;
-import org.eclipse.ui.internal.preferences.PreferencesAdapter;
-import org.eclipse.ui.internal.preferences.PropertyMapAdapter;
-import org.eclipse.ui.internal.preferences.ThemeManagerAdapter;
-import org.eclipse.ui.internal.presentations.defaultpresentation.DefaultPartList;
-import org.eclipse.ui.internal.util.PrefUtil;
-import org.eclipse.ui.presentations.IPartMenu;
-import org.eclipse.ui.presentations.IPresentablePart;
-import org.eclipse.ui.presentations.IPresentationSerializer;
-import org.eclipse.ui.presentations.IStackPresentationSite;
-import org.eclipse.ui.presentations.StackDropResult;
-import org.eclipse.ui.presentations.StackPresentation;
-
-/**
- * @since 3.0
- */
-public final class TabbedStackPresentation extends StackPresentation {
-
- private PresentablePartFolder folder;
- private ISystemMenu systemMenu;
- private ISystemMenu partList;
- private PreferenceStoreAdapter apiPreferences = new PreferenceStoreAdapter(PrefUtil
- .getAPIPreferenceStore());
- private ThemeManagerAdapter themePreferences = new ThemeManagerAdapter(
- PlatformUI.getWorkbench().getThemeManager());
-
- private TabOrder tabs;
-
- private TabDragHandler dragBehavior;
-
- private boolean initializing = true;
- private int ignoreSelectionChanges = 0;
-
- private TabFolderListener tabFolderListener = new TabFolderListener() {
- public void handleEvent(TabFolderEvent e) {
- switch (e.type) {
- case TabFolderEvent.EVENT_MINIMIZE: {
- getSite().setState(IStackPresentationSite.STATE_MINIMIZED);
- break;
- }
- case TabFolderEvent.EVENT_MAXIMIZE: {
- getSite().setState(IStackPresentationSite.STATE_MAXIMIZED);
- break;
- }
- case TabFolderEvent.EVENT_RESTORE: {
- getSite().setState(IStackPresentationSite.STATE_RESTORED);
- break;
- }
- case TabFolderEvent.EVENT_CLOSE: {
- IPresentablePart part = folder.getPartForTab(e.tab);
-
- if (part != null) {
- getSite().close(new IPresentablePart[] { part });
- }
- break;
- }
- case TabFolderEvent.EVENT_SHOW_LIST: {
- showPartList();
- break;
- }
- case TabFolderEvent.EVENT_GIVE_FOCUS_TO_PART: {
- IPresentablePart part = getSite().getSelectedPart();
- if (part != null) {
- part.setFocus();
- }
- break;
- }
- case TabFolderEvent.EVENT_PANE_MENU: {
- IPresentablePart part = getSite().getSelectedPart();
- if (part != null) {
- part.setFocus();
- }
- TabbedStackPresentation.this.showPaneMenu(folder
- .getPartForTab(e.tab), new Point(e.x, e.y));
- break;
- }
- case TabFolderEvent.EVENT_DRAG_START: {
- AbstractTabItem beingDragged = e.tab;
- Point initialLocation = new Point(e.x, e.y);
-
- if (beingDragged == null) {
- getSite().dragStart(initialLocation, false);
- } else {
- IPresentablePart part = folder.getPartForTab(beingDragged);
-
- try {
- dragStart = folder.indexOf(part);
- getSite().dragStart(part, initialLocation, false);
- } finally {
- dragStart = -1;
- }
- }
- break;
- }
- case TabFolderEvent.EVENT_TAB_SELECTED: {
- if (ignoreSelectionChanges > 0) {
- return;
- }
-
- IPresentablePart part = folder.getPartForTab(e.tab);
-
- if (part != null) {
- getSite().selectPart(part);
- }
- break;
- }
- case TabFolderEvent.EVENT_SYSTEM_MENU: {
- IPresentablePart part = folder.getPartForTab(e.tab);
-
- if (part == null) {
- part = getSite().getSelectedPart();
- }
-
- if (part != null) {
- showSystemMenu(new Point(e.x, e.y), part);
- }
- break;
- }
- case TabFolderEvent.EVENT_PREFERRED_SIZE: {
- IPresentablePart part = folder.getPartForTab(e.tab);
- if (part == null) {
- // Standalone views with no title have no tab, so just get the part.
- IPresentablePart[] parts = getSite().getPartList();
- if (parts.length > 0) part = parts[0];
- }
- if (part == getSite().getSelectedPart()) {
- getSite().flushLayout();
- }
- break;
- }
- }
- }
- };
-
- private int dragStart = -1;
- private Map prefs = new HashMap();
-
- public TabbedStackPresentation(IStackPresentationSite site, AbstractTabFolder widget, ISystemMenu systemMenu) {
- this(site, new PresentablePartFolder(widget), systemMenu);
- }
-
- public TabbedStackPresentation(IStackPresentationSite site, PresentablePartFolder folder, ISystemMenu systemMenu) {
- this(site, folder, new LeftToRightTabOrder(folder), new ReplaceDragHandler(folder.getTabFolder()), systemMenu);
- }
-
- public TabbedStackPresentation(IStackPresentationSite site,
- PresentablePartFolder newFolder, TabOrder tabs, TabDragHandler dragBehavior, ISystemMenu systemMenu) {
- super(site);
- this.systemMenu = systemMenu;
-
- this.folder = newFolder;
- this.tabs = tabs;
- this.dragBehavior = dragBehavior;
-
- // Add a dispose listener. This will call the presentationDisposed()
- // method when the widget is destroyed.
- folder.getTabFolder().getControl().addDisposeListener(new DisposeListener() {
- public void widgetDisposed(DisposeEvent e) {
- presentationDisposed();
- }
- });
-
- folder.getTabFolder().addListener(tabFolderListener);
-
- this.partList = new DefaultPartList(site, newFolder);
- }
-
- /**
- * Restores a presentation from a previously stored state
- *
- * @param serializer (not null)
- * @param savedState (not null)
- */
- public void restoreState(IPresentationSerializer serializer,
- IMemento savedState) {
- tabs.restoreState(serializer, savedState);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.presentations.StackPresentation#saveState(org.eclipse.ui.presentations.IPresentationSerializer, org.eclipse.ui.IMemento)
- */
- public void saveState(IPresentationSerializer context, IMemento memento) {
- super.saveState(context, memento);
-
- tabs.saveState(context, memento);
- }
-
- /**
- * Returns true iff the presentation has been disposed
- *
- * @return true iff the presentation has been disposed
- */
- private boolean isDisposed() {
- return folder == null || folder.isDisposed();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.presentations.StackPresentation#setBounds(org.eclipse.swt.graphics.Rectangle)
- */
- public void setBounds(Rectangle bounds) {
- folder.setBounds(bounds);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.presentations.StackPresentation#computeMinimumSize()
- */
- public Point computeMinimumSize() {
- return folder.getTabFolder().computeSize(SWT.DEFAULT, SWT.DEFAULT);
- }
-
- /**
- * Returns the minimum size for this stack, taking into account
- * the available perpendicular space.
- * @param width indicates whether a width (=true) or a height (=false) is being computed
- * @param availablePerpendicular available space perpendicular to the direction being measured
- * or INFINITE if unbounded (pixels).
- * @return returns the preferred minimum size (pixels).
- * This is a width if width == true or a height if width == false.
- */
- private int computePreferredMinimumSize(boolean width, int availablePerpendicular) {
- int minSize;
- int hint = availablePerpendicular == INFINITE ? SWT.DEFAULT : availablePerpendicular;
- if (width) {
- minSize = folder.getTabFolder().computeSize(SWT.DEFAULT, hint).x;
- } else {
- minSize = folder.getTabFolder().computeSize(hint, SWT.DEFAULT).y;
- }
- return minSize;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.ISizeProvider#computePreferredSize(boolean, int, int, int)
- */
- public int computePreferredSize(boolean width, int availableParallel,
- int availablePerpendicular, int preferredResult) {
-
- // If there is exactly one part in the stack, this just returns the
- // preferred size of the part as the preferred size of the stack.
- IPresentablePart[] parts = getSite().getPartList();
- if (parts.length == 1 && parts[0] != null
- && !(getSite().getState() == IStackPresentationSite.STATE_MINIMIZED)) {
- int partSize = parts[0].computePreferredSize(width,
- availableParallel, availablePerpendicular, preferredResult);
-
- if (partSize == INFINITE)
- return partSize;
-
- // Adjust preferred size to take into account tab and border trim.
- int minSize = computePreferredMinimumSize(width, availablePerpendicular);
- if (width) {
- // PaneFolder adds some bogus tab spacing, so just find the maximum width.
- partSize = Math.max(minSize, partSize);
- } else {
- // Add them (but only if there's enough room)
- if (INFINITE-minSize > partSize)
- partSize += minSize;
- }
-
- return partSize;
- }
-
- if (preferredResult != INFINITE || getSite().getState() == IStackPresentationSite.STATE_MINIMIZED) {
- int minSize = computePreferredMinimumSize(width, availablePerpendicular);
-
- if (getSite().getState() == IStackPresentationSite.STATE_MINIMIZED) {
- return minSize;
- }
-
- return Math.max(minSize, preferredResult);
- }
-
- return INFINITE;
- }
-
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.presentations.StackPresentation#getSizeFlags(boolean)
- */
- public int getSizeFlags(boolean width) {
- int flags = 0;
- // If there is exactly one part in the stack,
- // then take into account the size flags of the part.
- IPresentablePart[] parts = getSite().getPartList();
- if (parts.length == 1 && parts[0] != null) {
- flags |= parts[0].getSizeFlags(width);
- }
-
- return flags | super.getSizeFlags(width);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.presentations.StackPresentation#showPartList()
- */
- public void showPartList() {
- if (partList != null) {
- final int numberOfParts = folder.getTabFolder().getItemCount();
- if (numberOfParts > 0) {
- partList.show(getControl(), folder.getTabFolder()
- .getPartListLocation(), getSite().getSelectedPart());
- }
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.presentations.StackPresentation#dispose()
- */
- public void dispose() {
- // Dispose the tab folder's widgetry
- folder.getTabFolder().getControl().dispose();
- }
-
- /**
- * Called when the tab folder is disposed.
- */
- private void presentationDisposed() {
- apiPreferences.dispose();
- themePreferences.dispose();
-
- Iterator iter = prefs.values().iterator();
- while(iter.hasNext()) {
- PropertyMapAdapter next = (PropertyMapAdapter)iter.next();
- next.dispose();
- }
-
- if (systemMenu != null) {
- systemMenu.dispose();
- }
-
- if (partList != null) {
- partList.dispose();
- }
-
- systemMenu = null;
- partList = null;
-
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.presentations.StackPresentation#setActive(int)
- */
- public void setActive(int newState) {
- folder.getTabFolder().setActive(newState);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.presentations.StackPresentation#setVisible(boolean)
- */
- public void setVisible(boolean isVisible) {
- IPresentablePart current = getSite().getSelectedPart();
- if (current != null) {
- current.setVisible(isVisible);
- }
-
- folder.setVisible(isVisible);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.presentations.StackPresentation#setState(int)
- */
- public void setState(int state) {
- folder.getTabFolder().setState(state);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.presentations.StackPresentation#getControl()
- */
- public Control getControl() {
- return folder.getTabFolder().getControl();
- }
-
- /**
- * @return AbstractTabFolder the presentation's tab folder
- */
- public AbstractTabFolder getTabFolder() {
- return folder.getTabFolder();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.presentations.StackPresentation#addPart(org.eclipse.ui.presentations.IPresentablePart, java.lang.Object)
- */
- public void addPart(IPresentablePart newPart, Object cookie) {
- ignoreSelectionChanges++;
- try {
- if (initializing) {
- tabs.addInitial(newPart);
- } else {
- if (cookie == null) {
- tabs.add(newPart);
- } else {
- int insertionPoint = dragBehavior
- .getInsertionPosition(cookie);
-
- tabs.insert(newPart, insertionPoint);
- }
- }
- } finally {
- ignoreSelectionChanges--;
- }
-
- if (tabs.getPartList().length == 1) {
- if (newPart.getSizeFlags(true) != 0 || newPart.getSizeFlags(false) != 0) {
- getSite().flushLayout();
- }
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.presentations.StackPresentation#movePart(org.eclipse.ui.presentations.IPresentablePart, java.lang.Object)
- */
- public void movePart(IPresentablePart toMove, Object cookie) {
- ignoreSelectionChanges++;
- try {
- int insertionPoint = dragBehavior.getInsertionPosition(cookie);
-
- if (insertionPoint == folder.indexOf(toMove)) {
- return;
- }
-
- tabs.move(toMove, insertionPoint);
- } finally {
- ignoreSelectionChanges--;
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.presentations.StackPresentation#removePart(org.eclipse.ui.presentations.IPresentablePart)
- */
- public void removePart(IPresentablePart oldPart) {
- ignoreSelectionChanges++;
- try {
- tabs.remove(oldPart);
- } finally {
- ignoreSelectionChanges--;
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.presentations.StackPresentation#selectPart(org.eclipse.ui.presentations.IPresentablePart)
- */
- public void selectPart(IPresentablePart toSelect) {
- initializing = false;
-
- tabs.select(toSelect);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.presentations.StackPresentation#dragOver(org.eclipse.swt.widgets.Control, org.eclipse.swt.graphics.Point)
- */
- public StackDropResult dragOver(Control currentControl, Point location) {
- return dragBehavior.dragOver(currentControl, location, dragStart);
- }
-
- public void showSystemMenu() {
- showSystemMenu(folder.getTabFolder().getSystemMenuLocation(), getSite().getSelectedPart());
- }
-
- public void showSystemMenu(Point displayCoordinates, IPresentablePart context) {
- if (context != getSite().getSelectedPart()) {
- getSite().selectPart(context);
- }
- systemMenu.show(getControl(), displayCoordinates, context);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.presentations.StackPresentation#showPaneMenu()
- */
- public void showPaneMenu() {
- IPresentablePart part = getSite().getSelectedPart();
-
- if (part != null) {
- showPaneMenu(part, folder.getTabFolder().getPaneMenuLocation());
- }
- }
-
- public void showPaneMenu(IPresentablePart part, Point location) {
- Assert.isTrue(!isDisposed());
-
- IPartMenu menu = part.getMenu();
-
- if (menu != null) {
- menu.showMenu(location);
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.presentations.StackPresentation#getTabList(org.eclipse.ui.presentations.IPresentablePart)
- */
- public Control[] getTabList(IPresentablePart part) {
- ArrayList list = new ArrayList();
- if (folder.getTabFolder().getTabPosition() == SWT.BOTTOM) {
- if (part.getControl() != null) {
- list.add(part.getControl());
- }
- }
-
- list.add(folder.getTabFolder().getControl());
-
- if (part.getToolBar() != null) {
- list.add(part.getToolBar());
- }
-
- if (folder.getTabFolder().getTabPosition() == SWT.TOP) {
- if (part.getControl() != null) {
- list.add(part.getControl());
- }
- }
-
- return (Control[]) list.toArray(new Control[list.size()]);
- }
-
- public void setPartList(ISystemMenu menu) {
- this.partList = menu;
- }
-
- public IDynamicPropertyMap getTheme() {
- return themePreferences;
- }
-
- public IDynamicPropertyMap getApiPreferences() {
- return apiPreferences;
- }
-
- public IDynamicPropertyMap getPluginPreferences(Plugin toQuery) {
- String id = toQuery.getBundle().getSymbolicName();
- IDynamicPropertyMap result = (IDynamicPropertyMap)prefs.get(id);
-
- if (result != null) {
- return result;
- }
-
- result = new PreferencesAdapter(toQuery.getPluginPreferences());
- prefs.put(id, result);
- return result;
- }
-
- /**
- * Move the tabs around. This is for testing <b>ONLY</b>.
- * @param part the part to move
- * @param index the new index
- * @since 3.2
- */
- public void moveTab(IPresentablePart part, int index) {
- tabs.move(part, index);
- folder.layout(true);
- }
-
- /**
- * Get the tab list. This is for testing <b>ONLY</b>.
- * @return the presentable parts in order.
- * @since 3.2
- */
- public IPresentablePart[] getPartList() {
- return tabs.getPartList();
- }
-
- /**
- * Cause the folder to hide or show its
- * Minimize and Maximize affordances.
- *
- * @param show
- * <code>true</code> - the min/max buttons are visible.
- * @since 3.3
- */
- public void showMinMax(boolean show) {
- folder.getTabFolder().showMinMax(show);
- }
-}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/util/WidgetTabItem.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/util/WidgetTabItem.java
deleted file mode 100644
index 8bf63a26b2e..00000000000
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/util/WidgetTabItem.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2005 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.presentations.util;
-
-import org.eclipse.swt.widgets.Widget;
-
-/**
- * @since 3.1
- */
-public abstract class WidgetTabItem extends AbstractTabItem {
-
- private Object data;
- private Widget widget;
-
- public WidgetTabItem(Widget theWidget) {
- this.widget = theWidget;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.internal.presentations.util.AbstractTabItem#dispose()
- */
- public void dispose() {
- widget.dispose();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.internal.presentations.util.AbstractTabItem#getData()
- */
- public Object getData() {
- return data;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.internal.presentations.util.AbstractTabItem#setData(java.lang.Object)
- */
- public void setData(Object data) {
- this.data = data;
- }
-
- public Widget getWidget() {
- return widget;
- }
-}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/progress/TaskBarProgressManager.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/progress/TaskBarProgressManager.java
deleted file mode 100644
index f4fe6636b45..00000000000
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/progress/TaskBarProgressManager.java
+++ /dev/null
@@ -1,350 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 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:
- * Tasktop Technologies - initial API and implementation
- ******************************************************************************/
-
-package org.eclipse.ui.internal.progress;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.jobs.Job;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.DisposeEvent;
-import org.eclipse.swt.events.DisposeListener;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.widgets.TaskItem;
-import org.eclipse.ui.progress.IProgressConstants;
-import org.eclipse.ui.progress.IProgressConstants2;
-import org.eclipse.ui.progress.WorkbenchJob;
-
-/**
- * The TaskBarProgressManager is the class that displays progress in the
- * application TaskBar if the job specifies that it should show progress (@see
- * {@link IProgressConstants2#SHOW_IN_TASKBAR_ICON_PROPERTY}
- *
- * @since 3.6
- */
-public class TaskBarProgressManager {
-
- private IJobProgressManagerListener listener;
-
- private WorkbenchJob animationUpdateJob;
-
- private boolean isAnimated = false;
-
- private List jobs = Collections.synchronizedList(new ArrayList());
-
- private Map jobInfoMap = Collections.synchronizedMap(new HashMap());
-
- private final TaskItem taskItem;
-
- private ImageDescriptor overlayDescriptor;
-
- private Image overlayImage;
-
- public TaskBarProgressManager(TaskItem taskItem) {
- Assert.isNotNull(taskItem);
- this.taskItem = taskItem;
- animationUpdateJob = getAnimationUpdateJob();
- animationUpdateJob.setSystem(true);
- listener = getProgressListener();
-
- // Register the IJobProgressManagerListener so we can display progress
- // on the application TaskBar
- ProgressManager.getInstance().addListener(listener);
-
- taskItem.addDisposeListener(new DisposeListener() {
- public void widgetDisposed(DisposeEvent e) {
- dispose();
- }
- });
- }
-
- /**
- * Remove the listener and stop the animation
- */
- public void dispose() {
- ProgressManager.getInstance().removeListener(listener);
- setAnimated(false);
- disposeOverlay();
- }
-
- private WorkbenchJob getAnimationUpdateJob() {
- return new WorkbenchJob(ProgressMessages.AnimationManager_AnimationStart) {
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.eclipse.ui.progress.UIJob#runInUIThread(org.eclipse.core.
- * runtime .IProgressMonitor)
- */
- public IStatus runInUIThread(IProgressMonitor monitor) {
-
- if (isAnimated) {
- if (!taskItem.isDisposed() && !jobs.isEmpty()) {
- Job job = (Job) jobs.get(0);
- JobInfo jobInfo = (JobInfo) jobInfoMap.get(job);
- if (job != null && jobInfo != null) {
- int percentDone = getPercentDone(jobInfo);
- if (percentDone == IProgressMonitor.UNKNOWN
- || (jobInfo.hasTaskInfo() && jobInfo.getTaskInfo().totalWork == IProgressMonitor.UNKNOWN)) {
- setProgressState(SWT.INDETERMINATE);
- } else {
- setProgressState(SWT.NORMAL);
- if (!taskItem.isDisposed()) {
- taskItem.setProgress(percentDone);
- }
- }
- } else {
- setProgressState(SWT.DEFAULT);
- }
- updateImage(job);
- } else {
- updateImage(null);
- }
- } else {
- setProgressState(SWT.DEFAULT);
- updateImage(null);
- }
-
- if (isAnimated && taskItem != null && !taskItem.isDisposed()) {
- schedule(400);
- }
- return Status.OK_STATUS;
- }
-
- private void setProgressState(int state) {
- if (!taskItem.isDisposed() && taskItem.getProgressState() != state) {
- taskItem.setProgressState(SWT.DEFAULT);
- taskItem.setProgressState(state);
- }
- }
-
- private int getPercentDone(JobTreeElement info) {
- if (info.isJobInfo()) {
- return ((JobInfo) info).getPercentDone();
- }
-
- if (info.hasChildren()) {
- Object[] roots = ((GroupInfo) info).getChildren();
- if (roots.length == 1 && roots[0] instanceof JobTreeElement) {
- TaskInfo ti = ((JobInfo) roots[0]).getTaskInfo();
- if (ti != null) {
- return ti.getPercentDone();
- }
- }
- return ((GroupInfo) info).getPercentDone();
- }
- return 0;
- }
- };
- }
-
- private void updateImage(Job job) {
-
- if (taskItem == null || taskItem.isDisposed())
- return;
-
- if (job == null) {
- disposeOverlay();
- taskItem.setOverlayImage(null);
- return;
- }
-
- // first check whether the job specifies image property
- // if not check with progress manager for its family
- ImageDescriptor descriptor = (ImageDescriptor) job
- .getProperty(IProgressConstants.ICON_PROPERTY);
- if (descriptor != null) {
-
- // if the description is same, do nothing.
- // Else dispose old one and store this
- if (!descriptor.equals(overlayDescriptor)) {
- disposeOverlay();
- setOverlay(descriptor);
- }
- } else if (ProgressManager.getInstance().getIconFor(job) != null) {
- disposeOverlay();
- Image newImage = ProgressManager.getInstance().getIconFor(job);
- taskItem.setOverlayImage(newImage);
- } else {
- disposeOverlay();
- taskItem.setOverlayImage(null);
- }
- }
-
- private void setOverlay(ImageDescriptor descriptor) {
- overlayDescriptor = descriptor;
- overlayImage = descriptor.createImage();
- taskItem.setOverlayImage(overlayImage);
- }
-
- private void disposeOverlay() {
- overlayDescriptor = null;
- if (overlayImage != null) {
- overlayImage.dispose();
- overlayImage = null;
- }
- }
-
- private IJobProgressManagerListener getProgressListener() {
- return new IJobProgressManagerListener() {
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.eclipse.ui.internal.progress.IJobProgressManagerListener#
- * addJob(org.eclipse.ui.internal.progress.JobInfo)
- */
- public void addJob(JobInfo info) {
- // Don't count the animate job itself
- if (isNotTracked(info)) {
- return;
- }
- if (jobs.isEmpty()) {
- setAnimated(true);
- }
- if (!jobs.contains(info.getJob())) {
- jobs.add(info.getJob());
- }
- jobInfoMap.put(info.getJob(), info);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.eclipse.ui.internal.progress.IJobProgressManagerListener#
- * refreshJobInfo(org.eclipse.ui.internal.progress.JobInfo)
- */
- public void refreshJobInfo(JobInfo info) {
- int state = info.getJob().getState();
- if (state == Job.RUNNING) {
- addJob(info);
- } else {
- removeJob(info);
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.eclipse.ui.internal.progress.IJobProgressManagerListener#
- * refreshAll()
- */
- public void refreshAll() {
- ProgressManager manager = ProgressManager.getInstance();
- jobs.clear();
- jobInfoMap.clear();
- setAnimated(false);
- JobInfo[] currentInfos = manager.getJobInfos(showsDebug());
- for (int i = 0; i < currentInfos.length; i++) {
- addJob(currentInfos[i]);
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.eclipse.ui.internal.progress.IJobProgressManagerListener#
- * remove(org.eclipse.ui.internal.progress.JobInfo)
- */
- public void removeJob(JobInfo info) {
- jobs.remove(info.getJob());
- jobInfoMap.remove(info.getJob());
- if (jobs.isEmpty()) {
- setAnimated(false);
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.eclipse.ui.internal.progress.IJobProgressManagerListener#
- * showsDebug()
- */
- public boolean showsDebug() {
- return false;
- }
-
- /**
- * If the job isn't running or doesn't specify the
- * IProgressConstants#SHOW_IN_TASKBAR_ICON_PROPERTY property, don't
- * bother tracking it.
- */
- private boolean isNotTracked(JobInfo info) {
- Job job = info.getJob();
- return job.getState() != Job.RUNNING || !shouldShowSystemProgress(info);
- }
-
- private boolean shouldShowSystemProgress(JobInfo info) {
- Boolean showInTaskBarIcon = Boolean.FALSE;
- Object property = info.getJob().getProperty(
- IProgressConstants2.SHOW_IN_TASKBAR_ICON_PROPERTY);
-
- if (property instanceof Boolean) {
- showInTaskBarIcon = (Boolean) property;
- }
- return showInTaskBarIcon.booleanValue();
-
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.eclipse.ui.internal.progress.IJobProgressManagerListener#
- * addGroup(org.eclipse.ui.internal.progress.GroupInfo)
- */
- public void addGroup(GroupInfo info) {
- // Don't care about groups
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.eclipse.ui.internal.progress.IJobProgressManagerListener#
- * removeGroup(org.eclipse.ui.internal.progress.GroupInfo)
- */
- public void removeGroup(GroupInfo group) {
- // Don't care about groups
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.eclipse.ui.internal.progress.IJobProgressManagerListener#
- * refreshGroup(org.eclipse.ui.internal.progress.GroupInfo)
- */
- public void refreshGroup(GroupInfo info) {
- // Don't care about groups
- }
- };
- }
-
- private synchronized void setAnimated(boolean animated) {
- isAnimated = animated;
- animationUpdateJob.schedule();
- }
-}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/registry/PerspectiveExtensionReader.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/registry/PerspectiveExtensionReader.java
deleted file mode 100644
index 45c53865f22..00000000000
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/registry/PerspectiveExtensionReader.java
+++ /dev/null
@@ -1,373 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2009 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
- * Dan Rubel <dan_rubel@instantiations.com>
- * - Fix for bug 11490 - define hidden view (placeholder for view) in plugin.xml
- * Chris Gross <schtoo@schtoo.com>
- * - Fix for 99155 - allow standalone view placeholders
- *******************************************************************************/
-
-package org.eclipse.ui.internal.registry;
-
-import java.util.HashSet;
-import java.util.Set;
-
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.dynamichelpers.IExtensionTracker;
-import org.eclipse.ui.IPageLayout;
-import org.eclipse.ui.IViewLayout;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.internal.DirtyPerspectiveMarker;
-import org.eclipse.ui.internal.PageLayout;
-import org.eclipse.ui.internal.WorkbenchPlugin;
-
-/**
- * A strategy to read perspective extension from the registry.
- * A pespective extension is one of a view, viewAction, perspAction,
- * newWizardAction, or actionSet.
- */
-public class PerspectiveExtensionReader extends RegistryReader {
- private String targetID;
-
- private PageLayout pageLayout;
-
- private Set includeOnlyTags = null;
-
- private static final String VAL_LEFT = "left";//$NON-NLS-1$
-
- private static final String VAL_RIGHT = "right";//$NON-NLS-1$
-
- private static final String VAL_TOP = "top";//$NON-NLS-1$
-
- private static final String VAL_BOTTOM = "bottom";//$NON-NLS-1$
-
- private static final String VAL_STACK = "stack";//$NON-NLS-1$
-
- private static final String VAL_FAST = "fast";//$NON-NLS-1$
-
- private static final String VAL_TRUE = "true";//$NON-NLS-1$
-
- // VAL_FALSE added by dan_rubel@instantiations.com
- // TODO: this logic is backwards... we should be checking for true, but
- // technically this is API now...
- private static final String VAL_FALSE = "false";//$NON-NLS-1$
-
- private IExtensionTracker tracker;
-
- /**
- * PerspectiveExtensionReader constructor..
- */
- public PerspectiveExtensionReader() {
- // do nothing
- }
-
- /**
- * Read the view extensions within a registry.
- *
- * @param extensionTracker the tracker
- * @param id the id
- * @param out the layout
- */
- public void extendLayout(IExtensionTracker extensionTracker, String id, PageLayout out) {
- tracker = extensionTracker;
- targetID = id;
- pageLayout = out;
- readRegistry(Platform.getExtensionRegistry(), PlatformUI.PLUGIN_ID,
- IWorkbenchRegistryConstants.PL_PERSPECTIVE_EXTENSIONS);
- }
-
- /**
- * Returns whether the given tag should be included.
- */
- private boolean includeTag(String tag) {
- return includeOnlyTags == null || includeOnlyTags.contains(tag);
- }
-
- /**
- * Process an action set.
- */
- private boolean processActionSet(IConfigurationElement element) {
- String id = element.getAttribute(IWorkbenchRegistryConstants.ATT_ID);
- if (id != null) {
- pageLayout.addActionSet(id);
- }
- return true;
- }
-
- /**
- * Process an extension.
- * Assumption: Extension is for current perspective.
- */
- private boolean processExtension(IConfigurationElement element) {
- IConfigurationElement[] children = element.getChildren();
- for (int nX = 0; nX < children.length; nX++) {
- IConfigurationElement child = children[nX];
- String type = child.getName();
- if (includeTag(type)) {
- boolean result = false;
- if (type.equals(IWorkbenchRegistryConstants.TAG_ACTION_SET)) {
- result = processActionSet(child);
- } else if (type.equals(IWorkbenchRegistryConstants.TAG_VIEW)) {
- result = processView(child);
- } else if (type.equals(IWorkbenchRegistryConstants.TAG_VIEW_SHORTCUT)) {
- result = processViewShortcut(child);
- } else if (type.equals(IWorkbenchRegistryConstants.TAG_NEW_WIZARD_SHORTCUT)) {
- result = processWizardShortcut(child);
- } else if (type.equals(IWorkbenchRegistryConstants.TAG_PERSP_SHORTCUT)) {
- result = processPerspectiveShortcut(child);
- } else if (type.equals(IWorkbenchRegistryConstants.TAG_SHOW_IN_PART)) {
- result = processShowInPart(child);
- } else if (type.equals(IWorkbenchRegistryConstants.TAG_HIDDEN_MENU_ITEM)) {
- result = processHiddenMenuItem(child);
- } else if (type.equals(IWorkbenchRegistryConstants.TAG_HIDDEN_TOOLBAR_ITEM)) {
- result = processHiddenToolBarItem(child);
- }
- if (!result) {
- WorkbenchPlugin.log("Unable to process element: " + //$NON-NLS-1$
- type
- + " in perspective extension: " + //$NON-NLS-1$
- element.getDeclaringExtension()
- .getUniqueIdentifier());
- }
- }
- }
- return true;
- }
-
- /**
- * Process a perspective shortcut
- */
- private boolean processPerspectiveShortcut(IConfigurationElement element) {
- String id = element.getAttribute(IWorkbenchRegistryConstants.ATT_ID);
- if (id != null) {
- pageLayout.addPerspectiveShortcut(id);
- }
- return true;
- }
-
- /**
- * Process a show in element.
- */
- private boolean processShowInPart(IConfigurationElement element) {
- String id = element.getAttribute(IWorkbenchRegistryConstants.ATT_ID);
- if (id != null) {
- pageLayout.addShowInPart(id);
- }
- return true;
- }
-
- /**
- * Process a hidden menu item
- */
- private boolean processHiddenMenuItem(IConfigurationElement element) {
- String id = element.getAttribute(IWorkbenchRegistryConstants.ATT_ID);
- if (id != null) {
- pageLayout.addHiddenMenuItemId(id);
- }
- return true;
- }
-
- /**
- * Process a hidden toolbar item
- */
- private boolean processHiddenToolBarItem(IConfigurationElement element) {
- String id = element.getAttribute(IWorkbenchRegistryConstants.ATT_ID);
- if (id != null) {
- pageLayout.addHiddenToolBarItemId(id);
- }
- return true;
- }
-
- // processView(IConfigurationElement) modified by dan_rubel@instantiations.com
- /**
- * Process a view
- */
- private boolean processView(IConfigurationElement element) {
- // Get id, relative, and relationship.
- String id = element.getAttribute(IWorkbenchRegistryConstants.ATT_ID);
- String relative = element.getAttribute(IWorkbenchRegistryConstants.ATT_RELATIVE);
- String relationship = element.getAttribute(IWorkbenchRegistryConstants.ATT_RELATIONSHIP);
- String ratioString = element.getAttribute(IWorkbenchRegistryConstants.ATT_RATIO);
- boolean visible = !VAL_FALSE.equals(element.getAttribute(IWorkbenchRegistryConstants.ATT_VISIBLE));
- String closeable = element.getAttribute(IWorkbenchRegistryConstants.ATT_CLOSEABLE);
- String moveable = element.getAttribute(IWorkbenchRegistryConstants.ATT_MOVEABLE);
- String standalone = element.getAttribute(IWorkbenchRegistryConstants.ATT_STANDALONE);
- String showTitle = element.getAttribute(IWorkbenchRegistryConstants.ATT_SHOW_TITLE);
-
- // Default to 'false'
- String minVal = element.getAttribute(IWorkbenchRegistryConstants.ATT_MINIMIZED);
- boolean minimized = minVal != null && VAL_TRUE.equals(minVal);
-
- float ratio;
-
- if (id == null) {
- logMissingAttribute(element, IWorkbenchRegistryConstants.ATT_ID);
- return false;
- }
- if (relationship == null) {
- logMissingAttribute(element, IWorkbenchRegistryConstants.ATT_RELATIONSHIP);
- return false;
- }
- if (!VAL_FAST.equals(relationship) && relative == null) {
- logError(
- element,
- "Attribute '" + IWorkbenchRegistryConstants.ATT_RELATIVE + "' not defined. This attribute is required when " + IWorkbenchRegistryConstants.ATT_RELATIONSHIP + "=\"" + relationship + "\"."); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- return false;
- }
-
- // Get the ratio.
- if (ratioString == null) {
- // The ratio has not been specified.
- ratio = IPageLayout.NULL_RATIO;
- } else {
- try {
- ratio = new Float(ratioString).floatValue();
- } catch (NumberFormatException e) {
- return false;
- }
- // If the ratio is outside the allowable range, mark it as invalid.
- if (ratio < IPageLayout.RATIO_MIN || ratio > IPageLayout.RATIO_MAX) {
- ratio = IPageLayout.INVALID_RATIO;
- }
- }
-
- // Get relationship details.
- boolean stack = false;
- boolean fast = false;
- int intRelation = 0;
- if (relationship.equals(VAL_LEFT)) {
- intRelation = IPageLayout.LEFT;
- } else if (relationship.equals(VAL_RIGHT)) {
- intRelation = IPageLayout.RIGHT;
- } else if (relationship.equals(VAL_TOP)) {
- intRelation = IPageLayout.TOP;
- } else if (relationship.equals(VAL_BOTTOM)) {
- intRelation = IPageLayout.BOTTOM;
- } else if (relationship.equals(VAL_STACK)) {
- stack = true;
- } else if (relationship.equals(VAL_FAST)) {
- fast = true;
- } else {
- return false;
- }
-
- if (visible) {
- // If adding a view (not just a placeholder), remove any existing placeholder.
- // See bug 85948 [Perspectives] Adding register & expressions view by default to debug perspective fails
- pageLayout.removePlaceholder(id);
- }
-
- // If stack ..
- if (stack) {
- if (visible) {
- pageLayout.stackView(id, relative);
- } else {
- pageLayout.stackPlaceholder(id, relative);
- }
- }
-
- // If the view is a fast view...
- else if (fast) {
- if (ratio == IPageLayout.NULL_RATIO) {
- // The ratio has not been specified.
- pageLayout.addFastView(id);
- } else {
- pageLayout.addFastView(id, ratio);
- }
- } else {
-
- // The view is a regular view.
- // If the ratio is not specified or is invalid, use the default ratio.
- if (ratio == IPageLayout.NULL_RATIO
- || ratio == IPageLayout.INVALID_RATIO) {
- ratio = IPageLayout.DEFAULT_VIEW_RATIO;
- }
-
- if (visible) {
- if (VAL_TRUE.equals(standalone)) {
- pageLayout.addStandaloneView(id, !VAL_FALSE
- .equals(showTitle), intRelation, ratio, relative);
- } else {
- pageLayout.addView(id, intRelation, ratio, relative, minimized);
- }
- } else {
- // Fix for 99155, CGross (schtoo@schtoo.com)
- // Adding standalone placeholder for standalone views
- if (VAL_TRUE.equals(standalone)) {
- pageLayout.addStandaloneViewPlaceholder(id, intRelation,
- ratio, relative, !VAL_FALSE.equals(showTitle));
- } else {
- pageLayout.addPlaceholder(id, intRelation, ratio, relative);
- }
- }
- }
- IViewLayout viewLayout = pageLayout.getViewLayout(id);
- // may be null if it's been filtered by activity
- if (viewLayout != null) {
- if (closeable != null) {
- viewLayout.setCloseable(!VAL_FALSE.equals(closeable));
- }
- if (moveable != null) {
- viewLayout.setMoveable(!VAL_FALSE.equals(moveable));
- }
- }
-
- return true;
- }
-
- /**
- * Process a view shortcut
- */
- private boolean processViewShortcut(IConfigurationElement element) {
- String id = element.getAttribute(IWorkbenchRegistryConstants.ATT_ID);
- if (id != null) {
- pageLayout.addShowViewShortcut(id);
- }
- return true;
- }
-
- /**
- * Process a wizard shortcut
- */
- private boolean processWizardShortcut(IConfigurationElement element) {
- String id = element.getAttribute(IWorkbenchRegistryConstants.ATT_ID);
- if (id != null) {
- pageLayout.addNewWizardShortcut(id);
- }
- return true;
- }
-
- protected boolean readElement(IConfigurationElement element) {
- String type = element.getName();
- if (type.equals(IWorkbenchRegistryConstants.TAG_PERSPECTIVE_EXTENSION)) {
- String id = element.getAttribute(IWorkbenchRegistryConstants.ATT_TARGET_ID);
- if (targetID.equals(id) || "*".equals(id)) { //$NON-NLS-1$
- if (tracker != null) {
- tracker.registerObject(element.getDeclaringExtension(), new DirtyPerspectiveMarker(id), IExtensionTracker.REF_STRONG);
- }
- return processExtension(element);
- }
- return true;
- }
- return false;
- }
-
- /**
- * Sets the tags to include. All others are ignored.
- *
- * @param tags the tags to include
- */
- public void setIncludeOnlyTags(String[] tags) {
- includeOnlyTags = new HashSet();
- for (int i = 0; i < tags.length; i++) {
- includeOnlyTags.add(tags[i]);
- }
- }
-}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/registry/PerspectiveRegistryReader.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/registry/PerspectiveRegistryReader.java
deleted file mode 100644
index 244c93f9957..00000000000
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/registry/PerspectiveRegistryReader.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 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.registry;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.IExtensionRegistry;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.internal.WorkbenchPlugin;
-
-/**
- * A strategy to read view extensions from the registry.
- */
-public class PerspectiveRegistryReader extends RegistryReader {
- private PerspectiveRegistry registry;
-
- /**
- * RegistryViewReader constructor comment.
- *
- * @param out the output registry
- */
- public PerspectiveRegistryReader(PerspectiveRegistry out) {
- super();
- registry = out;
- }
-
- /**
- * readElement method comment.
- */
- // for dynamic UI - change access from protected to public
- protected boolean readElement(IConfigurationElement element) {
- if (element.getName().equals(IWorkbenchRegistryConstants.TAG_PERSPECTIVE)) {
- try {
- PerspectiveDescriptor desc = new PerspectiveDescriptor(element.getAttribute(IWorkbenchRegistryConstants.ATT_ID), element);
- registry.addPerspective(desc);
- } catch (CoreException e) {
- // log an error since its not safe to open a dialog here
- WorkbenchPlugin.log(
- "Unable to create layout descriptor.", e.getStatus());//$NON-NLS-1$
- }
- return true;
- }
-
- return false;
- }
-
- /**
- * Read the view extensions within a registry.
- *
- * @param in the registry to read
- */
- public void readPerspectives(IExtensionRegistry in) {
- readRegistry(in, PlatformUI.PLUGIN_ID,
- IWorkbenchRegistryConstants.PL_PERSPECTIVES);
- }
-}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/registry/ViewRegistryReader.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/registry/ViewRegistryReader.java
deleted file mode 100644
index 96283de1740..00000000000
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/registry/ViewRegistryReader.java
+++ /dev/null
@@ -1,110 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 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
- * Jan-Hendrik Diederich, Bredex GmbH - bug 201052
- *******************************************************************************/
-package org.eclipse.ui.internal.registry;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.IExtensionRegistry;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.internal.WorkbenchPlugin;
-
-/**
- * A strategy to read view extensions from the registry.
- */
-public class ViewRegistryReader extends RegistryReader {
- /**
- * General view category id
- */
- public static String GENERAL_VIEW_ID = "org.eclipse.ui"; //$NON-NLS-1$
-
- private ViewRegistry viewRegistry;
-
- /**
- * RegistryViewReader constructor comment.
- */
- public ViewRegistryReader() {
- super();
- }
-
- /**
- * Reads the category element.
- */
- protected void readCategory(IConfigurationElement element) {
- try {
- viewRegistry.add(new Category(element));
- } catch (CoreException e) {
- // log an error since its not safe to show a dialog here
- WorkbenchPlugin.log(
- "Unable to create view category.", e.getStatus());//$NON-NLS-1$
- }
- }
-
- /**
- * readElement method comment.
- */
- protected boolean readElement(IConfigurationElement element) {
- String elementName = element.getName();
- if (elementName.equals(IWorkbenchRegistryConstants.TAG_VIEW)) {
- readView(element);
- return true;
- }
- if (elementName.equals(IWorkbenchRegistryConstants.TAG_CATEGORY)) {
- readCategory(element);
- readElementChildren(element);
- return true;
- }
- if (elementName.equals(IWorkbenchRegistryConstants.TAG_STICKYVIEW)) {
- readSticky(element);
- return true;
- }
-
- return false;
- }
-
- /**
- * Reads the sticky view element.
- */
- protected void readSticky(IConfigurationElement element) {
- try {
- viewRegistry.add(new StickyViewDescriptor(element));
- } catch (CoreException e) {
- // log an error since its not safe to open a dialog here
- WorkbenchPlugin.log(
- "Unable to create sticky view descriptor.", e.getStatus());//$NON-NLS-1$
-
- }
- }
-
- /**
- * Reads the view element.
- */
- protected void readView(IConfigurationElement element) {
- try {
- viewRegistry.add(new ViewDescriptor(element));
- } catch (CoreException e) {
- // log an error since its not safe to open a dialog here
- WorkbenchPlugin.log(
- "Unable to create view descriptor.", e.getStatus());//$NON-NLS-1$
- }
- }
-
- /**
- * Read the view extensions within a registry.
- * @param in the extension registry
- * @param out the view registry
- */
- public void readViews(IExtensionRegistry in, ViewRegistry out) {
- // this does not seem to really ever be throwing an the exception
- viewRegistry = out;
- readRegistry(in, PlatformUI.PLUGIN_ID, IWorkbenchRegistryConstants.PL_VIEWS);
- }
-}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/services/EvaluationAuthority.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/services/EvaluationAuthority.java
deleted file mode 100644
index f110d1964c1..00000000000
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/services/EvaluationAuthority.java
+++ /dev/null
@@ -1,298 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 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.services;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-
-import org.eclipse.core.commands.util.Tracing;
-import org.eclipse.core.expressions.Expression;
-import org.eclipse.core.expressions.ExpressionInfo;
-import org.eclipse.core.runtime.ISafeRunnable;
-import org.eclipse.core.runtime.ListenerList;
-import org.eclipse.core.runtime.SafeRunner;
-import org.eclipse.jface.util.IPropertyChangeListener;
-import org.eclipse.jface.util.PropertyChangeEvent;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.ISources;
-import org.eclipse.ui.internal.WorkbenchPlugin;
-import org.eclipse.ui.internal.misc.Policy;
-import org.eclipse.ui.services.IEvaluationReference;
-import org.eclipse.ui.services.IEvaluationService;
-
-/**
- * @since 3.3
- *
- */
-public class EvaluationAuthority extends ExpressionAuthority {
-
- /**
- *
- */
- private static final String COMPONENT = "EVALUATION"; //$NON-NLS-1$
-
- /**
- * A bucket sort of the evaluation references based on source priority. Each
- * reference will appear only once per set, but may appear in multiple sets.
- * If no references are defined for a particular priority level, then the
- * array at that index will only contain <code>null</code>.
- */
- private final Map cachesBySourceName = new HashMap();
- private ListenerList serviceListeners = new ListenerList();
- private int notifying = 0;
-
- // private final Map cachesByExpression = new HashMap();
-
- public void addEvaluationListener(IEvaluationReference ref) {
- // we update the source priority bucket sort of activations.
- String[] sourceNames = getNames(ref);
- for (int i = 0; i < sourceNames.length; i++) {
- Map cachesByExpression = (HashMap) cachesBySourceName
- .get(sourceNames[i]);
- if (cachesByExpression == null) {
- cachesByExpression = new HashMap(1);
- cachesBySourceName.put(sourceNames[i], cachesByExpression);
- }
- final Expression expression = ref.getExpression();
- Set caches = (Set) cachesByExpression.get(expression);
- if (caches == null) {
- caches = new HashSet();
- cachesByExpression.put(expression, caches);
- }
- caches.add(ref);
- }
-
- boolean result = evaluate(ref);
- firePropertyChange(ref, null, valueOf(result));
- }
-
- private Boolean valueOf(boolean result) {
- return result ? Boolean.TRUE : Boolean.FALSE;
- }
-
- private String[] getNames(IEvaluationReference ref) {
- ExpressionInfo info = new ExpressionInfo();
- ref.getExpression().collectExpressionInfo(info);
- ArrayList allNames = new ArrayList(Arrays.asList(info
- .getAccessedVariableNames()));
- if (info.hasDefaultVariableAccess()) {
- allNames.add(ISources.ACTIVE_CURRENT_SELECTION_NAME);
- }
- allNames.addAll(Arrays.asList(info.getAccessedPropertyNames()));
- return (String[]) allNames.toArray(new String[allNames.size()]);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.internal.services.ExpressionAuthority#sourceChanged(int)
- */
- protected void sourceChanged(int sourcePriority) {
- // no-op, we want the other one
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.internal.services.ExpressionAuthority#sourceChanged(java.lang.String[])
- */
- protected void sourceChanged(String[] sourceNames) {
- startSourceChange(sourceNames);
- try {
- // evaluations to recompute
- for (int i = 0; i < sourceNames.length; i++) {
- Map cachesByExpression = (HashMap) cachesBySourceName
- .get(sourceNames[i]);
- if (cachesByExpression != null) {
- Collection v = cachesByExpression.values();
- Set[] expressionCaches = (Set[]) v
- .toArray(new Set[v.size()]);
- for (int j = 0; j < expressionCaches.length; j++) {
- if (expressionCaches[j].size() > 0) {
- EvaluationReference[] refs = (EvaluationReference[]) expressionCaches[j]
- .toArray(new EvaluationReference[expressionCaches[j]
- .size()]);
- refsWithSameExpression(refs);
- }
- }
- }
- }
- } finally {
- endSourceChange(sourceNames);
- }
- }
-
- /**
- * This will evaluate all refs with the same expression.
- *
- * @param refs
- */
- private void refsWithSameExpression(EvaluationReference[] refs) {
- int k = 0;
- while (k < refs.length && !refs[k].isPostingChanges()) {
- k++;
- }
- if (k >= refs.length) {
- return;
- }
- EvaluationReference ref = refs[k];
- boolean oldValue = evaluate(ref);
- ref.clearResult();
- final boolean newValue = evaluate(ref);
- if (oldValue != newValue) {
- firePropertyChange(ref, valueOf(oldValue), valueOf(newValue));
- }
- for (k++; k < refs.length; k++) {
- ref = refs[k];
- // this is not as expensive as it looks
- if (ref.isPostingChanges()) {
- oldValue = evaluate(ref);
- if (oldValue != newValue) {
- ref.setResult(newValue);
- firePropertyChange(ref, valueOf(oldValue),
- valueOf(newValue));
- }
- }
- }
- }
-
- /**
- * @param sourceNames
- */
- private void startSourceChange(final String[] sourceNames) {
- if (Policy.DEBUG_SOURCES) {
- Tracing.printTrace(COMPONENT, "start source changed: " //$NON-NLS-1$
- + Arrays.asList(sourceNames));
- }
- notifying++;
- if (notifying == 1) {
- fireServiceChange(IEvaluationService.PROP_NOTIFYING, Boolean.FALSE,
- Boolean.TRUE);
- }
- }
-
- /**
- * @param sourceNames
- */
- private void endSourceChange(final String[] sourceNames) {
- if (Policy.DEBUG_SOURCES) {
- Tracing.printTrace(COMPONENT, "end source changed: " //$NON-NLS-1$
- + Arrays.asList(sourceNames));
- }
- if (notifying == 1) {
- fireServiceChange(IEvaluationService.PROP_NOTIFYING, Boolean.TRUE,
- Boolean.FALSE);
- }
- notifying--;
- }
-
- /**
- * @param ref
- */
- public void removeEvaluationListener(IEvaluationReference ref) {
- // Next we update the source priority bucket sort of activations.
- String[] sourceNames = getNames(ref);
- for (int i = 0; i < sourceNames.length; i++) {
- Map cachesByExpression = (HashMap) cachesBySourceName
- .get(sourceNames[i]);
- if (cachesByExpression != null) {
- Set caches = (Set) cachesByExpression.get(ref.getExpression());
- if (caches != null) {
- caches.remove(ref);
- if (caches.isEmpty()) {
- cachesByExpression.remove(ref.getExpression());
- }
- }
- if (cachesByExpression.isEmpty()) {
- cachesBySourceName.remove(sourceNames[i]);
- }
- }
- }
- boolean result = evaluate(ref);
- firePropertyChange(ref, valueOf(result), null);
- }
-
- /**
- * @param ref
- * @param oldValue
- * @param newValue
- */
- private void firePropertyChange(IEvaluationReference ref, Object oldValue,
- Object newValue) {
- ref.getListener().propertyChange(
- new PropertyChangeEvent(ref, ref.getProperty(), oldValue,
- newValue));
- }
-
- private void fireServiceChange(final String property,
- final Object oldValue, final Object newValue) {
- Object[] listeners = serviceListeners.getListeners();
- for (int i = 0; i < listeners.length; i++) {
- final IPropertyChangeListener listener = (IPropertyChangeListener) listeners[i];
- SafeRunner.run(new ISafeRunnable() {
- public void handleException(Throwable exception) {
- WorkbenchPlugin.log(exception);
- }
-
- public void run() throws Exception {
- listener.propertyChange(new PropertyChangeEvent(
- EvaluationAuthority.this, property, oldValue,
- newValue));
- }
- });
- }
- }
-
- /**
- * @param listener
- */
- public void addServiceListener(IPropertyChangeListener listener) {
- serviceListeners.add(listener);
- }
-
- /**
- * @param listener
- */
- public void removeServiceListener(IPropertyChangeListener listener) {
- serviceListeners.remove(listener);
- }
-
- /**
- * <p>
- * Bug 95792. A mechanism by which the key binding architecture can force an
- * update of the handlers (based on the active shell) before trying to
- * execute a command. This mechanism is required for GTK+ only.
- * </p>
- * <p>
- * DO NOT CALL THIS METHOD.
- * </p>
- */
- final void updateShellKludge() {
- updateCurrentState();
- sourceChanged(new String[] { ISources.ACTIVE_SHELL_NAME });
- }
-
- /**
- * Returns the currently active shell.
- *
- * @return The currently active shell; may be <code>null</code>.
- */
- final Shell getActiveShell() {
- return (Shell) getVariable(ISources.ACTIVE_SHELL_NAME);
- }
-
-}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/testing/ContributionInfoMessages.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/testing/ContributionInfoMessages.java
deleted file mode 100644
index fd2f3b92c39..00000000000
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/testing/ContributionInfoMessages.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 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.testing;
-
-import org.eclipse.osgi.util.NLS;
-
-/**
- * @since 3.6
- *
- */
-public class ContributionInfoMessages extends NLS {
- private static final String BUNDLE_NAME = "org.eclipse.ui.internal.testing.messages";//$NON-NLS-1$
-
-
- public static String ContributionInfo_Editor;
- public static String ContributionInfo_View;
- public static String ContributionInfo_ActionSet;
- public static String ContributionInfo_Category;
- public static String ContributionInfo_ColorDefinition;
- public static String ContributionInfo_Wizard;
- public static String ContributionInfo_Perspective;
- public static String ContributionInfo_Page;
- public static String ContributionInfo_EarlyStartupPlugin;
- public static String ContributionInfo_Unknown;
- public static String ContributionInfo_Job;
- public static String ContributionInfo_TableItem;
- public static String ContributionInfo_TreeItem;
- public static String ContributionInfo_Window;
- public static String ContributionInfo_LabelDecoration;
- public static String ContributionInfo_ViewContent;
-
- public static String ContributionInfo_ContributedBy;
-
- static {
- // load message values from bundle file
- NLS.initializeMessages(BUNDLE_NAME, ContributionInfoMessages.class);
- }
-
-}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/testing/PluginContributionAdapterFactory.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/testing/PluginContributionAdapterFactory.java
deleted file mode 100644
index a96ab1aa235..00000000000
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/testing/PluginContributionAdapterFactory.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 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.testing;
-
-import org.eclipse.core.runtime.IAdapterFactory;
-import org.eclipse.core.runtime.jobs.Job;
-import org.eclipse.ui.IPluginContribution;
-import org.eclipse.ui.internal.decorators.DecoratorDefinition;
-import org.eclipse.ui.internal.dialogs.WizardCollectionElement;
-import org.eclipse.ui.internal.dialogs.WorkbenchWizardElement;
-import org.eclipse.ui.internal.preferences.WorkbenchPreferenceExpressionNode;
-import org.eclipse.ui.internal.progress.JobInfo;
-import org.eclipse.ui.internal.registry.ActionSetDescriptor;
-import org.eclipse.ui.internal.registry.Category;
-import org.eclipse.ui.internal.registry.EditorDescriptor;
-import org.eclipse.ui.internal.registry.PerspectiveDescriptor;
-import org.eclipse.ui.internal.registry.ViewDescriptor;
-import org.eclipse.ui.internal.themes.ColorDefinition;
-import org.eclipse.ui.internal.themes.ThemeElementCategory;
-import org.eclipse.ui.testing.ContributionInfo;
-import org.eclipse.ui.views.IViewCategory;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.FrameworkUtil;
-
-/**
- * @since 3.6
- *
- */
-public class PluginContributionAdapterFactory implements IAdapterFactory {
-
- public Object getAdapter(Object adaptableObject, Class adapterType) {
- if (adapterType != ContributionInfo.class) {
- return null;
- }
- if (adaptableObject instanceof IPluginContribution) {
- IPluginContribution contribution = (IPluginContribution) adaptableObject;
-
- String elementType;
-
- if (contribution instanceof EditorDescriptor) {
- elementType = ContributionInfoMessages.ContributionInfo_Editor;
- } else if (contribution instanceof ViewDescriptor) {
- elementType = ContributionInfoMessages.ContributionInfo_View;
- } else if (contribution instanceof ActionSetDescriptor) {
- elementType = ContributionInfoMessages.ContributionInfo_ActionSet;
- } else if (contribution instanceof Category) {
- elementType = ContributionInfoMessages.ContributionInfo_Category;
- } else if (contribution instanceof IViewCategory) {
- elementType = ContributionInfoMessages.ContributionInfo_Category;
- } else if (contribution instanceof ThemeElementCategory) {
- elementType = ContributionInfoMessages.ContributionInfo_Category;
- } else if (contribution instanceof WizardCollectionElement) {
- elementType = ContributionInfoMessages.ContributionInfo_Category;
- } else if (contribution instanceof ColorDefinition) {
- elementType = ContributionInfoMessages.ContributionInfo_ColorDefinition;
- } else if (contribution instanceof WorkbenchWizardElement) {
- elementType = ContributionInfoMessages.ContributionInfo_Wizard;
- } else if (contribution instanceof PerspectiveDescriptor) {
- elementType = ContributionInfoMessages.ContributionInfo_Perspective;
- } else if (contribution instanceof WorkbenchPreferenceExpressionNode) {
- elementType = ContributionInfoMessages.ContributionInfo_Page;
- } else if (contribution instanceof DecoratorDefinition) {
- elementType = ContributionInfoMessages.ContributionInfo_LabelDecoration;
- } else {
- elementType = ContributionInfoMessages.ContributionInfo_Unknown;
- }
-
- return new ContributionInfo(contribution.getPluginId(), elementType, null);
- }
- if (adaptableObject instanceof JobInfo) {
- JobInfo jobInfo = (JobInfo) adaptableObject;
- Job job = jobInfo.getJob();
- if (job != null) {
- Bundle bundle = FrameworkUtil.getBundle(job.getClass());
- if (bundle != null) {
- return new ContributionInfo(bundle.getSymbolicName(),
- ContributionInfoMessages.ContributionInfo_Job, null);
- }
- }
- }
- return null;
- }
-
- public Class[] getAdapterList() {
- return new Class[] { ContributionInfo.class };
- }
-
-}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/testing/messages.properties b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/testing/messages.properties
deleted file mode 100644
index 778c53a77eb..00000000000
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/testing/messages.properties
+++ /dev/null
@@ -1,29 +0,0 @@
-###############################################################################
-# Copyright (c) 2010 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
-###############################################################################
-
-ContributionInfo_Unknown=unknown contribution
-ContributionInfo_Editor=editor
-ContributionInfo_View=view
-ContributionInfo_ActionSet=command group
-ContributionInfo_Category=category
-ContributionInfo_ColorDefinition=color definition
-ContributionInfo_Wizard=wizard
-ContributionInfo_Perspective=perspective
-ContributionInfo_Page=page
-ContributionInfo_EarlyStartupPlugin=early startup plug-in
-ContributionInfo_Job=job
-ContributionInfo_TableItem=table item
-ContributionInfo_TreeItem=tree item
-ContributionInfo_Window=window
-ContributionInfo_LabelDecoration=label decoration
-ContributionInfo_ViewContent=view content
-
-ContributionInfo_ContributedBy=This {0} has been contributed by: {1}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/tweaklets/Workbench3xImplementation.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/tweaklets/Workbench3xImplementation.java
deleted file mode 100644
index 3549cf30c80..00000000000
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/tweaklets/Workbench3xImplementation.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 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.tweaklets;
-
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.ui.WorkbenchException;
-import org.eclipse.ui.internal.Perspective;
-import org.eclipse.ui.internal.WorkbenchPage;
-import org.eclipse.ui.internal.WorkbenchWindow;
-import org.eclipse.ui.internal.registry.PerspectiveDescriptor;
-
-/**
- * @since 3.4
- *
- */
-public class Workbench3xImplementation extends WorkbenchImplementation {
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.internal.tweaklets.WorkbenchImplementation#createWBW(int)
- */
- public WorkbenchWindow createWorkbenchWindow(int newWindowNumber) {
- return new WorkbenchWindow(newWindowNumber);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.internal.tweaklets.WorkbenchImplementation#createWBPage(org.eclipse.ui.internal.WorkbenchWindow, java.lang.String, org.eclipse.core.runtime.IAdaptable)
- */
- public WorkbenchPage createWorkbenchPage(WorkbenchWindow workbenchWindow,
- String perspID, IAdaptable input) throws WorkbenchException {
- return new WorkbenchPage(workbenchWindow, perspID, input);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.internal.tweaklets.WorkbenchImplementation#createWBPage(org.eclipse.ui.internal.WorkbenchWindow, org.eclipse.core.runtime.IAdaptable)
- */
- public WorkbenchPage createWorkbenchPage(WorkbenchWindow workbenchWindow,
- IAdaptable finalInput) throws WorkbenchException {
- return new WorkbenchPage(workbenchWindow, finalInput);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.internal.tweaklets.WorkbenchImplementation#createPerspective(org.eclipse.ui.internal.registry.PerspectiveDescriptor, org.eclipse.ui.internal.WorkbenchPage)
- */
- public Perspective createPerspective(PerspectiveDescriptor desc,
- WorkbenchPage workbenchPage) throws WorkbenchException {
- return new Perspective(desc, workbenchPage);
- }
-
-}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/tweaklets/WorkbenchImplementation.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/tweaklets/WorkbenchImplementation.java
deleted file mode 100644
index 1c7afedaf2c..00000000000
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/tweaklets/WorkbenchImplementation.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 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.tweaklets;
-
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.ui.WorkbenchException;
-import org.eclipse.ui.internal.Perspective;
-import org.eclipse.ui.internal.WorkbenchPage;
-import org.eclipse.ui.internal.WorkbenchWindow;
-import org.eclipse.ui.internal.registry.PerspectiveDescriptor;
-import org.eclipse.ui.internal.tweaklets.Tweaklets.TweakKey;
-
-/**
- * Tweak that enables experimental Eclipse 4.0 functionality
- *
- * @since 3.4
- *
- */
-public abstract class WorkbenchImplementation {
- public static TweakKey KEY = new Tweaklets.TweakKey(WorkbenchImplementation.class);
-
- static {
- Tweaklets.setDefault(WorkbenchImplementation.KEY, new Workbench3xImplementation());
- }
-
- /** Default c'tor */
- public WorkbenchImplementation() {}
-
- /**
- * @param newWindowNumber
- * @return
- */
- public abstract WorkbenchWindow createWorkbenchWindow(int newWindowNumber);
-
- /**
- * @param workbenchWindow
- * @param perspID
- * @param input
- * @return
- * @throws WorkbenchException
- */
- public abstract WorkbenchPage createWorkbenchPage(WorkbenchWindow workbenchWindow,
- String perspID, IAdaptable input) throws WorkbenchException;
-
- /**
- * @param workbenchWindow
- * @param finalInput
- * @return
- * @throws WorkbenchException
- */
- public abstract WorkbenchPage createWorkbenchPage(WorkbenchWindow workbenchWindow,
- IAdaptable finalInput) throws WorkbenchException;
-
- /**
- * @param desc
- * @param workbenchPage
- * @return
- * @throws WorkbenchException
- */
- public abstract Perspective createPerspective(PerspectiveDescriptor desc,
- WorkbenchPage workbenchPage) throws WorkbenchException;
-}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/presentations/PresentationUtil.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/presentations/PresentationUtil.java
deleted file mode 100644
index b3f394865cf..00000000000
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/presentations/PresentationUtil.java
+++ /dev/null
@@ -1,173 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 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.presentations;
-
-import org.eclipse.jface.util.Geometry;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.Listener;
-import org.eclipse.ui.internal.dnd.DragUtil;
-
-/**
- * Contains various utility methods for Presentation authors
- *
- * @since 3.0
- */
-public class PresentationUtil {
- private static Point anchor;
-
- private final static int HYSTERESIS = 16;
-
- private static int initialMouseButton = 0;
-
- private final static String LISTENER_ID = PresentationUtil.class.getName()
- + ".dragListener"; //$NON-NLS-1$
-
- private static Event dragEvent;
-
- private static Listener currentListener = null;
-
- private static Control dragSource;
-
- private static Listener dragListener = new Listener() {
- public void handleEvent(Event event) {
- dragEvent = event;
- if (dragSource != event.widget) {
- dragSource = null;
- currentListener = null;
- }
- }
- };
-
- /**
- * Returns whether the mouse has moved enough to warrant
- * opening a tracker.
- */
- private static boolean hasMovedEnough(Event event) {
- return Geometry.distanceSquared(DragUtil.getEventLoc(event), anchor) >= HYSTERESIS
- * HYSTERESIS;
- }
-
- private static Listener moveListener = new Listener() {
- public void handleEvent(Event event) {
- handleMouseMove(event);
- }
- };
-
- private static Listener clickListener = new Listener() {
- public void handleEvent(Event e) {
- handleMouseClick(e);
- }
- };
-
- private static Listener mouseDownListener = new Listener() {
- public void handleEvent(Event event) {
- if (event.widget instanceof Control) {
- // Remember the button that started the drag so we
- // can forward it on the call to the 'externalDragListener'
- initialMouseButton = event.button;
-
- dragSource = (Control) event.widget;
- currentListener = (Listener) dragSource.getData(LISTENER_ID);
- anchor = DragUtil.getEventLoc(event);
-
- if (dragEvent != null && (dragEvent.widget != dragSource)) {
- dragEvent = null;
- }
- }
- }
- };
-
- private static void handleMouseClick(Event event) {
- cancelDrag();
- }
-
- private static void handleMouseMove(Event e) {
- if (currentListener != null && dragEvent != null && hasMovedEnough(e)) {
- if (dragSource != null && !dragSource.isDisposed()
- && dragSource == e.widget) {
- Event de = dragEvent;
-
- // cache the current value so we can restore it later
- int originalMouseButton = de.button;
-
- // Update the button field so that the drag listener
- // can detect whether or not it's a 'right button' drag
- de.button = initialMouseButton;
-
- Listener l = currentListener;
- cancelDrag();
- l.handleEvent(de);
-
- // Restore the event's state so that other listeners see
- // the original values
- de.button = originalMouseButton;
- } else {
- cancelDrag();
- }
- }
- }
-
- private static void cancelDrag() {
- currentListener = null;
- dragEvent = null;
- dragSource = null;
-
- initialMouseButton = 0;
- }
-
- /**
- * Adds a drag listener to the given control. The behavior is very similar
- * to control.addListener(SWT.DragDetect, dragListener), however the listener
- * attached by this method is less sensitive. The drag event is only fired
- * once the user moves the cursor more than HYSTERESIS pixels.
- * <p>
- * This is useful for registering a listener that will trigger an editor or
- * view drag, since an overly sensitive drag listener can cause users to accidentally
- * drag views when trying to select a tab.</p>
- * <p>
- * Currently, only one such drag listener can be registered at a time. </p>
- *
- * @param control the control containing the drag listener
- * @param externalDragListener the drag listener to attach
- */
- public static void addDragListener(Control control,
- Listener externalDragListener) {
- control.addListener(SWT.DragDetect, dragListener);
- control.addListener(SWT.MouseUp, clickListener);
- control.addListener(SWT.MouseDoubleClick, clickListener);
- control.addListener(SWT.MouseDown, mouseDownListener);
- control.addListener(SWT.MouseMove, moveListener);
- control.setData(LISTENER_ID, externalDragListener);
- }
-
- /**
- * Removes a drag listener that was previously attached using addDragListener
- *
- * @param control the control containing the drag listener
- * @param externalDragListener the drag listener to remove
- */
- public static void removeDragListener(Control control,
- Listener externalDragListener) {
- control.removeListener(SWT.DragDetect, dragListener);
- control.removeListener(SWT.MouseUp, clickListener);
- control.removeListener(SWT.MouseDoubleClick, clickListener);
- control.removeListener(SWT.MouseDown, mouseDownListener);
- control.removeListener(SWT.MouseMove, moveListener);
- control.setData(LISTENER_ID, null);
- if (externalDragListener == currentListener) {
- cancelDrag();
- }
- }
-
-}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/presentations/WorkbenchPresentationFactory.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/presentations/WorkbenchPresentationFactory.java
deleted file mode 100644
index 3539c45f93c..00000000000
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/presentations/WorkbenchPresentationFactory.java
+++ /dev/null
@@ -1,153 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 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.presentations;
-
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.ui.IWorkbenchPreferenceConstants;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.internal.presentations.defaultpresentation.DefaultMultiTabListener;
-import org.eclipse.ui.internal.presentations.defaultpresentation.DefaultSimpleTabListener;
-import org.eclipse.ui.internal.presentations.defaultpresentation.DefaultTabFolder;
-import org.eclipse.ui.internal.presentations.defaultpresentation.DefaultThemeListener;
-import org.eclipse.ui.internal.presentations.defaultpresentation.EmptyTabFolder;
-import org.eclipse.ui.internal.presentations.util.PresentablePartFolder;
-import org.eclipse.ui.internal.presentations.util.StandardEditorSystemMenu;
-import org.eclipse.ui.internal.presentations.util.StandardViewSystemMenu;
-import org.eclipse.ui.internal.presentations.util.TabbedStackPresentation;
-
-/**
- * The default presentation factory for the Workbench.
- *
- * @since 3.0
- */
-public class WorkbenchPresentationFactory extends AbstractPresentationFactory {
-
- // don't reset these dynamically, so just keep the information static.
- // see bug:
- // 75422 [Presentations] Switching presentation to R21 switches immediately,
- // but only partially
- private static int editorTabPosition = PlatformUI.getPreferenceStore()
- .getInt(IWorkbenchPreferenceConstants.EDITOR_TAB_POSITION);
- private static int viewTabPosition = PlatformUI.getPreferenceStore()
- .getInt(IWorkbenchPreferenceConstants.VIEW_TAB_POSITION);
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.presentations.AbstractPresentationFactory#createEditorPresentation(org.eclipse.swt.widgets.Composite,
- * org.eclipse.ui.presentations.IStackPresentationSite)
- */
- public StackPresentation createEditorPresentation(Composite parent,
- IStackPresentationSite site) {
- DefaultTabFolder folder = new DefaultTabFolder(parent,
- editorTabPosition | SWT.BORDER, site
- .supportsState(IStackPresentationSite.STATE_MINIMIZED),
- site.supportsState(IStackPresentationSite.STATE_MAXIMIZED));
-
- /*
- * Set the minimum characters to display, if the preference is something
- * other than the default. This is mainly intended for RCP applications
- * or for expert users (i.e., via the plug-in customization file).
- *
- * Bug 32789.
- */
- final IPreferenceStore store = PlatformUI.getPreferenceStore();
- if (store
- .contains(IWorkbenchPreferenceConstants.EDITOR_MINIMUM_CHARACTERS)) {
- final int minimumCharacters = store
- .getInt(IWorkbenchPreferenceConstants.EDITOR_MINIMUM_CHARACTERS);
- if (minimumCharacters >= 0) {
- folder.setMinimumCharacters(minimumCharacters);
- }
- }
-
- PresentablePartFolder partFolder = new PresentablePartFolder(folder);
-
- TabbedStackPresentation result = new TabbedStackPresentation(site,
- partFolder, new StandardEditorSystemMenu(site));
-
- DefaultThemeListener themeListener = new DefaultThemeListener(folder,
- result.getTheme());
- result.getTheme().addListener(themeListener);
-
- new DefaultMultiTabListener(result.getApiPreferences(),
- IWorkbenchPreferenceConstants.SHOW_MULTIPLE_EDITOR_TABS, folder);
-
- new DefaultSimpleTabListener(result.getApiPreferences(),
- IWorkbenchPreferenceConstants.SHOW_TRADITIONAL_STYLE_TABS,
- folder);
-
- return result;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.presentations.AbstractPresentationFactory#createViewPresentation(org.eclipse.swt.widgets.Composite,
- * org.eclipse.ui.presentations.IStackPresentationSite)
- */
- public StackPresentation createViewPresentation(Composite parent,
- IStackPresentationSite site) {
-
- DefaultTabFolder folder = new DefaultTabFolder(parent, viewTabPosition
- | SWT.BORDER, site
- .supportsState(IStackPresentationSite.STATE_MINIMIZED), site
- .supportsState(IStackPresentationSite.STATE_MAXIMIZED));
-
- final IPreferenceStore store = PlatformUI.getPreferenceStore();
- final int minimumCharacters = store
- .getInt(IWorkbenchPreferenceConstants.VIEW_MINIMUM_CHARACTERS);
- if (minimumCharacters >= 0) {
- folder.setMinimumCharacters(minimumCharacters);
- }
-
- PresentablePartFolder partFolder = new PresentablePartFolder(folder);
-
- folder.setUnselectedCloseVisible(false);
- folder.setUnselectedImageVisible(true);
-
- TabbedStackPresentation result = new TabbedStackPresentation(site,
- partFolder, new StandardViewSystemMenu(site));
-
- DefaultThemeListener themeListener = new DefaultThemeListener(folder,
- result.getTheme());
- result.getTheme().addListener(themeListener);
-
- new DefaultSimpleTabListener(result.getApiPreferences(),
- IWorkbenchPreferenceConstants.SHOW_TRADITIONAL_STYLE_TABS,
- folder);
-
- return result;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.presentations.AbstractPresentationFactory#createStandaloneViewPresentation(org.eclipse.swt.widgets.Composite,
- * org.eclipse.ui.presentations.IStackPresentationSite, boolean)
- */
- public StackPresentation createStandaloneViewPresentation(Composite parent,
- IStackPresentationSite site, boolean showTitle) {
-
- if (showTitle) {
- return createViewPresentation(parent, site);
- }
- EmptyTabFolder folder = new EmptyTabFolder(parent, true);
- TabbedStackPresentation presentation = new TabbedStackPresentation(
- site, folder, new StandardViewSystemMenu(site));
-
- return presentation;
- }
-
-}

Back to the top