01: package net.sourceforge.tracelog.ui;
02:
03: import java.io.BufferedReader;
04: import java.io.InputStreamReader;
05:
06: import net.sourceforge.tracelog.listeners.GenericListener;
07: import net.sourceforge.tracelog.utils.Util;
08:
09: 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,
31: SWT.DIALOG_TRIM | SWT.SYSTEM_MODAL);
32: historyShell.setLayout(new GridLayout());
33: historyShell.setText("Change History");
34:
35: ScrolledComposite sc = new ScrolledComposite(historyShell,
36: SWT.V_SCROLL | SWT.BORDER);
37: sc.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
38: sc.setBackground(UIUtil.getColorWhite());
39:
40: Composite c = new Composite(sc, SWT.NONE);
41: c.setLayout(new FillLayout());
42:
43: sc.setContent(c);
44:
45: Label label = new Label(c, SWT.NONE);
46: label.setBackground(UIUtil.getColorWhite());
47:
48: try {
49: BufferedReader rd = new BufferedReader(
50: new InputStreamReader(Util
51: .getOwnResource(projectProperties
52: .getVersionFilePath())));
53: while ((line = rd.readLine()) != null) {
54: msg += " " + line + Util.LINE_BREAK;
55: }
56: rd.close();
57: } catch (Exception ex) {
58: }
59:
60: label.setText(msg + Util.LINE_BREAK);
61:
62: Button button = new Button(historyShell, SWT.PUSH);
63: button.setText("Close");
64: button
65: .setLayoutData(new GridData(
66: GridData.HORIZONTAL_ALIGN_END));
67:
68: button.addMouseListener(new GenericListener() {
69: public void mouseUp(MouseEvent e) {
70: historyShell.dispose();
71: }
72: });
73:
74: historyShell.setSize(400, 300);
75: c.setSize(c.computeSize(SWT.DEFAULT, SWT.DEFAULT));
76: UIUtil.centerAlignedShell(parentShell, historyShell);
77:
78: historyShell.open();
79: }
80: }
|