no message
This commit is contained in:
56
src/Common/Visual/Menus/DataMenuBar.java
Normal file
56
src/Common/Visual/Menus/DataMenuBar.java
Normal file
@@ -0,0 +1,56 @@
|
||||
package Common.Visual.Menus;
|
||||
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));
|
||||
}
|
||||
}
|
||||
38
src/Common/Visual/Menus/StyledPopupMenu.java
Normal file
38
src/Common/Visual/Menus/StyledPopupMenu.java
Normal file
@@ -0,0 +1,38 @@
|
||||
package Common.Visual.Menus;
|
||||
import Common.Visual.CommonUI;
|
||||
import Common.Visual.Themes.ThemeElement;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.PopupMenuEvent;
|
||||
import javax.swing.event.PopupMenuListener;
|
||||
public class StyledPopupMenu extends JPopupMenu implements ThemeElement {
|
||||
public StyledPopupMenu() {
|
||||
addPopupMenuListener(new PopupMenuListener() {
|
||||
@Override
|
||||
public void popupMenuWillBecomeVisible(PopupMenuEvent e) {
|
||||
CheckElementsVisibility();
|
||||
}
|
||||
@Override
|
||||
public void popupMenuWillBecomeInvisible(PopupMenuEvent e) {
|
||||
}
|
||||
@Override
|
||||
public void popupMenuCanceled(PopupMenuEvent e) {
|
||||
}
|
||||
});
|
||||
}
|
||||
private void refreshTheme_r(MenuElement element) {
|
||||
element.getComponent().setBackground(CommonUI.getTheme().background);
|
||||
element.getComponent().setForeground(CommonUI.getTheme().foreground);
|
||||
for (MenuElement se : element.getSubElements())
|
||||
refreshTheme_r(se);
|
||||
}
|
||||
@Override
|
||||
public void applyTheme() {
|
||||
setBackground(CommonUI.getTheme().background);
|
||||
setForeground(CommonUI.getTheme().foreground);
|
||||
refreshTheme_r(this);
|
||||
}
|
||||
public void CheckElementsVisibility() {
|
||||
applyTheme();
|
||||
}
|
||||
}
|
||||
32
src/Common/Visual/Menus/TableMenu.java
Normal file
32
src/Common/Visual/Menus/TableMenu.java
Normal file
@@ -0,0 +1,32 @@
|
||||
package Common.Visual.Menus;
|
||||
import Common.CommonConstants;
|
||||
import Common.Utils.CommonUtils;
|
||||
import Common.Visual.Menus.StyledPopupMenu;
|
||||
import Common.Visual.Menus.VisualiserMenuItem;
|
||||
|
||||
import javax.swing.*;
|
||||
public class TableMenu extends StyledPopupMenu {
|
||||
int row = CommonConstants.Nan;
|
||||
int column = CommonConstants.Nan;
|
||||
Object target = null;
|
||||
//-
|
||||
JTable owner = null;
|
||||
VisualiserMenuItem mcopy;
|
||||
public TableMenu(JTable owner_in) {
|
||||
owner = owner_in;
|
||||
mcopy = new VisualiserMenuItem("Копировать текст текущей ячейки", "/icons/Editor/Copy.png");
|
||||
//если удалось нажать значит все условия выполнены
|
||||
mcopy.addActionListener(e -> CommonUtils.CopyToClipboard(target.toString()));
|
||||
add(mcopy);
|
||||
}
|
||||
@Override
|
||||
public void CheckElementsVisibility() {
|
||||
row = owner.getSelectedRow();
|
||||
column = owner.getSelectedColumn();
|
||||
if ((row >= 0) && (column >= 0)) {
|
||||
target = owner.getValueAt(row, column);
|
||||
mcopy.setVisible(true);
|
||||
} else mcopy.setVisible(false);
|
||||
super.CheckElementsVisibility();
|
||||
}
|
||||
}
|
||||
44
src/Common/Visual/Menus/TextComboBoxMenu.java
Normal file
44
src/Common/Visual/Menus/TextComboBoxMenu.java
Normal file
@@ -0,0 +1,44 @@
|
||||
package Common.Visual.Menus;
|
||||
import Common.Utils.CommonUtils;
|
||||
import Common.Visual.CommonUI;
|
||||
import Common.Visual.Menus.StyledPopupMenu;
|
||||
import Common.Visual.Menus.VisualiserMenuItem;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
public class TextComboBoxMenu extends StyledPopupMenu {
|
||||
protected JComboBox<String> box;
|
||||
protected String selectedText = null;
|
||||
//-------------------------------------------------
|
||||
JMenuItem m_copy;
|
||||
JMenuItem m_paste;
|
||||
//-------------------------------------------------
|
||||
public TextComboBoxMenu(JComboBox<String> box_in) {
|
||||
box = box_in;
|
||||
m_copy = new VisualiserMenuItem("Копировать", "/icons/Editor/Copy.png");
|
||||
m_copy.addActionListener(
|
||||
new AbstractAction() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
CommonUtils.CopyToClipboard(box.getSelectedItem().toString());
|
||||
}
|
||||
});
|
||||
add(m_copy);
|
||||
m_paste = new VisualiserMenuItem("Вставить", "/icons/Editor/Paste.png");
|
||||
m_paste.addActionListener(
|
||||
new AbstractAction() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
CommonUI.TrySelect(box, CommonUtils.getFromClipboard());
|
||||
}
|
||||
});
|
||||
add(m_paste);
|
||||
}
|
||||
@Override
|
||||
public void CheckElementsVisibility() {
|
||||
boolean visible_ = box.getSelectedIndex() >= 0;
|
||||
m_paste.setVisible(visible_);
|
||||
m_copy.setVisible(visible_);
|
||||
super.CheckElementsVisibility();
|
||||
}
|
||||
}
|
||||
88
src/Common/Visual/Menus/TextEditorMenu.java
Normal file
88
src/Common/Visual/Menus/TextEditorMenu.java
Normal file
@@ -0,0 +1,88 @@
|
||||
package Common.Visual.Menus;
|
||||
import Common.Utils.CommonUtils;
|
||||
import Common.Visual.Menus.StyledPopupMenu;
|
||||
import Common.Visual.Menus.VisualiserMenuItem;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.text.JTextComponent;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.util.Vector;
|
||||
public class TextEditorMenu extends StyledPopupMenu {
|
||||
protected JTextComponent editor;
|
||||
protected String selectedText = null;
|
||||
//-------------------------------------------------
|
||||
JMenuItem m_cut;
|
||||
JMenuItem m_copy;
|
||||
JMenuItem m_paste;
|
||||
protected JMenuItem m_strike;
|
||||
protected JMenuItem m_unstrike;
|
||||
//-------------------------------------------------
|
||||
public TextEditorMenu(JTextComponent editor_in) {
|
||||
editor = editor_in;
|
||||
m_cut = new VisualiserMenuItem("Вырезать", "/icons/Editor/Cut.png");
|
||||
m_cut.addActionListener(new AbstractAction() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
editor.cut();
|
||||
}
|
||||
});
|
||||
add(m_cut);
|
||||
m_copy = new VisualiserMenuItem("Копировать", "/icons/Editor/Copy.png");
|
||||
m_copy.addActionListener(
|
||||
new AbstractAction() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
editor.copy();
|
||||
}
|
||||
});
|
||||
add(m_copy);
|
||||
m_paste = new VisualiserMenuItem("Вставить", "/icons/Editor/Paste.png");
|
||||
m_paste.addActionListener(
|
||||
new AbstractAction() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
editor.paste();
|
||||
}
|
||||
});
|
||||
add(m_paste);
|
||||
//--
|
||||
m_strike = new VisualiserMenuItem("Вычеркнуть","/icons/Editor/Strikethrough.png");
|
||||
m_strike.addActionListener(
|
||||
new AbstractAction() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
String[] data = selectedText.split("\n");
|
||||
Vector<String> new_data = new Vector<>();
|
||||
for (String line: data){
|
||||
new_data.add(CommonUtils.strikeThrough(line));
|
||||
}
|
||||
editor.replaceSelection(String.join("\n", new_data));
|
||||
}
|
||||
});
|
||||
add(m_strike);
|
||||
m_unstrike = new VisualiserMenuItem("Отменить вычёркивание","/icons/Editor/NoStrike.png");
|
||||
m_unstrike.addActionListener(
|
||||
new AbstractAction() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
String[] data = selectedText.split("\n");
|
||||
Vector<String> new_data = new Vector<>();
|
||||
for (String line: data){
|
||||
new_data.add(CommonUtils.noStrikeThrough(line));
|
||||
}
|
||||
editor.replaceSelection(String.join("\n", new_data));
|
||||
}
|
||||
});
|
||||
add(m_unstrike);
|
||||
}
|
||||
@Override
|
||||
public void CheckElementsVisibility() {
|
||||
selectedText = editor.getSelectedText();
|
||||
m_cut.setVisible(editor.isEditable() && (selectedText != null));
|
||||
m_paste.setVisible(editor.isEditable());
|
||||
m_copy.setVisible(selectedText != null);
|
||||
m_strike.setVisible(editor.isEditable() && (selectedText != null));
|
||||
m_unstrike.setVisible(editor.isEditable() && (selectedText != null));
|
||||
super.CheckElementsVisibility();
|
||||
}
|
||||
}
|
||||
21
src/Common/Visual/Menus/VisualiserMenuItem.java
Normal file
21
src/Common/Visual/Menus/VisualiserMenuItem.java
Normal file
@@ -0,0 +1,21 @@
|
||||
package Common.Visual.Menus;
|
||||
import Common.Utils.CommonUtils;
|
||||
import Common.Visual.CommonUI;
|
||||
import Common.Visual.Fonts.VisualiserFonts;
|
||||
|
||||
import javax.swing.*;
|
||||
public class VisualiserMenuItem extends JMenuItem {
|
||||
public VisualiserMenuItem(String text) {
|
||||
super(text, null);
|
||||
setFont(CommonUI.getTheme().Fonts.get(VisualiserFonts.Menu));
|
||||
}
|
||||
public VisualiserMenuItem(String text, String icon_path) {
|
||||
super(text);
|
||||
setFont(CommonUI.getTheme().Fonts.get(VisualiserFonts.Menu));
|
||||
if (icon_path != null)
|
||||
setIcon(CommonUtils.getIcon(icon_path));
|
||||
}
|
||||
public VisualiserMenuItem(){
|
||||
setFont(CommonUI.getTheme().Fonts.get(VisualiserFonts.Menu));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user