コード例 #1
0
/** $Id: UCMEditorPaletteFactory.java,v 1.29 2006/04/01 03:44:03 franco Exp $ $Author: franco $ */
コード例 #2
0
  /**
   * Creates {@code ToolEntry} for the Struts components.
   *
   * @param paletteRoot the {@code PaletteRoot} entry
   * @return the {@code PaletteContainer} instance
   */
  private static void createStrutsGroup(PaletteRoot paletteRoot) {
    // PaletteDrawer drawer = new PaletteDrawer("Administrative Elements");

    IConfigurationElement[] cElements = S2Plugin.getDefault().getPaletteCategories();
    for (IConfigurationElement cElement : cElements) {
      boolean collapsable = Boolean.getBoolean(cElement.getAttribute("collapsible"));
      PaletteContainer container = null;
      if (collapsable) {
        container = createCollapsableCategory(cElement);
      } else {
        container = createCategory(cElement);
      }
      paletteRoot.add(container);

      String categoryName = cElement.getAttribute("name");
      PaletteDrawer drawer = new PaletteDrawer(categoryName);

      IConfigurationElement[] cEntries = cElement.getChildren();
      for (IConfigurationElement cEntry : cEntries) {
        try {
          String eName = cEntry.getAttribute("name");
          Object eClass = cEntry.createExecutableExtension("class");
          String iSmall = cEntry.getAttribute("smallimage");
          String iLarge = cEntry.getAttribute("largeimage");
          String description = cElement.getAttribute("description");
          PaletteEntry entry =
              new CombinedTemplateCreationEntry(
                  eName,
                  description,
                  new SimpleFactory(eClass.getClass()),
                  S2EditorUI.getImageDescriptor(iSmall),
                  S2EditorUI.getImageDescriptor(iLarge));
          drawer.add(entry);
        } catch (CoreException e) {
          e.printStackTrace();
        }
      }
      paletteRoot.add(drawer);
    }

    //		/* Tool Entry for Bean creation */
    //		PaletteEntry entry = new CombinedTemplateCreationEntry("Bean",
    //				"Create Struts 2 Bean", new SimpleFactory(S2Bean.class),
    //				S2EditorUI.getImageDescriptor("icons/11880.bmp.gif"),
    //				S2EditorUI.getImageDescriptor("icons/11880.bmp.gif"));
    //		drawer.add(entry);
    //
    //		/* Tool Entry for Constant creation */
    //		entry = new CombinedTemplateCreationEntry("Constant",
    //				"Create Struts 2 Constant", new SimpleFactory(S2Constant.class),
    //				S2EditorUI.getImageDescriptor("icons/17405.thread_view.png"),
    //				S2EditorUI.getImageDescriptor("icons/17405.thread_view.png"));
    //		drawer.add(entry);
    //
    //		/* Tool Entry for package creation */
    //		entry = new CombinedTemplateCreationEntry("Package",
    //				"Create Struts 2 Package", S2Package.class, new SimpleFactory(S2Package.class),
    //				S2EditorUI.getImageDescriptor("icons/10464.package_obj.gif"),
    //				S2EditorUI.getImageDescriptor("icons/10464.package_obj.gif"));
    //		drawer.add(entry);
    //
    //		/* Tool Entry for Include creation */
    //		entry = new CombinedTemplateCreationEntry("Include",
    //				"Create Struts 2 Include", new SimpleFactory(S2Include.class),
    //				S2EditorUI.getImageDescriptor("icons/showchild_mode.gif"),
    //				S2EditorUI.getImageDescriptor("icons/showchild_mode.gif"));
    //		drawer.add(entry);
    //		paletteRoot.add(drawer);
    //
    //		drawer = new PaletteDrawer("Request Handling");
    //
    //		/* Tool Entry for Action Creation */
    //		entry = new CombinedTemplateCreationEntry("Action",
    //				"Create Struts 2 Action", new SimpleFactory(S2Action.class),
    //				S2EditorUI.getImageDescriptor("icons/innerclass_public_obj.gif"),
    //				S2EditorUI.getImageDescriptor("icons/innerclass_public_obj.gif"));
    //		drawer.add(entry);
    //
    //		/* Tool Entry for default-Action Creation */
    //		entry = new CombinedTemplateCreationEntry("Default Action Reference",
    //				"Create Struts 2 Default Action Reference", new SimpleFactory(Object.class),
    //				S2EditorUI.getImageDescriptor("icons/innerclass_public_obj.gif"),
    //				S2EditorUI.getImageDescriptor("icons/innerclass_public_obj.gif"));
    //		drawer.add(entry);
    //
    //		/* Tool Entry for Interceptors creation */
    //		entry = new CombinedTemplateCreationEntry("Interceptors",
    //				"Create Struts 2 Interceptor", new SimpleFactory(S2Interceptors.class),
    //				S2EditorUI.getImageDescriptor("icons/arraypartition_obj.gif"),
    //				S2EditorUI.getImageDescriptor("icons/arraypartition_obj.gif"));
    //		drawer.add(entry);
    //
    //		/* Tool Entry for Interceptor creation */
    //		entry = new CombinedTemplateCreationEntry("Interceptor",
    //				"Create Struts 2 Interceptor", new SimpleFactory(S2Interceptor.class),
    //				S2EditorUI.getImageDescriptor("icons/remove_correction.gif"),
    //				S2EditorUI.getImageDescriptor("icons/remove_correction.gif"));
    //		drawer.add(entry);
    //
    //		/* Tool Entry for Interceptor-stack creation */
    //		entry = new CombinedTemplateCreationEntry("Interceptor-Stack",
    //				"Create Struts 2 Interceptor-stack", new SimpleFactory(S2InterceptorStack.class),
    //				S2EditorUI.getImageDescriptor("icons/thin_max_view.gif"),
    //				S2EditorUI.getImageDescriptor("icons/thin_max_view.gif"));
    //		drawer.add(entry);
    //
    //		/* Tool Entry for Interceptor-ref creation */
    //		entry = new CombinedTemplateCreationEntry("Interceptor-ref",
    //				"Create Struts 2 Interceptor-ref", new SimpleFactory(S2InterceptorRef.class),
    //				S2EditorUI.getImageDescriptor("icons/change.gif"),
    //				S2EditorUI.getImageDescriptor("icons/change.gif"));
    //		drawer.add(entry);
    //
    //		paletteRoot.add(drawer);
    //
    //		drawer = new PaletteDrawer("Error Handling");
    //		/* Tool Entry for Exception creation */
    //		entry = new CombinedTemplateCreationEntry("Exception",
    //				"Create Struts 2 Exception mappings", new SimpleFactory(Object.class),
    //				S2EditorUI.getImageDescriptor("icons/10377.enum_obj.gif"),
    //				S2EditorUI.getImageDescriptor("icons/10377.enum_obj.gif"));
    //		drawer.add(entry);
    //		paletteRoot.add(drawer);
    //
    //		drawer = new PaletteDrawer("Resources");
    //		/* Tool Entry for JSP/HTML Page creation */
    //		entry = new CombinedTemplateCreationEntry("JSP/HTML",
    //				"Create JSP/HTML pages", new SimpleFactory(S2JSPHTML.class),
    //				S2EditorUI.getImageDescriptor("icons/14474.PD_Plugin.gif"),
    //				S2EditorUI.getImageDescriptor("icons/14474.PD_Plugin.gif"));
    //		drawer.add(entry);
    //		paletteRoot.add(drawer);
    //
    //		drawer = new PaletteDrawer("Comments");
    //
    //		/* Tool Entry for Comment creation */
    //		entry = new CombinedTemplateCreationEntry("Comment",
    //				"Create a new Comment", new SimpleFactory(S2Comment.class),
    //				S2EditorUI.getImageDescriptor("icons/10377.enum_obj.gif"),
    //				S2EditorUI.getImageDescriptor("icons/10377.enum_obj.gif"));
    //		drawer.add(entry);
    //		paletteRoot.add(drawer);
  }