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 28240 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]
workbench patch
85608_workbench_patch.txt (text/plain), 13.73 KB, created by
Stefan Xenos
on 2005-10-13 12:50:30 EDT
(
hide
)
Description:
workbench patch
Filename:
MIME Type:
Creator:
Stefan Xenos
Created:
2005-10-13 12:50:30 EDT
Size:
13.73 KB
patch
obsolete
>Index: Eclipse UI/org/eclipse/ui/internal/IPreferenceConstants.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/IPreferenceConstants.java,v >retrieving revision 1.52 >diff -u -r1.52 IPreferenceConstants.java >--- Eclipse UI/org/eclipse/ui/internal/IPreferenceConstants.java 11 Oct 2005 20:55:18 -0000 1.52 >+++ Eclipse UI/org/eclipse/ui/internal/IPreferenceConstants.java 13 Oct 2005 16:49:30 -0000 >@@ -200,4 +200,11 @@ > * @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.2 >+ */ >+ public static final String NEVER_STEAL_FOCUS = "NEVER_STEAL_FOCUS"; //$NON-NLS-1$ > } >Index: Eclipse UI/org/eclipse/ui/internal/WorkbenchMessages.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/WorkbenchMessages.java,v >retrieving revision 1.42 >diff -u -r1.42 WorkbenchMessages.java >--- Eclipse UI/org/eclipse/ui/internal/WorkbenchMessages.java 10 Oct 2005 20:09:33 -0000 1.42 >+++ Eclipse UI/org/eclipse/ui/internal/WorkbenchMessages.java 13 Oct 2005 16:49:30 -0000 >@@ -902,4 +902,10 @@ > public static String FastViewBar_show_view; > > >+ public static String WorkbenchPreference_NeverStealFocus; >+ >+ >+ public static String WorkbenchPreference_NeverStealFocusTooltip; >+ >+ > } >\ No newline at end of file >Index: Eclipse UI/org/eclipse/ui/internal/WorkbenchPage.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/WorkbenchPage.java,v >retrieving revision 1.235 >diff -u -r1.235 WorkbenchPage.java >--- Eclipse UI/org/eclipse/ui/internal/WorkbenchPage.java 28 Sep 2005 12:55:36 -0000 1.235 >+++ Eclipse UI/org/eclipse/ui/internal/WorkbenchPage.java 13 Oct 2005 16:49:30 -0000 >@@ -102,6 +102,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; > >@@ -547,6 +548,22 @@ > 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); > >@@ -751,6 +768,22 @@ > 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)) { > label = part != null ? part.getTitle() : "none"; //$NON-NLS-1$ >@@ -927,6 +960,7 @@ > */ > private IViewPart busyShowView(String viewID, String secondaryID, int mode) > throws PartInitException { >+ > Perspective persp = getActivePerspective(); > if (persp == null) > return null; >@@ -962,6 +996,23 @@ > * Performs showing of the view in the given mode. > */ > private void busyShowView(IViewPart part, int mode) { >+ >+ // 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) { >@@ -2061,6 +2112,7 @@ > this.window = w; > this.input = input; > >+ InputMonitor.init(); > // Create presentation. > createClientComposite(); > editorPresentation = new EditorAreaHelper(this); >@@ -3214,6 +3266,11 @@ > return showView(viewID, null, VIEW_ACTIVATE); > } > >+ private boolean isGrabFocusDisabled() { >+ return WorkbenchPlugin.getDefault().getPreferenceStore().getBoolean( >+ IPreferenceConstants.NEVER_STEAL_FOCUS); >+ } >+ > /* > * (non-Javadoc) > * >@@ -3222,7 +3279,7 @@ > */ > public IViewPart showView(final String viewID, final String secondaryID, > final int mode) throws PartInitException { >- >+ > if (secondaryID != null) { > if (secondaryID.length() == 0 > || secondaryID.indexOf(ViewFactory.ID_SEP) != -1) >Index: Eclipse UI/org/eclipse/ui/internal/messages.properties >=================================================================== >RCS file: /home/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/messages.properties,v >retrieving revision 1.289 >diff -u -r1.289 messages.properties >--- Eclipse UI/org/eclipse/ui/internal/messages.properties 10 Oct 2005 20:09:33 -0000 1.289 >+++ Eclipse UI/org/eclipse/ui/internal/messages.properties 13 Oct 2005 16:49:31 -0000 >@@ -348,6 +348,8 @@ > WorkbenchPreference_stickyCycleButton = Keep &next/previous part dialog open > WorkbenchPreference_RunInBackgroundButton=Always r&un in background > WorkbenchPreference_RunInBackgroundToolTip=Run long operations in the background where possible >+WorkbenchPreference_NeverStealFocus=Never steal focus >+WorkbenchPreference_NeverStealFocusTooltip=Prevents views and editors from opening automatically > WorkbenchPreference_HeapStatusButton = Sho&w Heap Status > WorkbenchPreference_HeapStatusButtonToolTip = Show the Heap Status area on the bottom of the window > >Index: Eclipse UI/org/eclipse/ui/internal/dialogs/WorkbenchPreferencePage.java >=================================================================== >RCS file: /home/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 13 Oct 2005 16:49:31 -0000 >@@ -55,6 +55,8 @@ > > private Button showUserDialogButton; > >+ private Button neverStealFocusButton; >+ > private boolean openOnSingleClick; > > private boolean selectOnHover; >@@ -93,6 +95,7 @@ > */ > protected void createButtons(Composite composite) { > createShowUserDialogPref(composite); >+ createNoStealFocusPref(composite); > createStickyCyclePref(composite); > createHeapStatusPref(composite); > } >@@ -126,6 +129,20 @@ > } > > /** >+ * 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)); >+ } >+ >+ /** > * Creates the composite which will contain all the preference controls for > * this page. > * >@@ -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(); > } >@@ -356,6 +375,8 @@ > store.setValue(IPreferenceConstants.OPEN_AFTER_DELAY, openAfterDelay); > store.setValue(IPreferenceConstants.RUN_IN_BACKGROUND, > showUserDialogButton.getSelection()); >+ store.setValue(IPreferenceConstants.NEVER_STEAL_FOCUS, >+ neverStealFocusButton.getSelection()); > PrefUtil.getAPIPreferenceStore().setValue(IWorkbenchPreferenceConstants.SHOW_MEMORY_MONITOR, showHeapStatusButton.getSelection()); > updateHeapStatus(showHeapStatusButton.getSelection()); > >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,133 @@ >+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