{
classPath.removeAll ();
// Root element
final JarEntry root = jarStructure.getRoot ();
final WebBreadcrumbButton rootElement = new WebBreadcrumbButton ();
rootElement.setIcon ( root.getIcon () );
TooltipManager.setTooltip ( rootElement, root.getIcon (), jarStructure.getJarLocation () );
rootElement.addActionListener ( new ActionListener ()
{
@Override
public void actionPerformed ( final ActionEvent e )
{
final WebPopupMenu rootMenu = new WebPopupMenu ();
final WebMenuItem showInFS = new WebMenuItem ( "Show in folder", browseIcon );
showInFS.addActionListener ( new ActionListener ()
{
@Override
public void actionPerformed ( final ActionEvent e )
{
try
{
final File jarFile = new File ( jarStructure.getJarLocation () );
Desktop.getDesktop ().browse ( jarFile.getParentFile ().toURI () );
}
catch ( final Throwable ex )
{
Log.error ( this, ex );
}
}
} );
rootMenu.add ( showInFS );
final List<JarEntry> entries = jarStructure.getChildEntries ( root );
if ( entries.size () > 0 )
{
rootMenu.addSeparator ();
for ( final JarEntry entry : entries )
{
rootMenu.add ( createEntryMenuItem ( entry ) );
}
}
rootMenu.showBelowMiddle ( rootElement );
}
} );
classPath.add ( rootElement );
if ( lastEntry != null )
{
// All other elements
final List<JarEntry> path = lastEntry.getPath ();
for ( final JarEntry entry : path )
{
if ( entry.getType ().equals ( JarEntryType.packageEntry ) )
{
final WebBreadcrumbButton element = new WebBreadcrumbButton ();
element.setIcon ( entry.getIcon () );
element.setText ( entry.getName () );
element.addActionListener ( new ActionListener ()
{
@Override
public void actionPerformed ( final ActionEvent e )
{
final List<JarEntry> entries = jarStructure.getChildEntries ( entry );
if ( entries.size () > 0 )
{
final WebPopupMenu packageMenu = new WebPopupMenu ();
for ( final JarEntry menuEntry : entries )
{
packageMenu.add ( createEntryMenuItem ( menuEntry ) );
}
packageMenu.showBelowMiddle ( element );
}
}
} );
classPath.add ( element );
}
else
{
final WebBreadcrumbLabel element = new WebBreadcrumbLabel ();
element.setIcon ( entry.getIcon () );
element.setText ( entry.getName () );
classPath.add ( element );
}
}
}