Displaying a Custom Icon for a Content Type

Version 1

    You can have the application display a different icon for included content types. To do that, you override SkinUtils.getJiveObjectIcon. Include your code where it will execute on application startup, or where it will execute when your plugin is initialized.

     

    Note: If you're building a custom content type, be sure to check out Content Type Framework and TypeUIProvider.

     

    To replace an included icon with another, your code should add an icon generator that is associated with the existing content type -- here, a blog post:

    // Override an existing icon
    IconGenerator blogpostIG = new IconGenerator() {
       public String getIcon(JiveObject object, boolean returnAsCssClass, int type) {
          return "my-blog-post";
       }
    };
    SkinUtils.addIconGenerator(JiveConstants.BLOGPOST, blogpostIG);
    

    When you want to associate an icon with a particular content type, but only when that content type features a particular property and value, check for the property on the JiveObject instance your code receives:

    // Only handle documents with a certain property, otherwise use the default.
    IconGenerator documentIG = new IconGenerator() {
       public String getIcon(JiveObject object, boolean returnAsCssClass, int type) {
          Document doc = (Document)object;
          if (doc.getProperties().get("my.prop) != null) {
             return "my-property";
          }
          else {
             return null;
          }
       }
    };
    SkinUtils.addIconGenerator(JiveConstants.DOCUMENT, documentIG);