本文整理汇总了Java中org.eclipse.emf.common.util.ECollections.sort方法的典型用法代码示例。如果您正苦于以下问题:Java ECollections.sort方法的具体用法?Java ECollections.sort怎么用?Java ECollections.sort使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.emf.common.util.ECollections
的用法示例。
在下文中一共展示了ECollections.sort方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getEVersionsForIndexBranch
import org.eclipse.emf.common.util.ECollections; //导入方法依赖的package包/类
public List<EntityVersion> getEVersionsForIndexBranch(NoSQLSchema model)
{
List<EntityVersion> result = new ArrayList<EntityVersion>();
ECollections.sort(model.getEntities(), new Comparator<Entity>()
{
public int compare(Entity e0, Entity e1)
{
return e0.getName().compareTo(e1.getName());
}
});
for (Entity entity : model.getEntities())
for (EntityVersion eVersion : entity.getEntityversions())
result.add(eVersion);
return result;
}
示例2: getEVersionsFromEVersion
import org.eclipse.emf.common.util.ECollections; //导入方法依赖的package包/类
public List<EntityVersion> getEVersionsFromEVersion(EntityVersion eVersion)
{
List<EntityVersion> result = new ArrayList<EntityVersion>();
NoSQLSchema model = (NoSQLSchema)eVersion.eContainer().eContainer();
ECollections.sort(model.getEntities(), new Comparator<Entity>()
{
public int compare(Entity e0, Entity e1)
{
return e0.getName().compareTo(e1.getName());
}
});
for (Entity entity : model.getEntities())
for (EntityVersion evInEntity : entity.getEntityversions())
if (evInEntity.isRoot() && (evInEntity == eVersion || SchemaCollector.getEVersionsFromSchema(evInEntity).contains(eVersion)))
result.add(evInEntity);
return result;
}
示例3: getRepresentativePlanElements
import org.eclipse.emf.common.util.ECollections; //导入方法依赖的package包/类
/**
* Given a list representing a selection, return a list
* with the following properties:
*
* 1. the list is in temporal order (all elements will have a start time)
* 2. each element in the returned list was in the source list
* 3. each element in the returned list is in some chain
* 4. no two elements in the returned list are from the same chain
*
* @param list
* @return
*/
public static List<? extends EPlanElement> getRepresentativePlanElements(Collection<? extends EPlanElement> list) {
Map<TemporalChain, EPlanElement> chainToRepresentativeMap = createChainToRepresentiveMap(list);
EList<EPlanElement> representatives = new BasicEList<EPlanElement>(chainToRepresentativeMap.values());
ECollections.sort(representatives, new Comparator<EPlanElement>() {
@Override
public int compare(EPlanElement o1, EPlanElement o2) {
Date start1 = o1.getMember(TemporalMember.class).getStartTime();
Date start2 = o2.getMember(TemporalMember.class).getStartTime();
Amount<Duration> duration = DateUtils.subtract(start1, start2);
int comparison = duration.compareTo(DateUtils.ZERO_DURATION);
if (comparison != 0) {
return comparison;
}
return PlanUtils.INHERENT_ORDER.compare(o1, o2);
}
});
return representatives;
}
示例4: reorderElements
import org.eclipse.emf.common.util.ECollections; //导入方法依赖的package包/类
private void reorderElements(List<EPlanChild> allPlanElements, EPlanElement firstElement, int insertionIndex) {
this.newOrder = allPlanElements;
ISelection selection = new StructuredSelection(allPlanElements);
this.transferable = modifier.getTransferable(selection);
EList<EPlanChild> oldOrder = new BasicEList<EPlanChild>(allPlanElements);
ECollections.sort(oldOrder, PlanStructureComparator.INSTANCE);
this.oldOrder = oldOrder;
this.origin = modifier.getLocation(transferable);
TemporalChainTransferExtension.setTransferableChains(transferable, Collections.<TemporalChain>emptySet());
EPlanElement parent = (EPlanElement)firstElement.eContainer();
if (insertionIndex == 0) {
this.destination = new PlanInsertionLocation(parent, InsertionSemantics.ON, allPlanElements);
} else {
EPlanElement element = EPlanUtils.getChildren(parent).get(insertionIndex - 1);
this.destination = new PlanInsertionLocation(element, InsertionSemantics.AFTER, allPlanElements);
}
}
示例5: getChangedTimes
import org.eclipse.emf.common.util.ECollections; //导入方法依赖的package包/类
@Override
protected Map<EPlanElement, Date> getChangedTimes(EList<EPlanElement> sortedElements) {
IEditorPart editor = getActiveEditor();
Shell shell = editor.getSite().getShell();
ECollections.sort(sortedElements, TemporalChainUtils.CHAIN_ORDER);
EPlanElement planElement = sortedElements.get(0);
Date referenceDate = planElement.getMember(TemporalMember.class).getStartTime();
MoveSelectedDialog dialog = new MoveSelectedDialog(shell, referenceDate);
int code = dialog.open();
if (code != Window.OK) {
return Collections.emptyMap();
}
Map<EPlanElement, Date> map = new HashMap<EPlanElement, Date>();
Amount<Duration> offset = dialog.getOffset();
for (EPlanElement pe : sortedElements) {
TemporalMember member = pe.getMember(TemporalMember.class);
Date startTime = member.getStartTime();
Date newTime = DateUtils.add(startTime, offset);
map.put(pe, newTime);
}
return map;
}
示例6: execute
import org.eclipse.emf.common.util.ECollections; //导入方法依赖的package包/类
@Override
public Object execute(ExecutionEvent event) {
ISelection selection = HandlerUtil.getCurrentSelection(event);
EList<EPlanElement> elements = getSelectedTemporalElements(selection);
if (elements.size() > 0) {
IEditorPart editor = getActiveEditor();
if (editor == null) {
return null;
}
CopyManyTimesInputValidator validator = new CopyManyTimesInputValidator();
InputDialog d = new InputDialog(editor.getSite().getShell(), actionName, "How many copies do you want to make?", "", validator);
int code = d.open();
int nCopies = validator.getValue(); // this line must be after d.open();
if ((code == Window.OK) && (nCopies > 0) && (nCopies < 101)) {
ECollections.sort(elements, TemporalChainUtils.CHAIN_ORDER);
makinCopies(elements, nCopies);
}
}
return null;
}
示例7: execute
import org.eclipse.emf.common.util.ECollections; //导入方法依赖的package包/类
@Override
public Object execute(ExecutionEvent event) {
ISelection selection = HandlerUtil.getCurrentSelection(event);
EList<EPlanElement> elements = getSelectedTemporalElements(selection);
ECollections.sort(elements, TemporalChainUtils.CHAIN_ORDER);
EPlan plan = EPlanUtils.getPlan(elements.get(0));
Map<EPlanElement, Date> startTimes = getChangedTimes(elements);
// create moves for children
IPlanModifier modifier = PlanModifierMember.get(plan).getModifier();
TemporalExtentsCache cache = new TemporalExtentsCache(plan);
Map<EPlanElement, TemporalExtent> changedTimes = new LinkedHashMap<EPlanElement, TemporalExtent>();
for (EPlanElement element: startTimes.keySet()) {
Date start = startTimes.get(element);
Map<EPlanElement, TemporalExtent> extents = modifier.moveToStart(element, start, cache);
changedTimes.putAll(extents);
if (!extents.containsKey(element)) {
TemporalMember member = element.getMember(TemporalMember.class);
TemporalExtent extent = member.getExtent();
changedTimes.put(element, extent.moveToStart(start));
}
}
IUndoableOperation op = new SetExtentsOperation(actionVerb, plan, changedTimes, cache);
IUndoContext undoContext = TransactionUtils.getUndoContext(plan);
CommonUtils.execute(op, undoContext);
return null;
}
示例8: computeChecksum
import org.eclipse.emf.common.util.ECollections; //导入方法依赖的package包/类
/**
* Computes the checksum for a given {@link IdEObjectCollection}.
* The checksum for a collection is independent of the order of the
* collection's elements at the root level.
*
* @param collection
* the collection for which to compute a checksum
* @return the computed checksum
*
* @throws SerializationException
* in case any errors occur during computation of the checksum
*/
public static long computeChecksum(IdEObjectCollection collection) throws SerializationException {
final ResourceSetImpl resourceSetImpl = new ResourceSetImpl();
// TODO: do we need to instantiate the factory registry each time?
resourceSetImpl.setResourceFactoryRegistry(new ResourceFactoryRegistry());
final XMIResource res = (XMIResource) resourceSetImpl.createResource(VIRTUAL_URI);
((ResourceImpl) res).setIntrinsicIDToEObjectMap(new HashMap<String, EObject>());
final IdEObjectCollection copy = copyIdEObjectCollection(collection, res);
ECollections.sort(copy.getModelElements(), new Comparator<EObject>() {
public int compare(EObject o1, EObject o2) {
return copy.getModelElementId(o1).getId().compareTo(copy.getModelElementId(o2).getId());
}
});
final String serialized = copiedEObjectToString(copy, res);
return computeChecksum(serialized);
}
示例9: createContentsIfNecessary
import org.eclipse.emf.common.util.ECollections; //导入方法依赖的package包/类
private void createContentsIfNecessary(final View theElementView) {
final EObject theElement = theElementView.getElement();
final EList<Property> ownedAttributes = asEList(getOwnedAttributes(theElement));
if (!ownedAttributes.isEmpty()) {
final View theOwnedAttributeCompartment = getTheAttributeCompartment(theElementView);
for (final Property p : ownedAttributes) {
getOrCreateTheView(p, theOwnedAttributeCompartment);
}
@SuppressWarnings("unchecked")
final EList<View> attributeViews = theOwnedAttributeCompartment.getPersistedChildren();
ECollections.sort(attributeViews, new Comparator<View>() {
@Override
public int compare(final View left, final View right) {
return Integer.compare(indexOf(ownedAttributes, left.getElement(), 0),
indexOf(ownedAttributes, right.getElement(), 0));
}
});
}
for (final Generalization g : getGeneralizations(theElement)) {
getOrCreateTheView(g, theElementView.getDiagram());
}
}
示例10: copyContainment
import org.eclipse.emf.common.util.ECollections; //导入方法依赖的package包/类
@Override
protected void copyContainment(final EReference eReference, final EObject eObject, final EObject copyEObject) {
if (UMLPackage.Literals.CLASSIFIER.isInstance(eObject) && eObject.eIsSet(eReference) && eReference.isMany()
&& !((Collection<?>) eObject.eGet(eReference)).isEmpty()) {
@SuppressWarnings("unchecked")
final EList<EObject> source = (EList<EObject>) eObject.eGet(eReference);
@SuppressWarnings("unchecked")
final EList<EObject> target = (EList<EObject>) copyEObject.eGet(getTarget(eReference));
target.addAll(copyAll(source));
final Namespace original = (Namespace) eObject;
ECollections.sort(target, new Comparator<EObject>() {
@Override
public int compare(final EObject left, final EObject right) {
return Integer.compare(indexOf(source, original.getOwnedMember(getName(left)), 0),
indexOf(source, original.getOwnedMember(getName(right)), 0));
}
});
} else {
super.copyContainment(eReference, eObject, copyEObject);
}
}
示例11: sortPrimitiveList
import org.eclipse.emf.common.util.ECollections; //导入方法依赖的package包/类
private void sortPrimitiveList(EList<IdEObject> list) {
ECollections.sort(list, new Comparator<IdEObject>() {
@Override
public int compare(IdEObject o1, IdEObject o2) {
return comparePrimitives(o1, o2);
}
});
}
示例12: sortTraceRecords
import org.eclipse.emf.common.util.ECollections; //导入方法依赖的package包/类
private static void sortTraceRecords(EObject trace) {
if (!(trace instanceof org.eclipse.m2m.internal.qvt.oml.trace.Trace)) {
throw new IllegalArgumentException();
}
ECollections.sort(((org.eclipse.m2m.internal.qvt.oml.trace.Trace) trace).getTraceRecords(),
new TraceRecordComparator());
}
开发者ID:Cooperate-Project,项目名称:CooperateModelingEnvironment,代码行数:8,代码来源:TraceRecordTransformationTestBase.java
示例13: ChainOperation
import org.eclipse.emf.common.util.ECollections; //导入方法依赖的package包/类
/**
* Chain the elements in the specified order.
* @param modifier
* @param elements
* @param shouldReorderByTime
*/
public ChainOperation(PlanStructureModifier modifier, List<EPlanChild> elements, boolean shouldReorderByTime) {
super("chain items");
this.modifier = modifier;
trace.debug("creating " + ChainOperation.class.getSimpleName() + ": " + elements);
if ((elements == null) || (elements.size() < 2)) {
throw new IllegalArgumentException("must chain 2 or more elements");
}
if (!ConstraintUtils.sameParent(elements)) {
throw new IllegalArgumentException("all chained elements should have the same parent");
}
this.oldChains = TemporalChainUtils.getChains(elements, true);
EList<EPlanChild> allPlanElements = TemporalChainUtils.getChainPlanElements(oldChains);
for (EPlanChild element : elements) {
if (!allPlanElements.contains(element)) {
allPlanElements.add(element);
}
}
if (shouldReorderByTime) {
ECollections.sort(allPlanElements, TemporalChainUtils.CHAIN_ORDER);
} else {
ECollections.sort(allPlanElements, PlanStructureComparator.INSTANCE);
}
this.newChain = TemporalChainUtils.createChain(allPlanElements);
this.context = EPlanUtils.getPlan(allPlanElements.get(0));
checkOrder(allPlanElements);
}
示例14: getChangedTimes
import org.eclipse.emf.common.util.ECollections; //导入方法依赖的package包/类
@Override
protected Map<EPlanElement, Date> getChangedTimes(EList<EPlanElement> elements) {
ECollections.sort((EList<? extends EPlanElement>)elements, END_TIME_ORDER);
Date end = elements.get(elements.size()-1).getMember(TemporalMember.class).getExtent().getEnd();
Map<EPlanElement, Date> map = new HashMap<EPlanElement, Date>();
for (EPlanElement element: elements) {
TemporalExtent extent = element.getMember(TemporalMember.class).getExtent();
if (extent != null) {
map.put(element, new Date(end.getTime() - extent.getDurationMillis() ));
}
}
return map;
}
示例15: isEnabledForSelection
import org.eclipse.emf.common.util.ECollections; //导入方法依赖的package包/类
@Override
public boolean isEnabledForSelection(ISelection selection) {
EList<EPlanElement> elements = getSelectedTemporalElements(selection);
if (elements.size() != 2) {
return false;
} else {
ECollections.sort(elements, TemporalChainUtils.CHAIN_ORDER);
TemporalExtent one = elements.get(0).getMember(TemporalMember.class).getExtent();
TemporalExtent two = elements.get(1).getMember(TemporalMember.class).getExtent();
return(!(one == null || two == null));
}
}