1 /**********************************************************************
2 * Copyright (c) 2003 IBM Corporation and others.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Common Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/cpl-v10.html
9 * IBM - Initial API and implementation
10 **********************************************************************/
11 package net.sourceforge.phpdt.monitor.ui.internal.viewers;
13 import net.sourceforge.phpdt.monitor.core.MonitorCore;
14 import net.sourceforge.phpdt.monitor.ui.IContentViewer;
15 import net.sourceforge.phpdt.monitor.ui.internal.ContextIds;
17 import org.eclipse.jface.resource.JFaceResources;
18 import org.eclipse.swt.SWT;
19 import org.eclipse.swt.layout.GridData;
20 import org.eclipse.swt.layout.GridLayout;
21 import org.eclipse.swt.widgets.Composite;
22 import org.eclipse.swt.widgets.Display;
23 import org.eclipse.swt.widgets.Text;
24 import org.eclipse.ui.help.WorkbenchHelp;
27 * A basic byte viewer.
29 public class ByteViewer implements IContentViewer {
31 protected Composite comp;
34 * @see net.sourceforge.phpdt.monitor.ui.IContentViewer#dispose()
36 public void dispose() {
41 * @see net.sourceforge.phpdt.monitor.ui.IContentViewer#setContent()
43 public void setContent(byte[] b) {
46 out = MonitorCore.parse(b);
48 String lineSeparator = System.getProperty("line.separator");
49 int ls = lineSeparator.length();
50 if (out.length() > ls) {
51 while (out.substring(0, ls).indexOf(lineSeparator) >= 0)
52 out = out.substring(ls, out.length());
59 * @see net.sourceforge.phpdt.monitor.ui.IContentViewer#init(Composite)
61 public void init(Composite parent) {
62 comp = new Composite(parent, SWT.NONE);
63 GridLayout layout = new GridLayout();
64 layout.numColumns = 1;
65 layout.marginHeight = 0;
66 layout.marginWidth = 0;
67 comp.setLayout(layout);
68 GridData data = new GridData(GridData.FILL_BOTH);
69 comp.setLayoutData(data);
71 text = new Text(comp, SWT.BORDER | SWT.MULTI | SWT.READ_ONLY | SWT.H_SCROLL | SWT.V_SCROLL);
72 Display display = comp.getDisplay();
73 text.setBackground(display.getSystemColor(SWT.COLOR_LIST_BACKGROUND));
74 text.setForeground(display.getSystemColor(SWT.COLOR_LIST_FOREGROUND));
75 text.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.FILL_VERTICAL));
76 text.setFont(JFaceResources.getTextFont());
77 WorkbenchHelp.setHelp(text, ContextIds.VIEW_RESPONSE);