Using your own SQLite database in Android applications

February 28th, 2012 by ljshj No comments »

 

Most all of the Android examples and tutorials out there assume you want to create and populate your database at runtime and not to use and access an independent, preloaded database with your Android application.

The method I’m going to show you takes your own SQLite database file from the “assets” folder and copies into the system database path of your application so the SQLiteDatabase API can open and access it normally.

 

1. Preparing the SQLite database file.

Assuming you already have your sqlite database created, we need to do some modifications to it.
If you don’t have a sqlite manager I recommend you to download the opensource SQLite Database Browser available for Win/Linux/Mac.

Open your database and add a new table called “android_metadata”, you can execute the following SQL statement to do it:

CREATE TABLE "android_metadata" ("locale" TEXT DEFAULT 'en_US')

Now insert a single row with the text ‘en_US’ in the “android_metadata” table:

INSERT INTO "android_metadata" VALUES ('en_US')

Then, it is necessary to rename the primary id field of your tables to “_id” so Android will know where to bind the id field of your tables.
You can easily do this with SQLite Database Browser by pressing the edit table button Edit Table, then selecting the table you want to edit and finally selecting the field you want to rename.

After renaming the id field of all your data tables to “_id” and adding the “android_metadata” table, your database it’s ready to be used in your Android application.

Modified databaseModified database

Note: in this image we see the tables “Categories” and “Content” with the id field renamed to “_id” and the just added table “android_metadata”.

2. Copying, opening and accessing your database in your Android application.

Now just put your database file in the “assets” folder of your project and create a Database Helper class by extending the SQLiteOpenHelper class from the “android.database.sqlite” package.

Make your DataBaseHelper class look like this:

public class DataBaseHelper extends SQLiteOpenHelper{

    //The Android's default system path of your application database.
    private static String DB_PATH = "/data/data/YOUR_PACKAGE/databases/";

    private static String DB_NAME = "myDBName";

    private SQLiteDatabase myDataBase; 

    private final Context myContext;

    /**
     * Constructor
     * Takes and keeps a reference of the passed context in order to access to the application assets and resources.
     * @param context
     */
    public DataBaseHelper(Context context) {

    	super(context, DB_NAME, null, 1);
        this.myContext = context;
    }	

  /**
     * Creates a empty database on the system and rewrites it with your own database.
     * */
    public void createDataBase() throws IOException{

    	boolean dbExist = checkDataBase();

    	if(dbExist){
    		//do nothing - database already exist
    	}else{

    		//By calling this method and empty database will be created into the default system path
               //of your application so we are gonna be able to overwrite that database with our database.
        	this.getReadableDatabase();

        	try {

    			copyDataBase();

    		} catch (IOException e) {

        		throw new Error("Error copying database");

        	}
    	}

    }

    /**
     * Check if the database already exist to avoid re-copying the file each time you open the application.
     * @return true if it exists, false if it doesn't
     */
    private boolean checkDataBase(){

    	SQLiteDatabase checkDB = null;

    	try{
    		String myPath = DB_PATH + DB_NAME;
    		checkDB = SQLiteDatabase.openDatabase(myPath, null, SQLiteDatabase.OPEN_READONLY);

    	}catch(SQLiteException e){

    		//database does't exist yet.

    	}

    	if(checkDB != null){

    		checkDB.close();

    	}

    	return checkDB != null ? true : false;
    }

    /**
     * Copies your database from your local assets-folder to the just created empty database in the
     * system folder, from where it can be accessed and handled.
     * This is done by transfering bytestream.
     * */
    private void copyDataBase() throws IOException{

    	//Open your local db as the input stream
    	InputStream myInput = myContext.getAssets().open(DB_NAME);

    	// Path to the just created empty db
    	String outFileName = DB_PATH + DB_NAME;

    	//Open the empty db as the output stream
    	OutputStream myOutput = new FileOutputStream(outFileName);

    	//transfer bytes from the inputfile to the outputfile
    	byte[] buffer = new byte[1024];
    	int length;
    	while ((length = myInput.read(buffer))>0){
    		myOutput.write(buffer, 0, length);
    	}

    	//Close the streams
    	myOutput.flush();
    	myOutput.close();
    	myInput.close();

    }

    public void openDataBase() throws SQLException{

    	//Open the database
        String myPath = DB_PATH + DB_NAME;
    	myDataBase = SQLiteDatabase.openDatabase(myPath, null, SQLiteDatabase.OPEN_READONLY);

    }

    @Override
	public synchronized void close() {

    	    if(myDataBase != null)
    		    myDataBase.close();

    	    super.close();

	}

	@Override
	public void onCreate(SQLiteDatabase db) {

	}

	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {

	}

        // Add your public helper methods to access and get content from the database.
       // You could return cursors by doing "return myDataBase.query(....)" so it'd be easy
       // to you to create adapters for your views.

}

That’s it.
Now you can create a new instance of this DataBaseHelper class and call the createDataBase() and openDataBase() methods. Remember to change the “YOUR_PACKAGE” to your application package namespace (i.e: com.examplename.myapp) in the DB_PATH string.

       ...

        DataBaseHelper myDbHelper = new DataBaseHelper();
        myDbHelper = new DataBaseHelper(this);

        try {

        	myDbHelper.createDataBase();

 	} catch (IOException ioe) {

 		throw new Error("Unable to create database");

 	}

 	try {

 		myDbHelper.openDataBase();

 	}catch(SQLException sqle){

 		throw sqle;

 	}

        ...

 

没 NFC?没问题!带 NFC 发射器的 micro SD 卡

September 20th, 2011 by ljshj No comments »

可能你觉得 Google Wallet 是一个很不错的东西,不过自己却没有支持 NFC 的手机(比如说 Nexus S),不过现在好了!Netcom 的公司展示了带有 NFC 发射器的 micro SD 卡,毫无疑问,只要将该 micro SD 卡插入到手机中就可以享用 NFC 功能了。

那么它是如何工作的呢?只要将这个 micro SD 卡插入到你的非 NFC 设备即可!使用一个预装的应用就可以让你的手机与 SD 卡进行数据交换。不过这个 NFC micro SD 卡并非在所有具有 micro SD 卡插槽的设备上都能工作,它在外面覆盖金属的 micro SD 卡插槽中就不行,比如三星 Vibrant 上就不行(金属屏蔽效应,你懂的),不过如果是在硬质塑料的设备上(比如 Evo 上)就可以。后面有一个演示视频。

由于发射器非常小,所以可以找到一个“最佳角度”,这样你在使用时才会省心一点,稍微有点点不给力,所以等到上市时想要购买这种卡的话最好先好好测试一下,要不然用的时候找不到信号就只有干瞪眼了…

继续观看视频:

 

iOS设备观看地址原始视频地址

Google Walle 手机钱包

September 20th, 2011 by ljshj No comments »

北京时间9月20日消息,据国外媒体报道,谷歌今天正式发布了基于近距离无线通信(NFC)的移动支付服务谷歌钱包(Google Wallet)。这项服务的合作伙伴包括花旗银行、MasterCard、Verifone、First Data和Sprint。目前谷歌钱包仅支持在Sprint的Nexus S手机上使用,所使用的信用卡也仅限于花旗的MasterCard。不过谷歌已经向Visa、Discover和美国运通授权了NFC规格,未来它还将支持更多的信用卡。

 

什么是谷歌钱包?

科技博客this is my next编辑在纽约试用了谷歌钱包,以下是评测报告。

  谷歌钱包是手机上的一款应用,在PIN码保护下可以连接兼容的信用卡、借记卡、预付费卡、客户忠诚卡和礼品卡。用户只要将手机在MasterCard PayPass上轻轻一挥,支付就可以完成。它是通过手机中的NFC芯片将支付信息传输到收款设备上。

目前MasterCard PayPass设备已经遍及上万个商家,因此找到支持谷歌钱包的商铺应该不是什么问题。现在数据传输只能从手机到收款设备,是单向的,未来还将支持双向传输,比如回传电子发票等。

  目前谷歌钱包应用只支持运营商Sprint独家发售的三星Nexus S 4G智能手机。即使其他版本的Nexus S拥有相同的NFC芯片,技术上满足各项要求,目前还是无法使用谷歌钱包。谷歌已经决定在第一阶段只和Sprint合作。谷歌已经明确提出,要扩大谷歌钱包和硬件支持的深度和广度,但在推出初期,只支持Sprint的Nexus S 4G手机。谷歌没有说明Sprint在其中扮演的角色,显然它不会介入支付过程。据推测Sprint会在智能手机上帮助谷歌进行一些相应的推广活动,但为什么目前仅支持Sprint旗下的Nexus S 4G手机,从技术和后勤角度均找不出令人信服的理由。

谷歌钱包成功所面临的最大障碍就是每次交易过程中,都有一大帮其他公司介入,从零售商到信用卡发卡组织。最后唯一支持的信用卡只有花旗银行发行的MasterCard,但谷歌也找到了应对办法:谷歌钱包内置了预付费卡,用户可以用其他卡向它充值,从而使谷歌钱包在发行初期就拥有更大的用户群。

谷歌钱包的工作流程

用户如果拥有相应的花旗银行MasterCard,并支持PayPass,只要在手机中输入卡号、过期日期、持卡人姓名等与手机绑定。谷歌钱包中的预付费卡则支持绑定任何借记卡。礼品卡部分目前谷歌钱包只支持American Eagle Outfitters(美洲鹰奥菲特),它还需要用户拥有卡号和相关激活码。

设置好卡以后,支付就变得非常简单,只要拿起手机在商店信用卡读卡器的PayPass区域轻轻一挥即可。如果距离上次输入4位PIN码太久,用户会被要求重新输入,然后重新挥动手机完成付款。谷歌钱包的速度令人印象深刻,比使用传统塑料卡片的速度要快得多。

  虽然支持所有拥有PayPass设备的商家,但谷歌只在纽约和旧金山发布了钱包产品。原因之一就是营销策略,谷歌与合作伙伴可以在这些市场进行集中投资,激发公众的使用兴趣。此外,这两座城市的用户会看到更多的谷歌Offers优惠项目。Offer同时提供Groupon风格的团购项目和更为传统的优惠券。一些优惠措施会在用户进行搜索时显示出来,用户只要点击就能自动将优惠传送至自己的钱包账户。梅西百货是此次谷歌钱包的零售商合作伙伴之一,这意味着用户的体验将是全程的:他们可以直接在钱包中支付或传送相应的Offers优惠项目。

  在每个人看来,安全显然是个大问题,谷歌也意识到了这一点。在最基本层面上,如果手机黑屏,NFC芯片也将关闭,这意味着用户将手机放在口袋中或拿在手上走过读卡器,也不会传输或接收到任何数据。此外,有一枚加密芯片控制访问手机卡上的数据,这就是谷歌的“安全元素”,任何应用无法直接与之联系。任何通信只能通过加密芯片中转。谷歌对此非常自豪,认为这在移动支付服务上是史无前例的。换句话说,流氓应用想要未经用户许可就读取财务数据是不可能的。

结论

对于谷歌来说,“软发行”一项服务是它的行事策略,为的是着眼于未来的潜力和持续的更新。就如同谷歌的很多其他应用一样,发行很久了但仍挂着“测试版”(Beta)的标签。要了解钱包产品的运作方式就要了解谷歌自己的运作方式。谷歌钱包投放市场时并不是一款完整的工具,虽然它已经拥有大量名头很响的合作伙伴,但要让它变得无处不在还有很多工作要做。目前的谷歌钱包的效率和安全减轻了外界的许多担忧。但谷歌还需要有更多零售商、银行参与,当然还需要更多搭载NFC芯片的兼容手机。它可以先从整个Nexus S产品线开始,而不是像现在这样,仅仅支持Sprint 4G版本。(柯山)

SMIL 1.0 players, SMIL 2.0 players capable of SMIL 1.0

March 21st, 2011 by ljshj No comments »

Ambulant 1.4
SMIL 2.1 CR

SMIL查看软件

DigitHoles

October 3rd, 2010 by ljshj No comments »
Java:
public class DigitHoles {
	public int numHoles(int number) {
		int[]a=new int[]{1,0,0,0,1,0,1,0,2,1};
		int result = 0;
		for(;number>0;number/=10){
			result += a[number%10];
		}
		return result;
	}
}

C++:
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <iostream>

using namespace std;

class DigitHoles {
public:
 int numHoles(int number);
};

int DigitHoles::numHoles(int number) {
 char str[10];
 sprintf(str, "%d",number); 

 int ret = 0; 

 for ( int i = 0; i < 10; i++) { 
 if ( str[i] == '0' || str[i] == '4' || str[i] == '6' || str[i] == '9') { 
 ret += 1; 
 } else if ( str[i] == '8') { 
 ret += 2; 
 } 
 } 
 return ret; 
}

全球15个顶级技术类博客

May 8th, 2010 by ljshj No comments »

1) 生活骇客(Lifehacker)

http://www.lifehacker.com

生活骇客(Lifehacker)的座右铭表达了它的全部理念:“不要为技术而生活,要为生活而关注技术!”这个博客提供了有关于各方各面的“时间节省”小贴士,从Firefox网络浏览器的快捷操作,到来自“时间管理教”忠实信徒的谆谆教诲。

2) IT工具箱博客(IT Toolbox Blogs)

http://blogs.ittoolbox.com

IT工具箱博客(IT Toolbox Blogs)有着一大群“战斗在第一线”的IT专家们讨论有关于技术和IT管理的话题。它拥有一系列专业性的博客在处理跟IT安全、数据库、项目管理和其它等等相关的问题。这是一个包罗万象的网站。

3) 硅谷闲话(Valleywag)

http://valleywag.com

“众口铄金,积毁销骨”。硅谷闲话(Valleywag)是专门为那些相信“在技术行业中的生死在很大程度上都取决于硅谷周围所传播的闲话”的人准备的。对于那些热衷于制造、听闻和传播硅谷谣言的那些人来说,这个网站凭借着其卓越的“专业素养”而让人大为惊叹。

4) Kotaku

http://kotaku.com

Kotaku是电脑游戏爱好者的“加油站”。它拥有跟电脑游戏有关的一切,从对游戏的测评,到相关的讨论和扯淡,再到作弊技巧。这里有你所需要的一切,比如某款游戏到哪里去购买,以及怎样进行玩耍。

5) 威胁空间(Danger Room)

http://blog.wired.com/defense

《连线(Wired)》杂志所推出的军事和防卫博客网站,它向读者介绍了这个世界上最新、最酷、最令人震撼的军事技术——更不用提那些丑闻、争论和其它类型的军事新闻。网站中还提供了许多视频和图片。

6) 小发明(Gizmodo)

http://gizmodo.com

小发明(Gizmodo)网站专门为读者挖掘全世界最新、最酷、或是最稀奇古怪的技术发明——从高清晰电视、到咖啡机、到弹力腰带,再到USB驱动器。是的,他们同样也发布那些严肃的技术性新闻。

7 )  O’Reilly 雷达(O’Reilly Radar)

http://radar.oreilly.com

这是你能够阅读到Tim O’Reilly(著名的O’Reilly出版公司的创始人)和其它人讨论有关于网络、编程、开放源代码运动、知识产权、政策、Web 2.0和其它前沿科技的地方。

8 )  技术丑闻(Techdirt)

http://www.techdirt.com

技术丑闻(Techdirt)是一个话题中心,以在当前的互联网和电脑领域的热门事件上引发激烈争论而闻名。流言蜚语是它的所爱!简洁是它的特点!

9) Groklaw

http://www.groklaw.net

Groklaw网站的原本存在目的是支持SCO公司对IBM和Novell公司所发起的漫长的专利侵权诉讼,但是不知道什么时候,这里的讨论转向了其它方面,话题包括了技术、知识产权以及政府法规。

10) 改造一整天(Hack a Day)

http://www.hackaday.com

想要学习怎样为一个廉价的Linux路由器添加一个USB设备吗?想要制作一个蛇形机器人吗?或是将自己的XBox 360游戏机改造成一台笔记本?“改造一整天(Hack a Day)”上提供了这些地下室项目,以及其它更多有趣的项目。这个网站是为那些真正有一定技术素养,喜欢自己动手改造技术产品的玩家所准备的。但与此同时,你也可以在这里发现很多乐趣,说不定还会从中开发出一项新的爱好。

11)小玩意儿(Engadget)

http://www.engadget.com

就像可口可乐和百事可乐的关系一样,小玩意儿(Engadget)和小发明(Gizmodo)就像是一对孪生兄弟。它也是专注于技术产品相关的介绍、评论,有时候也会有充满激情的演讲和辩论。小玩意儿(Engadget)上充满了摄制精美的产品图片,而它网站的编辑们还有着广泛的内部渠道,可以在新潮的技术产品还处于先期或早期发布阶段,就可以一睹它们的芳容。同样的,小玩意儿(Engadget)上面也会刊登一些真正非常有趣的手工制作的玩意儿。但是,我们更喜欢小发明(Gizmodo)一点。

12) Feedster

www.feedster.com/feedpapers/Technology

一切都是那么的水到渠成。这个网站汇集了各种各样的博客站点,包括技术类、体育类、名人八卦、美食、个人体验等等等等——只要你能想到的,它都拥有。同时,它还提高了卓越的站内搜索功能,以及一个非常酷的RSS新闻阅读软件。它在技术新闻里面加入了非常出色的幽默感。这真是一个各方面都很优秀的网站。

13) 永远的骇客(Forever Geek)

http://forevergeek.com

永远的骇客(Forever Geek)是一个非常棒的网站,它有无数的博客文章,覆盖了多种多样的话题,从技术,到大众新闻,到好莱坞电影,再到电脑游戏测评。这绝对是一个骇客的天堂。假如你想要了解即将上映的好莱坞巨片《变形金刚》的最新消息,或是阅读一篇有关于Photoshop CS3软件的测评,这就是你应该去的地方。

14)粗鲁的文字(Rough Type)

www.roughtype.com

Nick Carr(笔名“Does IT Matter?”)撰写的一个思想锐利的博客,专门讨论与技术相关的各种各样的话题和趋势。他的文章文笔优美,让人阅读起来津津有味,但是同时也会常常激烈那些被批评的公司、人物、技术和政策。

15) 自助餐(Smorgasbord)

www.smorgasbord.net

作为一个为那些喜爱数码产品和电脑游戏的骇客们所专门打造的站点,这个网站同样也提供最新的有关于政治和名人的新闻。这种娱乐价值和技术新闻的战略组合,让自助餐(Smorgasbord)跻身于最优秀者的行列。

荣誉提名:

1) 苹果(Apple)非官方博客 (TUAW)

www.tuaw.com

TUAW集结了许多独立的博客——这些独立的博客虽然和苹果公司官方没有正式的关系,但是这并不意味着他们的信息不充分、意见没有影响力。这是一个了解苹果公司相关新闻的最好来源。它没有跻身前15名的唯一原因是它太过于专注于一个单一话题。

2) Elliot Back 的博客(Elliot Back’s blog)

http://elliottback.com/wp

作为自封的“计算机科学家”,Elliot对于每一件自己所关注的事情大放厥词,从为什么XML标准很糟,到泰坦尼克号的旅客名单,再到对好莱坞巨片《斯巴达300勇士》的影评。这个网站的内容多种多样,但是安排巧妙。此外,他还会提供一些非常棒的小贴士,比如如何增进系统的性能,以及屏蔽垃圾邮件。

3) Ed Foster 的牢骚录(Ed Foster’s Gripelog)

www.gripe2ed.com/scoop

时下有一类新的博客网站涌现了出来,它们专门抨击和曝光那些侵害消费者权益的公司和产品,诸如数码产品恶劣的售后服务、粗糙的产品外观或是其他诸如此类的一些问题,但是Ed Foster可谓是这一行的开山鼻祖。看看他最新所关注的一些话题:有缺陷的DRM系统、plasma品牌电视机的质保陷阱,以及糟糕的移动电话服务质量。

4) Gadgetell

www.gadgetell.com

假如你想要了解最新的数码产品、电玩游戏新闻,以及其他相关的一些消息,这是一个很棒的网站。

5) 4sysops

http://4sysops.com

它为Windows系统的管理员们提供了非常优秀的小提示和操作教程。

30 Useful Web-Based Applications for Designers

April 28th, 2010 by ljshj No comments »

A web application is an application that is accessed via a web browser over a network. They may also mean a computer software application that is hosted in a browser-controlled environment or coded in a browser-supported language (such as JavaScript, combined with a browser-rendered markup language like HTML) and reliant on a common web browser to render the application executable.

With the help of these free web-based online applications you can make your work even easier than before.

Web based applications are good alternatives to costly software for sure. Instead of buying costly software , you can make use of these online tools to do your design and development work.

Nothing can be more useful than handy tools you can use in your design process. Whether you’d like diagramming application, photo editing, format or optimize CSS code, generate patterns- you can use dozens of tools to make your life easier.

These Useful web based applications for every designers can to help you accomplish tasks such as color palette selection, creating unique fonts, editing images, and testing typography. You are welcome to share your favorite tools if you know about any free web based application which our readers may like.

Color palette

Essential color scheme palette where you select the RGB values and get a set of color schemes for your website designs.

Colorschemedesigner

A brand new interface, as well as the engine, all rewritten from the scratch. Rapidly increased precision and color space conversions, better preview, enhanced scheme creation system, unique scheme IDs and permanent URL of the scheme.

Colorspire

Choose the right clors for your website layout designs this is the best and useful tool.

Adobe Kuler

Where you can browse and create color themes. The web-hosted application for generating color themes that can inspire all projects. No matter what you’re creating, with Kuler you can experiment quickly with color variations and browse thousands of themes from the Kuler community.

Colorjack

ColorJack is an online Color Scheme Generator used by Graphic Designers, Interior Decorators, and many other people from around the world.

Dailycolorscheme(beta)

Dailycolorscheme for your daily color resource. You can select a new scheme every day and with lots of schemes in the archive.

Colortoy

ColorToy 2.0 is a Flash based color scheme generator and picker. It generates complementary color schemes based on your inputted color values or randomly.

CSS

Useful tools for CSS related.Using these tools web designers can rule the website communities.

Inline CSS(Mailchimp)

An email campaign, you know that if your CSS is not coded inline, it is likely to get stripped out by email clients, which can make your email design pretty funky looking. Writing CSS inline can be time consuming, and repetitive. MailChimp has a CSS inline conversion tool built right in that will automatically transform all of your local styles into inline styles. Designers have found it so useful, we thought we’d share it with everyone else – even if you don’t have a MailChimp account.

Csstxt

A CSS style generator with text

Codebeautifier

An online CSS Formatter and Optimiser.It has many compression types too for code layout.

Menu

Izzymenu

Create professional looking CSS menus for your Website as easy as never before.Build your cool menu online, without writing a single line of code.It’s easy to use, Online Menu Builder, which allows you to build your CSS & DHTML menu in minutes.Choose from dozens ready styles or create your own menu style. IzzyMenu, online menu generator is the best solution for amateurs and professionals

Typography

Typography is a main aspect of a design.It creates the mood and solicits emotion about the design. Working with typography can be challenging, but fortunately, there is a plethora of free tools on the web that can help you work with type.

Csstypeset

CSS Type Set is a hands-on typography tool allowing designers and developers to interactively test and learn how to style their web content.

Typechart

TYPECHART lets you flip through, preview and compare web typography while retrieving the CSS.

Fontstruct

FontStruct is a free font-building tool brought to you by the world’s leading retailer of digital type, FontShop.Lets you quickly and easily create fonts constructed out of geometrical shapes, which are arranged in a grid pattern, like tiles or bricks.

Typetester

Typetester is an online application for comparison of the fonts for the screen. Its primary role is to make web designer’s life easier. As the new fonts are bundled into operating systems, the list of the common fonts will be updated.

Dummy text generators

Dummy text or sample text is very important for web and application developers. They use dummy text and figures as test data as they concetrate on design and other important aspects of projects.

Blindtextgenerator

This handy tool helps you create dummy text for all your layout needs.

Adhesiontext

A text tool that generates dummy text, with a limited set of characters, for English, French, German, Spanish, Portuguese, Catalan, Russian and Greek.

Background patterns

Bgpatterns

Web based tiled backgrounds designer, create any pattern your site needs just for few minutes. Adjustable size, pictures, colors, texture and transparency.

Patterncooler

A free seamless pattern background resource for designers.You can add your own colors to contemporary and retro pattern designs, or browse from thousands of pre-colored patterns from their archive.

Tartanmaker

Tartan Maker – the new trendsetting application for cool designers. a free tool for the webdesign community.

Other tools

Some more common tools for designers like strpe generators,Fav icon generators,Ajax Loaders etc.

Dabbleboard

Dabbleboard is an online collaboration application that’s centered around the whiteboard. With a new type of drawing interface that’s actually easy and fun to use, Dabbleboard gets out of your way and just lets you draw.

Aviary

Aviary is on a mission to make creation accessible to artists of all genres, from graphic design to audio editing.

Stripe generator

Stripemania

Stripemania is a simple and free web 2.0 tool to create seamless diagonal stripes for your designs. You are able to choose the size of the stripes and the spacing between those. You can even add color gradient effect for all of your stripes.

Freshgenerator

FreshGenerator is a webdesign tool which can create interesting graphic elements used in many web 2.0 sites. You may use it to create boxes of different styles and colors.

Cacoo

Cacoo is a user friendly online drawing tool that allows you to create a variety of diagrams such as site maps, wire frames, UML and network charts.Cacoo can be used free of charge.

Gridsystemgenerator

The grid system generator will create custom grid systems in valid css / xhtml for rapid prototyping, development and production environments.

Favicon

Favicon.cc is a tool to create or download favicon.ico icons, that get displayed in the address bar of every browser.

Genfavicon

Preloaders

Free animated loading gif preloaders generator for AJAX loading.

Splashup

Splashup is the only full-featured, free range, image editor online. Create new images, edit existing images and manipulate layers with filters.

jQuery 表格工具集

April 23rd, 2010 by ljshj 1 comment »

本文搜集了大量 jQuery 表格插件,帮助 Web 设计者更好地驾御 HTML 表格,你可以对表格进行横向和竖向排序,设置固定表头,对表格进行搜索,对大表格进行分页,对表格进行滚动,拖放操作等等。这些插件很多都包含详细的教程。

jQuery 表格插件
Flexigrid – Web 2.0 Javscript Grid for jQuery – 可变列宽,自动适应表头宽度,可通过 Ajax 连接 XML 数据源,类似 Ext Grid,但基于 jQuery 因此更轻量小巧。

Chromatable JQuery Plugin – 固定表头,可滚动内容区,内容区滚动的时候表头位置保持不变。

Ingrid, the jQuery Datagrid – 在 HTML 表格上加入列宽调整,分页,排序,行列式样等功能(演示)。

JQTreeTable – 在表格中加入树形结构

Scrollable HTML table – 将普通 HTML 表格变为可滚动状态。将表头部分放入 THEAD 区,内容部分放入 TBODY 区,脚注部分放入 TFOOT 区域,引用 webtoolkit.scrollabletable.js 文件,然后在每个表格后面创建 ScrollableTable() 对象即可(演示)。

KeyTable – 象 Excel 那样,在单元格之间巡游,可以现场编辑。

graphTable – 借助 flot 将 HTML 表格中的内容变成图形(演示)。

DataTables – 非常强大的 jQuery 表格插件,可变宽页码浏览,现场过滤。多列排序,自动探测数据类型,智能列宽,可从几乎任何数据源获取数据。

jqGrid Plugin – 基于 Ajax 的 jQuery 表格插件,可以 Ajax 方式从服务器端获取数据填充进来(演示)。

Visualize: Accessible Charts & Graphs from Table Elements – 从 HTML 表格收集数据,并借助 HTML5 Canvas 对象转换为图表。

Grider – 一个简单的 jQuery 插件,可以对 HTML 表格进行计算,平均,累加,最大值,最小值等。


表格功能增强
Table Drag and Drop – 通过拖放,对表格中的数据重新排列,可以设置禁止拖放的行。

Table Pagination – 在表格下方自动生成分页导航。

tableRowCheckboxToggle – 可根据 class name 对表格的行自动 check on/off

BS Table Crosshair Plugin – 鼠标在表格上移动时,所经过的单元格自动交叉加亮

jqtable2csv – 将 HTML 表格转换为 SVG 字符串。

Colorize – 自动对表格间隔行使用不同背景颜色

jExpand – 一个非常轻量的 jQuery 插件,可以展开/关闭表格单元格,使表格可以容纳更多内容。

columnHover – 鼠标经过时,可以整列加亮,甚至支持 colspans 和 rowspans

HeatColor – 根据规则,或自动对表格中的值进行分析,对不同范围的值按不同颜色区分。

Fixed Header Table – 固定表头可滚动表格


表格搜索,筛选
tableFilter – 给表格添加简单的筛选功能。

uiTableFilter – 根据条件筛选(隐藏)表格行

Tablesorter 2.0 – 将普通的,拥有 THEAD 和 TBODY 标签的表格转换为可排序表格,可以分析多种数据,支持多列排序。

PicNet Table Filter – 实时的,Google 式筛选功能

jQuery tinysort – 排序

LiveFilter 1.1 – 非常轻量的表格筛选插件,部署非常简单。

jQtablesearch – 快速搜索,非常快

Quicksearch – 简单的搜索功能
jQuery 现场编辑
TableEditor – Flexible in place editing of TableSorter – 现场编辑表格内容,用户可以插入 Ajax 机制回存数据

jGridEditor – 现场编辑,可配置 Ajax 回存数据

[eclipse]How to Create a New Project Wizard

April 22nd, 2010 by ljshj No comments »
To create a basic new project (i.e. the user can't create a java project or
plug-in project. The project defaults to a Simple project), use the
following code.

newProjectPage_ = new BasicNewProjectResourceWizard();

newProjectPage_.init(CmvcUiPlugin.getDefault().getWorkbench(), null);

WizardDialog dialog = new WizardDialog(shell_, newProjectPage_);

dialog.open();

// Returns null if a new project is not created

return newProjectPage_.getNewProject();

To create a java project / plug-in project, u need to do more work. U need
to add a listener for new project and remove the listener when after u have
finished processing. (I think this is the only way u could get information
about the new project created). CVS uses the following mechanism to create a
new project wizard. The following example returns the name of the new
project created

/**

* Create a new Project through a Wizard

*

* @return the newly created project

*/

private IProject displayNewProjectWizard() {

NewProjectListener newProjectListener = new NewProjectListener();

// Adding a Listener to listen for post change events

ResourcesPlugin.getWorkspace().addResourceChangeListener(

newProjectListener,

IResourceChangeEvent.POST_CHANGE);

NewProjectAction newProjectAction =

new NewProjectAction(

PlatformUI.getWorkbench().getActiveWorkbenchWindow());

newProjectAction.run();

ResourcesPlugin.getWorkspace().removeResourceChangeListener(

newProjectListener);

return newProjectListener.getNewProjectCreated();

}

/**

* A Project Creation Listener

*/

class NewProjectListener implements IResourceChangeListener {

// The Project that will be created

private IProject newProject_ = null;

/**

* @see
IResourceChangeListener#resourceChanged(org.eclipse.core.resources.IResource
ChangeEvent)

*/

public void resourceChanged(IResourceChangeEvent event) {

IResourceDelta root = event.getDelta();

// Get all the affected Children. One of them would be the newly

// created project

IResourceDelta[] projectDeltas = root.getAffectedChildren();

for (int i = 0; i < projectDeltas.length; i++) {

// Get individual delta's

IResourceDelta delta = projectDeltas[i];

IResource resource = delta.getResource();

if (delta.getKind() == IResourceDelta.ADDED) {

// The New Project that has been created via the New Project Wizard

newProject_ = (IProject) resource;

}

}

}

/**

* Get the new Project Created

*/

public IProject getNewProjectCreated() {

return newProject_;

}

}

Best jQuery plugins for working with Forms

April 21st, 2010 by ljshj No comments »
Form Validator with several features such as grouping required fields or conditional checking if it is valid or not. Also you can validate string, numeric, date or e-mail. And you can combine several validations. For example: required numeric input and minimum 5 chars long.

jQuery Live Form Validation

jQuery plugin which helps create easy form validations with high flexibility and a large set of options.

jquery.validate

This jQuery plugin takes the boring, repetitive work out of input validation. You need specify only what valid input is, and the plugin takes care of the rest.

Salid – The Simple jQuery Validator

Salid provides simple form validation in the fewest lines possible.

Just another jQuery validation plugin

This is just another jQuery validation plugin with several interesting features.

Fvalidate

A Web 2.0 HTML form validation plugin.

Live Form Validation – jQuery Accessible RIA

jQuery Accessible RIA, a collection of strictly WAI WCAG 2.0 and WAI ARIA conform web applications based on the popular Java-Script framework jQuery (using the UI Widget Factory). This one extends a standard HTML form. A live-validation, a validation while typing, checks every field with a configurable regular expression. You could set your own reg-ex or use one of the predefined patterns.

a-tools

Cross-browser text selection and modification plugin built on top of the jQuery library.

jQuery Doubleselect Plugin

Fill in a second select box dependent on the first one.

After the Deadline – Spell and Grammar Checker for Web Applications

After the Deadline is an open source proofreading service that checks spelling, misused words, style, and grammar in web applications.

AJAX Terminal

jQuery plugin to create a web-based console-like behavior that posts user input commands to an AJAX server, and prints the result text.

ajaxContactForm to simplify te sending of a inquiryform.

jquery.ajaxContactForm is a plugin made to simplify te sending of a inquiryform. The plugin gathers all the filled out data, after testing it on: required values, required numberical values and/or required e-mail structure. After that it sends the form via AJAX.

akeditables

This plugin is based on jEditable, and provides a way to create editable area on clicking links etc. It provides save and cancel button instead of ENTER key to save the content.

akModal: simplest alternative to thickbox

akModal is the simplest way to achieve the modal dialog box or pop up box for simple purposes like showing signin box etc.

asmSelect – Alternative Select Multiple

A progressive enhancement to select multiple form elements.

autoclear

Easily set default/helper values in text fields using this plugin.

Autocomplete

Autocomplete an input field to enable users quickly finding and selecting some value, leveraging searching and filtering.

autoNumeric

A flexible International numeric formatting, that will automatically place a thousand separator as you type.

bestUpper

BestUpper is change chars to uppercase when is typing.

Checkbox ShiftClick

ShiftClick allows you to select multiple checkboxes by clicking to set an ‘anchor’ and shift-clicking to select or deselect all of the checkboxes in between.

Clearable Text Field

Clearable Text Field is a jQuery plugin which shows up a cross icon to clear value when user input something in a form field. It works like a find form of your browser: the clear button shows up when you enter any characters in it and disappears when you clear the form.

ClockPick, a Time Picker

ClockPick is a timepicker plugin, enabling users to enter a time value into a form field. Using a unique popup div UI, ClockPick gets the job done in about 1/5 the time it takes to enter a time value using a traditional select menu UI.

Collapsible Fieldsets

For those of you that use Drupal, this is a jQuery plugin that mimics the fieldsets you find there. You can initialize the fieldsets to start either in an opened or closed format, and degrades gracefully.

ComboSelect

Transforms a single select element into a pair of multi-selects with controls to move items left to right and vice versa. Keeps items sorted alphabetically in both lists (if desired). Selected items are submitted by the original form element. Double-clicking moves an item from one side to the other.

Custom HTML form Selectbox

Replaces the standard HTML form selectbox with a custom looking selectbox. Allows for disable, multiselect, scrolling, and very customizable.

Custom Maxlength

This plugin makes it easy to apply a “maxlength” attribute to custom elements for example a textarea.

Form suggestion and validation box in “Twitter style”

This plugins reproduces the same suggestion box style that you can see on Twitter signup page. The usage is pretty simple. It shows a “tip” text when the input field is focused and a feedback when the validation passes or fails.

In-field Input Label

The inputLabel jQuery plugin uses a passed in string or a reference form label text to insert a “placeholder” text inside a form input field.

jListBox

jListbox is a jQuery plugin to obtain a formatted select box.

JQF1 JQuery FormOne Form styling

The most complete form style plugin.

Multiple Select Info

jQuery Multi Select Info is More information for multiple select, so we know which one is selected