diff --git a/pom.xml b/pom.xml index 35d7302e..6734d2ca 100644 --- a/pom.xml +++ b/pom.xml @@ -80,7 +80,7 @@ com.fasterxml.jackson.core jackson-databind - 2.9.10 + 2.10.1 diff --git a/src/main/java/snowflake/App.java b/src/main/java/snowflake/App.java index 7e9b16a9..5adcbe9e 100644 --- a/src/main/java/snowflake/App.java +++ b/src/main/java/snowflake/App.java @@ -25,8 +25,8 @@ import java.util.Properties; public class App { - public static final String APP_VERSION = "102"; - public static final String APP_VERSION_STR = "1.0.2"; + public static final String APP_VERSION = "103"; + public static final String APP_VERSION_STR = "1.0.3"; public static UIDefaults comboBoxSkin = new UIDefaults(); public static UIDefaults toolBarButtonSkin = new UIDefaults(); public static UIDefaults scrollBarSkin = new UIDefaults(); diff --git a/src/main/java/snowflake/common/ssh/AbstractUserInteraction.java b/src/main/java/snowflake/common/ssh/AbstractUserInteraction.java index eef8c9cc..dabc3e65 100644 --- a/src/main/java/snowflake/common/ssh/AbstractUserInteraction.java +++ b/src/main/java/snowflake/common/ssh/AbstractUserInteraction.java @@ -4,6 +4,7 @@ import com.jcraft.jsch.UserInfo; import snowflake.App; import snowflake.components.newsession.SessionInfo; +import snowflake.utils.GraphicsUtils; import javax.swing.*; import javax.swing.border.LineBorder; @@ -59,7 +60,7 @@ public String[] promptKeyboardInteractive(String destination, String name, System.out.println(s); list.add(new JLabel(s)); if (echo[i++]) { - JTextField txt = new JTextField(30); + JTextField txt = GraphicsUtils.createTextField(30);//new JTextField(30); list.add(txt); } else { JPasswordField pass = new JPasswordField(30); diff --git a/src/main/java/snowflake/components/diskusage/DiskUsageAnalyzer.java b/src/main/java/snowflake/components/diskusage/DiskUsageAnalyzer.java index 344233d4..be31588c 100644 --- a/src/main/java/snowflake/components/diskusage/DiskUsageAnalyzer.java +++ b/src/main/java/snowflake/components/diskusage/DiskUsageAnalyzer.java @@ -5,6 +5,7 @@ import snowflake.components.common.DisabledPanel; import snowflake.components.common.StartPage; import snowflake.components.newsession.SessionInfo; +import snowflake.utils.GraphicsUtils; import snowflake.utils.SshCommandUtils; import javax.swing.*; @@ -188,7 +189,7 @@ private void analyze(String path) { private Component createFolderBox() { JLabel folderLabel = new JLabel("Enter the folder path to analyze"); - textField = new JTextField(30); + textField = GraphicsUtils.createTextField(30);//new JTextField(30); textField.setMaximumSize(new Dimension(Integer.MAX_VALUE, textField.getPreferredSize().height)); folderLabel.setAlignmentX(Box.LEFT_ALIGNMENT); textField.setAlignmentX(Box.LEFT_ALIGNMENT); diff --git a/src/main/java/snowflake/components/files/browser/ssh/SshFileOperations.java b/src/main/java/snowflake/components/files/browser/ssh/SshFileOperations.java index 8167684e..2c741918 100644 --- a/src/main/java/snowflake/components/files/browser/ssh/SshFileOperations.java +++ b/src/main/java/snowflake/components/files/browser/ssh/SshFileOperations.java @@ -5,6 +5,7 @@ import snowflake.common.FileSystem; import snowflake.common.FileType; import snowflake.common.ssh.SshClient; +import snowflake.utils.GraphicsUtils; import snowflake.utils.PathUtils; import snowflake.utils.SshCommandUtils; import snowflake.utils.SudoUtils; @@ -343,8 +344,8 @@ private boolean mkdirWithPrivilege(String path, String newFolder, SshClient clie } public boolean createLink(FileInfo[] files, FileSystem fs, SshClient client) { - JTextField txtLinkName = new JTextField(30); - JTextField txtFileName = new JTextField(30); + JTextField txtLinkName = GraphicsUtils.createTextField(30);//new JTextField(30); + JTextField txtFileName = GraphicsUtils.createTextField(30);//new JTextField(30); JCheckBox chkHardLink = new JCheckBox("Hardlink"); if (files.length > 0) { diff --git a/src/main/java/snowflake/components/files/editor/TextEditor.java b/src/main/java/snowflake/components/files/editor/TextEditor.java index 6f7b0f3c..e8301304 100644 --- a/src/main/java/snowflake/components/files/editor/TextEditor.java +++ b/src/main/java/snowflake/components/files/editor/TextEditor.java @@ -3,6 +3,7 @@ import snowflake.App; import snowflake.common.FileInfo; import snowflake.components.files.FileComponentHolder; +import snowflake.utils.GraphicsUtils; import snowflake.utils.LayoutUtils; import javax.swing.*; @@ -143,7 +144,7 @@ public TextEditor( setFontSize(fontSize); }); - txtFullFilePath = new JTextField(); + txtFullFilePath = GraphicsUtils.createTextField();//new JTextField(); txtFullFilePath.setEditable(false); txtFullFilePath.setBorder(null); @@ -227,7 +228,7 @@ public TextEditor( JLabel lblTitle = new JLabel("Please enter full path of the file below to open"); - JTextField txtFilePath = new JTextField(30); + JTextField txtFilePath = GraphicsUtils.createTextField(30);//new JTextField(30); JButton btnOpenFile = new JButton("Open"); JLabel lblTitle2 = new JLabel("Alternatively you can select the file from file browser"); diff --git a/src/main/java/snowflake/components/files/logviewer/LogPage.java b/src/main/java/snowflake/components/files/logviewer/LogPage.java index aeafa006..09c0fca9 100644 --- a/src/main/java/snowflake/components/files/logviewer/LogPage.java +++ b/src/main/java/snowflake/components/files/logviewer/LogPage.java @@ -7,6 +7,7 @@ import snowflake.common.ssh.SshClient; import snowflake.components.files.FileComponentHolder; import snowflake.utils.FormatUtils; +import snowflake.utils.GraphicsUtils; import snowflake.utils.PathUtils; import snowflake.utils.SshCommandUtils; @@ -46,7 +47,7 @@ public LogPage(String filePath, FileComponentHolder holder) { super(new BorderLayout()); this.filePath = filePath; this.holder = holder; - txtCurrentPage = new JTextField(); + txtCurrentPage = GraphicsUtils.createTextField();//new JTextField(); txtCurrentPage.addActionListener(e -> { System.out.println("Called"); int page = Integer.parseInt(txtCurrentPage.getText().trim()); diff --git a/src/main/java/snowflake/components/files/logviewer/LogViewerPanel.java b/src/main/java/snowflake/components/files/logviewer/LogViewerPanel.java index 8707cd06..3ac266a1 100644 --- a/src/main/java/snowflake/components/files/logviewer/LogViewerPanel.java +++ b/src/main/java/snowflake/components/files/logviewer/LogViewerPanel.java @@ -3,6 +3,7 @@ import snowflake.common.FileInfo; import snowflake.components.files.FileComponentHolder; import snowflake.components.files.editor.TabHeader; +import snowflake.utils.GraphicsUtils; import javax.swing.*; import java.awt.*; @@ -27,7 +28,7 @@ public LogViewerPanel(FileComponentHolder holder) { add(tabs, "Tabs"); JLabel lblTitle = new JLabel("Please enter full path of the file below to open"); - JTextField txtFilePath = new JTextField(30); + JTextField txtFilePath = GraphicsUtils.createTextField(30);//new JTextField(30); JButton btnOpenFile = new JButton("Open"); JLabel lblTitle2 = new JLabel("Alternatively you can select the file from file browser"); diff --git a/src/main/java/snowflake/components/files/logviewer/PagedLogSearchPanel.java b/src/main/java/snowflake/components/files/logviewer/PagedLogSearchPanel.java index 3110d193..e3561511 100644 --- a/src/main/java/snowflake/components/files/logviewer/PagedLogSearchPanel.java +++ b/src/main/java/snowflake/components/files/logviewer/PagedLogSearchPanel.java @@ -2,6 +2,7 @@ import com.google.common.primitives.Longs; import snowflake.App; +import snowflake.utils.GraphicsUtils; import javax.swing.*; import javax.swing.border.EmptyBorder; @@ -20,7 +21,7 @@ public class PagedLogSearchPanel extends JPanel { public PagedLogSearchPanel(SearchListener searchListener) { super(new BorderLayout()); this.searchListener = searchListener; - txtSearch = new JTextField(20); + txtSearch = GraphicsUtils.createTextField(20);//new JTextField(20); JButton btnSearch = new JButton(); btnSearch.putClientProperty("Nimbus.Overrides", App.toolBarButtonSkin); diff --git a/src/main/java/snowflake/components/files/search/FileSearchPanel.java b/src/main/java/snowflake/components/files/search/FileSearchPanel.java index 8b5c1ac9..5a659985 100644 --- a/src/main/java/snowflake/components/files/search/FileSearchPanel.java +++ b/src/main/java/snowflake/components/files/search/FileSearchPanel.java @@ -3,6 +3,7 @@ import snowflake.App; import snowflake.common.ssh.SshClient; import snowflake.components.files.FileComponentHolder; +import snowflake.utils.GraphicsUtils; import snowflake.utils.PathUtils; import snowflake.utils.ScriptLoader; import snowflake.utils.SshCommandUtils; @@ -80,7 +81,7 @@ public FileSearchPanel(FileComponentHolder holder) { JLabel lblName = new JLabel( "Search for"); lblName.setAlignmentX(LEFT_ALIGNMENT); - txtName = new JTextField(20); + txtName = GraphicsUtils.createTextField(20);//new JTextField(20); txtName.addActionListener(e -> { find(); }); @@ -90,7 +91,7 @@ public FileSearchPanel(FileComponentHolder holder) { JLabel lblFolder = new JLabel("Search in"); lblFolder.setAlignmentX(LEFT_ALIGNMENT); - txtFolder = new JTextField(20); + txtFolder = GraphicsUtils.createTextField(20);//new JTextField(20); txtFolder.setPreferredSize(pref); txtFolder.setMaximumSize(pref); txtFolder.setAlignmentX(LEFT_ALIGNMENT); @@ -107,7 +108,7 @@ public FileSearchPanel(FileComponentHolder holder) { lblSize.setAlignmentX(LEFT_ALIGNMENT); - txtSize = new JTextField(); + txtSize = GraphicsUtils.createTextField();//new JTextField(); txtSize.setAlignmentX(LEFT_ALIGNMENT); Dimension txtSizeD = new Dimension(60, txtSize.getPreferredSize().height); txtSize.setPreferredSize(txtSizeD); diff --git a/src/main/java/snowflake/components/keymanager/LocalKeyPanel.java b/src/main/java/snowflake/components/keymanager/LocalKeyPanel.java index 29d5eb34..b1b7f632 100644 --- a/src/main/java/snowflake/components/keymanager/LocalKeyPanel.java +++ b/src/main/java/snowflake/components/keymanager/LocalKeyPanel.java @@ -1,6 +1,7 @@ package snowflake.components.keymanager; import snowflake.components.newsession.SessionInfo; +import snowflake.utils.GraphicsUtils; import javax.swing.*; import javax.swing.border.EmptyBorder; @@ -20,7 +21,7 @@ public LocalKeyPanel(SessionInfo info, Consumer callback1, Consumer callba this.callback1 = callback1; this.callback2 = callback2; JLabel lblTitle = new JLabel("Public key file:"); - txtKeyFile = new JTextField(20); + txtKeyFile = GraphicsUtils.createTextField(20);//new JTextField(20); txtKeyFile.setBorder(null); txtKeyFile.setEditable(false); Box hbox = Box.createHorizontalBox(); diff --git a/src/main/java/snowflake/components/keymanager/RemoteKeyPanel.java b/src/main/java/snowflake/components/keymanager/RemoteKeyPanel.java index 0df34ca7..18647ad8 100644 --- a/src/main/java/snowflake/components/keymanager/RemoteKeyPanel.java +++ b/src/main/java/snowflake/components/keymanager/RemoteKeyPanel.java @@ -1,6 +1,7 @@ package snowflake.components.keymanager; import snowflake.components.newsession.SessionInfo; +import snowflake.utils.GraphicsUtils; import javax.swing.*; import javax.swing.border.EmptyBorder; @@ -25,7 +26,7 @@ public RemoteKeyPanel(SessionInfo info, Consumer callback1, Consumer callb this.callback2 = callback2; this.callback2 = callback3; JLabel lblTitle = new JLabel("Public key file:"); - txtKeyFile = new JTextField(20); + txtKeyFile = GraphicsUtils.createTextField(20);//new JTextField(20); txtKeyFile.setBorder(null); txtKeyFile.setEditable(false); Box hbox = Box.createHorizontalBox(); diff --git a/src/main/java/snowflake/components/newsession/NewSessionDlg.java b/src/main/java/snowflake/components/newsession/NewSessionDlg.java index 1147559c..f29d67a9 100644 --- a/src/main/java/snowflake/components/newsession/NewSessionDlg.java +++ b/src/main/java/snowflake/components/newsession/NewSessionDlg.java @@ -161,7 +161,7 @@ public void windowClosing(WindowEvent e) { lblName.setHorizontalAlignment(JLabel.LEADING); //lblName.setFont(Utility.getFont(Constants.SMALL)); - txtName = new JTextField(30); + txtName = GraphicsUtils.createTextField(30);//new JTextField(30); txtName.setAlignmentX(Component.LEFT_ALIGNMENT); //txtName.setFont(Utility.getFont(Constants.SMALL)); txtName.getDocument().addDocumentListener(new DocumentListener() { diff --git a/src/main/java/snowflake/components/newsession/SessionInfoPanel.java b/src/main/java/snowflake/components/newsession/SessionInfoPanel.java index 31e05249..4faf8e48 100644 --- a/src/main/java/snowflake/components/newsession/SessionInfoPanel.java +++ b/src/main/java/snowflake/components/newsession/SessionInfoPanel.java @@ -109,7 +109,7 @@ private void createUI() { lblRemoteFolder = new JLabel(TextHolder.getString("host.remotedir")); lblKeyFile = new JLabel(TextHolder.getString("host.keyfile")); - inpHostName = new JTextField(30); + inpHostName = GraphicsUtils.createTextField(30);// new JTextField(30); inpHostName.getDocument().addDocumentListener(new DocumentListener() { @Override @@ -139,7 +139,7 @@ public void stateChanged(ChangeEvent arg0) { } }); inpPort = new JSpinner(portModel); - inpUserName = new JTextField(30); + inpUserName = GraphicsUtils.createTextField(30);//new JTextField(30); inpUserName.getDocument().addDocumentListener(new DocumentListener() { @Override @@ -185,7 +185,7 @@ private void updatePassword() { } }); - inpLocalFolder = new JTextField(30); + inpLocalFolder = GraphicsUtils.createTextField(30);//new JTextField(30); inpLocalFolder.getDocument() .addDocumentListener(new DocumentListener() { @@ -209,7 +209,7 @@ private void updateFolder() { } }); - inpRemoteFolder = new JTextField(30); + inpRemoteFolder = GraphicsUtils.createTextField(30);//new JTextField(30); inpRemoteFolder.getDocument() .addDocumentListener(new DocumentListener() { @@ -243,7 +243,7 @@ private void updateFolder() { } }); - inpKeyFile = new JTextField(30); + inpKeyFile = GraphicsUtils.createTextField(30);//new JTextField(30); inpKeyFile.getDocument().addDocumentListener(new DocumentListener() { @Override diff --git a/src/main/java/snowflake/components/sysinfo/ServicePanel.java b/src/main/java/snowflake/components/sysinfo/ServicePanel.java index 0d20243b..e4790fff 100644 --- a/src/main/java/snowflake/components/sysinfo/ServicePanel.java +++ b/src/main/java/snowflake/components/sysinfo/ServicePanel.java @@ -3,6 +3,8 @@ */ package snowflake.components.sysinfo; +import snowflake.utils.GraphicsUtils; + import java.awt.BorderLayout; import java.awt.Dimension; import java.awt.event.ActionListener; @@ -65,7 +67,7 @@ public ServicePanel() { table.setFillsViewportHeight(true); JLabel lbl1 = new JLabel("Search"); - txtFilter = new JTextField(30); + txtFilter = GraphicsUtils.createTextField(30);//new JTextField(30); txtFilter.addActionListener(e -> { filter(); }); diff --git a/src/main/java/snowflake/components/sysinfo/ServiceTableModel.java b/src/main/java/snowflake/components/sysinfo/ServiceTableModel.java index 1c5a8ccb..9092a1f6 100644 --- a/src/main/java/snowflake/components/sysinfo/ServiceTableModel.java +++ b/src/main/java/snowflake/components/sysinfo/ServiceTableModel.java @@ -22,8 +22,10 @@ public void addEntry(ServiceEntry e) { } public void addEntries(List entries) { - list.addAll(entries); - fireTableDataChanged(); + if(entries!=null){ + list.addAll(entries); + fireTableDataChanged(); + } } @Override diff --git a/src/main/java/snowflake/components/sysinfo/SocketPanel.java b/src/main/java/snowflake/components/sysinfo/SocketPanel.java index a43f07a7..79eb2332 100644 --- a/src/main/java/snowflake/components/sysinfo/SocketPanel.java +++ b/src/main/java/snowflake/components/sysinfo/SocketPanel.java @@ -1,5 +1,7 @@ package snowflake.components.sysinfo; +import snowflake.utils.GraphicsUtils; + import javax.swing.*; import javax.swing.border.EmptyBorder; import java.awt.*; @@ -30,7 +32,7 @@ public SocketPanel() { table.setFillsViewportHeight(true); JLabel lbl1 = new JLabel("Search"); - txtFilter = new JTextField(30); + txtFilter = GraphicsUtils.createTextField(30);//new JTextField(30); btnFilter = new JButton("Search"); Box b1 = Box.createHorizontalBox(); diff --git a/src/main/java/snowflake/components/taskmgr/ProcessListPanel.java b/src/main/java/snowflake/components/taskmgr/ProcessListPanel.java index 6e2348fb..df5f21fb 100644 --- a/src/main/java/snowflake/components/taskmgr/ProcessListPanel.java +++ b/src/main/java/snowflake/components/taskmgr/ProcessListPanel.java @@ -1,5 +1,7 @@ package snowflake.components.taskmgr; +import snowflake.utils.GraphicsUtils; + import javax.swing.*; import javax.swing.border.EmptyBorder; import javax.swing.table.TableRowSorter; @@ -79,7 +81,7 @@ public boolean include( // b1.setBorder(new EmptyBorder(5, 5, 5, 5)); b1.add(new JLabel("Processes")); b1.add(Box.createHorizontalStrut(10)); - txtFilter = new JTextField(30); + txtFilter = GraphicsUtils.createTextField(30);//new JTextField(30); txtFilter.addActionListener(e -> { this.filterText = getProcessFilterText(); model.fireTableDataChanged(); diff --git a/src/main/java/snowflake/components/terminal/snippets/SnippetPanel.java b/src/main/java/snowflake/components/terminal/snippets/SnippetPanel.java index d5748d44..5c5a6b63 100644 --- a/src/main/java/snowflake/components/terminal/snippets/SnippetPanel.java +++ b/src/main/java/snowflake/components/terminal/snippets/SnippetPanel.java @@ -1,6 +1,7 @@ package snowflake.components.terminal.snippets; import snowflake.App; +import snowflake.utils.GraphicsUtils; import javax.swing.*; import javax.swing.border.EmptyBorder; @@ -31,7 +32,7 @@ public SnippetPanel(Consumer callback, Consumer callback2) { topBox.add(Box.createHorizontalStrut(10)); listView.setCellRenderer(new SnippetListRenderer()); - searchTextField = new JTextField(30); + searchTextField = GraphicsUtils.createTextField(30);//new JTextField(30); searchTextField.getDocument().addDocumentListener(new DocumentListener() { @Override public void insertUpdate(DocumentEvent e) { @@ -57,8 +58,8 @@ public void changedUpdate(DocumentEvent e) { btnCopy = new JButton("Copy"); btnAdd.addActionListener(e -> { - JTextField txtName = new JTextField(30); - JTextField txtCommand = new JTextField(30); + JTextField txtName = GraphicsUtils.createTextField(30);//new JTextField(30); + JTextField txtCommand = GraphicsUtils.createTextField(30);//new JTextField(30); if (JOptionPane.showOptionDialog(null, new Object[]{"Snippet name", txtName, "Command", txtCommand}, @@ -83,8 +84,8 @@ public void changedUpdate(DocumentEvent e) { SnippetItem snippetItem = listModel.get(index); - JTextField txtName = new JTextField(30); - JTextField txtCommand = new JTextField(30); + JTextField txtName = GraphicsUtils.createTextField(30);//new JTextField(30); + JTextField txtCommand = GraphicsUtils.createTextField(30);//new JTextField(30); txtName.setText(snippetItem.getName()); txtCommand.setText(snippetItem.getCommand()); diff --git a/src/main/java/snowflake/utils/GraphicsUtils.java b/src/main/java/snowflake/utils/GraphicsUtils.java index 71654308..4c1fa6e1 100644 --- a/src/main/java/snowflake/utils/GraphicsUtils.java +++ b/src/main/java/snowflake/utils/GraphicsUtils.java @@ -6,6 +6,8 @@ import javax.swing.*; import java.awt.*; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; public class GraphicsUtils { public static UIDefaults createSkinnedButton(UIDefaults btnSkin) { @@ -384,4 +386,66 @@ public void paint(Graphics2D g, Object object, int width, int height) { btnSkin.put("MenuItem[MouseOver].backgroundPainter", painter); return btnSkin; } + + private static JPopupMenu popup(JTextField c) { + JPopupMenu popup = new JPopupMenu(); + JMenuItem mCut = new JMenuItem("Cut"); + JMenuItem mCopy = new JMenuItem("Copy"); + JMenuItem mPaste = new JMenuItem("Paste"); + JMenuItem mSelect = new JMenuItem("Select all"); + + popup.add(mCut); + popup.add(mCopy); + popup.add(mPaste); + popup.add(mSelect); + + mCut.addActionListener(e -> { + c.cut(); + }); + + mCopy.addActionListener(e -> { + c.copy(); + }); + + mPaste.addActionListener(e -> { + c.paste(); + }); + + mSelect.addActionListener(e -> { + c.selectAll(); + }); + + return popup; + } + + private static void installPopUp(JTextField c) { + c.putClientProperty("flat.popup", popup(c)); + c.addMouseListener(new MouseAdapter() { + @Override + public void mouseClicked(MouseEvent e) { + System.out.println("Right click on text field"); + if (e.getButton() == MouseEvent.BUTTON3 + || e.isPopupTrigger()) { + + JPopupMenu pop = (JPopupMenu) c + .getClientProperty("flat.popup"); + if (pop != null) { + pop.show(c, e.getX(), e.getY()); + } + } + } + }); + } + + public static JTextField createTextField() { + JTextField c = new JTextField(); + installPopUp(c); + return c; + } + + public static JTextField createTextField(int n) { + JTextField c = new JTextField(n); + installPopUp(c); + return c; + } }