How to import images in eclipse correctly - eclipse

I tried to resolve this by both manually just dragging the image to eclipse or getting to the import. But the images always happenes to be an Text file as the Image below shows. Please Help!
Go zoom in and you can see the image imported is a text file
enter image description here
and when i open it:
enter image description here

Go to File Location.
Right Click --> Properties.
In General Tab --> Open With: --> Click Change
Then either from recommended / Other Software choose your application with which you want to open it.

The file has been imported correctly. If you just want to use the image from your code you don't have to do anything.
You are opening the file using the text editor rather than an image viewer. To view the file try right clicking on the file and selecting 'Open With' and selecting 'System Editor'.

Related

Eclipse why is there weird text when you look at the tab for an image?

I've been following a tutorial series on Youtube for learning to program games with java and Eclipse. At one point, I had to drag and drop a PNG file into a folder and when it finished, the guy in the video had a document icon and when he opened the tab for the image, there was just text with letters and symbols but, I got a globe icon and when I opened the tab for the image, I saw the image.
why would there be a difference and what does it mean?
You are just using a different editor for image files. The default editor in current Eclipse releases is the internal web browser which will show you the image. Older releases didn't use this editor and just tried to show you the contents of the file as though they were text.
You can see the same result by right clicking on the file and selecting 'Open With > Text Editor'. This isn't very useful as trying to change a binary image file with the text editor will damage the image.

Eclipse open all files in project

How can I open all source code files in a eclipse project at once? It takes too long to open all files in large projects by expanding out the packages and clicking on all the files.
I would like to know how to do this so I can ctrl+e to classes quickly.
It is not a good way to keep open all source files in a project because a project may have hundreds of source files. There is NO direct way to open all source files in eclipse.
However you can do it in two ways:
Using open resource dialog:
Create a working set which includes your project. Refer this.
Press Ctrl+Shift+R and select the your working set(Click on the downward pointed triangle button)
Type *.java in the text box. Dialog will list all java files in your project. Press Ctrl+A to select all files. Click on open button.
Using search dialog:
Select your project in Package explorer/Navigator/Projects view.
Press Ctrl+H. Go to File search tab. Leave "Containing text:" as blank. In File name patterns text box enter *.java. In scope section choose Selected resource option. Press search button. All source files will be displayed in search view.
Change the view layout of Search view to Show as list(In search view toolbar click on the downward pointed triangle button)
Press Ctrl+A to select all results. Right click and select open option.

Eclipse File Associations: displaying images

I am developing some help documentation in a Java project in Eclipse. In the resources folder there are my HTML pages and a couple of GIF and PNG images that will be displayed inside the HTML.
Now for my convenience I want to preview the images in the file structure of the project, to see what they show and which one to include in the HTML page. If I double-click an image, the default action that Eclipse does is: it opens it in Internet Explorer. Since I don't like IE, I want to change this default action. What I would prefer actually is that it opens some image viewer of some kind inside Eclipse.
I know this is a matter of file associations. However I was not able to get it working.
What I tried to do so far:
As an example I did it for *.gif.
I went to Preferences -> General -> Editors -> File Associations. There I pressed "Add..." and added *.gif.
Then I pressed "Add..." at the Associated Editors section and added an external gif viewer:
I expected this to open the default image viewing program from my Windows system, but for some reason it still opens it in Internet Explorer.
So what can I do to change this? Does Eclipse have an internal image viewer of some kind?
Why not just install plugin for viewing images
http://marketplace.eclipse.org/content/quickimage -> http://psnet.nu/c/quickimage
Sources https://github.com/persal/quickimage
There was nothing wrong with Eclipse, and the described solution is fine.
In fact the problem was with the Windows system. The system's default file association with images was the Internet Explorer. Changing that solved the problem.
right click on the file -> open With.. and then select -> System Editor (it should remain selected as a checkbox does)
After that you should be able to double click on a file and open it with the right app.
My environment is eclipse indigo build 1857 on gentoo linux
EDIT:
When you associate some external software with an extension, you should see on the menu "open With.." all application associated with the extension(On the top).
Then you can see : Text Editor - System Editor - Default Editor - Other...
Text Editor: open your file with the text editor
System Editor: open your file with the app associated with extension in the operating system
Default Editor: open your file with the (default) app associated by you under Preferences ->General -> EDitor -> File Associaton etc...
You should have something like this picture, without "In-Place Editor" option
Eclipse Oxygen (4.7)
Eclipse Oxygen (4.7) added the following feature - Images are opened in the Eclipse IDE.
You just need to double click the file name in the Package Explorer.
The file URI looks like this file:/// + absolute path:
Now there is a bug related to the URI shown on the right side.
If you rename the file, it won't be updated without reopening the file.

How to use github icon set on fontello

Fontello has an area where you can drag custom fonts onto.
GitHub style page here shows they have a custom font I want to use on that fontello can someone please help me to import it.
Yeah I love the GitHub icon font "Octicons" too. Unfortunately as far as I know they're assumed to not freely available to the public - see here: https://github.com/FortAwesome/Font-Awesome/issues/191#issuecomment-6180040
That said - I just did some source file snooping and grabbed the TTF and other files here if you wanna try this on fontello? https://dl.dropboxusercontent.com/u/7951258/fonts/octicons-from-github.com_20140302.zip
PS: If you do find a way to get a hold of them legitamitely please post an update though!
Go to GitHub Style page HERE
Open the inspector Ctrl + Shift + C
Click on Fonts
Click on "See all fonts used in this page"
Find octicons section
Highlight and copy (with Ctrl+C, cant right click here) that box below >Used as: "octicons"
Open notepad and paste it there.
Find the format(svg) and copy it
Go back to firefox, type in http://github.com/ and then paste the string you copied so now in URL bar it says https://github.com//assets/octicons-cdc456dbc5906e59b8c4d1c649a4b734fb0fd97b.svg#octicons
Hit enter and now right click in the page after it loads and go view source
Save this source to your drive
Now go to Fontello tab and then drag the downloaded file into the area on Fontello site where it says "Drag custom SVG icons or SVG font here" on fontello
DONE. Wait and magically all the github icons are now available to you!! Its grouped as "Custom Icons"
Super cool!!

Eclipse: Get location of the current file?

If I've got a file open in Eclipse, how can I figure out where it is on the filesystem?
For example, in Vim I would use :pwd.
Use the Eclipse menu:
File->Properties
or the shortcut:
Alt-Enter
You should be able to see the Location associated with the Resource
Just hit Alt-Enter.
The other solution ("File-->Properties" or "Alt+Enter") didn't work for me.
I use:
Right Click (in current editor) --> Show In (shortcut: Alt+Shift+W) --> Project Explorer
This shows in Project Explorer the location of the file. If the file is a class in a referenced library, the dependency tree is automatically opened.
What you're looking for is the 'Properties' dialogue for the current file. This can be activated in two ways:
Selecting from the menu: File -> Properties
Using the shortcut: Alt + Enter
This gives you a dialogue which contains both the full path of the document, as well as the relative path from the workspace root.
The dialogue can be quite handy: it allows you to highlight and copy the file path.
Linking to Project Explorer won't work if you have many files - it will select the right file in the list, but it won't "scroll" to that portion so it is visible.
You'd have to manual scroll the Project Explorer view to see where the file is. It could also be nested so deeply that the full location will be obscured by truncation.
Another way to quickly (keyboard-free) see the path is to hover over the file type icon (on top of the open editor window).
Eclipse also has the ability to link the explorer view with the current file, so that whenever you change a file, it is expanded and selected in the explorer view.
Just look for the following image at the top of the view: