给 eclipse 做个日历的插件
2004-07-15 20:31
531 查看
昨天看了 coldfusion 论坛的一个帖子(http://www.5d.cn/bbs/newsdetail.asp?id=980498),诱发了写一个简单 eclipse 插件的想法。
这是昨天晚上写的程序
虽然没有太大必要,但是还是有点用的,我把这个程序改造了一下,写了个 eclipse 插件
CalendarView.java
CalendarImp.java
plugin.xml
测试用例:
这是昨天晚上写的程序
虽然没有太大必要,但是还是有点用的,我把这个程序改造了一下,写了个 eclipse 插件
CalendarView.java
package com.eiffelqiu.tools; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.SWT; import org.eclipse.ui.part.ViewPart; /** * Calendar plugin for eclipse * * @author Qiu Hai Feng * @version 1.0, Created on 2003-10-28 15:36:57 */ public class CalendarView extends ViewPart { Label label; public CalendarView() { } public void createPartControl(Composite parent) { label = new Label(parent, SWT.WRAP); label.setText(CalendarImp.show()); } public void setFocus() { } }
CalendarImp.java
package com.eiffelqiu.tools; import java.util.*; /** * Calendar implementation * * @author Qiu Hai Feng * @version 1.0, Created on 2003-10-28 15:36:57 */ public class CalendarImp { /** * concate calendar output string * * @param void * @return String */ public static String show() { StringBuffer calString = new StringBuffer(); GregorianCalendar nowDate = new GregorianCalendar(); int today = nowDate.get(Calendar.DAY_OF_MONTH); int month = nowDate.get(Calendar.MONTH); nowDate.set(Calendar.DAY_OF_MONTH, 1); int weekday = nowDate.get(Calendar.DAY_OF_WEEK); calString.append("Sun Mon Tue Wed Thu Fri Sat/n" ); // indent first line of calendar for (int i = Calendar.SUNDAY; i < weekday; i++) calString.append(" " ); do { // print the day int day = nowDate.get(Calendar.DAY_OF_MONTH); if (day < 10) calString.append(" " ); calString.append( " " + day); // mark current day with * if (day == today) calString.append("* " ); else calString.append(" " ); if (weekday == Calendar.SATURDAY) calString.append("/n" ); // advanced d to next day nowDate.add(Calendar.DAY_OF_MONTH, 1); weekday = nowDate.get(Calendar.DAY_OF_WEEK); } while (nowDate.get(Calendar.MONTH) == month); if (weekday != Calendar.SUNDAY) calString.append("/n" ); return calString.toString(); } }
plugin.xml
<?xml version="1.0" encoding="UTF-8"?> id="com.eiffelqiu.tools" name="com.eiffelqiu.tools" version="1.0.0"> id="com.eiffelqiu.tools.calendar" name="Calendar" /> id="com.eiffelqiu.tools.calendar" name="Eiffel tools" category="com.eiffelqiu.tools.calendar" class="com.eiffelqiu.tools.CalendarView" />
测试用例:
package com.eiffelqiu.tools; import junit.framework.TestCase; /** * Calendar implementation * * @author Qiu Hai Feng * @version 1.0, Created on 2003-10-28 15:36:57 */ public class CalendarImpTest extends TestCase { /** * Constructor for CalendarImpTest. * @param name */ public CalendarImpTest(String name) { super(name); } public static void main(String[] args) { junit.swingui.TestRunner.run(CalendarImpTest.class); } /* * @see TestCase#setUp() */ protected void setUp() throws Exception { super.setUp(); } /* * @see TestCase#tearDown() */ protected void tearDown() throws Exception { super.tearDown(); } public void testShow() { assertTrue(!CalendarImp.show().equals(null)); assertEquals(CalendarImp.show(),CalendarImp.show()); } }
相关文章推荐
- 给eclipse 做个日历的插件
- Eclipse编辑环境下使用vim插件--viplugin
- Eclipse开发Swing, SWT, RCP的插件
- Eclipse安装git插件
- windows下eclipse perl插件epic的安装及配置
- Eclipse上GIT插件EGIT使用手册 .
- GWT eclipse 插件--googlipse
- Eclipse或者sts 中安装定位项目中文件位置的插件OpenExplorer
- eclipse 安装 swt 插件
- Eclipser安装插件后无法启动
- 关于eclipse(64位)下aptana插件安装报错问题解决
- 收集Eclipse插件安装网址
- 比较全面的Eclipse配置详解(包括智能提示设置、智能提示插件修改,修改空格自动上屏、JDK配置、各种快捷键列表……)
- Eclipse 安装最新SVN插件
- 通过Eclipse插件Bytecode Outline方便了解Java字节码
- Eclipse中Svn插件配置
- eclipse插件OpenExplorer快速打开文件目录
- maven系列--eclipse的m2插件
- 用Emma的Eclipse插件进行代码覆盖率测试
- 求eclipse 的JSEclipse插件