3333import org .eclipse .pde .internal .ui .editor .FormLayoutFactory ;
3434import org .eclipse .pde .internal .ui .editor .PDEFormPage ;
3535import org .eclipse .pde .internal .ui .editor .PDESection ;
36+ import org .eclipse .pde .internal .ui .editor .validation .ControlValidationUtility ;
37+ import org .eclipse .pde .internal .ui .editor .validation .TextValidator ;
3638import org .eclipse .pde .internal .ui .parts .ComboPart ;
3739import org .eclipse .pde .internal .ui .parts .FormEntry ;
3840import org .eclipse .swt .SWT ;
@@ -56,6 +58,7 @@ public class MatchSection extends PDESection implements IPartSelectionListener {
5658
5759 private FormEntry fVersionText ;
5860 private FormEntry fFilterText ;
61+ private TextValidator fFilterEntryValidator ;
5962
6063 private ComboPart fMatchCombo ;
6164 protected IPluginReference fCurrentImport ;
@@ -159,6 +162,12 @@ public void textDirty(FormEntry text) {
159162 fBlockChanges = false ;
160163 }
161164 });
165+ fFilterEntryValidator = new TextValidator (getManagedForm (), fFilterText .getText (), getProject (), true ) {
166+ @ Override
167+ protected boolean validateControl () {
168+ return validateFilter ();
169+ }
170+ };
162171 update ((IPluginReference ) null );
163172
164173 section .setClient (container );
@@ -168,6 +177,16 @@ public void textDirty(FormEntry text) {
168177 section .setLayoutData (new GridData (GridData .FILL_HORIZONTAL | GridData .VERTICAL_ALIGN_BEGINNING ));
169178 }
170179
180+ private boolean validateFilter () {
181+ // No validation required for an optional field
182+ if (fFilterText .getText ().getText ().length () == 0 ) {
183+ return true ;
184+ }
185+ // Value must match the current environment and contain valid syntax
186+ return ControlValidationUtility .validateFilterField (fFilterText .getText ().getText (),
187+ fFilterEntryValidator );
188+ }
189+
171190 private void createReexportButton (FormToolkit toolkit , Composite container ) {
172191 fReexportButton = toolkit .createButton (container , PDEUIMessages .ManifestEditor_MatchSection_reexport , SWT .CHECK );
173192 fReexportButton .addSelectionListener (widgetSelectedAdapter (e -> {
@@ -236,7 +255,6 @@ private void applyFilter(String filter) {
236255 ((IFeatureImport ) fCurrentImport ).setFilter (filter );
237256 }
238257 } catch (InvalidSyntaxException e ) {
239- PDEPlugin .logException (e );
240258 } catch (CoreException e ) {
241259 PDEPlugin .logException (e );
242260 }
0 commit comments