Sometimes tiny things overlooked can prove fatal or resolving them result to time consuming affair.In my Eclipse tips series i try to check the small things which can prove very pertinent.

Right Alignment of actions on the toolbar

Today i got a small requirement to align the toolbar actions to right side of the toolbar.I defintely thought there should be some style bits in the SWT class which would help me to achieve the same.I looked for SWT.RIGHT and SWT.RIGHT_TO_END, both did not work.Then reading a java docs i found about SWT.END (as again one take away from the Eclipse day was to always read the javadocs).So I already have a composite on which the layout was applied, but it the layout data was not fully taking the horizonatal space.Below is the code
GridDataFactory.fillDefaults().align(SWT.END, SWT.CENTER).grab(true, false).applyTo(toolbar);

where toolbar is the instance of the toolbar created.
Eclipse Resource

Now some useful things on the Eclipse resource framework.
We know a resource which is not not under the Eclipse worksapce can not get a handle for IFile and EFS understands IFile.

Eclipse Plug-in's Metadata location

All Eclipse plug-in have a metdata location which they can use to store some files.How do we get access to that metadata location.
Get the instance of the active bundle, then apply this api bundle.getPlatformLocation().
This returns the metadata location of the plug-in.
Update of OutlineView on Tab change of MultipageEditor


OK.This was something i am enthralled after doing it.It was a good challenge at 12-30 A.M. i could finish it.I could also think this as an extension of My eclipse editor tutorial, but nevertheless.
Will try to dig deep into MultipageEditor in other posts.Each editor as we know has an outline view attached to it and the outline view is attached as PartListener.So when the editorpart gets activated the part listeners react and create the control.Hence the attached OutlineView gets activated.
Now lets come to PageBook. A PageBook is a container which enables the visibility of the page.For a MultipageEditor the Outline view is a pagebook and then use the pagebook API showPage(Control) to show the page(Outline).
Find the code snippet below which helps to create the outlinepage.
public void setPageActive(IContentOutlinePage page) {

this.currentPage = page;
if (mPagebook == null) {
// still not being made
return;
}
Control control = page.getControl();
if (control == null || control.isDisposed()) {
// first time
if (page instanceof IPageBookViewPage) {
try {
((IPageBookViewPage) page).init(getSite());
} catch (PartInitException e) {
e.printStrackTrace();
}
}
page.createControl(mPagebook);
control = page.getControl();
}
mPagebook.showPage(control);


Above is the code which should be called when the page change happens such that for each of the pages the outlinepage is created.
I Hope all the above tips were useful
0

Add a comment

For long time i was thinking of creating a web application since my daily job does not requires me to work on web applications. So  i have to keep myself updated with the latest web technologies by doing some hobby or kind of innovation projects.
I had created web applications in the past using java stack i.e. jsp, servlets, EJBs ,Struts and Spring as well as using SAP's application stack of HANA , XS and UI5.

But i have always found that most of the consumer web applications are developed using PHP (For e.g. Facebook and Wordpress). So, i thought it becomes imperative for me to learn PHP and develop a simple web application with CRUD operation.

By CRUD i meant create, read, update and delete operation on a business domain object.

So i decided to write up my application with the combination of PHP and MySQL as backend.
Below post will describe my initial steps from the choice of database, to the stack opted , to the IDE chosen and finally to the application. My initial thought of the application is like the below diagram.



I downloaded Bitnami's WAMP  (Windows Apache MySQL PHP ) stack. To download and find more details click Here. I Used Bitnami stack because it eases out the setting up of the Apache server, adding php as a component in apache, setting up mysql etc. You can also later on install applications as you like into the bitnami stack. You can obviously download them separately and set them up.

After you have setup your bitnami properly you must get the below screenshot if you hit localhost:80




Now coming to the development tools, since i had ample experience with eclipse , i decided to use eclipse and PHP development tools. For download and for more details click https://eclipse.org/pdt/. PDT gives me all the IDE assistance for developing PHP  code like code completion, code formatting etc . Also i am able to be there in the Eclipse envrionment and take advantage of all the other features of Eclipse.

I started with creating a simple php application and it was quite easy to start up a PHP application without db interaction. Since PHP is an interpreted language you don't need to start your server, every time you make changes to your code.

Naturally the second step was to debug my application. For this eclipse provides two options.

  1. Using zend debugger for debugging
  2. Using XDebug debugger for debugging
I started with Zend debugger but found few problems like not getting suspended at the breakpoints. More details here. So i switched to xdebug debugger which is working fine till now. Follow the steps mentioned in the xdebug installation guide to fall into a seamless path of xdebug based debugging.

So after setting up a basic php application without db, I wanted to write a complete a application with basic CRUD operations on a business/domain object.
In my previous web applications i have coded most of these parts by myself.. Then i found that some web frameworks could have done that job for me. So this time i wanted to be smart and generate boilerplate code for my CRUD operations. 

So my requirement was to give a business object or domain object,create them db   and then generate the POJOs/Object classes for my model with fields of the db mapped to the object property of my php POJO class. Also the corresponding UI for the model must be generated.

Searching a bit found me CakePHP. Check more details about CakePHP here. Do give a check for the license of CakePHP before you use it. It perfectly fitted my requirements for a hobby project.
CakePHP provides a model view controller boilerplate code for a db table i.e. ORM class for db table, controller code and UI code for that db table based ORM class. It also generates some basic code for logging ,ORM, exception handling, unit automated tests (very useful) etc. Obviously you can then customize them according to your needs.

So once you have your language (PHP) , your database (MySQL) and your web server (Apache Server) ready you can embark on your journey of using CakePHP.
I followed the bookmarker tutorial here , just replaced the bookmarker model with my model.

You can find all the steps in detail mention in the tutorial , but i will mention here in broad/easy steps.

  1. Get your CakePHP first by using Composer.
  2. Check your installation directory structure to verify if CakePHP has been properly installed.
  3. Create your database by following CakePHP's conventions
  4. Create your database configuration file. This file is used by CakePHP to connect to the specific database,  and to create scaffolding code for the table given. Please note the username/password you are giving. The user account you have given must be there in the mysql's user list.
  5. Now execute "cake bake" commands to generate the boilerplate code for your project. (More information on the bake console is here. This is the most intriguing part where plethora of code is generated for you.
  6. If your commands are successful, then you must code being generated under the project directory.
Now some details into the code generated.

  1. <Your application>/src/controller: Contains the controller code for your table. For e.g. if your table is bookmarker, so you will find another class named BookmarkerController along with AppController. This forms the "C" of MVC pattern. Job of this class is to route the incoming requests and response and initialize any other framework related classes.
  2. <Your application>/src/Model: Contains the model code for your table.  This forms the "M" of MVC.  Further this folder contains three sub folders 'Table' , 'Entity' and 'Behaviour'. Table class extends the CakePHP table class which contains the CRUD methods for reading/writing to Database. Entity class is used to modify any record specific behaviour. I did not felt the need to customize the 'Behaviour' class yet.
  3. <Your application>/src/Template: Contains the rendering code of your view. This forms the "V" of MVC. You can further modify these files (.ctp) to change the layout of your view.
There are some other classes also got generated, but for my very first basic step i did not need them .So, that's it my basic application with CRUD functionality was ready.
Hit your localhost/<my app>/<your controller name> and see your application running.Once you hit the above application. You actually hit the 'index' action of your controller. Below is the snapshot of my application. ( i have hidden my domain objects in my snapshot).

Have look at the layout below. It autmagically (that's what its called in CakePHP) fetched the content from db ( I had two rows). Filled my UI. Also have UI actions for the other crud operations like view, edit and delete at the right side of the page. So  i am relieved of doing the basic stuff of getting the UI up, writing code for UI, adding styling etc. etc.

Initial page of the application


In the next post i will write up on some of the features of CakePHP and will dig deeper into it. I will also touch upon the customizations which i have done in my application for e.g. adding enum support for my application ,authentication and authorization functionality.








11

View comments

  1. Nice and very informative post about of website development courses and all the point describe step by step. Thanks for sharing. Keep sharing!!! I feel strongly about it and love learning more on this topic. It is extremely helpful for me. https://goo.gl/YXYcsl

    ReplyDelete
  2. Being new to the blogging world I feel like there is still so much to learn. Your tips helped to clarify a few things for me as well as giving..
    iOS Training in Chennai
    Android Training in Chennai
    php Training in Chennai

    ReplyDelete
  3. Very informative, keep up the good work.

    ReplyDelete
  4. This blog is having the general information. Got a creative work and this is very different one.We have to develop our creativity mind.This blog helps for this. Thank you for this blog. This is very interesting and useful.
    PHP Training in Chennai

    ReplyDelete
  5. Hello, nice website. I wanted to reach to you since you have lots of experience working with java.

    I developed myself a program to become an Oracle Certified Professional Java Programmer. my site is: www.softmastery.com

    If you like it don't doubt in contacting it! Regards

    ReplyDelete
  6. Your blog is really awesome and you have clearly explained many more topics and it is really good thus it is very much interesting and really nice too. https://goo.gl/5USw97

    ReplyDelete
  7. Really great post, Thank you for sharing this knowledge. Excellently written article, if only all bloggers offered the same level of content as you, the internet would be a much better place vancouver pr company. Please keep it up. Keep posting.
    Best regards

    ReplyDelete
  8. Thank you so much for this amazing posts and please keep update like this excellent article.
    seo classes in nagpur
    web design training institute in nagpur

    ReplyDelete
  9. Very great post. I simply stumbled upon your blog and wanted to say that I have really enjoyed browsing your weblog posts. After all I’ll be subscribing on your feed and I am hoping you write again very soon! I am glad, i have found your post while searching about cadeau vader online.

    ReplyDelete
  10. I am a regular reader of your blogs. I found that your all blogs are very interesting and amazing.
    Thank You for sharing with users for such an useful information.

    Hire Top CakePHP Companies

    ReplyDelete
Picture
Picture
Logo
Logo
Blog Archive
My Blog List
My Blog List
About Me
About Me
Loading
Dynamic Views theme. Powered by Blogger. Report Abuse.