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); }
JSLFrame oFrame = desktop.getSelectedFrame(); File fn = showSaveDialog(); if (fn == null) return; if (oFrame instanceof LibraryFrame) { saveFrame((LibraryFrame)oFrame, fn); } else if (oFrame instanceof SceneFrame) { saveFrame((SceneFrame)oFrame, fn);
    private void saveFrameAs() {        CompatibleFileDialog fc2 = new CompatibleFileDialog();        FileFilter type1 = new ExtensionFilter("PatchEdit Library Files (*.patchlib)", ".patchlib");        fc2.addChoosableFileFilter(type1);        fc2.setFileFilter(type1);        fc2.setCurrentDirectory(new File (appConfig.getLibPath()));        if (fc2.showSaveDialog(PatchEdit.getInstance()) != JFileChooser.APPROVE_OPTION)            return;        File file = fc2.getSelectedFile();	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);	}    }