mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-29 11:55:40 +02:00
ToolChain edit: added functionality for files
This commit is contained in:
parent
a25388f72b
commit
b9d5c2f110
3 changed files with 147 additions and 70 deletions
|
@ -10,10 +10,14 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.managedbuilder.ui.properties;
|
package org.eclipse.cdt.managedbuilder.ui.properties;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.settings.model.ICResourceDescription;
|
import org.eclipse.cdt.core.settings.model.ICResourceDescription;
|
||||||
import org.eclipse.cdt.managedbuilder.core.BuildException;
|
import org.eclipse.cdt.managedbuilder.core.BuildException;
|
||||||
import org.eclipse.cdt.managedbuilder.core.IBuilder;
|
import org.eclipse.cdt.managedbuilder.core.IBuilder;
|
||||||
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
|
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
|
||||||
|
import org.eclipse.cdt.managedbuilder.core.IFileInfo;
|
||||||
import org.eclipse.cdt.managedbuilder.core.IFolderInfo;
|
import org.eclipse.cdt.managedbuilder.core.IFolderInfo;
|
||||||
import org.eclipse.cdt.managedbuilder.core.IResourceInfo;
|
import org.eclipse.cdt.managedbuilder.core.IResourceInfo;
|
||||||
import org.eclipse.cdt.managedbuilder.core.ITool;
|
import org.eclipse.cdt.managedbuilder.core.ITool;
|
||||||
|
@ -41,7 +45,8 @@ public class ToolChainEditTab extends AbstractCBuildPropertyTab {
|
||||||
private Button b_dispCompatible;
|
private Button b_dispCompatible;
|
||||||
private Combo c_toolchain;
|
private Combo c_toolchain;
|
||||||
private Combo c_builder;
|
private Combo c_builder;
|
||||||
private Button button_edit;
|
private Combo c_tool;
|
||||||
|
// private Button button_edit;
|
||||||
|
|
||||||
private IBuilder[] v_bs;
|
private IBuilder[] v_bs;
|
||||||
private IToolChain[] v_tcs;
|
private IToolChain[] v_tcs;
|
||||||
|
@ -49,7 +54,6 @@ public class ToolChainEditTab extends AbstractCBuildPropertyTab {
|
||||||
|
|
||||||
private IConfiguration cfg;
|
private IConfiguration cfg;
|
||||||
private IResourceInfo ri;
|
private IResourceInfo ri;
|
||||||
private IFolderInfo fi;
|
|
||||||
|
|
||||||
public void createControls(Composite parent) {
|
public void createControls(Composite parent) {
|
||||||
super.createControls(parent);
|
super.createControls(parent);
|
||||||
|
@ -63,19 +67,7 @@ public class ToolChainEditTab extends AbstractCBuildPropertyTab {
|
||||||
c_toolchain.setLayoutData(gd);
|
c_toolchain.setLayoutData(gd);
|
||||||
c_toolchain.addSelectionListener(new SelectionAdapter() {
|
c_toolchain.addSelectionListener(new SelectionAdapter() {
|
||||||
public void widgetSelected(SelectionEvent e) {
|
public void widgetSelected(SelectionEvent e) {
|
||||||
if (fi != null) {
|
modifyToolchain();
|
||||||
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;
|
|
||||||
fi.changeToolChain(tc, ManagedBuildManager.calculateChildId(tc.getId(), null), tc.getUniqueRealName());
|
|
||||||
}
|
|
||||||
} catch (BuildException be) {}
|
|
||||||
updateData();
|
|
||||||
}
|
|
||||||
}});
|
}});
|
||||||
c_toolchain.setEnabled(!page.isForFile());
|
c_toolchain.setEnabled(!page.isForFile());
|
||||||
|
|
||||||
|
@ -86,14 +78,22 @@ public class ToolChainEditTab extends AbstractCBuildPropertyTab {
|
||||||
c_builder.setLayoutData(gd);
|
c_builder.setLayoutData(gd);
|
||||||
c_builder.addSelectionListener(new SelectionAdapter() {
|
c_builder.addSelectionListener(new SelectionAdapter() {
|
||||||
public void widgetSelected(SelectionEvent e) {
|
public void widgetSelected(SelectionEvent e) {
|
||||||
int x = c_builder.getSelectionIndex();
|
modifyBuilder();
|
||||||
IBuilder b = v_bs[x];
|
|
||||||
cfg.changeBuilder(b, ManagedBuildManager.calculateChildId(b.getId(), null), b.getUniqueRealName());
|
|
||||||
updateData();
|
|
||||||
}});
|
}});
|
||||||
c_builder.setEnabled(page.isForProject());
|
c_builder.setEnabled(page.isForProject());
|
||||||
|
|
||||||
// make table for tools list
|
// make table for tools list
|
||||||
|
if (page.isForFile()) {
|
||||||
|
Group g = setupGroup(usercomp, Messages.getString("ToolChainEditTab.5"), 2, GridData.FILL_BOTH); //$NON-NLS-1$
|
||||||
|
c_tool = new Combo(g, SWT.READ_ONLY | SWT.DROP_DOWN | SWT.BORDER);
|
||||||
|
gd = new GridData(GridData.FILL_HORIZONTAL);
|
||||||
|
gd.horizontalSpan = 2;
|
||||||
|
c_tool.setLayoutData(gd);
|
||||||
|
c_tool.addSelectionListener(new SelectionAdapter() {
|
||||||
|
public void widgetSelected(SelectionEvent e) {
|
||||||
|
saveToolSelected();
|
||||||
|
}});
|
||||||
|
} else { // Folder or Project
|
||||||
Group g = setupGroup(usercomp, Messages.getString("ToolChainEditTab.3"), 2, GridData.FILL_BOTH); //$NON-NLS-1$
|
Group g = setupGroup(usercomp, Messages.getString("ToolChainEditTab.3"), 2, GridData.FILL_BOTH); //$NON-NLS-1$
|
||||||
|
|
||||||
text = new Text(g, SWT.BORDER | SWT.WRAP | SWT.MULTI |
|
text = new Text(g, SWT.BORDER | SWT.WRAP | SWT.MULTI |
|
||||||
|
@ -102,7 +102,7 @@ public class ToolChainEditTab extends AbstractCBuildPropertyTab {
|
||||||
gd.grabExcessHorizontalSpace = true;
|
gd.grabExcessHorizontalSpace = true;
|
||||||
text.setLayoutData(gd);
|
text.setLayoutData(gd);
|
||||||
|
|
||||||
button_edit = new Button(g, SWT.PUSH);
|
Button button_edit = new Button(g, SWT.PUSH);
|
||||||
GridData gdb = new GridData(GridData.VERTICAL_ALIGN_CENTER);
|
GridData gdb = new GridData(GridData.VERTICAL_ALIGN_CENTER);
|
||||||
gdb.grabExcessHorizontalSpace = false;
|
gdb.grabExcessHorizontalSpace = false;
|
||||||
gdb.horizontalAlignment = SWT.FILL;
|
gdb.horizontalAlignment = SWT.FILL;
|
||||||
|
@ -110,30 +110,16 @@ public class ToolChainEditTab extends AbstractCBuildPropertyTab {
|
||||||
button_edit.setLayoutData(gdb);
|
button_edit.setLayoutData(gdb);
|
||||||
button_edit.addSelectionListener(new SelectionAdapter() {
|
button_edit.addSelectionListener(new SelectionAdapter() {
|
||||||
public void widgetSelected(SelectionEvent event) {
|
public void widgetSelected(SelectionEvent event) {
|
||||||
ToolSelectionDialog d = new ToolSelectionDialog(usercomp.getShell());
|
modifyTools();
|
||||||
d.all = v_tools;
|
|
||||||
d.fi = fi;
|
|
||||||
int result = d.open();
|
|
||||||
if (result == 0 && (d.removed.size() > 0 || d.added.size() > 0)) {
|
|
||||||
try {
|
|
||||||
fi.modifyToolChain(
|
|
||||||
(ITool[])d.removed.toArray(new ITool[d.removed.size()]),
|
|
||||||
(ITool[])d.added.toArray(new ITool[d.added.size()]));
|
|
||||||
} catch (BuildException b) {}
|
|
||||||
updateData();
|
|
||||||
}
|
|
||||||
}});
|
}});
|
||||||
|
|
||||||
button_edit.setLayoutData(new GridData(GridData.END));
|
button_edit.setLayoutData(new GridData(GridData.END));
|
||||||
button_edit.setText(Messages.getString("ToolChainEditTab.4")); //$NON-NLS-1$
|
button_edit.setText(Messages.getString("ToolChainEditTab.4")); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
|
}
|
||||||
public void updateData(ICResourceDescription rcfg) {
|
public void updateData(ICResourceDescription rcfg) {
|
||||||
cfg = getCfg(rcfg.getConfiguration());
|
cfg = getCfg(rcfg.getConfiguration());
|
||||||
ri = cfg.getResourceInfo(rcfg.getPath(), false);
|
ri = cfg.getResourceInfo(rcfg.getPath(), false);
|
||||||
if (ri instanceof IFolderInfo)
|
|
||||||
fi = (IFolderInfo)ri;
|
|
||||||
else
|
|
||||||
fi = null;
|
|
||||||
updateData();
|
updateData();
|
||||||
}
|
}
|
||||||
private void updateData() {
|
private void updateData() {
|
||||||
|
@ -142,16 +128,18 @@ public class ToolChainEditTab extends AbstractCBuildPropertyTab {
|
||||||
v_tools = new ITool[r_tools.length];
|
v_tools = new ITool[r_tools.length];
|
||||||
|
|
||||||
IToolChain tc = null;
|
IToolChain tc = null;
|
||||||
if (fi != null)
|
if (ri instanceof IFolderInfo)
|
||||||
tc = ManagedBuildManager.getRealToolChain(fi.getToolChain());
|
tc = ManagedBuildManager.getRealToolChain(((IFolderInfo)ri).getToolChain());
|
||||||
|
|
||||||
int cnt = 0;
|
int cnt = 0;
|
||||||
int pos = -1;
|
int pos = -1;
|
||||||
c_toolchain.removeAll();
|
c_toolchain.removeAll();
|
||||||
for (int i=0; i<r_tcs.length; i++) {
|
for (int i=0; i<r_tcs.length; i++) {
|
||||||
if (r_tcs[i].isSystemObject()) continue;
|
if (r_tcs[i].isSystemObject()) continue;
|
||||||
|
|
||||||
if (b_dispCompatible.getSelection() &&
|
if (b_dispCompatible.getSelection() &&
|
||||||
fi != null && ! fi.isToolChainCompatible(r_tcs[i]))
|
(ri instanceof IFolderInfo) &&
|
||||||
|
! ((IFolderInfo)ri).isToolChainCompatible(r_tcs[i]))
|
||||||
continue;
|
continue;
|
||||||
c_toolchain.add(r_tcs[i].getUniqueRealName());
|
c_toolchain.add(r_tcs[i].getUniqueRealName());
|
||||||
v_tcs[cnt] = r_tcs[i];
|
v_tcs[cnt] = r_tcs[i];
|
||||||
|
@ -165,19 +153,14 @@ public class ToolChainEditTab extends AbstractCBuildPropertyTab {
|
||||||
if (pos != -1) {
|
if (pos != -1) {
|
||||||
c_toolchain.select(pos);
|
c_toolchain.select(pos);
|
||||||
c_builder.setEnabled(true);
|
c_builder.setEnabled(true);
|
||||||
button_edit.setEnabled(true);
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (cfg.getBuilder().isManagedBuildOn()) {
|
if (cfg.getBuilder().isManagedBuildOn()) {
|
||||||
c_toolchain.setText(EMPTY_STR); // unprobable case
|
c_toolchain.setText(EMPTY_STR); // unprobable case
|
||||||
} else {
|
} else {
|
||||||
// try {
|
|
||||||
// fi.changeToolChain(null, null, null);
|
|
||||||
// } catch (BuildException e) {}
|
|
||||||
c_toolchain.select(c_toolchain.getItemCount() - 1);
|
c_toolchain.select(c_toolchain.getItemCount() - 1);
|
||||||
}
|
}
|
||||||
c_builder.setEnabled(false);
|
c_builder.setEnabled(false);
|
||||||
button_edit.setEnabled(false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
IBuilder b = ManagedBuildManager.getRealBuilder(cfg.getBuilder());
|
IBuilder b = ManagedBuildManager.getRealBuilder(cfg.getBuilder());
|
||||||
|
@ -208,15 +191,38 @@ public class ToolChainEditTab extends AbstractCBuildPropertyTab {
|
||||||
System.arraycopy(v_tools, 0, tmp, 0, cnt);
|
System.arraycopy(v_tools, 0, tmp, 0, cnt);
|
||||||
v_tools = tmp;
|
v_tools = tmp;
|
||||||
|
|
||||||
if (fi != null) {
|
if (page.isForFile()) { // Edit tool in combo for File
|
||||||
ITool[] tools = fi.getTools();
|
c_tool.removeAll();
|
||||||
String s = EMPTY_STR;
|
ITool[] tools = ri.getTools();
|
||||||
for (int i = 0; i < tools.length; i++) {
|
ITool curr = null, real = null;
|
||||||
s = s + tools[i].getUniqueRealName() + "\n"; //$NON-NLS-1$
|
if (tools != null && tools.length > 0) {
|
||||||
|
for (int i=0; i<tools.length; i++) {
|
||||||
|
if (tools[i] != null && !tools[i].getCustomBuildStep()) {
|
||||||
|
curr = tools[i];
|
||||||
|
real = ManagedBuildManager.getRealTool(curr);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pos = (curr == null) ? v_tools.length : -1;
|
||||||
|
|
||||||
|
for (int i=0; i<v_tools.length; i++) {
|
||||||
|
if (pos == -1 && real.matches(v_tools[i])) {
|
||||||
|
pos = i;
|
||||||
|
c_tool.add(curr.getUniqueRealName()); // tool from v_tools may
|
||||||
|
} else {
|
||||||
|
c_tool.add(v_tools[i].getUniqueRealName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
c_tool.add(Messages.getString("ToolChainEditTab.6")); //$NON-NLS-1$
|
||||||
|
c_tool.select(pos);
|
||||||
|
} else { // display tools list for Folder and Project
|
||||||
|
String s = EMPTY_STR;
|
||||||
|
ITool[] tools = ri.getTools();
|
||||||
|
for (int i = 0; i < tools.length; i++)
|
||||||
|
s = s + tools[i].getUniqueRealName() + "\n"; //$NON-NLS-1$
|
||||||
text.setText(s);
|
text.setText(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void checkPressed(SelectionEvent e) {
|
public void checkPressed(SelectionEvent e) {
|
||||||
|
@ -240,11 +246,80 @@ public class ToolChainEditTab extends AbstractCBuildPropertyTab {
|
||||||
fi2.changeToolChain(tc, ManagedBuildManager.calculateChildId(tc.getId(), null), tc.getUniqueRealName());
|
fi2.changeToolChain(tc, ManagedBuildManager.calculateChildId(tc.getId(), null), tc.getUniqueRealName());
|
||||||
fi2.modifyToolChain(tools2, tools1);
|
fi2.modifyToolChain(tools2, tools1);
|
||||||
} catch (BuildException e) {}
|
} catch (BuildException e) {}
|
||||||
} else {}
|
} else if (ri1 instanceof IFileInfo && ri2 instanceof IFileInfo) {
|
||||||
|
((IFileInfo)ri2).setTools(ri1.getTools());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void performDefaults() {
|
protected void performDefaults() {
|
||||||
updateData();
|
updateData();
|
||||||
}
|
}
|
||||||
protected void updateButtons() {} // Do nothing. No buttons to update.
|
protected void updateButtons() {} // Do nothing. No buttons to update.
|
||||||
|
|
||||||
|
private void saveToolSelected() {
|
||||||
|
int pos = c_tool.getSelectionIndex();
|
||||||
|
ITool[] oldTools = ri.getTools();
|
||||||
|
if (oldTools != null && oldTools.length > 0) {
|
||||||
|
if (pos == (c_tool.getItemCount() - 1)) {// NO TOOL selected
|
||||||
|
List newTools = new ArrayList(oldTools.length);
|
||||||
|
for (int i=0; i<oldTools.length; i++)
|
||||||
|
if (oldTools[i].getCustomBuildStep()) // ignore all tools except customBuild's
|
||||||
|
newTools.add(oldTools[i]);
|
||||||
|
((IFileInfo)ri).setTools((ITool[])newTools.toArray(new ITool[newTools.size()]));
|
||||||
|
} else { // modify only one (selected) tool
|
||||||
|
for (int i=0; i<oldTools.length; i++) {
|
||||||
|
if (oldTools[i].getCustomBuildStep()) // skip custom steps
|
||||||
|
continue;
|
||||||
|
if ( ! oldTools[i].matches(v_tools[pos])) { // really changed ?
|
||||||
|
oldTools[i] = v_tools[pos];
|
||||||
|
((IFileInfo)ri).setTools(oldTools);
|
||||||
|
}
|
||||||
|
break; // exit after first not-custom tool met
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else { // old list was empty.
|
||||||
|
if (pos == (c_tool.getItemCount() - 1)) // NO TOOL selected
|
||||||
|
((IFileInfo)ri).setTools(new ITool[0]);
|
||||||
|
else
|
||||||
|
((IFileInfo)ri).setTools(new ITool[] {v_tools[pos]});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void modifyTools() {
|
||||||
|
ToolSelectionDialog d = new ToolSelectionDialog(usercomp.getShell());
|
||||||
|
d.all = v_tools;
|
||||||
|
d.fi = (IFolderInfo)ri;
|
||||||
|
int result = d.open();
|
||||||
|
if (result == 0 && (d.removed.size() > 0 || d.added.size() > 0)) {
|
||||||
|
try {
|
||||||
|
((IFolderInfo)ri).modifyToolChain(
|
||||||
|
(ITool[])d.removed.toArray(new ITool[d.removed.size()]),
|
||||||
|
(ITool[])d.added.toArray(new ITool[d.added.size()]));
|
||||||
|
} catch (BuildException b) {}
|
||||||
|
updateData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void modifyToolchain() {
|
||||||
|
if (ri instanceof IFolderInfo) {
|
||||||
|
int x = c_toolchain.getSelectionIndex();
|
||||||
|
try {
|
||||||
|
if (NO_TC.equals(c_toolchain.getItem(x))) {
|
||||||
|
((IFolderInfo)ri).changeToolChain(null, null, null);
|
||||||
|
} else {
|
||||||
|
IToolChain tc = v_tcs[x];
|
||||||
|
if (tc == null) return;
|
||||||
|
((IFolderInfo)ri).changeToolChain(tc, ManagedBuildManager.calculateChildId(tc.getId(), null), tc.getUniqueRealName());
|
||||||
|
}
|
||||||
|
} catch (BuildException be) {}
|
||||||
|
updateData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void modifyBuilder() {
|
||||||
|
int x = c_builder.getSelectionIndex();
|
||||||
|
IBuilder b = v_bs[x];
|
||||||
|
cfg.changeBuilder(b, ManagedBuildManager.calculateChildId(b.getId(), null), b.getUniqueRealName());
|
||||||
|
updateData();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,6 +52,8 @@ ToolChainEditTab.1=Current toolchain
|
||||||
ToolChainEditTab.2=Current builder
|
ToolChainEditTab.2=Current builder
|
||||||
ToolChainEditTab.3=Used tools
|
ToolChainEditTab.3=Used tools
|
||||||
ToolChainEditTab.4=Select tools
|
ToolChainEditTab.4=Select tools
|
||||||
|
ToolChainEditTab.5=Select tool
|
||||||
|
ToolChainEditTab.6=-- NO TOOL --
|
||||||
NewVarDialog.0=New variable
|
NewVarDialog.0=New variable
|
||||||
NewVarDialog.1=Apply to all configurations
|
NewVarDialog.1=Apply to all configurations
|
||||||
NewCfgDialog.0=Existing configuration
|
NewCfgDialog.0=Existing configuration
|
||||||
|
|
Loading…
Add table
Reference in a new issue