use of net.sf.eclipsecs.core.projectconfig.FileSet in project eclipse-cs by checkstyle.
the class CheckstyleBuilder method handleBuildSelection.
/**
* Builds the selected resources.
*
* @param resources
* the resourcesto build
* @param configuration
* the project configuration
* @param monitor
* the progress monitor
* @param project
* the built project
* @param kind
* the kind of build
* @param <T>
* the resource type parameter
* @throws CoreException
* if the build fails
*/
public final <T extends IResource> void handleBuildSelection(final Collection<T> resources, final IProjectConfiguration configuration, final IProgressMonitor monitor, final IProject project, final int kind) throws CoreException {
// on full build remove all previous checkstyle markers
if (kind == IncrementalProjectBuilder.FULL_BUILD) {
project.deleteMarkers(CheckstyleMarker.MARKER_ID, false, IResource.DEPTH_INFINITE);
}
boolean backgroundFullBuild = CheckstylePluginPrefs.getBoolean(CheckstylePluginPrefs.PREF_BACKGROUND_FULL_BUILD);
try {
//
// Build a set of auditors from the file sets of this project
// configuration.
// File sets that share the same check configuration merge into
// one Auditor.
//
List<FileSet> fileSets = configuration.getFileSets();
Map<ICheckConfiguration, Auditor> audits = new HashMap<>();
for (FileSet fileSet : fileSets) {
// skip not enabled filesets
if (!fileSet.isEnabled()) {
continue;
}
ICheckConfiguration checkConfig = fileSet.getCheckConfig();
if (checkConfig == null) {
throw new CheckstylePluginException(NLS.bind(Messages.errorNoCheckConfig, project.getName()));
}
// get an already created audit from the map
Auditor audit = audits.get(checkConfig);
// create the audit with the file sets check configuration
if (audit == null) {
audit = new Auditor(checkConfig);
audits.put(checkConfig, audit);
}
// check which files belong to the file set
for (IResource resource : resources) {
if (resource instanceof IFile) {
IFile file = (IFile) resource;
// if file set includes file add to the audit
if (fileSet.includesFile(file)) {
audit.addFile(file);
// remove markers on this file
file.deleteMarkers(CheckstyleMarker.MARKER_ID, false, IResource.DEPTH_ZERO);
// remove markers from package to prevent
// packagehtml messages from accumulatin
file.getParent().deleteMarkers(CheckstyleMarker.MARKER_ID, false, IResource.DEPTH_ZERO);
}
}
}
}
// run all auditors
for (Auditor audit : audits.values()) {
if (monitor.isCanceled()) {
throw new OperationCanceledException();
}
if (backgroundFullBuild && kind == FULL_BUILD) {
AuditorJob j = new AuditorJob(project, audit);
j.schedule();
} else {
audit.runAudit(project, monitor);
}
}
} catch (CheckstylePluginException e) {
Status status = new Status(IStatus.ERROR, CheckstylePlugin.PLUGIN_ID, IStatus.ERROR, e.getLocalizedMessage(), e);
throw new CoreException(status);
}
}
use of net.sf.eclipsecs.core.projectconfig.FileSet in project eclipse-cs by checkstyle.
the class ComplexFileSetsEditor method editFileSet.
private void editFileSet() {
IStructuredSelection selection = (IStructuredSelection) mViewer.getSelection();
FileSet fileSet = (FileSet) selection.getFirstElement();
if (fileSet == null) {
//
return;
}
try {
FileSetEditDialog dialog = new FileSetEditDialog(mComposite.getShell(), fileSet.clone(), mProject, mPropertyPage);
if (Window.OK == dialog.open()) {
FileSet newFileSet = dialog.getFileSet();
mFileSets.remove(fileSet);
mFileSets.add(newFileSet);
mViewer.refresh();
mViewer.setChecked(newFileSet, newFileSet.isEnabled());
mPropertyPage.getContainer().updateButtons();
}
} catch (CheckstylePluginException e) {
CheckstyleUIPlugin.errorDialog(mComposite.getShell(), NLS.bind(Messages.errorFailedEditFileset, e.getMessage()), e, true);
}
}
use of net.sf.eclipsecs.core.projectconfig.FileSet in project eclipse-cs by checkstyle.
the class ComplexFileSetsEditor method createContents.
/**
* {@inheritDoc}
*/
@Override
public Control createContents(Composite parent) throws CheckstylePluginException {
mComposite = parent;
Group composite = new Group(parent, SWT.NONE);
composite.setText(Messages.ComplexFileSetsEditor_titleAdvancedFilesetEditor);
GridLayout layout = new GridLayout();
layout.numColumns = 2;
composite.setLayout(layout);
//
// Create the table of file sets.
//
Table table = new Table(composite, SWT.CHECK | SWT.BORDER | SWT.FULL_SELECTION);
GridData data = new GridData(GridData.FILL_BOTH);
table.setLayoutData(data);
table.setHeaderVisible(true);
table.setLinesVisible(true);
TableLayout tableLayout = new TableLayout();
table.setLayout(tableLayout);
TableColumn column1 = new TableColumn(table, SWT.NONE);
column1.setText(Messages.ComplexFileSetsEditor_colEnabled);
column1.setResizable(false);
TableColumn column2 = new TableColumn(table, SWT.NONE);
column2.setText(Messages.ComplexFileSetsEditor_colFilesetName);
TableColumn column3 = new TableColumn(table, SWT.NONE);
column3.setText(Messages.ComplexFileSetsEditor_colConfiguration);
tableLayout.addColumnData(new ColumnWeightData(20));
tableLayout.addColumnData(new ColumnWeightData(40));
tableLayout.addColumnData(new ColumnWeightData(40));
mViewer = new CheckboxTableViewer(table);
mViewer.setLabelProvider(new FileSetLabelProvider());
mViewer.setContentProvider(new ArrayContentProvider());
mViewer.setComparator(new FileSetViewerSorter());
mViewer.setInput(mFileSets);
//
for (FileSet fileSet : mFileSets) {
mViewer.setChecked(fileSet, fileSet.isEnabled());
}
mViewer.addDoubleClickListener(new IDoubleClickListener() {
@Override
public void doubleClick(DoubleClickEvent e) {
editFileSet();
}
});
mViewer.addCheckStateListener(new ICheckStateListener() {
@Override
public void checkStateChanged(CheckStateChangedEvent event) {
changeEnabledState(event);
}
});
//
// Build the buttons.
//
Composite buttons = new Composite(composite, SWT.NULL);
buttons.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING));
layout = new GridLayout();
layout.marginHeight = 0;
layout.marginWidth = 0;
buttons.setLayout(layout);
mAddButton = createPushButton(buttons, Messages.ComplexFileSetsEditor_btnAdd);
mAddButton.addListener(SWT.Selection, new Listener() {
@Override
public void handleEvent(Event evt) {
addFileSet();
}
});
mEditButton = createPushButton(buttons, Messages.ComplexFileSetsEditor_btnEdit);
mEditButton.addListener(SWT.Selection, new Listener() {
@Override
public void handleEvent(Event evt) {
editFileSet();
}
});
mRemoveButton = createPushButton(buttons, Messages.ComplexFileSetsEditor_btnRemove);
mRemoveButton.addListener(SWT.Selection, new Listener() {
@Override
public void handleEvent(Event evt) {
removeFileSet();
}
});
return composite;
}
use of net.sf.eclipsecs.core.projectconfig.FileSet in project eclipse-cs by checkstyle.
the class ComplexFileSetsEditor method removeFileSet.
private void removeFileSet() {
IStructuredSelection selection = (IStructuredSelection) mViewer.getSelection();
FileSet fileSet = (FileSet) selection.getFirstElement();
if (fileSet == null) {
//
return;
}
mFileSets.remove(fileSet);
mViewer.refresh();
mPropertyPage.getContainer().updateButtons();
}
use of net.sf.eclipsecs.core.projectconfig.FileSet in project eclipse-cs by checkstyle.
the class ComplexFileSetsEditor method changeEnabledState.
private void changeEnabledState(CheckStateChangedEvent event) {
if (event.getElement() instanceof FileSet) {
FileSet fileSet = (FileSet) event.getElement();
fileSet.setEnabled(event.getChecked());
mViewer.refresh();
}
}
Aggregations