mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-30 04:15:35 +02:00
Bug 307496: Add make target offered too often.
This commit is contained in:
parent
1ea8996371
commit
d0592246c4
1 changed files with 21 additions and 16 deletions
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2000, 2007 QNX Software Systems and others.
|
* Copyright (c) 2000, 2010 QNX Software Systems and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -7,6 +7,7 @@
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* QNX Software Systems - Initial API and implementation
|
* QNX Software Systems - Initial API and implementation
|
||||||
|
* Markus Schorn (Wind River Systems)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.make.internal.ui.editor;
|
package org.eclipse.cdt.make.internal.ui.editor;
|
||||||
|
|
||||||
|
@ -48,6 +49,7 @@ public class AddBuildTargetAction extends Action {
|
||||||
*
|
*
|
||||||
* @see org.eclipse.jface.action.IAction#run()
|
* @see org.eclipse.jface.action.IAction#run()
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
IMakeTargetManager manager = MakeCorePlugin.getDefault().getTargetManager();
|
IMakeTargetManager manager = MakeCorePlugin.getDefault().getTargetManager();
|
||||||
IFile file = getFile();
|
IFile file = getFile();
|
||||||
|
@ -56,8 +58,8 @@ public class AddBuildTargetAction extends Action {
|
||||||
if (file != null && rules.length > 0 && shell != null) {
|
if (file != null && rules.length > 0 && shell != null) {
|
||||||
StringBuffer sbBuildName = new StringBuffer();
|
StringBuffer sbBuildName = new StringBuffer();
|
||||||
StringBuffer sbMakefileTarget = new StringBuffer();
|
StringBuffer sbMakefileTarget = new StringBuffer();
|
||||||
for (int i = 0; i < rules.length; i++) {
|
for (ITargetRule rule : rules) {
|
||||||
String name = rules[i].getTarget().toString().trim();
|
String name = rule.getTarget().toString().trim();
|
||||||
if (sbBuildName.length() == 0) {
|
if (sbBuildName.length() == 0) {
|
||||||
sbBuildName.append(name);
|
sbBuildName.append(name);
|
||||||
} else {
|
} else {
|
||||||
|
@ -113,13 +115,16 @@ public class AddBuildTargetAction extends Action {
|
||||||
|
|
||||||
public boolean canActionBeAdded(ISelection selection) {
|
public boolean canActionBeAdded(ISelection selection) {
|
||||||
ITargetRule[] rules = getTargetRules(selection);
|
ITargetRule[] rules = getTargetRules(selection);
|
||||||
for (int i = 0; i < rules.length; i++) {
|
if (rules.length == 0)
|
||||||
IFile file = getFile();
|
return false;
|
||||||
if (file == null)
|
|
||||||
return false;
|
IFile file = getFile();
|
||||||
if (!MakeCorePlugin.getDefault().getTargetManager().hasTargetBuilder(file.getProject()))
|
if (file == null)
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
|
if (!MakeCorePlugin.getDefault().getTargetManager().hasTargetBuilder(file.getProject()))
|
||||||
|
return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -133,16 +138,16 @@ public class AddBuildTargetAction extends Action {
|
||||||
|
|
||||||
private ITargetRule[] getTargetRules(ISelection sel) {
|
private ITargetRule[] getTargetRules(ISelection sel) {
|
||||||
if (!sel.isEmpty() && sel instanceof IStructuredSelection) {
|
if (!sel.isEmpty() && sel instanceof IStructuredSelection) {
|
||||||
List list = ((IStructuredSelection)sel).toList();
|
List<?> list = ((IStructuredSelection)sel).toList();
|
||||||
if (list.size() > 0) {
|
if (list.size() > 0) {
|
||||||
List targets = new ArrayList(list.size());
|
List<ITargetRule> targets = new ArrayList<ITargetRule>(list.size());
|
||||||
Object[] elements = list.toArray();
|
Object[] elements = list.toArray();
|
||||||
for (int i = 0; i < elements.length; i++) {
|
for (Object element : elements) {
|
||||||
if (elements[i] instanceof ITargetRule) {
|
if (element instanceof ITargetRule) {
|
||||||
targets.add(elements[i]);
|
targets.add((ITargetRule) element);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return (ITargetRule[])targets.toArray(EMPTY_TARGET_RULES);
|
return targets.toArray(EMPTY_TARGET_RULES);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return EMPTY_TARGET_RULES;
|
return EMPTY_TARGET_RULES;
|
||||||
|
|
Loading…
Add table
Reference in a new issue