-
Notifications
You must be signed in to change notification settings - Fork 149
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix #414 - add an option to match any parameter
- Loading branch information
Christoph Läubrich
committed
Jun 16, 2020
1 parent
591b3b0
commit 99a8934
Showing
6 changed files
with
194 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
109 changes: 109 additions & 0 deletions
109
...lipse.editor/src/main/java/cucumber/eclipse/editor/properties/ProjectGlueCodeOptions.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
package cucumber.eclipse.editor.properties; | ||
|
||
import org.eclipse.core.resources.IProject; | ||
import org.eclipse.core.resources.IResource; | ||
import org.eclipse.core.resources.IncrementalProjectBuilder; | ||
import org.eclipse.core.resources.ProjectScope; | ||
import org.eclipse.core.runtime.CoreException; | ||
import org.eclipse.core.runtime.ICoreRunnable; | ||
import org.eclipse.core.runtime.IProgressMonitor; | ||
import org.eclipse.core.runtime.jobs.Job; | ||
import org.eclipse.core.runtime.preferences.IEclipsePreferences; | ||
import org.eclipse.swt.SWT; | ||
import org.eclipse.swt.events.SelectionEvent; | ||
import org.eclipse.swt.events.SelectionListener; | ||
import org.eclipse.swt.layout.GridData; | ||
import org.eclipse.swt.layout.GridLayout; | ||
import org.eclipse.swt.widgets.Button; | ||
import org.eclipse.swt.widgets.Composite; | ||
import org.eclipse.swt.widgets.Control; | ||
import org.eclipse.ui.IWorkbenchPropertyPage; | ||
import org.eclipse.ui.dialogs.PropertyPage; | ||
import org.osgi.service.prefs.BackingStoreException; | ||
|
||
public class ProjectGlueCodeOptions extends PropertyPage implements IWorkbenchPropertyPage { | ||
|
||
private Button matchAllParameterButton; | ||
|
||
private static final String NAMESPACE = "cucumber.steps.glue"; | ||
private static final String KEY_MATCH_ALL_PARAMETER = "matchAllParameter"; | ||
|
||
public ProjectGlueCodeOptions() { | ||
} | ||
|
||
@Override | ||
protected Control createContents(Composite parent) { | ||
Composite composite = new Composite(parent, SWT.NONE); | ||
composite.setLayout(new GridLayout(2, false)); | ||
GridData data = new GridData(GridData.FILL_BOTH); | ||
data.grabExcessHorizontalSpace = true; | ||
composite.setLayoutData(data); | ||
matchAllParameterButton = createEnableOption(composite); | ||
return composite; | ||
} | ||
|
||
private Button createEnableOption(Composite composite) { | ||
Button button = new Button(composite, SWT.CHECK); | ||
GridData gd = new GridData(); | ||
button.setLayoutData(gd); | ||
gd.horizontalSpan = 2; | ||
button.setText("Match regardless of parametertype"); | ||
button.setSelection(isMatchAllParameter(getResource())); | ||
button.addSelectionListener(new SelectionListener() { | ||
|
||
@Override | ||
public void widgetSelected(SelectionEvent e) { | ||
} | ||
|
||
@Override | ||
public void widgetDefaultSelected(SelectionEvent e) { | ||
|
||
} | ||
}); | ||
return button; | ||
} | ||
|
||
private IResource getResource() { | ||
return getElement().getAdapter(IResource.class); | ||
} | ||
|
||
private static IEclipsePreferences getNode(IResource resource) { | ||
ProjectScope scope = new ProjectScope(resource.getProject()); | ||
IEclipsePreferences node = scope.getNode(NAMESPACE); | ||
return node; | ||
} | ||
|
||
protected void performDefaults() { | ||
super.performDefaults(); | ||
matchAllParameterButton.setSelection(false); | ||
} | ||
|
||
public boolean performOk() { | ||
IResource resource = getResource(); | ||
IEclipsePreferences node = getNode(resource); | ||
boolean oldvalue = isMatchAllParameter(resource); | ||
boolean newValue = matchAllParameterButton.getSelection(); | ||
if (newValue != oldvalue) { | ||
node.putBoolean(KEY_MATCH_ALL_PARAMETER, newValue); | ||
try { | ||
node.flush(); | ||
} catch (BackingStoreException e) { | ||
} | ||
IProject project = resource.getProject(); | ||
Job.create("Rebuild of " + project.getName(), new ICoreRunnable() { | ||
|
||
@Override | ||
public void run(IProgressMonitor monitor) throws CoreException { | ||
project.build(IncrementalProjectBuilder.FULL_BUILD, monitor); | ||
} | ||
}).schedule(); | ||
} | ||
return true; | ||
} | ||
|
||
public static boolean isMatchAllParameter(IResource resource) { | ||
IEclipsePreferences node = getNode(resource); | ||
return node.getBoolean(KEY_MATCH_ALL_PARAMETER, false); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
25 changes: 25 additions & 0 deletions
25
cucumber.eclipse.targetdefinition/cucumber.eclipse.targetdefinition_mars.target
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?xml version="1.0" encoding="UTF-8" standalone="no"?> | ||
<?pde version="3.8"?><target name="targetdefinition" sequenceNumber="10"> | ||
<locations> | ||
<location includeAllPlatforms="false" includeConfigurePhase="true" includeMode="planner" includeSource="true" type="InstallableUnit"> | ||
<unit id="org.hamcrest.library.source" version="1.3.0.v201505072020"/> | ||
<unit id="org.hamcrest.text" version="1.1.0.v20090501071000"/> | ||
<unit id="org.hamcrest.core.source" version="1.3.0.v201303031735"/> | ||
<unit id="org.hamcrest.integration" version="1.3.0.v201305210900"/> | ||
<unit id="org.mockito" version="1.9.5.v201311280930"/> | ||
<unit id="org.hamcrest.core" version="1.3.0.v201303031735"/> | ||
<unit id="org.hamcrest.integration.source" version="1.3.0.v201305210900"/> | ||
<unit id="org.hamcrest.generator" version="1.3.0.v201305210900"/> | ||
<unit id="org.hamcrest" version="1.1.0.v20090501071000"/> | ||
<unit id="org.hamcrest.generator.source" version="1.3.0.v201305210900"/> | ||
<unit id="org.hamcrest.text.source" version="1.1.0.v20090501071000"/> | ||
<unit id="org.mockito.source" version="1.9.5.v201311280930"/> | ||
<unit id="org.hamcrest.library" version="1.3.0.v201505072020"/> | ||
<repository location="http://download.eclipse.org/tools/orbit/downloads/drops/R20150519210750/repository/"/> | ||
</location> | ||
<location includeAllPlatforms="false" includeConfigurePhase="true" includeMode="planner" includeSource="true" type="InstallableUnit"> | ||
<unit id="org.eclipse.sdk.ide" version="4.5.2.M20160212-1500"/> | ||
<repository location="http://download.eclipse.org/releases/mars"/> | ||
</location> | ||
</locations> | ||
</target> |