Lines 10-15
Link Here
|
10 |
*******************************************************************************/ |
10 |
*******************************************************************************/ |
11 |
package org.eclipse.ui.part; |
11 |
package org.eclipse.ui.part; |
12 |
|
12 |
|
|
|
13 |
import java.text.MessageFormat; |
14 |
|
13 |
import org.eclipse.core.runtime.IConfigurationElement; |
15 |
import org.eclipse.core.runtime.IConfigurationElement; |
14 |
import org.eclipse.core.runtime.IExecutableExtension; |
16 |
import org.eclipse.core.runtime.IExecutableExtension; |
15 |
import org.eclipse.core.runtime.Platform; |
17 |
import org.eclipse.core.runtime.Platform; |
Lines 22-32
Link Here
|
22 |
import org.eclipse.ui.ISharedImages; |
24 |
import org.eclipse.ui.ISharedImages; |
23 |
import org.eclipse.ui.IWorkbenchPart; |
25 |
import org.eclipse.ui.IWorkbenchPart; |
24 |
import org.eclipse.ui.IWorkbenchPart2; |
26 |
import org.eclipse.ui.IWorkbenchPart2; |
|
|
27 |
import org.eclipse.ui.IWorkbenchPartConstants; |
25 |
import org.eclipse.ui.IWorkbenchPartSite; |
28 |
import org.eclipse.ui.IWorkbenchPartSite; |
26 |
import org.eclipse.ui.PlatformUI; |
29 |
import org.eclipse.ui.PlatformUI; |
27 |
import org.eclipse.ui.IWorkbenchPartConstants; |
|
|
28 |
import org.eclipse.ui.internal.ReferenceCounter; |
30 |
import org.eclipse.ui.internal.ReferenceCounter; |
29 |
import org.eclipse.ui.internal.WorkbenchImages; |
31 |
import org.eclipse.ui.internal.WorkbenchImages; |
|
|
32 |
import org.eclipse.ui.internal.WorkbenchMessages; |
30 |
import org.eclipse.ui.internal.misc.Assert; |
33 |
import org.eclipse.ui.internal.misc.Assert; |
31 |
import org.eclipse.ui.internal.util.Util; |
34 |
import org.eclipse.ui.internal.util.Util; |
32 |
import org.eclipse.ui.plugin.AbstractUIPlugin; |
35 |
import org.eclipse.ui.plugin.AbstractUIPlugin; |
Lines 52-59
Link Here
|
52 |
private ListenerList propChangeListeners = new ListenerList(2); |
55 |
private ListenerList propChangeListeners = new ListenerList(2); |
53 |
|
56 |
|
54 |
private String partName = ""; //$NON-NLS-1$ |
57 |
private String partName = ""; //$NON-NLS-1$ |
55 |
private String statusText = ""; //$NON-NLS-1$ |
58 |
private String contentDescription = ""; //$NON-NLS-1$ |
56 |
|
59 |
|
|
|
60 |
private boolean automaticTitle = true; |
61 |
|
57 |
/** |
62 |
/** |
58 |
* Creates a new workbench part. |
63 |
* Creates a new workbench part. |
59 |
*/ |
64 |
*/ |
Lines 202-210
Link Here
|
202 |
// Save config element. |
207 |
// Save config element. |
203 |
configElement = cfig; |
208 |
configElement = cfig; |
204 |
|
209 |
|
205 |
// Part name and title. |
210 |
// Part name and title. |
206 |
partName = Util.safeString(cfig.getAttribute("name"));//$NON-NLS-1$; |
211 |
title = Util.safeString(cfig.getAttribute("name"));//$NON-NLS-1$; |
207 |
title = partName; |
212 |
setPartName(title); |
208 |
|
213 |
|
209 |
// Icon. |
214 |
// Icon. |
210 |
String strIcon = cfig.getAttribute("icon");//$NON-NLS-1$ |
215 |
String strIcon = cfig.getAttribute("icon");//$NON-NLS-1$ |
Lines 250-262
Link Here
|
250 |
* @param title the title, or <code>null</code> to clear |
255 |
* @param title the title, or <code>null</code> to clear |
251 |
*/ |
256 |
*/ |
252 |
protected void setTitle(String title) { |
257 |
protected void setTitle(String title) { |
253 |
title = Util.safeString(title); |
258 |
title = Util.safeString(title); |
|
|
259 |
|
260 |
automaticTitle = (title.equals("")); //$NON-NLS-1$ |
261 |
if (automaticTitle) { |
262 |
String description = getContentDescription(); |
263 |
String name = getPartName(); |
264 |
|
265 |
if (Util.equals(description, "")) { //$NON-NLS-1$ |
266 |
title = name; |
267 |
} else { |
268 |
title = MessageFormat.format(WorkbenchMessages.getString("WorkbenchPart.AutoTitleFormat"), new String[] {name, description}); //$NON-NLS-1$ |
269 |
} |
270 |
} |
271 |
|
272 |
internalSetTitle(title); |
273 |
} |
274 |
|
275 |
private void internalSetTitle(String title) { |
276 |
|
254 |
//Do not send changes if they are the same |
277 |
//Do not send changes if they are the same |
255 |
if(Util.equals(this.title, title)) |
278 |
if(Util.equals(this.title, title)) |
256 |
return; |
279 |
return; |
257 |
this.title = title; |
280 |
this.title = title; |
258 |
firePropertyChange(IWorkbenchPart.PROP_TITLE); |
281 |
firePropertyChange(IWorkbenchPart.PROP_TITLE); |
259 |
} |
282 |
} |
|
|
283 |
|
260 |
/** |
284 |
/** |
261 |
* Sets or clears the title image of this part. |
285 |
* Sets or clears the title image of this part. |
262 |
* |
286 |
* |
Lines 322-327
Link Here
|
322 |
return; |
346 |
return; |
323 |
this.partName = partName; |
347 |
this.partName = partName; |
324 |
firePropertyChange(IWorkbenchPartConstants.PROP_PART_NAME); |
348 |
firePropertyChange(IWorkbenchPartConstants.PROP_PART_NAME); |
|
|
349 |
|
350 |
if (automaticTitle) { |
351 |
setTitle(""); //$NON-NLS-1$ |
352 |
} |
325 |
} |
353 |
} |
326 |
|
354 |
|
327 |
/* (non-Javadoc) |
355 |
/* (non-Javadoc) |
Lines 330-356
Link Here
|
330 |
* @since 3.0 |
358 |
* @since 3.0 |
331 |
*/ |
359 |
*/ |
332 |
public String getContentDescription() { |
360 |
public String getContentDescription() { |
333 |
return statusText; |
361 |
return contentDescription; |
334 |
} |
362 |
} |
335 |
|
363 |
|
336 |
/** |
364 |
/** |
337 |
* Sets the status text for this part. The status text is typically |
365 |
* Sets the content description for this part. The content description is typically |
338 |
* a short string describing the current contents of the part. If parts |
366 |
* a short string describing the current contents of the part. If parts |
339 |
* use the setTitle method, their content description may be set automatically. |
367 |
* use the setTitle method, their content description may be set automatically. |
340 |
* |
368 |
* |
341 |
* @param statusText the status text, or the empty string indicating |
369 |
* @param description the status text, or the empty string indicating |
342 |
* that the workbench should manage the status message for this part |
370 |
* that the workbench should manage the description for this part |
343 |
* |
371 |
* |
344 |
* @since 3.0 |
372 |
* @since 3.0 |
345 |
*/ |
373 |
*/ |
346 |
protected void setContentDescription(String statusText) { |
374 |
protected void setContentDescription(String description) { |
347 |
Assert.isNotNull(statusText); |
375 |
Assert.isNotNull(description); |
348 |
|
376 |
|
349 |
//Do not send changes if they are the same |
377 |
//Do not send changes if they are the same |
350 |
if(Util.equals(this.statusText, statusText)) |
378 |
if(Util.equals(contentDescription, description)) |
351 |
return; |
379 |
return; |
352 |
this.statusText = statusText; |
380 |
this.contentDescription = description; |
|
|
381 |
|
353 |
firePropertyChange(IWorkbenchPartConstants.PROP_CONTENT_DESCRIPTION); |
382 |
firePropertyChange(IWorkbenchPartConstants.PROP_CONTENT_DESCRIPTION); |
|
|
383 |
|
384 |
if (automaticTitle) { |
385 |
setTitle(""); //$NON-NLS-1$ |
386 |
} |
354 |
} |
387 |
} |
|
|
388 |
|
355 |
|
389 |
|
356 |
} |
390 |
} |