mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-25 09:55:29 +02:00
Bug#182450
This commit is contained in:
parent
0a66354f66
commit
f6e9360d5d
3 changed files with 138 additions and 20 deletions
|
@ -11,6 +11,7 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.cdt.managedbuilder.ui.properties;
|
||||
|
||||
import org.eclipse.cdt.core.settings.model.ICMultiItemsHolder;
|
||||
import org.eclipse.cdt.core.settings.model.ICResourceDescription;
|
||||
import org.eclipse.cdt.managedbuilder.core.IBuilder;
|
||||
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
|
||||
|
@ -20,6 +21,7 @@ import org.eclipse.cdt.managedbuilder.internal.core.Configuration;
|
|||
import org.eclipse.cdt.newmake.core.IMakeBuilderInfo;
|
||||
import org.eclipse.cdt.ui.CUIPlugin;
|
||||
import org.eclipse.cdt.ui.newui.AbstractCPropertyTab;
|
||||
import org.eclipse.cdt.ui.newui.ICPropertyProvider;
|
||||
import org.eclipse.cdt.ui.newui.TriButton;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.swt.SWT;
|
||||
|
@ -42,6 +44,8 @@ import org.eclipse.swt.widgets.Text;
|
|||
import org.eclipse.swt.widgets.Widget;
|
||||
|
||||
public class BuildBehaviourTab extends AbstractCBuildPropertyTab {
|
||||
|
||||
private static int TRI_STATES_SIZE = 4;
|
||||
// Widgets
|
||||
//3
|
||||
private TriButton b_stopOnError;
|
||||
|
@ -170,18 +174,87 @@ public class BuildBehaviourTab extends AbstractCBuildPropertyTab {
|
|||
t_cmdClean.getAccessible().addAccessibleListener(makeTargetLabelAccessibleListener);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return:
|
||||
* Mode 0:
|
||||
* 0: bld.isManagedBuildOn()
|
||||
* 1: bld.isDefaultBuildCmd()
|
||||
* 2: bld.canKeepEnvironmentVariablesInBuildfile()
|
||||
* 3: bld.keepEnvironmentVariablesInBuildfile()
|
||||
* Mode 1:
|
||||
* 0: isStopOnError
|
||||
* 1: supportsStopOnError(true)
|
||||
* 2: bld.supportsStopOnError(false)
|
||||
* 3: cfg.getInternalBuilderParallel()
|
||||
*/
|
||||
static int[] calc3states(ICPropertyProvider p,
|
||||
TriButton b3,
|
||||
IConfiguration c,
|
||||
boolean p0) {
|
||||
if (p.isMultiCfg() &&
|
||||
b3.in3mode() &&
|
||||
c instanceof ICMultiItemsHolder)
|
||||
{
|
||||
IConfiguration[] cfs = (IConfiguration[])((ICMultiItemsHolder)c).getItems();
|
||||
IBuilder b = cfs[0].getEditableBuilder();
|
||||
int[] res = new int[TRI_STATES_SIZE];
|
||||
boolean[] x = new boolean[TRI_STATES_SIZE];
|
||||
x[0] = (p0) ? b.isManagedBuildOn() : b.isStopOnError();
|
||||
x[1] = (p0) ? b.isDefaultBuildCmd(): b.supportsStopOnError(true);
|
||||
x[2] = (p0) ? b.canKeepEnvironmentVariablesInBuildfile() :
|
||||
b.supportsStopOnError(false);
|
||||
x[3] = (p0) ? b.keepEnvironmentVariablesInBuildfile() :
|
||||
((Configuration)cfs[0]).getInternalBuilderParallel();
|
||||
for (int i=1; i<cfs.length; i++) {
|
||||
b = cfs[i].getEditableBuilder();
|
||||
if (res[0] != TriButton.UNKNOWN &&
|
||||
x[0] != (p0) ? b.isManagedBuildOn() : b.isStopOnError())
|
||||
res[0] = TriButton.UNKNOWN;
|
||||
if (res[1] != TriButton.UNKNOWN &&
|
||||
x[1] != (p0) ? b.isDefaultBuildCmd() : b.supportsStopOnError(true))
|
||||
res[1] = TriButton.UNKNOWN;
|
||||
if (res[2] != TriButton.UNKNOWN &&
|
||||
x[2] != (p0) ? b.canKeepEnvironmentVariablesInBuildfile() : b.supportsStopOnError(false))
|
||||
res[2] = TriButton.UNKNOWN;
|
||||
if (res[3] != TriButton.UNKNOWN &&
|
||||
x[3] != (p0) ? b.keepEnvironmentVariablesInBuildfile() : ((Configuration)cfs[i]).getInternalBuilderParallel())
|
||||
res[3] = TriButton.UNKNOWN;
|
||||
}
|
||||
for (int i=0; i<TRI_STATES_SIZE; i++) {
|
||||
if (res[i] != TriButton.UNKNOWN)
|
||||
res[i] = x[i] ? TriButton.YES : TriButton.NO;
|
||||
}
|
||||
return res;
|
||||
} else
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* sets widgets states
|
||||
*/
|
||||
protected void updateButtons() {
|
||||
bldr = icfg.getEditableBuilder();
|
||||
|
||||
b_stopOnError.setSelection(bldr.isStopOnError());
|
||||
b_stopOnError.setEnabled(
|
||||
bldr.supportsStopOnError(true) &&
|
||||
bldr.supportsStopOnError(false));
|
||||
int[] extStates = calc3states(page, b_stopOnError, icfg, false);
|
||||
|
||||
if (extStates != null) {
|
||||
b_stopOnError.setTriSelection(extStates[0]);
|
||||
b_stopOnError.setEnabled(
|
||||
extStates[1] == TriButton.YES &&
|
||||
extStates[2] == TriButton.YES);
|
||||
} else {
|
||||
b_stopOnError.setSelection(bldr.isStopOnError());
|
||||
b_stopOnError.setEnabled(
|
||||
bldr.supportsStopOnError(true) &&
|
||||
bldr.supportsStopOnError(false));
|
||||
}
|
||||
// parallel
|
||||
b_parallel.setSelection(getInternalBuilderParallel());
|
||||
if (extStates == null) // no extended states
|
||||
b_parallel.setSelection(getInternalBuilderParallel());
|
||||
else
|
||||
b_parallel.setTriSelection(extStates[3]);
|
||||
|
||||
b_parallelOpt.setSelection(getParallelDef());
|
||||
b_parallelNum.setSelection(!getParallelDef());
|
||||
int n = getParallelNumber();
|
||||
|
|
|
@ -127,23 +127,34 @@ public class BuilderSettingsTab extends AbstractCBuildPropertyTab {
|
|||
protected void updateButtons() {
|
||||
bldr = icfg.getEditableBuilder();
|
||||
|
||||
b_genMakefileAuto.setEnabled(icfg.supportsBuild(true));
|
||||
b_genMakefileAuto.setSelection(bldr.isManagedBuildOn());
|
||||
b_useDefault.setSelection(bldr.isDefaultBuildCmd());
|
||||
int[] extStates = BuildBehaviourTab.calc3states(page, b_useDefault, icfg, true);
|
||||
|
||||
b_genMakefileAuto.setEnabled(icfg.supportsBuild(true));
|
||||
if (extStates == null) { // no extended states available
|
||||
b_genMakefileAuto.setSelection(bldr.isManagedBuildOn());
|
||||
b_useDefault.setSelection(bldr.isDefaultBuildCmd());
|
||||
if(!bldr.canKeepEnvironmentVariablesInBuildfile())
|
||||
b_expandVars.setEnabled(false);
|
||||
else {
|
||||
b_expandVars.setEnabled(true);
|
||||
b_expandVars.setSelection(!bldr.keepEnvironmentVariablesInBuildfile());
|
||||
}
|
||||
} else {
|
||||
b_genMakefileAuto.setTriSelection(extStates[0]);
|
||||
b_useDefault.setTriSelection(extStates[1]);
|
||||
if(extStates[2] != TriButton.YES)
|
||||
b_expandVars.setEnabled(false);
|
||||
else {
|
||||
b_expandVars.setEnabled(true);
|
||||
b_expandVars.setTriSelection(extStates[3]);
|
||||
}
|
||||
}
|
||||
c_builderType.select(isInternalBuilderEnabled() ? 1 : 0);
|
||||
c_builderType.setEnabled(
|
||||
canEnableInternalBuilder(true) &&
|
||||
canEnableInternalBuilder(false));
|
||||
|
||||
t_buildCmd.setText(getMC());
|
||||
|
||||
if(!bldr.canKeepEnvironmentVariablesInBuildfile())
|
||||
b_expandVars.setEnabled(false);
|
||||
else {
|
||||
b_expandVars.setEnabled(true);
|
||||
b_expandVars.setSelection(!bldr.keepEnvironmentVariablesInBuildfile());
|
||||
}
|
||||
|
||||
if (page.isMultiCfg()) {
|
||||
group_dir.setVisible(false);
|
||||
|
@ -370,10 +381,33 @@ public class BuilderSettingsTab extends AbstractCBuildPropertyTab {
|
|||
}
|
||||
|
||||
private void setUseDefaultBuildCmd(boolean val) {
|
||||
|
||||
try {
|
||||
if (icfg instanceof IMultiConfiguration) {
|
||||
IConfiguration[] cfs = (IConfiguration[])((IMultiConfiguration)icfg).getItems();
|
||||
for (int i=0; i<cfs.length; i++) {
|
||||
IBuilder b = cfs[i].getEditableBuilder();
|
||||
if (b != null)
|
||||
b.setUseDefaultBuildCmd(val);
|
||||
}
|
||||
} else {
|
||||
icfg.getEditableBuilder().setUseDefaultBuildCmd(val);
|
||||
}
|
||||
} catch (CoreException e) {
|
||||
CUIPlugin.getDefault().log(e);
|
||||
}
|
||||
}
|
||||
|
||||
private void setKeepEnvironmentVariablesInBuildfile(boolean val) {
|
||||
|
||||
if (icfg instanceof IMultiConfiguration) {
|
||||
IConfiguration[] cfs = (IConfiguration[])((IMultiConfiguration)icfg).getItems();
|
||||
for (int i=0; i<cfs.length; i++) {
|
||||
IBuilder b = cfs[i].getEditableBuilder();
|
||||
if (b != null)
|
||||
b.setKeepEnvironmentVariablesInBuildfile(val);
|
||||
}
|
||||
} else {
|
||||
icfg.getEditableBuilder().setKeepEnvironmentVariablesInBuildfile(val);
|
||||
}
|
||||
}
|
||||
|
||||
private void setCommand(String buildCommand) {
|
||||
|
|
|
@ -29,8 +29,9 @@ import org.eclipse.swt.widgets.Event;
|
|||
import org.eclipse.swt.widgets.Label;
|
||||
|
||||
public class TriButton extends Composite implements SelectionListener {
|
||||
private static final String[] ITEMS = {"No", "Yes", "?"}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
||||
|
||||
private static final String[] ITEMS = {"No", "Yes"}; //$NON-NLS-1$ //$NON-NLS-2$
|
||||
private static final String QMARK = "?"; //$NON-NLS-1$
|
||||
|
||||
public static final int NO = 0;
|
||||
public static final int YES = 1;
|
||||
public static final int UNKNOWN = 2;
|
||||
|
@ -104,7 +105,13 @@ public class TriButton extends Composite implements SelectionListener {
|
|||
selection != YES &&
|
||||
selection != UNKNOWN)
|
||||
selection = NO;
|
||||
if (triMode) combo.select(selection);
|
||||
if (triMode) {
|
||||
if (selection == UNKNOWN) {
|
||||
combo.setText(QMARK);
|
||||
combo.select(-1);
|
||||
} else
|
||||
combo.select(selection);
|
||||
}
|
||||
else button.setSelection(selection == 1);
|
||||
}
|
||||
|
||||
|
@ -172,4 +179,8 @@ public class TriButton extends Composite implements SelectionListener {
|
|||
SelectionEvent se = new SelectionEvent(e);
|
||||
widgetSelected(se);
|
||||
}
|
||||
|
||||
public boolean in3mode() {
|
||||
return triMode;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue