001/* 002 Licensed to the Apache Software Foundation (ASF) under one 003 or more contributor license agreements. See the NOTICE file 004 distributed with this work for additional information 005 regarding copyright ownership. The ASF licenses this file 006 to you under the Apache License, Version 2.0 (the 007 "License"); you may not use this file except in compliance 008 with the License. You may obtain a copy of the License at 009 010 http://www.apache.org/licenses/LICENSE-2.0 011 012 Unless required by applicable law or agreed to in writing, 013 software distributed under the License is distributed on an 014 "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 015 KIND, either express or implied. See the License for the 016 specific language governing permissions and limitations 017 under the License. 018*/ 019package org.apache.wiki.ui.admin.beans; 020 021import org.apache.wiki.api.core.Engine; 022import org.apache.wiki.modules.WikiModuleInfo; 023import org.apache.wiki.plugin.DefaultPluginManager.WikiPluginInfo; 024import org.apache.wiki.plugin.PluginManager; 025import org.apache.wiki.util.XHTML; 026import org.apache.wiki.util.XhtmlUtil; 027import org.jdom2.Element; 028 029import javax.management.NotCompliantMBeanException; 030import java.util.Collection; 031 032 033public class PluginBean extends ModuleBean { 034 035 public PluginBean( final Engine engine ) throws NotCompliantMBeanException { 036 super( engine ); 037 } 038 039 /** 040 * {@inheritDoc} 041 */ 042 @Override 043 public String getTitle() { 044 return "Plugins"; 045 } 046 047 /** 048 * {@inheritDoc} 049 */ 050 @Override 051 public int getType() { 052 return CORE; 053 } 054 055 /** 056 * {@inheritDoc} 057 */ 058 @Override 059 protected Collection< WikiModuleInfo > modules() { 060 return m_engine.getManager( PluginManager.class ).modules(); 061 } 062 063 /** 064 * {@inheritDoc} 065 */ 066 @Override 067 protected Element heading() { 068 final Element trHead = XhtmlUtil.element( XHTML.tr ); 069 trHead.addContent( XhtmlUtil.element( XHTML.th ).addContent( "Name" ) ) 070 .addContent( XhtmlUtil.element( XHTML.th ).addContent( "Alias" ) ) 071 .addContent( XhtmlUtil.element( XHTML.th ).addContent( "Author" ) ) 072 .addContent( XhtmlUtil.element( XHTML.th ).addContent( "Notes" ) ); 073 return trHead; 074 } 075 076 /** 077 * {@inheritDoc} 078 */ 079 @Override 080 protected Element rowBody( final WikiModuleInfo plugin ) { 081 final Element tr = XhtmlUtil.element( XHTML.tr ); 082 tr.addContent( XhtmlUtil.element( XHTML.td ).addContent( plugin.getName() ) ) 083 .addContent( XhtmlUtil.element( XHTML.td ).addContent( ( ( WikiPluginInfo )plugin).getAlias() ) ) 084 .addContent( XhtmlUtil.element( XHTML.td ).addContent( plugin.getAuthor() ) ) 085 .addContent( XhtmlUtil.element( XHTML.td ).addContent( validModuleVersion( plugin ) ) ); 086 return tr; 087 } 088 089}