if (isPublicStatic(jsVariable))
{
model.addElement(jsVariable);
}
}
final JBList list = new JBList(model);
list.setCellRenderer(new ListCellRenderer()
{
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus)
{
@SuppressWarnings({"unchecked"})
final JComponent comp = new JBLabel(((JSVariable) value).getName());
comp.setOpaque(true);
if (isSelected)
{
comp.setBackground(list.getSelectionBackground());
comp.setForeground(list.getSelectionForeground());
}
else
{
comp.setBackground(list.getBackground());
comp.setForeground(list.getForeground());
}
return comp;
}
});
list.getSelectionModel().addListSelectionListener(new ListSelectionListener()
{
public void valueChanged(ListSelectionEvent e)
{
Object source = e.getSource();
System.out.println(source.toString());
}
});
/* list.addKeyListener(new KeyAdapter()
{
@Override public void keyReleased(KeyEvent e)
{
if (e.getKeyCode() == KeyEvent.VK_ENTER)
{
Object selectedValue = list.getSelectedValue();
openMappedElement((JSElement) selectedValue, classType, project);
}
}
});*/
PopupChooserBuilder popupChooserBuilder = new PopupChooserBuilder(list);
JBPopup popup = popupChooserBuilder.createPopup();
popup.showCenteredInCurrentWindow(project);
list.addMouseListener(new MouseAdapter()
{
@Override public void mousePressed(MouseEvent e)
{
System.out.println(e.toString());
openMappedElement((JSElement) list.getSelectedValue(), classType, project);
}
});
list.addKeyListener(new KeyAdapter()
{
@Override public void keyPressed(KeyEvent e)
{
if (e.getKeyCode() == KeyEvent.VK_ENTER)
{
System.out.println(e.toString());
openMappedElement((JSElement) list.getSelectedValue(), classType, project);
}
}
});