Skip to main content



      Home
Home » Newcomers » Newcomers » What is the problem in calling org.apache.commons.cli.Option from EditorPart
What is the problem in calling org.apache.commons.cli.Option from EditorPart [message #229122] Fri, 24 August 2007 06:00
Eclipse UserFriend
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
Previous Topic:Inserting a real tab if the editor is configured to use spaces
Next Topic:Changing eclipse font dimension
Goto Forum:
  


Current Time: Mon Nov 10 18:04:01 EST 2025

Powered by FUDForum. Page generated in 0.28436 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top