-
Notifications
You must be signed in to change notification settings - Fork 121
UI support for setting filter attribute in feature editor #1942
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
cbb0d90 to
78bca44
Compare
|
|
||
| @Override | ||
| public String getFilter() { | ||
| // TODO Auto-generated method stub |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO should be rempved
| @Override | ||
| public String getFilter() { | ||
| // TODO Auto-generated method stub | ||
| return version; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| return version; | |
| return filter; |
| <classpathentry kind="src" path="xslt"/> | ||
| <classpathentry kind="output" path="bin"/> | ||
| </classpath> | ||
| </classpath> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please revert whit-space only changes
| } | ||
|
|
||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do not include unrelated changes
| ((IFeatureImport) fCurrentImport).setFilter(filter); | ||
| } | ||
| } catch (InvalidSyntaxException e) { | ||
| PDEPlugin.logException(e); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should not be logged but create an error marker, so this likely is better done in the Feature Validation process and when users are typing in a filter than during storing of the filter.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If there is already a utility code fr this it is of course perfectly valid to reuse that.
|
Thank you for the feedback @laeubi. I'll address those changes and update the pull request. |
841e6ef to
eb94655
Compare
Co-authored-by: Brandon Algarra <[email protected]> Co-authored-by: Khang Nguyen <[email protected]>
|
Hi @HannesWell, just wanted to follow up on this pull request. We have addressed the feedback given by @laeubi and would like to know if there is anything else needed before it gets merged. Thank you for your time! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds filter support to plugin and feature imports in PDE. The changes introduce a new "filter" field to the MatchSection UI component, allowing users to specify OSGi filter expressions for conditional dependencies.
Key changes:
- Added filter field UI components to MatchSection with validation
- Extended IPluginImport API with getFilter() and setFilter() methods
- Implemented filter property storage in PluginImport and PluginImportNode classes
Reviewed Changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| pderesources.properties | Added UI labels for filter field and error message |
| PDEUIMessages.java | Added constants for filter-related messages |
| ControlValidationUtility.java | Added validateFilterField() method for filter validation |
| MatchSection.java | Added filter field UI, validation, and handlers to the match section |
| IPluginImport.java | Added P_FILTER constant and filter getter/setter methods to the API |
| PluginImport.java | Implemented filter property storage and change notification |
| PluginImportNode.java | Implemented filter getter/setter for XML-based plugin imports |
Comments suppressed due to low confidence (3)
ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/plugin/PluginImport.java:240
- The
restorePropertymethod is missing a case forP_FILTER. When the filter property is changed and needs to be restored (e.g., during undo/redo operations), the method won't handle it correctly. Add a case to check forP_FILTERand callsetFilter()accordingly.
public void restoreProperty(String name, Object oldValue, Object newValue) throws CoreException {
if (name.equals(P_MATCH)) {
setMatch(((Integer) newValue).intValue());
return;
}
if (name.equals(P_REEXPORTED)) {
setReexported(((Boolean) newValue).booleanValue());
return;
}
if (name.equals(P_OPTIONAL)) {
setOptional(((Boolean) newValue).booleanValue());
return;
}
if (name.equals(P_VERSION)) {
setVersion(newValue != null ? newValue.toString() : null);
return;
}
super.restoreProperty(name, oldValue, newValue);
}
ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/editor/plugin/MatchSection.java:97
- The
cancelEditmethod only cancels edits forfVersionTextbut not forfFilterText. This could leave uncommitted changes in the filter field when the user cancels editing. AddfFilterText.cancelEdit()to ensure consistent behavior.
public void cancelEdit() {
fVersionText.cancelEdit();
super.cancelEdit();
}
ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/editor/plugin/MatchSection.java:91
- The
commitmethod commits version text but doesn't commit filter text changes. This means filter field changes won't be persisted when the form is saved. AddfFilterText.commit()to ensure filter changes are saved properly.
public void commit(boolean onSave) {
if (isDirty() == false) {
return;
}
if (fCurrentImport != null && fVersionText.getText().isEnabled()) {
fVersionText.commit();
String value = fVersionText.getValue();
int match = IMatchRules.NONE;
if (value != null && value.length() > 0) {
applyVersion(value);
match = getMatch();
}
applyMatch(match);
}
super.commit(onSave);
}
| private void applyFilter(String filter) { | ||
| try { | ||
| if (fCurrentImport == null) | ||
| return; | ||
| if (filter == null || filter.isEmpty()) | ||
| ((IFeatureImport) fCurrentImport).setFilter(null); | ||
| else { | ||
| FrameworkUtil.createFilter(filter); | ||
| ((IFeatureImport) fCurrentImport).setFilter(filter); | ||
| } | ||
| } catch (InvalidSyntaxException e) { | ||
| } catch (CoreException e) { | ||
| PDEPlugin.logException(e); | ||
| } | ||
| } |
Copilot
AI
Oct 31, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The method unconditionally casts fCurrentImport to IFeatureImport, but MatchSection is also used for plugin imports (IPluginImport) in DependenciesPage. This will cause a ClassCastException when used in the plugin context. The code should check the type and cast appropriately to either IPluginImport or IFeatureImport, both of which support the filter property.
|
|
||
| resetMatchCombo(fCurrentImport); | ||
| fFilterText.setEditable(isEditable()); | ||
| fFilterText.setValue(((IFeatureImport) fCurrentImport).getFilter()); |
Copilot
AI
Oct 31, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The unconditional cast to IFeatureImport will cause a ClassCastException when MatchSection is used in the plugin dependencies context where fCurrentImport is an IPluginImport. Check the instance type and cast appropriately, as both IPluginImport and IFeatureImport support the filter property.
| fFilterText.setValue(((IFeatureImport) fCurrentImport).getFilter()); | |
| fFilterText.setValue(fCurrentImport.getFilter()); |
| FrameworkUtil.createFilter(filter); | ||
| ((IFeatureImport) fCurrentImport).setFilter(filter); | ||
| } | ||
| } catch (InvalidSyntaxException e) { |
Copilot
AI
Oct 31, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The InvalidSyntaxException is silently swallowed without logging or user feedback. While validation occurs in validateFilter(), the exception here indicates the filter was accepted by the validator but failed when creating the actual filter. This scenario should be logged for debugging purposes, similar to how CoreException is handled.
| } catch (InvalidSyntaxException e) { | |
| } catch (InvalidSyntaxException e) { | |
| PDEPlugin.logException(e); |
|
|
||
|
|
||
| } |
Copilot
AI
Oct 31, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extra blank lines at the end of the file should be removed to maintain consistent code formatting.
|
|
||
| public class MatchSection extends PDESection implements IPartSelectionListener { | ||
|
|
||
|
|
Copilot
AI
Oct 31, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extra blank line after the class declaration should be removed for consistent formatting.


Summary
Continuation of closed PR #1931
Issue
Add support for setting the filter attribute in the feature editor under the dependencies tab #1808,
Solution
@KN0987 @BAlgarra