always show profile link

This commit is contained in:
rusefi 2020-07-21 20:29:07 -04:00
parent f9dc225da3
commit bcdd030566
1 changed files with 12 additions and 13 deletions

View File

@ -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) {