1 package net.sourceforge.tracelog.ui; 2 3 import java.io.BufferedReader ; 4 import java.io.InputStreamReader ; 5 6 import net.sourceforge.tracelog.listeners.GenericListener; 7 import net.sourceforge.tracelog.utils.Util; 8 9 import org.eclipse.swt.SWT; 10 import org.eclipse.swt.custom.ScrolledComposite; 11 import org.eclipse.swt.events.MouseEvent; 12 import org.eclipse.swt.layout.FillLayout; 13 import org.eclipse.swt.layout.GridData; 14 import org.eclipse.swt.layout.GridLayout; 15 import org.eclipse.swt.widgets.Button; 16 import org.eclipse.swt.widgets.Composite; 17 import org.eclipse.swt.widgets.Label; 18 import org.eclipse.swt.widgets.Shell; 19 20 public class ShellHistory extends AbstractWidget { 21 22 ShellHistory() { 23 super(); 24 } 25 26 public void run() { 27 String line = ""; 28 String msg = ""; 29 30 final Shell historyShell = new Shell(parentShell, SWT.DIALOG_TRIM | SWT.SYSTEM_MODAL); 31 historyShell.setLayout(new GridLayout()); 32 historyShell.setText("Change History"); 33 34 ScrolledComposite sc = new ScrolledComposite(historyShell, SWT.V_SCROLL | SWT.BORDER); 35 sc.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); 36 sc.setBackground(Util.COLOR_WHITE); 37 38 Composite c = new Composite(sc, SWT.NONE); 39 c.setLayout(new FillLayout()); 40 41 sc.setContent(c); 42 43 Label label = new Label(c, SWT.NONE); 44 label.setBackground(Util.COLOR_WHITE); 45 46 try { 47 BufferedReader rd = new BufferedReader (new InputStreamReader (Util.getOwnResource(projectProperties.getVersionFilePath()))); 48 while ((line = rd.readLine()) != null) { 49 msg += " " + line + "\n"; 50 } 51 rd.close(); 52 } 53 catch (Exception ex) { 54 } 55 56 label.setText(msg + "\n"); 57 58 Button button = new Button(historyShell, SWT.PUSH); 59 button.setText("Close"); 60 button.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); 61 62 button.addMouseListener(new GenericListener() { 63 public void mouseUp(MouseEvent e) { 64 historyShell.dispose(); 65 } 66 }); 67 68 historyShell.setSize(400, 300); 69 c.setSize(c.computeSize(SWT.DEFAULT, SWT.DEFAULT)); 70 Util.centerAlignedShell(parentShell, historyShell); 71 72 historyShell.open(); 73 } 74 } 75 | Popular Tags |