给eclipse 做个日历的插件
来源:互联网 发布:八爪鱼采集器 知乎 编辑:程序博客网 时间:2024/06/11 21:34
昨天看了 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
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 做个日历的插件
- 精挑细选的10个jQuery日历插件
- 使用Tkinter做个日历
- 使用Tkinter做个日历
- 10个美观实用的 jQuery/Mootool 日历插件
- 25个有用的jQuery日历和日期选取插件
- 25个有用的jQuery日历和日期选取插件
- 8个基于jQuery和HTML5的日历时钟插件
- c#自定义日历插件,给重要日期添加色彩。以及系统自带的monthCalendar日历插件
- js做的日历
- Javascript做的日历
- ListView做的日历
- 给自己的博客做个广告
- 给自己的网站做个“toolbar”
- 给linux做个USB的钥匙
- 给ECLIPSE开发自己的插件
- 日历插件的使用
- 在.NET中实现对象序列化
- 8种人将被淘汰,你在里面吗?
- EA游戏Battlefield 2(战地风云2) 单机地图简介
- Core Java 中的一个 StaticTest 类
- VS.net2003安装两个问题及解决方案
- 给eclipse 做个日历的插件
- 解析.Net框架下的序列化机制
- struts2
- DataGrid中字符串长度的设置
- Win Forms开发时,如何合理释放验证窗体
- asp.net(C#)服务器绝对路径转换成URL相对路径[修改]
- 浪漫的道歉
- Spring中的面向对象查询
- 关于未命名空间