How to set eclipse preferences use plugin? - eclipse

Now I'm using python to change settings files under .metadata/ in my workspace.I need find every line needed in these files beacuase I don't want any unnecessary content.
For example , if I want set tab's width be 4. I need change the file
.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.editors.prefs
in workspace and add a line following in it , not simply copy the settings file:
tabWidth=4
So I want to know : Can I set this value by java code in eclipse plugin? If it can, please give me related classes :-)
And, does it more complex than python's method?

In a plugin you can use:
IPreferenceStore store = new ScopedPreferenceStore(InstanceScope.INSTANCE, "org.eclipse.ui.editors");
store.setValue("tabWidth", 4);

Related

Custom content assist for default java editor in Eclipse

I'm currently trying to develop an Eclipse Plugin to support code replacement, like what the default content assist in Eclipse do. What I want to implement is something like "insert argument names automatically on method completion with visualized box around the argument" and I can "use the Tab key to navigate between the inserted names" and "while navigating, list of optional variables for current argument can be displayed and be chosen".
In short, it comes to two questions:
How to add the visualized box around the already existed variable or even Java keywords that need replacement? And at the meanwhile I can use Tab key to switch between these boxes.
How to display a list of candidates to select from when I trigger on the box?
By now I only figure out the extension point : org.eclipse.jdt.ui.javaCompletionProposalComputer may be useful, but I have no idea where to start at? Thanks in advance.
Oh, finally I've solved it myself...
For the 'box', it should be the LinkedModeModel, this class should work with LinkedPositionGroup and LinkedPosition to add mutiple boxes. And we should use LinkedModeUI to set it up.
For the content assistant, there's no need to use the extension point. There is a ProposalPosition class which extends LinkedPosition for you to add your proposals for the 'box' in its constructor. And we can simply use the CompletionProposal to construct a ICompletionProposal array as the argument of ProposalPosition's constructor.

Proper Case formatting a text in JasperReports

Is there a way to create a "proper case text display in JasperReports". I am using JasperReports 5.x with iReport Designer.
I have data returned from DB which is a string/text field user entered text... the problem here is some users enter in all calitals and some enter in all small I want to display the text values in a proper case... I know this can be achieved in SQL but unfortunately I dont have that option to simply edit the query....
Thanks for your help in advance...
Meeza
There wouldnt be any standard settings in iReport, you would need to use an external Method to create the text you need. I would try to go for an Apache Commons solution, or create your own Method.
I have not used the WordUtils class from Apache Commons Lang, but it looks like capitalize may be what you want.
http://commons.apache.org/proper/commons-lang/javadocs/api-2.6/org/apache/commons/lang/WordUtils.html#capitalize(java.lang.String)
To Add a Jar to your classpath in iReport:
Tools -> Option -> Classpath -> Add Jar
You then need to import the Class as well:
From the Report root element, edit the Properties. Find "Imports" click on the ellipses (...) and add your class!
iReport Imports

TYPO3 extension: how to find certain TS setting

I found in typo3 admin side(/typo3), you can have two ways to set up TS,
you can set up through template->root, I think TS here will affect the whole site.
you can set up through template->certain page, it will only affect this page.
So my question is:
If I want to find where(which page) has TS setting such as : code = LIST, how could I do?
Use Web > Template module it has tools, you can for an example use Template Analyzer for the search
Try querying the database in phpMyAdmin or similar. The following looks in Template Setup:
SELECT pid, config, constants
FROM sys_template
WHERE config LIKE '%code = LIST%'
Replace config with constants to look in Template Constants. pid is the page ID.
If it is not set in the TypoScript, it perhaps has been set in the plugin itself. Just check the plugin content element itself.
In the Template module, go to the page where the setting is in effect.
Use the TSOB (Typo Script Object Browser) to search for "list":
This must show you all TS for this page that contains "list".
If you don't see the setting you can run a cmd/ctrl-F Search over the entire results.
You would have to search for "[code] = LIST".
Which will lead you to the following entry:
Hovering over the label will produce the above tooltip. Copy the line number.
Now change to the Template Analyzer. Here, you can click through all cascading templates and search for the line number:
This is definitely the line that sets that value.
From the "Template hierarchy" tree you will easily find the template that contains the setting.

eclipse - how to change package explorer sorting order (don't want lexicographic sorting)?

Is there a way I can have it:
Sonication1,
Sonication2,
Sonication3...
I think you can't. Change naming if possible: Sonication01, Sonication02, ..., Sonication10, Sonication11 to get wanted order.
I believe that it is possible but it is a long and manual process.
You can select the properties of the Java project and click properties. Then, go to Java Build Path and selecting 'Order and Export.' There, you would move the wanted file up and down using the buttons and clicking apply.
I hope that this would answer your question.

Does the Eclipse editor have an equivalent of Emacs's "align-regex"?

I've been using Eclipse pretty regularly for several years now, but I admit to not having explored all the esoterica it has to offer, particularly in the areas of what formatting features the editors offer.
The main thing I miss from (X)emacs is the "align-regex" command, which let me take several lines into a region and then format them so that some common pattern in all lines was aligned. The simplest example of this is a series of variable assignments:
var str = new String('aString');
var index = 0;
var longCamelCaseObjectName = new LongNameObject();
After doing align-regex on "=", that would become:
var str = new String('aString');
var index = 0;
var longCamelCaseObjectName = new LongNameObject();
Now, you may have your own thoughts on stylistic (ab)use of white space and alignment, etc., but that's just an example (I'm actually trying to align a different kind of mess entirely).
Can anyone tell me off-hand if there's an easy key-combo-shortcut for this in Eclipse? Or even a moderately-tricky one?
You can set the formatter to do this:
Preferences -> Java -> Code Style -> Formatter. Click 'Edit' on the profile (you may need to make a new one since you can't edit the default).
In the indentation section select 'Align fields with columns'.
Then, in your code CTRL+SHIFT+F will run that formatter.
That will of course run all the other rules, so you may want to peruse the various options here.
Version 2.8.7 of the Emacs+ plugin now supplies a fairly complete align-regexp implementation in Eclipse
If you wish to do something more complex than just aligning fields (or anything else the Eclipse code formatter offers you) you are pretty much left with having to write your own plugin.
columns4eclipse is a nice option. It is an Eclipse plugin that allow you to do the alignments you mention in your question. I use it with Eclipse 4.3 and 4.5, it works well. I had made a gif video showing its use but my answer got deleted by a mod, so I let you try and see by yourself.
This plug-in does exactly what you want: OCDFormat
It works in all text files, not only Java.