You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@netbeans.apache.org by GitBox <gi...@apache.org> on 2018/10/20 15:22:02 UTC

[GitHub] tmysik closed pull request #974: [NETBEANS-1461] PHPStan max level

tmysik closed pull request #974: [NETBEANS-1461] PHPStan max level
URL: https://github.com/apache/incubator-netbeans/pull/974
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/php/php.code.analysis/src/org/netbeans/modules/php/analysis/ui/PHPStanLevelListCellRenderer.java b/php/php.code.analysis/src/org/netbeans/modules/php/analysis/ui/PHPStanLevelListCellRenderer.java
new file mode 100644
index 0000000000..6f316be25d
--- /dev/null
+++ b/php/php.code.analysis/src/org/netbeans/modules/php/analysis/ui/PHPStanLevelListCellRenderer.java
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.netbeans.modules.php.analysis.ui;
+
+import java.awt.Component;
+import javax.swing.JList;
+import javax.swing.ListCellRenderer;
+
+public class PHPStanLevelListCellRenderer implements ListCellRenderer<String> {
+
+    private final ListCellRenderer<? super String> defaultRenderer;
+
+    public PHPStanLevelListCellRenderer(ListCellRenderer<? super String> defaultRenderer) {
+        this.defaultRenderer = defaultRenderer;
+    }
+
+    @Override
+    public Component getListCellRendererComponent(JList<? extends String> list, String value, int index, boolean isSelected, boolean cellHasFocus) {
+        String level = value;
+        if ("7".equals(level)) { // NOI18N
+            level += " (max)"; // NOI18N
+        }
+        return defaultRenderer.getListCellRendererComponent(list, level, index, isSelected, cellHasFocus);
+    }
+
+}
diff --git a/php/php.code.analysis/src/org/netbeans/modules/php/analysis/ui/analyzer/PHPStanCustomizerPanel.java b/php/php.code.analysis/src/org/netbeans/modules/php/analysis/ui/analyzer/PHPStanCustomizerPanel.java
index b39a80b644..5177f21f23 100644
--- a/php/php.code.analysis/src/org/netbeans/modules/php/analysis/ui/analyzer/PHPStanCustomizerPanel.java
+++ b/php/php.code.analysis/src/org/netbeans/modules/php/analysis/ui/analyzer/PHPStanCustomizerPanel.java
@@ -27,6 +27,7 @@
 import javax.swing.event.DocumentListener;
 import org.netbeans.modules.analysis.spi.Analyzer;
 import org.netbeans.modules.php.analysis.options.AnalysisOptions;
+import org.netbeans.modules.php.analysis.ui.PHPStanLevelListCellRenderer;
 import org.netbeans.modules.php.analysis.ui.options.PHPStanOptionsPanel;
 import org.openide.filesystems.FileChooserBuilder;
 import org.openide.util.NbBundle;
@@ -71,6 +72,7 @@ private void setEnabledCheckBox() {
 
     private void setLevelComboBox() {
         assert EventQueue.isDispatchThread();
+        phpStanLevelComboBox.setRenderer(new PHPStanLevelListCellRenderer(phpStanLevelComboBox.getRenderer()));
         phpStanLevelComboBox.setSelectedItem(settings.get(LEVEL, String.valueOf(AnalysisOptions.getInstance().getPHPStanLevel())));
         phpStanLevelComboBox.addItemListener(e -> setLevel());
     }
diff --git a/php/php.code.analysis/src/org/netbeans/modules/php/analysis/ui/options/PHPStanOptionsPanel.java b/php/php.code.analysis/src/org/netbeans/modules/php/analysis/ui/options/PHPStanOptionsPanel.java
index d1afcaceae..1b449ea215 100644
--- a/php/php.code.analysis/src/org/netbeans/modules/php/analysis/ui/options/PHPStanOptionsPanel.java
+++ b/php/php.code.analysis/src/org/netbeans/modules/php/analysis/ui/options/PHPStanOptionsPanel.java
@@ -29,6 +29,7 @@
 import org.netbeans.modules.php.analysis.commands.PHPStan;
 import org.netbeans.modules.php.analysis.options.AnalysisOptions;
 import org.netbeans.modules.php.analysis.options.AnalysisOptionsValidator;
+import org.netbeans.modules.php.analysis.ui.PHPStanLevelListCellRenderer;
 import org.netbeans.modules.php.api.util.FileUtils;
 import org.netbeans.modules.php.api.util.UiUtils;
 import org.netbeans.modules.php.api.validation.ValidationResult;
@@ -61,6 +62,7 @@ public PHPStanOptionsPanel() {
         "PHPStanOptionsPanel.hint=Full path of PHPStan script (typically {0} or {1}).",})
     private void init() {
         phpStanHintLabel.setText(Bundle.PHPStanOptionsPanel_hint(PHPStan.NAME, PHPStan.LONG_NAME));
+        phpStanLevelComboBox.setRenderer(new PHPStanLevelListCellRenderer(phpStanLevelComboBox.getRenderer()));
         // add listener
         DefaultDocumentListener defaultDocumentListener = new DefaultDocumentListener();
         phpStanTextField.getDocument().addDocumentListener(defaultDocumentListener);


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists