try { if (desktop.getSelectedFrame ()==null) {ErrorMsg.reportError ("Error", "Unable to Save Library. Library to save must be focused");
try { if (desktop.getSelectedFrame() == null) { ErrorMsg.reportError("Error", "Unable to Save Library. Library to save must be focused"); } else { if (!file.getName().toUpperCase().endsWith(".PATCHLIB")) file = new File(file.getPath() + ".patchlib"); if (file.isDirectory()) { ErrorMsg.reportError("Error", "Can not Save over a Directory"); return;
    protected void saveFrameAs ()    {        FileDialog fc2=new FileDialog (PatchEdit.this);	fc2.setMode(fc2.SAVE);        FilenameFilter type1 = new ExtensionFilter ("PatchEdit Library Files (*.patchlib)",".patchlib");        fc2.setFilenameFilter (type1);	File file = null;	try {	  try {	    file = ((LibraryFrame)desktop.getSelectedFrame ()).filename;	  } catch (Exception e) {	    file = ((SceneFrame)desktop.getSelectedFrame()).filename;	  }	  fc2.setDirectory(file.getParent());	  fc2.setFile(file.getName());	} catch (Exception e) {	  fc2.setDirectory (appConfig.getLibPath());	  fc2.setFile("Untitled.patchlib");	}	fc2.show();	if (fc2.getFile() == null)	  return;	file = new File(fc2.getDirectory(), fc2.getFile());	try	  {	    if (desktop.getSelectedFrame ()==null)	      {ErrorMsg.reportError ("Error", "Unable to Save Library. Library to save must be focused");	      }	    else	      {		if (!file.getName ().toUpperCase ().endsWith (".PATCHLIB"))		  file=new File (file.getPath ()+".patchlib");		if (file.isDirectory ())		  { ErrorMsg.reportError ("Error", "Can not Save over a Directory");		    return;		  }		if (file.exists ())		  if (JOptionPane.showConfirmDialog (null,"Are you sure?","File Exists",JOptionPane.YES_NO_OPTION) == JOptionPane.NO_OPTION) return;		try {		  ((LibraryFrame)desktop.getSelectedFrame ()).save (file);		} catch (Exception pr)		  {		    ((SceneFrame)desktop.getSelectedFrame()).save(file);		  }	      }	  } catch (Exception ex)	  {ErrorMsg.reportError ("Error", "Unable to Save Library",ex);}                }