Thursday, September 23, 2010

Another day of "sigh"

This error/exception belongs to wrong Run Configurations in the project.:



osgi> !SESSION 2010-09-23 17:05:21.083 -----------------------------------------------
eclipse.buildId=unknown
java.version=1.6.0_20
java.vendor=Sun Microsystems Inc.
BootLoader constants: OS=win32, ARCH=x86, WS=win32, NL=en_US
Framework arguments: -product etdeltatm.rcp.ui.product
Command-line arguments: -product etdeltatm.rcp.ui.product -data C:\Documents and Settings\bkhanal\workspace/../runtime-etdeltatm.rcp.ui.product -dev file:C:/Documents and Settings/bkhanal/workspace/.metadata/.plugins/org.eclipse.pde.core/etdeltatm.rcp.ui.product/dev.properties -os win32 -ws win32 -arch x86 -consoleLog -console

!ENTRY org.eclipse.equinox.app 0 0 2010-09-23 17:05:22.614
!MESSAGE Product etdeltatm.rcp.ui.product could not be found.


!ENTRY org.eclipse.osgi 4 0 2010-09-23 17:05:22.661
!MESSAGE Application error
!STACK 1
java.lang.RuntimeException: No application id has been found.
at org.eclipse.equinox.internal.app.EclipseAppContainer.startDefaultApp(EclipseAppContainer.java:236)

My setting was set with an product mode (Program to run:) , and it thus could not start. Changing the Program to run as Run as application and setting the "plugin" tabs to the default mode solved and saved the rest of day. I thought this was worth mentioning, as it was taking almost 3-4 hours of my time and googling the problems, even though there was no problem - just a mis configurations, sighhhh indeed.

Wednesday, September 22, 2010

RCP Resources: continued...

Here I will try to keep some helpful resources for the RCP development:

  • http://obscuredclarity.blogspot.com/2008/11/eclipse-rcp-tutorial-table-of-contents.html
  • http://callocorg.wordpress.com/2010/07/12/adding-eclipse-rcp-views-declaratively-into-ifolderlayout/
  • http://wiki.eclipse.org/index.php/Rich_Client_Platform
  • http://www.eclipse.org/articles/viewArticle/ViewArticle2.html
  • http://weblogs.java.net/blog/scottschram/archive/2005/03/nasa_explores_e.html
  • http://www.eclipse.org/eclipse/platform-text/development/rcp/examples/index.html
  • http://wiki.eclipse.org/Eclipse_RCP_How-to
  • http://wiki.eclipse.org/RCP_Custom_Look_and_Feel
  • http://www.eclipse.org/articles/Article-Forms/article.html
  • http://www.eclipse.org/articles/Article-Forms/article.html
  • http://help.eclipse.org/helios/index.jsp
  • http://sourceforge.net/projects/metaleclipse/
  • http://eclipse.org/community/rcp.php
  • http://www.eclipsezone.com/eclipse/forums/t53312.html
  • http://www.eclipse.org/swt/snippets/ - nice and simple examples of the tools we need.

Tuesday, September 21, 2010

org.eclipse.swt.SWTException: Invalid threadaccess - Two days of follow up and finally its done :

This exception has been nagging up the problem with creation of JFreeChart with the RCP. The reason is that its not allowed to access the UI thread directly; you have to wrap it in something like this: (Source)



new Thread(new Runnable() {
public void run() {
while (true) {
try { Thread.sleep(1000); } catch (Exception e) { }
Display.getDefault().asyncExec(new Runnable() {
public void run() {
... do any work that updates the screen ...
}
}
}
}
}).start();



Ok, but the case is different in our case in the way that we already have actionPerformed method and the update has to be perfomed after getting the value from the database every one second or so. So, in above case, we dont need to create different thread, nor we need code for the timer. So, in our project, this will look something like this:


performDbConnection();
final long f = dataBase.returnNoOfDataset();

// this will only use the current display
try
{
Display.getDefault().asyncExec (new Runnable ()
{
public void run ()
{
series.addOrUpdate(new Millisecond(), f);
}
});
}
catch(Exception E)
{
System.out.println("Exception while updating the chart dynamically: " + e.toString() + "\n");
}


The Mashable & 92Y Social Good Summit

mashable on livestream.com. Broadcast Live Free

Friday, September 17, 2010

Another great video: ICT4D failures

This was a video from Clint released at the annual IPID conference, 2010, Barcelona --

*Top 7 Reasons Why Most ICT4D Projects FAIL*





How important it is to think about all these. I will be following these points quite obviously in upcoming discussions.

Thursday, September 16, 2010

RCP + JFreeChart: PaintListener exception

When trying to create JFreeChart in RCP, I prominently ran into this exception saying as missing PaintListener:

Could not create the view: org/eclipse/swt/events/PaintListener


Later I found out that I missed to include "org.eclipse.swt" as a dependancy in JfreeChart plug-in I created before:

Which means I somehow skipped the 3.3 in the link :

http://www.vogella.de/articles/EclipseJFreeChart/article.html

Friday, June 11, 2010

Good Lecture in Search Engine And Web Crawler

Today I was working with the web-crawl and found this interesting/useful lecture.

Sunday, June 6, 2010

many stories with many slides.

There are stories, and its name, and then their page(numbers), even creating dynamic page would me a problem if I dont arrange the stories in some order. Then 5 stories with 20-30 slides/pages each would be difficult to manage if there was proper organization and proper page inclusion.

When I went to this code:


$page = $_GET['page'];
$pages = array('page1', 'page2', 'page3');
if (!empty($page)) {
if(in_array($page,$pages)) {
$page .= '.php';
include($page);
}
else {
echo 'Page not found. Return to
index';
}
}
else {
include('page1.php');
}
?>

This way I can restrict story to the name of the charater themselves and in other case it will redirect to the main story page, perfect!!!

and also the next advice on the same page:


$url = '';
if (!empty($_GET['category'])) {
$url .= $_GET['category'] . '/';
}
if (!empty($_GET['page'])) {
$url .= $_GET['page'] . '.php';
}
include $url;
?>

will allow me to include the stories on the different folder, but without much work in the links that will show in one php file.

Source: http://inobscuro.com/tutorials/php-dynamic-includes-16/

I got an idea that I can do this for the stories -> name_of_character -> and the page number. This was very handy when I was thinking about how to put all those stories slides in form of html/images and I dont have to think about writing code for each pages. Perfect

Deleting all tables from the database...

after almost 2 hours of clogging my head and thinking about how to dump the data from the local forum that I created for the sura platform to the remote database in CS server, finally managed to create a page that will help me with this kind of situation further...


/* fill in your database name */
$database_name = "my_db";

/* connect to MySQL */
if (!$link = mysql_connect("db_host_name", "username", "pass")) {
die("Could not connect: " . mysql_error());
}

/* query all tables */
$sql = "SHOW TABLES FROM $database_name";
if($result = mysql_query($sql)){
/* add table name to array */
while($row = mysql_fetch_row($result)){
$found_tables[]=$row[0];
}
}
else{
die("Error, could not list tables. MySQL Error: " . mysql_error());
}

/* loop through and drop each table */
foreach($found_tables as $table_name){
$sql = "DROP TABLE $database_name.$table_name";
if($result = mysql_query($sql)){
echo "Success - table $table_name deleted.";
}
else{
echo "Error deleting $table_name. MySQL Error: " . mysql_error() . "";
}
}



In the local machine, the GUI can generate the sql script (along with insert commands), or from the command line can also be done as:

mysqldump -u username -ppassword --databases databasename > database_script.sql
(if no database is specified, all the databases will be dumped/copied)



Then, to restore database from backup.
 mysql -u username -ppassword databasename < database_script.sql 


And thats all, the database from my local machine got transferred to the CS SQL server.