Skip to content

Commit eda9dd5

Browse files
committed
Add local rules button, make ruleSetFile is stored only when needed
1 parent 0daad64 commit eda9dd5

File tree

2 files changed

+25
-22
lines changed

2 files changed

+25
-22
lines changed

net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/runtime/properties/impl/ProjectPropertiesManagerImpl.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -331,15 +331,16 @@ private void writeProjectProperties(final IProject project, final ProjectPropert
331331
*/
332332
private ProjectPropertiesTO fillTransferObject(IProjectProperties projectProperties) throws PropertiesException {
333333
final ProjectPropertiesTO bean = new ProjectPropertiesTO();
334-
bean.setRuleSetStoredInProject(projectProperties.isRuleSetStoredInProject());
335-
bean.setRuleSetFile(projectProperties.getRuleSetFile());
336334
bean.setWorkingSetName(projectProperties.getProjectWorkingSet() == null ? null
337335
: projectProperties.getProjectWorkingSet().getName());
338336
bean.setIncludeDerivedFiles(projectProperties.isIncludeDerivedFiles());
339337
bean.setViolationsAsErrors(projectProperties.violationsAsErrors());
340338
bean.setFullBuildEnabled(projectProperties.isFullBuildEnabled());
341339

342-
if (!projectProperties.isRuleSetStoredInProject()) {
340+
bean.setRuleSetStoredInProject(projectProperties.isRuleSetStoredInProject());
341+
if (projectProperties.isRuleSetStoredInProject()) {
342+
bean.setRuleSetFile(projectProperties.getRuleSetFile());
343+
} else {
343344
final List<RuleSet> ruleSets = projectProperties.getProjectRuleSetList();
344345
final List<RuleSpecTO> rules = new ArrayList<>();
345346
List<String> excludePatterns = new ArrayList<>();

net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/ui/properties/PMDProjectPropertyPage.java

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@ protected Control createContents(final Composite parent) {
176176
ruleSetStoredInProjectButton = buildStoreRuleSetInProjectButton(ruleSetPanel);
177177
ruleSetFileText = buildRuleSetFileText(ruleSetPanel);
178178
ruleSetBrowseButton = buildRuleSetBrowseButton(ruleSetPanel);
179+
buildLocalRulesButton(ruleSetPanel);
179180

180181
data = new GridData(SWT.FILL, SWT.NONE, true, false);
181182
ruleSetFileText.setLayoutData(data);
@@ -327,25 +328,26 @@ public void widgetSelected(SelectionEvent e) {
327328
return button;
328329
}
329330

330-
// /**
331-
// * Create the radio button for storing configuration in a project file
332-
// *
333-
// * @param parent
334-
// * the parent composite
335-
// */
336-
// private Button buildLocalRulesButton(final Composite parent) {
337-
// Button button = newRadioButton(parent, "Use local rules");
338-
//
339-
// button.setSelection(!model.isRuleSetStoredInProject());
340-
//
341-
// button.addSelectionListener(new SelectionAdapter() {
342-
// public void widgetSelected(SelectionEvent e) {
343-
// adjustControls();
344-
// }
345-
// });
346-
//
347-
// return button;
348-
// }
331+
/**
332+
* Create the radio button for storing configuration in a project file
333+
*
334+
* @param parent
335+
* the parent composite
336+
*/
337+
private Button buildLocalRulesButton(final Composite parent) {
338+
Button button = newRadioButton(parent, "Use local rules");
339+
340+
button.setSelection(!model.isRuleSetStoredInProject());
341+
342+
button.addSelectionListener(new SelectionAdapter() {
343+
@Override
344+
public void widgetSelected(SelectionEvent e) {
345+
adjustControls();
346+
}
347+
});
348+
349+
return button;
350+
}
349351

350352
/**
351353
* Create the the rule set file name text.

0 commit comments

Comments
 (0)