/* * v1.0 Edited by Jing and Omair (05/11/2005) * -Fixed FileDialog box; made modal with respect to "this class" so that when it is clicked it stays on top. * * -Fixed Save as .bat --> so that now when there's incorrect *.ma filename or if there's no filename * you won't be able to save a *.bat file. * * -Fixed Error in testString() * currently the function is setup so that it seeks numbers in the string [no matter where] and contatenates them, adds 1 to the concatenated number and appends the number to the end of the string. * so if you make a file name called 4567i and you overwrite the file [using automatic] you will get a new file called: 4567i4568 when it should be 4567i1 * Fix: rewrote the function by checking from the back instead of from the front to find the location of a character. Then the numbers [after the char] will be chopped off as a substring and returned. * * -Fixed Error in setDigit() * When trying to save a *.bat file called "2" and saving another file called "2" using the automatic save will result in either window not responding or nothing happens. * Fix: altered the setDigit() [no more index out of bounds exception] so that when filename is a number it returns a string representation of the newly updated number. * * -Fixed Error when closing window * Bug: When window is first opened, it will not close when clicking on the "X" (close button at the top right corner of window) * Fix: set OK2Close = true by default so that window will close. * * -Fixed Error for when canceling browse * BUG: When there's a file in the text box [text box filled] beside the browse button and if browse is clicked and you hit cancel to "cancel" file selection. * The file name will be erased from the text box [empty text box] and you will have to reselect the file. * Fix: Check for if the file returned from the file selection is equal to "" [nothing] if so then don't update text box field. * * -Fixed error which occurs if the root directory of eclipse has spaces in it * Bug: If the root directory of eclipse has spaces in it then this button didn't function at all * Fix: We need to enclose IPath objects namely path and internalPath in double quotes by simply concatenating * their string representations by "/"" * * -Fixed error which occurs if any fileNames have a space in them * Bug: If the for e.g. say a .val file has spaces in it then an error will occur terminating the function * immediately * Fix: All filenames were enclosed in double quotes which was done in collect parameters */ package CELLDEV.buttons; import java.io.BufferedReader; import java.io.File; import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; import java.io.InputStreamReader; import org.eclipse.core.resources.IContainer; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.IWorkspaceRoot; import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IPath; import org.eclipse.jface.dialogs.Dialog; import org.eclipse.jface.dialogs.IDialogConstants; import org.eclipse.jface.dialogs.IInputValidator; import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.swt.SWT; import org.eclipse.swt.events.KeyEvent; import org.eclipse.swt.events.KeyListener; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.graphics.Color; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.FileDialog; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.MessageBox; import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Text; import org.eclipse.ui.PlatformUI; import CDBuilder.CDBuilderPlugin; import CDBuilder.buttons.OverwriteGui; import CDBuilder.console.ConsoleDocument; import CDBuilder.console.StreamHandler; /** * @author ssim, Ali Monadi * * This class is responsible for the popup gui which appears when the GraphAction button * is pressed */ public class CountMessageGUI extends Dialog{ private Shell parent; private String title; private String message1; private String message2; private String message3; private String message4; private String message5; private static String logValue; private static String outValue; private static String timeValue; private static String advValue; private Button simuButton; private Button doneButton; private Button killButton; private Button saveSetButton; private Button loadSetButton; private Button saveBatButton; private Button loadBatButton; private Label lable; private Button checkBoxOut; private Button checkBoxAdv; private Button fileButtonlog; private Button fileButtonOut; private Button checkBoxComment; private Button checkBoxEOF; private Text textlog; private Text textHour, textMin, textSec, textmilliS; private Text textAdv; private Text textComment; private static boolean checkedAdv = false; private boolean simuKilled = false; private static boolean checkedComment = false; private RunSimu rsimu; private Process simuProcess; private Label errorMessageLabel; private IInputValidator validator; private IPath path; private IPath internalPath; private String logFileName; private Composite composite; private int n; //window will only cose if OK2Close is true. This is set to true automatically at beginning [not set in constructor] private boolean OK2Close=true; class conWrite implements Runnable { String line; public conWrite(String line) { this.line = line; } public void run() { ConsoleDocument.getCDOS().set(line); } } class RunSimu extends Thread { Dialog d; String command; public RunSimu(String command, Dialog d) { this.command = command; this.d = d; } public void run() { try { ConsoleDocument cdos = ConsoleDocument.getCDOS(); IContainer container = ResourcesPlugin.getWorkspace().getRoot().getContainerForLocation(path); FileWriter tempFile = new FileWriter(path.append("tempSimu.bat").toString()); //testing purposes tempFile.write("\""+internalPath+"contart\"" + command); //internalPath is where the cd++.exe is located tempFile.close(); simuProcess = Runtime.getRuntime().exec("cmd /c \"" + path.toString() + "tempSimu.bat\"", null, new File(path.toString())); StreamHandler outputHandler = new StreamHandler(simuProcess.getInputStream(), "OUTPUT", true); StreamHandler errorHandler = new StreamHandler(simuProcess.getErrorStream(), "ERROR", true); outputHandler.start(); errorHandler.start(); int exitVal = simuProcess.waitFor(); container.refreshLocal(1,null); ResourcesPlugin.getWorkspace().getRoot().getFileForLocation(path.append("tempSimu.bat")).delete(true,null); Display.getDefault().syncExec(new Runnable() { public void run(){ doneButton.setEnabled(true); killButton.setEnabled(false); simuButton.setEnabled(true); d.close(); } }); if (simuKilled) { Display.getDefault().syncExec(new conWrite("***User has killed the simulation***" + "\n")); simuKilled = false; } } catch (Throwable T) { T.printStackTrace(); } } } public CountMessageGUI(Shell parentShell,IPath path, IPath internalPath, String logFileName) { super(parentShell); parent = parentShell; this.title = "Count Messages"; message1 = "Log file (.log)"; message2 = "Output file name"; message3 = "Enter stop time (hour: minute: second: millisecond):"; message4 = "Advanced Users Only. Enter desired parameters:"; message5 = "Comments"; this.logFileName = logFileName; this.internalPath = internalPath;// internal directory this.path = path; // path of project } /* * This function will check to see if the file name entered in the * * @param Text name, the text box value containing the file name * @param String extention, the extention the name shoule have * @return a string containing the file name with the proper extention */ public String checkExtention(Text name , String extention){ String fileName = name.getText().trim(); if(!fileName.endsWith(extention) && !fileName.endsWith(extention.toUpperCase())) return fileName.concat(extention); return fileName; } /* * checks to see if the given string matches a file name found in the project directory * * @param String file, name of file * @param String errMsg, message to be displayed IF file was not found */ private boolean checkFileExistence(String file, String errMsg){ IWorkspaceRoot root = (IWorkspaceRoot)PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getInput(); IResource[] files; IFile fileHandle = null; try { files = root.getContainerForLocation(path).members(); for(int i=0;i99){ textHour.setText("00"); }else{ textHour.setText(value.toString()); } } if(e.keyCode == SWT.ARROW_DOWN){ value = new Integer(value.intValue()-1); if (value.intValue()<0){ textHour.setText("99"); }else{ textHour.setText(value.toString()); } } }catch(Exception e1){ textHour.setText(""); } } public void keyReleased(KeyEvent e) { } }); // lable and textbox for MIn lable = new Label(composite,SWT.NONE); lable.setText(":"); textMin = new Text(composite, SWT.SINGLE | SWT.BORDER); textMin.setTextLimit(2); gridData15 = new GridData(); gridData15.widthHint = 15; gridData15.heightHint = 13; textMin.setLayoutData (gridData15); textMin.setEnabled(true); textMin.setToolTipText("MIMUTES"); textMin.setText("00"); textMin.addKeyListener(new KeyListener(){ public void keyPressed(KeyEvent e) { try{ Integer time = new Integer(textMin.getText()); if(e.keyCode == SWT.ARROW_UP){ time = new Integer(time.intValue()+1); if (time.intValue()>60){ textMin.setText("00"); }else{ textMin.setText(time.toString()); } } if(e.keyCode==SWT.ARROW_DOWN){ time=new Integer(time.intValue()-1); if (time.intValue()<0){ textMin.setText("60"); }else{ textMin.setText(time.toString()); } } }catch(Exception e1){ textMin.setText(""); } } public void keyReleased(KeyEvent e) { } }); // lable and textbox for seconds lable = new Label(composite,SWT.NONE); lable.setText(":"); textSec = new Text(composite, SWT.SINGLE | SWT.BORDER); textSec.setTextLimit(2); gridData15 = new GridData(); gridData15.widthHint = 15; gridData15.heightHint = 13; textSec.setLayoutData (gridData15); textSec.setEnabled(true); textSec.setToolTipText("SECONDS"); textSec.setText("00"); textSec.addKeyListener(new KeyListener(){ public void keyPressed(KeyEvent e) { try{ Integer time = new Integer(textSec.getText()); if(e.keyCode == SWT.ARROW_UP){ time = new Integer(time.intValue()+1); if (time.intValue()>60){ textSec.setText("00"); }else{ textSec.setText(time.toString()); } } if(e.keyCode==SWT.ARROW_DOWN){ time = new Integer(time.intValue()-1); if (time.intValue()<0){ textSec.setText("60"); }else{ textSec.setText(time.toString()); } } }catch(Exception e1){ textSec.setText(""); } } public void keyReleased(KeyEvent e) { } }); // lable and textbox for milli-seconds lable = new Label(composite,SWT.NONE); lable.setText(":"); textmilliS = new Text(composite, SWT.SINGLE | SWT.BORDER); textmilliS.setTextLimit(3); gridData15 = new GridData(); gridData15.widthHint = 20; gridData15.heightHint = 13; textmilliS.setLayoutData (gridData15); textmilliS.setEnabled(true); textmilliS.setToolTipText("MILLISECONDS"); textmilliS.setText("000"); textmilliS.addKeyListener(new KeyListener(){ public void keyPressed(KeyEvent e) { try{ Integer time = new Integer(textmilliS.getText()); if(e.keyCode == SWT.ARROW_UP){ time = new Integer(time.intValue()+1); if (time.intValue()>999){ textmilliS.setText("000"); }else{ textmilliS.setText(time.toString()); } } if(e.keyCode==SWT.ARROW_DOWN){ time = new Integer(time.intValue()-1); if (time.intValue()<0){ textmilliS.setText("999"); }else{ textmilliS.setText(time.toString()); } } }catch(Exception e1){ textmilliS.setText(""); } } public void keyReleased(KeyEvent e) { } }); // Row Twelve - The check box and text box for read to end of file checkBoxEOF = new Button(composite, SWT.CHECK); GridData gridData1P2 = new GridData(); gridData15.widthHint = 50; gridData15.heightHint = 13; gridData1P2.horizontalAlignment = GridData.CENTER; checkBoxEOF.setLayoutData(gridData1P2); checkBoxEOF.setSelection(true); checkBoxEOF.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e){ if(checkBoxEOF.getSelection() == true) { textHour.setEnabled(false); textMin.setEnabled(false); textSec.setEnabled(false); textmilliS.setEnabled(false); } else { textHour.setEnabled(true); textMin.setEnabled(true); textSec.setEnabled(true); textmilliS.setEnabled(true); } } }); Label newlabel = new Label(composite, SWT.NONE); newlabel.setText("Read to end of file"); //GridData gridData = new GridData(); //gridData.horizontalAlignment = GridData.FILL; //gridData.horizontalSpan=9; //newlabel.setLayoutData(gridData); //newlabel.setFont(parent.getFont()); //Row Eleven - Text Discription of Advanced Label label6 = new Label(composite, SWT.WRAP); label6.setText(message4); GridData gridData16 = new GridData(); gridData16.horizontalAlignment = GridData.BEGINNING; gridData16.horizontalSpan = 10; label6.setLayoutData(gridData16); label6.setFont(parent.getFont()); //Row Tweleve - The check box and text box for advanced checkBoxAdv = new Button(composite, SWT.CHECK); GridData gridData17 = new GridData(); gridData17.horizontalAlignment = GridData.BEGINNING; checkBoxAdv.setLayoutData(gridData17); checkBoxAdv.setSelection(checkedAdv); checkBoxAdv.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e){ if(textAdv.getEnabled() == true) { textAdv.setEnabled(false); checkedAdv = false; } else { textAdv.setEnabled(true); checkedAdv = true; } } }); textAdv = new Text(composite, SWT.SINGLE | SWT.BORDER); GridData gridData18 = new GridData(); gridData18.horizontalAlignment = GridData.FILL; gridData18.grabExcessHorizontalSpace = true; gridData18.horizontalSpan = 9; textAdv.setLayoutData(gridData18); textAdv.setEnabled(checkedAdv); // Row Eight - Text description of the Comment text box Label label8 = new Label(composite, SWT.WRAP); label8.setText(message5); GridData gridData19 = new GridData(); gridData19.horizontalAlignment = GridData.BEGINNING; gridData19.horizontalSpan = 10; label8.setLayoutData(gridData19); label8.setFont(parent.getFont()); // Row Nine - The check box and text box for comment checkBoxComment = new Button(composite, SWT.CHECK); GridData gridData20 = new GridData(); gridData20.horizontalAlignment = GridData.BEGINNING; checkBoxComment.setLayoutData(gridData20); checkBoxComment.setSelection(false); checkBoxComment.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e){ if(textComment.getEnabled() == true) { textComment.setEnabled(false); checkedComment = false; } else { textComment.setEnabled(true); checkedComment = true; } } }); textComment= new Text(composite, SWT.SINGLE | SWT.BORDER); GridData gridData21 = new GridData(); gridData21.horizontalSpan = 9; gridData21.horizontalAlignment = GridData.FILL; gridData21.grabExcessHorizontalSpace = true; textComment.setLayoutData(gridData21); textComment.setEnabled(false); //Row Sixteen - Save as Batch button saveBatButton = new Button(composite, SWT.PUSH); saveBatButton.setText("Save as .bat"); saveBatButton.setToolTipText("Save Settings to batch file"); GridData gridDataSBB= new GridData(); gridDataSBB.horizontalAlignment = GridData.END; gridDataSBB.horizontalSpan = 9; saveBatButton.setLayoutData(gridDataSBB); saveBatButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e){ composite.setEnabled(false); simuButton.setEnabled(false); doneButton.setEnabled(false); saveBatButton.setEnabled(false); loadBatButton.setEnabled(false); OK2Close = false; SaveBatchFileGui("*.bat"); } }); // Row Fifteen - Load Batch button loadBatButton = new Button(composite, SWT.PUSH); loadBatButton.setText("Load .bat"); loadBatButton.setToolTipText("Load Batch from file"); GridData gridDataLBB = new GridData(); gridDataLBB.horizontalAlignment = GridData.BEGINNING; loadBatButton.setLayoutData(gridDataLBB); loadBatButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e){ try { BufferedReader batchReader = new BufferedReader(new FileReader(path.toString() + NewFileGui("*.bat"))); String command = null; command = batchReader.readLine(); System.out.println("\nLoading: " + command); try{ String comments = batchReader.readLine(); while(!comments.trim().startsWith("rem")) comments = batchReader.readLine(); textComment.setText(comments.substring(4)); checkedComment = true; checkBoxComment.setSelection(checkedComment); textComment.setEnabled(checkedComment); }catch(NullPointerException e1){ e1.printStackTrace(); } // finding the index of characters in the String, 'command' int indexStartlog = command.indexOf(" "); int indexEndlog = command.indexOf(".log"); int indexStartHour = command.indexOf(" ", indexEndlog + 1); int indexstartMin = command.indexOf(":", indexStartHour + 1); int indexstartSec = command.indexOf(":", indexstartMin + 1); int indexstartmilliS = command.indexOf(":", indexstartSec + 1); int indexEndmilliS = command.indexOf(" ", indexstartSec + 1); //int indexStartAdv = command.indexOf( " ", indexstartmilliS + 1); //ME if (indexStartlog != -1) { textlog.setText(command.substring(indexStartlog + 1, indexEndlog + 4 ).trim()); } else { textlog.setText(""); } if (indexStartHour != -1) { textHour.setText(command.substring(indexStartHour + 1 , indexstartMin )); } else { textHour.setText(""); } if (indexstartMin != -1) { textMin.setText(command.substring(indexstartMin + 1 , indexstartSec )); } else { textMin.setText(""); } if (indexstartSec != -1) { textSec.setText(command.substring(indexstartSec + 1 , indexstartmilliS )); } else { textSec.setText(""); } if (indexstartmilliS != -1) { textmilliS.setText(command.substring(indexstartmilliS + 1 , indexEndmilliS )); } else { textmilliS.setText(""); } //ORIGINAL SECTION START if (indexEndmilliS < command.length()){ textAdv.setText(command.substring(indexEndmilliS + 1 , command.length())); } //ORIGINAL SECTION END /* //ME REVISED SECTION START if ( (indexStartAdv!=-1) && ( (command.length()-indexStartAdv) > 1) ){ //advanced present checkBoxAdv.setSelection(true); textAdv.setEnabled(true); textAdv.setText(command.substring( indexStartAdv + 1, command.length() ).trim() ); } else { //advanced not present textAdv.setText(""); checkBoxAdv.setSelection(false); textAdv.setEnabled(false); } */ //ME REVISED SECTION END }catch (Exception error) { error.printStackTrace(); System.out.println("************EXCEPTION: opening file******"); } } }); errorMessageLabel = new Label(composite, SWT.NONE); errorMessageLabel.setFont(parent.getFont()); return composite; } /** * @see org.eclipse.jface.window.Window#close() */ public boolean close() { if (OK2Close) { boolean returnValue = super.close(); return returnValue; } return true; } /** * This method takes the fileName and concatenates the digits of n * [found through testString] to the end of the string [if required]. * Edited: by Jing Cao * * @param fileName * @param integer to be appended * @return String tempFileName [new file name with the number at end] */ private String setDigit(String fileName, int n) { //beg setDigit String tempFileName = new String(fileName); String tempString; char c; int i; //Note: the string array only extends from 0 -> (length of string-1) for (i = (fileName.length() - 1); i >= 0; i--) { //This for loop will find the location where the number starts. c = tempFileName.charAt(i); if ((c < '0') || (c > '9')) //if the chracter is not a number then break out of the for loop break; // the value of 'i' will be the index where there is a character [not a number] } tempFileName = tempFileName.trim(); //redundant, it gets rid of spaces infront or after the fileName tempString = new String(Integer.toString(n)); if (i < 0) //the fileName consists of all numbers return tempString; // then return the updated number as the file name! //else tempFileName = tempFileName.substring(0, i + 1); //get the character part of the string //note: the +1 is required because substring(beg,end) is "exclusive" of the end. return tempFileName.concat(tempString); //adds the updated number to the end of the characters and returns the string } //end setDigit /** * This method takes a file name (stripped off ".bat") and * returns the digits (numbers) at the end as a string. * Returns '0' if there's no number at the end of the file name. * Will return the file name if the string is composed of only numbers. * Edited by Jing Cao. * * @param fileName * @return number [of the type string] */ private String testString(String fileName) { //beg testString() //Variable Declarations String tempString = new String(fileName); //redunant but just to make shure that we don't make changes to testString() String number = new String(""); //this string stores the number int i; char c; //Note: the string array only extends from 0 -> (length of string-1) for (i = (fileName.length() - 1); i >= 0; i--) { //This for loop will find the location where the number starts. c = tempString.charAt(i); if ((c < '0') || (c > '9')) //if the chracter is not a number then break out of the for loop break; // the value of 'i' will be the index where there is a character [not a number] } //if statements to set the number string properly if (i == (fileName.length() - 1)) //sets number to 0 if no number found at end of the string. number = "0"; else if (i == -1) //means that the file name is a number! number = new String(fileName); //then set number to be the file name else number = tempString.substring(i + 1); //creates the number string by chopping off the letters number = number.trim(); //removes any spaces at the beginning or the end of the string return number; } //end testString() //this function is used by load.bat to load a new file. private String NewFileGui(String filter) { composite.setEnabled(false); simuButton.setEnabled(false); doneButton.setEnabled(false); OK2Close = false; FileDialog fileDialog = new FileDialog(parent); String[] extention = new String[1]; extention[0] = filter; fileDialog.setFilterPath(path.toString()); fileDialog.setFilterExtensions(extention); fileDialog.open(); composite.setEnabled(true); simuButton.setEnabled(true); doneButton.setEnabled(true); loadBatButton.setEnabled(true); saveBatButton.setEnabled(true); OK2Close = true; return fileDialog.getFileName(); } /* * This function is responsible for saving a batch file */ private void SaveBatchFileGui(String filter) { String[] param = new String[10]; String Command = collectParameters (); String temp; if (Command == null){ composite.setEnabled(true); doneButton.setEnabled(true); simuButton.setEnabled(true); saveBatButton.setEnabled(true); loadBatButton.setEnabled(true); OK2Close = true; return; } composite.setEnabled(false); simuButton.setEnabled(false); doneButton.setEnabled(false); FileDialog fileDialog = new FileDialog(parent, SWT.SAVE); String[] extention = new String[1]; extention[0] = filter; fileDialog.setFilterPath(path.toString()); fileDialog.setFilterExtensions(extention); fileDialog.open(); String fileName = fileDialog.getFileName(); try { if (fileName.endsWith(".bat")) { fileName = fileName.substring(0, fileName.length()-4); } if(fileName == ""){ fileDialog.setFilterPath(""); fileDialog.setFilterExtensions(null); composite.setEnabled(true); simuButton.setEnabled(true); doneButton.setEnabled(true); saveBatButton.setEnabled(true); loadBatButton.setEnabled(true); OK2Close = true; return; } File batFile = new File(path.toString() + fileName + ".bat"); boolean cancelled = false; if (batFile.exists()) { IPreferenceStore store = CDBuilderPlugin.getDefault().getPreferenceStore(); if(store.getInt("batchChoice") == 3) { OverwriteGui ovG = new OverwriteGui(new Shell()); ovG.open(); if (ovG.buttonPressed() == 0) { System.out.print("canceled saving bat"); cancelled = true; composite.setEnabled(true); simuButton.setEnabled(true); doneButton.setEnabled(true); saveBatButton.setEnabled(true); loadBatButton.setEnabled(true); OK2Close = true; } if (ovG.buttonPressed() == 2) { boolean looking = true; int n = 0; while(looking) { n=(Integer.decode(testString(fileName))).intValue(); n++; temp = setDigit(fileName,n); File existFileCount = new File(path.toString() + temp+ ".bat"); System.out.println(path.toString() + temp + ".bat"); fileName = temp; if(!existFileCount.exists()) { looking = false; MessageBox mbox = new MessageBox(new Shell(),SWT.ICON_INFORMATION | SWT.OK); mbox.setText("Saving File"); mbox.setMessage("The file has been saved as "+ fileName+".bat"); mbox.open(); composite.setEnabled(true); simuButton.setEnabled(true); doneButton.setEnabled(true); saveBatButton.setEnabled(true); loadBatButton.setEnabled(true); } } if(ovG.noAskAgain() ) store.setValue("batchChoice", 2); } if (ovG.buttonPressed() == 1) { if(ovG.noAskAgain() ) store.setValue("batchChoice", 1); } } else if(store.getInt("batchChoice") == 2) { boolean looking = true; int n = 0; while(looking) { n++; File existFileCount = new File(path.toString() + fileName + "-" + n + ".bat"); System.out.println(path.toString() + fileName +"-" + n + ".bat"); if(!existFileCount.exists()) { looking = false; fileName = fileName.concat("-" + Integer.toString(n)); } } } else { } }// end if (batFile.exists()) if (!cancelled) { composite.setEnabled(false); simuButton.setEnabled(false); doneButton.setEnabled(false); OK2Close = false; FileWriter batchFile; System.out.println(path.toString() + fileName + ".bat"); String command = collectParameters(); if (command == null){ return; } System.out.println(command); batchFile = new FileWriter(path.toString() + fileName + ".bat"); batchFile.write(command + "\n"); batchFile.write("rem " + textComment.getText() + "\n"); batchFile.write("pause"); batchFile.close(); composite.setEnabled(true); simuButton.setEnabled(true); doneButton.setEnabled(true); saveBatButton.setEnabled(true); loadBatButton.setEnabled(true); OK2Close = true; } } catch (Exception e) { e.printStackTrace(); } }//end of SaveBatchFileGui() }//end class GraphcellGUI