Project p = (Project) projectCombo.getSelectedItem();
if (p == null) {
throw new IllegalStateException("Project cannot be null.");
}
Collection<JavaPackage> packages = ProjectUtils.getSourcePackages(p, true);
JavaPackageComboBoxModel model = new JavaPackageComboBoxModel();
model.addAll(packages);
packageCombo.setModel(model);
if (model.getSize() > 0) {
DataObject data = PackageUtils.getSelectedPackage();
if (data != null) {
try {
final JavaPackage selected = new JavaPackage(ClassPathUtils.getSourceClassPath(p), data.getPrimaryFile());
packageCombo.setSelectedItem(selected);