KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ui > internal > part > services > ChildStatusHandler


1 /*******************************************************************************
2  * Copyright (c) 2005 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
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.ui.internal.part.services;
12
13 import org.eclipse.core.runtime.IStatus;
14 import org.eclipse.jface.resource.ImageDescriptor;
15 import org.eclipse.ui.internal.components.Assert;
16 import org.eclipse.ui.internal.components.framework.ComponentException;
17 import org.eclipse.ui.internal.components.framework.IServiceProvider;
18 import org.eclipse.ui.internal.part.Part;
19 import org.eclipse.ui.internal.part.components.services.IPartDescriptor;
20 import org.eclipse.ui.internal.part.components.services.IStatusHandler;
21 import org.eclipse.ui.internal.part.multiplexer.INestedComponent;
22 import org.eclipse.ui.internal.part.multiplexer.ISharedContext;
23
24 public class ChildStatusHandler implements IStatusHandler, INestedComponent {
25
26     private boolean active = false;
27     private IStatusHandler parent;
28     private ImageDescriptor image;
29     private IStatus message;
30     
31     /**
32      * Component constructor. Do not invoke directly.
33      */

34     public ChildStatusHandler(IPartDescriptor descr, ISharedContext shared) throws ComponentException {
35         Assert.isNotNull(descr);
36         IServiceProvider sharedContainer = shared.getSharedComponents();
37         
38         this.parent = (IStatusHandler)sharedContainer.getService(IStatusHandler.class);
39     }
40     
41     public void set(IStatus message, ImageDescriptor image) {
42         this.image = image;
43         this.message = message;
44         
45         if (active) {
46             parent.set(message, image);
47         }
48     }
49
50     public void activate(Part partBeingActivated) {
51         parent.set(message, image);
52         
53         active = true;
54     }
55
56     public void deactivate(Object JavaDoc newActive) {
57         parent.set(null, null);
58         active = false;
59     }
60
61 }
62
Popular Tags