1 23 package org.objectweb.clif.scenario.util.isac.util.tree; 24 25 import java.util.Vector ; 26 27 import org.apache.log4j.Category; 28 import org.eclipse.swt.SWT; 29 import org.eclipse.swt.custom.StyledText; 30 import org.eclipse.swt.events.SelectionEvent; 31 import org.eclipse.swt.events.SelectionListener; 32 import org.eclipse.swt.layout.GridData; 33 import org.eclipse.swt.layout.GridLayout; 34 import org.eclipse.swt.widgets.Button; 35 import org.eclipse.swt.widgets.Dialog; 36 import org.eclipse.swt.widgets.Display; 37 import org.eclipse.swt.widgets.Shell; 38 import org.objectweb.clif.scenario.util.isac.loadprofile.gui.Size; 39 40 46 public class ErrorWarningDialog extends Dialog { 47 static Category cat = Category.getInstance(ErrorWarningDialog.class 49 .getName()); 50 51 private static final String DIALOG_TITLE = "Errors and Warnings which append during last process" ; 53 private static final String BOK_LABEL = "OK" ; 54 55 private static final Size DEFAULT_SIZE = new Size(500,250) ; 57 58 private Vector lines ; 59 private StyledText styledText ; 60 private Button bOk ; 61 private Shell shell ; 62 63 71 public ErrorWarningDialog(Shell shell, Vector lines) { 72 super(shell); 73 this.lines = lines; 75 } 76 77 80 public void open() { 81 this.shell = new Shell(getParent(), SWT.DIALOG_TRIM 82 | SWT.APPLICATION_MODAL); 83 shell.setText(DIALOG_TITLE); 84 shell.setSize(DEFAULT_SIZE.getWidth(), DEFAULT_SIZE.getHeight()); 85 GridLayout gl = new GridLayout(); 87 gl.numColumns = 1; 88 shell.setLayout(gl); 89 this.styledText = new StyledText(shell, SWT.BORDER | SWT.MULTI 91 | SWT.V_SCROLL | SWT.H_SCROLL); 92 GridData gridData = new GridData() ; 94 gridData.grabExcessHorizontalSpace = true ; 95 gridData.grabExcessVerticalSpace = true ; 96 gridData.horizontalAlignment = GridData.FILL ; 97 gridData.verticalAlignment = GridData.FILL ; 98 this.styledText.setLayoutData(gridData) ; 99 this.setText() ; 101 102 this.bOk = new Button(shell, SWT.FLAT) ; 104 this.bOk.setText(BOK_LABEL) ; 105 this.bOk.addSelectionListener(new SelectionListener() { 107 public void widgetDefaultSelected(SelectionEvent arg0) { 108 shell.close() ; 109 } 110 public void widgetSelected(SelectionEvent arg0) { 111 shell.close() ; 112 } 113 }) ; 114 GridData bGrid = new GridData() ; 116 bGrid.grabExcessHorizontalSpace = true ; 117 bGrid.horizontalAlignment = GridData.FILL ; 118 this.bOk.setLayoutData(bGrid) ; 119 120 shell.open(); 121 Display display = getParent().getDisplay(); 122 while (!shell.isDisposed()) { 123 if (!display.readAndDispatch()) 124 display.sleep(); 125 } 126 } 127 128 132 private void setText() { 133 for (int i=0;i<this.lines.size();i++) { 134 this.styledText.append((String )this.lines.elementAt(i)+"\n") ; 135 } 136 } 137 } | Popular Tags |