Package org.eclipse.core.commands

Examples of org.eclipse.core.commands.Category


       */
      final String tooltip = readOptional(element, ATT_TOOLTIP);

      // Define the command.
      command = commandService.getCommand(commandId);
      final Category category = commandService.getCategory(null);
      final String name = LegacyActionTools.removeAcceleratorText(Action
          .removeMnemonics(label));
      command.define(name, tooltip, category, null);

      // TODO Decide the command state.
View Full Code Here


      Map categoriesByName = new HashMap();

      for (Iterator iterator = commandService.getDefinedCategoryIds()
          .iterator(); iterator.hasNext();) {
        Category category = commandService
            .getCategory((String) iterator.next());

        try {
          if (commandIdsByCategoryId.containsKey(category.getId())) {
            String name = category.getName();
            Collection categories = (Collection) categoriesByName
                .get(name);

            if (categories == null) {
              categories = new HashSet();
              categoriesByName.put(name, categories);
            }

            categories.add(category);
          }
        } catch (NotDefinedException eNotDefined) {
          // Do nothing
        }
      }

      Map schemesByName = new HashMap();

      final Scheme[] definedSchemes = bindingService.getDefinedSchemes();
      for (int i = 0; i < definedSchemes.length; i++) {
        final Scheme scheme = definedSchemes[i];
        try {
          String name = scheme.getName();
          Collection schemes = (Collection) schemesByName.get(name);

          if (schemes == null) {
            schemes = new HashSet();
            schemesByName.put(name, schemes);
          }

          schemes.add(scheme);
        } catch (final NotDefinedException e) {
          // Do nothing.
        }
      }

      contextIdsByUniqueName = new HashMap();
      contextUniqueNamesById = new HashMap();

      for (Iterator iterator = contextsByName.entrySet().iterator(); iterator
          .hasNext();) {
        Map.Entry entry = (Map.Entry) iterator.next();
        String name = (String) entry.getKey();
        Set contexts = (Set) entry.getValue();
        Iterator iterator2 = contexts.iterator();

        if (contexts.size() == 1) {
          Context context = (Context) iterator2.next();
          contextIdsByUniqueName.put(name, context.getId());
          contextUniqueNamesById.put(context.getId(), name);
        } else {
          while (iterator2.hasNext()) {
            Context context = (Context) iterator2.next();
            String uniqueName = MessageFormat.format(
                Util.translateString(RESOURCE_BUNDLE,
                    "uniqueName"), new Object[] { name, //$NON-NLS-1$
                    context.getId() });
            contextIdsByUniqueName.put(uniqueName, context.getId());
            contextUniqueNamesById.put(context.getId(), uniqueName);
          }
        }
      }

      categoryIdsByUniqueName = new HashMap();
      categoryUniqueNamesById = new HashMap();

      for (Iterator iterator = categoriesByName.entrySet().iterator(); iterator
          .hasNext();) {
        Map.Entry entry = (Map.Entry) iterator.next();
        String name = (String) entry.getKey();
        Set categories = (Set) entry.getValue();
        Iterator iterator2 = categories.iterator();

        if (categories.size() == 1) {
          Category category = (Category) iterator2.next();
          categoryIdsByUniqueName.put(name, category.getId());
          categoryUniqueNamesById.put(category.getId(), name);
        } else {
          while (iterator2.hasNext()) {
            Category category = (Category) iterator2.next();
            String uniqueName = MessageFormat.format(
                Util.translateString(RESOURCE_BUNDLE,
                    "uniqueName"), new Object[] { name, //$NON-NLS-1$
                    category.getId() });
            categoryIdsByUniqueName.put(uniqueName, category
                .getId());
            categoryUniqueNamesById.put(category.getId(),
                uniqueName);
          }
        }
      }
View Full Code Here

      // Read out the description.
      final String description = readOptional(configurationElement,
          ATT_DESCRIPTION);

      final Category category = commandService.getCategory(categoryId);
      category.define(name, description);
    }

    // If there were any warnings, then log them now.
    logWarnings(
        warningsToLog,
View Full Code Here

      // Read out the help context identifier.
      final String helpContextId = readOptional(configurationElement,
          ATT_HELP_CONTEXT_ID);

      final Command command = commandService.getCommand(commandId);
      final Category category = commandService.getCategory(categoryId);
      if (!category.isDefined()) {
        addWarning(
            warningsToLog,
            "Commands should really have a category", //$NON-NLS-1$
            configurationElement, commandId,
            "categoryId", categoryId); //$NON-NLS-1$
View Full Code Here

            try {
                // Do not create operation category anymore; only worked for one window
                // categories.put(ID, new OperationCategory(element)); //$NON-NLS-1$
                   
                // Create a Command Category
                Category category = commands.getCategory(ID);
                if( !category.isDefined()){
                    category.define(NAME, DESCRIPTION);                   
                }
                // TODO: Create an ActionSet
               
                // TODO: Create a Definition to Check the ActionSet
               
View Full Code Here

      ICommandService service = (ICommandService) o;
      commands.addAll(Arrays.asList(service.getDefinedCommands()));
      return service.getDefinedCategories();
     
    } else if (o instanceof Category) {
      Category cat = (Category) o;
      Set<Command> children = new HashSet<Command>();
      for (Command cmd : commands) {
        try {
          if (cmd.getCategory().equals(cat)) {
            children.add(cmd);
View Full Code Here

        return cmd1.getId().compareTo(cmd2.getId());
      }
     
    } else if ((e1 instanceof Category) && (e2 instanceof Category)) {
     
      Category cat1 = (Category) e1;
      Category cat2 = (Category) e2;
     
      if (cat1.getId().equals(UNCATEGORIZED_ID)) {
        return 1;
      }
     
      if (cat2.getId().equals(UNCATEGORIZED_ID)) {
        return -1;
      }
     
      try {
        return cat1.getName().compareTo(cat2.getName());
      } catch (NotDefinedException e) {
        return cat1.getId().compareTo(cat2.getId());
      }
    }
    return super.compare(viewer, e1, e2);
  }
View Full Code Here

TOP

Related Classes of org.eclipse.core.commands.Category

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.