NullPointerException in Intellij ModalityState.current()

Answered

Hi,

I've been using intellij com.intellij.ui.treeStructure.treetable.TreeTable recently and just encountered a null pointer which doesn't actually include my code in the stack trace. 

I've managed to reproduce the problem, there isn't much code so i will post here everything you need to reproduce. To get the exception, simply try to edit a row of the tree table.

import com.intellij.ui.treeStructure.treetable.*;
import com.intellij.util.ui.ColumnInfo;

import javax.swing.*;
import javax.swing.tree.DefaultMutableTreeNode;

public class TreeTableRunner {

static TreeTable treeTable;

TreeTableRunner() {
treeTable = createTreeTable();
}

private TreeTable createTreeTable() {
DefaultMutableTreeNode rootNode = new DefaultMutableTreeNode("node");

TreeTableModel model = new ListTreeTableModel(rootNode, createColumns()) {
@Override
public boolean isCellEditable(Object node, int column) {
return true;
}

@Override
public void setValueAt(Object o, Object o1, int i) {
if (o instanceof DefaultMutableTreeNode) {
((DefaultMutableTreeNode) o).setUserObject(o1);
}
}
};

return new TreeTable(model);
}

private ColumnInfo[] createColumns() {
final ColumnInfo propertyColumn = new ColumnInfo("Property") {
@Override
public Object valueOf(final Object o) {
return o;
}

@Override
public Class getColumnClass() {
return TreeTableModel.class;
}
};

final ColumnInfo valueColumn = new ColumnInfo("Value") {

@Override
public Object valueOf(Object o) {
return o;
}

@Override
public Class getColumnClass() {
return Object.class;
}

@Override
public boolean isCellEditable(Object o) {
return true;
}

};

return new ColumnInfo[]{propertyColumn, valueColumn};
}

public static void main(String[] args) {
new TreeTableRunner();

JFrame frame = new JFrame();
frame.setBounds(500, 400, 400, 500);
frame.getContentPane().add(new JScrollPane(treeTable));
frame.setVisible(true);
}
}

Here is the exception stack trace:

Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at com.intellij.openapi.application.ModalityState.current(ModalityState.java:62)
at com.intellij.ui.table.JBTable$MyCellEditorRemover.permanentFocusOwnerChanged(JBTable.java:669)
at com.intellij.ui.table.JBTable$MyCellEditorRemover.propertyChange(JBTable.java:617)
at java.beans.PropertyChangeSupport.fire(PropertyChangeSupport.java:335)
at java.beans.PropertyChangeSupport.firePropertyChange(PropertyChangeSupport.java:328)
at java.beans.PropertyChangeSupport.firePropertyChange(PropertyChangeSupport.java:263)
at java.awt.KeyboardFocusManager.firePropertyChange(KeyboardFocusManager.java:1493)
at java.awt.KeyboardFocusManager.setGlobalPermanentFocusOwner(KeyboardFocusManager.java:780)
at java.awt.DefaultKeyboardFocusManager.dispatchEvent(DefaultKeyboardFocusManager.java:668)
at java.awt.Component.dispatchEventImpl(Component.java:4760)
at java.awt.Container.dispatchEventImpl(Container.java:2297)
at java.awt.Component.dispatchEvent(Component.java:4711)
at sun.awt.SunToolkit$1.run(SunToolkit.java:521)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:311)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:758)
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.awt.EventQueue.dispatchEvent(EventQueue.java:728)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:205)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)

Please let me know if there's anything else you need, thanks in advance.

2 comments
Avatar
Vassiliy Kudryashov
Comment actions Permalink

Open API is designed to be used in plugins, not in separate Java application. Please explain your case with plugin codebase.

0
Comment actions Permalink

Ah I see. After testing in plugin it turned out to be fine, thank you for your reply.

0

Please sign in to leave a comment.