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 113271 Details for
Bug 246165
[Mac] When copy/paste/select all operation is performed, menu doesn't flash
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
Patch against ui.carbon and ui.workbench
246165.txt (text/plain), 9.24 KB, created by
Kim Horne
on 2008-09-23 12:41:27 EDT
(
hide
)
Description:
Patch against ui.carbon and ui.workbench
Filename:
MIME Type:
Creator:
Kim Horne
Created:
2008-09-23 12:41:27 EDT
Size:
9.24 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.ui.workbench >Index: Eclipse UI/org/eclipse/ui/internal/keys/WorkbenchKeyboard.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/keys/WorkbenchKeyboard.java,v >retrieving revision 1.98 >diff -u -r1.98 WorkbenchKeyboard.java >--- Eclipse UI/org/eclipse/ui/internal/keys/WorkbenchKeyboard.java 31 Jul 2008 18:09:40 -0000 1.98 >+++ Eclipse UI/org/eclipse/ui/internal/keys/WorkbenchKeyboard.java 23 Sep 2008 16:40:07 -0000 >@@ -23,9 +23,12 @@ > import org.eclipse.core.commands.common.CommandException; > import org.eclipse.core.commands.common.NotDefinedException; > import org.eclipse.core.commands.util.Tracing; >+import org.eclipse.core.expressions.IEvaluationContext; >+import org.eclipse.core.runtime.AssertionFailedException; > import org.eclipse.core.runtime.IStatus; > import org.eclipse.core.runtime.Status; > import org.eclipse.jface.bindings.Binding; >+import org.eclipse.jface.bindings.TriggerSequence; > import org.eclipse.jface.bindings.keys.KeySequence; > import org.eclipse.jface.bindings.keys.KeyStroke; > import org.eclipse.jface.bindings.keys.ParseException; >@@ -53,6 +56,8 @@ > import org.eclipse.ui.internal.handlers.HandlerService; > import org.eclipse.ui.internal.misc.Policy; > import org.eclipse.ui.internal.misc.StatusUtil; >+import org.eclipse.ui.internal.tweaklets.Tweaklets; >+import org.eclipse.ui.internal.tweaklets.Tweaklets.TweakKey; > import org.eclipse.ui.internal.util.Util; > import org.eclipse.ui.keys.IBindingService; > import org.eclipse.ui.statushandlers.StatusManager; >@@ -78,6 +83,32 @@ > public final class WorkbenchKeyboard { > > /** >+ * Tweaklet key for menu flashing. >+ * >+ * @since 3.5 >+ */ >+ public static TweakKey KEY = new Tweaklets.TweakKey(MenuFlasher.class); >+ >+ /** >+ * Tweaklet class for flashing the menu. >+ * >+ * @since 3.5 >+ */ >+ public abstract static class MenuFlasher { >+ >+ /** >+ * Flash a menu item that matches the provided key sequence >+ * >+ * @param currentState >+ * the current context >+ * @param triggerSequence >+ * the trigger sequence to flash >+ */ >+ public abstract void flash(IEvaluationContext currentState, >+ TriggerSequence triggerSequence); >+ } >+ >+ /** > * A display filter for handling key bindings. This filter can either be > * enabled or disabled. If disabled, the filter does not process incoming > * events. The filter starts enabled. >@@ -372,6 +403,13 @@ > private final IWorkbench workbench; > > /** >+ * Flasher tweaklet. May be <code>null</code> >+ * >+ * @since 3.5 >+ */ >+ private MenuFlasher flasher; >+ >+ /** > * Constructs a new instance of <code>WorkbenchKeyboard</code> associated > * with a particular workbench. > * >@@ -384,6 +422,14 @@ > workbench = associatedWorkbench; > state = new KeyBindingState(associatedWorkbench); > workbench.addWindowListener(windowListener); >+ try { >+ flasher = (MenuFlasher)Tweaklets.get(KEY); >+ } >+ catch (AssertionFailedException e) { >+ // no-op. No flasher, no problem. Any exceptions in creating a >+ // flasher class would have been logged by the Tweaklets code so we >+ // shouldn't do anything. >+ } > } > > /** >@@ -469,6 +515,8 @@ > } > > try { >+ if (flasher != null) >+ flasher.flash(handlerService.getCurrentState(), binding.getTriggerSequence()); > handlerService.executeCommand(parameterizedCommand, trigger); > } catch (final NotDefinedException e) { > // The command is not defined. Forwarded to the IExecutionListener. >#P org.eclipse.ui.carbon >Index: META-INF/MANIFEST.MF >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.carbon/META-INF/MANIFEST.MF,v >retrieving revision 1.12 >diff -u -r1.12 MANIFEST.MF >--- META-INF/MANIFEST.MF 25 Apr 2008 18:53:05 -0000 1.12 >+++ META-INF/MANIFEST.MF 23 Sep 2008 16:40:08 -0000 >@@ -2,7 +2,7 @@ > Bundle-ManifestVersion: 2 > Bundle-Name: %fragmentName > Bundle-SymbolicName: org.eclipse.ui.carbon; singleton:=true >-Bundle-Version: 4.0.0.qualifier >+Bundle-Version: 4.0.1.qualifier > Bundle-Vendor: %providerName > Fragment-Host: org.eclipse.ui;bundle-version="[3.2.0,4.0.0)" > Bundle-Localization: fragment-carbon >Index: fragment.xml >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.carbon/fragment.xml,v >retrieving revision 1.17 >diff -u -r1.17 fragment.xml >--- fragment.xml 25 Apr 2008 18:50:01 -0000 1.17 >+++ fragment.xml 23 Sep 2008 16:40:08 -0000 >@@ -8,5 +8,15 @@ > class="org.eclipse.ui.internal.carbon.CarbonUIEnhancer"> > </startup> > </extension> >+ <extension >+ point="org.eclipse.ui.internalTweaklets"> >+ <tweaklet >+ definition="org.eclipse.ui.internal.keys.WorkbenchKeyboard$MenuFlasher" >+ description="%menu.tweaklet.description." >+ id="org.eclipse.ui.carbon.menuFlasher" >+ implementation="org.eclipse.ui.internal.carbon.CarbonMenuFlasher" >+ name="%menu.tweaklet.name."> >+ </tweaklet> >+ </extension> > > </fragment> >Index: fragment-carbon.properties >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.carbon/fragment-carbon.properties,v >retrieving revision 1.2 >diff -u -r1.2 fragment-carbon.properties >--- fragment-carbon.properties 3 May 2005 17:54:04 -0000 1.2 >+++ fragment-carbon.properties 23 Sep 2008 16:40:08 -0000 >@@ -11,3 +11,6 @@ > > providerName=Eclipse.org > fragmentName=Eclipse UI MacOS X Enhancements >+ >+menu.tweaklet.description. = Flashes the appropriate main menu entry on keybinding activation >+menu.tweaklet.name. = Carbon Menu Flasher >\ No newline at end of file >Index: src/org/eclipse/ui/internal/carbon/CarbonMenuFlasher.java >=================================================================== >RCS file: src/org/eclipse/ui/internal/carbon/CarbonMenuFlasher.java >diff -N src/org/eclipse/ui/internal/carbon/CarbonMenuFlasher.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/ui/internal/carbon/CarbonMenuFlasher.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,109 @@ >+package org.eclipse.ui.internal.carbon; >+ >+import java.lang.reflect.Field; >+ >+import org.eclipse.core.expressions.IEvaluationContext; >+import org.eclipse.jface.bindings.TriggerSequence; >+import org.eclipse.swt.internal.carbon.OS; >+import org.eclipse.swt.widgets.Menu; >+import org.eclipse.swt.widgets.MenuItem; >+import org.eclipse.swt.widgets.Shell; >+import org.eclipse.ui.ISources; >+import org.eclipse.ui.internal.keys.WorkbenchKeyboard.MenuFlasher; >+ >+/** >+ * @since 4.0.1 >+ * >+ */ >+public class CarbonMenuFlasher extends MenuFlasher { >+ >+ private static Field handleField; >+ static { >+ try { >+ Field handleField = Menu.class.getDeclaredField("handle"); //$NON-NLS-1$ >+ handleField.setAccessible(true); >+ // only set it after we've successfully set the accessibility >+ CarbonMenuFlasher.handleField = handleField; >+ } catch (SecurityException e) { >+ throw new ExceptionInInitializerError("Could not change accessibility of required 'handle' field for CarbonMenuFlasher"); //$NON-NLS-1$ >+ } catch (NoSuchFieldException e) { >+ throw new ExceptionInInitializerError("Could not find required 'handle' field for CarbonMenuFlasher"); //$NON-NLS-1$ >+ } >+ } >+ >+ /* >+ * (non-Javadoc) >+ * >+ * @see >+ * org.eclipse.ui.internal.keys.WorkbenchKeyboard.MenuFlasher#flash(org. >+ * eclipse.core.expressions.IEvaluationContext, >+ * org.eclipse.jface.bindings.TriggerSequence) >+ */ >+ public void flash(IEvaluationContext currentState, >+ TriggerSequence triggerSequence) { >+ Shell currentShell = (Shell) currentState >+ .getVariable(ISources.ACTIVE_WORKBENCH_WINDOW_SHELL_NAME); >+ if (currentShell != null) { >+ Menu menuBar = currentShell.getMenuBar(); >+ flashItemWithTrigger(menuBar, triggerSequence); >+ } >+ } >+ >+ /** >+ * @param menuBar >+ * @param triggerSequence >+ */ >+ private boolean flashItemWithTrigger(Menu menuBar, >+ TriggerSequence triggerSequence) { >+ MenuItem[] items = menuBar.getItems(); >+ for (int i = 0; i < items.length; i++) { >+ MenuItem menuItem = items[i]; >+ String menuItemText = menuItem.getText(); >+ if (menuItemText.endsWith(triggerSequence.format())) { >+ try { >+ flash(menuItem); >+ } catch (IllegalArgumentException e) { >+ e.printStackTrace(); >+ } catch (IllegalAccessException e) { >+ e.printStackTrace(); >+ } >+ return true; >+ } >+ Menu childMenu = menuItem.getMenu(); >+ if (childMenu != null) { >+ boolean childResult = flashItemWithTrigger(childMenu, >+ triggerSequence); >+ if (childResult) >+ return true; >+ } >+ } >+ return false; >+ } >+ >+ /** >+ * Flash the provided menu item. >+ * @param menuItem the item to flash >+ * @throws IllegalAccessException thrown if the handle field of the Menu class could not be invoked. >+ * @throws IllegalArgumentException not thrown >+ */ >+ private void flash(MenuItem menuItem) throws IllegalArgumentException, >+ IllegalAccessException { >+ >+ Menu menu = menuItem.getParent(); >+ while (menu.getParentMenu() != null >+ && menu.getParentMenu().getParentMenu() != null) { >+ menu = menu.getParentMenu(); >+ } >+ >+ if (menu == null) >+ return; >+ >+ final short menuId = OS.GetMenuID(handleField.getInt(menu)); >+ OS.HiliteMenu(menuId); >+ try { >+ Thread.sleep(125); >+ } catch (InterruptedException e) { >+ } >+ OS.HiliteMenu((short) 0); >+ } >+}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 246165
: 113271