auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
public static Route fromLearned(org.midonet.midolman.layer3.Route from) { Route route = new Route(); route.id = new UUID(0xffffffffffffffffL, 0xffffffffffffffffL); route.dstNetworkAddr = IPv4Addr.apply(from.dstNetworkAddr).toString(); route.dstNetworkLength = from.dstNetworkLength; route.srcNetworkAddr = IPv4Addr.apply(from.srcNetworkLength).toString(); route.srcNetworkLength = from.srcNetworkLength; route.nextHopGateway = IPv4Addr.apply(from.nextHopGateway).toString(); route.weight = from.weight; route.routerId = from.routerId; route.nextHopPort = from.nextHopPort; route.type = NextHop.Normal; route.learned = true; return route; }

Target:
public static Route fromLearned(org.midonet.midolman.layer3.Route from) { Route route = new Route(); route.id = NO_ID; route.dstNetworkAddr = IPv4Addr.apply(from.dstNetworkAddr).toString(); route.dstNetworkLength = from.dstNetworkLength; route.srcNetworkAddr = IPv4Addr.apply(from.srcNetworkAddr).toString(); route.srcNetworkLength = from.srcNetworkLength; route.nextHopGateway = IPv4Addr.apply(from.nextHopGateway).toString(); route.weight = from.weight; route.routerId = from.routerId; route.nextHopPort = from.nextHopPort; route.type = NextHop.Normal; route.learned = true; return route; }
Source:
protected File getAbsoluteFile( String bundleName, String relativePath ) { String absolutePath = this.managedResourcesFolder.getAbsolutePath(); absolutePath += "/" + bundleName; absolutePath += ( relativePath.startsWith( "/" ) ? "" : "/" ) + relativePath .replace( MANAGED_RESOURCES_DIR, "" ); return new File( absolutePath ); }

Target:
protected File getAbsoluteFile( String bundleName, String relativePath ) { return Paths.get( this.managedResourcesFolder.getPath(), bundleName, relativePath.replace( MANAGED_RESOURCES_DIR, "" ) ) .toFile(); }
Source:
public Models getModels() { if (!mModels.getLoaded()) { loadModels(); } while (!mModels.getLoaded()) { try { Timber.d("Waiting for models"); new Exception().printStackTrace(); TimeUnit.MILLISECONDS.sleep(200); } catch (InterruptedException e) { throw new RuntimeException(e); } } return mModels; }

Target:
public Models getModels() { if (futureLoadingModel == null) { loadModels(); } try { futureLoadingModel.get(); } catch (ExecutionException | InterruptedException e) { return mModels.load(loadColumn("models")); } return mModels; }
Source:
public void initialized() { initialized = true; if (gerritPushTargetPanels.size() == 1) { String branchName; try { String gitReviewFilePath = StringUtils.join( new String[]{ProjectManager.getInstance().getOpenProjects()[0].getBasePath(), GITREVIEW_FILENAME}, File.separator); Properties properties = new Properties(); properties.load(new FileInputStream(gitReviewFilePath)); branchName = properties.getProperty("defaultbranch"); } catch (IOException e) { branchName = gerritPushTargetPanels.values().iterator().next(); } if (branchName == null) { branchName = gerritPushTargetPanels.values().iterator().next(); } branchTextField.setText(branchName); } SwingUtilities.invokeLater(new Runnable() { public void run() { initDestinationBranch(); } }); }

Target:
public void initialized() { initialized = true; if (gerritPushTargetPanels.size() == 1) { String branchName = gerritPushTargetPanels.values().iterator().next(); Optional<String> gitReviewBranchName = getGitReviewBranchName(); branchTextField.setText(gitReviewBranchName.or(branchName)); } SwingUtilities.invokeLater(new Runnable() { public void run() { initDestinationBranch(); } }); }
Source:
public static WebArchive appDeployment1() { WebArchive war = ShrinkWrap.create(WebArchive.class, EJB_SECURITY + ".war"); war.addClasses(BasicAuthenticationMechanismPicketboxRemovedTestCase.class, SecuredEJB.class, SecuredEJBServlet.class); war.setWebXML(Utils.getResource("org/jboss/as/test/integration/web/security/authentication/deployment/web.xml")); war.addAsWebInfResource(Utils.getResource("org/jboss/as/test/integration/web/security/authentication/deployment/jboss-web.xml"), "jboss-web.xml"); war.addAsWebInfResource(Utils.getResource("org/jboss/as/test/integration/web/security/authentication/deployment/beans.xml"), "beans.xml"); war.addAsResource(BasicAuthenticationMechanismPicketboxRemovedTestCase.class.getPackage(), "jboss-ejb-client.properties", "jboss-ejb-client.properties"); return war; }

Target:
public static WebArchive appDeployment1() { WebArchive war = ShrinkWrap.create(WebArchive.class, EJB_SECURITY + ".war"); war.addClasses(BasicAuthenticationMechanismPicketboxRemovedTestCase.class, SecuredEJB.class, SecuredEJBServlet.class); war.addAsWebInfResource(BasicAuthenticationMechanismPicketboxRemovedTestCase.class.getPackage(), "jboss-web.xml", "jboss-web.xml"); war.addAsWebInfResource(BasicAuthenticationMechanismPicketboxRemovedTestCase.class.getPackage(), "web.xml", "web.xml"); return war; }
Source:
protected HashMap<Guid, AsyncTaskStatus> ParseTaskStatusList(XmlRpcStruct taskStatusList) { HashMap<Guid, AsyncTaskStatus> result = new HashMap<Guid, AsyncTaskStatus>( taskStatusList.getCount()); for (Map.Entry<String, ?> entry : taskStatusList.getEntries()) { try { Guid taskGuid = new Guid(entry.getKey().toString()); Map<String, Object> xrsTaskStatusAsMAp = (Map<String, Object>) entry.getValue(); XmlRpcStruct xrsTaskStatus = (xrsTaskStatusAsMAp == null) ? null : new XmlRpcStruct(xrsTaskStatusAsMAp); if (xrsTaskStatus == null) { log.errorFormat("Task ID {0} has no task data", entry.getKey().toString()); } else { TaskStatusForXmlRpc tempVar = new TaskStatusForXmlRpc(); tempVar.mCode = Integer.parseInt(xrsTaskStatus.getItem("code").toString()); tempVar.mMessage = xrsTaskStatus.getItem("message").toString(); tempVar.mTaskResult = xrsTaskStatus.getItem("taskResult").toString(); tempVar.mTaskState = xrsTaskStatus.getItem("taskState").toString(); TaskStatusForXmlRpc taskStatus = tempVar; AsyncTaskStatus task = ParseTaskStatus(taskStatus); result.put(taskGuid, task); } } catch (RuntimeException exp) { log.error( String.format( "HSMGetAllTasksStatusesVDSCommand: Error while parsing task status from list. key: %1$s, value: %2$s - ignoring.", entry.getKey().toString(), entry.getValue().toString()), exp); } } return result; }

Target:
protected HashMap<Guid, AsyncTaskStatus> ParseTaskStatusList(XmlRpcStruct taskStatusList) { HashMap<Guid, AsyncTaskStatus> result = new HashMap<Guid, AsyncTaskStatus>( taskStatusList.getCount()); for (Map.Entry<String, ?> entry : taskStatusList.getEntries()) { try { Guid taskGuid = new Guid(entry.getKey().toString()); Map<String, Object> xrsTaskStatusAsMAp = (Map<String, Object>) entry.getValue(); if (xrsTaskStatusAsMAp == null) { log.errorFormat("Task ID {0} has no task data", entry.getKey().toString()); } else { XmlRpcStruct xrsTaskStatus = new XmlRpcStruct(xrsTaskStatusAsMAp); TaskStatusForXmlRpc tempVar = new TaskStatusForXmlRpc(); tempVar.mCode = Integer.parseInt(xrsTaskStatus.getItem("code").toString()); tempVar.mMessage = xrsTaskStatus.getItem("message").toString(); tempVar.mTaskResult = xrsTaskStatus.getItem("taskResult").toString(); tempVar.mTaskState = xrsTaskStatus.getItem("taskState").toString(); TaskStatusForXmlRpc taskStatus = tempVar; AsyncTaskStatus task = ParseTaskStatus(taskStatus); result.put(taskGuid, task); } } catch (RuntimeException exp) { log.error( String.format( "HSMGetAllTasksStatusesVDSCommand: Error while parsing task status from list. key: %1$s, value: %2$s - ignoring.", entry.getKey().toString(), entry.getValue().toString()), exp); } } return result; }
Source:
public void testCheckVariantExistsDoesExist() throws URISyntaxException { testCheckVariantExistsHelper("20:71822:C:G"); }

Target:
public void testCheckVariantExistsDoesExist() throws URISyntaxException { assertTrue(testCheckVariantExistsHelper("20:71822:C:G")); }
Source:
public static Color getSWTColor(ColorByDefinition colorByDefinition) { Color color = colorByDefinition.getResource(); IColorAndFontProvider provider = CSSActivator.getDefault().getColorAndFontProvider(); if (provider == null) { return color; } RGB colorFromDefinition = provider.getColor(colorByDefinition.getSymbolicName()); if (colorFromDefinition != null && !colorFromDefinition.equals(color.getRGB())) { color = new Color(color.getDevice(), colorFromDefinition); } return color; }

Target:
public static Color getSWTColor(ColorByDefinition colorByDefinition) { Color color = colorByDefinition.getResource(); IColorAndFontProvider provider = CSSActivator.getDefault().getColorAndFontProvider(); if (provider == null) { return color; } RGB colorFromDefinition = provider.getColor(colorByDefinition.getSymbolicName()); if (colorFromDefinition != null && !colorFromDefinition.equals(color.getRGB())) { Device device = color.getDevice(); color.dispose(); color = new Color(device, colorFromDefinition); colorByDefinition.setResource(color); } colorByDefinition.setValid(true); return color; }
Source:
private TypeSpec createUnbinderClass() { ClassName targetClassName = ClassName.bestGuess(targetClass); MethodSpec unbinderConstructor = MethodSpec.constructorBuilder() .addParameter(targetClassName, "target") .addStatement("this.$1N = $1N", "target") .build(); TypeSpec.Builder result = TypeSpec.classBuilder(unbinderBinding.getUnbinderClassName().simpleName()) .addSuperinterface(UNBINDER) .addModifiers(PRIVATE, STATIC, FINAL) .addField(targetClassName, "target", PRIVATE) .addMethod(unbinderConstructor); MethodSpec.Builder unbindMethod = MethodSpec.methodBuilder("unbind") .addAnnotation(Override.class) .addModifiers(PUBLIC); for (ViewBindings bindings : viewIdMap.values()) { addFieldAndUnbindStatement(result, unbindMethod, bindings); for (FieldViewBinding fieldBinding : bindings.getFieldBindings()) { unbindMethod.addStatement("target.$L = null", fieldBinding.getName()); } } for (FieldCollectionViewBinding fieldCollectionBinding : collectionBindings.keySet()) { unbindMethod.addStatement("target.$L = null", fieldCollectionBinding.getName()); } unbindMethod.addStatement("target.$L = null", unbinderBinding.getUnbinderFieldName()); unbindMethod.addStatement("target = null"); result.addMethod(unbindMethod.build()); return result.build(); }

Target:
private TypeSpec createUnbinderClass() { ClassName targetClassName = ClassName.bestGuess(targetClass); MethodSpec unbinderConstructor = MethodSpec.constructorBuilder() .addParameter(targetClassName, "target") .addStatement("this.$1N = $1N", "target") .build(); TypeSpec.Builder result = TypeSpec.classBuilder(unbinderBinding.getUnbinderClassName().simpleName()) .addSuperinterface(UNBINDER) .addModifiers(PRIVATE, STATIC, FINAL) .addField(targetClassName, "target", PRIVATE) .addMethod(unbinderConstructor); MethodSpec.Builder unbindMethod = MethodSpec.methodBuilder("unbind") .addAnnotation(Override.class) .addModifiers(PUBLIC); unbindMethod.addStatement("if (target == null) throw new $T($S)", IllegalStateException.class, "Bindings already cleared."); for (ViewBindings bindings : viewIdMap.values()) { addFieldAndUnbindStatement(result, unbindMethod, bindings); for (FieldViewBinding fieldBinding : bindings.getFieldBindings()) { unbindMethod.addStatement("target.$L = null", fieldBinding.getName()); } } for (FieldCollectionViewBinding fieldCollectionBinding : collectionBindings.keySet()) { unbindMethod.addStatement("target.$L = null", fieldCollectionBinding.getName()); } unbindMethod.addStatement("target.$L = null", unbinderBinding.getUnbinderFieldName()); unbindMethod.addStatement("target = null"); result.addMethod(unbindMethod.build()); return result.build(); }
Source:
public void evaluate() throws Throwable { PackageManager pm = mContext.getPackageManager(); buildPackageList(SystemProperties.get(PACKAGE_PATH_PROPERTY), pm); if (mLoadPackages.isEmpty()) { throw new TestHelperException("No installed helper packages found"); } Log.d(LOG_TAG, "Helper search path: " + String.join(":", mSourceDirs)); mHelperManager = HelperManager.getInstance(mSourceDirs, mInstrumentation); for (String prefix : mPrefixes) { try { Pattern classMatch = Pattern.compile("^.*\\.\\Q" + prefix + "\\E[^.]*$"); mHelper = mHelperManager.get(mHelperClass, classMatch); break; } catch (TestHelperException e) { Log.d( LOG_TAG, String.format( "No %s implementation found with prefix %s.", mHelperClass, prefix)); } } mBase.evaluate(); }

Target:
public void evaluate() throws Throwable { PackageManager pm = mContext.getPackageManager(); buildPackageList(SystemProperties.get(PACKAGE_PATH_PROPERTY), pm); if (mLoadPackages.isEmpty()) { throw new TestHelperException("No installed helper packages found"); } Log.d(LOG_TAG, "Helper search path: " + String.join(":", mSourceDirs)); mHelperManager = HelperManager.getInstance(mSourceDirs, mInstrumentation); for (String prefix : mPrefixes) { try { Pattern classMatch = Pattern.compile("^.*\\.\\Q" + prefix + "\\E[^.]*$"); mHelper = mHelperManager.get(mHelperClass, classMatch); break; } catch (TestHelperException e) { Log.d(LOG_TAG, String.format( "No %s implementation found with prefix %s.", mHelperClass, prefix), e); } } if (mHelper == null) { throw new TestHelperException("No implementation found for " + mHelperClass); } mBase.evaluate(); }
Source:
public JedisSentinelPool(String masterName, Set<String> sentinels, final GenericObjectPoolConfig poolConfig, final int connectionTimeout, final int soTimeout, final String password, final int database, final String clientName, final int sentinelConnectionTimeout, final int sentinelSoTimeout, final String sentinelPassword, final String sentinelClientName) { this(masterName, sentinels, poolConfig, connectionTimeout, soTimeout, null, password, database, clientName, sentinelConnectionTimeout, sentinelSoTimeout, null, sentinelPassword, sentinelClientName, false, false, null, null, null); }

Target:
public JedisSentinelPool(String masterName, Set<String> sentinels, final GenericObjectPoolConfig poolConfig, final int connectionTimeout, final int soTimeout, final String password, final int database, final String clientName, final int sentinelConnectionTimeout, final int sentinelSoTimeout, final String sentinelPassword, final String sentinelClientName) { this(masterName, sentinels, poolConfig, connectionTimeout, soTimeout, null, password, database, clientName, sentinelConnectionTimeout, sentinelSoTimeout, null, sentinelPassword, sentinelClientName); }
Source:
public void testCommit() throws SQLException, AuthorizeException, IOException { Context instance = new Context(); assertThat("HibernateDBConnection should exist", instance.getDBConnection(), notNullValue()); assertTrue("Context should be valid", instance.isValid()); assertTrue("Transaction should be open", instance.isTransactionAlive()); when(authorizeServiceSpy.isAdmin(instance)).thenReturn(true); String createdEmail = "myfakeemail@gmail.com"; EPerson newUser = ePersonService.create(instance); newUser.setFirstName(instance, "Tim"); newUser.setLastName(instance, "Smith"); newUser.setEmail(createdEmail); newUser.setCanLogIn(true); newUser.setLanguage(instance, I18nUtil.getDefaultLocale().getLanguage()); instance.commit(); assertThat("HibernateDBConnection should still be open", instance.getDBConnection(), notNullValue()); assertTrue("Context should still be valid", instance.isValid()); assertFalse("DB transaction should be closed", instance.isTransactionAlive()); newUser = instance.reloadEntity(newUser); assertEquals("New user should be created", newUser.getEmail(), createdEmail); String newEmail = "myrealemail@gmail.com"; newUser.setEmail(newEmail); instance.commit(); newUser = instance.reloadEntity(newUser); assertEquals("New email address should be saved", newUser.getEmail(), newEmail); ePersonService.delete(instance, newUser); cleanupContext(instance); }

Target:
public void testCommit() throws SQLException, AuthorizeException, IOException { Context instance = new Context(); assertThat("HibernateDBConnection should exist", instance.getDBConnection(), notNullValue()); assertTrue("Context should be valid", instance.isValid()); assertTrue("Transaction should be open", instance.isTransactionAlive()); when(authorizeServiceSpy.isAdmin(instance)).thenReturn(true); String createdEmail = "myfakeemail@example.com"; EPerson newUser = ePersonService.create(instance); newUser.setFirstName(instance, "Tim"); newUser.setLastName(instance, "Smith"); newUser.setEmail(createdEmail); newUser.setCanLogIn(true); newUser.setLanguage(instance, I18nUtil.getDefaultLocale().getLanguage()); instance.commit(); assertThat("HibernateDBConnection should still be open", instance.getDBConnection(), notNullValue()); assertTrue("Context should still be valid", instance.isValid()); assertFalse("DB transaction should be closed", instance.isTransactionAlive()); newUser = instance.reloadEntity(newUser); assertEquals("New user should be created", newUser.getEmail(), createdEmail); String newEmail = "myrealemail@example.com"; newUser.setEmail(newEmail); instance.commit(); newUser = instance.reloadEntity(newUser); assertEquals("New email address should be saved", newUser.getEmail(), newEmail); ePersonService.delete(instance, newUser); cleanupContext(instance); }
Source:
public void processEntity(Entity entity, float deltaTime) { timeRunning+=deltaTime; ViewPortComponent ViewPortComponent = viewPortMapper.get(entity); Camera camera = ViewPortComponent.viewPort.getCamera(); batch.setProjectionMatrix(camera.combined); batch.begin(); drawRecursively(entity, 1f); batch.end(); if (!drawOnly) { if (rayHandler != null) { rayHandler.setCulling(false); OrthographicCamera orthoCamera = (OrthographicCamera) camera; camera.combined.scl(1f / PhysicsBodyLoader.getScale()); rayHandler.setCombinedMatrix(orthoCamera); rayHandler.updateAndRender(); } if (world != null && isPhysicsOn) { doPhysicsStep(deltaTime); } } }

Target:
public void processEntity(Entity entity, float deltaTime) { timeRunning+=deltaTime; ViewPortComponent ViewPortComponent = viewPortMapper.get(entity); Camera camera = ViewPortComponent.viewPort.getCamera(); camera.update(); batch.setProjectionMatrix(camera.combined); batch.begin(); drawRecursively(entity, 1f); batch.end(); if (rayHandler != null) { rayHandler.setCulling(false); OrthographicCamera orthoCamera = (OrthographicCamera) camera; camera.combined.scl(1f / PhysicsBodyLoader.getScale()); rayHandler.setCombinedMatrix(orthoCamera); rayHandler.updateAndRender(); } }
Source:
private Icon makeMarkerIcon(boolean isActive) { Bitmap bmp = Bitmap.createBitmap(MAP_PLACE_ICON_SIZE, MAP_PLACE_ICON_SIZE, Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(bmp); Paint paint = new Paint(); paint.setAntiAlias(true); Drawable d; if (isActive) { paint.setColor(getResources().getColor(R.color.blue_liberal)); int circleSize = bmp.getWidth() / 2; canvas.drawCircle(circleSize, circleSize, circleSize, paint); Drawable drawable = ContextCompat.getDrawable(getActivity(), R.drawable.ic_place_dark); Bitmap bitmap = ((BitmapDrawable) drawable).getBitmap(); d = new BitmapDrawable(getResources(), Bitmap.createScaledBitmap(bitmap, MAP_PLACE_ICON_SIZE, MAP_PLACE_ICON_SIZE, true)); d = DrawableCompat.wrap(d).mutate(); DrawableCompat.setTint(d, getResources().getColor(R.color.blue_liberal)); } else { paint.setColor(getResources().getColor(R.color.green_progressive)); int circleSize = bmp.getWidth() / 2; canvas.drawCircle(circleSize, circleSize, circleSize / 2, paint); d = new BitmapDrawable(getResources(), bmp); } return new Icon(d); }

Target:
private Icon makeMarkerIcon(boolean isActive) { int iconSize = (int) getResources().getDimension(R.dimen.map_marker_icon_size); Bitmap bmp = Bitmap.createBitmap(iconSize, iconSize, Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(bmp); Paint paint = new Paint(); paint.setAntiAlias(true); Drawable d; if (isActive) { paint.setColor(getResources().getColor(R.color.blue_liberal)); int circleSize = bmp.getWidth() / 2; canvas.drawCircle(circleSize, circleSize, circleSize, paint); Drawable drawable = ContextCompat.getDrawable(getActivity(), R.drawable.ic_place_dark); Bitmap bitmap = ((BitmapDrawable) drawable).getBitmap(); d = new BitmapDrawable(getResources(), Bitmap.createScaledBitmap(bitmap, iconSize, iconSize, true)); d = DrawableCompat.wrap(d).mutate(); DrawableCompat.setTint(d, getResources().getColor(R.color.blue_liberal)); } else { paint.setColor(getResources().getColor(R.color.green_progressive)); int circleSize = bmp.getWidth() / 2; canvas.drawCircle(circleSize, circleSize, circleSize / 2, paint); d = new BitmapDrawable(getResources(), bmp); } return new Icon(d); }
Source:
private Checksum fileChecksum(File file) throws IOException { String location = file.getCanonicalPath(); if (checksumsByPath.containsKey(location)) { return checksumsByPath.get(location); } Checksum cs; synchronized (this) { cs = Checksum.forFile(file); } checksumsByPath.put(location, cs); return cs; }

Target:
private Checksum fileChecksum(File file) throws IOException { String location = file.getCanonicalPath(); synchronized (checksumsByPath) { Checksum checksum = checksumsByPath.get(location); if (checksum != null) return checksum; checksum = Checksum.forFile(file); checksumsByPath.put(location, checksum); return checksum; } }
Source:
public void load() { lock.lock(); try { File queueFile = getQueueFile(); if (queueFile.exists()) { BufferedReader in = new BufferedReader(new InputStreamReader(new FileInputStream(queueFile))); try { String line; while ((line = in.readLine()) != null) { AbstractProject j = Jenkins.getInstance().getItemByFullName(line, AbstractProject.class); if (j != null) j.scheduleBuild(); } } finally { in.close(); } queueFile.delete(); } else { queueFile = getXMLQueueFile(); if (queueFile.exists()) { Object unmarshaledObj = new XmlFile(XSTREAM, queueFile).read(); List items; if (unmarshaledObj instanceof State) { State state = (State) unmarshaledObj; items = state.items; WaitingItem.COUNTER.set(state.counter); } else { items = (List) unmarshaledObj; long maxId = 0; for (Object o : items) { if (o instanceof Item) { maxId = Math.max(maxId, ((Item)o).id); } } WaitingItem.COUNTER.set(maxId); } for (Object o : items) { if (o instanceof Task) { schedule((Task)o, 0); } else if (o instanceof Item) { Item item = (Item)o; if (item.task == null) { continue; } if (item instanceof WaitingItem) { item.enter(this); } else if (item instanceof BlockedItem) { item.enter(this); } else if (item instanceof BuildableItem) { item.enter(this); } else { throw new IllegalStateException("Unknown item type! " + item); } } } File bk = new File(queueFile.getPath() + ".bak"); bk.delete(); queueFile.renameTo(bk); queueFile.delete(); } } } catch (IOException e) { LOGGER.log(Level.WARNING, "Failed to load the queue file " + getXMLQueueFile(), e); } finally { updateSnapshot(); lock.unlock(); } }

Target:
public void load() { lock.lock(); try { try { File queueFile = getQueueFile(); if (queueFile.exists()) { BufferedReader in = new BufferedReader(new InputStreamReader(new FileInputStream(queueFile))); try { String line; while ((line = in.readLine()) != null) { AbstractProject j = Jenkins.getInstance().getItemByFullName(line, AbstractProject.class); if (j != null) j.scheduleBuild(); } } finally { in.close(); } queueFile.delete(); } else { queueFile = getXMLQueueFile(); if (queueFile.exists()) { Object unmarshaledObj = new XmlFile(XSTREAM, queueFile).read(); List items; if (unmarshaledObj instanceof State) { State state = (State) unmarshaledObj; items = state.items; WaitingItem.COUNTER.set(state.counter); } else { items = (List) unmarshaledObj; long maxId = 0; for (Object o : items) { if (o instanceof Item) { maxId = Math.max(maxId, ((Item)o).id); } } WaitingItem.COUNTER.set(maxId); } for (Object o : items) { if (o instanceof Task) { schedule((Task)o, 0); } else if (o instanceof Item) { Item item = (Item)o; if (item.task == null) { continue; } if (item instanceof WaitingItem) { item.enter(this); } else if (item instanceof BlockedItem) { item.enter(this); } else if (item instanceof BuildableItem) { item.enter(this); } else { throw new IllegalStateException("Unknown item type! " + item); } } } File bk = new File(queueFile.getPath() + ".bak"); bk.delete(); queueFile.renameTo(bk); queueFile.delete(); } } } catch (IOException e) { LOGGER.log(Level.WARNING, "Failed to load the queue file " + getXMLQueueFile(), e); } finally { updateSnapshot(); } } finally { lock.unlock(); } }
Source:
public void process(JSONRequestContext jsonRequestContext) { StudentGroupContactLogEntryCommentDAO entryCommentDAO = DAOFactory.getInstance().getStudentGroupContactLogEntryCommentDAO(); try { Long commentId = jsonRequestContext.getLong("commentId"); StudentGroupContactLogEntryComment comment = entryCommentDAO.findById(commentId); String commentText = jsonRequestContext.getRequest().getParameter("commentText"); String commentCreatorName = jsonRequestContext.getRequest().getParameter("commentCreatorName"); Date commentDate = new Date(NumberUtils.createLong(jsonRequestContext.getRequest().getParameter("commentDate"))); entryCommentDAO.update(comment, commentText, commentDate, commentCreatorName); Map<String, Object> info = new HashMap<String, Object>(); info.put("id", comment.getId()); info.put("creatorName", comment.getCreatorName()); info.put("timestamp", comment.getCommentDate().getTime()); info.put("text", comment.getText()); info.put("entryId", comment.getEntry().getId()); jsonRequestContext.addResponseParameter("results", info); } catch (Exception e) { throw new SmvcRuntimeException(e); } }

Target:
public void process(JSONRequestContext jsonRequestContext) { StudentGroupContactLogEntryCommentDAO entryCommentDAO = DAOFactory.getInstance().getStudentGroupContactLogEntryCommentDAO(); Long commentId = jsonRequestContext.getLong("commentId"); if (commentId == null) throw new SmvcRuntimeException(StatusCode.UNDEFINED, "CommentId was not defined."); try { StudentGroupContactLogEntryComment comment = entryCommentDAO.findById(commentId); String commentText = jsonRequestContext.getString("commentText"); String commentCreatorName = jsonRequestContext.getString("commentCreatorName"); Date commentDate = jsonRequestContext.getDate("commentDate"); entryCommentDAO.update(comment, commentText, commentDate, commentCreatorName); Map<String, Object> info = new HashMap<String, Object>(); info.put("id", comment.getId()); info.put("creatorName", comment.getCreatorName()); info.put("timestamp", comment.getCommentDate() != null ? comment.getCommentDate().getTime() : ""); info.put("text", comment.getText()); info.put("entryId", comment.getEntry().getId()); jsonRequestContext.addResponseParameter("results", info); } catch (Exception e) { throw new SmvcRuntimeException(e); } }
Source:
public void setAcceptableValues(Collection<String> values) { panels.clear(); wrapperPanel.clear(); if (values != null) { for (final String value : values) { if(! checkBoxes.containsKey(value)) { addCheckBoxOptions(value); } } } int row = 0; int column = 0; for(String currentCheckBoxLabel : panels.keySet()) { if(column == 4) { column = 0; row++; } weekDaysTable.setWidget(row, column, panels.get(currentCheckBoxLabel)); column++; } selectedItems = initSelectedItems(); if (selectedItemsString != null) { setSelections(Arrays.asList(selectedItemsString.split(","))); } wrapperPanel.add(weekDaysTable); }

Target:
public void setAcceptableValues(Collection<String> values) { panels.clear(); wrapperPanel.clear(); if (values != null) { for (final String value : values) { if(! checkBoxes.containsKey(value)) { addCheckBox(value); } } } int row = 0; int column = 0; for(String currentCheckBoxLabel : panels.keySet()) { if(column == MAX_COLUMNS_IN_A_ROW) { column = 0; row++; } checkBoxesTable.setWidget(row, column, panels.get(currentCheckBoxLabel)); column++; } selectedItems = initSelectedItems(); if (selectedItemsString != null) { setSelections(Arrays.asList(selectedItemsString.split(","))); } wrapperPanel.add(checkBoxesTable); }
Source:
public static void listVolumes(ServerContext context) throws Exception { try { listTable(Ample.DataLevel.ROOT, context); } catch (UnsupportedOperationException ex) { } System.out.println(); listTable(Ample.DataLevel.METADATA, context); System.out.println(); listTable(Ample.DataLevel.USER, context); }

Target:
public static void listVolumes(ServerContext context) throws Exception { listTable(Ample.DataLevel.ROOT, context); System.out.println(); listTable(Ample.DataLevel.METADATA, context); System.out.println(); listTable(Ample.DataLevel.USER, context); }
Source:
private static void initFactoryClassList() { if (factoryClassNames.isEmpty()) { String baseODK = BuildConfig.BUILD_DIR + "/intermediates/javac/commcareDebug/compileCommcareDebugJavaWithJavac/classes/"; String baseCC = BuildConfig.PROJECT_DIR + "/../../commcare-core/build/classes/java/main/"; addExternalizableClassesFromDir(baseODK.replace("/", File.separator), factoryClassNames); addExternalizableClassesFromDir(baseCC.replace("/", File.separator), factoryClassNames); } }

Target:
private static void initFactoryClassList() { if (factoryClassNames.isEmpty()) { String[] baseODK = new String[]{BuildConfig.BUILD_DIR + "/intermediates/javac/commcareDebug/compileCommcareDebugJavaWithJavac/classes/" , BuildConfig.BUILD_DIR + "/intermediates/javac/commcareDebug/classes/"}; String baseCC = BuildConfig.PROJECT_DIR + "/../../commcare-core/build/classes/java/main/"; for(String variant : baseODK) { addExternalizableClassesFromDir(variant.replace("/", File.separator), factoryClassNames); } addExternalizableClassesFromDir(baseCC.replace("/", File.separator), factoryClassNames); } }
Source:
public void handleError(String error) { if (error != null && !error.isEmpty()) { mErrorView.setVisibility(View.VISIBLE); mErrorView.setText(error); mInputView.setContentDescription(String.format("%s. %s. Error, %s.", mInputView.getSelectedItemName(), mField.getInstructions(), error)); } else { logger.warn("error message not provided, so not informing the user about this error"); } }

Target:
public void handleError(String error) { if (error != null && !error.isEmpty()) { mErrorView.setVisibility(View.VISIBLE); mErrorView.setText(error); final String errorTag = mInputView.getResources().getString(R.string.label_error); mInputView.setContentDescription(String.format("%s. %s. %s, %s.", mInputView.getSelectedItemName(), mField.getInstructions(), errorTag, error)); } else { logger.warn("error message not provided, so not informing the user about this error"); } }
Source:
public boolean isDuplicateConcurRequestCashAdvance(ConcurRequestedCashAdvance concurRequestedCashAdvance) { Collection<ConcurRequestedCashAdvance> concurRequestedCashAdvances = null; Map<String, String> fieldValues = new HashMap<String, String>(); fieldValues.put(ConcurPropertyConstants.ConcurRequestedCashAdvance.EMPLOYEE_ID, concurRequestedCashAdvance.getEmployeeId()); fieldValues.put(ConcurPropertyConstants.ConcurRequestedCashAdvance.REQUEST_ID, concurRequestedCashAdvance.getRequestId()); fieldValues.put(ConcurPropertyConstants.ConcurRequestedCashAdvance.PAYMENT_AMOUNT, concurRequestedCashAdvance.getPaymentAmount().toString()); concurRequestedCashAdvances = businessObjectService.findMatching(ConcurRequestedCashAdvance.class, fieldValues); boolean isDuplicate = (CollectionUtils.isEmpty(concurRequestedCashAdvances)) ? false : true; return isDuplicate; }

Target:
public boolean isDuplicateConcurRequestCashAdvance(ConcurRequestedCashAdvance concurRequestedCashAdvance) { Collection<ConcurRequestedCashAdvance> concurRequestedCashAdvances = null; Map<String, String> fieldValues = new HashMap<String, String>(); fieldValues.put(ConcurPropertyConstants.ConcurRequestedCashAdvance.EMPLOYEE_ID, concurRequestedCashAdvance.getEmployeeId()); fieldValues.put(ConcurPropertyConstants.ConcurRequestedCashAdvance.REQUEST_ID, concurRequestedCashAdvance.getRequestId()); fieldValues.put(ConcurPropertyConstants.ConcurRequestedCashAdvance.PAYMENT_AMOUNT, concurRequestedCashAdvance.getPaymentAmount().toString()); concurRequestedCashAdvances = businessObjectService.findMatching(ConcurRequestedCashAdvance.class, fieldValues); boolean isDuplicate = CollectionUtils.isNotEmpty(concurRequestedCashAdvances); return isDuplicate; }
Source:
public TabletData(KeyExtent extent, VolumeManager fs, TabletMetadata meta) { this.time = meta.getTime(); this.compactID = meta.getCompactId().orElse(-1); this.flushID = meta.getFlushId().orElse(-1); this.directoryName = meta.getDirName(); this.logEntries.addAll(meta.getLogs()); meta.getScans() .forEach(tabletFile -> scanFiles.add(new FileRef(tabletFile.getMetadataEntry()))); if (meta.getLast() != null) this.lastLocation = new TServerInstance(meta.getLast()); meta.getFilesMap().forEach((tabletFile, dfv) -> { dataFiles.put(new FileRef(tabletFile.getMetadataEntry()), dfv); }); meta.getLoaded().forEach((path, txid) -> { bulkImported.computeIfAbsent(txid, k -> new ArrayList<FileRef>()).add(new FileRef(path)); }); }

Target:
public TabletData(KeyExtent extent, VolumeManager fs, TabletMetadata meta) { this.time = meta.getTime(); this.compactID = meta.getCompactId().orElse(-1); this.flushID = meta.getFlushId().orElse(-1); this.directoryName = meta.getDirName(); this.logEntries.addAll(meta.getLogs()); meta.getScans().forEach(tabletFile -> scanFiles.add(new FileRef(tabletFile))); if (meta.getLast() != null) this.lastLocation = new TServerInstance(meta.getLast()); meta.getFilesMap().forEach((tabletFile, dfv) -> { dataFiles.put(new FileRef(tabletFile), dfv); }); meta.getLoaded().forEach((path, txid) -> { bulkImported.computeIfAbsent(txid, k -> new ArrayList<FileRef>()).add(new FileRef(path)); }); }
Source:
public void makeProgress(int progress) { new Handler().postDelayed(() -> { circularProgressBar.setCurrentProgress(progress); if (progress == MAX_PROGRESS) { new Handler().postDelayed(() -> { setCircularProgressVisibility(GONE); circularProgressBar.setCurrentProgress(NO_PROGRESS); }, FINAL_LOAD_DELAY); } }, NO_DELAY); }

Target:
public void makeProgress(int progress) { circularProgressBar.setCurrentProgress(progress); }
Source:
public static String appendClause(String query, String clause) { if (StringUtils.isEmpty(query)) { return clause; } else if (StringUtils.isEmpty(query)) { return query; } else { return query + " AND " + clause; } }

Target:
public static String appendClause(String query, String clause) { if (StringUtils.isBlank(query)) { return clause; } else if (StringUtils.isBlank(clause)) { return query; } else { return query + " AND " + clause; } }
Source:
public void testCountProjectsByFilter() throws MiddlewareQueryException { final List<Project> projects = this.workbenchDataManager.getProjects(); final Map<ProgramFilters, Object> filters = new HashMap<>(); if(!projects.isEmpty()){ Project project = projects.get(0); filters.put(ProgramFilters.CROP_TYPE, project.getCropType()); filters.put(ProgramFilters.PROGRAM_NAME, project.getProjectName()); long count = this.workbenchDataManager.countProjectsByFilter(filters); assertThat(new Long(1),is(equalTo(count))); } }

Target:
public void testCountProjectsByFilter() throws MiddlewareQueryException { final List<Project> projects = this.workbenchDataManager.getProjects(); final Map<ProgramFilters, Object> filters = new HashMap<>(); if(!projects.isEmpty()){ final Project project = projects.get(0); filters.put(ProgramFilters.CROP_TYPE, project.getCropType()); filters.put(ProgramFilters.PROGRAM_NAME, project.getProjectName()); final long count = this.workbenchDataManager.countProjectsByFilter(filters); assertThat(new Long(1),is(equalTo(count))); } }
Source:
public boolean isTheNewDesignAvailable() { if (Jenkins.getVersion().isNewerThan(new VersionNumber("2.88"))) { return true; } return false; }

Target:
public boolean isTheNewDesignAvailable() { final VersionNumber version = Jenkins.getVersion(); if (version != null && version.isNewerThan(new VersionNumber("2.103"))) { return true; } return false; }
Source:
public Binding[] getBindings() { Set<Binding> bindings = new HashSet<Binding>(); bindings.addAll(bindingService.getActiveBindings()); for (Binding binding : manager.getBindings()) { bindings.add(binding); } return bindings.toArray(new Binding[0]); }

Target:
public Binding[] getBindings() { return manager.getBindings(); }
Source:
Sample to(SampleDto sampleDto) throws IOException { authorizationManager.throwIfUnauthenticated(); checkArgument(sampleDto.getProjectId() != null, "A Project id must be provided to construct Sample."); Sample sample = Dtos.to(sampleDto); Project project = sqlProjectDAO.get(sampleDto.getProjectId()); ServiceUtils.throwIfNull(project, "projectId", sampleDto.getProjectId()); sample.setProject(project); if (sampleDto.getSampleAdditionalInfo().getParentId() != null) { Sample parent = sampleDao.getSample(sampleDto.getSampleAdditionalInfo().getParentId()); ServiceUtils.throwIfNull(parent, "parentId", sampleDto.getSampleAdditionalInfo().getParentId()); sample.getSampleAdditionalInfo().setParent(parent); } if (sampleDto.getSampleIdentity() != null) { sample.setIdentity(identityService.to(sampleDto.getSampleIdentity())); } if (sampleDto.getSampleAnalyte() != null) { sample.setSampleAnalyte(sampleAnalyteService.to(sampleDto.getSampleAnalyte())); } if (sampleDto.getSampleTissue() != null) { sample.setSampleTissue(sampleTissueService.to(sampleDto.getSampleTissue())); } return sample; }

Target:
Sample to(SampleDto sampleDto) throws IOException { authorizationManager.throwIfUnauthenticated(); checkArgument(sampleDto.getProjectId() != null, "A Project id must be provided to construct Sample."); Sample sample = Dtos.to(sampleDto); Project project = sqlProjectDAO.get(sampleDto.getProjectId()); ServiceUtils.throwIfNull(project, "projectId", sampleDto.getProjectId()); sample.setProject(project); if (sampleDto.getSampleAdditionalInfo() != null && sampleDto.getSampleAdditionalInfo().getParentId() != null) { Sample parent = sampleDao.getSample(sampleDto.getSampleAdditionalInfo().getParentId()); ServiceUtils.throwIfNull(parent, "parentId", sampleDto.getSampleAdditionalInfo().getParentId()); sample.getSampleAdditionalInfo().setParent(parent); } if (sampleDto.getSampleIdentity() != null) { sample.setIdentity(identityService.to(sampleDto.getSampleIdentity())); } if (sampleDto.getSampleAnalyte() != null) { sample.setSampleAnalyte(sampleAnalyteService.to(sampleDto.getSampleAnalyte())); } if (sampleDto.getSampleTissue() != null) { sample.setSampleTissue(sampleTissueService.to(sampleDto.getSampleTissue())); } return sample; }
Source:
protected String createProcessTitle(Map<String, String> context) { return "MoveIndexAlias"; }

Target:
protected String createProcessTitle(Map<String, String> context) { return Strings.apply("Moving active elasticsearch alias from index '%s' to '%s'", Strings.join(elastic.getLowLevelClient() .getIndicesForAlias(mixing.getDescriptor(context.get("ed"))), ","), context.get("destination")); }
Source:
public Response doExport(Action action) { validateParameters(action, "storageDomain.id|name"); Disk disk = get(); Guid sourceStorageDomainId = new Guid(disk.getStorageDomains().getStorageDomains().get(0).getId()); Guid sourceStoragePoolId = StorageDomainHelper.getStoragePoolIdForDomain(this, sourceStorageDomainId); ExportRepoImageParameters exportParameters = new ExportRepoImageParameters(new Guid(disk.getImageId())); exportParameters.setStoragePoolId(sourceStoragePoolId); exportParameters.setStorageDomainId(sourceStorageDomainId); exportParameters.setImageGroupID(new Guid(disk.getId())); exportParameters.setDestinationDomainId(getStorageDomainId(action)); return doAction(VdcActionType.ExportRepoImage, exportParameters, action); }

Target:
public Response doExport(Action action) { validateParameters(action, "storageDomain.id|name"); Disk disk = get(); ExportRepoImageParameters exportParameters = new ExportRepoImageParameters(asGuid(disk.getImageId())); exportParameters.setStorageDomainId(asGuid(disk.getStorageDomains().getStorageDomains().get(0).getId())); exportParameters.setStoragePoolId(getDataCenterId(exportParameters.getStorageDomainId())); exportParameters.setImageGroupID(asGuid(disk.getId())); exportParameters.setDestinationDomainId(getStorageDomainId(action)); return doAction(VdcActionType.ExportRepoImage, exportParameters, action); }
Source:
public void drawLicenseIcons(ImageLicense license, Canvas canvas, Context context) { final int bottom = SnippetImage.HEIGHT - SnippetImage.BOTTOM_PADDING; final int top = bottom - SnippetImage.ICONS_HEIGHT; int left = SnippetImage.HORIZONTAL_PADDING; int right = left + SnippetImage.ICONS_WIDTH; if (isArticleRTL) { right = SnippetImage.WIDTH - SnippetImage.HORIZONTAL_PADDING; left = right - SnippetImage.ICONS_WIDTH; } if (!license.isMainPage()) { Drawable d = context.getResources().getDrawable(license.getLicenseIcon()); d.setBounds(left, top, right, bottom); d.draw(canvas); } }

Target:
public void drawLicenseIcons(ImageLicense license, Canvas canvas, Context context) { final int bottom = SnippetImage.HEIGHT - SnippetImage.BOTTOM_PADDING; final int top = bottom - SnippetImage.ICONS_HEIGHT; int left = SnippetImage.HORIZONTAL_PADDING; int right = left + SnippetImage.ICONS_WIDTH; if (isArticleRTL) { right = SnippetImage.WIDTH - SnippetImage.HORIZONTAL_PADDING; left = right - SnippetImage.ICONS_WIDTH; } Drawable d = context.getResources().getDrawable(leadImageBitmap == null ? R.drawable.ic_license_cc : license.getLicenseIcon()); d.setBounds(left, top, right, bottom); d.draw(canvas); }
Source:
private static boolean getLoginStatus(final String page) { if (StringUtils.isBlank(page)) { Log.e(Settings.tag, "cgeoBase.checkLogin: No page given"); return false; } setActualStatus(res.getString(R.string.init_login_popup_ok)); setActualLoginStatus(BaseUtils.matches(page, GCConstants.PATTERN_LOGIN_NAME)); if (isActualLoginStatus()) { setActualUserName(BaseUtils.getMatch(page, GCConstants.PATTERN_LOGIN_NAME, true, "???")); setActualMemberStatus(BaseUtils.getMatch(page, GCConstants.PATTERN_MEMBER_STATUS, true, "???")); setActualCachesFound(Integer.parseInt(BaseUtils.getMatch(page, GCConstants.PATTERN_CACHES_FOUND, true, "0").replaceAll("[,\\.]", ""))); return true; } setActualLoginStatus(BaseUtils.matches(page, GCConstants.PATTERN_LOGIN_NAME_LOGIN_PAGE)); if (isActualLoginStatus()) { setActualUserName(Settings.getUsername()); setActualMemberStatus(Settings.getMemberStatus()); return true; } setActualStatus(res.getString(R.string.init_login_popup_failed)); return false; }

Target:
private static boolean getLoginStatus(final String page) { if (StringUtils.isBlank(page)) { Log.e(Settings.tag, "cgeoBase.checkLogin: No page given"); return false; } setActualStatus(res.getString(R.string.init_login_popup_ok)); setActualLoginStatus(BaseUtils.matches(page, GCConstants.PATTERN_LOGIN_NAME)); if (isActualLoginStatus()) { setActualUserName(BaseUtils.getMatch(page, GCConstants.PATTERN_LOGIN_NAME, true, "???")); setActualMemberStatus(BaseUtils.getMatch(page, GCConstants.PATTERN_MEMBER_STATUS, true, "???")); setActualCachesFound(Integer.parseInt(BaseUtils.getMatch(page, GCConstants.PATTERN_CACHES_FOUND, true, "0").replaceAll("[,.]", ""))); return true; } setActualLoginStatus(BaseUtils.matches(page, GCConstants.PATTERN_LOGIN_NAME_LOGIN_PAGE)); if (isActualLoginStatus()) { setActualUserName(Settings.getUsername()); setActualMemberStatus(Settings.getMemberStatus()); return true; } setActualStatus(res.getString(R.string.init_login_popup_failed)); return false; }
Source:
List<String> getAllSeeds() { final ImmutableList.Builder<String> builder = new ImmutableList.Builder<>(); return builder.addAll(currentSeeds).addAll(newSeeds).addAll(oldSeeds).build(); }

Target:
List<String> getAllSeeds() { return new ImmutableList.Builder<String>() .addAll(currentSeeds) .addAll(newSeeds) .addAll(oldSeeds) .build(); }
Source:
public void filter() { final String filterText = view.getFilterText(); final List<SocialUser> filteredUsers = allUsers.stream() .filter(user -> user.getName().contains(filterText) || user.getUserName().contains(filterText)) .collect(Collectors.toList()); listUsers(filteredUsers); }

Target:
public void filter() { final String filterText = view.getFilterText(); final List<SocialUser> filteredUsers = allUsers.stream() .filter(user -> { final String name = user.getName(); final String userName = user.getUserName(); final boolean nameMatch = name != null && name.contains(filterText); final boolean userNameMatch = userName.contains(filterText); return nameMatch || userNameMatch; }) .collect(Collectors.toList()); listUsers(filteredUsers); }
Source:
public synchronized PartitioningSpillResult partitionAndSpill(Page page, IntPredicate spillPartitionMask) { requireNonNull(page, "page is null"); requireNonNull(spillPartitionMask, "spillPartitionMask is null"); checkArgument(page.getChannelCount() == types.size(), "Wrong page channel count, expected %s but got %s", types.size(), page.getChannelCount()); checkState(!readingStarted, "reading already started"); IntArrayList unspilledPositions = partitionPage(page, spillPartitionMask); ListenableFuture<?> future = flushFullBuilders(); return new PartitioningSpillResult(future, page.getPositions(unspilledPositions.toIntArray(), 0, unspilledPositions.size())); }

Target:
public synchronized PartitioningSpillResult partitionAndSpill(Page page, IntPredicate spillPartitionMask) { requireNonNull(page, "page is null"); requireNonNull(spillPartitionMask, "spillPartitionMask is null"); checkArgument(page.getChannelCount() == types.size(), "Wrong page channel count, expected %s but got %s", types.size(), page.getChannelCount()); checkState(!readingStarted, "reading already started"); IntArrayList unspilledPositions = partitionPage(page, spillPartitionMask); ListenableFuture<?> future = flushFullBuilders(); return new PartitioningSpillResult(future, page.getPositions(unspilledPositions.elements(), 0, unspilledPositions.size())); }
Source:
void createHandle (int index) { if ((style & SWT.BALLOON) != 0) { state |= HANDLE; handle = OS.gtk_window_new (OS.GTK_WINDOW_POPUP); Color background = display.getSystemColor (SWT.COLOR_INFO_BACKGROUND); if (OS.GTK_VERSION >= OS.VERSION (3, 10, 0)) { long context = OS.gtk_widget_get_style_context (handle); String css = "GtkWindow {background-color: rgb(" + background.getRed() +", " + background.getGreen() +", " + background.getBlue() +");}"; gtk_css_provider_load_from_css (context, css); OS.gtk_style_context_invalidate (context); } else if (OS.GTK_VERSION < OS.VERSION (3, 10, 0) && OS.GTK_VERSION >= OS.VERSION (3, 0, 0)) { GdkColor color = background.handle; GdkRGBA rgba = new GdkRGBA(); rgba.alpha = 1; rgba.red = (color.red & 0xFFFF) / (float)0xFFFF; rgba.green = (color.green & 0xFFFF) / (float)0xFFFF; rgba.blue = (color.blue & 0xFFFF) / (float)0xFFFF; OS.gtk_widget_override_color (handle, OS.GTK_STATE_FLAG_NORMAL, rgba); } else { OS.gtk_widget_modify_bg (handle, OS.GTK_STATE_NORMAL, background.handle); } OS.gtk_window_set_type_hint (handle, OS.GDK_WINDOW_TYPE_HINT_TOOLTIP); } }

Target:
void createHandle (int index) { if ((style & SWT.BALLOON) != 0) { state |= HANDLE; handle = OS.gtk_window_new (OS.GTK_WINDOW_POPUP); Color background = display.getSystemColor (SWT.COLOR_INFO_BACKGROUND); if (OS.GTK3) { long context = OS.gtk_widget_get_style_context (handle); String css = "GtkWindow {background-color: rgb(" + background.getRed() +", " + background.getGreen() +", " + background.getBlue() +");}"; gtk_css_provider_load_from_css (context, css); OS.gtk_style_context_invalidate (context); } else { OS.gtk_widget_modify_bg (handle, OS.GTK_STATE_NORMAL, background.handle); } OS.gtk_window_set_type_hint (handle, OS.GDK_WINDOW_TYPE_HINT_TOOLTIP); } }