Changeset 4624


Ignore:
Timestamp:
Nov 4, 2008, 2:56:42 PM (15 years ago)
Author:
Nicklas Nordborg
Message:

Fixes #1155: Automatic plug-in registration wizard should group plug-ins by JAR file

Location:
trunk
Files:
3 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/core/net/sf/basedb/util/PluginConfigInfo.java

    r4515 r4624  
    2727import java.util.List;
    2828import java.util.ListIterator;
     29
     30import net.sf.basedb.core.DbControl;
     31import net.sf.basedb.core.Include;
     32import net.sf.basedb.core.ItemQuery;
     33import net.sf.basedb.core.PluginConfiguration;
     34import net.sf.basedb.core.query.Expressions;
     35import net.sf.basedb.core.query.Hql;
     36import net.sf.basedb.core.query.Restrictions;
    2937
    3038import org.jdom.Document;
     
    145153    return orderInXml;
    146154  }
     155 
     156  private boolean exists;
     157 
     158  /**
     159    Check the database if a configuration with the same name is already installed
     160    or not. This method should be called before {@link #exists()} is called.
     161    @param dc An open DbControl
     162    @since 2.9
     163  */
     164  public void checkInstallation(DbControl dc)
     165  {
     166    exists = false;
     167    ItemQuery<PluginConfiguration> query = PluginConfiguration.getQuery();
     168    query.restrict(
     169      Restrictions.eq(
     170        Hql.property("pluginDefinition.className"),
     171        Expressions.string(getPluginClass())
     172      )
     173    );
     174    query.restrict(
     175      Restrictions.eq(
     176        Hql.property("name"),
     177        Expressions.string(getName())
     178    ));
     179    query.include(Include.ALL);
     180    exists = query.count(dc) > 0;
     181  }
     182
     183  /**
     184    If plug-in configuration with the same name already exists or not.
     185    Before calling this method, {@link #checkInstallation(DbControl)} must be called.
     186    @return TRUE if a configuration exists
     187    @since 2.9
     188  */
     189  public boolean exists()
     190  {
     191    return exists;
     192  }
    147193}
  • trunk/src/core/net/sf/basedb/util/PluginInfo.java

    r4515 r4624  
    2525import net.sf.basedb.core.Application;
    2626import net.sf.basedb.core.BaseException;
     27import net.sf.basedb.core.DbControl;
    2728import net.sf.basedb.core.InvalidDataException;
     29import net.sf.basedb.core.ItemNotFoundException;
     30import net.sf.basedb.core.Permission;
     31import net.sf.basedb.core.PermissionDeniedException;
     32import net.sf.basedb.core.PluginDefinition;
    2833import net.sf.basedb.core.plugin.About;
    2934import net.sf.basedb.core.plugin.Plugin;
     
    250255  }
    251256 
     257  public boolean hasConfigurations()
     258  {
     259    return configs != null && configs.size() > 0;
     260  }
     261 
    252262  /**
    253263    The path inside a jar to the xml-file that holds
     
    258268  {
    259269    return configurationImportFile;
     270  }
     271 
     272 
     273  private boolean denied;
     274  private boolean isInstalled;
     275  private boolean inSameJarFile;
     276 
     277  /**
     278    Checks the database if this plug-in is installed or not. This method should
     279    be called before {@link #isDenied()}, {@link #isInstalled()} or
     280    {@link #inSameJarFile()} is called.
     281    @param dc An open DbControl
     282    @since 2.9
     283  */
     284  public void checkInstallation(DbControl dc)
     285  {
     286    denied = false;
     287    isInstalled = false;
     288    inSameJarFile = false;
     289   
     290    try
     291    {
     292      PluginDefinition plugin = PluginDefinition.getByClassName(dc, getClassName());
     293      isInstalled = true;
     294      inSameJarFile = getJarPath().equals(plugin.getJarPath());
     295      denied = plugin.hasPermission(Permission.WRITE);
     296    }
     297    catch (ItemNotFoundException ex)
     298    {}
     299    catch (PermissionDeniedException ex)
     300    {
     301      denied = true;
     302    }
     303  }
     304 
     305  /**
     306    If the currently logged in user has write permission to the (installed) plug-in
     307    or not. Before calling this method, {@link #checkInstallation(DbControl)}
     308    must be called.
     309    @return TRUE if the user has write permission, FALSE otherwise
     310    @since 2.9
     311  */
     312  public boolean isDenied()
     313  {
     314    return denied;
     315  }
     316 
     317  /**
     318    If the plug-in is already installed in BASE.  Before calling this method,
     319    {@link #checkInstallation(DbControl)} must be called.
     320    @return TRUE if the plug-in is installed
     321    @since 2.9
     322  */
     323  public boolean isInstalled()
     324  {
     325    return isInstalled;
     326  }
     327 
     328  /**
     329    If the plug-in is already installed in the same or a different JAR file.
     330    Before calling this method, {@link #checkInstallation(DbControl)}
     331    must be called.
     332    @return TRUE if the plug-in is installed in the same JAR file
     333    @since 2.9
     334  */
     335  public boolean inSameJarFile()
     336  {
     337    return inSameJarFile;
    260338  }
    261339 
  • trunk/www/admin/plugindefinitions/auto_install.jsp

    r4510 r4624  
    4444  import="net.sf.basedb.util.PluginConfigInfo"
    4545  import="net.sf.basedb.util.Values"
     46  import="net.sf.basedb.util.Tree"
    4647  import="net.sf.basedb.clients.web.util.HTML"
    4748  import="net.sf.basedb.clients.web.Base"
    48  
    4949  import="java.util.Collections"
    5050  import="java.util.List"
     
    5656<%@ taglib prefix="t" uri="/WEB-INF/tab.tld" %>
    5757<%!
     58
     59private Tree<Object> generateTree(DbControl dc, java.io.File pluginDir)
     60  throws Exception
     61{
     62  Tree<Object> tree = new Tree<Object>(null);
     63  FileFilter jarFilter = new RegexpFileFilter(".*\\.jar", null);
     64  List<java.io.File> jarFiles = FileUtil.findFiles(pluginDir, jarFilter);
     65  for (java.io.File file : jarFiles)
     66  {
     67    addToTree(dc, tree, file);
     68  }
     69  return tree;
     70}
     71
     72private void addToTree(DbControl dc, Tree<Object> tree, java.io.File file)
     73  throws Exception
     74{
     75  List<PluginInfo> plugins = PluginInfo.loadFromJar(file);
     76  if (plugins != null && plugins.size() > 0)
     77  {
     78    Tree.Entry jarEntry = tree.getRootEntry().addChild(file);
     79    for (PluginInfo pluginInfo : plugins)
     80    {
     81      pluginInfo.checkInstallation(dc);
     82      Tree.Entry pluginEntry = jarEntry.addChild(pluginInfo);
     83      List<PluginConfigInfo> configs = pluginInfo.getConfigurations();
     84      if (configs != null)
     85      {
     86        for (PluginConfigInfo configInfo : configs)
     87        {
     88          configInfo.checkInstallation(dc);
     89          pluginEntry.addChild(configInfo);
     90        }
     91      }
     92    }
     93  }
     94}
     95String generateJoustTree(Tree<Object> tree)
     96{
     97  StringBuilder sb = new StringBuilder();
     98  Tree.Entry<Object> rootEntry = tree.getRootEntry();
     99  Iterator<Tree.Entry<Object>> it = tree.entryIterator();
     100  while (it.hasNext())
     101  {
     102    Tree.Entry<Object> entry = it.next();
     103    Tree.Entry<Object> parentEntry = entry.getParent();
     104    Object node = entry.getNode();
     105    if (node == null) continue;
     106    int joustId = System.identityHashCode(entry);
     107
     108    String name = node.toString();
     109    String folderIcon = "";
     110    boolean open = false;
     111    sb.append("var node").append(joustId).append(" = ");
     112    if (parentEntry == rootEntry)
     113    {
     114      sb.append("JoustMenu.addMenuItem(-1");
     115    }
     116    else
     117    {
     118      String parentVar = "node" + System.identityHashCode(parentEntry);
     119      sb.append("JoustMenu.addChildItem(").append(parentVar);
     120    }
     121
     122    if (node instanceof java.io.File)
     123    {
     124      java.io.File file = (java.io.File)node;
     125      name = file.getName();
     126      folderIcon = "JarFile";
     127      int numUpdated = 0;
     128      int numInstalled = 0;
     129      for (Tree.Entry<Object> children : entry.getChildren())
     130      {
     131        PluginInfo child = (PluginInfo)children.getNode();
     132        if (!child.inSameJarFile())
     133        {
     134          numUpdated++;
     135        }
     136        else
     137        {
     138          numInstalled++;
     139        }
     140      }
     141      if (numUpdated > 0)
     142      {
     143        name += " (" + numUpdated + " new";
     144        if (numInstalled > 0) name += "; " + numInstalled + " existing";
     145        name += ")";
     146        open = true;
     147      }
     148      else
     149      {
     150        name += " (already installed)";
     151      }
     152    }
     153    else if (node instanceof PluginInfo)
     154    {
     155      PluginInfo info = (PluginInfo)node;
     156      name = info.getAbout().getName();
     157      if (info.inSameJarFile() || info.isDenied())
     158      {
     159        folderIcon = "PluginDisabled";
     160      }
     161      else if (info.isInstalled())
     162      {
     163        folderIcon = "PluginWarning";
     164      }
     165      else
     166      {
     167        folderIcon = "Plugin";
     168      }
     169    }
     170    else if (node instanceof PluginConfigInfo)
     171    {
     172      PluginConfigInfo info = (PluginConfigInfo)node;
     173      name = info.getName();
     174      if (info.exists())
     175      {
     176        folderIcon = "ConfigurationWarning";
     177      }
     178      else
     179      {
     180        folderIcon = "Configuration";
     181      }
     182    }
     183   
     184    sb.append(",'").append(folderIcon).append("'");
     185    sb.append(",'").append(HTML.javaScriptEncode(name)).append("'");
     186    sb.append(", null, '', '").append(joustId).append("');\n");
     187    if (open)
     188    {
     189      sb.append("JoustMenu.menuItems[node").append(joustId).append("].isOpen = true;\n");
     190    }
     191  }
     192
     193  return sb.toString();
     194}
     195
    58196private String getInfoMessage(PluginInfo info, int id)
    59197{
    60198  StringBuilder message = new StringBuilder();
    61   message.append("<div id=\"info."+id+"\" class=\"postit\" style=\"width:350px;display:none;\">");
     199  message.append("<div id=\"info."+id+"\" class=\"postit\" style=\"width:400px; display:none;\">");
    62200 
    63201  message.append("<b>").append("Jar: ").append("</b>");
     
    101239  List<PluginInfo> pluginInfos = new LinkedList<PluginInfo>();
    102240  FileFilter jarFilter = new RegexpFileFilter(".*\\.jar", null);
     241 
     242  Tree<Object> plugins = generateTree(dc, pluginDir);
     243 
    103244  List<java.io.File> jarFiles = FileUtil.findFiles(pluginDir, jarFilter);
    104245   
     
    109250  %>
    110251  <base:page type="popup" title="<%=title%>">
    111   <base:head scripts="tabcontrol.js" styles="tabcontrol.css">
     252  <base:head scripts="tabcontrol.js,newjoust.js" styles="tabcontrol.css">
    112253    <script language="JavaScript">
    113254   
     
    118259      frm.submit();
    119260    }
    120     function toggle(grpId)
    121     {
    122       var grp = document.getElementById('grp.'+grpId);
    123       var grpIcon = document.getElementById('grp.'+grpId+'.icon');
    124       var anchor = document.getElementById('a.'+grpId);
    125       var cnfId = 1;
    126       var cnf = document.getElementById('cnf.'+grpId+'.'+cnfId);
    127       if (cnf && cnf.style.display == 'none')
    128       {
    129         grpIcon.src = getRoot()+'images/joust/minustop.gif';
    130         anchor.title='Collapse to hide configurations';
    131       }
    132       else
    133       {
    134         grpIcon.src = getRoot()+'images/joust/plusonly.gif';
    135         anchor.title='Expand to see configurations for this plugin';       
    136       }
    137       while (cnf)
    138       {
    139         Main.showHide(cnf.id);
    140         cnfId++;
    141         cnf = document.getElementById('cnf.'+grpId+'.'+cnfId);
    142       }
    143     }
    144     function setConfigsOnChange(pluginId, selectList, pluginExists)
    145     {
    146       var installoption = selectList[selectList.selectedIndex].value;
    147       if (installoption == 'plugin+confs')
    148       {
    149         var cnfId = 1;
    150         var cnf = document.getElementById('setconfig.'+pluginId+'.'+cnfId);
    151         while (cnf)
    152         {
    153           for (var i = 0; i < cnf.length; i++)
    154           {
    155            
    156             if (cnf[i].value == '1')
    157             {
    158               cnf.selectedIndex = i;
    159               i = cnf.length;                         
    160             }
    161           }
    162           cnfId++;
    163           cnf = document.getElementById('setconfig.'+pluginId+'.'+cnfId);
    164         }
    165       }
    166       else if (!pluginExists && installoption == '')
    167       {
    168         var cnfId = 1;
    169         var cnf = document.getElementById('setconfig.'+pluginId+'.'+cnfId);
    170         while (cnf)
    171         {
    172           for (var i = 0; i < cnf.length; i++)
    173           {
    174            
    175             if (cnf[i].value == '0')
    176             {
    177               cnf.selectedIndex = i;
    178               i = cnf.length;                         
    179             }
    180           }
    181           cnfId++;
    182           cnf = document.getElementById('setconfig.'+pluginId+'.'+cnfId);
    183         }
    184       }
    185     }
    186     function setPluginOnChange(pluginId, selectList, pluginExists)
    187     {
    188       var configOption = selectList[selectList.selectedIndex].value;
    189       var pluginList = document.getElementById('setplugin.' + pluginId);
    190       var pluginOption = pluginList[pluginList.selectedIndex].value;
    191       if ( (configOption == '1' && !pluginExists && pluginOption == '') ||
    192         (configOption == '0' && pluginOption == 'plugin+confs') )
    193       {
    194         for (var i=0; i<pluginList.length;i++)
    195         {
    196           if (pluginList[i].value == 'plugin')
    197           {
    198             pluginList.selectedIndex = i;
    199             i = pluginList.length;
    200           }
    201         }
    202       }
    203     }
     261    function installAll(jarFile)
     262    {
     263      var frm = document.forms['autoinstall'];
     264      for (var i = 0; i < frm.elements.length; i++)
     265      {
     266        var element = frm[i];
     267        if (element.name.indexOf(jarFile) == 0 && element.type == 'select-one' && !element.disabled)
     268        {
     269          element.selectedIndex = element.options.length-1;
     270          pluginOnChange(element);
     271        }
     272      }
     273    }
     274
     275    function pluginOnChange(list)
     276    {
     277      var selected = list[list.selectedIndex].value;
     278      var configOption = selected == 'plugin+confs' ? 1 : 0;
     279      var frm = document.forms['autoinstall'];
     280      var pluginClass = list.name.substring(list.name.indexOf(':')+1);
     281      for (var i = 0; i < frm.elements.length; i++)
     282      {
     283        var element = frm[i];
     284        if (element.name.indexOf(pluginClass+":config") == 0 && element.type == 'select-one' && !element.disabled)
     285        {
     286          Forms.selectListOption(element, configOption);
     287        }
     288      }   
     289    }
     290
     291    function configOnChange(list)
     292    {
     293      var selected = list[list.selectedIndex].value;
     294      if (selected == 0) return;
     295      var frm = document.forms['autoinstall'];
     296      var pluginClass = list.name.substring(0, list.name.indexOf(':'));
     297      for (var i = 0; i < frm.elements.length; i++)
     298      {
     299        var element = frm[i];
     300        if (element.name.indexOf(pluginClass) > 0 && element.type == 'select-one' && !element.disabled)
     301        {
     302          Forms.selectListOption(element, 'plugin+confs');
     303        }
     304      }   
     305     
     306    }
     307
    204308    function toggleInformation(pluginId)
    205309    {
     
    214318      }
    215319    }
     320    function init()
     321    {
     322      var iconDir = getRoot()+'images/joust/';
     323      IconStore.init(iconDir + 'big/', 18, 22);
     324      IconStore.addIcon('JarFile', iconDir + 'jarfile.png', 18, 16);
     325      IconStore.addIcon('Plugin', iconDir + 'plugin.png', 18, 16);
     326      IconStore.addIcon('PluginDisabled', iconDir + 'plugindisabled.png', 18, 16);
     327      IconStore.addIcon('PluginWarning', iconDir + 'pluginwarning.png', 18, 16);
     328      IconStore.addIcon('Configuration', iconDir + 'item.gif', 18, 16);
     329      IconStore.addIcon('ConfigurationWarning', iconDir + 'itemwarning.gif', 18, 16);
     330
     331      JoustMenu.toggle = function(menuItemIndex)
     332      {
     333        var menuItem = this.menuItems[menuItemIndex];
     334        if (!menuItem) return;
     335        // Switch the open/closed status and hide or show the children
     336        menuItem.isOpen = !menuItem.isOpen;
     337        if (menuItem.isOpen)
     338        {
     339          this.showChildren(menuItemIndex);
     340        }
     341        else
     342        {
     343          this.hideChildren(menuItemIndex);
     344        }
     345        this.updateIconsAndText(menuItemIndex);
     346      }
     347     
     348      JoustMenu.drawMenuItems = function(firstIndex, indentString)
     349      {
     350        var menuItem = this.menuItems[firstIndex];
     351        while (menuItem)
     352        {
     353          var html = menuItem.draw(indentString);
     354          var padIcon = IconStore.getIcon(menuItem.noOutlineIcon == true ? null : menuItem.nextItemIndex == -1 ? 'iconBlank' : 'iconLine');
     355          var padHtml = padIcon == null ? '' : padIcon.getImgTag();
     356         
     357          var menuDiv = document.getElementById('tree.'+menuItem.externalId);
     358          menuDiv.innerHTML = html;
     359         
     360          if (menuItem.firstChildIndex != -1)
     361          {
     362            this.drawMenuItems(menuItem.firstChildIndex, indentString+padHtml);
     363          }
     364          if (!menuItem.isOpen)
     365          {
     366            this.hideChildren(menuItem.index);
     367          }
     368          menuItem = this.menuItems[menuItem.nextItemIndex];
     369        }
     370        return '';
     371      }
     372
     373      JoustMenu.hideChildren = function(menuItemIndex)
     374      {
     375        var menuItem = this.menuItems[menuItemIndex];
     376        if (menuItem)
     377        {
     378          var firstChildIndex = menuItem.firstChildIndex;
     379          var child = this.menuItems[firstChildIndex];
     380          while (child)
     381          {
     382            var e = document.getElementById('row.'+child.externalId);
     383            e.style.display = 'none';
     384            this.hideChildren(child.index);
     385            child = this.menuItems[child.nextItemIndex];
     386          }
     387        }
     388      }
     389     
     390      JoustMenu.showChildren = function(menuItemIndex)
     391      {
     392        var menuItem = this.menuItems[menuItemIndex];
     393        if (menuItem)
     394        {
     395          var firstChildIndex = menuItem.firstChildIndex;
     396          var child = this.menuItems[firstChildIndex];
     397          while (child)
     398          {
     399            var e = document.getElementById('row.'+child.externalId);
     400            e.style.display = Browser.isIE ? 'block' : 'table-row';
     401            if (child.isOpen)
     402            {
     403              this.showChildren(child.index);
     404            }
     405            child = this.menuItems[child.nextItemIndex];
     406          }
     407        }
     408      }
     409      <%=generateJoustTree(plugins)%>
     410      JoustMenu.draw('joust');
     411    }
    216412    </script>
    217413  </base:head>
    218   <base:body>
     414  <base:body onload="init()">
    219415    <form name="autoinstall" action="index.jsp" method="post" onsubmit="return false;">
    220416    <input type="hidden" name="ID" value="<%=ID%>">
     
    223419   
    224420    <h3 class="docked"><%=title%> <base:help tabcontrol="plugins" /></h3>
    225    
    226     <t:tabcontrol id="plugins" contentstyle="<%="height: "+(int)(scale*260)+"px;"%>"
     421    <t:tabcontrol id="plugins" contentstyle="<%="height: "+(int)(scale*340)+"px;"%>"
    227422      position="bottom">
    228423      <t:tab id="plugins" title="Available plugins" validate="validatePlugins()" helpid="plugindefinition.autoinstaller">
     
    230425          <table border="0" cellspacing="0" cellpadding="0">
    231426            <tr>
    232               <td width="45%"><b>Plugins</b></td>             
     427              <td width="45%"><b>Plugins</b></td>
    233428              <td><b>Install</b></td>
    234429              <td><b>Trusted</b></td>
     
    236431            </tr>
    237432            <%
    238             int plugin = 0;
    239             for (PluginInfo info : pluginInfos)
     433            Iterator<Tree.Entry<Object>> ite = plugins.entryIterator();
     434            while (ite.hasNext())
    240435            {
    241               String name = info.getAbout().getName();
    242               List<PluginConfigInfo> cnfInfos = info.getConfigurations();
    243               ++plugin;
    244               int cnf = 0;
    245               boolean hasConfigs = cnfInfos != null && !cnfInfos.isEmpty();
    246               boolean classExists = true;
    247               boolean jarExists = false;
    248               PluginDefinition pd = null;
    249               try
     436              Tree.Entry<Object> entry = ite.next();
     437              Object node = entry.getNode();
     438              if (node == null) continue;
     439              int joustId = System.identityHashCode(entry);
     440              String name = node.toString();
     441              PluginInfo pluginInfo = null;
     442              PluginConfigInfo configInfo = null;
     443              java.io.File jarFile = null;
     444              if (node instanceof PluginInfo)
    250445              {
    251                 pd = PluginDefinition.getByClassName(dc, info.getClassName());
    252                 if (pd.getJarPath().equals(info.getJarPath()))
     446                pluginInfo = (PluginInfo)node;
     447                name = pluginInfo.getAbout().getName();
     448              }
     449              else if (node instanceof PluginConfigInfo)
     450              {
     451                configInfo = (PluginConfigInfo)node;
     452                name = configInfo.getName();
     453              }
     454              else if (node instanceof java.io.File)
     455              {
     456                jarFile = (java.io.File)node;
     457                name = jarFile.getName();
     458              }
     459              %>
     460              <tr id="row.<%=joustId%>">
     461                <td style="white-space: nowrap;"><div id="tree.<%=joustId%>"><%=name %></div></td>
     462                <%
     463                if (jarFile != null)
    253464                {
    254                   jarExists = true;
    255                 }
    256               }
    257               catch(ItemNotFoundException ex)
    258               {
    259                 classExists = false;
    260                 jarExists = false;
    261               }             
    262               %>
    263               <tr id="plugin.<%=plugin%>">
    264                 <td style="padding-top: 6px;">                 
    265                   <%
    266                   if (hasConfigs)
     465                  boolean enableInstall = false;
     466                  for (Tree.Entry<Object> children : entry.getChildren())
    267467                  {
    268                   %>
    269                     <a href="javascript:toggle(<%=plugin%>)" id="<%="a."+plugin%>" title="Expand to see configurations for this plugin">
    270                     <base:icon id="<%="grp."+plugin+".icon"%>" image="joust/plusonly.gif" />
    271                     <a onmouseover="javascript:toggleInformation(<%=plugin%>)"
    272                       onmouseout="javascript:toggleInformation(<%=plugin%>)"
    273                     >
    274                       <base:icon image="info.gif"/>
    275                     </a>                 
    276                     <%=getInfoMessage(info, plugin)%>
    277                     &nbsp;<%=HTML.encodeTags(name)%></a>&nbsp;&nbsp;                   
    278                     <%
     468                    PluginInfo child = (PluginInfo)children.getNode();
     469                    if (!child.isInstalled()) enableInstall = true;
    279470                  }
    280                   else
     471                  if (enableInstall)
    281472                  {
    282473                    %>
    283                     <a onmouseover="javascript:toggleInformation(<%=plugin%>)"
    284                       onmouseout="javascript:toggleInformation(<%=plugin%>)"
    285                     >
    286                       <base:icon image="info.gif"/>
    287                     </a>                 
    288                     <%=getInfoMessage(info, plugin)%>
    289                     &nbsp;<%=HTML.encodeTags(name)%>&nbsp;&nbsp;
    290                     <%
     474                    <td><a href="javascript:installAll('<%=jarFile.getAbsolutePath()%>')">Install all</a></td>
     475                    <%
    291476                  }
    292                   %>                 
    293                  
    294                 </td>
    295                 <td>
    296                   <select id="setplugin.<%=plugin%>" name="<%=info.getJarPath()%>.<%=info.getClassName()%>"
    297                     style="width:90px"
    298                     onchange="setConfigsOnChange(<%=plugin%>,this, <%=classExists%>)"
    299                     <%=classExists&&jarExists ? "disabled" : "" %>
    300                    >
    301                     <option value="" title="Plugin will not be installed">no
    302                     <%
    303                     if (hasConfigs)
    304                     {
     477                }
     478                if (pluginInfo != null)
     479                {
     480                  boolean disabled = pluginInfo.isDenied() || pluginInfo.inSameJarFile();
     481                  %>
     482                  <td>
     483                    <input type="hidden" name="<%=pluginInfo.getClassName()%>:isInstalled" value="<%=pluginInfo.isInstalled()%>">
     484                    <input type="hidden" name="<%=pluginInfo.getClassName()%>:inSameJarFile" value="<%=pluginInfo.inSameJarFile()%>">
     485                    <select 
     486                      name="<%=pluginInfo.getJarPath()%>:<%=pluginInfo.getClassName()%>"
     487                      onchange="pluginOnChange(this)"
     488                      style="width:90px"
     489                      <%=disabled ? "disabled" : "" %>
     490                      >
     491                      <%
     492                      if (disabled)
     493                      {
     494                        %>
     495                        <option value="" title="Already installed">installed
     496                        <%
     497                      }
     498                      else
     499                      {
     500                        %>
     501                        <option value="" title="Plugin will not be installed">no
     502                        <%
     503                      }
     504                      if (pluginInfo.hasConfigurations())
     505                      {
     506                        %>
     507                        <option value="plugin" title="Only the plugin will be installed">plugin only
     508                        <option value="plugin+confs"
     509                          title="Plugin and all configurations will be installed">plugin + configurations</option>
     510                        <%
     511                      }
     512                      else
     513                      {
     514                        %>
     515                        <option value="plugin" title="Plugin will be installed">yes
     516                        <%
     517                      }
    305518                      %>
    306                       <option value="plugin" title="Only the plugin will be installed">plugin only
    307                       <option value="plugin+confs"
    308                         title="Plugin and all configurations will be installed">plugin + configurations</option>
     519                    </select>
     520                    <a onmouseover="javascript:toggleInformation(<%=joustId%>)"
     521                      onmouseout="javascript:toggleInformation(<%=joustId%>)"
     522                      ><base:icon image="info.gif"/></a>
     523                      <%=getInfoMessage(pluginInfo, joustId) %>
     524                  </td>
     525                  <%
     526                  if (!disabled)
     527                  {
     528                    %>
     529                    <td>
     530                      <select name="<%=pluginInfo.getClassName()%>:trusted"
     531                        <%=disabled ? "disabled" : ""%>
     532                      >
     533                        <option value="0">no
     534                        <option value="1">yes
     535                      </select>
     536                    </td>
     537                  <td>
     538                    <select name="<%=pluginInfo.getClassName()%>:immediate_execution"
     539                      <%=disabled ? "disabled" : ""%>
     540                      >
     541                      <option value="0">deny
     542                      <option value="1">allow
    309543                      <%
    310                     }
    311                     else
    312                     {
     544                      if (allowImmediateExecution == null)
     545                      {
     546                        %>
     547                        <option value="" selected>auto
     548                        <%
     549                      }
    313550                      %>
    314                       <option value="plugin" title="Plugin will be installed">yes
    315                       <%
    316                     }
    317                     %>
    318                   </select>&nbsp;&nbsp;
    319                   <input type="hidden" name="<%=info.getClassName()%>.classExists" value="<%=classExists%>">
    320                   <input type="hidden" name="<%=info.getClassName()%>.jarExists" value="<%=jarExists%>">
    321                   <base:icon image="<%=classExists&&!jarExists ? "itemexists.gif" : "" %>"
    322                     tooltip="The plugin is loaded from a different jar-file"
    323                   />
    324                   <base:icon image="<%=classExists&&jarExists ? "hasvalues.gif" : "" %>"
    325                     tooltip="Plugin with the same class name is already installed"
    326                   />
    327                 </td>
    328                 <td>
    329                   &nbsp;
    330                   <select name="<%=info.getClassName()%>.trusted"
    331                     <%=classExists&&jarExists ? "disabled" : ""%>
    332                   >
    333                     <option value="0">no
    334                     <option value="1">yes
    335                   </select>
    336                   &nbsp;&nbsp;
    337                 </td>
    338                 <td>
    339                   &nbsp;
    340                   <select name="<%=info.getClassName()%>.immediate_execution"
    341                     <%=classExists&&jarExists ? "disabled" : ""%>
    342                   >
    343                     <option value="0">deny
    344                     <option value="1">allow
    345                     <%
    346                     if (allowImmediateExecution == null)
    347                     {
    348                       %>
    349                       <option value="" selected>auto
    350                       <%
    351                     }
    352                     %>
    353                   </select>
    354                 </td>
    355               </tr>
    356               <%
    357               if (hasConfigs)
    358               {
    359                 Iterator<PluginConfigInfo> cnfi = cnfInfos.iterator();
    360                 while (cnfi.hasNext())
    361                 {
    362                   PluginConfigInfo cnfInfo = cnfi.next();
    363                   boolean isDuplicate = false;
    364                   if (classExists)
    365                   {
    366                     ItemQuery<PluginConfiguration> cnfQuery = pd.getPluginConfigurations();
    367                     cnfQuery.include(Include.ALL);
    368                     cnfQuery.restrict(Restrictions.eq(Hql.property("name"), Expressions.string(cnfInfo.getName())));
    369                     Iterator<PluginConfiguration> it = cnfQuery.iterate(dc);
    370                     isDuplicate = it != null && it.hasNext();
    371                   }
    372                   ++cnf;
    373                   boolean hasNext = cnfi.hasNext();
    374                   %>
    375                   <tr id="cnf.<%=plugin%>.<%=cnf%>" style="display: none;">
    376                     <td>
    377                       <base:icon
    378                         image="<%=hasNext ? "joust/big/join.gif" : "joust/big/joinbottom.gif"%>"
    379                       />                     
    380                       <%=HTML.encodeTags(cnfInfo.getName())%>&nbsp;
    381                     </td>
    382                     <td>
    383                       <select id="setconfig.<%=plugin%>.<%=cnf%>" name="<%=info.getClassName()%>.<%=cnfInfo.getName()%>"
    384                         onChange="setPluginOnChange(<%=plugin%>, this, <%=classExists%>)">
    385                         <option value="0" title="Configuration will not be imported">no</option>
    386                         <option value="1" title="Configuration will be imported">yes</option>
    387                       </select>
    388                       <base:icon image="<%=isDuplicate ? "warning.gif" : ""%>" tooltip="Plugin already has a configuration with this name"/>
    389                     </td>
    390                   </tr>
     551                    </select>
     552                  </td>
    391553                  <%
    392554                }
    393555              }
     556              else if (configInfo != null)
     557              {
     558                %>
     559                <td>
     560                  <select
     561                    onchange="configOnChange(this)"
     562                    name="<%=configInfo.getPluginClass()%>:config:<%=configInfo.getName()%>">
     563                    <option value="0" title="Configuration will not be imported">no</option>
     564                    <option value="1" title="Configuration will be imported">yes</option>
     565                  </select>
     566                </td>
     567                <%
     568              }
     569              %>
     570              </tr>
     571              <%
    394572            }
    395573            %>
     
    397575        </div>
    398576        <div align="right">
    399           &nbsp;<i><base:icon image="warning.gif" /> = duplicate configuration</i><br>
    400           &nbsp;<i><base:icon image="hasvalues.gif" /> = plugin already installed</i><br>
    401           &nbsp;<i><base:icon image="itemexists.gif" /> = exists in a different jar-file,<br>
    402             installing will change the jar path.</i><br>
     577          &nbsp;<i><base:icon image="joust/plugindisabled.png" /> = plug-in is already installed</i><br>
     578          &nbsp;<i><base:icon image="joust/pluginwarning.png" /> = exists in a different JAR file</i><br>
     579          &nbsp;<i><base:icon image="joust/itemwarning.gif" /> = configuration already exists</i><br>
    403580        </div>
    404581      </t:tab>
    405    
    406582    </t:tabcontrol>
    407583   
  • trunk/www/admin/plugindefinitions/index.jsp

    r4587 r4624  
    183183    for (PluginInfo info : pluginInfos)
    184184    {
    185       String selectedOption = request.getParameter(info.getJarPath() + "." + info.getClassName());
     185      String selectedOption = request.getParameter(info.getJarPath() + ":" + info.getClassName());
    186186      if (selectedOption == null) selectedOption = "";     
    187       boolean classExists = Values.getBoolean(request.getParameter(info.getClassName()+".classExists"));
    188       boolean jarExists = Values.getBoolean(request.getParameter(info.getClassName()+".jarExists"));
    189       int usePermissions = Values.getInt(request.getParameter("use_permissions"));
     187      boolean isInstalled = Values.getBoolean(request.getParameter(info.getClassName()+":isInstalled"));
     188      boolean inSameJarFile = Values.getBoolean(request.getParameter(info.getClassName()+":inSameJarFile"));
    190189      if (selectedOption.equals("plugin") || selectedOption.equals("plugin+confs"))
    191190      {
    192191        //The plugin doesn't exists
    193         if (!classExists)
     192        if (!isInstalled)
    194193        {
    195194          PluginDefinition pd = null;
    196195          try
    197196          {
    198             pd = PluginDefinition.getNew(dc, info.getClassName(), info.getJarPath(), usePermissions==2);
     197            pd = PluginDefinition.getNew(dc, info.getClassName(), info.getJarPath(), true);
    199198          }
    200199          catch(BaseException bex)
     
    206205          {
    207206            dc.saveItem(pd);
    208             pd.setTrusted(Values.getBoolean(request.getParameter("trusted")));
    209             String aie = Values.getStringOrNull(request.getParameter("immediate_execution"));
     207            pd.setTrusted(Values.getBoolean(request.getParameter(info.getClassName()+":trusted")));
     208            String aie = Values.getStringOrNull(request.getParameter(info.getClassName()+":immediate_execution"));
    210209            pd.setAllowImmediateExecution(aie == null ?
    211210              pd.getMainType() == Plugin.MainType.EXPORT : Values.getBoolean(aie));           
     
    213212        }
    214213        //The plugin exists but in a different jar, this will change the plugin's jarpath
    215         else if (classExists && !jarExists)
     214        else if (isInstalled && !inSameJarFile)
    216215        {
    217216          try
    218217          {
    219218            PluginDefinition pd = PluginDefinition.getByClassName(dc, info.getClassName());
    220             pd.loadPluginInformation(info.getJarPath(), info.getClassName(), usePermissions == 2);
     219            pd.loadPluginInformation(info.getJarPath(), info.getClassName(), true);
    221220          }
    222221          catch(BaseException bex)
     
    239238        for (PluginConfigInfo cnfInfo : configInfos)
    240239        {
    241           Boolean toImport = Values.getBoolean(request.getParameter(info.getClassName() + "." + cnfInfo.getName()));
     240          Boolean toImport = Values.getBoolean(request.getParameter(info.getClassName() + ":config:" + cnfInfo.getName()));
    242241          configurations.put(cnfInfo.getOrderInXml(), toImport);
    243242        }
Note: See TracChangeset for help on using the changeset viewer.