Modified to use CompilerPage vs previous hackery, much better looking now! http://infoether.com/~tom/jdev_compilepage_screenshot.png
git-svn-id: https://pmd.svn.sourceforge.net/svnroot/pmd/trunk@3991 51baf565-9d33-0410-a72c-fc3788e3496d
This commit is contained in:
@ -7,6 +7,7 @@
|
|||||||
<property name="pluginversion" value="1.7"/>
|
<property name="pluginversion" value="1.7"/>
|
||||||
<property name="bundle.jarname" value="net.sourceforge.pmd.jdeveloper.${pluginversion}.jar"/>
|
<property name="bundle.jarname" value="net.sourceforge.pmd.jdeveloper.${pluginversion}.jar"/>
|
||||||
<property name="jdeveloper.install.dir" value="c:/data/jdev1013/jdev/lib/ext/${ant.project.name}-${pluginversion}"/>
|
<property name="jdeveloper.install.dir" value="c:/data/jdev1013/jdev/lib/ext/${ant.project.name}-${pluginversion}"/>
|
||||||
|
<property name="linux.jdeveloper.install.dir" value="/home/tom/jdev1013/jdev/extensions/"/>
|
||||||
|
|
||||||
|
|
||||||
<path id="project.class.path">
|
<path id="project.class.path">
|
||||||
@ -14,7 +15,8 @@
|
|||||||
<pathelement location="lib/javax-ide.jar"/>
|
<pathelement location="lib/javax-ide.jar"/>
|
||||||
<pathelement location="lib/javatools.jar"/>
|
<pathelement location="lib/javatools.jar"/>
|
||||||
<pathelement location="lib/ide.jar"/>
|
<pathelement location="lib/ide.jar"/>
|
||||||
<pathelement location="lib/myjdevdeps.jar"/>
|
<pathelement location="lib/ojc.jar"/>
|
||||||
|
<pathelement location="lib/jdev.jar"/>
|
||||||
<pathelement location="build"/>
|
<pathelement location="build"/>
|
||||||
</path>
|
</path>
|
||||||
|
|
||||||
@ -48,6 +50,12 @@
|
|||||||
<copy file="lib/jaxen-1.1-beta-7.jar" todir="${jdeveloper.install.dir}/lib"/>
|
<copy file="lib/jaxen-1.1-beta-7.jar" todir="${jdeveloper.install.dir}/lib"/>
|
||||||
</target>
|
</target>
|
||||||
|
|
||||||
|
<target name="deploylinux" depends="delete,jar">
|
||||||
|
<copy file="lib/${bundle.jarname}" todir="${linux.jdeveloper.install.dir}"/>
|
||||||
|
<copy file="lib/${pmdjar}" todir="${linux.jdeveloper.install.dir}/net.sourceforge.pmd.jdeveloper.1.7/lib"/>
|
||||||
|
<copy file="lib/jaxen-1.1-beta-7.jar" todir="${linux.jdeveloper.install.dir}/net.sourceforge.pmd.jdeveloper.1.7/lib"/>
|
||||||
|
</target>
|
||||||
|
|
||||||
<target name="release" depends="clean,jar">
|
<target name="release" depends="clean,jar">
|
||||||
<mkdir dir="tmp/${ant.project.name}-${pluginversion}/lib"/>
|
<mkdir dir="tmp/${ant.project.name}-${pluginversion}/lib"/>
|
||||||
<copy file="lib/${ant.project.name}-${pluginversion}.jar" todir="tmp/${ant.project.name}-${pluginversion}/lib/"/>
|
<copy file="lib/${ant.project.name}-${pluginversion}.jar" todir="tmp/${ant.project.name}-${pluginversion}/lib/"/>
|
||||||
|
@ -1,3 +1,7 @@
|
|||||||
|
????, 2005 - 1.8:
|
||||||
|
Better presentation of the rule violations.
|
||||||
|
Upgraded to PMD 3.3.
|
||||||
|
|
||||||
Oct 18, 2005 - 1.7:
|
Oct 18, 2005 - 1.7:
|
||||||
Merged in changes from Olaf Heimburger to update plugin to work with JDev 10.1.3 early access.
|
Merged in changes from Olaf Heimburger to update plugin to work with JDev 10.1.3 early access.
|
||||||
Modified to use "update center" functionality. Update center location is http://pmd.sf.net/center.xml
|
Modified to use "update center" functionality. Update center location is http://pmd.sf.net/center.xml
|
||||||
|
Binary file not shown.
@ -1,36 +0,0 @@
|
|||||||
package net.sourceforge.pmd.jdeveloper;
|
|
||||||
|
|
||||||
import net.sourceforge.pmd.RuleViolation;
|
|
||||||
import oracle.ide.editor.EditorManager;
|
|
||||||
import oracle.ide.net.URLFactory;
|
|
||||||
import oracle.jdeveloper.ceditor.CodeEditor;
|
|
||||||
|
|
||||||
import javax.swing.*;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This class was inspired by a class on Sun's web site in the JList tutorial section. It's
|
|
||||||
* been twiddled somewhat since then.
|
|
||||||
*/
|
|
||||||
public class JumpingSelectionModel extends DefaultListSelectionModel {
|
|
||||||
|
|
||||||
private DefaultListModel model;
|
|
||||||
|
|
||||||
public JumpingSelectionModel(DefaultListModel model) {
|
|
||||||
this.model = model;
|
|
||||||
}
|
|
||||||
|
|
||||||
public JumpingSelectionModel() {
|
|
||||||
setSelectionMode(SINGLE_SELECTION);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSelectionInterval(int index0, int index1) {
|
|
||||||
int oldIndex = getMinSelectionIndex();
|
|
||||||
super.setSelectionInterval(index0, index1);
|
|
||||||
int newIndex = getMinSelectionIndex();
|
|
||||||
if (oldIndex != newIndex) {
|
|
||||||
RuleViolation rv = ((RuleViolationWrapper)model.getElementAt(newIndex)).getRuleViolation();
|
|
||||||
EditorManager.getEditorManager().openDefaultEditorInFrame(URLFactory.newFileURL(rv.getFilename()));
|
|
||||||
((CodeEditor)EditorManager.getEditorManager().getCurrentEditor()).gotoLine(rv.getLine(), 0, false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,21 +1,10 @@
|
|||||||
package net.sourceforge.pmd.jdeveloper;
|
package net.sourceforge.pmd.jdeveloper;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.FileInputStream;
|
|
||||||
|
|
||||||
import java.util.Iterator;
|
|
||||||
|
|
||||||
import javax.ide.model.Document;
|
|
||||||
|
|
||||||
import javax.swing.JMenuItem;
|
|
||||||
import javax.swing.JOptionPane;
|
|
||||||
|
|
||||||
import net.sourceforge.pmd.PMD;
|
import net.sourceforge.pmd.PMD;
|
||||||
import net.sourceforge.pmd.PMDException;
|
import net.sourceforge.pmd.PMDException;
|
||||||
import net.sourceforge.pmd.Report;
|
import net.sourceforge.pmd.Report;
|
||||||
import net.sourceforge.pmd.RuleContext;
|
import net.sourceforge.pmd.RuleContext;
|
||||||
import net.sourceforge.pmd.RuleViolation;
|
import net.sourceforge.pmd.RuleViolation;
|
||||||
|
|
||||||
import oracle.ide.Addin;
|
import oracle.ide.Addin;
|
||||||
import oracle.ide.AddinManager;
|
import oracle.ide.AddinManager;
|
||||||
import oracle.ide.Context;
|
import oracle.ide.Context;
|
||||||
@ -25,19 +14,28 @@ import oracle.ide.controller.ContextMenu;
|
|||||||
import oracle.ide.controller.ContextMenuListener;
|
import oracle.ide.controller.ContextMenuListener;
|
||||||
import oracle.ide.controller.Controller;
|
import oracle.ide.controller.Controller;
|
||||||
import oracle.ide.controller.IdeAction;
|
import oracle.ide.controller.IdeAction;
|
||||||
import oracle.ide.controller.Menubar;
|
|
||||||
import oracle.ide.editor.EditorManager;
|
import oracle.ide.editor.EditorManager;
|
||||||
import oracle.ide.log.LogManager;
|
import oracle.ide.log.LogManager;
|
||||||
import oracle.ide.log.LogPage;
|
import oracle.ide.log.LogPage;
|
||||||
import oracle.ide.log.LogWindow;
|
import oracle.ide.log.LogWindow;
|
||||||
import oracle.ide.model.Element;
|
import oracle.ide.model.Element;
|
||||||
|
import oracle.ide.model.Node;
|
||||||
import oracle.ide.model.Project;
|
import oracle.ide.model.Project;
|
||||||
import oracle.ide.model.Reference;
|
|
||||||
import oracle.ide.navigator.NavigatorManager;
|
import oracle.ide.navigator.NavigatorManager;
|
||||||
import oracle.ide.panels.Navigable;
|
import oracle.ide.panels.Navigable;
|
||||||
|
import oracle.jdeveloper.compiler.IdeLog;
|
||||||
|
import oracle.jdeveloper.compiler.IdeStorage;
|
||||||
import oracle.jdeveloper.model.JavaSourceNode;
|
import oracle.jdeveloper.model.JavaSourceNode;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileInputStream;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
|
||||||
public class Plugin implements Addin, Controller, ContextMenuListener {
|
public class Plugin implements Addin, Controller, ContextMenuListener {
|
||||||
|
|
||||||
@ -94,6 +92,9 @@ public class Plugin implements Addin, Controller, ContextMenuListener {
|
|||||||
}
|
}
|
||||||
private boolean added;
|
private boolean added;
|
||||||
|
|
||||||
|
// whew, this is kludgey
|
||||||
|
private Map fileToNodeMap = new HashMap();
|
||||||
|
|
||||||
public boolean handleEvent(IdeAction ideAction, Context context) {
|
public boolean handleEvent(IdeAction ideAction, Context context) {
|
||||||
if (!added) {
|
if (!added) {
|
||||||
LogManager.getLogManager().addPage(rvPage);
|
LogManager.getLogManager().addPage(rvPage);
|
||||||
@ -102,24 +103,22 @@ public class Plugin implements Addin, Controller, ContextMenuListener {
|
|||||||
}
|
}
|
||||||
if (ideAction.getCommandId() == CHECK_CMD_ID) {
|
if (ideAction.getCommandId() == CHECK_CMD_ID) {
|
||||||
try {
|
try {
|
||||||
|
fileToNodeMap.clear();
|
||||||
PMD pmd = new PMD();
|
PMD pmd = new PMD();
|
||||||
SelectedRules rs = new SelectedRules(SettingsPanel.createSettingsStorage());
|
SelectedRules rs = new SelectedRules(SettingsPanel.createSettingsStorage());
|
||||||
RuleContext ctx = new RuleContext();
|
RuleContext ctx = new RuleContext();
|
||||||
ctx.setReport(new Report());
|
ctx.setReport(new Report());
|
||||||
if (resolveType(context.getElement()) == PROJECT) {
|
if (context.getElement() instanceof Project) {
|
||||||
Iterator i = context.getProject().getListOfChildren().iterator();
|
Project project = (Project)context.getElement();
|
||||||
while (i.hasNext()) {
|
for (Iterator i = project.getChildren(); i.hasNext();) {
|
||||||
Object obj = i.next();
|
Object obj = i.next();
|
||||||
if (!(obj instanceof Reference)) {
|
if (!(obj instanceof JavaSourceNode)) {
|
||||||
System.out.println("PMD plugin expected a Reference, found a " + obj.getClass() + " instead. Odd.");
|
System.out.println("PMD plugin expected a JavaSourceNode, found a " + obj.getClass() + " instead. Odd.");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
obj = ((Reference)obj).getData();
|
JavaSourceNode candidate = (JavaSourceNode)obj;
|
||||||
if (!(obj instanceof Document)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
Document candidate = (Document)obj;
|
|
||||||
if (candidate.getLongLabel().endsWith(".java") && new File(candidate.getLongLabel()).exists()) {
|
if (candidate.getLongLabel().endsWith(".java") && new File(candidate.getLongLabel()).exists()) {
|
||||||
|
fileToNodeMap.put(candidate.getLongLabel(), candidate);
|
||||||
ctx.setSourceCodeFilename(candidate.getLongLabel());
|
ctx.setSourceCodeFilename(candidate.getLongLabel());
|
||||||
FileInputStream fis = new FileInputStream(new File(candidate.getLongLabel()));
|
FileInputStream fis = new FileInputStream(new File(candidate.getLongLabel()));
|
||||||
pmd.processFile(fis, rs.getSelectedRules(), ctx);
|
pmd.processFile(fis, rs.getSelectedRules(), ctx);
|
||||||
@ -128,6 +127,7 @@ public class Plugin implements Addin, Controller, ContextMenuListener {
|
|||||||
}
|
}
|
||||||
render(ctx);
|
render(ctx);
|
||||||
} else if (resolveType(context.getElement()) == SOURCE) {
|
} else if (resolveType(context.getElement()) == SOURCE) {
|
||||||
|
fileToNodeMap.put(context.getNode().getLongLabel(), context.getNode());
|
||||||
ctx.setSourceCodeFilename(context.getNode().getLongLabel());
|
ctx.setSourceCodeFilename(context.getNode().getLongLabel());
|
||||||
pmd.processFile(context.getNode().getInputStream(), rs.getSelectedRules(), ctx);
|
pmd.processFile(context.getNode().getInputStream(), rs.getSelectedRules(), ctx);
|
||||||
render(ctx);
|
render(ctx);
|
||||||
@ -145,9 +145,6 @@ public class Plugin implements Addin, Controller, ContextMenuListener {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* TODO investigate CompilerPage as a replacement for RuleViolationPage; or could perhaps subclass it instead.
|
|
||||||
*/
|
|
||||||
private void render(RuleContext ctx) {
|
private void render(RuleContext ctx) {
|
||||||
rvPage.show();
|
rvPage.show();
|
||||||
rvPage.clearAll();
|
rvPage.clearAll();
|
||||||
@ -158,9 +155,13 @@ public class Plugin implements Addin, Controller, ContextMenuListener {
|
|||||||
((LogWindow)page).show();
|
((LogWindow)page).show();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
List list = new ArrayList();
|
||||||
for (Iterator i = ctx.getReport().iterator(); i.hasNext();) {
|
for (Iterator i = ctx.getReport().iterator(); i.hasNext();) {
|
||||||
rvPage.add((RuleViolation)i.next());
|
RuleViolation rv = (RuleViolation)i.next();
|
||||||
|
Node node = (Node)fileToNodeMap.get(rv.getFilename());
|
||||||
|
list.add(new IdeLog.Message(Ide.getActiveWorkspace(), Ide.getActiveProject(), new IdeStorage(node), rv.getDescription(), 2, rv.getNode().getBeginLine()+1, rv.getNode().getBeginColumn()));
|
||||||
}
|
}
|
||||||
|
rvPage.add(list);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -172,8 +173,7 @@ public class Plugin implements Addin, Controller, ContextMenuListener {
|
|||||||
// Controller
|
// Controller
|
||||||
|
|
||||||
// ContextMenuListener
|
// ContextMenuListener
|
||||||
public void menuWillHide(ContextMenu contextMenu) {
|
public void menuWillHide(ContextMenu contextMenu) {}
|
||||||
}
|
|
||||||
|
|
||||||
public void menuWillShow(ContextMenu contextMenu) {
|
public void menuWillShow(ContextMenu contextMenu) {
|
||||||
Element doc = contextMenu.getContext().getElement();
|
Element doc = contextMenu.getContext().getElement();
|
||||||
|
@ -1,34 +1,16 @@
|
|||||||
package net.sourceforge.pmd.jdeveloper;
|
package net.sourceforge.pmd.jdeveloper;
|
||||||
|
|
||||||
import net.sourceforge.pmd.RuleViolation;
|
import oracle.jdeveloper.compiler.CompilerPage;
|
||||||
import oracle.ide.layout.ViewId;
|
|
||||||
import oracle.ide.log.AbstractLogPage;
|
|
||||||
|
|
||||||
import javax.swing.*;
|
import java.util.List;
|
||||||
import java.awt.*;
|
|
||||||
|
|
||||||
public class RuleViolationPage extends AbstractLogPage {
|
public class RuleViolationPage extends CompilerPage {
|
||||||
|
|
||||||
private DefaultListModel model = new DefaultListModel();
|
|
||||||
private JScrollPane scrollPane;
|
|
||||||
private JList list;
|
|
||||||
|
|
||||||
public RuleViolationPage() {
|
public RuleViolationPage() {
|
||||||
super(new ViewId("PMDPage", Plugin.TITLE), null, false);
|
super(Plugin.TITLE, Plugin.TITLE, null);
|
||||||
list = new JList(model);
|
|
||||||
list.setSelectionModel(new JumpingSelectionModel(model));
|
|
||||||
scrollPane = new JScrollPane(list);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void add(RuleViolation ruleViolation) {
|
public void add(List list) {
|
||||||
model.addElement(new RuleViolationWrapper(ruleViolation));
|
super.logMsg(list);
|
||||||
}
|
|
||||||
|
|
||||||
public Component getGUI() {
|
|
||||||
return scrollPane;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void clearAll() {
|
|
||||||
model.clear();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,20 +0,0 @@
|
|||||||
package net.sourceforge.pmd.jdeveloper;
|
|
||||||
|
|
||||||
import net.sourceforge.pmd.RuleViolation;
|
|
||||||
|
|
||||||
public class RuleViolationWrapper {
|
|
||||||
|
|
||||||
private RuleViolation ruleViolation;
|
|
||||||
|
|
||||||
public RuleViolationWrapper(RuleViolation ruleViolation) {
|
|
||||||
this.ruleViolation = ruleViolation;
|
|
||||||
}
|
|
||||||
|
|
||||||
public RuleViolation getRuleViolation() {
|
|
||||||
return this.ruleViolation;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String toString() {
|
|
||||||
return ruleViolation.getFilename() + "; line " + ruleViolation.getLine() +"; ("+ ruleViolation.getRule().getName() + ") " + ruleViolation.getDescription();
|
|
||||||
}
|
|
||||||
}
|
|
@ -6,7 +6,11 @@ import net.sourceforge.pmd.RuleSetFactory;
|
|||||||
import net.sourceforge.pmd.RuleSetNotFoundException;
|
import net.sourceforge.pmd.RuleSetNotFoundException;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import java.util.*;
|
import java.util.Comparator;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Properties;
|
||||||
|
import java.util.TreeMap;
|
||||||
|
|
||||||
public class SelectedRules {
|
public class SelectedRules {
|
||||||
|
|
||||||
|
@ -7,7 +7,10 @@ import oracle.ide.panels.TraversableContext;
|
|||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import javax.swing.border.EmptyBorder;
|
import javax.swing.border.EmptyBorder;
|
||||||
import java.awt.*;
|
import java.awt.BorderLayout;
|
||||||
|
import java.awt.Component;
|
||||||
|
import java.awt.FileDialog;
|
||||||
|
import java.awt.Frame;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
import java.awt.event.ActionListener;
|
import java.awt.event.ActionListener;
|
||||||
import java.awt.event.MouseAdapter;
|
import java.awt.event.MouseAdapter;
|
||||||
|
Reference in New Issue
Block a user