KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jface > action > SubStatusLineManager


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.jface.action;
12
13 import org.eclipse.core.runtime.IProgressMonitor;
14 import org.eclipse.swt.graphics.Image;
15
16 /**
17  * A <code>SubStatusLineManager</code> is used to define a set of contribution
18  * items within a parent manager. Once defined, the visibility of the entire set can
19  * be changed as a unit.
20  */

21 public class SubStatusLineManager extends SubContributionManager implements
22         IStatusLineManager {
23     /**
24      * Current status line message.
25      */

26     private String JavaDoc message;
27
28     /**
29      * Current status line error message.
30      */

31     private String JavaDoc errorMessage;
32
33     /**
34      * Current status line message image.
35      */

36     private Image messageImage;
37
38     /**
39      * Current status line error image
40      */

41     private Image errorImage;
42
43     /**
44      * Constructs a new manager.
45      *
46      * @param mgr the parent manager. All contributions made to the
47      * <code>SubStatusLineManager</code> are forwarded and appear in the
48      * parent manager.
49      */

50     public SubStatusLineManager(IStatusLineManager mgr) {
51         super(mgr);
52     }
53
54     /**
55      * @return the parent status line manager that this sub-manager contributes
56      * to
57      */

58     protected final IStatusLineManager getParentStatusLineManager() {
59         // Cast is ok because that's the only
60
// thing we accept in the construtor.
61
return (IStatusLineManager) getParent();
62     }
63
64     /* (non-Javadoc)
65      * Method declared on IStatusLineManager.
66      */

67     public IProgressMonitor getProgressMonitor() {
68         return getParentStatusLineManager().getProgressMonitor();
69     }
70
71     /* (non-Javadoc)
72      * Method declared on IStatusLineManager.
73      */

74     public boolean isCancelEnabled() {
75         return getParentStatusLineManager().isCancelEnabled();
76     }
77
78     /* (non-Javadoc)
79      * Method declared on IStatusLineManager.
80      */

81     public void setCancelEnabled(boolean enabled) {
82         getParentStatusLineManager().setCancelEnabled(enabled);
83     }
84
85     /* (non-Javadoc)
86      * Method declared on IStatusLineManager.
87      */

88     public void setErrorMessage(String JavaDoc message) {
89         this.errorImage = null;
90         this.errorMessage = message;
91         if (isVisible()) {
92             getParentStatusLineManager().setErrorMessage(errorMessage);
93         }
94     }
95
96     /* (non-Javadoc)
97      * Method declared on IStatusLineManager.
98      */

99     public void setErrorMessage(Image image, String JavaDoc message) {
100         this.errorImage = image;
101         this.errorMessage = message;
102         if (isVisible()) {
103             getParentStatusLineManager().setErrorMessage(errorImage,
104                     errorMessage);
105         }
106     }
107
108     /* (non-Javadoc)
109      * Method declared on IStatusLineManager.
110      */

111     public void setMessage(String JavaDoc message) {
112         this.messageImage = null;
113         this.message = message;
114         if (isVisible()) {
115             getParentStatusLineManager().setMessage(message);
116         }
117     }
118
119     /* (non-Javadoc)
120      * Method declared on IStatusLineManager.
121      */

122     public void setMessage(Image image, String JavaDoc message) {
123         this.messageImage = image;
124         this.message = message;
125         if (isVisible()) {
126             getParentStatusLineManager().setMessage(messageImage, message);
127         }
128     }
129
130     /* (non-Javadoc)
131      * Method declared on SubContributionManager.
132      */

133     public void setVisible(boolean visible) {
134         super.setVisible(visible);
135         if (visible) {
136             getParentStatusLineManager().setErrorMessage(errorImage,
137                     errorMessage);
138             getParentStatusLineManager().setMessage(messageImage, message);
139         } else {
140             getParentStatusLineManager().setMessage(null, null);
141             getParentStatusLineManager().setErrorMessage(null, null);
142         }
143     }
144
145     /* (non-Javadoc)
146      * Method declared on IStatusLineManager.
147      */

148     public void update(boolean force) {
149         // This method is not governed by visibility. The client may
150
// call <code>setVisible</code> and then force an update. At that
151
// point we need to update the parent.
152
getParentStatusLineManager().update(force);
153     }
154 }
155
Popular Tags