JFace TreeViewer is a very useful UI control for displaying hierarchical data. It is used extensively in Eclipse, for example in Project/Package/Navigator view, Outline view, Debug Variables view etc. Eclipse .org hosts a nice article on TreeViewer – How to use the JFace Tree Viewer.
To specify data and its hierarchy in the TreeViewer, you implement ITreeContentProvider interface. This interface has methods like getElements, getChildren which you need to override to provide content and structure to the TreeViewer. You would typically return array of your model objects from getElements or getChildren methods. And since it is a tree view, you can expand or collapse the nodes. The model classes for an example in the above article could be Category (book, game etc.), Book and Game. Category can have Books or Games. You might load this information from a database and pass it to the content provider object. To refresh information in the TreeViewer, you would call one of the variants of refresh() function.
Continue reading “Maintaining expanded/collapsed state in Eclipse TreeViewer”
So I first evaluated Eclipse plugin that CDT provides. Before I get to that plugin, here are some useful links about CDT –
A few months back I had created an application that recorded and played back drawings on HTML5 Canvas. For some time now I wanted to refactor the code in that application and create a reusable ‘component’ from it. Which is what I did this week.
Go ahead and try the demo first – Press ‘Record’ key below and then draw some strokes/lines in the box with the mouse (holding down left button). Once you are done, click Stop button. Click ‘Play’ button to play back the drawing you just drew. You can pause and resume too.
Continue reading “Record and Playback Drawing in HTML5 Canvas”
I spent quite a lot of time today trying to debug “Access restriction” error in one of my Eclipse plugins. In the last four years of Eclipse plugin development, I don’t recall ever facing this issue, but today suddenly some of the imports in one of the classes in my Eclipse plugin were flagged off as errors –
Access restriction: The type ISelection is not accessible due to restriction on required library <eclipse-path>\eclipse\plugins\org.eclipse.jface_3.6.1.M20100825-0800.jar
I had seen warnings about ‘restricted access’ for some of the imports earlier, but those were for classes that Eclipse discouraged to use e,g, for internal Eclipse classes. But today I was seeing errors.
The error does not tell much about what could have gone wrong. ISelection is exported from jface plugin and it is a public interface. And I had used this class without any error in other plugins.
Continue reading “"Access restriction" error in Eclipse plugins”
I have been stuck with the problem of making UI widgets fill horizontally in a grid layout a few times. The solution is simple, but when I have to create UI using Eclipse SWT after a long gap, I tend to forget how I had made this work earlier, so I decided to blog about this.
I had to create a simple UI with one label and associated text box. I coded it like this –
GridLayout layout = new GridLayout(2, false);
tabContainer.setLayout(layout); //this is the parent composite
Label label1 = new Label(tabContainer, SWT.NONE);
GridData gd = new GridData();
gd.grabExcessHorizontalSpace = false;
Text txtBox1 = new Text(tabContainer, SWT.BORDER);
gd = new GridData();
gd.grabExcessHorizontalSpace = true;
Continue reading “Eclipse SWT GridLayout – Making the widget fill horizontally”
I finally got around to fixing a bug in my Android application, Simple Task Reminder, which was on my to-do list for a long time.The issue was that all reminders set in this application were lost on device restart. The solution was to set reminders again after device rebooted.
Android SDK provides a mechanism to receive notification for your application, after the device is booted. You need to add a broadcast receiver in the manifest file –
Continue reading “Starting Android Activity on device restart”
WebAppRunner is the Eclipse RCP application I created to run web applications as standalone desktop applications. I had explained earlier how this application could be used by creating a demo FileList application. In this post I am going to show how WebAppRunner can be used to create Database applications.
I have created a demo application, SQLiteApp.
Continue reading “Developing Database Applications with WebAppRunner”
I wanted to hide/show menu bar in my WebAppRunner Eclipse application, depending on settings. I figured getting menu bar manager and calling setVisible method would do the job, but it was not sufficient.
Eclipse checks visibility of each menu manager in the menu bar and even if one of them is visible, it would not hide the menu bar after calling setVisible(false).
Continue reading “Hiding menu and tool bars in Eclipse RCP Application”
That application is now ready. If you want to give it a try, download it from following links. The application is about 21 MB in size.
JRE is not packaged in the above application. You will have to download and install it, if you don’t have it already.
I have also created a sample app to show how a web page can call Java APIs. The application uses JDK File APIs to get list of files. Download FileListApp from here. Below is a screen shot of this application –
Continue reading “WebAppRunner – Run your web applications standalone”
I have been developing Eclipse plugins for more than four years now. I have implemented many features in the ColdFusion Builder, which is an Eclipse based IDE. Eclipse SDK provides a SWT Browser control which can be used within Eclipse plugin to display HTML files. Eclipse does not include any browser, but it uses the system browser- on Windows it is Internet Explorer and on Macintosh it is Safari. I have used this control mainly to display static HTML content or open a URL on a remote server, e.g. for executing ColdFusion Builder extensions written in CFML.