Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » How to access Path from preference page and use it in Button Programming(Fetch path from preference page and use it in Button program to run)
How to access Path from preference page and use it in Button Programming [message #707359] Mon, 01 August 2011 14:53
SHUBHAM is currently offline SHUBHAMFriend
Messages: 4
Registered: July 2011
Junior Member
Hello
I have made a preference page in Eclipse and that is using FileFieldEditor to select ".bat" and ".exe" file. I want to fetch path from the selected FileFieldEditor and use it in different plugin to run that file when a button is pressed on workbench.

The preference page programming is

public SAML() {
super(GRID);
setPreferenceStore(RmpPlugin.getDefault().getPreferenceStore());
setDescription("Browse Appropriate files");
}

public FileFieldEditor f;
public FileFieldEditor f1;
public void createFieldEditors() {
f=new FileFieldEditor(PreferenceConstants.P_PATH,
"&Prism.bat File:", getFieldEditorParent());
addField(f);

f1=new FileFieldEditor(PreferenceConstants.P_PATH1,
"&NuSMV Application File:", getFieldEditorParent());
addField(f1);
}


and Button programming is

try{
IPreferenceStore store = plugin.getPreferenceStore();

ProcessBuilder pb=new ProcessBuilder(store.getString(PreferenceConstants.P_PATH));
pb.directory(new File(store.getString(PreferenceConstants.P_PATH)));
Process p=pb.start();

BufferedReader input = new BufferedReader(new InputStreamReader(p.getInputStream()));

String in;
while((in = input.readLine()) != null) {
out.println(in);
}


int exitVal=p.waitFor();

if(exitVal==0)
{
out.println("Printing on console");

}
else
out.println("Process failed");
}
catch (Exception e)
{
out.println(e.toString());
e.printStackTrace();

}

When i am setting the file from preference page, and clicking on the button on workbench then it says that file not found.

Please suggest me how to fix it.
Any effort would be appreciated.
Thank You

Button programming is in different package and PreferencePage programming is in different package.
Previous Topic:(no subject)
Next Topic:(no subject)
Goto Forum:
  


Current Time: Fri Apr 19 01:23:41 GMT 2024

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

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

Back to the top