Hide parts of labels by specifying a regexp
Brought to you by:
mgebha
It would be nice not only to prepend and append
decoration text label, but to select parts of the regexp
to display.
eg : I would like to remove the .java extension from
Java files (in order to save space into package explorer).
I know they are java files from the icon : file extension
is not necessary to display.
Therefore if I could define a regexp like *.java and only
select the first part {1}. It would only display Java file
name and not their extension.
Keep the good job.
Mat
Logged In: YES
user_id=680457
I like this idea. This feature could be added to the "Text
decoration" tab: A checkbox and a textfield for entering the
regexp.
What would be a good title for the checkbox? "Regexp filter"?
Also how should one specify which of the groups in the regexp
shall be kept and which ones shall be discarded?
Logged In: YES
user_id=1120735
Hello,
I just woke up from hibernation.
> What would be a good title for the checkbox? "Regexp
filter"?
Sounds good to me
> Also how should one specify which of the groups in the regexp
shall be kept and which ones shall be discarded?
Why not leverage regexp substitute method (apache's ORO
library provide such mechanism)? Let me explain.
On can set up incoming regexp:
(.*).java
and the substitute regexp :
{1}
Using substitute method with input string :
Toto.java
we would get :
Toto
Other example :
regexp : (.*)-build(.*).xml
substitute : {1}-ant{2}.vxml
string : test-buildTOTO.xml
output : test-antTOTO.vxml
This mechanism is used with Struts url wildcard pattern.
I admit, one must learn, work from some examples, to use
this feature.
Cheers.
Mat
Logged In: YES
user_id=680457
Originator: NO
I finally found myself some time and tried to implement a prototype for the label modification.
Using regular expression groups and message format patterns for modifying the label works quite well, but there is one problem:
I would expect to configure the regular expression to "(.*)(\.java)" and the message format to "{1}" in order to change "Foo.java" to "Foo".
Unfortunately it might happen that the universal label decorator is not the first Eclipse label decorator to modify the text. So e.g. the CVS decoration might already have added CVS revision information to the original label. Instead of "Foo.java" the label is something like "Foo.java 1.1 (ASCII -kk)". One will either loose this CVS information or one will have to be more careful when specifying the regular expression pattern: Pattern "(.*)(\.java)(.*)" and message format "{1}{3}" works (althought I do not yet know how Eclipse 3.3M7 manages to apply the new color formatting w/o knowing about this my plugins modification...).
I consider this quite complicated... I would not like to finish and publish this feature before Eclipse enhancement request 28938 is implemented into the eclipse platform: https://bugs.eclipse.org/bugs/show_bug.cgi?id=28938