Java 类org.eclipse.core.commands.Category 实例源码

项目:e4macs    文件:CommandCategoryEditor.java   
private boolean checkDefaults(ArrayList<Category> compareCats) {

        boolean result = true;
        Category[] newArray = sortCats(compareCats);
        if (defaultCats == null) {
            defaultCats = sortCats(convertToCats(getPreferenceStore().getDefaultString(getPreferenceName()),
                    getAllCategories()));
        }
        if (newArray.length == defaultCats.length) {
            for (int i = 0; i < newArray.length; i++) {
                if (newArray[i] != defaultCats[i]) {
                    result = false;
                    break;
                }
            }
        } else {
            result = false;
        }
        return result;
    }
项目:e4macs    文件:CommandCategoryEditor.java   
/**
 * @param catIdList is a 'list' of category ids
 *  
 * @see org.eclipse.jface.preference.ListEditor#parseString(java.lang.String)
 */
protected String[] parseString(String catIdList) {

    Category[] allCats = this.getAllCategories();
    active = convertToCats(catIdList,allCats);
    inactive = new ArrayList<Category>();
    for (int i=0; i< allCats.length; i++){
        if (!active.contains(allCats[i])){
            inactive.add(allCats[i]);
        }
    }
    String[] result = new String[active.size()];
    for (int i=0; i< result.length; i++){
        result[i] = getLabel(active.get(i));
    }
    return result;
}
项目:e4macs    文件:CommandSupport.java   
/**
 * Get the current set of defined categories corresponding to the included category names
 * 
 * @param ics
 * @return the filtered set of categories
 * 
 * @throws NotDefinedException
 */
private HashSet<Category> getCategories(ICommandService ics) throws NotDefinedException 
{
    if (catHash.isEmpty() && catIncludes != null) {
        Category[] cats = ics.getDefinedCategories();
        for (int i = 0; i < cats.length; i++) {
            for (int j = 0; j < catIncludes.length; j++) {
                if (catIncludes[j].equals(cats[i].getId())) {
                    catHash.add(cats[i]);
                    break;
                }
            }
        }
    }
    return catHash;
}
项目:e4macs    文件:CommandCategoryEditor.java   
private void checkCats(){
    List myList = this.getListUnchecked();
    if (myList != null) {
    String[] items = myList.getItems();
    if (items.length != active.size()) {
        // a remove happened 
        ArrayList<Category> moveCats = new ArrayList<Category>();
        String[] catLabels = new String[active.size()];
        for (int i = 0; i < active.size(); i++) {
            catLabels[i] = getLabel(active.get(i));
        }
        for (int i = 0; i < catLabels.length; i++) {
            boolean ok = false;
            for (int j = 0; j < items.length; j++) {
                if (items[j].equals(catLabels[i])) {
                    ok = true;
                    break;
                }
            }
            if (!ok) {
                moveCats.add(active.get(i));
            }
        }
        if (!moveCats.isEmpty()) {
            active.removeAll(moveCats);
            inactive.addAll(moveCats);
        }
    }
}
  }
项目:e4macs    文件:CommandCategoryEditor.java   
/**
   * Cook up a label that is, hopefully, distinct and useful
   * @param cat
   * @return
   */
  String getLabel(Category cat) {
    String result = null;
    try {
        String desc = cat.getDescription();
    result= cat.getName() + DISPLAY_SEPARATOR + (desc != null ? desc : ""); //$NON-NLS-1$
} catch (NotDefinedException e) {}
return result;
  }
项目:e4macs    文件:CommandCategoryEditor.java   
/**
 * @see org.eclipse.jface.preference.ListEditor#createList(java.lang.String[])
 */
protected String createList(String[] items) {

    Category[] orderedCats = sortCats(active);
    StringBuilder result = new StringBuilder("");//$NON-NLS-1$

    for (int i = 0; i < orderedCats.length; i++) {
        result.append(orderedCats[i].getId());
        result.append(SEPARATOR);
    }
    return result.toString();
}
项目:e4macs    文件:CommandCategoryEditor.java   
private ArrayList<Category> convertToCats(String idList, Category[] allCats){
    ArrayList<Category> result;
    StringTokenizer st = new StringTokenizer(idList, SEPARATOR);
    result = new ArrayList<Category>();
    while (st.hasMoreElements()) {
        String next = ((String) st.nextElement()).trim(); 
        for (int i=0; i< allCats.length; i++){
            if (allCats[i].getId().equals(next)){
                result.add(allCats[i]);                 
                break;
            }
        }
    }
    return result;
}
项目:e4macs    文件:CommandCategoryEditor.java   
Category[] sortCats(java.util.List<Category> sCats) {
    Category[] sCatsArray = sCats.toArray(new Category[0]);
    Arrays.sort(sCatsArray, new Comparator<Category>() {
        public int compare(Category o1, Category o2) {
            int result = 0;
            try {
                result = o1.getName().compareTo(o2.getName());
            } catch (NotDefinedException e) {}
            return result;
        }
    });
    return sCatsArray;
}
项目:e4macs    文件:CommandCategoryEditor.java   
/**
 * Initialize our categories with cats
 * 
 * @param cats
 */
void setCategories(ArrayList<Category> cats){

    Category[] orderedCats = sortCats(cats);
    categoryArray = new ArrayList<Category>();
    for (int i=0; i < orderedCats.length; i++){
        categoryArray.add((Category)orderedCats[i]);
    }
}
项目:e4macs    文件:CommandCategoryEditor.java   
/**
 * Get all the selected categories from the add dialog
 * @return
 */
    ArrayList<Category> getNewCategories() {
    int[] selection = catList.getSelectionIndices();
    ArrayList<Category> cats = new ArrayList<Category>();
    for (int i = 0; i < selection.length; i++) {
        cats.add(categoryArray.get(selection[i]));  
    }
    return cats;
}
项目:e4macs    文件:CommandSupport.java   
public TreeMap<String, Command> getCommandList(IEditorPart editor, boolean all) {
        ICommandService ics = (ICommandService) editor.getSite().getService(ICommandService.class);
        Command[] commands = ics.getDefinedCommands();
        commandTree = new TreeMap<String, Command>();
        try {
            HashSet<Category>catHash = (all ? null : getCategories(ics));
            boolean isOk = all;
            for (int i = 0; i < commands.length; i++) {
                if (!isOk && catHash.contains(commands[i].getCategory())) {
                    IParameter[] params = commands[i].getParameters(); 
                    isOk = commands[i].isHandled();
                    // if the command has parameters, they must all be optional
                    if (isOk && params != null) {
                        for (int j = 0; j < params.length; j++) {
                            if (!(isOk = params[j].isOptional())) {
                                break;
                            }
                        }
                    }
                }
                if (isOk) {
                    commandTree.put(fixName(commands[i].getName()), commands[i]);
                }
                isOk = all;
            }
        } catch (NotDefinedException e) {}
//      getContexts(editor);
        return commandTree;
    }
项目:translationstudio8    文件:CategoryPatternFilter.java   
public CategoryPatternFilter(boolean filterCategories, Category c) {
    uncategorized = c;
    filterCategories(filterCategories);
}
项目:tmxeditor8    文件:CategoryPatternFilter.java   
public CategoryPatternFilter(boolean filterCategories, Category c) {
    uncategorized = c;
    filterCategories(filterCategories);
}
项目:tmxeditor8    文件:CategoryPatternFilter.java   
public CategoryPatternFilter(boolean filterCategories, Category c) {
    uncategorized = c;
    filterCategories(filterCategories);
}
项目:e4macs    文件:CommandSupport.java   
/**
 * Used by preference page to update changes to include categories
 * @param newCats
 */
public static void setCategories(String[] newCats){
    catIncludes = newCats;
    catHash = new HashSet<Category>();      
}
项目:gef-gwt    文件:ICommandService.java   
/**
 * Retrieves the category with the given identifier. If no such category
 * exists, then an undefined category with the given id is created.
 * 
 * @param categoryId
 *            The identifier to find. If the category is <code>null</code>,
 *            then a category suitable for uncategorized items is defined
 *            and returned.
 * @return A category with the given identifier, either defined or
 *         undefined.
 */
public Category getCategory(String categoryId);
项目:gef-gwt    文件:ICommandService.java   
/**
 * Returns the collection of all of the defined categories in the workbench.
 * 
 * @return The collection of categories (<code>Category</code>) that are
 *         defined; never <code>null</code>, but may be empty.
 * @since 3.2
 */
public Category[] getDefinedCategories();
项目:e4macs    文件:CommandCategoryEditor.java   
/**
 * Receive the results of the add dialog
 * 
 * @param cats
 */
void setOkCategories(ArrayList<Category> cats) {
    newOnes = cats;
}
项目:e4macs    文件:CommandCategoryEditor.java   
/**
 * Get all the currently defined categories
 * @return
 */
private Category[] getAllCategories() {
    return ((ICommandService) PlatformUI.getWorkbench().getService(ICommandService.class)).getDefinedCategories();
}
项目:relations    文件:CategoryPatternFilter.java   
/**
 * CategoryPatternFilter constructor.
 *
 * @param filterCategories
 *            boolean
 * @param category
 *            {@link Category}
 */
public CategoryPatternFilter(final boolean filterCategories,
        final Category category) {
    uncategorized = category;
    filterCategories(filterCategories);
}