package yukihane.inqubus;
-import java.nio.file.FileSystem;
-import java.nio.file.FileSystems;
+import java.io.IOException;
import java.nio.file.Path;
+import java.nio.file.Paths;
import java.util.logging.Level;
import java.util.logging.Logger;
+import javax.swing.JOptionPane;
import javax.swing.UIManager;
import javax.swing.UIManager.LookAndFeelInfo;
import javax.swing.UnsupportedLookAndFeelException;
import org.apache.commons.configuration.ConfigurationException;
+import yukihane.inqubus.config.Config;
import yukihane.inqubus.gui.MainFrame;
+import yukihane.inqubus.saccubus.prompt.Prompt;
/**
* いんきゅばす起動クラス.
private static final Logger logger = Logger.getLogger(Main.class.getName());
public static void main(String args[]) {
- final FileSystem fileSystem = FileSystems.getDefault();
- final Path path = fileSystem.getPath("inqubus.xml");
+ final Path path = Paths.get("inqubus.xml");
+ boolean showWelcome;
try {
Config.INSTANCE.load(path.toString());
+ showWelcome = false;
} catch (ConfigurationException ex) {
- logger.log(Level.FINE, "コンフィグファイルが無いためデフォルト値で起動", ex);
+ showWelcome = true;
+ logger.log(Level.FINER, "コンフィグファイルが無いためデフォルト値で起動", ex);
}
- setLookAndFeel();
- java.awt.EventQueue.invokeLater(new Runnable() {
- public void run() {
- new MainFrame().setVisible(true);
+ // 第1引数がメールアドレスと思しき時はさきゅばすフォーマットのコマンドラインであるとみなしてパース
+ if (args.length > 0 && args[0].contains("@")) {
+ try {
+ new Prompt().main(args);
+ } catch (Exception ex) {
+ logger.log(Level.SEVERE, "処理が正常終了しませんでした", ex);
}
- });
+ return;
+ }
+
+ final RunWindow invoke = new RunWindow(showWelcome);
+ java.awt.EventQueue.invokeLater(invoke);
+ }
+
+ private static class RunWindow implements Runnable {
+
+ private final boolean showWelcome;
+
+ private RunWindow(boolean showWelcome) {
+ this.showWelcome = showWelcome;
+ }
+
+ @Override
+ public void run() {
+ setLookAndFeel();
+ final MainFrame frame = new MainFrame();
+ frame.startWatcher();
+ frame.setVisible(true);
+ if (showWelcome) {
+ JOptionPane.showMessageDialog(frame,
+ "<html>設定はメニューの <b>ツール > オプション</b> から行えます</html>",
+ "いんきゅばすへようこそ", JOptionPane.INFORMATION_MESSAGE);
+ }
+ }
}
private static void setLookAndFeel() {