Skip to content

Commit

Permalink
Moved 'openLogFile' block to MainUI class, fixed log file location on…
Browse files Browse the repository at this point in the history
… Windows, blocking the opening.
  • Loading branch information
Valentin BAIZEAU committed Jul 19, 2019
1 parent fa997ec commit 60733fb
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -88,14 +88,8 @@ public void paintComponent(Graphics graphics) {

@Override
public void actionPerformed(ActionEvent e) {
if (e.getSource() == this.logBtn) {
if (Desktop.isDesktopSupported())
try {
Desktop.getDesktop().edit(this.parent.getRemoteParent().getLogFile());
} catch (IOException e1) {
e1.printStackTrace();
}
}
if (e.getSource() == this.logBtn)
this.parent.openLogFile();
if (e.getSource() == this.syncBtn)
this.parent.sendToSync();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@

import java.awt.CardLayout;
import java.awt.Color;
import java.awt.Desktop;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
import java.io.IOException;

import javax.swing.ImageIcon;
import javax.swing.JFileChooser;
Expand Down Expand Up @@ -166,6 +168,14 @@ protected void selectDirectory()
}
}

protected void openLogFile()
{
if (Desktop.isDesktopSupported())
try {
Desktop.getDesktop().edit(this.getRemoteParent().getLogFile());
} catch (IOException e1) {}
}

protected void sendToSync()
{
CardLayout cardLayout = (CardLayout) cards.getLayout();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ public class RemotesyncUI {

private File logFile;

private SyncConfiguration syncConfiguration = ConfigurationUtil.INSTANCE.getUserConfiguration()
.getCurrentSyncConfiguration();
private SyncConfiguration syncConfiguration = ConfigurationUtil.INSTANCE.getUserConfiguration().getCurrentSyncConfiguration();

/**
* Launch the application.
Expand Down Expand Up @@ -96,13 +95,11 @@ private void initialize() {
}

private void setCustomOut() {
logFile = new File("./.log");
logFile = new File(ConfigurationUtil.INSTANCE.getUserHomeDirectory(), "log.txt");
PrintStream ps = null;
try
{
try {
ps = new PrintStream(logFile);
} catch (FileNotFoundException e)
{
} catch (FileNotFoundException e) {
return;
}
System.setOut(ps);
Expand Down

0 comments on commit 60733fb

Please sign in to comment.