Exemplo n.º 1
0
  public void loadOldStylePluginFrom(File pluginFile) throws IOException {
    JarFile jarFile = new JarFile(pluginFile);
    // add jar to our extension classLoader
    SoapUIExtensionClassLoader extensionClassLoader = getExtensionClassLoader();
    extensionClassLoader.addFile(pluginFile);

    // look for factories
    JarEntry entry = jarFile.getJarEntry("META-INF/factories.xml");
    if (entry != null) {
      getFactoryRegistry().addConfig(jarFile.getInputStream(entry), extensionClassLoader);
    }

    // look for listeners
    entry = jarFile.getJarEntry("META-INF/listeners.xml");
    if (entry != null) {
      getListenerRegistry().addConfig(jarFile.getInputStream(entry), extensionClassLoader);
    }

    // look for actions
    entry = jarFile.getJarEntry("META-INF/actions.xml");
    if (entry != null) {
      getActionRegistry().addConfig(jarFile.getInputStream(entry), extensionClassLoader);
    }

    // add jar to resource classloader so embedded images can be found with
    // UISupport.loadImageIcon(..)
    UISupport.addResourceClassLoader(new URLClassLoader(new URL[] {pluginFile.toURI().toURL()}));
  }
Exemplo n.º 2
0
 /** Get the default folder URL */
 public URL getDefaultFolderURL() {
   try {
     final File defaultFolder = getDefaultFolder();
     return (defaultFolder != null) ? defaultFolder.toURI().toURL() : null;
   } catch (MalformedURLException exception) {
     throw new RuntimeException("Exception getting the default document URL.", exception);
   }
 }
Exemplo n.º 3
0
  /**
   * Look inside a jar file, find the plugin.xml file, and use it to determine the name and version
   * of the plugin.
   *
   * @param f The file to investigate.
   * @return A string array containing the plugin name in the first element and the version number
   *     in the second, or null if the filename couldn't be interpreted.
   */
  public static String[] getNameAndVersion(File f) {

    try {
      File temp = unpackPluginXML(f);
      if (temp == null) return null; // Couldn't find the plugin.xml file
      ManifestInfo mi =
          PluginCore.getManager().getRegistry().readManifestInfo(temp.toURI().toURL());
      temp.delete();
      return new String[] {mi.getId(), mi.getVersion().toString()};
    } catch (MalformedURLException e) {
      e.printStackTrace();
      return null;
    } catch (ManifestProcessingException e) {
      return null; // Couldn't make sense of the plugin.xml
    }
  }
Exemplo n.º 4
0
  /**
   * Sets the icon for the given file.
   *
   * @param file the file to set an icon for
   * @return the byte array containing the thumbnail
   */
  private byte[] getFileThumbnail(File file) {
    byte[] bytes = null;
    if (FileUtils.isImage(file.getName())) {
      try {
        ImageIcon image = new ImageIcon(file.toURI().toURL());
        int width = image.getIconWidth();
        int height = image.getIconHeight();

        if (width > THUMBNAIL_WIDTH) width = THUMBNAIL_WIDTH;
        if (height > THUMBNAIL_HEIGHT) height = THUMBNAIL_HEIGHT;

        bytes = ImageUtils.getScaledInstanceInBytes(image.getImage(), width, height);
      } catch (MalformedURLException e) {
        if (logger.isDebugEnabled()) logger.debug("Could not locate image.", e);
      }
    }
    return bytes;
  }
Exemplo n.º 5
0
    /**
     * Show the selector for selecting the default folder.
     *
     * @return true if the user selected a default folder and false if not.
     */
    protected boolean showDefaultFolderSelector() throws Exception {
      final JFileChooser selector = new JFileChooser(_activeFileChooser.getCurrentDirectory());
      selector.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
      final String title =
          (_subfolderName == null)
              ? "Default Folder"
              : "Default Parent Folder of " + _subfolderName;
      selector.setDialogTitle(title);
      final int status = selector.showDialog(_view, "Make Default");

      switch (status) {
        case JFileChooser.APPROVE_OPTION:
          final File defaultFolder = selector.getSelectedFile();
          if (defaultFolder != null) {
            _folderTracker.cacheURL(defaultFolder.toURI().toURL());
            return true;
          } else {
            return false;
          }
        default:
          return false;
      }
    }