diff --git a/.gitignore b/.gitignore index bd64445..5ffd15a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,34 @@ # IntelliJ .idea/ *.iml -out/ \ No newline at end of file +out/ +*.ipr +*.iws + +#Gradle +.gradletasknamecache +.gradle/ +build/ +# dropbox credentials +dropbox.json + + +# files for the dex VM +*.dex + +# Java class files +*.class + +# generated files +bin/ +gen/ + +# Local configuration file (sdk path, etc) +local.properties + +# Eclipse project files +.classpath +.project + +# Proguard folder generated by Eclipse +proguard/ \ No newline at end of file diff --git a/README.md b/README.md index 93c2e42..6623eb8 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,8 @@ # Iron Gate +[![build-passing](https://img.shields.io/badge/build-passing-brightgreen.svg)]() +[![version](https://img.shields.io/badge/version-0.2-red.svg)]() -Iron Gate is the code name given to a really convenient files and folders organization system. This is a cross-platform application built for Windows and Mac OSX. Some really great features: +Iron Gate is the code name given to a really convenient files and folders organization system. This is a cross-platform application built for Windows and Mac OSX. A few things Iron Gate can do: - Tag files and folders for quick search up - Save folder structures frequently used @@ -8,30 +10,30 @@ Iron Gate is the code name given to a really convenient files and folders organi - Search, upload, and download other user directory templates - Easily remove unused files and folders - ... more to come - - -### Version -0.2 - -### Tech - -The following is used to develop Iron Gate: -* [JavaFX] - great GUI library -* [JavaFX Scene Builder] - faster way to build! +### Cloud Support -Iron Gate is open source, feel free to [contribute]! +Iron Gate supports the following cloud services +- Dropbox +- Google Drive +- OneDrive ### Installation Any java based IDE can build Iron Gate, although [IntelliJ] is highly recommended. -### Plugins +### Libraries and Other Technology + +The following is used to develop Iron Gate: -Iron Gate will eventually use the following plugins: -* Dropbox -* Google Drive -* OneDrive +- [JavaFX] - great GUI library +- [JavaFX Scene Builder] - faster way to build! +- [JUnit] - a simple framework to write repeatable tests +- [Dropbox SDK] - a Java library to access Dropbox's HTTP-based Core API v2 +- [Google Drive API] - integration with google drive +- [OneDrive API] - integration with one drive + +Iron Gate is open source, feel free to [contribute]! ### Todos - ~~file browser controller~~ @@ -46,3 +48,7 @@ Iron Gate will eventually use the following plugins: [JavaFX Scene Builder]: [IntelliJ]: [contribute]: + [Dropbox SDK]: https://github.com/dropbox/dropbox-sdk-java + [JUnit]: http://junit.org/ + [Google Drive API]: https://developers.google.com/drive/v3/web/enable-sdk + [OneDrive API]: https://dev.onedrive.com/ diff --git a/build.gradle b/build.gradle new file mode 100644 index 0000000..08da353 --- /dev/null +++ b/build.gradle @@ -0,0 +1,16 @@ +group 'xyz.venfo.desktop' +version '1.0-SNAPSHOT' + +apply plugin: 'java' + +sourceCompatibility = 1.5 + +repositories { + mavenCentral() +} + +dependencies { + compile group: 'com.dropbox.core', name: 'dropbox-core-sdk', version: '2.0-beta-7' + compile group: 'org.json', name: 'json', version: '20160212' + testCompile group: 'junit', name: 'junit', version: '4.11' +} \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000..30d399d Binary files /dev/null and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..b76e764 --- /dev/null +++ b/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,6 @@ +#Thu Feb 25 00:26:14 EST 2016 +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-2.5-all.zip diff --git a/gradlew b/gradlew new file mode 100755 index 0000000..91a7e26 --- /dev/null +++ b/gradlew @@ -0,0 +1,164 @@ +#!/usr/bin/env bash + +############################################################################## +## +## Gradle start up script for UN*X +## +############################################################################## + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS="" + +APP_NAME="Gradle" +APP_BASE_NAME=`basename "$0"` + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD="maximum" + +warn ( ) { + echo "$*" +} + +die ( ) { + echo + echo "$*" + echo + exit 1 +} + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +case "`uname`" in + CYGWIN* ) + cygwin=true + ;; + Darwin* ) + darwin=true + ;; + MINGW* ) + msys=true + ;; +esac + +# For Cygwin, ensure paths are in UNIX format before anything is touched. +if $cygwin ; then + [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"` +fi + +# Attempt to set APP_HOME +# Resolve links: $0 may be a link +PRG="$0" +# Need this for relative symlinks. +while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG=`dirname "$PRG"`"/$link" + fi +done +SAVED="`pwd`" +cd "`dirname \"$PRG\"`/" >&- +APP_HOME="`pwd -P`" +cd "$SAVED" >&- + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD="java" + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then + MAX_FD_LIMIT=`ulimit -H -n` + if [ $? -eq 0 ] ; then + if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then + MAX_FD="$MAX_FD_LIMIT" + fi + ulimit -n $MAX_FD + if [ $? -ne 0 ] ; then + warn "Could not set maximum file descriptor limit: $MAX_FD" + fi + else + warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" + fi +fi + +# For Darwin, add options to specify how the application appears in the dock +if $darwin; then + GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" +fi + +# For Cygwin, switch paths to Windows format before running java +if $cygwin ; then + APP_HOME=`cygpath --path --mixed "$APP_HOME"` + CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + + # We build the pattern for arguments to be converted via cygpath + ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` + SEP="" + for dir in $ROOTDIRSRAW ; do + ROOTDIRS="$ROOTDIRS$SEP$dir" + SEP="|" + done + OURCYGPATTERN="(^($ROOTDIRS))" + # Add a user-defined pattern to the cygpath arguments + if [ "$GRADLE_CYGPATTERN" != "" ] ; then + OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" + fi + # Now convert the arguments - kludge to limit ourselves to /bin/sh + i=0 + for arg in "$@" ; do + CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` + CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option + + if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition + eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` + else + eval `echo args$i`="\"$arg\"" + fi + i=$((i+1)) + done + case $i in + (0) set -- ;; + (1) set -- "$args0" ;; + (2) set -- "$args0" "$args1" ;; + (3) set -- "$args0" "$args1" "$args2" ;; + (4) set -- "$args0" "$args1" "$args2" "$args3" ;; + (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + esac +fi + +# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules +function splitJvmOpts() { + JVM_OPTS=("$@") +} +eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS +JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" + +exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" diff --git a/gradlew.bat b/gradlew.bat new file mode 100644 index 0000000..8a0b282 --- /dev/null +++ b/gradlew.bat @@ -0,0 +1,90 @@ +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS= + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto init + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto init + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:init +@rem Get command-line arguments, handling Windowz variants + +if not "%OS%" == "Windows_NT" goto win9xME_args +if "%@eval[2+2]" == "4" goto 4NT_args + +:win9xME_args +@rem Slurp the command line arguments. +set CMD_LINE_ARGS= +set _SKIP=2 + +:win9xME_args_slurp +if "x%~1" == "x" goto execute + +set CMD_LINE_ARGS=%* +goto execute + +:4NT_args +@rem Get arguments from the 4NT Shell from JP Software +set CMD_LINE_ARGS=%$ + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/settings.gradle b/settings.gradle new file mode 100644 index 0000000..bb7e57e --- /dev/null +++ b/settings.gradle @@ -0,0 +1,2 @@ +rootProject.name = 'IronGate' + diff --git a/src/main/java/FileTreeItem.java b/src/main/java/directory/FileTreeItem.java similarity index 99% rename from src/main/java/FileTreeItem.java rename to src/main/java/directory/FileTreeItem.java index ef1aa5b..bf8970f 100644 --- a/src/main/java/FileTreeItem.java +++ b/src/main/java/directory/FileTreeItem.java @@ -1,4 +1,4 @@ -package main.java; +package directory; import javafx.collections.FXCollections; import javafx.collections.ObservableList; diff --git a/src/main/java/FolderViewManager.java b/src/main/java/directory/FolderViewManager.java similarity index 83% rename from src/main/java/FolderViewManager.java rename to src/main/java/directory/FolderViewManager.java index 17f6034..2706404 100644 --- a/src/main/java/FolderViewManager.java +++ b/src/main/java/directory/FolderViewManager.java @@ -1,4 +1,4 @@ -package main.java; +package directory; import javafx.collections.ObservableList; import javafx.scene.control.TreeItem; @@ -21,32 +21,43 @@ directory searches, displaying directories, and all things directly changing the Folder View. + Additionally, this class extends SimpleFileVisitor which uses java 8. + @author Kristopher Guzman kristopherguz@gmail.com @author Brian Patino patinobrian@gmail.com */ public class FolderViewManager { - - //private IronFileVisitor ironVisitor; // might be used later - private final Image hddIcon = new Image("/main/resources/icons/hdd.png"); + private final Image hddIcon = new Image("/icons/hdd.png"); +// private directory.IronFileVisitor ironVisitor; // might be used later private TreeView view; private CmdExecutor command; private List> selectedFiles; public FolderViewManager(TreeView dirTree) { - /*ironVisitor = new IronFileVisitor(); // save this for later + /*ironVisitor = new directory.IronFileVisitor(); // save this for later ironVisitor.setRoot(new TreeItem<>());*/ // save this for later OSDetection.getOS(); view = dirTree; command = new CmdExecutor(); - } - - + /** + * Sets the root directory of the file browser to the specified folder. + * + * @param file root folder/file to start browser view + **/ + public void setRootDirectory(IronFile file) { + FileTreeItem rootItem = new FileTreeItem(file); + view.setRoot(rootItem); + } + /** + * Overloaded method that sets a collection of folders/files as file browser view. + * + * @param hardDrives a collection of hard drives to being from root + * */ public void setRootDirectory(IronFile[] hardDrives) { view.setRoot(new FileTreeItem(new IronFile(""))); // needs a blank file as root for (IronFile hdd : hardDrives) { - System.out.println(hdd.getName()); FileTreeItem diskTreeItem = new FileTreeItem(hdd); diskTreeItem.setGraphic(new ImageView(hddIcon)); view.getRoot().getChildren().add(diskTreeItem); @@ -55,143 +66,86 @@ public void setRootDirectory(IronFile[] hardDrives) { } public void setSelectedFiles(List> files) { - selectedFiles = files; - } public void setFileAttrForSelected() { - for(TreeItem item : selectedFiles) { - setFileAttr(item.getValue(), "test_attr_key", "test_attr_value"); - } - } public void getFileAttrForSelected() { - for(TreeItem item : selectedFiles) { - getFileAttr(item.getValue(), "test_attr_key"); - } - } public void deleteFileAttrForSelected() { - for(TreeItem item : selectedFiles) { - deleteFileAttr(item.getValue(), "test_attr_key"); - } - } public void setFileAttr(IronFile file, String key, String value) { - if(OSDetection.OSType == OSDetection.OS.WINDOWS) { - try { - UserDefinedFileAttributeView view = Files.getFileAttributeView(file.toPath(), UserDefinedFileAttributeView.class); - //might want to give unique prefix to tag keys to avoid collision with system metadata view.write(key, Charset.defaultCharset().encode(value)); - - } catch(IOException e) { e.printStackTrace(); } - + } catch(IOException e) { + e.printStackTrace(); + } } else if(OSDetection.OSType == OSDetection.OS.MAC) { - String option = ""; - if(file.isDirectory()) { option = "-r"; } - - String cmd = "xattr -w " + option + " " + key + " " + value + " " + file.getAbsolutePath(); - try { - String output = command.run(cmd); - } catch(IOException e) { e.printStackTrace(); } - - } - } public String getFileAttr(IronFile file, String key) { - if(OSDetection.OSType == OSDetection.OS.WINDOWS) { - try { UserDefinedFileAttributeView view = Files.getFileAttributeView(file.toPath(), UserDefinedFileAttributeView.class); - ByteBuffer buf = ByteBuffer.allocate(view.size(key)); view.read(key, buf); buf.flip(); - return Charset.defaultCharset().decode(buf).toString(); - - } catch(IOException e) { e.printStackTrace(); } + } catch(IOException e) { + e.printStackTrace(); + } } else if(OSDetection.OSType == OSDetection.OS.MAC) { - System.out.println("file path: " + file.getAbsolutePath()); - String option = ""; - if(file.isDirectory()) { //option = "-r"; } - - String cmd = "xattr -p " + option + " " + key + " " + file.getAbsolutePath(); //then append the attr command - try { - String output = command.run(cmd); - } catch(IOException e) { e.printStackTrace(); } - } - return null; - } public void deleteFileAttr(IronFile file, String key) { - if(OSDetection.OSType == OSDetection.OS.WINDOWS) { - try { - UserDefinedFileAttributeView view = Files.getFileAttributeView(file.toPath(), UserDefinedFileAttributeView.class); view.delete(key); - } catch(IOException e) { e.printStackTrace(); } - } else if(OSDetection.OSType == OSDetection.OS.MAC) { - System.out.println("file path: " + file.getAbsolutePath()); - - String cmd = "xattr -d " + key + " " + file.getAbsolutePath(); //then append the attr command - try { - String output = command.run(cmd); - - } catch(IOException e) { e.printStackTrace(); } - } - } - } diff --git a/src/main/java/IronFile.java b/src/main/java/directory/IronFile.java similarity index 98% rename from src/main/java/IronFile.java rename to src/main/java/directory/IronFile.java index ce9d6f3..8349e01 100644 --- a/src/main/java/IronFile.java +++ b/src/main/java/directory/IronFile.java @@ -1,5 +1,4 @@ - -package main.java; +package directory; import java.io.File; diff --git a/src/main/java/IronFileVisitor.java b/src/main/java/directory/IronFileVisitor.java similarity index 91% rename from src/main/java/IronFileVisitor.java rename to src/main/java/directory/IronFileVisitor.java index ddc9222..eb77a4c 100644 --- a/src/main/java/IronFileVisitor.java +++ b/src/main/java/directory/IronFileVisitor.java @@ -1,10 +1,7 @@ -package main.java; +package directory; -import javafx.scene.Scene; import javafx.scene.control.TreeItem; -import javafx.scene.control.TreeView; -import java.io.File; import java.io.IOException; import java.nio.file.FileVisitResult; import java.nio.file.Path; @@ -27,7 +24,7 @@ public class IronFileVisitor extends SimpleFileVisitor{ public FileVisitResult visitFile(Path pathFile, BasicFileAttributes attrs) throws IOException { IronFile current = new IronFile(pathFile.toFile()); // System.out.println(current.getAbsolutePath()); -// root.getChildren().add(new TreeItem<>(new IronFile(current.getAbsolutePath()))); +// root.getChildren().add(new TreeItem<>(new directory.IronFile(current.getAbsolutePath()))); System.out.printf("Visiting file %s\n", pathFile); return FileVisitResult.CONTINUE; } diff --git a/src/main/java/Controller.java b/src/main/java/launcher/Controller.java similarity index 77% rename from src/main/java/Controller.java rename to src/main/java/launcher/Controller.java index 742115b..ce9a486 100644 --- a/src/main/java/Controller.java +++ b/src/main/java/launcher/Controller.java @@ -1,4 +1,4 @@ -package main.java; +package launcher; import javafx.beans.value.ChangeListener; import javafx.beans.value.ObservableValue; @@ -6,24 +6,20 @@ import javafx.event.ActionEvent; import javafx.event.Event; import javafx.event.EventHandler; +import directory.FolderViewManager; +import directory.IronFile; import javafx.fxml.FXML; -import javafx.scene.Node; import javafx.scene.control.MenuItem; -import javafx.scene.control.TreeCell; -import javafx.scene.control.TreeItem; import javafx.scene.control.TreeView; import javafx.scene.image.Image; import javafx.scene.image.ImageView; import javafx.scene.input.MouseEvent; import sun.misc.Resource; import sun.reflect.generics.tree.Tree; +import com.dropbox.core.*; +import com.dropbox.core.v2.*; +import webapp.DropboxController; -import java.io.File; -import java.io.IOException; -import java.nio.file.FileVisitOption; -import java.nio.file.Files; -import java.nio.file.Paths; -import java.util.EnumSet; import java.util.ResourceBundle; public class Controller{ @@ -32,6 +28,7 @@ public class Controller{ @FXML private MenuItem fileTag; @FXML private MenuItem fileExit; @FXML private MenuItem editPreferences; + @FXML private MenuItem fileDropboxSignin; @FXML private TreeView dirTree; @FXML private MenuItem toolsTagFiles; @FXML private MenuItem toolsDeleteTags; @@ -43,42 +40,35 @@ public class Controller{ manager.setRootDirectory(hardDrives); dirTree.setOnMouseClicked(new EventHandler() { - @Override public void handle(MouseEvent args) { - ObservableList> selectedItems = dirTree.getSelectionModel().getSelectedItems(); - manager.setSelectedFiles(selectedItems); - } - }); - toolsTagFiles.setOnAction(new EventHandler() { - @Override public void handle(ActionEvent event) { - manager.setFileAttrForSelected(); - } - }); toolsDeleteTags.setOnAction(new EventHandler() { - @Override public void handle(ActionEvent event) { - manager.deleteFileAttrForSelected(); - } - }); - + DropboxController dbManager = new DropboxController(); + try { + dbManager.test(); + } catch (DbxException e) { + e.printStackTrace(); + } +// directory.IronFile homeDir = new directory.IronFile(System.getProperty("user.home")); // use this for specific directory +// manager.setRootDirectory(homeDir); } } diff --git a/src/main/java/Main.java b/src/main/java/launcher/Main.java similarity index 84% rename from src/main/java/Main.java rename to src/main/java/launcher/Main.java index 151fb3b..d64ce98 100644 --- a/src/main/java/Main.java +++ b/src/main/java/launcher/Main.java @@ -1,4 +1,4 @@ -package main.java; +package launcher; import javafx.application.Application; import javafx.fxml.FXMLLoader; @@ -17,8 +17,8 @@ public class Main extends Application { @Override public void start(Stage primaryStage) throws Exception{ -// setUserAgentStylesheet(STYLESHEET_CASPIAN); - Parent root = FXMLLoader.load(getClass().getResource("/main/resources/StartPage.fxml")); + setUserAgentStylesheet(STYLESHEET_CASPIAN); + Parent root = FXMLLoader.load(getClass().getResource("/StartPage.fxml")); primaryStage.setTitle("Iron-gate!"); primaryStage.setScene(new Scene(root, 990, 700)); Scene scene = primaryStage.getScene(); // we get the scene from above diff --git a/src/main/java/webapp/Dropbox.java b/src/main/java/webapp/Dropbox.java new file mode 100644 index 0000000..64c8696 --- /dev/null +++ b/src/main/java/webapp/Dropbox.java @@ -0,0 +1,64 @@ +package webapp; + +import org.json.JSONObject; + +import java.io.File; +import java.io.FileReader; +import java.net.URL; + +/** + * Dropbox API specific + */ +public class Dropbox { + // retrieve private credentials from Dropbox Developers app + private String key; + private String secret; + private String token; + + public Dropbox() { + readSetCredentials(); + } + public Dropbox(String key, String secret) { + this.key = key; + this.secret = secret; + } + public Dropbox(String key, String secret, String token) { + this.key = key; + this.secret = secret; + this.token = token; + } + + private void readSetCredentials() { + try { + URL url = getClass().getResource("/services/dropbox.json"); + FileReader readCred = new FileReader(url.getPath()); + JSONObject dropCred = new JSONObject(url.getPath()); + key = dropCred.getString("key"); + secret = dropCred.getString("secret"); + token = dropCred.getString("token"); + } catch (Exception e) { + e.printStackTrace(); + } + } + + public String getKey() { + return key; + } + public String getSecret() { + return secret; + } + public String getToken() { + return token; + } + public void setKey(String key) { + this.key = key; + } + public void setSecret(String secret) { + this.secret = secret; + } + public void setToken(String token) { + this.token = token; + } + + +} diff --git a/src/main/java/webapp/DropboxController.java b/src/main/java/webapp/DropboxController.java new file mode 100644 index 0000000..623a458 --- /dev/null +++ b/src/main/java/webapp/DropboxController.java @@ -0,0 +1,29 @@ +package webapp; + +import com.dropbox.core.DbxException; +import com.dropbox.core.DbxRequestConfig; +import com.dropbox.core.v2.DbxClientV2; +import com.dropbox.core.v2.users.FullAccount; + +/** + * This class controls the Dropbox application logic. + */ +public class DropboxController { + private static Dropbox dropbox; + private DbxClientV2 client; + private DbxRequestConfig config; + + public DropboxController() { + initialize(); + } + + private void initialize() { + dropbox = new Dropbox(); // uses default json file credentials + config = new DbxRequestConfig("dropbox/IronGate", "en_US"); + client = new DbxClientV2(config, dropbox.getToken()); + } + + public void test() throws DbxException{ + FullAccount account = client.users.getCurrentAccount(); + } +} diff --git a/src/main/resources/StartPage.fxml b/src/main/resources/StartPage.fxml index 9b538e3..6967c50 100644 --- a/src/main/resources/StartPage.fxml +++ b/src/main/resources/StartPage.fxml @@ -2,20 +2,31 @@ - - - - - - - + + + + + + + + + + + + + + + + + - + + diff --git a/src/test/java/Test.java b/src/test/java/Test.java new file mode 100644 index 0000000..f274cd4 --- /dev/null +++ b/src/test/java/Test.java @@ -0,0 +1,6 @@ +/** + * A test of test methods + */ +public class Test { + +} diff --git a/src/test/resources/blank.text b/src/test/resources/blank.text new file mode 100644 index 0000000..cb843b9 --- /dev/null +++ b/src/test/resources/blank.text @@ -0,0 +1 @@ +resources test goes here \ No newline at end of file