How do blind users interact with error indicators in Eclipse? - java

I am currently helping a blind person to learn Java using Eclipse as their IDE. However, when there are errors, e.g. a typo, the red underlines indicating an error are not useful/apparent.
How can blind users be made aware of errors or other visual indicators within Eclipse?

In eclipse you can use Ctrl+. and Ctrl+, to navigate forwards and backwards through underlined sections.
When the cursor is in an underlined section, the error is shown in the status bar which your screen reader may be able to read (with JAWS use Insert+PgDn or CapsLock+PgDn).
There are some more tips for Eclipse's accessibility features in the Eclipse Help pages.

Jaws normally says "invalid" before each invalid part of code in the code editor as you navigate with arrow keys.
You have nothing specific to configure for this. At least for me, it worked out of the box from day 1.
IN case of doubt or if it doesn't work out of the box, you can customize the way Jaws behaves by going to the setting center.
More specifically, in the speech and sound scheme, you might pick a modern scheme different than classic, or want to customize the way the "invalid" font style is announced.
You will also certainly need to pay triple attention to things that eclipse automatically insert for you as you type, like closing parens and braces, as they aren't announced at all by Jaws when they are automatically inserted. They can easily make you enter unwanted extra characters.
As a blind user I prefer to completely disable all autocompletes like this and only keep it on demand with shortcuts like F2, but that's a personal choice.
Unfortunately, I can't help if you are using NVDA, but there certainly are solutions as well.

Related

Source Editor in Eclipse plug-in

I'm developing an Eclipse plug-in, mostly as a learning exercise, in which I have a wizard page. In this wizard page I would like to have a small text area that behaves like a code editor with the appropriate content assist and information hovers etc, much like the breakpoint properties wizard has for adding conditions.
I'm new to plug-in development and I may not have quite picked up the vocabulary, so I'm not having much luck searching for examples. Can someone please point me in the right direction?
I assume that you are looking for an embeddable Java source editor - and with that you hit a difficult topic.
The source viewer mentioned by Chris Gerken is called JDISourceViewer. It is instantiated and configured in JavaBreakpointConditionEditor::createControl.
If you cannot find the mentioned classes, or if you want to experiment with them, then open the Plug-ins view, find the org.eclipse.jdt.debug.ui plug-in and select Import As > Source Project from the context menu.
Unfortunately - in the beginning - the (Java) editors weren't designed to be embedded outside of the editor area and many editor participants (e.g. actions, formatter, etc) still expect an IEditorPart. Hence it is a quirky and complicated endeavour to use an editor in a dialog or the like.
Moreover, the Java source editing infrastructure is not exposed as public API. It isn't meant to be used by clients and can change at any time without prior notice. You will see respective warnings in yoyur code. For a learning exercise, however, that shouldn't matter much.

Apply Intellij Code Improvement Suggestions

I'm using Intellij for Java development. In the code editor on the right, it displays some yellow markers which indicate issue with my code, e.g. improvement suggestions. When I hover over the affected code line it tell me what to do. Unfortunately I didn't find a way of automatically applying said suggestion. How do I do that? I don't want to do fixes by hand but rather allow Intellij to do them for convenience.
CTRL + Space is only code completion.
Just place the cursor over the highlighted code, hit Alt+Enter, select the suggested fix and hit Enter.
You can also apply the fix for all problems of the given type within specified scope (current file, project, ...). If you want to do that, just select Run inspection on from the menu that is shown.
I'm not sure if there is a way to apply these fixes automatically completely without user intervention, but even if there was, it probably wouldn't be very user friendly, as the warnings are sometimes false-positive.
If you want to apply a code suggestion it it simply Alt+Enter while the cursor is over the highlighted code. I would strongly suggest not automatically applying suggestions and to use your better judgement.
I can personally attest that while it's a little extra work, being able to choose the suggestions validity is much better. There's been more than a few times when the suggestion wouldn't make sense in the context.
As a sidenote I'd suggest having a reference for the KB shortcuts open so you can improve your speed within the IDE: Mac or Windows/Linux

Linux or Sublime Text tab-style auto complete for Eclipse?

Is there a way to enable Sublime Text style tab-autocomplete in Eclipse. I've gotten very used to simply typing the first few letters of a variable name in Sublime, hitting tab to complete the variable name, and then moving on without thought. It's proving to be a tough muscle memory to break as I transition to Eclipse.
I know about CTRL + Space for bringing up the code completion menu for automatically generating certain attribute names and whatnot, but I'm more referring to that really quick completion of names while I type them.
Maybe a quick eclipse hack will work for you?
I have never used Sublime's autocomplete, but it sounds like Xcode has something similar. Just fill the "auto activation triggers" textbox with any/all characters that you'd want to toggle autocomplete.

changing switches to "if-else" statements

I've just recently become interested in programming, and I want to create Android apps for phones or tablets. I've come a long way in a couple weeks from knowing almost nothing about java/xml. I'm very serious about this. I'm going to find the answer to this question one way or the other. In fact, I hope to have it figured out before anyone answers this. I've fixed many issues without resorting to asking anyone, but I've just been stuck on this issue too long. I figured I'd give this a shot.
I'm using an older tutorial to build a practice twitter app (the tutorials for these seem to be everywhere, which is why I chose it). I'm using Eclipse for an editor.
The following is an example of code from the tutorial. which relates to my question:
#Override
public void onCreate (Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.timeline);
Apparently since the intro of ADT 14, you can no longer use the (R.layout.timeline) phrase, which the error message refers to as a "switch statement."
Now, in a post I found on another site, someone who had a similar issue shows a screenshot of the "quick fix" in Eclipse using ctrl+1. in the screenshot, the fix that pops up says "convert switch to 'if-else' statement." This fix does not pop up in my version of Eclipse. My quick fix options are "migrate Android code", "create field 'timeline' in type 'layout'", "create constant 'timeline' in type 'layout'" or "rename in file."
If I choose "migrate Android code", a window pops up informing me of the ADT 14 update, and how switch statements are no longer allowed in library projects. It says to convert the switch statement to an "if-else" statement by pressing ctrl+1 for the quick fix, then choosing "switch to 'if-else' statement" like it does in the screenshot I found. But again, when I do this, that option does not pop up.
I would much rather know what needs to be changed in the code than know how to make the right quick fix pop up. If it isn't too much trouble, an explanation of why exactly these changes are affective would be very helpful. I have many (MANY) errors in my java files right now, but most of them are due to this exact problem in different forms. If I could see just one before/after example I could probably figure it out from there without an explanation. But after hours of searching, I cannot find that so far by googling.
Thanks so much in advance....
And for the record, I don't see any switch classes in any of my java files, if that makes a difference for the answer...
Make sure you click on the switch keyword itself then press Ctrl + 1.
This confused me at first as well...
If it still doesn't show up, what version of Eclipse are you using?
If you are using a Mac select the keyword switch and click Shift + Command + 1.
That will show a prompt to change switch to if else conditions.
I've been having the same issues. For me, I was switching on view.getId(). Before the switch, declare int id = view.getId();. Then switch in id. Then you can ctrl+1 click and the "Convert Switch to If/Else" should pop up.
They made this change to decrease the build speed. My projects now build in roughly 1/10th of the time. I'm glad I upgraded the ADT.
The issue happens because since ADT 14 resource identifiers are no longer final.
The quick solution you can change switch statements with if-else statements.
With Android Studio 4.1.3
Step:1. Just right click on the switch keyword of statement.
Step:2 Click on the first option Show Context Actions.
Step:3 Click replace switch with if.
Done
To me, it looks like you don't have a timeline resource.
Breaking down R.layout.timeline
R refers to Resources
layout refers to the collection of layouts in your application
and timeline refers the specific resource that you are trying to apply setContentView() too.
If my hunch is correct, you don't have the timeline resource.
Create a new XML file in your layout folder in eclipse and name it 'timeline'
That should resolve the issue.
I hope you got things working.
I agree that this sounds like some weird Eclipse error that is not what it seems, and not what Quick Fix says it is. Eclipse has been known to lie from time to time. Cleaning your project (as #Stephen Dubya said), cutting out the offending code, saving the file, pasting it back in, and saving again...these are some of the non-obvious tricks that sometimes get Eclipse to behave.
In general, I think it would be good for you to get more familiar with some of the Java basics like switch; I think it will make your learning of Android a lot easier. Although the tools and documentation keep improving, Android is still young and not always easy to learn using tutorials, especially when you aren't used to writing code at all or using complicated IDEs like Eclipse.
But I digress. It is only in Android library projects, not regular projects, that Android doesn't treat resources as constants (final variables), since ADT 14. That means means that in library projects, you can't use R.layout.timeline or similar resource variables in your switch statements. You can only switch on whole numbers or enum values.
Using if-else all the time may be your best bet, anyway. switch can, especially for beginners, lead to logic errors in your code, and anything you can write using switch can be rewritten using if-else blocks. Personally, I've stopped using switch in Android and other Java code altogether.
You need to place the curse right before the s in the word switch, and the press cmd 1 . If you switch statements have fall-through clauses, the option to convert won't be available.
Somehow I overworked this error. I have deleted my project from workspace. Reverted it's .project files to old ones commited at SVN. Then at Eclipse uninstalling ADT and install it again. Then import my project. - > Libraries are added the old way and as result all fields at R.java are now final. Hope this helps.

How can I stop using a mouse while programming in my IDE?

I love using an IDE, because I get some great productivity gains. However, I have a couple reasons to stop using a mouse with an IDE:
To code faster - It definitely slows down my coding when my typing is interrupted with all of the constant point and clicking.
To relieve pain - I've never had pain from the keyboard, but I get tendinitis from the mouse.
I've got my cheat sheet for my IDE printed out and now I'm ready.
What's the best way get off the mouse?
Are there any hurdles that I'm going to run into?
Are there any tips for specific IDEs (Visual Studio, Eclipse, etc.) ?
Move it to the wrong side (eg if you are right handed then put it on the left of the keyboard). That way, you can still use it if necessary, but you should find you aren't using it unecessarily.
If changing sides isn't enough to confuse your brain, then moving it to a place where it is accessible but you have to think before reaching for it. As long as you can't reach for the mouse without thinking about it, then you will find that it is easier to use keyboard shortcuts instead. Essentially you want the mouse to be an option but the keyboard to be a better/easier/more convenient one!
As for pitfalls, well you may find that if you have to test any interfaces (web based or dektop) that you need to revert back to using the mouse. Also I find that if I have to work outside of the IDE, then it is just not as efficient to do without the mouse. Often we use WOrd for specifications and documentation, and trying to get away with using that without a mouse, is tricky (in my experience).
Another potential source of annoyance, is when switching between applications (Eclipse, VS, etc), you find that they often use different keyboard shortcuts, and so it can take a while to get back up to speed again, or you have to spend some time reconfiguring the shortcuts to be consistent.
Unplug it.
If your mouse is completely gone then you will be forced to learn how to live without it and therefore will become productive without it.
Anytime you're about to use the mouse, forcibly stop yourself and look up the keyboard shortcut for that operation. Do that a few times per operation and soon your muscle memory will kick in and you won't even have to think about it anymore.
Learn the keyboard short cuts :)
Also some editors are better suited for mouse free operation. I use ViEmu with Visual Studio which has helped me reduce, but not eliminate the need for using the mouse.
Get a trackball.
Your real question is about pain and productivity, the mouse is just a by-product of your circumstances. I would rephrase the question to reflect your real purpose.
Check out the wrist braces. I've heard from people that it makes a huge difference.
For VS, check out Sara Ford's blog.
Bind Macros to Keyboard Shortcuts
Keyboard Shortcuts to navigate task list
Search her blog for plenty of other tips and tricks.
Use the command line whenever you can (Install Powershell)
Switch to vim or emacs for code editing (or use ViEmu if you really need the intellisense)
If you develop web applications and/or spend a lot of time on the web, get the Vimperator or Firemacs extensions
Learn keyboard shortcuts for everything else.
???
Profit!!! (from your increased productivity)
Hide the mouse under a copy of your cheat sheet.
For visual studio I use the ViEmu plugin that allows you to use vi commands in visual studio. It's a bit difficult to get the hang of it but once you're done you'll only be using the mouse on the designer.
Get a webcam and eye-tracking software. Then you can fix bugs just by looking at them. It makes you feel all-powerful.
I've summed up some shortcuts that will get you working faster with Visual Studio in my blog.
I recommend you start at this article, that shows you the shortcuts I'd recommend you should get to know first...
Switch to emacs.
Open the nearest drawer and shove it in and close the drawer. That way, when you really do need it it'll be inconvenient to use it!!!
Also, if you're using multiple IDEs it pays to configure key bindings that are common across them, so that you can switch between them easily.
Change your keys to Emacs setup , Learn the Keyboard Shortcuts. I rarely use the mouse, if ever, in eclipse. i find it alot easier to just use emacs key short cuts.
When I contracted for an investment bank in NYC, there was this guy who didn't use a mouse. He was a java/kdb dev and just used vim. I used to think it was the strangest thing that he didn't have a mouse attached to his computer, but damn.. that guy was productive. Probably the most productive guy I've ever worked with.
So yea, if you really want to go that route you could try using vim, or something similar. You'll lose the features you're used to in your IDE, but it worked for him...
Become a better typer. As a slow
typer, I find myself going to the
mouse so I dont have to type. If I
were more efficient at typing, I would
be less inclined to use the mouse.
If you are using a laptop and a
mouse, remove the mouse and leave the
trackpad as your only option. That
will be so painful that you will be
forced to learn more keyboard
shortcuts.
Some very good answers above.
I spent a while injured with RSI and mousing was an issue. I already used shortcuts a LOT.
But coding using strictly the keyboard was definitely slower, especially when it comes to navigating around the code.
As I was using vi at the time, I would primarily move around the screen by doing searches for text at the location I wanted to go to; this is very fast, assuming you pick unambiguous text. Leaving line-numbers on and then going to the line number is another way to rapidly navigating. Judicious use of code folding (available in many IDEs) helps, too.
Finally, consider an alternate pointing device. A trackpad sucks for games but can be more accessible for coding, especially if you put it in easy reach of the keys (e.g., if you use a split keyboard, between the two hands). Try switching between two or more styles of device, to avoid injury because of one specific device. And don't ignore wrist pain! Treat it before it gets worse and you end up non-productive for a year or something.
Configure your IDE to use VI or EMACS keyboard controls (and learn them.) Both options allow you do do most tasks without moving your hands of the home row. You'll see your productivity drop during the learning curve but jump way up after as you save a lot of time by not moving your hand of the keyboard to use the mouse.
As a side note, learning to use a terminal based editor is a good skill to have in case you ever need to remotely administer a *nix machine. It will save your bacon some day.
MouseFeeds plugin will help you in eclipse:
http://www.mousefeed.com/installation
All these coders and no one suggested to write some code to hide the pointer when the IDE's window is active??
Great question... A co-worker suggested Launchy to me as a way to reduce mouse-use/be more productive. It searches your Start Menu (or non-windows equivalent) for apps, docs, shortcuts, etc. Type alt+spacebar to bring up its prompt where you type what you want to launch. Here are a few examples - what you type depends on other things in your Start Menu.
ch for Chrome, f for Firefox
ca for Calculator
expl for Windows Explorer
A power-user can fiddle with its settings to get more out of it but even basic users will benefit from it. Hope it helps.
Change your keyboard:
(source: datahand.com)
Hide your mouse - at least one arm's length away - then you can always get it back in an emergency
Move it far enough away that it's inconvenient to use, while your cheat sheet is close enough to easily lookup whenever you are in doubt about how to do something. I would not suggest unplugging it, since it is a useful tool for some operations, such as moving files around. I find drag and drop in some sort of tree like file system view is much easier than the alternatives. The majority of editing operations though, are quickly accomplished via key strokes once you remember them.
I am using IntellijIDEA IDE. There is one very annoying plugin - "Key promoter".
For every mouse-inited action it shows annoying alert with keyboard shortcut which you could use to do the same action.
Well, it took about 2 or 3 weeks for me to stop using mouse at all. It was hard to not turn it off (plugin), but very useful :)
IMHO the best answer is combination of two already given answers:
Print out the keyboard shortcut cheat sheet of your IDE and tape it to the wall next to the screen.
Unplug it. Also this makes a bit harder to procrastinate by switching to SO in the other window...
You may also want to consider doing your coding on a Macbook/Macbook pro. I generally HATE touchpads, but I've had to do some coding on the plane and the new touch-sensitive pads are actually really convenient. For example, you can do things like scrolling with a flick of two singers, and it's a lot more accurate.
It may not be perfect, but it might help with your hands.
I don't think avoiding the mouse completely is practical (you need things like hovers, etc.)
First off, don't try to do everything with a keyboard, start by forcing yourself to use keyboards for the top 3 things that you do all the time. Get the biggest bang for your buck/effort and you will quickly want to use more.
Keep a sheet of paper near by where you write down keyboard short cuts you use. (Alternatively, add this to a company wiki so others can benefit.)
Pay attention to menu items, they frequently have keyboard short cuts.
Find out the keyboard shortcuts that show all other keyboard short cuts.
I use Eclipse all the time, there are several keyboard short cuts that I find invaluable:
CTRL + SPACE - Content Assist
CTRL + 3 - Open any UI Element in eclipse by typing
CTRL + SHIFT + T - Open by type (Uses Capital letters to do word searches and * for wild card, for instance NuPoEx would find NullPointerException)
ALT + SHIFT + R - Rename current selection
ALT + SHIFT + T - Refactor Menu
And CTRL+SHIFT + L gives you a list of all keyboard shortcuts

Categories

Resources