8
8
import com .intellij .openapi .project .Project ;
9
9
import com .intellij .openapi .ui .popup .JBPopupFactory ;
10
10
import com .intellij .openapi .util .Disposer ;
11
+ import com .intellij .ui .components .JBScrollPane ;
11
12
import com .intellij .util .messages .MessageBus ;
13
+ import com .intellij .util .ui .JBUI ;
12
14
import com .neueda .jetbrains .plugin .graphdb .database .api .query .GraphQueryResult ;
13
15
import com .neueda .jetbrains .plugin .graphdb .jetbrains .actions .execute .ExecuteQueryPayload ;
14
16
import com .neueda .jetbrains .plugin .graphdb .jetbrains .component .datasource .metadata .DataSourceMetadata ;
24
26
import java .util .Map ;
25
27
26
28
import static com .neueda .jetbrains .plugin .graphdb .jetbrains .ui .console .event .QueryParametersRetrievalErrorEvent .PARAMS_ERROR_COMMON_MSG ;
29
+ import static com .neueda .jetbrains .plugin .graphdb .jetbrains .ui .datasource .interactions .DataSourceDialog .HEIGHT ;
30
+ import static com .neueda .jetbrains .plugin .graphdb .jetbrains .ui .datasource .interactions .DataSourceDialog .THICKNESS ;
27
31
import static com .neueda .jetbrains .plugin .graphdb .jetbrains .util .ExceptionWrapper .getCause ;
32
+ import static com .neueda .jetbrains .plugin .graphdb .jetbrains .util .ExceptionWrapper .truncateString ;
28
33
import static com .neueda .jetbrains .plugin .graphdb .jetbrains .util .ExceptionWrapper .wrapExceptionInMeaningMessage ;
29
34
30
35
public class LogPanel implements Disposable {
31
- private static final String SHOW_DETAILS = "Show details " ;
36
+ private static final String SHOW_DETAILS = "Details... " ;
32
37
33
38
private ConsoleView log ;
34
39
private Map <String , String > exceptions = new HashMap <>();
@@ -159,7 +164,7 @@ private String printException(Exception exception) {
159
164
}
160
165
error (errorMessage );
161
166
String details = exception .getMessage () + '\n' + getCause (exception );
162
- log .printHyperlink (SHOW_DETAILS , p -> showPopup ("Error" , details ));
167
+ log .printHyperlink (SHOW_DETAILS , p -> showPopup ("Error details " , details ));
163
168
newLine ();
164
169
return errorMessage ;
165
170
}
@@ -168,12 +173,23 @@ private void newLine() {
168
173
log .print ("\n " , ConsoleViewContentType .NORMAL_OUTPUT );
169
174
}
170
175
171
- private void showPopup (String title , String text ) {
176
+ private void showPopup (String title , String details ) {
177
+ JPanel popupPanel = new JPanel (new BorderLayout ());
178
+ popupPanel .setBorder (JBUI .Borders .empty (THICKNESS ));
179
+
180
+ JTextArea exceptionDetails = new JTextArea ();
181
+ exceptionDetails .setLineWrap (true );
182
+ exceptionDetails .append (details );
183
+ JLabel jLabel = new JLabel (truncateString (details , 120 ), AllIcons .Process .State .RedExcl , JLabel .LEFT );
184
+
185
+ JBScrollPane scrollPane = new JBScrollPane (exceptionDetails );
186
+ scrollPane .setPreferredSize (new Dimension (-1 , HEIGHT ));
187
+ popupPanel .add (jLabel , BorderLayout .CENTER );
188
+ popupPanel .add (scrollPane , BorderLayout .SOUTH );
189
+
172
190
JBPopupFactory .getInstance ()
173
191
.createComponentPopupBuilder (
174
- new JLabel (text ,
175
- AllIcons .General .Error ,
176
- JLabel .LEFT ),
192
+ popupPanel ,
177
193
log .getComponent ())
178
194
.setTitle (title )
179
195
.createPopup ()
0 commit comments