From 254d328cabeddb2a3f957b32b2b323c1a844d9da Mon Sep 17 00:00:00 2001 From: hptruong93 Date: Mon, 23 May 2022 14:32:09 -0400 Subject: [PATCH] Remove usage of JOptionPane in favor of logging. --- src/frontEnd/MainBackEndHolder.java | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/src/frontEnd/MainBackEndHolder.java b/src/frontEnd/MainBackEndHolder.java index 81a187f..47b6823 100644 --- a/src/frontEnd/MainBackEndHolder.java +++ b/src/frontEnd/MainBackEndHolder.java @@ -17,8 +17,6 @@ import java.util.logging.Logger; import java.util.stream.Collectors; -import javax.swing.JOptionPane; - import org.jnativehook.GlobalScreen; import core.config.AbstractRemoteRepeatsClientsConfig; @@ -378,7 +376,7 @@ protected synchronized void switchRunningCompiledAction() { } } else { if (customFunction == null) { - JOptionPane.showMessageDialog(null, "No compiled action in memory"); + LOGGER.warning("No compiled action in memory"); return; } @@ -581,12 +579,12 @@ public void editSourceCode(String source) { FileUtility.writeToFile(source, tempSourceFile, false); } catch (IOException e) { - JOptionPane.showMessageDialog(null, "Encountered error creating temporary source file.\n" + e.getMessage()); + LOGGER.warning("Encountered error creating temporary source file.\n" + e.getMessage()); return; } if (!Desktop.openFile(tempSourceFile)) { - JOptionPane.showMessageDialog(null, "Unable to open file for editting.\n"); + LOGGER.warning("Unable to open file for editting.\n"); } } @@ -595,13 +593,13 @@ public void editSourceCode(String source) { */ public String reloadSourceCode() { if (tempSourceFile == null || !tempSourceFile.exists()) { - JOptionPane.showMessageDialog(null, "Temp file not accessible."); + LOGGER.warning("Temp file not accessible."); return null; } StringBuffer sourceCode = FileUtility.readFromFile(tempSourceFile); if (sourceCode == null) { - JOptionPane.showMessageDialog(null, "Unable to read from temp file."); + LOGGER.warning("Unable to read from temp file."); return null; } String source = sourceCode.toString(); @@ -611,7 +609,7 @@ public String reloadSourceCode() { private void unregisterTask(UserDefinedAction task) { keysManager.unregisterTask(task); if (!TaskSourceManager.removeTask(task)) { - JOptionPane.showMessageDialog(null, "Encountered error removing source file " + task.getSourcePath()); + LOGGER.warning("Encountered error removing source file " + task.getSourcePath()); } } @@ -888,7 +886,6 @@ public void importTasks(File inputFile) { boolean moved = FileUtility.moveDirectory(src, dst); if (!moved) { LOGGER.warning("Failed to move files from " + src.getAbsolutePath() + " to " + dst.getAbsolutePath()); - JOptionPane.showMessageDialog(null, "Failed to move files."); return; } int existingGroupCount = taskGroups.size(); @@ -899,13 +896,13 @@ public void importTasks(File inputFile) { currentGroup = taskGroups.get(existingGroupCount); // Take the new group with lowest index. setTaskInvoker(); } else { - JOptionPane.showMessageDialog(null, "No new task group found!"); + LOGGER.warning("No new task group found!"); return; } if (result) { - JOptionPane.showMessageDialog(null, "Successfully imported tasks. Switching to a new task group..."); + LOGGER.info("Successfully imported tasks. Switching to a new task group..."); } else { - JOptionPane.showMessageDialog(null, "Encountered error(s) while importing tasks. Switching to a new task group..."); + LOGGER.warning("Encountered error(s) while importing tasks. Switching to a new task group..."); } } @@ -929,7 +926,7 @@ public void exportTasks(File outputDirectory) { ZipUtility.zipDir(destination, zipFile); FileUtility.deleteFile(destination); - JOptionPane.showMessageDialog(null, "Data exported to " + zipPath); + LOGGER.info("Data exported to " + zipPath); } public void cleanUnusedSource() {