Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
corpus-services-gui
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Lange, Dr. Herbert
corpus-services-gui
Commits
be37d4c9
Commit
be37d4c9
authored
2 years ago
by
Lange, Dr. Herbert
Browse files
Options
Downloads
Patches
Plain Diff
added save button
parent
e1f96428
No related branches found
No related tags found
No related merge requests found
Pipeline
#12444
passed
2 years ago
Stage: test
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/java/de/uni_hamburg/corpora/gui/GUI.java
+45
-7
45 additions, 7 deletions
src/main/java/de/uni_hamburg/corpora/gui/GUI.java
with
45 additions
and
7 deletions
src/main/java/de/uni_hamburg/corpora/gui/GUI.java
+
45
−
7
View file @
be37d4c9
...
...
@@ -70,9 +70,12 @@ public class GUI {
JPanel
buttonPanel
=
new
JPanel
(
new
GridLayout
(
1
,
4
));
JButton
checkButton
=
new
JButton
(
"Check corpus"
);
buttonPanel
.
add
(
checkButton
);
JButton
reportButton
=
new
JButton
(
"Show report"
);
reportButton
.
setEnabled
(
false
);
buttonPanel
.
add
(
reportButton
);
JButton
showReportButton
=
new
JButton
(
"Show report"
);
showReportButton
.
setEnabled
(
false
);
buttonPanel
.
add
(
showReportButton
);
JButton
saveReportButton
=
new
JButton
(
"Save report"
);
saveReportButton
.
setEnabled
(
false
);
buttonPanel
.
add
(
saveReportButton
);
JButton
updateButton
=
new
JButton
(
"Update corpus services"
);
buttonPanel
.
add
(
updateButton
);
JButton
exitButton
=
new
JButton
(
"Exit"
);
...
...
@@ -82,7 +85,8 @@ public class GUI {
Function
<
String
,
Void
>
callback
=
(
outFile
)
->
{
reportFile
=
outFile
;
reportButton
.
setEnabled
(
true
);
showReportButton
.
setEnabled
(
true
);
saveReportButton
.
setEnabled
(
true
);
JOptionPane
.
showMessageDialog
(
window
,
"Checks executed successfully. You can now check the report."
,
"Success"
,
...
...
@@ -93,7 +97,7 @@ public class GUI {
};
checkButton
.
addActionListener
(
actionEvent
->
{
checkButton
.
setEnabled
(
false
);
r
eportButton
.
setEnabled
(
false
);
showR
eportButton
.
setEnabled
(
false
);
updateButton
.
setEnabled
(
false
);
// Do the checking
try
{
...
...
@@ -163,7 +167,7 @@ public class GUI {
updateButton
.
setEnabled
(
true
);
exitButton
.
setEnabled
(
true
);
});
r
eportButton
.
addActionListener
(
actionEvent
->
{
showR
eportButton
.
addActionListener
(
actionEvent
->
{
Desktop
dt
=
Desktop
.
getDesktop
();
try
{
dt
.
open
(
new
File
(
reportFile
));
...
...
@@ -174,6 +178,40 @@ public class GUI {
JOptionPane
.
ERROR_MESSAGE
);
}
});
saveReportButton
.
addActionListener
(
actionEvent
->
{
JFileChooser
chooser
=
new
JFileChooser
();
chooser
.
setFileFilter
(
new
FileNameExtensionFilter
(
"HTML file"
,
"html"
,
"htm"
));
chooser
.
setFileSelectionMode
(
JFileChooser
.
FILES_ONLY
);
chooser
.
setSelectedFile
(
new
File
(
reportFile
));
int
result
=
chooser
.
showSaveDialog
(
configButton
);
if
(
result
==
JFileChooser
.
APPROVE_OPTION
)
{
if
(!(
chooser
.
getSelectedFile
().
toString
().
toLowerCase
().
endsWith
(
"htm"
)
||
chooser
.
getSelectedFile
().
toString
().
toLowerCase
().
endsWith
(
"html"
)))
chooser
.
setSelectedFile
(
new
File
(
chooser
.
getSelectedFile
().
toString
()
+
".html"
));
boolean
overwrite
=
true
;
if
(
chooser
.
getSelectedFile
().
exists
())
{
int
overwriteResp
=
JOptionPane
.
showConfirmDialog
(
window
,
"File "
+
chooser
.
getSelectedFile
()
+
" already exists. Do you want to overwrite?"
,
"Overwrite"
,
JOptionPane
.
YES_NO_OPTION
);
if
(
overwriteResp
==
JOptionPane
.
NO_OPTION
)
{
overwrite
=
false
;
}
}
try
{
if
(
overwrite
)
{
new
BufferedInputStream
(
new
FileInputStream
(
reportFile
))
.
transferTo
(
new
BufferedOutputStream
(
new
FileOutputStream
(
chooser
.
getSelectedFile
())));
}
}
catch
(
IOException
e
)
{
JOptionPane
.
showMessageDialog
(
window
,
"Error saving report to "
+
chooser
.
getSelectedFile
().
getPath
()
+
". Reason: "
+
e
,
"Error"
,
JOptionPane
.
ERROR_MESSAGE
);
}
}
});
// Handle exit
exitButton
.
addActionListener
(
actionEvent
->
{
// Close window
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment