public static void saveSourceToFile(File file, String text){
        if(file != null){
            try(PrintWriter printWriter = new PrintWriter(file)){
                printWriter.print(text);
            }catch (FileNotFoundException ex){
                JOptionPane.showMessageDialog(frames.getFrameCreateAlgo(),
                        "Error #998 " + ex.getMessage() , "Save error", JOptionPane.ERROR_MESSAGE);
            }
        }

    }