I recently got a new computer, and installed Eclipse 2018-12 (4.10.0)
Since I installed it, auto complete for Java has been showing results in the wrong order. It puts substring matches before exact matches. If, for example, I'm calling the stream() method on a list, I'd type "myList.stream()". The suggestions will show stream() at the bottom of the list, and parallelStream() at the top. Since the default behavior is to replace what you typed with the top result, stream() gets replaced with parallelStream() when I continue typing. The same thing happens on Maps. When I'm trying to use put(), it replaces it with .compute(). On Streams, map() gets replaced with flatMap() as well.
Example of the suggestions for stream()
I've looked all over for a setting to change this, but have yet to even find someone else with this issue. Any help would be appreciated.
If it's useful, I'm on Windows 10.
Well, I feel silly answering my own question minutes after posting it, but I just figured out how to fix it, so here goes.
Load Preferences, then navigate to Java->Editor->Content Assist->Advanced. Check the Java Proposals check box.
I'm not that familiar with the different proposal types in these settings, but turning that one on fixed the problem.
Java->Editor->Content Assist,
uncheck "show substring matches" in section "Sorting and Filtering"
Related
I have been coding for a while now and as far as I'm aware, once you've outputted a line to System.out.println in Java; you cannot change it.
The reason I ask this question is because of some very strange results from my program. The program records the time of the bubble sort and merge sort algorithms in sorting different kinds of int arrays and prints the average of these times at different sizes of n, where n is the size of the array.
Now I've had a litany of problems with this program thus far, but I do not understand how the following is possible:
...
At 200000, randomly-sorted takes:
NaN //Expected output, since I did not activate the random arrays.
...
However, at the same line, and in an unpredictable manner, the program occasionally does this:
...
At 200000, randomly-sorted takes:
75683.45
...
And then swaps back again after a while!
So the program is somehow managing to replace the outputted line, which I have never experienced before.
Any help or clarification very much appreciated! If you need the code, I am more than happy to share.
EDIT: To clarify, this is on a Macbook Air running Java SE 6. As for the code, please refer to my Github account with the entire project at the following link - https://github.com/danielsoutar/complexityPractical.
Side-note: One other thing. For bubble sort, the randomly-generated arrays apparently take longer to sort than a reverse-sorted array, which is clearly nonsense. Not sure if that matters to this problem but it is something to note.
the question was kinda unclear to me, but as far as I understand you could take a look at RegEx for filtering out on a String or clear the Console and put your output back in.
Clear console:
Runtime.getRuntime().exec("cls");
RegEx example:
yourString.replaceAll("[yourCharactersToReplace]","");
System.out refers to a PrintStream instance. In the abstract, a PrintStream object represents a place where you can send text. Period. Once the text is sent, that's the end of the story.
But in reality the text actually goes somewhere. If you are invoking your Java program from a command line, then it's very likely that the place where the text goes is a terminal emulator window or a console window; and it's also very likely that the console recognizes certain codes that your program can embed in the text that tell it to do things.
Things like, change the color of the text, move the cursor around in the window, and over-write text that already was there.
There have been literally hundreds of different coding systems to let a computer program do those things on a terminal screen/window, but one is supported by almost all consoles and terminal emulators. Google for "ANSI escape codes" to learn more about it.
If you want your program to purposefully move the cursor around, change the text color, etc. Then you might want to use a 3rd party library like jcurses (google for that too) to handle the possibility of a console that does not accept (or is not configured to accept) ANSI escape codes.
I've started using Selenide recently, and I'm loving the fluent code it allows.
I do have strange issue with ElementsCollection, however.
$$("some ref").filterBy(not(attribute("an-attr-that-should-not-be"))).getTexts()
This query intermittently returns stringified StaleElementReferenceExceptions, and I can't understand why.
If I run the query in the debugger, it returns valid values, while during normal runtime (single thread application), this is what I get.
The target element is a GWT combo box results list.
Could someone please point me in the right direction?
Update: if it's relevant, I'm using InternetExplorerDriver.
Chrome and ChromeDriver specifically fire off StaleElementReferenceException like its the point of your test - any time an element is no longer visible the WebElement reference you have to it becomes invalid and you must look it up again. If the combo is showing/hiding or changing those could cause this (need more details on which combo and what seems to cause it for more specific) - try looking up the element when you expect to use it instead of reusing the reference again and again.
Found the problem. Apparently, the Selenide ElementsCollection cached a previous version of the element list, which updated a lot slower than anticipated, and was trying to access this ghost data when retrieving texts.
Fixed by using $$ where the list is iterated, instead of the usual static constants in class header.
My solution for this problem was very simple and straight. I just set the timeout for the search of an element around 10 seconds and it worked. It can be done only with one string:
Configuration.timeout=10000
The value is in milliseconds, of course.
I'm using the Solr 3.6.1 Webapp with the SOLR-2155 Patch for geohash field support.
I set everything up like described here: https://github.com/dsmiley/SOLR-2155
Now and then the search returns a totally false distance for every hit. Refreshing the result won't help. If I change the offset of the search (e.g. listing the 2nd page) it's all fine again. Even going back to the first page now shows up the right distance.
It's not the webapp because the json stream I get directly from Solr contains the same distances as result score. In my case it's always 20015,12km.
Here is my Query:
fq={!geofilt}
&fl=internalid,score
&start=0
&rows=10
&sort=geodist()+asc
&sfield=location
&pt=53.6,10.11
&d=50
&q={!func}geodist()
I wrote SOLR-2155. I'm not particularly happy with the distance sorting code therein; there seems to be something I overlooked. It shouldn't be some sort of math issue, it's some sort of Lucene internals issue, I think. If you have just one point per document, then use solr.LatLonType. If you have multiple then.... :-( I don't know what the problem is. In Solr 4, the replacement code for this called SpatialRecursivePrefixTreeFieldType and it uses different code but it is similar, so I'm not sure if the problem will go away or not. But even in that case, again, I'm not at all happy with the implementation. I know how I want to do it right, but it's not on the top of my TODO list right now.
BTW, you are basically reporting a bug, and the proper place to report a bug would be the issue tracker of the project in question -- in this case, that's GitHub SOLR-2155. StackOverflow doesn't make sense for that.
I am currently implementing some sort of text-version (revision) comparison visualizations and am trying to find some information about how wikipedia achieves their "View History"-feature in which they allow to compare the current revision with an older one.
You can find one example (About stackoverflow!) here:
http://en.wikipedia.org/w/index.php?title=Stack_Overflow&diff=512241244&oldid=458578615
I have implemented several ideas so far and also tried to reproduce the way wikipedia is doing it. For this I've implemented the Levenshtein-distance algorithm ( http://en.wikipedia.org/wiki/Levenshtein_distance ).
Lets assume I have two lists. I am iterating over the first list and check for the index-position of the first list on the second if the string found there is more than 50% equal. If it is, I'll just print both Strings side by side in my comparison view and continue with the next item of the first list. If it is not, I check the next item in the second list until I find it or leave the field for the second list blank if it cannot be found. (Although I would basically prefer that a sentence from the second list also always appears on the comparison view instead of leaving it out, just e.g. with a blank field for the first list field)
This method has some weaknesses. At first, if some sentence got deleted I would need to check the positions around the index for not simply "forgetting" it. But still I need to take care that text positions don't get inverted if I do so.
Has anyone of you tried to achieve something similar with java? If there are some code examples how others or you achieved it, I would gladly take a look to learn from it.
And of course, if you know anything about the algorithm wikipedia (and general wikis I assume?) uses for their revision comparison I'd be glad to hear it.
Thanks a lot
Wikipedia explains how the wiki difference engine works - http://en.wikipedia.org/wiki/Help:Diff
You can follow the links at the bottom of the page to learn more, but this page lists the template used.
Another implementation besides Wikipedia's version control is diff on Unix flavor systems. GNU actually makes the source code available for diff which may enable you to look at their algorithms here:
http://ftp.gnu.org/gnu/diffutils/
In a re-implementation of an existing program, I would like to keep the message text that users are familiar with. One of the enhancements I'd like to add is a good keyboard-only interface including mnemonics. But using the intuitive mnemonic character with the existing text gives some ugly results. For example:
useUpperCheckBox = new JCheckBox("Use UPPERCASE letters");
useUpperCheckBox.setMnemonic(KeyEvent.VK_U);
underlines the "U" in "Use" rather than the "U" in "UPPERCASE". Since the user's eye is naturally drawn to "UPPERCASE" looking for a mnemonic, the default location of the decoration is a bit unintuitive.
Yes, I've read the docs and the tutorials that say that the first instance of the mnemonic character is underlined, but that isn't what I want. It comes up often enough that I can't believe I'm the only one frustrated by this. Surely someone smarter than me has figured out how to place the decoration somewhere different than the default location.
Use the source, Luke. Looking at the source code of setMnemonic() led me quickly to AbstractButton.setDisplayedMnemonicIndex():
Provides a hint to the look and feel
as to which character in the text
should be decorated to represent the
mnemonic.
I think what you are looking for is: setDisplayedMnemonicIndex(int index)
I realise this isn't the situation here, but it is related:
If you are using AbstractAction, try putValue(DISPLAYED_MNEMONIC_INDEX_KEY, index);.