1
package org.herac.tuxguitar.gui.util;
3
import org.eclipse.swt.SWT;
4
import org.eclipse.swt.widgets.Display;
5
import org.eclipse.swt.widgets.Shell;
6
import org.herac.tuxguitar.gui.actions.ActionLock;
8
public class DialogUtils {
10
public static final int OPEN_STYLE_WAIT = 0x01;
12
public static final int OPEN_STYLE_PACK = 0x02;
14
public static final int OPEN_STYLE_LAYOUT = 0x04;
16
public static final int OPEN_STYLE_CENTER = 0x08;
18
public static final int OPEN_STYLE_MAXIMIZED = 0x10;
20
public static final Shell newDialog(Display display,int style){
21
return new Shell(display, style);
24
public static final Shell newDialog(Shell parent,int style){
25
parent.setCursor(parent.getDisplay().getSystemCursor(SWT.CURSOR_WAIT));
26
return new Shell(parent, style);
29
public static final void openDialog(Shell dialog,int style){
30
DialogUtils.openDialog(dialog,dialog.getParent().getShell(),style);
33
public static final void openDialog(Shell dialog,Shell parent,int style){
34
Display display = dialog.getDisplay();
35
if((style & OPEN_STYLE_PACK) != 0){
38
if((style & OPEN_STYLE_LAYOUT) != 0){
41
if((style & OPEN_STYLE_MAXIMIZED) != 0){
42
dialog.setMaximized(true);
44
else if((style & OPEN_STYLE_CENTER) != 0){
45
int x = Math.max(0,parent.getBounds().x + (parent.getBounds().width - dialog.getSize().x) / 2);
46
int y = Math.max(0,parent.getBounds().y + (parent.getBounds().height - dialog.getSize().y) / 2);
47
dialog.setLocation(x,y);
51
parent.setCursor(display.getSystemCursor(SWT.CURSOR_ARROW));
53
if((style & OPEN_STYLE_WAIT) != 0){
54
if( (dialog.getStyle() & SWT.APPLICATION_MODAL) == 0 ){
57
while (!display.isDisposed() && !dialog.isDisposed()) {
58
if (!display.readAndDispatch()) {