mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-23 14:42:11 +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 */
|
||||
fListEditor.setWorkspaceSupport(true);
|
||||
|
||||
fListEditor.setContext(fMacrosBlock.getContextInfo());
|
||||
|
||||
if(fEditedMacro != null){
|
||||
loadMacroSettings(fEditedMacro,true);
|
||||
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.IOptionCategory;
|
||||
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.Tool;
|
||||
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.MacroResolver;
|
||||
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.macros.BuildMacroException;
|
||||
import org.eclipse.cdt.managedbuilder.macros.IBuildMacro;
|
||||
import org.eclipse.cdt.ui.dialogs.ICOptionContainer;
|
||||
import org.eclipse.jface.preference.IPreferenceStore;
|
||||
import org.eclipse.jface.util.IPropertyChangeListener;
|
||||
import org.eclipse.jface.util.ListenerList;
|
||||
|
@ -220,7 +224,7 @@ public class BuildToolSettingsPreferenceStore implements IPreferenceStore {
|
|||
null,
|
||||
EMPTY_STRING,
|
||||
WHITESPACE,
|
||||
block.obtainMacroProvider())),
|
||||
obtainMacroProvider())),
|
||||
WHITESPACE);
|
||||
} catch (BuildException e) {
|
||||
}
|
||||
|
@ -236,6 +240,12 @@ public class BuildToolSettingsPreferenceStore implements IPreferenceStore {
|
|||
return getDefaultString(name);
|
||||
}
|
||||
|
||||
public BuildMacroProvider obtainMacroProvider(){
|
||||
if(block != null)
|
||||
return block.obtainMacroProvider();
|
||||
return (BuildMacroProvider)ManagedBuildManager.getBuildMacroProvider();
|
||||
}
|
||||
|
||||
public static String listToString(String[] items) {
|
||||
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.TypedViewerFilter;
|
||||
import org.eclipse.cdt.managedbuilder.core.IBuildObject;
|
||||
import org.eclipse.cdt.managedbuilder.core.IHoldsOptions;
|
||||
import org.eclipse.cdt.managedbuilder.core.IManagedProject;
|
||||
import org.eclipse.cdt.managedbuilder.core.IOption;
|
||||
import org.eclipse.cdt.managedbuilder.core.IResourceConfiguration;
|
||||
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.internal.macros.OptionContextData;
|
||||
import org.eclipse.cdt.managedbuilder.internal.macros.DefaultMacroSubstitutor;
|
||||
import org.eclipse.cdt.managedbuilder.internal.macros.IMacroContextInfo;
|
||||
import org.eclipse.cdt.managedbuilder.internal.macros.MacroResolver;
|
||||
import org.eclipse.cdt.managedbuilder.internal.ui.ManagedBuilderUIImages;
|
||||
import org.eclipse.cdt.managedbuilder.internal.ui.ManagedBuilderUIMessages;
|
||||
import org.eclipse.cdt.managedbuilder.macros.BuildMacroException;
|
||||
|
@ -141,15 +138,13 @@ public class FileListControl {
|
|||
IResource resource = null;
|
||||
|
||||
currentPathText = getText().getText();
|
||||
if(option != null && holder != null){
|
||||
if(contextInfo != null){
|
||||
try {
|
||||
currentPathText = ManagedBuildManager.getBuildMacroProvider().
|
||||
resolveValue(
|
||||
currentPathText,
|
||||
"", //$NON-NLS-1$
|
||||
" ", //$NON-NLS-1$
|
||||
IBuildMacroProvider.CONTEXT_OPTION,
|
||||
new OptionContextData(option, holder));
|
||||
currentPathText =
|
||||
MacroResolver.resolveToString(currentPathText,
|
||||
new DefaultMacroSubstitutor(contextInfo ,
|
||||
"", //$NON-NLS-1$
|
||||
" ")); //$NON-NLS-1$
|
||||
} catch (BuildMacroException e) {
|
||||
}
|
||||
}
|
||||
|
@ -160,13 +155,7 @@ public class FileListControl {
|
|||
/* Resolve variables */
|
||||
IStringVariableManager variableManager =
|
||||
VariablesPlugin.getDefault().getStringVariableManager();
|
||||
/*
|
||||
try {
|
||||
currentPathText = variableManager.performStringSubstitution(
|
||||
currentPathText, false);
|
||||
} catch (CoreException e)
|
||||
{}
|
||||
*/
|
||||
|
||||
/* Remove workspace location prefix (if any) */
|
||||
path = new Path(currentPathText);
|
||||
IPath workspacePath = ResourcesPlugin.getWorkspace().getRoot().getLocation();
|
||||
|
@ -180,18 +169,8 @@ public class FileListControl {
|
|||
if (!path.toString().trim().equals("")) { //$NON-NLS-1$
|
||||
resource = ResourcesPlugin.getWorkspace().getRoot().findMember(path);
|
||||
}
|
||||
if (resource == null){
|
||||
if(holder instanceof ITool){
|
||||
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();
|
||||
}
|
||||
}
|
||||
if (resource == null)
|
||||
resource = rc;
|
||||
|
||||
/* Create workspace folder/file selection dialog and
|
||||
* set initial selection */
|
||||
|
@ -237,7 +216,7 @@ public class FileListControl {
|
|||
|
||||
if (resource != null) {
|
||||
getText().setText(variableManager.generateVariableExpression(WORKSPACELOC_VAR,
|
||||
resource.getFullPath().toOSString()));
|
||||
resource.getFullPath().toString()));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -335,8 +314,8 @@ public class FileListControl {
|
|||
|
||||
/* Workspace support */
|
||||
private boolean fWorkspaceSupport = false;
|
||||
private IOption option;
|
||||
private IHoldsOptions holder;
|
||||
private IMacroContextInfo contextInfo;
|
||||
private IResource rc;
|
||||
|
||||
private java.util.List listeners = new ArrayList();
|
||||
private String oldValue[];
|
||||
|
@ -754,16 +733,22 @@ public class FileListControl {
|
|||
public void setWorkspaceSupport(boolean enable) {
|
||||
fWorkspaceSupport = enable;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set the project the field editor was created for.
|
||||
* Set the field editor context.
|
||||
* @param project
|
||||
*/
|
||||
public void setContext(IOption option, IHoldsOptions holder) {
|
||||
this.option = option;
|
||||
this.holder = holder;
|
||||
public void setContext(IMacroContextInfo info) {
|
||||
contextInfo = info;
|
||||
for(;info != null;info = info.getNext()){
|
||||
if(info.getContextType() == IBuildMacroProvider.CONTEXT_PROJECT){
|
||||
IManagedProject mngProj = (IManagedProject)info.getContextData();
|
||||
this.rc = mngProj.getOwner();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the input dialog string
|
||||
*
|
||||
|
|
|
@ -18,6 +18,8 @@ import java.util.StringTokenizer;
|
|||
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
|
||||
import org.eclipse.cdt.managedbuilder.core.IHoldsOptions;
|
||||
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.jface.preference.FieldEditor;
|
||||
import org.eclipse.jface.preference.IPreferenceStore;
|
||||
|
@ -205,9 +207,14 @@ public class FileListControlFieldEditor extends FieldEditor {
|
|||
/* Enable workspace support for list and set project */
|
||||
list.setWorkspaceSupport(true);
|
||||
if (store instanceof BuildToolSettingsPreferenceStore){
|
||||
Object[] option = ((BuildToolSettingsPreferenceStore)store).getOption(getPreferenceName());
|
||||
BuildToolSettingsPreferenceStore btsStore = ((BuildToolSettingsPreferenceStore)store);
|
||||
Object[] option = btsStore.getOption(getPreferenceName());
|
||||
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