Skip to content

Commit

Permalink
#4 Avoid Storing a Copies of Profiles
Browse files Browse the repository at this point in the history
  • Loading branch information
mgoellnitz committed Nov 18, 2019
1 parent 853e902 commit 5204fa5
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 58 deletions.
15 changes: 7 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,19 +119,19 @@ You can start the application through
- a Unix shell script ('bin/JFileSync3')
- a Unity launcher script

ATTENTION: Because JFileSync is distributed as a Zip archive, Unix users will
ATTENTION: Because JFileSync3 is distributed as a Zip archive, Unix users will
have to give executable rights manually before launching the application, e.g.:
'chmod a+rx JFileSync.sh'.
'chmod a+rx bin/JFileSync3'.

Nearly all functions of JFileSync3 can be controlled via the Graphical User
Interface (GUI). However, JFileSync3 provides full access to all features
(apart from plug-ins) via the command line interface. Call `bin/JFileSync -help`
(apart from plug-ins) via the command line interface. Call `bin/JFileSync3 -help`
to get an overview of all possible command line options.


## Configuration

JFileSync works with profiles controlling which folders to use, which files to
JFileSync3 works with profiles controlling which folders to use, which files to
include or ommit, how to log into WebDAV servers, and which encryption cipher
and passphrase to use.

Expand Down Expand Up @@ -193,7 +193,6 @@ You can find a copy all licenses of JFileSync3 and the used libraries in the
Required packages for JFileSync3 development (not included in the distribution):

- Java 8 SDK >= 1.8.0 (see 'http://java.sun.com')
- Gradle >= 2.1.1 (see 'http://www.gradle.org')

Used and as a result recommended development tools:

Expand Down Expand Up @@ -242,13 +241,13 @@ the 64bit ld and windres from mingw-binutils.
The software is built with the usual

```bash
gradle build
./gradlew build
```

and can be started - e.g. for IDE integration - through

```bash
gradle run
./gradlew run
```

Take the ZIP file from build/distributions.
Expand All @@ -257,5 +256,5 @@ A small test-suite can be found in profiles/test (which is not packaged in the
distribtions zip) and can be called via

```bash
gradle encryptionTest
./gradlew encryptionTest
```
37 changes: 2 additions & 35 deletions src/jfs/conf/JFSConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,6 @@
*/
public abstract class JFSConfig implements Cloneable {

/** Stores the default configuration file. */
protected static File defaultFile = new File(JFSConst.HOME_DIR+File.separator+JFSConst.DEFAULT_PROFILE_FILE);

/** Stores the title of the configuration. */
protected String title;

Expand Down Expand Up @@ -96,7 +93,7 @@ public abstract class JFSConfig implements Cloneable {
protected boolean dontAskQuestions = true;


/**
/**
* Stores the only instance of the class.
*
* SingletonHolder is loaded on the first execution of JFSConfig.getInstance()
Expand Down Expand Up @@ -160,36 +157,6 @@ public final void clean() {
}


/**
* Loads the default configuration file in the user's home directory after program start if no configuration file
* was specified (GUI only).
*/
public final void loadDefaultFile() {
if (defaultFile.exists()) {
// Loading the default file should not change whether the profile
// was changed:
boolean isStored = isCurrentProfileStored();
loadProfile(defaultFile);
setCurrentProfileStored(isStored);
}
}


/**
* Stores the default configuration file to the user's home directory after program termination (GUI only). If the
* directory doesn't exist, it is created from scratch.
*/
public final void storeDefaultFile() {
File home = new File(JFSConst.HOME_DIR);

if ( !home.exists()) {
home.mkdir();
}

storeProfile(defaultFile);
}


/**
* Loads a profile.
*
Expand Down Expand Up @@ -979,5 +946,5 @@ public final Object clone() {

return clone;
}

}
5 changes: 0 additions & 5 deletions src/jfs/conf/JFSConst.java
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,6 @@ private static class SingletonHolder {
*/
public final static String WORKING_DIR = System.getProperty("user.dir", ".");

/**
* The file name of the default user profile file.
*/
public final static String DEFAULT_PROFILE_FILE = "Profile.xml";

/**
* The file name of the settings file.
*/
Expand Down
24 changes: 14 additions & 10 deletions src/jfs/gui/JFSMainView.java
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,10 @@ public JFSMainView(boolean loadDefaults) {

// Load default configuration if option is specified:
if (loadDefaults) {
config.loadDefaultFile();
File currentProfile = JFSSettings.getInstance().getCurrentProfile();
if (currentProfile!=null&&currentProfile.exists()) {
config.load(currentProfile);
}
}

// Redirect error stream to log file:
Expand Down Expand Up @@ -638,9 +641,6 @@ public void actionPerformed(String cmd) {
JOptionPane.WARNING_MESSAGE);

if (result==JOptionPane.OK_OPTION) {
// Store last entered profile data:
config.storeDefaultFile();

// Store settings:
s.store();

Expand Down Expand Up @@ -839,12 +839,16 @@ public void componentResized(ComponentEvent arg0) {

if (state==Frame.NORMAL) {
settings.setWindowBounds(r.x, r.y, r.width, r.height);
} else if (state==Frame.MAXIMIZED_VERT) {
settings.setWindowX(r.x);
settings.setWindowWidth(r.width);
} else if (state==Frame.MAXIMIZED_HORIZ) {
settings.setWindowY(r.y);
settings.setWindowHeight(r.height);
} else {
if (state==Frame.MAXIMIZED_VERT) {
settings.setWindowX(r.x);
settings.setWindowWidth(r.width);
} else {
if (state==Frame.MAXIMIZED_HORIZ) {
settings.setWindowY(r.y);
settings.setWindowHeight(r.height);
}
}
}
}

Expand Down

0 comments on commit 5204fa5

Please sign in to comment.