Untitled

 avatar
unknown
plain_text
2 years ago
1.4 kB
4
Indexable
package utils;

import java.io.File;
import java.util.Map;
import javafx.scene.control.TextArea;
import javafx.scene.input.Clipboard;
import javafx.scene.input.ClipboardContent;

public class TRVManager {
  private static String dirPath = (new File("")).getAbsolutePath() + File.separator + "files";
  
  private static final String jarFileName = "TestResultViewer.jar";
  
  public static void openTRV(File baseFile, TextArea textArea) {
    String command = "java -jar " + dirPath + File.separator + "TestResultViewer.jar";
    if (baseFile != null)
      command = command + " \"" + baseFile.getPath() + "\""; 
    String text_1 = "1. The command below is saved on the clipboard.\nUse Ctrl + Shift + V right away in Terminal.\n\n" + command + "\n\n\n";
    String text_2 = "2. If the TRV is on a different path, just change the TRV path. ( TestResultViewer.jar)";
    copyCommandOnClipboard(command);
    setTRVcommandOnTextArea(textArea, text_1 + text_2);
  }
  
  private static void copyCommandOnClipboard(String command) {
    Clipboard clipboard = Clipboard.getSystemClipboard();
    ClipboardContent content = new ClipboardContent();
    content.putString(command);
    clipboard.setContent((Map)content);
  }
  
  private static void setTRVcommandOnTextArea(TextArea textArea, String text) {
    textArea.clear();
    textArea.setText(text);
  }
}
Editor is loading...