no message
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
package _VisualDVM;
|
||||
import Common.Utils.CommonUtils;
|
||||
import Common.Utils.Utils_;
|
||||
import Common.Utils.Index;
|
||||
import Common.Utils.StringTemplate;
|
||||
import Common.Utils.TextLog;
|
||||
import Common.Visual.CommonUI;
|
||||
import Common.Visual.UI_;
|
||||
import _VisualDVM.GlobalData.GlobalDatabase;
|
||||
import Common.Visual.Windows.Dialog.VFileChooser_;
|
||||
import _VisualDVM.GlobalData.Settings.SettingName;
|
||||
@@ -44,7 +44,7 @@ public class Utils {
|
||||
try {
|
||||
FileUtils.forceMkdir(dir);
|
||||
} catch (Exception e) {
|
||||
CommonUtils.MainLog.PrintException(e);
|
||||
Utils_.MainLog.PrintException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -56,14 +56,14 @@ public class Utils {
|
||||
try {
|
||||
forceDeleteWithCheck(f);
|
||||
} catch (Exception e) {
|
||||
CommonUtils.MainLog.PrintException(e);
|
||||
Utils_.MainLog.PrintException(e);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
FileUtils.forceMkdir(dir);
|
||||
} catch (Exception e) {
|
||||
CommonUtils.MainLog.PrintException(e);
|
||||
Utils_.MainLog.PrintException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -71,7 +71,7 @@ public class Utils {
|
||||
try {
|
||||
return new String(Files.readAllBytes(file.toPath()));
|
||||
} catch (Exception e) {
|
||||
CommonUtils.MainLog.PrintException(e);
|
||||
Utils_.MainLog.PrintException(e);
|
||||
}
|
||||
return "";
|
||||
}
|
||||
@@ -83,7 +83,7 @@ public class Utils {
|
||||
try {
|
||||
forceDeleteWithCheck(f);
|
||||
} catch (Exception e) {
|
||||
CommonUtils.MainLog.PrintException(e);
|
||||
Utils_.MainLog.PrintException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -112,7 +112,7 @@ public class Utils {
|
||||
public static File CreateTempResourceFile(String res_name) throws Exception {
|
||||
URL u = (Utils.class.getResource("/files/" + res_name));
|
||||
InputStream i = u.openStream();
|
||||
Path p = Paths.get(Global.TempDirectory.getAbsolutePath(), CommonUtils.getDateName(res_name));
|
||||
Path p = Paths.get(Global.TempDirectory.getAbsolutePath(), Utils_.getDateName(res_name));
|
||||
Files.copy(i, p, StandardCopyOption.REPLACE_EXISTING);
|
||||
return p.toFile();
|
||||
}
|
||||
@@ -133,13 +133,13 @@ public class Utils {
|
||||
return res;
|
||||
}
|
||||
public static File getTempFileName(String name, String ext) {
|
||||
return Paths.get(System.getProperty("user.dir"), "Temp", CommonUtils.getDateName(name) + (ext.isEmpty() ? "" : ("." + ext))).toFile();
|
||||
return Paths.get(System.getProperty("user.dir"), "Temp", Utils_.getDateName(name) + (ext.isEmpty() ? "" : ("." + ext))).toFile();
|
||||
}
|
||||
public static File getTempFileName(String name) {
|
||||
return getTempFileName(name, "");
|
||||
}
|
||||
public static boolean isAnchestor(File child, File anchestor) {
|
||||
return child.getAbsolutePath().startsWith(anchestor.getAbsolutePath() + (CommonUtils.isWindows() ? "\\" : "/"));
|
||||
return child.getAbsolutePath().startsWith(anchestor.getAbsolutePath() + (Utils_.isWindows() ? "\\" : "/"));
|
||||
}
|
||||
//при условии что это точно его предок
|
||||
public static String getRelativeAddress(File file, File anchestor) {
|
||||
@@ -152,12 +152,12 @@ public class Utils {
|
||||
Log.Writeln_("Имя файла не может быть пустым");
|
||||
res = false;
|
||||
}
|
||||
if (CommonUtils.ContainsCyrillic(name)) {
|
||||
if (Utils_.ContainsCyrillic(name)) {
|
||||
Log.Writeln_("Имя файла не может содержать кириллицу");
|
||||
res = false;
|
||||
}
|
||||
if (CommonUtils.ContainsForbiddenName(name)) {
|
||||
Log.Writeln_("Имя файла не может содержать запрещённых символов\n" + CommonUtils.printAllForbiddenCharacters());
|
||||
if (Utils_.ContainsForbiddenName(name)) {
|
||||
Log.Writeln_("Имя файла не может содержать запрещённых символов\n" + Utils_.printAllForbiddenCharacters());
|
||||
res = false;
|
||||
}
|
||||
return res;
|
||||
@@ -166,7 +166,7 @@ public class Utils {
|
||||
//идет по всем уровням файлов
|
||||
public static boolean validateProjectFile(File file, TextLog Log) {
|
||||
String name = file.getName();
|
||||
if (CommonUtils.ContainsCyrillic(name) || CommonUtils.ContainsForbiddenName(name)) {
|
||||
if (Utils_.ContainsCyrillic(name) || Utils_.ContainsForbiddenName(name)) {
|
||||
Log.Writeln_(file.getAbsolutePath());
|
||||
return false;
|
||||
}
|
||||
@@ -189,7 +189,7 @@ public class Utils {
|
||||
validateProjectFolder_r(dir, files_list);
|
||||
if (!files_list.isEmpty())
|
||||
Log.Writeln_("Имена " + filesLines.length + " файлов/подпапок содержат запрещённые символы " +
|
||||
CommonUtils.printAllForbiddenCharacters() +
|
||||
Utils_.printAllForbiddenCharacters() +
|
||||
"или кириллицу");
|
||||
//нужно проверить корень на наличие хоть одной программы.
|
||||
return Log.isEmpty();
|
||||
@@ -206,11 +206,11 @@ public class Utils {
|
||||
} else return;
|
||||
if (file.exists()) {
|
||||
attempts++;
|
||||
System.out.println("файл " + CommonUtils.Brackets(file.getAbsolutePath()) + " занят");
|
||||
System.out.println("файл " + Utils_.Brackets(file.getAbsolutePath()) + " занят");
|
||||
Thread.sleep(2000);
|
||||
} else return;
|
||||
}
|
||||
throw new PassException("Не удалось удалить файл " + CommonUtils.Brackets(file.getAbsolutePath()) + " за " + attempts + " попыток");
|
||||
throw new PassException("Не удалось удалить файл " + Utils_.Brackets(file.getAbsolutePath()) + " за " + attempts + " попыток");
|
||||
}
|
||||
public static void GetVertices(float R, float r, float x0, float y0, int n, float phi) {
|
||||
boolean inner = false;
|
||||
@@ -233,7 +233,7 @@ public class Utils {
|
||||
} catch (Exception e) {
|
||||
// тут можно обработать ошибку
|
||||
// возникает она если в передаваемый алгоритм в getInstance(,,,) не существует
|
||||
CommonUtils.MainLog.PrintException(e);
|
||||
Utils_.MainLog.PrintException(e);
|
||||
}
|
||||
BigInteger bigInt = new BigInteger(1, digest);
|
||||
String md5Hex = bigInt.toString(16);
|
||||
@@ -264,11 +264,11 @@ public class Utils {
|
||||
} else return;
|
||||
if (file.exists()) {
|
||||
attempts++;
|
||||
CommonUtils.MainLog.Print("неудачная попытка удаления: файл " + CommonUtils.Brackets(file.getAbsolutePath()) + " занят");
|
||||
Utils_.MainLog.Print("неудачная попытка удаления: файл " + Utils_.Brackets(file.getAbsolutePath()) + " занят");
|
||||
Thread.sleep(2000);
|
||||
} else return;
|
||||
}
|
||||
throw new PassException("Не удалось удалить файл " + CommonUtils.Brackets(file.getAbsolutePath()) + " за " + attempts + " попыток");
|
||||
throw new PassException("Не удалось удалить файл " + Utils_.Brackets(file.getAbsolutePath()) + " за " + attempts + " попыток");
|
||||
}
|
||||
public static Socket createClientSocket(InetAddress address, int port, int timeout) throws Exception {
|
||||
Socket socket = new Socket();
|
||||
@@ -286,7 +286,7 @@ public class Utils {
|
||||
if (files != null) {
|
||||
for (File file : files) {
|
||||
if (file.isFile()) {
|
||||
String file_extension = CommonUtils.getExtension(file);
|
||||
String file_extension = Utils_.getExtension(file);
|
||||
for (String ext : extensions) {
|
||||
if (file_extension.equalsIgnoreCase(ext)) {
|
||||
res.add(file);
|
||||
@@ -326,8 +326,8 @@ public class Utils {
|
||||
}
|
||||
public static File createScript(File scriptDirectory, File targetDirectory, String name, String scriptText) throws Exception {
|
||||
//->
|
||||
File scriptFile = Paths.get(scriptDirectory.getAbsolutePath(), name + (CommonUtils.isWindows() ? ".bat" : "")).toFile();
|
||||
FileUtils.write(scriptFile, "cd " + CommonUtils.DQuotes(targetDirectory.getAbsolutePath()) + "\n" + scriptText);
|
||||
File scriptFile = Paths.get(scriptDirectory.getAbsolutePath(), name + (Utils_.isWindows() ? ".bat" : "")).toFile();
|
||||
FileUtils.write(scriptFile, "cd " + Utils_.DQuotes(targetDirectory.getAbsolutePath()) + "\n" + scriptText);
|
||||
if (!scriptFile.setExecutable(true)) throw new PassException("Не удалось создать исполняемый файл для скрипта");
|
||||
return scriptFile;
|
||||
}
|
||||
@@ -428,7 +428,7 @@ public class Utils {
|
||||
try {
|
||||
for (String line : FileUtils.readLines(test, Charset.defaultCharset())) {
|
||||
// #pragma dvm array distribute[block][block], не важно
|
||||
String packedLine = CommonUtils.removeCharacters(CommonUtils.removeRedundantSpaces(line).toLowerCase(), "\n", "\r", "\t");
|
||||
String packedLine = Utils_.removeCharacters(Utils_.removeRedundantSpaces(line).toLowerCase(), "\n", "\r", "\t");
|
||||
if (packedLine.startsWith(prefix)) {
|
||||
packedLine = packedLine.substring(prefix.length());
|
||||
boolean bracketOpen = false;
|
||||
@@ -501,7 +501,7 @@ public class Utils {
|
||||
}
|
||||
protected static boolean isSource(File file) {
|
||||
if (file.isFile()) {
|
||||
String extension = CommonUtils.getExtension(file).toLowerCase();
|
||||
String extension = Utils_.getExtension(file).toLowerCase();
|
||||
switch (extension) {
|
||||
case "f":
|
||||
case "fdv":
|
||||
@@ -533,7 +533,7 @@ public class Utils {
|
||||
}
|
||||
}
|
||||
if (sources.isEmpty()) {
|
||||
if (question) return CommonUI.Question("Папка " + CommonUtils.Brackets(folder.getName()) + "\n" +
|
||||
if (question) return UI_.Question("Папка " + Utils_.Brackets(folder.getName()) + "\n" +
|
||||
"не содержит ни одного файла, распознанного как поддерживаемый код\n" +
|
||||
"Всё равно открыть её как проект");
|
||||
else return false;
|
||||
@@ -542,8 +542,8 @@ public class Utils {
|
||||
public static void Kill(String PID, boolean force) {
|
||||
if (!PID.isEmpty()) {
|
||||
String killCommand =
|
||||
force ? CommonUtils.isWindows() ? "taskkill /PID " + CommonUtils.DQuotes(PID) + " /F /T" : "kill -9 " + CommonUtils.DQuotes(PID) :
|
||||
CommonUtils.isWindows() ? "taskkill /PID " + CommonUtils.DQuotes(PID) : "kill -2 " + CommonUtils.DQuotes(PID);
|
||||
force ? Utils_.isWindows() ? "taskkill /PID " + Utils_.DQuotes(PID) + " /F /T" : "kill -9 " + Utils_.DQuotes(PID) :
|
||||
Utils_.isWindows() ? "taskkill /PID " + Utils_.DQuotes(PID) : "kill -2 " + Utils_.DQuotes(PID);
|
||||
System.out.println(killCommand);
|
||||
try {
|
||||
Process killer = Utils.startScript(Global.TempDirectory, Global.TempDirectory, "killer", killCommand);
|
||||
@@ -558,12 +558,12 @@ public class Utils {
|
||||
if (name.isEmpty())
|
||||
return false;
|
||||
char[] letters = name.toCharArray();
|
||||
if (!(CommonUtils.isEnglishLetter(letters[0]) || letters[0] == '_')) {
|
||||
if (!(Utils_.isEnglishLetter(letters[0]) || letters[0] == '_')) {
|
||||
return false;
|
||||
}
|
||||
//---
|
||||
for (int i = 1; i < letters.length; ++i) {
|
||||
if (!(CommonUtils.isEnglishLetter(letters[i]) || letters[i] == '_' || CommonUtils.isIntegerValue(String.valueOf(letters[i])))) {
|
||||
if (!(Utils_.isEnglishLetter(letters[i]) || letters[i] == '_' || Utils_.isIntegerValue(String.valueOf(letters[i])))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -659,13 +659,13 @@ public class Utils {
|
||||
try {
|
||||
if (p != null) res = Double.parseDouble(p);
|
||||
} catch (Exception ex) {
|
||||
CommonUtils.MainLog.PrintException(ex);
|
||||
Utils_.MainLog.PrintException(ex);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
public static void RestoreSelectedDirectory(VFileChooser_ directoryChooser) {
|
||||
String last_dir_home =
|
||||
((GlobalDatabase)CommonUtils.db).settings.get(SettingName.ProjectsSearchDirectory).Value;
|
||||
((GlobalDatabase) Utils_.db).settings.get(SettingName.ProjectsSearchDirectory).Value;
|
||||
if (!last_dir_home.isEmpty())
|
||||
directoryChooser.SetCurrentDirectory(last_dir_home);
|
||||
}
|
||||
@@ -682,7 +682,7 @@ public class Utils {
|
||||
public static boolean checkFileCreation(File file) {
|
||||
for (int i = 1; i <= 10; ++i) {
|
||||
if (file.exists()) return true;
|
||||
else CommonUtils.sleep(1000);
|
||||
else Utils_.sleep(1000);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -713,11 +713,11 @@ public class Utils {
|
||||
break;
|
||||
case ' ':
|
||||
case '\t':
|
||||
if (((GlobalDatabase)CommonUtils.db).settings.get(SettingName.SpacesOn).toBoolean()) line.append(c);
|
||||
if (((GlobalDatabase) Utils_.db).settings.get(SettingName.SpacesOn).toBoolean()) line.append(c);
|
||||
v_line.append(c);
|
||||
break;
|
||||
case '\n': //конец строки
|
||||
if (((GlobalDatabase)CommonUtils.db).settings.get(SettingName.FortranWrapsOn).toBoolean()) {
|
||||
if (((GlobalDatabase) Utils_.db).settings.get(SettingName.FortranWrapsOn).toBoolean()) {
|
||||
//оракул. лезем в начало следующей строки
|
||||
//и анализируем первые 5 символов
|
||||
boolean hasWrap = false;
|
||||
@@ -743,7 +743,7 @@ public class Utils {
|
||||
break;
|
||||
}
|
||||
//добавление строки в результат.
|
||||
if ((line.length() > 0) || ((GlobalDatabase)CommonUtils.db).settings.get(SettingName.EmptyLinesOn).toBoolean()
|
||||
if ((line.length() > 0) || ((GlobalDatabase) Utils_.db).settings.get(SettingName.EmptyLinesOn).toBoolean()
|
||||
// Global.db.settings.get(SettingName.SpacesOn).toBoolean()
|
||||
) {
|
||||
lines.add(line.toString());
|
||||
@@ -762,7 +762,7 @@ public class Utils {
|
||||
if ((i > 0) && (c != '\n')) {
|
||||
//строка оборвалась на EOF
|
||||
//добавление строки в результат.
|
||||
if ((line.length() > 0) ||((GlobalDatabase)CommonUtils.db).settings.get(SettingName.EmptyLinesOn).toBoolean()
|
||||
if ((line.length() > 0) ||((GlobalDatabase) Utils_.db).settings.get(SettingName.EmptyLinesOn).toBoolean()
|
||||
// && Global.db.settings.get(SettingName.SpacesOn).toBoolean()
|
||||
) {
|
||||
lines.add(line.toString());
|
||||
@@ -774,13 +774,13 @@ public class Utils {
|
||||
public static boolean CompareLines(String line1_raw, String line2_raw) {
|
||||
String line1 = line1_raw;
|
||||
String line2 = line2_raw;
|
||||
if (!((GlobalDatabase)CommonUtils.db).settings.get(SettingName.RegisterOn).toBoolean()) {
|
||||
if (!((GlobalDatabase) Utils_.db).settings.get(SettingName.RegisterOn).toBoolean()) {
|
||||
line1 = line1.toUpperCase();
|
||||
line2 = line2.toUpperCase();
|
||||
}
|
||||
if (!((GlobalDatabase)CommonUtils.db).settings.get(SettingName.SpacesOn).toBoolean()) {
|
||||
line1 = CommonUtils.removeCharacters(line1, " ", "\t");
|
||||
line2 = CommonUtils.removeCharacters(line2, " ", "\t");
|
||||
if (!((GlobalDatabase) Utils_.db).settings.get(SettingName.SpacesOn).toBoolean()) {
|
||||
line1 = Utils_.removeCharacters(line1, " ", "\t");
|
||||
line2 = Utils_.removeCharacters(line2, " ", "\t");
|
||||
}
|
||||
return line1.equals(line2);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user