Saturday, December 12, 2009

Installing MonoDevelop 2.2 with debug support


First of all the mono which is in fedora12 repository doesn't have a working debugger. So i had to build it my self using the latest monodevelop-2.1.2 source code. Follow the below steps and you will have a working mono develop with debugger support (I am using mono-2.4 which doesn't contain the soft debugger).


  1. Extract the monodevelop-2.1.2.tar.bz2 and run ./configure script. make sure you install the required libs and their devel packages as well.
  2. Run make.
  3. Run make install.
  4. Extract monodevelop-debugger-mdb-2.1.2.tar.bz2 (Mono Debugger support).
  5. Set the PKG_CONFIG_PATH to point the directory which contains monodevelop.pc file using the command export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
  6. Run ./configure script.
  7. Run make
  8. Run make install.
You can do the same steps 5, 6, 7, 8 if you need to install the GDB Debugger support as well.
Your done :).



Blogged with the Flock Browser

Tuesday, December 8, 2009

How to run flash-plugin version 10 with flock and firefox on Fedora

It seems most of the users have a problem running Flock and Firefox with flash-plug-in version 10. This can be avoided if you install Firefox version which is provided by fedora it self. But for flock you can't do that. So as i found in this forum it seems the following solution works on fedora for custom Firefox and Flock installations.

Delete the following files from the Firefox or Flock installation folder.
  • libfreebl3.chk
  • libfreebl3.so
Good luck :)

Saturday, June 27, 2009

Compiling Amarok2 on FC9

I am sharing my experience on compiling amarok2 on fc9. As amarok wiki (http://amarok.kde.org/wiki/Compiling:2.0) says you need to have the those dependecies and their devel packages installed in your system. Well installing mysql embedded is bit of a trouble since i couldn't find on fc9 repos. So what i did was i got it installed from fc10 update site.

[fc10-updates-newkey]
name=Fedora 10 - i386 - Updates Newkey
failovermethod=priority
#baseurl=http://download.fedoraproject.org/pub/fedora/linux/updates/10/i386.newkey/
mirrorlist=http://mirrors.fedoraproject.org/mirrorlist?repo=updates-released-f10&arch=i386
enabled=0
gpgcheck=0
gpgkey=

In addtion you will need the following 2 rpms installed in your system qtscriptbindings-0.1.0-5.fc9.i386.rpm and qtscriptgenerator-0.1.0-5.fc9.i386.rpm. You can download those from the following urls which i found from http://rpm.pbone.net/ (A great rpm search engine).

ftp://ftp.univie.ac.at/systems/linux/fedora/updates/9/i386.newkey/qtscriptbindings-0.1.0-5.fc9.i386.rpm
ftp://ftp.univie.ac.at/systems/linux/fedora/updates/9/i386.newkey/qtscriptgenerator-0.1.0-5.fc9.i386.rpm

After that compile it as described in amarok wiki.

But sad say friends, as i felt it was not worthy of the time i spent on compiling amarok2 :(. Because i didnt like the inherited KDE4 theme looks and the missing equalizer :(. Any way this might help the people who still want to install amarok2 on fc9.



Sunday, March 8, 2009

Start your HSDPA connection when linux starts.

Well in my previous post i showed you how to use a HSDPA modem in linux. But that ejecting and running wvdial was some what a trouble for me. I wanted my internet connection to be ready when i login to my system. So i wrote a startup script and a helper script to handling switching the device to modem mode and dial using wvdial. Feel free to use the following scripts at your own risk.

-------------------Contents of /bin/3gwvdial-------------------
#!/bin/bash
if [ -f /etc/3gwvdial.conf ]; then
if [ -a /dev/ttyUSB0 ]; then
echo "Modem found"
else
echo "Modem not found, switching to modem mode."
xargs eject < /etc/3gwvdial.conf
sleep 10
fi
wvdial -C /etc/wvdial.conf &>/dev/null &
echo "Connected."
else
echo "/etc/3gwvdial.conf file not found."
exit -1
fi
----------------------------------------------------------------


In the above script, you have to mention the device file of your HSDPA modem in
/etc/3gwvdial.conf file as follows

-----------------Contents of /etc/3gwvdial.conf---------------
/dev/sr3
--------------------------------------------------------------

After that make sure you give executable permission to your script. Plug your HSDPA modem (no need to eject for the first time), run the script as the super user. If nothing goes wrong you will be connected to internet. So now its time for the startup script.

-----------------Contents of /etc/init.d/hsdpa---------------
#!/bin/bash
#
# description: Controls the hsdpa connection using 3gwvdial script.
# processname: hsdpa
# chkconfig: 2345 11 89

# Source function library.
. /etc/rc.d/init.d/functions

start() {
echo -n $"Starting hsdpa: "
/bin/3gwvdial &>/dev/null &
success
echo
}

stop() {
echo -n $"Shutting down hsdpa: "
killall wvdial &>/dev/null &
success
echo
}

# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
start
RETVAL=$?
;;
status)
status wvdial
;;
*)
echo $"Usage: $0 {start|stop|restart|status}"
exit 1
esac

exit 0
-------------------------------------------------------------

Give executable permission to the above file as well. Run the following command as super user.

/sbin/chkconfig --add hsdpa

Now try to start you newly created service by following command as super user.

/sbin/service hsdpa start

You must have internet by now. If any improvements that you think for the above scripts please drop a comment.

Internet on linux with HSDPA

Well if you own a HSDPA modem most of the time your vendor will say that it doesn't support linux :( . I own a BandLuxe C120 HSDPA modem, But i didn't gave up configuring it on linux. Most of the HSDPA modems comes with driver stored inside the modem. When you plug it for first time in your PC, the modem get detected as a USB storage which is read-only. And it will start installing the necessary driver software. So after that it will switch to the modem mode and work. Unfortunately it works only for windows for most of the time. Well that's how it works in brief.

For more information you can visit http://my.opera.com/CrazyTerabyte/blog/2008/12/28/bandluxe-c120-3g-modem-from-oi-velox-plug.

So the working solution for my BandLuxe C120 was ejecting the device once it get detected for the first time. This will switch the device to modem mode. Then you will find a new USB device file some thing like /dev/ttyUSB0. That is your modem.

After that now you need to use the dialer program to dial out. For me wvdial worked. So here i will be mentioning the required modem commands to dial with wvdial.

Modem = /dev/ttyUSB0
ISDN = off
Modem Type = USB Modem
Baud = 115200
Init = ATZ
Init2 = AT+CGDCONT=1,"IP",""
Phone = *99#
Dial Command = ATM1L3DT
Ask Password = off
Password = no_need
Username = no_need
Carrier Check = on
Check Def Route = on
Abort on No Dialtone = on
Stupid Mode = on
Auto DNS = on

These settings will work for wvdial, and there are some settings you need to put in /etc/ppp/options file as well.
/dev/ttyUSB0
115200
noauth
noipdefault
nodetach
local
usepeerdns
lock

Now run the wvdial program as root. Thats it happy browsing :)

Sunday, December 28, 2008

Controlling TabIndex in Java Swing

If you have used Visual Basic then you are familiar with TabIndex property. Well some one who moved to Java world recently would think "Where can i set the tab index in Swing applications ?", well the answer is "There is no place to do it."

In Swing tabindex is determined by the layout manager. Layout manager is what layout your GUI's components inside a container such as a JFrame.

So as Swing documentation explains if u want to take control over the tab order in swing you have to implement your own FocusTraversalPolicy. Let see how to do that.

if we check the FocusTraversalPolicy abstract class, there are few abstract methods namely getComponentAfter, getComponentBefore, getFirstComponent, getLastComponent, getDefaultComponent.

We can implement the above methods in such a way that our FocusTraversalPolicy will allow us to give the tab index for our components. So our next problem will be how are we going to record the order of tab index. Well we will be using a component collection which will contains the components where the collection's element order will represent the tab index. The user has to add his/her GUI components into the above collection in the order of tab index he/she needs. The below is part of my implementation.


private class IndexedFocusTraversalPolicy extends 
  FocusTraversalPolicy {

   private ArrayList<Component> components = 
      new ArrayList<Component>();

   public void addIndexedComponent(Component component) {
        components.add(component);
   }

   @Override
   public Component getComponentAfter(Container aContainer, 
               Component aComponent) {
        int atIndex = components.indexOf(aComponent);
        int nextIndex = (atIndex + 1) % components.size();
        return components.get(nextIndex);
   }

   @Override
   public Component getComponentBefore(Container aContainer,
         Component aComponent) {
        int atIndex = components.indexOf(aComponent);
        int nextIndex = (atIndex + components.size() - 1) %
                components.size();
        return components.get(nextIndex);
   }

   @Override
   public Component getFirstComponent(Container aContainer) {
        return components.get(0);
   }
}
Usage:
Put this code inside your JFrame constructor after you have initialized the GUI components.


IndexedFocusTraversalPolicy policy = new IndexedFocusTraversalPolicy();
policy.addIndexedComponent(jTextField1);
policy.addIndexedComponent(jTextField2);
policy.addIndexedComponent(jTextField3);
policy.addIndexedComponent(jTextField4);
policy.addIndexedComponent(jTextField5);
policy.addIndexedComponent(jTextField6);
setFocusTraversalPolicy(policy);


No matter what layout you use the above GUI's tab order will be as follows.
JtextField1 → jTextField2 → jTextField3 → jTextField4 → jTextField5 → jTextField6
So now you can control your GUI components tab order. :)

Thursday, November 27, 2008

Table Model with Addnew row


Have you ever thought of having your JTable which show a add new row
like in the below screenshot ?



Well you only have to fool the JTable ;) and do some extra stuff in
your model. Below I will how to create the above table model.

In simple if we look at the JTable source we can see it uses
getRowCount
method when it draws table rows. That means
it will draw rows to match the number of rows in your model.
So the first thing you should do is to get a extra row painted
which really not in your model is to override the
getRowCount
method as below.

public final int getRowCount() {
if (dataList == null) {
return 0;
} else {
return dataList.size() + 1;
}
}

Note: dataList is the Collection what holding my data in the
model. If your extending the DefaultTableModel, then the
name dataList will be replace by dataVector variable name.

Ok now will the table will draw you a extra row ?
Nope. Because since the last row doesn't exist in my dataList
an ArrayIndexOutOfBoundsException will be thrown from the
model's getValueAt method. So next this is the method we
are going to override. What will do here is we have to take
care of the last row which is not in the dataList. To handle
that will define a method which will return default values for
each column so the TableCellRenderer can render that
value and TableCellEditor will use that value in edit mode.

public Object getColumnDefaultValue(int columnIndex) {
if (columnIndex == 0) {
return "";
} else {
return 0.0;
}
}

And the getValueAt method will be modified as below

public final Object getValueAt(int rowIndex, int columnIndex) {
if (rowIndex == dataList.size()) {
return getColumnDefaultValue(columnIndex);
} else {
return super.getValueAt(rowIndex, columnIndex);
}
}

Ok now you will see your new row in the JTable. But still you
can't edit, because the setVaueAt method will fail since there
is nothing to edit in the dataList for this new row index.
So we have to override the setValueAt method as well.
What we have to do in this is if the new row index is
edited we have to create a new row in the dataList and
pass the call back the setValueAt in the super class. Here
is the code explaining how to do that.

public final void setValueAt(Object aValue,
int rowIndex, int columnIndex) {
if (rowIndex == dataList.size()) {
dataList.add(createNewTableRow());
}
super.setValueAt(aValue, rowIndex, columnIndex);
}


In the above code you can see I have used a method
createNewTableRow. This method take care of the new
row creation. You can find the code below.

public Object[] createNewTableRow() {
return new Object[]{"", 0.0};
}

Thats all, now you have a TableModel which shows
you new row at the end.