no message

This commit is contained in:
2024-10-08 22:33:49 +03:00
parent 90546fc62e
commit e0974fe4a8
246 changed files with 1170 additions and 849 deletions

View File

@@ -1,13 +1,41 @@
package Common.Visual;
import Common.Database.Tables.DataSet;
import Common.Mode;
import Common.Utils.CommonUtils;
import Common.Visual.Themes.DefaultTheme;
import Common.Visual.Themes.VisualiserTheme;
import _VisualDVM.Global;
import javax.swing.*;
import javax.swing.event.ChangeListener;
import javax.swing.text.DefaultFormatter;
import java.awt.*;
import java.util.LinkedHashMap;
import java.util.Stack;
public class CommonUI {
public static boolean active=true; //есть ли интерфейс. в консольных версиях не нужен.
public static boolean isActive() {
return active;
}
//---
public static LinkedHashMap<Class<? extends DataSet>, DataMenuBar> menuBars = new LinkedHashMap<>();
public static Stack<Component> windowsStack = new Stack<>();
static VisualiserTheme theme = new DefaultTheme();
public static VisualiserTheme getTheme() {
return theme;
}
public static void setTheme(VisualiserTheme theme_in){
theme= theme_in;
}
public static Component getFrontWindow() {
Component res = null;
try {
res = windowsStack.peek();
} catch (Exception ignored){
}
return res;
}
//-----
public static void Clear(Container container) {
container.removeAll();
@@ -37,4 +65,42 @@ public class CommonUI {
}
}
}
public static void MakeSpinnerRapid(JSpinner spinner, ChangeListener listener) {
JComponent comp = spinner.getEditor();
JFormattedTextField field = (JFormattedTextField) comp.getComponent(0);
DefaultFormatter formatter = (DefaultFormatter) field.getFormatter();
formatter.setCommitsOnValidEdit(true);
formatter.setAllowsInvalid(true);
spinner.addChangeListener(listener);
}
//Примитивные диалоговые элементы
public static boolean Question(Component parent, String text) {
return !CommonUI.isActive() || (JOptionPane.showConfirmDialog(parent,
text + "?",
"Подтверждение",
JOptionPane.YES_NO_OPTION,
JOptionPane.QUESTION_MESSAGE) == 0);
}
public static boolean Question(String text) {
return Question(getFrontWindow(), text);
}
public static void Info(String message) {
CommonUtils.CopyToClipboard(message);
if (CommonUI.isActive())
JOptionPane.showMessageDialog(getFrontWindow(), message, "", 1);
}
public static void Error(String message) {
CommonUtils.CopyToClipboard(message);
if (CommonUI.isActive())
JOptionPane.showMessageDialog(getFrontWindow(), message, "", 0);
}
public static boolean Warning(String text) {
return !CommonUI.isActive() ||
JOptionPane.showConfirmDialog(getFrontWindow(),
text + "\nВы уверены?",
"Подтверждение",
JOptionPane.YES_NO_OPTION,
JOptionPane.WARNING_MESSAGE) == 0;
}
//--
}