Last active
November 24, 2016 23:30
-
-
Save halirutan/c65df3b6b1efbe7b465515b9f888c1f8 to your computer and use it in GitHub Desktop.
Shows how that a ComboBox cannot ititially be set to enabled(false) in LocalInspection
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Copyright (c) 2016 Patrick Scheibe | |
* Permission is hereby granted, free of charge, to any person obtaining a copy | |
* of this software and associated documentation files (the "Software"), to deal | |
* in the Software without restriction, including without limitation the rights | |
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
* copies of the Software, and to permit persons to whom the Software is | |
* furnished to do so, subject to the following conditions: | |
* | |
* The above copyright notice and this permission notice shall be included in | |
* all copies or substantial portions of the Software. | |
* | |
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | |
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | |
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | |
* THE SOFTWARE. | |
*/ | |
package de.halirutan.mathematica.codeinsight.inspections.bugs; | |
import com.intellij.codeInspection.LocalInspectionTool; | |
import com.intellij.codeInspection.LocalInspectionToolSession; | |
import com.intellij.codeInspection.ProblemsHolder; | |
import com.intellij.openapi.ui.ComboBox; | |
import com.intellij.openapi.ui.VerticalFlowLayout; | |
import com.intellij.psi.PsiElementVisitor; | |
import org.jetbrains.annotations.Nls; | |
import org.jetbrains.annotations.NotNull; | |
import org.jetbrains.annotations.Nullable; | |
import javax.swing.*; | |
import java.awt.event.ActionEvent; | |
import java.awt.event.ActionListener; | |
public class TestInspection extends LocalInspectionTool { | |
public enum TestValues {VALUE_1, VALUE_2, VALUE_3} | |
@Nullable | |
@Override | |
public JComponent createOptionsPanel() { | |
final JPanel panel = new JPanel(new VerticalFlowLayout(VerticalFlowLayout.TOP)); | |
final ComboBox comboBox = new ComboBox(TestValues.values()); | |
panel.add(comboBox); | |
comboBox.setEditable(false); | |
comboBox.setEnabled(false); | |
comboBox.addActionListener(new ActionListener() { | |
@Override | |
public void actionPerformed(ActionEvent e) { | |
comboBox.setEnabled(false); | |
} | |
}); | |
return panel; | |
} | |
@Nls | |
@NotNull | |
@Override | |
public String getDisplayName() { | |
return "Test Inspection"; | |
} | |
@Nullable | |
@Override | |
public String getStaticDescription() { | |
return "Test inspection to show how ComboBox works"; | |
} | |
@Nls | |
@NotNull | |
@Override | |
public String getGroupDisplayName() { | |
return "Test Group"; | |
} | |
@NotNull | |
@Override | |
public PsiElementVisitor buildVisitor(@NotNull final ProblemsHolder holder, final boolean isOnTheFly, @NotNull LocalInspectionToolSession session) { | |
return PsiElementVisitor.EMPTY_VISITOR; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment