From bcdd030566f6760e4191e46b13b3d39820a0f8dd Mon Sep 17 00:00:00 2001 From: rusefi Date: Tue, 21 Jul 2020 20:29:07 -0400 Subject: [PATCH] always show profile link --- .../src/com/rusefi/ui/AuthTokenPanel.java | 25 +++++++++---------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/java_console/shared_ui/src/com/rusefi/ui/AuthTokenPanel.java b/java_console/shared_ui/src/com/rusefi/ui/AuthTokenPanel.java index e77e5b4a9b..e0b700fe7f 100644 --- a/java_console/shared_ui/src/com/rusefi/ui/AuthTokenPanel.java +++ b/java_console/shared_ui/src/com/rusefi/ui/AuthTokenPanel.java @@ -17,12 +17,11 @@ import static com.rusefi.ui.storage.PersistentConfiguration.getConfig; public class AuthTokenPanel { private static final String TOKEN_WARNING = "Please copy token from your forum profile"; - private static final String TOKEN_SUBSTRING = "token"; private static final String AUTH_TOKEN = "auth_token"; private static final String TOKEN_PROFILE_URL = "https://rusefi.com/forum/ucp.php?i=254"; - private JPanel content = new JPanel(new BorderLayout()); - private JTextField textField = new JTextField(); + private final JPanel content = new JPanel(new BorderLayout()); + private final JTextField authTokenTestField = new JTextField(); public AuthTokenPanel() { @@ -30,12 +29,12 @@ public class AuthTokenPanel { content.setBorder(BorderFactory.createTitledBorder("rusEFI Online Authentication Token")); - textField.setPreferredSize(new Dimension(200, 24)); + authTokenTestField.setPreferredSize(new Dimension(200, 24)); String authToken = getAuthToken(); System.out.println("Got from settings: " + authToken); - textField.getDocument().addDocumentListener(new DocumentListener() { + authTokenTestField.getDocument().addDocumentListener(new DocumentListener() { @Override public void insertUpdate(DocumentEvent e) { onTextChange(); @@ -61,7 +60,7 @@ public class AuthTokenPanel { try { String data = (String) clipboard.getData(DataFlavor.stringFlavor); if (AutoTokenUtil.isToken(data)) { - textField.setText(data); + authTokenTestField.setText(data); } } catch (IOException | UnsupportedFlavorException ex) { // ignoring this exception @@ -75,7 +74,7 @@ public class AuthTokenPanel { setPasteButtonEnabledBasedOnClipboardContent(clipboard, paste); - top.add(textField); + top.add(authTokenTestField); top.add(paste); /* JButton save = new JButton("Save"); @@ -90,9 +89,9 @@ public class AuthTokenPanel { content.add(top); if (authToken.trim().isEmpty()) { authToken = TOKEN_WARNING; - content.add(new URLLabel("Get your token from your forum profile", TOKEN_PROFILE_URL), BorderLayout.SOUTH); } - textField.setText(authToken); + content.add(new URLLabel("Manage authentication token at your forum profile", TOKEN_PROFILE_URL), BorderLayout.SOUTH); + authTokenTestField.setText(authToken); } private void setPasteButtonEnabledBasedOnClipboardContent(Clipboard clipboard, JButton paste) { @@ -105,12 +104,12 @@ public class AuthTokenPanel { } private void grabText() { - setAuthToken(AuthTokenPanel.this.textField.getText()); + setAuthToken(AuthTokenPanel.this.authTokenTestField.getText()); PersistentConfiguration.getConfig().save(); } private void onTextChange() { - if (AutoTokenUtil.isToken(textField.getText())) { + if (AutoTokenUtil.isToken(authTokenTestField.getText())) { grabText(); } } @@ -129,11 +128,11 @@ public class AuthTokenPanel { } public boolean hasToken() { - return AutoTokenUtil.isToken(textField.getText()); + return AutoTokenUtil.isToken(authTokenTestField.getText()); } public String getToken() { - return textField.getText(); + return authTokenTestField.getText(); } public void showError(JComponent parent) {