Changeset 4624
- Timestamp:
- Nov 4, 2008, 2:56:42 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 3 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/core/net/sf/basedb/util/PluginConfigInfo.java
r4515 r4624 27 27 import java.util.List; 28 28 import java.util.ListIterator; 29 30 import net.sf.basedb.core.DbControl; 31 import net.sf.basedb.core.Include; 32 import net.sf.basedb.core.ItemQuery; 33 import net.sf.basedb.core.PluginConfiguration; 34 import net.sf.basedb.core.query.Expressions; 35 import net.sf.basedb.core.query.Hql; 36 import net.sf.basedb.core.query.Restrictions; 29 37 30 38 import org.jdom.Document; … … 145 153 return orderInXml; 146 154 } 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 } 147 193 } -
trunk/src/core/net/sf/basedb/util/PluginInfo.java
r4515 r4624 25 25 import net.sf.basedb.core.Application; 26 26 import net.sf.basedb.core.BaseException; 27 import net.sf.basedb.core.DbControl; 27 28 import net.sf.basedb.core.InvalidDataException; 29 import net.sf.basedb.core.ItemNotFoundException; 30 import net.sf.basedb.core.Permission; 31 import net.sf.basedb.core.PermissionDeniedException; 32 import net.sf.basedb.core.PluginDefinition; 28 33 import net.sf.basedb.core.plugin.About; 29 34 import net.sf.basedb.core.plugin.Plugin; … … 250 255 } 251 256 257 public boolean hasConfigurations() 258 { 259 return configs != null && configs.size() > 0; 260 } 261 252 262 /** 253 263 The path inside a jar to the xml-file that holds … … 258 268 { 259 269 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; 260 338 } 261 339 -
trunk/www/admin/plugindefinitions/auto_install.jsp
r4510 r4624 44 44 import="net.sf.basedb.util.PluginConfigInfo" 45 45 import="net.sf.basedb.util.Values" 46 import="net.sf.basedb.util.Tree" 46 47 import="net.sf.basedb.clients.web.util.HTML" 47 48 import="net.sf.basedb.clients.web.Base" 48 49 49 import="java.util.Collections" 50 50 import="java.util.List" … … 56 56 <%@ taglib prefix="t" uri="/WEB-INF/tab.tld" %> 57 57 <%! 58 59 private 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 72 private 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 } 95 String 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 58 196 private String getInfoMessage(PluginInfo info, int id) 59 197 { 60 198 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;\">"); 62 200 63 201 message.append("<b>").append("Jar: ").append("</b>"); … … 101 239 List<PluginInfo> pluginInfos = new LinkedList<PluginInfo>(); 102 240 FileFilter jarFilter = new RegexpFileFilter(".*\\.jar", null); 241 242 Tree<Object> plugins = generateTree(dc, pluginDir); 243 103 244 List<java.io.File> jarFiles = FileUtil.findFiles(pluginDir, jarFilter); 104 245 … … 109 250 %> 110 251 <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"> 112 253 <script language="JavaScript"> 113 254 … … 118 259 frm.submit(); 119 260 } 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 204 308 function toggleInformation(pluginId) 205 309 { … … 214 318 } 215 319 } 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 } 216 412 </script> 217 413 </base:head> 218 <base:body >414 <base:body onload="init()"> 219 415 <form name="autoinstall" action="index.jsp" method="post" onsubmit="return false;"> 220 416 <input type="hidden" name="ID" value="<%=ID%>"> … … 223 419 224 420 <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;"%>" 227 422 position="bottom"> 228 423 <t:tab id="plugins" title="Available plugins" validate="validatePlugins()" helpid="plugindefinition.autoinstaller"> … … 230 425 <table border="0" cellspacing="0" cellpadding="0"> 231 426 <tr> 232 <td width="45%"><b>Plugins</b></td> 427 <td width="45%"><b>Plugins</b></td> 233 428 <td><b>Install</b></td> 234 429 <td><b>Trusted</b></td> … … 236 431 </tr> 237 432 <% 238 int plugin = 0;239 for (PluginInfo info : pluginInfos)433 Iterator<Tree.Entry<Object>> ite = plugins.entryIterator(); 434 while (ite.hasNext()) 240 435 { 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 try436 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) 250 445 { 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) 253 464 { 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()) 267 467 { 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 <%=HTML.encodeTags(name)%></a> 278 <% 468 PluginInfo child = (PluginInfo)children.getNode(); 469 if (!child.isInstalled()) enableInstall = true; 279 470 } 280 else471 if (enableInstall) 281 472 { 282 473 %> 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 <%=HTML.encodeTags(name)%> 290 <% 474 <td><a href="javascript:installAll('<%=jarFile.getAbsolutePath()%>')">Install all</a></td> 475 <% 291 476 } 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 } 305 518 %> 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 309 543 <% 310 } 311 else 312 { 544 if (allowImmediateExecution == null) 545 { 546 %> 547 <option value="" selected>auto 548 <% 549 } 313 550 %> 314 <option value="plugin" title="Plugin will be installed">yes 315 <% 316 } 317 %> 318 </select> 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 330 <select name="<%=info.getClassName()%>.trusted" 331 <%=classExists&&jarExists ? "disabled" : ""%> 332 > 333 <option value="0">no 334 <option value="1">yes 335 </select> 336 337 </td> 338 <td> 339 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())%> 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> 391 553 <% 392 554 } 393 555 } 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 <% 394 572 } 395 573 %> … … 397 575 </div> 398 576 <div align="right"> 399 <i><base:icon image="warning.gif" /> = duplicate configuration</i><br> 400 <i><base:icon image="hasvalues.gif" /> = plugin already installed</i><br> 401 <i><base:icon image="itemexists.gif" /> = exists in a different jar-file,<br> 402 installing will change the jar path.</i><br> 577 <i><base:icon image="joust/plugindisabled.png" /> = plug-in is already installed</i><br> 578 <i><base:icon image="joust/pluginwarning.png" /> = exists in a different JAR file</i><br> 579 <i><base:icon image="joust/itemwarning.gif" /> = configuration already exists</i><br> 403 580 </div> 404 581 </t:tab> 405 406 582 </t:tabcontrol> 407 583 -
trunk/www/admin/plugindefinitions/index.jsp
r4587 r4624 183 183 for (PluginInfo info : pluginInfos) 184 184 { 185 String selectedOption = request.getParameter(info.getJarPath() + " ." + info.getClassName());185 String selectedOption = request.getParameter(info.getJarPath() + ":" + info.getClassName()); 186 186 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")); 190 189 if (selectedOption.equals("plugin") || selectedOption.equals("plugin+confs")) 191 190 { 192 191 //The plugin doesn't exists 193 if (! classExists)192 if (!isInstalled) 194 193 { 195 194 PluginDefinition pd = null; 196 195 try 197 196 { 198 pd = PluginDefinition.getNew(dc, info.getClassName(), info.getJarPath(), usePermissions==2);197 pd = PluginDefinition.getNew(dc, info.getClassName(), info.getJarPath(), true); 199 198 } 200 199 catch(BaseException bex) … … 206 205 { 207 206 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")); 210 209 pd.setAllowImmediateExecution(aie == null ? 211 210 pd.getMainType() == Plugin.MainType.EXPORT : Values.getBoolean(aie)); … … 213 212 } 214 213 //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) 216 215 { 217 216 try 218 217 { 219 218 PluginDefinition pd = PluginDefinition.getByClassName(dc, info.getClassName()); 220 pd.loadPluginInformation(info.getJarPath(), info.getClassName(), usePermissions == 2);219 pd.loadPluginInformation(info.getJarPath(), info.getClassName(), true); 221 220 } 222 221 catch(BaseException bex) … … 239 238 for (PluginConfigInfo cnfInfo : configInfos) 240 239 { 241 Boolean toImport = Values.getBoolean(request.getParameter(info.getClassName() + " ." + cnfInfo.getName()));240 Boolean toImport = Values.getBoolean(request.getParameter(info.getClassName() + ":config:" + cnfInfo.getName())); 242 241 configurations.put(cnfInfo.getOrderInXml(), toImport); 243 242 }
Note: See TracChangeset
for help on using the changeset viewer.