This is an automated email from the ASF dual-hosted git repository. tmysik pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/netbeans.git
The following commit(s) were added to refs/heads/master by this push: new eddc016 [NETBEANS-4340] Added PHP Mess Detector options configuration new 0a3a255 Merge pull request #2231 from KacerCZ/netbeans-4340-phpmd-params eddc016 is described below commit eddc016e0ac71b5e76d42b5910fb398f32af7934 Author: Tomas Prochazka <ka...@razdva.cz> AuthorDate: Sat Jul 4 19:00:17 2020 +0200 [NETBEANS-4340] Added PHP Mess Detector options configuration https://issues.apache.org/jira/browse/NETBEANS-4340 Added CLI options to PHP Mess Detector configuration. --- .../php/analysis/MessDetectorAnalyzerImpl.java | 16 ++++- .../modules/php/analysis/MessDetectorParams.java | 10 +++ .../php/analysis/commands/MessDetector.java | 4 ++ .../php/analysis/options/AnalysisOptions.java | 10 +++ .../php/analysis/ui/analyzer/Bundle.properties | 1 + .../ui/analyzer/MessDetectorCustomizerPanel.form | 28 ++++++-- .../ui/analyzer/MessDetectorCustomizerPanel.java | 81 +++++++++++++++++----- .../php/analysis/ui/options/Bundle.properties | 1 + .../ui/options/MessDetectorOptionsPanel.form | 53 +++++++++----- .../ui/options/MessDetectorOptionsPanel.java | 75 ++++++++++++++------ 10 files changed, 218 insertions(+), 61 deletions(-) diff --git a/php/php.code.analysis/src/org/netbeans/modules/php/analysis/MessDetectorAnalyzerImpl.java b/php/php.code.analysis/src/org/netbeans/modules/php/analysis/MessDetectorAnalyzerImpl.java index 204272b..9c28a05 100644 --- a/php/php.code.analysis/src/org/netbeans/modules/php/analysis/MessDetectorAnalyzerImpl.java +++ b/php/php.code.analysis/src/org/netbeans/modules/php/analysis/MessDetectorAnalyzerImpl.java @@ -185,7 +185,8 @@ public class MessDetectorAnalyzerImpl implements Analyzer { private MessDetectorParams getValidMessDetectorParams() { MessDetectorParams messDetectorParams = new MessDetectorParams() .setRuleSets(getValidMessDetectorRuleSets()) - .setRuleSetFile(getValidRuleSetFile()); + .setRuleSetFile(getValidRuleSetFile()) + .setOptions(getValidOptions()); ValidationResult result = new AnalysisOptionsValidator() .validateMessDetector(messDetectorParams) .getResult(); @@ -223,6 +224,19 @@ public class MessDetectorAnalyzerImpl implements Analyzer { return FileUtil.toFileObject(new File(ruleSetFile)); } + @CheckForNull + private String getValidOptions() { + String options = null; + Preferences settings = context.getSettings(); + if (settings != null) { + options = settings.get(MessDetectorCustomizerPanel.OPTIONS, null); + } + if (options == null) { + options = AnalysisOptions.getInstance().getMessDetectorOptions(); + } + return options; + } + //~ Inner classes @ServiceProvider(service=AnalyzerFactory.class) diff --git a/php/php.code.analysis/src/org/netbeans/modules/php/analysis/MessDetectorParams.java b/php/php.code.analysis/src/org/netbeans/modules/php/analysis/MessDetectorParams.java index d4a39f6..1096ba4 100644 --- a/php/php.code.analysis/src/org/netbeans/modules/php/analysis/MessDetectorParams.java +++ b/php/php.code.analysis/src/org/netbeans/modules/php/analysis/MessDetectorParams.java @@ -27,6 +27,7 @@ public final class MessDetectorParams { private List<String> ruleSets; private FileObject ruleSetFile; + private String options; public List<String> getRuleSets() { return Collections.unmodifiableList(ruleSets); @@ -45,4 +46,13 @@ public final class MessDetectorParams { this.ruleSetFile = ruleSetFile; return this; } + + public String getOptions() { + return options; + } + + MessDetectorParams setOptions(String options) { + this.options = options; + return this; + } } diff --git a/php/php.code.analysis/src/org/netbeans/modules/php/analysis/commands/MessDetector.java b/php/php.code.analysis/src/org/netbeans/modules/php/analysis/commands/MessDetector.java index 8419b0d..558628e 100644 --- a/php/php.code.analysis/src/org/netbeans/modules/php/analysis/commands/MessDetector.java +++ b/php/php.code.analysis/src/org/netbeans/modules/php/analysis/commands/MessDetector.java @@ -171,6 +171,10 @@ public final class MessDetector { params.add(StringUtils.implode(FileUtil.getMIMETypeExtensions(FileUtils.PHP_MIME_TYPE), ",")); // NOI18N // exclude addIgnoredFiles(params, files); + String options = parameters.getOptions(); + if (StringUtils.hasText(options)) { + params.addAll(StringUtils.explode(options, " ")); // NOI18N + } return params; } diff --git a/php/php.code.analysis/src/org/netbeans/modules/php/analysis/options/AnalysisOptions.java b/php/php.code.analysis/src/org/netbeans/modules/php/analysis/options/AnalysisOptions.java index de157a9..f969a96 100644 --- a/php/php.code.analysis/src/org/netbeans/modules/php/analysis/options/AnalysisOptions.java +++ b/php/php.code.analysis/src/org/netbeans/modules/php/analysis/options/AnalysisOptions.java @@ -44,6 +44,7 @@ public final class AnalysisOptions { private static final String MESS_DETECTOR_PATH = "messDetector.path"; // NOI18N private static final String MESS_DETECTOR_RULE_SETS = "messDetector.ruleSets"; // NOI18N private static final String MESS_DETECTOR_RULE_SET_FILE = "messDetector.ruleSetFile"; // NOI18N + private static final String MESS_DETECTOR_OPTIONS = "messDetector.options"; // NOI18N // coding standards fixer private static final String CODING_STANDARDS_FIXER_VERSION = "codingStandardsFixer.version"; // NOI18N private static final String CODING_STANDARDS_FIXER_PATH = "codingStandardsFixer.path"; // NOI18N @@ -142,6 +143,15 @@ public final class AnalysisOptions { getPreferences().put(MESS_DETECTOR_RULE_SET_FILE, ruleSetFilePath); } + @CheckForNull + public String getMessDetectorOptions() { + return getPreferences().get(MESS_DETECTOR_OPTIONS, null); + } + + public void setMessDetectorOptions(String options) { + getPreferences().put(MESS_DETECTOR_OPTIONS, options); + } + // coding standards fixer @CheckForNull public String getCodingStandardsFixerVersion() { diff --git a/php/php.code.analysis/src/org/netbeans/modules/php/analysis/ui/analyzer/Bundle.properties b/php/php.code.analysis/src/org/netbeans/modules/php/analysis/ui/analyzer/Bundle.properties index 4106718..3dcecf1 100644 --- a/php/php.code.analysis/src/org/netbeans/modules/php/analysis/ui/analyzer/Bundle.properties +++ b/php/php.code.analysis/src/org/netbeans/modules/php/analysis/ui/analyzer/Bundle.properties @@ -22,6 +22,7 @@ CodeSnifferCustomizerPanel.standardLabel.text=S&tandard: MessDetectorCustomizerPanel.ruleSetsLabel.text=Rule Sets: MessDetectorCustomizerPanel.ruleSetFileLabel.text=Rule Set &File: MessDetectorCustomizerPanel.ruleSetFileBrowseButton.text=&Browse... +MessDetectorCustomizerPanel.optionsLabel.text=&Options: # coding standards fixer CodingStandardsFixerCustomizerPanel.configLabel.text=Confi&g: diff --git a/php/php.code.analysis/src/org/netbeans/modules/php/analysis/ui/analyzer/MessDetectorCustomizerPanel.form b/php/php.code.analysis/src/org/netbeans/modules/php/analysis/ui/analyzer/MessDetectorCustomizerPanel.form index fa17e74..55dc26b 100644 --- a/php/php.code.analysis/src/org/netbeans/modules/php/analysis/ui/analyzer/MessDetectorCustomizerPanel.form +++ b/php/php.code.analysis/src/org/netbeans/modules/php/analysis/ui/analyzer/MessDetectorCustomizerPanel.form @@ -45,14 +45,20 @@ <Group type="103" groupAlignment="0" attributes="0"> <Component id="ruleSetsLabel" min="-2" max="-2" attributes="0"/> <Component id="ruleSetFileLabel" min="-2" max="-2" attributes="0"/> + <Component id="optionsLabel" min="-2" max="-2" attributes="0"/> </Group> <EmptySpace max="-2" attributes="0"/> <Group type="103" groupAlignment="0" attributes="0"> - <Component id="ruleSetFileTextField" max="32767" attributes="0"/> - <Component id="ruleSetsScrollPane" pref="0" max="32767" attributes="0"/> + <Group type="102" attributes="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Component id="ruleSetFileTextField" max="32767" attributes="0"/> + <Component id="ruleSetsScrollPane" pref="0" max="32767" attributes="0"/> + </Group> + <EmptySpace max="-2" attributes="0"/> + <Component id="ruleSetFileBrowseButton" min="-2" max="-2" attributes="0"/> + </Group> + <Component id="optionsTextField" max="32767" attributes="0"/> </Group> - <EmptySpace max="-2" attributes="0"/> - <Component id="ruleSetFileBrowseButton" min="-2" max="-2" attributes="0"/> </Group> </Group> </DimensionLayout> @@ -71,6 +77,11 @@ <Component id="ruleSetFileLabel" alignment="3" min="-2" max="-2" attributes="0"/> <Component id="ruleSetFileBrowseButton" alignment="3" min="-2" max="-2" attributes="0"/> </Group> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="optionsTextField" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="optionsLabel" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> </Group> </Group> </DimensionLayout> @@ -129,5 +140,14 @@ <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="ruleSetFileBrowseButtonActionPerformed"/> </Events> </Component> + <Component class="javax.swing.JTextField" name="optionsTextField"> + </Component> + <Component class="javax.swing.JLabel" name="optionsLabel"> + <Properties> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="org/netbeans/modules/php/analysis/ui/analyzer/Bundle.properties" key="MessDetectorCustomizerPanel.optionsLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/> + </Property> + </Properties> + </Component> </SubComponents> </Form> diff --git a/php/php.code.analysis/src/org/netbeans/modules/php/analysis/ui/analyzer/MessDetectorCustomizerPanel.java b/php/php.code.analysis/src/org/netbeans/modules/php/analysis/ui/analyzer/MessDetectorCustomizerPanel.java index e6e31de..bbfe641 100644 --- a/php/php.code.analysis/src/org/netbeans/modules/php/analysis/ui/analyzer/MessDetectorCustomizerPanel.java +++ b/php/php.code.analysis/src/org/netbeans/modules/php/analysis/ui/analyzer/MessDetectorCustomizerPanel.java @@ -56,6 +56,7 @@ public class MessDetectorCustomizerPanel extends JPanel { public static final String ENABLED = "messDetector.enabled"; // NOI18N public static final String RULE_SETS = "messDetector.ruleSets"; // NOI18N public static final String RULE_SET_FILE = "messDetector.ruleSetFile"; // NOI18N + public static final String OPTIONS = "messDetector.options"; // NOI18N private static final String RULE_SET_FILE_LAST_FOLDER_SUFFIX = ".messDetector.ruleSetFile"; // NOI18N private final MessDetectorRuleSetsListModel ruleSetsListModel = new MessDetectorRuleSetsListModel(); @@ -86,28 +87,30 @@ public class MessDetectorCustomizerPanel extends JPanel { } private void init() { + setEnabledCheckBox(); + setRuleSetsList(); + setRuleSetFileTextField(); + setOptionsTextField(); + } + + private void setEnabledCheckBox() { enabledCheckBox.addItemListener((e) -> { setMessDetectorEnabled(); - setRuleSetsComponentsEnabled(enabledCheckBox.isSelected()); + setAllComponentsEnabled(enabledCheckBox.isSelected()); }); boolean isEnabled = settings.getBoolean(ENABLED, false); enabledCheckBox.setSelected(isEnabled); - setRuleSetsComponentsEnabled(isEnabled); + setAllComponentsEnabled(isEnabled); + } + private void setRuleSetsList() { ruleSetsList.setModel(ruleSetsListModel); ruleSetsList.setCellRenderer(new MessDetectorRuleSetsListCellRenderer(ruleSetsList.getCellRenderer())); - - // rule sets List<String> ruleSets = getRuleSets(settings); if (ruleSets == null) { ruleSets = AnalysisOptions.getInstance().getMessDetectorRuleSets(); } selectRuleSets(ruleSets); - - String ruleSetFile = settings.get(RULE_SET_FILE, AnalysisOptions.getInstance().getMessDetectorRuleSetFilePath()); - ruleSetFileTextField.setText(ruleSetFile); - - // listeners ruleSetsList.getSelectionModel().addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { @@ -117,7 +120,11 @@ public class MessDetectorCustomizerPanel extends JPanel { validateAndSetData(); } }); + } + private void setRuleSetFileTextField() { + String ruleSetFile = settings.get(RULE_SET_FILE, AnalysisOptions.getInstance().getMessDetectorRuleSetFilePath()); + ruleSetFileTextField.setText(ruleSetFile); ruleSetFileTextField.getDocument().addDocumentListener(new DocumentListener() { @Override public void insertUpdate(DocumentEvent e) { @@ -136,6 +143,27 @@ public class MessDetectorCustomizerPanel extends JPanel { }); } + private void setOptionsTextField() { + String options = settings.get(OPTIONS, AnalysisOptions.getInstance().getMessDetectorOptions()); + optionsTextField.setText(options); + optionsTextField.getDocument().addDocumentListener(new DocumentListener() { + @Override + public void insertUpdate(DocumentEvent e) { + validateAndSetData(); + } + + @Override + public void removeUpdate(DocumentEvent e) { + validateAndSetData(); + } + + @Override + public void changedUpdate(DocumentEvent e) { + validateAndSetData(); + } + }); + } + public List<String> getSelectedRuleSets() { return ruleSetsList.getSelectedValuesList(); } @@ -144,6 +172,10 @@ public class MessDetectorCustomizerPanel extends JPanel { return ruleSetFileTextField.getText().trim(); } + public String getOptions() { + return optionsTextField.getText().trim(); + } + void selectRuleSets(List<String> ruleSets) { ruleSetsList.clearSelection(); for (String ruleSet : ruleSets) { @@ -178,19 +210,22 @@ public class MessDetectorCustomizerPanel extends JPanel { private void setData() { settings.put(RULE_SETS, AnalysisUtils.serialize(getSelectedRuleSets())); settings.put(RULE_SET_FILE, getRuleSetFile()); + settings.put(OPTIONS, getOptions()); } private void setMessDetectorEnabled() { settings.putBoolean(ENABLED, enabledCheckBox.isSelected()); } - private void setRuleSetsComponentsEnabled(boolean isEnabled) { + private void setAllComponentsEnabled(boolean isEnabled) { ruleSetsLabel.setEnabled(isEnabled); ruleSetsList.setEnabled(isEnabled); ruleSetsScrollPane.setEnabled(isEnabled); ruleSetFileLabel.setEnabled(isEnabled); ruleSetFileTextField.setEnabled(isEnabled); ruleSetFileBrowseButton.setEnabled(isEnabled); + optionsLabel.setEnabled(isEnabled); + optionsTextField.setEnabled(isEnabled); } /** @@ -208,6 +243,8 @@ public class MessDetectorCustomizerPanel extends JPanel { ruleSetFileTextField = new JTextField(); ruleSetFileLabel = new JLabel(); ruleSetFileBrowseButton = new JButton(); + optionsTextField = new JTextField(); + optionsLabel = new JLabel(); ruleSetsLabel.setLabelFor(ruleSetsList); Mnemonics.setLocalizedText(ruleSetsLabel, NbBundle.getMessage(MessDetectorCustomizerPanel.class, "MessDetectorCustomizerPanel.ruleSetsLabel.text")); // NOI18N @@ -226,6 +263,8 @@ public class MessDetectorCustomizerPanel extends JPanel { } }); + Mnemonics.setLocalizedText(optionsLabel, NbBundle.getMessage(MessDetectorCustomizerPanel.class, "MessDetectorCustomizerPanel.optionsLabel.text")); // NOI18N + GroupLayout layout = new GroupLayout(this); this.setLayout(layout); layout.setHorizontalGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING) @@ -235,13 +274,17 @@ public class MessDetectorCustomizerPanel extends JPanel { .addGroup(layout.createSequentialGroup() .addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING) .addComponent(ruleSetsLabel) - .addComponent(ruleSetFileLabel)) + .addComponent(ruleSetFileLabel) + .addComponent(optionsLabel)) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING) - .addComponent(ruleSetFileTextField) - .addComponent(ruleSetsScrollPane, GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)) - .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) - .addComponent(ruleSetFileBrowseButton)) + .addGroup(layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING) + .addComponent(ruleSetFileTextField) + .addComponent(ruleSetsScrollPane, GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)) + .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) + .addComponent(ruleSetFileBrowseButton)) + .addComponent(optionsTextField))) ); layout.setVerticalGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING) .addGroup(GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() @@ -254,7 +297,11 @@ public class MessDetectorCustomizerPanel extends JPanel { .addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE) .addComponent(ruleSetFileTextField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addComponent(ruleSetFileLabel) - .addComponent(ruleSetFileBrowseButton))) + .addComponent(ruleSetFileBrowseButton)) + .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE) + .addComponent(optionsTextField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) + .addComponent(optionsLabel))) ); }// </editor-fold>//GEN-END:initComponents @@ -271,6 +318,8 @@ public class MessDetectorCustomizerPanel extends JPanel { // Variables declaration - do not modify//GEN-BEGIN:variables private JCheckBox enabledCheckBox; + private JLabel optionsLabel; + private JTextField optionsTextField; private JButton ruleSetFileBrowseButton; private JLabel ruleSetFileLabel; private JTextField ruleSetFileTextField; diff --git a/php/php.code.analysis/src/org/netbeans/modules/php/analysis/ui/options/Bundle.properties b/php/php.code.analysis/src/org/netbeans/modules/php/analysis/ui/options/Bundle.properties index c58565a..e1b9f9c 100644 --- a/php/php.code.analysis/src/org/netbeans/modules/php/analysis/ui/options/Bundle.properties +++ b/php/php.code.analysis/src/org/netbeans/modules/php/analysis/ui/options/Bundle.properties @@ -29,6 +29,7 @@ MessDetectorOptionsPanel.minVersionInfoLabel.text=Mess Detector 1.4 or newer is MessDetectorOptionsPanel.messDetectorRuleSetFileLabel.text=Rule Set &File: MessDetectorOptionsPanel.messDetectorRuleSetFileBrowseButton.text=B&rowse... MessDetectorOptionsPanel.messDetectorRuleSetFileLabel.AccessibleContext.accessibleName=Rule Set &File: +MessDetectorOptionsPanel.messDetectorOptionsLabel.text=&Options: # code sniffer CodeSnifferOptionsPanel.codeSnifferSearchButton.text=&Search... diff --git a/php/php.code.analysis/src/org/netbeans/modules/php/analysis/ui/options/MessDetectorOptionsPanel.form b/php/php.code.analysis/src/org/netbeans/modules/php/analysis/ui/options/MessDetectorOptionsPanel.form index d4daf9c..0ca99c4 100644 --- a/php/php.code.analysis/src/org/netbeans/modules/php/analysis/ui/options/MessDetectorOptionsPanel.form +++ b/php/php.code.analysis/src/org/netbeans/modules/php/analysis/ui/options/MessDetectorOptionsPanel.form @@ -37,11 +37,24 @@ <Layout> <DimensionLayout dim="0"> <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Component id="minVersionInfoLabel" min="-2" max="-2" attributes="0"/> + <Component id="messDetectorLearnMoreLabel" alignment="0" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace max="32767" attributes="0"/> + </Group> + <Group type="102" alignment="0" attributes="0"> + <Component id="noteLabel" min="-2" max="-2" attributes="0"/> + <EmptySpace min="0" pref="0" max="32767" attributes="0"/> + </Group> <Group type="102" alignment="0" attributes="0"> <Group type="103" groupAlignment="0" attributes="0"> <Component id="messDetectorLabel" min="-2" max="-2" attributes="0"/> <Component id="messDetectorRuleSetsLabel" min="-2" max="-2" attributes="0"/> <Component id="messDetectorRuleSetFileLabel" min="-2" max="-2" attributes="0"/> + <Component id="messDetectorOptionsLabel" min="-2" max="-2" attributes="0"/> </Group> <EmptySpace max="-2" attributes="0"/> <Group type="103" groupAlignment="0" attributes="0"> @@ -56,29 +69,20 @@ <Component id="messDetectorSearchButton" linkSize="1" min="-2" max="-2" attributes="0"/> </Group> <Group type="102" attributes="0"> - <Component id="messDetectorRuleSetFileTextField" max="32767" attributes="0"/> + <Component id="messDetectorHintLabel" min="-2" max="-2" attributes="0"/> + <EmptySpace max="32767" attributes="0"/> + </Group> + <Group type="102" alignment="1" attributes="0"> + <Group type="103" groupAlignment="1" attributes="0"> + <Component id="messDetectorOptionsTextField" alignment="0" max="32767" attributes="0"/> + <Component id="messDetectorRuleSetFileTextField" max="32767" attributes="0"/> + </Group> <EmptySpace max="-2" attributes="0"/> <Component id="messDetectorRuleSetFileBrowseButton" min="-2" max="-2" attributes="0"/> <EmptySpace min="-2" pref="83" max="-2" attributes="0"/> </Group> - <Group type="102" attributes="0"> - <Component id="messDetectorHintLabel" min="-2" max="-2" attributes="0"/> - <EmptySpace max="-2" attributes="0"/> - </Group> </Group> </Group> - <Group type="102" attributes="0"> - <EmptySpace max="-2" attributes="0"/> - <Group type="103" groupAlignment="0" attributes="0"> - <Component id="minVersionInfoLabel" min="-2" max="-2" attributes="0"/> - <Component id="messDetectorLearnMoreLabel" alignment="0" min="-2" max="-2" attributes="0"/> - </Group> - <EmptySpace max="32767" attributes="0"/> - </Group> - <Group type="102" alignment="0" attributes="0"> - <Component id="noteLabel" min="-2" max="-2" attributes="0"/> - <EmptySpace min="0" pref="0" max="32767" attributes="0"/> - </Group> </Group> </DimensionLayout> <DimensionLayout dim="1"> @@ -106,11 +110,17 @@ </Group> </Group> <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="messDetectorOptionsTextField" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="messDetectorOptionsLabel" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace max="-2" attributes="0"/> <Component id="noteLabel" min="-2" max="-2" attributes="0"/> <EmptySpace min="-2" max="-2" attributes="0"/> <Component id="minVersionInfoLabel" min="-2" max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/> <Component id="messDetectorLearnMoreLabel" min="-2" max="-2" attributes="0"/> + <EmptySpace max="32767" attributes="0"/> </Group> </Group> </DimensionLayout> @@ -227,5 +237,14 @@ <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="messDetectorRuleSetFileBrowseButtonActionPerformed"/> </Events> </Component> + <Component class="javax.swing.JTextField" name="messDetectorOptionsTextField"> + </Component> + <Component class="javax.swing.JLabel" name="messDetectorOptionsLabel"> + <Properties> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="org/netbeans/modules/php/analysis/ui/options/Bundle.properties" key="MessDetectorOptionsPanel.messDetectorOptionsLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/> + </Property> + </Properties> + </Component> </SubComponents> </Form> diff --git a/php/php.code.analysis/src/org/netbeans/modules/php/analysis/ui/options/MessDetectorOptionsPanel.java b/php/php.code.analysis/src/org/netbeans/modules/php/analysis/ui/options/MessDetectorOptionsPanel.java index c8f0f03..3aafc4b 100644 --- a/php/php.code.analysis/src/org/netbeans/modules/php/analysis/ui/options/MessDetectorOptionsPanel.java +++ b/php/php.code.analysis/src/org/netbeans/modules/php/analysis/ui/options/MessDetectorOptionsPanel.java @@ -91,6 +91,7 @@ public class MessDetectorOptionsPanel extends AnalysisCategoryPanel { messDetectorTextField.getDocument().addDocumentListener(defaultDocumentListener); messDetectorRuleSetsList.addListSelectionListener(new DefaultListSelectionListener()); messDetectorRuleSetFileTextField.getDocument().addDocumentListener(defaultDocumentListener); + messDetectorOptionsTextField.getDocument().addDocumentListener(defaultDocumentListener); // rulesets messDetectorRuleSetsList.setModel(ruleSetsListModel); @@ -121,6 +122,14 @@ public class MessDetectorOptionsPanel extends AnalysisCategoryPanel { messDetectorRuleSetFileTextField.setText(path); } + public String getMessDetectorOptions() { + return messDetectorOptionsTextField.getText().trim(); + } + + private void setMessDetectorOptions(String options) { + messDetectorOptionsTextField.setText(options); + } + public void addChangeListener(ChangeListener listener) { changeSupport.addChangeListener(listener); } @@ -158,6 +167,7 @@ public class MessDetectorOptionsPanel extends AnalysisCategoryPanel { setMessDetectorPath(analysisOptions.getMessDetectorPath()); setMessDetectorRuleSets(analysisOptions.getMessDetectorRuleSets()); setMessDetectorRuleSetFilePath(analysisOptions.getMessDetectorRuleSetFilePath()); + setMessDetectorOptions(analysisOptions.getMessDetectorOptions()); } @Override @@ -166,6 +176,7 @@ public class MessDetectorOptionsPanel extends AnalysisCategoryPanel { analysisOptions.setMessDetectorPath(getMessDetectorPath()); analysisOptions.setMessDetectorRuleSets(getMessDetectorRuleSets()); analysisOptions.setMessDetectorRuleSetFilePath(getMessDetectorRuleSetFilePath()); + analysisOptions.setMessDetectorOptions(getMessDetectorOptions()); } @Override @@ -180,6 +191,11 @@ public class MessDetectorOptionsPanel extends AnalysisCategoryPanel { if(saved == null ? !current.isEmpty() : !saved.equals(current)) { return true; } + saved = AnalysisOptions.getInstance().getMessDetectorOptions(); + current = getMessDetectorOptions().trim(); + if (saved == null ? !current.isEmpty() : !saved.equals(current)) { + return true; + } return !AnalysisOptions.getInstance().getMessDetectorRuleSets().equals(getMessDetectorRuleSets()); } @@ -213,6 +229,8 @@ public class MessDetectorOptionsPanel extends AnalysisCategoryPanel { messDetectorRuleSetFileTextField = new JTextField(); messDetectorRuleSetFileLabel = new JLabel(); messDetectorRuleSetFileBrowseButton = new JButton(); + messDetectorOptionsTextField = new JTextField(); + messDetectorOptionsLabel = new JLabel(); messDetectorLabel.setLabelFor(messDetectorTextField); Mnemonics.setLocalizedText(messDetectorLabel, NbBundle.getMessage(MessDetectorOptionsPanel.class, "MessDetectorOptionsPanel.messDetectorLabel.text")); // NOI18N @@ -261,42 +279,46 @@ public class MessDetectorOptionsPanel extends AnalysisCategoryPanel { } }); + Mnemonics.setLocalizedText(messDetectorOptionsLabel, NbBundle.getMessage(MessDetectorOptionsPanel.class, "MessDetectorOptionsPanel.messDetectorOptionsLabel.text")); // NOI18N + GroupLayout layout = new GroupLayout(this); this.setLayout(layout); layout.setHorizontalGroup(layout.createParallelGroup(Alignment.LEADING) .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addGroup(layout.createParallelGroup(Alignment.LEADING) + .addComponent(minVersionInfoLabel) + .addComponent(messDetectorLearnMoreLabel, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) + .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + .addGroup(layout.createSequentialGroup() + .addComponent(noteLabel, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) + .addGap(0, 0, Short.MAX_VALUE)) + .addGroup(layout.createSequentialGroup() .addGroup(layout.createParallelGroup(Alignment.LEADING) .addComponent(messDetectorLabel) .addComponent(messDetectorRuleSetsLabel) - .addComponent(messDetectorRuleSetFileLabel)) + .addComponent(messDetectorRuleSetFileLabel) + .addComponent(messDetectorOptionsLabel)) .addPreferredGap(ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(Alignment.LEADING) + .addGroup(Alignment.TRAILING, layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(Alignment.TRAILING) + .addComponent(messDetectorRuleSetsScrollPane, Alignment.LEADING) + .addComponent(messDetectorTextField)) + .addPreferredGap(ComponentPlacement.RELATED) + .addComponent(messDetectorBrowseButton) + .addPreferredGap(ComponentPlacement.RELATED) + .addComponent(messDetectorSearchButton)) .addGroup(layout.createSequentialGroup() .addComponent(messDetectorHintLabel) .addContainerGap()) - .addGroup(layout.createSequentialGroup() + .addGroup(Alignment.TRAILING, layout.createSequentialGroup() .addGroup(layout.createParallelGroup(Alignment.TRAILING) - .addComponent(messDetectorRuleSetFileTextField) - .addComponent(messDetectorRuleSetsScrollPane, Alignment.LEADING) - .addComponent(messDetectorTextField)) + .addComponent(messDetectorOptionsTextField, Alignment.LEADING) + .addComponent(messDetectorRuleSetFileTextField)) .addPreferredGap(ComponentPlacement.RELATED) - .addGroup(layout.createParallelGroup(Alignment.LEADING) - .addGroup(Alignment.TRAILING, layout.createSequentialGroup() - .addComponent(messDetectorBrowseButton) - .addPreferredGap(ComponentPlacement.RELATED) - .addComponent(messDetectorSearchButton)) - .addGroup(Alignment.TRAILING, layout.createSequentialGroup() - .addComponent(messDetectorRuleSetFileBrowseButton) - .addGap(83, 83, 83)))))) - .addGroup(layout.createSequentialGroup() - .addContainerGap() - .addGroup(layout.createParallelGroup(Alignment.LEADING) - .addComponent(minVersionInfoLabel) - .addComponent(messDetectorLearnMoreLabel, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) - .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) - .addGroup(layout.createSequentialGroup() - .addComponent(noteLabel, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) - .addGap(0, 0, Short.MAX_VALUE)) + .addComponent(messDetectorRuleSetFileBrowseButton) + .addGap(83, 83, 83)))) ); layout.linkSize(SwingConstants.HORIZONTAL, new Component[] {messDetectorBrowseButton, messDetectorSearchButton}); @@ -321,11 +343,16 @@ public class MessDetectorOptionsPanel extends AnalysisCategoryPanel { .addComponent(messDetectorRuleSetFileBrowseButton) .addComponent(messDetectorRuleSetFileLabel)))) .addPreferredGap(ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(Alignment.BASELINE) + .addComponent(messDetectorOptionsTextField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) + .addComponent(messDetectorOptionsLabel)) + .addPreferredGap(ComponentPlacement.RELATED) .addComponent(noteLabel, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addPreferredGap(ComponentPlacement.RELATED) .addComponent(minVersionInfoLabel) .addPreferredGap(ComponentPlacement.RELATED) - .addComponent(messDetectorLearnMoreLabel, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) + .addComponent(messDetectorLearnMoreLabel, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) + .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) ); messDetectorRuleSetFileLabel.getAccessibleContext().setAccessibleName(NbBundle.getMessage(MessDetectorOptionsPanel.class, "MessDetectorOptionsPanel.messDetectorRuleSetFileLabel.AccessibleContext.accessibleName")); // NOI18N @@ -410,6 +437,8 @@ public class MessDetectorOptionsPanel extends AnalysisCategoryPanel { private JLabel messDetectorHintLabel; private JLabel messDetectorLabel; private JLabel messDetectorLearnMoreLabel; + private JLabel messDetectorOptionsLabel; + private JTextField messDetectorOptionsTextField; private JButton messDetectorRuleSetFileBrowseButton; private JLabel messDetectorRuleSetFileLabel; private JTextField messDetectorRuleSetFileTextField; --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@netbeans.apache.org For additional commands, e-mail: commits-h...@netbeans.apache.org For further information about the NetBeans mailing lists, visit: https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists