<|start_filename|>src/main/java/com/zbw/gitpic/utils/Preference.java<|end_filename|>
package com.zbw.gitpic.utils;

import java.util.Properties;

/**
 * @author zbw
 * @create 2018/2/27 22:51
 */
public class Preference {

    private static final Preference INSTANCE = new Preference();

    private Properties properties;

    private String projectPath;

    private String picPath;

    private String gitUsername;

    private String gitPassword;

    private Preference() {
        init();
    }

    public static Preference getInstance() {
        return INSTANCE;
    }

    private void init() {
        if (null == properties) {
            properties = PropsUtil.loadProps(Constants.SETTING_FILE);
        }
        projectPath = PropsUtil.getString(properties, Constants.SETTING_PROJECT_PATH);
        picPath = PropsUtil.getString(properties, Constants.SETTING_PIC_PATH);
        gitUsername = PropsUtil.getString(properties, Constants.SETTING_GIT_USERNAME);
        gitPassword = PropsUtil.getString(properties, Constants.SETTING_GIT_PASSWORD);
    }

    public void saveProjectPath(String projectPath) {
        PropsUtil.saveString(properties, Constants.SETTING_FILE, Constants.SETTING_PROJECT_PATH, projectPath);
        this.projectPath = projectPath;
    }

    public void savePicPath(String picPath) {
        PropsUtil.saveString(properties, Constants.SETTING_FILE, Constants.SETTING_PIC_PATH, picPath);
        this.picPath = picPath;
    }

    public void saveGitUsername(String username) {
        PropsUtil.saveString(properties, Constants.SETTING_FILE, Constants.SETTING_GIT_USERNAME, username);
        this.gitUsername = username;
    }

    public void saveGitPassword(String password) {
        PropsUtil.saveString(properties, Constants.SETTING_FILE, Constants.SETTING_GIT_PASSWORD, password);
        this.gitPassword = password;
    }


    public String getProjectPath() {
        return projectPath;
    }

    public String getPicPath() {
        return picPath;
    }

    public String getGitUsername() {
        return gitUsername;
    }

    public String getGitPassword() {
        return gitPassword;
    }
}


<|start_filename|>src/main/java/com/zbw/gitpic/utils/PropsUtil.java<|end_filename|>
package com.zbw.gitpic.utils;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.*;
import java.util.Properties;

/**
 * 属性文件助手
 *
 * @author zbw
 * @create 2017/11/20 11:23
 */
public final class PropsUtil {

    private static final Logger logger = LoggerFactory.getLogger(PropsUtil.class);

    synchronized static public Properties loadProps(String propsName) {
        String jarUrl = JarUtil.getJarDir();
        String fileUrl = jarUrl + File.separator + propsName;
        File propFile = new File(fileUrl);
        if (!propFile.exists()) {
            try {
                propFile.createNewFile();
            } catch (IOException e) {
                logger.error(e.getMessage(), e);
            }
        }

        Properties props = new Properties();
        InputStream in = null;
        try {
            in = new FileInputStream(propFile);
            props.load(in);
        } catch (IOException e) {
            logger.error(e.getMessage(), e);
        } finally {
            try {
                if (null != in) {
                    in.close();
                }
            } catch (IOException e) {
                logger.error(e.getMessage(), e);
            }
        }
        return props;
    }

    public static void saveString(Properties props, String propsName, String key, String value) {
        props.setProperty(key, value);
        try {
            String jarUrl = JarUtil.getJarDir();
            String fileUrl = jarUrl + File.separator + propsName;
            FileOutputStream fos = new FileOutputStream(new File(fileUrl));
            props.store(fos, "This is the properties for gitPic");
            fos.close();
        } catch (Exception e) {
            logger.error(e.getMessage(), e);
        }
    }

    /**
     * 获取字符型属性
     */
    public static String getString(Properties props, String key) {
        String value = "";
        if (props.containsKey(key)) {
            value = props.getProperty(key);
        }
        return value;
    }

    /**
     * 获取字符型属性（带有默认值）
     */
    public static String getString(Properties props, String key, String defalutValue) {
        String value = defalutValue;
        if (props.containsKey(key)) {
            value = props.getProperty(key);
        }
        return value;
    }

    /**
     * 获取数值型属性
     */
    public static int getNumber(Properties props, String key) {
        int value = 0;
        if (props.containsKey(key)) {
            value = CastUtil.castInt(props.getProperty(key));
        }
        return value;
    }

    /**
     * 获取数值型属性（带有默认值）
     *
     * @param props
     * @param key
     * @param defaultValue
     * @return
     */
    public static int getNumber(Properties props, String key, int defaultValue) {
        int value = defaultValue;
        if (props.containsKey(key)) {
            value = CastUtil.castInt(props.getProperty(key));
        }
        return value;
    }

    /**
     * 获取布尔型属性
     */
    public static boolean getBoolean(Properties props, String key) {
        return getBoolean(props, key, false);
    }

    /**
     * 获取布尔型属性（带有默认值）
     */
    public static boolean getBoolean(Properties props, String key, boolean defalutValue) {
        boolean value = defalutValue;
        if (props.containsKey(key)) {
            value = CastUtil.castBoolean(props.getProperty(key));
        }
        return value;
    }

}


<|start_filename|>src/main/resources/css/jfoenix-components-style.css<|end_filename|>
.dark {
    -fx-background-color: #2b2b2b;
}

.orange {
    -fx-background-color: #E64A19;
}

.blue {
    -fx-background-color: #448AFF;
}

.text-dark {
    -fx-text-fill: #bababa;
}

.text-success {
    -fx-text-fill: #37B158;
}

.text-error {
    -fx-text-fill: RED;
}

.text-field-dark {
    -fx-background-color: #2b2b2b;
}

.text-field-dark:focused {
    -fx-background-color: #2b2b2b;
}

.toggle-button-primary {
    -jfx-toggle-color: #5264AE;
}

.button-tiny {
    -fx-pref-width: 100px;
    -fx-font-size: 12px;
}

.dialog-accept {
    -fx-text-fill: #03A9F4;
    -fx-font-weight: BOLD;
    -fx-padding: 0.7em 0.8em;
}

.dialog-cancel {
    -fx-text-fill: #bababa;
    -fx-font-weight: BOLD;
    -fx-padding: 0.7em 0.8em;
}

.button-folder {
    -fx-background-image: url('../images/folder_dark.png');
    -fx-background-repeat: no-repeat;
    -fx-background-position: center;
    -fx-pref-height: 24px;
    -fx-pref-width: 24px;
}

.button-folder:hover {
    -fx-background-image: url('../images/folder_light.png');
}



<|start_filename|>src/main/java/com/zbw/gitpic/Bootstrap.java<|end_filename|>
package com.zbw.gitpic;

import com.zbw.gitpic.utils.ThreadPool;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.image.Image;
import javafx.stage.Stage;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * @author zbw
 * @create 2018/2/24 17:28
 */
public class Bootstrap extends Application {

    private static final Logger logger = LoggerFactory.getLogger(Bootstrap.class);

    @Override
    public void start(Stage primaryStage) throws Exception {
        logger.info("app start!");

        Parent root = FXMLLoader.load(getClass().getResource("/fxml/main.fxml"));
        final Scene scene = new Scene(root, 400, 400);
        scene.getStylesheets().add(Bootstrap.class.getResource("/css/jfoenix-components.css").toExternalForm());
        scene.getStylesheets().add(Bootstrap.class.getResource("/css/jfoenix-components-style.css").toExternalForm());
        primaryStage.setTitle("gitPic");
        primaryStage.setScene(scene);
        primaryStage.setResizable(false);
        primaryStage.getIcons().add(new Image(Bootstrap.class.getClassLoader().getResourceAsStream("images/github_logo.png")));
        primaryStage.show();
    }

    @Override
    public void stop() throws Exception {
        logger.info("app stop!");

        ThreadPool.getInstance().shutdown();
        super.stop();
    }

    public static void main(String[] args) {
        launch(args);
    }
}
