Skip to content

Commit

Permalink
v1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
salif committed May 28, 2021
1 parent d9a35e4 commit 55f2610
Show file tree
Hide file tree
Showing 16 changed files with 66 additions and 45 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ dependencies {
}

application {
getMainClass().set('eu.salif.sinhrz.gui.App')
mainClass = 'eu.salif.sinhrz.GuiApp'
}

jar {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,18 @@

package eu.salif.sinhrz;

import eu.salif.sinhrz.errors.SinhrzException;
import eu.salif.sinhrz.implementations.ArgsImpl;
import eu.salif.sinhrz.implementations.SinhrzImpl;
import eu.salif.sinhrz.interfaces.Localisation;
import eu.salif.sinhrz.interfaces.Sinhrz;
import eu.salif.sinhrz.localisations.BulgarianLocalisation;
import eu.salif.sinhrz.localisations.EnglishLocalisation;

import java.io.PrintStream;
import java.util.Locale;

public class App {
public class CliApp {
public static void main(String[] args) {
Localisation localisation = getLocalisation();
PrintStream errStream = System.err;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,12 @@
* limitations under the License.
*/

package eu.salif.sinhrz.gui;
package eu.salif.sinhrz;

public class App {
import eu.salif.sinhrz.gui.SinhrzFrame;

public class GuiApp {
public static void main(String[] args) {
new SinhrzFrame(eu.salif.sinhrz.App.getLocalisation()).setVisible(true);
new SinhrzFrame(CliApp.getLocalisation()).setVisible(true);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@
* limitations under the License.
*/

package eu.salif.sinhrz;
package eu.salif.sinhrz.errors;

import eu.salif.sinhrz.interfaces.Localisation;

import java.io.PrintStream;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@
* limitations under the License.
*/

package eu.salif.sinhrz;
package eu.salif.sinhrz.errors;

import eu.salif.sinhrz.interfaces.Localisation;

import java.io.PrintStream;

Expand Down
33 changes: 18 additions & 15 deletions app/src/main/java/eu/salif/sinhrz/gui/SinhrzFrame.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@

package eu.salif.sinhrz.gui;

import eu.salif.sinhrz.Args;
import eu.salif.sinhrz.Localisation;
import eu.salif.sinhrz.Sinhrz;
import eu.salif.sinhrz.SinhrzException;
import eu.salif.sinhrz.interfaces.Args;
import eu.salif.sinhrz.interfaces.Localisation;
import eu.salif.sinhrz.interfaces.Sinhrz;
import eu.salif.sinhrz.errors.SinhrzException;
import eu.salif.sinhrz.implementations.ArgsImpl;
import eu.salif.sinhrz.implementations.SinhrzImpl;

Expand All @@ -31,7 +31,7 @@
import java.io.PrintStream;
import java.nio.file.Path;

class SinhrzFrame extends JFrame implements ActionListener {
public class SinhrzFrame extends JFrame implements ActionListener {
private final Localisation localisation;
private JTextField inputSinhrzFileName;
private JTextField inputSinhrzLockFileName;
Expand All @@ -44,9 +44,9 @@ class SinhrzFrame extends JFrame implements ActionListener {
private PrintStream errStream;
private PrintStream outStream;

SinhrzFrame(Localisation localisation) {
public SinhrzFrame(Localisation localisation) {
this.localisation = localisation;
setTitle(this.localisation.NAME() + " | " + this.localisation.LOC_NAME());
setTitle(String.format("%s | %s", this.localisation.NAME(), this.localisation.LOC_NAME()));
setSize(500, 500);
setLayout(null);
addElements();
Expand Down Expand Up @@ -214,19 +214,22 @@ public boolean getDoInit() {
return inputDoInit.isSelected();
}

@Override
public boolean getDoVerbose() {
return inputDoVerbose.isSelected();
}
});
@Override
public boolean getDoVerbose() {
return inputDoVerbose.isSelected();
}
});
boolean success = sinhrz.sync();
if (success) {
JOptionPane.showMessageDialog(this, outOutputStream.toString());
JTextArea textArea = new JTextArea(outOutputStream.toString());
JScrollPane scrollPane = new JScrollPane(textArea);
textArea.setEditable(false);
scrollPane.setPreferredSize(new Dimension(400, 200));
JOptionPane.showMessageDialog(this, scrollPane);
}
} catch (SinhrzException sinhrzException) {
sinhrzException.print(localisation, errStream);
JOptionPane.showMessageDialog(this,
errOutputStream.toString(),
JOptionPane.showMessageDialog(this, errOutputStream.toString(),
this.localisation.ERROR_MESSAGE(), JOptionPane.ERROR_MESSAGE);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@

package eu.salif.sinhrz.implementations;

import eu.salif.sinhrz.Args;
import eu.salif.sinhrz.Localisation;
import eu.salif.sinhrz.SinhrzException;
import eu.salif.sinhrz.interfaces.Args;
import eu.salif.sinhrz.interfaces.Localisation;
import eu.salif.sinhrz.errors.SinhrzException;

import java.io.PrintStream;
import java.nio.file.Path;
Expand Down
28 changes: 17 additions & 11 deletions app/src/main/java/eu/salif/sinhrz/implementations/SinhrzImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@

package eu.salif.sinhrz.implementations;

import eu.salif.sinhrz.Args;
import eu.salif.sinhrz.Sinhrz;
import eu.salif.sinhrz.SinhrzException;
import eu.salif.sinhrz.SinhrzWarning;
import eu.salif.sinhrz.interfaces.Args;
import eu.salif.sinhrz.interfaces.Sinhrz;
import eu.salif.sinhrz.errors.SinhrzException;
import eu.salif.sinhrz.errors.SinhrzWarning;

import java.io.File;
import java.io.IOException;
Expand All @@ -41,6 +41,19 @@ public SinhrzImpl() {
@Override
public void setArgs(Args args) throws SinhrzException {
this.args = args;
if (this.args.getDoVerbose()) {
String m = String.format("%s: '%s'%n%s: '%s'%n%s: '%s'%n%s: '%s'%n",
this.args.getLocalisation().GUI_LOCAL_LABEL(),
this.args.getLocalLabel(),
this.args.getLocalisation().GUI_LOCAL_PATH(),
this.args.getLocalPath().toAbsolutePath(),
this.args.getLocalisation().GUI_REMOTE_LABEL(),
this.args.getRemoteLabel(),
this.args.getLocalisation().GUI_REMOTE_PATH(),
this.args.getRemotePath().toAbsolutePath());
this.args.getErrStream().print(m);
this.args.getOutStream().print(m);
}
this.setPaths();
this.validateArgs();
this.setFileNameFilter(new FileNameFilter(this.args.getSinhrzFileName(), this.args.getSinhrzLockFileName()));
Expand Down Expand Up @@ -138,13 +151,6 @@ private Set<String> list(File f, Path p) {
@Override
public boolean sync() throws SinhrzException {
this.lock();
if (this.args.getDoVerbose()) {
this.args.getOutStream().printf("'%s': '%s'%n'%s': '%s'%n",
this.args.getLocalLabel(),
this.args.getLocalPath().toAbsolutePath(),
this.args.getRemoteLabel(),
this.args.getRemotePath().toAbsolutePath());
}
try {
List<String> sinhrzFiles = Files.readAllLines(this.paths.getLocalSinhrzFilePath());
Set<String> localFiles = list(this.args.getLocalPath().toFile(), Path.of(""));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package eu.salif.sinhrz;
package eu.salif.sinhrz.interfaces;

import java.io.PrintStream;
import java.nio.file.Path;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package eu.salif.sinhrz;
package eu.salif.sinhrz.interfaces;

public abstract class Localisation {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,12 @@
* limitations under the License.
*/

package eu.salif.sinhrz;
package eu.salif.sinhrz.interfaces;

import eu.salif.sinhrz.errors.SinhrzException;

public interface Sinhrz {
void setArgs(Args args) throws SinhrzException;

boolean sync() throws SinhrzException;
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

package eu.salif.sinhrz.localisations;

import eu.salif.sinhrz.Localisation;
import eu.salif.sinhrz.interfaces.Localisation;

public class BulgarianLocalisation extends Localisation {
@Override
Expand Down Expand Up @@ -106,7 +106,7 @@ public String INFO_COPYING_FROM_TO(String s, String f, String t) {

@Override
public String ERROR_IS_NOT_INIT(String s) {
return String.format("'%s' не е инициализирано", s);
return String.format("'%s' не е инициализирана", s);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

package eu.salif.sinhrz.localisations;

import eu.salif.sinhrz.Localisation;
import eu.salif.sinhrz.interfaces.Localisation;

public class EnglishLocalisation extends Localisation {

Expand Down
2 changes: 1 addition & 1 deletion res/sinhrz
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#!/bin/sh
exec /usr/bin/env java -cp ./sinhrz.jar eu.salif.sinhrz.App "$@"
exec java -cp /usr/lib/sinhrz/app.jar eu.salif.sinhrz.CliApp "$@"
2 changes: 1 addition & 1 deletion res/sinhrz-gui
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#!/bin/sh
exec /usr/bin/env java -cp ./sinhrz.jar eu.salif.sinhrz.gui.App "$@"
exec java -cp /usr/lib/sinhrz/app.jar eu.salif.sinhrz.GuiApp "$@"
2 changes: 1 addition & 1 deletion res/sinhrz.desktop
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
[Desktop Entry]
Name=Sinhrz
GenericName=Sinhrz
Comment=A simple folder synchronisation tool
Comment=A simple folder synchronization tool
Icon=emblem-synchronizing
Type=Application
Categories=Utility
Expand Down

0 comments on commit 55f2610

Please sign in to comment.