In RAP Platform , how to create a login dialog? [message #758434] |
Wed, 23 November 2011 04:44  |
Eclipse User |
|
|
|
hellow dear,
The follow is my code,
Application class:
public Object start(IApplicationContext context) throws Exception {
Display display = PlatformUI.createDisplay();
// Entry Point Login
LoginDialog loginDialog = new LoginDialog(null);
int result = loginDialog.open();
if (result != Window.OK) {
return IApplication.EXIT_OK;
} else {
WorkbenchAdvisor advisor = new ApplicationWorkbenchAdvisor();
return PlatformUI.createAndRunWorkbench(display, advisor);
}
}
by using eclipse wtp3.3 create WAR product configuration,Export the file(.WAR)and logs.zip
logs.zip content:
1. ERROR in D:\work\eoffice\src\com\yidatec\eoffice\startup\Application.java (at line 22)
int result = loginDialog.open();
^^^^^^^^^^^
loginDialog cannot be resolved
I am waiting for you good news. I am Chinese,and just learning RAP for just a while.
Thank you first!!!
[Updated on: Wed, 23 November 2011 04:50] by Moderator
|
|
|
Re: In RAP Platform , how to create a login dialog? [message #758438 is a reply to message #758434] |
Wed, 23 November 2011 04:55   |
Eclipse User |
|
|
|
Hi terry,
You have to write your own login dialog class which extends dialog class.
Here is the example:
public class LoginDialog extends Dialog{
private Text m_userName_Text = null;
private Text m_userPassword_Text = null;
private String m_Title=null;
private String m_loginName=null;
private String m_password=null;
public LoginDialog(Shell parentShell, String title){
super(parentShell);
m_Title=title;
}
protected void configureShell(Shell shell) {
super.configureShell(shell);
if (m_Title != null){
shell.setText(m_Title);
}
}
protected Control createDialogArea(Composite parent){
Composite composite = new Composite(parent, SWT.NONE);
GridLayout layout = new GridLayout();
layout.numColumns = 2;
composite.setLayout(layout);
createDialogAreaHelper(composite);
composite.pack();
return composite;
}
private void createDialogAreaHelper(Composite composite){
Label m_userName_Text_Label = new Label(composite, SWT.NONE );
m_userName_Text_Label.setText("User Name"+" : " );
GridData userNamedata = new GridData();
userNamedata.widthHint = 100;
m_userName_Text_Label.setLayoutData(userNamedata);
m_userName_Text = new Text(composite, SWT.SINGLE | SWT.BORDER);
userNamedata = new GridData();
userNamedata.widthHint = 243;
m_userName_Text.setLayoutData(userNamedata);
m_userName_Text.setText("username");
Label m_userPassword_Text_Label = new Label(composite, SWT.NONE );
m_userPassword_Text_Label.setText("Password"+" : " );
GridData passwordData = new GridData();
passwordData.widthHint = 100;
m_userPassword_Text_Label.setLayoutData(passwordData);
m_userPassword_Text = new Text(composite, SWT.SINGLE | SWT.BORDER | SWT.PASSWORD);
passwordData = new GridData();
passwordData.widthHint = 243;
m_userPassword_Text.setLayoutData(passwordData);
m_userPassword_Text.setEchoChar('*');
m_userPassword_Text.setText("password");
}catch(Exception e) {
return;
}
}
protected void okPressed(){
String userName = m_userName_Text.getText().trim();
String userPassword=m_userPassword_Text.getText().trim();
super.okPressed();
}
protected void enableDisableButtons(boolean enable) {
getButton(IDialogConstants.OK_ID).setEnabled(enable);
}
private boolean checkFileds(){
m_loginName = m_userName_Text.getText().trim();
m_password = m_userPassword_Text.getText().trim();
if(m_loginName.length() <= 0){
return false;
}
if(m_password.length() <= 0){
return false;
}
}
return true;
}
}
I hope this will help you

[Updated on: Wed, 23 November 2011 04:55] by Moderator
|
|
|
Re: In RAP Platform , how to create a login dialog? [message #758442 is a reply to message #758438] |
Wed, 23 November 2011 05:24  |
Eclipse User |
|
|
|
By using eclipse wtp3.3 create WAR product configuration,Export the file(XXX.WAR) and one error come out
this is the @dit.log
# 11-11-23 18:09:30
# Eclipse Compiler for Java(TM) 0.B76_R37x, 3.7.1, Copyright IBM Corp 2000, 2011. All rights reserved.
----------
1. ERROR in D:\work\eoffice\src\com\yidatec\eoffice\startup\Application.java (at line 22)
}
^
Syntax error on token "}", { expected after this token
----------
2. ERROR in D:\work\eoffice\src\com\yidatec\eoffice\startup\Application.java (at line 24)
return PlatformUI.createAndRunWorkbench(display,
new ApplicationWorkbenchAdvisor());
}
public void stop() {
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Syntax error on token(s), misplaced construct(s)
----------
3. ERROR in D:\work\eoffice\src\com\yidatec\eoffice\startup\Application.java (at line 26)
}
^
Syntax error on token "}", delete this token
----------
4. ERROR in D:\work\eoffice\src\com\yidatec\eoffice\startup\Application.java (at line 28)
public void stop() {
^^^^
Syntax error on token "void", @ expected
|
|
|
Powered by
FUDForum. Page generated in 0.07625 seconds