<No Comment Entered>
git-svn-id: https://pmd.svn.sourceforge.net/svnroot/pmd/trunk@366 51baf565-9d33-0410-a72c-fc3788e3496d
This commit is contained in:
@ -28,6 +28,7 @@ import com.borland.primetime.properties.NodeProperty;
|
|||||||
import com.borland.primetime.properties.GlobalProperty;
|
import com.borland.primetime.properties.GlobalProperty;
|
||||||
import com.borland.primetime.properties.PropertyManager;
|
import com.borland.primetime.properties.PropertyManager;
|
||||||
import com.borland.primetime.properties.PropertyDialog;
|
import com.borland.primetime.properties.PropertyDialog;
|
||||||
|
import com.borland.jbuilder.node.PackageNode;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -39,6 +40,7 @@ public class PMDOpenTool {
|
|||||||
* Default constructor
|
* Default constructor
|
||||||
*/
|
*/
|
||||||
public PMDOpenTool () {
|
public PMDOpenTool () {
|
||||||
|
int j;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -52,6 +54,7 @@ public class PMDOpenTool {
|
|||||||
GROUP_PMD.add(ACTION_PMDConfig);
|
GROUP_PMD.add(ACTION_PMDConfig);
|
||||||
JBuilderMenu.GROUP_Tools.add(GROUP_PMD);
|
JBuilderMenu.GROUP_Tools.add(GROUP_PMD);
|
||||||
registerWithContentManager();
|
registerWithContentManager();
|
||||||
|
registerWithProjectView();
|
||||||
PropertyManager.registerPropertyGroup(new RuleSetPropertyGroup());
|
PropertyManager.registerPropertyGroup(new RuleSetPropertyGroup());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -70,6 +73,15 @@ public class PMDOpenTool {
|
|||||||
ContentManager.registerContextActionProvider(cap);
|
ContentManager.registerContextActionProvider(cap);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void registerWithProjectView() {
|
||||||
|
ContextActionProvider cap = new ContextActionProvider() {
|
||||||
|
public Action getContextAction (Browser browser, Node[] nodes) {
|
||||||
|
return ACTION_PMDProjectCheck;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
ProjectView.registerContextActionProvider(cap);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create PMD Rule Sets based upon the configuration settings
|
* Create PMD Rule Sets based upon the configuration settings
|
||||||
* @param ruleSetFactory PMD RuleSetFactory
|
* @param ruleSetFactory PMD RuleSetFactory
|
||||||
@ -129,13 +141,20 @@ public class PMDOpenTool {
|
|||||||
public void actionPerformed (Browser browser) {
|
public void actionPerformed (Browser browser) {
|
||||||
Node node = Browser.getActiveBrowser().getActiveNode();
|
Node node = Browser.getActiveBrowser().getActiveNode();
|
||||||
if (node instanceof JavaFileNode) {
|
if (node instanceof JavaFileNode) {
|
||||||
|
Browser.getActiveBrowser().getMessageView().clearMessages(msgCat); //clear the message window
|
||||||
|
checkNode(node);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
static void checkNode(Node node) {
|
||||||
TextNodeViewer viewer = (TextNodeViewer)Browser.getActiveBrowser().getViewerOfType(node,
|
TextNodeViewer viewer = (TextNodeViewer)Browser.getActiveBrowser().getViewerOfType(node,
|
||||||
TextNodeViewer.class);
|
TextNodeViewer.class);
|
||||||
if (viewer != null) {
|
if (viewer != null) {
|
||||||
Document doc = viewer.getEditor().getDocument();
|
Document doc = viewer.getEditor().getDocument();
|
||||||
try {
|
try {
|
||||||
Report rpt = instanceCheck(doc.getText(0, doc.getLength()));
|
Report rpt = instanceCheck(doc.getText(0, doc.getLength()));
|
||||||
Browser.getActiveBrowser().getMessageView().clearMessages(msgCat); //clear the message window
|
|
||||||
if (rpt == null) {
|
if (rpt == null) {
|
||||||
Browser.getActiveBrowser().getMessageView().addMessage(msgCat,
|
Browser.getActiveBrowser().getMessageView().addMessage(msgCat,
|
||||||
"Error Processing File");
|
"Error Processing File");
|
||||||
@ -160,8 +179,6 @@ public class PMDOpenTool {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
//Create the menu action item for configuring PMD
|
//Create the menu action item for configuring PMD
|
||||||
public static BrowserAction ACTION_PMDConfig = new BrowserAction("Configure PMD",
|
public static BrowserAction ACTION_PMDConfig = new BrowserAction("Configure PMD",
|
||||||
@ -172,6 +189,26 @@ public class PMDOpenTool {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//create the project menu action for running a PMD check against all the java files within the active project
|
||||||
|
public static BrowserAction ACTION_PMDProjectCheck = new BrowserAction ("PMD Check Project", 'P', "Check all the java files in the project") {
|
||||||
|
public void actionPerformed(Browser browser) {
|
||||||
|
Node[] nodes = browser.getActiveBrowser().getActiveProject().getDisplayChildren();
|
||||||
|
Browser.getActiveBrowser().getMessageView().clearMessages(msgCat); //clear the message window
|
||||||
|
for (int i=0; i<nodes.length; i++ ) {
|
||||||
|
if (nodes[i] instanceof PackageNode) {
|
||||||
|
PackageNode node = (PackageNode)nodes[i];
|
||||||
|
Node[] fileNodes = node.getDisplayChildren();
|
||||||
|
for (int j=0; j<fileNodes.length; j++) {
|
||||||
|
if (fileNodes[j] instanceof JavaFileNode) {
|
||||||
|
checkNode(fileNodes[j]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Main method for testing purposes
|
* Main method for testing purposes
|
||||||
* @param args standard arguments
|
* @param args standard arguments
|
||||||
@ -268,6 +305,3 @@ class HighlightMark extends LineMark {
|
|||||||
super(highlightStyle);
|
super(highlightStyle);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -56,6 +56,7 @@ public class RuleSetPropertyGroup
|
|||||||
* Standard Constructor
|
* Standard Constructor
|
||||||
*/
|
*/
|
||||||
public RuleSetPropertyGroup () {
|
public RuleSetPropertyGroup () {
|
||||||
|
int k;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -54,6 +54,7 @@ public class RuleSetPropertyPage extends PropertyPage {
|
|||||||
* Constuctor
|
* Constuctor
|
||||||
*/
|
*/
|
||||||
public RuleSetPropertyPage () {
|
public RuleSetPropertyPage () {
|
||||||
|
int y;
|
||||||
try {
|
try {
|
||||||
jbInit();
|
jbInit();
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
|
Reference in New Issue
Block a user