diff --git a/pmd-jbuilder/lib/PMDOpenTool.jar b/pmd-jbuilder/lib/PMDOpenTool.jar index 68951f85c9..774c2cf8d6 100644 Binary files a/pmd-jbuilder/lib/PMDOpenTool.jar and b/pmd-jbuilder/lib/PMDOpenTool.jar differ diff --git a/pmd-jbuilder/src/html/cpd-props.html b/pmd-jbuilder/src/html/cpd-props.html new file mode 100644 index 0000000000..7a0685be93 --- /dev/null +++ b/pmd-jbuilder/src/html/cpd-props.html @@ -0,0 +1,7 @@ + + +CPD stands for "Cut and Paste Tool". The function of CPD is to find duplicate code across all the files in a particular
+project. You can specify the minimum number of tokens that constitute a legitimate CPD find. A token represents the smallest
+parseable unit in the Java language. For example, all java keywords, variable names, method names, etc are considered tokens. + + \ No newline at end of file diff --git a/pmd-jbuilder/src/net/sourceforge/pmd/jbuilder/CPDPropertyGroup.java b/pmd-jbuilder/src/net/sourceforge/pmd/jbuilder/CPDPropertyGroup.java new file mode 100644 index 0000000000..98f263df0f --- /dev/null +++ b/pmd-jbuilder/src/net/sourceforge/pmd/jbuilder/CPDPropertyGroup.java @@ -0,0 +1,37 @@ +package net.sourceforge.pmd.jbuilder; + +import com.borland.primetime.properties.PropertyGroup; +import com.borland.primetime.properties.PropertyPageFactory; +import com.borland.primetime.properties.PropertyPage; +import com.borland.primetime.ide.MessageCategory; +import com.borland.primetime.properties.GlobalIntegerProperty; + +/** + *

Title: JBuilder OpenTool for PMD

+ *

Description: Provides an environemnt for using the PMD aplication from within JBuilder

+ *

Copyright: Copyright (c) 2002

+ *

Company: InfoEther

+ * @author David Craine + * @version 1.0 + */ + +public class CPDPropertyGroup implements PropertyGroup { + static GlobalIntegerProperty PROP_MIN_TOKEN_COUNT = new GlobalIntegerProperty(Constants.RULESETS, "mintokencount", 30); + + public CPDPropertyGroup() { + } + public void initializeProperties() { + } + + public PropertyPageFactory getPageFactory(Object topic) { + if (topic == Constants.RULESETS_TOPIC) { + return new PropertyPageFactory("CPD Properties", "Configure the CPD RuleSets") { + + public PropertyPage createPropertyPage () { + return new CPDPropertyPage(); + } + }; + } + return null; + } +} \ No newline at end of file diff --git a/pmd-jbuilder/src/net/sourceforge/pmd/jbuilder/CPDPropertyPage.java b/pmd-jbuilder/src/net/sourceforge/pmd/jbuilder/CPDPropertyPage.java new file mode 100644 index 0000000000..2d851f6191 --- /dev/null +++ b/pmd-jbuilder/src/net/sourceforge/pmd/jbuilder/CPDPropertyPage.java @@ -0,0 +1,96 @@ +package net.sourceforge.pmd.jbuilder; + +import java.awt.*; +import java.awt.event.*; +import java.util.*; + +import javax.swing.*; +import javax.swing.border.*; +import javax.swing.event.*; + +import com.borland.primetime.help.*; +import com.borland.primetime.ide.*; +import com.borland.primetime.properties.*; +import net.sourceforge.pmd.*; +import com.borland.jbcl.layout.*; + + +/** + *

Title: JBuilder OpenTool for PMD

+ *

Description: Provides an environemnt for using the PMD aplication from within JBuilder

+ *

Copyright: Copyright (c) 2002

+ *

Company: InfoEther

+ * @author David Craine + * @version 1.0 + */ + +public class CPDPropertyPage extends PropertyPage { + static CPDPropertyPage currentInstance = null; + private JPanel jPanel1 = new JPanel(); + private VerticalFlowLayout verticalFlowLayout1 = new VerticalFlowLayout(); + private JLabel jLabel1 = new JLabel(); + private JTextField jTextField1 = new JTextField(); + + public CPDPropertyPage() { + currentInstance = this; + try { + jbInit(); + init2(); + } + catch(Exception e) { + e.printStackTrace(); + } + } + + + /** + * This methiod is called by JBuilder when the user presses "OK" in the property dialog + */ + public void writeProperties() { + try { + int minTokenCount = Integer.parseInt(jTextField1.getText()); + CPDPropertyGroup.PROP_MIN_TOKEN_COUNT.setInteger(minTokenCount); + } + catch (Exception ex) { + + } + + } + + /** + * This methiod is called by JBuilder + */ + public HelpTopic getHelpTopic() { + return new ZipHelpTopic( + null, + getClass().getResource("/html/cpd-props.html").toString()); + } + + /** + * This methiod is called by JBuilder + */ + public void readProperties() { + } + + /** + * JBuilder-constructed initialization + * @throws Exception + */ + private void jbInit() throws Exception { + this.setLayout(verticalFlowLayout1); + jLabel1.setText("Minimum Token Count"); + jTextField1.setPreferredSize(new Dimension(40, 21)); + this.add(jPanel1, null); + jPanel1.add(jLabel1, null); + jPanel1.add(jTextField1, null); + } + + /** + * additional intiialzation + */ + private void init2() { + jTextField1.setText(String.valueOf(CPDPropertyGroup.PROP_MIN_TOKEN_COUNT.getInteger())); + } + +} + diff --git a/pmd-jbuilder/src/net/sourceforge/pmd/jbuilder/PMDOpenTool.java b/pmd-jbuilder/src/net/sourceforge/pmd/jbuilder/PMDOpenTool.java index d132e63e57..3fcfae3ac1 100644 --- a/pmd-jbuilder/src/net/sourceforge/pmd/jbuilder/PMDOpenTool.java +++ b/pmd-jbuilder/src/net/sourceforge/pmd/jbuilder/PMDOpenTool.java @@ -43,6 +43,7 @@ public class PMDOpenTool { static MessageCategory msgCat = new MessageCategory("PMD Results"); static MessageCategory cpdCat = new MessageCategory("CPD Results"); public static ActionGroup GROUP_PMD = new ActionGroup("PMD", 'p', true); + public static ActionGroup GROUP_TOOLBAR_PMD = new ActionGroup("PMD", 'P', true); static Font fileNameMsgFont = new Font("Dialog", Font.BOLD, 12); static Font stdMsgFont = new Font("Dialog", Font.PLAIN, 12); @@ -65,11 +66,14 @@ public class PMDOpenTool { GROUP_PMD.add(B_ACTION_PMDCheck); + GROUP_PMD.add(B_ACTION_PMDProjectCheck); + GROUP_PMD.add(B_ACTION_CPDProjectCheck); GROUP_PMD.add(B_ACTION_PMDConfig); JBuilderMenu.GROUP_Tools.add(GROUP_PMD); - JBuilderToolBar.GROUP_RunBar.add(B_ACTION_PMDCheck); - JBuilderToolBar.GROUP_RunBar.add(B_ACTION_PMDProjectCheck); - JBuilderToolBar.GROUP_RunBar.add(B_ACTION_CPDProjectCheck); + GROUP_TOOLBAR_PMD.add(B_ACTION_PMDCheck); + GROUP_TOOLBAR_PMD.add(B_ACTION_PMDProjectCheck); + GROUP_TOOLBAR_PMD.add(B_ACTION_CPDProjectCheck); + Browser.addToolBarGroup(GROUP_TOOLBAR_PMD); registerWithContentManager(); registerWithProjectView(); @@ -82,6 +86,7 @@ public class PMDOpenTool { ActiveRuleSetPropertyGroup apropGrp = new ActiveRuleSetPropertyGroup(); ConfigureRuleSetPropertyGroup cpropGrp = new ConfigureRuleSetPropertyGroup(); AcceleratorPropertyGroup accpropGrp = new AcceleratorPropertyGroup(); + CPDPropertyGroup cpdPropGrp = new CPDPropertyGroup(); //register the Keymap shortcuts if they are enabled if (AcceleratorPropertyGroup.PROP_KEYS_ENABLED.getBoolean()) { @@ -92,6 +97,7 @@ public class PMDOpenTool { PropertyManager.registerPropertyGroup(cpropGrp); PropertyManager.registerPropertyGroup(ipropGrp); PropertyManager.registerPropertyGroup(accpropGrp); + PropertyManager.registerPropertyGroup(cpdPropGrp); } } @@ -332,7 +338,7 @@ public class PMDOpenTool { try { Browser.getActiveBrowser().getMessageView().clearMessages(cpdCat); //clear the message window CPD cpd = new CPD(); - cpd.setMinimumTileSize(25); + cpd.setMinimumTileSize(CPDPropertyGroup.PROP_MIN_TOKEN_COUNT.getInteger()); Node[] nodes = Browser.getActiveBrowser().getActiveProject().getDisplayChildren(); CPDDialog cpdd = new CPDDialog(cpd); for (int i=0; i