KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ui > internal > ide > model > WorkbenchStatus


1 /*******************************************************************************
2  * Copyright (c) 2000, 2006 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.ui.internal.ide.model;
12
13 import org.eclipse.core.runtime.IAdaptable;
14 import org.eclipse.core.runtime.IStatus;
15 import org.eclipse.ui.model.IWorkbenchAdapter;
16 import org.eclipse.ui.model.WorkbenchAdapter;
17
18 /**
19  * UI manfestation of a status object.
20  */

21 public class WorkbenchStatus extends WorkbenchAdapter implements IAdaptable {
22     private IStatus status;
23
24     private Object JavaDoc[] 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 JavaDoc getAdapter(Class JavaDoc 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 JavaDoc[] getChildren(Object JavaDoc o) {
46         if (children == null) {
47             IStatus[] childStatii = status.getChildren();
48             children = new Object JavaDoc[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 JavaDoc getLabel(Object JavaDoc o) {
60         return status.getMessage();
61     }
62
63     /**
64      * Returns the wrapped status object.
65      */

66     public IStatus getStatus() {
67         return status;
68     }
69 }
70
Popular Tags