diff --git a/pmd-netbeans/src/manifest.mf b/pmd-netbeans/src/manifest.mf index 3c6a95cc09..5f0e19d796 100644 --- a/pmd-netbeans/src/manifest.mf +++ b/pmd-netbeans/src/manifest.mf @@ -1,5 +1,5 @@ Manifest-Version: 1.0 -OpenIDE-Module-Specification-Version: 0.50 +OpenIDE-Module-Specification-Version: 0.50.3 Created-By: NetBeans Class-Path: ext/pmd-1.01.jar OpenIDE-Module: pmd diff --git a/pmd-netbeans/src/pmd/FaultRegistry.java b/pmd-netbeans/src/pmd/FaultRegistry.java index 8011faa31f..3344262917 100644 --- a/pmd-netbeans/src/pmd/FaultRegistry.java +++ b/pmd-netbeans/src/pmd/FaultRegistry.java @@ -37,11 +37,16 @@ import org.openide.loaders.DataObject; * @author Ole-Martin Mørk * @created 24. oktober 2002 */ -abstract class FaultRegistry { +public class FaultRegistry { /** The registered faults */ - private static Map faults = new HashMap(); - + private Map faults = new HashMap(); + private static FaultRegistry instance = new FaultRegistry(); + private FaultRegistry() {} + + public static FaultRegistry getInstance() { + return instance; + } /** * Returns the associated dataobject @@ -50,13 +55,13 @@ abstract class FaultRegistry { * @return the associated dataobject * @see pmd.Fault#getFault() */ - public static DataObject getDataObject( String key ) { + public DataObject getDataObject( String key ) { return ( DataObject )faults.get( key ); } /** Clears all entries of the registry */ - public static void clearRegistry() { + public void clearRegistry() { faults.clear(); } @@ -68,7 +73,7 @@ abstract class FaultRegistry { * @param object the object where the fault is * @see pmd.Fault#getFault() */ - public static void registerFault( Fault fault, DataObject object ) { + public void registerFault( Fault fault, DataObject object ) { faults.put( fault.getFault(), object ); } } diff --git a/pmd-netbeans/src/pmd/PMDOutputListener.java b/pmd-netbeans/src/pmd/PMDOutputListener.java index b5d8c809d7..0cd711cd79 100644 --- a/pmd-netbeans/src/pmd/PMDOutputListener.java +++ b/pmd-netbeans/src/pmd/PMDOutputListener.java @@ -78,7 +78,7 @@ public class PMDOutputListener implements OutputListener { */ public void outputLineAction( OutputEvent outputEvent ) { annotation.detach(); - DataObject object = FaultRegistry.getDataObject( outputEvent.getLine() ); + DataObject object = FaultRegistry.getInstance().getDataObject( outputEvent.getLine() ); LineCookie cookie = ( LineCookie )object.getCookie( LineCookie.class ); Set lineset = cookie.getLineSet(); int lineNum = Fault.getLineNum( outputEvent.getLine() ); diff --git a/pmd-netbeans/src/pmd/RunPMDAction.java b/pmd-netbeans/src/pmd/RunPMDAction.java index 66679309f2..d7a50bf36f 100644 --- a/pmd-netbeans/src/pmd/RunPMDAction.java +++ b/pmd-netbeans/src/pmd/RunPMDAction.java @@ -159,7 +159,7 @@ public class RunPMDAction extends CookieAction { buffer.append( violation.getDescription() ); Fault fault = new Fault( violation.getLine(), name, buffer.toString() ); list.add( fault ); - FaultRegistry.registerFault( fault, dataobject ); + FaultRegistry.getInstance().registerFault( fault, dataobject ); } Collections.sort( list ); for( int i = 0; i < list.size(); i++ ) { @@ -178,7 +178,7 @@ public class RunPMDAction extends CookieAction { protected void performAction( Node[] node ) { PMDOutputListener listener = PMDOutputListener.getInstance(); listener.detach(); - FaultRegistry.clearRegistry(); + FaultRegistry.getInstance().clearRegistry(); try { printed = false; InputOutput io = TopManager.getDefault().getIO( "PMD output", false ); diff --git a/pmd-netbeans/src/pmd/config/PMDOptionsSettingsBeanInfo.java b/pmd-netbeans/src/pmd/config/PMDOptionsSettingsBeanInfo.java index 745df6bcb5..b6f3d57c4a 100644 --- a/pmd-netbeans/src/pmd/config/PMDOptionsSettingsBeanInfo.java +++ b/pmd-netbeans/src/pmd/config/PMDOptionsSettingsBeanInfo.java @@ -37,7 +37,6 @@ import org.openide.TopManager; import org.openide.util.NbBundle; import org.openide.util.Utilities; import pmd.config.ui.RuleEditor; -import pmd.config.ui.RuleEnabler; /** * Description of {@link PMDOptionsSettings}. @@ -54,17 +53,18 @@ public class PMDOptionsSettingsBeanInfo extends SimpleBeanInfo { */ public PropertyDescriptor[] getPropertyDescriptors() { PropertyEditorManager.registerEditor( PMDOptionsSettingsBeanInfo.class, RuleEditor.class ); + PropertyDescriptor descriptor[] = new PropertyDescriptor[1]; try { PropertyDescriptor rules = new PropertyDescriptor( "rules", PMDOptionsSettings.class, "getRules", "setRules" ); rules.setDisplayName( NbBundle.getMessage( PMDOptionsSettingsBeanInfo.class, "PROP_rules" ) ); rules.setShortDescription( NbBundle.getMessage( PMDOptionsSettingsBeanInfo.class, "HINT_rules" ) ); rules.setPropertyEditorClass( RuleEditor.class ); - return new PropertyDescriptor[]{rules}; + descriptor[0] = rules; } catch( IntrospectionException ie ) { TopManager.getDefault().getErrorManager().notify( ie ); - return null; } + return descriptor; } diff --git a/pmd-netbeans/src/pmd/config/ui/AvailableListModel.java b/pmd-netbeans/src/pmd/config/ui/AvailableListModel.java index 5fc742eef3..a963cb0603 100644 --- a/pmd-netbeans/src/pmd/config/ui/AvailableListModel.java +++ b/pmd-netbeans/src/pmd/config/ui/AvailableListModel.java @@ -129,6 +129,7 @@ public class AvailableListModel extends AbstractListModel { } public void refresh() { + list.clear(); try { RuleSetFactory ruleSetFactory = new RuleSetFactory(); Iterator iterator = ruleSetFactory.getRegisteredRuleSets(); diff --git a/pmd-netbeans/src/pmd/config/ui/PropertiesModel.java b/pmd-netbeans/src/pmd/config/ui/PropertiesModel.java new file mode 100644 index 0000000000..3818108ff6 --- /dev/null +++ b/pmd-netbeans/src/pmd/config/ui/PropertiesModel.java @@ -0,0 +1,60 @@ +/* + * PropertiesModel.java + * + * Created on 21. november 2002, 20:59 + */ + +package pmd.config.ui; + +import java.util.Enumeration; +import javax.swing.table.AbstractTableModel; +import net.sourceforge.pmd.Rule; +import net.sourceforge.pmd.RuleProperties; + +/** + * + * @author ole martin mørk + */ +public class PropertiesModel extends AbstractTableModel { + + private final String values[][]; + /** Creates a new instance of PropertiesModel */ + public PropertiesModel( Rule rule ) { + if( rule == null ) { + values = new String[0][0]; + return; + } + RuleProperties properties = rule.getProperties(); + values = new String[properties.size()][2]; + Enumeration keys = properties.keys(); + int counter = 0; + while(keys.hasMoreElements() ) { + String key = (String)keys.nextElement(); + values[counter][0] = key; + values[counter][1] = properties.getProperty( key ); + counter++; + } + + } + + public int getColumnCount() { + return 2; + } + + public int getRowCount() { + return values.length; + } + + public Object getValueAt(int param, int param1) { + return values[param][param1]; + } + + public String getColumnName( int column ) { + return column == 0 ? "Name" : "Value"; + } + + public boolean isCellEditable( int rowIndex, int columnIndex ) { + return columnIndex == 1; + } + +} \ No newline at end of file diff --git a/pmd-netbeans/src/pmd/config/ui/RuleEditor.java b/pmd-netbeans/src/pmd/config/ui/RuleEditor.java index 0688ad5f64..56744c0086 100644 --- a/pmd-netbeans/src/pmd/config/ui/RuleEditor.java +++ b/pmd-netbeans/src/pmd/config/ui/RuleEditor.java @@ -36,7 +36,6 @@ public class RuleEditor extends PropertyEditorSupport { return true; } - /** * Gets the value attribute of the RuleEditor object * @@ -44,10 +43,9 @@ public class RuleEditor extends PropertyEditorSupport { */ public Object getValue() { String string = getValueAsText( SelectedListModel.getSelectedListModelInstance().getData() ); + //JOptionPane.showMessageDialog( null, string ); return string; } - - /** * Gets the asText attribute of the RuleEditor object * diff --git a/pmd-netbeans/src/pmd/config/ui/RuleEnabler.form b/pmd-netbeans/src/pmd/config/ui/RuleEnabler.form index 1d07e1c6a2..e449544f74 100644 --- a/pmd-netbeans/src/pmd/config/ui/RuleEnabler.form +++ b/pmd-netbeans/src/pmd/config/ui/RuleEnabler.form @@ -2,7 +2,7 @@