no message
This commit is contained in:
@@ -5,7 +5,6 @@ import Visual_DVM_2021.Passes.PassCode_2021;
|
||||
import java.util.Vector;
|
||||
import java.util.regex.Pattern;
|
||||
public class Constants {
|
||||
public static final int Nan = -1;
|
||||
public static final int planner_version = 3;
|
||||
//--
|
||||
public static final String ComponentsDirectoryName = "Components";
|
||||
@@ -52,15 +51,6 @@ public class Constants {
|
||||
public static final String package_json = "package_json";
|
||||
public static final String results_json = "results_json";
|
||||
//--
|
||||
public static final PassCode_2021[] startingSapforTestingCodes_old = new PassCode_2021[]{
|
||||
PassCode_2021.SPF_InsertIncludesPass
|
||||
};
|
||||
public static final PassCode_2021[] terminalSapforTestingCodes_old = new PassCode_2021[]{
|
||||
PassCode_2021.CreateParallelVariants,
|
||||
PassCode_2021.SPF_SharedMemoryParallelization,
|
||||
PassCode_2021.SPF_InsertDvmhRegions
|
||||
};
|
||||
//--
|
||||
public static final Vector<PassCode_2021> startSapforCodes =
|
||||
new Vector_<>(PassCode_2021.SPF_InsertIncludesPass);
|
||||
|
||||
@@ -486,9 +476,6 @@ public class Constants {
|
||||
'`', '|', '=', '#', ':', '/', '\\',
|
||||
'~', '^'
|
||||
};
|
||||
public static char[] regular_metasymbols = new char[]{
|
||||
'<', '>', '(', ')', '[', ']', '{', '}', '^', '-', '=', '$', '!', '|', '?', '*', '+', '.'
|
||||
};
|
||||
//все запретные символы через пробел.
|
||||
public static String all_forbidden_characters_string = "";
|
||||
public static Vector<String> admins_mails = new Vector_<>(
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
package Common_old.UI;
|
||||
import Common_old.Constants;
|
||||
import Common.CommonConstants;
|
||||
import Common_old.Current;
|
||||
import Common.Database.Objects.DBObject;
|
||||
import Common.Database.Tables.DBTable;
|
||||
@@ -207,7 +207,7 @@ public class DataSetControlForm extends ControlWithCurrentForm<DataTable> {
|
||||
}
|
||||
};
|
||||
if (CurrentName() != Current.Undefined) {
|
||||
current_row_i = Constants.Nan;
|
||||
current_row_i = CommonConstants.Nan;
|
||||
ListSelectionModel selModel = control.getSelectionModel();
|
||||
selModel.addListSelectionListener(e -> {
|
||||
int row = control.getSelectedRow();
|
||||
@@ -224,7 +224,7 @@ public class DataSetControlForm extends ControlWithCurrentForm<DataTable> {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
current_row_i = Constants.Nan;
|
||||
current_row_i = CommonConstants.Nan;
|
||||
getDataSource().dropCurrent();
|
||||
if (events_on) {
|
||||
try {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
package Common_old.UI.Menus;
|
||||
import Common.Utils.CommonUtils;
|
||||
import Common_old.Current;
|
||||
import _VisualDVM.Global;
|
||||
import Common_old.UI.Editor.CaretInfo;
|
||||
@@ -218,9 +219,9 @@ public class MainEditorMenu extends TextEditorMenu {
|
||||
if (!Utils.isFunctionName(selectedText)) {
|
||||
String tip = "Имя процедуры может содержать только английские буквы, цифры и подчеркивания, и не может начинаться с цифры.";
|
||||
//-
|
||||
m_inline.setText("Невозможно подставить вызов процедуры " + Utils.Brackets(selectedText) +
|
||||
m_inline.setText("Невозможно подставить вызов процедуры " + CommonUtils.Brackets(selectedText) +
|
||||
" . Выделено некорректное имя.");
|
||||
m_gotoFunction.setText("Невозможно перейти к объявлению процедуры " + Utils.Brackets(selectedText) +
|
||||
m_gotoFunction.setText("Невозможно перейти к объявлению процедуры " + CommonUtils.Brackets(selectedText) +
|
||||
" . Выделено некорректное имя.");
|
||||
//-
|
||||
m_inline.setToolTipText(tip);
|
||||
@@ -228,40 +229,40 @@ public class MainEditorMenu extends TextEditorMenu {
|
||||
return;
|
||||
}
|
||||
if (!Pass_2021.passes.get(PassCode_2021.SPF_GetGraphFunctions).isDone()) {
|
||||
m_inline.setText("Невозможно подставить вызов процедуры " + Utils.Brackets(selectedText) +
|
||||
m_inline.setText("Невозможно подставить вызов процедуры " + CommonUtils.Brackets(selectedText) +
|
||||
" . Выполните проход \"Граф процедур \".");
|
||||
m_gotoFunction.setText("Невозможно перейти к объявлению процедуры " + Utils.Brackets(selectedText) +
|
||||
m_gotoFunction.setText("Невозможно перейти к объявлению процедуры " + CommonUtils.Brackets(selectedText) +
|
||||
" . Выполните проход \"Граф процедур \"");
|
||||
return;
|
||||
}
|
||||
if (Current.getSapfor().isIntrinsic(selectedText)) {
|
||||
m_inline.setText("Невозможно подставить вызов процедуры " + Utils.Brackets(selectedText) +
|
||||
m_inline.setText("Невозможно подставить вызов процедуры " + CommonUtils.Brackets(selectedText) +
|
||||
" . Процедура является стандартной.");
|
||||
m_gotoFunction.setText("Невозможно перейти к объявлению процедуры " + Utils.Brackets(selectedText) +
|
||||
m_gotoFunction.setText("Невозможно перейти к объявлению процедуры " + CommonUtils.Brackets(selectedText) +
|
||||
" . Процедура является стандартной.");
|
||||
return;
|
||||
}
|
||||
call = Current.getFile().find_func_call(selectedText);
|
||||
if (call == null) {
|
||||
m_inline.setText("Невозможно подставить вызов процедуры " + Utils.Brackets(selectedText) +
|
||||
m_inline.setText("Невозможно подставить вызов процедуры " + CommonUtils.Brackets(selectedText) +
|
||||
" . Вызов не найден в текущей строке.");
|
||||
m_gotoFunction.setText("Невозможно перейти к объявлению процедуры " + Utils.Brackets(selectedText) +
|
||||
m_gotoFunction.setText("Невозможно перейти к объявлению процедуры " + CommonUtils.Brackets(selectedText) +
|
||||
" . Объявление процедуры уже находится в текущей строке.");
|
||||
return;
|
||||
}
|
||||
decl = Current.getProject().allFunctions.get(call.funcName);
|
||||
if (decl.type.equals(FunctionType.NotFound)) {
|
||||
m_inline.setText("Невозможно подставить вызов процедуры " + Utils.Brackets(selectedText) +
|
||||
m_inline.setText("Невозможно подставить вызов процедуры " + CommonUtils.Brackets(selectedText) +
|
||||
" . Объявление процедуры не найдено в проекте.");
|
||||
m_gotoFunction.setText("Невозможно перейти к объявлению процедуры " + Utils.Brackets(selectedText) +
|
||||
m_gotoFunction.setText("Невозможно перейти к объявлению процедуры " + CommonUtils.Brackets(selectedText) +
|
||||
" . Объявление процедуры не найдено в проекте.");
|
||||
return;
|
||||
}
|
||||
//---
|
||||
m_inline.setEnabled(true);
|
||||
m_gotoFunction.setEnabled(true);
|
||||
m_inline.setText("Подставить вызов процедуры " + Utils.Brackets(selectedText));
|
||||
m_gotoFunction.setText("Перейти к объявлению процедуры " + Utils.Brackets(selectedText));
|
||||
m_inline.setText("Подставить вызов процедуры " + CommonUtils.Brackets(selectedText));
|
||||
m_gotoFunction.setText("Перейти к объявлению процедуры " + CommonUtils.Brackets(selectedText));
|
||||
//--
|
||||
}
|
||||
private void checkHeader() {
|
||||
@@ -280,11 +281,11 @@ public class MainEditorMenu extends TextEditorMenu {
|
||||
return;
|
||||
}
|
||||
if (!Current.getFile().relativeHeaders.containsKey(header_)) {
|
||||
m_gotoHeader.setText("Невозможно перейти к заголовочному файлу " + Utils.Brackets(header_) + " . Файл не найден среди включений текущего файла.");
|
||||
m_gotoHeader.setText("Невозможно перейти к заголовочному файлу " + CommonUtils.Brackets(header_) + " . Файл не найден среди включений текущего файла.");
|
||||
return;
|
||||
}
|
||||
header = Current.getFile().relativeHeaders.get(header_);
|
||||
m_gotoHeader.setText("Переход к заголовочному файлу " + Utils.Brackets(header_));
|
||||
m_gotoHeader.setText("Переход к заголовочному файлу " + CommonUtils.Brackets(header_));
|
||||
m_gotoHeader.setEnabled(true);
|
||||
}
|
||||
}
|
||||
@@ -302,7 +303,7 @@ public class MainEditorMenu extends TextEditorMenu {
|
||||
return;
|
||||
}
|
||||
m_loop_union.setEnabled(true);
|
||||
m_loop_union.setText("Объединить цикл в строке " + Utils.Brackets(loop.line) + " со следующим");
|
||||
m_loop_union.setText("Объединить цикл в строке " + CommonUtils.Brackets(loop.line) + " со следующим");
|
||||
}
|
||||
@Override
|
||||
public void CheckElementsVisibility() {
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
package Common_old.UI.Menus;
|
||||
import Common.Utils.CommonUtils;
|
||||
import Common_old.Current;
|
||||
import Common_old.UI.Menus_2023.StableMenuItem;
|
||||
import Common_old.UI.Selectable;
|
||||
import Common_old.UI.Trees.DataTree;
|
||||
import Common_old.UI.Trees.SelectableTree;
|
||||
import Common_old.Utils.Utils;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
@@ -72,9 +72,9 @@ public abstract class SelectionTreeMenu extends GraphMenu<DataTree> {
|
||||
if ((current != null) && (current.getClass().equals(getTargetClass()))) {
|
||||
String name = ((Selectable) current).getSelectionText();
|
||||
m_select_for_current.setText("Выбрать всё для " +
|
||||
Utils.Brackets(name));
|
||||
CommonUtils.Brackets(name));
|
||||
m_unselect_for_current.setText("Отменить выбор всех для " +
|
||||
Utils.Brackets(name));
|
||||
CommonUtils.Brackets(name));
|
||||
//-
|
||||
m_select_for_current.setVisible(true);
|
||||
m_unselect_for_current.setVisible(true);
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
package Common_old.UI.Menus;
|
||||
import Common_old.Constants;
|
||||
import Common.CommonConstants;
|
||||
import Common_old.Utils.Utils;
|
||||
|
||||
import javax.swing.*;
|
||||
public class TableMenu extends StyledPopupMenu {
|
||||
int row = Constants.Nan;
|
||||
int column = Constants.Nan;
|
||||
int row = CommonConstants.Nan;
|
||||
int column = CommonConstants.Nan;
|
||||
Object target = null;
|
||||
//-
|
||||
JTable owner = null;
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
package Common_old.UI.Tables;
|
||||
import Common_old.Constants;
|
||||
import Common.CommonConstants;
|
||||
public class ColumnInfo {
|
||||
private String Name = "?";
|
||||
private boolean visible = true;
|
||||
private boolean editable = false;
|
||||
private TableRenderers renderer = TableRenderers.RendererDefault;
|
||||
private TableEditors editor = TableEditors.EditorDefault;
|
||||
private int maxWidth = Constants.Nan;
|
||||
private int minWidth = Constants.Nan;
|
||||
private int maxWidth = CommonConstants.Nan;
|
||||
private int minWidth = CommonConstants.Nan;
|
||||
//private int lastWidth = Utils.Nan;
|
||||
// public void setLastWidth(int width_in) {
|
||||
// lastWidth = width_in;
|
||||
@@ -72,7 +72,7 @@ public class ColumnInfo {
|
||||
this.maxWidth = maxWidth_in;
|
||||
}
|
||||
public boolean hasMaxWidth() {
|
||||
return maxWidth != Constants.Nan;
|
||||
return maxWidth != CommonConstants.Nan;
|
||||
}
|
||||
//-
|
||||
public int getMinWidth() {
|
||||
@@ -82,7 +82,7 @@ public class ColumnInfo {
|
||||
this.minWidth = minWidth_in;
|
||||
}
|
||||
public boolean hasMinWidth() {
|
||||
return minWidth != Constants.Nan;
|
||||
return minWidth != CommonConstants.Nan;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
package Common_old.UI;
|
||||
import Common_old.Utils.Utils;
|
||||
import Common.Utils.CommonUtils;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.util.Vector;
|
||||
@@ -12,7 +12,7 @@ public class VisualiserStringList extends JList<String> {
|
||||
public void fill(Vector<String> content) {
|
||||
elements = new DefaultListModel<>();
|
||||
for (String s : content)
|
||||
elements.addElement(Utils.Brackets(s));
|
||||
elements.addElement(CommonUtils.Brackets(s));
|
||||
setModel(elements);
|
||||
}
|
||||
public String pack() {
|
||||
@@ -25,7 +25,7 @@ public class VisualiserStringList extends JList<String> {
|
||||
return res;
|
||||
}
|
||||
public void addElement(String element) {
|
||||
String element_ = Utils.Brackets(element);
|
||||
String element_ = CommonUtils.Brackets(element);
|
||||
if (!elements.contains(element_))
|
||||
elements.addElement(element_);
|
||||
else UI.Info("элемент " + element_ + " уже существует.");
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
package Common_old.UI.Windows;
|
||||
import Common.Utils.CommonUtils;
|
||||
import Common_old.Current;
|
||||
import Common_old.UI.TextField.StyledTextField;
|
||||
import Common_old.UI.Trees.StyledTree;
|
||||
import Common_old.UI.UI;
|
||||
import Common_old.Utils.Utils;
|
||||
import Visual_DVM_2021.Passes.PassCode_2021;
|
||||
import Visual_DVM_2021.Passes.Pass_2021;
|
||||
import javafx.util.Pair;
|
||||
@@ -100,8 +100,8 @@ public class SearchReplaceForm extends Form {
|
||||
}
|
||||
}
|
||||
public void applyParams() {
|
||||
String toFind = Utils.hideRegularMetasymbols(tfFind.getText());
|
||||
String toReplace = Utils.hideRegularMetasymbols(tfReplace.getText());
|
||||
String toFind = CommonUtils.hideRegularMetasymbols(tfFind.getText());
|
||||
String toReplace = CommonUtils.hideRegularMetasymbols(tfReplace.getText());
|
||||
context.setSearchFor(toFind);
|
||||
context.setMatchCase(registerOn.isSelected());
|
||||
context.setWholeWord(wholeWordOn.isSelected());
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package Common_old.Utils.Files;
|
||||
import Common.Utils.CommonUtils;
|
||||
import Common_old.Constants;
|
||||
import Common_old.Utils.Utils;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.filechooser.FileFilter;
|
||||
@@ -11,7 +11,7 @@ public class ProjectsChooser extends VFileChooser_ {
|
||||
@Override
|
||||
public boolean accept(File f) {
|
||||
return
|
||||
!Utils.ContainsCyrillic(f.getAbsolutePath()) &&
|
||||
!CommonUtils.ContainsCyrillic(f.getAbsolutePath()) &&
|
||||
!f.getName().equalsIgnoreCase(Constants.data)
|
||||
;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
package Common_old.Utils.Files;
|
||||
import Common_old.Utils.Utils;
|
||||
import Common.Utils.CommonUtils;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.filechooser.FileFilter;
|
||||
@@ -9,7 +9,7 @@ public class VDirectoryChooser extends VFileChooser_ {
|
||||
super(title, new FileFilter() {
|
||||
@Override
|
||||
public boolean accept(File f) {
|
||||
return !Utils.ContainsCyrillic(f.getAbsolutePath());
|
||||
return !CommonUtils.ContainsCyrillic(f.getAbsolutePath());
|
||||
}
|
||||
@Override
|
||||
public String getDescription() {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
package Common_old.Utils.Files;
|
||||
import Common_old.Utils.Utils;
|
||||
import Common.Utils.CommonUtils;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.filechooser.FileFilter;
|
||||
@@ -20,7 +20,7 @@ public class VFileChooser extends VFileChooser_ {
|
||||
fileChooser.setFileFilter(new FileFilter() {
|
||||
@Override
|
||||
public boolean accept(File f) {
|
||||
return !Utils.ContainsCyrillic(f.getName())
|
||||
return !CommonUtils.ContainsCyrillic(f.getName())
|
||||
&& (f.isDirectory() || acceptExtensions(f));
|
||||
}
|
||||
@Override
|
||||
@@ -36,7 +36,7 @@ public class VFileChooser extends VFileChooser_ {
|
||||
}
|
||||
public boolean acceptExtensions(File file) {
|
||||
if (Extensions.isEmpty()) return true;
|
||||
String file_ext = Utils.getExtension(file);
|
||||
String file_ext = CommonUtils.getExtension(file);
|
||||
for (String ext : Extensions)
|
||||
if (ext.equalsIgnoreCase(file_ext)) return true;
|
||||
return false;
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
package Common_old.Utils;
|
||||
import Common.CommonConstants;
|
||||
import Common.Utils.CommonUtils;
|
||||
import Common.Utils.Index;
|
||||
import Common.Utils.StringTemplate;
|
||||
import Common.Utils.TextLog;
|
||||
@@ -38,13 +40,6 @@ import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.IntStream;
|
||||
public class Utils {
|
||||
//--->>
|
||||
public static String hideRegularMetasymbols(String word) {
|
||||
String res = word.replace("\\", "\\\\");
|
||||
for (char c : Constants.regular_metasymbols)
|
||||
res = res.replace(String.valueOf(c), "\\" + c);
|
||||
return res;
|
||||
}
|
||||
public static boolean isLinuxSystemCommand(String text) {
|
||||
for (String command : Constants.linux_system_commands) {
|
||||
if (text.equalsIgnoreCase(command)) return true;
|
||||
@@ -72,48 +67,9 @@ public class Utils {
|
||||
for (char f : Constants.forbidden_file_name_characters)
|
||||
Constants.all_forbidden_characters_string += f + " ";
|
||||
}
|
||||
public static String DQuotes(Object o) {
|
||||
return "\"" + o.toString() + "\"";
|
||||
}
|
||||
public static String Quotes(Object o) {
|
||||
return "'" + o.toString() + "'";
|
||||
}
|
||||
public static String Brackets(Object o) {
|
||||
return "[" + o.toString() + "]";
|
||||
}
|
||||
public static String Bold(Object o) {
|
||||
return "<b>" + o.toString() + "</b>";
|
||||
}
|
||||
public static String RBrackets(Object o) {
|
||||
return "(" + o.toString() + ")";
|
||||
}
|
||||
public static String MFVar(Object o) {
|
||||
return "$(" + o.toString() + ")";
|
||||
}
|
||||
public static String TBrackets(Object o) {
|
||||
return "<" + o.toString() + ">";
|
||||
}
|
||||
public static String getExtension(File file) {
|
||||
String fn = file.getName();
|
||||
int di = fn.lastIndexOf(".");
|
||||
return (di >= 0) ? fn.substring(di + 1).toLowerCase() : "";
|
||||
}
|
||||
public static String getExtensionByName(String fn) {
|
||||
;
|
||||
int di = fn.lastIndexOf(".");
|
||||
return (di >= 0) ? fn.substring(di + 1).toLowerCase() : "";
|
||||
}
|
||||
public static String getFileNameWithoutExtension(File file) {
|
||||
return getNameWithoutExtension(file.getName());
|
||||
}
|
||||
public static String getNameWithoutExtension(String fn) {
|
||||
return (fn.contains(".")) ? fn.substring(0, fn.lastIndexOf(".")).toLowerCase() : fn.toLowerCase();
|
||||
}
|
||||
public static boolean ContainsCyrillic(String string) {
|
||||
return string.chars()
|
||||
.mapToObj(Character.UnicodeBlock::of)
|
||||
.anyMatch(b -> b.equals(Character.UnicodeBlock.CYRILLIC));
|
||||
}
|
||||
public static void CheckDirectory(File dir) {
|
||||
if (!dir.exists()) {
|
||||
try {
|
||||
@@ -145,8 +101,6 @@ public class Utils {
|
||||
public static Object requireNonNullElse(Object value, Object default_value) {
|
||||
return (value != null) ? value : default_value;
|
||||
}
|
||||
//https://javadevblog.com/kak-schitat-fajl-v-string-primer-chteniya-fajla-na-java.html
|
||||
//https://habr.com/ru/post/269667/
|
||||
public static String ReadAllText(File file) {
|
||||
try {
|
||||
return new String(Files.readAllBytes(file.toPath()));
|
||||
@@ -155,16 +109,6 @@ public class Utils {
|
||||
}
|
||||
return "";
|
||||
}
|
||||
public static String toU(String path) {
|
||||
return path.replace('\\', '/');
|
||||
}
|
||||
public static String toW(String path) {
|
||||
return path.replace('/', '\\');
|
||||
}
|
||||
public static double getFileSizeMegaBytes(File file) {
|
||||
double res = file.length() / (1024 * 1024);
|
||||
return res;
|
||||
}
|
||||
public static void CleanDirectory(File dir) {
|
||||
if (dir.exists() && dir.isDirectory()) {
|
||||
File[] files = dir.listFiles();
|
||||
@@ -179,7 +123,7 @@ public class Utils {
|
||||
}
|
||||
}
|
||||
}
|
||||
public static long last_ticks = Constants.Nan;
|
||||
public static long last_ticks = CommonConstants.Nan;
|
||||
public static void sleep(long millis) {
|
||||
try {
|
||||
Thread.sleep(millis);
|
||||
@@ -213,187 +157,6 @@ public class Utils {
|
||||
StandardOpenOption.CREATE,
|
||||
StandardOpenOption.TRUNCATE_EXISTING);
|
||||
}
|
||||
public static boolean isDigit(String s) {
|
||||
try {
|
||||
Integer.parseInt(s);
|
||||
return true;
|
||||
} catch (NumberFormatException e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
public static boolean isEnglishLetter(char c) {
|
||||
return (((c >= 'a') && (c <= 'z')) || ((c >= 'A') && (c <= 'Z')));
|
||||
}
|
||||
public static boolean isRussianLetter(char c) {
|
||||
return ((c >= 'а') && (c <= 'я'))
|
||||
|| ((c >= 'А') && (c <= 'Я'))
|
||||
|| (c == 'Ё')
|
||||
|| (c == 'ё');
|
||||
}
|
||||
public static boolean isSign(char c) {
|
||||
switch (c) {
|
||||
//арифметика.
|
||||
case '+':
|
||||
case '-':
|
||||
case '*':
|
||||
case '/':
|
||||
case '<':
|
||||
case '>':
|
||||
case '&':
|
||||
case '=':
|
||||
case '%':
|
||||
case '^':
|
||||
//- обр слеш
|
||||
case '\\':
|
||||
//препинание
|
||||
case ' ':
|
||||
case '_':
|
||||
case '.':
|
||||
case ',':
|
||||
case '!':
|
||||
case '?':
|
||||
case ';':
|
||||
case ':':
|
||||
//escape последовательности
|
||||
case '\t':
|
||||
case '\n':
|
||||
case '\r':
|
||||
//кавычки
|
||||
case '\'':
|
||||
case '"':
|
||||
//- скобки
|
||||
case '(':
|
||||
case ')':
|
||||
case '[':
|
||||
case ']':
|
||||
case '{':
|
||||
case '}':
|
||||
//прочее
|
||||
case '~':
|
||||
case '`':
|
||||
case '|':
|
||||
case '@':
|
||||
case '$':
|
||||
case '#':
|
||||
case '№':
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public static char Translit(char c) {
|
||||
switch (c) {
|
||||
case 'А':
|
||||
case 'а':
|
||||
case 'Я':
|
||||
case 'я':
|
||||
return 'A';
|
||||
//
|
||||
case 'Б':
|
||||
case 'б':
|
||||
return 'B';
|
||||
//-
|
||||
case 'В':
|
||||
case 'в':
|
||||
return 'V';
|
||||
//
|
||||
case 'Г':
|
||||
case 'г':
|
||||
return 'G';
|
||||
//
|
||||
case 'Д':
|
||||
case 'д':
|
||||
return 'D';
|
||||
//
|
||||
case 'Е':
|
||||
case 'е':
|
||||
case 'Ё':
|
||||
case 'ё':
|
||||
case 'Э':
|
||||
case 'э':
|
||||
return 'E';
|
||||
//
|
||||
case 'Ж':
|
||||
case 'ж':
|
||||
return 'J';
|
||||
//
|
||||
case 'З':
|
||||
case 'з':
|
||||
return 'Z';
|
||||
//
|
||||
case 'И':
|
||||
case 'и':
|
||||
case 'Й':
|
||||
case 'й':
|
||||
return 'I';
|
||||
//
|
||||
case 'К':
|
||||
case 'к':
|
||||
return 'K';
|
||||
//
|
||||
case 'Л':
|
||||
case 'л':
|
||||
return 'L';
|
||||
//
|
||||
case 'М':
|
||||
case 'м':
|
||||
return 'M';
|
||||
//
|
||||
case 'Н':
|
||||
case 'н':
|
||||
return 'N';
|
||||
//
|
||||
case 'О':
|
||||
case 'о':
|
||||
return 'O';
|
||||
//
|
||||
case 'П':
|
||||
case 'п':
|
||||
return 'P';
|
||||
//
|
||||
case 'Р':
|
||||
case 'р':
|
||||
return 'R';
|
||||
//
|
||||
case 'С':
|
||||
case 'с':
|
||||
return 'S';
|
||||
case 'Т':
|
||||
case 'т':
|
||||
return 'T';
|
||||
//
|
||||
case 'У':
|
||||
case 'у':
|
||||
case 'Ю':
|
||||
case 'ю':
|
||||
return 'U';
|
||||
case 'Х':
|
||||
case 'х':
|
||||
case 'Щ':
|
||||
case 'щ':
|
||||
case 'Ш':
|
||||
case 'ш':
|
||||
return 'H';
|
||||
//
|
||||
case 'Ф':
|
||||
case 'ф':
|
||||
return 'F';
|
||||
//
|
||||
case 'Ч':
|
||||
case 'ч':
|
||||
case 'Ц':
|
||||
case 'ц':
|
||||
return 'C';
|
||||
//
|
||||
case 'Ы':
|
||||
case 'ы':
|
||||
return 'Y';
|
||||
//
|
||||
}
|
||||
return ' ';
|
||||
}
|
||||
public static String ending(boolean flag) {
|
||||
return flag ? ")" : ",";
|
||||
}
|
||||
// http://java-online.ru/blog-archive.xhtml
|
||||
public static void getFilesCountR(File dir, Index res) {
|
||||
for (File f : dir.listFiles()) {
|
||||
@@ -412,18 +175,6 @@ public class Utils {
|
||||
DateFormat df = new SimpleDateFormat(pattern);
|
||||
return df.format(date);
|
||||
}
|
||||
public static boolean isBracketsBalanced(String fragment) {
|
||||
int cc = 0;
|
||||
for (char c : fragment.toCharArray()) {
|
||||
if (c == '(')
|
||||
cc++;
|
||||
if (c == ')')
|
||||
cc--;
|
||||
if (cc < 0)
|
||||
return false;
|
||||
}
|
||||
return (cc == 0);
|
||||
}
|
||||
public static File CreateTempResourceFile(String res_name) throws Exception {
|
||||
URL u = (Utils.class.getResource("/files/" + res_name));
|
||||
InputStream i = u.openStream();
|
||||
@@ -477,7 +228,7 @@ public class Utils {
|
||||
Log.Writeln_("Имя файла не может быть пустым");
|
||||
res = false;
|
||||
}
|
||||
if (ContainsCyrillic(name)) {
|
||||
if (CommonUtils.ContainsCyrillic(name)) {
|
||||
Log.Writeln_("Имя файла не может содержать кириллицу");
|
||||
res = false;
|
||||
}
|
||||
@@ -491,7 +242,7 @@ public class Utils {
|
||||
//идет по всем уровням файлов
|
||||
public static boolean validateProjectFile(File file, TextLog Log) {
|
||||
String name = file.getName();
|
||||
if (ContainsCyrillic(name) || ContainsForbiddenName(name)) {
|
||||
if (CommonUtils.ContainsCyrillic(name) || ContainsForbiddenName(name)) {
|
||||
Log.Writeln_(file.getAbsolutePath());
|
||||
return false;
|
||||
}
|
||||
@@ -567,11 +318,11 @@ public class Utils {
|
||||
} else return;
|
||||
if (file.exists()) {
|
||||
attempts++;
|
||||
System.out.println("файл " + Brackets(file.getAbsolutePath()) + " занят");
|
||||
System.out.println("файл " + CommonUtils.Brackets(file.getAbsolutePath()) + " занят");
|
||||
Thread.sleep(2000);
|
||||
} else return;
|
||||
}
|
||||
throw new PassException("Не удалось удалить файл " + Brackets(file.getAbsolutePath()) + " за " + attempts + " попыток");
|
||||
throw new PassException("Не удалось удалить файл " + CommonUtils.Brackets(file.getAbsolutePath()) + " за " + attempts + " попыток");
|
||||
}
|
||||
public static void GetVertices(float R, float r, float x0, float y0, int n, float phi) {
|
||||
boolean inner = false;
|
||||
@@ -625,11 +376,11 @@ public class Utils {
|
||||
} else return;
|
||||
if (file.exists()) {
|
||||
attempts++;
|
||||
Global.Log.Print("неудачная попытка удаления: файл " + Brackets(file.getAbsolutePath()) + " занят");
|
||||
Global.Log.Print("неудачная попытка удаления: файл " + CommonUtils.Brackets(file.getAbsolutePath()) + " занят");
|
||||
Thread.sleep(2000);
|
||||
} else return;
|
||||
}
|
||||
throw new PassException("Не удалось удалить файл " + Brackets(file.getAbsolutePath()) + " за " + attempts + " попыток");
|
||||
throw new PassException("Не удалось удалить файл " + CommonUtils.Brackets(file.getAbsolutePath()) + " за " + attempts + " попыток");
|
||||
}
|
||||
public static byte[] packFile(File src) throws Exception {
|
||||
byte[] dst = Files.readAllBytes(src.toPath());
|
||||
@@ -669,7 +420,7 @@ public class Utils {
|
||||
if (files != null) {
|
||||
for (File file : files) {
|
||||
if (file.isFile()) {
|
||||
String file_extension = getExtension(file);
|
||||
String file_extension = CommonUtils.getExtension(file);
|
||||
for (String ext : extensions) {
|
||||
if (file_extension.equalsIgnoreCase(ext)) {
|
||||
res.add(file);
|
||||
@@ -710,7 +461,7 @@ public class Utils {
|
||||
public static File createScript(File scriptDirectory, File targetDirectory, String name, String scriptText) throws Exception {
|
||||
//->
|
||||
File scriptFile = Paths.get(scriptDirectory.getAbsolutePath(), name + (Global.isWindows ? ".bat" : "")).toFile();
|
||||
FileUtils.write(scriptFile, "cd " + Utils.DQuotes(targetDirectory.getAbsolutePath()) + "\n" + scriptText);
|
||||
FileUtils.write(scriptFile, "cd " + CommonUtils.DQuotes(targetDirectory.getAbsolutePath()) + "\n" + scriptText);
|
||||
if (!scriptFile.setExecutable(true)) throw new PassException("Не удалось создать исполняемый файл для скрипта");
|
||||
return scriptFile;
|
||||
}
|
||||
@@ -847,25 +598,6 @@ public class Utils {
|
||||
}
|
||||
return res;
|
||||
}
|
||||
public static Vector<String> unpackStrings(String string, boolean brackets) {
|
||||
Vector<String> res = new Vector<>();
|
||||
if (string.isEmpty())
|
||||
res.add(brackets ? "[]" : "");
|
||||
else {
|
||||
StringBuilder line = new StringBuilder();
|
||||
for (char c : string.toCharArray()) {
|
||||
if (c == '\n') {
|
||||
res.add(brackets ? Utils.Brackets(line.toString()) : line.toString());
|
||||
line = new StringBuilder();
|
||||
} else
|
||||
line.append(c);
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
public static Vector<String> unpackStrings(String string) {
|
||||
return unpackStrings(string, false);
|
||||
}
|
||||
public static boolean isTimeout(long startDate, long maxtime_sec) {
|
||||
Date now = new Date();
|
||||
long delta = (now.getTime() - startDate) / 1000;
|
||||
@@ -914,7 +646,7 @@ public class Utils {
|
||||
}
|
||||
protected static boolean isSource(File file) {
|
||||
if (file.isFile()) {
|
||||
String extension = getExtension(file).toLowerCase();
|
||||
String extension = CommonUtils.getExtension(file).toLowerCase();
|
||||
switch (extension) {
|
||||
case "f":
|
||||
case "fdv":
|
||||
@@ -946,7 +678,7 @@ public class Utils {
|
||||
}
|
||||
}
|
||||
if (sources.isEmpty()) {
|
||||
if (question) return UI.Question("Папка " + Brackets(folder.getName()) + "\n" +
|
||||
if (question) return UI.Question("Папка " + CommonUtils.Brackets(folder.getName()) + "\n" +
|
||||
"не содержит ни одного файла, распознанного как поддерживаемый код\n" +
|
||||
"Всё равно открыть её как проект");
|
||||
else return false;
|
||||
@@ -955,8 +687,8 @@ public class Utils {
|
||||
public static void Kill(String PID, boolean force) {
|
||||
if (!PID.isEmpty()) {
|
||||
String killCommand =
|
||||
force ? Global.isWindows ? "taskkill /PID " + Utils.DQuotes(PID) + " /F /T" : "kill -9 " + Utils.DQuotes(PID) :
|
||||
Global.isWindows ? "taskkill /PID " + Utils.DQuotes(PID) : "kill -2 " + Utils.DQuotes(PID);
|
||||
force ? Global.isWindows ? "taskkill /PID " + CommonUtils.DQuotes(PID) + " /F /T" : "kill -9 " + CommonUtils.DQuotes(PID) :
|
||||
Global.isWindows ? "taskkill /PID " + CommonUtils.DQuotes(PID) : "kill -2 " + CommonUtils.DQuotes(PID);
|
||||
System.out.println(killCommand);
|
||||
try {
|
||||
Process killer = Utils.startScript(Global.TempDirectory, Global.TempDirectory, "killer", killCommand);
|
||||
@@ -971,12 +703,12 @@ public class Utils {
|
||||
if (name.isEmpty())
|
||||
return false;
|
||||
char[] letters = name.toCharArray();
|
||||
if (!(isEnglishLetter(letters[0]) || letters[0] == '_')) {
|
||||
if (!(CommonUtils.isEnglishLetter(letters[0]) || letters[0] == '_')) {
|
||||
return false;
|
||||
}
|
||||
//---
|
||||
for (int i = 1; i < letters.length; ++i) {
|
||||
if (!(isEnglishLetter(letters[i]) || letters[i] == '_' || Utils.isDigit(String.valueOf(letters[i])))) {
|
||||
if (!(CommonUtils.isEnglishLetter(letters[i]) || letters[i] == '_' || CommonUtils.isDigit(String.valueOf(letters[i])))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package Common_old.Utils.Validators;
|
||||
import Common.Utils.CommonUtils;
|
||||
import Common_old.Constants;
|
||||
import _VisualDVM.Global;
|
||||
import Common_old.Utils.Utils;
|
||||
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.Vector;
|
||||
@@ -173,7 +173,7 @@ public class ShellParser {
|
||||
System.out.print(c == '\r' ? ("\\r") :
|
||||
(c == '\n' ? "\\n\n" : c));
|
||||
if (isCommandSymbol())
|
||||
System.out.print(Utils.RBrackets(code));
|
||||
System.out.print(CommonUtils.RBrackets(code));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user