Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
DocExplore
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Alexander BURNETT
DocExplore
Commits
8a754927
Commit
8a754927
authored
6 years ago
by
aburn
Browse files
Options
Downloads
Patches
Plain Diff
Added custom subject line
parent
055c1db5
Branches
Branches containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/org/interreg/docexplore/gui/ErrorDialog.java
+71
-70
71 additions, 70 deletions
src/org/interreg/docexplore/gui/ErrorDialog.java
src/org/interreg/docexplore/gui/ErrorHandler.java
+62
-59
62 additions, 59 deletions
src/org/interreg/docexplore/gui/ErrorHandler.java
with
133 additions
and
129 deletions
src/org/interreg/docexplore/gui/ErrorDialog.java
+
71
−
70
View file @
8a754927
...
...
@@ -12,8 +12,8 @@ In this respect, the user's attention is drawn to the risks associated with load
The fact that you are presently reading this means that you have had knowledge of the CeCILL license and that you accept its terms.
*/
package
org.interreg.docexplore.gui
;
package
org.interreg.docexplore.gui
;
import
java.awt.BorderLayout
;
import
java.awt.Component
;
import
java.awt.Container
;
...
...
@@ -62,47 +62,47 @@ import org.interreg.docexplore.util.ZipUtils;
import
com.jcraft.jsch.ChannelSftp
;
import
com.jcraft.jsch.JSch
;
import
com.jcraft.jsch.Session
;
@SuppressWarnings
(
"serial"
)
public
class
ErrorDialog
extends
JDialog
{
JLabel
message
;
JToggleButton
detailsButton
,
sendButton
;
JTextPane
detailsPane
;
import
com.jcraft.jsch.Session
;
@SuppressWarnings
(
"serial"
)
public
class
ErrorDialog
extends
JDialog
{
JLabel
message
;
JToggleButton
detailsButton
,
sendButton
;
JTextPane
detailsPane
;
JScrollPane
scrollPane
;
JPanel
sendPane
;
JTextField
login
,
password
;
JCheckBox
remember
,
screenshot
;
JTextArea
comment
;
JTextArea
comment
;
Throwable
ex
=
null
;
String
trace
=
""
;
File
prefs
;
public
ErrorDialog
()
{
File
prefs
;
public
ErrorDialog
()
{
super
(
JOptionPane
.
getRootFrame
(),
Lang
.
s
(
"errorGenericTitle"
),
true
);
this
.
prefs
=
new
File
(
DocExploreTool
.
getHomeDir
(),
"edcache"
);
getContentPane
().
setLayout
(
new
BorderLayout
(
20
,
20
));
JPanel
messagePanel
=
new
JPanel
(
new
FlowLayout
(
FlowLayout
.
LEFT
,
10
,
10
));
messagePanel
.
add
(
new
JLabel
(
ImageUtils
.
getIcon
(
"remove-24x24.png"
)));
messagePanel
.
add
(
message
=
new
JLabel
(
""
));
//messagePanel.getInsets().set(20, 20, 20, 20);
getContentPane
().
add
(
messagePanel
,
BorderLayout
.
NORTH
);
JPanel
buttonPanel
=
new
JPanel
(
new
FlowLayout
(
FlowLayout
.
CENTER
));
buttonPanel
.
add
(
new
JButton
(
new
AbstractAction
(
Lang
.
s
(
"dialogCloseLabel"
))
{
public
void
actionPerformed
(
ActionEvent
e
)
{
ErrorDialog
.
this
.
setVisible
(
false
);
}}));
buttonPanel
.
add
(
detailsButton
=
new
JToggleButton
(
new
AbstractAction
(
Lang
.
s
(
"errorDetailsLabel"
))
{
public
void
actionPerformed
(
ActionEvent
e
)
this
.
prefs
=
new
File
(
DocExploreTool
.
getHomeDir
(),
"edcache"
);
getContentPane
().
setLayout
(
new
BorderLayout
(
20
,
20
));
JPanel
messagePanel
=
new
JPanel
(
new
FlowLayout
(
FlowLayout
.
LEFT
,
10
,
10
));
messagePanel
.
add
(
new
JLabel
(
ImageUtils
.
getIcon
(
"remove-24x24.png"
)));
messagePanel
.
add
(
message
=
new
JLabel
(
""
));
//messagePanel.getInsets().set(20, 20, 20, 20);
getContentPane
().
add
(
messagePanel
,
BorderLayout
.
NORTH
);
JPanel
buttonPanel
=
new
JPanel
(
new
FlowLayout
(
FlowLayout
.
CENTER
));
buttonPanel
.
add
(
new
JButton
(
new
AbstractAction
(
Lang
.
s
(
"dialogCloseLabel"
))
{
public
void
actionPerformed
(
ActionEvent
e
)
{
ErrorDialog
.
this
.
setVisible
(
false
);
}}));
buttonPanel
.
add
(
detailsButton
=
new
JToggleButton
(
new
AbstractAction
(
Lang
.
s
(
"errorDetailsLabel"
))
{
public
void
actionPerformed
(
ActionEvent
e
)
{
removePane
(
detailsButton
);
if
(
detailsButton
.
isSelected
())
ErrorDialog
.
this
.
getContentPane
().
add
(
scrollPane
,
BorderLayout
.
SOUTH
);
pack
();
removePane
(
detailsButton
);
if
(
detailsButton
.
isSelected
())
ErrorDialog
.
this
.
getContentPane
().
add
(
scrollPane
,
BorderLayout
.
SOUTH
);
pack
();
}}));
// buttonPanel.add(sendButton = new JToggleButton(new AbstractAction(Lang.s("errorSend")) {public void actionPerformed(ActionEvent e)
// {
...
...
@@ -110,16 +110,16 @@ public class ErrorDialog extends JDialog
// if (sendButton.isSelected())
// ErrorDialog.this.getContentPane().add(sendPane, BorderLayout.SOUTH);
// pack();
// }}));
buttonPanel
.
setPreferredSize
(
new
Dimension
(
480
,
40
));
getContentPane
().
add
(
buttonPanel
,
BorderLayout
.
CENTER
);
detailsPane
=
new
JTextPane
();
scrollPane
=
new
JScrollPane
(
detailsPane
,
JScrollPane
.
VERTICAL_SCROLLBAR_ALWAYS
,
JScrollPane
.
HORIZONTAL_SCROLLBAR_NEVER
);
scrollPane
.
setPreferredSize
(
new
Dimension
(
480
,
240
));
detailsPane
.
setBackground
(
getContentPane
().
getBackground
());
scrollPane
.
setBorder
(
BorderFactory
.
createCompoundBorder
(
BorderFactory
.
createEmptyBorder
(
10
,
10
,
10
,
10
),
// }}));
buttonPanel
.
setPreferredSize
(
new
Dimension
(
480
,
40
));
getContentPane
().
add
(
buttonPanel
,
BorderLayout
.
CENTER
);
detailsPane
=
new
JTextPane
();
scrollPane
=
new
JScrollPane
(
detailsPane
,
JScrollPane
.
VERTICAL_SCROLLBAR_ALWAYS
,
JScrollPane
.
HORIZONTAL_SCROLLBAR_NEVER
);
scrollPane
.
setPreferredSize
(
new
Dimension
(
480
,
240
));
detailsPane
.
setBackground
(
getContentPane
().
getBackground
());
scrollPane
.
setBorder
(
BorderFactory
.
createCompoundBorder
(
BorderFactory
.
createEmptyBorder
(
10
,
10
,
10
,
10
),
scrollPane
.
getBorder
()));
sendPane
=
new
JPanel
(
new
LooseGridLayout
(
0
,
2
,
5
,
5
,
false
,
false
,
SwingConstants
.
LEFT
,
SwingConstants
.
TOP
,
true
,
false
));
...
...
@@ -144,7 +144,7 @@ public class ErrorDialog extends JDialog
((
JButton
)
e
.
getSource
()).
setEnabled
(
true
);
}}.
start
();
}}));
comment
.
setLineWrap
(
true
);
comment
.
setLineWrap
(
true
);
}
private
void
send
()
throws
Exception
...
...
@@ -231,24 +231,25 @@ public class ErrorDialog extends JDialog
Component
comp
=
((
BorderLayout
)
ErrorDialog
.
this
.
getContentPane
().
getLayout
()).
getLayoutComponent
(
BorderLayout
.
SOUTH
);
if
(
comp
!=
null
)
getContentPane
().
remove
(
comp
);
}
}
public
void
show
(
Throwable
ex
)
{
this
.
ex
=
ex
;
message
.
setText
(
Lang
.
s
(
"errorGenericMessage"
));
StringWriter
out
=
new
StringWriter
();
public
void
show
(
Throwable
ex
)
{
show
(
Lang
.
s
(
"errorGenericMessage"
),
ex
);}
public
void
show
(
String
object
,
Throwable
ex
)
{
this
.
ex
=
ex
;
message
.
setText
(
object
);
StringWriter
out
=
new
StringWriter
();
ex
.
printStackTrace
(
new
PrintWriter
(
out
,
true
));
trace
=
out
.
toString
();
trace
=
out
.
toString
();
detailsPane
.
setText
(
trace
);
comment
.
setText
(
""
);
readPrefs
();
removePane
(
null
);
pack
();
GuiUtils
.
centerOnScreen
(
this
);
setVisible
(
true
);
removePane
(
null
);
pack
();
GuiUtils
.
centerOnScreen
(
this
);
setVisible
(
true
);
}
public
static
final
void
makeScreenshot
(
Container
argFrame
,
File
file
)
...
...
@@ -261,16 +262,16 @@ public class ErrorDialog extends JDialog
try
{
ImageIO
.
write
(
bufferedImage
,
"JPG"
,
file
);}
catch
(
IOException
ioe
)
{
ioe
.
printStackTrace
();}
}
public
static
void
main
(
String
[]
args
)
{
try
{
UIManager
.
setLookAndFeel
(
UIManager
.
getSystemLookAndFeelClassName
());}
catch
(
Exception
e
)
{
e
.
printStackTrace
();}
ErrorDialog
dialog
=
new
ErrorDialog
();
dialog
.
show
(
new
Exception
(
"Big problem!"
));
dialog
.
show
(
new
Exception
(
"Another big problem!"
));
System
.
exit
(
0
);
}
}
}
public
static
void
main
(
String
[]
args
)
{
try
{
UIManager
.
setLookAndFeel
(
UIManager
.
getSystemLookAndFeelClassName
());}
catch
(
Exception
e
)
{
e
.
printStackTrace
();}
ErrorDialog
dialog
=
new
ErrorDialog
();
dialog
.
show
(
new
Exception
(
"Big problem!"
));
dialog
.
show
(
new
Exception
(
"Another big problem!"
));
System
.
exit
(
0
);
}
}
This diff is collapsed.
Click to expand it.
src/org/interreg/docexplore/gui/ErrorHandler.java
+
62
−
59
View file @
8a754927
...
...
@@ -12,67 +12,70 @@ In this respect, the user's attention is drawn to the risks associated with load
The fact that you are presently reading this means that you have had knowledge of the CeCILL license and that you accept its terms.
*/
package
org.interreg.docexplore.gui
;
import
java.io.File
;
import
java.io.FileOutputStream
;
import
java.io.OutputStreamWriter
;
import
java.text.DateFormat
;
import
java.util.Calendar
;
import
org.interreg.docexplore.DocExploreTool
;
public
class
ErrorHandler
{
File
errorLog
;
ErrorDialog
dialog
=
new
ErrorDialog
();
public
ErrorHandler
(
File
errorLog
)
{
this
.
errorLog
=
errorLog
;
package
org.interreg.docexplore.gui
;
import
java.io.File
;
import
java.io.FileOutputStream
;
import
java.io.OutputStreamWriter
;
import
java.text.DateFormat
;
import
java.util.Calendar
;
import
org.interreg.docexplore.DocExploreTool
;
public
class
ErrorHandler
{
File
errorLog
;
ErrorDialog
dialog
=
new
ErrorDialog
();
public
ErrorHandler
(
File
errorLog
)
{
this
.
errorLog
=
errorLog
;
}
public
ErrorHandler
()
{
this
(
new
File
(
DocExploreTool
.
getHomeDir
(),
"error.log"
));}
public
void
submit
(
Throwable
e
)
{
submit
(
e
,
false
);}
public
void
submit
(
Throwable
e
,
boolean
silent
)
{
e
.
printStackTrace
();
write
(
e
);
if
(!
silent
)
dialog
.
show
(
e
);
}
public
ErrorHandler
()
{
this
(
new
File
(
DocExploreTool
.
getHomeDir
(),
"error.log"
));}
public
void
submit
(
Throwable
e
)
{
submit
(
e
,
false
);}
public
void
submit
(
Throwable
e
,
boolean
silent
)
public
void
submit
(
String
object
,
Throwable
e
)
{
e
.
printStackTrace
();
write
(
e
);
if
(!
silent
)
{
// String msg = e.getMessage() == null || e.getMessage().trim().length() == 0 ? "Oops!" : e.getMessage();
// JOptionPane.showMessageDialog(null, msg, "Error", JOptionPane.ERROR_MESSAGE);
dialog
.
show
(
e
);
}
}
public
void
write
(
Throwable
e
)
{
try
{
OutputStreamWriter
writer
=
new
OutputStreamWriter
(
new
FileOutputStream
(
errorLog
,
true
));
StringBuffer
sb
=
new
StringBuffer
(
DateFormat
.
getDateTimeInstance
(
DateFormat
.
MEDIUM
,
DateFormat
.
MEDIUM
).
format
(
Calendar
.
getInstance
().
getTime
()));
sb
.
append
(
" : "
);
Throwable
t
=
e
;
while
(
t
!=
null
)
{
sb
.
append
(
t
.
getMessage
()).
append
(
"\n"
);
for
(
StackTraceElement
elem
:
t
.
getStackTrace
())
sb
.
append
(
"\t\t"
).
append
(
elem
.
toString
()).
append
(
"\n"
);
t
=
t
.
getCause
();
if
(
t
!=
null
)
sb
.
append
(
"\tCaused by : "
);
}
writer
.
write
(
sb
.
toString
());
writer
.
close
();
}
catch
(
Exception
ex
)
{
ex
.
printStackTrace
();}
}
public
final
static
ErrorHandler
defaultHandler
=
new
ErrorHandler
();
}
dialog
.
show
(
object
,
e
);
}
public
void
write
(
Throwable
e
)
{
try
{
OutputStreamWriter
writer
=
new
OutputStreamWriter
(
new
FileOutputStream
(
errorLog
,
true
));
StringBuffer
sb
=
new
StringBuffer
(
DateFormat
.
getDateTimeInstance
(
DateFormat
.
MEDIUM
,
DateFormat
.
MEDIUM
).
format
(
Calendar
.
getInstance
().
getTime
()));
sb
.
append
(
" : "
);
Throwable
t
=
e
;
while
(
t
!=
null
)
{
sb
.
append
(
t
.
getMessage
()).
append
(
"\n"
);
for
(
StackTraceElement
elem
:
t
.
getStackTrace
())
sb
.
append
(
"\t\t"
).
append
(
elem
.
toString
()).
append
(
"\n"
);
t
=
t
.
getCause
();
if
(
t
!=
null
)
sb
.
append
(
"\tCaused by : "
);
}
writer
.
write
(
sb
.
toString
());
writer
.
close
();
}
catch
(
Exception
ex
)
{
ex
.
printStackTrace
();}
}
public
final
static
ErrorHandler
defaultHandler
=
new
ErrorHandler
();
}
This diff is collapsed.
Click to expand it.
Preview
0%
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