use of org.sonarlint.eclipse.core.resource.ISonarLintProject in project sonarlint-eclipse by SonarSource.
the class ProjectsSelectionWizardPage method doCreateControl.
@Override
protected void doCreateControl(Composite container) {
projectsViewer = new TableViewer(container, SWT.MULTI | SWT.BORDER);
projectsViewer.addSelectionChangedListener(event -> updateButtonsState());
projectsViewer.setContentProvider(new ArrayContentProvider());
projectsViewer.setLabelProvider(new SonarLintProjectLabelProvider());
projectsViewer.setInput(new ArrayList<>(model.getEclipseProjects()));
projectsViewer.getTable().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 3));
var dataBindingContext = new DataBindingContext();
observableInput = ViewersObservables.observeInput(projectsViewer);
projectsBinding = dataBindingContext.bindValue(observableInput, BeanProperties.value(ProjectBindingModel.class, ProjectBindingModel.PROPERTY_PROJECTS).observe(model), new UpdateValueStrategy().setBeforeSetValidator(new MandatoryProjectsValidator("You must select at least one project")), null);
ControlDecorationSupport.create(projectsBinding, SWT.LEFT | SWT.TOP);
WizardPageSupport.create(this, dataBindingContext);
var btnAddProject = new Button(container, SWT.NONE);
btnAddProject.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
addSonarLintProjectsAction();
}
});
btnAddProject.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
btnAddProject.setText("Add...");
btnRemove = new Button(container, SWT.NONE);
btnRemove.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
var newInput = new ArrayList<ISonarLintProject>((List) projectsViewer.getInput());
newInput.removeAll(getSelectedElements());
observableInput.setValue(newInput);
}
});
btnRemove.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
btnRemove.setText("Remove");
updateButtonsState();
}
Aggregations