Changeset 2147


Ignore:
Timestamp:
Apr 4, 2006, 11:21:54 AM (18 years ago)
Author:
Nicklas Nordborg
Message:

Added PathParameterType? to allow plugins to ask for a File or Directory path to
save it's output.

Location:
trunk
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/test/NullPlugin.java

    r1789 r2147  
    2525import net.sf.basedb.core.Item;
    2626import net.sf.basedb.core.BaseException;
     27import net.sf.basedb.core.Path;
     28import net.sf.basedb.core.PathParameterType;
    2729import net.sf.basedb.core.PluginParameter;
    2830import net.sf.basedb.core.ProgressReporter;
     
    216218    new FileParameterType(null, false, 0)
    217219  );
     220 
     221  private static final PluginParameter<String> oneDirectory = new PluginParameter<String>(
     222    "oneDirectory", "Save to directory", "Please specify the output directory where the plugin should store it's generated files",
     223    new PathParameterType(Path.Type.DIRECTORY)
     224  );
     225 
     226  private static final PluginParameter<String> onePath = new PluginParameter<String>(
     227      "onePath", "Save as", "Please specify the file name where the plugin should store it's output",
     228      new PathParameterType(Path.Type.FILE)
     229    );
    218230
    219231  private RequestInformation configurePlugin;
     
    307319    parameters.add(oneFile);
    308320    parameters.add(manyFiles);
     321    parameters.add(oneDirectory);
     322    parameters.add(onePath);
    309323
    310324    configurePlugin = new RequestInformation(
  • trunk/www/common/plugin/configure.jsp

    r2126 r2147  
    5050  import="net.sf.basedb.core.BooleanParameterType"
    5151  import="net.sf.basedb.core.FileParameterType"
     52  import="net.sf.basedb.core.PathParameterType"
    5253  import="net.sf.basedb.core.ItemContext"
     54  import="net.sf.basedb.core.Path"
    5355  import="net.sf.basedb.clients.web.Base"
    5456  import="net.sf.basedb.clients.web.WebException"
     
    417419      valueOnBlur(path);
    418420    }
     421    function saveAsOnClick(inputName)
     422    {
     423      var frm = document.forms['configure'];
     424      var url = '../../filemanager/index.jsp?ID=<%=ID%>&cmd=SaveAs&callback=saveAsCallback';
     425      lastFileInputName = inputName;
     426      Main.openPopup(url, 'SaveAs', 1000, 700);
     427    }
     428    function saveAsCallback(path)
     429    {
     430      var frm = document.forms['configure'];
     431      frm[lastFileInputName].value = path;
     432      valueOnBlur(path);
     433    }
     434    function selectDirectoryOnClick(inputName)
     435    {
     436      var frm = document.forms['configure'];
     437      var url = '../../filemanager/directories/index.jsp?ID=<%=ID%>&mode=selectonedirectory&callback=setFileCallback';
     438      lastFileInputName = inputName;
     439      Main.openPopup(url, 'SelectDirectory', 350, 500);
     440    }
     441   
    419442    function hideErrorList()
    420443    {
     
    813836                  }
    814837                }
     838                else if (pType instanceof PathParameterType)
     839                {
     840                  PathParameterType ppType = (PathParameterType)pType;
     841                  String browse = "";
     842                  if (ppType.getPathType() == Path.Type.FILE)
     843                  {
     844                    browse = "saveAsOnClick('" + inputName + "')";
     845                  }
     846                  else
     847                  {
     848                    browse = "selectDirectoryOnClick('" + inputName + "')";
     849                  }
     850                  %>
     851                  <table border="0" cellspacing="0" cellpadding="0">
     852                  <tr>
     853                  <td>
     854                    <input type="text" class="text" name="<%=inputName%>" size="40" value=""
     855                      onblur="valueOnBlur(this.value)">&nbsp;</td>
     856                  <td><base:button
     857                      title="Browse&hellip;"
     858                      onclick="<%=browse%>"
     859                      />
     860                  </td>
     861                  </tr>
     862                  </table>
     863                  <%
     864                }
    815865                else
    816866                {
  • trunk/www/common/plugin/index.jsp

    r1945 r2147  
    4444  import="net.sf.basedb.core.BooleanParameterType"
    4545  import="net.sf.basedb.core.FileParameterType"
     46  import="net.sf.basedb.core.PathParameterType"
    4647  import="net.sf.basedb.core.File"
    4748  import="net.sf.basedb.core.Path"
     
    306307              dc.close();
    307308            }
     309            else if (pType instanceof PathParameterType)
     310            {
     311              oValues = sValues;
     312            }
    308313          }
    309314          pcRequest.setParameterValues(param.getName(), oValues == null ? null : Arrays.asList(oValues));
Note: See TracChangeset for help on using the changeset viewer.