mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-30 21:55:31 +02:00
Bug 398913 - 'Connect' button remains disabled after being used
Change-Id: I301e897b5c4c76e3edbcd6f517c15793e4323d04 Reviewed-on: https://git.eclipse.org/r/10345 Reviewed-by: Mikhail Khodjaiants <mikhailkhod@googlemail.com> IP-Clean: Mikhail Khodjaiants <mikhailkhod@googlemail.com> Tested-by: Mikhail Khodjaiants <mikhailkhod@googlemail.com>
This commit is contained in:
parent
18ff30de24
commit
895e0aa394
3 changed files with 76 additions and 7 deletions
|
@ -40,8 +40,8 @@ import org.eclipse.cdt.dsf.gdb.IGDBLaunchConfigurationConstants;
|
|||
import org.eclipse.cdt.dsf.gdb.actions.IConnect;
|
||||
import org.eclipse.cdt.dsf.gdb.internal.ui.GdbUIPlugin;
|
||||
import org.eclipse.cdt.dsf.gdb.internal.ui.actions.ProcessInfo;
|
||||
import org.eclipse.cdt.dsf.gdb.internal.ui.launching.NewExecutableInfo;
|
||||
import org.eclipse.cdt.dsf.gdb.internal.ui.launching.LaunchUIMessages;
|
||||
import org.eclipse.cdt.dsf.gdb.internal.ui.launching.NewExecutableInfo;
|
||||
import org.eclipse.cdt.dsf.gdb.internal.ui.launching.ProcessPrompter;
|
||||
import org.eclipse.cdt.dsf.gdb.internal.ui.launching.ProcessPrompter.PrompterInfo;
|
||||
import org.eclipse.cdt.dsf.gdb.launching.GdbLaunch;
|
||||
|
@ -61,7 +61,6 @@ import org.eclipse.core.runtime.IStatus;
|
|||
import org.eclipse.core.runtime.Path;
|
||||
import org.eclipse.core.runtime.Status;
|
||||
import org.eclipse.debug.core.IRequest;
|
||||
import org.eclipse.debug.core.commands.AbstractDebugCommand;
|
||||
import org.eclipse.debug.core.commands.IDebugCommandRequest;
|
||||
import org.eclipse.debug.core.commands.IEnabledStateRequest;
|
||||
import org.eclipse.swt.SWT;
|
||||
|
@ -70,7 +69,7 @@ import org.eclipse.swt.widgets.FileDialog;
|
|||
import org.eclipse.swt.widgets.Shell;
|
||||
import org.eclipse.ui.progress.UIJob;
|
||||
|
||||
public class GdbConnectCommand extends AbstractDebugCommand implements IConnectHandler, IConnect {
|
||||
public class GdbConnectCommand extends RefreshableDebugCommand implements IConnectHandler, IConnect {
|
||||
|
||||
private final GdbLaunch fLaunch;
|
||||
private final DsfExecutor fExecutor;
|
||||
|
@ -279,7 +278,9 @@ public class GdbConnectCommand extends AbstractDebugCommand implements IConnectH
|
|||
// cancelled it.
|
||||
} catch (RejectedExecutionException e) {
|
||||
// Can be thrown if the session is shutdown
|
||||
}
|
||||
} finally {
|
||||
updateEnablement();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -29,8 +29,8 @@ import org.eclipse.cdt.dsf.debug.service.IProcesses;
|
|||
import org.eclipse.cdt.dsf.debug.service.command.ICommandControlService;
|
||||
import org.eclipse.cdt.dsf.gdb.IGDBLaunchConfigurationConstants;
|
||||
import org.eclipse.cdt.dsf.gdb.internal.ui.GdbUIPlugin;
|
||||
import org.eclipse.cdt.dsf.gdb.internal.ui.launching.NewExecutableInfo;
|
||||
import org.eclipse.cdt.dsf.gdb.internal.ui.launching.NewExecutableDialog;
|
||||
import org.eclipse.cdt.dsf.gdb.internal.ui.launching.NewExecutableInfo;
|
||||
import org.eclipse.cdt.dsf.gdb.launching.GdbLaunch;
|
||||
import org.eclipse.cdt.dsf.gdb.service.IGDBBackend;
|
||||
import org.eclipse.cdt.dsf.gdb.service.SessionType;
|
||||
|
@ -43,12 +43,11 @@ import org.eclipse.core.runtime.IStatus;
|
|||
import org.eclipse.core.runtime.Status;
|
||||
import org.eclipse.debug.core.ILaunchConfiguration;
|
||||
import org.eclipse.debug.core.IRequest;
|
||||
import org.eclipse.debug.core.commands.AbstractDebugCommand;
|
||||
import org.eclipse.debug.core.commands.IEnabledStateRequest;
|
||||
import org.eclipse.jface.window.Window;
|
||||
import org.eclipse.ui.progress.UIJob;
|
||||
|
||||
public class GdbDebugNewExecutableCommand extends AbstractDebugCommand implements IDebugNewExecutableHandler {
|
||||
public class GdbDebugNewExecutableCommand extends RefreshableDebugCommand implements IDebugNewExecutableHandler {
|
||||
|
||||
private class PromptJob extends UIJob {
|
||||
|
||||
|
@ -188,6 +187,8 @@ public class GdbDebugNewExecutableCommand extends AbstractDebugCommand implement
|
|||
}
|
||||
catch( RejectedExecutionException e ) {
|
||||
// Can be thrown if the session is shutdown
|
||||
} finally {
|
||||
updateEnablement();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,67 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2013 Mentor Graphics 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:
|
||||
* Mentor Graphics - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.cdt.dsf.gdb.internal.ui.commands;
|
||||
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.IStatus;
|
||||
import org.eclipse.core.runtime.Status;
|
||||
import org.eclipse.debug.core.commands.AbstractDebugCommand;
|
||||
import org.eclipse.debug.ui.IDebugUIConstants;
|
||||
import org.eclipse.jface.viewers.ISelectionProvider;
|
||||
import org.eclipse.ui.IViewPart;
|
||||
import org.eclipse.ui.IWorkbenchPage;
|
||||
import org.eclipse.ui.IWorkbenchPartSite;
|
||||
import org.eclipse.ui.IWorkbenchWindow;
|
||||
import org.eclipse.ui.PlatformUI;
|
||||
import org.eclipse.ui.progress.UIJob;
|
||||
|
||||
/**
|
||||
* The enablement of a {@link AbstractDebugCommand} is updated only when the current
|
||||
* debug context is changed. In some cases we need to force an update without changing
|
||||
* the context. This class provides such a functionality.
|
||||
* The proper way is to modify {@link AbstractDebugCommand}.
|
||||
*/
|
||||
public abstract class RefreshableDebugCommand extends AbstractDebugCommand {
|
||||
|
||||
protected class UpdateEnablementJob extends UIJob {
|
||||
|
||||
protected UpdateEnablementJob() {
|
||||
super("Update enablement job"); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
@Override
|
||||
public IStatus runInUIThread(IProgressMonitor monitor) {
|
||||
// Reseting the current selection in the Debug view will force the enablement update
|
||||
IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
|
||||
if (window != null) {
|
||||
IWorkbenchPage page = window.getActivePage();
|
||||
if (page != null) {
|
||||
IViewPart view = page.findView(IDebugUIConstants.ID_DEBUG_VIEW);
|
||||
if (view != null) {
|
||||
IWorkbenchPartSite site = view.getSite();
|
||||
if (site != null) {
|
||||
ISelectionProvider selProvider = site.getSelectionProvider();
|
||||
if (selProvider != null) {
|
||||
selProvider.setSelection(selProvider.getSelection());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return Status.OK_STATUS;
|
||||
}
|
||||
}
|
||||
|
||||
protected void updateEnablement() {
|
||||
new UpdateEnablementJob().schedule();
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue