0
|
1 |
// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
2 |
// All rights reserved.
|
|
3 |
// This component and the accompanying materials are made available
|
|
4 |
// under the terms of "Eclipse Public License v1.0"
|
|
5 |
// which accompanies this distribution, and is available
|
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
7 |
//
|
|
8 |
// Initial Contributors:
|
|
9 |
// Nokia Corporation - initial contribution.
|
|
10 |
//
|
|
11 |
// Contributors:
|
|
12 |
//
|
|
13 |
// Description:
|
|
14 |
//
|
|
15 |
|
|
16 |
package com.symbian.smt.gui.views;
|
|
17 |
|
|
18 |
import org.eclipse.swt.SWT;
|
|
19 |
import org.eclipse.swt.widgets.Composite;
|
|
20 |
import org.eclipse.swt.widgets.Text;
|
|
21 |
import org.eclipse.ui.part.ViewPart;
|
|
22 |
|
|
23 |
public class ConsoleOutput extends ViewPart {
|
|
24 |
|
|
25 |
public static final String ID = "com.symbian.smt.gui.views.consoleoutput"; //$NON-NLS-1$
|
|
26 |
private static Text text;
|
|
27 |
private static StringBuilder theText = new StringBuilder();
|
|
28 |
|
|
29 |
/**
|
|
30 |
* Adds text to the console output
|
|
31 |
*
|
|
32 |
* @param String
|
|
33 |
* Text to add to the console
|
|
34 |
* @return void
|
|
35 |
*/
|
|
36 |
public static void addText(String someText) {
|
|
37 |
|
|
38 |
theText.append(someText);
|
|
39 |
theText.append(System.getProperty("line.separator"));
|
|
40 |
|
|
41 |
if (text != null) {
|
|
42 |
text.setText(theText.toString());
|
|
43 |
text.append("");
|
|
44 |
}
|
|
45 |
}
|
|
46 |
|
|
47 |
/**
|
|
48 |
* Returns the text contained in the console output
|
|
49 |
*
|
|
50 |
* @return String
|
|
51 |
*/
|
|
52 |
public static String getText() {
|
|
53 |
if (theText.toString().length() > 0) {
|
|
54 |
return theText.toString();
|
|
55 |
}
|
|
56 |
|
|
57 |
return "";
|
|
58 |
}
|
|
59 |
|
|
60 |
/**
|
|
61 |
* Resets the console output, removes all text
|
|
62 |
*
|
|
63 |
* @return void
|
|
64 |
*/
|
|
65 |
public static void reset() {
|
|
66 |
theText = new StringBuilder();
|
|
67 |
|
|
68 |
if (text != null) {
|
|
69 |
text.setText("");
|
|
70 |
}
|
|
71 |
}
|
|
72 |
|
|
73 |
@Override
|
|
74 |
public void createPartControl(Composite parent) {
|
|
75 |
text = new Text(parent, SWT.WRAP | SWT.V_SCROLL | SWT.MULTI
|
|
76 |
| SWT.BORDER);
|
|
77 |
text.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_WHITE));
|
|
78 |
text.setEditable(false);
|
|
79 |
}
|
|
80 |
|
|
81 |
@Override
|
|
82 |
public void setFocus() {
|
|
83 |
if (theText != null) {
|
|
84 |
text.setText(theText.toString());
|
|
85 |
text.append("");
|
|
86 |
}
|
|
87 |
}
|
|
88 |
} |