Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
openbis
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
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
sispub
openbis
Commits
e94e93e0
Commit
e94e93e0
authored
13 years ago
by
felmer
Browse files
Options
Downloads
Patches
Plain Diff
LMS-2227 ErrorsPanel: Layout improved
SVN: 21221
parent
fc74c26d
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
datastore_server/source/java/ch/systemsx/cisd/openbis/dss/client/api/gui/ErrorsPanel.java
+50
-51
50 additions, 51 deletions
...systemsx/cisd/openbis/dss/client/api/gui/ErrorsPanel.java
with
50 additions
and
51 deletions
datastore_server/source/java/ch/systemsx/cisd/openbis/dss/client/api/gui/ErrorsPanel.java
+
50
−
51
View file @
e94e93e0
...
...
@@ -17,30 +17,29 @@
package
ch.systemsx.cisd.openbis.dss.client.api.gui
;
import
java.awt.CardLayout
;
import
java.awt.Color
;
import
java.awt.Font
;
import
java.net.URL
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.awt.Dimension
;
import
java.awt.FlowLayout
;
import
java.awt.event.ActionEvent
;
import
java.awt.event.ActionListener
;
import
java.util.LinkedHashSet
;
import
java.util.Set
;
import
javax.swing.BorderFactory
;
import
javax.swing.BoxLayout
;
import
javax.swing.ImageIcon
;
import
javax.swing.J
EditorPane
;
import
javax.swing.J
Button
;
import
javax.swing.JFrame
;
import
javax.swing.JLabel
;
import
javax.swing.JPanel
;
import
javax.swing.JScrollPane
;
import
javax.swing.ScrollPaneConstants
;
import
javax.swing.event.HyperlinkEvent
;
import
javax.swing.event.HyperlinkEvent.EventType
;
import
javax.swing.event.HyperlinkListener
;
import
ch.systemsx.cisd.openbis.dss.generic.shared.api.v1.validation.ValidationError
;
/**
* @author Pawel Glyzewski
*/
public
class
ErrorsPanel
extends
JPanel
implements
HyperlinkListener
public
class
ErrorsPanel
extends
JPanel
{
private
static
final
long
serialVersionUID
=
5932698456919803620L
;
...
...
@@ -50,77 +49,87 @@ public class ErrorsPanel extends JPanel implements HyperlinkListener
private
static
final
String
VALIDATION_SUCCESS_CARD
=
"Success"
;
private
static
final
String
WRONG_ICON_URL
=
ErrorsPanel
.
class
.
getResource
(
"/wrong.png"
)
.
toString
();
private
static
final
ImageIcon
OK_ICON
=
new
ImageIcon
(
ErrorsPanel
.
class
.
getResource
(
"/ok.png"
));
private
static
final
ImageIcon
WRONG_ICON
=
new
ImageIcon
(
ErrorsPanel
.
class
.
getResource
(
"/wrong.png"
));
private
static
final
ImageIcon
WAIT_ICON
=
new
ImageIcon
(
ErrorsPanel
.
class
.
getResource
(
"/wait.gif"
));
private
final
List
<
ValidationError
>
errors
=
new
ArrayList
<
ValidationError
>();
private
final
Set
<
String
>
errors
=
new
LinkedHashSet
<
String
>();
private
final
ErrorMessageDialog
errorMessageDialog
;
private
final
JEditorPane
errorsArea
;
private
final
JScrollPane
errorsAreaScroll
;
private
final
JPanel
errorsPanel
;
public
ErrorsPanel
(
JFrame
mainWindow
)
{
super
(
new
CardLayout
());
errorMessageDialog
=
new
ErrorMessageDialog
(
mainWindow
);
errorsArea
=
new
JEditorPane
(
"text/html"
,
""
);
errorsArea
.
addHyperlinkListener
(
this
);
errorsArea
.
setEditable
(
false
);
errorsArea
.
setBackground
(
getBackground
());
errorsArea
.
setFont
(
new
Font
(
getFont
().
getName
(),
Font
.
BOLD
,
getFont
().
getSize
()));
errorsArea
.
setForeground
(
Color
.
RED
);
errorsAreaScroll
=
new
JScrollPane
(
errorsArea
);
errorsPanel
=
new
JPanel
();
errorsPanel
.
setLayout
(
new
BoxLayout
(
errorsPanel
,
BoxLayout
.
Y_AXIS
));
errorsAreaScroll
=
new
JScrollPane
(
errorsPanel
);
errorsAreaScroll
.
setBorder
(
BorderFactory
.
createEmptyBorder
());
errorsAreaScroll
.
setHorizontalScrollBarPolicy
(
ScrollPaneConstants
.
HORIZONTAL_SCROLLBAR_NEVER
);
this
.
add
(
errorsAreaScroll
,
VALIDATION_ERRORS_CARD
);
this
.
add
(
new
JLabel
(
"Validating, please wait..."
,
WAIT_ICON
,
JLabel
.
CENTER
),
this
.
add
(
new
JLabel
(
"Validating, please wait..."
,
WAIT_ICON
,
JLabel
.
LEFT
),
VALIDATION_WAIT_CARD
);
this
.
add
(
new
JLabel
(
"Validated successfully."
,
OK_ICON
,
JLabel
.
CENTER
),
this
.
add
(
new
JLabel
(
"Validated successfully."
,
OK_ICON
,
JLabel
.
LEFT
),
VALIDATION_SUCCESS_CARD
);
}
public
void
clear
()
{
errorsArea
.
setText
(
""
);
errorsArea
.
setToolTipText
(
""
);
this
.
errors
.
clear
();
errorsPanel
.
removeAll
();
errorsPanel
.
invalidate
();
errorsPanel
.
getParent
().
validate
();
}
public
void
reportError
(
ValidationError
error
)
{
errors
.
add
(
error
);
errors
.
add
(
error
.
getErrorMessage
()
);
displayErrors
();
}
private
void
displayErrors
()
{
StringBuilder
sb
=
new
StringBuilder
();
int
counter
=
0
;
for
(
ValidationError
error
:
errors
)
if
(
errors
.
isEmpty
())
{
sb
.
append
(
"<center><div><a href='http://openbis.ch/"
+
(
counter
++)
+
"' ><img border='0' hspace='10' src='"
).
append
(
WRONG_ICON_URL
)
.
append
(
"' ></img><font color='black'>"
)
.
append
(
truncateErrorMessage
(
error
.
getErrorMessage
()))
.
append
(
" [...]</font></a></div></center>"
);
return
;
}
errorsArea
.
setText
(
sb
.
toString
());
System
.
out
.
println
(
errorsArea
.
getText
());
errorsPanel
.
removeAll
();
for
(
final
String
error
:
errors
)
{
JPanel
line
=
new
JPanel
(
new
FlowLayout
(
FlowLayout
.
LEFT
));
String
truncateErrorMessage
=
truncateErrorMessage
(
error
);
JLabel
label
=
new
JLabel
(
truncateErrorMessage
,
WRONG_ICON
,
JLabel
.
LEFT
);
line
.
add
(
label
);
if
(
truncateErrorMessage
.
length
()
<
error
.
length
())
{
JButton
button
=
new
JButton
(
"..."
);
button
.
setPreferredSize
(
new
Dimension
(
25
,
label
.
getPreferredSize
().
height
));
button
.
addActionListener
(
new
ActionListener
()
{
public
void
actionPerformed
(
ActionEvent
e
)
{
errorMessageDialog
.
showErrorMessage
(
error
);
}
});
line
.
add
(
button
);
}
errorsPanel
.
add
(
line
);
}
errorsPanel
.
invalidate
();
errorsPanel
.
getParent
().
validate
();
}
private
String
truncateErrorMessage
(
String
errorMessage
)
...
...
@@ -143,16 +152,6 @@ public class ErrorsPanel extends JPanel implements HyperlinkListener
:
errorMessage
;
}
public
void
hyperlinkUpdate
(
HyperlinkEvent
event
)
{
if
(
event
.
getEventType
()
==
EventType
.
ACTIVATED
)
{
URL
url
=
event
.
getURL
();
int
idx
=
Integer
.
parseInt
(
url
.
getPath
().
substring
(
1
));
errorMessageDialog
.
showErrorMessage
(
errors
.
get
(
idx
).
getErrorMessage
());
}
}
public
void
waitCard
()
{
((
CardLayout
)
this
.
getLayout
()).
show
(
this
,
VALIDATION_WAIT_CARD
);
...
...
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