|
23 | 23 | import com.vaadin.flow.component.Component; |
24 | 24 | import com.vaadin.flow.component.Html; |
25 | 25 | import com.vaadin.flow.component.button.Button; |
| 26 | +import com.vaadin.flow.component.button.ButtonVariant; |
26 | 27 | import com.vaadin.flow.component.dependency.CssImport; |
27 | 28 | import com.vaadin.flow.component.dialog.Dialog; |
28 | 29 | import com.vaadin.flow.component.html.Div; |
|
35 | 36 | import java.util.UUID; |
36 | 37 | import org.slf4j.Logger; |
37 | 38 | import org.slf4j.LoggerFactory; |
| 39 | +import org.vaadin.olli.ClipboardHelper; |
38 | 40 |
|
39 | 41 | /** |
40 | 42 | * Component to visualize an error, caused by an exception, as a modal sub-window. <br> |
@@ -145,11 +147,21 @@ private VerticalLayout createMainLayout() { |
145 | 147 | mainLayout.setHorizontalComponentAlignment(Alignment.START, errorLabel); |
146 | 148 |
|
147 | 149 | HorizontalLayout buttonsLayout = new HorizontalLayout(); |
| 150 | + buttonsLayout.setWidthFull(); |
148 | 151 | buttonsLayout.setSpacing(true); |
149 | 152 | buttonsLayout.setPadding(false); |
150 | 153 | buttonsLayout.setMargin(false); |
151 | 154 |
|
152 | 155 | if (!productionMode) { |
| 156 | + // copy details to clipboard button |
| 157 | + Button clipboarButton = new Button(i18n.getClipboard()); |
| 158 | + clipboarButton.addThemeVariants(ButtonVariant.LUMO_TERTIARY); |
| 159 | + ClipboardHelper clipboardHelper = new ClipboardHelper(getStackTrace(), clipboarButton); |
| 160 | + buttonsLayout.add(clipboardHelper); |
| 161 | + buttonsLayout.setAlignSelf(Alignment.START, clipboardHelper); |
| 162 | + buttonsLayout.setFlexGrow(1.0, clipboardHelper); |
| 163 | + |
| 164 | + // show details button |
153 | 165 | Button button = createDetailsButtonLayout(); |
154 | 166 | buttonsLayout.add(button); |
155 | 167 | mainLayout.add(createExceptionTraceLayout()); |
@@ -202,14 +214,18 @@ protected Component createStackTraceArea() { |
202 | 214 | area.setClassName("stacktrace"); |
203 | 215 | area.setWidthFull(); |
204 | 216 | area.setHeight("15em"); |
| 217 | + area.add(getStackTrace()); |
| 218 | + return area; |
| 219 | + } |
| 220 | + |
| 221 | + private String getStackTrace() { |
205 | 222 | final ByteArrayOutputStream baos = new ByteArrayOutputStream(); |
206 | 223 | final PrintWriter pw = new PrintWriter(baos); |
207 | 224 | cause.printStackTrace(pw); |
208 | 225 | pw.flush(); |
209 | | - area.add(baos.toString()); |
210 | | - return area; |
| 226 | + return baos.toString(); |
211 | 227 | } |
212 | | - |
| 228 | + |
213 | 229 | protected Html createErrorLabel() { |
214 | 230 | String label = errorMessage == null ? i18n.getDefaultErrorMessage() : errorMessage; |
215 | 231 | if (productionMode) { |
|
0 commit comments