Preparing for a new release, finished some javadoc, created shortcut and generally freshed up the code

git-svn-id: https://pmd.svn.sourceforge.net/svnroot/pmd/trunk@1265 51baf565-9d33-0410-a72c-fc3788e3496d
This commit is contained in:
Ole-Martin Mork
2002-11-25 23:25:48 +00:00
parent 0c4c028c08
commit 9f0263195e
16 changed files with 387 additions and 210 deletions

View File

@ -1,3 +1,6 @@
Version 0.6
- New properties dialog. Makes it possible to select individual rules
Version 0.5
- Fixed bug 633432 pmd-netbeans can't change settings (netbeans)
- Fixed bug 634463 Problem with UnusedPrivateField (netbeans)

View File

@ -10,7 +10,6 @@ the directory where you downloaded pmd-netbeans and choose the file pmd.nbm.
Press Next, accept the license and choose to include the pmd module. Press
Finish, restart the IDE and you're done :)
------------------------
USE
------------------------
@ -25,5 +24,4 @@ OPTIONS
------------------------
Go to Options/IDE Configuration/Server And External Tool Settings/PMD Settings
to choose which rulesets to use. Go to the PMD documentation to learn more about
rulesets.
to choose which rules to use.

View File

@ -27,11 +27,9 @@
package pmd;
/**
* Contains a fault that pmd discovers @authorOle-Martin Mørk @created17.
* oktober 2002
*
* Contains a fault that pmd discovers
* @created 17.oktober 2002
* @author Ole-Martin Mřrk
* @created 3. november 2002
*/
public class Fault implements Comparable {

View File

@ -56,8 +56,9 @@ import org.openide.util.actions.CookieAction;
import org.openide.windows.InputOutput;
import org.openide.windows.OutputWriter;
import pmd.config.ConfigUtils;
import pmd.config.PMDOptionsSettings;
import pmd.config.ui.SelectedListModel;
/**
* Action that can always be invoked and work procedurally.
@ -66,7 +67,7 @@ import pmd.config.ui.SelectedListModel;
* @created 17. oktober 2002
*/
public class RunPMDAction extends CookieAction {
/** Indicates if any violations has been printed */
private boolean printed = false;
@ -115,7 +116,7 @@ public class RunPMDAction extends CookieAction {
* Returns the mode of this action
*
* @return Description of the Return Value
* @see org.openide.util.actions.SystemAction#MODE_EXACTLY_ONE
* @see org.openide.util.actions.CookieAction#MODE_ALL
*/
protected int mode() {
return MODE_ALL;
@ -207,6 +208,9 @@ public class RunPMDAction extends CookieAction {
if( !printed ) {
io.getOut().println( "Everything ok", null );
}
else {
io.getOut().println( "Finished", null );
}
}
catch( IOException e ) {
@ -224,16 +228,12 @@ public class RunPMDAction extends CookieAction {
*/
private static RuleSet constructRuleSets() {
RuleSet rules = new RuleSet();
SelectedListModel.getSelectedListModelInstance().setData( PMDOptionsSettings.getDefault().getRules() );
List list = SelectedListModel.getSelectedListModelInstance().getData();
Iterator iterator = list.iterator();
while( iterator.hasNext() ) {
rules.addRule( (Rule)iterator.next() );
}
List list = ConfigUtils.createRuleList(
PMDOptionsSettings.getDefault().getRules() );
Iterator iterator = list.iterator();
while( iterator.hasNext() ) {
rules.addRule( ( Rule )iterator.next() );
}
return rules;
}

View File

@ -38,19 +38,38 @@ import org.openide.util.NbBundle;
*/
public class PMDOptionsSettings extends SystemOption {
private static final long serialVersionUID = 8418202279282091070L;
/** The serialVersionUID. Don't change! */
private final static long serialVersionUID = 8418202279282091070L;
/** The constant for the rulesets property */
/**
* The constant for the rulesets property
* @deprecated this property is not in use.
*/
public final static String PROP_RULESETS = "rulesets";
/** The constant for the rulesets property */
/** The constant for the rulesets property */
public final static String PROP_RULES = "rules";
/** The default rules.*/
private static final String DEFAULT_RULES =
"AvoidDuplicateLiterals, StringToString, StringInstantiation, JUnitStaticSuite, " +
"JUnitSpelling, ForLoopsMustUseBracesRule, IfElseStmtsMustUseBracesRule, " +
"WhileLoopsMustUseBracesRule, IfStmtsMustUseBraces, EmptyCatchBlock, EmptyIfStmt, " +
"EmptyWhileStmt, JumbledIncrementer, UnnecessaryConversionTemporaryRule, " +
"OverrideBothEqualsAndHashcodeRule, EmptyTryBlock, EmptySwitchStatements, " +
"EmptyFinallyBlock, UnusedLocalVariable, UnusedPrivateField, UnusedFormalParameter, " +
"UnnecessaryConstructorRule, UnusedPrivateMethod, SwitchStmtsShouldHaveDefault, " +
"SimplifyBooleanReturnsRule, LooseCouplingRule, AvoidDeeplyNestedIfStmts, " +
"AvoidReassigningParametersRule, OnlyOneReturn, UseSingletonRule, " +
"DontImportJavaLang, UnusedImports, DuplicateImports, ";
// No constructor please!
/** Sets the default rulesets and initializes the option */
/** Sets the default rulesets and initializes the option */
protected void initialize() {
super.initialize();
setRulesets("");
setRulesets( "" );
setRules( DEFAULT_RULES );
}
@ -85,44 +104,41 @@ public class PMDOptionsSettings extends SystemOption {
}
/**
* Returns the rulesets property
*
/** Returns the rulesets property
* @deprecated not used anymore, use {@link #getRules}
* @return the rulesets property
*/
public String getRulesets() {
return ( String )getProperty( PROP_RULESETS );
}
/**
* Sets the rulesets property
*
/** Sets the rulesets property
* @deprecated not used anymore, use {@link #setRules}
* @param rulesets the rulesets value to set
*/
public void setRulesets( String rulesets ) {
putProperty( PROP_RULESETS, rulesets, true );
}
/**
/**
* Returns the rulesets property
*
* @return the rulesets property
*/
public String getRules() {
return ( String )getProperty( PROP_RULES );
}
/**
* Sets the rulesets property
*
* @param rulesets the rulesets value to set
* @param rules The new rules value
*/
public void setRules( String rules) {
public void setRules( String rules ) {
putProperty( PROP_RULES, rules, true );
}
}

View File

@ -0,0 +1 @@
<HTML><BODY>The properties of pmd.</BODY></HTML>

View File

@ -1,7 +1,28 @@
/*
* ListModel.java
* Copyright (c) 2002, Ole-Martin Mørk
* All rights reserved.
*
* Created on 14. november 2002, 21:26
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
* DAMAGE.
*/
package pmd.config.ui;
@ -12,25 +33,27 @@ import java.util.List;
import java.util.Set;
import javax.swing.AbstractListModel;
import net.sourceforge.pmd.Rule;
import net.sourceforge.pmd.RuleSet;
import net.sourceforge.pmd.RuleSetFactory;
import net.sourceforge.pmd.RuleSetNotFoundException;
/**
* The datamodel for the available rules list
* @author ole martin mørk
* @created 16. november 2002
*/
public class AvailableListModel extends AbstractListModel {
/** The instance */
private static AvailableListModel listmodel = new AvailableListModel();
/** The data in the list */
private List list = new ArrayList();
/**
* Gets the instance attribute of the AvailableListModel class
* Gets the instance of the AvailableListModel class
*
* @return The instance value
* @return The instance
*/
public static AvailableListModel getInstance() {
return listmodel;
@ -44,18 +67,18 @@ public class AvailableListModel extends AbstractListModel {
/**
* Gets the elementAt attribute of the AvailableListModel object
* Gets the element at the specified index
*
* @param param Description of the Parameter
* @return The elementAt value
* @param index index of the list
* @return The list element
*/
public Object getElementAt( int param ) {
return ( ( Rule )list.get( param ) );
public Object getElementAt( int index ) {
return ( ( Rule )list.get( index ) );
}
/**
* Gets the size attribute of the AvailableListModel object
* Gets the size of the list
*
* @return The size value
*/
@ -65,7 +88,7 @@ public class AvailableListModel extends AbstractListModel {
/**
* Sets the list attribute of the AvailableListModel object
* Sets the list.
*
* @param list The new list value
*/
@ -74,10 +97,8 @@ public class AvailableListModel extends AbstractListModel {
}
/**
* Description of the Method
*
* @param o Description of the Parameter
/** Adds object <CODE>o</CODE> to the list
* @param o The parameter to add to the list
*/
public void add( Object o ) {
if( !list.contains( o ) ) {
@ -86,11 +107,10 @@ public class AvailableListModel extends AbstractListModel {
}
}
/**
* Description of the Method
* Removes <code>o</code> from the list
*
* @param o Description of the Parameter
* @param o the object to remove
*/
public void remove( Object o ) {
int i = list.indexOf( o );
@ -99,7 +119,7 @@ public class AvailableListModel extends AbstractListModel {
}
/** Description of the Method */
/** Removes all elements in the list */
public void removeAll() {
int i = list.size();
list.clear();
@ -107,10 +127,8 @@ public class AvailableListModel extends AbstractListModel {
}
/**
* Adds a feature to the All attribute of the AvailableListModel object
*
* @param coll The feature to be added to the All attribute
/** Adds all data in <CODE>coll</CODE> to the list
* @param coll The collection containing Rule elements
*/
public void addAll( Collection coll ) {
int i = list.size();
@ -119,15 +137,15 @@ public class AvailableListModel extends AbstractListModel {
}
/**
* Gets the data attribute of the AvailableListModel object
*
* @return The data value
/** Returns the data for the list
* @return The data
*/
public List getData() {
return list;
}
/** Resets the list */
public void refresh() {
list.clear();
try {

View File

@ -1,7 +1,28 @@
/*
* ListCellRenderer.java
* Copyright (c) 2002, Ole-Martin Mørk
* All rights reserved.
*
* Created on 14. november 2002, 21:46
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
* DAMAGE.
*/
package pmd.config.ui;
@ -12,25 +33,22 @@ import javax.swing.UIManager;
import javax.swing.border.EmptyBorder;
import net.sourceforge.pmd.Rule;
/**
/** The cellrenderer used in the lists
* @author ole martin mørk
* @created 16. november 2002
*/
public class ListCell implements ListCellRenderer {
/**
* Gets the listCellRendererComponent attribute of the ListCell object
*
* @param jList Description of the Parameter
* @param obj Description of the Parameter
* @param param Description of the Parameter
* @param param3 Description of the Parameter
* @param param4 Description of the Parameter
* @return The listCellRendererComponent value
/** Gets the listCellRendererComponent attribute of the ListCell object
* @param list Not used
* @param value The value to be rendered
* @param index Not used
* @param isSelected Says if the element is selected or not
* @param cellHasFocus not used
* @return A JLabel rendering the rule
*/
public java.awt.Component getListCellRendererComponent(
JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
JList list, Object value, int index, boolean isSelected, boolean cellHasFocus ) {
Rule rule = ( Rule )value;
JLabel box = new JLabel( rule.getName() );
box.setEnabled( true );

View File

@ -1,9 +1,29 @@
/*
* PropertiesModel.java
* Copyright (c) 2002, Ole-Martin Mørk
* All rights reserved.
*
* Created on 21. november 2002, 20:59
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
* DAMAGE.
*/
package pmd.config.ui;
import java.util.Enumeration;
@ -11,14 +31,19 @@ import javax.swing.table.AbstractTableModel;
import net.sourceforge.pmd.Rule;
import net.sourceforge.pmd.RuleProperties;
/**
*
* @author ole martin mørk
/** The datamodel for the properties table
* @author ole martin mørk
* @created 25. november 2002
*/
public class PropertiesModel extends AbstractTableModel {
/** The values used in the table */
private final String values[][];
/** Creates a new instance of PropertiesModel */
/** Creates a new instance of PropertiesModel
* @param rule The rule the table should be based upon
*/
public PropertiesModel( Rule rule ) {
if( rule == null ) {
values = new String[0][0];
@ -28,33 +53,58 @@ public class PropertiesModel extends AbstractTableModel {
values = new String[properties.size()][2];
Enumeration keys = properties.keys();
int counter = 0;
while(keys.hasMoreElements() ) {
String key = (String)keys.nextElement();
while( keys.hasMoreElements() ) {
String key = ( String )keys.nextElement();
values[counter][0] = key;
values[counter][1] = properties.getProperty( key );
counter++;
}
}
/** Gets the number of columns in the table
* @return the number of columns
*/
public int getColumnCount() {
return 2;
}
/** Gets the number of rows in the table
* @return the number of rows
*/
public int getRowCount() {
return values.length;
}
public Object getValueAt(int param, int param1) {
return values[param][param1];
/** Gets the value at the specified place in the table
* @return the value at row-column
* @param row The row where the data is
* @param column The column where the data is
*/
public Object getValueAt( int row, int column ) {
return values[row][column];
}
/** Gets the name of the columns
* @param column The column index
* @return The name of the column
*/
public String getColumnName( int column ) {
return column == 0 ? "Name" : "Value";
}
/** Says if the cell is editable
* @param rowIndex The row
* @param columnIndex The column
* @return false
*/
public boolean isCellEditable( int rowIndex, int columnIndex ) {
return columnIndex == 1;
return false;
}
}
}

View File

@ -1,90 +1,97 @@
/*
* RuleEditor.java
* Copyright (c) 2002, Ole-Martin Mørk
* All rights reserved.
*
* Created on 18. november 2002, 21:50
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
* DAMAGE.
*/
package pmd.config.ui;
import java.awt.Component;
import java.beans.PropertyEditorSupport;
import java.util.Iterator;
import java.util.List;
import net.sourceforge.pmd.Rule;
import pmd.config.ConfigUtils;
/**
/** The PropertyEditor of the Rule property
* @author ole martin mørk
* @created 18. november 2002
*/
public class RuleEditor extends PropertyEditorSupport {
/**
* Gets the customEditor attribute of the RuleEditor object
*
* @return The customEditor value
/**
* Returns the custom editor of the Rule property
* @return the editor
*/
public Component getCustomEditor() {
return new RuleEnabler( this );
}
/**
* Description of the Method
*
* @return Description of the Return Value
/**
* Returns true
* @return true
*/
public boolean supportsCustomEditor() {
return true;
}
/**
* Gets the value attribute of the RuleEditor object
*
* @return The value value
/**
* Returns the selected rules
* @return the selected rules
*/
public Object getValue() {
String string = getValueAsText( SelectedListModel.getSelectedListModelInstance().getData() );
//JOptionPane.showMessageDialog( null, string );
return string;
return ConfigUtils.getValueAsText(
SelectedListModel.getSelectedListModelInstance().getData() );
}
/**
* Gets the asText attribute of the RuleEditor object
*
* @return The asText value
/**
* Returns a string representation of the property value
* @return the property as text
*/
public String getAsText() {
return getValue().toString();
}
/**
* Sets the value attribute of the RuleEditor object
*
* @param obj The new value value
/**
* Sets the value to be edited in the editor
* @param obj The new value
*/
public void setValue( Object obj ) {
if( obj != null ) {
SelectedListModel.getSelectedListModelInstance().setData( ( String )obj );
SelectedListModel.getSelectedListModelInstance().setList(
ConfigUtils.createRuleList( (String)obj ) );
AvailableListModel.getInstance().refresh();
AvailableListModel.getInstance().getData().removeAll( SelectedListModel.getSelectedListModelInstance().getData() );
AvailableListModel.getInstance().getData().removeAll(
SelectedListModel.getSelectedListModelInstance().getData() );
}
}
public void setAsText( String string ) throws IllegalArgumentException {}
/**
* Gets the valueAsText attribute of the RuleEditor object
*
* @param value Description of the Parameter
* @return The valueAsText value
/**
* Not implemented
* @param string the text
* @exception IllegalArgumentException never
*/
private String getValueAsText( List value ) {
StringBuffer buffer = new StringBuffer();
if( value != null ) {
Iterator iterator = value.iterator();
while( iterator.hasNext() ) {
Rule rule = ( Rule )iterator.next();
buffer.append( rule.getName() ).append( ", " );
}
}
return String.valueOf( buffer );
}
public void setAsText( String string ) throws IllegalArgumentException { }
}

View File

@ -55,7 +55,6 @@
<SubComponents>
<Container class="javax.swing.JScrollPane" name="jScrollPane1">
<Properties>
<Property name="toolTipText" type="java.lang.String" value="null"/>
<Property name="horizontalScrollBarPolicy" type="int" value="31"/>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[270, 100]"/>
@ -137,7 +136,6 @@
<ComponentRef name="chosenList"/>
</Property>
<Property name="text" type="java.lang.String" value="Chosen rules"/>
<Property name="horizontalAlignment" type="int" value="11"/>
</Properties>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
@ -217,7 +215,6 @@
<SubComponents>
<Component class="javax.swing.JLabel" name="jLabel6">
<Properties>
<Property name="displayedMnemonic" type="int" value="73"/>
<Property name="text" type="java.lang.String" value="Information"/>
</Properties>
<Constraints>
@ -228,12 +225,10 @@
</Component>
<Component class="javax.swing.JLabel" name="jLabel5">
<Properties>
<Property name="displayedMnemonic" type="int" value="69"/>
<Property name="labelFor" type="java.awt.Component" editor="org.netbeans.modules.form.ComponentChooserEditor">
<ComponentRef name="example"/>
</Property>
<Property name="text" type="java.lang.String" value="Example"/>
<Property name="horizontalAlignment" type="int" value="11"/>
</Properties>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
@ -302,11 +297,11 @@
</Component>
<Component class="javax.swing.JLabel" name="jLabel7">
<Properties>
<Property name="displayedMnemonic" type="int" value="80"/>
<Property name="labelFor" type="java.awt.Component" editor="org.netbeans.modules.form.ComponentChooserEditor">
<ComponentRef name="jScrollPane5"/>
</Property>
<Property name="text" type="java.lang.String" value="Properties"/>
<Property name="text" type="java.lang.String" value="View properties"/>
<Property name="toolTipText" type="java.lang.String" value="These are readonly properties, you have to edit the rulesets properties to change them. Consult http://pmd.sf.net for more information"/>
</Properties>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
@ -316,6 +311,7 @@
</Component>
<Container class="javax.swing.JScrollPane" name="jScrollPane5">
<Properties>
<Property name="toolTipText" type="java.lang.String" value="These are readonly properties, you have to edit the rulesets properties to change them. Consult http://pmd.sf.net for more information"/>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[600, 50]"/>
</Property>

View File

@ -1,22 +1,44 @@
/*
* Editor.java
* Copyright (c) 2002, Ole-Martin Mørk
* All rights reserved.
*
* Created on 18. november 2002, 21:19
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
* DAMAGE.
*/
package pmd.config.ui;
import java.beans.PropertyEditorSupport;
import javax.swing.JPanel;
import net.sourceforge.pmd.Rule;
/**
*
* @author ole martin mørk
/** The JPanel used to edit the Rule property
* @author ole martin mørk
*/
public class RuleEnabler extends JPanel {
private final PropertyEditorSupport editor;
/** Creates a new editor
* @param editor The object to be notified of changes in the property
*/
public RuleEnabler( PropertyEditorSupport editor ) {
this.editor = editor;
initComponents();
@ -67,8 +89,8 @@ public class RuleEnabler extends JPanel {
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 0;
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTH;
gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
add(jLabel1, gridBagConstraints);
jLabel2.setText("See http://pmd.sf.net for more information");
@ -77,8 +99,8 @@ public class RuleEnabler extends JPanel {
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 1;
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTH;
gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
add(jLabel2, gridBagConstraints);
gridBagConstraints = new java.awt.GridBagConstraints();
@ -90,7 +112,6 @@ public class RuleEnabler extends JPanel {
jPanel5.setLayout(new java.awt.GridBagLayout());
jScrollPane1.setToolTipText("null");
jScrollPane1.setHorizontalScrollBarPolicy(javax.swing.JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
jScrollPane1.setPreferredSize(new java.awt.Dimension(270, 100));
availableList.setModel(AvailableListModel.getInstance());
@ -155,21 +176,20 @@ public class RuleEnabler extends JPanel {
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 0;
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints.insets = new java.awt.Insets(3, 0, 3, 3);
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
gridBagConstraints.insets = new java.awt.Insets(3, 0, 3, 3);
jPanel5.add(jLabel3, gridBagConstraints);
jLabel4.setDisplayedMnemonic('C');
jLabel4.setLabelFor(chosenList);
jLabel4.setText("Chosen rules");
jLabel4.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 2;
gridBagConstraints.gridy = 0;
gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints.insets = new java.awt.Insets(3, 3, 3, 0);
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHEAST;
gridBagConstraints.insets = new java.awt.Insets(3, 3, 3, 0);
jPanel5.add(jLabel4, gridBagConstraints);
chooseOne.setText(">");
@ -183,8 +203,8 @@ public class RuleEnabler extends JPanel {
gridBagConstraints.gridx = 1;
gridBagConstraints.gridy = 1;
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints.insets = new java.awt.Insets(2, 1, 0, 1);
gridBagConstraints.anchor = java.awt.GridBagConstraints.SOUTH;
gridBagConstraints.insets = new java.awt.Insets(2, 1, 0, 1);
jPanel5.add(chooseOne, gridBagConstraints);
choseAll.setText(">>");
@ -226,16 +246,16 @@ public class RuleEnabler extends JPanel {
gridBagConstraints.gridx = 1;
gridBagConstraints.gridy = 4;
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints.insets = new java.awt.Insets(0, 1, 2, 1);
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTH;
gridBagConstraints.insets = new java.awt.Insets(0, 1, 2, 1);
jPanel5.add(removeAll, gridBagConstraints);
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 3;
gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
gridBagConstraints.weighty = 0.7;
gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
add(jPanel5, gridBagConstraints);
gridBagConstraints = new java.awt.GridBagConstraints();
@ -247,7 +267,6 @@ public class RuleEnabler extends JPanel {
jPanel6.setLayout(new java.awt.GridBagLayout());
jLabel6.setDisplayedMnemonic('I');
jLabel6.setText("Information");
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
@ -255,17 +274,15 @@ public class RuleEnabler extends JPanel {
gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
jPanel6.add(jLabel6, gridBagConstraints);
jLabel5.setDisplayedMnemonic('E');
jLabel5.setLabelFor(example);
jLabel5.setText("Example");
jLabel5.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 1;
gridBagConstraints.gridy = 0;
gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTH;
gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
jPanel6.add(jLabel5, gridBagConstraints);
jScrollPane4.setHorizontalScrollBarPolicy(javax.swing.JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
@ -279,10 +296,10 @@ public class RuleEnabler extends JPanel {
gridBagConstraints.gridy = 1;
gridBagConstraints.gridheight = java.awt.GridBagConstraints.REMAINDER;
gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
gridBagConstraints.insets = new java.awt.Insets(2, 0, 2, 2);
gridBagConstraints.anchor = java.awt.GridBagConstraints.SOUTHWEST;
gridBagConstraints.weightx = 0.5;
gridBagConstraints.weighty = 1.0;
gridBagConstraints.insets = new java.awt.Insets(2, 0, 2, 2);
jPanel6.add(jScrollPane4, gridBagConstraints);
jScrollPane2.setHorizontalScrollBarPolicy(javax.swing.JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
@ -297,19 +314,19 @@ public class RuleEnabler extends JPanel {
gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
gridBagConstraints.gridheight = java.awt.GridBagConstraints.REMAINDER;
gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 0);
gridBagConstraints.anchor = java.awt.GridBagConstraints.SOUTH;
gridBagConstraints.weightx = 0.5;
gridBagConstraints.weighty = 1.0;
gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 0);
jPanel6.add(jScrollPane2, gridBagConstraints);
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 5;
gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
gridBagConstraints.weightx = 1.0;
gridBagConstraints.weighty = 1.0;
gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
add(jPanel6, gridBagConstraints);
gridBagConstraints = new java.awt.GridBagConstraints();
@ -319,17 +336,18 @@ public class RuleEnabler extends JPanel {
gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
add(bottomSeparator, gridBagConstraints);
jLabel7.setDisplayedMnemonic('P');
jLabel7.setLabelFor(jScrollPane5);
jLabel7.setText("Properties");
jLabel7.setText("View properties");
jLabel7.setToolTipText("These are readonly properties, you have to edit the rulesets properties to change them. Consult http://pmd.sf.net for more information");
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 7;
gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHEAST;
gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
add(jLabel7, gridBagConstraints);
jScrollPane5.setToolTipText("These are readonly properties, you have to edit the rulesets properties to change them. Consult http://pmd.sf.net for more information");
jScrollPane5.setPreferredSize(new java.awt.Dimension(600, 50));
jScrollPane5.setMinimumSize(new java.awt.Dimension(300, 50));
properties.setModel(new PropertiesModel(null));
@ -339,26 +357,35 @@ public class RuleEnabler extends JPanel {
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 8;
gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
gridBagConstraints.anchor = java.awt.GridBagConstraints.SOUTH;
gridBagConstraints.weightx = 1.0;
gridBagConstraints.weighty = 0.7;
gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
add(jScrollPane5, gridBagConstraints);
}//GEN-END:initComponents
/** Fired when the user clicks on the chosenList list
* @param evt the event fired
*/
private void chosenListMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_chosenListMouseClicked
if( evt.getClickCount() >= 2 ) {
removeOneActionPerformed( null );
}
}//GEN-LAST:event_chosenListMouseClicked
/** Fired when the user clicks on the availableList list
* @param evt the event fired
*/
private void availableListMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_availableListMouseClicked
if( evt.getClickCount() >= 2 ) {
chooseOneActionPerformed( null );
}
}//GEN-LAST:event_availableListMouseClicked
/** Called when the user selects a value in the chosenList
* @param evt the event fired
*/
private void chosenListValueChanged(javax.swing.event.ListSelectionEvent evt) {//GEN-FIRST:event_chosenListValueChanged
Rule rule = (Rule)chosenList.getSelectedValue();
example.setText( rule.getExample().trim());
@ -366,6 +393,9 @@ public class RuleEnabler extends JPanel {
properties.setModel( new PropertiesModel( rule ) );
}//GEN-LAST:event_chosenListValueChanged
/** Called when the user selects a value in the availableList
* @param evt the event fired
*/
private void availableListValueChanged(javax.swing.event.ListSelectionEvent evt) {//GEN-FIRST:event_availableListValueChanged
Rule rule = (Rule)availableList.getSelectedValue();
example.setText( rule.getExample().trim() );
@ -373,6 +403,9 @@ public class RuleEnabler extends JPanel {
properties.setModel( new PropertiesModel( rule ) );
}//GEN-LAST:event_availableListValueChanged
/** Called when the user clicks on the removeAll button
* @param evt the event fired
*/
private void removeAllActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_removeAllActionPerformed
AvailableListModel.getInstance().addAll( SelectedListModel.getSelectedListModelInstance().getData() );
SelectedListModel.getSelectedListModelInstance().removeAll();
@ -380,6 +413,9 @@ public class RuleEnabler extends JPanel {
}//GEN-LAST:event_removeAllActionPerformed
/** Called when the user clicks the removeOne button
* @param evt the event fired
*/
private void removeOneActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_removeOneActionPerformed
int index = chosenList.getSelectedIndex();
Object object[] = chosenList.getSelectedValues();
@ -400,12 +436,18 @@ public class RuleEnabler extends JPanel {
}//GEN-LAST:event_removeOneActionPerformed
/** Called when the user clicks on chooseAll button
* @param evt the event fired
*/
private void choseAllActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_choseAllActionPerformed
SelectedListModel.getSelectedListModelInstance().addAll( AvailableListModel.getInstance().getData() );
AvailableListModel.getInstance().removeAll();
editor.firePropertyChange();
}//GEN-LAST:event_choseAllActionPerformed
/** Called when the user clicks on chooseOne button
* @param evt the event fired
*/
private void chooseOneActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_chooseOneActionPerformed
int index = availableList.getSelectedIndex();
Object object[] = availableList.getSelectedValues();
@ -444,9 +486,9 @@ public class RuleEnabler extends JPanel {
private javax.swing.JScrollPane jScrollPane3;
private javax.swing.JScrollPane jScrollPane2;
private javax.swing.JLabel jLabel3;
private javax.swing.JSeparator middleSeparator;
private javax.swing.JEditorPane information;
private javax.swing.JPanel jPanel6;
private javax.swing.JSeparator middleSeparator;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JLabel jLabel2;
private javax.swing.JPanel jPanel5;

View File

@ -1,46 +1,66 @@
/*
* SelectedListModel.java
* Copyright (c) 2002, Ole-Martin Mørk
* All rights reserved.
*
* Created on 16. november 2002, 13:16
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
* DAMAGE.
*/
package pmd.config.ui;
import java.util.ArrayList;
import java.util.Iterator;
import net.sourceforge.pmd.Rule;
/**
*
* @author ole martin mørk
/** The datamodel behind the SelectedList
* @author ole martin mørk
* @created 25. november 2002
*/
public class SelectedListModel extends AvailableListModel {
/** The instance */
private static SelectedListModel listmodel = new SelectedListModel();
/** Creates a new instance of SelectedListModel */
private SelectedListModel() {
super();
}
/** Gets the instance of the SelectedListModel class
* @return the instance
*/
public static AvailableListModel getInstance() {
return listmodel;
return getSelectedListModelInstance();
}
/** Resets the content of the list */
public void refresh() {
setList( new ArrayList() );
}
public void setData( String rules ) {
Iterator iterator = AvailableListModel.getInstance().getData().iterator();
while( iterator.hasNext() ) {
Rule rule = (Rule)iterator.next();
if( rules.indexOf( rule.getName() + ", " ) > -1 ) {
add( rule );
}
}
}
/** Gets the instance of the SelectedListModel class
* @return The instance
*/
public static SelectedListModel getSelectedListModelInstance() {
return listmodel;
}

View File

@ -0,0 +1 @@
<HTML><BODY>The userinterface of the properties dialog.</BODY></HTML>

View File

@ -23,14 +23,22 @@ SystemFileSystem
</folder>
</folder>
<folder name="Actions">
<file name="pmd-RunPMDAction.instance">
<attr name="SystemFileSystem.localizingBundle" stringvalue="pmd.Bundle"/>
</file>
<folder name="pmd-netbeans">
<file name="pmd-RunPMDAction.instance">
<attr name="SystemFileSystem.localizingBundle" stringvalue="pmd.Bundle"/>
</file>
</folder>
</folder>
<folder name="Editors">
<folder name="AnnotationTypes">
<file name="pmd-annotation.xml" url="resources/annotation.xml"/>
</folder>
</folder>
<folder name="Shortcuts">
<file name="CS-P.instance">
<attr name="instanceClass" stringvalue="pmd.RunPMDAction"/>
</file>
</folder>
</filesystem>

View File

@ -0,0 +1 @@
<HTML><BODY>The pmd action.</BODY></HTML>