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 59186 Details for
Bug 85608
[ViewMgmt] [EditorMgmt] Create option to disable views that open automatically
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]
Grab Focus v02
grabFocus-v02.txt (text/plain), 14.57 KB, created by
Paul Webster
on 2007-02-16 14:12:04 EST
(
hide
)
Description:
Grab Focus v02
Filename:
MIME Type:
Creator:
Paul Webster
Created:
2007-02-16 14:12:04 EST
Size:
14.57 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.ui.ide >Index: src/org/eclipse/ui/internal/ide/dialogs/IDEWorkbenchPreferencePage.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/dialogs/IDEWorkbenchPreferencePage.java,v >retrieving revision 1.29 >diff -u -r1.29 IDEWorkbenchPreferencePage.java >--- src/org/eclipse/ui/internal/ide/dialogs/IDEWorkbenchPreferencePage.java 4 Oct 2005 15:54:26 -0000 1.29 >+++ src/org/eclipse/ui/internal/ide/dialogs/IDEWorkbenchPreferencePage.java 16 Feb 2007 19:10:23 -0000 >@@ -41,6 +41,7 @@ > Composite composite = createComposite(parent); > > createShowUserDialogPref(composite); >+ createNoStealFocusPref(composite); > createStickyCyclePref(composite); > createHeapStatusPref(composite); > >#P org.eclipse.ui.workbench >Index: Eclipse UI/org/eclipse/ui/internal/IPreferenceConstants.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/IPreferenceConstants.java,v >retrieving revision 1.58 >diff -u -r1.58 IPreferenceConstants.java >--- Eclipse UI/org/eclipse/ui/internal/IPreferenceConstants.java 18 Dec 2006 22:41:37 -0000 1.58 >+++ Eclipse UI/org/eclipse/ui/internal/IPreferenceConstants.java 16 Feb 2007 19:10:24 -0000 >@@ -214,12 +214,19 @@ > * @since 3.0 > */ > public static final String SHOULD_PROMPT_FOR_ENABLEMENT = "shouldPromptForEnablement"; //$NON-NLS-1$ >+ >+ /** >+ * Prevents views and editors from moving to the foreground automatically. >+ * >+ * @since 3.3 >+ */ >+ public static final String NEVER_STEAL_FOCUS = "NEVER_STEAL_FOCUS"; //$NON-NLS-1$ > > /** >- * Experimental preference ID for automatic pinning editors on dirty. >- * >- * @since 3.3 >- */ >+ * Experimental preference ID for automatic pinning editors on dirty. >+ * >+ * @since 3.3 >+ */ > public static final String EDITOR_EXPERIMENTAL_TAB_BEHAVIOUR = "EDITOR_EXPERIMENTAL_TAB_BEHAVIOUR"; //$NON-NLS-1$ > > } >Index: Eclipse UI/org/eclipse/ui/internal/WorkbenchMessages.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/WorkbenchMessages.java,v >retrieving revision 1.80 >diff -u -r1.80 WorkbenchMessages.java >--- Eclipse UI/org/eclipse/ui/internal/WorkbenchMessages.java 25 Jan 2007 17:58:19 -0000 1.80 >+++ Eclipse UI/org/eclipse/ui/internal/WorkbenchMessages.java 16 Feb 2007 19:10:24 -0000 >@@ -988,6 +988,9 @@ > > > public static String FastViewBar_show_view; >+ public static String WorkbenchPreference_NeverStealFocus; >+ public static String WorkbenchPreference_NeverStealFocusTooltip; >+ > > // Content assist support > public static String ContentAssist_Cue_Description_Key; >Index: Eclipse UI/org/eclipse/ui/internal/messages.properties >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/messages.properties,v >retrieving revision 1.338 >diff -u -r1.338 messages.properties >--- Eclipse UI/org/eclipse/ui/internal/messages.properties 25 Jan 2007 17:58:19 -0000 1.338 >+++ Eclipse UI/org/eclipse/ui/internal/messages.properties 16 Feb 2007 19:10:24 -0000 >@@ -351,7 +351,9 @@ > WorkbenchPreference_RunInBackgroundToolTip=Run long operations in the background where possible > WorkbenchPreference_HeapStatusButton = Sho&w heap status > WorkbenchPreference_HeapStatusButtonToolTip = Show the heap status area on the bottom of the window >- >+WorkbenchPreference_NeverStealFocus=Never steal focus >+WorkbenchPreference_NeverStealFocusTooltip=Prevents views and editors from opening automatically >+ > > # --- Appearance --- > ViewsPreference_currentPresentation = Current &Presentation: >Index: Eclipse UI/org/eclipse/ui/internal/WorkbenchPage.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/WorkbenchPage.java,v >retrieving revision 1.280 >diff -u -r1.280 WorkbenchPage.java >--- Eclipse UI/org/eclipse/ui/internal/WorkbenchPage.java 1 Feb 2007 15:43:15 -0000 1.280 >+++ Eclipse UI/org/eclipse/ui/internal/WorkbenchPage.java 16 Feb 2007 19:10:24 -0000 >@@ -107,6 +107,7 @@ > import org.eclipse.ui.model.IWorkbenchAdapter; > import org.eclipse.ui.part.MultiEditor; > import org.eclipse.ui.presentations.IStackPresentationSite; >+import org.eclipse.ui.progress.IWorkbenchSiteProgressService; > import org.eclipse.ui.views.IStickyViewDescriptor; > import org.eclipse.ui.views.IViewRegistry; > >@@ -574,6 +575,21 @@ > if (window.isClosing()) { > return; > } >+ // There is a preference to prevent background threads from activating views or bringing >+ // them to the top. If the user has set this preference, just bold the tab whenever >+ // a background thread tries to use VIEW_VISIBLE or VIEW_ACTIVATE >+ >+ if (composite != null && composite.isVisible() && isGrabFocusDisabled() && !InputMonitor.isProcessingUserInput()) { >+ IWorkbenchSiteProgressService progressService = (IWorkbenchSiteProgressService)part.getSite().getAdapter(IWorkbenchSiteProgressService.class); >+ >+ // Bold the tab if possible >+ if (progressService != null) { >+ progressService.warnOfContentChange(); >+ } >+ >+ // And exit to ensure we don't mess with activation or layout >+ return; >+ } > > // If zoomed, unzoom. > zoomOutIfNecessary(part); >@@ -780,6 +796,21 @@ > if (persp == null || !certifyPart(part)) { > return; > } >+ // There is a preference to prevent background threads from activating views or bringing >+ // them to the top. If the user has set this preference, just bold the tab whenever >+ // a background thread tries to use VIEW_VISIBLE or VIEW_ACTIVATE >+ >+ if (isGrabFocusDisabled() && !InputMonitor.isProcessingUserInput()) { >+ IWorkbenchSiteProgressService progressService = (IWorkbenchSiteProgressService)part.getSite().getAdapter(IWorkbenchSiteProgressService.class); >+ >+ // Bold the tab if possible >+ if (progressService != null) { >+ progressService.warnOfContentChange(); >+ } >+ >+ // And exit to ensure we don't mess with activation or layout >+ return; >+ } > > String label = null; // debugging only > if (UIStats.isDebugging(UIStats.BRING_PART_TO_TOP)) { >@@ -1004,7 +1035,24 @@ > * Performs showing of the view in the given mode. > */ > private void busyShowView(IViewPart part, int mode) { >- if (mode == VIEW_ACTIVATE) { >+ >+ // There is a preference to prevent background threads from activating views or bringing >+ // them to the top. If the user has set this preference, just bold the tab whenever >+ // a background thread tries to use VIEW_VISIBLE or VIEW_ACTIVATE >+ >+ if (isGrabFocusDisabled() && mode != VIEW_CREATE && !InputMonitor.isProcessingUserInput()) { >+ IWorkbenchSiteProgressService progressService = (IWorkbenchSiteProgressService)part.getSite().getAdapter(IWorkbenchSiteProgressService.class); >+ >+ // Bold the tab if possible >+ if (progressService != null) { >+ progressService.warnOfContentChange(); >+ } >+ >+ // And exit to ensure we don't mess with activation or layout >+ return; >+ } >+ >+ if (mode == VIEW_ACTIVATE) { > activate(part); > } else if (mode == VIEW_VISIBLE) { > IWorkbenchPartReference ref = getActivePartReference(); >@@ -2224,6 +2272,8 @@ > // Save args. > this.window = w; > this.input = input; >+ >+ InputMonitor.init(); > > // Create presentation. > createClientComposite(); >@@ -3538,6 +3588,11 @@ > return showView(viewID, null, VIEW_ACTIVATE); > } > >+ private boolean isGrabFocusDisabled() { >+ return WorkbenchPlugin.getDefault().getPreferenceStore().getBoolean( >+ IPreferenceConstants.NEVER_STEAL_FOCUS); >+ } >+ > /* > * (non-Javadoc) > * >Index: Eclipse UI/org/eclipse/ui/internal/dialogs/WorkbenchPreferencePage.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/dialogs/WorkbenchPreferencePage.java,v >retrieving revision 1.43 >diff -u -r1.43 WorkbenchPreferencePage.java >--- Eclipse UI/org/eclipse/ui/internal/dialogs/WorkbenchPreferencePage.java 4 Oct 2005 15:54:28 -0000 1.43 >+++ Eclipse UI/org/eclipse/ui/internal/dialogs/WorkbenchPreferencePage.java 16 Feb 2007 19:10:24 -0000 >@@ -54,6 +54,8 @@ > private Button openAfterDelayButton; > > private Button showUserDialogButton; >+ >+ private Button neverStealFocusButton; > > private boolean openOnSingleClick; > >@@ -93,6 +95,7 @@ > */ > protected void createButtons(Composite composite) { > createShowUserDialogPref(composite); >+ createNoStealFocusPref(composite); > createStickyCyclePref(composite); > createHeapStatusPref(composite); > } >@@ -110,7 +113,21 @@ > .getPreferenceStore().getBoolean( > IPreferenceConstants.RUN_IN_BACKGROUND)); > } >- >+ >+ /** >+ * Create the widget for the user dialog preference. >+ * >+ * @param composite >+ */ >+ protected void createNoStealFocusPref(Composite composite) { >+ neverStealFocusButton = new Button(composite, SWT.CHECK); >+ neverStealFocusButton.setText(WorkbenchMessages.WorkbenchPreference_NeverStealFocus); >+ neverStealFocusButton.setToolTipText(WorkbenchMessages.WorkbenchPreference_NeverStealFocusTooltip); >+ neverStealFocusButton.setSelection(WorkbenchPlugin.getDefault() >+ .getPreferenceStore().getBoolean( >+ IPreferenceConstants.NEVER_STEAL_FOCUS)); >+ } >+ > /** > * Create the widget for the heap status preference. > * >@@ -337,6 +354,8 @@ > IPreferenceConstants.RUN_IN_BACKGROUND)); > showHeapStatusButton.setSelection(PrefUtil.getAPIPreferenceStore().getDefaultBoolean( > IWorkbenchPreferenceConstants.SHOW_MEMORY_MONITOR)); >+ neverStealFocusButton.setSelection(store.getDefaultBoolean( >+ IPreferenceConstants.NEVER_STEAL_FOCUS)); > > super.performDefaults(); > } >@@ -358,6 +377,8 @@ > showUserDialogButton.getSelection()); > PrefUtil.getAPIPreferenceStore().setValue(IWorkbenchPreferenceConstants.SHOW_MEMORY_MONITOR, showHeapStatusButton.getSelection()); > updateHeapStatus(showHeapStatusButton.getSelection()); >+ store.setValue(IPreferenceConstants.NEVER_STEAL_FOCUS, >+ neverStealFocusButton.getSelection()); > > int singleClickMethod = openOnSingleClick ? OpenStrategy.SINGLE_CLICK > : OpenStrategy.DOUBLE_CLICK; >Index: Eclipse UI/org/eclipse/ui/internal/InputMonitor.java >=================================================================== >RCS file: Eclipse UI/org/eclipse/ui/internal/InputMonitor.java >diff -N Eclipse UI/org/eclipse/ui/internal/InputMonitor.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ Eclipse UI/org/eclipse/ui/internal/InputMonitor.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,144 @@ >+/******************************************************************************* >+ * 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.swt.SWT; >+import org.eclipse.swt.widgets.Display; >+import org.eclipse.swt.widgets.Event; >+import org.eclipse.swt.widgets.Listener; >+ >+/** >+ * This class monitors an SWT display and attempts to determine if the display >+ * is currently reacting to user input. This can be used to disable certain >+ * APIs (for example, APIs that steal focus or change the workbench layout) >+ * when they are called from an *syncExec. >+ * >+ * @since 3.2 >+ */ >+public class InputMonitor { >+ private Display display; >+ >+ private int[] eventIds = { >+ SWT.KeyDown, >+ SWT.KeyUp, >+ SWT.MouseDown, >+ SWT.MouseUp, >+ SWT.MouseDoubleClick, >+ SWT.Selection, >+ SWT.MenuDetect, >+ SWT.DragDetect >+ }; >+ >+ private boolean enabled = false; >+ private boolean filterAdded = false; >+ >+ private Listener listener = new Listener() { >+ public void handleEvent(Event event) { >+ enableInput(); >+ } >+ }; >+ >+ private Runnable disabler = new Runnable() { >+ public void run() { >+ enabled = false; >+ addFilter(); >+ } >+ }; >+ >+ /** >+ * Returns true iff the Display for the current thread is currently >+ * processing a user input event. Must be called in the UI thread. >+ * >+ * @return true iff the Display for the current thread is currently >+ * processing a user input event. >+ */ >+ public static boolean isProcessingUserInput() { >+ return getMonitor(Display.getCurrent()).checkIsProcessingUserInput(); >+ } >+ >+ /** >+ * Ensures that the input monitor for the current thread is initialized. >+ * Multiple calls to this method in the same thread are ignored. >+ */ >+ public static void init() { >+ getMonitor(Display.getCurrent()); >+ } >+ >+ /** >+ * Returns a InputMonitor for the given display. Sucessive calls >+ * will return the same object instance. >+ * >+ * @param d >+ * @return >+ */ >+ public static InputMonitor getMonitor(Display d) { >+ String key = InputMonitor.class.getName(); >+ Object mon = d.getData(key); >+ >+ if (mon != null && mon instanceof InputMonitor) { >+ return (InputMonitor) mon; >+ } >+ >+ InputMonitor newMonitor = new InputMonitor(d); >+ >+ d.setData(key, newMonitor); >+ >+ return newMonitor; >+ } >+ >+ public InputMonitor(Display d) { >+ this.display = d; >+ >+ addFilter(); >+ } >+ >+ private void addFilter() { >+ if (filterAdded) { >+ return; >+ } >+ filterAdded = true; >+ >+ for (int i = 0; i < eventIds.length; i++) { >+ int id = eventIds[i]; >+ >+ display.addFilter(id, listener ); >+ } >+ } >+ >+ public boolean checkIsProcessingUserInput() { >+ return enabled; >+ } >+ >+ public void dispose() { >+ removeFilter(); >+ } >+ >+ private void removeFilter() { >+ if (!filterAdded) { >+ return; >+ } >+ filterAdded = false; >+ >+ for (int i = 0; i < eventIds.length; i++) { >+ int id = eventIds[i]; >+ >+ display.removeFilter(id, listener); >+ } >+ } >+ >+ protected void enableInput() { >+ if (enabled) return; >+ enabled = true; >+ removeFilter(); >+ display.asyncExec(disabler); >+ } >+}
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 85608
:
28240
|
28241
|
59186
|
61721
|
61929