Skip to content

Commit

Permalink
added context menu for text fields
Browse files Browse the repository at this point in the history
  • Loading branch information
subhra74 committed Nov 14, 2019
1 parent 432236c commit d8e118a
Show file tree
Hide file tree
Showing 20 changed files with 116 additions and 33 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.9.10</version>
<version>2.10.1</version>
</dependency>

<!-- https://mvnrepository.com/artifact/com.fifesoft/rstaui -->
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/snowflake/App.java
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.*;
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.*;
Expand Down Expand Up @@ -143,7 +144,7 @@ public TextEditor(
setFontSize(fontSize);
});

txtFullFilePath = new JTextField();
txtFullFilePath = GraphicsUtils.createTextField();//new JTextField();
txtFullFilePath.setEditable(false);
txtFullFilePath.setBorder(null);

Expand Down Expand Up @@ -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");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.*;
Expand All @@ -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");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
});
Expand All @@ -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);
Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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();
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -185,7 +185,7 @@ private void updatePassword() {
}
});

inpLocalFolder = new JTextField(30);
inpLocalFolder = GraphicsUtils.createTextField(30);//new JTextField(30);
inpLocalFolder.getDocument()
.addDocumentListener(new DocumentListener() {

Expand All @@ -209,7 +209,7 @@ private void updateFolder() {
}
});

inpRemoteFolder = new JTextField(30);
inpRemoteFolder = GraphicsUtils.createTextField(30);//new JTextField(30);
inpRemoteFolder.getDocument()
.addDocumentListener(new DocumentListener() {

Expand Down Expand Up @@ -243,7 +243,7 @@ private void updateFolder() {
}
});

inpKeyFile = new JTextField(30);
inpKeyFile = GraphicsUtils.createTextField(30);//new JTextField(30);
inpKeyFile.getDocument().addDocumentListener(new DocumentListener() {

@Override
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/snowflake/components/sysinfo/ServicePanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,10 @@ public void addEntry(ServiceEntry e) {
}

public void addEntries(List<ServiceEntry> entries) {
list.addAll(entries);
fireTableDataChanged();
if(entries!=null){
list.addAll(entries);
fireTableDataChanged();
}
}

@Override
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/snowflake/components/sysinfo/SocketPanel.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package snowflake.components.sysinfo;

import snowflake.utils.GraphicsUtils;

import javax.swing.*;
import javax.swing.border.EmptyBorder;
import java.awt.*;
Expand Down Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package snowflake.components.terminal.snippets;

import snowflake.App;
import snowflake.utils.GraphicsUtils;

import javax.swing.*;
import javax.swing.border.EmptyBorder;
Expand Down Expand Up @@ -31,7 +32,7 @@ public SnippetPanel(Consumer<String> callback, Consumer<String> 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) {
Expand All @@ -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},
Expand All @@ -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());
Expand Down
Loading

0 comments on commit d8e118a

Please sign in to comment.