Skip to content

Commit 60733fb

Browse files
author
Valentin BAIZEAU
committed
Moved 'openLogFile' block to MainUI class, fixed log file location on Windows, blocking the opening.
1 parent fa997ec commit 60733fb

3 files changed

Lines changed: 16 additions & 15 deletions

File tree

remotesync-ui/src/main/java/org/piwigo/remotesync/ui/swing/FinishUI.java

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -88,14 +88,8 @@ public void paintComponent(Graphics graphics) {
8888

8989
@Override
9090
public void actionPerformed(ActionEvent e) {
91-
if (e.getSource() == this.logBtn) {
92-
if (Desktop.isDesktopSupported())
93-
try {
94-
Desktop.getDesktop().edit(this.parent.getRemoteParent().getLogFile());
95-
} catch (IOException e1) {
96-
e1.printStackTrace();
97-
}
98-
}
91+
if (e.getSource() == this.logBtn)
92+
this.parent.openLogFile();
9993
if (e.getSource() == this.syncBtn)
10094
this.parent.sendToSync();
10195
}

remotesync-ui/src/main/java/org/piwigo/remotesync/ui/swing/MainUI.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,13 @@
1212

1313
import java.awt.CardLayout;
1414
import java.awt.Color;
15+
import java.awt.Desktop;
1516
import java.awt.Graphics;
1617
import java.awt.Image;
1718
import java.awt.event.ActionEvent;
1819
import java.awt.event.ActionListener;
1920
import java.io.File;
21+
import java.io.IOException;
2022

2123
import javax.swing.ImageIcon;
2224
import javax.swing.JFileChooser;
@@ -166,6 +168,14 @@ protected void selectDirectory()
166168
}
167169
}
168170

171+
protected void openLogFile()
172+
{
173+
if (Desktop.isDesktopSupported())
174+
try {
175+
Desktop.getDesktop().edit(this.getRemoteParent().getLogFile());
176+
} catch (IOException e1) {}
177+
}
178+
169179
protected void sendToSync()
170180
{
171181
CardLayout cardLayout = (CardLayout) cards.getLayout();

remotesync-ui/src/main/java/org/piwigo/remotesync/ui/swing/RemotesyncUI.java

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,7 @@ public class RemotesyncUI {
3636

3737
private File logFile;
3838

39-
private SyncConfiguration syncConfiguration = ConfigurationUtil.INSTANCE.getUserConfiguration()
40-
.getCurrentSyncConfiguration();
39+
private SyncConfiguration syncConfiguration = ConfigurationUtil.INSTANCE.getUserConfiguration().getCurrentSyncConfiguration();
4140

4241
/**
4342
* Launch the application.
@@ -96,13 +95,11 @@ private void initialize() {
9695
}
9796

9897
private void setCustomOut() {
99-
logFile = new File("./.log");
98+
logFile = new File(ConfigurationUtil.INSTANCE.getUserHomeDirectory(), "log.txt");
10099
PrintStream ps = null;
101-
try
102-
{
100+
try {
103101
ps = new PrintStream(logFile);
104-
} catch (FileNotFoundException e)
105-
{
102+
} catch (FileNotFoundException e) {
106103
return;
107104
}
108105
System.setOut(ps);

0 commit comments

Comments
 (0)