no message
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
package Common.Database.Objects;
|
||||
import Common.Utils.CommonUtils;
|
||||
import Common_old.UI.Selectable;
|
||||
import Common.Visual.Selectable;
|
||||
import Common.Utils.Index;
|
||||
import com.sun.org.glassfish.gmbal.Description;
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ package Common.Database.Tables;
|
||||
import Common_old.Current;
|
||||
import Common.Visual.DataSetFilter;
|
||||
import Common_old.UI.DataSetControlForm;
|
||||
import Common_old.UI.Menus_2023.DataMenuBar;
|
||||
import Common.Visual.DataMenuBar;
|
||||
import Common_old.UI.Tables.ColumnFilter;
|
||||
import Common_old.UI.UI;
|
||||
import Common_old.UI.Windows.Dialog.DBObjectDialog;
|
||||
@@ -10,7 +10,7 @@ import Common_old.UI.Windows.Dialog.DialogFields;
|
||||
import Common.Utils.TextLog;
|
||||
import Common.Database.Objects.DBObject;
|
||||
import Common.Visual.CommonUI;
|
||||
import Visual_DVM_2021.UI.Interface.FilterWindow;
|
||||
import Common.Visual.FilterInterface;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
@@ -28,7 +28,7 @@ public class DataSet<K, D extends DBObject> extends DataSetAnchestor {
|
||||
public LinkedHashMap<K, D> Data = new LinkedHashMap<>(); //наполнение
|
||||
//-
|
||||
public DataSetControlForm ui_;
|
||||
protected FilterWindow f_ui; // отображение количества объектов
|
||||
protected FilterInterface f_ui; // отображение количества объектов
|
||||
//-
|
||||
public LinkedHashMap<Integer, ColumnFilter> columnsFilters = new LinkedHashMap<>(); //текстовые фильтры столбцов
|
||||
//--
|
||||
@@ -42,7 +42,7 @@ public class DataSet<K, D extends DBObject> extends DataSetAnchestor {
|
||||
Name = d.getSimpleName();
|
||||
}
|
||||
public void mountUI(JPanel content_in) {
|
||||
UI.Clear(content_in);
|
||||
CommonUI.Clear(content_in);
|
||||
//-->
|
||||
ui_ = createUI();
|
||||
ui_.setContent(content_in);
|
||||
@@ -66,7 +66,7 @@ public class DataSet<K, D extends DBObject> extends DataSetAnchestor {
|
||||
public DataSetControlForm getUi() {
|
||||
return ui_;
|
||||
}
|
||||
public void setFilterUI(FilterWindow ui_in) {
|
||||
public void setFilterUI(FilterInterface ui_in) {
|
||||
f_ui = ui_in;
|
||||
}
|
||||
public void ClearUI() {
|
||||
|
||||
@@ -6,6 +6,9 @@ import org.apache.commons.io.FileUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.Arrays;
|
||||
import java.util.Vector;
|
||||
import java.util.stream.Collectors;
|
||||
public class CommonUtils {
|
||||
//JSON
|
||||
//--
|
||||
@@ -243,6 +246,16 @@ public class CommonUtils {
|
||||
}
|
||||
return (cc == 0);
|
||||
}
|
||||
public static String removeRedundantSpaces(String s_in) {
|
||||
return String.join(" ",
|
||||
Arrays.stream(s_in.split(" ")).filter(d -> !d.isEmpty()).collect(Collectors.toCollection(Vector::new)));
|
||||
}
|
||||
public static String removeCharacters(String string, String... to_remove) {
|
||||
String res = string;
|
||||
for (String c : to_remove)
|
||||
res = res.replace(c, "");
|
||||
return res;
|
||||
}
|
||||
//ФАЙЛЫ
|
||||
public static String getExtension(File file) {
|
||||
String fn = file.getName();
|
||||
|
||||
49
src/Common/Utils/Loggable.java
Normal file
49
src/Common/Utils/Loggable.java
Normal file
@@ -0,0 +1,49 @@
|
||||
package Common.Utils;
|
||||
import Common.Utils.CommonUtils;
|
||||
import Common_old.Current;
|
||||
import Common_old.UI.DebugPrintLevel;
|
||||
import Common_old.UI.UI;
|
||||
import Common_old.Utils.Utils;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileWriter;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.Date;
|
||||
public interface Loggable {
|
||||
String getLogHomePath();
|
||||
String getLogName();
|
||||
default File getLogFile() {
|
||||
return Paths.get(getLogHomePath(), (getLogName() + "_log.txt")).toFile();
|
||||
}
|
||||
default void ClearLog() {
|
||||
try {
|
||||
Utils.forceDeleteWithCheck(getLogFile());
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
}
|
||||
default void Print(String message) {
|
||||
try {
|
||||
FileWriter Log = new FileWriter(getLogFile(), true);
|
||||
String datedMessage = CommonUtils.Brackets(new Date()) + " " + message;
|
||||
Log.write(datedMessage + "\n");
|
||||
Log.close();
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
}
|
||||
default void Print(DebugPrintLevel level, String message) {
|
||||
if (level.isEnabled())
|
||||
Print(CommonUtils.Brackets(level.getDescription()) + " " + message);
|
||||
}
|
||||
default void PrintException(Exception ex) {
|
||||
StringWriter out = new StringWriter();
|
||||
PrintWriter writer = new PrintWriter(out);
|
||||
ex.printStackTrace(writer);
|
||||
writer.flush();
|
||||
Print(out.toString());
|
||||
if (Current.hasUI())
|
||||
UI.Error("Возникло исключение. Подробности в файле журнала\n" +
|
||||
CommonUtils.Brackets(getLogFile().getAbsolutePath()));
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,4 @@
|
||||
package Common.Utils;
|
||||
import Common_old.Utils.Utils;
|
||||
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
public class StringTemplate {
|
||||
@@ -13,8 +11,8 @@ public class StringTemplate {
|
||||
public String pattern = "";
|
||||
//------------------------------------------------------------------
|
||||
public StringTemplate(String p, String s) {
|
||||
prefix = Utils.pack(p);
|
||||
suffix = Utils.pack(s);
|
||||
prefix = CommonUtils.removeRedundantSpaces(p);
|
||||
suffix = CommonUtils.removeRedundantSpaces(s);
|
||||
String[] prefix_words = prefix.split(" ");
|
||||
String[] suffix_words = suffix.split(" ");
|
||||
//настраиваем регулярное выражение----------
|
||||
|
||||
@@ -1,8 +1,40 @@
|
||||
package Common.Visual;
|
||||
import Common_old.UI.Menus_2023.DataMenuBar;
|
||||
import Common.Database.Tables.DataSet;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Stack;
|
||||
public class CommonUI {
|
||||
public static LinkedHashMap<Class<? extends DataSet>, DataMenuBar> menuBars = new LinkedHashMap<>();
|
||||
public static Stack<Component> windowsStack = new Stack<>();
|
||||
//-----
|
||||
public static void Clear(Container container) {
|
||||
container.removeAll();
|
||||
container.repaint();
|
||||
container.revalidate();
|
||||
}
|
||||
// http://java-online.ru/swing-joptionpane.xhtml
|
||||
public static <T> void TrySelect(JComboBox box, T value_in) {
|
||||
if (value_in != null) {
|
||||
for (int i = 0; i < box.getItemCount(); ++i) {
|
||||
T value = (T) box.getItemAt(i);
|
||||
if (value.equals(value_in)) {
|
||||
box.setSelectedIndex(i);
|
||||
return;
|
||||
}
|
||||
}
|
||||
box.addItem(value_in);
|
||||
box.setSelectedIndex(box.getItemCount() - 1);
|
||||
}
|
||||
}
|
||||
public static void TrySelect_s(JComboBox box, String value_string_in) {
|
||||
for (int i = 0; i < box.getItemCount(); ++i) {
|
||||
Object value = box.getItemAt(i);
|
||||
if (value.toString().equals(value_string_in)) {
|
||||
box.setSelectedIndex(i);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
56
src/Common/Visual/DataMenuBar.java
Normal file
56
src/Common/Visual/DataMenuBar.java
Normal file
@@ -0,0 +1,56 @@
|
||||
package Common.Visual;
|
||||
import Common.Database.Tables.DataSet;
|
||||
import Common_old.UI.Menus_2023.MenuBarButton;
|
||||
import Common_old.UI.Menus_2023.VisualiserMenuBar;
|
||||
import Visual_DVM_2021.Passes.PassCode_2021;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionListener;
|
||||
public class DataMenuBar extends VisualiserMenuBar {
|
||||
public JLabel countLabel = null;
|
||||
JButton selectAllButton = null;
|
||||
JButton unselectAllButton = null;
|
||||
//-
|
||||
public ActionListener selectAllListener = null;
|
||||
public ActionListener unselectAllListener = null;
|
||||
//-
|
||||
public DataMenuBar(String dataName, PassCode_2021... passes) {
|
||||
// Font font = Current.getTheme().Fonts.get(VisualiserFonts.TreeBoldItalic).deriveFont(12.0F);
|
||||
add(new JLabel(dataName + " : "));
|
||||
add(countLabel = new JLabel("?"));
|
||||
addPasses(passes);
|
||||
}
|
||||
public void createSelectionButtons(DataSet dataSet) {
|
||||
java.awt.Dimension d = new Dimension(25, 25);
|
||||
if (selectAllButton == null) {
|
||||
add(selectAllButton = new MenuBarButton() {
|
||||
{
|
||||
setIcon("/Common/icons/SelectAll.png");
|
||||
setToolTipText("Выбрать всё");
|
||||
setPreferredSize(d);
|
||||
setMinimumSize(d);
|
||||
setMaximumSize(d);
|
||||
}
|
||||
}, 0);
|
||||
}
|
||||
if (unselectAllButton == null) {
|
||||
add(unselectAllButton = new MenuBarButton() {
|
||||
{
|
||||
setIcon("/Common/icons/UnselectAll.png");
|
||||
setToolTipText("Отменить всё");
|
||||
setPreferredSize(d);
|
||||
setMinimumSize(d);
|
||||
setMaximumSize(d);
|
||||
}
|
||||
}, 1);
|
||||
}
|
||||
if (selectAllListener != null) {
|
||||
selectAllButton.removeActionListener(selectAllListener); }
|
||||
selectAllButton.addActionListener(selectAllListener = e -> dataSet.CheckAll(true));
|
||||
if (unselectAllListener != null) {
|
||||
unselectAllButton.removeActionListener(unselectAllListener);
|
||||
}
|
||||
unselectAllButton.addActionListener(unselectAllListener = e -> dataSet.CheckAll(false));
|
||||
}
|
||||
}
|
||||
7
src/Common/Visual/FilterInterface.java
Normal file
7
src/Common/Visual/FilterInterface.java
Normal file
@@ -0,0 +1,7 @@
|
||||
package Common.Visual;
|
||||
public interface FilterInterface {
|
||||
void ShowMatchesCount(int count);
|
||||
default void ShowNoMatches() {
|
||||
ShowMatchesCount(0);
|
||||
}
|
||||
}
|
||||
38
src/Common/Visual/Selectable.java
Normal file
38
src/Common/Visual/Selectable.java
Normal file
@@ -0,0 +1,38 @@
|
||||
package Common.Visual;
|
||||
import Common_old.Utils.Utils;
|
||||
|
||||
import javax.swing.*;
|
||||
public interface Selectable {
|
||||
boolean isSelected();
|
||||
default void Select(boolean flag) {
|
||||
if (isSelectionEnabled())
|
||||
select(flag);
|
||||
}
|
||||
void select(boolean flag);
|
||||
//-
|
||||
default ImageIcon GetSelectionIcon() {
|
||||
return
|
||||
isSelectionEnabled() ?
|
||||
Utils.getIcon("/Common/icons/" + (isSelected() ? "Pick" : "NotPick") + ".png") :
|
||||
GetDisabledIcon();
|
||||
}
|
||||
default ImageIcon GetDisabledIcon() {
|
||||
return Utils.getIcon("/Common/icons/Arrays/Unknown.png");
|
||||
}
|
||||
default void SwitchSelection() {
|
||||
Select(!isSelected());
|
||||
}
|
||||
//строчный контент для передачи параметров проходам.
|
||||
default String getSelectionContent() {
|
||||
return toString();
|
||||
}
|
||||
//-
|
||||
default String getSelectionText() {
|
||||
return toString();
|
||||
}
|
||||
default boolean isSelectionEnabled() {
|
||||
return true;
|
||||
}
|
||||
default void SelectAllChildren(boolean select) {
|
||||
}
|
||||
}
|
||||
8
src/Common/Visual/StatusEnum.java
Normal file
8
src/Common/Visual/StatusEnum.java
Normal file
@@ -0,0 +1,8 @@
|
||||
package Common.Visual;
|
||||
import _VisualDVM.Syntax.VisualiserFonts;
|
||||
public interface StatusEnum {
|
||||
default String getDescription() {
|
||||
return toString();
|
||||
}
|
||||
default VisualiserFonts getFont() {return VisualiserFonts.UnknownState;}
|
||||
}
|
||||
Reference in New Issue
Block a user