|
Lines 1-5
Link Here
|
| 1 |
/******************************************************************************* |
1 |
/******************************************************************************* |
| 2 |
* Copyright (c) 2000, 2005 IBM Corporation and others. |
2 |
* Copyright (c) 2000, 2006 IBM Corporation and others. |
| 3 |
* All rights reserved. This program and the accompanying materials |
3 |
* All rights reserved. This program and the accompanying materials |
| 4 |
* are made available under the terms of the Eclipse Public License v1.0 |
4 |
* are made available under the terms of the Eclipse Public License v1.0 |
| 5 |
* which accompanies this distribution, and is available at |
5 |
* which accompanies this distribution, and is available at |
|
Lines 36-47
Link Here
|
| 36 |
import org.eclipse.jface.action.IAction; |
36 |
import org.eclipse.jface.action.IAction; |
| 37 |
import org.eclipse.jface.action.IContributionItem; |
37 |
import org.eclipse.jface.action.IContributionItem; |
| 38 |
import org.eclipse.jface.action.IContributionManager; |
38 |
import org.eclipse.jface.action.IContributionManager; |
|
|
39 |
import org.eclipse.jface.action.ICoolBarManager; |
| 39 |
import org.eclipse.jface.action.IMenuManager; |
40 |
import org.eclipse.jface.action.IMenuManager; |
|
|
41 |
import org.eclipse.jface.action.IToolBarContributionItem; |
| 42 |
import org.eclipse.jface.action.IToolBarManager2; |
| 40 |
import org.eclipse.jface.action.MenuManager; |
43 |
import org.eclipse.jface.action.MenuManager; |
| 41 |
import org.eclipse.jface.action.Separator; |
44 |
import org.eclipse.jface.action.Separator; |
| 42 |
import org.eclipse.jface.action.StatusLineManager; |
45 |
import org.eclipse.jface.action.StatusLineManager; |
| 43 |
import org.eclipse.jface.action.ToolBarContributionItem; |
|
|
| 44 |
import org.eclipse.jface.action.ToolBarManager; |
| 45 |
import org.eclipse.jface.commands.ActionHandler; |
46 |
import org.eclipse.jface.commands.ActionHandler; |
| 46 |
import org.eclipse.jface.menus.ILayoutNode; |
47 |
import org.eclipse.jface.menus.ILayoutNode; |
| 47 |
import org.eclipse.jface.menus.SMenuLayout; |
48 |
import org.eclipse.jface.menus.SMenuLayout; |
|
Lines 117-122
Link Here
|
| 117 |
import org.eclipse.ui.internal.misc.Policy; |
118 |
import org.eclipse.ui.internal.misc.Policy; |
| 118 |
import org.eclipse.ui.internal.misc.UIListenerLogging; |
119 |
import org.eclipse.ui.internal.misc.UIListenerLogging; |
| 119 |
import org.eclipse.ui.internal.misc.UIStats; |
120 |
import org.eclipse.ui.internal.misc.UIStats; |
|
|
121 |
import org.eclipse.ui.internal.presentations.ActionBarPresentation; |
| 122 |
import org.eclipse.ui.internal.presentations.InternalPresentationFactory; |
| 120 |
import org.eclipse.ui.internal.progress.ProgressRegion; |
123 |
import org.eclipse.ui.internal.progress.ProgressRegion; |
| 121 |
import org.eclipse.ui.internal.registry.ActionSetRegistry; |
124 |
import org.eclipse.ui.internal.registry.ActionSetRegistry; |
| 122 |
import org.eclipse.ui.internal.registry.IActionSetDescriptor; |
125 |
import org.eclipse.ui.internal.registry.IActionSetDescriptor; |
|
Lines 125-130
Link Here
|
| 125 |
import org.eclipse.ui.internal.services.ServiceLocator; |
128 |
import org.eclipse.ui.internal.services.ServiceLocator; |
| 126 |
import org.eclipse.ui.internal.util.PrefUtil; |
129 |
import org.eclipse.ui.internal.util.PrefUtil; |
| 127 |
import org.eclipse.ui.menus.IMenuService; |
130 |
import org.eclipse.ui.menus.IMenuService; |
|
|
131 |
import org.eclipse.ui.presentations.AbstractPresentationFactory; |
| 128 |
|
132 |
|
| 129 |
/** |
133 |
/** |
| 130 |
* A window within the workbench. |
134 |
* A window within the workbench. |
|
Lines 318-325
Link Here
|
| 318 |
addCoolBar(SWT.FLAT); |
322 |
addCoolBar(SWT.FLAT); |
| 319 |
addStatusLine(); |
323 |
addStatusLine(); |
| 320 |
|
324 |
|
| 321 |
actionPresentation = new ActionPresentation(this); |
|
|
| 322 |
|
| 323 |
// register with the tracker |
325 |
// register with the tracker |
| 324 |
getExtensionTracker() |
326 |
getExtensionTracker() |
| 325 |
.registerHandler( |
327 |
.registerHandler( |
|
Lines 700-706
Link Here
|
| 700 |
* Return whether or not the coolbar layout is locked. |
702 |
* Return whether or not the coolbar layout is locked. |
| 701 |
*/ |
703 |
*/ |
| 702 |
protected boolean isCoolBarLocked() { |
704 |
protected boolean isCoolBarLocked() { |
| 703 |
CoolBarManager cbm = getCoolBarManager(); |
705 |
ICoolBarManager cbm = getCoolBarManager2(); |
| 704 |
return cbm != null && cbm.getLockLayout(); |
706 |
return cbm != null && cbm.getLockLayout(); |
| 705 |
} |
707 |
} |
| 706 |
|
708 |
|
|
Lines 1411-1417
Link Here
|
| 1411 |
boolean result; |
1413 |
boolean result; |
| 1412 |
try { |
1414 |
try { |
| 1413 |
// Clear the action sets, fix for bug 27416. |
1415 |
// Clear the action sets, fix for bug 27416. |
| 1414 |
actionPresentation.clearActionSets(); |
1416 |
getActionPresentation().clearActionSets(); |
| 1415 |
|
1417 |
|
| 1416 |
// Remove the handler submissions. Bug 64024. |
1418 |
// Remove the handler submissions. Bug 64024. |
| 1417 |
final IWorkbench workbench = getWorkbench(); |
1419 |
final IWorkbench workbench = getWorkbench(); |
|
Lines 1476-1482
Link Here
|
| 1476 |
*/ |
1478 |
*/ |
| 1477 |
/* package */ |
1479 |
/* package */ |
| 1478 |
void lockCoolBar(boolean lock) { |
1480 |
void lockCoolBar(boolean lock) { |
| 1479 |
getCoolBarManager().setLockLayout(lock); |
1481 |
getCoolBarManager2().setLockLayout(lock); |
| 1480 |
} |
1482 |
} |
| 1481 |
|
1483 |
|
| 1482 |
/** |
1484 |
/** |
|
Lines 1642-1649
Link Here
|
| 1642 |
// This needs to be done before pages are created to ensure proper |
1644 |
// This needs to be done before pages are created to ensure proper |
| 1643 |
// canonical creation |
1645 |
// canonical creation |
| 1644 |
// of cool items |
1646 |
// of cool items |
| 1645 |
if (getCoolBarManager() != null) { |
1647 |
ICoolBarManager coolBarMgr = getCoolBarManager2(); |
| 1646 |
CoolBarManager coolBarMgr = getCoolBarManager(); |
1648 |
if (coolBarMgr != null) { |
| 1647 |
IMemento coolBarMem = memento |
1649 |
IMemento coolBarMem = memento |
| 1648 |
.getChild(IWorkbenchConstants.TAG_COOLBAR_LAYOUT); |
1650 |
.getChild(IWorkbenchConstants.TAG_COOLBAR_LAYOUT); |
| 1649 |
if (coolBarMem != null) { |
1651 |
if (coolBarMem != null) { |
|
Lines 1711-1722
Link Here
|
| 1711 |
if (oldItem != null) { |
1713 |
if (oldItem != null) { |
| 1712 |
newItem = oldItem; |
1714 |
newItem = oldItem; |
| 1713 |
} else { |
1715 |
} else { |
| 1714 |
newItem = new ToolBarContributionItem( |
1716 |
ActionBarPresentation actionBarPresentation = getActionBarPresentation(); |
| 1715 |
new ToolBarManager(coolBarMgr |
1717 |
newItem = actionBarPresentation.createToolBarContributionItem( |
|
|
1718 |
actionBarPresentation.createToolBarManager(coolBarMgr |
| 1716 |
.getStyle()), id); |
1719 |
.getStyle()), id); |
| 1717 |
if (type |
1720 |
if (type |
| 1718 |
.equals(IWorkbenchConstants.TAG_TYPE_PLACEHOLDER)) { |
1721 |
.equals(IWorkbenchConstants.TAG_TYPE_PLACEHOLDER)) { |
| 1719 |
ToolBarContributionItem newToolBarItem = (ToolBarContributionItem) newItem; |
1722 |
IToolBarContributionItem newToolBarItem = (IToolBarContributionItem) newItem; |
| 1720 |
if (height != null) { |
1723 |
if (height != null) { |
| 1721 |
newToolBarItem.setCurrentHeight(height |
1724 |
newToolBarItem.setCurrentHeight(height |
| 1722 |
.intValue()); |
1725 |
.intValue()); |
|
Lines 1744-1756
Link Here
|
| 1744 |
} |
1747 |
} |
| 1745 |
// Set the current height and width |
1748 |
// Set the current height and width |
| 1746 |
if ((width != null) |
1749 |
if ((width != null) |
| 1747 |
&& (newItem instanceof ToolBarContributionItem)) { |
1750 |
&& (newItem instanceof IToolBarContributionItem)) { |
| 1748 |
((ToolBarContributionItem) newItem) |
1751 |
((IToolBarContributionItem) newItem) |
| 1749 |
.setCurrentWidth(width.intValue()); |
1752 |
.setCurrentWidth(width.intValue()); |
| 1750 |
} |
1753 |
} |
| 1751 |
if ((height != null) |
1754 |
if ((height != null) |
| 1752 |
&& (newItem instanceof ToolBarContributionItem)) { |
1755 |
&& (newItem instanceof IToolBarContributionItem)) { |
| 1753 |
((ToolBarContributionItem) newItem) |
1756 |
((IToolBarContributionItem) newItem) |
| 1754 |
.setCurrentHeight(height.intValue()); |
1757 |
.setCurrentHeight(height.intValue()); |
| 1755 |
} |
1758 |
} |
| 1756 |
} |
1759 |
} |
|
Lines 1935-1941
Link Here
|
| 1935 |
if (coolbarMem == null) { |
1938 |
if (coolbarMem == null) { |
| 1936 |
return false; |
1939 |
return false; |
| 1937 |
} |
1940 |
} |
| 1938 |
CoolBarManager coolBarMgr = getCoolBarManager(); |
1941 |
ICoolBarManager coolBarMgr = getCoolBarManager2(); |
| 1939 |
// Check to see if layout is locked |
1942 |
// Check to see if layout is locked |
| 1940 |
Integer locked = coolbarMem.getInteger(IWorkbenchConstants.TAG_LOCKED); |
1943 |
Integer locked = coolbarMem.getInteger(IWorkbenchConstants.TAG_LOCKED); |
| 1941 |
boolean state = (locked != null) && (locked.intValue() == 1); |
1944 |
boolean state = (locked != null) && (locked.intValue() == 1); |
|
Lines 2027-2037
Link Here
|
| 2027 |
} |
2030 |
} |
| 2028 |
// If a tool bar contribution item already exists for this id |
2031 |
// If a tool bar contribution item already exists for this id |
| 2029 |
// then use the old object |
2032 |
// then use the old object |
| 2030 |
if (oldItem instanceof ToolBarContributionItem) { |
2033 |
if (oldItem instanceof IToolBarContributionItem) { |
| 2031 |
newItem = oldItem; |
2034 |
newItem = oldItem; |
| 2032 |
} else { |
2035 |
} else { |
| 2033 |
newItem = new ToolBarContributionItem(new ToolBarManager( |
2036 |
ActionBarPresentation actionBarPresentaiton = getActionBarPresentation(); |
| 2034 |
coolBarMgr.getStyle()), id); |
2037 |
newItem = actionBarPresentaiton.createToolBarContributionItem( |
|
|
2038 |
actionBarPresentaiton.createToolBarManager(coolBarMgr.getStyle()), id); |
| 2035 |
// make it invisible by default |
2039 |
// make it invisible by default |
| 2036 |
newItem.setVisible(false); |
2040 |
newItem.setVisible(false); |
| 2037 |
// Need to add the item to the cool bar manager so that its |
2041 |
// Need to add the item to the cool bar manager so that its |
|
Lines 2267-2282
Link Here
|
| 2267 |
} |
2271 |
} |
| 2268 |
|
2272 |
|
| 2269 |
// / Save the order of the cool bar contribution items |
2273 |
// / Save the order of the cool bar contribution items |
| 2270 |
if (getCoolBarManager() != null) { |
2274 |
ICoolBarManager coolBarMgr = getCoolBarManager2(); |
| 2271 |
getCoolBarManager().refresh(); |
2275 |
if (coolBarMgr != null) { |
|
|
2276 |
coolBarMgr.refresh(); |
| 2272 |
IMemento coolBarMem = memento |
2277 |
IMemento coolBarMem = memento |
| 2273 |
.createChild(IWorkbenchConstants.TAG_COOLBAR_LAYOUT); |
2278 |
.createChild(IWorkbenchConstants.TAG_COOLBAR_LAYOUT); |
| 2274 |
if (getCoolBarManager().getLockLayout() == true) { |
2279 |
if (coolBarMgr.getLockLayout() == true) { |
| 2275 |
coolBarMem.putInteger(IWorkbenchConstants.TAG_LOCKED, 1); |
2280 |
coolBarMem.putInteger(IWorkbenchConstants.TAG_LOCKED, 1); |
| 2276 |
} else { |
2281 |
} else { |
| 2277 |
coolBarMem.putInteger(IWorkbenchConstants.TAG_LOCKED, 0); |
2282 |
coolBarMem.putInteger(IWorkbenchConstants.TAG_LOCKED, 0); |
| 2278 |
} |
2283 |
} |
| 2279 |
IContributionItem[] items = getCoolBarManager().getItems(); |
2284 |
IContributionItem[] items = coolBarMgr.getItems(); |
| 2280 |
for (int i = 0; i < items.length; i++) { |
2285 |
for (int i = 0; i < items.length; i++) { |
| 2281 |
IMemento coolItemMem = coolBarMem |
2286 |
IMemento coolItemMem = coolBarMem |
| 2282 |
.createChild(IWorkbenchConstants.TAG_COOLITEM); |
2287 |
.createChild(IWorkbenchConstants.TAG_COOLITEM); |
|
Lines 2312-2319
Link Here
|
| 2312 |
*/ |
2317 |
*/ |
| 2313 |
final int height; |
2318 |
final int height; |
| 2314 |
final int width; |
2319 |
final int width; |
| 2315 |
if (item instanceof ToolBarContributionItem) { |
2320 |
if (item instanceof IToolBarContributionItem) { |
| 2316 |
ToolBarContributionItem toolBarItem = (ToolBarContributionItem) item; |
2321 |
IToolBarContributionItem toolBarItem = (IToolBarContributionItem) item; |
| 2317 |
toolBarItem.saveWidgetState(); |
2322 |
toolBarItem.saveWidgetState(); |
| 2318 |
height = toolBarItem.getCurrentHeight(); |
2323 |
height = toolBarItem.getCurrentHeight(); |
| 2319 |
width = toolBarItem.getCurrentWidth(); |
2324 |
width = toolBarItem.getCurrentWidth(); |
|
Lines 2619-2625
Link Here
|
| 2619 |
} |
2624 |
} |
| 2620 |
// updateAll required in order to enable accelerators on pull-down menus |
2625 |
// updateAll required in order to enable accelerators on pull-down menus |
| 2621 |
getMenuBarManager().updateAll(false); |
2626 |
getMenuBarManager().updateAll(false); |
| 2622 |
getCoolBarManager().update(false); |
2627 |
getCoolBarManager2().update(false); |
| 2623 |
getStatusLineManager().update(false); |
2628 |
getStatusLineManager().update(false); |
| 2624 |
} |
2629 |
} |
| 2625 |
|
2630 |
|
|
Lines 2683-2694
Link Here
|
| 2683 |
|
2688 |
|
| 2684 |
WorkbenchPage currentPage = getActiveWorkbenchPage(); |
2689 |
WorkbenchPage currentPage = getActiveWorkbenchPage(); |
| 2685 |
if (currentPage == null) |
2690 |
if (currentPage == null) |
| 2686 |
actionPresentation.clearActionSets(); |
2691 |
getActionPresentation().clearActionSets(); |
| 2687 |
else { |
2692 |
else { |
| 2688 |
if (getCoolBarManager() != null) { |
2693 |
if (getCoolBarManager2() != null) { |
| 2689 |
getCoolBarManager().refresh(); |
2694 |
getCoolBarManager2().refresh(); |
| 2690 |
} |
2695 |
} |
| 2691 |
actionPresentation.setActionSets(currentPage.getActionSets()); |
2696 |
getActionPresentation().setActionSets(currentPage.getActionSets()); |
| 2692 |
} |
2697 |
} |
| 2693 |
fireActionSetsChanged(); |
2698 |
fireActionSetsChanged(); |
| 2694 |
updateActionBars(); |
2699 |
updateActionBars(); |
|
Lines 3195-3205
Link Here
|
| 3195 |
.getPerspectiveBar(); |
3200 |
.getPerspectiveBar(); |
| 3196 |
} |
3201 |
} |
| 3197 |
|
3202 |
|
| 3198 |
// for dynamic UI |
3203 |
/** |
| 3199 |
public ActionPresentation getActionPresentation() { |
3204 |
* Returns the action presentation for dynamic UI |
| 3200 |
return actionPresentation; |
3205 |
* @return action presentation |
| 3201 |
} |
3206 |
*/ |
| 3202 |
|
3207 |
public ActionPresentation getActionPresentation() { |
|
|
3208 |
if (actionPresentation == null) { |
| 3209 |
actionPresentation = new ActionPresentation(this); |
| 3210 |
} |
| 3211 |
return actionPresentation; |
| 3212 |
} |
| 3213 |
|
| 3214 |
/*package*/ ActionBarPresentation getActionBarPresentation() { |
| 3215 |
// allow replacement of the actionbar presentation |
| 3216 |
ActionBarPresentation actionBarPresentation; |
| 3217 |
AbstractPresentationFactory presentationFactory = |
| 3218 |
getWindowConfigurer().getPresentationFactory(); |
| 3219 |
if (presentationFactory instanceof InternalPresentationFactory) { |
| 3220 |
actionBarPresentation = ((InternalPresentationFactory) presentationFactory) |
| 3221 |
.createActionBarPresentation(this); |
| 3222 |
} |
| 3223 |
else |
| 3224 |
actionBarPresentation = new ActionBarPresentation(); |
| 3225 |
|
| 3226 |
return actionBarPresentation; |
| 3227 |
} |
| 3228 |
|
| 3203 |
/* |
3229 |
/* |
| 3204 |
* (non-Javadoc) |
3230 |
* (non-Javadoc) |
| 3205 |
* |
3231 |
* |
|
Lines 3210-3215
Link Here
|
| 3210 |
} |
3236 |
} |
| 3211 |
|
3237 |
|
| 3212 |
/** |
3238 |
/** |
|
|
3239 |
* Returns a new cool bar manager for the window. |
| 3240 |
* <p> |
| 3241 |
* Subclasses may override this method to customize the cool bar manager. |
| 3242 |
* </p> |
| 3243 |
* |
| 3244 |
* @return a cool bar manager |
| 3245 |
* @since 3.2 |
| 3246 |
*/ |
| 3247 |
protected ICoolBarManager createCoolBarManager2(int style) { |
| 3248 |
return getActionBarPresentation().createCoolBarManager(style); |
| 3249 |
} |
| 3250 |
|
| 3251 |
/** |
| 3252 |
* Creates the control for the cool bar manager. |
| 3253 |
* <p> |
| 3254 |
* Subclasses may override this method to customize the cool bar manager. |
| 3255 |
* </p> |
| 3256 |
* |
| 3257 |
* @return an instance of <code>CoolBar</code>\ |
| 3258 |
* @since 3.2 |
| 3259 |
*/ |
| 3260 |
protected Control createCoolBarControl(Composite parent) { |
| 3261 |
return getActionBarPresentation().createCoolBarControl(getCoolBarManager2(), parent); |
| 3262 |
} |
| 3263 |
|
| 3264 |
/** |
| 3265 |
* Returns a new tool bar manager for the window. |
| 3266 |
* <p> |
| 3267 |
* Subclasses may override this method to customize the tool bar manager. |
| 3268 |
* </p> |
| 3269 |
* @return a tool bar manager |
| 3270 |
* @since 3.2 |
| 3271 |
*/ |
| 3272 |
protected IToolBarManager2 createToolBarManager2(int style) { |
| 3273 |
return getActionBarPresentation().createToolBarManager(style); |
| 3274 |
} |
| 3275 |
|
| 3276 |
/** |
| 3277 |
* Creates the control for the tool bar manager. |
| 3278 |
* <p> |
| 3279 |
* Subclasses may override this method to customize the tool bar manager. |
| 3280 |
* </p> |
| 3281 |
* @return a Control |
| 3282 |
* @since 3.2 |
| 3283 |
*/ |
| 3284 |
protected Control createToolBarControl(Composite parent) { |
| 3285 |
return getActionBarPresentation().createToolBarControl(getToolBarManager2(), parent); |
| 3286 |
} |
| 3287 |
|
| 3288 |
/** |
| 3213 |
* Delegate to the presentation factory. |
3289 |
* Delegate to the presentation factory. |
| 3214 |
* |
3290 |
* |
| 3215 |
* @see org.eclipse.jface.window.ApplicationWindow#createStatusLineManager |
3291 |
* @see org.eclipse.jface.window.ApplicationWindow#createStatusLineManager |