Documentation is generated by running the build
task in the dqgui root project. The folder projectDocs contains all help and tutorials.
To import the project into your IDE just import the dqgui root project.
More about the important gradle tasks can be found in the dqgui/README.
Lets stick with the recommended Java conventions and use spaces (4 spaces) instead of tabs to indent our codebase. To set Eclipse to 4 spaces instead of a tab do the following:
Window -> Preferences -> Java -> Code Style -> Formatter -> New (Initialize with Eclipse [built-in] and "Open the edit dialog now") -> Indentation -> Tab policy: spaces only & Indentation size = 4 & Tab size: 4. Apply and select the new profile.
Q: Oh no! My eclipses default settings is on tabs and I already did some work. What do I do now?
A: Well that's unfortunate but it happens to all of us at one point of time. Luckily there is an eclipse plugin that allows us to fight back and banish the evil tabs from our codebase. Be sure to dqgui-single -> Properties -> AnyEdit Tools -> Convert... -> Tab width/number of spaces for tab = 4 first.
Our projects .gitignore covers Eclipse and IntelliJ so even tho we specified Eclipse in our Feasibility Study the usage of IntelliJ should be a non-issue.
Always build the project once after import! (build -> build task)
Eclipse will sometimes fail to recognize newly added dependencies. To force a refresh Right Click on build.gradle -> Gradle -> Refresh Gradle Project.
To run the main method use the application -> run task in the dqgui-core folder. Now you can just hit the green run button in Eclipse.
Do not ever attempt to use Javas IO or NIO classes to access those files! This will fail as soon as you run the jar!
For this we have the resource folder (example below):
|-src
| |-main
| |-resources
|-gui
|-style.css
If we want to access the style.css file we can either use the getResourceAsStream(location) method to receive an InputStream that can be used with a BufferedReader for example or getResource(location) which will result in an URL object that pinpoints the location exactly inside and outside of a JAR. These methods can be accessed through getClass() if we're inside an instantiable object or ClassName.class if our class is never instantiated.
resources is our root directory. To access style.css we would use "/gui/style.css" as location parameter for the methods.
Example:
public class Example {
public Example() {
getClass().getResource("/gui/style.css");
getClass().getResourceAsStream("/gui/style.css");
}
public static void exampleStatic() {
Example.class.getResource("/gui/style.css");
Example.class.getResourceAsStream("/gui/style.css");
}
}
Results if run in IDE:
file:/C:/Users/mynt/Desktop/Neuer%20Ordner/DQGUI/dqgui-single/build/main/resources/gui/style.css
java.io.BufferedInputStream@15db9742
Results if run in jar:
jar:file:/C:/Users/mynt/Desktop/Neuer%20Ordner/DQGUI/dqgui-single/build/libs/dqgui-single.jar!/gui/style.css
sun.net.www.protocol.jar.JarURLConnection$JarURLInputStream@232204a1
We use tinylog2 in our project. Their documentation is pretty good but unless you plan on diddling with the config files this is all you need to know:
import org.tinylog.Logger;
Logger.trace("Hello World!");
Logger.debug("Hello World!");
Logger.info("Hello World!");
Logger.warn("Hello World!");
Logger.error("Hello World!");
Log will be output in the console and via the dqgui_log.log file. Console output also features the line the method has been called from.