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