代码改变世界

android学习:android开发常见技巧设置,提高开发效率

2014-11-22 21:21  -夜  阅读(170)  评论(0编辑  收藏  举报

一. 智能提示

在下图位置,添加   .abcdefghijklmnopqrstuvwxyz(,    实现开发过程中 对java代码和xml文件更快捷的智能提示。

二. Eclipse包折叠视图




三、修改默认编码为UTF-8


参考:http://blog.csdn.net/pdw_jsp/article/details/6212896
1、windows->Preferences...打开"首选项"对话框,左侧导航树,导航到general->Workspace,右侧 Text file encoding,选择Other,改变为UTF-8,以后新建立工程其属性对话框中的Text file encoding即为UTF-8。
2、windows->Preferences...打开"首选项"对话框,左侧导航树,导航到general->Content Types,右侧Context Types树,点开Text,选择Java Source File,在下面的Default encoding输入框中输入UTF-8,点Update,则设置Java文件编码为UTF-8。其他java应用开发相关的文件如:properties、XML等已经由Eclipse缺省指定,分别为ISO8859-1,UTF-8,如开发中确需改变编码格式则可以在此指定。

四、代码块折叠 com.cb.eclipse.folding(类似Visual Studio的#region ...#endregion 


参考:
http://www.cnblogs.com/haiq/archive/2011/06/22/2087069.html
http://my.oschina.net/axes/blog/124714

代码折叠默认快捷键:
<span style="font-size:18px;">    Ctrl+Shift+Numpad_Divede(小键盘的/号)
    Ctrl+Shift+Numpad_Multiply(小键盘的*号)</span>

2. 将压缩包中的 com.cb.eclipse.folding_1.0.6.jar 放到 eclipse\plugins 目录下,重新启动 eclipse.
3. 启动eclipse后,进入 window->preference 菜单选项,在配置窗口中选择 java->editor,select folding to user 中选择"Coffee Bytes Java Folding",保存后重启 eclipse 。
4. 重启之后再次进入步骤2,勾选最后一个 User Defined Regions, 保存后即可。(当然可以在User Defined Regions自定义折叠方式)



五、get/set方法自动加上字段注释

参考:http://blog.csdn.net/manageer/article/details/9028891

1. 找到Eclipse目录下搜索找到org.eclipse.jdt.ui_*.jar(*是版本号),进行备份

2. 将jar文件改成.rar格式并使用压缩软件打开。

3. 找到\org\eclipse\jdt\internal\corext\codemanipulation这个目录下的GetterSetterUtil.class这个文件。反编译修改getSetterStub 和 getGetterStub 方法,修改如下,或者直接使用(此链接文件)替换(记得要备份喔)

if (addComments) {
	//field.getCompilationUnit() 得到当前类文件内容,就是要get,set的东西
	//parentType.getTypeQualifiedName('.') 得到类名
	//getterName 拼出get的方法名
	//field.getElementName() 得到字段名
	//typeName 类型
	String comment= CodeGeneration.getGetterComment(
			field.getCompilationUnit(),
			parentType.getTypeQualifiedName('.'),
			getterName,
			field.getElementName(),
			typeName, 
			accessorName, 
			lineDelim);
	ISourceRange sr = field.getJavadocRange();
	  if( null != sr ) {
		  String filedComment = field.getSource();
		  filedComment = filedComment.substring(0, sr.getLength());
		  filedComment = filedComment.replaceAll("[\n,\r,*,/, ,\t]", "");

		  comment = comment.replaceFirst(field.getElementName(), filedComment);
		    
		  int i = comment.lastIndexOf(field.getElementName());
		  int j = getCount(comment, field.getElementName());
		  if (i != -1 && j >= 2) {
			  comment = comment.substring(0, i) + filedComment + comment.substring(i + field.getElementName().length());
		  }
	  }
	  
	if (comment != null) {
		buf.append(comment);
		buf.append(lineDelim);
	}
}

4. 开启开发工具找到Window->Preferences->Java->CodeStyle->Code Templates->Comments->Getters/Setters

  getters:

[java] view plaincopy
  1. /**   
  2.  * 获取${bare_field_name}   
  3.  * @return ${bare_field_name} ${bare_field_name}   
  4.  */    
setters:

[java] view plaincopy
  1. /**   
  2.  * 设置${bare_field_name}   
  3.  * @param ${bare_field_name} ${bare_field_name}   
  4.  */    

注意:生成Get/Set方法时勾选上Generate method comments

六、其它设置

  1. 设置字体大小:Window->preferences->General——Appearance——Colors and Fonts——Basic——Text Font——Edit
  2. 显示行号:Window->preferences->General——Editors——Text Editors——Show  line numbers
  3. 保存的时候,自动格式化代码:Window->preferences->java——>editor——>Save Actions
  4. 设置自定义代码代码风格:窗口→首选项→Java→代码样式→格式化程序→新建
  5. 设置注释模板:Window->preferences->java->code style ->code templates ->Comments ->typese->edit->

/**
 * @author 付亮
 * @date ${date}${time}
 * ${tags}
 */
或者在:在eclipse的安装路径下,打开eclipse.ini的配置文件

在-vmargs下加入:

-Duser.name=你的名字



云天博客:http://www.yuntianseo.com   专注于网络营销推广!   更多草根创业资讯了解:云天博客

版权声明:本文为博主原创文章,未经博主允许不得转载。

作者:夜 本文地址:http://www.cnblogs.com/ful1021 本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明。如有问题,可以邮件:531761819@qq.com 联系我,非常感谢。