mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-23 14:42:11 +02:00
Toolchain modification page:
- "no toolchain" handling added - conditional page display (if permitted in prefs)
This commit is contained in:
parent
038a5598b4
commit
1b5b9915d0
8 changed files with 80 additions and 31 deletions
|
@ -596,6 +596,8 @@
|
|||
value="org.eclipse.cdt.managedbuilder.core.managedBuildNature">
|
||||
</filter>
|
||||
<enabledWhen>
|
||||
<and>
|
||||
<test property="org.eclipse.cdt.ui.toolEditEnabled" value="" />
|
||||
<or>
|
||||
<instanceof value="org.eclipse.core.resources.IProject"/>
|
||||
<instanceof value="org.eclipse.cdt.core.model.ICProject"/>
|
||||
|
@ -612,6 +614,7 @@
|
|||
<test property="org.eclipse.cdt.ui.isSource" value="" />
|
||||
</and>
|
||||
</or>
|
||||
</and>
|
||||
</enabledWhen>
|
||||
</page>
|
||||
</extension>
|
||||
|
|
|
@ -31,6 +31,8 @@ import org.eclipse.swt.widgets.Group;
|
|||
import org.eclipse.swt.widgets.Text;
|
||||
|
||||
public class ToolChainEditTab extends AbstractCBuildPropertyTab {
|
||||
|
||||
private static final String NO_TC = Messages.getString("StdProjectTypeHandler.0"); //$NON-NLS-1$
|
||||
private static final IToolChain[] r_tcs = ManagedBuildManager.getRealToolChains();
|
||||
private static final IBuilder[] r_bs = ManagedBuildManager.getRealBuilders();
|
||||
private static final ITool[] r_tools = ManagedBuildManager.getRealTools();
|
||||
|
@ -39,6 +41,7 @@ public class ToolChainEditTab extends AbstractCBuildPropertyTab {
|
|||
private Button b_dispCompatible;
|
||||
private Combo c_toolchain;
|
||||
private Combo c_builder;
|
||||
private Button button_edit;
|
||||
|
||||
private IBuilder[] v_bs;
|
||||
private IToolChain[] v_tcs;
|
||||
|
@ -51,10 +54,8 @@ public class ToolChainEditTab extends AbstractCBuildPropertyTab {
|
|||
public void createControls(Composite parent) {
|
||||
super.createControls(parent);
|
||||
usercomp.setLayout(new GridLayout(2, false));
|
||||
|
||||
b_dispCompatible = setupCheck(usercomp, Messages.getString("ToolChainEditTab.0"), 2, GridData.BEGINNING); //$NON-NLS-1$
|
||||
|
||||
|
||||
setupLabel(usercomp, Messages.getString("ToolChainEditTab.1"), 2, GridData.BEGINNING); //$NON-NLS-1$
|
||||
c_toolchain = new Combo(usercomp, SWT.BORDER);
|
||||
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
|
||||
|
@ -64,10 +65,14 @@ public class ToolChainEditTab extends AbstractCBuildPropertyTab {
|
|||
public void widgetSelected(SelectionEvent e) {
|
||||
if (fi != null) {
|
||||
int x = c_toolchain.getSelectionIndex();
|
||||
try {
|
||||
if (NO_TC.equals(c_toolchain.getItem(x))) {
|
||||
fi.changeToolChain(null, null, null);
|
||||
} else {
|
||||
IToolChain tc = v_tcs[x];
|
||||
if (tc == null) return;
|
||||
try {
|
||||
fi.changeToolChain(tc, ManagedBuildManager.calculateChildId(tc.getId(), null), tc.getUniqueRealName());
|
||||
}
|
||||
} catch (BuildException be) {}
|
||||
updateData();
|
||||
}
|
||||
|
@ -97,13 +102,13 @@ public class ToolChainEditTab extends AbstractCBuildPropertyTab {
|
|||
gd.grabExcessHorizontalSpace = true;
|
||||
text.setLayoutData(gd);
|
||||
|
||||
Button b = new Button(g, SWT.PUSH);
|
||||
button_edit = new Button(g, SWT.PUSH);
|
||||
GridData gdb = new GridData(GridData.VERTICAL_ALIGN_CENTER);
|
||||
gdb.grabExcessHorizontalSpace = false;
|
||||
gdb.horizontalAlignment = SWT.FILL;
|
||||
gdb.widthHint = 80;
|
||||
b.setLayoutData(gdb);
|
||||
b.addSelectionListener(new SelectionAdapter() {
|
||||
button_edit.setLayoutData(gdb);
|
||||
button_edit.addSelectionListener(new SelectionAdapter() {
|
||||
public void widgetSelected(SelectionEvent event) {
|
||||
ToolSelectionDialog d = new ToolSelectionDialog(usercomp.getShell());
|
||||
d.all = v_tools;
|
||||
|
@ -119,8 +124,8 @@ public class ToolChainEditTab extends AbstractCBuildPropertyTab {
|
|||
}
|
||||
}});
|
||||
|
||||
b.setLayoutData(new GridData(GridData.END));
|
||||
b.setText(Messages.getString("ToolChainEditTab.4")); //$NON-NLS-1$
|
||||
button_edit.setLayoutData(new GridData(GridData.END));
|
||||
button_edit.setText(Messages.getString("ToolChainEditTab.4")); //$NON-NLS-1$
|
||||
}
|
||||
public void updateData(ICResourceDescription rcfg) {
|
||||
cfg = getCfg(rcfg.getConfiguration());
|
||||
|
@ -137,9 +142,8 @@ public class ToolChainEditTab extends AbstractCBuildPropertyTab {
|
|||
v_tools = new ITool[r_tools.length];
|
||||
|
||||
IToolChain tc = null;
|
||||
if (fi != null) {
|
||||
if (fi != null)
|
||||
tc = ManagedBuildManager.getRealToolChain(fi.getToolChain());
|
||||
}
|
||||
|
||||
int cnt = 0;
|
||||
int pos = -1;
|
||||
|
@ -154,10 +158,26 @@ public class ToolChainEditTab extends AbstractCBuildPropertyTab {
|
|||
if (r_tcs[i].equals(tc)) pos = cnt;
|
||||
cnt++;
|
||||
}
|
||||
if (pos != -1)
|
||||
// "No toolchain" is enabled for Make projects only.
|
||||
if (!cfg.getBuilder().isManagedBuildOn())
|
||||
c_toolchain.add(NO_TC);
|
||||
if (pos != -1) {
|
||||
c_toolchain.select(pos);
|
||||
else
|
||||
c_toolchain.setText(EMPTY_STR);
|
||||
c_builder.setEnabled(true);
|
||||
button_edit.setEnabled(true);
|
||||
}
|
||||
else {
|
||||
if (cfg.getBuilder().isManagedBuildOn()) {
|
||||
c_toolchain.setText(EMPTY_STR); // unprobable case
|
||||
} else {
|
||||
try {
|
||||
fi.changeToolChain(null, null, null);
|
||||
} catch (BuildException e) {}
|
||||
c_toolchain.select(c_toolchain.getItemCount() - 1);
|
||||
}
|
||||
c_builder.setEnabled(false);
|
||||
button_edit.setEnabled(false);
|
||||
}
|
||||
|
||||
IBuilder b = ManagedBuildManager.getRealBuilder(cfg.getBuilder());
|
||||
cnt = 0;
|
||||
|
|
|
@ -1914,14 +1914,26 @@
|
|||
id="org.eclipse.cdt.Tester1"
|
||||
class="org.eclipse.cdt.ui.newui.PropertyTester"
|
||||
namespace="org.eclipse.cdt.ui"
|
||||
properties="isSource"
|
||||
properties="isSource,toolEditEnabled"
|
||||
type="org.eclipse.cdt.core.model.ITranslationUnit"/>
|
||||
<propertyTester
|
||||
id="org.eclipse.cdt.Tester2"
|
||||
class="org.eclipse.cdt.ui.newui.PropertyTester"
|
||||
namespace="org.eclipse.cdt.ui"
|
||||
properties="isSource"
|
||||
properties="isSource,toolEditEnabled"
|
||||
type="org.eclipse.core.resources.IFile"/>
|
||||
<propertyTester
|
||||
id="org.eclipse.cdt.Tester3"
|
||||
class="org.eclipse.cdt.ui.newui.PropertyTester"
|
||||
namespace="org.eclipse.cdt.ui"
|
||||
properties="toolEditEnabled"
|
||||
type="org.eclipse.cdt.core.model.IResource"/>
|
||||
<propertyTester
|
||||
id="org.eclipse.cdt.Tester4"
|
||||
class="org.eclipse.cdt.ui.newui.PropertyTester"
|
||||
namespace="org.eclipse.cdt.ui"
|
||||
properties="toolEditEnabled"
|
||||
type="org.eclipse.cdt.core.model.ICElement"/>
|
||||
</extension>
|
||||
<extension
|
||||
point="org.eclipse.ui.exportWizards">
|
||||
|
|
|
@ -199,7 +199,8 @@ implements
|
|||
if (!checkElement()) {
|
||||
s = UIMessages.getString("AbstractPage.0"); //$NON-NLS-1$
|
||||
} else if (!isApplicable()) {
|
||||
s = UIMessages.getString("AbstractPage.1"); //$NON-NLS-1$
|
||||
return null;
|
||||
// s = UIMessages.getString("AbstractPage.1"); //$NON-NLS-1$
|
||||
} else if (!isCDTProject(getProject())) {
|
||||
s = UIMessages.getString("AbstractPage.2"); //$NON-NLS-1$
|
||||
}
|
||||
|
|
|
@ -26,6 +26,7 @@ public class CDTPrefUtil {
|
|||
public static final String KEY_MULTI = "properties.multi.config.enable"; //$NON-NLS-1$
|
||||
public static final String KEY_DTREE = "properties.data.hierarchy.enable"; //$NON-NLS-1$
|
||||
public static final String KEY_NOSAVE = "properties.save.position.disable"; //$NON-NLS-1$
|
||||
public static final String KEY_TOOLM = "properties.toolchain.modification.enable"; //$NON-NLS-1$
|
||||
// string keys
|
||||
public static final String KEY_PREFTC = "wizard.preferred.toolchains"; //$NON-NLS-1$
|
||||
|
||||
|
|
|
@ -340,6 +340,7 @@ PropertyPageDefsTab.0=Show <Manage configurations> button
|
|||
PropertyPageDefsTab.1=Display <Data hierarchy> tab
|
||||
PropertyPageDefsTab.2=Enable multiple configurations setting
|
||||
PropertyPageDefsTab.3=Save property dialog size and position
|
||||
PropertyPageDefsTab.4=Display <Toolchain modification> tab
|
||||
ProjectConvert.convertersList=Converters List
|
||||
|
||||
ScannerConfigOptionsDialog.title=Discovery Options
|
||||
|
|
|
@ -24,6 +24,7 @@ public class PropertyPageDefsTab extends AbstractCPropertyTab {
|
|||
private Button show_mul;
|
||||
private Button show_mng;
|
||||
private Button show_sav;
|
||||
private Button show_tool;
|
||||
|
||||
public void createControls(Composite parent) {
|
||||
super.createControls(parent);
|
||||
|
@ -45,12 +46,17 @@ public class PropertyPageDefsTab extends AbstractCPropertyTab {
|
|||
show_sav.setText(UIMessages.getString("PropertyPageDefsTab.3")); //$NON-NLS-1$
|
||||
show_sav.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
|
||||
|
||||
show_tool = new Button(usercomp, SWT.CHECK);
|
||||
show_tool.setText(UIMessages.getString("PropertyPageDefsTab.4")); //$NON-NLS-1$
|
||||
show_tool.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
|
||||
|
||||
show_tree.setSelection(CDTPrefUtil.getBool(CDTPrefUtil.KEY_DTREE));
|
||||
show_mul.setSelection(CDTPrefUtil.getBool(CDTPrefUtil.KEY_MULTI));
|
||||
show_mng.setSelection(!CDTPrefUtil.getBool(CDTPrefUtil.KEY_NOMNG));
|
||||
show_sav.setSelection(!CDTPrefUtil.getBool(CDTPrefUtil.KEY_NOSAVE));
|
||||
show_tool.setSelection(CDTPrefUtil.getBool(CDTPrefUtil.KEY_TOOLM));
|
||||
|
||||
show_mul.setEnabled(false);
|
||||
show_mul.setVisible(false); // temporary
|
||||
}
|
||||
|
||||
protected void performOK() {
|
||||
|
@ -58,12 +64,14 @@ public class PropertyPageDefsTab extends AbstractCPropertyTab {
|
|||
CDTPrefUtil.setBool(CDTPrefUtil.KEY_MULTI, show_mul.getSelection());
|
||||
CDTPrefUtil.setBool(CDTPrefUtil.KEY_NOMNG, !show_mng.getSelection());
|
||||
CDTPrefUtil.setBool(CDTPrefUtil.KEY_NOSAVE, !show_sav.getSelection());
|
||||
CDTPrefUtil.setBool(CDTPrefUtil.KEY_TOOLM, show_tool.getSelection());
|
||||
}
|
||||
protected void performDefaults() {
|
||||
show_tree.setSelection(false);
|
||||
show_mul.setSelection(false);
|
||||
show_mng.setSelection(true);
|
||||
show_mng.setSelection(true);
|
||||
show_tool.setSelection(false);
|
||||
}
|
||||
|
||||
protected void performApply(ICResourceDescription src, ICResourceDescription dst) { performOK(); }
|
||||
|
|
|
@ -19,12 +19,12 @@ import org.eclipse.cdt.core.model.ITranslationUnit;
|
|||
* Checks whether given object is a source file.
|
||||
*/
|
||||
public class PropertyTester extends org.eclipse.core.expressions.PropertyTester {
|
||||
private static final String KEY = "isSource"; //$NON-NLS-1$
|
||||
private static final String KEY_SRC = "isSource"; //$NON-NLS-1$
|
||||
private static final String KEY_TOOL = "toolEditEnabled"; //$NON-NLS-1$
|
||||
|
||||
public boolean test(Object receiver, String property, Object[] args,
|
||||
Object expectedValue) {
|
||||
if (!KEY.equals(property)) return false;
|
||||
|
||||
if (KEY_SRC.equals(property)) {
|
||||
if (receiver instanceof ITranslationUnit) {
|
||||
return ((ITranslationUnit)receiver).isSourceUnit();
|
||||
}
|
||||
|
@ -32,7 +32,10 @@ public class PropertyTester extends org.eclipse.core.expressions.PropertyTester
|
|||
IFile file = (IFile)receiver;
|
||||
return CoreModel.isValidSourceUnitName(file.getProject(), file.getName());
|
||||
}
|
||||
else return false;
|
||||
} else if (KEY_TOOL.equals(property)) {
|
||||
return CDTPrefUtil.getBool(CDTPrefUtil.KEY_TOOLM);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue