/* * 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. * */ 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.InputStream; 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.preference.IPreferenceStore; import org.eclipse.swt.SWT; import org.eclipse.swt.events.KeyEvent; import org.eclipse.swt.events.KeyListener; import org.eclipse.swt.events.ModifyEvent; import org.eclipse.swt.events.ModifyListener; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Combo; 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.IEditorInput; import org.eclipse.ui.IEditorPart; import org.eclipse.ui.IWorkbenchPage; import org.eclipse.ui.PlatformUI; import org.eclipse.ui.part.FileEditorInput; import CDBuilder.CDBuilderPlugin; import CDBuilder.buttons.OverwriteGui; import CDBuilder.console.ConsoleDocument; import CDBuilder.console.StreamHandler; /** * @author ali monadi * * To change the template for this generated type comment go to * Window>Preferences>Java>Code Generation>Code and Comments */ public class Drawlog3DGUI extends Dialog { private Shell parent; private String title; private String modelMessage; private String logMessage; private String timeMessage; private String coupleMessage; private String widthMessage; private String percisionMessage; private String sliceMessage; private String zeroMessage; private String outputMessage; private static String modelValue; private static String logValue; private static String timeValue; private static String coupleValue; private static String widthValue; private static String percisionValue; private static String sliceValue; private static String outputValue; private Button loadBatButton; private Button saveBatButton; private Button drawlogButton; private Button closeButton; private Button killButton; private Button fileButtonOutput; private Button fileButtonModel; private Button fileButtonLog; private boolean modelExist; private Label colon1, colon2, colon3; private Text modelText; private Text logText; private Text textTime1,textTime2,textTime3,textTime4; private Combo coupleCombo; private Text outputText; private Text widthText; private Text percisionText; private Text sliceText; private Text sliceMessages; private Text messageInterval; private Button zeroCheckBox; private static boolean zeroValue= true; private static boolean checkedTime = false; private static boolean checkedWidth = true ; private static boolean checkedPercision = true; private static boolean checkedSlice = false; private Button checkBoxTime; private Button widthCheckBox; private Button percisionCheckBox; private Button sliceCheckBox; private Button msgsliceCheckBox; private Button msgIntervalCheckBox; private Process drawlogProcess; private IPath path; private IPath internalPath; private boolean drawlogKilled = false; private RunDrawlog rDrawlog; class conWrite implements Runnable { String line; public conWrite(String line) { this.line = line; } public void run() { ConsoleDocument.getCDOS().set(line); } } class RunDrawlog extends Thread { IWorkspaceRoot root; String command; Dialog d; public RunDrawlog(String command, Dialog d,IWorkspaceRoot root) { this.command = command; this.root = root; this.d=d; } public void run() { try { ConsoleDocument cdos = ConsoleDocument.getCDOS(); IContainer container = ResourcesPlugin.getWorkspace().getRoot().getContainerForLocation(path); //create a temporary batch file and write the command in it FileWriter tempFile = new FileWriter(path.append("tempDraw.bat").toString()); tempFile.write("\"" + internalPath +"drawlog3D.exe\" "+ command); tempFile.close(); // run batch file drawlogProcess=Runtime.getRuntime().exec("cmd /c tempDraw.bat",null,path.toFile()); StreamHandler outputHandler = new StreamHandler(drawlogProcess.getInputStream(), "OUTPUT", true); StreamHandler errorHandler = new StreamHandler(drawlogProcess.getErrorStream(), "ERROR", true); outputHandler.start(); errorHandler.start(); drawlogProcess.waitFor(); container.refreshLocal(1,null); //delete temporary file after finish running Process remove = Runtime.getRuntime().exec("rm tempDraw.bat",null,path.toFile()); outputHandler = new StreamHandler(remove.getInputStream(), "OUTPUT", true); errorHandler = new StreamHandler(remove.getErrorStream(), "ERROR", true); outputHandler.start(); errorHandler.start(); remove.waitFor(); container.refreshLocal(1,null); Display.getDefault().syncExec(new Runnable() { public void run(){ closeButton.setEnabled(true); killButton.setEnabled(false); drawlogButton.setEnabled(true); d.close(); IFile file=root.getFileForLocation(path.append(outputValue)); IEditorPart editor = null; IEditorInput input = new FileEditorInput(file); IWorkbenchPage page =PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); if (page != null) { editor = page.findEditor(input); if (editor != null) { page.bringToTop(editor); } else { try { editor = page.openEditor(input,"org.eclipse.ui.DefaultTextEditor",false); } catch (Exception e) { e.printStackTrace(); } } } try { file.refreshLocal(1,null); } catch (CoreException e) { e.printStackTrace(); } } }); //check if user cancel process if (drawlogKilled) { if (ResourcesPlugin.getWorkspace().getRoot().getFileForLocation(path.append("tempDraw.bat")).exists()){ container.refreshLocal(1,null); ResourcesPlugin.getWorkspace().getRoot().getFileForLocation(path.append("tempDraw.bat")).delete(true,null); } Display.getDefault().syncExec(new conWrite("***User has killed the simulation***" + "\n")); drawlogKilled = false; } Display.getDefault().syncExec(new conWrite("Drawlog file created" + "\n")); } catch (Throwable T) { T.printStackTrace(); } } } public Drawlog3DGUI(Shell parent,IPath internalPath, IPath path) { super(parent); this.parent = parent; this.title ="Drawlog"; modelMessage = "Coupled model file name (.ma)"; coupleMessage = "Cellular model name"; logMessage = "Log file name(.log)"; outputMessage = "Output file name (.drw)"; timeMessage = "Enter the starting time"; widthMessage ="Enter the width"; percisionMessage = "Enter the number of digits after the decimal"; sliceMessage = "Number of slice (s) when used as 3D Models" ; zeroMessage = "Do not print the zero value"; this.path = path; this.internalPath = internalPath; } protected void buttonPressed(int buttonId) { try{ String[] param = new String[10]; if (buttonId == IDialogConstants.CLOSE_ID) close(); if (buttonId == IDialogConstants.PROCEED_ID) { //get parameter name modelValue= modelText.getText().trim(); if (modelValue.length()==0) throw new Exception("Enter ma file"); String ma = modelValue.substring( modelValue.length()-3 ); if (!ma.equalsIgnoreCase(".ma")){ modelValue=modelValue.concat(".ma"); modelText.setText(modelValue); } if (!modelExist){ throw new Exception("model file does not exist"); } logValue= logText.getText().trim(); if (logValue.length()==0) throw new Exception("Enter log file"); if (!logValue.endsWith(".log")){ logValue=logValue.concat(".log"); logText.setText(logValue); } IWorkspaceRoot root = (IWorkspaceRoot)PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getInput(); IResource[] files; IFile fileHandle=null; //get handle of all file in the folder files = root.getContainerForLocation(path).members(); for(int i=0;i" + outputValue); System.out.println(command); rDrawlog = new RunDrawlog(command,this,root); rDrawlog.start(); } //open drawlog file when done IContainer container = ResourcesPlugin.getWorkspace().getRoot().getContainerForLocation(path); container.refreshLocal(1,null); //IFile file =WorkbenchPlugin.getPluginWorkspace().getRoot().getFileForLocation(path.append(outputValue)); super.buttonPressed(buttonId); }catch(Exception e){ e.printStackTrace(); MessageBox mb = new MessageBox(new Shell(),SWT.RETRY | SWT.ICON_ERROR | SWT.APPLICATION_MODAL); mb.setText("Simulation Stopped"); mb.setMessage(e.getMessage()); mb.open(); try { mb.wait(); } catch (InterruptedException e1) { e1.printStackTrace(); } closeButton.setEnabled(true); killButton.setEnabled(false); drawlogButton.setEnabled(true); return; } } protected void configureShell(Shell shell) { super.configureShell(shell); //the following line registers the shell of SimuGui to parent //which causes the file-dialog box modal to the SimuGui dialog //this fixes the problem associated with the file-dialog not being modal to SimuGui parent = shell; if (title != null) shell.setText(title); } protected void createButtonsForButtonBar(Composite parent) { // create OK and Cancel buttons by default //makes all the button and text field of the panel drawlogButton = createButton(parent, IDialogConstants.PROCEED_ID, "Drawlog", true); drawlogButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e){ killButton.setEnabled(true); drawlogButton.setEnabled(false); closeButton.setEnabled(false); } }); closeButton = createButton(parent, IDialogConstants.CLOSE_ID, IDialogConstants.CLOSE_LABEL, true); killButton = createButton(parent, IDialogConstants.STOP_ID, "Kill", true); killButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e){ closeButton.setEnabled(true); killButton.setEnabled(false); drawlogButton.setEnabled(true); drawlogProcess.destroy(); try { Process lookProcess = Runtime.getRuntime().exec("ps"); BufferedReader bf= new BufferedReader(new InputStreamReader(lookProcess.getInputStream())); String msg=null; while((msg=bf.readLine())!=null){ if (msg.indexOf(path.toString().substring(2))!=-1){ msg=msg.substring(2).trim(); Process killProcess=Runtime.getRuntime().exec("kill -9 " + msg.substring(0,msg.indexOf(" "))); } } } catch (IOException e1) { e1.printStackTrace(); } drawlogKilled = true; } }); killButton.setEnabled(false); modelText.setFocus(); } private Label createLabel(Composite parent, Composite composite, String message) { Label label = new Label(composite, SWT.NONE); label.setText(message); GridData gridData = new GridData(); gridData.horizontalAlignment = GridData.FILL; gridData.horizontalSpan=10; label.setLayoutData(gridData); label.setFont(parent.getFont()); return label; } private Text createText(Composite composite, int size) { Text text= new Text(composite, SWT.SINGLE | SWT.BORDER); GridData gridData = new GridData(); gridData.horizontalSpan=size; gridData.horizontalAlignment = GridData.FILL; gridData.grabExcessHorizontalSpace=true; gridData.widthHint = convertHorizontalDLUsToPixels(IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH); text.setLayoutData(gridData); return text; } private Button createFileButton(Composite composite, String description) { Button fileButton = new Button(composite, SWT.PUSH); fileButton.setText("Browse"); fileButton.setToolTipText(description); GridData gridData = new GridData(); gridData.horizontalAlignment = GridData.BEGINNING; fileButton.setLayoutData(gridData); return fileButton; } private Button createCheckBoxButton(Composite composite, boolean checked) { Button checkBox = new Button(composite, SWT.CHECK); GridData gridData = new GridData(); gridData.horizontalAlignment = GridData.BEGINNING; checkBox.setLayoutData(gridData); checkBox.setSelection(checked); return checkBox; } private String NewFileGui(String filter) { FileDialog fileDialog = new FileDialog(parent); String[] extention = new String[1]; extention[0] = filter; fileDialog.setFilterPath(path.toString()); fileDialog.setFilterExtensions(extention); fileDialog.open(); return fileDialog.getFileName(); } private void SaveBatchFileGui(String filter) { String[] param = new String[10]; 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 { System.out.println(path.toString() + fileName); if (fileName.endsWith(".bat")) { fileName = fileName.substring(0, fileName.length()-4); } File existFile = new File(path.toString() + fileName + ".bat"); boolean cancelled = false; if (existFile.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; } if (ovG.buttonPressed() == 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)); } } 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 { } } if (!cancelled) { FileWriter batchFile = new FileWriter(path.toString() + fileName + ".bat"); System.out.println(path.toString() + fileName + ".bat"); param[0] = "-m" +modelText.getText(); if(coupleCombo.getText().length()!=0){ param[1] = "-c"+coupleCombo.getText(); } if(textTime1.isEnabled()){ param[2] = "-t" + textTime1.getText()+":"+textTime2.getText()+":"+textTime3.getText()+":"+textTime4.getText(); } if(logText.getText().length() !=0 ) { param[3] = "-l" + logText.getText(); } if(widthText.isEnabled()){ param[4] = "-w" + widthText.getText(); } if(percisionText.isEnabled()){ param[5] = "-p" + percisionText.getText(); } if(zeroValue) param[6] = "-0"; if(sliceText.isEnabled()){ param[7] = "-f" + sliceText.getText(); } if(outputText.getText().length()!=0 ) { param[8] = "> " + outputText.getText(); } String combine = ""; for(int i=0; i<9;i++){ if (param[i] != null) combine = combine + " " + param[i]; } String command = ("drawlog "+ combine); System.out.println(command); batchFile.write(command + "\n"); batchFile.write("pause"); batchFile.close(); } } catch (Exception e) { e.printStackTrace(); } } protected Control createDialogArea(Composite parent) { Composite composite = (Composite)super.createDialogArea(parent); GridLayout gridLayout = new GridLayout(); gridLayout.numColumns = 10; composite.setLayout(gridLayout); //Row One - Should be text description of ma text box Label modelLabel = createLabel(parent,composite, modelMessage); //Row Two - Text box and file loader for model file modelText = createText(composite, 9); modelText.addModifyListener( new ModifyListener() { public void modifyText(ModifyEvent e) { coupleCombo.removeAll(); int offset; if(modelText.getText().length() >= 3 && ( modelText.getText().endsWith(".ma") || modelText.getText().endsWith(".MA") ) ){ offset = modelText.getText().length()-3; }else{ offset = modelText.getText().length(); } if (modelText.getText().length()!=0){ logText.setText(modelText.getText().substring(0,offset) + ".log" ); outputText.setText(modelText.getText().substring(0,offset) + ".drw" ); } modelExist=true; IWorkspaceRoot root = (IWorkspaceRoot)PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getInput(); try { IResource[] files; IFile dropFile = null; files = root.getContainerForLocation(path).members(); for(int i=0;i0) coupleCombo.setText(coupleCombo.getItem(0)); } } catch (Exception e1) { e1.printStackTrace(); } } }); fileButtonModel = createFileButton(composite, "Select ma file"); fileButtonModel.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e){ String fileName = NewFileGui("*.ma"); if (!fileName.equals("")) modelText.setText(fileName); } }); //Row Three - Should be the text description of the log label Label logLabel = createLabel(parent, composite, logMessage); //Row Four - Text Box and file loader for log file and output file logText = createText(composite, 9); fileButtonLog = createFileButton(composite, "Select log file"); fileButtonLog.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e){ String fileName = NewFileGui("*.log"); if (!fileName.equals("")) logText.setText(fileName); } }); Label outputLabel = createLabel(parent, composite, outputMessage); outputText = createText(composite, 9); fileButtonOutput = createFileButton(composite, "Select output file"); fileButtonOutput.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e){ String fileName = NewFileGui("*.drw"); if (!fileName.equals("")) outputText.setText(fileName); } }); //Row Five - A text description of the couple label Label coupleLabel = createLabel(parent, composite, coupleMessage); //Row Six - Text Drop Box of the couple Loader GridData gridData12 = new GridData(); coupleCombo = new Combo (composite, SWT.READ_ONLY); gridData12.horizontalSpan=10; gridData12.horizontalAlignment = GridData.FILL; gridData12.grabExcessHorizontalSpace=true; gridData12.widthHint = convertHorizontalDLUsToPixels(IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH); coupleCombo.setLayoutData(gridData12); //Row Seven Label for the Time Label label5 = new Label(composite, SWT.WRAP); label5.setText(timeMessage); GridData gridData13 = new GridData(); gridData13.horizontalAlignment = GridData.BEGINNING; gridData13.horizontalSpan = 10; label5.setLayoutData(gridData13); label5.setFont(parent.getFont()); //Row ten - The check box and text box for time checkBoxTime = new Button(composite, SWT.CHECK); GridData gridData14 = new GridData(); gridData14.horizontalAlignment = GridData.BEGINNING; checkBoxTime.setLayoutData(gridData14); checkBoxTime.setSelection(checkedTime); checkBoxTime.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e){ if(textTime1.getEnabled() == true) { textTime1.setEnabled(false); textTime2.setEnabled(false); textTime3.setEnabled(false); textTime4.setEnabled(false); checkedTime = false; } else { textTime1.setEnabled(true); textTime2.setEnabled(true); textTime3.setEnabled(true); textTime4.setEnabled(true); checkedTime = true; } } }); textTime1= new Text(composite, SWT.SINGLE | SWT.BORDER); textTime1.setTextLimit(2); GridData gridData15 = new GridData(); gridData15.widthHint = 15; gridData15.heightHint = 13; textTime1.setLayoutData (gridData15); textTime1.setEnabled(checkedTime); textTime1.setToolTipText("Hours"); textTime1.setText("00"); textTime1.addKeyListener(new KeyListener(){ public void keyPressed(KeyEvent e) { try{ if(e.keyCode==SWT.ARROW_UP){ Integer time= new Integer(textTime1.getText()); time=new Integer(time.intValue()+1); if (time.intValue()>99){ textTime1.setText("00"); }else{ textTime1.setText(time.toString()); } } if(e.keyCode==SWT.ARROW_DOWN){ Integer time= new Integer(textTime1.getText()); time=new Integer(time.intValue()-1); if (time.intValue()<0){ textTime1.setText("99"); }else{ textTime1.setText(time.toString()); } } }catch(Exception e1){ e1.printStackTrace(); } } public void keyReleased(KeyEvent e) { } }); colon1 = new Label(composite,SWT.NONE); colon1.setText(":"); textTime2 =new Text(composite, SWT.SINGLE | SWT.BORDER); textTime2.setTextLimit(2); gridData15 = new GridData(); gridData15.widthHint = 15; gridData15.heightHint = 13; textTime2.setLayoutData (gridData15); textTime2.setEnabled(checkedTime); textTime2.setToolTipText("Minutes"); textTime2.setText("00"); textTime2.addKeyListener(new KeyListener(){ public void keyPressed(KeyEvent e) { try{ if(e.keyCode==SWT.ARROW_UP){ Integer time= new Integer(textTime2.getText()); time=new Integer(time.intValue()+1); if (time.intValue()>99){ textTime2.setText("00"); }else{ textTime2.setText(time.toString()); } } if(e.keyCode==SWT.ARROW_DOWN){ Integer time= new Integer(textTime2.getText()); time=new Integer(time.intValue()-1); if (time.intValue()<0){ textTime2.setText("99"); }else{ textTime2.setText(time.toString()); } } }catch(Exception e1){ e1.printStackTrace(); } } public void keyReleased(KeyEvent e) { } }); colon2 = new Label(composite,SWT.NONE); colon2.setText(":"); textTime3= new Text(composite, SWT.SINGLE | SWT.BORDER); textTime3.setTextLimit(2); gridData15 = new GridData(); gridData15.widthHint = 15; gridData15.heightHint = 13; textTime3.setLayoutData (gridData15); textTime3.setEnabled(checkedTime); textTime3.setToolTipText("Seconds"); textTime3.setText("00"); textTime3.addKeyListener(new KeyListener(){ public void keyPressed(KeyEvent e) { try{ if(e.keyCode==SWT.ARROW_UP){ Integer time= new Integer(textTime3.getText()); time=new Integer(time.intValue()+1); if (time.intValue()>99){ textTime3.setText("00"); }else{ textTime3.setText(time.toString()); } } if(e.keyCode==SWT.ARROW_DOWN){ Integer time= new Integer(textTime3.getText()); time=new Integer(time.intValue()-1); if (time.intValue()<0){ textTime3.setText("99"); }else{ textTime3.setText(time.toString()); } } }catch(Exception e1){ e1.printStackTrace(); } } public void keyReleased(KeyEvent e) { } }); colon2 = new Label(composite,SWT.NONE); colon2.setText(":"); textTime4= new Text(composite, SWT.SINGLE | SWT.BORDER); textTime4.setTextLimit(3); textTime4.setText("000"); gridData15 = new GridData(); gridData15.widthHint = 20; gridData15.heightHint = 13; textTime4.setLayoutData (gridData15); textTime4.setToolTipText("Milliseconds"); textTime4.setEnabled(checkedTime); textTime4.addKeyListener(new KeyListener(){ public void keyPressed(KeyEvent e) { try{ if(e.keyCode==SWT.ARROW_UP){ Integer time= new Integer(textTime4.getText()); time=new Integer(time.intValue()+1); if (time.intValue()>999){ textTime4.setText("000"); }else{ textTime4.setText(time.toString()); } } if(e.keyCode==SWT.ARROW_DOWN){ Integer time= new Integer(textTime4.getText()); time=new Integer(time.intValue()-1); if (time.intValue()<0){ textTime4.setText("999"); }else{ textTime4.setText(time.toString()); } } }catch(Exception e1){ e1.printStackTrace(); } } public void keyReleased(KeyEvent e) { } }); //Row Nine Label for width Label widthLabel = createLabel(parent, composite, widthMessage); //Row Ten Checkbox and Text for Width widthCheckBox = createCheckBoxButton(composite, checkedWidth); widthText = createText(composite,9); widthText.setEnabled(false); widthCheckBox.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e){ if(widthText.getEnabled() == true) { widthText.setEnabled(false); }else { widthText.setEnabled(true); } } }); //Row Eleven Label for percision Label percisionLabel = createLabel(parent, composite, percisionMessage); //Row Twelve Checkbox and Text for percision percisionCheckBox = createCheckBoxButton(composite, checkedPercision); percisionText = createText(composite,9); percisionText.setEnabled(false); percisionCheckBox.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e){ if(percisionText.getEnabled() == true) { percisionText.setEnabled(false); }else { percisionText.setEnabled(true); } } }); //Row Thirteen Label for slice Label sliceLabel = createLabel(parent, composite, sliceMessage); //Row Fourteen Checkbox and Text for Slice sliceCheckBox = createCheckBoxButton(composite, checkedSlice); sliceText = createText(composite,9); sliceText.setEnabled(false); sliceCheckBox.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e){ if(sliceText.getEnabled() == true) { sliceText.setEnabled(false); }else { sliceText.setEnabled(true); } } }); //Row Thirteen Label for sliceMessages (messages from this slice will only be included) Label MsgsliceLabel = createLabel(parent, composite, "Enter slice number for the wanted messages:"); //Row Fourteen Checkbox and Text for Slice msgsliceCheckBox = createCheckBoxButton(composite, false); sliceMessages = createText(composite,9); sliceMessages.setEnabled(false); msgsliceCheckBox.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e){ if(sliceMessages.getEnabled() == true) { sliceMessages.setEnabled(false); }else { sliceMessages.setEnabled(true); } } }); //Row Thirteen Label for sliceMessages (messages from this slice will only be included) Label MsgIntervalLabel = createLabel(parent, composite, "Enter the intervals where you want the messages to be considered:"); //Row Fourteen Checkbox and Text for Slice msgIntervalCheckBox = createCheckBoxButton(composite, false); messageInterval = createText(composite,9); messageInterval.setEnabled(false); msgIntervalCheckBox.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e){ if(messageInterval.getEnabled() == true) { messageInterval.setEnabled(false); }else { messageInterval.setEnabled(true); } } }); //Row Fifteen Label for zero zeroCheckBox = createCheckBoxButton(composite, zeroValue); zeroCheckBox.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e){ if(zeroValue) { zeroValue = false; } else { zeroValue = true; } } }); //Row Sixteen CheckBox for Zero Label label = new Label(composite, SWT.NONE); label.setText(zeroMessage); GridData gridData = new GridData(); gridData.horizontalAlignment = GridData.FILL; gridData.horizontalSpan=9; label.setLayoutData(gridData); label.setFont(parent.getFont()); 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){ SaveBatchFileGui("*.bat"); } }); //Row seventeen - 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; command = batchReader.readLine(); if (command.trim().startsWith("..\\")) command=command.substring(3).trim(); while(!command.trim().startsWith("drawlog")||command.indexOf("-m")==-1){ command = batchReader.readLine(); if (command.trim().startsWith("..\\")) command=command.substring(3).trim(); } int indexStartMa = command.indexOf("-m"); int indexEndMa = command.indexOf(".ma"); int indexStartCouple = command.indexOf("-c"); int indexEndCouple = command.indexOf(" ",indexStartCouple); int indexWidth = command.indexOf("-w"); int indexStartLog = command.indexOf("-l"); int indexEndLog = command.indexOf(".log"); int hourIndexStart = command.indexOf("-t"); int hourIndexEnd = command.indexOf(":", hourIndexStart); int minuteIndexStart = command.indexOf(":"); int minuteIndexEnd = command.indexOf(":", minuteIndexStart+1); int secondIndexStart = command.indexOf(":",minuteIndexEnd); int secondIndexEnd = command.indexOf(":", secondIndexStart+1); int mSecondIndexStart = command.indexOf(":",secondIndexEnd); int mSecondIndexEnd = command.indexOf(" ", mSecondIndexStart+1); int indexPrecision=command.indexOf("-p"); int indexSlice=command.indexOf("-f"); int indexOutput=command.indexOf(">"); if (indexStartMa != -1) { modelText.setText(command.substring(indexStartMa+2, indexEndMa + 4 ).trim()); }else{ modelText.setText(""); } if (indexOutput != -1) { outputText.setText(command.substring(indexOutput+1).trim()); }else{ outputText.setText(""); } if (indexStartLog != -1) { logText.setText(command.substring(indexStartLog+2, indexEndLog + 4)); } else { logText.setText(""); } if (hourIndexStart != -1) { textTime1.setText(command.substring(hourIndexStart+2, hourIndexEnd)); textTime2.setText(command.substring(minuteIndexStart+1, minuteIndexEnd)); textTime3.setText(command.substring(secondIndexStart+1, secondIndexEnd)); textTime4.setText(command.substring(mSecondIndexStart+1,mSecondIndexEnd)); checkedTime = true; checkBoxTime.setSelection(checkedTime); textTime1.setEnabled(checkedTime); textTime2.setEnabled(checkedTime); textTime3.setEnabled(checkedTime); textTime4.setEnabled(checkedTime); } else { textTime1.setText("00"); textTime2.setText("00"); textTime3.setText("00"); textTime4.setText("000"); checkedTime = false; checkBoxTime.setSelection(checkedTime); textTime1.setEnabled(checkedTime); textTime2.setEnabled(checkedTime); textTime3.setEnabled(checkedTime); textTime4.setEnabled(checkedTime); } if (indexWidth != -1) { widthText.setText(command.substring(indexWidth+2,command.indexOf(" ",indexWidth))); checkedWidth = true; widthCheckBox.setSelection(true); widthText.setEnabled(true); } else { widthText.setText(""); checkedWidth = false; widthCheckBox.setSelection(false); widthText.setEnabled(false); } if (indexPrecision != -1) { percisionText.setText(command.substring(indexPrecision+2,command.indexOf(" ",indexPrecision))); checkedPercision = true; percisionCheckBox.setSelection(true); percisionText.setEnabled(true); } else { percisionText.setText(""); checkedPercision = false; percisionCheckBox.setSelection(false); percisionText.setEnabled(false); } if (indexSlice != -1) { sliceText.setText(command.substring(indexSlice+2,command.indexOf(" ",indexSlice))); checkedSlice = true; sliceCheckBox.setSelection(true); sliceText.setEnabled(true); } else { sliceText.setText(""); checkedSlice = false; sliceCheckBox.setSelection(false); sliceText.setEnabled(false); } if (command.indexOf("-0") != -1) { zeroValue=true; zeroCheckBox.setSelection(true); } else { zeroValue=false; zeroCheckBox.setSelection(false); } } catch (Exception error) { error.printStackTrace(); } } }); return composite; } }