Sunday, August 3, 2014

Import Export in Eclipse

Import-Export in eclipse can be used like these ways :

Import project from another workspace.
For some reason we usually have more than one workspace and each them have some project inside bur sometime we need to open a project from unopened workspace, rather than switch between workspace we can import a project from that workspace. To do this clik File in menu or just right-click in Package Explorer and click Import, import window will show up. Expand 



General and click Exsisting project into workspace and then Next, an import projects window will open and click Select root derectory (if not selected yet) then browse project folder in unopened workspace from window 



explorer and OK, it will send back to previous import project window and that chosen project folder appear in project box and already checked (check it if not), if you want to work with this project from the owner workspace (unopened workspace) directly just leave Copy project into workspace uncheck but if you want to copy it into current opened workspace check this box, by do that you will have two same project in two workspace and you can work with one of them independenly means if you do modification in one project, another same project will not updated. Finally click Finish and that project will appear in your Package Explorer.

Import Android Code from another folder.
For example we want to import sample android code from android SDK, so click Import from File menu, on import window expand Android and click 



Existing android code into workspace and then Next, an Import project window will open and browse android code from window explorer, for example : Eclipse – adt-bundle…..- Eclipse –SDK – sample - android 14 – Lunar Lander and OK. That chosen android sample code appear in project box and 



check it’s checkbox, if you want to work with this project from original place directly just leave checkbox Copy project into workspace uncheck but if you want to copy it into current opened workspace check this box, choose the second one so you can work with this code freely, you can learn it and do modification as well. Then click Finish and that code appear in your Package Explorer.

Import project from currently opened workspace.
Sometimes we need to delete some projects from Package Explorer list but not from workspace means project just disappear from list but still in workspace, this because too many project listed in Package Explorer will make eclipse take long enaugh to get ready at first time opened because eclipse will check one by one all project from error. To delete from list, right-click project name in Package Explorer – Delete – OK. Don’t check Delete project content on disk because it will delete project from workspace too. To display it back on the list click Import from File menu or right-click in Package Explorer and import window will open, expand General, click Existing project into workspace then Next. From import projects window browse the project you want to import from current workspace and click OK, it will go back to previous window and the project will appear in projects box. Notice : project sometime displayed in grey and unchecked because Copy project into workspace option still checked, just uncheck it and click Refresh to make project appear solid black and checked then click Finish and that project will be back in Package Explorer list.

Export to Archive File
Project archive file is usefull to used later to do recover project or just to compare the discrapancies between two project with same name. To archive just click Export from File menu or right-click in Package Explorer and export window will open, expand General, click Archive File then Next. In file 



system window just pick project you want to archive, you can archive the whole project or just certain folders/files to be archived. Browse the directory where the archive file will be saved, in Options you can Save in zip (recommended) or tar format, you may Compress the content of the file (recommended). Check option Create directory structure for files (recommended) if you want to archive files and complete directory structure just like in project package, or if you just want to save files and directory associated with them check Create only selected directories. Then Finish.

Export to File System
To do this click Export from File menu or right-click in Package Explorer and export window will open, expand General, click File System then Next. In file 



system window just pick project you want to save, you can save the whole project or just certain folders/files to be saved. Browse the directory where the archive file will be saved, in Options check option Create directory structure for files (recommended) if you want to archive files and complete directory structure just like in project package, or if you just want to save files and directory associated with them check Create only selected directories. Then Finish.

How to Use Archive Files / File System ?
If you for some reason lost your project, say accidentally deleted, You can import archive files use import project from another worspace procedure just like described above, just Select archive files as source.



If you want to recover some files in your project, say you make mistake that you can’t fixed, do import file system. Click Import from File menu or right-click in Package Explorer and import window will open, expand General, click File System then Next. From file system window in From directory browse file system you want to import and click OK, it will go back to previous window and the file system will appear in explorer box. Select all files in file system or pick particular files you want to import then in Into folder browse folder in your project directory (this directory must be the same with directory you pick in From directory), click Finish and just click Yes if

 
overwrite warning pop up then the failed files in your project will be recovered with file from file system. You can also use archive file to recover some failed files in your project but you have to extract it first.

Friday, August 1, 2014

Change Eclipse Editor Appearance

Default eclipse editor window use font courier new size 10 and background white, it not suit me at all because the font too small for me and the background I prefer more cool (color like green blue). May be you have same opinion with me and want to change, lets do it. I want to change the editor appearance like this :



First, open eclipse and open one project, in java editor (eg. MainActivity.java) right click and in context menu click Preferences. It will show this :



In preferences window on the left pane, expand General-Appearance-Colors and Fonts. On the right pane expand Basic and click Text Font, it will show the default font and size currently used, Click Edit to change and choose



font and size you want, for myself I choose font Lucida Console Bold size 12 and click Apply. Do it the same for Text Editor Block Selection Font. Why Lucida Console? Because just like Courier New this font is monospace font (monospace font is recomended font for programming editor) and this font distinct each character clearly like bracket () and curly bracket {} (compare to Courier New bracket () and curly bracket {}).
Next to change the background, Expand General-Editor-Text Editor, point to Appearance color options click Background color, at the right of it show




System Default checked and color box greyed, uncheck System Default and click color box to change the color then Apply, I change to color something like teal.
Now to show line number at right side of editor , point to check box above it and check Show line numbers and then Apply. If you ok with line number color that’s it but if you want to change line number color go down to Apperance color option click Line number foreground click color box and change the color, I choose black to show number more clear. So far this change will be applied to xml editor too.
These change specific to java editor, first change Static Fields to bold, to do that expand Java – Editor – Syntax coloring, at Element box expand Java




and scroll down to find Static fields and check Bold on the right of Element box and Apply.
Two more thing that I want to change are first change matching brackets highlight, in Java – Editor click Editor and in Appearance color option box click Matching brackets highlight and click color box on the right of the box, change to color yellow because I want to more bright color to make me more aware.


The second is change the way bracket highlight behave, go above Appearance color options box and in Bracket highlighting change from Matching bracket (default) to Enclosing bracket. The defference beetween two is Matching bracket just highlight one bracket only if you put cursor right on it’s couple bracket meanwhile Enclosing brackets always highlight coresponding both brackets wherever you put cursor.
To do some change in xml editor open one xml file (eg. Activity_main.xml), right click on it and choose Preferences on context menu. In Preferences window expand General – Editor – Structure Text Editor, in Appearance color options click Matching color highlight and click color box and change color to yellow.





To change attribute font to bold, expand XML – XML Files – Editor – Syntax coloring, at Syntax Element box find Attribute vakue and check Bold on the right of Syntax Element box and Apply.

That’s all guys.