mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-29 03:45:35 +02:00
Tool settings save: fix
This commit is contained in:
parent
6ddba293ac
commit
31a7f8ac8f
1 changed files with 39 additions and 70 deletions
|
@ -19,19 +19,17 @@ import java.util.Map;
|
||||||
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.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.IHoldsOptions;
|
import org.eclipse.cdt.managedbuilder.core.IHoldsOptions;
|
||||||
import org.eclipse.cdt.managedbuilder.core.IOption;
|
import org.eclipse.cdt.managedbuilder.core.IOption;
|
||||||
import org.eclipse.cdt.managedbuilder.core.IOptionCategory;
|
import org.eclipse.cdt.managedbuilder.core.IOptionCategory;
|
||||||
import org.eclipse.cdt.managedbuilder.core.IResourceConfiguration;
|
import org.eclipse.cdt.managedbuilder.core.IResourceConfiguration;
|
||||||
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;
|
||||||
import org.eclipse.cdt.managedbuilder.core.IToolChain;
|
|
||||||
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
|
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
|
||||||
import org.eclipse.cdt.managedbuilder.internal.macros.BuildMacroProvider;
|
import org.eclipse.cdt.managedbuilder.internal.macros.BuildMacroProvider;
|
||||||
import org.eclipse.core.resources.IFile;
|
|
||||||
import org.eclipse.core.resources.IResource;
|
import org.eclipse.core.resources.IResource;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
|
||||||
import org.eclipse.core.runtime.IProgressMonitor;
|
|
||||||
import org.eclipse.jface.preference.IPreferencePageContainer;
|
import org.eclipse.jface.preference.IPreferencePageContainer;
|
||||||
import org.eclipse.jface.preference.IPreferenceStore;
|
import org.eclipse.jface.preference.IPreferenceStore;
|
||||||
import org.eclipse.jface.viewers.ISelectionChangedListener;
|
import org.eclipse.jface.viewers.ISelectionChangedListener;
|
||||||
|
@ -77,11 +75,8 @@ public class ToolSettingsTab extends AbstractCBuildPropertyTab implements IPrefe
|
||||||
private ToolListContentProvider listprovider;
|
private ToolListContentProvider listprovider;
|
||||||
private Object propertyObject;
|
private Object propertyObject;
|
||||||
|
|
||||||
private boolean defaultNeeded;
|
|
||||||
|
|
||||||
private IResourceInfo fInfo;
|
private IResourceInfo fInfo;
|
||||||
|
|
||||||
|
|
||||||
public void createControls(Composite par) {
|
public void createControls(Composite par) {
|
||||||
super.createControls(par);
|
super.createControls(par);
|
||||||
usercomp.setLayout(new GridLayout());
|
usercomp.setLayout(new GridLayout());
|
||||||
|
@ -365,9 +360,6 @@ public class ToolSettingsTab extends AbstractCBuildPropertyTab implements IPrefe
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeValues(String id) {
|
|
||||||
}
|
|
||||||
|
|
||||||
private void handleOptionSelection() {
|
private void handleOptionSelection() {
|
||||||
// Get the selection from the tree list
|
// Get the selection from the tree list
|
||||||
if (optionList == null) return;
|
if (optionList == null) return;
|
||||||
|
@ -418,64 +410,42 @@ public class ToolSettingsTab extends AbstractCBuildPropertyTab implements IPrefe
|
||||||
selectedElement = null;
|
selectedElement = null;
|
||||||
handleOptionSelection();
|
handleOptionSelection();
|
||||||
setDirty(true);
|
setDirty(true);
|
||||||
defaultNeeded = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* (non-Javadoc)
|
* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.ui.dialogs.ICOptionPage#performApply(IProgressMonitor)
|
* @see org.eclipse.cdt.ui.dialogs.ICOptionPage#performApply(IProgressMonitor)
|
||||||
*/
|
*/
|
||||||
public void performApply(IProgressMonitor monitor) throws CoreException {
|
private void copyHoldsOptions(IHoldsOptions src, IHoldsOptions dst, IResourceInfo res){
|
||||||
if(defaultNeeded){
|
if(src instanceof ITool) {
|
||||||
if(propertyObject instanceof IFile)
|
ITool t1 = (ITool)src;
|
||||||
ManagedBuildManager.resetResourceConfiguration(page.getProject(), getCfg().getResourceConfiguration(((IFile)propertyObject).getFullPath().toOSString()));
|
ITool t2 = (ITool)dst;
|
||||||
else
|
if (t1.getCustomBuildStep()) return;
|
||||||
ManagedBuildManager.resetConfiguration(page.getProject(), getCfg());
|
t2.setToolCommand(t1.getToolCommand());
|
||||||
defaultNeeded = false;
|
t2.setCommandLinePattern(t1.getCommandLinePattern());
|
||||||
}
|
}
|
||||||
saveConfig();
|
IOption op1[] = src.getOptions();
|
||||||
setDirty(false);
|
IOption op2[] = dst.getOptions();
|
||||||
}
|
for(int i = 0; i < op1.length; i++) {
|
||||||
|
setOption(op1[i], op2[i], dst, res);
|
||||||
private void saveHoldsOptions(IHoldsOptions holder){
|
|
||||||
if(holder instanceof ITool && ((ITool)holder).getCustomBuildStep())
|
|
||||||
return;
|
|
||||||
if(holder instanceof ITool) {
|
|
||||||
String currentValue = ((ITool)holder).getToolCommand();
|
|
||||||
if (!(currentValue.equals(((ITool)holder).getToolCommand()))) {
|
|
||||||
((ITool)holder).setToolCommand(((ITool)holder).getToolCommand());
|
|
||||||
fInfo.setRebuildState(true);
|
|
||||||
}
|
|
||||||
currentValue = ((ITool)holder).getCommandLinePattern();
|
|
||||||
if (!(currentValue.equals(((ITool)holder).getCommandLinePattern()))) {
|
|
||||||
((ITool)holder).setCommandLinePattern(((ITool)holder).getCommandLinePattern());
|
|
||||||
fInfo.setRebuildState(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
IOption options[] = holder.getOptions();
|
|
||||||
for(int i = 0; i < options.length; i++) {
|
|
||||||
saveOption(options[i], holder);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void saveOption(IOption option, IHoldsOptions holder){
|
private void setOption(IOption op1, IOption op2, IHoldsOptions dst, IResourceInfo res){
|
||||||
// IResourceInfo info = fCfg;
|
|
||||||
try {
|
try {
|
||||||
IOption setOption = null;
|
switch (op1.getValueType()) {
|
||||||
// Transfer value from preference store to options
|
|
||||||
switch (option.getValueType()) {
|
|
||||||
case IOption.BOOLEAN :
|
case IOption.BOOLEAN :
|
||||||
boolean boolVal = option.getBooleanValue();
|
boolean boolVal = op1.getBooleanValue();
|
||||||
setOption = ManagedBuildManager.setOption(fInfo, holder, option, boolVal);
|
ManagedBuildManager.setOption(res, dst, op2, boolVal);
|
||||||
break;
|
break;
|
||||||
case IOption.ENUMERATED :
|
case IOption.ENUMERATED :
|
||||||
String enumVal = option.getStringValue();
|
String enumVal = op1.getStringValue();
|
||||||
String enumId = option.getEnumeratedId(enumVal);
|
String enumId = op1.getEnumeratedId(enumVal);
|
||||||
String out = (enumId != null && enumId.length() > 0) ? enumId : enumVal;
|
String out = (enumId != null && enumId.length() > 0) ? enumId : enumVal;
|
||||||
setOption = ManagedBuildManager.setOption(fInfo, holder, option, out);
|
ManagedBuildManager.setOption(res, dst, op2, out);
|
||||||
break;
|
break;
|
||||||
case IOption.STRING :
|
case IOption.STRING :
|
||||||
setOption = ManagedBuildManager.setOption(fInfo, holder, option, option.getStringValue());
|
ManagedBuildManager.setOption(res, dst, op2, op1.getStringValue());
|
||||||
break;
|
break;
|
||||||
case IOption.STRING_LIST :
|
case IOption.STRING_LIST :
|
||||||
case IOption.INCLUDE_PATH :
|
case IOption.INCLUDE_PATH :
|
||||||
|
@ -492,30 +462,15 @@ public class ToolSettingsTab extends AbstractCBuildPropertyTab implements IPrefe
|
||||||
case IOption.UNDEF_LIBRARY_PATHS:
|
case IOption.UNDEF_LIBRARY_PATHS:
|
||||||
case IOption.UNDEF_LIBRARY_FILES:
|
case IOption.UNDEF_LIBRARY_FILES:
|
||||||
case IOption.UNDEF_MACRO_FILES:
|
case IOption.UNDEF_MACRO_FILES:
|
||||||
String[] data = (String[])((List)option.getValue()).toArray(new String[0]);
|
String[] data = (String[])((List)op1.getValue()).toArray(new String[0]);
|
||||||
setOption = ManagedBuildManager.setOption(fInfo, holder, option, data);
|
ManagedBuildManager.setOption(res, dst, op2, data);
|
||||||
break;
|
break;
|
||||||
default :
|
default :
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Call an MBS CallBack function to inform that Settings related to Apply/OK button
|
|
||||||
// press have been applied.
|
|
||||||
if (setOption == null) setOption = option;
|
|
||||||
} catch (BuildException e) {
|
} catch (BuildException e) {
|
||||||
} catch (ClassCastException e) {
|
} catch (ClassCastException e) {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private void saveConfig(){
|
|
||||||
IToolChain tc = fInfo.getParent().getToolChain();
|
|
||||||
saveHoldsOptions(tc);
|
|
||||||
|
|
||||||
ITool tools[] = fInfo.getParent().getFilteredTools();
|
|
||||||
for(int i = 0; i < tools.length; i++){
|
|
||||||
saveHoldsOptions(tools[i]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean containsDefaults(){
|
protected boolean containsDefaults(){
|
||||||
|
@ -634,8 +589,22 @@ public class ToolSettingsTab extends AbstractCBuildPropertyTab implements IPrefe
|
||||||
setValues();
|
setValues();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void performApply(ICResourceDescription src, ICResourceDescription dst) {
|
protected void performApply(ICResourceDescription src, ICResourceDescription dst) {
|
||||||
|
IResourceInfo ri1 = getResCfg(src);
|
||||||
|
IResourceInfo ri2 = getResCfg(dst);
|
||||||
|
copyHoldsOptions(ri1.getParent().getToolChain(), ri2.getParent().getToolChain(), ri2);
|
||||||
|
ITool[] t1, t2;
|
||||||
|
if (ri1 instanceof IFolderInfo){
|
||||||
|
t1 = ((IFolderInfo)ri1).getFilteredTools();
|
||||||
|
t2 = ((IFolderInfo)ri2).getFilteredTools();
|
||||||
|
} else if (ri1 instanceof IFileInfo) {
|
||||||
|
t1 = ((IFileInfo)ri1).getToolsToInvoke();
|
||||||
|
t2 = ((IFileInfo)ri2).getToolsToInvoke();
|
||||||
|
} else return;
|
||||||
|
if (t1.length != t2.length) return; // not our case
|
||||||
|
for (int i=0; i<t1.length; i++)
|
||||||
|
copyHoldsOptions(t1[i], t2[i], ri2);
|
||||||
|
setDirty(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
// IPreferencePageContainer methods
|
// IPreferencePageContainer methods
|
||||||
|
|
Loading…
Add table
Reference in a new issue