尝试通过自己的插件在想法中设置运行配置时为“ null”

时间:2019-08-16 15:08:13

标签: java intellij-idea intellij-plugin

我正在尝试设置自己的配置插件。

例如,我使用本指南https://www.jetbrains.org/intellij/sdk/docs/tutorials/run_configurations.html

尝试运行此插件后,我看到此错误:“ @NotNull方法test / DemoSettingsEditor.createEditor不得返回null”

@NotNull method test/DemoSettingsEditor.createEditor must not return null 
java.lang.IllegalStateException: @NotNull method test/DemoSettingsEditor.createEditor must not return null
    at test.DemoSettingsEditor.$$$reportNull$$$0(DemoSettingsEditor.java)
    at test.DemoSettingsEditor.createEditor(DemoSettingsEditor.java:33)
    at com.intellij.openapi.options.SettingsEditor.getComponent(SettingsEditor.java:107)
    at com.intellij.execution.impl.ConfigurationSettingsEditor$ConfigToSettingsWrapper.createEditor(ConfigurationSettingsEditor.java:309)
    at com.intellij.openapi.options.SettingsEditor.getComponent(SettingsEditor.java:107)
    at com.intellij.openapi.options.GroupSettingsBuilder.doCreateComponent(GroupSettingsBuilder.java:55)
    at com.intellij.openapi.options.GroupSettingsBuilder.createCompoundEditor(GroupSettingsBuilder.java:47)
    at com.intellij.openapi.options.CompositeSettingsEditor.createEditor(CompositeSettingsEditor.java:100)
    at com.intellij.openapi.options.SettingsEditor.getComponent(SettingsEditor.java:107)
    at com.intellij.execution.impl.ConfigurationSettingsEditorWrapper.createEditor(ConfigurationSettingsEditorWrapper.java:84)
    at com.intellij.openapi.options.SettingsEditor.getComponent(SettingsEditor.java:107)
    at com.intellij.openapi.options.SettingsEditorConfigurable.<init>(SettingsEditorConfigurable.java:38)
    at com.intellij.execution.impl.BaseRCSettingsConfigurable.<init>(BaseRCSettingsConfigurable.java:17)
    at com.intellij.execution.impl.TemplateConfigurable.<init>(TemplateConfigurable.java:14)
    at com.intellij.execution.impl.RunConfigurable.showTemplateConfigurable(RunConfigurable.kt:322)
    at com.intellij.execution.impl.RunConfigurable.access$showTemplateConfigurable(RunConfigurable.kt:75)
    at com.intellij.execution.impl.RunConfigurable$initTree$3.valueChanged(RunConfigurable.kt:260)
    at javax.swing.JTree.fireValueChanged(JTree.java:2934)
    at javax.swing.JTree$TreeSelectionRedirector.valueChanged(JTree.java:3398)
    at javax.swing.tree.DefaultTreeSelectionModel.fireValueChanged(DefaultTreeSelectionModel.java:635)
    at com.intellij.ui.treeStructure.Tree$MySelectionModel.fireValueChanged(Tree.java:672)
    at javax.swing.tree.DefaultTreeSelectionModel.notifyPathChange(DefaultTreeSelectionModel.java:1093)
    at javax.swing.tree.DefaultTreeSelectionModel.setSelectionPaths(DefaultTreeSelectionModel.java:294)
    at javax.swing.tree.DefaultTreeSelectionModel.setSelectionPath(DefaultTreeSelectionModel.java:188)
    at javax.swing.JTree.setSelectionPath(JTree.java:1641)
    at javax.swing.plaf.basic.BasicTreeUI.selectPathForEvent(BasicTreeUI.java:2393)
    at javax.swing.plaf.basic.BasicTreeUI$Handler.handleSelection(BasicTreeUI.java:3609)
    at javax.swing.plaf.basic.BasicTreeUI$Handler.mousePressedDND(BasicTreeUI.java:3586)
    at javax.swing.plaf.basic.BasicTreeUI$Handler.mousePressed(BasicTreeUI.java:3545)
    at com.intellij.util.ui.MouseEventAdapter.mousePressed(MouseEventAdapter.java:33)
    at java.awt.AWTEventMulticaster.mousePressed(AWTEventMulticaster.java:279)
    at java.awt.AWTEventMulticaster.mousePressed(AWTEventMulticaster.java:279)
    at java.awt.AWTEventMulticaster.mousePressed(AWTEventMulticaster.java:279)
    at java.awt.AWTEventMulticaster.mousePressed(AWTEventMulticaster.java:279)
    at java.awt.Component.processMouseEvent(Component.java:6536)
    at javax.swing.JComponent.processMouseEvent(JComponent.java:3324)
    at com.intellij.ui.treeStructure.Tree.processMouseEvent(Tree.java:424)
    at java.awt.Component.processEvent(Component.java:6304)
    at java.awt.Container.processEvent(Container.java:2239)
    at java.awt.Component.dispatchEventImpl(Component.java:4889)
    at java.awt.Container.dispatchEventImpl(Container.java:2297)
    at java.awt.Component.dispatchEvent(Component.java:4711)
    at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4904)
    at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4532)
    at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4476)
    at java.awt.Container.dispatchEventImpl(Container.java:2283)
    at java.awt.Window.dispatchEventImpl(Window.java:2746)
    at java.awt.Component.dispatchEvent(Component.java:4711)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:760)
    at java.awt.EventQueue.access$500(EventQueue.java:97)
    at java.awt.EventQueue$3.run(EventQueue.java:709)
    at java.awt.EventQueue$3.run(EventQueue.java:703)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:74)
    at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:84)
    at java.awt.EventQueue$4.run(EventQueue.java:733)
    at java.awt.EventQueue$4.run(EventQueue.java:731)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:74)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:730)
    at com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.java:781)
    at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:718)
    at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:382)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:205)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:109)
    at java.awt.WaitDispatchSupport$2.run(WaitDispatchSupport.java:190)
    at java.awt.WaitDispatchSupport$4.run(WaitDispatchSupport.java:235)
    at java.awt.WaitDispatchSupport$4.run(WaitDispatchSupport.java:233)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.awt.WaitDispatchSupport.enter(WaitDispatchSupport.java:233)
    at java.awt.Dialog.show(Dialog.java:1084)
    at com.intellij.openapi.ui.impl.DialogWrapperPeerImpl$MyDialog.show(DialogWrapperPeerImpl.java:698)
    at com.intellij.openapi.ui.impl.DialogWrapperPeerImpl.show(DialogWrapperPeerImpl.java:430)
    at com.intellij.openapi.ui.DialogWrapper.invokeShow(DialogWrapper.java:1690)
    at com.intellij.openapi.ui.DialogWrapper.show(DialogWrapper.java:1639)
    at com.intellij.execution.actions.EditRunConfigurationsAction.actionPerformed(EditRunConfigurationsAction.java:47)
    at com.intellij.openapi.actionSystem.ex.ActionUtil$1.run(ActionUtil.java:255)
    at com.intellij.openapi.actionSystem.ex.ActionUtil.performActionDumbAware(ActionUtil.java:272)
    at com.intellij.openapi.actionSystem.impl.ActionManagerImpl.lambda$null$2(ActionManagerImpl.java:1343)
    at com.intellij.openapi.application.TransactionGuardImpl.performUserActivity(TransactionGuardImpl.java:195)
    at com.intellij.openapi.actionSystem.impl.ActionManagerImpl.lambda$tryToExecuteNow$3(ActionManagerImpl.java:1300)
    at com.intellij.openapi.wm.impl.FocusManagerImpl.lambda$doWhenFocusSettlesDown$2(FocusManagerImpl.java:199)
    at com.intellij.util.ui.UIUtil.invokeLaterIfNeeded(UIUtil.java:3094)
    at com.intellij.ide.IdeEventQueue.ifFocusEventsInTheQueue(IdeEventQueue.java:183)
    at com.intellij.ide.IdeEventQueue.executeWhenAllFocusEventsLeftTheQueue(IdeEventQueue.java:132)
    at com.intellij.openapi.wm.impl.FocusManagerImpl.doWhenFocusSettlesDown(FocusManagerImpl.java:190)
    at com.intellij.openapi.wm.impl.FocusManagerImpl.doWhenFocusSettlesDown(FocusManagerImpl.java:196)
    at com.intellij.openapi.wm.impl.IdeFocusManagerImpl.doWhenFocusSettlesDown(IdeFocusManagerImpl.java:63)
    at com.intellij.openapi.actionSystem.impl.ActionManagerImpl.tryToExecuteNow(ActionManagerImpl.java:1299)
    at com.intellij.openapi.actionSystem.impl.ActionManagerImpl.lambda$tryToExecute$1(ActionManagerImpl.java:1284)
    at com.intellij.openapi.actionSystem.impl.ActionManagerImpl.tryToExecute(ActionManagerImpl.java:1287)
    at com.intellij.execution.actions.RunConfigurationsComboBoxAction.performWhenButton(RunConfigurationsComboBoxAction.java:163)
    at com.intellij.execution.actions.RunConfigurationsComboBoxAction.access$000(RunConfigurationsComboBoxAction.java:34)
    at com.intellij.execution.actions.RunConfigurationsComboBoxAction$1.fireActionPerformed(RunConfigurationsComboBoxAction.java:140)
    at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2348)
    at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402)
    at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259)
    at javax.swing.AbstractButton.doClick(AbstractButton.java:376)
    at javax.swing.AbstractButton.doClick(AbstractButton.java:356)
    at com.intellij.openapi.actionSystem.ex.ComboBoxAction$ComboBoxButton$1.mousePressed(ComboBoxAction.java:155)
    at java.awt.AWTEventMulticaster.mousePressed(AWTEventMulticaster.java:280)
    at java.awt.AWTEventMulticaster.mousePressed(AWTEventMulticaster.java:279)

这是教程中的代码:

public class PrismRunConfigurationEditor extends SettingsEditor<PrismRunConfiguration> {

    private JPanel jPanel;
    private LabeledComponent<ComponentWithBrowseButton> myMainClass;

    @Override
    protected void resetEditorFrom(final PrismRunConfiguration runConfiguration) {

    }

    @Override
    protected void applyEditorTo(final PrismRunConfiguration runConfiguration) throws ConfigurationException {

    }

    @NotNull
    @Override
    protected JComponent createEditor() {
        System.out.println("createEditor: " + jPanel);
        return jPanel;
    }

    private void createUIComponents() {
        myMainClass = new LabeledComponent<ComponentWithBrowseButton>();
        myMainClass.setComponent(new TextFieldWithBrowseButton());
    }
}

如果我将jPanel设置为新的JPanel(),那么一切都会很好

public class PrismRunConfigurationEditor extends SettingsEditor<PrismRunConfiguration> {

    private JPanel jPanel = new JPanel();
    private LabeledComponent<ComponentWithBrowseButton> myMainClass;

    @Override
    protected void resetEditorFrom(final PrismRunConfiguration runConfiguration) {

    }

    @Override
    protected void applyEditorTo(final PrismRunConfiguration runConfiguration) throws ConfigurationException {

    }

    @NotNull
    @Override
    protected JComponent createEditor() {
        System.out.println("createEditor: " + jPanel);
        return jPanel;
    }

    private void createUIComponents() {
        myMainClass = new LabeledComponent<ComponentWithBrowseButton>();
        myMainClass.setComponent(new TextFieldWithBrowseButton());
    }
}

但是看来这不是正确的方法。

0 个答案:

没有答案