use of ch.acanda.eclipse.pmd.properties.PMDPropertyPageViewModel.RuleSetViewModel in project eclipse-pmd by acanda.
the class PMDPropertyPageController method addRuleSetConfiguration.
public void addRuleSetConfiguration(final Shell shell) {
final AddRuleSetConfigurationWizard wizard = new AddRuleSetConfigurationWizard(project);
final WizardDialog dialog = new WizardDialog(shell, wizard);
dialog.setPageSize(300, SWT.DEFAULT);
final int result = dialog.open();
if (result == Window.OK && wizard.getRuleSetModel() != null) {
final RuleSetViewModel viewModel = toViewModel(wizard.getRuleSetModel(), project);
model.addRuleSet(viewModel);
final HashSet<RuleSetViewModel> activeConfigs = new HashSet<>(model.getActiveRuleSets());
activeConfigs.add(viewModel);
model.setActiveRuleSets(activeConfigs);
}
}
use of ch.acanda.eclipse.pmd.properties.PMDPropertyPageViewModel.RuleSetViewModel in project eclipse-pmd by acanda.
the class PMDPropertyPageControllerTest method removeSelectedConfigurations.
/**
* Verifies that {@link PMDPropertyPageController#removeSelectedConfigurations()} updates the view model correctly.
*/
@Test
public void removeSelectedConfigurations() {
final PMDPropertyPageController controller = new PMDPropertyPageController();
final PMDPropertyPageViewModel model = controller.getModel();
final IProject project = mock(IProject.class);
model.setInitialState(true, ImmutableSortedSet.<RuleSetModel>of(), project);
final ImmutableList<RuleSetViewModel> ruleSets = createRuleSets();
model.setRuleSets(ruleSets);
model.setActiveRuleSets(ruleSets.subList(0, 2));
model.setSelectedRuleSets(ruleSets.subList(1, 3));
controller.removeSelectedConfigurations();
assertEquals("ruleSets", "[A, D]", toNameString(model.getRuleSets()));
assertEquals("activeRuleSets", "[A]", toNameString(model.getActiveRuleSets()));
assertEquals("selectedRuleSets", "[]", toNameString(model.getSelectedRuleSets()));
}
use of ch.acanda.eclipse.pmd.properties.PMDPropertyPageViewModel.RuleSetViewModel in project eclipse-pmd by acanda.
the class PMDPropertyPageControllerTest method removeSelectedConfigurationsWithoutSelection.
/**
* Verifies that {@link PMDPropertyPageController#removeSelectedConfigurations()} updates the view model correctly
* when none of the rule sets are selected.
*/
@Test
public void removeSelectedConfigurationsWithoutSelection() {
final PMDPropertyPageController controller = new PMDPropertyPageController();
final PMDPropertyPageViewModel model = controller.getModel();
final IProject project = mock(IProject.class);
model.setInitialState(true, ImmutableSortedSet.<RuleSetModel>of(), project);
final ImmutableList<RuleSetViewModel> ruleSets = createRuleSets();
model.setRuleSets(ruleSets);
model.setActiveRuleSets(ruleSets.subList(0, 2));
model.setSelectedRuleSets(ImmutableList.<RuleSetViewModel>of());
controller.removeSelectedConfigurations();
assertEquals("ruleSets", "[A, B, C, D]", toNameString(model.getRuleSets()));
assertEquals("activeRuleSets", "[A, B]", toNameString(model.getActiveRuleSets()));
assertEquals("selectedRuleSets", "[]", toNameString(model.getSelectedRuleSets()));
}
Aggregations