本文整理汇总了Java中org.eclipse.emf.common.util.ECollections类的典型用法代码示例。如果您正苦于以下问题:Java ECollections类的具体用法?Java ECollections怎么用?Java ECollections使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ECollections类属于org.eclipse.emf.common.util包,在下文中一共展示了ECollections类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getVariableDeclarations
import org.eclipse.emf.common.util.ECollections; //导入依赖的package包/类
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public EList<VariableDeclaration> getVariableDeclarations() {
EList<VariableDeclaration> _switchResult = null;
boolean _matched = false;
if (this instanceof VariableDeclaration) {
_matched=true;
_switchResult = ECollections.<VariableDeclaration>toEList(java.util.Collections.<VariableDeclaration>unmodifiableList(org.eclipse.xtext.xbase.lib.CollectionLiterals.<VariableDeclaration>newArrayList(((VariableDeclaration) this))));
}
if (!_matched) {
if (this instanceof VariableBinding) {
_matched=true;
_switchResult = ECollections.<VariableDeclaration>toEList(Iterators.<VariableDeclaration>filter(this.eAllContents(), VariableDeclaration.class));
}
}
if (!_matched) {
_switchResult = ECollections.<VariableDeclaration>toEList(java.util.Collections.<VariableDeclaration>unmodifiableList(org.eclipse.xtext.xbase.lib.CollectionLiterals.<VariableDeclaration>newArrayList()));
}
return _switchResult;
}
示例2: getStructuralMembers
import org.eclipse.emf.common.util.ECollections; //导入依赖的package包/类
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public EList<TStructMember> getStructuralMembers() {
EList<TStructMember> _xifexpression = null;
TStructuralType _structuralType = this.getStructuralType();
boolean _tripleNotEquals = (_structuralType != null);
if (_tripleNotEquals) {
_xifexpression = this.getStructuralType().getOwnedMembers();
}
else {
EList<TStructMember> _xifexpression_1 = null;
boolean _isEmpty = this.getAstStructuralMembers().isEmpty();
boolean _not = (!_isEmpty);
if (_not) {
_xifexpression_1 = this.getAstStructuralMembers();
}
else {
_xifexpression_1 = this.getGenStructuralMembers();
}
_xifexpression = _xifexpression_1;
}
return ECollections.<TStructMember>unmodifiableEList(_xifexpression);
}
示例3: addItem
import org.eclipse.emf.common.util.ECollections; //导入依赖的package包/类
protected <T extends Item> T addItem ( final T item, final CustomizationRequest customizationRequest, final Set<MasterListener<T>> masterListeners )
{
final List<String> originalLocalTags = new ArrayList<> ( customizationRequest.getLocalTags () ); // we do need a copy
customizeItem ( item, customizationRequest );
// set the name after customizing
final List<String> hier = new LinkedList<> ();
hier.addAll ( customizationRequest.getHierarchy () );
hier.addAll ( customizationRequest.getLocalTags () );
item.setName ( Names.makeHierarchy ( hier ) ); // FIXME: should allow a different naming scheme
logger.debug ( "Setting item name: {}", item.getName () );
if ( item.getInformation () == null )
{
item.setInformation ( OsgiFactory.eINSTANCE.createItemInformation () );
}
// apply the hierarchy afterwards ... overriding!
ECollections.setEList ( item.getInformation ().getHierarchy (), customizationRequest.getHierarchy () );
itemAdded ( item, customizationRequest, originalLocalTags, masterListeners );
return item;
}
示例4: getValues
import org.eclipse.emf.common.util.ECollections; //导入依赖的package包/类
@Override
public EList<JvmAnnotationValue> getValues() {
EList<JvmAnnotationValue> explicitValues = getExplicitValues();
List<JvmOperation> operations = Lists.newArrayList(getAnnotation().getDeclaredOperations());
if (operations.size() <= explicitValues.size()) {
return ECollections.unmodifiableEList(explicitValues);
}
Set<JvmOperation> seenOperations = Sets.newHashSetWithExpectedSize(operations.size());
BasicEList<JvmAnnotationValue> result = new BasicEList<JvmAnnotationValue>(operations.size());
for(JvmAnnotationValue value: explicitValues) {
seenOperations.add(value.getOperation());
result.add(value);
}
for(JvmOperation operation: operations) {
if (seenOperations.add(operation)) {
JvmAnnotationValue defaultValue = operation.getDefaultValue();
if (defaultValue != null) {
result.add(defaultValue);
}
}
}
return ECollections.unmodifiableEList(result);
}
示例5: 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;
}
示例6: 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;
}
示例7: filter
import org.eclipse.emf.common.util.ECollections; //导入依赖的package包/类
/**
* Filters an {@link EList} of type T to contain only elements matching the provided predicate.
*
* @param <T>
* list element type
* @param unfiltered
* unfiltered list
* @param predicate
* to apply
* @return filtered list
*/
public static <T> EList<T> filter(final EList<T> unfiltered, final Predicate<? super T> predicate) {
if (unfiltered == null) {
return ECollections.emptyEList();
}
if (predicate == null) {
throw new IllegalArgumentException("predicate must not be null"); //$NON-NLS-1$
}
EList<T> filtered = new BasicEList<T>(unfiltered.size() / 2); // Initial guess: half the original size
for (T t : unfiltered) {
if (predicate.apply(t)) {
filtered.add(t);
}
}
return filtered;
}
示例8: generatePropertiesForCatalogsInConfigurableSection
import org.eclipse.emf.common.util.ECollections; //导入依赖的package包/类
/**
* Generate properties for languages or legacy catalogs.
*
* @param section
* the section
* @param properties
* the properties
*/
private void generatePropertiesForCatalogsInConfigurableSection(final ConfigurableSection section, final Properties properties) {
String language = null;
EList<ConfiguredCatalog> configuredCatalogs = ECollections.emptyEList();
if (section instanceof CheckConfiguration) {
configuredCatalogs = ((CheckConfiguration) section).getLegacyCatalogConfigurations();
} else if (section instanceof ConfiguredLanguageValidator) {
language = ((ConfiguredLanguageValidator) section).getLanguage();
configuredCatalogs = ((ConfiguredLanguageValidator) section).getCatalogConfigurations();
}
for (ConfiguredCatalog catalog : configuredCatalogs) {
Set<Check> configuredChecks = Sets.newHashSet();
for (ConfiguredCheck configuredCheck : catalog.getCheckConfigurations()) {
generatePropertiesForConfiguredCheck(properties, language, configuredCheck);
configuredChecks.add(configuredCheck.getCheck());
}
for (Check unconfiguredCheck : Sets.difference(Sets.newHashSet(catalog.getCatalog().getAllChecks()), configuredChecks)) {
putInheritedProperties(properties, language, unconfiguredCheck, catalog, ECollections.emptyEList());
}
}
}
示例9: siblings
import org.eclipse.emf.common.util.ECollections; //导入依赖的package包/类
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public EList<Classifier> siblings() {
ArrayList<Classifier> result = CollectionLiterals.<Classifier>newArrayList();
EList<Classifier> _parents = this.parents();
for (final Classifier p : _parents) {
EList<Classifier> _children = p.children();
for (final Classifier sibling : _children) {
boolean _equals = sibling.equals(this);
boolean _not = (!_equals);
if (_not) {
result.add(sibling);
}
}
}
return ECollections.<Classifier>toEList(result);
}
示例10: ends
import org.eclipse.emf.common.util.ECollections; //导入依赖的package包/类
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public EList<EndPoint> ends() {
ArrayList<EndPoint> result = CollectionLiterals.<EndPoint>newArrayList();
Model _model = this.getModel();
EList<Relationship> _allRelationships = _model.allRelationships();
for (final Relationship rel : _allRelationships) {
boolean _isEnd = rel.isEnd(this);
if (_isEnd) {
EList<EndPoint> _endPoints = rel.getEndPoints();
for (final EndPoint ep : _endPoints) {
{
final Classifier type_ = ep.getEndType();
boolean _notEquals = (!Objects.equal(type_, null));
if (_notEquals) {
boolean _equals = type_.equals(this);
boolean _not = (!_equals);
if (_not) {
result.add(ep);
}
}
}
}
}
}
return ECollections.<EndPoint>toEList(result);
}
示例11: 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;
}
示例12: 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);
}
}
示例13: 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;
}
示例14: 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;
}
示例15: 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;
}