List of usage examples for java.lang String compareTo
public int compareTo(String anotherString)
From source file:de.tudarmstadt.ukp.csniper.webapp.statistics.page.export.ExportExcelTask.java
@Override protected void run() { Workbook wb = new HSSFWorkbook(); Sheet sheet = wb.createSheet("Summary"); PrintSetup printSetup = sheet.getPrintSetup(); printSetup.setLandscape(true);/*w ww . j a va 2 s.c o m*/ sheet.setFitToPage(true); sheet.setHorizontallyCenter(true); contextProvider.setOutputPos(exportModel.includePos); outputFile = null; OutputStream os = null; try { List<AggregatedEvaluationResult> results = repository.listAggregatedResults(formModel.getCollections(), formModel.getTypes(), formModel.getUsers(), formModel.getUserThreshold(), formModel.getConfidenceThreshold()); List<AdditionalColumn> ac = exportModel.additionalColumns; Collections.sort(results, new Comparator<AggregatedEvaluationResult>() { @Override public int compare(AggregatedEvaluationResult aO1, AggregatedEvaluationResult aO2) { String id1 = aO1.getItem().getCollectionId() + "|" + aO1.getItem().getDocumentId(); String id2 = aO2.getItem().getCollectionId() + "|" + aO2.getItem().getDocumentId(); return id1.compareTo(id2); } }); // Write header row List<String> colIds = new ArrayList<String>(Arrays.asList("User", "Collection", "Document", "Begin", "End", "Left", "Unit", "Right", "Type", "Class", "Confidence", "Correct", "Wrong")); for (int i = 0; i < ac.size(); i++) { colIds.add(ac.get(i).getName()); } Row headerRow = sheet.createRow(0); for (int i = 0; i < colIds.size(); i++) { Cell cell = headerRow.createCell(i); cell.setCellValue(colIds.get(i)); } // Write rest setTotal(results.size()); int rowNum = 1; for (AggregatedEvaluationResult aer : results) { ResultFilter classification = aer.getClassification(); if (formModel.getFilters().contains(classification)) { ItemContext context = contextProvider.getContext(aer.getItem(), exportModel.contextSize, exportModel.contextSize); // only differentiate between users if additional columns are being exported Set<String> users; if (ac.isEmpty()) { users = new HashSet<String>(Arrays.asList("")); } else { users = aer.getUsers(false); } // output the AggregatedEvaluationResult for every user (because the additional // columns entries might differ) for (String user : users) { Row row = sheet.createRow(rowNum); row.createCell(0).setCellValue(user); row.createCell(1).setCellValue(aer.getItem().getCollectionId()); row.createCell(2).setCellValue(aer.getItem().getDocumentId()); row.createCell(3).setCellValue(aer.getItem().getBeginOffset()); row.createCell(4).setCellValue(aer.getItem().getEndOffset()); row.createCell(5).setCellValue(context.getLeft()); row.createCell(6).setCellValue(context.getUnit()); row.createCell(7).setCellValue(context.getRight()); row.createCell(8).setCellValue(aer.getItem().getType()); row.createCell(9).setCellValue(classification.toString()); row.createCell(10).setCellValue(aer.getConfidence()); row.createCell(11).setCellValue(aer.getCorrect()); row.createCell(12).setCellValue(aer.getWrong()); for (int i = 0; i < ac.size(); i++) { String cellValue = repository.getEvaluationResult(aer.getItem().getId(), user) .getAdditionalColumns().get(ac.get(i)); if (cellValue == null) { cellValue = ""; } row.createCell(colIds.size() - ac.size() + i).setCellValue(cellValue); } rowNum++; } } // Make sure we do not get to 100% before we did the classification, because // otherwise ProgressBar.onFinish() will trigger!!! increment(); if (isCancelled()) { break; } } outputFile = File.createTempFile("date", ".csv"); os = new FileOutputStream(outputFile); wb.write(os); } catch (IOException e) { e.printStackTrace(); error("Export failed: " + ExceptionUtils.getRootCauseMessage(e)); cancel(); } finally { IOUtils.closeQuietly(os); if (isCancelled()) { clean(); } } }
From source file:controller.GetLyricsSwingWorker.java
protected String doInBackground() throws Exception { numLyricsChanged = 0;//w ww .j a v a 2 s . c o m MainFrame.getSongTable().setEnabled(false); MainFrame.getOpenButton().setEnabled(false); MainFrame.getGoButton().setEnabled(false); SongTableModel model = ((SongTableModel) MainFrame.getSongTable().getModel()); MainFrame.getProgressBar().setMinimum(0); MainFrame.getProgressBar().setValue(0); MainFrame.getProgressBar().setMaximum(model.getRowCount()); for (int i = 0; i < model.getRowCount(); i++) { String lyricsColumn = model.getValueAt(i, 2); MainFrame.getSongTable().scrollRectToVisible(MainFrame.getSongTable().getCellRect(i, 0, true)); MainFrame.getSongTable().getSelectionModel().setSelectionInterval(i, i); // If lyrics are blank if (lyricsColumn.compareTo("") == 0) { Logger.LogToStatusBar("Getting lyrics " + (i + 1) + " of " + model.getRowCount()); String artist = model.getValueAt(i, 0); artist = artist.replace("[", ""); artist = artist.replace("]", ""); artist = WordUtils.capitalize(artist); String track = model.getValueAt(i, 1); track = track.replace("[", ""); track = track.replace("]", ""); track = WordUtils.capitalize(track); if (MainFrame.useLyricWiki() == true) { String lyrics = LyricWikiScraper.getLyrics(artist, track); // If artist has an & sign, try replacing with 'and' and search again for more results if (artist.contains("&") && (lyrics.compareTo("") == 0 || lyrics != null)) { Logger.LogToStatusBar("Artist contains &, searching again with 'And' instead"); artist = artist.replace("&", " And "); lyrics = LyricWikiScraper.getLyrics(artist, track); } if (lyrics != null && lyrics.compareTo("") != 0) { model.setValueAt(lyrics, i, 2); MP3TagHandler.saveLyrics(lyrics, model.getValueAt(i, 3)); numLyricsChanged += 1; } } else { String lyrics = SongMeaningsScraper.getLyrics(artist, track); // If artist has an & sign, try replacing with 'and' and search again for more results if (artist.contains("&") && (lyrics.compareTo("") == 0 || lyrics != null)) { Logger.LogToStatusBar("Artist contains &, searching again with 'And' instead"); artist = artist.replace("&", " And "); lyrics = SongMeaningsScraper.getLyrics(artist, track); } if (lyrics.compareTo("") != 0) { model.setValueAt(lyrics, i, 2); MP3TagHandler.saveLyrics(lyrics, model.getValueAt(i, 3)); numLyricsChanged += 1; } } } // Lyrics are not blank else { // If overwriteLyrics is set, we are overwriting them anyway if (MainFrame.overwriteLyrics() == true) { Logger.LogToStatusBar("Getting lyrics " + (i + 1) + " of " + model.getRowCount()); String artist = model.getValueAt(i, 0); artist = artist.replace("[", ""); artist = artist.replace("]", ""); String track = model.getValueAt(i, 1); track = track.replace("[", ""); track = track.replace("]", ""); if (MainFrame.useLyricWiki() == true) { String lyrics = LyricWikiScraper.getLyrics(artist, track); // If artist has an & sign, try replacing with 'and' and search again for more results if (artist.contains("&") && (lyrics.compareTo("") == 0 || lyrics != null)) { Logger.LogToStatusBar("Artist contains &, searching again with 'And' instead"); artist = artist.replace("&", "And"); lyrics = LyricWikiScraper.getLyrics(artist, track); } if (lyrics != null && lyrics.compareTo("") != 0) { model.setValueAt(lyrics, i, 2); MP3TagHandler.saveLyrics(lyrics, model.getValueAt(i, 3)); numLyricsChanged += 1; } } else { String lyrics = SongMeaningsScraper.getLyrics(artist, track); // If artist has an & sign, try replacing with 'and' and search again for more results if (artist.contains("&") && (lyrics.compareTo("") == 0 || lyrics != null)) { Logger.LogToStatusBar("Artist contains &, searching again with 'And' instead"); artist = artist.replace("&", "And"); lyrics = SongMeaningsScraper.getLyrics(artist, track); } if (lyrics.compareTo("") != 0) { model.setValueAt(lyrics, i, 2); MP3TagHandler.saveLyrics(lyrics, model.getValueAt(i, 3)); numLyricsChanged += 1; } } } } int value = MainFrame.getProgressBar().getValue() + 1; if (value > MainFrame.getProgressBar().getMaximum()) { value = MainFrame.getProgressBar().getMaximum(); } MainFrame.getProgressBar().setValue(value); } MainFrame.getOpenButton().setEnabled(true); MainFrame.getGoButton().setEnabled(true); MainFrame.getSongTable().setEnabled(true); Logger.LogToStatusBar("Done getting lyrics (changed " + numLyricsChanged + " lyrics)"); // TODO: Resolve artist / song mismatches return null; }
From source file:fr.sanofi.fcl4transmart.controllers.listeners.geneExpression.SelectSTSMFListener.java
public boolean checkFormat(File file) { try {// ww w . j a v a 2s . co m BufferedReader br = new BufferedReader(new FileReader(file)); String line = br.readLine(); Vector<String> samples = FileHandler.getSamplesId(((GeneExpressionData) this.dataType).getRawFile()); Vector<String> samplesSTSMF = new Vector<String>(); String category = ""; while ((line = br.readLine()) != null) { if (line.compareTo("") != 0) { String[] fields = line.split("\t", -1); //check columns number if (fields.length != 9) { this.selectSTSMFUI.displayMessage("Error:\nLines have not the right number of columns"); br.close(); return false; } //check that study id is set if (fields[0].compareTo("") == 0) { this.selectSTSMFUI.displayMessage("Error:\nStudy identifiers have to be set"); br.close(); return false; } //check that subject id is set if (fields[3].compareTo("") == 0) { this.selectSTSMFUI.displayMessage("Error:\nSubjects identifiers have to be set"); br.close(); return false; } //check that samples id is set if (fields[4].compareTo("") == 0) { this.selectSTSMFUI.displayMessage("Error:\nSamples identifiers have to be set"); br.close(); return false; } //check that platform is set if (fields[5].compareTo("") == 0) { this.selectSTSMFUI.displayMessage("Error:\nPlatform has to be set"); br.close(); return false; } //check that tissue type is set if (fields[5].compareTo("") == 0) { this.selectSTSMFUI.displayMessage("Error:\nTissue type has to be set"); br.close(); return false; } //check that category codes are set if (fields[8].compareTo("") == 0) { this.selectSTSMFUI.displayMessage("Error:\nCategory codes have to be set"); br.close(); return false; } if (category.compareTo("") == 0) { category = fields[8]; } else { if (fields[8].compareTo(category) != 0) { this.selectSTSMFUI.displayMessage("Category code has to be always the same"); br.close(); return false; } } if (!samplesSTSMF.contains(fields[3])) { if (samples.contains(fields[3])) { samplesSTSMF.add(fields[3]); } } } } if (samplesSTSMF.size() != samples.size()) { this.selectSTSMFUI .displayMessage("Error:\nSample identifiers are not the same than in raw data file"); br.close(); return false; } br.close(); } catch (Exception e) { selectSTSMFUI.displayMessage("Error: " + e.getLocalizedMessage()); e.printStackTrace(); return false; } return true; }
From source file:org.ambraproject.admin.action.IssueManagementActionTest.java
@DataProvider(name = "basicInfo") public Object[][] getBasicInfo() { Issue issue = new Issue(); issue.setRespectOrder(true);//from w w w. j a va2 s . c o m issue.setIssueUri("id:testIssueForIssueManagement"); issue.setDisplayName("Malbolge"); issue.setImageUri("id:testImageForIssueManagement"); issue.setArticleDois(new ArrayList<String>(8)); List<TOCArticleGroup> articleGroupList = new ArrayList<TOCArticleGroup>(4); for (ArticleType type : ArticleType.getOrderedListForDisplay()) { TOCArticleGroup group = new TOCArticleGroup(type); for (int i = 1; i < 3; i++) { Article article = new Article(); article.setDoi("id:" + type.getHeading().replaceAll(" ", "_") + "-article" + i); article.setTitle("Title for Article " + i + " in group " + type.getHeading()); article.setTypes(new HashSet<String>(1)); article.getTypes().add(type.getUri().toString()); //ensure that articles are ordered in time Calendar date = Calendar.getInstance(); date.add(Calendar.SECOND, -1 * (type.getHeading().hashCode() + i)); article.setDate(date.getTime()); dummyDataStore.store(article); issue.getArticleDois().add(article.getDoi()); //add an articleInfo to TOC group ArticleInfo info = new ArticleInfo(); info.setDoi(article.getDoi()); info.setAt(article.getTypes()); info.setTitle(article.getTitle()); group.addArticle(info); } articleGroupList.add(group); } //group for orphans TOCArticleGroup orphans = new TOCArticleGroup(null); orphans.setHeading("Orphaned Article"); orphans.setPluralHeading("Orphaned Articles"); Article orphan1 = new Article(); orphan1.setDoi("id:orphaned-article-for-IssueManagementAction1"); orphan1.setTypes(new HashSet<String>(1)); orphan1.getTypes().add("id:definitelyNotARealArticleType"); dummyDataStore.store(orphan1); ArticleInfo orphan1Info = new ArticleInfo(); orphan1Info.setDoi(orphan1.getDoi()); orphans.addArticle(orphan1Info); issue.getArticleDois().add(orphan1.getDoi()); ArticleInfo orphan2Info = new ArticleInfo(); orphan2Info.setDoi("id:non-existent-article-orphan"); orphans.addArticle(orphan2Info); issue.getArticleDois().add(orphan2Info.getDoi()); articleGroupList.add(orphans); //sort the issue article list in a weird way so we can tell that the article csv is ordered by toc groups Collections.sort(issue.getArticleDois(), new Comparator<String>() { @Override public int compare(String o1, String o2) { return -1 * o1.compareTo(o2); } }); for (TOCArticleGroup group : articleGroupList) { Collections.sort(group.getArticles(), new Comparator<ArticleInfo>() { @Override public int compare(ArticleInfo o1, ArticleInfo o2) { return -1 * o1.getDoi().compareTo(o2.getDoi()); } }); } dummyDataStore.store(issue); return new Object[][] { { issue, articleGroupList } }; }
From source file:com.commander4j.util.JUtility.java
/** * Method isValidJavaVersion.//from w w w . ja v a2 s.co m * * @param minVersion * String * @return boolean */ public static boolean isValidJavaVersion(String minVersion) { boolean result = false; String current = System.getProperty("java.version"); int comp = current.compareTo(minVersion); if (comp < 0) { result = false; } else { result = true; } return result; }
From source file:cn.calm.osgi.conter.FelixOsgiHost.java
protected void startFelix() { // load properties from felix embedded file Properties configProps = getProperties("default.properties"); // Copy framework properties from the system properties. FelixPropertiesUtil.copySystemProperties(configProps); replaceSystemPackages(configProps);/* w ww . java2 s . co m*/ // struts, xwork and felix exported packages Properties strutsConfigProps = getProperties("osgi.properties"); addExportedPackages(strutsConfigProps, configProps); // find bundles and adde em to autostart property addAutoStartBundles(configProps); // Bundle cache String storageDir = System.getProperty("java.io.tmpdir") + ".felix-cache"; configProps.setProperty(Constants.FRAMEWORK_STORAGE, storageDir); if (LOG.isDebugEnabled()) LOG.debug("Storing bundles at [#0]", storageDir); String cleanBundleCache = getServletContextParam("struts.osgi.clearBundleCache", "true"); if ("true".equalsIgnoreCase(cleanBundleCache)) { if (LOG.isDebugEnabled()) LOG.debug("Clearing bundle cache"); configProps.put(FelixConstants.FRAMEWORK_STORAGE_CLEAN, FelixConstants.FRAMEWORK_STORAGE_CLEAN_ONFIRSTINIT); } configProps.put(FelixConstants.SERVICE_URLHANDLERS_PROP, "false"); configProps.put(FelixConstants.LOG_LEVEL_PROP, getServletContextParam("struts.osgi.logLevel", "3")); configProps.put(FelixConstants.BUNDLE_CLASSPATH, "."); configProps.put("org.osgi.framework.startlevel.beginning", getServletContextParam("struts.osgi.runLevel", "3")); // try { Map<String, String> map = new TreeMap<String, String>(new Comparator<String>() { public int compare(String obj1, String obj2) { // ??? return obj1.compareTo(obj2); } }); for (Object o : configProps.keySet()) { map.put(String.valueOf(o), configProps.getProperty(String.valueOf(o))); } FrameworkFactory ff = new FrameworkFactory(); f = ff.newFramework(map); // f.start(); f.init(); AutoProcessor.process(map, f.getBundleContext()); f.start(); } catch (Exception ex) { throw new RuntimeException("Couldn't start Apache Felix", ex); } // add the bundle context to the ServletContext servletContext.setAttribute(OSGI_BUNDLE_CONTEXT, f.getBundleContext()); }
From source file:com.clevertrail.mobile.findtrail.Activity_FindTrail_ByLocation.java
private int submitSearch() { double dSearchLat = 0; double dSearchLong = 0; double dSearchDistance = 0; if (!Utils.isNetworkAvailable(mActivity)) { return R.string.error_nointernetconnection; }/*from ww w .j a v a2 s .c om*/ // is this searching by proximity RadioButton rbProximity = (RadioButton) findViewById(R.id.rbFindTrailByLocationProximity); if (rbProximity != null && rbProximity.isChecked()) { // search by proximity // do we have a location? if (currentLocation != null) { dSearchLat = currentLocation.getLatitude(); dSearchLong = currentLocation.getLongitude(); } else { return R.string.error_currentlocationnotfound; } } else { //searching by city EditText etCity = (EditText) findViewById(R.id.txtFindTrailByLocationCity); if (etCity != null) { String sCity = etCity.getText().toString(); if (sCity.compareTo("") != 0) { //get the json info about the location from google maps JSONObject json = getLocationInfo(sCity); if (json == null) { return R.string.error_couldnotconnecttogooglemaps; } else { //get the lat/lng from the geocoding result from google maps Point pt = getLatLong(json); if (pt != null) { dSearchLat = pt.dLat; dSearchLong = pt.dLng; } else { return R.string.error_googlecouldnotfindcity; } } } else { return R.string.error_entercityname; } } } //find out how far the search radius will be int nProximityPos = m_cbFindTrailByLocationProximity.getSelectedItemPosition(); switch (nProximityPos) { case 0: dSearchDistance = 5; break; case 1: dSearchDistance = 10; break; case 2: dSearchDistance = 25; break; case 3: dSearchDistance = 50; break; case 4: dSearchDistance = 100; break; } // search for the given lat/long/dist JSONArray trailListJSON = fetchTrailListJSON(dSearchLat, dSearchLong, dSearchDistance); //do we have a trails that fit the criteria? if (trailListJSON != null && trailListJSON.length() > 0) { int len = trailListJSON.length(); try { Object_TrailList.clearTrails(); for (int i = 0; i < len; ++i) { JSONObject trail = trailListJSON.getJSONObject(i); Object_TrailList.addTrailWithJSON(trail); } } catch (JSONException e) { return R.string.error_corrupttrailinfo; } Intent i = new Intent(mActivity, Activity_FindTrail_DisplayMap.class); mActivity.startActivity(i); } else { return R.string.error_notrailsfoundinsearchradius; } return 0; }
From source file:edu.psu.citeseerx.fixers.LegacyMetadataFixer.java
private boolean doCorrections(Document doc, LegacyData lData) { boolean corrected = false; boolean fieldCorrected = false; String versionName = doc.getVersionName(); if (versionName != null && versionName.compareTo("USER") == 0) { corrected = correctEmpty(doc, lData); } else {//from ww w .j a v a 2 s.co m String oldTitle = lData.title.toLowerCase(); if ((oldTitle.trim().length() > 0) && (oldTitle.compareTo("unknown") != 0)) { fieldCorrected = updateDocField(doc, Document.TITLE_KEY, lData.title); corrected = fieldCorrected ? fieldCorrected : corrected; } if ((lData.abs.trim().length() > 0) && (lData.abs.toLowerCase().compareTo("unknown") != 0)) { fieldCorrected = updateDocField(doc, Document.ABSTRACT_KEY, lData.abs); corrected = fieldCorrected ? fieldCorrected : corrected; } if (lData.volume.trim().length() > 0 && (lData.volume.toLowerCase().compareTo("unknown") != 0)) { try { Integer.parseInt(lData.volume); fieldCorrected = updateDocField(doc, Document.VOL_KEY, lData.volume); corrected = fieldCorrected ? fieldCorrected : corrected; } catch (NumberFormatException nfE) { } } if (lData.year.trim().length() > 0 && (lData.year.toLowerCase().compareTo("unknown") != 0)) { try { Integer.parseInt(lData.year); fieldCorrected = updateDocField(doc, Document.YEAR_KEY, lData.year); corrected = fieldCorrected ? fieldCorrected : corrected; } catch (NumberFormatException nfE) { } } if ((lData.publisher.trim().length() > 0) && (lData.publisher.toLowerCase().compareTo("unknown") != 0)) { fieldCorrected = updateDocField(doc, Document.PUBLISHER_KEY, lData.publisher); corrected = fieldCorrected ? fieldCorrected : corrected; } // Now the authors. List<Author> currentAuthors = doc.getAuthors(); boolean authorAdded = false; boolean authorCorrected = false; for (int i = 0; i < lData.authors.length; ++i) { boolean matchFound = false; String oldAuthor = lData.authors[i]; if (oldAuthor.trim().length() == 0 || oldAuthor.toLowerCase().contains("et al")) { continue; } StringWrapper oldAuthPrep = distanceMetric.prepare(oldAuthor); double similarity = 0; for (Author currentAuthor : currentAuthors) { String currentAuthName = currentAuthor.getDatum(Author.NAME_KEY); similarity = distanceMetric.score(oldAuthPrep, distanceMetric.prepare(currentAuthName)); if (similarity >= 1.0) { // An exact match found matchFound = true; break; } else if (similarity >= similarityFactor && similarity < 1.0) { // They are similar but not equals. Changed it currentAuthor.setDatum(Author.NAME_KEY, lData.authors[i]); authorCorrected = true; matchFound = true; break; } } if (!matchFound) { // it's one that we don't have Author newAuthor = new Author(); newAuthor.setDatum(Author.NAME_KEY, lData.authors[i]); authorAdded = true; if (i < currentAuthors.size()) { currentAuthors.add(i, newAuthor); } else { currentAuthors.add(newAuthor); } authorCorrected = true; } } corrected = authorCorrected ? authorCorrected : corrected; // when adding an author the order could change. Fix it! for (int j = 0; j < currentAuthors.size(); ++j) { if (authorAdded) { String order = currentAuthors.get(j).getDatum(Author.ORD_KEY); order = (order == null) ? "-1" : order; int currentOrder = Integer.parseInt(order); if (currentOrder != j + 1) { currentAuthors.get(j).setDatum(Author.ORD_KEY, Integer.toString(j + 1)); currentAuthors.get(j).setSource(Author.ORD_KEY, CORRECTION_SOURCE); } } if (authorCorrected) { // update source of correction for the rest of the fields setCorrectionSource(currentAuthors.get(j)); } } } return corrected; }
From source file:com.properned.application.SystemController.java
public void initialize() { logger.info("Initialize System controller"); localeButton.disableProperty().bind(multiLanguageProperties.isLoadedProperty().not()); saveButton.disableProperty().bind(multiLanguageProperties.isDirtyProperty().not() .or(multiLanguageProperties.isLoadedProperty().not())); Stage primaryStage = Properned.getInstance().getPrimaryStage(); primaryStage.titleProperty()//from w w w .j av a 2 s . c om .bind(multiLanguageProperties.baseNameProperty() .concat(Bindings.when(multiLanguageProperties.isLoadedProperty()) .then(new SimpleStringProperty(" (") .concat(multiLanguageProperties.parentDirectoryPathProperty()).concat(")")) .otherwise("")) .concat(Bindings.when(multiLanguageProperties.isDirtyProperty()).then(" *").otherwise(""))); FilteredList<String> filteredList = new FilteredList<>(multiLanguageProperties.getListMessageKey(), new Predicate<String>() { @Override public boolean test(String t) { String filter = filterText.getText(); if (filter == null || filter.equals("")) { return true; } return t.contains(filter); } }); SortedList<String> sortedList = new SortedList<>(filteredList, new Comparator<String>() { @Override public int compare(String o1, String o2) { return o1.compareTo(o2); } }); messageKeyList.setItems(sortedList); filterText.textProperty().addListener(new ChangeListener<String>() { @Override public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue) { // Filter the list filteredList.setPredicate(new Predicate<String>() { @Override public boolean test(String t) { String filter = filterText.getText(); if (filter == null || filter.equals("")) { return true; } return t.contains(filter); } }); // check the add button disabled status if (isKeyCanBeAdded(newValue)) { addButton.setDisable(false); } else { addButton.setDisable(true); } } }); ChangeListener<String> changeMessageListener = new ChangeListener<String>() { @Override public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue) { logger.info("Message key selection changed : " + newValue); valueList.setItems(FXCollections.observableArrayList()); valueList.setItems(FXCollections .observableArrayList(multiLanguageProperties.getMapPropertiesByLocale().keySet())); } }; messageKeyList.getSelectionModel().selectedItemProperty().addListener(changeMessageListener); messageKeyList.setCellFactory(c -> new MessageKeyListCell(multiLanguageProperties)); valueList.setCellFactory(c -> new ValueListCell(multiLanguageProperties, messageKeyList)); filterText.setOnKeyReleased(new EventHandler<KeyEvent>() { @Override public void handle(KeyEvent event) { if (event.getCode() == KeyCode.DOWN) { messageKeyList.requestFocus(); event.consume(); } else if (event.getCode() == KeyCode.ENTER) { addKey(); event.consume(); } } }); }