added a progress dialog for PMD
git-svn-id: https://pmd.svn.sourceforge.net/svnroot/pmd/trunk@860 51baf565-9d33-0410-a72c-fc3788e3496d
This commit is contained in:
@ -0,0 +1,85 @@
|
||||
package net.sourceforge.pmd.eclipse.actions;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.sourceforge.pmd.eclipse.PMDPlugin;
|
||||
import net.sourceforge.pmd.eclipse.PMDVisitor;
|
||||
import net.sourceforge.pmd.eclipse.preferences.PMDPreferencePage;
|
||||
import net.sourceforge.pmd.eclipse.util.Common;
|
||||
import net.sourceforge.pmd.eclipse.util.ProgressDialog;
|
||||
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.jface.action.IAction;
|
||||
import org.eclipse.jface.dialogs.MessageDialog;
|
||||
import org.eclipse.jface.dialogs.ProgressMonitorDialog;
|
||||
import org.eclipse.jface.preference.IPreferenceStore;
|
||||
import org.eclipse.jface.viewers.ISelection;
|
||||
import org.eclipse.ui.IObjectActionDelegate;
|
||||
import org.eclipse.ui.IWorkbenchPart;
|
||||
import org.eclipse.ui.IWorkbenchWindow;
|
||||
import org.eclipse.ui.IWorkbenchWindowActionDelegate;
|
||||
import sun.security.krb5.internal.crypto.c;
|
||||
import org.eclipse.ui.PlatformUI;
|
||||
|
||||
/**
|
||||
* Insert the type's description here.
|
||||
* @see IWorkbenchWindowActionDelegate
|
||||
*/
|
||||
public class PMDCheckProjectAction implements IObjectActionDelegate {
|
||||
IWorkbenchPart targetPart;
|
||||
/**
|
||||
* The constructor.
|
||||
*/
|
||||
public PMDCheckProjectAction() {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.eclipse.ui.IObjectActionDelegate#setActivePart(IAction, IWorkbenchPart)
|
||||
*/
|
||||
public void setActivePart(IAction action, IWorkbenchPart targetPart) {
|
||||
this.targetPart = targetPart;
|
||||
}
|
||||
|
||||
/**
|
||||
* Insert the method's description here.
|
||||
* @see IWorkbenchWindowActionDelegate#run
|
||||
*/
|
||||
public void run(IAction action) {
|
||||
String[] rulesetFiles = PMDPlugin.getDefault().getRuleSetsPreference();
|
||||
|
||||
PMDVisitor visitor = null;
|
||||
try {
|
||||
visitor = new PMDVisitor(rulesetFiles);
|
||||
Common.PMD_DIALOG = new ProgressDialog(targetPart.getSite().getShell(), "PMD Status", ProgressDialog.UNKNOWN);
|
||||
Common.PMD_DIALOG.open();
|
||||
PMDPlugin.getWorkspace().getRoot().accept( visitor );
|
||||
Common.PMD_DIALOG.close();
|
||||
Common.PMD_DIALOG = null;
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Insert the method's description here.
|
||||
* @see IWorkbenchWindowActionDelegate#selectionChanged
|
||||
*/
|
||||
public void selectionChanged(IAction action, ISelection selection) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Insert the method's description here.
|
||||
* @see IWorkbenchWindowActionDelegate#dispose
|
||||
*/
|
||||
public void dispose() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Insert the method's description here.
|
||||
* @see IWorkbenchWindowActionDelegate#init
|
||||
*/
|
||||
public void init(IWorkbenchWindow window) {
|
||||
}
|
||||
}
|
14
pmd-eclipse/src/net/sourceforge/pmd/eclipse/util/Common.java
Normal file
14
pmd-eclipse/src/net/sourceforge/pmd/eclipse/util/Common.java
Normal file
@ -0,0 +1,14 @@
|
||||
package net.sourceforge.pmd.eclipse.util;
|
||||
|
||||
/**
|
||||
* @author David Craine
|
||||
*
|
||||
* To change this generated comment edit the template variable "typecomment":
|
||||
* Window>Preferences>Java>Templates.
|
||||
* To enable and disable the creation of type comments go to
|
||||
* Window>Preferences>Java>Code Generation.
|
||||
*/
|
||||
public class Common {
|
||||
public static ProgressDialog PMD_DIALOG;
|
||||
|
||||
}
|
@ -0,0 +1,86 @@
|
||||
package net.sourceforge.pmd.eclipse.util;
|
||||
|
||||
import org.eclipse.jface.dialogs.Dialog;
|
||||
import org.eclipse.jface.dialogs.ProgressIndicator;
|
||||
import org.eclipse.jface.window.ApplicationWindow;
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.layout.GridData;
|
||||
import org.eclipse.swt.layout.GridLayout;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.swt.widgets.Label;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
import org.eclipse.swt.widgets.Text;
|
||||
|
||||
/**
|
||||
* @author David Craine
|
||||
*
|
||||
* To change this generated comment edit the template variable "typecomment":
|
||||
* Window>Preferences>Java>Templates.
|
||||
* To enable and disable the creation of type comments go to
|
||||
* Window>Preferences>Java>Code Generation.
|
||||
*/
|
||||
public class ProgressDialog extends ApplicationWindow {
|
||||
private ProgressIndicator progressIndicator;
|
||||
private Label label;
|
||||
private Composite entryTable;
|
||||
public static final int UNKNOWN = -1;
|
||||
private int max=UNKNOWN;
|
||||
private String title;
|
||||
|
||||
|
||||
/**
|
||||
* Constructor for ProgressDialog.
|
||||
* @param parentShell
|
||||
*/
|
||||
public ProgressDialog(Shell parentShell, String title, int max) {
|
||||
super(parentShell);
|
||||
this.title = title;
|
||||
|
||||
}
|
||||
/**
|
||||
* @see org.eclipse.jface.window.Window#configureShell(Shell)
|
||||
*/
|
||||
protected void configureShell(Shell newShell) {
|
||||
super.configureShell(newShell);
|
||||
|
||||
newShell.setText(title);
|
||||
entryTable = new Composite(newShell, SWT.NULL);
|
||||
GridLayout layout = new GridLayout();
|
||||
layout.numColumns = 1;
|
||||
entryTable.setLayout(layout);
|
||||
|
||||
//create the label
|
||||
label = new Label(entryTable, SWT.NULL);
|
||||
label.setText("");
|
||||
GridData data = new GridData(GridData.FILL_HORIZONTAL);
|
||||
data.horizontalSpan = 1;
|
||||
label.setLayoutData(data);
|
||||
|
||||
progressIndicator = new ProgressIndicator(entryTable);
|
||||
data = new GridData(GridData.FILL_HORIZONTAL);
|
||||
data.horizontalSpan = 1;
|
||||
data.verticalSpan = 10;
|
||||
progressIndicator.setLayoutData(data);
|
||||
if (max==UNKNOWN)
|
||||
progressIndicator.beginAnimatedTask();
|
||||
else
|
||||
progressIndicator.beginTask(max);
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void show() {
|
||||
this.create();
|
||||
this.getShell().setSize(300,200);
|
||||
this.open();
|
||||
}
|
||||
|
||||
|
||||
public void worked(double work) {
|
||||
progressIndicator.worked(work);
|
||||
}
|
||||
|
||||
public void setMessage(String msg) {
|
||||
label.setText(msg);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user