Alter order of content assist eclipse for android development - java

I am working on an Android app, using Eclipse 4.2. I have content assist set up almost as I want it. However, when I, for example, start typing int to create a Java int variable, the Android.R.Integer entry in content assist is the primary entry.
I have content assist set up by relevance. This is just an annoyance because every time I want to make an int variable, I have to either hit Esc or hit enter and delete "eger" from the end of the type.
Thanks in advance.

None of the solutions posted here really worked, so what I did was to go to
Java -> Appearance -> Type Filters
and add *int* (yes, it's an asterisk followed by int and then another asterisk).
There's a checkbox next to the filter you just added, make sure it is checked.
Problem solved (finally!)

You can use Preferences->Java->Appearance->Type Filters to filter out the suggestions you want to ignore.
I'm wondering why you really need content assist to create an int variable, it would be easier to simply type it. But if you really want to, you can type the integer value and then use the Ctrl-2-L shortcut to create the local variable.

In
Java->Appearance>Type Filters
click add
type 'int*' -> click ok.
Then when you type in int , the first is int instead of integer .

Cren I am in the same boat. I have the content assist set to auto activate with every letter because I find it extremely useful that way, but have the same int(eger) problem that you do.
I have come up with a few ways to deal with it and thought I would share them in case you find one of them useful.
You could use a Type Filter as ralph suggested works just fine, you just don't get the assist when you actually want Integer, which isn't that big of a deal.
You could delay the content assist long enough so that you can type "int" and enter before it pops up, giving you a delay always. (In Preferences->Java->Editor->Content Assist there is an Auto activation delay setting)
Or remove 'i', 'n', and 't' from the Auto activation triggers (again in Preferences->Java->Editor->Content Assist). This is the method I am currently trying out, and it seems to work with everything, even Integer, saving me from having to type "ger" :).

Related

How to set color of Java comment in latex/Lyx?

I need to insert Java/Android code into Latex/Lyx, and I would like to highlight Java comments with a certain colour. I have done it earlier in the document, but now when I try the same code, it is not working for some reason. One difference between the codes are, that the one I'm now trying to insert is Android Java-code, and the former was pure Java, could that have an affect? The settings I'm using in the both cases are these:
\def\listingsfont{\ttfamily}
\lstset{language=Java}
\lstset{basicstyle=\ttfamily\scriptsize}
\lstset{keywordstyle=\color{blue}\ttfamily}
\lstset{stringstyle=\color{red}\ttfamily}
\lstset{commentstyle=\color{green}\ttfamily}
\lstset{breaklines=true}
\lstset{tabsize=2}
\begin{lstlisting}[frame=single] % Start your code-block
So first time working, second time not any more. What happens is, that all comment marks (//) appear as blue, but only the marks, not the whole comments with them. Strings are highlighted correctly.
EDIT: I have gained some new information what is happening. After the first time, when this code was working, I have a latex code where language is set as R. If I insert this code before the code that is written in R, all is working as it should. But if I insert the code after the code that is written in R, then it is no longer working. So something weird happens there.
EDIT2: For testing purposes, I changed the settings for the R-code as (language=Java). What happened was, that after that, all the Java code in the latex appeared correctly. So apparently, setting language as R breaks Lyx/Latex somehow to not being able to highlight other languages.
If you use \lstset, this is the default for the whole document. Try setting the language of each listing in LyX separate instead (through the settings you reach in the context menu of the program listing)

Displaying a string, from an array within an array with JasperReports

I currently use iReport 5.1.0, Tomcat 7, Java, Spring MVC amongs other things.
I believe my current problem lies within the iReport itself, although it may be more complex.
I currently have an Object (Guide),
My Guide has a list of Objects, (itemsGuide)
My itemsGuide has a list of Objects, (itemsTeam)
My itemsTeam has a list of Objects, (professional)
My professional has a name.
My jasper file, receives as parameter the Guide, in the iReport software I must assign the fields and the current variables, although I must print, in a single line, parameters from the itemsTeam object (a couple of strings), and in this very specific case I will always have only one professional, although the variable lies within a list, therefore I must access the first object in this array to then display its attribute.
I keep getting the most unusual errors as I try to do this rather simple process.
The iReport either doesn't find the variables in itemsTeam or the ones in professional, when, for some unknown reason it "works" my preview of the PDF (it says "The document has no pages", to avoid the error msg I change the attribute in my report proprety, but now, it simple shows the iReport file without any field/variable, only the graphical elements).
I am utterly confused, would anyone be so kind as to lend a hand to this poor newcomer?
the JRXML file has over 37k characters and I can't post it as an edit, I uploaded as a txt file insted.
Thanks in advance.
No more need for the link to the xml ~
-- CATURDAY EDIT --
Allright, I seem to be getting closer to my solution.
At this point I've tried quite a few different approaches to my problem.
Although I couldn't completely solve it, I managed to get closer, or so I believe.
Now, all I have to find out (it seems) is:
How to access an array within an array.
I managed my way around the guide and the itemsGuide, I can't access the array within itemsGuide, I need to access a variable named "team" within that array (itemsGuide) and then print the value of a few strings in this array (which is of a specific class, itemsTeam) and a string in an object (professional).
All this, without subreport.
Anyone ?
Allright, what I spent about 4 days trying to find out, my co-worker with more experience than me found out in about 20 minutes.
The issue wasn't within iReports itself, it was necessary to create methods in the class in order to return the desired object/list, something I did not even consider given that I know very little of how iReports (and java honestly) works.
But according to what I understood from what has been done it has something to do with reflection and a couple of methods in the java class.
Thanks guys. :>

Eclipse shortcut to insert variable in string literal

When I need to interpolate a String variable into a quoted string literal in the Eclipse java editor, I generally type "++" and eclipse usually inserts another " after the latter one, so I then have to go past it with arrow keys and then backspace to remove the duplicate, then go insert some spaces in between the "++" and type my variable name.
This seems like a lot of work. I have found Practically Macro, but I thought there might be something built in for this situation which is very common for me.
I'm not sure if this shortcut exists, try doing CTRL+SHIFT+L when the string is selected.
Also there is this link which has a whole bunch of nice keyboard shortcuts, I know it may not answer the question completely but maybe it'll get you one step closer. :)
**** Edit: In that link the "Ctrl-2 something" post looks promising.****
The most relevant built-in feature is maybe the "Pick out part of a string" quick assist:
insert a space (or anything else) where you want to add a variable,
select it,
press Ctrl+1,
select the "Pick out part of a string" quick assist,
insert your variable name.
Reference: "Pick out part of a string" section in this post.

IDEA: "Assign statement to new local variable"?

As a long time Eclipse user, I'm playing around a little bit with IntelliJ IDEA 10. I can't seem to find out how to perform an "Assign statement to new local variable" code completion.
Feature explanation:
I type something like
new BufferedOutputStream(out)
and then hit Cmd (or Ctrl)+1 and enter, and Eclipse changes the line into:
BufferedOutputStream bufferedOutputStream = new BufferedOutputStream(out);
At the same time, I can type over "bufferedOutputStream" immediately to rename it (or select from the options "bufferedOutputStream", "outputStream" and "stream" from a dropdown).
I use this feature for absolutely every assignment, and it's an enormous time saver - this must be available in IDEA, too - but where is it hidden?
Refactor | Introduce Variable (Ctrl+Alt+V on Windows). Note that you don't need to select the text if it's the only text in the current line. Then you can change the variable name in-line just like you've described and press Enter to complete editing.
Another way is to use the Postfix Completion:
Type .var (or just .v to select it from the list) and confirm it with Enter.
As CrazyCoder mentions you can use Ctrl+Alt+V. Also instead of selecting the expression, clicking into somewhere in your expression and using Ctrl+W to expand scope is very useful while using introduce refactorings. Extract refactorings are:
Extract variable: Ctrl+Alt+V
Extract field: Ctrl+Alt+F
Extract method: Ctrl+Alt+M
Extract parameter: Ctrl+Alt+P
Extract constant: Ctrl+Alt+C
Also, Idea is a polygot editor so you can use these extract refactorings for other file types like js or html also (not all refactorings work in all file types but Ctrl+W works mostly).
There are more extract refactorings which do not have shortcuts which you can access from Refactor|Extract menu (both menu bar and context menu). To quick access all refactorings you can use Ctrl+Alt+Shift+T for a popup menu.
As a last word, I highly encourage you using "Tip of the Day" (Help|Tip of the Day). It is a fast way to learn many helpful features of Idea.
It's not as nice as Eclipse, but you can try the following:
new BufferedOutputStream(out)
Select the expression above, either with your mouse (or by using Ctrl+W).
Then hit Ctrl+Alt+V to Introduce a Variable or (Ctrl+Alt+F to Introduce a Field)
Easiest is, hit Alt+Enter, you will be offered with a list of options, and just select "Introduce local Variable".

Showing Suggestions below text field taking values from database

I am having a form. I want to show user suggestions about the name of the security he can enter. For the same I want to use the values of securities that I have installed in my Oracle Database.
I want to do something like this, if user enters a, he should get all security names below the text field which starts from a, when user selects anyone of them, then the text field must show the selected values.
Thanks in Advance.
You need autocomplete enabled text field. There's a tutorial how to build one. Even better, use jQuery java script library for this and many other features.
I'd suggest a trie. They are great for things like predicive text and auto complete.
Get all the valid security names and put them into the trie, then query the trie with whatever prefix the use has entered and it will give you all the matching names.
Note that Java doesn't come with a Trie implementation itself buy it would be pretty easy to write your own or borrow one, for eg from here; http://forums.sun.com/thread.jspa?threadID=5295936
Edit: You didn't say if this was going to be on the web or desktop (eg Swing)....

Categories