GWT-Ext Store instances are all over my code. And I am populating them by various means. While migrating from GWT-Ext to SmartGWT, converting Stores to DataSources will probably take up a lot of time. I was wondering if I could migrate and test only the grids first and deal with the stores later. Code below could help do just that. It creates a DataSource from a Store. You can use this data source to populate SmartGWT grids and when the grids are working fine, replace the stores completely. Isn’t exactly a life saver but nevertheless. Have tested it only on a trivial store.
It doesn’t matter but assume that the RecordDef used to create the Store looks like this:
RecordDef recordDef = new RecordDef(new FieldDef[] {
new StringFieldDef("company"),
new FloatFieldDef("price"),
new FloatFieldDef("change"),
new FloatFieldDef("pctChange"),
new DateFieldDef("lastChanged", "n/j h:ia"),
new StringFieldDef("symbol"),
new StringFieldDef("industry")
});
Create a DataSource with the same fields:
private DataSource createDataSource(Store store){
DataSource dataSource = new DataSource();
dataSource.setClientOnly(true);
String[] fields = store.getFields();
for(String field:fields) {
DataSourceField smartgwtField = new DataSourceField();
smartgwtField.setName(field);
dataSource.addField(smartgwtField);
}
return dataSource;
}
Add a method that copies records from the Store to the data source created above and call it in the Store’s onLoad handler
public void copyStore(Store store, DataSource dataSource) {
Record[] records = store.getRecords();
String[] fields = store.getFields();
for(Record gwtextRecord:records) {
ListGridRecord smartgwtRecord = new ListGridRecord();
for(String field:fields) {
smartgwtRecord.setAttribute(field, gwtextRecord.getAsString(field));
}
dataSource.addData(smartgwtRecord);
}
}
For heavy stores, this code will probably punish the browser and column data types are ignored as well but it is meant only for the dev environment until all components have been replaced eventually.
PS: If you need it, here is a small sample with GWT-Ext and SmartGWT grids being populated from the same RPC method. You will need to add gwtext.jar and smartgwt.jar and use Cypal studio plugin or add compile/run scripts.
I needed to install Trac on my laptop. Trac is an enhanced wiki and issue tracking system for software development projects. I had used it about 2 years back and had liked it then. However, I had never installed it myself. I assumed it will be like any other installation. But just after starting out, I realized that I was grossly mistaken. Installing Trac and getting it running with the webadmin plugin and users configured for your projects is a little more than a post-work headache.
I have the following setup:
- OS: Vista business 32-bit
- Python: Not already installed on my system
After installation, we will be running Trac 0.10.4 with webadmin plugin and users configured for a project. This installation will be running on Apache and we won’t be using Trac’s standalone webserver (tracd). I am not using Trac’s subversion feature since I am already running VisualSVN server (and I love its ease of use). Ill try to switch sometime later if thats not another royal pain.
It turns out that the steps are quite simple … if you happen to know them.
You should have the Trac installation running now. Backup is as simple as creating a copy of the “projects” folder. If you can’t see the admin link on the upper right corner after all this, be prepared to spend the night getting it to show up. Start here!
Finally, if you have any Trac tips up your sleeve, I would love to read them. Things such as setting up multiple projects, having different sets of users for projects …
Update (27/11): Help Mumbai page with all relevant phone numbers: http://helpmumbai.pinstorm.com/
There is a lot of trouble in Mumbai, India right now. There are terrorists throughout the city and if you switch the television on at this moment (2 AM), you will lose your nerves. If you want to touchbase with your dear ones here but are not able to get through, leave a message with your and your friend’s numbers. I will try to get through to them as frequently as I can. If you are in Mumbai and can help folks, try and answer the queries here or leave your number here.
Blood needed at various hospitals (source: IBN live stream):
St. George’s hospital: (022) 22620242
JJ Hospital: (022) 23739031
CNN IBN Live Streaming: http://tinyurl.com/644733
DFAT emergency number: 1300 555 135 (via @AnneBB)
http://twitter.com/squorch/status/1025372562
http://twitter.com/Asfaq/statuses/1025385789
Mumbai police telephone numbers: http://www.mumbaipolice.org/imp_telnfax.htm
Wikipedia article: http://en.wikipedia.org/wiki/26_November_2008_Mumbai_attacks
Update: There are people at MumbaiHelp who can help as well http://mumbaihelp.blogspot.com/2008/11/can-we-help.html
SmartGWT 1.0, a web application library based on SmartClient and GWT, was released this Monday. From the release announcement at Sanjiv’s blog and the showcase demos, it is evident that this library packs a lot of power and is definitely worth checking out. I have come across SmartClient only recently. And now that I know of it, Ill try and get acquainted with it when I can.
Links:
SmartClient: http://www.smartclient.com/
SmartGWT: http://code.google.com/p/smartgwt/
Visual Builder videos: http://www.smartclient.com/technology/visualbuilder.jsp
Google Chat
It once happened that I did not recollect adding someone on GTalk and yet the contact showed up in my buddy list. I thought maybe the other guy did and that I forgot about it after accepting the request. Then it started happening very frequently and I had no clue.
Well, it turns out that if you communicate frequently with some people, GMail automatically allows them to chat with you and see when you are online. Its great to make new friends and learn from new people but sometimes, its just better to know who is on your buddy list! To turn this otherwise helpful feature off, log into your Gmail account and go to Settings >> Chat. Select “Only allow people that I’ve explicitly approved to chat with me and see when I’m online.”
FoxClocks
If you work across timezones, you will probably agree that having to remember / calculate the time at your client’s end isn’t always a fun thing to do. I had a couple of Timezone widgets added to my iGoogle page but I didn’t find them compelling. Just last week, I noticed Andy McDonald’s FoxClocks as a recommended extension on the Firefox add-on page. One look at the screenshot and I blinked only after it was installed. Needless to say, its a very well-made, unobtrusive extension which sits in the statusbar / toolbar and is right there when you need it. Highly customizable and highly recommended.
While working with a GWT-Ext application, I found that most of the Combo boxes used are just meant to be readonly drop down lists. Like the style 2 combo boxes we had in VB. A 2D array with display and value fields is all that is needed. Yet, every combo needs 6-7 lines to get going.
This utility method may be handy in such situations:
public static ComboBox getDropDownCombo(Object[][] data, String fieldLabel, String emptyText, int width, int listWidth)
{
Store store = new SimpleStore(new String[]{"display", "value"}, data);
ComboBox combo = new ComboBox();
combo.setEditable(false);
combo.setStore(store);
combo.setDisplayField("display");
combo.setValueField("value");
combo.setMode(ComboBox.LOCAL);
combo.setTriggerAction(ComboBox.ALL);
if(fieldLabel != null)
combo.setFieldLabel(fieldLabel);
else
combo.setHideLabel(true);
if(width != -1)
combo.setWidth(width);
if(listWidth != -1)
combo.setListWidth(listWidth);
if(emptyText != null)
combo.setEmptyText(emptyText);
else
// if there is no empty text, select the first value by default
combo.setValue(data[0][1].toString());
return combo;
}
Sample usage could be:
String[][] data = {{ "Mark as read", "1"}, {"Mark as unread", "2"}, {"Add star", "3"}, {"Remove star", "4"}};
ComboBox cmbMin = UIHelper.getDropDownCombo(data, "Actions", "[Select]", 275, -1);
Yesterday, while dabbling with jQuery and getting amazed by the wealth of plugins and effects available for this library, I came across http://digitalbush.com/2008/07/31/masked-input-plugin-114/. It allows you to fit text fields with an input mask to allow only fixed-width input in a certain format. I had seen it first in MS Access a long long time ago.
To use it with GWT-Ext, include jquery.js and jquery.maskedinput.js in your host HTML file. Use <script></script> and not <script/> to avoid wasting time later.
<script language = "javascript" type="text/javascript" src="js/jquery.js" ></script>
<script language = "javascript" type="text/javascript" src="js/jquery.maskedinput.js" ></script>
Now write some native code to call the plugin’s methods:
private native void addPlaceholder(String placeholder, String maskString) /*-{
$wnd.$.mask.addPlaceholder(placeholder, maskString);
}-*/;
private native void mask(String id, String maskString, String placeholderString) /*-{
if(placeholderString != null)
$wnd.$('#' + id).mask(maskString, {placeholder:placeholderString});
else
$wnd.$('#' + id).mask(maskString);
}-*/;
Add the mask to a text field:
addPlaceholder("~", "[+-]");
textField.doOnRender(new Function(){
public void execute() {
mask(textField.getId(), "Rs. ~9999.99/-", " ");
}
});
This will only allow values of the type “Rs. +2345.50/-” with “Rs. ” and “/-” already filled in for the user.
Update: See this: http://gwt-ext.com/forum/viewtopic.php?f=9&t=2984. Thanks mdeg and vanderbill!
BarCampMumbai4 is happening on 4th and 5th of October, 2008 at SJMSOM, IIT, Powai, Mumbai. Its a 2 day camp and you can either present something or be a volunteer. Check out http://barcampmumbai.org/ for registration and other details.
This will be my first BarCamp meet. If you will be around, drop me an email at abhijeet[dot]maharana[at]gmail.com. I would love to meet up with you. See you there!
Google Chrome is all over the place – websites, blogs, Twitter, here, there …. Instinctively, I checked it out just now and my first reaction was “Ah! Its sexy!”. I am sold on the UI alone. Its simple, clean, futuristic. And sexy! I am not going to post the nitty gritty details because you can read about it here. And of course, the comic book!
- The UI, as I have mentioned floored me completely. I like sleek looking apps. Everyone does!
- Task manager: Right click the Chrome task bar button or the title bar ..err.. tab bar to get the Task Manager. Kill individual tabs and plugins to your heart’s content! I killed the Flash plugin and all tabs displayed an error message where Flash content was present. But the tabs and everything else were working fine. This also shows detailed “stats for nerds” in a tab.
- Google Gears: Its integrated right into the browser. Speed difference is quite evident and specially applicable to application shortcuts on the desktop.
- Developer tools: It has a sleek looking DOM inspector. Its like Firebug but a lot could be added. One thing Ill miss for sure is the “Inspect element” button in Firebug. Although I can right click a page element and inspect it, it would have been lot better if it was also within the DOM inspector. Or is it tucked in somewhere and I missed it?
Chrome has generated a lot of excitement. It would be great to see how it influences the web and the developers out there. Till then, I have a few things to figure out:
- How to get the menu bar back (if there is one).
- How to get the status bar to always show up. Not seeing the status bar even for a second gives me creeps!
- What sites to browse with incognito.
- What works and what doesn’t with this shiny new toy.
More than all this, after the terrible experience I had while developing for IE6 few years back, I am hoping that Chrome will clear up some of the mess that web development is. I haven’t had a serious brush with Webkit till now. But I guess its about time to do that.
Update: Jyoti had a weird “The application failed to initialize properly” error and she managed to track it down to this issue: http://code.google.com/p/chromium/issues/detail?id=38. Looks like a lot of people having trouble with it.
Quite sometime back, Khadaa commented that Dan’s HTMLEditor would be a good plugin to have as part of the GWT-Ext-UX project. I have just committed the GWT-Ext wrapper code. The wrapper code is quite small but I was stuck with some nasty bugs which took some time to squish. And I learnt a couple of things in the process.
Logs say that quite a number of readers arrived here searching for GWT-Ext HtmlEditor. Check out from SVN to start using the widget right away. Only the styles plugin is in. Undo/redo and images plugins are pending. Will try to work on them soon. If you want to add them to the project yourself, go right ahead.
Related links: