01: /*******************************************************************************
02: * Copyright (c) 2000, 2006 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: *******************************************************************************/package org.eclipse.ui.internal.ide.model;
11:
12: import org.eclipse.core.runtime.IAdaptable;
13: import org.eclipse.core.runtime.IStatus;
14: import org.eclipse.ui.model.IWorkbenchAdapter;
15: import org.eclipse.ui.model.WorkbenchAdapter;
16:
17: /**
18: * UI manfestation of a status object.
19: */
20: public class WorkbenchStatus extends WorkbenchAdapter implements
21: IAdaptable {
22: private IStatus status;
23:
24: private Object[] children;
25:
26: public WorkbenchStatus(IStatus status) {
27: this .status = status;
28: }
29:
30: /**
31: * Returns an object which is an instance of the given class
32: * associated with this object. Returns <code>null</code> if
33: * no such object can be found.
34: */
35: public Object getAdapter(Class adapter) {
36: if (adapter == IWorkbenchAdapter.class) {
37: return this ;
38: }
39: return null;
40: }
41:
42: /**
43: * Returns the children of this element.
44: */
45: public Object[] getChildren(Object o) {
46: if (children == null) {
47: IStatus[] childStatii = status.getChildren();
48: children = new Object[childStatii.length];
49: for (int i = 0; i < childStatii.length; i++) {
50: children[i] = new WorkbenchStatus(childStatii[i]);
51: }
52: }
53: return children;
54: }
55:
56: /**
57: * @see IWorkbenchAdapter#getLabel
58: */
59: public String getLabel(Object o) {
60: return status.getMessage();
61: }
62:
63: /**
64: * Returns the wrapped status object.
65: */
66: public IStatus getStatus() {
67: return status;
68: }
69: }
|