Skip to content

Commit 493dbbc

Browse files
authored
Linux popup (#35)
* updated the type of the error JFrame to see if that would remove its transparency on Linux * updated how logs are created and fixed Popup issue * fixed issue with the different file separators * Updated the routines.py to make it compatible with python 3.7 * Updated the README and the routines script * Updated the README
1 parent 91620fe commit 493dbbc

34 files changed

+179
-156
lines changed

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,8 @@ build/
77
# test data
88
test/
99

10+
# log data
11+
logs/
12+
1013
# vs code files
11-
.vscode
14+
.vscode

README.md

Lines changed: 55 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@
1212
<a href="#installation">Installation</a>
1313
</li>
1414
<li>
15-
<a href="#features">Features</a>
15+
<a href="#usage">Usage</a>
1616
</li>
1717
<li>
18-
<a href="#usage">Usage</a>
18+
<a href="#features">Features</a>
1919
</li>
2020
<li>
2121
<a href="#documentation">Documentation</a>
@@ -34,21 +34,72 @@
3434
<a href="https://java.com/en/download/">Java</a>
3535
</li>
3636
<li>
37-
<a href="https://www.python.org/downloads/">Python 2.7</a>
37+
<a href="https://www.python.org/downloads/">Python 2.7 or later</a>
3838
</li>
3939
<li>
4040
Some kind of hosting service for MySQL such as <a href="http://wampserver.aviatechno.net/">WAMP</a>
4141
</li>
4242
</ol>
4343

44-
_Note: the python scripts have only been tested in Python 2.7_
44+
_Note: the python scripts have only been tested in Python 2.7 and 3.7_
4545

4646
Clone this repo by running `git clone https://github.com/pjkaufman/Java_DiffChecker.git`.
4747

4848
Make sure that Python and the jre paths have been added to your PATH variable.
4949

5050
<a href="#table_of_contents">Back to Table of Contents</a>
5151

52+
<h2 id="usage">Usage</h2>
53+
54+
Go to the base directory and run
55+
56+
```
57+
python routines.py
58+
```
59+
60+
You should see
61+
62+
```
63+
Routine Options
64+
run - makes and runs the JAR file
65+
push - commits the current repo and pushes it
66+
debug - runs the current code base for testing
67+
clean - deletes the test, logs, and build directories
68+
Enter desired option:
69+
```
70+
71+
### Running
72+
73+
When prompted by the script for a routine to run, type 'run'.
74+
75+
If there are no errors you will see the following GUI:
76+
77+
<div align="center">
78+
<img src="UserGuides\images\runResult.png" alt="Database Difference Checker Home" height = "300"/>
79+
</div>
80+
81+
### Testing
82+
83+
After modifying any of the Java files in the repository, you can go to the base directory of this repository and run
84+
85+
```
86+
python routines.py
87+
```
88+
89+
When prompted for the routine to run, enter 'debug'. This will compile all of the current Java files into the test/db_diff_checker_gui folder where it will be run if no errors occur (no JAR file will be created).
90+
91+
### Manually Running The JAR File
92+
93+
In order to use the JAR file with logs, make sure that where you run the jar file you have a logs folder.
94+
95+
To run the applciation through the JAR file run
96+
97+
```
98+
java -jar path_to_jar_file
99+
```
100+
101+
<a href="#table_of_contents">Back to Table of Contents</a>
102+
52103
<h2 id="features">Features</h2>
53104

54105
<ol>
@@ -107,47 +158,6 @@ Make sure that Python and the jre paths have been added to your PATH variable.
107158

108159
<a href="#table_of_contents">Back to Table of Contents</a>
109160

110-
<h2 id="usage">Usage</h2>
111-
112-
Go to the base directory and run
113-
114-
```
115-
python routines.py
116-
```
117-
118-
You should see
119-
120-
```
121-
Routine Options
122-
run - makes and runs the JAR file
123-
push - commits the current repo and pushes it
124-
debug - runs the current code base for testing
125-
clean - deletes the test and builds directories
126-
Enter desired option:
127-
```
128-
129-
### Running
130-
131-
When prompted by the script for a routine to run, type 'run'.
132-
133-
If there are no errors you will see the following GUI:
134-
135-
<div align="center">
136-
<img src="UserGuides\images\runResult.png" alt="Database Difference Checker Home" height = "300"/>
137-
</div>
138-
139-
### Testing
140-
141-
After modifying any of the Java files in the repository, you can go to the base directory and run
142-
143-
```
144-
python routines.py
145-
```
146-
147-
When prompted for the routine to run, enter 'debug'. This will compile all of the current Java files into the test/db_diff_checker_gui folder where it will be run if no errors occur (no JAR file will be created).
148-
149-
<a href="#table_of_contents">Back to Table of Contents</a>
150-
151161
<h2 id="documentation">Documentation</h2>
152162

153163
### How It Works

dbdiffchecker/ErrorPopup.java

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,15 @@
1111
import java.util.ArrayList;
1212
import javax.swing.JLabel;
1313
import javax.swing.SwingWorker;
14+
import javax.swing.BorderFactory;
15+
import java.awt.Color;
1416

1517
/**
1618
* ErrorPopup is a JFrame that shows a message about an error that occurred.
17-
* Program Name: Database Difference Checker
18-
* CSCI Course: 325
19-
* Grade Received: Pass
19+
* Program Name: Database Difference Checker CSCI Course: 325 Grade Received:
20+
* Pass
2021
* @author Peter Kaufman
21-
* @version 2-16-19
22+
* @version 3-17-19
2223
* @since 9-21-17
2324
*/
2425
public class ErrorPopup extends JFrameV2 {
@@ -33,30 +34,32 @@ public class ErrorPopup extends JFrameV2 {
3334
*/
3435
public ErrorPopup(DatabaseDiffernceCheckerException error) {
3536

37+
String errorMessage = "";
3638
StringWriter sw = new StringWriter();
3739
error.printStackTrace(new PrintWriter(sw));
3840
String exceptionAsString = sw.toString();
3941
try {
4042
log(exceptionAsString);
41-
} catch(DatabaseDiffernceCheckerException err) {
43+
} catch (DatabaseDiffernceCheckerException err) {
4244
System.out.println("Could not log the error...");
43-
}
44-
error.printStackTrace();
45+
}
4546
this.error = false;
46-
initComponents();
47-
this.errorLabel.setText(error.getMessage().substring(error.getMessage().indexOf(":") + 2));
47+
errorMessage = error.getMessage().substring(error.getMessage().indexOf(":") + 2);
48+
initComponents(errorMessage.length());
49+
this.errorLabel.setText(errorMessage);
4850
this.setVisible(true);
4951
}
5052

5153
/**
52-
* Sets up the GUI Layout, sets up all action events, and initializes instance variables.
54+
* Sets up the GUI Layout, sets up all action events, and initializes instance
55+
* variables.
5356
* @author Peter Kaufman
5457
*/
55-
private void initComponents() {
58+
private void initComponents(int sizeFactor) {
5659
// set up JFrame properties
5760
setTitle("Error");
58-
setType(Window.Type.POPUP);
59-
setMinimumSize(new Dimension(430, 100));
61+
setType(Window.Type.UTILITY);
62+
setMinimumSize(new Dimension(7 * sizeFactor, 100));
6063
setResizable(false);
6164
// set component properties
6265
titleLabel.setFont(new Font("Tahoma", 1, 18));
@@ -66,6 +69,7 @@ private void initComponents() {
6669
getContentPane().setLayout(new BorderLayout());
6770
add(titleLabel, BorderLayout.NORTH);
6871
add(errorLabel, BorderLayout.CENTER);
72+
this.getRootPane().setBorder(BorderFactory.createMatteBorder(0, 1, 1, 1, Color.white));
6973
pack();
7074
}
7175
}

dbdiffchecker/FileHandler.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
public class FileHandler {
2626

2727
// static variables
28-
static final String logFileName = "activity.log";
28+
static final String logFileName = "activity.log";
2929
static final String lastSequelStatementFileName = "lastRun.txt";
3030
static final String databaseSnapshotFileName = "dbsnapshot";
3131

@@ -38,7 +38,7 @@ public class FileHandler {
3838
public static void serializeDatabase(Database database) throws DatabaseDiffernceCheckerException {
3939
try {
4040
FileOutputStream fileOutput = new FileOutputStream(
41-
new File("logs\\" + databaseSnapshotFileName));
41+
new File("logs" + File.separator + databaseSnapshotFileName));
4242
ObjectOutputStream outputStream = new ObjectOutputStream(fileOutput);
4343

4444
// Write object to file
@@ -67,7 +67,7 @@ public static void serializeDatabase(Database database) throws DatabaseDiffernce
6767
public static void writeToFile(ArrayList<String> sequelStatements) throws IOException {
6868

6969
PrintWriter out = new PrintWriter(new FileWriter(
70-
new File("logs\\" + lastSequelStatementFileName)));
70+
new File("logs" + File.separator + lastSequelStatementFileName)));
7171
for (String statement: sequelStatements) {
7272

7373
out.println(statement);
@@ -84,7 +84,7 @@ public static void writeToFile(ArrayList<String> sequelStatements) throws IOExce
8484
public static void writeToFile(String data) throws IOException {
8585

8686
Date currentTime = new Date();
87-
PrintWriter out = new PrintWriter(new FileWriter(new File("logs\\" + logFileName), true));
87+
PrintWriter out = new PrintWriter(new FileWriter(new File("logs" + File.separator + logFileName), true));
8888
out.println(currentTime.toString() + " " + data);
8989
out.close();
9090
}
@@ -100,7 +100,7 @@ public static Database deserailizDatabase() throws DatabaseDiffernceCheckerExcep
100100
Database database = null;
101101
try {
102102
FileInputStream fileInput = new FileInputStream(
103-
new File("logs\\" + databaseSnapshotFileName));
103+
new File("logs" + File.separator + databaseSnapshotFileName));
104104
ObjectInputStream inputStream = new ObjectInputStream(fileInput);
105105

106106
// Read object
@@ -118,7 +118,7 @@ public static Database deserailizDatabase() throws DatabaseDiffernceCheckerExcep
118118
.indexOf(":") + 1);
119119
}
120120
throw new DatabaseDiffernceCheckerException(errorMessage, cause);
121-
}
121+
}
122122

123123
return database;
124124
}
@@ -132,7 +132,7 @@ public static Database deserailizDatabase() throws DatabaseDiffernceCheckerExcep
132132
*/
133133
public static ArrayList<String> readFrom(String file) throws IOException {
134134

135-
Scanner in = new Scanner(new File("logs\\" + file));
135+
Scanner in = new Scanner(new File("logs" + File.separator + file));
136136
ArrayList<String> fileLines = new ArrayList<>();
137137
while (in.hasNextLine()) {
138138

@@ -144,14 +144,14 @@ public static ArrayList<String> readFrom(String file) throws IOException {
144144
}
145145

146146
/**
147-
* Ttakes a file path and determines whether the file exists or not.
147+
* Takes a file path and determines whether the file exists or not.
148148
* @author Chris Dail
149149
* @param file The file path to the file.
150150
* @return Whether the file exists or not.
151151
* @see <a href="https://stackoverflow.com/questions/1816673/how-do-i-check-if-a-file-exists-in-java">https://stackoverflow.com/questions/1816673/how-do-i-check-if-a-file-exists-in-java</a>
152152
*/
153153
public static boolean fileExists(String file) {
154154

155-
return new File("logs\\" + file).isFile();
155+
return new File("logs" + File.separator + file).isFile();
156156
}
157157
}

docs/allclasses-frame.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
<!-- NewPage -->
33
<html lang="en">
44
<head>
5-
<!-- Generated by javadoc (1.8.0_201) on Thu Mar 07 05:09:06 EST 2019 -->
5+
<!-- Generated by javadoc (1.8.0_101) on Mon Mar 18 18:58:19 EDT 2019 -->
66
<title>All Classes</title>
7-
<meta name="date" content="2019-03-07">
7+
<meta name="date" content="2019-03-18">
88
<link rel="stylesheet" type="text/css" href="stylesheet.css" title="Style">
99
<script type="text/javascript" src="script.js"></script>
1010
</head>

docs/allclasses-noframe.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
<!-- NewPage -->
33
<html lang="en">
44
<head>
5-
<!-- Generated by javadoc (1.8.0_201) on Thu Mar 07 05:09:06 EST 2019 -->
5+
<!-- Generated by javadoc (1.8.0_101) on Mon Mar 18 18:58:19 EDT 2019 -->
66
<title>All Classes</title>
7-
<meta name="date" content="2019-03-07">
7+
<meta name="date" content="2019-03-18">
88
<link rel="stylesheet" type="text/css" href="stylesheet.css" title="Style">
99
<script type="text/javascript" src="script.js"></script>
1010
</head>

docs/constant-values.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
<!-- NewPage -->
33
<html lang="en">
44
<head>
5-
<!-- Generated by javadoc (1.8.0_201) on Thu Mar 07 05:09:06 EST 2019 -->
5+
<!-- Generated by javadoc (1.8.0_101) on Mon Mar 18 18:58:19 EDT 2019 -->
66
<title>Constant Field Values</title>
7-
<meta name="date" content="2019-03-07">
7+
<meta name="date" content="2019-03-18">
88
<link rel="stylesheet" type="text/css" href="stylesheet.css" title="Style">
99
<script type="text/javascript" src="script.js"></script>
1010
</head>

docs/dbdiffchecker/Column.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
<!-- NewPage -->
33
<html lang="en">
44
<head>
5-
<!-- Generated by javadoc (1.8.0_201) on Thu Mar 07 05:08:58 EST 2019 -->
5+
<!-- Generated by javadoc (1.8.0_101) on Mon Mar 18 18:58:13 EDT 2019 -->
66
<title>Column</title>
7-
<meta name="date" content="2019-03-07">
7+
<meta name="date" content="2019-03-18">
88
<link rel="stylesheet" type="text/css" href="../stylesheet.css" title="Style">
99
<script type="text/javascript" src="../script.js"></script>
1010
</head>

docs/dbdiffchecker/DBCompare.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
<!-- NewPage -->
33
<html lang="en">
44
<head>
5-
<!-- Generated by javadoc (1.8.0_201) on Thu Mar 07 05:09:01 EST 2019 -->
5+
<!-- Generated by javadoc (1.8.0_101) on Mon Mar 18 18:58:16 EDT 2019 -->
66
<title>DBCompare</title>
7-
<meta name="date" content="2019-03-07">
7+
<meta name="date" content="2019-03-18">
88
<link rel="stylesheet" type="text/css" href="../stylesheet.css" title="Style">
99
<script type="text/javascript" src="../script.js"></script>
1010
</head>

docs/dbdiffchecker/DB_Diff_Checker_GUI.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
<!-- NewPage -->
33
<html lang="en">
44
<head>
5-
<!-- Generated by javadoc (1.8.0_201) on Thu Mar 07 05:09:00 EST 2019 -->
5+
<!-- Generated by javadoc (1.8.0_101) on Mon Mar 18 18:58:15 EDT 2019 -->
66
<title>DB_Diff_Checker_GUI</title>
7-
<meta name="date" content="2019-03-07">
7+
<meta name="date" content="2019-03-18">
88
<link rel="stylesheet" type="text/css" href="../stylesheet.css" title="Style">
99
<script type="text/javascript" src="../script.js"></script>
1010
</head>

0 commit comments

Comments
 (0)