How to make a project's subdirectory read-only in eclipse? - eclipse

How can I make a project's subdirectory read-only in eclipse?
The reason I need to do this is that I'm currently learning how to build a child theme in wordpress. I need to be able to view the parent theme's files but sometimes I edit the parent file (e.g. functions.php, style.css) instead of the child's file with the same name.
I know I could set the filesystem attributes recursively to read-only on everything other than my child theme, but I'm wondering if there's a better way? When I do this and I try to edit a read-only file, eclipse shows me a dialog offering to clear the attribute. This is not convenient because if I accidentally press enter or space before I realise there's a dialog, the default is to clear the attribute and then I have to set it again. Ideally I'd like to tell eclipse to not let me edit any files under some specific directories that I choose.
Thanks

Related

Files in Folder named "templates" don't apply colors and suggest in VisualStudioCode

If I name the folder "templates" or "template", the files in the folder don't apply colors or suggest in VisualStudio Code.
1st image shows when I named the folder "templates", and 2nd one shows when I named the folder "foo" (flutter).
I'm not sure but this happens maybe because of a extension that I added?
Please tell me how can I avoid this.
This is my setting of files.associations:
As indicated by the asker in the comments, the issue is due to file associations. Check your settings.json file to see if you have anything set in the "files.associations" setting that could be causing this. Otherwise, try disabling extensions that aren't needed to see if they are related to the issue. You can also change what file association is being used by clicking the lanugage indicator on the bottom right of the screen that has a "Select Language Mode" hover message. The same action can be done by using the command palette and using the "Change Language Mode" command.

Rename resource file does not change editor part title

In my plugin project, I have a project explorer view where I can rename a config file which in shown in another editor part. The file can be renamed in the explorer with the rename resource dialog but the corresponding the editor tab title does not change. The same problem is described here and also here. Is there a standard way to get the rename functionality working without the creating a custom listener?
Editors based on AbstractTextEditor (or one of its subclasses such as TextEditor) should handle renames through the FileDocumentProvider which listens for resource changes.
Other editors need to use an IResourceChangeListener to deal with this.

eclipse hide a item entirely from processing

My requirement: To hide specific file/folder from the project explorer.
Following the steps given on below link, i am able to successfully do so,
http://help.eclipse.org/luna/index.jsp?topic=%2Forg.eclipse.platform.doc.user%2Ftasks%2Ftasks-48b.htm
But, I want to hide them entirely from the processing, e.g. If I do a search for some word in *.java files, results show up from the hidden folder as well. Any way to exclude it from search results (or from entire processing of what eclipse looks for) ?
Resources marked as 'derived' are ignored by most things.
You can set the derived flag on the 'Resource' tab of the file or folder Properties.
You can use the IResource.setDerived method to set the flag programatically.

How to change open with options in navigator depending upon name of the resource?

I am working on eclipse RCP application which implements CommonNavigator view to display navigator. I have few LinkedResources in navigator that link to files on the file system with custom extension. These custom extension files are opened in custom editor as well as in TextEditor.
One of the file named default.ext will be common to all the projects and I want to keep it read only. Is it possible to open file in custom editor only? For ex. Default.ext should be opened in only custom editor, however Test.ext should be opened in custom editor as well as text editor.
This way I could handle save action in my editor depending upon file name and keep the file read only.
Is there any other way to keep files read only?
Short answer: not possible in the way you describe.
Long answer: if somebody really wants to modify a file then there's no way or need to stop this. What you can do is either (1) hide the file from user or (2) set Read-only flag to discourage users from modifying the file.

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.