org.pushingpixels.flamingo.api.bcb.core
Class BreadcrumbMultiSvnSelector.PathCallback

java.lang.Object
  extended by org.pushingpixels.flamingo.api.bcb.BreadcrumbBarCallBack<String>
      extended by org.pushingpixels.flamingo.api.bcb.core.BreadcrumbMultiSvnSelector.PathCallback
Enclosing class:
BreadcrumbMultiSvnSelector

protected class BreadcrumbMultiSvnSelector.PathCallback
extends BreadcrumbBarCallBack<String>

SVN-specific implementation of the BreadcrumbBarCallBack.

This is tricky. Unlike other implementations that connect in the setup method, this implementation connects when the first path selection is done. The code in BasicBreadcrumbBar.PopupAction.actionPerformed(ActionEvent) adds two items - the selected SVN repository and the matching choices. The first addition requires connecting to the selected repository, which is done off EDT (using SwingWorker). The second addition must wait until the connection has been established since otherwise the repository is not yet available. In order to make the second addition wait, we use a CountDownLatch.

It is CountDownLatch.countDown() in the SwingWorker.done() that wraps the connection. The BreadcrumbBarCallBack#getPathChoices(BreadcrumbItem[]) and BreadcrumbBarCallBack#getLeafs(BreadcrumbItem[]) call CountDownLatch.await() on the same latch that blocks until the connection is done. Since both these methods should be wrapped off EDT in a separate SwingWorker, this doesn't block the UI.


Field Summary
protected  List<BreadcrumbMultiSvnSelector.SvnRepositoryInfo> repositories
          Information on all the configured SVN repositories.
 
Fields inherited from class org.pushingpixels.flamingo.api.bcb.BreadcrumbBarCallBack
throwsExceptions
 
Constructor Summary
BreadcrumbMultiSvnSelector.PathCallback(BreadcrumbMultiSvnSelector.SvnRepositoryInfo... repoList)
          Creates a new callback.
 
Method Summary
 void addSvnRepositoryInfo(BreadcrumbMultiSvnSelector.SvnRepositoryInfo repositoryInfo)
          Adds information on a new SVN repository.
 InputStream getLeafContent(String leaf)
          Returns the input stream with the leaf content.
 List<StringValuePair<String>> getLeafs(List<BreadcrumbItem<String>> path)
          Returns the choice element that corresponds to the specified path.
 List<StringValuePair<String>> getPathChoices(List<BreadcrumbItem<String>> path)
          Returns the choice element that corresponds to the specified path.
 void setup()
          Sets up the callback.
 
Methods inherited from class org.pushingpixels.flamingo.api.bcb.BreadcrumbBarCallBack
setThrowsExceptions
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

repositories

protected List<BreadcrumbMultiSvnSelector.SvnRepositoryInfo> repositories
Information on all the configured SVN repositories.

Constructor Detail

BreadcrumbMultiSvnSelector.PathCallback

public BreadcrumbMultiSvnSelector.PathCallback(BreadcrumbMultiSvnSelector.SvnRepositoryInfo... repoList)
Creates a new callback.

Parameters:
repoList - List of all SVN repositories.
Method Detail

addSvnRepositoryInfo

public void addSvnRepositoryInfo(BreadcrumbMultiSvnSelector.SvnRepositoryInfo repositoryInfo)
Adds information on a new SVN repository.

Parameters:
repositoryInfo -

setup

public void setup()
Description copied from class: BreadcrumbBarCallBack
Sets up the callback.

Overrides:
setup in class BreadcrumbBarCallBack<String>

getPathChoices

public List<StringValuePair<String>> getPathChoices(List<BreadcrumbItem<String>> path)
                                             throws BreadcrumbBarException
Description copied from class: BreadcrumbBarCallBack
Returns the choice element that corresponds to the specified path. If the path is empty, null should be returned. If path is null, the "root" elements should be returned

Overrides:
getPathChoices in class BreadcrumbBarCallBack<String>
Parameters:
path - Breadcrumb bar path.
Returns:
The choice element that corresponds to the specified path
Throws:
BreadcrumbBarException - Runtime exception that wraps the cause. Is thrown only when BreadcrumbBarCallBack.setThrowsExceptions(boolean) has been called with true parameter.

getLeafs

public List<StringValuePair<String>> getLeafs(List<BreadcrumbItem<String>> path)
                                       throws BreadcrumbBarException
Description copied from class: BreadcrumbBarCallBack
Returns the choice element that corresponds to the specified path. If the path is empty, null should be returned. If path is null, the "root" elements should be returned

Overrides:
getLeafs in class BreadcrumbBarCallBack<String>
Parameters:
path - Breadcrumb bar path.
Returns:
The choice element that corresponds to the specified path
Throws:
BreadcrumbBarException - Runtime exception that wraps the cause. Is thrown only when BreadcrumbBarCallBack.setThrowsExceptions(boolean) has been called with true parameter.

getLeafContent

public InputStream getLeafContent(String leaf)
                           throws BreadcrumbBarException
Description copied from class: BreadcrumbBarCallBack
Returns the input stream with the leaf content. Some implementations may return null if this is not applicable.

Overrides:
getLeafContent in class BreadcrumbBarCallBack<String>
Parameters:
leaf - Leaf.
Returns:
Input stream with the leaf content. May be null if this is not applicable.
Throws:
BreadcrumbBarException - Runtime exception that wraps the cause. Is thrown only when BreadcrumbBarCallBack.setThrowsExceptions(boolean) has been called with true parameter.