Skip to content

Commit

Permalink
Add a project config option to have validators for all features
Browse files Browse the repository at this point in the history
Currently a validator has to be configured for each feature, if one
wants to validate all features in a project this become cumbersome.

This adds a configuration option to enable validators for the whole
project.
  • Loading branch information
Christoph Läubrich authored and laeubi committed Jun 2, 2024
1 parent 803758c commit c3bc1e8
Show file tree
Hide file tree
Showing 4 changed files with 128 additions and 37 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#language: en
#This Feature has no validator enabled in the feature file but in the project preferences!
Feature: Connection between DataTable Key and a specific Step Value


Scenario: All Keys are related to a Step Value. Example 1
Given the animal "Cat"
| Key | Value |
| Color | Black |
| Lifespan | 3 |
| Whiskers | 24 |

Then the food is "fish"


Scenario: All Keys are related to a Step Value. Example 2
Given the animal "Elephant"
| Key | Value |
| Color | Grey |
| Lifespan | 70 |
| Trunk | 1.8 |
| Tusk | 1.3 |

Then the food is "leaves"


Scenario: There are some unrelated Keys to a Step Value. This Keys are available for other Step Value
Given the animal "Cat"
| Key | Value |
| Color | Black |
| Lifespan | 3 |
| Whiskers | 24 |
| Trunk | 1.8 |

Then the food is "fish"


Scenario: There are some unrelated Keys to a Step Value. This Keys are not available for each Step Value
Given the animal "Cat"
| Key | Value |
| Color | Black |
| Lifespan | 3 |
| Whiskers | 24 |
| Wings | 2 |

Then the food is "fish"

10 changes: 9 additions & 1 deletion io.cucumber.eclipse.editor/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,14 @@
</action>
</viewerContribution>
</extension>

<extension
point="org.eclipse.ui.propertyPages">
<page
class="io.cucumber.eclipse.editor.properties.CucumberPropertiesPage"
icon="icons/cukes.gif"
id="cucumber.eclipse.editor.properties.main"
name="Cucumber">
</page>
</extension>

</plugin>
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
package io.cucumber.eclipse.editor.properties;

import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.ProjectScope;
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
import org.eclipse.jface.preference.PreferencePage;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.dialogs.PropertyPage;
import org.osgi.service.prefs.BackingStoreException;

import io.cucumber.eclipse.editor.Images;

public class CucumberPropertiesPage extends PropertyPage {

private static final String NAMESPACE = "io.cucumber.eclipse.editor";
private static final String KEY_VALIDATION_PLUGINS = "validationPlugins";
private Text validationPlugins;

public CucumberPropertiesPage() {
setTitle("Cucumber");
setDescription("You can configure Cucumber related properties for your project here");
setImageDescriptor(Images.getCukesIconDescriptor());
noDefaultAndApplyButton();
}

/**
* @see PreferencePage#createContents(Composite)
*/
@Override
protected Control createContents(Composite parent) {
Composite composite = new Composite(parent, SWT.NONE);
GridLayout layout = new GridLayout();
layout.numColumns = 2;
composite.setLayout(layout);
Label label = new Label(composite, SWT.NONE);
label.setText("Validation Plugins ");
label.setToolTipText(
"Add a comma seperated list of plugins that should be used for validation regardless of feature settings");
validationPlugins = new Text(composite, SWT.BORDER);
GridData data = new GridData(GridData.FILL_HORIZONTAL);
validationPlugins.setLayoutData(data);
return composite;
}

@Override
public boolean performOk() {
IEclipsePreferences node = getNode(getResource());
node.put(KEY_VALIDATION_PLUGINS, validationPlugins.getText());
try {
node.flush();
} catch (BackingStoreException e) {
}
return true;
}

private IResource getResource() {
return getElement().getAdapter(IResource.class);
}

public static IEclipsePreferences getNode(IResource resource) {
ProjectScope scope = new ProjectScope(resource.getProject());
IEclipsePreferences node = scope.getNode(NAMESPACE);
return node;
}

}

0 comments on commit c3bc1e8

Please sign in to comment.