1 19 20 package org.netbeans.modules.ruby.rubyproject.ui.customizer; 21 22 import java.io.File ; 23 import java.io.IOException ; 24 import java.util.*; 25 import java.awt.*; 26 import java.io.BufferedReader ; 27 import java.io.InputStream ; 28 import java.io.InputStreamReader ; 29 import javax.swing.JPanel ; 30 import org.netbeans.modules.ruby.rubyproject.api.RubyInstallation; 31 import org.openide.ErrorManager; 32 33 import org.openide.util.HelpCtx; 34 import org.openide.util.RequestProcessor; 35 import org.openide.util.RequestProcessor; 36 37 41 public class CustomizerCompile extends JPanel implements HelpCtx.Provider { 42 43 44 public CustomizerCompile( RubyProjectProperties uiProperties ) { 45 initComponents(); 46 47 additionalJavacParamsJTextField.setDocument( uiProperties.JAVAC_COMPILER_ARG_MODEL ); 48 49 RequestProcessor.getDefault().post(new Runnable () { 51 52 public void run() { 53 String path = RubyInstallation.getInstance().getRuby(); 54 ProcessBuilder pb = new ProcessBuilder (path, "-help"); 55 Map<String ,String > env = pb.environment(); 56 String currentPath = env.get("PATH"); 57 58 if (currentPath == null) { 59 currentPath = ""; 60 } 61 currentPath = new File (RubyInstallation.getInstance().getRuby()).getParent() + 62 File.pathSeparator + currentPath; 63 env.put("PATH", currentPath); 64 StringBuilder sb = new StringBuilder (); 65 66 try { 67 Process process = pb.start(); 68 InputStream is = process.getInputStream(); 72 InputStreamReader isr = new InputStreamReader (is); 73 BufferedReader br = new BufferedReader (isr); 74 String line; 75 76 while ((line = br.readLine()) != null) { 77 sb.append(line); 78 sb.append("\n"); 79 } 80 process.waitFor(); 81 } 82 catch (IOException ex) { 83 ErrorManager.getDefault().notify(ex); 84 } 85 catch (InterruptedException ex) { 86 ErrorManager.getDefault().notify(ex); 87 } 88 flagsArea.setText(sb.toString()); 89 } 90 }, 50); 91 } 92 93 public HelpCtx getHelpCtx() { 94 return new HelpCtx( CustomizerCompile.class ); 95 } 96 97 98 103 private void initComponents() { 105 java.awt.GridBagConstraints gridBagConstraints; 106 107 additionalJavacParamsJLabel = new javax.swing.JLabel (); 108 additionalJavacParamsJTextField = new javax.swing.JTextField (); 109 additionalJavacParamsExampleJLabel = new javax.swing.JLabel (); 110 jScrollPane1 = new javax.swing.JScrollPane (); 111 flagsArea = new javax.swing.JTextArea (); 112 113 setLayout(new java.awt.GridBagLayout ()); 114 115 additionalJavacParamsJLabel.setDisplayedMnemonic(org.openide.util.NbBundle.getMessage (CustomizerCompile.class,"MNE_AdditionalCompilerOptions").charAt(0)); 116 additionalJavacParamsJLabel.setLabelFor(additionalJavacParamsJTextField); 117 org.openide.awt.Mnemonics.setLocalizedText(additionalJavacParamsJLabel, org.openide.util.NbBundle.getMessage (CustomizerCompile.class,"LBL_AdditionalCompilerOptions")); 118 gridBagConstraints = new java.awt.GridBagConstraints (); 119 gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; 120 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 121 gridBagConstraints.insets = new java.awt.Insets (0, 0, 5, 12); 122 add(additionalJavacParamsJLabel, gridBagConstraints); 123 gridBagConstraints = new java.awt.GridBagConstraints (); 124 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 125 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 126 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 127 gridBagConstraints.weightx = 1.0; 128 gridBagConstraints.insets = new java.awt.Insets (0, 0, 5, 0); 129 add(additionalJavacParamsJTextField, gridBagConstraints); 130 additionalJavacParamsJTextField.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage (CustomizerCompile.class,"AD_AdditionalCompilerOptions")); 131 132 org.openide.awt.Mnemonics.setLocalizedText(additionalJavacParamsExampleJLabel, org.openide.util.NbBundle.getMessage (CustomizerCompile.class,"LBL_AdditionalCompilerOptionsExample")); 133 gridBagConstraints = new java.awt.GridBagConstraints (); 134 gridBagConstraints.gridx = 1; 135 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 136 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 137 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; 138 gridBagConstraints.insets = new java.awt.Insets (0, 0, 12, 0); 139 add(additionalJavacParamsExampleJLabel, gridBagConstraints); 140 141 flagsArea.setColumns(20); 142 flagsArea.setEditable(false); 143 flagsArea.setLineWrap(true); 144 flagsArea.setRows(5); 145 flagsArea.setWrapStyleWord(true); 146 jScrollPane1.setViewportView(flagsArea); 147 148 gridBagConstraints = new java.awt.GridBagConstraints (); 149 gridBagConstraints.gridx = 0; 150 gridBagConstraints.gridy = 2; 151 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 152 gridBagConstraints.gridheight = java.awt.GridBagConstraints.REMAINDER; 153 gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; 154 gridBagConstraints.weightx = 1.0; 155 gridBagConstraints.weighty = 1.0; 156 gridBagConstraints.insets = new java.awt.Insets (12, 0, 0, 0); 157 add(jScrollPane1, gridBagConstraints); 158 } 160 161 private javax.swing.JLabel additionalJavacParamsExampleJLabel; 163 private javax.swing.JLabel additionalJavacParamsJLabel; 164 private javax.swing.JTextField additionalJavacParamsJTextField; 165 private javax.swing.JTextArea flagsArea; 166 private javax.swing.JScrollPane jScrollPane1; 167 169 170 171 } 172 | Popular Tags |