mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-08 10:16:03 +02:00
Fix for browsing workspace functionality in the FileListControl
This commit is contained in:
parent
34a2d013f9
commit
20a2976398
4 changed files with 50 additions and 46 deletions
|
@ -236,6 +236,8 @@ public class NewBuildMacroDialog extends StatusDialog {
|
||||||
/* Enable workspace support for list editor */
|
/* Enable workspace support for list editor */
|
||||||
fListEditor.setWorkspaceSupport(true);
|
fListEditor.setWorkspaceSupport(true);
|
||||||
|
|
||||||
|
fListEditor.setContext(fMacrosBlock.getContextInfo());
|
||||||
|
|
||||||
if(fEditedMacro != null){
|
if(fEditedMacro != null){
|
||||||
loadMacroSettings(fEditedMacro,true);
|
loadMacroSettings(fEditedMacro,true);
|
||||||
fMacroNameEdit.setEnabled(false);
|
fMacroNameEdit.setEnabled(false);
|
||||||
|
|
|
@ -18,6 +18,7 @@ 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.ManagedBuildManager;
|
||||||
import org.eclipse.cdt.managedbuilder.internal.core.Option;
|
import org.eclipse.cdt.managedbuilder.internal.core.Option;
|
||||||
import org.eclipse.cdt.managedbuilder.internal.core.Tool;
|
import org.eclipse.cdt.managedbuilder.internal.core.Tool;
|
||||||
import org.eclipse.cdt.managedbuilder.internal.macros.BuildMacroProvider;
|
import org.eclipse.cdt.managedbuilder.internal.macros.BuildMacroProvider;
|
||||||
|
@ -25,9 +26,12 @@ import org.eclipse.cdt.managedbuilder.internal.macros.DefaultMacroSubstitutor;
|
||||||
import org.eclipse.cdt.managedbuilder.internal.macros.IMacroContextInfo;
|
import org.eclipse.cdt.managedbuilder.internal.macros.IMacroContextInfo;
|
||||||
import org.eclipse.cdt.managedbuilder.internal.macros.MacroResolver;
|
import org.eclipse.cdt.managedbuilder.internal.macros.MacroResolver;
|
||||||
import org.eclipse.cdt.managedbuilder.internal.macros.MbsMacroSupplier;
|
import org.eclipse.cdt.managedbuilder.internal.macros.MbsMacroSupplier;
|
||||||
|
import org.eclipse.cdt.managedbuilder.internal.ui.MacrosSetBlock;
|
||||||
|
import org.eclipse.cdt.managedbuilder.internal.ui.ManagedBuildOptionBlock;
|
||||||
import org.eclipse.cdt.managedbuilder.internal.ui.ToolsSettingsBlock;
|
import org.eclipse.cdt.managedbuilder.internal.ui.ToolsSettingsBlock;
|
||||||
import org.eclipse.cdt.managedbuilder.macros.BuildMacroException;
|
import org.eclipse.cdt.managedbuilder.macros.BuildMacroException;
|
||||||
import org.eclipse.cdt.managedbuilder.macros.IBuildMacro;
|
import org.eclipse.cdt.managedbuilder.macros.IBuildMacro;
|
||||||
|
import org.eclipse.cdt.ui.dialogs.ICOptionContainer;
|
||||||
import org.eclipse.jface.preference.IPreferenceStore;
|
import org.eclipse.jface.preference.IPreferenceStore;
|
||||||
import org.eclipse.jface.util.IPropertyChangeListener;
|
import org.eclipse.jface.util.IPropertyChangeListener;
|
||||||
import org.eclipse.jface.util.ListenerList;
|
import org.eclipse.jface.util.ListenerList;
|
||||||
|
@ -220,7 +224,7 @@ public class BuildToolSettingsPreferenceStore implements IPreferenceStore {
|
||||||
null,
|
null,
|
||||||
EMPTY_STRING,
|
EMPTY_STRING,
|
||||||
WHITESPACE,
|
WHITESPACE,
|
||||||
block.obtainMacroProvider())),
|
obtainMacroProvider())),
|
||||||
WHITESPACE);
|
WHITESPACE);
|
||||||
} catch (BuildException e) {
|
} catch (BuildException e) {
|
||||||
}
|
}
|
||||||
|
@ -236,6 +240,12 @@ public class BuildToolSettingsPreferenceStore implements IPreferenceStore {
|
||||||
return getDefaultString(name);
|
return getDefaultString(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public BuildMacroProvider obtainMacroProvider(){
|
||||||
|
if(block != null)
|
||||||
|
return block.obtainMacroProvider();
|
||||||
|
return (BuildMacroProvider)ManagedBuildManager.getBuildMacroProvider();
|
||||||
|
}
|
||||||
|
|
||||||
public static String listToString(String[] items) {
|
public static String listToString(String[] items) {
|
||||||
return listToString(items,DEFAULT_SEPERATOR);
|
return listToString(items,DEFAULT_SEPERATOR);
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,14 +17,11 @@ import java.util.Iterator;
|
||||||
|
|
||||||
import org.eclipse.cdt.internal.ui.dialogs.StatusInfo;
|
import org.eclipse.cdt.internal.ui.dialogs.StatusInfo;
|
||||||
import org.eclipse.cdt.internal.ui.dialogs.TypedViewerFilter;
|
import org.eclipse.cdt.internal.ui.dialogs.TypedViewerFilter;
|
||||||
import org.eclipse.cdt.managedbuilder.core.IBuildObject;
|
import org.eclipse.cdt.managedbuilder.core.IManagedProject;
|
||||||
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.IResourceConfiguration;
|
import org.eclipse.cdt.managedbuilder.internal.macros.DefaultMacroSubstitutor;
|
||||||
import org.eclipse.cdt.managedbuilder.core.ITool;
|
import org.eclipse.cdt.managedbuilder.internal.macros.IMacroContextInfo;
|
||||||
import org.eclipse.cdt.managedbuilder.core.IToolChain;
|
import org.eclipse.cdt.managedbuilder.internal.macros.MacroResolver;
|
||||||
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
|
|
||||||
import org.eclipse.cdt.managedbuilder.internal.macros.OptionContextData;
|
|
||||||
import org.eclipse.cdt.managedbuilder.internal.ui.ManagedBuilderUIImages;
|
import org.eclipse.cdt.managedbuilder.internal.ui.ManagedBuilderUIImages;
|
||||||
import org.eclipse.cdt.managedbuilder.internal.ui.ManagedBuilderUIMessages;
|
import org.eclipse.cdt.managedbuilder.internal.ui.ManagedBuilderUIMessages;
|
||||||
import org.eclipse.cdt.managedbuilder.macros.BuildMacroException;
|
import org.eclipse.cdt.managedbuilder.macros.BuildMacroException;
|
||||||
|
@ -141,15 +138,13 @@ public class FileListControl {
|
||||||
IResource resource = null;
|
IResource resource = null;
|
||||||
|
|
||||||
currentPathText = getText().getText();
|
currentPathText = getText().getText();
|
||||||
if(option != null && holder != null){
|
if(contextInfo != null){
|
||||||
try {
|
try {
|
||||||
currentPathText = ManagedBuildManager.getBuildMacroProvider().
|
currentPathText =
|
||||||
resolveValue(
|
MacroResolver.resolveToString(currentPathText,
|
||||||
currentPathText,
|
new DefaultMacroSubstitutor(contextInfo ,
|
||||||
"", //$NON-NLS-1$
|
"", //$NON-NLS-1$
|
||||||
" ", //$NON-NLS-1$
|
" ")); //$NON-NLS-1$
|
||||||
IBuildMacroProvider.CONTEXT_OPTION,
|
|
||||||
new OptionContextData(option, holder));
|
|
||||||
} catch (BuildMacroException e) {
|
} catch (BuildMacroException e) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -160,13 +155,7 @@ public class FileListControl {
|
||||||
/* Resolve variables */
|
/* Resolve variables */
|
||||||
IStringVariableManager variableManager =
|
IStringVariableManager variableManager =
|
||||||
VariablesPlugin.getDefault().getStringVariableManager();
|
VariablesPlugin.getDefault().getStringVariableManager();
|
||||||
/*
|
|
||||||
try {
|
|
||||||
currentPathText = variableManager.performStringSubstitution(
|
|
||||||
currentPathText, false);
|
|
||||||
} catch (CoreException e)
|
|
||||||
{}
|
|
||||||
*/
|
|
||||||
/* Remove workspace location prefix (if any) */
|
/* Remove workspace location prefix (if any) */
|
||||||
path = new Path(currentPathText);
|
path = new Path(currentPathText);
|
||||||
IPath workspacePath = ResourcesPlugin.getWorkspace().getRoot().getLocation();
|
IPath workspacePath = ResourcesPlugin.getWorkspace().getRoot().getLocation();
|
||||||
|
@ -180,18 +169,8 @@ public class FileListControl {
|
||||||
if (!path.toString().trim().equals("")) { //$NON-NLS-1$
|
if (!path.toString().trim().equals("")) { //$NON-NLS-1$
|
||||||
resource = ResourcesPlugin.getWorkspace().getRoot().findMember(path);
|
resource = ResourcesPlugin.getWorkspace().getRoot().findMember(path);
|
||||||
}
|
}
|
||||||
if (resource == null){
|
if (resource == null)
|
||||||
if(holder instanceof ITool){
|
resource = rc;
|
||||||
IBuildObject bo = ((ITool)holder).getParent();
|
|
||||||
if(bo instanceof IResourceConfiguration){
|
|
||||||
resource = ((IResourceConfiguration)bo).getParent().getOwner();
|
|
||||||
} else if(bo instanceof IToolChain){
|
|
||||||
resource = ((IToolChain)bo).getParent().getOwner();
|
|
||||||
}
|
|
||||||
} else if(holder instanceof IToolChain){
|
|
||||||
resource = ((IToolChain)holder).getParent().getOwner();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Create workspace folder/file selection dialog and
|
/* Create workspace folder/file selection dialog and
|
||||||
* set initial selection */
|
* set initial selection */
|
||||||
|
@ -237,7 +216,7 @@ public class FileListControl {
|
||||||
|
|
||||||
if (resource != null) {
|
if (resource != null) {
|
||||||
getText().setText(variableManager.generateVariableExpression(WORKSPACELOC_VAR,
|
getText().setText(variableManager.generateVariableExpression(WORKSPACELOC_VAR,
|
||||||
resource.getFullPath().toOSString()));
|
resource.getFullPath().toString()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -335,8 +314,8 @@ public class FileListControl {
|
||||||
|
|
||||||
/* Workspace support */
|
/* Workspace support */
|
||||||
private boolean fWorkspaceSupport = false;
|
private boolean fWorkspaceSupport = false;
|
||||||
private IOption option;
|
private IMacroContextInfo contextInfo;
|
||||||
private IHoldsOptions holder;
|
private IResource rc;
|
||||||
|
|
||||||
private java.util.List listeners = new ArrayList();
|
private java.util.List listeners = new ArrayList();
|
||||||
private String oldValue[];
|
private String oldValue[];
|
||||||
|
@ -756,12 +735,18 @@ public class FileListControl {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the project the field editor was created for.
|
* Set the field editor context.
|
||||||
* @param project
|
* @param project
|
||||||
*/
|
*/
|
||||||
public void setContext(IOption option, IHoldsOptions holder) {
|
public void setContext(IMacroContextInfo info) {
|
||||||
this.option = option;
|
contextInfo = info;
|
||||||
this.holder = holder;
|
for(;info != null;info = info.getNext()){
|
||||||
|
if(info.getContextType() == IBuildMacroProvider.CONTEXT_PROJECT){
|
||||||
|
IManagedProject mngProj = (IManagedProject)info.getContextData();
|
||||||
|
this.rc = mngProj.getOwner();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -18,6 +18,8 @@ import java.util.StringTokenizer;
|
||||||
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
|
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
|
||||||
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.internal.macros.OptionContextData;
|
||||||
|
import org.eclipse.cdt.managedbuilder.macros.IBuildMacroProvider;
|
||||||
import org.eclipse.core.resources.IResource;
|
import org.eclipse.core.resources.IResource;
|
||||||
import org.eclipse.jface.preference.FieldEditor;
|
import org.eclipse.jface.preference.FieldEditor;
|
||||||
import org.eclipse.jface.preference.IPreferenceStore;
|
import org.eclipse.jface.preference.IPreferenceStore;
|
||||||
|
@ -205,9 +207,14 @@ public class FileListControlFieldEditor extends FieldEditor {
|
||||||
/* Enable workspace support for list and set project */
|
/* Enable workspace support for list and set project */
|
||||||
list.setWorkspaceSupport(true);
|
list.setWorkspaceSupport(true);
|
||||||
if (store instanceof BuildToolSettingsPreferenceStore){
|
if (store instanceof BuildToolSettingsPreferenceStore){
|
||||||
Object[] option = ((BuildToolSettingsPreferenceStore)store).getOption(getPreferenceName());
|
BuildToolSettingsPreferenceStore btsStore = ((BuildToolSettingsPreferenceStore)store);
|
||||||
|
Object[] option = btsStore.getOption(getPreferenceName());
|
||||||
if(option != null){
|
if(option != null){
|
||||||
list.setContext((IOption)option[1], (IHoldsOptions)option[0]);
|
list.setContext(
|
||||||
|
btsStore.obtainMacroProvider().getMacroContextInfo(
|
||||||
|
IBuildMacroProvider.CONTEXT_OPTION,
|
||||||
|
new OptionContextData((IOption)option[1],
|
||||||
|
(IHoldsOptions)option[0])));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue