⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 jext.java

📁 java写的多功能文件编辑器
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
      if (!plugin.toLowerCase().endsWith(".jar"))        continue;      try      {        new JARClassLoader(directory + File.separator + plugin);      } catch(IOException io) {        String[] args2 = { plugin };        System.err.println(getProperty("jar.error.load", args2));        io.printStackTrace();      }    }  }  /**   * Registers a plugin with the editor. This will also call   * the <code>start()</code> method of the plugin.   */  public static void addPlugin(Plugin plugin)  {    plugins.add(plugin);    try    {      plugin.start();    } catch (Throwable t) {      System.err.println("#--An exception has occurred while starting plugin:");      t.printStackTrace();    }    if (plugin instanceof SkinFactory)    {      //System.out.println("Added a SkinPlugin named: " + plugin.getClass().getName());      SkinManager.registerSkinFactory((SkinFactory) plugin);    }  }  /**   * Returns a plugin by it's class name.   * @param name The plugin to return   */  public static Plugin getPlugin(String name)  {    for (int i = 0; i < plugins.size(); i++)    {      Plugin p = (Plugin) plugins.get(i);      if (p.getClass().getName().equalsIgnoreCase(name))        return p;    }    return null;  }  /**   * Returns an array of installed plugins.   */  public static Plugin[] getPlugins()  {    /*Object[] o = plugins.toArray();    Plugin[] p = new Plugin[o.length];    for (int i = 0; i < o.length; i++)      p[i] = (Plugin) o[i];*/    Plugin[] p = (Plugin[]) plugins.toArray(new Plugin[0]);    return p;  }  /**   * Opens a new window.   * @param args Parameters from command line   */  public static JextFrame newWindow(String args[])  {    return newWindow(args, true);  }  /**   * Opens a new window.   */  public static JextFrame newWindow()  {    return newWindow(null, true);  }  /**   * Opens a new window, but eventually does not show it.   * @param args The command line arguments   * @param toShow When true the frame is shown   */  //Note: until code doesn't need it, better leaving it only for the package.  /*friendly*/ static JextFrame newWindow(String args[], boolean toShow)  {    synchronized (instances)    {      JextFrame window;      if (toShow && builtTextArea != null)      {        if (args != null)          for (int i = 0; i < args.length; i++)            builtTextArea.open(args[i]);        builtTextArea.setVisible(true);        window = builtTextArea;        builtTextArea = null;      } else {        window = new JextFrame(args, toShow);        //if (toShow)        instances.add(window);      }      return window;    }  }  /**   * Returns amount of opened Jext   */  public static int getWindowsCount()  {    return instances.size();  }  /**   * Notify all instances of Jext and all properties listeners to reload properties.   */  public static void propertiesChanged()  {    // we send the event to all the listeners available    for (int i = 0; i < instances.size(); i++)      ((JextFrame) instances.get(i)).loadProperties();  }  /**   * Notify all instances of Jext but the one which   * saved the file to reload recent menu   * @param The instance which saved a file   */  public static void recentChanged(JextFrame instance)  {    // we send the event to all the listeners available    JextFrame listener;    for (int i = 0; i < instances.size(); i++)    {      listener = (JextFrame) instances.get(i);      if (listener != instance && listener != null)        listener.reloadRecent();    }  }  /**   * Some external classes may need to notify   * each instance of Jext. XTree does.   * @return A <code>ArrayList</code> containing all instances of Jext   */  public static ArrayList getInstances()  {    return instances;  }  /**   * Many methods will need to use a <code>Toolkit</code>.   * This method simply avoid to write too many lines of   * code.   * @return The default <code>Toolkit</code>   */  public static Toolkit getMyToolkit()  {    return Toolkit.getDefaultToolkit();  }  /**   * Jext startup directory is saved during execution.   * @return Jext's startup directory   */  public static String getHomeDirectory()  {    return JEXT_HOME;  }  /**   * Store the properties on the HD. After having   * set up the properties, we need to store'em   * in a file.   * @deprecated Use <code>saveXMLProps()</code> instead   */  public static void saveProps()  {    if (usrProps != null)    {      try      {        OutputStream out = new FileOutputStream(usrProps);        props.store(out, "Jext Properties");        out.close();      } catch (IOException io) { }    }  }  /**   * Saves the user's properties to a file using the XML specifications.   * @param description is a <code>String</code> containing a little   * description of the properties file. This String is stored on   * topmost of the user's properties file. Can be set to   * <code>null</code>.   */  public static void saveXMLProps(String description)  {    saveXMLProps(usrProps, description);  }  /**   * Saves the user's properties to a file using the XML specifications.   * @param userProps is the path to the file in which properties will   * be stored. If it is set to <code>null</code>, properties are not   * saved at all.   * @param description is a <code>String</code> containing a little   * description of the properties file. This String is stored on   * topmost of the user's properties file. Can be set to   * <code>null</code>.   */  public static void saveXMLProps(String userProps, String description)  {    if (userProps != null)    {      try      {        BufferedWriter out = new BufferedWriter(new FileWriter(userProps));        String _out = new String("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");        out.write(_out, 0, _out.length());        out.newLine();        _out = new String("<!DOCTYPE xproperties SYSTEM \"xproperties.dtd\" >");        out.write(_out, 0, _out.length());        out.newLine();        _out = "<!-- Last save: " + (new Date()).toString() + " -->";        out.write(_out, 0, _out.length());        out.newLine();        if (description == null)          description = new String("Properties");        description = "<!-- " + description + " -->";        out.write(description, 0, description.length());        out.newLine();        out.newLine();        _out = new String("<xproperties>");        out.write(_out, 0, _out.length());        out.newLine();        setProperty("properties.version", BUILD);        char c = '\0';        StringBuffer buf;        Enumeration k = props.keys();        Enumeration e = props.elements();        for ( ; e.hasMoreElements(); )        {          buf = new StringBuffer("  <property name=\"");          buf.append(k.nextElement());          buf.append("\" value=\"");          String _e = (String) e.nextElement();          for (int i = 0; i < _e.length(); i++)          {            switch(c = _e.charAt(i))            {              case '\\':                buf.append('\\');                buf.append('\\');                break;              case '\'':                buf.append("&apos;");                break;              case '&':                buf.append("&amp;");                break;              case '\"':                buf.append("&#34;");                break;              case '\n':                buf.append('\\');                buf.append('n');                break;              case '\r':                buf.append('\\');                buf.append('r');                break;              default:                buf.append(c);            }          }          buf.append("\" />");          //for (int i = 0; i < buf.length(); i++)          //  out.write(buf.charAt(i));          out.write(buf.toString(), 0, buf.length());          out.newLine();        }        _out = new String("</xproperties>");        out.write(_out, 0, _out.length());        out.close();      } catch (IOException io) { }    }    //JARClassLoader.saveDisabledList();  }  /**   * The <code>XPropertiesHandler</code> needs to get Jext's   * <code>Properties</code> object to achieve its purpose.   * @return The current <code>Properties</code> object   */  public static Properties getProperties()  {    return props;  }  /**   * Load a set of properties from an XML file.   * This method, and not the caller, will search for the translated version of the XML.   * @param in An <code>InputStream</code> is specified to load properties from a JAR file   * @param fileName The XML filename   */  public static void loadXMLProps(InputStream in, String fileName)  {    XPropertiesReader.read(in, fileName);  }    /**   * Load a set of properties from an XML file.   * It is provided for when the caller already provides the translated file(for instance for the plugin   * translation); in this case toTranslate must be true, otherwise it will be translated the default way.   * @param in An <code>InputStream</code> is specified to load properties from a JAR file   * @param fileName The XML filename   * @since Jext3.2pre1   */     public static void loadXMLProps(InputStream in, String fileName, boolean toTranslate)  {    XPropertiesReader.read(in, fileName, toTranslate);  }  /**   * Load a set of actions from an XML file.   * @param in An <code>InputStream</code> is specified to load properties from a JAR file   * @param fileName The XML filename   */  public static void loadXMLActions(InputStream in, String fileName)  {    PyActionsReader.read(in, fileName);  }  /**   * Load a set of actions from an XML file.   * @param in An <code>InputStream</code> is specified to load properties from a JAR file   * @param fileName The XML filename   */  public static void loadXMLOneClickActions(InputStream in, String fileName)  {    OneClickActionsReader.read(in, fileName);  }  /**   * Returns an input stream corresponding to selected language.   * @param in The default stream   * @param fileName The requested file   */  public static InputStream getLanguageStream(InputStream in, String fileName)  {    ZipEntry entry;    if (languagePack != null && (entry = languagePackContains(fileName)) != null)    {      try      {        return languagePack.getInputStream(entry);      } catch (IOException ioe) {        return in;      }    } else      return in;  }  // returns a non-null ZipEntry object if current language pack  // contains requested file  public static ZipEntry languagePackContains(String fileName)  {    for (int i = 0; i < languageEntries.size(); i++)    {      ZipEntry entry = (ZipEntry) languageEntries.get(i);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -