Hi
I dont know how to connect mysql with ECLIPSE in RCP application. Please send me the sample code of connecting mysql sever with ECLIPSE in RCP application.
Coding Part:
RCP Application Codes:
Class ApplicationActi onBarAdvisor:
import org.eclipse.jfa ce.action.Actio n;
import org.eclipse.jfa ce.action.IMenu Manager;
import org.eclipse.jfa ce.action.MenuM anager;
import org.eclipse.jfa ce.action.Separ ator;
import org.eclipse.ui. IWorkbenchActio nConstants;
import org.eclipse.ui. IWorkbenchWindo w;
import org.eclipse.ui. actions.ActionF actory;
import org.eclipse.ui. actions.ActionF actory.IWorkben chAction;
import org.eclipse.ui. application.Act ionBarAdvisor;
import org.eclipse.ui. application.IAc tionBarConfigur er;
public class ApplicationActi onBarAdvisor extends ActionBarAdviso r {
private Action addmember;
public ApplicationActi onBarAdvisor(IA ctionBarConfigu rer configurer) {
super(configure r);
}
protected void makeActions(IWo rkbenchWindow window) {
addmember=new Addmember("Add a Member",window) ;
register(addmem ber);
}
protected void fillMenuBar(IMe nuManager menuBar) {
MenuManager File=new MenuManager("&F ile",IWorkbench ActionConstants .M_FILE);
MenuManager Member=new MenuManager("&M ember",null);
menuBar.add(Fil e);
File.add(Member );
Member.add(addm ember);
}
}
Class Addmember:
import org.eclipse.jfa ce.action.Actio n;
import org.eclipse.ui. IWorkbenchWindo w;
public class Addmember extends Action {
private IWorkbenchWindo w window;
//public static boolean internalCall = false;
//public Addmember(){ };
public Addmember(Strin g string, IWorkbenchWindo w window) {
// TODO Auto-generated constructor stub
super(string);
this.window=win dow;
setId(ICommandI ds.CMD_OPEN_MES SAGE);
// Associate the action with a pre-defined command, to allow key bindings.
setActionDefini tionId(ICommand Ids.CMD_OPEN_ME SSAGE);
}
public void run() {
addmemdialog d=new addmemdialog(wi ndow);
d.open();
}
}
Class addmemdialog:
import org.eclipse.jfa ce.dialogs.Mess ageDialog;
import org.eclipse.jfa ce.window.Appli cationWindow;
import org.eclipse.swt .SWT;
import org.eclipse.swt .events.MouseEv ent;
import org.eclipse.swt .events.MouseLi stener;
import org.eclipse.swt .layout.GridLay out;
import org.eclipse.swt .widgets.Button ;
import org.eclipse.swt .widgets.Compos ite;
import org.eclipse.swt .widgets.Contro l;
import org.eclipse.swt .widgets.Displa y;
import org.eclipse.swt .widgets.Label;
import org.eclipse.swt .widgets.Shell;
import org.eclipse.swt .widgets.Text;
import org.eclipse.ui. IWorkbenchWindo w;
public class addmemdialog extends ApplicationWind ow{
public addmemdialog(IW orkbenchWindow window) {
super(window.ge tShell());
// TODO Auto-generated constructor stub
}
@Override
protected void configureShell( Shell shell) {
// TODO Auto-generated method stub
super.configure Shell(shell);
shell.setText(" Adding a Member");
}
public void run(){
// TODO Auto-generated method stub
setBlockOnOpen( true);
open();
Display.getCurr ent().dispose() ;
}
protected Control createContents( Composite parent){
final Composite composite1 = new Composite(paren t,SWT.BORDER);
composite1.setB ounds(10,10,270 ,250);
composite1.setL ayout(new GridLayout(2,tr ue));
Label ID = new Label(composite 1,SWT.NONE);
ID.setText("Use r ID:");
final Text tID=new Text(composite1 ,SWT.BORDER);
tID.setTextLimi t(30);
Label name=new Label(composite 1,SWT.NONE);
name.setText("U ser name:");
final Text tname=new Text(composite1 ,SWT.BORDER);
tname.setTextLi mit(30);
Label pwd=new Label(composite 1,SWT.NONE);
pwd.setText("Pa ssword:");
final Text tpwd=new Text(composite1 ,SWT.BORDER);
tpwd.setEchoCha r('*');
tpwd.setTextLim it(10);
Label cpwd=new Label(composite 1,SWT.NONE);
cpwd.setText("C onfirm Password:");
final Text tcpwd=new Text(composite1 ,SWT.BORDER);
tcpwd.setEchoCh ar('*');
tcpwd.setTextLi mit(10);
Label dno=new Label(composite 1,SWT.NONE);
dno.setText("Do or number:");
final Text tdno=new Text(composite1 ,SWT.BORDER);
tdno.setTextLim it(30);
Label loc=new Label(composite 1,SWT.NONE);
loc.setText("Lo cality:");
final Text tloc=new Text(composite1 ,SWT.BORDER);
tloc.setTextLim it(30);
Label city=new Label(composite 1,SWT.NONE);
city.setText("C ity:");
final Text tcity=new Text(composite1 ,SWT.BORDER);
tcity.setTextLi mit(30);
Label pin=new Label(composite 1,SWT.NONE);
pin.setText("Pi ncode:");
final Text tpin=new Text(composite1 ,SWT.BORDER);
tpin.setTextLim it(30);
Label state=new Label(composite 1,SWT.NONE);
state.setText(" State:");
final Text tstate=new Text(composite1 ,SWT.BORDER);
tstate.setTextL imit(30);
Label phno=new Label(composite 1,SWT.NONE);
phno.setText("P hone Number:");
final Text tphno=new Text(composite1 ,SWT.BORDER);
tphno.setTextLi mit(30);
Label dtj=new Label(composite 1,SWT.NONE);
dtj.setText("Da te of joining:");
final Text tdtj=new Text(composite1 ,SWT.BORDER);
tdtj.setTextLim it(30);
Button btnsubmit=new Button(composit e1,SWT.PUSH);
btnsubmit.setTe xt("Submit");
Button btncancel=new Button(composit e1,SWT.PUSH);
btncancel.setTe xt("Cancel");
btnsubmit.addMo useListener(new MouseListener() {
public void mouseDoubleClic k(MouseEvent e) {
// TODO Auto-generated method stub
}
public void mouseDown(Mouse Event e){
// TODO Auto-generated method stub
if (tID.getText()= ="" || tname.getText() =="" || tpwd.getText()= ="" || tcpwd.getText() =="" || tdno.getText()= ="" || tloc.getText()= ="" || tcity.getText() =="" || tpin.getText()= ="" || tstate.getText( )=="" || tphno.getText() =="" || tdtj.getText()= =""){
MessageDialog.o penInformation( composite1.getS hell(), "Informatio n", "You have to enter all the fields");
}
else if(!tpwd.getTex t().equals(tcpw d.getText())){
MessageDialog.o penInformation( composite1.getS hell(), "Informatio n", "Your password and confirm password fields are not matched");
}
else
{
MessageDialog.o penInformation( composite1.getS hell(), "User Info", "Your account has been registered");
}
}
public void mouseUp(MouseEv ent e) {
// TODO Auto-generated method stub
}
});
btncancel.addMo useListener(new MouseListener() {
public void mouseDoubleClic k(MouseEvent e) {
// TODO Auto-generated method stub
}
public void mouseDown(Mouse Event e) {
// TODO Auto-generated method stub
tID.setText("") ;
tname.setText(" ");
tpwd.setText("" );
tcpwd.setText(" ");
tdno.setText("" );
tloc.setText("" );
tcity.setText(" ");
tpin.setText("" );
tstate.setText( "");
tphno.setText(" ");
tdtj.setText("" );
}
public void mouseUp(MouseEv ent e) {
// TODO Auto-generated method stub
}
});
return parent;
}
}
Here i have created menu File->Member->Addmember and when i click the items which i have specified appears on the screen such as label,text,butt on controls etc...
But when i click the submit button the mouse down procedure invokes and the validation code which i have specified executes.
Also i want the details to be updated in mysql database. Plaese send me the connection procedure....
Please help me....
I dont know how to connect mysql with ECLIPSE in RCP application. Please send me the sample code of connecting mysql sever with ECLIPSE in RCP application.
Coding Part:
RCP Application Codes:
Class ApplicationActi onBarAdvisor:
import org.eclipse.jfa ce.action.Actio n;
import org.eclipse.jfa ce.action.IMenu Manager;
import org.eclipse.jfa ce.action.MenuM anager;
import org.eclipse.jfa ce.action.Separ ator;
import org.eclipse.ui. IWorkbenchActio nConstants;
import org.eclipse.ui. IWorkbenchWindo w;
import org.eclipse.ui. actions.ActionF actory;
import org.eclipse.ui. actions.ActionF actory.IWorkben chAction;
import org.eclipse.ui. application.Act ionBarAdvisor;
import org.eclipse.ui. application.IAc tionBarConfigur er;
public class ApplicationActi onBarAdvisor extends ActionBarAdviso r {
private Action addmember;
public ApplicationActi onBarAdvisor(IA ctionBarConfigu rer configurer) {
super(configure r);
}
protected void makeActions(IWo rkbenchWindow window) {
addmember=new Addmember("Add a Member",window) ;
register(addmem ber);
}
protected void fillMenuBar(IMe nuManager menuBar) {
MenuManager File=new MenuManager("&F ile",IWorkbench ActionConstants .M_FILE);
MenuManager Member=new MenuManager("&M ember",null);
menuBar.add(Fil e);
File.add(Member );
Member.add(addm ember);
}
}
Class Addmember:
import org.eclipse.jfa ce.action.Actio n;
import org.eclipse.ui. IWorkbenchWindo w;
public class Addmember extends Action {
private IWorkbenchWindo w window;
//public static boolean internalCall = false;
//public Addmember(){ };
public Addmember(Strin g string, IWorkbenchWindo w window) {
// TODO Auto-generated constructor stub
super(string);
this.window=win dow;
setId(ICommandI ds.CMD_OPEN_MES SAGE);
// Associate the action with a pre-defined command, to allow key bindings.
setActionDefini tionId(ICommand Ids.CMD_OPEN_ME SSAGE);
}
public void run() {
addmemdialog d=new addmemdialog(wi ndow);
d.open();
}
}
Class addmemdialog:
import org.eclipse.jfa ce.dialogs.Mess ageDialog;
import org.eclipse.jfa ce.window.Appli cationWindow;
import org.eclipse.swt .SWT;
import org.eclipse.swt .events.MouseEv ent;
import org.eclipse.swt .events.MouseLi stener;
import org.eclipse.swt .layout.GridLay out;
import org.eclipse.swt .widgets.Button ;
import org.eclipse.swt .widgets.Compos ite;
import org.eclipse.swt .widgets.Contro l;
import org.eclipse.swt .widgets.Displa y;
import org.eclipse.swt .widgets.Label;
import org.eclipse.swt .widgets.Shell;
import org.eclipse.swt .widgets.Text;
import org.eclipse.ui. IWorkbenchWindo w;
public class addmemdialog extends ApplicationWind ow{
public addmemdialog(IW orkbenchWindow window) {
super(window.ge tShell());
// TODO Auto-generated constructor stub
}
@Override
protected void configureShell( Shell shell) {
// TODO Auto-generated method stub
super.configure Shell(shell);
shell.setText(" Adding a Member");
}
public void run(){
// TODO Auto-generated method stub
setBlockOnOpen( true);
open();
Display.getCurr ent().dispose() ;
}
protected Control createContents( Composite parent){
final Composite composite1 = new Composite(paren t,SWT.BORDER);
composite1.setB ounds(10,10,270 ,250);
composite1.setL ayout(new GridLayout(2,tr ue));
Label ID = new Label(composite 1,SWT.NONE);
ID.setText("Use r ID:");
final Text tID=new Text(composite1 ,SWT.BORDER);
tID.setTextLimi t(30);
Label name=new Label(composite 1,SWT.NONE);
name.setText("U ser name:");
final Text tname=new Text(composite1 ,SWT.BORDER);
tname.setTextLi mit(30);
Label pwd=new Label(composite 1,SWT.NONE);
pwd.setText("Pa ssword:");
final Text tpwd=new Text(composite1 ,SWT.BORDER);
tpwd.setEchoCha r('*');
tpwd.setTextLim it(10);
Label cpwd=new Label(composite 1,SWT.NONE);
cpwd.setText("C onfirm Password:");
final Text tcpwd=new Text(composite1 ,SWT.BORDER);
tcpwd.setEchoCh ar('*');
tcpwd.setTextLi mit(10);
Label dno=new Label(composite 1,SWT.NONE);
dno.setText("Do or number:");
final Text tdno=new Text(composite1 ,SWT.BORDER);
tdno.setTextLim it(30);
Label loc=new Label(composite 1,SWT.NONE);
loc.setText("Lo cality:");
final Text tloc=new Text(composite1 ,SWT.BORDER);
tloc.setTextLim it(30);
Label city=new Label(composite 1,SWT.NONE);
city.setText("C ity:");
final Text tcity=new Text(composite1 ,SWT.BORDER);
tcity.setTextLi mit(30);
Label pin=new Label(composite 1,SWT.NONE);
pin.setText("Pi ncode:");
final Text tpin=new Text(composite1 ,SWT.BORDER);
tpin.setTextLim it(30);
Label state=new Label(composite 1,SWT.NONE);
state.setText(" State:");
final Text tstate=new Text(composite1 ,SWT.BORDER);
tstate.setTextL imit(30);
Label phno=new Label(composite 1,SWT.NONE);
phno.setText("P hone Number:");
final Text tphno=new Text(composite1 ,SWT.BORDER);
tphno.setTextLi mit(30);
Label dtj=new Label(composite 1,SWT.NONE);
dtj.setText("Da te of joining:");
final Text tdtj=new Text(composite1 ,SWT.BORDER);
tdtj.setTextLim it(30);
Button btnsubmit=new Button(composit e1,SWT.PUSH);
btnsubmit.setTe xt("Submit");
Button btncancel=new Button(composit e1,SWT.PUSH);
btncancel.setTe xt("Cancel");
btnsubmit.addMo useListener(new MouseListener() {
public void mouseDoubleClic k(MouseEvent e) {
// TODO Auto-generated method stub
}
public void mouseDown(Mouse Event e){
// TODO Auto-generated method stub
if (tID.getText()= ="" || tname.getText() =="" || tpwd.getText()= ="" || tcpwd.getText() =="" || tdno.getText()= ="" || tloc.getText()= ="" || tcity.getText() =="" || tpin.getText()= ="" || tstate.getText( )=="" || tphno.getText() =="" || tdtj.getText()= =""){
MessageDialog.o penInformation( composite1.getS hell(), "Informatio n", "You have to enter all the fields");
}
else if(!tpwd.getTex t().equals(tcpw d.getText())){
MessageDialog.o penInformation( composite1.getS hell(), "Informatio n", "Your password and confirm password fields are not matched");
}
else
{
MessageDialog.o penInformation( composite1.getS hell(), "User Info", "Your account has been registered");
}
}
public void mouseUp(MouseEv ent e) {
// TODO Auto-generated method stub
}
});
btncancel.addMo useListener(new MouseListener() {
public void mouseDoubleClic k(MouseEvent e) {
// TODO Auto-generated method stub
}
public void mouseDown(Mouse Event e) {
// TODO Auto-generated method stub
tID.setText("") ;
tname.setText(" ");
tpwd.setText("" );
tcpwd.setText(" ");
tdno.setText("" );
tloc.setText("" );
tcity.setText(" ");
tpin.setText("" );
tstate.setText( "");
tphno.setText(" ");
tdtj.setText("" );
}
public void mouseUp(MouseEv ent e) {
// TODO Auto-generated method stub
}
});
return parent;
}
}
Here i have created menu File->Member->Addmember and when i click the items which i have specified appears on the screen such as label,text,butt on controls etc...
But when i click the submit button the mouse down procedure invokes and the validation code which i have specified executes.
Also i want the details to be updated in mysql database. Plaese send me the connection procedure....
Please help me....
Comment