Java Code Examples for org.eclipse.emf.common.util.ECollections#sort()

The following examples show how to use org.eclipse.emf.common.util.ECollections#sort() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: UpdateDataCommand.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
@Override
protected CommandResult doExecuteWithResult(IProgressMonitor monitor,
		IAdaptable info) throws ExecutionException {
	DataType t = searchDataType();	

	preHandleJavaObjectAndXMLData(t);

	data.setMultiple(multiplicity);
	data.setTransient(dataIsTransient);
	data.setDefaultValue(defaultValue);
	data.setDataType(t);
	data.setName(name);
	data.setDocumentation(description);
	data.setGenerated(generateData);

	((List) element.eGet(feature)).add(data);
	ECollections.sort(((EList<?>) element.eGet(feature)),new Comparator<Object>() {

		public int compare(Object o1, Object o2) {
			return ((Element) o1).getName().compareTo(((Element) o2).getName());
		}
	});
	return CommandResult.newOKCommandResult();
}
 
Example 2
Source File: IfcModel.java    From BIMserver with GNU Affero General Public License v3.0 5 votes vote down vote up
private void sortPrimitiveList(EList<IdEObject> list) {
	ECollections.sort(list, new Comparator<IdEObject>() {
		@Override
		public int compare(IdEObject o1, IdEObject o2) {
			return comparePrimitives(o1, o2);
		}
	});
}
 
Example 3
Source File: UsersWizardPage.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
private EList<CustomUserInfoValue> sortCustomUserInfoValues(final User selectedUser) {
    final EList<CustomUserInfoValue> customUserInfoValueList = selectedUser.getCustomUserInfoValues()
            .getCustomUserInfoValue();
    ECollections.sort(customUserInfoValueList, new Comparator<CustomUserInfoValue>() {

        @Override
        public int compare(final CustomUserInfoValue o1, final CustomUserInfoValue o2) {
            return o1.getName().compareToIgnoreCase(o2.getName());
        }
    });
    return customUserInfoValueList;
}
 
Example 4
Source File: AddDataCommand.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected CommandResult doExecuteWithResult(IProgressMonitor monitor,
		IAdaptable info) throws ExecutionException {
	DataType t = null ;
	t = ModelHelper.getDataTypeForID((Element) process, datatype);

	if (t instanceof JavaType) {
		data = ProcessFactory.eINSTANCE.createJavaObjectData();
		((JavaObjectData)data).setClassName(javaClassName);			
	} else if (t instanceof XMLType) {
		data = ProcessFactory.eINSTANCE.createXMLData();
		((XMLData)data).setNamespace(xmlNamespace);
		((XMLData)data).setType(xmlElement);
	} else {
		data = ProcessFactory.eINSTANCE.createData();
	}

	data.setMultiple(multiplicity);
	data.setDataType(t);
	data.setDefaultValue(defaultValue);
	data.setName(name);
	data.setDocumentation(description);
	data.setGenerated(generateData) ;
	data.setTransient(isTransient);

	((EList) container.eGet(feature)).add(data);
	ECollections.sort((EList<?>)container.eGet(feature),new Comparator<Object>() {

		public int compare(Object o1, Object o2) {
			return ((Element) o1).getName().compareTo(((Element) o2).getName());
		}
	});
	return CommandResult.newOKCommandResult(data);
}
 
Example 5
Source File: FindingDataAccessor.java    From elexis-3-core with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public List<Element> getList(){
	if (FindingsServiceHolder.findingsTemplateService != null) {
		FindingsTemplates findingsTemplates = FindingsServiceHolder.findingsTemplateService
			.getFindingsTemplates("Standard Vorlagen");
		
		List<String> parameters = new ArrayList<>();
		EList<FindingsTemplate> findingsTemplates2 = findingsTemplates.getFindingsTemplates();
		// sort
		ECollections.sort(findingsTemplates2, new Comparator<FindingsTemplate>() {
			
			@Override
			public int compare(FindingsTemplate o1, FindingsTemplate o2){
				if (o1 == null || o2 == null) {
					return o1 != null ? 1 : -1;
				}
				return StringUtils.lowerCase(o1.getTitle())
					.compareTo(StringUtils.lowerCase(o2.getTitle()));
			}
		});
		
		for (FindingsTemplate findingTemplate : findingsTemplates2) {
			if (findingTemplate.getInputData() instanceof InputDataGroupComponent
				|| findingTemplate.getInputData() instanceof InputDataGroup) {
				parameters.add(findingTemplate.getTitle());
			}
		}
		List<Element> ret = new ArrayList<Element>(parameters.size());
		for (String n : parameters) {
			// placeholder for first finding
			String placeholder = PREFIX_FIRST + n + SUFFIX;
			String readableName = n + " - " + "Erster";
			ret.add(createElement(readableName, placeholder));
			
			// placeholder for last finding
			placeholder = PREFIX_LAST + n + SUFFIX;
			readableName = n + " - " + "Letzter";
			ret.add(createElement(readableName, placeholder));
			
			// placeholder for all findings
			placeholder = PREFIX_ALL + n + SUFFIX;
			readableName = n + " - " + "Alle";
			ret.add(createElement(readableName, placeholder));
			}
		return ret;
	}
	return Collections.emptyList();
}