mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-19 06:55:23 +02:00
bug 300707: Add ability to specify file-extension filter for build-options that support file browsing
Patch from Baltasar Belyavsky
This commit is contained in:
parent
c5147d8bc0
commit
ec0f826863
7 changed files with 118 additions and 0 deletions
|
@ -1306,6 +1306,13 @@ Additional special types exist to flag options of special relevance to the build
|
||||||
</restriction>
|
</restriction>
|
||||||
</simpleType>
|
</simpleType>
|
||||||
</attribute>
|
</attribute>
|
||||||
|
<attribute name="browseFilterExtensions" type="string">
|
||||||
|
<annotation>
|
||||||
|
<documentation>
|
||||||
|
An optional value that specifies a comma-separated string of file-extension filters for the underlying file browse-dialog. For filters with multiple extensions, use semicolon as a separator - eg. "*.lib;*.a;*.cmd,*.*". This attribute only applies when user chooses to browse the file-system, and only when browseType is 'file'.
|
||||||
|
</documentation>
|
||||||
|
</annotation>
|
||||||
|
</attribute>
|
||||||
<attribute name="value" type="string">
|
<attribute name="value" type="string">
|
||||||
<annotation>
|
<annotation>
|
||||||
<documentation>
|
<documentation>
|
||||||
|
|
|
@ -75,6 +75,8 @@ public interface IOption extends IBuildObject {
|
||||||
|
|
||||||
// Schema attribute names for option elements
|
// Schema attribute names for option elements
|
||||||
public static final String BROWSE_TYPE = "browseType"; //$NON-NLS-1$
|
public static final String BROWSE_TYPE = "browseType"; //$NON-NLS-1$
|
||||||
|
/** @since 7.0 */
|
||||||
|
public static final String BROWSE_FILTER_EXTENSIONS = "browseFilterExtensions"; //$NON-NLS-1$
|
||||||
public static final String CATEGORY = "category"; //$NON-NLS-1$
|
public static final String CATEGORY = "category"; //$NON-NLS-1$
|
||||||
public static final String COMMAND = "command"; //$NON-NLS-1$
|
public static final String COMMAND = "command"; //$NON-NLS-1$
|
||||||
public static final String COMMAND_FALSE = "commandFalse"; //$NON-NLS-1$
|
public static final String COMMAND_FALSE = "commandFalse"; //$NON-NLS-1$
|
||||||
|
@ -173,6 +175,20 @@ public interface IOption extends IBuildObject {
|
||||||
*/
|
*/
|
||||||
public void setBrowseType(int type);
|
public void setBrowseType(int type);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the setting of the browseFilterExtensions attribute. For options of {@link #BROWSE_FILE} type.
|
||||||
|
* @since 7.0
|
||||||
|
*/
|
||||||
|
public String[] getBrowseFilterExtensions();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the browseFilterExtensions attribute. For options of {@link #BROWSE_FILE} type.
|
||||||
|
* @param extensions - file extensions to show in browse files dialog
|
||||||
|
*
|
||||||
|
* @since 7.0
|
||||||
|
*/
|
||||||
|
public void setBrowseFilterExtensions(String[] extensions);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the setting of the resourceFilter attribute
|
* Returns the setting of the resourceFilter attribute
|
||||||
*
|
*
|
||||||
|
|
|
@ -56,6 +56,7 @@ public class Option extends BuildObject implements IOption, IBuildPropertiesRest
|
||||||
// Managed Build model attributes
|
// Managed Build model attributes
|
||||||
private String unusedChildren;
|
private String unusedChildren;
|
||||||
private Integer browseType;
|
private Integer browseType;
|
||||||
|
private String[] browseFilterExtensions;
|
||||||
private List builtIns;
|
private List builtIns;
|
||||||
private IOptionCategory category;
|
private IOptionCategory category;
|
||||||
private String categoryId;
|
private String categoryId;
|
||||||
|
@ -202,6 +203,9 @@ public class Option extends BuildObject implements IOption, IBuildPropertiesRest
|
||||||
if (option.browseType != null) {
|
if (option.browseType != null) {
|
||||||
browseType = new Integer(option.browseType.intValue());
|
browseType = new Integer(option.browseType.intValue());
|
||||||
}
|
}
|
||||||
|
if (option.browseFilterExtensions != null) {
|
||||||
|
browseFilterExtensions = option.browseFilterExtensions.clone();
|
||||||
|
}
|
||||||
if (option.resourceFilter != null) {
|
if (option.resourceFilter != null) {
|
||||||
resourceFilter = new Integer(option.resourceFilter.intValue());
|
resourceFilter = new Integer(option.resourceFilter.intValue());
|
||||||
}
|
}
|
||||||
|
@ -356,6 +360,12 @@ public class Option extends BuildObject implements IOption, IBuildPropertiesRest
|
||||||
browseType = new Integer(BROWSE_DIR);
|
browseType = new Integer(BROWSE_DIR);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Get the browseFilterExtensions attribute
|
||||||
|
String browseFilterExtensionsStr = element.getAttribute(BROWSE_FILTER_EXTENSIONS);
|
||||||
|
if (browseFilterExtensionsStr != null) {
|
||||||
|
this.browseFilterExtensions = browseFilterExtensionsStr.split("\\s*,\\s*"); //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
|
||||||
categoryId = element.getAttribute(CATEGORY);
|
categoryId = element.getAttribute(CATEGORY);
|
||||||
|
|
||||||
// Get the resourceFilter attribute
|
// Get the resourceFilter attribute
|
||||||
|
@ -588,6 +598,14 @@ public class Option extends BuildObject implements IOption, IBuildPropertiesRest
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Get the browseFilterExtensions attribute
|
||||||
|
if (element.getAttribute(BROWSE_FILTER_EXTENSIONS) != null) {
|
||||||
|
String browseFilterExtensionsStr = element.getAttribute(BROWSE_FILTER_EXTENSIONS);
|
||||||
|
if (browseFilterExtensionsStr != null) {
|
||||||
|
this.browseFilterExtensions = browseFilterExtensionsStr.split("\\s*,\\s*"); //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (element.getAttribute(CATEGORY) != null) {
|
if (element.getAttribute(CATEGORY) != null) {
|
||||||
categoryId = element.getAttribute(CATEGORY);
|
categoryId = element.getAttribute(CATEGORY);
|
||||||
if (categoryId != null) {
|
if (categoryId != null) {
|
||||||
|
@ -861,6 +879,15 @@ public class Option extends BuildObject implements IOption, IBuildPropertiesRest
|
||||||
element.setAttribute(BROWSE_TYPE, str);
|
element.setAttribute(BROWSE_TYPE, str);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// browse filter extensions
|
||||||
|
if (browseFilterExtensions != null) {
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
for(String ext : browseFilterExtensions) {
|
||||||
|
sb.append(ext + ',');
|
||||||
|
}
|
||||||
|
element.setAttribute(BROWSE_FILTER_EXTENSIONS, sb.toString());
|
||||||
|
}
|
||||||
|
|
||||||
if (categoryId != null) {
|
if (categoryId != null) {
|
||||||
element.setAttribute(CATEGORY, categoryId);
|
element.setAttribute(CATEGORY, categoryId);
|
||||||
}
|
}
|
||||||
|
@ -985,6 +1012,20 @@ public class Option extends BuildObject implements IOption, IBuildPropertiesRest
|
||||||
return browseType.intValue();
|
return browseType.intValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.managedbuilder.core.IOption#getBrowseFilterExtensions()
|
||||||
|
*/
|
||||||
|
public String[] getBrowseFilterExtensions() {
|
||||||
|
if (browseFilterExtensions == null) {
|
||||||
|
if (superClass != null) {
|
||||||
|
return superClass.getBrowseFilterExtensions();
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return browseFilterExtensions.clone();
|
||||||
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.managedbuilder.core.IOption#getResourceFilter()
|
* @see org.eclipse.cdt.managedbuilder.core.IOption#getResourceFilter()
|
||||||
*/
|
*/
|
||||||
|
@ -1674,6 +1715,19 @@ public class Option extends BuildObject implements IOption, IBuildPropertiesRest
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.managedbuilder.core.IOption#setBrowseFilterExtensions(java.lang.String[])
|
||||||
|
*/
|
||||||
|
public void setBrowseFilterExtensions(String[] extensions) {
|
||||||
|
if (browseFilterExtensions == null || !(browseFilterExtensions.equals(extensions))) {
|
||||||
|
browseFilterExtensions = extensions;
|
||||||
|
if(!isExtensionElement()) {
|
||||||
|
isDirty = true;
|
||||||
|
rebuildState = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.managedbuilder.core.IOption#setValue(boolean)
|
* @see org.eclipse.cdt.managedbuilder.core.IOption#setValue(boolean)
|
||||||
*/
|
*/
|
||||||
|
@ -1901,6 +1955,7 @@ public class Option extends BuildObject implements IOption, IBuildPropertiesRest
|
||||||
if (superClass != null &&
|
if (superClass != null &&
|
||||||
unusedChildren == null &&
|
unusedChildren == null &&
|
||||||
browseType == null &&
|
browseType == null &&
|
||||||
|
browseFilterExtensions == null &&
|
||||||
(builtIns == null || builtIns.size() == 0) &&
|
(builtIns == null || builtIns.size() == 0) &&
|
||||||
category == null &&
|
category == null &&
|
||||||
categoryId == null &&
|
categoryId == null &&
|
||||||
|
|
|
@ -476,6 +476,13 @@ public class OptionReference implements IOption {
|
||||||
return option.getBrowseType();
|
return option.getBrowseType();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.managedbuilder.core.IOption#getBrowseFilterExtensions()
|
||||||
|
*/
|
||||||
|
public String[] getBrowseFilterExtensions() {
|
||||||
|
return option.getBrowseFilterExtensions();
|
||||||
|
}
|
||||||
|
|
||||||
private List getBuiltInList() {
|
private List getBuiltInList() {
|
||||||
if (builtIns == null) {
|
if (builtIns == null) {
|
||||||
builtIns = new ArrayList();
|
builtIns = new ArrayList();
|
||||||
|
@ -786,6 +793,12 @@ public class OptionReference implements IOption {
|
||||||
public void setBrowseType(int type) {
|
public void setBrowseType(int type) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.managedbuilder.core.IOption#setBrowseFilterExtensions(java.lang.String[])
|
||||||
|
*/
|
||||||
|
public void setBrowseFilterExtensions(String[] extensions) {
|
||||||
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.build.managed.IOption#setCategory(org.eclipse.cdt.core.build.managed.IOptionCategory)
|
* @see org.eclipse.cdt.core.build.managed.IOption#setCategory(org.eclipse.cdt.core.build.managed.IOptionCategory)
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -226,6 +226,7 @@ public class BuildOptionSettingsUI extends AbstractToolSettingUI {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
((FileFieldEditor)stringField).setFileExtensions(opt.getBrowseFilterExtensions());
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case IOption.BROWSE_NONE: {
|
case IOption.BROWSE_NONE: {
|
||||||
|
@ -325,6 +326,8 @@ public class BuildOptionSettingsUI extends AbstractToolSettingUI {
|
||||||
String tooltipHoverStr = displayFixedTip ? null : tipStr;
|
String tooltipHoverStr = displayFixedTip ? null : tipStr;
|
||||||
fieldEditor = new FileListControlFieldEditor(optId, nameStr,
|
fieldEditor = new FileListControlFieldEditor(optId, nameStr,
|
||||||
tooltipHoverStr, contextId, fieldEditorParent, opt.getBrowseType());
|
tooltipHoverStr, contextId, fieldEditorParent, opt.getBrowseType());
|
||||||
|
((FileListControlFieldEditor)fieldEditor).setFilterExtensions(opt.getBrowseFilterExtensions());
|
||||||
|
|
||||||
if (pageHasToolTipBox) {
|
if (pageHasToolTipBox) {
|
||||||
Label label = fieldEditor.getLabelControl(fieldEditorParent);
|
Label label = fieldEditor.getLabelControl(fieldEditorParent);
|
||||||
label.setData(new TipInfo(nameStr,tipStr));
|
label.setData(new TipInfo(nameStr,tipStr));
|
||||||
|
|
|
@ -142,6 +142,16 @@ public class FileListControlFieldEditor extends FieldEditor {
|
||||||
// this.values = parseString(value);
|
// this.values = parseString(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the filter-extensions for the underlying Browse dialog. Only applies when browseType is 'file'.
|
||||||
|
* @param filterExtensions
|
||||||
|
*
|
||||||
|
* @since 7.0
|
||||||
|
*/
|
||||||
|
public void setFilterExtensions(String[] filterExtensions) {
|
||||||
|
list.setFilterExtensions(filterExtensions);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fills this field editor's basic controls into the given parent.
|
* Fills this field editor's basic controls into the given parent.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -319,6 +319,9 @@ public class FileListControl {
|
||||||
if (currentName != null && currentName.trim().length() != 0) {
|
if (currentName != null && currentName.trim().length() != 0) {
|
||||||
browseDialog.setFilterPath(currentName);
|
browseDialog.setFilterPath(currentName);
|
||||||
}
|
}
|
||||||
|
if (FileListControl.this.filterExtensions != null) {
|
||||||
|
browseDialog.setFilterExtensions(FileListControl.this.filterExtensions);
|
||||||
|
}
|
||||||
result = browseDialog.open();
|
result = browseDialog.open();
|
||||||
if (result != null) {
|
if (result != null) {
|
||||||
fSetByBrowseDialog = true;
|
fSetByBrowseDialog = true;
|
||||||
|
@ -465,6 +468,7 @@ public class FileListControl {
|
||||||
|
|
||||||
// The type of browse support that is required
|
// The type of browse support that is required
|
||||||
private int browseType;
|
private int browseType;
|
||||||
|
private String[] filterExtensions;
|
||||||
/** The base path that should be used when adding new resources */
|
/** The base path that should be used when adding new resources */
|
||||||
private IPath path = new Path(""); //$NON-NLS-1$
|
private IPath path = new Path(""); //$NON-NLS-1$
|
||||||
|
|
||||||
|
@ -955,6 +959,16 @@ public class FileListControl {
|
||||||
promptForDelete = type == BROWSE_FILE || type == BROWSE_DIR;
|
promptForDelete = type == BROWSE_FILE || type == BROWSE_DIR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the filter-extensions for the underlying Browse dialog. Only applies when browseType is 'file'.
|
||||||
|
* @param filterExtensions
|
||||||
|
*
|
||||||
|
* @since 5.2
|
||||||
|
*/
|
||||||
|
public void setFilterExtensions(String[] filterExtensions) {
|
||||||
|
this.filterExtensions = filterExtensions;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enable/Disable workspace support. If enabled, the workspace browse button
|
* Enable/Disable workspace support. If enabled, the workspace browse button
|
||||||
* will be visible in the SelectPathInputDialog.
|
* will be visible in the SelectPathInputDialog.
|
||||||
|
|
Loading…
Add table
Reference in a new issue