no message
This commit is contained in:
@@ -3,7 +3,6 @@ import Common.Utils.Vector_;
|
||||
import Visual_DVM_2021.Passes.PassCode_2021;
|
||||
|
||||
import java.util.Vector;
|
||||
import java.util.regex.Pattern;
|
||||
public class Constants {
|
||||
public static final int planner_version = 3;
|
||||
//--
|
||||
@@ -465,19 +464,6 @@ public class Constants {
|
||||
"zypper"
|
||||
//</editor-fold>
|
||||
};
|
||||
public static char toStrike = (char) 822;
|
||||
public static char boop = (char) 7;
|
||||
public static final Pattern VALID_EMAIL_ADDRESS_REGEX =
|
||||
Pattern.compile("^[A-Z0-9._%+-]+@[A-Z0-9.-]+\\.[A-Z]{2,6}$", Pattern.CASE_INSENSITIVE);
|
||||
public static char[] forbidden_file_name_characters = new char[]{
|
||||
'#', '%', '&', '{', '}',
|
||||
'<', '>', '*', '?', '!',
|
||||
'$', '\'', '\"', '@', '+',
|
||||
'`', '|', '=', '#', ':', '/', '\\',
|
||||
'~', '^'
|
||||
};
|
||||
//все запретные символы через пробел.
|
||||
public static String all_forbidden_characters_string = "";
|
||||
public static Vector<String> admins_mails = new Vector_<>(
|
||||
|
||||
"vmk-post@yandex.ru"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
package Common_old.UI;
|
||||
import _VisualDVM.Global;
|
||||
import Common.Utils.CommonUtils;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
@@ -34,7 +34,7 @@ public class ControlForm<C extends Component> {
|
||||
try {
|
||||
control = control_class.newInstance();
|
||||
} catch (Exception e) {
|
||||
Global.Log.PrintException(e);
|
||||
CommonUtils.MainLog.PrintException(e);
|
||||
}
|
||||
}
|
||||
public boolean isShown() {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package Common_old.UI;
|
||||
import Common.CommonConstants;
|
||||
import Common.Utils.CommonUtils;
|
||||
import Common.Visual.CommonUI;
|
||||
import Common_old.Current;
|
||||
import Common.Database.Objects.DBObject;
|
||||
@@ -220,7 +221,7 @@ public class DataSetControlForm extends ControlWithCurrentForm<DataTable> {
|
||||
try {
|
||||
ShowCurrentObject();
|
||||
} catch (Exception ex) {
|
||||
Global.Log.PrintException(ex);
|
||||
CommonUtils.MainLog.PrintException(ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -231,7 +232,7 @@ public class DataSetControlForm extends ControlWithCurrentForm<DataTable> {
|
||||
try {
|
||||
ShowNoCurrentObject();
|
||||
} catch (Exception ex) {
|
||||
Global.Log.PrintException(ex);
|
||||
CommonUtils.MainLog.PrintException(ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -244,7 +245,7 @@ public class DataSetControlForm extends ControlWithCurrentForm<DataTable> {
|
||||
try {
|
||||
MouseAction2();
|
||||
} catch (Exception ex) {
|
||||
Global.Log.PrintException(ex);
|
||||
CommonUtils.MainLog.PrintException(ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -255,7 +256,7 @@ public class DataSetControlForm extends ControlWithCurrentForm<DataTable> {
|
||||
try {
|
||||
ShowNoCurrentObject();
|
||||
} catch (Exception e) {
|
||||
Global.Log.PrintException(e);
|
||||
CommonUtils.MainLog.PrintException(e);
|
||||
}
|
||||
}
|
||||
//---
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
package Common_old.UI.DragDrop;
|
||||
import _VisualDVM.Global;
|
||||
import Common.Utils.CommonUtils;
|
||||
|
||||
import java.awt.datatransfer.DataFlavor;
|
||||
import java.io.*;
|
||||
@@ -314,12 +314,12 @@ public class FileDrop {
|
||||
} // end try
|
||||
catch (IOException io) {
|
||||
log(out, "FileDrop: IOException - abort:");
|
||||
Global.Log.PrintException(io);
|
||||
CommonUtils.MainLog.PrintException(io);
|
||||
evt.rejectDrop();
|
||||
} // end catch IOException
|
||||
catch (java.awt.datatransfer.UnsupportedFlavorException ufe) {
|
||||
log(out, "FileDrop: UnsupportedFlavorException - abort:");
|
||||
Global.Log.PrintException(ufe);
|
||||
CommonUtils.MainLog.PrintException(ufe);
|
||||
evt.rejectDrop();
|
||||
} // end catch: UnsupportedFlavorException
|
||||
finally {
|
||||
@@ -446,7 +446,7 @@ public class FileDrop {
|
||||
dt.addDropTargetListener(dropListener);
|
||||
} // end try
|
||||
catch (java.util.TooManyListenersException e) {
|
||||
Global.Log.PrintException(e);
|
||||
CommonUtils.MainLog.PrintException(e);
|
||||
log(out, "FileDrop: Drop will not work due to previous error. Do you have another listener attached?");
|
||||
} // end catch
|
||||
// Listen for hierarchy changes and remove the drop target when the parent gets cleared out.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package Common_old.UI.Editor;
|
||||
import Common.Utils.CommonUtils;
|
||||
import Common_old.Current;
|
||||
import _VisualDVM.Global;
|
||||
import Common_old.UI.Menus.StyledPopupMenu;
|
||||
import Common_old.UI.Menus.TextEditorMenu;
|
||||
import _VisualDVM.Syntax.ThemeElement;
|
||||
@@ -115,8 +115,8 @@ public class BaseEditor extends RSyntaxTextArea implements ThemeElement, DialogF
|
||||
setSelectionEnd(getLineStartOffset(LineNum));
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
Global.Log.Print("Не удалось перейти на строку " + LineNum);
|
||||
Global.Log.PrintException(ex);
|
||||
CommonUtils.MainLog.Print("Не удалось перейти на строку " + LineNum);
|
||||
CommonUtils.MainLog.PrintException(ex);
|
||||
}
|
||||
}
|
||||
//------------------------------------------
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
package Common_old.UI.Editor;
|
||||
import _VisualDVM.Global;
|
||||
import Common.Utils.CommonUtils;
|
||||
import ProjectData.Files.UI.Editor.SPFEditor;
|
||||
import org.fife.ui.rsyntaxtextarea.RSyntaxTextArea;
|
||||
public class CaretInfo {
|
||||
@@ -22,7 +22,7 @@ public class CaretInfo {
|
||||
prefix_word = SPFEditor.getLastWord(before, ' ', ',', ':', '.', '(', ')');
|
||||
suffix_word = SPFEditor.getFirstWord(after, ' ', ',', ':', '.', '(', ')');
|
||||
} catch (Exception ex) {
|
||||
Global.Log.PrintException(ex);
|
||||
CommonUtils.MainLog.PrintException(ex);
|
||||
}
|
||||
}
|
||||
public CaretInfo() {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package Common_old.UI.Menus;
|
||||
import Common.Utils.CommonUtils;
|
||||
import Common_old.Current;
|
||||
import _VisualDVM.Global;
|
||||
import Visual_DVM_2021.Passes.PassCode_2021;
|
||||
import Visual_DVM_2021.Passes.Pass_2021;
|
||||
|
||||
@@ -21,7 +21,7 @@ public class AttachementsMenu extends StyledPopupMenu {
|
||||
try {
|
||||
Desktop.getDesktop().open(Current.getProject().getAttachmentsDirectory());
|
||||
} catch (Exception ex) {
|
||||
Global.Log.PrintException(ex);
|
||||
CommonUtils.MainLog.PrintException(ex);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package Common_old.UI.Menus;
|
||||
import Common.Utils.CommonUtils;
|
||||
import Common_old.Current;
|
||||
import _VisualDVM.Global;
|
||||
import Common_old.UI.Editor.CaretInfo;
|
||||
import Common_old.Utils.Utils;
|
||||
import ProjectData.Files.DBProjectFile;
|
||||
@@ -85,7 +84,7 @@ public class MainEditorMenu extends TextEditorMenu {
|
||||
1
|
||||
);
|
||||
} catch (Exception ex) {
|
||||
Global.Log.PrintException(ex);
|
||||
CommonUtils.MainLog.PrintException(ex);
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -102,7 +101,7 @@ public class MainEditorMenu extends TextEditorMenu {
|
||||
0
|
||||
);
|
||||
} catch (Exception ex) {
|
||||
Global.Log.PrintException(ex);
|
||||
CommonUtils.MainLog.PrintException(ex);
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -190,7 +189,7 @@ public class MainEditorMenu extends TextEditorMenu {
|
||||
try {
|
||||
Current.getSapfor().UpdateProjectFiles(false);
|
||||
} catch (Exception ex) {
|
||||
Global.Log.PrintException(ex);
|
||||
CommonUtils.MainLog.PrintException(ex);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -35,7 +35,7 @@ public class ProjectFilesMenu extends GraphMenu {
|
||||
try {
|
||||
Desktop.getDesktop().open(Current.getProject().Home);
|
||||
} catch (Exception ex) {
|
||||
Global.Log.PrintException(ex);
|
||||
CommonUtils.MainLog.PrintException(ex);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package Common_old.UI.Menus;
|
||||
import Common.CommonConstants;
|
||||
import Common_old.Utils.Utils;
|
||||
import Common.Utils.CommonUtils;
|
||||
|
||||
import javax.swing.*;
|
||||
public class TableMenu extends StyledPopupMenu {
|
||||
@@ -14,7 +14,7 @@ public class TableMenu extends StyledPopupMenu {
|
||||
owner = owner_in;
|
||||
mcopy = new VisualiserMenuItem("Копировать текст текущей ячейки", "/icons/Editor/Copy.png");
|
||||
//если удалось нажать значит все условия выполнены
|
||||
mcopy.addActionListener(e -> Utils.CopyToClipboard(target.toString()));
|
||||
mcopy.addActionListener(e -> CommonUtils.CopyToClipboard(target.toString()));
|
||||
add(mcopy);
|
||||
}
|
||||
@Override
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package Common_old.UI.Menus;
|
||||
import Common.Utils.CommonUtils;
|
||||
import Common.Visual.CommonUI;
|
||||
import Common_old.Utils.Utils;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
@@ -18,7 +18,7 @@ public class TextComboBoxMenu extends StyledPopupMenu {
|
||||
new AbstractAction() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
Utils.CopyToClipboard(box.getSelectedItem().toString());
|
||||
CommonUtils.CopyToClipboard(box.getSelectedItem().toString());
|
||||
}
|
||||
});
|
||||
add(m_copy);
|
||||
@@ -27,7 +27,7 @@ public class TextComboBoxMenu extends StyledPopupMenu {
|
||||
new AbstractAction() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
CommonUI.TrySelect(box, Utils.getFromClipboard());
|
||||
CommonUI.TrySelect(box, CommonUtils.getFromClipboard());
|
||||
}
|
||||
});
|
||||
add(m_paste);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
package Common_old.UI.Menus;
|
||||
import Common_old.Utils.Utils;
|
||||
import Common.Utils.CommonUtils;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.text.JTextComponent;
|
||||
@@ -52,7 +52,7 @@ public class TextEditorMenu extends StyledPopupMenu {
|
||||
String[] data = selectedText.split("\n");
|
||||
Vector<String> new_data = new Vector<>();
|
||||
for (String line: data){
|
||||
new_data.add(Utils.strikeThrough(line));
|
||||
new_data.add(CommonUtils.strikeThrough(line));
|
||||
}
|
||||
editor.replaceSelection(String.join("\n", new_data));
|
||||
}
|
||||
@@ -66,7 +66,7 @@ public class TextEditorMenu extends StyledPopupMenu {
|
||||
String[] data = selectedText.split("\n");
|
||||
Vector<String> new_data = new Vector<>();
|
||||
for (String line: data){
|
||||
new_data.add(Utils.noStrikeThrough(line));
|
||||
new_data.add(CommonUtils.noStrikeThrough(line));
|
||||
}
|
||||
editor.replaceSelection(String.join("\n", new_data));
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
package Common_old.UI.Menus_2023.MainMenuBar.VisualiserSettingsMenu;
|
||||
import Common.Utils.CommonUtils;
|
||||
import _VisualDVM.Global;
|
||||
import Common_old.UI.Menus.PropertiesSubmenu;
|
||||
import Common_old.UI.Menus_2023.SettingsSubmenu;
|
||||
@@ -14,7 +15,7 @@ public class VisualiserSettingsMenu extends VisualiserMenu {
|
||||
"FocusPassesResult"
|
||||
));
|
||||
add(new CompactnessSettingsMenu());
|
||||
if (Global.isWindows) {
|
||||
if (CommonUtils.isWindows) {
|
||||
add(new SettingsSubmenu("Компиляция на локальной машине", null,
|
||||
SettingName.LocalMakePathWindows,
|
||||
SettingName.Kernels
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
package Common_old.UI.Tables;
|
||||
import Common_old.Utils.Utils;
|
||||
import Common.Utils.CommonUtils;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.util.Date;
|
||||
@@ -13,6 +13,6 @@ public class DateRenderer_ extends RendererCell<Date> {
|
||||
@Override
|
||||
public void Display() {
|
||||
if (value != null)
|
||||
setText(value.equals(zero) ? "нет" : Utils.print_date(value));
|
||||
setText(value.equals(zero) ? "нет" : CommonUtils.print_date(value));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package Common_old.UI.Trees;
|
||||
import Common.Utils.CommonUtils;
|
||||
import Common_old.Current;
|
||||
import _VisualDVM.Global;
|
||||
import Common_old.UI.DataControl_OLD;
|
||||
|
||||
import javax.swing.tree.DefaultMutableTreeNode;
|
||||
@@ -25,7 +25,7 @@ public class DataTree extends StyledTree implements DataControl_OLD {
|
||||
try {
|
||||
ShowCurrentObject();
|
||||
} catch (Exception ex) {
|
||||
Global.Log.PrintException(ex);
|
||||
CommonUtils.MainLog.PrintException(ex);
|
||||
}
|
||||
}
|
||||
public void SelectNodeByCriteria(Object criteria) {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
package Common_old.UI;
|
||||
import Common.Utils.CommonUtils;
|
||||
import Common_old.Current;
|
||||
import Common_old.UI.Menus_2023.CredentialsBar.CredentialsBar;
|
||||
import Common.Visual.DataMenuBar;
|
||||
@@ -13,7 +14,6 @@ import Common_old.UI.Trees.GraphTreeCellRenderer;
|
||||
import Common_old.UI.Trees.SelectionTreeCellRenderer;
|
||||
import Common_old.UI.Windows.FormType;
|
||||
import Common_old.UI.Windows.SearchReplaceForm;
|
||||
import Common_old.Utils.Utils;
|
||||
import Common.Database.Tables.DataSet;
|
||||
import Common.Visual.CommonUI;
|
||||
import GlobalData.Compiler.CompilersDBTable;
|
||||
@@ -329,12 +329,12 @@ public class UI {
|
||||
return Question(getFrontWindow(), text);
|
||||
}
|
||||
public static void Info(String message) {
|
||||
Utils.CopyToClipboard(message);
|
||||
CommonUtils.CopyToClipboard(message);
|
||||
if (Current.hasUI())
|
||||
JOptionPane.showMessageDialog(getFrontWindow(), message, "", 1);
|
||||
}
|
||||
public static void Error(String message) {
|
||||
Utils.CopyToClipboard(message);
|
||||
CommonUtils.CopyToClipboard(message);
|
||||
if (Current.hasUI())
|
||||
JOptionPane.showMessageDialog(getFrontWindow(), message, "", 0);
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@ package Common_old.UI.Windows.Dialog;
|
||||
import Common.Utils.CommonUtils;
|
||||
import Common.Visual.CommonUI;
|
||||
import Common_old.Current;
|
||||
import _VisualDVM.Global;
|
||||
import _VisualDVM.Syntax.ThemeElement;
|
||||
import _VisualDVM.Syntax.VisualiserFonts;
|
||||
import Common_old.UI.UI;
|
||||
@@ -68,7 +67,7 @@ public class Dialog<T, F extends DialogFields> extends JDialog implements ThemeE
|
||||
content = (fields = f.newInstance()).getContent();
|
||||
//--?
|
||||
} catch (Exception e) {
|
||||
Global.Log.PrintException(e);
|
||||
CommonUtils.MainLog.PrintException(e);
|
||||
}
|
||||
}
|
||||
public void onClose() {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
package Common_old.UI.Windows;
|
||||
import Common.Utils.CommonUtils;
|
||||
import _VisualDVM.Global;
|
||||
import _VisualDVM.Syntax.ThemeElement;
|
||||
import GlobalData.FormsParams.DBForm;
|
||||
@@ -13,7 +14,7 @@ public abstract class Form extends JFrame implements ThemeElement {
|
||||
public Form() {
|
||||
if (getIconName().length() > 0) setIconImage(new ImageIcon(Form.class.getResource(getIconName())).getImage());
|
||||
SetListener();
|
||||
this.setTitle(Global.isWindows ? getWTitleText() : getUTitleText());
|
||||
this.setTitle(CommonUtils.isWindows ? getWTitleText() : getUTitleText());
|
||||
pack();
|
||||
setMinimumSize(new Dimension(getDefaultWidth(), getDefaultHeight()));
|
||||
}
|
||||
@@ -55,7 +56,7 @@ public abstract class Form extends JFrame implements ThemeElement {
|
||||
try {
|
||||
LoadWindowParameters();
|
||||
} catch (Exception e) {
|
||||
Global.Log.PrintException(e);
|
||||
CommonUtils.MainLog.PrintException(e);
|
||||
}
|
||||
setContentPane(getMainPanel());
|
||||
setVisible(true);
|
||||
@@ -64,7 +65,7 @@ public abstract class Form extends JFrame implements ThemeElement {
|
||||
try {
|
||||
SaveWindowParameters();
|
||||
} catch (Exception e) {
|
||||
Global.Log.PrintException(e);
|
||||
CommonUtils.MainLog.PrintException(e);
|
||||
}
|
||||
setVisible(false);
|
||||
dispose();
|
||||
|
||||
@@ -17,9 +17,6 @@ import javafx.util.Pair;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
|
||||
import javax.swing.tree.DefaultMutableTreeNode;
|
||||
import java.awt.*;
|
||||
import java.awt.datatransfer.DataFlavor;
|
||||
import java.awt.datatransfer.StringSelection;
|
||||
import java.io.*;
|
||||
import java.math.BigInteger;
|
||||
import java.net.InetAddress;
|
||||
@@ -29,8 +26,6 @@ import java.net.URL;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.file.*;
|
||||
import java.security.MessageDigest;
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.Semaphore;
|
||||
@@ -44,27 +39,6 @@ public class Utils {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public static boolean ContainsForbiddenName(String string) {
|
||||
char[] chars = string.toCharArray();
|
||||
for (char c : chars)
|
||||
if (isForbidden(c)) return true;
|
||||
return false;
|
||||
}
|
||||
public static boolean isForbidden(char c) {
|
||||
for (char f : Constants.forbidden_file_name_characters)
|
||||
if (c == f) return true;
|
||||
return false;
|
||||
}
|
||||
public static String ReplaceForbiddenSymbols(String name) {
|
||||
StringBuilder res = new StringBuilder();
|
||||
for (char c : name.toCharArray())
|
||||
res.append(isForbidden(c) ? '_' : c);
|
||||
return res.toString();
|
||||
}
|
||||
public static void init() {
|
||||
for (char f : Constants.forbidden_file_name_characters)
|
||||
Constants.all_forbidden_characters_string += f + " ";
|
||||
}
|
||||
public static String MFVar(Object o) {
|
||||
return "$(" + o.toString() + ")";
|
||||
}
|
||||
@@ -73,7 +47,7 @@ public class Utils {
|
||||
try {
|
||||
FileUtils.forceMkdir(dir);
|
||||
} catch (Exception e) {
|
||||
Global.Log.PrintException(e);
|
||||
CommonUtils.MainLog.PrintException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -85,14 +59,14 @@ public class Utils {
|
||||
try {
|
||||
forceDeleteWithCheck(f);
|
||||
} catch (Exception e) {
|
||||
Global.Log.PrintException(e);
|
||||
CommonUtils.MainLog.PrintException(e);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
FileUtils.forceMkdir(dir);
|
||||
} catch (Exception e) {
|
||||
Global.Log.PrintException(e);
|
||||
CommonUtils.MainLog.PrintException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -103,7 +77,7 @@ public class Utils {
|
||||
try {
|
||||
return new String(Files.readAllBytes(file.toPath()));
|
||||
} catch (Exception e) {
|
||||
Global.Log.PrintException(e);
|
||||
CommonUtils.MainLog.PrintException(e);
|
||||
}
|
||||
return "";
|
||||
}
|
||||
@@ -115,7 +89,7 @@ public class Utils {
|
||||
try {
|
||||
forceDeleteWithCheck(f);
|
||||
} catch (Exception e) {
|
||||
Global.Log.PrintException(e);
|
||||
CommonUtils.MainLog.PrintException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -168,11 +142,6 @@ public class Utils {
|
||||
getFilesCountR(dir, res);
|
||||
return res.getValue();
|
||||
}
|
||||
public static String print_date(Date date) {
|
||||
String pattern = "dd.MM.yyyy HH:mm:ss";
|
||||
DateFormat df = new SimpleDateFormat(pattern);
|
||||
return df.format(date);
|
||||
}
|
||||
public static File CreateTempResourceFile(String res_name) throws Exception {
|
||||
URL u = (Utils.class.getResource("/files/" + res_name));
|
||||
InputStream i = u.openStream();
|
||||
@@ -203,7 +172,7 @@ public class Utils {
|
||||
return getTempFileName(name, "");
|
||||
}
|
||||
public static boolean isAnchestor(File child, File anchestor) {
|
||||
return child.getAbsolutePath().startsWith(anchestor.getAbsolutePath() + (Global.isWindows ? "\\" : "/"));
|
||||
return child.getAbsolutePath().startsWith(anchestor.getAbsolutePath() + (CommonUtils.isWindows ? "\\" : "/"));
|
||||
}
|
||||
//при условии что это точно его предок
|
||||
public static String getRelativeAddress(File file, File anchestor) {
|
||||
@@ -220,8 +189,8 @@ public class Utils {
|
||||
Log.Writeln_("Имя файла не может содержать кириллицу");
|
||||
res = false;
|
||||
}
|
||||
if (ContainsForbiddenName(name)) {
|
||||
Log.Writeln_("Имя файла не может содержать запрещённых символов\n" + Constants.all_forbidden_characters_string);
|
||||
if (CommonUtils.ContainsForbiddenName(name)) {
|
||||
Log.Writeln_("Имя файла не может содержать запрещённых символов\n" + CommonUtils.printAllForbiddenCharacters());
|
||||
res = false;
|
||||
}
|
||||
return res;
|
||||
@@ -230,7 +199,7 @@ public class Utils {
|
||||
//идет по всем уровням файлов
|
||||
public static boolean validateProjectFile(File file, TextLog Log) {
|
||||
String name = file.getName();
|
||||
if (CommonUtils.ContainsCyrillic(name) || ContainsForbiddenName(name)) {
|
||||
if (CommonUtils.ContainsCyrillic(name) || CommonUtils.ContainsForbiddenName(name)) {
|
||||
Log.Writeln_(file.getAbsolutePath());
|
||||
return false;
|
||||
}
|
||||
@@ -253,29 +222,11 @@ public class Utils {
|
||||
validateProjectFolder_r(dir, files_list);
|
||||
if (!files_list.isEmpty())
|
||||
Log.Writeln_("Имена " + filesLines.length + " файлов/подпапок содержат запрещённые символы " +
|
||||
Constants.all_forbidden_characters_string +
|
||||
CommonUtils.printAllForbiddenCharacters() +
|
||||
"или кириллицу");
|
||||
//нужно проверить корень на наличие хоть одной программы.
|
||||
return Log.isEmpty();
|
||||
}
|
||||
public static void CopyToClipboard(String text) {
|
||||
Toolkit.getDefaultToolkit()
|
||||
.getSystemClipboard()
|
||||
.setContents(
|
||||
new StringSelection(text),
|
||||
null
|
||||
);
|
||||
}
|
||||
public static String getFromClipboard() {
|
||||
String res = "";
|
||||
try {
|
||||
res = (String) Toolkit.getDefaultToolkit()
|
||||
.getSystemClipboard().getData(DataFlavor.stringFlavor);
|
||||
} catch (Exception ex) {
|
||||
Global.Log.PrintException(ex);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
public static void delete_with_check(File file) throws Exception {
|
||||
int attempts = 0;
|
||||
while (attempts < 10) {
|
||||
@@ -315,7 +266,7 @@ public class Utils {
|
||||
} catch (Exception e) {
|
||||
// тут можно обработать ошибку
|
||||
// возникает она если в передаваемый алгоритм в getInstance(,,,) не существует
|
||||
Global.Log.PrintException(e);
|
||||
CommonUtils.MainLog.PrintException(e);
|
||||
}
|
||||
BigInteger bigInt = new BigInteger(1, digest);
|
||||
String md5Hex = bigInt.toString(16);
|
||||
@@ -346,21 +297,12 @@ public class Utils {
|
||||
} else return;
|
||||
if (file.exists()) {
|
||||
attempts++;
|
||||
Global.Log.Print("неудачная попытка удаления: файл " + CommonUtils.Brackets(file.getAbsolutePath()) + " занят");
|
||||
CommonUtils.MainLog.Print("неудачная попытка удаления: файл " + CommonUtils.Brackets(file.getAbsolutePath()) + " занят");
|
||||
Thread.sleep(2000);
|
||||
} else return;
|
||||
}
|
||||
throw new PassException("Не удалось удалить файл " + CommonUtils.Brackets(file.getAbsolutePath()) + " за " + attempts + " попыток");
|
||||
}
|
||||
public static byte[] packFile(File src) throws Exception {
|
||||
byte[] dst = Files.readAllBytes(src.toPath());
|
||||
return dst;
|
||||
}
|
||||
public static void unpackFile(byte[] bytes, File dst) throws Exception {
|
||||
FileOutputStream os = new FileOutputStream(dst);
|
||||
os.write(bytes);
|
||||
os.close();
|
||||
}
|
||||
public static Socket createClientSocket(InetAddress address, int port, int timeout) throws Exception {
|
||||
Socket socket = new Socket();
|
||||
socket.setSoTimeout(timeout);
|
||||
@@ -372,19 +314,6 @@ public class Utils {
|
||||
InputStream i = u.openStream();
|
||||
Files.copy(i, dst.toPath(), StandardCopyOption.REPLACE_EXISTING);
|
||||
}
|
||||
public static boolean validateEmail(String address, TextLog log) {
|
||||
Matcher matcher = Constants.VALID_EMAIL_ADDRESS_REGEX.matcher(address);
|
||||
if (!matcher.find()) {
|
||||
log.Writeln_("введённый адрес электронной почты некорректен.");
|
||||
return false;
|
||||
}
|
||||
String match = address.substring(matcher.start(), matcher.end());
|
||||
if (!match.equals(address)) {
|
||||
log.Writeln_("введённый адрес электронной почты некорректен.");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public static void getFilesByExtensions_r(File dir, Vector<File> res, String... extensions) {
|
||||
File[] files = dir.listFiles();
|
||||
if (files != null) {
|
||||
@@ -430,7 +359,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();
|
||||
File scriptFile = Paths.get(scriptDirectory.getAbsolutePath(), name + (CommonUtils.isWindows ? ".bat" : "")).toFile();
|
||||
FileUtils.write(scriptFile, "cd " + CommonUtils.DQuotes(targetDirectory.getAbsolutePath()) + "\n" + scriptText);
|
||||
if (!scriptFile.setExecutable(true)) throw new PassException("Не удалось создать исполняемый файл для скрипта");
|
||||
return scriptFile;
|
||||
@@ -594,23 +523,6 @@ public class Utils {
|
||||
}
|
||||
return res;
|
||||
}
|
||||
public static String strikeThrough(String s) {
|
||||
StringBuilder res = new StringBuilder();
|
||||
for (char c : s.toCharArray()) {
|
||||
res.append(c);
|
||||
if (c != Constants.toStrike)
|
||||
res.append(Constants.toStrike);
|
||||
}
|
||||
return res.toString();
|
||||
}
|
||||
public static String noStrikeThrough(String s) {
|
||||
StringBuilder res = new StringBuilder();
|
||||
for (char c : s.toCharArray()) {
|
||||
if (c != (Constants.toStrike))
|
||||
res.append(c);
|
||||
}
|
||||
return res.toString();
|
||||
}
|
||||
public static void addEmptyLines(Vector<String> lines, int num) {
|
||||
IntStream.range(0, num).mapToObj(i -> "").forEach(lines::add);
|
||||
}
|
||||
@@ -657,8 +569,8 @@ public class Utils {
|
||||
public static void Kill(String PID, boolean force) {
|
||||
if (!PID.isEmpty()) {
|
||||
String killCommand =
|
||||
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);
|
||||
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);
|
||||
System.out.println(killCommand);
|
||||
try {
|
||||
Process killer = Utils.startScript(Global.TempDirectory, Global.TempDirectory, "killer", killCommand);
|
||||
@@ -782,7 +694,7 @@ public class Utils {
|
||||
try {
|
||||
if (p != null) res = Double.parseDouble(p);
|
||||
} catch (Exception ex) {
|
||||
Global.Log.PrintException(ex);
|
||||
CommonUtils.MainLog.PrintException(ex);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package Common_old.Utils.Validators;
|
||||
import Common.Utils.CommonUtils;
|
||||
import Common_old.Constants;
|
||||
import Common.Utils.TextLog;
|
||||
import Common_old.Utils.Utils;
|
||||
import org.fife.ui.rsyntaxtextarea.RSyntaxUtilities;
|
||||
public class PathValidator extends Validator {
|
||||
PathValidatorState state;
|
||||
@@ -39,7 +39,7 @@ public class PathValidator extends Validator {
|
||||
name.append(c);
|
||||
break;
|
||||
default:
|
||||
if (Utils.isForbidden(c))
|
||||
if (CommonUtils.isForbiddenCharacter(c))
|
||||
state = PathValidatorState.Forbidden;
|
||||
else name.append(c);
|
||||
break;
|
||||
@@ -54,7 +54,7 @@ public class PathValidator extends Validator {
|
||||
Log.Writeln(string_name + ": имя файла или каталога в пути имеет неверный формат");
|
||||
break;
|
||||
case Forbidden:
|
||||
Log.Writeln(string_name + ": Составляющие путь имена содержат запрещённые символы \n" + Constants.all_forbidden_characters_string);
|
||||
Log.Writeln(string_name + ": Составляющие путь имена содержат запрещённые символы \n" + CommonUtils.printAllForbiddenCharacters());
|
||||
break;
|
||||
case Name:
|
||||
if (spaces_count > 0)
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package Common_old.Utils.Validators;
|
||||
import Common.CommonConstants;
|
||||
import Common.Utils.CommonUtils;
|
||||
import Common_old.Constants;
|
||||
import _VisualDVM.Global;
|
||||
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.Vector;
|
||||
@@ -167,7 +166,7 @@ public class ShellParser {
|
||||
userName = userName_in;
|
||||
}
|
||||
public static void printChar() {
|
||||
if (c != Constants.boop) {
|
||||
if (c != CommonConstants.boop) {
|
||||
int code = c;
|
||||
if ((!return_active) || (c == '\n')) {
|
||||
System.out.print(c == '\r' ? ("\\r") :
|
||||
@@ -211,7 +210,7 @@ public class ShellParser {
|
||||
} else
|
||||
state = ShellParserState.End;
|
||||
} catch (Exception ex) {
|
||||
Global.Log.PrintException(ex);
|
||||
CommonUtils.MainLog.PrintException(ex);
|
||||
state = ShellParserState.End;
|
||||
}
|
||||
} while (!state.equals(ShellParserState.End));
|
||||
@@ -237,7 +236,7 @@ public class ShellParser {
|
||||
} else
|
||||
state = ShellParserState.End;
|
||||
} catch (Exception ex) {
|
||||
Global.Log.PrintException(ex);
|
||||
CommonUtils.MainLog.PrintException(ex);
|
||||
state = ShellParserState.End;
|
||||
}
|
||||
} while (!state.equals(ShellParserState.End));
|
||||
@@ -262,7 +261,7 @@ public class ShellParser {
|
||||
} else
|
||||
return;
|
||||
} catch (Exception ex) {
|
||||
Global.Log.PrintException(ex);
|
||||
CommonUtils.MainLog.PrintException(ex);
|
||||
return;
|
||||
}
|
||||
} while (!res.toString().contains(command));
|
||||
|
||||
Reference in New Issue
Block a user