saveCommentsToBug(currentSelectedBugLeaf);  FBFileChooser jfc=new FBFileChooser(); jfc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); jfc.setFileFilter(FindBugsProjectFileFilter.INSTANCE); File xmlFile=null; if (projectChanged) { int response = JOptionPane.showConfirmDialog(MainFrame.this, "The current project has been changed, Save current changes?" ,"Save Changes?", JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE);  if (response == JOptionPane.YES_OPTION) { if (projectDirectory!=null) save(projectDirectory); else projectSaveAs(); } else if (response == JOptionPane.CANCEL_OPTION) return;  }  boolean loading = true; while (loading) { int value=jfc.showOpenDialog(MainFrame.this); if(value==JFileChooser.APPROVE_OPTION){ loading = false; final File dir = jfc.getSelectedFile();  if(!dir.exists() || !dir.isDirectory()) { JOptionPane.showMessageDialog(null, "Warning! This project is not a directory."); loading = true; continue; } else { xmlFile= new File(dir.getAbsolutePath() + File.separator + dir.getName() + ".xml"); File fasFile=new File(dir.getAbsolutePath() + File.separator + dir.getName() + ".fas");  if (!xmlFile.exists()) { JOptionPane.showMessageDialog(null, "This directory does not contain saved bug XML data, please choose a different directory."); loading=true; continue; }  if (!fasFile.exists()) { JOptionPane.showMessageDialog(MainFrame.this, "Filter settings not found, using default settings."); try { fasFile.createNewFile(); ProjectSettings.newInstance().save(new FileOutputStream(fasFile)); } catch (IOException e) { if (MainFrame.DEBUG) System.err.println("Error saving new filter settings file, using default settings without saving these settings to the project."); ProjectSettings.newInstance(); } } else { try { ProjectSettings.loadInstance(new FileInputStream(fasFile)); } catch (FileNotFoundException e) {  if (MainFrame.DEBUG) System.err.println(".fas file not found, using default settings"); ProjectSettings.newInstance(); } }  final File extraFinalReferenceToXmlFile=xmlFile; new Thread(new Runnable(){ public void run() { BugTreeModel model=(BugTreeModel)tree.getModel();  BugTreeModel.pleaseWait(); MainFrame.this.setRebuilding(true); BugSet bs=BugLoader.loadBugs(extraFinalReferenceToXmlFile); MainFrame.this.setRebuilding(false); if (bs!=null) { editProjectMenuItem.setEnabled(true); model.getOffListenerList(); updateDesignation(); model.changeSet(bs); curProject=BugLoader.getLoadedProject(); projectDirectory=dir; curProject.setProjectFileName(projectDirectory.getName()); MainFrame.getInstance().updateStatusBar(); } } }).start(); MainFrame.this.setTitle("FindBugs: " + dir.getName()); } } else if (value==JFileChooser.CANCEL_OPTION) { return; } else loading = false; }  ArrayList<File> xmlFiles=GUISaveState.getInstance().getRecentProjects();  if (!xmlFiles.contains(xmlFile)) { GUISaveState.getInstance().addRecentProject(xmlFile); MainFrame.this.addRecentProjectToMenu(xmlFile); }    clearBottomTabs();  designationChanged = false; projectChanged = false;
openProject();
			public void actionPerformed(ActionEvent evt){				saveCommentsToBug(currentSelectedBugLeaf);								FBFileChooser jfc=new FBFileChooser();				jfc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);				jfc.setFileFilter(FindBugsProjectFileFilter.INSTANCE);				File xmlFile=null;				if (projectChanged)				{					int response = JOptionPane.showConfirmDialog(MainFrame.this, 							"The current project has been changed, Save current changes?"							,"Save Changes?", JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE);					if (response == JOptionPane.YES_OPTION)					{						if (projectDirectory!=null)							save(projectDirectory);						else							projectSaveAs();					}					else if (response == JOptionPane.CANCEL_OPTION)						return;					//IF no, do nothing.				}								boolean loading = true;				while (loading)				{					int value=jfc.showOpenDialog(MainFrame.this);					if(value==JFileChooser.APPROVE_OPTION){						loading = false;						final File dir = jfc.getSelectedFile();																		if(!dir.exists() || !dir.isDirectory())						{							JOptionPane.showMessageDialog(null, "Warning! This project is not a directory.");							loading = true;							continue;						}						else						{							xmlFile= new File(dir.getAbsolutePath() + File.separator + dir.getName() + ".xml");									File fasFile=new File(dir.getAbsolutePath() + File.separator + dir.getName() + ".fas");							if (!xmlFile.exists())							{								JOptionPane.showMessageDialog(null, "This directory does not contain saved bug XML data, please choose a different directory.");								loading=true;								continue;							}														if (!fasFile.exists())							{								JOptionPane.showMessageDialog(MainFrame.this, "Filter settings not found, using default settings.");								try {									fasFile.createNewFile();									ProjectSettings.newInstance().save(new FileOutputStream(fasFile));								} catch (IOException e) {									if (MainFrame.DEBUG) System.err.println("Error saving new filter settings file, using default settings without saving these settings to the project.");									ProjectSettings.newInstance();								}							} 							else							{								try 								{									ProjectSettings.loadInstance(new FileInputStream(fasFile));								} catch (FileNotFoundException e) 								{									//Impossible.									if (MainFrame.DEBUG) System.err.println(".fas file not found, using default settings");									ProjectSettings.newInstance();								}							}														final File extraFinalReferenceToXmlFile=xmlFile;							new Thread(new Runnable(){								public void run()								{									BugTreeModel model=(BugTreeModel)tree.getModel();//									Debug.println("please wait called by open menu item");									BugTreeModel.pleaseWait();									MainFrame.this.setRebuilding(true);									BugSet bs=BugLoader.loadBugs(extraFinalReferenceToXmlFile);									MainFrame.this.setRebuilding(false);									if (bs!=null)									{										editProjectMenuItem.setEnabled(true);										model.getOffListenerList();										updateDesignation();										model.changeSet(bs);										curProject=BugLoader.getLoadedProject();										projectDirectory=dir;										curProject.setProjectFileName(projectDirectory.getName());										MainFrame.getInstance().updateStatusBar();									}								}							}).start();							MainFrame.this.setTitle("FindBugs: " + dir.getName());						}					}					else if (value==JFileChooser.CANCEL_OPTION)					{						return;					}					else						loading = false;				}//				List<String> projectPaths=new ArrayList<String>();				ArrayList<File> xmlFiles=GUISaveState.getInstance().getRecentProjects();				if (!xmlFiles.contains(xmlFile))				{					GUISaveState.getInstance().addRecentProject(xmlFile);					MainFrame.this.addRecentProjectToMenu(xmlFile);				}								//Clears the bottom tabs so they are blank. And makes comments				//tab not enabled.								clearBottomTabs();				designationChanged = false;				projectChanged = false;			}