public void setTranslatedComment(String comment) { getOrCreateTranslation().setComment(comment); }
property.setKey(matcher.group(1).replace("\\n", "\n")); if(comment.length()>0) property.setComment(comment.toString());
private void createMessageFile(InputStream in, URI target, boolean isTemplate) throws IOException { BufferedReader reader = null; try { reader = new BufferedReader(new InputStreamReader(in, "UTF-8")); Property property = null; POHelper helper = new POHelper(); PropertyFile file = PropertiesFactory.eINSTANCE.createPropertyFile(); while((property=helper.readProperty(reader))!=null) { if(isTemplate) { property.setValue(property.getKey()); //get rid of the german comment property.setComment(null); } file.getProperties().add(property); } PropertiesResourceImpl resource = new PropertiesResourceImpl(target); resource.getContents().add(file); resource.save(new HashMap<Object, Object>()); } catch (UnsupportedEncodingException e) { LOGGER.error(e.getMessage(),e); } finally { reader.close(); } }
property.setComment(comment.toString()); PropertyAnnotation nonTranslatable = property.findAnnotation(PropertyAnnotations.NON_TRANSLATABLE); if(nonTranslatable!=null) {
property.setKey(key); property.setValue(translationDoc.get(QueryService.FIELD_VALUE)); property.setComment(translationDoc.get(QueryService.FIELD_COMMENT)); PropertyFileDescriptor slave = queryService.getDescriptor(translationDoc); if (slave == null)
/** * If we make it here, we know that the {@link Property} exists in the master * {@link PropertyFileDescriptor}, but we don't know if a corresponding {@link Property} exists * for the existing {@link PropertyFile}. If it does not, we create a new {@link Property}.<br> * * Hence perform a quick check, and create a new {@link Property} which we add to this * {@link PropertyFileDescriptor} if it does not yet exist.<br> */ private static void updateExistingProperty(PropertyFile existingFile, Property existingProperty, Property newProperty) { if (existingProperty == null) { existingProperty = PropertiesFactory.eINSTANCE.createProperty(); existingProperty.setKey(newProperty.getKey()); existingFile.getProperties().add(existingProperty); } existingProperty.setValue(newProperty.getValue()); existingProperty.setComment(newProperty.getComment()); }
@Override protected void onSubmit() { super.onSubmit(); IModel<List<? extends PropertyPair>> model = getModel(); List<? extends PropertyPair> list = model.getObject(); PropertyFileDescriptor descriptor = PropertyEditorPanel.this.getModelObject(); PropertyFile file = descriptor.loadProperties(); Map<String, Property> map = file.asMap(); for (PropertyPair pair : list) { Property translation = pair.getTranslation(); if(translation==null) continue; if (map.containsKey(translation.getKey())) { Property property = map.get(translation.getKey()); property.setComment(translation.getComment()); property.setValue(translation.getValue()); } else file.getProperties().add(translation); } propertyPersistence.saveProperties(descriptor, file); getSession().info("Saved successfully"); try { //TODO: this is very unclean... // give it some time to store the values Thread.sleep(500); } catch (InterruptedException e) { logger.error("Interrupted while waiting for property persistence",e); } } };
if (map.containsKey(translation.getKey())) { Property property = map.get(translation.getKey()); property.setComment(translation.getComment()); property.setValue(translation.getValue()); } else if (!isEmpty(translation.getValue())) {
origProp.setComment(newProp.getComment());