use of net.sourceforge.pmd.eclipse.ui.dialogs.CPDCheckDialog in project pmd-eclipse-plugin by pmd.
the class CPDCheckProjectAction method run.
/*
* @see org.eclipse.ui.IActionDelegate#run(IAction)
*/
public void run(final IAction action) {
// NOPMD:UnusedFormalParameter
final IWorkbenchPartSite site = targetPartSite();
final ISelection sel = site.getSelectionProvider().getSelection();
final Shell shell = site.getShell();
final String[] languages = LanguageFactory.supportedLanguages;
final String[] formats = { SIMPLE_KEY, XML_KEY, CSV_KEY };
final CPDCheckDialog dialog = new CPDCheckDialog(shell, languages, formats);
if (dialog.open() == Dialog.OK && sel instanceof IStructuredSelection) {
final StructuredSelection ss = (StructuredSelection) sel;
final Iterator<?> i = ss.iterator();
while (i.hasNext()) {
final Object obj = i.next();
if (obj instanceof IAdaptable) {
final IAdaptable adaptable = (IAdaptable) obj;
final IProject project = (IProject) adaptable.getAdapter(IProject.class);
if (project == null) {
LOG.warn("The selected object cannot adapt to a project");
LOG.debug(" -> selected object : " + obj);
} else {
this.detectCutAndPaste(project, dialog);
}
} else {
LOG.warn("The selected object is not adaptable");
LOG.debug(" -> selected object : " + obj);
}
}
}
}
Aggregations