Skip to main content
aboutsummaryrefslogtreecommitdiffstats
path: root/debug
diff options
context:
space:
mode:
Diffstat (limited to 'debug')
-rw-r--r--debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/CDebugCorePlugin.java13
-rw-r--r--debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/launch/CoreBuildLaunchBarTracker.java106
-rw-r--r--debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/launch/GenericTargetTypeProvider.java9
-rw-r--r--debug/org.eclipse.cdt.debug.ui/plugin.xml6
-rw-r--r--debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/launch/GenericTargetPropertiesBlock.java51
-rw-r--r--debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/launch/NewGenericTargetWizard.java36
-rw-r--r--debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/launch/NewGenericTargetWizardPage.java61
7 files changed, 161 insertions, 121 deletions
diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/CDebugCorePlugin.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/CDebugCorePlugin.java
index 78fd598077d..68ca1677e20 100644
--- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/CDebugCorePlugin.java
+++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/CDebugCorePlugin.java
@@ -17,6 +17,7 @@ import java.util.HashSet;
import org.eclipse.cdt.debug.core.breakpointactions.BreakpointActionManager;
import org.eclipse.cdt.debug.core.command.CCommandAdapterFactory;
import org.eclipse.cdt.debug.core.disassembly.IDisassemblyContextService;
+import org.eclipse.cdt.debug.core.launch.CoreBuildLaunchBarTracker;
import org.eclipse.cdt.debug.core.model.ICDebugElement;
import org.eclipse.cdt.debug.core.model.IRestart;
import org.eclipse.cdt.debug.core.sourcelookup.AbsolutePathSourceContainer;
@@ -45,6 +46,7 @@ import org.eclipse.debug.core.ILaunchConfigurationType;
import org.eclipse.debug.core.ILaunchDelegate;
import org.eclipse.debug.core.ILaunchManager;
import org.eclipse.debug.core.sourcelookup.ISourceContainer;
+import org.eclipse.launchbar.core.ILaunchBarManager;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceReference;
@@ -94,6 +96,8 @@ public class CDebugCorePlugin extends Plugin {
*/
private CommonSourceLookupDirector fCommonSourceLookupDirector;
+ private CoreBuildLaunchBarTracker coreBuildLaunchBarTracker;
+
/**
* The constructor.
*/
@@ -227,6 +231,11 @@ public class CDebugCorePlugin extends Plugin {
setDefaultLaunchDelegates();
Platform.getAdapterManager().registerAdapters(new DebugModelProvider(), ICDebugElement.class);
+
+ // Add core build launch bar listener
+ ILaunchBarManager launchBarManager = getService(ILaunchBarManager.class);
+ coreBuildLaunchBarTracker = new CoreBuildLaunchBarTracker();
+ launchBarManager.addListener(coreBuildLaunchBarTracker);
}
/* (non-Javadoc)
@@ -234,6 +243,10 @@ public class CDebugCorePlugin extends Plugin {
*/
@Override
public void stop(BundleContext context) throws Exception {
+ ILaunchBarManager launchBarManager = getService(ILaunchBarManager.class);
+ launchBarManager.removeListener(coreBuildLaunchBarTracker);
+ coreBuildLaunchBarTracker = null;
+
disposeDisassemblyContextService();
disposeBreakpointListenersList();
disposeCommonSourceLookupDirector();
diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/launch/CoreBuildLaunchBarTracker.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/launch/CoreBuildLaunchBarTracker.java
index c59735f9ee2..b79da79032d 100644
--- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/launch/CoreBuildLaunchBarTracker.java
+++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/launch/CoreBuildLaunchBarTracker.java
@@ -23,7 +23,9 @@ import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.ILaunchMode;
import org.eclipse.launchbar.core.ILaunchBarListener;
@@ -32,9 +34,8 @@ import org.eclipse.launchbar.core.ILaunchDescriptor;
import org.eclipse.launchbar.core.target.ILaunchTarget;
/**
- * A launchbar listener that attempts to set the active build configuration on
- * the project adapted from the launch descriptor that supports the given
- * target.
+ * A launchbar listener that attempts to set the active core build configuration
+ * on the project adapted from the launch descriptor.
*
* @since 8.3
*/
@@ -45,22 +46,20 @@ public class CoreBuildLaunchBarTracker implements ILaunchBarListener {
.getService(ICBuildConfigurationManager.class);
private final IToolChainManager toolChainManager = CDebugCorePlugin.getService(IToolChainManager.class);
- private final String targetTypeId;
+ private ILaunchMode lastMode;
+ private ILaunchDescriptor lastDescriptor;
+ private ILaunchTarget lastTarget;
- public CoreBuildLaunchBarTracker(String targetTypeId) {
- this.targetTypeId = targetTypeId;
- }
-
- private void setActiveBuildConfig(String mode, ILaunchDescriptor descriptor, ILaunchTarget target)
+ private void setActiveBuildConfig(ILaunchMode mode, ILaunchDescriptor descriptor, ILaunchTarget target)
throws CoreException {
- if (!targetTypeId.equals(target.getTypeId())) {
- return;
- }
-
IProject project = descriptor.getAdapter(IProject.class);
if (project == null) {
// Can we get the project name from the config
ILaunchConfiguration configuration = launchBarManager.getLaunchConfiguration(descriptor, target);
+ if (configuration == null) {
+ // TODO why is the configuration null?
+ return;
+ }
String projectName = configuration.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME, ""); //$NON-NLS-1$
if (!projectName.isEmpty()) {
project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
@@ -79,43 +78,63 @@ public class CoreBuildLaunchBarTracker implements ILaunchBarListener {
return;
}
+ IProject finalProject = project;
+
+ lastMode = mode;
+ lastDescriptor = descriptor;
+ lastTarget = target;
+
// Pick build config based on toolchain for target
- Map<String, String> properties = new HashMap<>();
- properties.putAll(target.getAttributes());
- Collection<IToolChain> tcs = toolChainManager.getToolChainsMatching(properties);
- if (!tcs.isEmpty()) {
- IToolChain toolChain = tcs.iterator().next();
- IProgressMonitor monitor = new NullProgressMonitor();
- ICBuildConfiguration buildConfig = configManager.getBuildConfiguration(project, toolChain, mode,
- new NullProgressMonitor());
- if (buildConfig != null) {
- IProjectDescription desc = project.getDescription();
- desc.setActiveBuildConfig(buildConfig.getBuildConfiguration().getName());
- project.setDescription(desc, monitor);
-
- // Copy over the build attributes from the launch config
- ILaunchConfiguration configuration = launchBarManager.getLaunchConfiguration(descriptor, target);
- Map<String, String> buildProps = configuration.getAttribute(
- CoreBuildLaunchConfigDelegate.getBuildAttributeName(mode),
- buildConfig.getDefaultProperties());
- buildConfig.setProperties(buildProps);
+ // Since this may create a new config, need to run it in a Job
+ Job job = new Job("Change Build Configurations") {
+ @Override
+ protected IStatus run(IProgressMonitor monitor) {
+ try {
+ Map<String, String> properties = new HashMap<>();
+ properties.putAll(target.getAttributes());
+ Collection<IToolChain> tcs = toolChainManager.getToolChainsMatching(properties);
+ if (!tcs.isEmpty()) {
+ IToolChain toolChain = tcs.iterator().next();
+ ICBuildConfiguration buildConfig = configManager.getBuildConfiguration(finalProject, toolChain,
+ mode.getIdentifier(), monitor);
+ if (buildConfig != null
+ && !buildConfig.getBuildConfiguration().equals(finalProject.getActiveBuildConfig())) {
+ IProjectDescription desc = finalProject.getDescription();
+ desc.setActiveBuildConfig(buildConfig.getBuildConfiguration().getName());
+ finalProject.setDescription(desc, monitor);
+
+ // Copy over the build attributes from the launch config
+ ILaunchConfiguration configuration = launchBarManager.getLaunchConfiguration(descriptor,
+ target);
+ Map<String, String> buildProps = configuration.getAttribute(
+ CoreBuildLaunchConfigDelegate.getBuildAttributeName(mode.getIdentifier()),
+ buildConfig.getDefaultProperties());
+ buildConfig.setProperties(buildProps);
+ }
+ }
+
+ return Status.OK_STATUS;
+ } catch (CoreException e) {
+ return e.getStatus();
+ }
}
- }
+ };
+ job.setRule(project.getWorkspace().getRoot());
+ job.schedule();
}
@Override
public void activeLaunchTargetChanged(ILaunchTarget target) {
try {
- if (target == null || target.equals(ILaunchTarget.NULL_TARGET)) {
+ if (target == null || target.equals(ILaunchTarget.NULL_TARGET) || target.equals(lastTarget)) {
return;
}
- ILaunchMode launchMode = launchBarManager.getActiveLaunchMode();
- if (launchMode == null) {
+ ILaunchMode mode = launchBarManager.getActiveLaunchMode();
+ if (mode == null) {
return;
}
- String mode = launchMode.getIdentifier();
ILaunchDescriptor descriptor = launchBarManager.getActiveLaunchDescriptor();
setActiveBuildConfig(mode, descriptor, target);
} catch (CoreException e) {
@@ -126,16 +145,15 @@ public class CoreBuildLaunchBarTracker implements ILaunchBarListener {
@Override
public void activeLaunchDescriptorChanged(ILaunchDescriptor descriptor) {
try {
- if (descriptor == null) {
+ if (descriptor == null || descriptor.equals(lastDescriptor)) {
return;
}
- ILaunchMode launchMode = launchBarManager.getActiveLaunchMode();
- if (launchMode == null) {
+ ILaunchMode mode = launchBarManager.getActiveLaunchMode();
+ if (mode == null) {
return;
}
- String mode = launchMode.getIdentifier();
ILaunchTarget target = launchBarManager.getActiveLaunchTarget();
setActiveBuildConfig(mode, descriptor, target);
} catch (CoreException e) {
@@ -147,13 +165,13 @@ public class CoreBuildLaunchBarTracker implements ILaunchBarListener {
@Override
public void activeLaunchModeChanged(ILaunchMode mode) {
try {
- if (mode == null) {
+ if (mode == null || mode.equals(lastMode)) {
return;
}
ILaunchDescriptor descriptor = launchBarManager.getActiveLaunchDescriptor();
ILaunchTarget target = launchBarManager.getActiveLaunchTarget();
- setActiveBuildConfig(mode.getIdentifier(), descriptor, target);
+ setActiveBuildConfig(mode, descriptor, target);
} catch (CoreException e) {
CDebugCorePlugin.log(e.getStatus());
}
diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/launch/GenericTargetTypeProvider.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/launch/GenericTargetTypeProvider.java
index 7426f213980..72e96535238 100644
--- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/launch/GenericTargetTypeProvider.java
+++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/launch/GenericTargetTypeProvider.java
@@ -7,21 +7,22 @@
*******************************************************************************/
package org.eclipse.cdt.debug.core.launch;
-import org.eclipse.cdt.debug.core.CDebugCorePlugin;
-import org.eclipse.launchbar.core.ILaunchBarManager;
import org.eclipse.launchbar.core.target.ILaunchTarget;
import org.eclipse.launchbar.core.target.ILaunchTargetManager;
import org.eclipse.launchbar.core.target.ILaunchTargetProvider;
import org.eclipse.launchbar.core.target.TargetStatus;
+/**
+ *
+ * @since 8.3
+ */
public class GenericTargetTypeProvider implements ILaunchTargetProvider {
public static final String TYPE_ID = "org.eclipse.cdt.launchTargetType.generic"; //$NON-NLS-1$
@Override
public void init(ILaunchTargetManager targetManager) {
- ILaunchBarManager launchBarManager = CDebugCorePlugin.getService(ILaunchBarManager.class);
- launchBarManager.addListener(new CoreBuildLaunchBarTracker(TYPE_ID));
+ // Nothing to do
}
@Override
diff --git a/debug/org.eclipse.cdt.debug.ui/plugin.xml b/debug/org.eclipse.cdt.debug.ui/plugin.xml
index 30dd0676ed3..ce9b8636f3d 100644
--- a/debug/org.eclipse.cdt.debug.ui/plugin.xml
+++ b/debug/org.eclipse.cdt.debug.ui/plugin.xml
@@ -2585,12 +2585,12 @@
id="org.eclipse.cdt.launchTargetType.generic"
labelProvider="org.eclipse.cdt.debug.internal.ui.launch.GenericTargetLabelProvider">
</launchTargetTypeUI>
- <wizard
+ <wizard2
class="org.eclipse.cdt.debug.internal.ui.launch.NewGenericTargetWizard"
icon="icons/obj16/cdt_logo_16.png"
- id="org.eclipse.cdt.debug.ui.newGenericTargetWizard"
+ id="org.eclipse.cdt.launchTargetType.generic"
name="%GenericTarget.name">
- </wizard>
+ </wizard2>
</extension>
</plugin>
diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/launch/GenericTargetPropertiesBlock.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/launch/GenericTargetPropertiesBlock.java
deleted file mode 100644
index bc5f6fd6892..00000000000
--- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/launch/GenericTargetPropertiesBlock.java
+++ /dev/null
@@ -1,51 +0,0 @@
-package org.eclipse.cdt.debug.internal.ui.launch;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Text;
-
-public class GenericTargetPropertiesBlock extends Composite {
-
- private Text nameText;
- private Text osText;
- private Text archText;
-
- public GenericTargetPropertiesBlock(Composite parent, int style) {
- super(parent, style);
- setLayout(new GridLayout(2, false));
-
- Label label = new Label(this, SWT.NONE);
- label.setText("Name:");
-
- nameText = new Text(this, SWT.BORDER);
- nameText.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
-
- label = new Label(this, SWT.NONE);
- label.setText("Operating System:");
-
- osText = new Text(this, SWT.BORDER);
- osText.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
-
- label = new Label(this, SWT.NONE);
- label.setText("CPU Architecture:");
-
- archText = new Text(this, SWT.BORDER);
- archText.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
- }
-
- public String getTargetName() {
- return nameText.getText();
- }
-
- public String getOS() {
- return osText.getText();
- }
-
- public String getArch() {
- return archText.getText();
- }
-
-}
diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/launch/NewGenericTargetWizard.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/launch/NewGenericTargetWizard.java
index a8f982dc916..1f9e8e0f3e5 100644
--- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/launch/NewGenericTargetWizard.java
+++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/launch/NewGenericTargetWizard.java
@@ -9,15 +9,13 @@ package org.eclipse.cdt.debug.internal.ui.launch;
import org.eclipse.cdt.debug.core.launch.GenericTargetTypeProvider;
import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.wizard.Wizard;
import org.eclipse.launchbar.core.target.ILaunchTarget;
import org.eclipse.launchbar.core.target.ILaunchTargetManager;
import org.eclipse.launchbar.core.target.ILaunchTargetWorkingCopy;
-import org.eclipse.ui.INewWizard;
-import org.eclipse.ui.IWorkbench;
+import org.eclipse.launchbar.ui.internal.Activator;
+import org.eclipse.launchbar.ui.target.LaunchTargetWizard;
-public class NewGenericTargetWizard extends Wizard implements INewWizard {
+public class NewGenericTargetWizard extends LaunchTargetWizard {
private NewGenericTargetWizardPage page;
@@ -26,15 +24,10 @@ public class NewGenericTargetWizard extends Wizard implements INewWizard {
}
@Override
- public void init(IWorkbench workbench, IStructuredSelection selection) {
- // nothing
- }
-
- @Override
public void addPages() {
super.addPages();
- page = new NewGenericTargetWizardPage();
+ page = new NewGenericTargetWizardPage(getLaunchTarget());
addPage(page);
}
@@ -44,8 +37,13 @@ public class NewGenericTargetWizard extends Wizard implements INewWizard {
String typeId = GenericTargetTypeProvider.TYPE_ID;
String id = page.getTargetName();
- ILaunchTarget target = manager.addLaunchTarget(typeId, id);
+ ILaunchTarget target = getLaunchTarget();
+ if (target == null) {
+ target = manager.addLaunchTarget(typeId, id);
+ }
+
ILaunchTargetWorkingCopy wc = target.getWorkingCopy();
+ wc.setId(id);
wc.setAttribute(ILaunchTarget.ATTR_OS, page.getOS());
wc.setAttribute(ILaunchTarget.ATTR_ARCH, page.getArch());
wc.save();
@@ -53,4 +51,18 @@ public class NewGenericTargetWizard extends Wizard implements INewWizard {
return true;
}
+ @Override
+ public boolean canDelete() {
+ return true;
+ }
+
+ @Override
+ public void performDelete() {
+ ILaunchTargetManager manager = Activator.getService(ILaunchTargetManager.class);
+ ILaunchTarget target = getLaunchTarget();
+ if (target != null) {
+ manager.removeLaunchTarget(getLaunchTarget());
+ }
+ }
+
}
diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/launch/NewGenericTargetWizardPage.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/launch/NewGenericTargetWizardPage.java
index 9f3f557d4f0..c3a064a8798 100644
--- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/launch/NewGenericTargetWizardPage.java
+++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/launch/NewGenericTargetWizardPage.java
@@ -8,35 +8,82 @@
package org.eclipse.cdt.debug.internal.ui.launch;
import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.launchbar.core.target.ILaunchTarget;
import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
public class NewGenericTargetWizardPage extends WizardPage {
- private GenericTargetPropertiesBlock propertiesBlock;
+ private final ILaunchTarget launchTarget;
- public NewGenericTargetWizardPage() {
+ private Text nameText;
+ private Text osText;
+ private Text archText;
+
+ public NewGenericTargetWizardPage(ILaunchTarget launchTarget) {
super(NewGenericTargetWizardPage.class.getName());
setTitle("Generic Target");
setDescription("Enter name and properties for the target.");
+ this.launchTarget = launchTarget;
}
@Override
public void createControl(Composite parent) {
- propertiesBlock = new GenericTargetPropertiesBlock(parent, SWT.NONE);
- setControl(propertiesBlock);
+ Composite comp = new Composite(parent, SWT.NONE);
+ comp.setLayout(new GridLayout(2, false));
+
+ Label label = new Label(comp, SWT.NONE);
+ label.setText("Name:");
+
+ nameText = new Text(comp, SWT.BORDER);
+ nameText.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
+ if (launchTarget != null) {
+ nameText.setText(launchTarget.getId());
+ }
+
+ label = new Label(comp, SWT.NONE);
+ label.setText("Operating System:");
+
+ osText = new Text(comp, SWT.BORDER);
+ osText.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
+ if (launchTarget != null) {
+ String os = launchTarget.getAttribute(ILaunchTarget.ATTR_OS, null);
+ if (os != null) {
+ osText.setText(os);
+ }
+ }
+
+ label = new Label(comp, SWT.NONE);
+ label.setText("CPU Architecture:");
+
+ archText = new Text(comp, SWT.BORDER);
+ archText.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
+ if (launchTarget != null) {
+ String arch = launchTarget.getAttribute(ILaunchTarget.ATTR_ARCH, null);
+ if (arch != null) {
+ archText.setText(arch);
+ }
+ }
+
+ setControl(comp);
}
public String getTargetName() {
- return propertiesBlock.getTargetName();
+ return nameText.getText().trim();
}
public String getOS() {
- return propertiesBlock.getOS();
+ String os = osText.getText().trim();
+ return !os.isEmpty() ? os : null;
}
public String getArch() {
- return propertiesBlock.getArch();
+ String arch = archText.getText().trim();
+ return !arch.isEmpty() ? arch : null;
}
}

Back to the top