protected TextEditGroup createTextEditGroup(String label) { if (label.length() > 0){ return new CategorizedTextEditGroup(label, new GroupCategorySet(new GroupCategory(label, label, label))); } else { return new TextEditGroup(label); } }
/** * Creates a new group category set containing the union of the given two * group category sets * * @param one the first set of group categories * @param two the second set of group categories * * @return the union */ public static GroupCategorySet union(GroupCategorySet one, GroupCategorySet two) { Assert.isNotNull(one); Assert.isNotNull(two); // for performance we are using identity here. This is // valid since group categories are value objects and // therefore best used as static final fields. if (one == two) return one; if (one == NONE) return two; if (two == NONE) return one; Set combined= new HashSet(); combined.addAll(one.asList()); combined.addAll(two.asList()); return new GroupCategorySet(combined); }
/** * Returns <code>true</code> if the change has one of the given group * categories. Otherwise <code>false</code> is returned. * * @param groupCategories the group categories to check * * @return whether the change has one of the given group * categories * * @since 3.2 */ public boolean hasOneGroupCategory(List<GroupCategory> groupCategories) { if (fCombiedGroupCategories == null) { fCombiedGroupCategories= GroupCategorySet.NONE; for (Iterator<TextEditBasedChangeGroup> iter= fChangeGroups.iterator(); iter.hasNext();) { TextEditBasedChangeGroup group= iter.next(); fCombiedGroupCategories= GroupCategorySet.union(fCombiedGroupCategories, group.getGroupCategorySet()); } } return fCombiedGroupCategories.containsOneCategory(groupCategories); }
/** * Adds a {@link TextEditBasedChangeGroup text edit change group}. * The edits managed by the given text edit change group must be part of * the change's root edit. * * @param group the text edit change group to add */ public void addChangeGroup(TextEditBasedChangeGroup group) { Assert.isTrue(group != null); fChangeGroups.add(group); if (fCombiedGroupCategories != null) { fCombiedGroupCategories= GroupCategorySet.union(fCombiedGroupCategories, group.getGroupCategorySet()); } }
boolean hasOneGroupCategory(List categories) { if (fChildren == null) return false; return getGroupCategorySet().containsOneCategory(categories); }
private void collectGroupCategories(Set/*<GroupCategory>*/ result, Change change) { if (change instanceof TextEditBasedChange) { TextEditBasedChangeGroup[] groups= ((TextEditBasedChange)change).getChangeGroups(); for (int i= 0; i < groups.length; i++) { result.addAll(groups[i].getGroupCategorySet().asList()); } } else if (change instanceof CompositeChange) { Change[] children= ((CompositeChange)change).getChildren(); for (int i= 0; i < children.length; i++) { collectGroupCategories(result, children[i]); } } }
/** * Returns whether one of the given categories is contained * in this set of group categories * * @param categories the categories to test containment for * * @return <code>true</code> if one of the given categories is * contained in this set; otherwise <code>false</code> */ public boolean containsOneCategory(List<GroupCategory> categories) { for (Iterator<GroupCategory> iter= categories.iterator(); iter.hasNext();) { GroupCategory category= iter.next(); if(contains(category)) return true; } return false; }
/** * Adds a {@link TextEditBasedChangeGroup text edit change group}. * The edits managed by the given text edit change group must be part of * the change's root edit. * * @param group the text edit change group to add */ public void addChangeGroup(TextEditBasedChangeGroup group) { Assert.isTrue(group != null); fChangeGroups.add(group); if (fCombiedGroupCategories != null) { fCombiedGroupCategories= GroupCategorySet.union(fCombiedGroupCategories, group.getGroupCategorySet()); } }
boolean hasOneGroupCategory(List categories) { return fChangeGroup.getGroupCategorySet().containsOneCategory(categories); }
/** * Returns whether one of the given categories is contained * in this set of group categories * * @param categories the categories to test containment for * * @return <code>true</code> if one of the given categories is * contained in this set; otherwise <code>false</code> */ public boolean containsOneCategory(List/*<GroupCategory>*/ categories) { for (Iterator iter= categories.iterator(); iter.hasNext();) { GroupCategory category= (GroupCategory)iter.next(); if(contains(category)) return true; } return false; }
protected TextEditGroup createTextEditGroup(String label, CompilationUnitRewrite rewrite) { if (label.length() > 0) { return rewrite.createCategorizedGroupDescription(label, new GroupCategorySet(new GroupCategory(label, label, label))); } else { return rewrite.createGroupDescription(label); } }
/** * Creates a new group category set containing the union of the given two * group category sets * * @param one the first set of group categories * @param two the second set of group categories * * @return the union */ public static GroupCategorySet union(GroupCategorySet one, GroupCategorySet two) { Assert.isNotNull(one); Assert.isNotNull(two); // for performance we are using identity here. This is // valid since group categories are value objects and // therefore best used as static final fields. if (one == two) return one; if (one == NONE) return two; if (two == NONE) return one; Set<GroupCategory> combined= new HashSet<>(); combined.addAll(one.asList()); combined.addAll(two.asList()); return new GroupCategorySet(combined); }
/** * Returns <code>true</code> if the change has one of the given group * categories. Otherwise <code>false</code> is returned. * * @param groupCategories the group categories to check * * @return whether the change has one of the given group * categories * * @since 3.2 */ public boolean hasOneGroupCategory(List groupCategories) { if (fCombiedGroupCategories == null) { fCombiedGroupCategories= GroupCategorySet.NONE; for (Iterator iter= fChangeGroups.iterator(); iter.hasNext();) { TextEditBasedChangeGroup group= (TextEditBasedChangeGroup)iter.next(); fCombiedGroupCategories= GroupCategorySet.union(fCombiedGroupCategories, group.getGroupCategorySet()); } } return fCombiedGroupCategories.containsOneCategory(groupCategories); }
/** * Adds a {@link TextEditBasedChangeGroup text edit change group}. * The edits managed by the given text edit change group must be part of * the change's root edit. * * @param group the text edit change group to add */ public void addChangeGroup(TextEditBasedChangeGroup group) { Assert.isTrue(group != null); fChangeGroups.add(group); if (fCombiedGroupCategories != null) { fCombiedGroupCategories= GroupCategorySet.union(fCombiedGroupCategories, group.getGroupCategorySet()); } }
private List collectTextEditBasedChangeGroups(List categories) { List result= new ArrayList(10); PreviewNode[] children= getChildren(); for (int i= 0; i < children.length; i++) { PreviewNode child= children[i]; if (child instanceof TextEditGroupNode) { TextEditBasedChangeGroup changeGroup= ((TextEditGroupNode)child).getChangeGroup(); if (categories == null || changeGroup.getGroupCategorySet().containsOneCategory(categories)) result.add(changeGroup); } else if (child instanceof InternalLanguageElementNode) { result.addAll(((InternalLanguageElementNode)child).collectTextEditBasedChangeGroups(categories)); } } return result; }
/** * Returns whether one of the given categories is contained * in this set of group categories * * @param categories the categories to test containment for * * @return <code>true</code> if one of the given categories is * contained in this set; otherwise <code>false</code> */ public boolean containsOneCategory(List<GroupCategory> categories) { for (Iterator<GroupCategory> iter= categories.iterator(); iter.hasNext();) { GroupCategory category= iter.next(); if(contains(category)) return true; } return false; }
protected TextEditGroup createTextEditGroup(String label, CompilationUnitRewrite rewrite) { if (label.length() > 0) { return rewrite.createCategorizedGroupDescription(label, new GroupCategorySet(new GroupCategory(label, label, label))); } else { return rewrite.createGroupDescription(label); } }
/** * Creates a new group category set containing the union of the given two * group category sets * * @param one the first set of group categories * @param two the second set of group categories * * @return the union */ public static GroupCategorySet union(GroupCategorySet one, GroupCategorySet two) { Assert.isNotNull(one); Assert.isNotNull(two); // for performance we are using identity here. This is // valid since group categories are value objects and // therefore best used as static final fields. if (one == two) return one; if (one == NONE) return two; if (two == NONE) return one; Set<GroupCategory> combined= new HashSet<>(); combined.addAll(one.asList()); combined.addAll(two.asList()); return new GroupCategorySet(combined); }
/** * Returns <code>true</code> if the change has one of the given group * categories. Otherwise <code>false</code> is returned. * * @param groupCategories the group categories to check * * @return whether the change has one of the given group * categories * * @since 3.2 */ public boolean hasOneGroupCategory(List<GroupCategory> groupCategories) { if (fCombiedGroupCategories == null) { fCombiedGroupCategories= GroupCategorySet.NONE; for (Iterator<TextEditBasedChangeGroup> iter= fChangeGroups.iterator(); iter.hasNext();) { TextEditBasedChangeGroup group= iter.next(); fCombiedGroupCategories= GroupCategorySet.union(fCombiedGroupCategories, group.getGroupCategorySet()); } } return fCombiedGroupCategories.containsOneCategory(groupCategories); }
private GroupCategorySet getGroupCategorySet() { if (fGroupCategories == null) { fGroupCategories= GroupCategorySet.NONE; for (Iterator iter= fChildren.iterator(); iter.hasNext();) { PreviewNode node= (PreviewNode)iter.next(); GroupCategorySet other= null; if (node instanceof TextEditGroupNode) { other= ((TextEditGroupNode)node).getGroupCategorySet(); } else if (node instanceof InternalLanguageElementNode) { other= ((InternalLanguageElementNode)node).getGroupCategorySet(); } else { Assert.isTrue(false, "Shouldn't happen"); //$NON-NLS-1$ } fGroupCategories= GroupCategorySet.union(fGroupCategories, other); } } return fGroupCategories; }