Skip to content

Commit

Permalink
spotless
Browse files Browse the repository at this point in the history
  • Loading branch information
CDaut committed Oct 11, 2024
1 parent 38c2c97 commit 8488187
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -92,16 +92,15 @@ public class ArtemisSettings implements Configurable {
// Button to log out of artemis
var logoutButton = new JButton("Logout");
logoutButton.addActionListener(a -> {
//request a logout
// request a logout
boolean loggedOut = PluginState.getInstance().logout();
//clear data iff logout was actually carried out
// clear data iff logout was actually carried out
if (loggedOut) {
ArtemisCredentialsProvider.getInstance().setJwt(null);
ArtemisCredentialsProvider.getInstance().setArtemisPassword(null);
ArtemisSettingsState.getInstance().setJwtExpiry(null);
this.apply();
}

});
contentPanel.add(logoutButton, "span 1, growx");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public static void resetCookies() {
.setOffScreenRendering(false)
.build();

//clear cookies
// clear cookies
CefApp.getInstance().onInitialization(state -> {
browser.getJBCefCookieManager().deleteCookies(null, null);
});
Expand All @@ -68,7 +68,6 @@ public static CompletableFuture<JBCefCookie> jcefBrowserLogin() {
.setUrl(ArtemisSettingsState.getInstance().getArtemisInstanceUrl())
.build();


// set focus handler because it gets invoked sometimes and causes NullPE otherwise
CefFocusHandler focusHandler = new CefWindowFocusHandler();
browserClient.addFocusHandler(focusHandler, browser.getCefBrowser());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
import java.util.concurrent.ExecutionException;
import java.util.function.Consumer;

import javax.swing.*;

import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.fileEditor.FileEditorManager;
Expand All @@ -38,11 +40,8 @@
import edu.kit.kastel.sdq.intelligrade.utils.ArtemisUtils;
import edu.kit.kastel.sdq.intelligrade.utils.IntellijUtil;
import org.apache.commons.io.FileUtils;
import org.cef.CefApp;
import org.jetbrains.annotations.NotNull;

import javax.swing.*;

public class PluginState {
private static final Logger LOG = Logger.getInstance(PluginState.class);

Expand Down Expand Up @@ -71,17 +70,20 @@ public static PluginState getInstance() {
*/
public boolean logout() {
int answer = JOptionPane.OK_OPTION;
//check if confirmation is necessary because assessment is running
// check if confirmation is necessary because assessment is running
if (isAssessing()) {
answer = JOptionPane.showConfirmDialog(null,
answer = JOptionPane.showConfirmDialog(
null,
"Logging out while assessing will terminate the current assessment. Continue?",
"Logging out while assessing!", JOptionPane.OK_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE);
"Logging out while assessing!",
JOptionPane.OK_CANCEL_OPTION,
JOptionPane.WARNING_MESSAGE);
}
//actually reset state
// actually reset state
if (answer == JOptionPane.OK_OPTION) {
this.resetState();

//reset JBCef cookies iff available
// reset JBCef cookies iff available
if (JBCefApp.isSupported()) {
CefUtils.resetCookies();
}
Expand Down

0 comments on commit 8488187

Please sign in to comment.