The option to save a file is greyed out in Eclipse - eclipse

I'm using Eclipse 3.7 on Ubuntu. Often, after editing a file, I cannot save it - the "save" option is greyed out in the menu and Ctrl+s seems to do nothing, even though the file has just been modified and the editor displays the asterisk before the file name in the tab header.
Changing the active tab to another file and then coming back to the first file "unlocks" the save option, which I can then choose.
What causes this behavior, and how can I fix it?

This is a reported bug in Eclipse. You can follow up and bring more information in the bug report in Eclipse's bugzilla.

The easiest workaround I could find was to just restart eclipse. Worked for me.

That can also happen when the Project Explorer view has focus (bug 211520)
The new Eclipse 2019-09 has fixed that issue
You can now save the active editor even when the Project Explorer has focus.
In cases where an extension contributes Saveables to the Project Explorer, the extension is honored and the save action on the Project Explorer will save the provided saveable item instead of the active editor.

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.

Disable editor tabs duplication while opening a single file in Eclipse

I have this problem bugging me for a little while now and I didn't find any help on SO or other resources.
In Eclipse Java EE (Version: Indigo Service Release 2 Build id: 20120216-1857), when double clicking a file (a class, or XML or whatever else) in the Package Explorer to open it in the editor, it will open a new tab every time I double click the file, even though the file has been previously opened in another tab. So for example, double clicking 3 times in a row on a single file in the Package Explorer will open 3 tabs in the editor for this single file.
I found some info about how to display search result in a common tab, or how to open a single file in two different editors, but nothing about this problem, I cannot find any setting to disable this annoying behavior.
Anyone got some clues about this problem ?
After putting back the default settings of Eclipse, it seems to be alright now. I will update this post in case the same problem happens later on.

How do you set the encoding to utf-8 in NetBeans 6.9?

I'm running NetBeans 6.9, can't seem to figure out where to set the encoding. I found some guides on google but all of them were for older versions.
The method by Mr. LordofFatality doesn't work for out-of-project files that you open via 'open file' menu.
In order to accomplish that, find a netbeans.conf file in you netbeans installation\etc\, find there a netbeans_default_options line and add there -J-Dfile.encoding=UTF-8 string.
If you don't find the "netbeans_default_options" option there, add a whole new line as following:
netbeans_default_options="-J-Dfile.encoding=UTF-8"
Relevant to NetBeans 7.2, also works in 7.4
In 6.9.1:
open the project pane if you don't see it already (Window > Projects);
right-click on the name of your project in the tree-view;
click properties;
make sure the menu item "sources" on the left is highlighted;
you should see "Encoding:" and a select-box next to it;
click OK. Done.
It SHOULD work that way and does work for anyone on the internet except me. On my Windows XP dev system files are still not saved as UTF-8. Still wondering why ...
open the project pane if you don't see it already (Window > Projects)
Right-click on the name of your project in the tree-view click
properties make sure the menu item "sources" on the left is
highlighted you should see "Encoding:" and a select-box next to it.
click ok. done.
it SHOULD work that way and does work for anyone on the internet
except me. on my windows xp dev system files are still not saved as
utf-8. still wondering why...
Your file should content one or more non-latin chars, this is why.
its bug always the editor saving my files as utf-8 without bom
See here !!!

SVN Export in Eclipse removes labels on tabs

I have a very strange effect when using subclipse with eclipse. Whenever I use Team->Export to export a file from the editor the export works fine, but the label of the tab of the file is removed.
Effect can be seen here: http://www.daspferd.de/img/tabs.png
Strangely enough it happens with php-files, css-files, html-files but NOT with javascript-files. So I'm assuming it's some kind of setting that I haven't found yet and not a bug in subclipse.
Anyone know where I can shut down this behaviour?
It could be a bug in the editors. If eclipse opens an editor on the exported file, it might not open it as an IFileEditorInput, and the editors therefore do not set the title correctly (that's the job of each individual editor implementation).
This is just a guess, but it would be consistent with some editors behaving ok and some not. It would basically be a missing feature in some of your editors.

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.