ISourceContainer alreadyCreatedContainer,
final ISourceLookupDirector director) {
if (type == null) {
return null;
}
final ISourceContainerBrowser browser = DebugUITools.getSourceContainerBrowser(type.getId());
if (browser == null) {
return null;
}
abstract class ActionBase implements ConfigureButtonAction {
public ISourceContainer run(Shell shell) {
ISourceContainer[] containers = runImpl(shell);
if (containers.length != 1) {
return null;
}
return containers[0];
}
abstract ISourceContainer[] runImpl(Shell shell);
}
ISourceContainer[] containers;
if (alreadyCreatedContainer != null && alreadyCreatedContainer.getType().equals(type)) {
// Edit existing.
final ISourceContainer[] alreadyCreatedContainerArray = { alreadyCreatedContainer };
if (browser.canEditSourceContainers(director, alreadyCreatedContainerArray)) {
return new ActionBase() {
@Override ISourceContainer[] runImpl(Shell shell) {
return browser.editSourceContainers(shell, director, alreadyCreatedContainerArray);
}
};
}
}
// Add new.
if (browser.canAddSourceContainers(director)) {
return new ActionBase() {
@Override ISourceContainer[] runImpl(Shell shell) {
return browser.addSourceContainers(shell, director);
}
};
}
return null;
}