mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-21 21:52:10 +02:00
Cleared up the target model making it a provider responsibility.
The launch config descriptor provides the list of targets for a given (usually active) config. The manager still manages which one is active.
This commit is contained in:
parent
6dd184d9be
commit
2f995b6acb
11 changed files with 101 additions and 81 deletions
1
debug/org.eclipse.cdt.debug.application.doc/.gitignore
vendored
Normal file
1
debug/org.eclipse.cdt.debug.application.doc/.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
/workspace/
|
1
doc/org.eclipse.cdt.doc.user/.gitignore
vendored
Normal file
1
doc/org.eclipse.cdt.doc.user/.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
/workspace/
|
|
@ -1,7 +1,7 @@
|
|||
package org.eclipse.cdt.launchbar.cdt.core.internal;
|
||||
|
||||
import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
|
||||
import org.eclipse.cdt.launchbar.core.ILaunchConfigurationDescriptor;
|
||||
import org.eclipse.cdt.launchbar.core.DefaultLaunchConfigurationDescriptor;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
import org.eclipse.core.resources.ResourcesPlugin;
|
||||
|
@ -12,17 +12,17 @@ import org.eclipse.debug.core.ILaunchConfigurationType;
|
|||
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
|
||||
import org.eclipse.debug.core.ILaunchManager;
|
||||
|
||||
public class CDTLaunchConfigDescriptor implements ILaunchConfigurationDescriptor {
|
||||
public class CDTLaunchConfigDescriptor extends DefaultLaunchConfigurationDescriptor {
|
||||
|
||||
private String projectName;
|
||||
private ILaunchConfiguration config;
|
||||
|
||||
public CDTLaunchConfigDescriptor(IProject project) {
|
||||
super(null);
|
||||
projectName = project.getName();
|
||||
}
|
||||
|
||||
public CDTLaunchConfigDescriptor(ILaunchConfiguration config) {
|
||||
this.config = config;
|
||||
super(config);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -53,6 +53,7 @@ public class CDTLaunchConfigDescriptor implements ILaunchConfigurationDescriptor
|
|||
ILaunchConfigurationWorkingCopy wc = configType.newInstance(null, getLaunchManager().generateLaunchConfigurationName(projectName));
|
||||
wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME, projectName);
|
||||
wc.setMappedResources(new IResource[] { getProject() });
|
||||
wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY, (String) null);
|
||||
|
||||
// TODO finish this off
|
||||
|
||||
|
@ -63,9 +64,7 @@ public class CDTLaunchConfigDescriptor implements ILaunchConfigurationDescriptor
|
|||
|
||||
@Override
|
||||
public boolean matches(ILaunchConfiguration launchConfiguration) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
// matches if it's the same project
|
||||
// TODO matches if it's the same project
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -8,16 +8,18 @@
|
|||
* Contributors:
|
||||
* Doug Schaefer
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.launchbar.core.internal;
|
||||
package org.eclipse.cdt.launchbar.core;
|
||||
|
||||
import org.eclipse.cdt.launchbar.core.ILaunchConfigurationDescriptor;
|
||||
import org.eclipse.cdt.launchbar.core.internal.LaunchBarManager;
|
||||
import org.eclipse.cdt.launchbar.core.internal.LocalTarget;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.debug.core.ILaunchConfiguration;
|
||||
import org.eclipse.debug.core.ILaunchConfigurationType;
|
||||
import org.eclipse.debug.core.ILaunchMode;
|
||||
|
||||
public class DefaultLaunchConfigurationDescriptor implements ILaunchConfigurationDescriptor {
|
||||
|
||||
final ILaunchConfiguration config;
|
||||
protected ILaunchConfiguration config;
|
||||
|
||||
public DefaultLaunchConfigurationDescriptor(ILaunchConfiguration config) {
|
||||
this.config = config;
|
||||
|
@ -43,4 +45,24 @@ public class DefaultLaunchConfigurationDescriptor implements ILaunchConfiguratio
|
|||
return config.equals(launchConfiguration);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ILaunchTarget getLaunchTarget(String id) {
|
||||
return LocalTarget.ID.equals(id) ? LaunchBarManager.getLocalLaunchTarget() : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ILaunchTarget[] getLaunchTargets() {
|
||||
return new ILaunchTarget[] { LaunchBarManager.getLocalLaunchTarget() };
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setActiveLaunchTarget(ILaunchTarget target) {
|
||||
// nothing to do
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setActiveLaunchMode(ILaunchMode mode) {
|
||||
// nothing to do
|
||||
}
|
||||
|
||||
}
|
|
@ -13,6 +13,7 @@ package org.eclipse.cdt.launchbar.core;
|
|||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.debug.core.ILaunchConfiguration;
|
||||
import org.eclipse.debug.core.ILaunchConfigurationType;
|
||||
import org.eclipse.debug.core.ILaunchMode;
|
||||
|
||||
public interface ILaunchConfigurationDescriptor {
|
||||
|
||||
|
@ -46,5 +47,36 @@ public interface ILaunchConfigurationDescriptor {
|
|||
* @return
|
||||
*/
|
||||
boolean matches(ILaunchConfiguration launchConfiguration);
|
||||
|
||||
/**
|
||||
* Return the list of launch targets this configuration can launcht to.
|
||||
*
|
||||
* @return launch targets
|
||||
*/
|
||||
ILaunchTarget[] getLaunchTargets();
|
||||
|
||||
/**
|
||||
* Return the launch target with the given id.
|
||||
*
|
||||
* @param id id of target
|
||||
* @return launch target
|
||||
*/
|
||||
ILaunchTarget getLaunchTarget(String id);
|
||||
|
||||
/**
|
||||
* Set the active launch mode. Allows the descriptor to prepare for a
|
||||
* launch in that mode.
|
||||
*
|
||||
* @param mode the new active launch mode
|
||||
*/
|
||||
void setActiveLaunchMode(ILaunchMode mode);
|
||||
|
||||
/**
|
||||
* Set the active launch target. Allows the descriptor to prepare for
|
||||
* a launch on that target.
|
||||
*
|
||||
* @param target the new active launch target
|
||||
*/
|
||||
void setActiveLaunchTarget(ILaunchTarget target);
|
||||
|
||||
}
|
||||
|
|
|
@ -12,8 +12,18 @@ package org.eclipse.cdt.launchbar.core;
|
|||
|
||||
public interface ILaunchTarget {
|
||||
|
||||
/**
|
||||
* Get the id for the target. The id of the active target is
|
||||
* stored in the preference store.
|
||||
*
|
||||
* @return id
|
||||
*/
|
||||
String getId();
|
||||
|
||||
/**
|
||||
* Returns a name to show in the UI for this target.
|
||||
*
|
||||
* @return name
|
||||
*/
|
||||
String getName();
|
||||
|
||||
ILaunchTargetType getType();
|
||||
|
||||
}
|
||||
|
|
|
@ -1,17 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2014 QNX Software Systems 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:
|
||||
* Doug Schaefer
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.launchbar.core;
|
||||
|
||||
public interface ILaunchTargetType {
|
||||
|
||||
String getId();
|
||||
|
||||
}
|
|
@ -19,6 +19,7 @@ import java.util.LinkedList;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.eclipse.cdt.launchbar.core.DefaultLaunchConfigurationDescriptor;
|
||||
import org.eclipse.cdt.launchbar.core.ILaunchBarManager;
|
||||
import org.eclipse.cdt.launchbar.core.ILaunchConfigurationDescriptor;
|
||||
import org.eclipse.cdt.launchbar.core.ILaunchConfigurationsProvider;
|
||||
|
@ -45,11 +46,14 @@ public class LaunchBarManager extends PlatformObject implements ILaunchBarManage
|
|||
private List<Listener> listeners = new LinkedList<>();
|
||||
private List<ProviderExtensionDescriptor> providers = new ArrayList<>();
|
||||
private Map<String, ILaunchConfigurationDescriptor> configDescs = new HashMap<>();
|
||||
private ILaunchConfigurationDescriptor lastConfigDesc, activeConfigDesc;
|
||||
private ILaunchConfigurationDescriptor lastConfigDesc;
|
||||
private ILaunchMode[] launchModes = new ILaunchMode[0];
|
||||
|
||||
private ILaunchConfigurationDescriptor activeConfigDesc;
|
||||
private ILaunchMode activeLaunchMode;
|
||||
private ILaunchTarget activeLaunchTarget;
|
||||
|
||||
private final LocalTargetType localTargetType = new LocalTargetType();
|
||||
private static final LocalTarget localLaunchTarget = new LocalTarget();
|
||||
|
||||
private static final String PREF_ACTIVE_CONFIG_DESC = "activeConfigDesc";
|
||||
private static final String PREF_ACTIVE_LAUNCH_MODE = "activeLaunchMode";
|
||||
|
@ -346,22 +350,27 @@ public class LaunchBarManager extends PlatformObject implements ILaunchBarManage
|
|||
|
||||
@Override
|
||||
public ILaunchTarget[] getLaunchTargets() {
|
||||
// TODO for reals
|
||||
return new ILaunchTarget[] { localTargetType.getTarget() };
|
||||
if (activeConfigDesc != null)
|
||||
return activeConfigDesc.getLaunchTargets();
|
||||
else
|
||||
return new ILaunchTarget[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public ILaunchTarget getActiveLaunchTarget() {
|
||||
// TODO for reals
|
||||
return localTargetType.getTarget();
|
||||
return activeLaunchTarget;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setActiveLaunchTarget(ILaunchTarget target) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
activeLaunchTarget = target;
|
||||
activeConfigDesc.setActiveLaunchTarget(target);
|
||||
}
|
||||
|
||||
public static LocalTarget getLocalLaunchTarget() {
|
||||
return localLaunchTarget;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addLaunchTarget(ILaunchTarget target) {
|
||||
// TODO Auto-generated method stub
|
||||
|
|
|
@ -11,24 +11,19 @@
|
|||
package org.eclipse.cdt.launchbar.core.internal;
|
||||
|
||||
import org.eclipse.cdt.launchbar.core.ILaunchTarget;
|
||||
import org.eclipse.cdt.launchbar.core.ILaunchTargetType;
|
||||
|
||||
public class LocalTarget implements ILaunchTarget {
|
||||
|
||||
private final LocalTargetType type;
|
||||
public static final String ID = "org.eclipse.cdt.local";
|
||||
|
||||
public LocalTarget(LocalTargetType type) {
|
||||
this.type = type;
|
||||
@Override
|
||||
public String getId() {
|
||||
return ID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "Local Machine";
|
||||
}
|
||||
|
||||
@Override
|
||||
public ILaunchTargetType getType() {
|
||||
return type;
|
||||
return "Local Machine"; // TODO externalize
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,32 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2014 QNX Software Systems 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:
|
||||
* Doug Schaefer
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.launchbar.core.internal;
|
||||
|
||||
import org.eclipse.cdt.launchbar.core.ILaunchTargetType;
|
||||
|
||||
public class LocalTargetType implements ILaunchTargetType {
|
||||
|
||||
private final LocalTarget target;
|
||||
|
||||
public LocalTargetType() {
|
||||
target = new LocalTarget(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getId() {
|
||||
return "org.eclipse.cdt.launchbar.target.local";
|
||||
}
|
||||
|
||||
public LocalTarget getTarget() {
|
||||
return target;
|
||||
}
|
||||
|
||||
}
|
|
@ -89,7 +89,7 @@ public class TargetSelector extends CSelector {
|
|||
if (labelProvider != null) {
|
||||
return labelProvider.getText(element);
|
||||
}
|
||||
return target.getName();
|
||||
return target.getId();
|
||||
}
|
||||
return super.getText(element);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue