1
|
package eu.etaxonomy.taxeditor.model;
|
2
|
|
3
|
import org.eclipse.core.runtime.IStatus;
|
4
|
import org.eclipse.jface.dialogs.ErrorDialog;
|
5
|
import org.eclipse.jface.dialogs.IDialogConstants;
|
6
|
import org.eclipse.swt.SWT;
|
7
|
import org.eclipse.swt.graphics.Point;
|
8
|
import org.eclipse.swt.widgets.Shell;
|
9
|
|
10
|
/**
|
11
|
* Error dialog class specifically implemented for the editor.
|
12
|
* The main difference with {@link org.eclipse.jface.dialogs.ErrorDialog} is that
|
13
|
* this dialog has a fixed max height.
|
14
|
*
|
15
|
* @author cmathew
|
16
|
*
|
17
|
*/
|
18
|
public class CdmErrorDialog extends ErrorDialog {
|
19
|
|
20
|
private static final int DIALOG_MAX_HEIGHT = 500;
|
21
|
|
22
|
public CdmErrorDialog(Shell parentShell, String dialogTitle,
|
23
|
String message, IStatus status) {
|
24
|
super(parentShell,
|
25
|
dialogTitle,
|
26
|
message, status,
|
27
|
IStatus.OK| IStatus.INFO | IStatus.WARNING | IStatus.ERROR);
|
28
|
}
|
29
|
|
30
|
@Override
|
31
|
protected void buttonPressed(int id) {
|
32
|
super.buttonPressed(id);
|
33
|
if (id == IDialogConstants.DETAILS_ID) {
|
34
|
Point oldSize = getShell().computeSize(SWT.DEFAULT, SWT.DEFAULT);
|
35
|
// set height to max allowed
|
36
|
if(getShell().getSize().y > DIALOG_MAX_HEIGHT) {
|
37
|
getShell().setSize(getShell().getSize().x, 500);
|
38
|
} else {
|
39
|
getShell().setSize(getShell().getSize().x, oldSize.y);
|
40
|
}
|
41
|
}
|
42
|
|
43
|
}
|
44
|
}
|