package istlab.KisoJikken;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import javax.swing.JOptionPane;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
/**
* Hello world!
*
*/
public class App {
public static String userhome;
public static String nwpsrc = File.separator+"NWP"+File.separator+"src";
public static String gitrepos = "https://git.istlab.info/git/miura250/NWP.git";
public static void main(String[] args) {
// ファイルがあるかチェック
userhome = System.getProperty("user.home");
getNWPifnotexist(false);
SwingUtilities.invokeLater(() -> {
try {
String laf = UIManager.getSystemLookAndFeelClassName();
UIManager.setLookAndFeel(laf);
} catch (Exception e) {
/* Never happens */ }
new Launcher(args).setVisible(true);
});
}
public static void getNWPifnotexist(boolean showMessageIfExist){
if (Files.notExists(Paths.get(userhome + nwpsrc))) {
int res = JOptionPane.showConfirmDialog(Launcher.theapp, "NWP実験用のファイルが " + userhome + nwpsrc + " にありません。ダウンロードしますか?");
if (res == JOptionPane.YES_OPTION) {
System.out.println("cd ; git clone "+gitrepos+" を実行。");
ProcessBuilder processBuilder = new ProcessBuilder("git", "clone", gitrepos);
processBuilder.directory(new File(userhome));
processBuilder.inheritIO();
try {
Process process;
process = processBuilder.start();
process.waitFor();
} catch (IOException | InterruptedException e1) {
e1.printStackTrace();
}
} else {
System.out.println("cd ; git clone "+gitrepos+" を実行してください。");
System.exit(0);
}
} else {
if (showMessageIfExist) JOptionPane.showMessageDialog(Launcher.theapp, "NWP実験用のファイルが " + userhome + nwpsrc + " にすでにあるため、ダウンロードをキャンセルしました。");
}
}
}