[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[pde-dev] How to access .jars in Runtime
|
We have developed a simple plug-in to convert WSDL file to Web Service by
using WSDL2Ws tool in Axis/C++.
it was done by implementing the interface IWorkbenchWindowActionDelegate.
Plug-in was developed as menu item to main menu bar.
The problem occured: The external jars are not accessed by the application
in Runtime.
Code:
public class WSDL2WsGUI implements IWorkbenchWindowActionDelegate {
private String selectedWSDLFile="";
private String selectedDirectory="";
Text txtWSDLFileName;
Combo cmblanguageSelect;
Combo cmbTargetSide;
Combo cmbSecurity ;
Combo cmbImpStyle;
String[] args=new String[6];
/**
* TODO: Implement the "WSDL2WsGUI" constructor.
*/
/*
public WSDL2WsGUI() {
}*/
/**
* TODO: Implement "run".
* @see IWorkbenchWindowActionDelegate#run
*/
public void run(IAction action){
final Shell shell=new Shell();
shell.setText("WSDL2WS Convertor Plug-in");
shell.setSize(450,500);
shell.open();
//Add Label widget
Label lblWSDLFileName = new Label(shell,SWT.NONE);
lblWSDLFileName.setText("WSDL File Name");
lblWSDLFileName.setSize(100,30);
lblWSDLFileName.setLocation(20,25);
Label lblOutputFolder = new Label(shell,SWT.NONE);
lblOutputFolder.setText("Target Output Folder");
lblOutputFolder.setSize(100,30);
lblOutputFolder.setLocation(20,100);
Label lblLanguage = new Label(shell,SWT.NONE);
lblLanguage.setText("Target Language");
lblLanguage.setSize(100,30);
lblLanguage.setLocation(20,150);
Label lblTargetSide = new Label(shell,SWT.NONE);
lblTargetSide.setText("Target Side");
lblTargetSide.setSize(100,30);
lblTargetSide.setLocation(20,200);
Label lblSecurity = new Label(shell,SWT.NONE);
lblSecurity.setText("Channel Security");
lblSecurity.setSize(100,30);
lblSecurity.setLocation(20,250);
Label lblImpStyle = new Label(shell,SWT.NONE);
lblImpStyle.setText("Channel Security");
lblImpStyle.setSize(100,30);
lblImpStyle.setLocation(20,300);
//Add Text widget
txtWSDLFileName = new Text(shell,SWT.BORDER);
txtWSDLFileName.setSize(150,25);
txtWSDLFileName.setLocation(140,20);
final Text txtOutputFolder=new Text(shell,SWT.BORDER);
txtOutputFolder.setSize(150,25);
txtOutputFolder.setLocation(140,95);
//Add Combo box wigdets
cmblanguageSelect=new Combo(shell,SWT.DROP_DOWN | SWT.READ_ONLY);
cmblanguageSelect.setItems(new String[] {"C","Java","C++"});
cmblanguageSelect.select(0);
cmblanguageSelect.setLocation(140,150);
cmblanguageSelect.setSize(100,25);
cmbTargetSide = new Combo(shell,SWT.DROP_DOWN | SWT.READ_ONLY);
cmbTargetSide.setItems(new String[] {"Client","Server","both"});
cmbTargetSide.select(0);
cmbTargetSide.setLocation(140,200);
cmbTargetSide.setSize(100,25);
cmbSecurity = new Combo(shell,SWT.DROP_DOWN | SWT.READ_ONLY);
cmbSecurity.setItems(new String[] {"ssl","none"});
cmbSecurity.select(0);
cmbSecurity.setLocation(140,250);
cmbSecurity.setSize(100,25);
cmbImpStyle = new Combo(shell,SWT.DROP_DOWN | SWT.READ_ONLY);
cmbImpStyle.setItems(new String[] {"struct","order","simple"});
cmbImpStyle.select(0);
cmbImpStyle.setLocation(140,300);
cmbImpStyle.setSize(100,25);
//Add Button
Button btnWSDLFile=new Button(shell,SWT.PUSH);
btnWSDLFile.setSize(100,30);
btnWSDLFile.setLocation(300,20);
btnWSDLFile.setText("Browse");
Button btnOutputFolder=new Button(shell,SWT.PUSH);
btnOutputFolder.setSize(100,30);
btnOutputFolder.setLocation(300,95);
btnOutputFolder.setText("Browse");
Button btnOk = new Button(shell,SWT.PUSH);
btnOk.setSize(50,30);
btnOk.setLocation(200,350);
btnOk.setText("OK");
//Set Actions to the buttons
btnWSDLFile.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
String[] filterExtensions = {"*.wsdl","*.xml"};
FileDialog WSDLfileDialog = new FileDialog(shell, SWT.OPEN);
WSDLfileDialog.setText("Open WSDL File");
WSDLfileDialog.setFilterPath("C:/");
WSDLfileDialog.setFilterExtensions(filterExtensions);
WSDLfileDialog.setFileName("default.wsdl");
selectedWSDLFile = WSDLfileDialog.open();
txtWSDLFileName.setText(selectedWSDLFile);
}
});
btnOutputFolder.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
DirectoryDialog outputDirectoryDialog = new DirectoryDialog(shell);
outputDirectoryDialog.setText("Select Directory");
outputDirectoryDialog.setFilterPath("C:/Program Files");
selectedDirectory = outputDirectoryDialog.open();
txtOutputFolder.setText(selectedDirectory);
}
});
btnOk.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e){
if (txtWSDLFileName.getText()==""){
System.out.println("asdadadadad");
MessageBox msgWSDLFile=new MessageBox(shell,SWT.ICON_ERROR | SWT.OK);
msgWSDLFile.setMessage("you have not specify the WSDL File");
msgWSDLFile.setText("Error");
msgWSDLFile.open();
}else{
args[0]=txtWSDLFileName.getText();
args[1]="-l"+cmblanguageSelect.getText();
args[2]="-s"+cmbTargetSide.getText();
args[3]="-c"+cmbSecurity.getText();
args[4]="-i"+cmbImpStyle.getText();
args[5]="-o"+txtOutputFolder.getText();
//Warnning Msg for Not spefify Target Directory
MessageBox msgTargetDir=new MessageBox(shell,SWT.ICON_WARNING |
SWT.OK);
msgTargetDir.setMessage("you have not specify the Target Directory");
msgTargetDir.setText("Warnning");
msgTargetDir.open();
CLArgParser data = new CLArgParser(args);
WSDL2Ws gen = null;
try {
gen = new WSDL2Ws(data);
} catch (Throwable e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
try {
gen.genarateWrappers(
null,
data.getOptionBykey("o"),
data.getOptionBykey("l"),
data.getOptionBykey("i"),
data.getOptionBykey("s"),
data.getOptionBykey("c"));
} catch (WrapperFault e2) {
// TODO Auto-generated catch block
e2.printStackTrace();
}
for(int i=0;i<args.length;i++)
System.out.println(args[i]);
}
}
});
}
/**
* TODO: Implement "selectionChanged".
* @see IWorkbenchWindowActionDelegate#selectionChanged
*/
public void selectionChanged(IAction action, ISelection selection) {
}
/**
* TODO: Implement "dispose".
* @see IWorkbenchWindowActionDelegate#dispose
*/
public void dispose() {
}
/**
* TODO: Implement "init".
* @see IWorkbenchWindowActionDelegate#init
*/
public void init(IWorkbenchWindow window) {
}
}