Skip to content

Commit 5778a3e

Browse files
aymane-harmazthegreystone
authored andcommitted
8432: Better exception handling for Email Trigger failure
Reviewed-by: hdafgard
1 parent 1034873 commit 5778a3e

File tree

3 files changed

+16
-6
lines changed

3 files changed

+16
-6
lines changed

application/org.openjdk.jmc.alert/src/main/java/org/openjdk/jmc/alert/AlertDialog.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
import org.eclipse.swt.events.SelectionListener;
5151
import org.eclipse.swt.graphics.Color;
5252
import org.eclipse.swt.graphics.Image;
53+
import org.eclipse.swt.graphics.Point;
5354
import org.eclipse.swt.layout.GridData;
5455
import org.eclipse.swt.layout.GridLayout;
5556
import org.eclipse.swt.widgets.Button;
@@ -68,6 +69,9 @@
6869
import org.openjdk.jmc.ui.misc.TypedLabelProvider;
6970

7071
public class AlertDialog extends TitleAreaDialog {
72+
// Minimum alert dialog height (in dialog units)
73+
public static final int MIN_ALERT_DIALOG_HEIGHT = 200;
74+
7175
private Button m_clearButton;
7276
private Text m_text;
7377
private TableViewer m_viewer;
@@ -194,6 +198,12 @@ protected Control createContents(Composite parent) {
194198
return contents;
195199
}
196200

201+
@Override
202+
protected Point getInitialSize() {
203+
Point shellSize = super.getInitialSize();
204+
return new Point(shellSize.x, Math.max(convertVerticalDLUsToPixels(MIN_ALERT_DIALOG_HEIGHT), shellSize.y));
205+
}
206+
197207
@Override
198208
protected Control createDialogArea(Composite parent) {
199209
Control dialogArea = super.createDialogArea(parent);
@@ -203,7 +213,7 @@ protected Control createDialogArea(Composite parent) {
203213
viewer.getTable().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
204214
m_text = createMessage(sash);
205215
m_text.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
206-
sash.setWeights(new int[] {75, 25});
216+
sash.setWeights(new int[] {60, 40});
207217
sash.setLayout(new GridLayout());
208218
return dialogArea;
209219
}

application/org.openjdk.jmc.alert/src/main/java/org/openjdk/jmc/alert/AlertPlugin.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,12 +148,12 @@ private String createExceptionMessage(Date d, Throwable exception, TriggerRule r
148148
new Object[] {df1.format(d), df2.format(d)}));
149149
}
150150
builder.append(NLS.bind(Messages.AlertPlugin_MESSAGE_EXCEPTION_INVOKING_ACTION, rule.getName()));
151-
if (triggerMessage != null) {
152-
builder.append("\n" + triggerMessage + "\n");
153-
}
154151
builder.append(NLS.bind(Messages.AlertPlugin_MESSAGE_EXCEPTION_INVOKING_ACTION_MESSAGE_CAPTION,
155152
exception.getLocalizedMessage()));
156153
builder.append(Messages.AlertPlugin_MESSAGE_EXCEPTION_INVOKING_ACTION_MESSAGE_MORE_INFORMATION);
154+
if (triggerMessage != null) {
155+
builder.append("\n" + triggerMessage);
156+
}
157157
return builder.toString();
158158
}
159159

application/org.openjdk.jmc.alert/src/main/resources/org/openjdk/jmc/alert/messages.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ AlertDialog_CLEAR_ALERTS_TEXT0=Clear
3838
AlertDialog_COLUMN_HEADER_SOURCE=Source
3939
AlertDialog_POP_UP_ON_ALERTS_TEXT=Show dialog on alerts
4040
AlertPlugin_MESSAGE_EXCEPTION_INVOKING_ACTION=An exception occurred when invoking the action for the rule {0}!\n
41-
AlertPlugin_MESSAGE_EXCEPTION_INVOKING_ACTION_MESSAGE_CAPTION=The message was: {0}\n\n
42-
AlertPlugin_MESSAGE_EXCEPTION_INVOKING_ACTION_MESSAGE_MORE_INFORMATION=For more information, please see the log!
41+
AlertPlugin_MESSAGE_EXCEPTION_INVOKING_ACTION_MESSAGE_CAPTION=The message was: {0}\n
42+
AlertPlugin_MESSAGE_EXCEPTION_INVOKING_ACTION_MESSAGE_MORE_INFORMATION=For more information, please see the log!\n
4343
AlertPlugin_RULE_X_Y_TEXT=Rule: {0}\\{1}\n
4444
AlertPlugin_SOURCE_X_TEXT=Source: {0}\n
4545
AlertPlugin_TIME_X_Y_TEXT=Time: {0} {1}\n

0 commit comments

Comments
 (0)