• <bdo id='0oWnd'></bdo><ul id='0oWnd'></ul>

        <i id='0oWnd'><tr id='0oWnd'><dt id='0oWnd'><q id='0oWnd'><span id='0oWnd'><b id='0oWnd'><form id='0oWnd'><ins id='0oWnd'></ins><ul id='0oWnd'></ul><sub id='0oWnd'></sub></form><legend id='0oWnd'></legend><bdo id='0oWnd'><pre id='0oWnd'><center id='0oWnd'></center></pre></bdo></b><th id='0oWnd'></th></span></q></dt></tr></i><div id='0oWnd'><tfoot id='0oWnd'></tfoot><dl id='0oWnd'><fieldset id='0oWnd'></fieldset></dl></div>
      1. <small id='0oWnd'></small><noframes id='0oWnd'>

        <legend id='0oWnd'><style id='0oWnd'><dir id='0oWnd'><q id='0oWnd'></q></dir></style></legend>
        <tfoot id='0oWnd'></tfoot>
      2. JAVA:如何从首选项页面访问文件路径并在编程代码中使用它

        JAVA : How to access file path from preference page and use it in Programming code(JAVA:如何从首选项页面访问文件路径并在编程代码中使用它)

          • <bdo id='3sGyc'></bdo><ul id='3sGyc'></ul>
              <tfoot id='3sGyc'></tfoot>
                  <tbody id='3sGyc'></tbody>
                <legend id='3sGyc'><style id='3sGyc'><dir id='3sGyc'><q id='3sGyc'></q></dir></style></legend>
              • <i id='3sGyc'><tr id='3sGyc'><dt id='3sGyc'><q id='3sGyc'><span id='3sGyc'><b id='3sGyc'><form id='3sGyc'><ins id='3sGyc'></ins><ul id='3sGyc'></ul><sub id='3sGyc'></sub></form><legend id='3sGyc'></legend><bdo id='3sGyc'><pre id='3sGyc'><center id='3sGyc'></center></pre></bdo></b><th id='3sGyc'></th></span></q></dt></tr></i><div id='3sGyc'><tfoot id='3sGyc'></tfoot><dl id='3sGyc'><fieldset id='3sGyc'></fieldset></dl></div>

                  <small id='3sGyc'></small><noframes id='3sGyc'>

                1. 本文介绍了JAVA:如何从首选项页面访问文件路径并在编程代码中使用它的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我的 ProcessBuilder 类 ---

                  My ProcessBuilder class ---

                   public class HelloWorldAction implements IWorkbenchWindowActionDelegate {
                  IWorkbenchWindow activeWindow = null;
                  
                  public void run(IAction proxyAction) {
                  
                      MessageConsole myConsole = null;
                      String name = "outputConsole";
                  
                      ConsolePlugin plugin = ConsolePlugin.getDefault();
                      IConsoleManager conMan = plugin.getConsoleManager();
                      IConsole[] existing = conMan.getConsoles();
                      for (int i = 0; i < existing.length; i++)
                         if (name.equals(existing[i].getName()))
                             myConsole = (MessageConsole) existing[i];
                  
                        //no console found, so create a new one
                      if (myConsole == null)
                          myConsole = new MessageConsole(name, null);
                  
                      conMan.addConsoles(new IConsole[]{myConsole});
                  
                      IWorkbench wb = PlatformUI.getWorkbench();
                      IWorkbenchWindow win = wb.getActiveWorkbenchWindow();
                      IWorkbenchPage page = win.getActivePage();
                  
                      String id = IConsoleConstants.ID_CONSOLE_VIEW;
                      try
                      {
                          IConsoleView view = (IConsoleView) page.showView(id);
                          view.display(myConsole);
                  
                      }
                      catch (Exception e)
                      {
                  
                      }
                  
                      MessageConsoleStream out = myConsole.newMessageStream();
                      out.println("Prism Button Works !");
                  
                  
                      try {           //to clear the console on every click of button
                  
                          IViewPart view = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().findView(IConsoleConstants.ID_CONSOLE_VIEW);
                          if (view != null) {
                              (myConsole).clearConsole();
                          }
                          ProcessBuilder pb=new ProcessBuilder("C:\Program Files\prism-4.0\bin\prism.bat");
                          pb.directory(new File("C:\Program Files\prism-4.0\bin"));
                          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();
                  
                          }
                      } 
                  // IActionDelegate method
                  public void selectionChanged(IAction proxyAction, ISelection selection) {
                      // do nothing, action is not dependent on the selection
                  }
                  
                  // IWorkbenchWindowActionDelegate method
                  public void init(IWorkbenchWindow window) {
                      activeWindow = window;
                  
                  }
                  
                  // IWorkbenchWindowActionDelegate method
                  public void dispose() {
                      //  nothing to do
                  }
                  

                  }

                  我的 FileFieldEditorClass

                  My FileFieldEditorClass

                     public class SAML
                  extends FieldEditorPreferencePage
                  implements IWorkbenchPreferencePage {
                  
                  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);
                  }
                  public void init(IWorkbench workbench) {
                  }
                  

                  }

                  FileFieldEditor 类在 com.myplugin.rmp.preferences 包中并且 ProcessBuilder 类在 com.myplugin.rmp 包中,

                  FileFieldEditor class is in com.myplugin.rmp.preferences package and ProcessBuilder class is in com.myplugin.rmp package,

                  现在建议我访问的方式.

                  Now suggest me the way to way to access.

                  推荐答案

                  在你构建 ProcessBuilder 的 try-block 中试试这个:

                  Try this inside your try-block where you construct your ProcessBuilder:

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

                  这篇关于JAVA:如何从首选项页面访问文件路径并在编程代码中使用它的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Bytecode features not available in the Java language(Java 语言中不可用的字节码功能)
                  ClassCastException because of classloaders?(ClassCastException 因为类加载器?)
                  How can I add a Javaagent to a JVM without stopping the JVM?(如何在不停止 JVM 的情况下将 Javaagent 添加到 JVM?)
                  Cannot load 64-bit SWT libraries on 32-bit JVM ( replacing SWT file )(无法在 32 位 JVM 上加载 64 位 SWT 库(替换 SWT 文件))
                  Encourage the JVM to GC rather than grow the heap?(鼓励 JVM 进行 GC 而不是增加堆?)
                  Why a sawtooth shaped graph?(为什么是锯齿形图形?)
                2. <small id='nqcko'></small><noframes id='nqcko'>

                3. <i id='nqcko'><tr id='nqcko'><dt id='nqcko'><q id='nqcko'><span id='nqcko'><b id='nqcko'><form id='nqcko'><ins id='nqcko'></ins><ul id='nqcko'></ul><sub id='nqcko'></sub></form><legend id='nqcko'></legend><bdo id='nqcko'><pre id='nqcko'><center id='nqcko'></center></pre></bdo></b><th id='nqcko'></th></span></q></dt></tr></i><div id='nqcko'><tfoot id='nqcko'></tfoot><dl id='nqcko'><fieldset id='nqcko'></fieldset></dl></div>
                  <legend id='nqcko'><style id='nqcko'><dir id='nqcko'><q id='nqcko'></q></dir></style></legend>
                    <tbody id='nqcko'></tbody>
                    • <bdo id='nqcko'></bdo><ul id='nqcko'></ul>

                        <tfoot id='nqcko'></tfoot>