blob: 727985240764b2e2c0975785dc401f69eea4cf76 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
/*******************************************************************************
* Copyright (c) 2006, 2008 Intel Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Intel Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.ui.actions;
import java.util.HashSet;
import java.util.Iterator;
import org.eclipse.core.resources.IProject;
import org.eclipse.jface.action.Action;
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
import org.eclipse.cdt.core.settings.model.ICProjectDescription;
import org.eclipse.cdt.ui.newui.AbstractPage;
import org.eclipse.cdt.ui.newui.CDTPropertyManager;
/**
* Action which changes active build configuration of the current project to
* the given one.
*/
public class ChangeConfigAction extends Action {
private String fConfigName = null;
protected HashSet<IProject> fProjects = null;
/**
* Constructs the action.
* @param projects List of selected managed-built projects
* @param configName Build configuration name
* @param accel Number to be used as accelerator
*/
public ChangeConfigAction(HashSet<IProject> projects, String configName, String displayName, int accel) {
super("&" + accel + " " + displayName); //$NON-NLS-1$ //$NON-NLS-2$
fProjects = projects;
fConfigName = configName;
}
/**
* @see org.eclipse.jface.action.IAction#run()
*/
@Override
public void run() {
Iterator<IProject> iter = fProjects.iterator();
while (iter.hasNext()) {
IProject prj = iter.next();
ICProjectDescription prjd = CDTPropertyManager.getProjectDescription(prj);
boolean changed = false;
ICConfigurationDescription[] configs = prjd.getConfigurations();
if (configs != null && configs.length > 0) {
for (ICConfigurationDescription config : configs) {
if (config.getName().equals(fConfigName)) {
config.setActive();
CDTPropertyManager.performOk(null);
AbstractPage.updateViews(prj);
changed = true;
break;
}
}
}
if (!changed)
CDTPropertyManager.performCancel(null);
}
}
}
|