Search in sources :

Example 1 with CommandException

use of name.herlin.command.CommandException in project pmd-eclipse-plugin by pmd.

the class GenerateReportAction method run.

/**
 * @see org.eclipse.ui.IActionDelegate#run(IAction)
 */
public final void run(final IAction action) {
    LOG.info("Generation Report action requested");
    final ISelection sel = targetSelection();
    if (sel instanceof IStructuredSelection) {
        try {
            IProject project = getProject((IStructuredSelection) sel);
            if (project != null) {
                if (!checkRenderers()) {
                    return;
                }
                RenderReportsCmd cmd = new RenderReportsCmd();
                cmd.setProject(project);
                cmd.setUserInitiated(true);
                registerRenderers(cmd);
                cmd.performExecute();
            }
        } catch (CommandException e) {
            showErrorById(StringKeys.ERROR_PMD_EXCEPTION, e);
        }
    }
}
Also used : RenderReportsCmd(net.sourceforge.pmd.eclipse.runtime.cmd.RenderReportsCmd) ISelection(org.eclipse.jface.viewers.ISelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) CommandException(name.herlin.command.CommandException) IProject(org.eclipse.core.resources.IProject)

Example 2 with CommandException

use of name.herlin.command.CommandException in project pmd-eclipse-plugin by pmd.

the class ViolationOverview method deleteMarkers.

private void deleteMarkers(IMarker[] markers) {
    if (markers.length > 0) {
        DeleteMarkersCommand cmd = new DeleteMarkersCommand();
        cmd.setMarkers(markers);
        try {
            cmd.performExecute();
        } catch (CommandException e) {
            PMDPlugin.getDefault().showError(getString(StringKeys.ERROR_CORE_EXCEPTION), e.getCause());
        }
    }
}
Also used : DeleteMarkersCommand(net.sourceforge.pmd.eclipse.runtime.cmd.DeleteMarkersCommand) CommandException(name.herlin.command.CommandException)

Example 3 with CommandException

use of name.herlin.command.CommandException in project pmd-eclipse-plugin by pmd.

the class DataflowViewPage method refreshDFATable.

/**
 * Executes a command to refresh the DFA table. After execution
 * {@link #refresh(IResource)} will be called.
 *
 * @param newResource
 *            the new resource
 */
public void refreshDFATable(IResource newResource) {
    isTableRefreshed = true;
    try {
        ReviewResourceForRuleCommand cmd = new ReviewResourceForRuleCommand();
        DataflowAnomalyAnalysisRule rule = new DataflowAnomalyAnalysisRule();
        rule.setUsesDFA();
        cmd.setUserInitiated(false);
        cmd.setRule(rule);
        cmd.setResource(newResource);
        cmd.addPropertyListener(this);
        cmd.performExecute();
    } catch (CommandException e) {
        logErrorByKey(StringKeys.ERROR_PMD_EXCEPTION, e);
    }
}
Also used : DataflowAnomalyAnalysisRule(net.sourceforge.pmd.lang.java.rule.errorprone.DataflowAnomalyAnalysisRule) ReviewResourceForRuleCommand(net.sourceforge.pmd.eclipse.runtime.cmd.ReviewResourceForRuleCommand) CommandException(name.herlin.command.CommandException)

Example 4 with CommandException

use of name.herlin.command.CommandException in project pmd-eclipse-plugin by pmd.

the class UpdateProjectPropertiesCmd method execute.

/**
 * @see name.herlin.command.AbstractProcessableCommand#execute()
 */
public void execute() throws CommandException {
    try {
        final IProjectProperties properties = projectProperties();
        properties.setPmdEnabled(pmdEnabled);
        properties.setProjectRuleSet(projectRuleSet);
        properties.setProjectWorkingSet(projectWorkingSet);
        properties.setRuleSetStoredInProject(ruleSetStoredInProject);
        properties.setRuleSetFile(ruleSetFile);
        properties.setIncludeDerivedFiles(includeDerivedFiles);
        properties.setFullBuildEnabled(fullBuildEnabled);
        properties.setViolationsAsErrors(violationsAsErrors);
        properties.sync();
        needRebuild = properties.isNeedRebuild();
        ruleSetFileExists = !properties.isRuleSetFileExist();
    } catch (PropertiesException e) {
        throw new CommandException(e.getMessage(), e);
    } finally {
        setTerminated(true);
    }
}
Also used : IProjectProperties(net.sourceforge.pmd.eclipse.runtime.properties.IProjectProperties) PropertiesException(net.sourceforge.pmd.eclipse.runtime.properties.PropertiesException) CommandException(name.herlin.command.CommandException)

Example 5 with CommandException

use of name.herlin.command.CommandException in project pmd-eclipse-plugin by pmd.

the class ReviewResourceAction method run.

/**
 * @see org.eclipse.jface.action.IAction#run()
 */
public void run() {
    try {
        ProgressMonitorDialog dialog = new ProgressMonitorDialog(Display.getCurrent().getActiveShell());
        dialog.run(false, false, new IRunnableWithProgress() {

            public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
                setMonitor(monitor);
                monitor.beginTask(getString(StringKeys.MONITOR_REVIEW), 5);
                ReviewCodeCmd cmd = new ReviewCodeCmd();
                cmd.addResource(resource);
                cmd.setStepCount(1);
                cmd.setTaskMarker(true);
                cmd.setUserInitiated(true);
                try {
                    cmd.performExecute();
                } catch (CommandException e) {
                    logErrorByKey(StringKeys.ERROR_CORE_EXCEPTION, e);
                }
                monitor.done();
            }
        });
    } catch (InvocationTargetException e) {
        logErrorByKey(StringKeys.ERROR_INVOCATIONTARGET_EXCEPTION, e);
    } catch (InterruptedException e) {
        logErrorByKey(StringKeys.ERROR_INTERRUPTED_EXCEPTION, e);
    }
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) ProgressMonitorDialog(org.eclipse.jface.dialogs.ProgressMonitorDialog) ReviewCodeCmd(net.sourceforge.pmd.eclipse.runtime.cmd.ReviewCodeCmd) CommandException(name.herlin.command.CommandException) InvocationTargetException(java.lang.reflect.InvocationTargetException) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress)

Aggregations

CommandException (name.herlin.command.CommandException)21 CoreException (org.eclipse.core.runtime.CoreException)11 PropertiesException (net.sourceforge.pmd.eclipse.runtime.properties.PropertiesException)5 IFile (org.eclipse.core.resources.IFile)4 RuleSet (net.sourceforge.pmd.RuleSet)3 ReviewCodeCmd (net.sourceforge.pmd.eclipse.runtime.cmd.ReviewCodeCmd)3 IProjectProperties (net.sourceforge.pmd.eclipse.runtime.properties.IProjectProperties)3 IProject (org.eclipse.core.resources.IProject)3 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)3 File (java.io.File)2 IFolder (org.eclipse.core.resources.IFolder)2 IResource (org.eclipse.core.resources.IResource)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 Map (java.util.Map)1 Timer (name.herlin.command.Timer)1