mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Tool chain modification update
This commit is contained in:
parent
bad9887e8d
commit
126bc9b482
2 changed files with 143 additions and 223 deletions
|
@ -13,11 +13,9 @@ package org.eclipse.cdt.managedbuilder.ui.properties;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.eclipse.cdt.core.settings.model.ICResourceDescription;
|
import org.eclipse.cdt.core.settings.model.ICResourceDescription;
|
||||||
import org.eclipse.cdt.internal.ui.CPluginImages;
|
import org.eclipse.cdt.internal.ui.CPluginImages;
|
||||||
import org.eclipse.cdt.managedbuilder.core.BuildException;
|
|
||||||
import org.eclipse.cdt.managedbuilder.core.IBuildObject;
|
import org.eclipse.cdt.managedbuilder.core.IBuildObject;
|
||||||
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;
|
||||||
|
@ -36,7 +34,11 @@ import org.eclipse.cdt.managedbuilder.tcmodification.IFileInfoModification;
|
||||||
import org.eclipse.cdt.managedbuilder.tcmodification.IFolderInfoModification;
|
import org.eclipse.cdt.managedbuilder.tcmodification.IFolderInfoModification;
|
||||||
import org.eclipse.cdt.managedbuilder.tcmodification.IModificationOperation;
|
import org.eclipse.cdt.managedbuilder.tcmodification.IModificationOperation;
|
||||||
import org.eclipse.cdt.managedbuilder.tcmodification.IToolChainModificationManager;
|
import org.eclipse.cdt.managedbuilder.tcmodification.IToolChainModificationManager;
|
||||||
|
import org.eclipse.cdt.managedbuilder.tcmodification.IToolListModification;
|
||||||
import org.eclipse.cdt.managedbuilder.tcmodification.IToolModification;
|
import org.eclipse.cdt.managedbuilder.tcmodification.IToolModification;
|
||||||
|
import org.eclipse.cdt.ui.CUIPlugin;
|
||||||
|
import org.eclipse.core.resources.IFileModificationValidator;
|
||||||
|
import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.IStatus;
|
import org.eclipse.core.runtime.IStatus;
|
||||||
import org.eclipse.swt.SWT;
|
import org.eclipse.swt.SWT;
|
||||||
import org.eclipse.swt.events.SelectionAdapter;
|
import org.eclipse.swt.events.SelectionAdapter;
|
||||||
|
@ -55,7 +57,7 @@ import org.eclipse.swt.widgets.Text;
|
||||||
|
|
||||||
public class ToolChainEditTab extends AbstractCBuildPropertyTab {
|
public class ToolChainEditTab extends AbstractCBuildPropertyTab {
|
||||||
|
|
||||||
public static final IToolChainModificationManager tcmm = ManagedBuildManager.getToolChainModificationManager();
|
private static final IToolChainModificationManager tcmmgr = ManagedBuildManager.getToolChainModificationManager();
|
||||||
private static final String NO_TC = Messages.getString("StdProjectTypeHandler.0"); //$NON-NLS-1$
|
private static final String NO_TC = Messages.getString("StdProjectTypeHandler.0"); //$NON-NLS-1$
|
||||||
private static final IToolChain[] r_tcs = ManagedBuildManager.getRealToolChains();
|
private static final IToolChain[] r_tcs = ManagedBuildManager.getRealToolChains();
|
||||||
private static final IBuilder[] r_bs = ManagedBuildManager.getRealBuilders();
|
private static final IBuilder[] r_bs = ManagedBuildManager.getRealBuilders();
|
||||||
|
@ -63,10 +65,9 @@ public class ToolChainEditTab extends AbstractCBuildPropertyTab {
|
||||||
private static final Color red = Display.getDefault().getSystemColor(SWT.COLOR_RED);
|
private static final Color red = Display.getDefault().getSystemColor(SWT.COLOR_RED);
|
||||||
private static final String SPACE = " "; //$NON-NLS-1$
|
private static final String SPACE = " "; //$NON-NLS-1$
|
||||||
|
|
||||||
static final Image IMG_WARNING = CPluginImages.get(CPluginImages.IMG_OBJS_REFACTORING_WARNING);
|
static private final Image IMG_WARNING = CPluginImages.get(CPluginImages.IMG_OBJS_REFACTORING_WARNING);
|
||||||
static final Image IMG_ERROR = CPluginImages.get(CPluginImages.IMG_OBJS_REFACTORING_ERROR);
|
static private final Image IMG_ERROR = CPluginImages.get(CPluginImages.IMG_OBJS_REFACTORING_ERROR);
|
||||||
static final Image IMG_INFO = CPluginImages.get(CPluginImages.IMG_OBJS_REFACTORING_INFO);
|
static private final Image IMG_INFO = CPluginImages.get(CPluginImages.IMG_OBJS_REFACTORING_INFO);
|
||||||
static final Image IMG_ARROW = CPluginImages.get(CPluginImages.IMG_PREFERRED);
|
|
||||||
|
|
||||||
private Text text;
|
private Text text;
|
||||||
private Button b_dispCompatible;
|
private Button b_dispCompatible;
|
||||||
|
@ -86,6 +87,7 @@ public class ToolChainEditTab extends AbstractCBuildPropertyTab {
|
||||||
|
|
||||||
private IConfiguration cfg;
|
private IConfiguration cfg;
|
||||||
private IResourceInfo ri;
|
private IResourceInfo ri;
|
||||||
|
private IToolListModification mod;
|
||||||
|
|
||||||
public void createControls(Composite parent) {
|
public void createControls(Composite parent) {
|
||||||
super.createControls(parent);
|
super.createControls(parent);
|
||||||
|
@ -159,15 +161,31 @@ public class ToolChainEditTab extends AbstractCBuildPropertyTab {
|
||||||
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) {
|
|
||||||
|
private IToolListModification getModification() {
|
||||||
|
if (ri instanceof IFolderInfo)
|
||||||
|
return tcmmgr.createModification((IFolderInfo)ri);
|
||||||
|
else
|
||||||
|
return tcmmgr.createModification((IFileInfo)ri);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void updateData(ICResourceDescription rcfg) {
|
||||||
cfg = getCfg(rcfg.getConfiguration());
|
cfg = getCfg(rcfg.getConfiguration());
|
||||||
ri = cfg.getResourceInfo(rcfg.getPath(), false);
|
ri = cfg.getResourceInfo(rcfg.getPath(), false);
|
||||||
|
mod = getModification();
|
||||||
updateData();
|
updateData();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void updateData() {
|
||||||
|
showErrorMessage();
|
||||||
|
fillToolChainCombo();
|
||||||
|
fillBuilderCombo();
|
||||||
|
fillToolsList();
|
||||||
|
}
|
||||||
|
|
||||||
private void showErrorMessage() {
|
private void showErrorMessage() {
|
||||||
if (ri instanceof IFolderInfo) {
|
if (ri instanceof IFolderInfo) {
|
||||||
IFolderInfoModification foim = tcmm.createModification((IFolderInfo)ri);
|
IFolderInfoModification foim = (IFolderInfoModification)mod;
|
||||||
if (foim.isToolChainCompatible()) {
|
if (foim.isToolChainCompatible()) {
|
||||||
st_toolchain.setText(EMPTY_STR);
|
st_toolchain.setText(EMPTY_STR);
|
||||||
} else {
|
} else {
|
||||||
|
@ -185,16 +203,16 @@ public class ToolChainEditTab extends AbstractCBuildPropertyTab {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else { // FileInfo
|
// } else { // FileInfo
|
||||||
IFileInfoModification fim = tcmm.createModification((IFileInfo)ri);
|
// IFileInfoModification fim = (IFileInfoModification)mod;
|
||||||
fim.getProjectToolModifications();
|
// fim.getProjectToolModifications();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void fillToolChainCombo() {
|
private void fillToolChainCombo() {
|
||||||
IToolChain tc = null;
|
IToolChain tc = null;
|
||||||
if (ri instanceof IFolderInfo)
|
if (ri instanceof IFolderInfo)
|
||||||
tc = ManagedBuildManager.getRealToolChain(((IFolderInfo)ri).getToolChain());
|
tc = ManagedBuildManager.getRealToolChain(((IFolderInfoModification)mod).getToolChain());
|
||||||
|
|
||||||
c_toolchain.removeAll();
|
c_toolchain.removeAll();
|
||||||
boolean isMng = cfg.getBuilder().isManagedBuildOn();
|
boolean isMng = cfg.getBuilder().isManagedBuildOn();
|
||||||
|
@ -202,7 +220,7 @@ public class ToolChainEditTab extends AbstractCBuildPropertyTab {
|
||||||
|
|
||||||
IToolChain[] tcs = r_tcs;
|
IToolChain[] tcs = r_tcs;
|
||||||
if (b_dispCompatible.getSelection() && (ri instanceof IFolderInfo)) {
|
if (b_dispCompatible.getSelection() && (ri instanceof IFolderInfo)) {
|
||||||
IFolderInfoModification fim = tcmm.createModification((IFolderInfo)ri);
|
IFolderInfoModification fim = (IFolderInfoModification)mod;
|
||||||
tcs = fim.getCompatibleToolChains();
|
tcs = fim.getCompatibleToolChains();
|
||||||
IToolChain[] tcs1 = new IToolChain[tcs.length + 1];
|
IToolChain[] tcs1 = new IToolChain[tcs.length + 1];
|
||||||
System.arraycopy(tcs, 0, tcs1, 0, tcs.length);
|
System.arraycopy(tcs, 0, tcs1, 0, tcs.length);
|
||||||
|
@ -245,7 +263,7 @@ public class ToolChainEditTab extends AbstractCBuildPropertyTab {
|
||||||
IBuilder[] bs = r_bs;
|
IBuilder[] bs = r_bs;
|
||||||
|
|
||||||
if (b_dispCompatible.getSelection() && (ri instanceof IFolderInfo)) {
|
if (b_dispCompatible.getSelection() && (ri instanceof IFolderInfo)) {
|
||||||
IFolderInfoModification fim = tcmm.createModification((IFolderInfo)ri);
|
IFolderInfoModification fim = (IFolderInfoModification)mod;
|
||||||
if (fim instanceof IConfigurationModification) {
|
if (fim instanceof IConfigurationModification) {
|
||||||
IBuilder[] bs1 = ((IConfigurationModification)fim).getCompatibleBuilders();
|
IBuilder[] bs1 = ((IConfigurationModification)fim).getCompatibleBuilders();
|
||||||
bs = new IBuilder[bs1.length + 1];
|
bs = new IBuilder[bs1.length + 1];
|
||||||
|
@ -273,7 +291,7 @@ public class ToolChainEditTab extends AbstractCBuildPropertyTab {
|
||||||
}
|
}
|
||||||
|
|
||||||
private ITool getToolForFile() {
|
private ITool getToolForFile() {
|
||||||
ITool[] tools = ri.getTools();
|
ITool[] tools = ((IFileInfoModification)mod).getProjectTools();
|
||||||
if (tools != null && tools.length > 0) {
|
if (tools != null && tools.length > 0) {
|
||||||
for (int i=0; i<tools.length; i++) {
|
for (int i=0; i<tools.length; i++) {
|
||||||
if (tools[i] != null && !tools[i].getCustomBuildStep()) {
|
if (tools[i] != null && !tools[i].getCustomBuildStep()) {
|
||||||
|
@ -347,7 +365,7 @@ public class ToolChainEditTab extends AbstractCBuildPropertyTab {
|
||||||
st_tool.setImage(null);
|
st_tool.setImage(null);
|
||||||
if (tool == null)
|
if (tool == null)
|
||||||
return;
|
return;
|
||||||
IFileInfoModification fim = tcmm.createModification((IFileInfo)ri);
|
IFileInfoModification fim = (IFileInfoModification)mod;
|
||||||
IToolModification tm = fim.getToolModification(tool);
|
IToolModification tm = fim.getToolModification(tool);
|
||||||
if (tm != null && !tm.isCompatible()) {
|
if (tm != null && !tm.isCompatible()) {
|
||||||
CompatibilityStatus cs = tm.getCompatibilityStatus();
|
CompatibilityStatus cs = tm.getCompatibilityStatus();
|
||||||
|
@ -361,7 +379,7 @@ public class ToolChainEditTab extends AbstractCBuildPropertyTab {
|
||||||
private boolean updateCompatibleTools(ITool real) {
|
private boolean updateCompatibleTools(ITool real) {
|
||||||
boolean result = false;
|
boolean result = false;
|
||||||
ArrayList list = new ArrayList();
|
ArrayList list = new ArrayList();
|
||||||
IFileInfoModification fim = tcmm.createModification((IFileInfo)ri);
|
IFileInfoModification fim = (IFileInfoModification)mod;
|
||||||
|
|
||||||
if (real != null) { // Current tool exists
|
if (real != null) { // Current tool exists
|
||||||
real = ManagedBuildManager.getRealTool(real);
|
real = ManagedBuildManager.getRealTool(real);
|
||||||
|
@ -397,204 +415,108 @@ public class ToolChainEditTab extends AbstractCBuildPropertyTab {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateData() {
|
protected void checkPressed(SelectionEvent e) {
|
||||||
showErrorMessage();
|
|
||||||
fillToolChainCombo();
|
|
||||||
fillBuilderCombo();
|
|
||||||
fillToolsList();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void checkPressed(SelectionEvent e) {
|
|
||||||
updateData();
|
updateData();
|
||||||
}
|
}
|
||||||
public void performApply(ICResourceDescription src,
|
protected void performApply(ICResourceDescription src,
|
||||||
ICResourceDescription dst) {
|
ICResourceDescription dst) {
|
||||||
IConfiguration cfg1 = getCfg(src.getConfiguration());
|
IConfiguration cfg = getCfg(dst.getConfiguration());
|
||||||
IConfiguration cfg2 = getCfg(dst.getConfiguration());
|
|
||||||
IBuilder b = cfg1.getBuilder();
|
|
||||||
cfg2.changeBuilder(b, ManagedBuildManager.calculateChildId(b.getId(), null), b.getUniqueRealName());
|
|
||||||
IResourceInfo ri1 = cfg1.getResourceInfo(src.getPath(), false);
|
|
||||||
IResourceInfo ri2 = cfg2.getResourceInfo(dst.getPath(), false);
|
|
||||||
if (ri1 instanceof IFolderInfo && ri2 instanceof IFolderInfo) {
|
|
||||||
IFolderInfo fi1 = (IFolderInfo)ri1;
|
|
||||||
IFolderInfo fi2 = (IFolderInfo)ri2;
|
|
||||||
IToolChain tc = fi1.getToolChain();
|
|
||||||
ITool[] tools1 = fi1.getTools();
|
|
||||||
ITool[] tools2 = fi2.getTools();
|
|
||||||
try {
|
try {
|
||||||
fi2.changeToolChain(tc, ManagedBuildManager.calculateChildId(tc.getId(), null), tc.getUniqueRealName());
|
IToolListModification tlm = (ri instanceof IFolderInfo) ?
|
||||||
fi2.modifyToolChain(tools2, tools1);
|
(IToolListModification)tcmmgr.createModification(cfg, (IFolderInfoModification)mod) :
|
||||||
} catch (BuildException e) {}
|
(IToolListModification)tcmmgr.createModification(cfg, (IFileInfoModification)mod);
|
||||||
} else if (ri1 instanceof IFileInfo && ri2 instanceof IFileInfo) {
|
tlm.apply();
|
||||||
((IFileInfo)ri2).setTools(ri1.getTools());
|
} catch (CoreException e) {
|
||||||
|
CUIPlugin.getDefault().log(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void performDefaults() {
|
protected void performDefaults() {
|
||||||
if (page.isForProject()) {
|
mod.restoreDefaults();
|
||||||
// 1.Per-project : change to the "default" tool-chain defined in the extension
|
apply();
|
||||||
// super-class of the project configuration. NOTE: the makefile project case might
|
|
||||||
// need a special handling in this case.
|
|
||||||
|
|
||||||
IConfiguration cfg1 = cfg.getParent();
|
|
||||||
if (cfg1.getToolChain() == null) {
|
|
||||||
if (cfg.getToolChain() != null) {
|
|
||||||
IToolChain tc1 = cfg.getToolChain().getSuperClass();
|
|
||||||
if (tc1 != null) {
|
|
||||||
IBuilder b = tc1.getBuilder();
|
|
||||||
cfg.changeBuilder(b, ManagedBuildManager.calculateChildId(b.getId(), null), b.getUniqueRealName());
|
|
||||||
try {
|
|
||||||
((IFolderInfo)ri).modifyToolChain(ri.getTools(), tc1.getTools());
|
|
||||||
} catch (BuildException e) {}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
cfg1 = ManagedBuildManager.getPreferenceConfiguration(true);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
IBuilder b = cfg1.getBuilder();
|
|
||||||
cfg.changeBuilder(b, ManagedBuildManager.calculateChildId(b.getId(), null), b.getUniqueRealName());
|
|
||||||
IResourceInfo ri1 = cfg1.getResourceInfo(ri.getPath(), false);
|
|
||||||
if (!((ToolChain)cfg1.getToolChain()).isPreferenceToolChain())
|
|
||||||
copyFI(ri1, ri);
|
|
||||||
else {
|
|
||||||
cfg1 = ManagedBuildManager.getPreferenceConfiguration(false);
|
|
||||||
IToolChain tc = cfg1.getToolChain();
|
|
||||||
try {
|
|
||||||
((IFolderInfo)ri).changeToolChain(tc, ManagedBuildManager.calculateChildId(tc.getId(), null), tc.getUniqueRealName());
|
|
||||||
((IFolderInfo)ri).modifyToolChain(ri.getTools(), tc.getTools());
|
|
||||||
|
|
||||||
} catch (BuildException e) {}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if (page.isForFolder()) {
|
|
||||||
// 2.per-folder : change to the same tool-chain as the one used by the parent
|
|
||||||
// folder.
|
|
||||||
IResourceInfo ri1 = cfg.getResourceInfo(ri.getPath().removeLastSegments(1), false);
|
|
||||||
copyFI(ri1, ri);
|
|
||||||
|
|
||||||
} else if (page.isForFile()) {
|
|
||||||
// 3.per-file : change to the tool from the parent folder's tool-chain suitable
|
|
||||||
// for the given file. NOTE: the custom build step tool should be preserved!
|
|
||||||
IResourceInfo ri1 = cfg.getResourceInfo(ri.getPath().removeLastSegments(1), false);
|
|
||||||
String ext = ri.getPath().getFileExtension();
|
|
||||||
|
|
||||||
ITool[] ts1 = ri1.getTools();
|
|
||||||
ITool newTool = null;
|
|
||||||
for (int i=0; i<ts1.length; i++) {
|
|
||||||
if (ts1[i].isInputFileType(ext)) {
|
|
||||||
newTool = ts1[i];
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ITool[] tools = ri.getTools();
|
|
||||||
int pos = -1;
|
|
||||||
for (int i=0; i<tools.length; i++) {
|
|
||||||
if (tools[i] != null && !tools[i].getCustomBuildStep()) {
|
|
||||||
pos = i;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (newTool != null) {
|
|
||||||
if (pos == -1) { // 1: NO TOOL -> tool
|
|
||||||
ITool[] ts2 = new ITool[tools.length + 1];
|
|
||||||
System.arraycopy(tools, 0, ts2, 0, tools.length);
|
|
||||||
ts2[tools.length] = newTool;
|
|
||||||
tools = ts2;
|
|
||||||
} else // 2: tool -> tool
|
|
||||||
tools[pos] = newTool;
|
|
||||||
} else if (pos != -1){ // 3: tool -> NO TOOL;
|
|
||||||
ITool[] ts2 = new ITool[tools.length - 1];
|
|
||||||
if (pos > 0)
|
|
||||||
System.arraycopy(tools, 0, ts2, 0, pos-1);
|
|
||||||
if (pos < ts2.length)
|
|
||||||
System.arraycopy(tools, pos+1, ts2, pos, ts2.length - pos);
|
|
||||||
tools = ts2;
|
|
||||||
}
|
|
||||||
((IFileInfo)ri).setTools(tools);
|
|
||||||
}
|
|
||||||
updateData();
|
updateData();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void copyFI(IResourceInfo src, IResourceInfo dst) {
|
|
||||||
if (src == null || dst == null)
|
|
||||||
return;
|
|
||||||
if (src instanceof IFolderInfo && dst instanceof IFolderInfo) {
|
|
||||||
IFolderInfo fi1 = (IFolderInfo)src;
|
|
||||||
IFolderInfo fi = (IFolderInfo)dst;
|
|
||||||
IToolChain tc = fi1.getToolChain();
|
|
||||||
ITool[] tools1 = fi1.getTools();
|
|
||||||
ITool[] tools2 = fi.getTools();
|
|
||||||
try {
|
|
||||||
fi.changeToolChain(tc, ManagedBuildManager.calculateChildId(tc.getId(), null), tc.getUniqueRealName());
|
|
||||||
fi.modifyToolChain(tools2, tools1);
|
|
||||||
} catch (BuildException e) {}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void updateButtons() {} // Do nothing. No buttons to update.
|
protected void updateButtons() {} // Do nothing. No buttons to update.
|
||||||
|
|
||||||
private void saveToolSelected() {
|
private void saveToolSelected() {
|
||||||
|
|
||||||
|
IFileInfoModification fim = (IFileInfoModification)mod;
|
||||||
|
|
||||||
|
// Find old tool
|
||||||
|
ITool oldTool = null;
|
||||||
|
ITool[] ots = fim.getProjectTools();
|
||||||
|
for (int i=0; i<ots.length; i++) {
|
||||||
|
if (!ots[i].getCustomBuildStep()) {
|
||||||
|
oldTool = ots[i];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Find new Tool
|
||||||
|
ITool newTool = null;
|
||||||
int pos = c_tool.getSelectionIndex();
|
int pos = c_tool.getSelectionIndex();
|
||||||
ITool[] oldTools = ri.getTools();
|
if (pos < (c_tool.getItemCount() - 1))
|
||||||
if (oldTools != null && oldTools.length > 0) {
|
newTool = v_tools[pos];
|
||||||
if (pos == (c_tool.getItemCount() - 1)) {// NO TOOL selected
|
|
||||||
List newTools = new ArrayList(oldTools.length);
|
// May be we've seleceted the same tool
|
||||||
for (int i=0; i<oldTools.length; i++)
|
if (newTool == null && oldTool == null)
|
||||||
if (oldTools[i].getCustomBuildStep()) // ignore all tools except customBuild's
|
return; // nothing to change
|
||||||
newTools.add(oldTools[i]);
|
if (newTool != null && newTool.matches(oldTool))
|
||||||
((IFileInfo)ri).setTools((ITool[])newTools.toArray(new ITool[newTools.size()]));
|
return; // nothing to change
|
||||||
} else { // modify only one (selected) tool
|
|
||||||
for (int i=0; i<oldTools.length; i++) {
|
// Apply changes
|
||||||
if (oldTools[i].getCustomBuildStep()) // skip custom steps
|
fim.changeProjectTools(oldTool, newTool);
|
||||||
continue;
|
apply();
|
||||||
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]});
|
|
||||||
}
|
|
||||||
updateData();
|
updateData();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Opens Tools selection dialog.
|
||||||
|
* Depending of result (OK/Cancel)
|
||||||
|
* either applies tools changes,
|
||||||
|
* or re-creates modification to abandon changes
|
||||||
|
*/
|
||||||
private void modifyTools() {
|
private void modifyTools() {
|
||||||
|
|
||||||
ToolSelectionDialog d = new ToolSelectionDialog(usercomp.getShell(), ri);
|
ToolSelectionDialog d = new ToolSelectionDialog(usercomp.getShell(), ri);
|
||||||
d.all = v_tools;
|
d.all = v_tools;
|
||||||
d.fi = (IFolderInfo)ri;
|
d.fi = (IFolderInfo)ri;
|
||||||
|
d.mod = mod;
|
||||||
int result = d.open();
|
int result = d.open();
|
||||||
if (result == 0 && (d.removed.size() > 0 || d.added.size() > 0)) {
|
if (d.removed.size() > 0 || d.added.size() > 0) {
|
||||||
try {
|
if (result == 0) {
|
||||||
((IFolderInfo)ri).modifyToolChain(
|
apply();
|
||||||
(ITool[])d.removed.toArray(new ITool[d.removed.size()]),
|
|
||||||
(ITool[])d.added.toArray(new ITool[d.added.size()]));
|
|
||||||
} catch (BuildException b) {}
|
|
||||||
updateData();
|
updateData();
|
||||||
|
} else {
|
||||||
|
mod = getModification(); // re-read data
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Applies changes to Modification
|
||||||
|
*/
|
||||||
|
private void apply() {
|
||||||
|
try {
|
||||||
|
mod.apply();
|
||||||
|
} catch (CoreException e) {
|
||||||
|
CUIPlugin.getDefault().log(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void modifyToolchain() {
|
private void modifyToolchain() {
|
||||||
if (ri instanceof IFolderInfo) {
|
IFolderInfoModification foim = (IFolderInfoModification)mod;
|
||||||
int x = c_toolchain.getSelectionIndex();
|
int x = c_toolchain.getSelectionIndex();
|
||||||
try {
|
|
||||||
if (NO_TC.equals(c_toolchain.getItem(x))) {
|
if (NO_TC.equals(c_toolchain.getItem(x))) {
|
||||||
((IFolderInfo)ri).changeToolChain(null, null, null);
|
foim.setToolChain(null);
|
||||||
} else {
|
} else {
|
||||||
IToolChain tc = v_tcs[x];
|
IToolChain tc = v_tcs[x];
|
||||||
if (tc == null) return;
|
if (tc == null) return;
|
||||||
((IFolderInfo)ri).changeToolChain(tc, ManagedBuildManager.calculateChildId(tc.getId(), null), tc.getUniqueRealName());
|
foim.setToolChain(tc);
|
||||||
}
|
}
|
||||||
} catch (BuildException be) {}
|
apply();
|
||||||
updateData();
|
updateData();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public static Image getErrorIcon(IStatus st) {
|
public static Image getErrorIcon(IStatus st) {
|
||||||
if (st.isOK())
|
if (st.isOK())
|
||||||
|
@ -609,9 +531,9 @@ public class ToolChainEditTab extends AbstractCBuildPropertyTab {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void modifyBuilder() {
|
private void modifyBuilder() {
|
||||||
int x = c_builder.getSelectionIndex();
|
IConfigurationModification cm = (IConfigurationModification)mod;
|
||||||
IBuilder b = v_bs[x];
|
cm.setBuilder(v_bs[c_builder.getSelectionIndex()]);
|
||||||
cfg.changeBuilder(b, ManagedBuildManager.calculateChildId(b.getId(), null), b.getUniqueRealName());
|
apply();
|
||||||
updateData();
|
updateData();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@ import java.util.Collections;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.eclipse.cdt.managedbuilder.core.IFileInfo;
|
import org.eclipse.cdt.internal.ui.CPluginImages;
|
||||||
import org.eclipse.cdt.managedbuilder.core.IFolderInfo;
|
import org.eclipse.cdt.managedbuilder.core.IFolderInfo;
|
||||||
import org.eclipse.cdt.managedbuilder.core.IModificationStatus;
|
import org.eclipse.cdt.managedbuilder.core.IModificationStatus;
|
||||||
import org.eclipse.cdt.managedbuilder.core.IResourceInfo;
|
import org.eclipse.cdt.managedbuilder.core.IResourceInfo;
|
||||||
|
@ -52,29 +52,27 @@ import org.eclipse.swt.widgets.Text;
|
||||||
|
|
||||||
public class ToolSelectionDialog extends Dialog {
|
public class ToolSelectionDialog extends Dialog {
|
||||||
|
|
||||||
private static final String EMPTY_STR = ""; //$NON-NLS-1$
|
static private final Image IMG_ARROW = CPluginImages.get(CPluginImages.IMG_PREFERRED);
|
||||||
private static final int COL_WIDTH = 300;
|
static private final String EMPTY_STR = ""; //$NON-NLS-1$
|
||||||
|
static private final int COL_WIDTH = 300;
|
||||||
|
static private Font boldFont = JFaceResources.getFontRegistry().getBold(JFaceResources.DIALOG_FONT);
|
||||||
|
static private Color red = Display.getDefault().getSystemColor(SWT.COLOR_RED);
|
||||||
|
static private Color gray = Display.getDefault().getSystemColor(SWT.COLOR_DARK_GRAY);
|
||||||
|
|
||||||
private Table t1, t2;
|
private Table t1, t2;
|
||||||
private Button b_add, b_del, b_rep, b_all;
|
private Button b_add, b_del, b_rep, b_all;
|
||||||
private CLabel errorLabel, l1;
|
private CLabel errorLabel, l1;
|
||||||
private Text txt2;
|
private Text txt2;
|
||||||
|
private ArrayList left, right;
|
||||||
|
|
||||||
|
public ArrayList added, removed;
|
||||||
public ITool[] all, used;
|
public ITool[] all, used;
|
||||||
public IFolderInfo fi;
|
public IFolderInfo fi;
|
||||||
ArrayList added, removed;
|
public IToolListModification mod = null;
|
||||||
private ArrayList left, right;
|
|
||||||
private Font boldFont = JFaceResources.getFontRegistry().getBold(JFaceResources.DIALOG_FONT);
|
|
||||||
private Color red = Display.getDefault().getSystemColor(SWT.COLOR_RED);
|
|
||||||
private Color gray = Display.getDefault().getSystemColor(SWT.COLOR_DARK_GRAY);
|
|
||||||
private IToolListModification tmod = null;
|
|
||||||
|
|
||||||
public ToolSelectionDialog(Shell shell, IResourceInfo ri) {
|
public ToolSelectionDialog(Shell shell, IResourceInfo ri) {
|
||||||
super (shell);
|
super (shell);
|
||||||
setShellStyle(getShellStyle() | SWT.RESIZE);
|
setShellStyle(getShellStyle() | SWT.RESIZE);
|
||||||
|
|
||||||
if (ri instanceof IFolderInfo)
|
|
||||||
tmod = ManagedBuildManager.getToolChainModificationManager().createModification((IFolderInfo)ri);
|
|
||||||
else
|
|
||||||
tmod = ManagedBuildManager.getToolChainModificationManager().createModification((IFileInfo)ri);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
@ -89,7 +87,7 @@ public class ToolSelectionDialog extends Dialog {
|
||||||
Composite composite = new Composite(parent, SWT.NULL);
|
Composite composite = new Composite(parent, SWT.NULL);
|
||||||
composite.setFont(parent.getFont());
|
composite.setFont(parent.getFont());
|
||||||
composite.setLayout(new GridLayout(3, false));
|
composite.setLayout(new GridLayout(3, false));
|
||||||
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
|
GridData gd = new GridData(GridData.FILL_BOTH);
|
||||||
gd.heightHint = 300;
|
gd.heightHint = 300;
|
||||||
composite.setLayoutData(gd);
|
composite.setLayoutData(gd);
|
||||||
|
|
||||||
|
@ -163,7 +161,7 @@ public class ToolSelectionDialog extends Dialog {
|
||||||
ITool tool = (ITool)t1.getItem(x).getData();
|
ITool tool = (ITool)t1.getItem(x).getData();
|
||||||
left.remove(tool);
|
left.remove(tool);
|
||||||
right.add(tool);
|
right.add(tool);
|
||||||
tmod.changeProjectTools(null, tool);
|
mod.changeProjectTools(null, tool);
|
||||||
updateData();
|
updateData();
|
||||||
}});
|
}});
|
||||||
b_add.setLayoutData(new GridData(GridData.FILL, GridData.BEGINNING, true, false));
|
b_add.setLayoutData(new GridData(GridData.FILL, GridData.BEGINNING, true, false));
|
||||||
|
@ -188,7 +186,7 @@ public class ToolSelectionDialog extends Dialog {
|
||||||
right.remove(tool);
|
right.remove(tool);
|
||||||
left.add(ManagedBuildManager.getRealTool(tool));
|
left.add(ManagedBuildManager.getRealTool(tool));
|
||||||
|
|
||||||
tmod.changeProjectTools(tool, null);
|
mod.changeProjectTools(tool, null);
|
||||||
|
|
||||||
updateData();
|
updateData();
|
||||||
}});
|
}});
|
||||||
|
@ -245,7 +243,7 @@ public class ToolSelectionDialog extends Dialog {
|
||||||
right.remove(tool2);
|
right.remove(tool2);
|
||||||
left.add(ManagedBuildManager.getRealTool(tool2));
|
left.add(ManagedBuildManager.getRealTool(tool2));
|
||||||
|
|
||||||
tmod.changeProjectTools(tool2, tool1);
|
mod.changeProjectTools(tool2, tool1);
|
||||||
|
|
||||||
updateData();
|
updateData();
|
||||||
}
|
}
|
||||||
|
@ -257,7 +255,7 @@ public class ToolSelectionDialog extends Dialog {
|
||||||
private void removeArrows(Table t) {
|
private void removeArrows(Table t) {
|
||||||
for (int j=0; j<t.getItemCount(); j++) {
|
for (int j=0; j<t.getItemCount(); j++) {
|
||||||
TableItem ti = t.getItem(j);
|
TableItem ti = t.getItem(j);
|
||||||
if (ToolChainEditTab.IMG_ARROW.equals(ti.getImage()))
|
if (IMG_ARROW.equals(ti.getImage()))
|
||||||
ti.setImage((Image)null);
|
ti.setImage((Image)null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -274,7 +272,7 @@ public class ToolSelectionDialog extends Dialog {
|
||||||
if (x == -1)
|
if (x == -1)
|
||||||
return;
|
return;
|
||||||
ITool tool = (ITool)src.getItem(x).getData();
|
ITool tool = (ITool)src.getItem(x).getData();
|
||||||
IToolModification tm = tmod.getToolModification(tool);
|
IToolModification tm = mod.getToolModification(tool);
|
||||||
if (tm == null)
|
if (tm == null)
|
||||||
return;
|
return;
|
||||||
IModificationOperation[] mo = tm.getSupportedOperations();
|
IModificationOperation[] mo = tm.getSupportedOperations();
|
||||||
|
@ -288,7 +286,7 @@ public class ToolSelectionDialog extends Dialog {
|
||||||
if (t == null)
|
if (t == null)
|
||||||
b.setEnabled(true); // enable Add or Del
|
b.setEnabled(true); // enable Add or Del
|
||||||
else if (t.matches(tt)) {
|
else if (t.matches(tt)) {
|
||||||
ti.setImage(ToolChainEditTab.IMG_ARROW);
|
ti.setImage(IMG_ARROW);
|
||||||
break; // exit from modif. loop
|
break; // exit from modif. loop
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -331,11 +329,11 @@ public class ToolSelectionDialog extends Dialog {
|
||||||
private int adjustPosition(Table t) {
|
private int adjustPosition(Table t) {
|
||||||
int j = t.getSelectionIndex();
|
int j = t.getSelectionIndex();
|
||||||
TableItem ti = t.getItem(j);
|
TableItem ti = t.getItem(j);
|
||||||
if (ToolChainEditTab.IMG_ARROW.equals(ti.getImage()))
|
if (IMG_ARROW.equals(ti.getImage()))
|
||||||
return j;
|
return j;
|
||||||
for (j=0; j<t.getItemCount(); j++) {
|
for (j=0; j<t.getItemCount(); j++) {
|
||||||
ti = t.getItem(j);
|
ti = t.getItem(j);
|
||||||
if (ToolChainEditTab.IMG_ARROW.equals(ti.getImage())) {
|
if (IMG_ARROW.equals(ti.getImage())) {
|
||||||
t.select(j);
|
t.select(j);
|
||||||
return j;
|
return j;
|
||||||
}
|
}
|
||||||
|
@ -363,9 +361,9 @@ public class ToolSelectionDialog extends Dialog {
|
||||||
Image image = null;
|
Image image = null;
|
||||||
TableItem ti = t.getItem(x);
|
TableItem ti = t.getItem(x);
|
||||||
ITool tool = (ITool)ti.getData();
|
ITool tool = (ITool)ti.getData();
|
||||||
IToolModification tm = tmod.getToolModification(tool);
|
IToolModification tm = mod.getToolModification(tool);
|
||||||
if (tm == null || tm.isCompatible()) {
|
if (tm == null || tm.isCompatible()) {
|
||||||
if (ToolChainEditTab.IMG_ARROW.equals(ti.getImage()) && !isPrj) {
|
if (IMG_ARROW.equals(ti.getImage()) && !isPrj) {
|
||||||
TableItem[] tis = t2.getSelection();
|
TableItem[] tis = t2.getSelection();
|
||||||
if (tis != null && tis.length > 0) {
|
if (tis != null && tis.length > 0) {
|
||||||
message = Messages.getString("ToolSelectionDialog.16") + //$NON-NLS-1$
|
message = Messages.getString("ToolSelectionDialog.16") + //$NON-NLS-1$
|
||||||
|
@ -397,7 +395,7 @@ public class ToolSelectionDialog extends Dialog {
|
||||||
* @param bold - whether the tool should be marked by bold font.
|
* @param bold - whether the tool should be marked by bold font.
|
||||||
*/
|
*/
|
||||||
private void add(ITool tool, Table table, boolean bold) {
|
private void add(ITool tool, Table table, boolean bold) {
|
||||||
IToolModification tm = tmod.getToolModification(tool);
|
IToolModification tm = mod.getToolModification(tool);
|
||||||
TableItem ti = new TableItem(table, 0);
|
TableItem ti = new TableItem(table, 0);
|
||||||
ti.setText(tool.getUniqueRealName());
|
ti.setText(tool.getUniqueRealName());
|
||||||
if (bold)
|
if (bold)
|
||||||
|
@ -468,7 +466,7 @@ public class ToolSelectionDialog extends Dialog {
|
||||||
for (int j=0;j<tools[i].length;j++) {
|
for (int j=0;j<tools[i].length;j++) {
|
||||||
if (t.matches(tools[i][j])) {
|
if (t.matches(tools[i][j])) {
|
||||||
conflictTools.add(ti.getText());
|
conflictTools.add(ti.getText());
|
||||||
ti.setBackground(gray);
|
ti.setForeground(red);
|
||||||
break loop;
|
break loop;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -489,7 +487,7 @@ public class ToolSelectionDialog extends Dialog {
|
||||||
ITool t = (ITool)ti.getData();
|
ITool t = (ITool)ti.getData();
|
||||||
for (int i=0;i<tools.length;i++) {
|
for (int i=0;i<tools.length;i++) {
|
||||||
if (t.matches(tools[i])) {
|
if (t.matches(tools[i])) {
|
||||||
ti.setForeground(red);
|
// ti.setBackground(gray);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -505,8 +503,8 @@ public class ToolSelectionDialog extends Dialog {
|
||||||
s = s + Messages.getString("ToolSelectionDialog.11"); //$NON-NLS-1$
|
s = s + Messages.getString("ToolSelectionDialog.11"); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
errorLabel.setText(s);
|
errorLabel.setText(s);
|
||||||
if(getButton(IDialogConstants.OK_ID) != null)
|
// if(getButton(IDialogConstants.OK_ID) != null)
|
||||||
getButton(IDialogConstants.OK_ID).setEnabled(false);
|
// getButton(IDialogConstants.OK_ID).setEnabled(false);
|
||||||
}
|
}
|
||||||
if (t1_pos > -1 && t1_pos < t1.getItemCount())
|
if (t1_pos > -1 && t1_pos < t1.getItemCount())
|
||||||
t1.select(t1_pos);
|
t1.select(t1_pos);
|
||||||
|
|
Loading…
Add table
Reference in a new issue