1 package org
.argeo
.slc
.client
.ui
.editors
;
3 import java
.text
.DateFormat
;
4 import java
.text
.SimpleDateFormat
;
7 import org
.argeo
.slc
.execution
.ExecutionStep
;
8 import org
.eclipse
.swt
.SWT
;
9 import org
.eclipse
.swt
.widgets
.Composite
;
10 import org
.eclipse
.swt
.widgets
.Control
;
11 import org
.eclipse
.swt
.widgets
.Display
;
12 import org
.eclipse
.swt
.widgets
.Text
;
13 import org
.eclipse
.ui
.forms
.editor
.FormEditor
;
14 import org
.eclipse
.ui
.forms
.editor
.FormPage
;
15 import org
.eclipse
.ui
.forms
.widgets
.FormToolkit
;
17 public class ProcessLogPage
extends FormPage
{
18 public final static String ID
= "processLogPage";
20 private DateFormat dateFormat
= new SimpleDateFormat("HH:mm:ss");
22 /** Where the log is displayed. */
25 * Stores logs received before the text was shown. TODO : rather store in in
26 * JCR and reads it from there.
28 private StringBuffer beforeTextInit
= new StringBuffer("");
30 public ProcessLogPage(FormEditor editor
) {
31 super(editor
, ID
, "Log");
35 public synchronized void createPartControl(Composite parent
) {
36 // bypass createFormContent
37 FormToolkit tk
= getEditor().getToolkit();
38 // parent.setLayout(new FillLayout());
39 text
= tk
.createText(parent
, "", SWT
.MULTI
| SWT
.H_SCROLL
41 text
.setEditable(false);
43 // transfer the existing buffer the first time
44 if (beforeTextInit
.length() > 0) {
45 text
.append(beforeTextInit
.toString());
47 beforeTextInit
.setLength(0);
53 // protected synchronized void createFormContent(IManagedForm mf) {
54 // ScrolledForm form = mf.getForm();
55 // form.setExpandHorizontal(true);
56 // form.setExpandVertical(true);
57 // // form.setText("Log");
58 // FillLayout mainLayout = new FillLayout();
59 // form.getBody().setLayout(mainLayout);
61 // FormToolkit tk = getManagedForm().getToolkit();
62 // text = tk.createText(form.getBody(), "", SWT.MULTI | SWT.H_SCROLL
64 // text.setEditable(false);
65 // // transfer the existing buffer the first time
66 // if (beforeTextInit.length() > 0) {
67 // text.append(beforeTextInit.toString());
69 // beforeTextInit.setLength(0);
73 public synchronized void addSteps(List
<ExecutionStep
> steps
) {
74 final StringBuffer buf
= new StringBuffer("");
75 for (ExecutionStep step
: steps
) {
76 buf
.append(dateFormat
.format(step
.getTimestamp()));
78 if (step
.getType().equals(ExecutionStep
.PHASE_START
)) {
79 buf
.append("## START ").append(step
.getLog());
81 } else if (step
.getType().equals(ExecutionStep
.PHASE_END
)) {
82 buf
.append("## END ").append(step
.getLog());
85 buf
.append(step
.getLog());
90 Display
.getDefault().asyncExec(new Runnable() {
92 text
.append(buf
.toString());
96 beforeTextInit
.append(buf
);
100 public Control
getPartControl() {
105 public void setFocus() {