7 Mar 2012

Add line number to your persistent XMI of DSL

I am developing a DSL using xtext. The DSL program is serialised as a XMI file. The final aim of this project is to transform the DSL program to the input of an analysis tool, and back annotate the analysis result to the DSL user. Obviously the first thing the DSL user want to see is the line number that results the analysis tool to report error. The xtext tutorial does not help a lot. After several hours working, this is my final solusion.

1. Update the Ecore model if the xtext project imports an existing Ecore model. If the Ecore model is generated, you can write a post processor, but it is suggested by xtext document that if you need to modify the Ecore model probably you need to import it rather than generate it.
In my case, I add attribute "lineNumber" to the model Statement that needs a line number.

2. Find the generated class StatementImpl.java. There should be a getLineNumber() method. Modify it to

public int getLineNumber() {
return NodeModelUtils.getNode(this).getStartLine();
}

It is possible that org.eclipse.xtext.nodemodel.util.NodeModelUtils cannot be import. Remember to add xtext plugin dependency to the plugin.xml
NodeModelUtils.getNode(EObject ob) returns the node that is directly associated with the given object by means of an EMF-Adapter.
getStartLine() simply return the line number that the syntax elements begins.

3. Change StatementImpl.eIsSet() method. Make sure when the feature ID is line number attribute, alway return true so that attribute can always be serialised.

4. Do not forget to change @generated to not generate.

Thanks to:
This helps a lot, but the api has been changed since xtext 2.0. There is no NodeUtil class. The original NodeUtil class is divided to INode and NodeModelUtils class.

2 Mar 2009

How to use Nokia E71 to receive pushing Email

Today my teacher Nuala had asked me about how to use push mail by E71 because her friend also had got one but he did not know how to set it. I had tried with my E71, and I found it is easy if you are not sensible of cost.

To receive Email in E71 you should do as follow:
  • Set up your e-mail. Always it is in the destop, reads like "set up email". Push it and choose "start e-mail setup".
  • Then type your e-mail address in the follow textbox. Please make sure that your e-mail supports POP3 protocol. For example, I type "lai****@gmail.com"
  • then type your password,and wait.
  • In your messaging menu, you can find the e-mail address you have just setted.
  • Select menu --> connect, you will download all the titles from your e-mail.
  • Then is the IMPORTANT part: as you want to enjoy a "push mail" which means you want to get your email as soon as your server had receive it, you should set your phone to receive mail automatically.
  • Push the left button, "E-mail settings -->Connection settings --> Incoming e-mail --> Access point in use --> User defined". And you will see a list of the access points. If you are using Chinamoblie service, probably you should choose "CMNET". If you cannot find CMNET, I suggest you search the web or phone the 10086 to ask help.
  • Then go to "e-mail settings --> Automatic retrieval --> E-mail notifications". You should choose "Auto-update".
OK, now you have done the settings. do not close the connection, just push the home button and minimize the e-mail window, and you can receive e-mail with no delay. I have tested my gmail accont, I have received the mail only seconds after I sent it.

Tips:
  • Whether this service is avalible depens on your e-mail service provider. You can receive e-mail form gmail in seconds, but it will costs much time if you were using QQ mail. As far as I know, gmail/hotmail/yahoo mail...all worked well.
  • The technology which E71 have is not exactly "push email". I think "push email" use a specific data access point, the service may charge money, but the data flow rate does not. But use CMNET you should pay for the data. I tested the flow rate, in one hour it costs about 30k. Ask Chinamobile to have a wap package, it will cost less than 30 RMB a month.
I hope this will help. E71 is really a good phone.

6 Feb 2009

Wine Evernote works well in ubuntu linux 8.04

I gave up Google notebook and now I am using Evernote as my note taking software. The advantage of Evernote is it has a desktop application which allows you to edit your note without Internet and then synchronize it when you get online. But as I said, they only support Windows and Mac.

Today I try to install it with wine, and it is incredible that Evernote 3.1 works very well on wine.



And the system cost is endurable, it costs 30m memory and do not cost much CPU time.


How to install and get it work?

1. Download the exe file from http://www.evernote.com/about/download/#a-macwin The latest version is 3.1
2. Open a terminal

wine Evernote_3.1.0.1034.exe

Continue the install, and then you can use Evernote3.

Problem with clipboard

There is a problem in copying/pasting words. If you copy words from a x-term application and paste it into Evernote, it won't work. But if you copy words from Evernote to a x-term application, it works.

I didn't find a really solution, but I found when you copy contents form a simple gnome application, do not use "ctrl+c" or the paste menu. Right click in where you want to paste and choose "Paste Special...(ctrl+shift+v)", then choose "paste plain text", then you pasted the contends to Evernote, even including Chinese is OK. If you choose paste HTML, nothing will happen.

My wine version: 1.1.5
My System: ubuntu 8.04 Hardy Heron

31 Jan 2009

From Google Notebook to Evernote

It is really sad that Google stopped the development of Google notebook. I am always respecting that it may have a off line version with Google gears, but the ending is they stopped it.

Evernote released a tool to help Google notebook users import their notes to Evernote. As Google Notebook is died, I have to find one instead of it. Evernote has a Monthly upload allowance -40M, but it is enough for notes taking. Evernote responses slow in China, this is a little depressed.

Evernote supports off line note taking and synchronizing. But it is strange that they only have windows and mac version for it. I go to the offical blog, many linux users are complaining about it. Some developers of Evernote are also linux fans, they said they would like to give a linux version, but the boss disagree. Really strange.

I will test is Evernote working with me well, and I will share my opinions later.

30 Jan 2009

Top 10 popular software in China which you may not know (I)

When my College English teacher Nejo started the computer in the classroom, he was confused with all the Chinese character on the desktop. He even could not play a video for us without a student's help. However, I guess even if Nejo sets the computer's language to English, he will still be confused about the software, because these software are installed in almost every Chinese computer, but foreigners may not know.

I will introduce you 10 most popular software in China. Some of them are useful out of China.

Thunder: a download software

发件人 Vincent's Blog

Thunder can download web files and it is also a bit torrent client. But the reason why it is so popular is it can search and download piratical software and movies easily. Use the website www.gougou.com you can find everything, from windows Xp to Red Alert3, newest movie or TV drama...... All videos have a Chinese subtitle, but I think it won't be a problem.

The download speed of Thunder is fast - if you consider the poor condition of Chinese Internet - it is amazing fast. Thunder uses a notorious technology, which can automatically search the same files on the web, and download it without the owner's permission.

To be legal or to get free stuff, it depends on you. In Chinese Internet many links are using Thunder's protocol - you can't download unless you use Thunder. So I think even if you don't need pirate version, you need install it in your computer if you are living in China.

For English user:

Thunder has a English version. For legal reasons, you may have problem in browsing www.gougou.com if your ip is from abroad.


ttplayer
发件人 链接用


It is a audio player. It can play almost all the audio files, mp3, wav, ape, wma, etc. It can automatically find lyric when you are on line, and there are thousands of skins you can download and change. It even has a audio converter, allows you to change the file format. I think as a small audio player it really does a good job, it fulfill every need of playing music.
For English user:

I'm afraid that it does not have a English language pack. Just don't feel shocked when you double click a mp3 file in a Chinese computer.

Storm Player
发件人 链接用

Now is the video player. Storm Player is the most popular video player in China, although I don't like it.

It was a hard time 5 years ago, you must install several video player in your system, one for one file format. Use media player to play wmv, use realplayer to play rm, use quicktime to play mov...... There are software which can play all video file, but it charges money. I think Storm player is the first free software which can play all video files. So it conquered the market.

But soon - I guess - the storm company has problems in how to gain profit. Storm player became worse, it showed advertisement, and install software in your computer without your agree. It even installed dangerous software, so I deleted it. Now they realize the decrease of users and are trying to fix it. I hope they could be better.

Overall, a video player which can cope with all file format is a require of our life, and Storm Player is one choice. I don't know why it is so popular in China, as KMP is better.

p.s. Storm player now is indicted by Real because Storm player uses DLL files form realplayer without Real's permit.
For English user:

Storm player has English language pack.

Power word
发件人 链接用

As only 13% content of Internet is written in Chinese, you will not be surprised that every computer in China has a dictionary. Google&Kingsoft Power word is a collaboration software between Google and Kingsoft, China. It is a free software, so it quickly become a pop software.

The old versions of Power word are all charging software, but you can find cracked version everywhere. At last they changed their strategy, made it free and got money from advertisement.

For English User:

I don't think a English speaker will use it. When you open a computer of a class room and find there is a small dictionary window near your mouse, just close Power word.

WPS: A substitute for MS Office




WPS is a substitute for MS Office. It is now free for personal customers. The advertisement of WPS is "look the same, and use the same". The interface of WPS is exactly the same as MS Office(but Microsoft did not sue them to plagiarize), so if you change to WPS you would not need a special train. WPS is compatible with Microsoft's file format, like doc or ppt.

WPS is a product of Kingsoft which is the most honored software company in China. Kingsoft started in the 1980s, when everyone was using DOS. WPS1.0 was a amazing
word processing software as Microsoft Word was not introduced into China. Although it is not a “what you see is what you get” software, it can do anything in word processing(Especially Chinese has more than 20'000 characters). In that time the most important skill for a computer staff was using WPS.

When Windows and Word came China, WPS was waned. It continues to develop their product but they could not compete with piratical MS Office.

For English User:

The latest version of WPS is WPS2008, it is free to download if you are personal customer. You can download it from their English website.

p.s. Wow, I writed a real long article, I will write the other 5 software later on.

29 Jan 2009

Starts Here

I am going to UK to get a master degree, so I'm trying my best to improve my English. As you see I am bad in Writing, and I know the best way for improving is practice.

In this blog I will share some interesting experience, and write my own understandings of computer techniques.

I hope I can make friends by this little blog.