| What is the problem in calling org.apache.commons.cli.Option from EditorPart [message #229122] |
Fri, 24 August 2007 06:00 |
Eclipse User |
|
|
|
Originally posted by: vanithavn.hcl.in
hello all
I have created a class called CommonsCli.java for implementing CLI in my
RCP application.
import org.apache.commons.cli.BasicParser;
import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.Option;
import org.apache.commons.cli.Options;
import org.apache.commons.cli.ParseException;
public class CommonsCli {
private Options connectOption;
private Option userOption;
private Option pwdOption;
private String result;
private CommandLine cmd;
private BasicParser parser;
private String[] input;
public CommonsCli(){
System.out.println(" commonsCLi constructor");
}
public void setCommand(String arg){
try {
this.input = arg.split(" ");
} catch (Exception e) {
e.printStackTrace();
}
}
public void processCommand(){
try {
connectOption = new Options();
userOption = new Option("u","user",true,"UserName");
pwdOption = new Option("p","pwd",true,"Password");
connectOption.addOption(userOption);
connectOption.addOption(pwdOption);
parser = new BasicParser();
cmd = parser.parse(connectOption, input);
result = "your user name and pwd is "+cmd.getOptionValue("u")+"
"+cmd.getOptionValue("p");
} catch (ParseException e) {
e.printStackTrace();
result = e.getMessage();
}
}
public String getResult() {
return result;
}
}
I have another one class called CLIEditor.java which extends EditorPart.
I want to invoke NewCli methods from my CLIEditor class. But when i
instantiate it like
NewCli newCli = NewCli();
from CLIEditor class it is neither prints the statement in NewCli
constructor nor throws any exception or error. But structs there without
opening the edior.(Because of the statement connectOption = new Options();)
What am i missing? Why some internal exception is thrown.
Thanks in advance
VV
|
|
|
Powered by
FUDForum. Page generated in 0.28436 seconds