28
|
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 * Port to the D programming language:
|
|
11 * Frank Benoit <benoit@tionex.de>
|
|
12 *******************************************************************************/
|
|
13 module dwtx.jface.action.SubStatusLineManager;
|
|
14
|
|
15 import dwtx.jface.action.SubContributionManager;
|
|
16 import dwtx.jface.action.IStatusLineManager;
|
|
17
|
|
18 import dwt.graphics.Image;
|
|
19 import dwtx.core.runtime.IProgressMonitor;
|
|
20
|
|
21 import dwt.dwthelper.utils;
|
|
22
|
|
23 /**
|
|
24 * A <code>SubStatusLineManager</code> is used to define a set of contribution
|
|
25 * items within a parent manager. Once defined, the visibility of the entire set can
|
|
26 * be changed as a unit.
|
|
27 */
|
|
28 public class SubStatusLineManager : SubContributionManager,
|
|
29 IStatusLineManager {
|
|
30 /**
|
|
31 * Current status line message.
|
|
32 */
|
|
33 private String message;
|
|
34
|
|
35 /**
|
|
36 * Current status line error message.
|
|
37 */
|
|
38 private String errorMessage;
|
|
39
|
|
40 /**
|
|
41 * Current status line message image.
|
|
42 */
|
|
43 private Image messageImage;
|
|
44
|
|
45 /**
|
|
46 * Current status line error image
|
|
47 */
|
|
48 private Image errorImage;
|
|
49
|
|
50 /**
|
|
51 * Constructs a new manager.
|
|
52 *
|
|
53 * @param mgr the parent manager. All contributions made to the
|
|
54 * <code>SubStatusLineManager</code> are forwarded and appear in the
|
|
55 * parent manager.
|
|
56 */
|
|
57 public this(IStatusLineManager mgr) {
|
|
58 super(mgr);
|
|
59 }
|
|
60
|
|
61 /**
|
|
62 * @return the parent status line manager that this sub-manager contributes
|
|
63 * to
|
|
64 */
|
|
65 protected final IStatusLineManager getParentStatusLineManager() {
|
|
66 // Cast is ok because that's the only
|
|
67 // thing we accept in the construtor.
|
|
68 return cast(IStatusLineManager) getParent();
|
|
69 }
|
|
70
|
|
71 /* (non-Javadoc)
|
|
72 * Method declared on IStatusLineManager.
|
|
73 */
|
|
74 public IProgressMonitor getProgressMonitor() {
|
|
75 return getParentStatusLineManager().getProgressMonitor();
|
|
76 }
|
|
77
|
|
78 /* (non-Javadoc)
|
|
79 * Method declared on IStatusLineManager.
|
|
80 */
|
|
81 public bool isCancelEnabled() {
|
|
82 return getParentStatusLineManager().isCancelEnabled();
|
|
83 }
|
|
84
|
|
85 /* (non-Javadoc)
|
|
86 * Method declared on IStatusLineManager.
|
|
87 */
|
|
88 public void setCancelEnabled(bool enabled) {
|
|
89 getParentStatusLineManager().setCancelEnabled(enabled);
|
|
90 }
|
|
91
|
|
92 /* (non-Javadoc)
|
|
93 * Method declared on IStatusLineManager.
|
|
94 */
|
|
95 public void setErrorMessage(String message) {
|
|
96 this.errorImage = null;
|
|
97 this.errorMessage = message;
|
|
98 if (isVisible()) {
|
|
99 getParentStatusLineManager().setErrorMessage(errorMessage);
|
|
100 }
|
|
101 }
|
|
102
|
|
103 /* (non-Javadoc)
|
|
104 * Method declared on IStatusLineManager.
|
|
105 */
|
|
106 public void setErrorMessage(Image image, String message) {
|
|
107 this.errorImage = image;
|
|
108 this.errorMessage = message;
|
|
109 if (isVisible()) {
|
|
110 getParentStatusLineManager().setErrorMessage(errorImage,
|
|
111 errorMessage);
|
|
112 }
|
|
113 }
|
|
114
|
|
115 /* (non-Javadoc)
|
|
116 * Method declared on IStatusLineManager.
|
|
117 */
|
|
118 public void setMessage(String message) {
|
|
119 this.messageImage = null;
|
|
120 this.message = message;
|
|
121 if (isVisible()) {
|
|
122 getParentStatusLineManager().setMessage(message);
|
|
123 }
|
|
124 }
|
|
125
|
|
126 /* (non-Javadoc)
|
|
127 * Method declared on IStatusLineManager.
|
|
128 */
|
|
129 public void setMessage(Image image, String message) {
|
|
130 this.messageImage = image;
|
|
131 this.message = message;
|
|
132 if (isVisible()) {
|
|
133 getParentStatusLineManager().setMessage(messageImage, message);
|
|
134 }
|
|
135 }
|
|
136
|
|
137 /* (non-Javadoc)
|
|
138 * Method declared on SubContributionManager.
|
|
139 */
|
|
140 public void setVisible(bool visible) {
|
|
141 super.setVisible(visible);
|
|
142 if (visible) {
|
|
143 getParentStatusLineManager().setErrorMessage(errorImage,
|
|
144 errorMessage);
|
|
145 getParentStatusLineManager().setMessage(messageImage, message);
|
|
146 } else {
|
|
147 getParentStatusLineManager().setMessage(null, null);
|
|
148 getParentStatusLineManager().setErrorMessage(null, null);
|
|
149 }
|
|
150 }
|
|
151
|
|
152 /* (non-Javadoc)
|
|
153 * Method declared on IStatusLineManager.
|
|
154 */
|
|
155 public void update(bool force) {
|
|
156 // This method is not governed by visibility. The client may
|
|
157 // call <code>setVisible</code> and then force an update. At that
|
|
158 // point we need to update the parent.
|
|
159 getParentStatusLineManager().update(force);
|
|
160 }
|
|
161 }
|