mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-09-07 18:43:32 +02:00
LaunhBar - some API changes and cleanup
* Project provider to react on project changes (i.e. when nature changed) * Added concept of open descriptor - which will be visible in UI, this will allow not to remap to null, reuse objects for other reasons, and eventually I want to replace object map into 1:1 mapping without nulls * Removed throwing CoreException from getLaunchDescriptors (it does not need to throw it) * Project based type now checks if project is open * Fixed copyright * Added interface for ILaunchDescriptorProjectBased Change-Id: I3277f5910c7df1bb4aa3e809dda3b61921dcad6e Signed-off-by: Alena Laskavaia <elaskavaia.cdt@gmail.com> Reviewed-on: https://git.eclipse.org/r/31321
This commit is contained in:
parent
4d4ab6cafd
commit
1bf2aa825f
12 changed files with 242 additions and 153 deletions
|
@ -289,19 +289,19 @@ public class LaunchBarManagerTest extends TestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetLaunchDescriptorsNull() {
|
public void testGetOpenLaunchDescriptorsNull() {
|
||||||
ILaunchDescriptor[] launchDescriptors = manager.getLaunchDescriptors();
|
ILaunchDescriptor[] launchDescriptors = manager.getOpenLaunchDescriptors();
|
||||||
assertEquals(0, launchDescriptors.length);
|
assertEquals(0, launchDescriptors.length);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testGetLaunchDescriptors() {
|
public void testGetOpenLaunchDescriptors() {
|
||||||
basicSetup();
|
basicSetup();
|
||||||
manager.launchObjectAdded(lc);
|
manager.launchObjectAdded(lc);
|
||||||
ILaunchDescriptor[] launchDescriptors = manager.getLaunchDescriptors();
|
ILaunchDescriptor[] launchDescriptors = manager.getOpenLaunchDescriptors();
|
||||||
assertEquals(1, launchDescriptors.length);
|
assertEquals(1, launchDescriptors.length);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testGetLaunchDescriptorsSort() {
|
public void testGetOpenLaunchDescriptorsSort() {
|
||||||
final ILaunchDescriptor res[] = new ILaunchDescriptor[1];
|
final ILaunchDescriptor res[] = new ILaunchDescriptor[1];
|
||||||
manager.addTargetType(targetType);
|
manager.addTargetType(targetType);
|
||||||
ConfigBasedLaunchDescriptorType descType1 = new ConfigBasedLaunchDescriptorType("id1", lctype.getIdentifier());
|
ConfigBasedLaunchDescriptorType descType1 = new ConfigBasedLaunchDescriptorType("id1", lctype.getIdentifier());
|
||||||
|
@ -320,7 +320,7 @@ public class LaunchBarManagerTest extends TestCase {
|
||||||
manager.addConfigProvider(descType3.getId(), targetType.getId(), true, provider);
|
manager.addConfigProvider(descType3.getId(), targetType.getId(), true, provider);
|
||||||
targetType.targets.add(mytarget);
|
targetType.targets.add(mytarget);
|
||||||
manager.launchObjectAdded(lc);
|
manager.launchObjectAdded(lc);
|
||||||
ILaunchDescriptor[] launchDescriptors = manager.getLaunchDescriptors();
|
ILaunchDescriptor[] launchDescriptors = manager.getOpenLaunchDescriptors();
|
||||||
assertEquals(1, launchDescriptors.length);
|
assertEquals(1, launchDescriptors.length);
|
||||||
assertNotNull(launchDescriptors[0]);
|
assertNotNull(launchDescriptors[0]);
|
||||||
assertSame(res[0], launchDescriptors[0]);
|
assertSame(res[0], launchDescriptors[0]);
|
||||||
|
@ -330,7 +330,7 @@ public class LaunchBarManagerTest extends TestCase {
|
||||||
public void testLaunchObjectAdded() throws CoreException {
|
public void testLaunchObjectAdded() throws CoreException {
|
||||||
basicSetup();
|
basicSetup();
|
||||||
manager.launchObjectAdded(lc);
|
manager.launchObjectAdded(lc);
|
||||||
ILaunchDescriptor[] launchDescriptors = manager.getLaunchDescriptors();
|
ILaunchDescriptor[] launchDescriptors = manager.getOpenLaunchDescriptors();
|
||||||
assertEquals(1, launchDescriptors.length);
|
assertEquals(1, launchDescriptors.length);
|
||||||
assertNotNull(launchDescriptors[0]);
|
assertNotNull(launchDescriptors[0]);
|
||||||
assertEquals(lc.getName(), launchDescriptors[0].getName());
|
assertEquals(lc.getName(), launchDescriptors[0].getName());
|
||||||
|
@ -342,7 +342,7 @@ public class LaunchBarManagerTest extends TestCase {
|
||||||
manager.launchObjectAdded(lc);
|
manager.launchObjectAdded(lc);
|
||||||
ILaunchConfiguration lc2 = mockLC("lc2", lctype);
|
ILaunchConfiguration lc2 = mockLC("lc2", lctype);
|
||||||
manager.launchObjectAdded(lc2);
|
manager.launchObjectAdded(lc2);
|
||||||
assertEquals(2, manager.getLaunchDescriptors().length);
|
assertEquals(2, manager.getOpenLaunchDescriptors().length);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -350,7 +350,7 @@ public class LaunchBarManagerTest extends TestCase {
|
||||||
basicSetup();
|
basicSetup();
|
||||||
assertNull(manager.launchObjectChanged(lc));
|
assertNull(manager.launchObjectChanged(lc));
|
||||||
manager.launchObjectAdded(lc);
|
manager.launchObjectAdded(lc);
|
||||||
assertEquals(1, manager.getLaunchDescriptors().length);
|
assertEquals(1, manager.getOpenLaunchDescriptors().length);
|
||||||
assertNotNull(manager.launchObjectChanged(lc));
|
assertNotNull(manager.launchObjectChanged(lc));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -362,6 +362,7 @@ public class LaunchBarManagerTest extends TestCase {
|
||||||
IPath path = new Path(projectName);
|
IPath path = new Path(projectName);
|
||||||
when(project.getFullPath()).thenReturn(path);
|
when(project.getFullPath()).thenReturn(path);
|
||||||
when(project.getType()).thenReturn(IResource.PROJECT);
|
when(project.getType()).thenReturn(IResource.PROJECT);
|
||||||
|
when(project.isOpen()).thenReturn(true);
|
||||||
return project;
|
return project;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -407,23 +408,23 @@ public class LaunchBarManagerTest extends TestCase {
|
||||||
projectMappingSetup();
|
projectMappingSetup();
|
||||||
// user created a project
|
// user created a project
|
||||||
manager.launchObjectAdded(aaa);
|
manager.launchObjectAdded(aaa);
|
||||||
assertEquals(1, manager.getLaunchDescriptors().length);
|
assertEquals(1, manager.getOpenLaunchDescriptors().length);
|
||||||
assertTrue(manager.getLaunchDescriptors()[0].getName().startsWith(aaa.getName()));
|
assertTrue(manager.getOpenLaunchDescriptors()[0].getName().startsWith(aaa.getName()));
|
||||||
// user clicked on descriptor geer to edit lc, new lc is created
|
// user clicked on descriptor geer to edit lc, new lc is created
|
||||||
manager.launchConfigurationAdded(lc);
|
manager.launchConfigurationAdded(lc);
|
||||||
assertEquals(1, manager.getLaunchDescriptors().length);
|
assertEquals(1, manager.getOpenLaunchDescriptors().length);
|
||||||
assertEquals(lc.getName(), manager.getLaunchDescriptors()[0].getName());
|
assertEquals(lc.getName(), manager.getOpenLaunchDescriptors()[0].getName());
|
||||||
// user cloned lc and changed some settings
|
// user cloned lc and changed some settings
|
||||||
ILaunchConfiguration lc2 = mockLC("lc2", lctype);
|
ILaunchConfiguration lc2 = mockLC("lc2", lctype);
|
||||||
mockLCProject(lc2, aaa.getName());
|
mockLCProject(lc2, aaa.getName());
|
||||||
manager.launchConfigurationAdded(lc2);
|
manager.launchConfigurationAdded(lc2);
|
||||||
assertEquals(2, manager.getLaunchDescriptors().length);
|
assertEquals(2, manager.getOpenLaunchDescriptors().length);
|
||||||
// user deleted lc
|
// user deleted lc
|
||||||
userDeletesLC(lc2);
|
userDeletesLC(lc2);
|
||||||
assertEquals(1, manager.getLaunchDescriptors().length);
|
assertEquals(1, manager.getOpenLaunchDescriptors().length);
|
||||||
// user deleted last lc, now we back to project default
|
// user deleted last lc, now we back to project default
|
||||||
userDeletesLC(lc);
|
userDeletesLC(lc);
|
||||||
assertEquals(1, manager.getLaunchDescriptors().length);
|
assertEquals(1, manager.getOpenLaunchDescriptors().length);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void userDeletesLC(ILaunchConfiguration lc2) {
|
protected void userDeletesLC(ILaunchConfiguration lc2) {
|
||||||
|
@ -443,6 +444,11 @@ public class LaunchBarManagerTest extends TestCase {
|
||||||
protected boolean ownsProject(IProject element) {
|
protected boolean ownsProject(IProject element) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ILaunchConfigurationType getLaunchConfigurationType() {
|
||||||
|
return lctype;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
provider = new ProjectBasedLaunchConfigurationProvider(lctype.getIdentifier()) {
|
provider = new ProjectBasedLaunchConfigurationProvider(lctype.getIdentifier()) {
|
||||||
protected IProject getProject(ILaunchConfiguration llc) {
|
protected IProject getProject(ILaunchConfiguration llc) {
|
||||||
|
@ -453,18 +459,21 @@ public class LaunchBarManagerTest extends TestCase {
|
||||||
basicSetup();
|
basicSetup();
|
||||||
aaa = mockProject("aaa");
|
aaa = mockProject("aaa");
|
||||||
mockLCProject(lc, aaa.getName());
|
mockLCProject(lc, aaa.getName());
|
||||||
assertEquals(0, manager.getLaunchDescriptors().length);
|
assertEquals(0, manager.getOpenLaunchDescriptors().length);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testLaunchObjectAddedRemapping2() throws CoreException {
|
public void testLaunchObjectAddedRemapping2() throws CoreException {
|
||||||
projectMappingSetup();
|
projectMappingSetup();
|
||||||
// test unmapping
|
// test unmapping
|
||||||
manager.launchObjectAdded(aaa);
|
manager.launchObjectAdded(aaa);
|
||||||
|
assertEquals(1, manager.getOpenLaunchDescriptors().length);
|
||||||
manager.launchObjectAdded(lc);
|
manager.launchObjectAdded(lc);
|
||||||
assertEquals(2, manager.getLaunchDescriptors().length);
|
assertEquals(2, manager.getOpenLaunchDescriptors().length); // XXX should be 1
|
||||||
manager.launchObjectAdded(aaa); // that would remove aaa mapping since lc is already there
|
manager.launchObjectChanged(aaa);
|
||||||
assertEquals(1, manager.getLaunchDescriptors().length);
|
assertEquals(1, manager.getOpenLaunchDescriptors().length);
|
||||||
assertEquals(lc.getName(), manager.getLaunchDescriptors()[0].getName());
|
assertEquals(lc.getName(), manager.getOpenLaunchDescriptors()[0].getName());
|
||||||
|
manager.launchObjectRemoved(lc);
|
||||||
|
assertEquals(0, manager.getOpenLaunchDescriptors().length); // XXX should be 1
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -490,9 +499,9 @@ public class LaunchBarManagerTest extends TestCase {
|
||||||
public void testLaunchObjectRemoved() throws CoreException {
|
public void testLaunchObjectRemoved() throws CoreException {
|
||||||
basicSetup();
|
basicSetup();
|
||||||
manager.launchObjectAdded(lc);
|
manager.launchObjectAdded(lc);
|
||||||
assertEquals(1, manager.getLaunchDescriptors().length);
|
assertEquals(1, manager.getOpenLaunchDescriptors().length);
|
||||||
manager.launchObjectRemoved(lc);
|
manager.launchObjectRemoved(lc);
|
||||||
assertEquals(0, manager.getLaunchDescriptors().length);
|
assertEquals(0, manager.getOpenLaunchDescriptors().length);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -825,7 +834,7 @@ public class LaunchBarManagerTest extends TestCase {
|
||||||
ILaunchMode mode = mockLaunchModes(lctype, "foo")[0];
|
ILaunchMode mode = mockLaunchModes(lctype, "foo")[0];
|
||||||
manager.launchConfigurationAdded(lc);
|
manager.launchConfigurationAdded(lc);
|
||||||
verify(provider).launchConfigurationAdded(lc);
|
verify(provider).launchConfigurationAdded(lc);
|
||||||
ILaunchDescriptor[] launchDescriptors = manager.getLaunchDescriptors();
|
ILaunchDescriptor[] launchDescriptors = manager.getOpenLaunchDescriptors();
|
||||||
assertEquals(1, launchDescriptors.length);
|
assertEquals(1, launchDescriptors.length);
|
||||||
assertNotNull(launchDescriptors[0]);
|
assertNotNull(launchDescriptors[0]);
|
||||||
assertEquals(lc.getName(), launchDescriptors[0].getName());
|
assertEquals(lc.getName(), launchDescriptors[0].getName());
|
||||||
|
@ -844,7 +853,7 @@ public class LaunchBarManagerTest extends TestCase {
|
||||||
ILaunchConfiguration lc2 = mockLC("lc2", lctype2);
|
ILaunchConfiguration lc2 = mockLC("lc2", lctype2);
|
||||||
manager.launchConfigurationAdded(lc2);
|
manager.launchConfigurationAdded(lc2);
|
||||||
verify(provider).launchConfigurationAdded(lc2);
|
verify(provider).launchConfigurationAdded(lc2);
|
||||||
ILaunchDescriptor[] launchDescriptors = manager.getLaunchDescriptors();
|
ILaunchDescriptor[] launchDescriptors = manager.getOpenLaunchDescriptors();
|
||||||
assertEquals(1, launchDescriptors.length);
|
assertEquals(1, launchDescriptors.length);
|
||||||
assertNotNull(launchDescriptors[0]);
|
assertNotNull(launchDescriptors[0]);
|
||||||
assertEquals(lc2.getName(), launchDescriptors[0].getName());
|
assertEquals(lc2.getName(), launchDescriptors[0].getName());
|
||||||
|
@ -909,7 +918,7 @@ public class LaunchBarManagerTest extends TestCase {
|
||||||
manager = new FixedLaunchBarManager();
|
manager = new FixedLaunchBarManager();
|
||||||
targetType.targets.add(mytarget);
|
targetType.targets.add(mytarget);
|
||||||
manager.launchObjectAdded(lc);
|
manager.launchObjectAdded(lc);
|
||||||
ILaunchDescriptor[] launchDescriptors = manager.getLaunchDescriptors();
|
ILaunchDescriptor[] launchDescriptors = manager.getOpenLaunchDescriptors();
|
||||||
assertEquals(1, launchDescriptors.length);
|
assertEquals(1, launchDescriptors.length);
|
||||||
assertNotNull(launchDescriptors[0]);
|
assertNotNull(launchDescriptors[0]);
|
||||||
assertEquals(lc.getName(), launchDescriptors[0].getName());
|
assertEquals(lc.getName(), launchDescriptors[0].getName());
|
||||||
|
@ -933,7 +942,7 @@ public class LaunchBarManagerTest extends TestCase {
|
||||||
store.put("activeConfigDesc", desc.getId());
|
store.put("activeConfigDesc", desc.getId());
|
||||||
manager = new FixedLaunchBarManager();
|
manager = new FixedLaunchBarManager();
|
||||||
verify(descType).getDescriptor(lc);
|
verify(descType).getDescriptor(lc);
|
||||||
ILaunchDescriptor[] launchDescriptors = manager.getLaunchDescriptors();
|
ILaunchDescriptor[] launchDescriptors = manager.getOpenLaunchDescriptors();
|
||||||
assertEquals(1, launchDescriptors.length);
|
assertEquals(1, launchDescriptors.length);
|
||||||
assertEquals(desc, launchDescriptors[0]);
|
assertEquals(desc, launchDescriptors[0]);
|
||||||
// assertEquals(desc, descriptor);
|
// assertEquals(desc, descriptor);
|
||||||
|
@ -956,7 +965,7 @@ public class LaunchBarManagerTest extends TestCase {
|
||||||
doThrow(new CoreException(new Status(1, "a", "n"))).when(element).createExecutableExtension("class");
|
doThrow(new CoreException(new Status(1, "a", "n"))).when(element).createExecutableExtension("class");
|
||||||
doReturn(new ILaunchConfiguration[] { lc }).when(lman).getLaunchConfigurations();
|
doReturn(new ILaunchConfiguration[] { lc }).when(lman).getLaunchConfigurations();
|
||||||
manager = new FixedLaunchBarManager();
|
manager = new FixedLaunchBarManager();
|
||||||
ILaunchDescriptor[] launchDescriptors = manager.getLaunchDescriptors();
|
ILaunchDescriptor[] launchDescriptors = manager.getOpenLaunchDescriptors();
|
||||||
assertEquals(0, launchDescriptors.length);
|
assertEquals(0, launchDescriptors.length);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -970,7 +979,7 @@ public class LaunchBarManagerTest extends TestCase {
|
||||||
doReturn(descType.getId() + "somestuff").when(element).getAttribute("id");
|
doReturn(descType.getId() + "somestuff").when(element).getAttribute("id");
|
||||||
doReturn(new ILaunchConfiguration[] { lc }).when(lman).getLaunchConfigurations();
|
doReturn(new ILaunchConfiguration[] { lc }).when(lman).getLaunchConfigurations();
|
||||||
manager = new FixedLaunchBarManager();
|
manager = new FixedLaunchBarManager();
|
||||||
ILaunchDescriptor[] launchDescriptors = manager.getLaunchDescriptors();
|
ILaunchDescriptor[] launchDescriptors = manager.getOpenLaunchDescriptors();
|
||||||
assertEquals(0, launchDescriptors.length);
|
assertEquals(0, launchDescriptors.length);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -986,7 +995,7 @@ public class LaunchBarManagerTest extends TestCase {
|
||||||
doReturn(new ILaunchConfiguration[] { lc }).when(lman).getLaunchConfigurations();
|
doReturn(new ILaunchConfiguration[] { lc }).when(lman).getLaunchConfigurations();
|
||||||
manager = new FixedLaunchBarManager();
|
manager = new FixedLaunchBarManager();
|
||||||
verify(descType).getDescriptor(lc);
|
verify(descType).getDescriptor(lc);
|
||||||
assertEquals(desc, manager.getLaunchDescriptors()[0]);
|
assertEquals(desc, manager.getOpenLaunchDescriptors()[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testExtensionDescriptorTypeNoPrio() throws CoreException {
|
public void testExtensionDescriptorTypeNoPrio() throws CoreException {
|
||||||
|
@ -1000,7 +1009,7 @@ public class LaunchBarManagerTest extends TestCase {
|
||||||
doReturn(new ILaunchConfiguration[] { lc }).when(lman).getLaunchConfigurations();
|
doReturn(new ILaunchConfiguration[] { lc }).when(lman).getLaunchConfigurations();
|
||||||
manager = new FixedLaunchBarManager();
|
manager = new FixedLaunchBarManager();
|
||||||
verify(descType).getDescriptor(lc);
|
verify(descType).getDescriptor(lc);
|
||||||
assertEquals(desc, manager.getLaunchDescriptors()[0]);
|
assertEquals(desc, manager.getOpenLaunchDescriptors()[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testExtensionTargetType() throws CoreException {
|
public void testExtensionTargetType() throws CoreException {
|
||||||
|
@ -1044,7 +1053,7 @@ public class LaunchBarManagerTest extends TestCase {
|
||||||
doReturn(new ILaunchConfiguration[] { lc }).when(lman).getLaunchConfigurations();
|
doReturn(new ILaunchConfiguration[] { lc }).when(lman).getLaunchConfigurations();
|
||||||
targetType.targets.add(mytarget);
|
targetType.targets.add(mytarget);
|
||||||
manager = new FixedLaunchBarManager();
|
manager = new FixedLaunchBarManager();
|
||||||
ILaunchDescriptor[] launchDescriptors = manager.getLaunchDescriptors();
|
ILaunchDescriptor[] launchDescriptors = manager.getOpenLaunchDescriptors();
|
||||||
assertEquals(1, launchDescriptors.length);
|
assertEquals(1, launchDescriptors.length);
|
||||||
assertEquals(desc, launchDescriptors[0]);
|
assertEquals(desc, launchDescriptors[0]);
|
||||||
assertEquals(mytarget, manager.getActiveLaunchTarget());
|
assertEquals(mytarget, manager.getActiveLaunchTarget());
|
||||||
|
|
|
@ -12,11 +12,9 @@ package org.eclipse.cdt.launchbar.core;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convenience implementation of ILaunchDescriptor
|
* Convenience implementation of ILaunchDescriptor
|
||||||
*
|
|
||||||
* @author elaskavaia
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public abstract class AbstractLaunchDescriptor implements ILaunchDescriptor {
|
public abstract class AbstractLaunchDescriptor implements ILaunchDescriptor {
|
||||||
|
private boolean open = true;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public abstract String getName();
|
public abstract String getName();
|
||||||
|
@ -46,4 +44,13 @@ public abstract class AbstractLaunchDescriptor implements ILaunchDescriptor {
|
||||||
return false;
|
return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isOpen() {
|
||||||
|
return open;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOpen(boolean open) {
|
||||||
|
this.open = open;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Doug Schaefer
|
* Alena Laskavaia - Initial API and implementation
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.launchbar.core;
|
package org.eclipse.cdt.launchbar.core;
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,9 @@ import org.eclipse.debug.core.ILaunchMode;
|
||||||
|
|
||||||
public interface ILaunchBarManager extends IAdaptable {
|
public interface ILaunchBarManager extends IAdaptable {
|
||||||
|
|
||||||
ILaunchDescriptor[] getLaunchDescriptors() throws CoreException;
|
ILaunchDescriptor[] getLaunchDescriptors();
|
||||||
|
|
||||||
|
ILaunchDescriptor[] getOpenLaunchDescriptors();
|
||||||
|
|
||||||
ILaunchDescriptor getActiveLaunchDescriptor() throws CoreException;
|
ILaunchDescriptor getActiveLaunchDescriptor() throws CoreException;
|
||||||
|
|
||||||
|
@ -52,6 +54,8 @@ public interface ILaunchBarManager extends IAdaptable {
|
||||||
|
|
||||||
ILaunchDescriptor launchObjectChanged(Object element) throws CoreException;
|
ILaunchDescriptor launchObjectChanged(Object element) throws CoreException;
|
||||||
|
|
||||||
|
ILaunchDescriptor getLaunchDescriptor(Object element);
|
||||||
|
|
||||||
interface Listener {
|
interface Listener {
|
||||||
|
|
||||||
void activeConfigurationDescriptorChanged();
|
void activeConfigurationDescriptorChanged();
|
||||||
|
|
|
@ -37,4 +37,9 @@ public interface ILaunchDescriptor {
|
||||||
*/
|
*/
|
||||||
ILaunchDescriptorType getType();
|
ILaunchDescriptorType getType();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Descriptor considered open when it is visible to user, and closed otherwise
|
||||||
|
*/
|
||||||
|
boolean isOpen();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,23 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* 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:
|
||||||
|
* Alena Laskavaia - Initial API and implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.launchbar.core;
|
||||||
|
|
||||||
|
import org.eclipse.core.resources.IProject;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Project Based launch descriptor knows about project it is associated with
|
||||||
|
*/
|
||||||
|
public interface ILaunchDescriptorProjectBased extends ILaunchDescriptor {
|
||||||
|
/**
|
||||||
|
* Get associate project
|
||||||
|
*/
|
||||||
|
public abstract IProject getProject();
|
||||||
|
}
|
|
@ -1,16 +1,12 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2014 QNX Software Systems. All Rights Reserved.
|
* 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
|
||||||
*
|
*
|
||||||
* You must obtain a written license from and pay applicable license fees to QNX
|
* Contributors:
|
||||||
* Software Systems before you may reproduce, modify or distribute this software,
|
* Alena Laskavaia - Initial API and implementationn
|
||||||
* or any work that includes all or part of this software. Free development
|
|
||||||
* licenses are available for evaluation and non-commercial purposes. For more
|
|
||||||
* information visit [http://licensing.qnx.com] or email licensing@qnx.com.
|
|
||||||
*
|
|
||||||
* This file may contain contributions from others. Please review this entire
|
|
||||||
* file for other proprietary rights or license notices, as well as the QNX
|
|
||||||
* Development Suite License Guide at [http://licensing.qnx.com/license-guide/]
|
|
||||||
* for other information.
|
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.launchbar.core;
|
package org.eclipse.cdt.launchbar.core;
|
||||||
|
|
||||||
|
|
|
@ -1,45 +1,46 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2014 QNX Software Systems. All Rights Reserved.
|
* 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
|
||||||
*
|
*
|
||||||
* You must obtain a written license from and pay applicable license fees to QNX
|
* Contributors:
|
||||||
* Software Systems before you may reproduce, modify or distribute this software,
|
* Alena Laskavaia - Initial API and implementation
|
||||||
* or any work that includes all or part of this software. Free development
|
|
||||||
* licenses are available for evaluation and non-commercial purposes. For more
|
|
||||||
* information visit [http://licensing.qnx.com] or email licensing@qnx.com.
|
|
||||||
*
|
|
||||||
* This file may contain contributions from others. Please review this entire
|
|
||||||
* file for other proprietary rights or license notices, as well as the QNX
|
|
||||||
* Development Suite License Guide at [http://licensing.qnx.com/license-guide/]
|
|
||||||
* for other information.
|
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.launchbar.core;
|
package org.eclipse.cdt.launchbar.core;
|
||||||
|
|
||||||
import org.eclipse.core.resources.IProject;
|
import org.eclipse.core.resources.IProject;
|
||||||
import org.eclipse.debug.core.ILaunchConfiguration;
|
import org.eclipse.debug.core.ILaunchConfiguration;
|
||||||
|
|
||||||
public class ProjectBasedLaunchDescriptor extends ConfigBasedLaunchDescriptor {
|
public class ProjectBasedLaunchDescriptor extends ConfigBasedLaunchDescriptor implements ILaunchDescriptorProjectBased {
|
||||||
private IProject project;
|
private IProject project;
|
||||||
|
|
||||||
public ProjectBasedLaunchDescriptor(ILaunchDescriptorType type, IProject p, ILaunchConfiguration lc) {
|
public ProjectBasedLaunchDescriptor(ILaunchDescriptorType type, IProject p, ILaunchConfiguration lc) {
|
||||||
super(type, lc);
|
super(type, lc);
|
||||||
|
if (p == null)
|
||||||
|
throw new NullPointerException();
|
||||||
this.project = p;
|
this.project = p;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
if (getLaunchConfiguration() == null)
|
ILaunchConfiguration lc = getLaunchConfiguration();
|
||||||
|
if (lc != null)
|
||||||
|
return lc.getName();
|
||||||
return project.getName();
|
return project.getName();
|
||||||
else
|
|
||||||
return getLaunchConfiguration().getName();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public IProject getProject() {
|
public IProject getProject() {
|
||||||
return project;
|
return project;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
if (getLaunchConfiguration() == null)
|
ILaunchConfiguration lc = getLaunchConfiguration();
|
||||||
return getName();
|
if (lc != null)
|
||||||
return "LC/" + getName();
|
return "LC/" + lc.getName();
|
||||||
|
return "P/" + project.getName();
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,22 +1,16 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2014 QNX Software Systems. All Rights Reserved.
|
* 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
|
||||||
*
|
*
|
||||||
* You must obtain a written license from and pay applicable license fees to QNX
|
* Contributors:
|
||||||
* Software Systems before you may reproduce, modify or distribute this software,
|
* Alena Laskavaia - Initial API and implementation
|
||||||
* or any work that includes all or part of this software. Free development
|
|
||||||
* licenses are available for evaluation and non-commercial purposes. For more
|
|
||||||
* information visit [http://licensing.qnx.com] or email licensing@qnx.com.
|
|
||||||
*
|
|
||||||
* This file may contain contributions from others. Please review this entire
|
|
||||||
* file for other proprietary rights or license notices, as well as the QNX
|
|
||||||
* Development Suite License Guide at [http://licensing.qnx.com/license-guide/]
|
|
||||||
* for other information.
|
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.launchbar.core;
|
package org.eclipse.cdt.launchbar.core;
|
||||||
|
|
||||||
import org.eclipse.cdt.launchbar.core.internal.Activator;
|
|
||||||
import org.eclipse.core.resources.IProject;
|
import org.eclipse.core.resources.IProject;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
|
||||||
import org.eclipse.debug.core.ILaunchConfiguration;
|
import org.eclipse.debug.core.ILaunchConfiguration;
|
||||||
|
|
||||||
public abstract class ProjectBasedLaunchDescriptorType extends ConfigBasedLaunchDescriptorType {
|
public abstract class ProjectBasedLaunchDescriptorType extends ConfigBasedLaunchDescriptorType {
|
||||||
|
@ -28,11 +22,18 @@ public abstract class ProjectBasedLaunchDescriptorType extends ConfigBasedLaunch
|
||||||
public boolean ownsLaunchObject(Object element) {
|
public boolean ownsLaunchObject(Object element) {
|
||||||
if (super.ownsLaunchObject(element))
|
if (super.ownsLaunchObject(element))
|
||||||
return true;
|
return true;
|
||||||
if (element instanceof IProject && ownsProject((IProject) element))
|
if (element instanceof IProject && ((IProject) element).isOpen() && ownsProject((IProject) element))
|
||||||
return true;
|
return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected boolean ownsLaunchDescriptor(ILaunchDescriptor ld) {
|
||||||
|
if (!(ld instanceof ProjectBasedLaunchDescriptorType))
|
||||||
|
return false;
|
||||||
|
ProjectBasedLaunchDescriptorType other = (ProjectBasedLaunchDescriptorType) ld;
|
||||||
|
return other.getLaunchConfigurationType().equals(getLaunchConfigurationType());
|
||||||
|
}
|
||||||
|
|
||||||
protected abstract boolean ownsProject(IProject element);
|
protected abstract boolean ownsProject(IProject element);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -40,24 +41,44 @@ public abstract class ProjectBasedLaunchDescriptorType extends ConfigBasedLaunch
|
||||||
if (element instanceof ILaunchConfiguration) {
|
if (element instanceof ILaunchConfiguration) {
|
||||||
ILaunchConfiguration llc = (ILaunchConfiguration) element;
|
ILaunchConfiguration llc = (ILaunchConfiguration) element;
|
||||||
IProject project = getProject(llc);
|
IProject project = getProject(llc);
|
||||||
|
// TODO we need disable project based descriptor here
|
||||||
return new ProjectBasedLaunchDescriptor(this, project, llc);
|
return new ProjectBasedLaunchDescriptor(this, project, llc);
|
||||||
} else if (element instanceof IProject) {
|
} else if (element instanceof IProject) {
|
||||||
try {
|
// this type creates two versions of the descriptor - launch config based
|
||||||
|
// and project based. Project based do not have a config. If at least one
|
||||||
|
// launch config created, associated with same project, we don't need descriptor with null config
|
||||||
|
// anymore so we return null in this case
|
||||||
|
IProject project = (IProject) element;
|
||||||
|
ProjectBasedLaunchDescriptor desc = new ProjectBasedLaunchDescriptor(this, project, null);
|
||||||
ILaunchDescriptor[] lds = getManager().getLaunchDescriptors();
|
ILaunchDescriptor[] lds = getManager().getLaunchDescriptors();
|
||||||
for (int i = 0; i < lds.length; i++) {
|
for (int i = 0; i < lds.length; i++) {
|
||||||
ILaunchDescriptor ld = lds[i];
|
ILaunchDescriptor ld = lds[i];
|
||||||
if (ld instanceof ProjectBasedLaunchDescriptor
|
if (isBetter(ld, desc)) {
|
||||||
&& element.equals(((ProjectBasedLaunchDescriptor) ld).getProject())) {
|
return null;// there is a better descriptor already
|
||||||
return null; // somebody else has it
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (CoreException e) {
|
return desc;
|
||||||
Activator.log(e);
|
|
||||||
}
|
|
||||||
return new ProjectBasedLaunchDescriptor(this, (IProject) element, null);
|
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return true is a is better then b (which would eliminate b)
|
||||||
|
*/
|
||||||
|
protected boolean isBetter(ILaunchDescriptor a, ILaunchDescriptor b) {
|
||||||
|
if (a instanceof ProjectBasedLaunchDescriptor && b instanceof ProjectBasedLaunchDescriptor) {
|
||||||
|
ProjectBasedLaunchDescriptor pa = (ProjectBasedLaunchDescriptor) a;
|
||||||
|
ProjectBasedLaunchDescriptor pb = (ProjectBasedLaunchDescriptor) b;
|
||||||
|
if (pb.getProject().equals(pa.getProject())
|
||||||
|
&& pa.getLaunchConfigurationType().equals(pb.getLaunchConfigurationType())
|
||||||
|
&& pa.getLaunchConfiguration() != null
|
||||||
|
&& pb.getLaunchConfiguration() == null) {
|
||||||
|
// a is for same project and same type, but actually have non-null configuraton
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
protected abstract IProject getProject(ILaunchConfiguration llc);
|
protected abstract IProject getProject(ILaunchConfiguration llc);
|
||||||
}
|
}
|
|
@ -14,6 +14,7 @@ import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.Iterator;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -60,7 +61,6 @@ public class LaunchBarManager extends PlatformObject implements ILaunchBarManage
|
||||||
private ILaunchDescriptor activeLaunchDesc;
|
private ILaunchDescriptor activeLaunchDesc;
|
||||||
private ILaunchMode activeLaunchMode;
|
private ILaunchMode activeLaunchMode;
|
||||||
private ILaunchTarget activeLaunchTarget;
|
private ILaunchTarget activeLaunchTarget;
|
||||||
|
|
||||||
private static final String PREF_ACTIVE_CONFIG_DESC = "activeConfigDesc";
|
private static final String PREF_ACTIVE_CONFIG_DESC = "activeConfigDesc";
|
||||||
private static final String PREF_ACTIVE_LAUNCH_MODE = "activeLaunchMode";
|
private static final String PREF_ACTIVE_LAUNCH_MODE = "activeLaunchMode";
|
||||||
private static final String PREF_ACTIVE_LAUNCH_TARGET = "activeLaunchTarget";
|
private static final String PREF_ACTIVE_LAUNCH_TARGET = "activeLaunchTarget";
|
||||||
|
@ -71,10 +71,7 @@ public class LaunchBarManager extends PlatformObject implements ILaunchBarManage
|
||||||
IEclipsePreferences store = getPreferenceStore();
|
IEclipsePreferences store = getPreferenceStore();
|
||||||
String activeConfigDescId = store.get(PREF_ACTIVE_CONFIG_DESC, null);
|
String activeConfigDescId = store.get(PREF_ACTIVE_CONFIG_DESC, null);
|
||||||
String configDescIds = store.get(PREF_CONFIG_DESC_ORDER, Collections.EMPTY_LIST.toString());
|
String configDescIds = store.get(PREF_CONFIG_DESC_ORDER, Collections.EMPTY_LIST.toString());
|
||||||
|
|
||||||
|
|
||||||
loadExtensions();
|
loadExtensions();
|
||||||
|
|
||||||
// Hook up the existing launch configurations and listen
|
// Hook up the existing launch configurations and listen
|
||||||
ILaunchManager launchManager = getLaunchManager();
|
ILaunchManager launchManager = getLaunchManager();
|
||||||
for (ILaunchConfiguration configuration : launchManager.getLaunchConfigurations()) {
|
for (ILaunchConfiguration configuration : launchManager.getLaunchConfigurations()) {
|
||||||
|
@ -83,13 +80,16 @@ public class LaunchBarManager extends PlatformObject implements ILaunchBarManage
|
||||||
launchManager.addLaunchConfigurationListener(this);
|
launchManager.addLaunchConfigurationListener(this);
|
||||||
reorderDescriptors(configDescIds);
|
reorderDescriptors(configDescIds);
|
||||||
// Now that all the descriptors are loaded, set the one
|
// Now that all the descriptors are loaded, set the one
|
||||||
ILaunchDescriptor configDesc = descriptors.get(activeConfigDescId);
|
ILaunchDescriptor configDesc = getDescriptorById(activeConfigDescId);
|
||||||
if (configDesc == null) {
|
if (configDesc == null) {
|
||||||
configDesc = getLastUsedDescriptor();
|
configDesc = getLastUsedDescriptor();
|
||||||
}
|
}
|
||||||
setActiveLaunchDescriptor(configDesc);
|
setActiveLaunchDescriptor(configDesc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private ILaunchDescriptor getDescriptorById(String activeConfigDescId) {
|
||||||
|
return descriptors.get(activeConfigDescId);
|
||||||
|
}
|
||||||
|
|
||||||
protected void loadExtensions() {
|
protected void loadExtensions() {
|
||||||
IExtensionPoint point = getExtensionPoint();
|
IExtensionPoint point = getExtensionPoint();
|
||||||
|
@ -156,7 +156,6 @@ public class LaunchBarManager extends PlatformObject implements ILaunchBarManage
|
||||||
Activator.log(e); // exceptions during extension loading, log and move on
|
Activator.log(e); // exceptions during extension loading, log and move on
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
// third pass - object providers
|
// third pass - object providers
|
||||||
for (IExtension extension : extensions) {
|
for (IExtension extension : extensions) {
|
||||||
|
@ -174,15 +173,13 @@ public class LaunchBarManager extends PlatformObject implements ILaunchBarManage
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private void reorderDescriptors(String configDescIds) {
|
private void reorderDescriptors(String configDescIds) {
|
||||||
configDescIds = configDescIds.replaceAll("[\\]\\[]", "");
|
configDescIds = configDescIds.replaceAll("[\\]\\[]", "");
|
||||||
String[] split = configDescIds.split(",");
|
String[] split = configDescIds.split(",");
|
||||||
for (int i = 0; i < split.length; i++) {
|
for (int i = 0; i < split.length; i++) {
|
||||||
String string = split[i];
|
String string = split[i];
|
||||||
String id = string.trim();
|
String id = string.trim();
|
||||||
ILaunchDescriptor desc = descriptors.get(id);
|
ILaunchDescriptor desc = getDescriptorById(id);
|
||||||
if (desc != null) {
|
if (desc != null) {
|
||||||
descriptors.remove(id);
|
descriptors.remove(id);
|
||||||
descriptors.put(id, desc);
|
descriptors.put(id, desc);
|
||||||
|
@ -314,8 +311,8 @@ public class LaunchBarManager extends PlatformObject implements ILaunchBarManage
|
||||||
// new object causes re-set of active descriptor too
|
// new object causes re-set of active descriptor too
|
||||||
setActiveLaunchDescriptor(desc);
|
setActiveLaunchDescriptor(desc);
|
||||||
}
|
}
|
||||||
|
|
||||||
return desc;
|
return desc;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -328,6 +325,11 @@ public class LaunchBarManager extends PlatformObject implements ILaunchBarManage
|
||||||
return remapLaunchObject(element);
|
return remapLaunchObject(element);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ILaunchDescriptor getLaunchDescriptor(Object element) {
|
||||||
|
return objectDescriptorMap.get(element);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ILaunchDescriptor launchObjectChanged(Object element) {
|
public ILaunchDescriptor launchObjectChanged(Object element) {
|
||||||
Activator.trace("launch object changed " + element);
|
Activator.trace("launch object changed " + element);
|
||||||
|
@ -366,20 +368,27 @@ public class LaunchBarManager extends PlatformObject implements ILaunchBarManage
|
||||||
return descs[descs.length - 1];
|
return descs[descs.length - 1];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ILaunchDescriptor[] getOpenLaunchDescriptors() {
|
||||||
|
ArrayList<ILaunchDescriptor> values = new ArrayList<>(descriptors.values());
|
||||||
|
for (Iterator<ILaunchDescriptor> iterator = values.iterator(); iterator.hasNext();) {
|
||||||
|
ILaunchDescriptor d = iterator.next();
|
||||||
|
if (!d.isOpen())
|
||||||
|
iterator.remove();
|
||||||
|
}
|
||||||
|
Collections.reverse(values);
|
||||||
|
return values.toArray(new ILaunchDescriptor[values.size()]);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ILaunchDescriptor[] getLaunchDescriptors() {
|
public ILaunchDescriptor[] getLaunchDescriptors() {
|
||||||
// return descriptor in usage order (most used first). UI can sort them later as it wishes
|
// return descriptor in usage order (most used first). UI can sort them later as it wishes
|
||||||
ILaunchDescriptor[] descs = descriptors.values().toArray(new ILaunchDescriptor[descriptors.size()]);
|
ArrayList<ILaunchDescriptor> values = new ArrayList<>(descriptors.values());
|
||||||
// reverse
|
Collections.reverse(values);
|
||||||
for (int i = 0; i < descs.length / 2; i++) {
|
return values.toArray(new ILaunchDescriptor[values.size()]);
|
||||||
ILaunchDescriptor ld = descs[i];
|
|
||||||
int j = descs.length - 1 - i;
|
|
||||||
descs[i] = descs[j];
|
|
||||||
descs[j] = ld;
|
|
||||||
}
|
|
||||||
return descs;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ILaunchDescriptor getActiveLaunchDescriptor() {
|
public ILaunchDescriptor getActiveLaunchDescriptor() {
|
||||||
return activeLaunchDesc;
|
return activeLaunchDesc;
|
||||||
|
@ -400,7 +409,6 @@ public class LaunchBarManager extends PlatformObject implements ILaunchBarManage
|
||||||
if (configDesc == null)
|
if (configDesc == null)
|
||||||
configDesc = getLastUsedDescriptor(); // do not set to null unless no descriptors
|
configDesc = getLastUsedDescriptor(); // do not set to null unless no descriptors
|
||||||
activeLaunchDesc = configDesc;
|
activeLaunchDesc = configDesc;
|
||||||
|
|
||||||
if (configDesc != null) { // keeps most used descriptor last
|
if (configDesc != null) { // keeps most used descriptor last
|
||||||
descriptors.remove(configDesc.getId());
|
descriptors.remove(configDesc.getId());
|
||||||
descriptors.put(configDesc.getId(), configDesc);
|
descriptors.put(configDesc.getId(), configDesc);
|
||||||
|
@ -409,7 +417,6 @@ public class LaunchBarManager extends PlatformObject implements ILaunchBarManage
|
||||||
setPreference(getPreferenceStore(), PREF_ACTIVE_CONFIG_DESC, getId(activeLaunchDesc));
|
setPreference(getPreferenceStore(), PREF_ACTIVE_CONFIG_DESC, getId(activeLaunchDesc));
|
||||||
Activator.trace("new active config is stored " + configDesc);
|
Activator.trace("new active config is stored " + configDesc);
|
||||||
setPreference(getPreferenceStore(), PREF_CONFIG_DESC_ORDER, descriptors.keySet().toString());
|
setPreference(getPreferenceStore(), PREF_CONFIG_DESC_ORDER, descriptors.keySet().toString());
|
||||||
|
|
||||||
// Send notifications
|
// Send notifications
|
||||||
updateLaunchDescriptor(activeLaunchDesc);
|
updateLaunchDescriptor(activeLaunchDesc);
|
||||||
// Set active target
|
// Set active target
|
||||||
|
@ -426,7 +433,6 @@ public class LaunchBarManager extends PlatformObject implements ILaunchBarManage
|
||||||
// checking active target
|
// checking active target
|
||||||
if (activeLaunchTarget != null && supportsTargetType(activeLaunchDesc, activeLaunchTarget.getType()))
|
if (activeLaunchTarget != null && supportsTargetType(activeLaunchDesc, activeLaunchTarget.getType()))
|
||||||
return; // not changing target
|
return; // not changing target
|
||||||
|
|
||||||
// last stored target from persistent storage
|
// last stored target from persistent storage
|
||||||
String activeTargetId = getPerDescriptorStore().get(PREF_ACTIVE_LAUNCH_TARGET, null);
|
String activeTargetId = getPerDescriptorStore().get(PREF_ACTIVE_LAUNCH_TARGET, null);
|
||||||
ILaunchTarget storedTarget = getLaunchTarget(activeTargetId);
|
ILaunchTarget storedTarget = getLaunchTarget(activeTargetId);
|
||||||
|
@ -744,4 +750,16 @@ public class LaunchBarManager extends PlatformObject implements ILaunchBarManage
|
||||||
public void launchConfigurationChanged(ILaunchConfiguration configuration) {
|
public void launchConfigurationChanged(ILaunchConfiguration configuration) {
|
||||||
// Nothing to do on changes
|
// Nothing to do on changes
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void dispose() {
|
||||||
|
ILaunchManager launchManager = getLaunchManager();
|
||||||
|
launchManager.removeLaunchConfigurationListener(this);
|
||||||
|
for (ILaunchObjectProvider o : objectProviders) {
|
||||||
|
try {
|
||||||
|
o.dispose();
|
||||||
|
} catch (Exception e) {
|
||||||
|
Activator.log(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,14 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* 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 - Initial API and implementation
|
||||||
|
* Alena Laskavaia
|
||||||
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.launchbar.core.internal;
|
package org.eclipse.cdt.launchbar.core.internal;
|
||||||
|
|
||||||
import org.eclipse.cdt.launchbar.core.ILaunchBarManager;
|
import org.eclipse.cdt.launchbar.core.ILaunchBarManager;
|
||||||
|
@ -14,13 +25,11 @@ import org.eclipse.core.resources.ResourcesPlugin;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
|
||||||
public class ProjectLaunchObjectProvider implements ILaunchObjectProvider, IResourceChangeListener {
|
public class ProjectLaunchObjectProvider implements ILaunchObjectProvider, IResourceChangeListener {
|
||||||
|
|
||||||
private ILaunchBarManager manager;
|
private ILaunchBarManager manager;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void init(ILaunchBarManager manager) {
|
public void init(ILaunchBarManager manager) {
|
||||||
this.manager = manager;
|
this.manager = manager;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
for (IProject project : ResourcesPlugin.getWorkspace().getRoot().getProjects()) {
|
for (IProject project : ResourcesPlugin.getWorkspace().getRoot().getProjects()) {
|
||||||
manager.launchObjectAdded(project);
|
manager.launchObjectAdded(project);
|
||||||
|
@ -28,7 +37,6 @@ public class ProjectLaunchObjectProvider implements ILaunchObjectProvider, IReso
|
||||||
} catch (CoreException e) {
|
} catch (CoreException e) {
|
||||||
Activator.log(e.getStatus());
|
Activator.log(e.getStatus());
|
||||||
}
|
}
|
||||||
|
|
||||||
ResourcesPlugin.getWorkspace().addResourceChangeListener(this, IResourceChangeEvent.POST_CHANGE);
|
ResourcesPlugin.getWorkspace().addResourceChangeListener(this, IResourceChangeEvent.POST_CHANGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,12 +53,14 @@ public class ProjectLaunchObjectProvider implements ILaunchObjectProvider, IReso
|
||||||
public boolean visit(IResourceDelta delta) throws CoreException {
|
public boolean visit(IResourceDelta delta) throws CoreException {
|
||||||
IResource res = delta.getResource();
|
IResource res = delta.getResource();
|
||||||
if (res instanceof IProject) {
|
if (res instanceof IProject) {
|
||||||
IProject project = (IProject) delta.getResource();
|
IProject project = (IProject) res;
|
||||||
int kind = delta.getKind();
|
int kind = delta.getKind();
|
||||||
if ((kind & IResourceDelta.ADDED) != 0) {
|
if ((kind & IResourceDelta.ADDED) != 0) {
|
||||||
manager.launchObjectAdded(project);
|
manager.launchObjectAdded(project);
|
||||||
} else if ((kind & IResourceDelta.REMOVED) != 0) {
|
} else if ((kind & IResourceDelta.REMOVED) != 0) {
|
||||||
manager.launchObjectRemoved(project);
|
manager.launchObjectRemoved(project);
|
||||||
|
} else if ((kind & IResourceDelta.CHANGED) != 0) {
|
||||||
|
manager.launchObjectChanged(project);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
} else if (res instanceof IFile || res instanceof IFolder) {
|
} else if (res instanceof IFile || res instanceof IFolder) {
|
||||||
|
@ -63,5 +73,4 @@ public class ProjectLaunchObjectProvider implements ILaunchObjectProvider, IReso
|
||||||
Activator.log(e.getStatus());
|
Activator.log(e.getStatus());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -82,8 +82,7 @@ public class ConfigSelector extends CSelector {
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public Object[] getElements(Object inputElement) {
|
public Object[] getElements(Object inputElement) {
|
||||||
try {
|
ILaunchDescriptor[] descs = getManager().getOpenLaunchDescriptors();
|
||||||
ILaunchDescriptor[] descs = getManager().getLaunchDescriptors();
|
|
||||||
if (descs.length > 0) {
|
if (descs.length > 0) {
|
||||||
if (descs.length > SEPARATOR_INDEX + 1) {
|
if (descs.length > SEPARATOR_INDEX + 1) {
|
||||||
ILaunchDescriptor[] descsCopy = new ILaunchDescriptor[SEPARATOR_INDEX + descs.length];
|
ILaunchDescriptor[] descsCopy = new ILaunchDescriptor[SEPARATOR_INDEX + descs.length];
|
||||||
|
@ -100,9 +99,6 @@ public class ConfigSelector extends CSelector {
|
||||||
} else
|
} else
|
||||||
return descs;
|
return descs;
|
||||||
}
|
}
|
||||||
} catch (CoreException e) {
|
|
||||||
Activator.log(e.getStatus());
|
|
||||||
}
|
|
||||||
return noConfigs;
|
return noConfigs;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Reference in a new issue