Skip to content

Commit

Permalink
Improve eclipse jobs
Browse files Browse the repository at this point in the history
* shorten job names and progress messages to avoid labels being
artificially shortened by the Eclipse UI
* use 'Checkstyle on "project name"' for builds triggered on projects
* use 'Checkstyle' for invocations on arbitrary selected files
* fix the Eclipse job listening for editors being opened to also use the
EclipseCS icon, label and to actually report some progress
  • Loading branch information
Bananeweizen authored and Calixte committed Sep 11, 2023
1 parent 185503f commit e8df55b
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 19 deletions.
2 changes: 2 additions & 0 deletions net.sf.eclipsecs.core/src/net/sf/eclipsecs/core/Messages.java
Original file line number Diff line number Diff line change
Expand Up @@ -108,5 +108,7 @@ private Messages() {

public static String RemoteConfigurationType_msgUnAuthorized;

public static String PartsOpenedJob_title;

// CHECKSTYLE:ON
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -72,11 +73,7 @@ public RunCheckstyleOnFilesJob(final List<IFile> 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
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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<IWorkbenchPartReference> mParts;

public PartsOpenedJob(Collection<IWorkbenchPartReference> parts) {
super(Messages.RunCheckstyleOnFilesJob_title);
super(Messages.PartsOpenedJob_title);
this.mParts = parts;
}

Expand All @@ -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<IFile> filesToCheck = new ArrayList<>();

for (IWorkbenchPartReference partRef : mParts) {

subMonitor.worked(1);
IFile editorFile = getEditorFile(partRef);
if (editorFile != null) {
UnOpenedFilesFilter.addOpenedFile(editorFile);
Expand Down

0 comments on commit e8df55b

Please sign in to comment.