Bug 194759

Summary: [CTabFolder] Text (filename) wrapping in tabs
Product: [Eclipse Project] Platform Reporter: drm / Gerard <drm>
Component: SWTAssignee: Duong Nguyen <duongn>
Status: NEW --- QA Contact:
Severity: enhancement    
Priority: P3 CC: Kevin_McGuire, Mike_Wilson, peter, ttclover
Version: 3.2   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description drm / Gerard CLA 2007-06-28 09:31:08 EDT
I wish for a setting in which i can choose how the filenames are cut off in the tabs.

For example now they are cut off as follows:

a-very-long-f... (for a file named "a-very-long-filename.txt")

A simple feature would be to be able to choose between:
wrap (end)   example       : a-very-long-...
wrap (center) example      : a-ve...name.txt
wrap (beginning) example   : ...ng-filename.txt
and additionally provide for a maximum length to accept, plus the ability to check off the extension of a filename, to provide more room for the rest of the filename

A more flexible one is to create regular expression replacement rules for filenames. For example, my PHP class names start with a prefix "class." I would like to show "RegisterFormHandler" for a file named "class.RegisterFormHandler.php". The regex replacement rule would be:
regex: /^class\.(.*)\.php$/
replacement: $1

Or, for implementing my own wrapping:
regex: /^({5,}).+({5,})$/
replacement: $1...$2


Another
Comment 1 Kevin McGuire CLA 2007-06-28 10:52:35 EDT
(text seems cut off at end)
Comment 2 drm / Gerard CLA 2007-06-28 16:44:46 EDT
The "Another" comment at the end should be disregarded, it is a typo.
Comment 3 Duong Nguyen CLA 2007-08-13 11:49:27 EDT
*** Bug 196363 has been marked as a duplicate of this bug. ***
Comment 4 Peter Centgraf CLA 2007-08-13 20:01:44 EDT
This version of the request is much broader and more IDE-specific than the one just marked as a dup.  I also doubt that this could be implemented as requested, since SWT is specified to run under OSGi Minimum Execution Environment 1.0, which does not include regular expressions support.

In any case, that bug contains a useful code snippet, so whoever implements this should take a look.

In the meantime, an updated target version would be nice, so this doesn't get lost.
Comment 5 Peter Centgraf CLA 2007-08-14 15:24:40 EDT
FYI, CLabel implements a variant of this idea that shortens the text in the middle, instead of the side.  That version does not support the ellipses parameter but is very similar otherwise.

I recommend creating an API for this with two new properties (with both getters and setters):

/**
 * Sets the portion of the text contents of this item that will be clipped
 * when the width of the text is too large for the available space.
 *
 * @param clipStyle one of SWT.LEAD, SWT.TRAIL, or SWT.CENTER
 */
public void setClipStyle(int clipStyle);

/**
 * Sets the String that will be used to replace clipped text in this widget.
 *
 * @param ellipses the new replacement string for clipped text, or null to
 *         use the default value
 */
public void setEllipses(String ellipses);

The method shortenText(GC, String text, String ellipses, int width, int clipStyle) could be provided as a static helper somewhere within the swt.custom package or as an instance method on Widget.

I'm still not clear whether it makes sense to put this only on CTabItem or also on CTabFolder.  I'm leaning towards the former.
Comment 6 Kevin McGuire CLA 2007-08-15 10:30:25 EDT
> I'm still not clear whether it makes sense to put this only on CTabItem or also
> on CTabFolder.  I'm leaning towards the former.

I'd say the CTabFolder should have a policy (either pluggable or preset list via a style bit/int) which the CTabItems consult, with the notion being that all tabs within a folder follow the same truncation rule.

Comment 7 Eclipse Webmaster CLA 2019-09-06 16:17:10 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.
Comment 8 Rolf Theunissen CLA 2021-10-06 05:20:18 EDT
*** Bug 576455 has been marked as a duplicate of this bug. ***