Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimeon Andreev2018-10-18 09:20:34 -0400
committerSimeon Andreev2018-10-26 11:23:38 -0400
commit29df3a9b90396e3f2a2dc11dfc9ca5ec129e099d (patch)
treea09df6782879e9fae396739e486bf69b241cfa5f /org.eclipse.debug.ui/ui
parent32924160077894cb14dc55ebbc8eb2b0c0156ae6 (diff)
downloadeclipse.platform.debug-29df3a9b90396e3f2a2dc11dfc9ca5ec129e099d.tar.gz
eclipse.platform.debug-29df3a9b90396e3f2a2dc11dfc9ca5ec129e099d.tar.xz
eclipse.platform.debug-29df3a9b90396e3f2a2dc11dfc9ca5ec129e099d.zip
Bug 540253 - Debug inactive after switching perspectivesI20181027-1800I20181026-1800
The fix for bug 538548 introduces a regression as follows. Switch from Java to Debug perspective, then back to Java perspective. Debug a snippet until a breakpoint is hit. Choose yes when asked whether to switch to the Debug perspective. Observe that debug controls are inactive. This is the case since LaunchView context provider no longer reacts to debug events, after switching to the Java perspective. It misses the breakpoint hit (which also triggers the Debug perspective switch-to confirmation dialog). This change removes the fix for bug 538548 and adds a local fix to SourceLookupService. The added fix prevents an editor popping up in the current perspective under the following conditions: 1. If the Debug View was not open in the current perspective. 2. Preferences to switch to a debug perspective on a breakpoint hit or on launch are set to "never". 3. Preference to activate the Debug View on a breakpoint hit is set to "disabled". Change-Id: Iab575ee2f9a292c23c47c95d23afadc49b8b2dff Signed-off-by: Simeon Andreev <simeon.danailov.andreev@gmail.com> Signed-off-by: Andrey Loskutov <loskutov@gmx.de>
Diffstat (limited to 'org.eclipse.debug.ui/ui')
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/SourceLookupService.java50
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/launch/LaunchView.java4
2 files changed, 46 insertions, 8 deletions
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/SourceLookupService.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/SourceLookupService.java
index 5337c5ff5..e5dcf37d0 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/SourceLookupService.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/SourceLookupService.java
@@ -16,12 +16,17 @@ package org.eclipse.debug.internal.ui.sourcelookup;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.PlatformObject;
+import org.eclipse.debug.internal.ui.DebugUIPlugin;
+import org.eclipse.debug.internal.ui.IInternalDebugUIConstants;
import org.eclipse.debug.internal.ui.views.launch.DebugElementAdapterFactory;
import org.eclipse.debug.ui.DebugUITools;
+import org.eclipse.debug.ui.IDebugUIConstants;
import org.eclipse.debug.ui.contexts.DebugContextEvent;
import org.eclipse.debug.ui.contexts.IDebugContextListener;
import org.eclipse.debug.ui.contexts.IDebugContextService;
import org.eclipse.debug.ui.sourcelookup.ISourceDisplay;
+import org.eclipse.jface.dialogs.MessageDialogWithToggle;
+import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.ui.IWorkbenchPage;
@@ -52,8 +57,44 @@ public class SourceLookupService implements IDebugContextListener, ISourceDispla
@Override
public synchronized void debugContextChanged(DebugContextEvent event) {
if ((event.getFlags() & DebugContextEvent.ACTIVATED) > 0) {
- displaySource(event.getContext(), event.getDebugContextProvider().getPart(), false);
+ if (isDebugViewActive() || canActivateDebugView()) {
+ displaySource(event.getContext(), event.getDebugContextProvider().getPart(), false);
+ }
+ }
+ }
+
+ private boolean isDebugViewActive() {
+ if (isDisposed()) {
+ return false;
+ }
+ IWorkbenchPage activePage = fWindow.getActivePage();
+ if (activePage != null) {
+ return activePage.findView(IDebugUIConstants.ID_DEBUG_VIEW) != null;
+ }
+ return false;
+ }
+
+ private boolean canActivateDebugView() {
+ if (isDisposed()) {
+ return false;
+ }
+ IPreferenceStore preferenceStore = DebugUIPlugin.getDefault().getPreferenceStore();
+ String[] switchPreferences = {
+ IInternalDebugUIConstants.PREF_SWITCH_TO_PERSPECTIVE,
+ IInternalDebugUIConstants.PREF_SWITCH_PERSPECTIVE_ON_SUSPEND,
+ };
+ for (String switchPreference : switchPreferences) {
+ String preferenceValue = preferenceStore.getString(switchPreference);
+ if (!MessageDialogWithToggle.NEVER.equals(preferenceValue)) {
+ return true;
+ }
}
+ boolean canActivateDebugView = preferenceStore.getBoolean(IInternalDebugUIConstants.PREF_ACTIVATE_DEBUG_VIEW);
+ return canActivateDebugView;
+ }
+
+ private boolean isDisposed() {
+ return fWindow == null;
}
/**
@@ -65,7 +106,9 @@ public class SourceLookupService implements IDebugContextListener, ISourceDispla
* @param force
*/
protected synchronized void displaySource(ISelection selection, IWorkbenchPart part, boolean force) {
- if (fWindow == null) return; // disposed
+ if (isDisposed()) {
+ return;
+ }
if (selection instanceof IStructuredSelection) {
IStructuredSelection structuredSelection = (IStructuredSelection)selection;
@@ -82,9 +125,6 @@ public class SourceLookupService implements IDebugContextListener, ISourceDispla
}
}
- /* (non-Javadoc)
- * @see org.eclipse.debug.internal.ui.contexts.ISourceDisplayAdapter#displaySource(java.lang.Object, org.eclipse.ui.IWorkbenchPage, boolean)
- */
@Override
public void displaySource(Object context, IWorkbenchPage page, boolean forceSourceLookup) {
if (context instanceof IAdaptable) {
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/launch/LaunchView.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/launch/LaunchView.java
index df5fe6ded..9ba292322 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/launch/LaunchView.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/launch/LaunchView.java
@@ -474,9 +474,7 @@ public class LaunchView extends AbstractDebugView
private ISelectionChangedListener fTreeViewerSelectionChangedListener = new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
- if (isActive()) {
- fTreeViewerDebugContextProvider.activate(event.getSelection());
- }
+ fTreeViewerDebugContextProvider.activate(event.getSelection());
}
};

Back to the top