no message
This commit is contained in:
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();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user