diff --git a/net.sf.eclipsecs.core/src/net/sf/eclipsecs/core/Messages.java b/net.sf.eclipsecs.core/src/net/sf/eclipsecs/core/Messages.java index a17ab30f5..f05dafbb5 100644 --- a/net.sf.eclipsecs.core/src/net/sf/eclipsecs/core/Messages.java +++ b/net.sf.eclipsecs.core/src/net/sf/eclipsecs/core/Messages.java @@ -108,5 +108,7 @@ private Messages() { public static String RemoteConfigurationType_msgUnAuthorized; + public static String PartsOpenedJob_title; + // CHECKSTYLE:ON } diff --git a/net.sf.eclipsecs.core/src/net/sf/eclipsecs/core/jobs/AbstractCheckJob.java b/net.sf.eclipsecs.core/src/net/sf/eclipsecs/core/jobs/AbstractCheckJob.java index 52682d24d..711031a2b 100644 --- a/net.sf.eclipsecs.core/src/net/sf/eclipsecs/core/jobs/AbstractCheckJob.java +++ b/net.sf.eclipsecs.core/src/net/sf/eclipsecs/core/jobs/AbstractCheckJob.java @@ -39,7 +39,7 @@ public AbstractCheckJob(String name) { @Override public final boolean isConflicting(ISchedulingRule rule) { - return rule instanceof AuditorJob || rule instanceof RunCheckstyleOnFilesJob; + return rule instanceof AbstractCheckJob; } @Override diff --git a/net.sf.eclipsecs.core/src/net/sf/eclipsecs/core/jobs/RunCheckstyleOnFilesJob.java b/net.sf.eclipsecs.core/src/net/sf/eclipsecs/core/jobs/RunCheckstyleOnFilesJob.java index e0d814b56..941c943a0 100644 --- a/net.sf.eclipsecs.core/src/net/sf/eclipsecs/core/jobs/RunCheckstyleOnFilesJob.java +++ b/net.sf.eclipsecs.core/src/net/sf/eclipsecs/core/jobs/RunCheckstyleOnFilesJob.java @@ -21,6 +21,7 @@ package net.sf.eclipsecs.core.jobs; import java.util.ArrayList; +import java.util.Collections; import java.util.HashMap; import java.util.Iterator; import java.util.List; @@ -72,11 +73,7 @@ public RunCheckstyleOnFilesJob(final List files) { * the file to check */ public RunCheckstyleOnFilesJob(final IFile file) { - super(Messages.RunCheckstyleOnFilesJob_title); - mFilesToCheck = new ArrayList<>(); - mFilesToCheck.add(file); - - setRule(this); + this(Collections.singletonList(file)); } @Override diff --git a/net.sf.eclipsecs.core/src/net/sf/eclipsecs/core/messages.properties b/net.sf.eclipsecs.core/src/net/sf/eclipsecs/core/messages.properties index 7e1e125fd..d99a47d82 100644 --- a/net.sf.eclipsecs.core/src/net/sf/eclipsecs/core/messages.properties +++ b/net.sf.eclipsecs.core/src/net/sf/eclipsecs/core/messages.properties @@ -1,8 +1,8 @@ Auditor_msgCheckingConfig = Checking {0} -Auditor_msgCheckingFile = Checking file {0}... +Auditor_msgCheckingFile = {0} Auditor_msgMsgCheckstyleInternalError = Checkstyle execution failed due to an internal error. Please check the error log for details... Auditor_txtUnknownModule = Unknown -AuditorJob_msgBuildProject = Running Checkstyle audit on "{0}" +AuditorJob_msgBuildProject = Checkstyle on "{0}" BuildProjectJob_msgBuildAllProjects = Build all projects BuildProjectJob_msgBuildProject = Build project "{0}" CheckstyleBuilder_msgErrorUnknown = Unknown @@ -25,10 +25,11 @@ errorUnknownFileFormat = Unknown file format: {0} errorWritingCheckConfigurations = Failed to write Checkstyle plugin configuration file:\\n{0} errorWritingConfigFile = Failed to write check configurations file msgErrorLoadingCheckstyleDTD = Unable to load internal DTD {0} +PartsOpenedJob_title = Checkstyle for opened editors ProjectConfigurationType_msgFileNotFound = Could not find {0} RemoteConfigurationType_errorFileNotFound = File not found: {0} RemoteConfigurationType_errorUnknownHost = Unknown host: {0} RemoteConfigurationType_msgRemoteCachingFailed = Could not cache remote configuration {0} ({1}) RemoteConfigurationType_msgUnAuthorized = 401: Authentication failed -RunCheckstyleOnFilesJob_title = Checking files... +RunCheckstyleOnFilesJob_title = Checkstyle SimpleFileSetsEditor_nameAllFileset = all diff --git a/net.sf.eclipsecs.ui/src/net/sf/eclipsecs/ui/properties/filter/CheckFileOnOpenPartListener.java b/net.sf.eclipsecs.ui/src/net/sf/eclipsecs/ui/properties/filter/CheckFileOnOpenPartListener.java index 20bad0f56..5d0f6fcf8 100644 --- a/net.sf.eclipsecs.ui/src/net/sf/eclipsecs/ui/properties/filter/CheckFileOnOpenPartListener.java +++ b/net.sf.eclipsecs.ui/src/net/sf/eclipsecs/ui/properties/filter/CheckFileOnOpenPartListener.java @@ -31,6 +31,7 @@ import net.sf.eclipsecs.core.Messages; import net.sf.eclipsecs.core.builder.CheckstyleMarker; +import net.sf.eclipsecs.core.jobs.AbstractCheckJob; import net.sf.eclipsecs.core.jobs.RunCheckstyleOnFilesJob; import net.sf.eclipsecs.core.nature.CheckstyleNature; import net.sf.eclipsecs.core.projectconfig.IProjectConfiguration; @@ -44,12 +45,12 @@ import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.WorkspaceJob; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IAdaptable; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; +import org.eclipse.core.runtime.SubMonitor; import org.eclipse.core.runtime.jobs.ISchedulingRule; import org.eclipse.ui.IEditorInput; import org.eclipse.ui.IEditorPart; @@ -325,12 +326,12 @@ private boolean isFileAffected(IFile file) { return affected; } - private class PartsOpenedJob extends WorkspaceJob implements ISchedulingRule { + private class PartsOpenedJob extends AbstractCheckJob { private Collection mParts; public PartsOpenedJob(Collection parts) { - super(Messages.RunCheckstyleOnFilesJob_title); + super(Messages.PartsOpenedJob_title); this.mParts = parts; } @@ -339,18 +340,13 @@ public boolean contains(ISchedulingRule rule) { return false; } - @Override - public boolean isConflicting(ISchedulingRule rule) { - return false; - } - @Override public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException { - + SubMonitor subMonitor = SubMonitor.convert(monitor, mParts.size()); List filesToCheck = new ArrayList<>(); for (IWorkbenchPartReference partRef : mParts) { - + subMonitor.worked(1); IFile editorFile = getEditorFile(partRef); if (editorFile != null) { UnOpenedFilesFilter.addOpenedFile(editorFile);