List of usage examples for java.io IOException getLocalizedMessage
public String getLocalizedMessage()
From source file:ctd.services.getCleanData2.java
public String cleanData() { String message = ""; String timestamp = new java.util.Date().getTime() + ""; try {/*w ww .j a v a 2 s. co m*/ CleanDataResult result = new CleanDataResult(); String error_message = ""; //get parameters. ResourceBundle res = ResourceBundle.getBundle("settings"); ResourceBundle cdf_list = ResourceBundle.getBundle("cdf"); //Base directory ftp folder: Here the temporary subfolders are found for each set of CEL-files, and the final assaytoken-based folder. String ftp_folder = res.getString("ws.upload_folder"); String rscript_cleandata = res.getString("ws.rscript_cleandata"); String rscript = res.getString("ws.rscript"); //db String db_username = res.getString("db.username"); String db_password = res.getString("db.password"); String db_database = res.getString("db.database"); //retrieve the information on the assignment from the database SessionFactory sessionFactory = new Configuration().configure().buildSessionFactory(); Session session = sessionFactory.openSession(); Transaction tr = session.beginTransaction(); Query q = session.createQuery( "from Ticket where password='" + getPassword() + "' AND ctd_REF='" + getCTD_REF() + "'"); Ticket ticket = null; String closed = ""; if (q.list().size() != 0) { ticket = (Ticket) q.list().get(0); closed = ticket.getClosed(); } if (ticket == null) { error_message = "Ticket password and CTD_REF don't match."; } if (closed.equals("yes")) { error_message = "Ticket is already used for normalization of these CEL-files."; ticket = null; } if (ticket != null) { //get the folder String folder = ticket.getFolder(); String zip_folder = ftp_folder + folder; //get contents File dir = new File(zip_folder); //find the zip file. File[] files = dir.listFiles(new FileFilter() { public boolean accept(File pathname) { return pathname.isFile(); } }); String cel_zip_file = ""; String zip_file = ""; String gct_file = ""; for (int i = 0; i < files.length; i++) { String file = files[i].getName(); if (file.contains("zip")) { // Add the timestamp to the zip files[i].renameTo(new File(zip_folder + "/" + timestamp + "_zip.zip")); file = timestamp + "_zip.zip"; cel_zip_file = file; zip_file = zip_folder + "/" + cel_zip_file; gct_file = zip_folder + "/" + timestamp + "_gctfile"; } } Process p3 = Runtime.getRuntime().exec("chmod 777 " + zip_file); ////////////////////////////////////////////////////////////////// //Do a system call to normalize. R. (zip_folder zip_file gct_file rscript) String args = rscript + " --verbose --vanilla " + rscript_cleandata + " -i" + zip_file + " -o" + gct_file + " -w" + zip_folder; Logger.getLogger(getTicket.class.getName()).log(Level.INFO, timestamp + ": Running: " + args); Process p = Runtime.getRuntime().exec(args); // Check if CEL files are unzipped allready // This is done by checking every 5 seconds for the existence of a .chip file // This is a bad way of doing this, in future versions of CTD // the output of the R scripts should be parsed boolean do_loop = true; while (do_loop) { File dir2 = new File(zip_folder); String[] files2 = dir2.list(); //Check if CEL files are allready there for (int i = 0; i < files2.length; i++) { String file = files2[i]; if (file.endsWith("chip")) { do_loop = false; try { Thread.sleep(5000); } catch (InterruptedException ex) { Logger.getLogger(getCleanData.class.getName()).log(Level.SEVERE, null, timestamp + ": " + ex); } } } } Logger.getLogger(getTicket.class.getName()).log(Level.INFO, timestamp + ": rscript has finished."); File dir2 = new File(zip_folder); String[] files2 = dir2.list(); String chip_file = ""; String chip_file_db = ""; ArrayList<String> unziped_files = new ArrayList<String>(); for (int i = 0; i < files2.length; i++) { String file = files2[i]; if (file.endsWith("CEL")) { unziped_files.add(file); } if (file.endsWith("chip")) { chip_file = file; chip_file_db = chip_file.split("_CDF_")[1]; File fileFile = new File(chip_file); fileFile.renameTo(new File(zip_folder + "/" + chip_file_db)); //Making the file correspond to the database entry. Duplicates can be safely overwritten, and will be. } } //Check if all CEL files are derived from the same chip. //This is essential for normalization. //initiate check hashmap. This map contains all the unique chip definition file names. There should be only one per analysis. ArrayList<StudySampleAssay> map = new ArrayList<StudySampleAssay>(); for (int i = 0; i < unziped_files.size(); i++) { String cel_file = unziped_files.get(i); StudySampleAssay ssa = new StudySampleAssay(); // Open the file that is the first // command line parameter //String cel_file_path = zip_folder + "/" + cel_file; String name = cel_file; ssa.setNameRawfile(name); ssa.setXREF(getCTD_REF()); map.add(ssa); } ticket.getStudySampleAssaies().addAll(map); session.saveOrUpdate(ticket); session.persist(ticket); tr.commit(); session.close(); //Storage chip definition file (CDF), creation gct file and database storage. SessionFactory sessionFactory1 = new Configuration().configure().buildSessionFactory(); Session session1 = sessionFactory1.openSession(); //check if cdf (chip definition file) is allready stored, if not, store it. List<ChipAnnotation> chip_annotation = null; Query q2 = session1.createQuery("from Chip Where Name='" + chip_file_db + "'"); if (q2.uniqueResult() != null) { Chip chip = (Chip) q2.list().get(0); chip_annotation = chip.getChipAnnotation(); } if (q2.uniqueResult() == null) { //Add this chip and its annotation Chip chip_new = new Chip(); chip_new.setName(chip_file_db); //read chip file String chip_file_path = zip_folder + "/" + chip_file; chip_annotation = readChip(chip_file_path); //Store the whole chip_new.getChipAnnotation().addAll(chip_annotation); Transaction tr1 = session1.beginTransaction(); session1.save(chip_new); session1.persist(chip_new); tr1.commit(); session1.close(); } //create the temp file for storage of the data_insert file. String data_file = zip_folder + "/expression.txt"; FileOutputStream out = null; PrintStream pr = null; out = new FileOutputStream(data_file); pr = new PrintStream(out); //create array data input file for the database table, find correct foreign keys. //get the study_sample_assay id and the probeset ids. SessionFactory sessionFactory2 = new Configuration().configure().buildSessionFactory(); Session session2 = sessionFactory2.openSession(); //Get the cip_annotation_id Query q3 = session2.createQuery("from Chip Where Name='" + chip_file_db + "'"); Chip chip = (Chip) q3.list().get(0); chip_annotation = chip.getChipAnnotation(); Iterator it2 = chip_annotation.iterator(); //for speed, put the chip annotation id in a hashmap HashMap<String, String> chip_annotation_ids = new HashMap<String, String>(); while (it2.hasNext()) { ChipAnnotation ca = (ChipAnnotation) it2.next(); String id = ca.getId().toString(); String ps = ca.getProbeset(); chip_annotation_ids.put(ps, id); } //Create the .gct-files try { Query qt = session2.createQuery("from Ticket where password='" + getPassword() + "' AND ctd_REF='" + getCTD_REF() + "'"); ticket = null; if (qt.list().size() != 0) { ticket = (Ticket) qt.list().get(0); } Iterator it3 = ticket.getStudySampleAssaies().iterator(); while (it3.hasNext()) { StudySampleAssay ssa = (StudySampleAssay) it3.next(); String name_raw_file = ssa.getNameRawfile(); String sampleToken = getSampletokens().get(name_raw_file); String ssa_id = ssa.getId().toString(); error_message = error_message + name_raw_file; String gct_file_generated = gct_file + ".gct"; ArrayList<Double> values = writeFile(pr, chip_annotation_ids, ssa_id, gct_file_generated, name_raw_file.replaceAll(".CEL", "")); Statistics stat = new Statistics(); stat.setData(values); Double average = stat.getAverage(); Double std = stat.getSTD(); ssa.setXREF(getCTD_REF()); ssa.setAverage(average); ssa.setStudyToken(getStudytoken()); ssa.setSampleToken(sampleToken); ssa.setStd(std); } } catch (IOException e) { Logger.getLogger(getTicket.class.getName()).log(Level.SEVERE, timestamp + ": ERROR IN getCleanData2: " + e.getMessage() + " " + e.getLocalizedMessage()); } pr.close(); out.close(); //update ticket Transaction tr2 = session2.beginTransaction(); session2.update(ticket); session2.persist(ticket); tr2.commit(); session2.close(); //import the data into the database String u = "--user=" + db_username; String passw = "--password=" + db_password; String[] commands = new String[] { "mysqlimport", u, passw, "--local", db_database, data_file }; Process p4 = Runtime.getRuntime().exec(commands); message = message + " RMA and GRSN on the CEL-files is done, data is stored."; //close the ticket when finished, normalization can only be performed once by the client. CloseTicket(); //Remove zip and data file (expression.txt) File fileFolderOld = new File(zip_folder); File fileFolderDest = new File(res.getString("ws.upload_folder") + getCTD_REF()); File[] listOfFiles = fileFolderOld.listFiles(); for (int i = 0; i < listOfFiles.length; i++) { if (listOfFiles[i].getPath().toLowerCase().endsWith(".zip") || listOfFiles[i].getPath().toLowerCase().endsWith("expression.txt")) { try { listOfFiles[i].delete(); } catch (Exception e) { Logger.getLogger(getTicket.class.getName()).log(Level.SEVERE, timestamp + ": ERROR IN getCleanData2 (try to delete): " + e.toString()); } } else { try { FileUtils.copyFileToDirectory(listOfFiles[i], fileFolderDest, false); listOfFiles[i].delete(); } catch (Exception e) { Logger.getLogger(getTicket.class.getName()).log(Level.SEVERE, timestamp + ": ERROR IN getCleanData2 (try to copy): " + e.toString()); } } } // Remove temporary folder try { fileFolderOld.delete(); } catch (Exception e) { Logger.getLogger(getTicket.class.getName()).log(Level.SEVERE, timestamp + ": ERROR IN getCleanData2: " + e.toString()); } // -------------------------------------------- // This piece of code is added in order to cleanup all the files // of aborted upload procedures. It checks for these old folders // (more than a day old and a temporaty name (which is just a number // from 1 upwards. It is assumed that a temporary folder has a // name shorter than 10 chars) and removes these files and folders File folderData = new File(res.getString("ws.upload_folder")); long lngTimestamp = new java.util.Date().getTime(); listOfFiles = folderData.listFiles(); for (int i = 0; i < listOfFiles.length; i++) { if (listOfFiles[i].lastModified() < (lngTimestamp - 10000) && listOfFiles[i].getName().length() < 10) { // This folder is more than a day old // We know it is a temporary folder because the name is less than 10 chars long File[] lstDelete = listOfFiles[i].listFiles(); for (int j = 0; j < lstDelete.length; j++) { // Delete all content of the old folder lstDelete[j].delete(); } // Delete the old folder if (!listOfFiles[i].delete()) { Logger.getLogger(getTicket.class.getName()).log(Level.SEVERE, "delSample(): Folder deletion failed: " + listOfFiles[i].getName()); } } } // -------------------------------------------- } // set the messages of the response result.setErrorMessage(error_message); result.setMessage(message); // Use SKARINGA in order to create the JSON response ObjectTransformer trans = null; try { trans = ObjectTransformerFactory.getInstance().getImplementation(); message = trans.serializeToString(result); } catch (NoImplementationException ex) { Logger.getLogger(getTicket.class.getName()).log(Level.SEVERE, "SKARINGA ERROR IN getCleanData2: " + ex.getLocalizedMessage()); } } catch (Exception e) { Logger.getLogger(getTicket.class.getName()).log(Level.SEVERE, timestamp + ": ERROR IN getCleanData2: " + e.toString()); } return message; }
From source file:com.adobe.phonegap.contentsync.Sync.java
private File backupExistingDirectory(String outputDirectory, String type, File dir) { File backup = new File(outputDirectory + ".bak"); if (dir.exists()) { if (type.equals(TYPE_MERGE)) { try { copyFolder(dir, backup); } catch (IOException e) { Log.e(LOG_TAG, e.getLocalizedMessage(), e); }//from w w w . j a v a 2 s . com } else { dir.renameTo(backup); } } return backup; }
From source file:com.ning.billing.recurly.RecurlyClient.java
private void closeStream(final InputStream in) { if (in != null) { try {/*from w w w. j a v a 2 s. co m*/ in.close(); } catch (IOException e) { log.warn("Failed to close http-client - provided InputStream: {}", e.getLocalizedMessage()); } } }
From source file:ch.zhaw.iamp.rct.ui.GrammarWindow.java
private boolean writeFileOrShowError(String file, JTextComponent source) { try {/*ww w . j a v a 2 s . c om*/ FileUtils.writeStringToFile(new File(file), source.getText()); source.requestFocus(); return true; } catch (IOException ex) { JOptionPane.showMessageDialog(this, "The file could not be written: " + ex.getLocalizedMessage(), "Error", JOptionPane.ERROR_MESSAGE); } return false; }
From source file:nf.frex.android.FrexActivity.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (resultCode != Activity.RESULT_OK) { return;/* w ww . j a va 2s. c o m*/ } if (requestCode == R.id.manage_fractals && data.getAction().equals(Intent.ACTION_VIEW)) { final Uri imageUri = data.getData(); if (imageUri != null) { File imageFile = new File(imageUri.getPath()); String configName = FrexIO.getFilenameWithoutExt(imageFile); File paramFile = new File(imageFile.getParent(), configName + FrexIO.PARAM_FILE_EXT); try { FileInputStream fis = new FileInputStream(paramFile); try { readFrexDoc(fis, configName); } finally { fis.close(); } } catch (IOException e) { Toast.makeText(FrexActivity.this, getString(R.string.error_msg, e.getLocalizedMessage()), Toast.LENGTH_SHORT).show(); } } } else if (requestCode == R.id.settings) { view.getGenerator().setNumTasks(SettingsActivity.getNumTasks(this)); } else if (requestCode == SELECT_PICTURE_REQUEST_CODE) { final Uri imageUri = data.getData(); final ColorQuantizer colorQuantizer = new ColorQuantizer(); final ProgressDialog progressDialog = new ProgressDialog(FrexActivity.this); final DialogInterface.OnCancelListener cancelListener = new DialogInterface.OnCancelListener() { @Override public void onCancel(DialogInterface dialog) { if (progressDialog.isShowing()) { progressDialog.dismiss(); } colorQuantizer.cancel(); } }; final ColorQuantizer.ProgressListener progressListener = new ColorQuantizer.ProgressListener() { @Override public void progress(final String msg, final int iter, final int maxIter) { runOnUiThread(new Runnable() { @Override public void run() { progressDialog.setMessage(msg); progressDialog.setProgress(iter); } }); } }; progressDialog.setTitle(getString(R.string.get_pal_from_img_title)); progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL); progressDialog.setCancelable(true); progressDialog.setOnCancelListener(cancelListener); progressDialog.setMax(colorQuantizer.getMaxIterCount()); progressDialog.show(); Thread thread = new Thread(new Runnable() { @Override public void run() { Bitmap bitmap; try { bitmap = FrexIO.readBitmap(getContentResolver(), imageUri, 256); } catch (IOException e) { alert("I/O error: " + e.getLocalizedMessage()); return; } ColorScheme colorScheme = colorQuantizer.quantize(bitmap, progressListener); progressDialog.dismiss(); if (colorScheme != null) { Log.d(TAG, "SELECT_PICTURE_REQUEST_CODE: Got colorScheme"); String colorSchemeId = "$" + imageUri.toString(); colorSchemes.add(colorSchemeId, colorScheme); view.setColorSchemeId(colorSchemeId); view.setColorScheme(colorScheme); view.recomputeColors(); runOnUiThread(new Runnable() { @Override public void run() { Log.d(TAG, "SELECT_PICTURE_REQUEST_CODE: showDialog(R.id.colors)"); showDialog(R.id.colors); } }); } } }); thread.start(); } }
From source file:es.juntadeandalucia.panelGestion.presentacion.controlador.impl.NewGIController.java
/** * This method initializes the task which reads the file * and counts the number of lines//from w w w . ja v a 2s . c o m */ public void initTask() { checkValidTable(); if (validTable) { try { // if it is a new schema then creates a new one if (isNewSchema()) { schema = new Schema(); schema.setDataBase(dataBase); schema.setName(schemaName); } // if it is a new table then creates a new one if (!taskvo.getTaskEntity().isUpdate()) { table = new Table(); table.setSchema(schema); table.setName(tableName); } // assigns the table to the task entity taskvo.getTaskEntity().setTable(table); // initializes the task taskvo.init(); // NEXT PHASE --> PROCESS FILE processFilePhase = true; uploadingFilePhase = false; } catch (IOException e) { String errorMsg = e.getLocalizedMessage(); StatusMessages.instance().add(Severity.ERROR, errorMsg); log.error(errorMsg); } catch (Exception e) { String errorMsg = "Error al iniciar la tarea: " + e.getLocalizedMessage(); StatusMessages.instance().add(Severity.ERROR, errorMsg); log.error(errorMsg); } } }
From source file:ch.zhaw.iamp.rct.ui.GrammarWindow.java
private boolean readFileOrShowError(String file, JTextComponent target) { File source = new File(file); if (source.exists()) { try {//w w w .ja va2 s . com target.setText(FileUtils.readFileToString(source)); target.setEnabled(true); target.requestFocus(); return true; } catch (IOException ex) { JOptionPane.showMessageDialog(this, "The file could not be read: " + ex.getLocalizedMessage(), "Error", JOptionPane.ERROR_MESSAGE); target.setEnabled(false); } } else { target.setText(""); target.setEnabled(true); target.requestFocus(); } return false; }
From source file:com.evolveum.polygon.scim.ServiceAccessManager.java
/** * Used for login to the service. The data needed for this operation is * provided by the configuration./* ww w . j a v a 2 s . c o m*/ * * @param configuration * The instance of "ScimConnectorConfiguration" which holds all * the provided configuration data. * * @return a Map object carrying meta information about the login session. */ public void logIntoService(ScimConnectorConfiguration configuration) { HttpPost loginInstance = new HttpPost(); Header authHeader = null; String loginAccessToken = null; String loginInstanceUrl = null; JSONObject jsonObject = null; String proxyUrl = configuration.getProxyUrl(); LOGGER.ok("proxyUrl: {0}", proxyUrl); // LOGGER.ok("Configuration: {0}", configuration); if (!"token".equalsIgnoreCase(configuration.getAuthentication())) { HttpClient httpClient; if (proxyUrl != null && !proxyUrl.isEmpty()) { HttpHost proxy = new HttpHost(proxyUrl, configuration.getProxyPortNumber()); DefaultProxyRoutePlanner routePlanner = new DefaultProxyRoutePlanner(proxy); httpClient = HttpClientBuilder.create().setRoutePlanner(routePlanner).build(); LOGGER.ok("Proxy enabled: {0}:{1}", proxyUrl, configuration.getProxyPortNumber()); } else { httpClient = HttpClientBuilder.create().build(); } String loginURL = new StringBuilder(configuration.getLoginURL()).append(configuration.getService()) .toString(); GuardedString guardedPassword = configuration.getPassword(); GuardedStringAccessor accessor = new GuardedStringAccessor(); guardedPassword.access(accessor); String contentUri = new StringBuilder("&client_id=").append(configuration.getClientID()) .append("&client_secret=").append(configuration.getClientSecret()).append("&username=") .append(configuration.getUserName()).append("&password=").append(accessor.getClearString()) .toString(); loginInstance = new HttpPost(loginURL); CloseableHttpResponse response = null; StringEntity bodyContent; String getResult = null; Integer statusCode = null; try { bodyContent = new StringEntity(contentUri); bodyContent.setContentType("application/x-www-form-urlencoded"); loginInstance.setEntity(bodyContent); response = (CloseableHttpResponse) httpClient.execute(loginInstance); getResult = EntityUtils.toString(response.getEntity()); statusCode = response.getStatusLine().getStatusCode(); if (statusCode == 200) { LOGGER.info("Login Successful"); } else { String[] loginUrlParts; String providerName = ""; if (configuration.getLoginURL() != null && !configuration.getLoginURL().isEmpty()) { loginUrlParts = configuration.getLoginURL().split("\\."); // e.g. // https://login.salesforce.com } else { loginUrlParts = configuration.getBaseUrl().split("\\."); // e.g. } // https://login.salesforce.com if (loginUrlParts.length >= 2) { providerName = loginUrlParts[1]; } if (!providerName.isEmpty()) { StrategyFetcher fetcher = new StrategyFetcher(); HandlingStrategy strategy = fetcher.fetchStrategy(providerName); strategy.handleInvalidStatus(" while loging into service", getResult, "loging into service", statusCode); } } jsonObject = (JSONObject) new JSONTokener(getResult).nextValue(); loginAccessToken = jsonObject.getString("access_token"); loginInstanceUrl = jsonObject.getString("instance_url"); } catch (UnsupportedEncodingException e) { LOGGER.error("Unsupported encoding: {0}. Occurrence in the process of login into the service", e.getLocalizedMessage()); LOGGER.info("Unsupported encoding: {0}. Occurrence in the process of login into the service", e); throw new ConnectorException( "Unsupported encoding. Occurrence in the process of login into the service", e); } catch (ClientProtocolException e) { LOGGER.error( "An protocol exception has occurred while processing the http response to the login request. Possible mismatch in interpretation of the HTTP specification: {0}", e.getLocalizedMessage()); LOGGER.info( "An protocol exception has occurred while processing the http response to the login request. Possible mismatch in interpretation of the HTTP specification: {0}", e); throw new ConnectionFailedException( "An protocol exception has occurred while processing the http response to the login request. Possible mismatch in interpretation of the HTTP specification", e); } catch (IOException ioException) { StringBuilder errorBuilder = new StringBuilder( "An error occurred while processing the query http response to the login request. "); if ((ioException instanceof SocketTimeoutException || ioException instanceof NoRouteToHostException)) { errorBuilder.insert(0, "The connection timed out. "); throw new OperationTimeoutException(errorBuilder.toString(), ioException); } else { LOGGER.error( "An error occurred while processing the query http response to the login request : {0}", ioException.getLocalizedMessage()); LOGGER.info( "An error occurred while processing the query http response to the login request : {0}", ioException); throw new ConnectorIOException(errorBuilder.toString(), ioException); } } catch (JSONException jsonException) { LOGGER.error( "An exception has occurred while setting the \"jsonObject\". Occurrence while processing the http response to the login request: {0}", jsonException.getLocalizedMessage()); LOGGER.info( "An exception has occurred while setting the \"jsonObject\". Occurrence while processing the http response to the login request: {0}", jsonException); throw new ConnectorException("An exception has occurred while setting the \"jsonObject\".", jsonException); } finally { try { response.close(); } catch (IOException e) { if ((e instanceof SocketTimeoutException || e instanceof NoRouteToHostException)) { throw new OperationTimeoutException( "The connection timed out while closing the http connection. Occurrence in the process of logging into the service", e); } else { LOGGER.error( "An error has occurred while processing the http response and closing the http connection. Occurrence in the process of logging into the service: {0}", e.getLocalizedMessage()); throw new ConnectorIOException( "An error has occurred while processing the http response and closing the http connection. Occurrence in the process of logging into the service", e); } } } authHeader = new BasicHeader("Authorization", "OAuth " + loginAccessToken); } else { loginInstanceUrl = configuration.getBaseUrl(); GuardedString guardedToken = configuration.getToken(); GuardedStringAccessor accessor = new GuardedStringAccessor(); guardedToken.access(accessor); loginAccessToken = accessor.getClearString(); authHeader = new BasicHeader("Authorization", "Bearer " + loginAccessToken); } String scimBaseUri = new StringBuilder(loginInstanceUrl).append(configuration.getEndpoint()) .append(configuration.getVersion()).toString(); this.baseUri = scimBaseUri; this.aHeader = authHeader; if (jsonObject != null) { this.loginJson = jsonObject; } }
From source file:de.dfki.iui.mmds.application.ScxmlDebugGui.java
/** * Create contents of the window./* w w w. j a va 2s . c om*/ */ protected void createContents(final Display display) { shlSiamDpDebug = new Shell(display); shlSiamDpDebug.setMinimumSize(new Point(680, 480)); shlSiamDpDebug .setImage(ResourceManager.getPluginImage("de.dfki.iui.mmds.dialogue", "resources/siamIcon.png")); shlSiamDpDebug.setSize(1166, 750); shlSiamDpDebug.setText("SiAM-dp Debug GUI"); shlSiamDpDebug.setLayout(new FormLayout()); topBox = new Composite(shlSiamDpDebug, SWT.NONE); topBox.setLayout(new FormLayout()); FormData fd_topBox = new FormData(); fd_topBox.top = new FormAttachment(0, 10); fd_topBox.bottom = new FormAttachment(0, 160); fd_topBox.right = new FormAttachment(100, -10); fd_topBox.left = new FormAttachment(0, 10); topBox.setLayoutData(fd_topBox); sashForm = new SashForm(shlSiamDpDebug, SWT.NONE); FormData fd_sashForm = new FormData(); fd_sashForm.top = new FormAttachment(topBox, 10, SWT.BOTTOM); composite = new Composite(topBox, SWT.BORDER); FormData fd_composite = new FormData(); fd_composite.right = new FormAttachment(0, 200); fd_composite.bottom = new FormAttachment(100, -60); fd_composite.top = new FormAttachment(0, 5); fd_composite.left = new FormAttachment(0, 5); composite.setLayoutData(fd_composite); deviceComboBox = new Combo(composite, SWT.BORDER); deviceComboBox.setLocation(10, 23); deviceComboBox.setSize(175, 21); Button btnOpenMicrophone = new Button(composite, SWT.NONE); btnOpenMicrophone.setLocation(10, 50); btnOpenMicrophone.setSize(121, 25); btnOpenMicrophone.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { openMicrophonePushed(); } }); btnOpenMicrophone.setText("Open Microphone"); Label lblDeviceId = new Label(composite, SWT.NONE); lblDeviceId.setBounds(10, 7, 55, 15); lblDeviceId.setText("Device Id:"); composite_1 = new Composite(topBox, SWT.BORDER); composite_1.setLayout(new FormLayout()); FormData fd_composite_1 = new FormData(); fd_composite_1.top = new FormAttachment(0, 5); fd_composite_1.left = new FormAttachment(composite, 5); fd_composite_1.right = new FormAttachment(100, -146); fd_composite_1.bottom = new FormAttachment(100, -5); composite_1.setLayoutData(fd_composite_1); eventComboBox = new Combo(composite_1, SWT.NONE); FormData fd_eventComboBox = new FormData(); fd_eventComboBox.right = new FormAttachment(0, 150); fd_eventComboBox.top = new FormAttachment(0, 3); fd_eventComboBox.left = new FormAttachment(0, 3); eventComboBox.setLayoutData(fd_eventComboBox); Button btnFireEvent = new Button(composite_1, SWT.NONE); FormData fd_btnFireEvent = new FormData(); fd_btnFireEvent.top = new FormAttachment(eventComboBox, 3); fd_btnFireEvent.right = new FormAttachment(eventComboBox, 0, SWT.RIGHT); fd_btnFireEvent.left = new FormAttachment(eventComboBox, 0, SWT.LEFT); btnFireEvent.setLayoutData(fd_btnFireEvent); btnFireEvent.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { try { Message message = (Message) EmfPersistence.readFromString(messageTextBox.getText()) .getContents().get(0); if (message instanceof InputMessage) eventService.postInputEvent((InputMessage) message, this); else if (message instanceof OutputMessage) eventService.postOutputEvent((OutputMessage) message, this); else if (message instanceof CustomMessage) eventService.postCustomEvent((CustomMessage) message, this); } catch (IOException e1) { MessageBox m = new MessageBox(display.getActiveShell(), SWT.OK | SWT.ERROR); m.setText("Parsing Error"); m.setMessage(e1.getLocalizedMessage()); m.open(); } } }); btnFireEvent.setText("Fire Event"); messageTextBox = new Text(composite_1, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.CANCEL | SWT.MULTI); FormData fd_messageTextBox = new FormData(); fd_messageTextBox.top = new FormAttachment(0, 3); fd_messageTextBox.left = new FormAttachment(eventComboBox, 3); fd_messageTextBox.bottom = new FormAttachment(100, -3); fd_messageTextBox.right = new FormAttachment(100, -10); messageTextBox.setLayoutData(fd_messageTextBox); composite_2 = new Composite(topBox, SWT.BORDER); FormData fd_composite_2 = new FormData(); fd_composite_2.top = new FormAttachment(composite, 6); fd_composite_2.bottom = new FormAttachment(100, -5); fd_composite_2.left = new FormAttachment(0, 5); fd_composite_2.right = new FormAttachment(0, 200); composite_2.setLayoutData(fd_composite_2); btnStepwise = new Button(composite_2, SWT.CHECK); btnStepwise.setBounds(10, 15, 67, 16); btnStepwise.setEnabled(true); btnStepwise.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { getEngine().setSuperStep(!btnStepwise.getSelection()); } }); btnStepwise.setText("Stepwise"); btnNext = new Button(composite_2, SWT.NONE); btnNext.setBounds(96, 10, 89, 25); btnNext.setEnabled(false); btnNext.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { getEngine().step(); } }); btnNext.setText("Next Step ==>"); Composite composite_3 = new Composite(topBox, SWT.BORDER); FormData fd_composite_3 = new FormData(); fd_composite_3.bottom = new FormAttachment(composite_1, 0, SWT.BOTTOM); fd_composite_3.right = new FormAttachment(composite_1, 146, SWT.RIGHT); fd_composite_3.top = new FormAttachment(0, 5); fd_composite_3.left = new FormAttachment(composite_1, 6); composite_3.setLayoutData(fd_composite_3); Button discourseContextButton = new Button(composite_3, SWT.TOGGLE); discourseContextButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { if (discourseContextGui == null) { discourseContextGui = new DiscourseContextGui( fadeService.getWorkingMemory().getDiscourseContext()); } if (!discourseContextGuiOpen) { discourseContextGui.open(); DisposeListener dl = new DisposeListener() { @Override public void widgetDisposed(DisposeEvent e) { discourseContextGuiOpen = false; discourseContextGui = null; discourseContextButton.setSelection(false); } }; discourseContextGui.getShell().addDisposeListener(dl); discourseContextGuiOpen = true; discourseContextButton.setSelection(true); } else { discourseContextGui.close(); discourseContextGuiOpen = false; discourseContextButton.setSelection(false); } } }); discourseContextButton.setBounds(3, 2, 130, 25); discourseContextButton.setText("Discourse Context"); Button discourseHistoryButton = new Button(composite_3, SWT.TOGGLE); discourseHistoryButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { if (discourseHistoryGui == null) { discourseHistoryGui = new DiscourseHistoryGui( fadeService.getWorkingMemory().getDiscourseHistory()); } if (!discourseHistoryGuiOpen) { discourseHistoryGui.open(); DisposeListener dl = new DisposeListener() { @Override public void widgetDisposed(DisposeEvent e) { discourseHistoryGuiOpen = false; discourseHistoryButton.setSelection(false); } }; discourseHistoryGui.getShell().addDisposeListener(dl); discourseHistoryGuiOpen = true; discourseHistoryButton.setSelection(true); } else { discourseHistoryGui.close(); discourseHistoryGuiOpen = false; discourseHistoryButton.setSelection(false); } } }); discourseHistoryButton.setBounds(3, 32, 130, 25); discourseHistoryButton.setText("Discourse History"); Button physicalContextButton = new Button(composite_3, SWT.TOGGLE); physicalContextButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { if (physicalContextGui == null) { physicalContextGui = new KnowledgeBaseGui(knowledgeManager.getWorld().getEntries(), entityResources); } if (!physicalContextGuiOpen) { physicalContextGui.open(); DisposeListener dl = new DisposeListener() { @Override public void widgetDisposed(DisposeEvent e) { physicalContextGuiOpen = false; physicalContextGui = null; physicalContextButton.setSelection(false); } }; physicalContextGui.getShell().addDisposeListener(dl); physicalContextGuiOpen = true; physicalContextButton.setSelection(true); } else { physicalContextGui.close(); physicalContextGuiOpen = false; physicalContextButton.setSelection(false); } } }); physicalContextButton.setBounds(3, 62, 130, 25); physicalContextButton.setText("Knowledge Base"); eventComboBox.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { Message message = testMessages.get(eventComboBox.getText()); if (message != null) { messageTextBox.setText(EmfPersistence.writeToString(message)); } } }); fd_sashForm.right = new FormAttachment(100, -10); fd_sashForm.left = new FormAttachment(0, 10); sashForm.setLayoutData(fd_sashForm); logGroup = new Group(sashForm, SWT.NONE); logGroup.setText("Logs"); logGroup.setLayout(new FillLayout(SWT.VERTICAL)); logTable = new Table(logGroup, SWT.BORDER | SWT.FULL_SELECTION); logTable.setHeaderVisible(true); logTable.setLinesVisible(true); eventColumn = new TableColumn(logTable, SWT.NONE); eventColumn.setWidth(120); eventColumn.setText("Event"); stateIdColumn = new TableColumn(logTable, SWT.NONE); stateIdColumn.setWidth(380); stateIdColumn.setText("StateID"); dialogueNodeIdColumn = new TableColumn(logTable, SWT.NONE); dialogueNodeIdColumn.setWidth(131); dialogueNodeIdColumn.setText("DialogueNodeID"); variableGroup = new Group(sashForm, SWT.NONE); variableGroup.setText("Variables"); variableGroup.setLayout(new FillLayout(SWT.HORIZONTAL)); variableTable = new Table(variableGroup, SWT.BORDER | SWT.FULL_SELECTION); variableTable.addMouseListener(new MouseAdapter() { @Override public void mouseDoubleClick(MouseEvent event) { TableItem item = variableTable.getItem(new Point(event.x, event.y)); Object content = null; final String key = item.getText(0); if (!item.getText(0).equals("null")) { content = ProjectManager.dialogueManager.getCurrentScxmlContext().get(key); } if (content instanceof EObject) { try { DebugGuiVariableInfo window = new DebugGuiVariableInfo((EObject) content); if (varInfos.get(key) == null) { window.open(); varInfos.put(key, window); DisposeListener dl = new DisposeListener() { @Override public void widgetDisposed(DisposeEvent e) { varInfos.put(key, null); } }; window.getShell().addDisposeListener(dl); } } catch (Exception e) { e.printStackTrace(); } } } }); variableTable.setHeaderVisible(true); variableTable.setLinesVisible(true); variableTableColumn1 = new TableColumn(variableTable, SWT.NONE); variableTableColumn1.setWidth(212); variableTableColumn1.setText("Name"); variableTableColumn2 = new TableColumn(variableTable, SWT.NONE); variableTableColumn2.setWidth(240); variableTableColumn2.setText("Content"); picturesComposite = new Composite(shlSiamDpDebug, SWT.NONE); fd_sashForm.bottom = new FormAttachment(picturesComposite, -10, SWT.TOP); FormData fd_picturesComposite = new FormData(); fd_picturesComposite.top = new FormAttachment(100, -120); fd_picturesComposite.bottom = new FormAttachment(100, -10); fd_picturesComposite.right = new FormAttachment(100, -10); fd_picturesComposite.left = new FormAttachment(0, 10); sashForm.setWeights(new int[] { 654, 473 }); picturesComposite.setLayout(null); picturesComposite.setLayoutData(fd_picturesComposite); Label siamLogo = new Label(picturesComposite, SWT.NONE); siamLogo.setImage(ResourceManager.getPluginImage("de.dfki.iui.mmds.dialogue", "resources/siam.png")); siamLogo.setBounds(285, 25, 228, 70); lblNewLabel = new Label(picturesComposite, SWT.NONE); lblNewLabel .setImage(ResourceManager.getPluginImage("de.dfki.iui.mmds.dialogue", "resources/bmbf_klein.png")); lblNewLabel.setBounds(519, 10, 116, 100); lblDfkiimage = new Label(picturesComposite, SWT.NONE); lblDfkiimage.setImage(ResourceManager.getPluginImage("de.dfki.iui.mmds.dialogue", "resources/dfki.png")); lblDfkiimage.setBounds(15, 15, 253, 90); }