Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 114510 Details for
Bug 231304
[Contributions] Tooltip for Menu Contributions placed on toolbar: does not include keybinding sequence(inconsistency in migrating from ActionSets to MenuContributions)
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
v04 - patch based on v03
Tooltip v04.txt (text/plain), 14.95 KB, created by
Prakash Rangaraj
on 2008-10-08 02:18:12 EDT
(
hide
)
Description:
v04 - patch based on v03
Filename:
MIME Type:
Creator:
Prakash Rangaraj
Created:
2008-10-08 02:18:12 EDT
Size:
14.95 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.ui.workbench >Index: Eclipse UI/org/eclipse/ui/keys/IBindingService.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/keys/IBindingService.java,v >retrieving revision 1.21 >diff -u -r1.21 IBindingService.java >--- Eclipse UI/org/eclipse/ui/keys/IBindingService.java 5 Jun 2008 13:46:55 -0000 1.21 >+++ Eclipse UI/org/eclipse/ui/keys/IBindingService.java 8 Oct 2008 06:14:47 -0000 >@@ -15,6 +15,7 @@ > > import org.eclipse.core.commands.ParameterizedCommand; > import org.eclipse.jface.bindings.Binding; >+import org.eclipse.jface.bindings.IBindingManagerListener; > import org.eclipse.jface.bindings.Scheme; > import org.eclipse.jface.bindings.TriggerSequence; > import org.eclipse.ui.commands.ICommandService; >@@ -53,6 +54,38 @@ > public static final String DEFAULT_DEFAULT_ACTIVE_SCHEME_ID = "org.eclipse.ui.defaultAcceleratorConfiguration"; //$NON-NLS-1$ > > /** >+ * <p> >+ * Adds a listener to this binding service. The listener will be notified >+ * when the set of defined schemes or bindings changes. This can be used to >+ * track the global appearance and disappearance of bindings. >+ * </p> >+ * <p> >+ * This method completes in amortized constant time (<code>O(1)</code>). >+ * </p> >+ * >+ * @param listener >+ * The listener to attach; must not be <code>null</code>. >+ * >+ * @since 3.5 >+ */ >+ public void addBindingManagerListener(IBindingManagerListener listener); >+ >+ /** >+ * <p> >+ * Removes a listener from this binding service. >+ * </p> >+ * <p> >+ * This method completes in amortized <code>O(1)</code>. >+ * </p> >+ * >+ * @param listener >+ * The listener to be removed; must not be <code>null</code>. >+ * >+ * @since 3.5 >+ */ >+ public void removeBindingManagerListener(IBindingManagerListener listener); >+ >+ /** > * Gets the active bindings for a given parameterized command. > * > * @param parameterizedCommand >Index: Eclipse UI/org/eclipse/ui/internal/keys/BindingService.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/keys/BindingService.java,v >retrieving revision 1.27 >diff -u -r1.27 BindingService.java >--- Eclipse UI/org/eclipse/ui/internal/keys/BindingService.java 24 Mar 2008 19:22:01 -0000 1.27 >+++ Eclipse UI/org/eclipse/ui/internal/keys/BindingService.java 8 Oct 2008 06:14:47 -0000 >@@ -17,6 +17,7 @@ > import org.eclipse.core.commands.common.NotDefinedException; > import org.eclipse.jface.bindings.Binding; > import org.eclipse.jface.bindings.BindingManager; >+import org.eclipse.jface.bindings.IBindingManagerListener; > import org.eclipse.jface.bindings.Scheme; > import org.eclipse.jface.bindings.TriggerSequence; > import org.eclipse.jface.bindings.keys.SWTKeySupport; >@@ -248,5 +249,27 @@ > public BindingPersistence getBindingPersistence() { > return bindingPersistence; > } >+ >+ /* >+ * (non-Javadoc) >+ * >+ * @see >+ * org.eclipse.ui.keys.IBindingService#addBindingManagerListener(org.eclipse >+ * .jface.bindings.IBindingManagerListener) >+ */ >+ public void addBindingManagerListener(IBindingManagerListener listener) { >+ bindingManager.addBindingManagerListener(listener); >+ } >+ >+ /* >+ * (non-Javadoc) >+ * >+ * @see >+ * org.eclipse.ui.keys.IBindingService#removeBindingManagerListener(org. >+ * eclipse.jface.bindings.IBindingManagerListener) >+ */ >+ public void removeBindingManagerListener(IBindingManagerListener listener) { >+ bindingManager.removeBindingManagerListener(listener); >+ } > > } >Index: Eclipse UI/org/eclipse/ui/menus/CommandContributionItem.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/menus/CommandContributionItem.java,v >retrieving revision 1.47 >diff -u -r1.47 CommandContributionItem.java >--- Eclipse UI/org/eclipse/ui/menus/CommandContributionItem.java 12 Sep 2008 19:54:44 -0000 1.47 >+++ Eclipse UI/org/eclipse/ui/menus/CommandContributionItem.java 8 Oct 2008 06:14:48 -0000 >@@ -25,10 +25,13 @@ > import org.eclipse.jface.action.IMenuListener; > import org.eclipse.jface.action.IMenuManager; > import org.eclipse.jface.action.MenuManager; >+import org.eclipse.jface.bindings.BindingManagerEvent; >+import org.eclipse.jface.bindings.IBindingManagerListener; > import org.eclipse.jface.bindings.TriggerSequence; > import org.eclipse.jface.resource.ImageDescriptor; > import org.eclipse.jface.resource.JFaceResources; > import org.eclipse.jface.resource.LocalResourceManager; >+import org.eclipse.osgi.util.NLS; > import org.eclipse.swt.SWT; > import org.eclipse.swt.graphics.Point; > import org.eclipse.swt.widgets.Button; >@@ -50,6 +53,7 @@ > import org.eclipse.ui.handlers.IHandlerService; > import org.eclipse.ui.help.IWorkbenchHelpSystem; > import org.eclipse.ui.internal.WorkbenchPlugin; >+import org.eclipse.ui.internal.menus.CommandMessages; > import org.eclipse.ui.internal.services.IWorkbenchLocationService; > import org.eclipse.ui.keys.IBindingService; > import org.eclipse.ui.services.IServiceLocator; >@@ -399,6 +403,9 @@ > > update(null); > updateIcons(); >+ >+ bindingService.addBindingManagerListener(bindingManagerListener); >+ > } > > /* (non-Javadoc) >@@ -428,6 +435,9 @@ > > update(null); > updateIcons(); >+ >+ bindingService.addBindingManagerListener(bindingManagerListener); >+ > } > > /* >@@ -460,6 +470,8 @@ > > update(null); > updateIcons(); >+ >+ bindingService.addBindingManagerListener(bindingManagerListener); > } > > /* >@@ -479,119 +491,142 @@ > public void update(String id) { > if (widget != null) { > if (widget instanceof MenuItem) { >- MenuItem item = (MenuItem) widget; >+ updateMenuItem(); >+ } else if (widget instanceof ToolItem) { >+ updateToolItem(); >+ } else if (widget instanceof Button) { >+ updateButton(); >+ } >+ } >+ } > >- String text = label; >- if (text == null) { >- if (command != null) { >- try { >- text = command.getCommand().getName(); >- } catch (NotDefinedException e) { >- WorkbenchPlugin.log("Update item failed " //$NON-NLS-1$ >- + getId(), e); >- } >- } >- } >- text = updateMnemonic(text); >+ private void updateMenuItem() { >+ MenuItem item = (MenuItem) widget; > >- String keyBindingText = null; >- if (command != null) { >- TriggerSequence binding = bindingService >- .getBestActiveBindingFor(command); >- if (binding != null) { >- keyBindingText = binding.format(); >- } >- } >- if (text != null) { >- if (keyBindingText == null) { >- item.setText(text); >- } else { >- item.setText(text + '\t' + keyBindingText); >- } >+ String text = label; >+ if (text == null) { >+ if (command != null) { >+ try { >+ text = command.getCommand().getName(); >+ } catch (NotDefinedException e) { >+ WorkbenchPlugin.log("Update item failed " //$NON-NLS-1$ >+ + getId(), e); > } >+ } >+ } >+ text = updateMnemonic(text); > >- if (item.getSelection() != checkedState) { >- item.setSelection(checkedState); >- } >+ String keyBindingText = null; >+ if (command != null) { >+ TriggerSequence binding = bindingService >+ .getBestActiveBindingFor(command); >+ if (binding != null) { >+ keyBindingText = binding.format(); >+ } >+ } >+ if (text != null) { >+ if (keyBindingText == null) { >+ item.setText(text); >+ } else { >+ item.setText(text + '\t' + keyBindingText); >+ } >+ } > >- boolean shouldBeEnabled = isEnabled(); >- if (item.getEnabled() != shouldBeEnabled) { >- item.setEnabled(shouldBeEnabled); >- } >- } else if (widget instanceof ToolItem) { >- ToolItem item = (ToolItem) widget; >+ if (item.getSelection() != checkedState) { >+ item.setSelection(checkedState); >+ } > >- String text = label; >- if (text == null) { >- if (command != null) { >- try { >- text = command.getCommand().getName(); >- } catch (NotDefinedException e) { >- WorkbenchPlugin.log("Update item failed " //$NON-NLS-1$ >- + getId(), e); >- } >- } >- } >+ boolean shouldBeEnabled = isEnabled(); >+ if (item.getEnabled() != shouldBeEnabled) { >+ item.setEnabled(shouldBeEnabled); >+ } >+ } > >- if ((icon == null || (mode & MODE_FORCE_TEXT) == MODE_FORCE_TEXT) >- && text != null) { >- item.setText(text); >- } >+ private void updateToolItem() { >+ ToolItem item = (ToolItem) widget; > >- if (tooltip != null) >- item.setToolTipText(tooltip); >- else { >- if (text != null) { >- item.setToolTipText(text); >- } >+ String text = label; >+ if (text == null) { >+ if (command != null) { >+ try { >+ text = command.getCommand().getName(); >+ } catch (NotDefinedException e) { >+ WorkbenchPlugin.log("Update item failed " //$NON-NLS-1$ >+ + getId(), e); > } >+ } >+ } > >- if (item.getSelection() != checkedState) { >- item.setSelection(checkedState); >- } >+ if ((icon == null || (mode & MODE_FORCE_TEXT) == MODE_FORCE_TEXT) >+ && text != null) { >+ item.setText(text); >+ } >+ >+ String toolTipText = getToolTipText(text); >+ item.setToolTipText(toolTipText); >+ >+ if (item.getSelection() != checkedState) { >+ item.setSelection(checkedState); >+ } >+ >+ boolean shouldBeEnabled = isEnabled(); >+ if (item.getEnabled() != shouldBeEnabled) { >+ item.setEnabled(shouldBeEnabled); >+ } >+ } > >- boolean shouldBeEnabled = isEnabled(); >- if (item.getEnabled() != shouldBeEnabled) { >- item.setEnabled(shouldBeEnabled); >+ private void updateButton() { >+ Button item = (Button) widget; >+ >+ String text = label; >+ if (text == null) { >+ if (command != null) { >+ try { >+ text = command.getCommand().getName(); >+ } catch (NotDefinedException e) { >+ WorkbenchPlugin.log("Update item failed " //$NON-NLS-1$ >+ + getId(), e); > } > } >- else if (widget instanceof Button) { >- Button item = (Button) widget; >+ } > >- String text = label; >- if (text == null) { >- if (command != null) { >- try { >- text = command.getCommand().getName(); >- } catch (NotDefinedException e) { >- WorkbenchPlugin.log("Update item failed " //$NON-NLS-1$ >- + getId(), e); >- } >- } >- } >+ if (text != null) { >+ item.setText(text); >+ } > >- if (text != null) { >- item.setText(text); >- } >+ String toolTipText = getToolTipText(text); >+ item.setToolTipText(toolTipText); > >- if (tooltip != null) >- item.setToolTipText(tooltip); >- else { >- if (text != null) { >- item.setToolTipText(text); >- } >- } >+ if (item.getSelection() != checkedState) { >+ item.setSelection(checkedState); >+ } > >- if (item.getSelection() != checkedState) { >- item.setSelection(checkedState); >- } >+ boolean shouldBeEnabled = isEnabled(); >+ if (item.getEnabled() != shouldBeEnabled) { >+ item.setEnabled(shouldBeEnabled); >+ } >+ } > >- boolean shouldBeEnabled = isEnabled(); >- if (item.getEnabled() != shouldBeEnabled) { >- item.setEnabled(shouldBeEnabled); >- } >+ private String getToolTipText(String text) { >+ String tooltipText = tooltip; >+ if (tooltip == null) >+ if (text != null) >+ tooltipText = text; >+ else >+ tooltipText = ""; //$NON-NLS-1$ >+ >+ TriggerSequence activeBinding = bindingService >+ .getBestActiveBindingFor(command); >+ if (activeBinding != null && !activeBinding.isEmpty()) { >+ String acceleratorText = activeBinding.format(); >+ if (acceleratorText != null >+ && acceleratorText.length() != 0) { >+ tooltipText = NLS.bind(CommandMessages.Tooltip_Accelerator, >+ tooltipText, acceleratorText); > } > } >+ >+ return tooltipText; > } > > private String updateMnemonic(String s) { >@@ -633,6 +668,11 @@ > command.getCommand().removeCommandListener(commandListener); > commandListener = null; > } >+ >+ if (bindingService != null) { >+ bindingService.removeBindingManagerListener(bindingManagerListener); >+ } >+ > command = null; > commandService = null; > bindingService = null; >@@ -829,4 +869,16 @@ > } > return super.isVisible(); > } >+ >+ private IBindingManagerListener bindingManagerListener = new IBindingManagerListener() { >+ >+ public void bindingManagerChanged(BindingManagerEvent event) { >+ if (event.isActiveBindingsChanged() >+ && event.isActiveBindingsChangedFor(getCommand())) { >+ update(); >+ } >+ >+ } >+ >+ }; > } >Index: Eclipse UI/org/eclipse/ui/internal/menus/CommandMessages.java >=================================================================== >RCS file: Eclipse UI/org/eclipse/ui/internal/menus/CommandMessages.java >diff -N Eclipse UI/org/eclipse/ui/internal/menus/CommandMessages.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ Eclipse UI/org/eclipse/ui/internal/menus/CommandMessages.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,31 @@ >+/******************************************************************************* >+ * 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.osgi.util.NLS; >+ >+/** >+ * >+ * @since 3.5 >+ * >+ */ >+public class CommandMessages extends NLS { >+ >+ private static final String BUNDLE_NAME = "org.eclipse.ui.internal.menus.messages";//$NON-NLS-1$ >+ >+ static { >+ // load message values from bundle file >+ NLS.initializeMessages(BUNDLE_NAME, CommandMessages.class); >+ } >+ >+ public static String Tooltip_Accelerator; >+} >Index: Eclipse UI/org/eclipse/ui/internal/menus/messages.properties >=================================================================== >RCS file: Eclipse UI/org/eclipse/ui/internal/menus/messages.properties >diff -N Eclipse UI/org/eclipse/ui/internal/menus/messages.properties >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ Eclipse UI/org/eclipse/ui/internal/menus/messages.properties 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,14 @@ >+############################################################################### >+# 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 >+ >+Tooltip_Accelerator = {0} ({1})
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Flags:
pwebster
:
iplog+
Actions:
View
|
Diff
Attachments on
bug 231304
:
112126
|
113819
|
114173
|
114290
|
114330
|
114419
| 114510 |
115137