Math2mat
|
00001 00020 package m2m.frontend.actions; 00021 00022 import org.eclipse.jface.dialogs.Dialog; 00023 import org.eclipse.swt.SWT; 00024 import org.eclipse.swt.layout.GridData; 00025 import org.eclipse.swt.layout.GridLayout; 00026 import org.eclipse.swt.widgets.Button; 00027 import org.eclipse.swt.widgets.Combo; 00028 import org.eclipse.swt.widgets.Composite; 00029 import org.eclipse.swt.widgets.Control; 00030 import org.eclipse.swt.widgets.DirectoryDialog; 00031 import org.eclipse.swt.widgets.Display; 00032 import org.eclipse.swt.widgets.Event; 00033 import org.eclipse.swt.widgets.FileDialog; 00034 import org.eclipse.swt.widgets.Group; 00035 import org.eclipse.swt.widgets.Label; 00036 import org.eclipse.swt.widgets.Listener; 00037 import org.eclipse.swt.widgets.MessageBox; 00038 import org.eclipse.swt.widgets.Shell; 00039 import org.eclipse.swt.widgets.Text; 00040 import org.eclipse.ui.IWorkbenchWindow; 00041 00042 import m2m.frontend.actions.M2MAction; 00043 import m2m.backend.project.ExternalToolsProperties; 00044 00045 public class ConfigureExternalToolsAction extends M2MAction{ 00046 00047 private String selectedPath; 00048 00049 public ConfigureExternalToolsAction(IWorkbenchWindow window, String label) { 00050 super(window,label); 00051 00052 // The id is used to refer to the action in a menu or toolbar 00053 setId(ICommandIds.CMD_CONFOPTIM); 00054 00055 // Associate the action with a pre-defined command, to allow key bindings. 00056 setActionDefinitionId(ICommandIds.CMD_CONFOPTIM); 00057 } 00058 00062 public void run() { 00063 Display display = window.getShell().getDisplay(); 00064 final Shell shell = new Shell(display); 00065 shell.setText("External tools configuration"); 00066 ExternalToolsPropertiesDlg dlg=new ExternalToolsPropertiesDlg(shell); 00067 dlg.open(); 00068 } 00069 00070 00071 00072 class ExternalToolsPropertiesDlg extends Dialog { 00073 00074 private Text ubiduleIP; 00075 private Text isePath; 00076 private Text xilinxLicense; 00077 private Text libPath; 00078 private Text octavePath; 00079 private Text vsimPath; 00080 private Text dotPath; 00081 private Combo simulationFiles; 00082 private Combo simulator; 00083 00084 00085 public ExternalToolsPropertiesDlg(Shell parentShell) { 00086 super(parentShell); 00087 } 00088 00089 protected void configureShell(Shell shell) { 00090 super.configureShell(shell); 00091 shell.setText("External tools properties"); 00092 } 00093 00094 00095 @Override 00096 public void create() { 00097 super.create(); 00098 } 00099 00100 @Override 00101 protected Control createDialogArea(Composite parent) { 00102 GridLayout layout = new GridLayout(); 00103 parent.setLayout(layout); 00104 00105 GridLayout pathLayout = new GridLayout(); 00106 pathLayout.numColumns = 3; 00107 00108 GridLayout buttonLayout = new GridLayout(); 00109 buttonLayout.numColumns = 2; 00110 00111 Group pathExec = new Group(parent, SWT.SHADOW_ETCHED_IN); 00112 //pathExec.setText("External tools configuration"); 00113 pathExec.setBounds(parent.getClientArea()); 00114 pathExec.setLayout(layout); 00115 00116 Composite pathComp = new Composite(pathExec, SWT.FILL); 00117 pathComp.setLayout(pathLayout); 00118 00119 Composite buttonComp = new Composite(pathExec, SWT.RIGHT); 00120 buttonComp.setLayout(buttonLayout); 00121 00122 00124 // Library path selection // 00126 Label libPathLabel = new Label(pathComp, SWT.NONE); 00127 libPathLabel.setText("Lib path :"); 00128 libPathLabel.setBounds(parent.getClientArea()); 00129 libPathLabel.setLocation(10, 25); 00130 libPathLabel.pack(); 00131 00132 //Octave path entry placement 00133 GridData libPathGridDataText = new GridData(); 00134 libPathGridDataText.widthHint = 250; 00135 libPathGridDataText.heightHint = 15; 00136 00137 //create Octave path entry 00138 libPath = new Text(pathComp, SWT.NONE); 00139 libPath.setBounds(105, 23, 1500, 25); 00140 libPath.setLocation(105, 23); 00141 libPath.setLayoutData(libPathGridDataText); 00142 libPath.pack(); 00143 00144 //create "browse" button for the Octave path entry 00145 Button findlibPath = new Button(pathComp, SWT.CENTER); 00146 findlibPath.setBounds(parent.getBounds()); 00147 findlibPath.setText("Browse..."); 00148 findlibPath.setLocation(250, 23); 00149 findlibPath.pack(); 00150 00151 //"browse" button's listener 00152 class openListener implements Listener { 00153 private Text textEntry = null; 00154 00155 public openListener(Text textEntry) { 00156 this.textEntry = textEntry; 00157 } 00158 00159 @Override 00160 public void handleEvent(Event event) { 00161 FileDialog dialog = new FileDialog(new Shell(), SWT.OPEN);//java.awt.FileDialog.LOAD 00162 dialog.setText("Choose path..."); 00163 selectedPath = dialog.open(); 00164 if(selectedPath != null) 00165 textEntry.setText(selectedPath); 00166 } 00167 }; 00168 00169 //"browse" button's listener 00170 class openDirListener implements Listener { 00171 private Text textEntry = null; 00172 private Shell shell; 00173 00174 public openDirListener(Text textEntry,Shell shell) { 00175 this.textEntry = textEntry; 00176 this.shell=shell; 00177 } 00178 00179 @Override 00180 public void handleEvent(Event event) { 00181 DirectoryDialog dlg = new DirectoryDialog(shell); 00182 dlg.setText("Choose a directory"); 00183 dlg.setMessage("Please choose a directory"); 00184 dlg.setFilterPath(textEntry.getText()); 00185 String dir=dlg.open(); 00186 if (dir!=null) 00187 textEntry.setText(dir); 00188 } 00189 }; 00190 00191 findlibPath.addListener(SWT.Selection, new openDirListener(libPath,this.getShell())); 00192 00193 00194 00196 // Octave path selection // 00198 Label octavePathLabel = new Label(pathComp, SWT.NONE); 00199 octavePathLabel.setText("Octave path :"); 00200 octavePathLabel.setBounds(parent.getClientArea()); 00201 octavePathLabel.setLocation(10, 25); 00202 octavePathLabel.pack(); 00203 00204 //Octave path entry placement 00205 GridData octaveGridDataText = new GridData(); 00206 octaveGridDataText.widthHint = 250; 00207 octaveGridDataText.heightHint = 15; 00208 00209 //create Octave path entry 00210 octavePath = new Text(pathComp, SWT.NONE); 00211 octavePath.setBounds(105, 23, 1500, 25); 00212 octavePath.setLocation(105, 23); 00213 octavePath.setLayoutData(octaveGridDataText); 00214 octavePath.pack(); 00215 00216 //create "browse" button for the Octave path entry 00217 Button findOctavePath = new Button(pathComp, SWT.CENTER); 00218 findOctavePath.setBounds(parent.getBounds()); 00219 findOctavePath.setText("Browse..."); 00220 findOctavePath.setLocation(250, 23); 00221 findOctavePath.pack(); 00222 00223 00224 findOctavePath.addListener(SWT.Selection, new openListener(octavePath)); 00225 00227 // Vsim path selection // 00229 Label vsimPathLabel = new Label(pathComp, SWT.NONE); 00230 vsimPathLabel.setText("Vsim path :"); 00231 vsimPathLabel.setBounds(parent.getClientArea()); 00232 vsimPathLabel.setLocation(10, 50); 00233 vsimPathLabel.pack(); 00234 00235 //Octave path entry placement 00236 GridData vsimGridDataText = new GridData(); 00237 vsimGridDataText.widthHint = 250; 00238 vsimGridDataText.heightHint = 15; 00239 00240 //create Octave path entry 00241 vsimPath = new Text(pathComp, SWT.NONE); 00242 vsimPath.setBounds(parent.getBounds()); 00243 vsimPath.setLocation(105, 50); 00244 vsimPath.setLayoutData(vsimGridDataText); 00245 vsimPath.pack(); 00246 00247 //create "browse" button for the Octave path entry 00248 Button findVsimPath = new Button(pathComp, SWT.NONE); 00249 findVsimPath.setBounds(parent.getBounds()); 00250 findVsimPath.setText("Browse..."); 00251 findVsimPath.setLocation(250, 50); 00252 findVsimPath.pack(); 00253 00254 findVsimPath.addListener(SWT.Selection, new openListener(vsimPath)); 00255 00256 00258 // ISE path selection // 00260 Label isePathLabel = new Label(pathComp, SWT.NONE); 00261 isePathLabel.setText("Xilinx ISE path :"); 00262 isePathLabel.setBounds(parent.getClientArea()); 00263 isePathLabel.setLocation(10, 50); 00264 isePathLabel.pack(); 00265 00266 //ISE path entry placement 00267 GridData iseGridDataText = new GridData(); 00268 iseGridDataText.widthHint = 250; 00269 iseGridDataText.heightHint = 15; 00270 00271 //create ISE path entry 00272 isePath = new Text(pathComp, SWT.NONE); 00273 isePath.setBounds(parent.getBounds()); 00274 isePath.setLocation(105, 50); 00275 isePath.setLayoutData(iseGridDataText); 00276 isePath.pack(); 00277 00278 //create "browse" button for the ISE path entry 00279 Button findIsePath = new Button(pathComp, SWT.NONE); 00280 findIsePath.setBounds(parent.getBounds()); 00281 findIsePath.setText("Browse..."); 00282 findIsePath.setLocation(250, 50); 00283 findIsePath.pack(); 00284 00285 findIsePath.addListener(SWT.Selection, new openDirListener(isePath,this.getShell())); 00286 00287 00288 00290 // dot path selection // 00292 Label dotPathLabel = new Label(pathComp, SWT.NONE); 00293 dotPathLabel.setText("Dot path :"); 00294 dotPathLabel.setBounds(parent.getClientArea()); 00295 dotPathLabel.setLocation(10, 50); 00296 dotPathLabel.pack(); 00297 00298 //dot path entry placement 00299 GridData dotGridDataText = new GridData(); 00300 dotGridDataText.widthHint = 250; 00301 dotGridDataText.heightHint = 15; 00302 00303 //create dot path entry 00304 dotPath = new Text(pathComp, SWT.NONE); 00305 dotPath.setBounds(parent.getBounds()); 00306 dotPath.setLocation(105, 50); 00307 dotPath.setLayoutData(dotGridDataText); 00308 dotPath.pack(); 00309 00310 //create "browse" button for the dot path entry 00311 Button findDotPath = new Button(pathComp, SWT.NONE); 00312 findDotPath.setBounds(parent.getBounds()); 00313 findDotPath.setText("Browse..."); 00314 findDotPath.setLocation(250, 50); 00315 findDotPath.pack(); 00316 00317 findDotPath.addListener(SWT.Selection, new openListener(dotPath)); 00318 00319 00320 00321 00323 // Simulation files selection // 00325 Label simFilesLabel = new Label(pathComp, SWT.NONE); 00326 simFilesLabel.setText("Simulation files :"); 00327 simFilesLabel.setBounds(parent.getClientArea()); 00328 simFilesLabel.setLocation(10, 50); 00329 simFilesLabel.pack(); 00330 00331 //dot path entry placement 00332 GridData simFilesText = new GridData(); 00333 simFilesText.widthHint = 250; 00334 simFilesText.heightHint = 15; 00335 00336 //create dot path entry 00337 simulationFiles = new Combo(pathComp, SWT.NONE); 00338 simulationFiles.add("Original OVM"); 00339 simulationFiles.add("M2M OVM"); 00340 simulationFiles.add("Original UVM"); 00341 00342 Label emptyLabel = new Label(pathComp, SWT.NONE); 00343 emptyLabel.setText(""); 00344 00345 00347 // Simulator selection // 00349 Label simulatorLabel = new Label(pathComp, SWT.NONE); 00350 simulatorLabel.setText("Simulator :"); 00351 simulatorLabel.setBounds(parent.getClientArea()); 00352 simulatorLabel.setLocation(10, 50); 00353 simulatorLabel.pack(); 00354 00355 //dot path entry placement 00356 GridData simulatorText = new GridData(); 00357 simulatorText.widthHint = 250; 00358 simulatorText.heightHint = 15; 00359 00360 //create dot path entry 00361 simulator = new Combo(pathComp, SWT.NONE); 00362 for(int i=0;i<ExternalToolsProperties.simulatorTypes.length;i++) 00363 simulator.add(ExternalToolsProperties.simulatorTypes[i]); 00364 00365 Label emptyLabel0 = new Label(pathComp, SWT.NONE); 00366 emptyLabel0.setText(""); 00367 00369 // Xilinx license // 00371 Label xilinxLicenseLabel = new Label(pathComp, SWT.NONE); 00372 xilinxLicenseLabel.setText("Xilinx license :"); 00373 xilinxLicenseLabel.setBounds(parent.getClientArea()); 00374 xilinxLicenseLabel.setLocation(10, 50); 00375 xilinxLicenseLabel.pack(); 00376 00377 //dot path entry placement 00378 GridData xilinxLicenseText = new GridData(); 00379 xilinxLicenseText.widthHint = 250; 00380 xilinxLicenseText.heightHint = 15; 00381 00382 //create dot path entry 00383 xilinxLicense = new Text(pathComp, SWT.NONE); 00384 xilinxLicense.setBounds(parent.getBounds()); 00385 xilinxLicense.setLocation(105, 50); 00386 xilinxLicense.setLayoutData(xilinxLicenseText); 00387 xilinxLicense.pack(); 00388 00389 Label emptyLabel1 = new Label(pathComp, SWT.NONE); 00390 emptyLabel1.setText(""); 00391 00393 // Ubidule IP // 00395 Label ubiduleIPLabel = new Label(pathComp, SWT.NONE); 00396 ubiduleIPLabel.setText("Ubidule IP :"); 00397 ubiduleIPLabel.setBounds(parent.getClientArea()); 00398 ubiduleIPLabel.setLocation(10, 50); 00399 ubiduleIPLabel.pack(); 00400 00401 //dot path entry placement 00402 GridData ubiduleIPText = new GridData(); 00403 ubiduleIPText.widthHint = 250; 00404 ubiduleIPText.heightHint = 15; 00405 00406 //create dot path entry 00407 ubiduleIP = new Text(pathComp, SWT.NONE); 00408 ubiduleIP.setBounds(parent.getBounds()); 00409 ubiduleIP.setLocation(105, 50); 00410 ubiduleIP.setLayoutData(ubiduleIPText); 00411 ubiduleIP.pack(); 00412 00413 Label emptyLabel2 = new Label(pathComp, SWT.NONE); 00414 emptyLabel2.setText(""); 00415 00416 00417 00418 00419 libPath.setText(ExternalToolsProperties.getReference().getLibPath()); 00420 isePath.setText(ExternalToolsProperties.getReference().getIsePath()); 00421 vsimPath.setText(ExternalToolsProperties.getReference().getVsimPath()); 00422 octavePath.setText(ExternalToolsProperties.getReference().getOctavePath()); 00423 dotPath.setText(ExternalToolsProperties.getReference().getDotPath()); 00424 simulationFiles.select(ExternalToolsProperties.getReference().getSimulationFiles()); 00425 simulator.select(ExternalToolsProperties.getReference().getSimulator()); 00426 xilinxLicense.setText(ExternalToolsProperties.getReference().getXilinxLicense()); 00427 ubiduleIP.setText(ExternalToolsProperties.getReference().getUbiduleIP()); 00428 00429 00430 return parent; 00431 } 00432 00433 00434 protected void okPressed() { 00435 ExternalToolsProperties props = ExternalToolsProperties.getReference(); 00436 00437 if (libPath.getText().compareTo(props.getLibPath())!=0) { 00438 MessageBox mess=new MessageBox(window.getShell(),SWT.OK); 00439 mess.setMessage("You changed the location of the lib files. Please restart the application."); 00440 mess.setText("Important notice"); 00441 mess.open(); 00442 } 00443 00444 props.setLibPath(libPath.getText()); 00445 props.setOctavePath(octavePath.getText()); 00446 props.setVsimPath(vsimPath.getText()); 00447 props.setIsePath(isePath.getText()); 00448 props.setDotPath(dotPath.getText()); 00449 props.setSimulationFiles(simulationFiles.getSelectionIndex()); 00450 props.setSimulator(simulator.getSelectionIndex()); 00451 props.setXilinxLicense(xilinxLicense.getText()); 00452 props.setUbiduleIP(ubiduleIP.getText()); 00453 00454 this.close(); 00455 } 00456 00457 } 00458 00459 }