Search in sources :

Example 1 with DetectCutAndPasteCmd

use of net.sourceforge.pmd.eclipse.runtime.cmd.DetectCutAndPasteCmd in project pmd-eclipse-plugin by pmd.

the class CPDCheckProjectAction method detectCutAndPaste.

/**
 * Run the DetectCutAndPaste command against the selected project
 * and creates optionally the report file.
 *
 * @param project a project
 * @param dialog the object of the dialog with the selected values
 * @throws CommandException
 */
private void detectCutAndPaste(final IProject project, CPDCheckDialog dialog) {
    final String selectedLanguage = dialog.getSelectedLanguage();
    final int tilesize = dialog.getTileSize();
    final boolean createReport = dialog.isCreateReportSelected();
    final Renderer selectedRenderer = this.createRenderer(dialog.getSelectedFormat());
    final String fileName = this.createFileName(dialog.getSelectedFormat());
    final CPDView2 view = showView();
    try {
        final DetectCutAndPasteCmd detectCmd = new DetectCutAndPasteCmd();
        detectCmd.setProject(project);
        detectCmd.setCreateReport(createReport);
        detectCmd.setLanguage(selectedLanguage);
        detectCmd.setMinTileSize(tilesize);
        detectCmd.setRenderer(selectedRenderer);
        detectCmd.setReportName(fileName);
        detectCmd.setUserInitiated(true);
        detectCmd.addPropertyListener(view);
        detectCmd.performExecute();
    } catch (CommandException e) {
        logError(getString(StringKeys.ERROR_PMD_EXCEPTION), e);
    }
}
Also used : CPDView2(net.sourceforge.pmd.eclipse.ui.views.cpd2.CPDView2) DetectCutAndPasteCmd(net.sourceforge.pmd.eclipse.runtime.cmd.DetectCutAndPasteCmd) XMLRenderer(net.sourceforge.pmd.cpd.XMLRenderer) CSVRenderer(net.sourceforge.pmd.cpd.CSVRenderer) Renderer(net.sourceforge.pmd.cpd.Renderer) SimpleRenderer(net.sourceforge.pmd.cpd.SimpleRenderer) CommandException(name.herlin.command.CommandException)

Aggregations

CommandException (name.herlin.command.CommandException)1 CSVRenderer (net.sourceforge.pmd.cpd.CSVRenderer)1 Renderer (net.sourceforge.pmd.cpd.Renderer)1 SimpleRenderer (net.sourceforge.pmd.cpd.SimpleRenderer)1 XMLRenderer (net.sourceforge.pmd.cpd.XMLRenderer)1 DetectCutAndPasteCmd (net.sourceforge.pmd.eclipse.runtime.cmd.DetectCutAndPasteCmd)1 CPDView2 (net.sourceforge.pmd.eclipse.ui.views.cpd2.CPDView2)1