Program: 122302
Project: 122302
Buggy source:
/** 
 * Open an appropriate destination browser so that the user can specify a source to import from.
 */
@Override protected void handleDestinationBrowseButtonPressed(){
  FileDialog dialog=new FileDialog(getContainer().getShell(),SWT.SAVE);
  JobExportType jobExportType=getCurrentExportType1();
switch (jobExportType) {
case WSWAR:
    dialog.setFilterExtensions(new String[]{"String_Node_Str" + FileConstants.WAR_FILE_SUFFIX,"String_Node_Str"});
  break;
case JBOSSESB:
dialog.setFilterExtensions(new String[]{"String_Node_Str" + FileConstants.ESB_FILE_SUFFIX,"String_Node_Str"});
break;
case OSGI:
dialog.setFilterExtensions(new String[]{"String_Node_Str" + FileConstants.JAR_FILE_SUFFIX,"String_Node_Str"});
break;
case PETALSESB:
dialog.setFilterExtensions(new String[]{"String_Node_Str" + FileConstants.ZIP_FILE_SUFFIX,"String_Node_Str"});
break;
default :
dialog.setFilterExtensions(new String[]{"String_Node_Str" + FileConstants.ZIP_FILE_SUFFIX,"String_Node_Str"});
}
if (jobExportType.equals(JobExportType.PETALSESB)) {
IPath destPath=new Path(saDestinationFilePath);
String fileName, directory;
if (destPath.toFile().isDirectory()) {
fileName=getPetalsDefaultSaName();
directory=destPath.toOSString();
}
 else {
fileName=destPath.lastSegment();
directory=destPath.removeLastSegments(1).toOSString();
}
dialog.setFileName(fileName);
dialog.setFilterPath(directory);
}
 else {
dialog.setText("String_Node_Str");
dialog.setFileName(getDefaultFileName().get(0));
String currentSourceString=getDestinationValue();
int lastSeparatorIndex=currentSourceString.lastIndexOf(File.separator);
if (lastSeparatorIndex != -1) {
dialog.setFilterPath(currentSourceString.substring(0,lastSeparatorIndex));
}
}
String selectedFileName=dialog.open();
if (selectedFileName == null) {
return;
}
if (!selectedFileName.endsWith(getOutputSuffix())) {
selectedFileName+=getOutputSuffix();
}
if (selectedFileName != null && !selectedFileName.endsWith(getSelectedJobVersion() + getOutputSuffix())) {
String b=selectedFileName.substring(0,(selectedFileName.length() - 4));
File file=new File(b);
String str=file.getName();
String s=getDefaultFileName().get(0);
if (str.equals(s)) {
if (getDefaultFileName().get(1) != null && !"String_Node_Str".equals(getDefaultFileName().get(1))) {
selectedFileName=b + ((JobExportType.OSGI.equals(jobExportType)) ? "String_Node_Str" : "String_Node_Str") + getDefaultFileName().get(1)+ getOutputSuffix();
}
 else {
selectedFileName=b + getOutputSuffix();
}
}
 else {
selectedFileName=b + getOutputSuffix();
}
}
if (selectedFileName != null) {
setErrorMessage(null);
saDestinationFilePath=selectedFileName;
setDestinationValue(selectedFileName);
if (getDialogSettings() != null) {
IDialogSettings section=getDialogSettings().getSection(DESTINATION_FILE);
if (section == null) {
section=getDialogSettings().addNewSection(DESTINATION_FILE);
}
section.put(DESTINATION_FILE,selectedFileName);
}
}
}

Fixed version (ground truth):
/** 
 * Open an appropriate destination browser so that the user can specify a source to import from.
 */
@Override protected void handleDestinationBrowseButtonPressed(){
  FileDialog dialog=new FileDialog(getContainer().getShell(),SWT.SAVE);
  JobExportType jobExportType=getCurrentExportType1();
switch (jobExportType) {
case WSWAR:
    dialog.setFilterExtensions(new String[]{"String_Node_Str" + FileConstants.WAR_FILE_SUFFIX,"String_Node_Str"});
  break;
case JBOSSESB:
dialog.setFilterExtensions(new String[]{"String_Node_Str" + FileConstants.ESB_FILE_SUFFIX,"String_Node_Str"});
break;
case OSGI:
if (isAddMavenScript()) {
dialog.setFilterExtensions(new String[]{"String_Node_Str" + FileConstants.ZIP_FILE_SUFFIX,"String_Node_Str"});
}
 else {
dialog.setFilterExtensions(new String[]{"String_Node_Str" + FileConstants.JAR_FILE_SUFFIX,"String_Node_Str"});
}
break;
case PETALSESB:
dialog.setFilterExtensions(new String[]{"String_Node_Str" + FileConstants.ZIP_FILE_SUFFIX,"String_Node_Str"});
break;
default :
dialog.setFilterExtensions(new String[]{"String_Node_Str" + FileConstants.ZIP_FILE_SUFFIX,"String_Node_Str"});
}
if (jobExportType.equals(JobExportType.PETALSESB)) {
IPath destPath=new Path(saDestinationFilePath);
String fileName, directory;
if (destPath.toFile().isDirectory()) {
fileName=getPetalsDefaultSaName();
directory=destPath.toOSString();
}
 else {
fileName=destPath.lastSegment();
directory=destPath.removeLastSegments(1).toOSString();
}
dialog.setFileName(fileName);
dialog.setFilterPath(directory);
}
 else {
dialog.setText("String_Node_Str");
dialog.setFileName(getDefaultFileName().get(0));
String currentSourceString=getDestinationValue();
int lastSeparatorIndex=currentSourceString.lastIndexOf(File.separator);
if (lastSeparatorIndex != -1) {
dialog.setFilterPath(currentSourceString.substring(0,lastSeparatorIndex));
}
}
String selectedFileName=dialog.open();
if (selectedFileName == null) {
return;
}
String idealSuffix;
if (isAddMavenScript()) {
idealSuffix=FileConstants.ZIP_FILE_SUFFIX;
}
 else {
idealSuffix=getOutputSuffix();
}
if (!selectedFileName.endsWith(idealSuffix)) {
selectedFileName+=idealSuffix;
}
if (selectedFileName != null && !selectedFileName.endsWith(getSelectedJobVersion() + idealSuffix)) {
String b=selectedFileName.substring(0,(selectedFileName.length() - 4));
File file=new File(b);
String str=file.getName();
String s=getDefaultFileName().get(0);
if (str.equals(s)) {
if (getDefaultFileName().get(1) != null && !"String_Node_Str".equals(getDefaultFileName().get(1))) {
selectedFileName=b + ((JobExportType.OSGI.equals(jobExportType)) ? "String_Node_Str" : "String_Node_Str") + getDefaultFileName().get(1)+ idealSuffix;
}
 else {
selectedFileName=b + idealSuffix;
}
}
 else {
selectedFileName=b + idealSuffix;
}
}
if (selectedFileName != null) {
setErrorMessage(null);
saDestinationFilePath=selectedFileName;
setDestinationValue(selectedFileName);
if (getDialogSettings() != null) {
IDialogSettings section=getDialogSettings().getSection(DESTINATION_FILE);
if (section == null) {
section=getDialogSettings().addNewSection(DESTINATION_FILE);
}
section.put(DESTINATION_FILE,selectedFileName);
}
}
}