}
}
private void showFilesPopup ( final File[] files, final WebBreadcrumbButton fileButton )
{
final WebWindow window = new WebWindow ( SwingUtils.getWindowAncestor ( fileButton ) );
window.setCloseOnFocusLoss ( true );
window.setAlwaysOnTop ( true );
final WebList list = new WebList ( files );
list.setRolloverSelectionEnabled ( true );
list.setSelectedIndex ( 0 );
list.setVisibleRowCount ( Math.min ( maxVisibleListFiles, files.length ) );
list.setCellRenderer ( new WebListCellRenderer ()
{
@Override
public Component getListCellRendererComponent ( final JList list, final Object value, final int index, final boolean isSelected,
final boolean cellHasFocus )
{
final WebListElement element =
( WebListElement ) super.getListCellRendererComponent ( list, value, index, isSelected, cellHasFocus );
final File child = ( File ) value;
element.setIcon ( FileUtils.getFileIcon ( child ) );
final String fileName = FileUtils.getDisplayFileName ( child );
element.setText ( FileUtils.getShortFileName ( fileName, listFileNameLength ) );
return element;
}
} );
final MouseAdapter mouseAdapter = new MouseAdapter ()
{
@Override
public void mousePressed ( final MouseEvent e )
{
if ( list.getSelectedIndex () != -1 )
{
setCurrentFile ( ( File ) list.getSelectedValue () );
final Component lc = getLastComponent ();
lc.requestFocus ();
lc.requestFocusInWindow ();
if ( autoExpandLastElement && lc instanceof AbstractButton )
{
( ( AbstractButton ) lc ).doClick ();
}
}
}
};
list.addMouseListener ( mouseAdapter );
list.addKeyListener ( new KeyAdapter ()
{
@Override
public void keyReleased ( final KeyEvent e )
{
if ( Hotkey.ESCAPE.isTriggered ( e ) )
{
fileButton.requestFocusInWindow ();
}
}
} );
final WebScrollPane listScroll = new WebScrollPane ( list );
listScroll.setShadeWidth ( 0 );
listScroll.setDrawFocus ( false );
window.add ( listScroll );
window.applyComponentOrientation ( getComponentOrientation () );
window.pack ();
final Point los = fileButton.getLocationOnScreen ();
final Insets bi = list.getWebListCellRenderer ().getBorder ().getBorderInsets ( list );
if ( getComponentOrientation ().isLeftToRight () )
{
window.setLocation ( los.x + fileButton.getInsets ().left - listScroll.getInsets ().left -
bi.left, los.y + fileButton.getHeight () + 2 );
}
else
{
window.setLocation ( los.x + fileButton.getWidth () - fileButton.getInsets ().right -
listScroll.getWidth () + listScroll.getInsets ().right + bi.right, los.y + fileButton.getHeight () + 2 );
}
window.setVisible ( true );
list.requestFocusInWindow ();
}