In Eclipse, how do I refresh the icon decorators (per-file 1+ warning, 1+ error) in my Project Explorer? - eclipse

In Eclipse, in the Project Explorer pane, each Java file will have an icon decorator, indicating whether that file has 1+ compilation errors, or 1+ compilation warnings.
I often find that these icon decorators are out of date with my latest file changes.
How can I force them to be up to date?
I try right-clicking on the project's top-level directory and selecting Refresh, but that doesn't help. Neither does restarting Eclipse.
I realize that one alternative is to use the Markers pane, but that gets me the entire list of all warnings/errors across all files. I'd rather know, see visually, which files have problems and which are clean.

You haven't said which language you are using and whether autobuilds are on or off.
In general, problem markers are only added and removed by your project's builder. If you are using Java, for example, that language has full automatic incremental build support, so the markers update whenever you save a file. Not all languages enjoy this; you may need to explicitly rebuild your project(s) to force an update.
If you believe a marker is out-of-date, or just want to hide it, it's usually safe to delete it from the Markers view; the relevant builder will reinstate it if necessary next time it runs.

Related

Double clicking a resource in Eclipse Project Explorer does not open the second file

In an Eclipse based application (RCP), when double clicking on a file that appears in the project explorer, for the first file this will work – the associated editor will open. However, when double clicking again on a file, it will not open. If you click somewhere out of the Project Explorer and then return to the Project Explorer, then the second double click will work.
Note that right-clicking on the resource and selecting “Open” always works. In addition, in Package Explorer it always works.
I believe this is related to eclipse bugs 285239 and 256761.
Does anyone know of a way that I can overcome this problem, as the RCP developer. The file editor is a custom editor in one of my plugins.
The problem does not seem to happen to me with java files in standard eclipse for java development.
Thanks,
Eyal.
I solved the problem by implementing a setFocus method on the editor class. In the setFocus, I set the focus to some component. (To be precise in my case the editor was a subclass of SharedHeaderFormEditor so I set the focus to the active page).
The truth is that the specification of the setFocus method in IWorkbenchPart requires you to "assign the focus to one of the controls contained in the part's parent composite". It seems that the default implementation of setFocus in some cases did not do that (I don't know why, maybe I was missing something or for other reason).
Note that also setting focus explicitly to a control from within editor initializing partialy solves the problem.

how to remove google sign in button in eclipse

I'm facing a wierd problem. My eclipse, has a google signin button which is occupying some of the space which I do not want to happen. Initially it had "Sign-in to Google" text along with it. I've followed some blog post and set accordingly to show just the icon (I don't remember that blog post link).
But now, the icon is getting replicating .. it is being shown 12 times. It is actually creating childs :P
I've gone through all the options present in Customize Perspective menu, none of them had this button listed. Can someone help me in removing that google sign button from my perspective? One possible suspect is- my eclipse crashes when I suspend and wakeup my machine.
You can use the Window > Reset Perspective... menu command to reset the perspective to its default state, which might eliminate that toolbar and buttons. If that fails, I would create a new workspace and import the projects into it using File > Import > Existing Projects into Workspace.
If you want to try to salvage your existing workspace, it's possible to do so my manually editing Eclipse's internal file that stores your Workbench layout, but it's a bit tricky. Here are the steps I've followed to eliminate a similar repeated toolbar item:
Exit Eclipse.
Find the Workbench layout file, it's path is <workbench>\.metadata\.plugins\org.eclipse.e4.workbench\workbench.xmi. Make a backup of this file before you touch it - this is essential because it's easy to corrupt the file if you change the wrong things.
Open the file in your favorite XML-aware editor - most packages of Eclipse include the XML editor that works just fine1, but be aware that if you use Eclipse to edit the file you can't have Eclipse open on the workspace that contains the workbench.xmi you want to edit.
Find the section of <trimBars> nodes in the XML; from there you have to determine which <trimBars> node you need to edit. In your case it looks like a vertical one, probably with a side="Right" attribute.
Under the correct <trimBars> node you'll find multiple <chlidren> nodes, each with an elementId attribute that should help you identify it; you're looking for <children> nodes that are identified as something related to the Google plugin.
Delete the <children> nodes that seem related to the unwanted toolbar buttons. In your case, it appears that there is an entire toolbar that you might want to eliminate, so you might want to delete the entire containing <trimBars> node.
Save the file and start Eclipse on that workspace.
1Some packages of Eclipse include EMF tools that will open it in a special XMI editor that does not provide a view of the source, only a structural tree view. Depending on how you like to work with XML, this might be easier than editing raw XML.
This is not a perspective but a view. You can hover over that bar with the buttons and click Alt+Shift+F1 to check where this View comes from. Then you can either disable/uninstall the contributing feature (Help -> Installation Details) or check where the feature came from.
If it comes from the IDE, you can open a bug for it. If it is contributed from a third party plugin, contact the developers of that plugin.
There is an eclipse bug concerning duplicate view toolbar buttons in Luna that has recently closed as well. Maybe this solves your problem as well.
Edit: Taken from this bug:
root cause is that in Luna 4.4M5 WorkbenchWindowControlContribution.createControl is called twice, the
first time with a null value for
WorkbenchWindowControlContribution.getWorkbenchWindow() while it is
still being created. This is related to what has been reported here
https://bugs.eclipse.org/bugs/show_bug.cgi?id=427452
second cause is that my createControl(Composite parent) method was calling PlatformUI.getWorkbench().getActiveWorkbenchWindow() instead
of WorkbenchWindowControlContribution.getWorkbenchWindow(). This
resulted in an attempt to create a new Workbench Window, which
recursively calls createControl() again. This has already been
reported here https://bugs.eclipse.org/bugs/show_bug.cgi?id=366708

Eclipse IDE lost popup menu suggestions

I've seem to have lost the ability in my Eclipse to auto-correct errors in my source code lines.
For example, a line like this:
Date date = new Date();
has red jagged lines beneath the Date() part. Previously I could mouse hover over it see a popup menu of options to fix it. Now I all I ever get is a popup with the text "Cannot resolve to a type".
The only change I can think of that I've made and I don't know if it has anything to do with this problem, is that I started editing my .java files with an outside editor. Then focusing back into Eclipse I get a popup saying the source has changed and do I want to update so I say OK.
Sometimes I will edit inside Eclipse and sometimes i will edit the source outside of Eclipse. I'm not sure if this is a bad practice or not?
Its your wish to edit Java files outside or inside eclipse. But Java editor has many features which are very helpful to developers. I suggest to edit Java files inside eclipse only.If you find other editors are good or you used to it then no problem you can edit Java files out side eclipse also. The problem you mentioned in not related to it. But make sure that changes are applied before building project in eclipse.
Solution
This occurs whenever there are multiple classes are available with the same name in you build path then eclipse don't know which one to import by default. So keep the caret on the error line and press Ctrl+1. Then a eclipse gives options to user to import one among these. See the picture below. Choose the right one then error will disappear.

How to programmatically reload a text editor in Eclipse?

In Eclipse, if I change a file programmatically, and it is open in a text editor, it doesn't always reload, not even when refreshing the resource programmatically. How can I forcibly reload the text editor from code so that it show the changed file contents?
In your project explorer or navigator, you can right-click on the file that's currently open and select refresh. This has always worked for me, even when editing files with several programs. Make sure to click the file itself, not parent objects like packages or folders or projects.
Edit
Refreshing programmatically? I would look into an Eclipse scripting tool:
http://eclipse-shell.sourceforge.net/
I guess there was another one called Monkey, but it doesn't appear to be maintained.
I don't know of any possibility to programmatically reload the file.
Some editors (e.g. GMF editors) look for changes in the underlying files, and refresh themselves, but this is not required at all.
I don't think that a forced reload is an option implemented globally, as in some cases there could be some merging steps involved that can be quite erroneous.
My ideas to solve this:
Have a specific editor that refreshes its content when the used resource changes (this can be timeconsuming);
Or close the editors of the file and reopen them (this is ugly in the eye of the user).
Since the Luna release of eclipse there's no need to reload files with F5/manual Refresh.
Really nice, especially as there was a bug with the F5 key binding.

Eclipse 3.4.1 - how to view compiler output in Console while building a project

I have what appears to be a very annoying problem. When compiling a project in Eclipse, I see no Console that shows the invocation of the Java compiler and the build results (as in NetBeans).
If I, for instance, import an existing project into Eclipse and invoke Project->Build Project, is there a view that will show me results of the compilation? While I know that my project contains a number of files that have errors, invoking Build Project shows no visual result/progress of the compilation. It does not show the list of errors so that I can quickly jump to them.
I'm aware that there is a "Problems" view, which shows a list of problems (and not just compiler errors) in all projects and not the particular project that I am working with, which makes it very inconvenient to locate and jump to source of the problem.
You can configure the problem view to show only problems in the current project:
Click on the small triangle at the far right of the view.
In the popup menu, select "Configure Contents..."
Select each item in the "Configurations" list and click on "Scope: On any element in the same project"
If you want to see the compiler working, you need open the "Progress" view.
Since Eclipse JDT provides its own built-in Java compiler, you generally do not see the invocation of Java Compiler.
The built-in Java compiler is tightly integrated with Eclipse and JDT, and provides the source indexing that enables powerful IDE features such as refactoring and quick fix.
Plus, it enables incremental build in background after each file modification, hence no visible "java" invocation.
You can replace/complete the java compiler with a javac` call of your own:
For instance, Using Alcatel-Lucent nmake with Eclipse JDT does precisely that, and uses a configuration launcher (which you can instruct to show a console):
You will need to add that special builder in the "builder" section of your project.
Do not forget you can create many "Problem view", and set one of them to show only problems for your current project.
Select: "on any element in same project"
Goto Windows->Show View->Console
or
Alt+Shift+Q,C
Console appears in tab with Problem view
Your question contains a couple of assumptions that you might want to re-think.
It does not show the list of errors so that I can quickly jump to them.
Errors are flagged in the edit window while you are editing. You can fix them on the spot, without having to "jump" anywhere.
If you drop an entire source file into your project, you may not be in an edit window on that file. (And, of course, that's not standard Eclipse usage.) The simplest way I know do deal with that is simply to "Refresh" the project and look in the Package Explorer view to see whether there are any errors detected (which will happen immediately if you "refresh" a file into a source folder). Double-click on any files which show an error icon and look at the right-hand side of the edit window to see exactly where the errors are.
I'm aware that there is a "Problems" view, which shows a list of problems (and not just compiler errors) in all projects and not the particular project that I am working with...
Unless you are using multiple projects, with inter-project dependencies, I find it useful to close all but the current project on which I'm working. Then the "Problems" view is specific to the current context.
Finally, I'd recommend looking at the Mylin "getting started" page for other hints on how Eclipse can help you focus on the current task.