2024-10-07 00:58:29 +03:00
|
|
|
package Common_old.UI.Menus;
|
2024-10-07 14:22:52 +03:00
|
|
|
import Common.CommonConstants;
|
2024-10-07 22:04:09 +03:00
|
|
|
import Common.Utils.CommonUtils;
|
2023-09-17 22:13:42 +03:00
|
|
|
|
|
|
|
|
import javax.swing.*;
|
|
|
|
|
public class TableMenu extends StyledPopupMenu {
|
2024-10-07 14:22:52 +03:00
|
|
|
int row = CommonConstants.Nan;
|
|
|
|
|
int column = CommonConstants.Nan;
|
2023-09-17 22:13:42 +03:00
|
|
|
Object target = null;
|
|
|
|
|
//-
|
|
|
|
|
JTable owner = null;
|
|
|
|
|
VisualiserMenuItem mcopy;
|
|
|
|
|
public TableMenu(JTable owner_in) {
|
|
|
|
|
owner = owner_in;
|
|
|
|
|
mcopy = new VisualiserMenuItem("Копировать текст текущей ячейки", "/icons/Editor/Copy.png");
|
|
|
|
|
//если удалось нажать значит все условия выполнены
|
2024-10-07 22:04:09 +03:00
|
|
|
mcopy.addActionListener(e -> CommonUtils.CopyToClipboard(target.toString()));
|
2023-09-17 22:13:42 +03:00
|
|
|
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();
|
|
|
|
|
}
|
|
|
|
|
}
|