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

📄 jext.java

📁 java写的多功能文件编辑器
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
      if (entry.getName().equalsIgnoreCase(fileName))        return entry;    }    return null;  }  /**   * Load a set of properties.   * @param in An <code>InputStream</code> is specified to load properties from a JAR file   * @deprecated Maintained only for plugins compliance. Use <code>loadXMLProps()</code>   * instead of this method.   */  public static void loadProps(InputStream in)  {    try    {      props.load(new BufferedInputStream(in));      in.close();    } catch (IOException ioe) { }  }  /**   * Creates the necessary directories.   */  public static void initDirectories()  {    File dir = new File(SETTINGS_DIRECTORY);    if (!dir.exists())    {      dir.mkdir();      dir = new File(SETTINGS_DIRECTORY + "plugins" + File.separator);      if (!dir.exists())        dir.mkdir();      dir = new File(SETTINGS_DIRECTORY + "scripts" + File.separator);      if (!dir.exists())        dir.mkdir();      dir = new File(SETTINGS_DIRECTORY + "xinsert" + File.separator);      if (!dir.exists())        dir.mkdir();    }  }  /**   * Init the properties.   */  public static void initProperties()  {    usrProps = SETTINGS_DIRECTORY + ".jext-props.xml";    defaultProps = props = new Properties();    /////////////////////////////////////////////////////////////////    // DEPRECATED BY THE METHOD loadXMLProps()    /////////////////////////////////////////////////////////////////    //    loadProps(Jext.class.getResourceAsStream("jext-gui.keys"));    //    loadProps(Jext.class.getResourceAsStream("jext-gui.text"));    //    loadProps(Jext.class.getResourceAsStream("jext.props"));    //    loadProps(Jext.class.getResourceAsStream("jext.tips"));    /////////////////////////////////////////////////////////////////    // loads specified language pack    File lang = new File(SETTINGS_DIRECTORY + ".lang");    if (lang.exists())    {      try      {        BufferedReader reader = new BufferedReader(new FileReader(lang));        String language = reader.readLine();        reader.close();        if (language != null && !language.equals("English"))        {          File langPack = new File(JEXT_HOME + File.separator + "lang" +                                               File.separator + language + "_pack.jar");          if (langPack.exists())          {            languagePack = new ZipFile(langPack);            languageEntries = new ArrayList();            Enumeration entries = languagePack.entries();            while (entries.hasMoreElements())              languageEntries.add(entries.nextElement());            setLanguage(language);          } else            lang.delete();        }      } catch (IOException ioe) { }    }    //loadXMLProps(Jext.class.getResourceAsStream("jext.props.xml"), "jext.props.xml");    loadXMLProps(Jext.class.getResourceAsStream("jext-text.props.xml"), "jext-text.props.xml");    loadXMLProps(Jext.class.getResourceAsStream("jext-keys.props.xml"), "jext-keys.props.xml");    loadXMLProps(Jext.class.getResourceAsStream("jext-defs.props.xml"), "jext-defs.props.xml");    loadXMLProps(Jext.class.getResourceAsStream("jext-tips.props.xml"), "jext-tips.props.xml");    Properties pyProps = new Properties();    pyProps.put("python.cachedir", SETTINGS_DIRECTORY + "pythoncache" + File.separator);    PythonInterpreter.initialize(System.getProperties(), pyProps, new String[0]);    initPlugins();    if (usrProps != null)    {      props = new Properties(defaultProps);      try      {        loadXMLProps(new FileInputStream(USER_PROPS), ".jext-props.xml");        if (DELETE_OLD_SETTINGS)        {          String pVersion = getProperty("properties.version");          if (pVersion == null || BUILD.compareTo(pVersion) > 0)          {            File userSettings = new File(USER_PROPS);            if (userSettings.exists())            {              userSettings.delete();              defaultProps = props = new Properties();              //loadXMLProps(Jext.class.getResourceAsStream("jext.props.xml"), "jext.props.xml");              loadXMLProps(Jext.class.getResourceAsStream("jext-text.props.xml"), "jext-text.props.xml");              loadXMLProps(Jext.class.getResourceAsStream("jext-keys.props.xml"), "jext-keys.props.xml");              loadXMLProps(Jext.class.getResourceAsStream("jext-defs.props.xml"), "jext-defs.props.xml");              loadXMLProps(Jext.class.getResourceAsStream("jext-tips.props.xml"), "jext-tips.props.xml");              JARClassLoader.reloadPluginsProperties();              props = new Properties(defaultProps);            }          }        }      } catch (FileNotFoundException fnfe) {      } catch (IOException ioe) { }    }    initModes(); //must be here since the user can change the mode filters.    Search.load();    if (Utilities.JDK_VERSION.charAt(2) >= '4')    {      try      {        Class cl = Class.forName("org.jext.JavaSupport");        Method m = cl.getMethod("initJavaSupport", new Class[0]);        if (m !=  null)          m.invoke(null, new Object[0]);      } catch (Exception e) { }    }    // Add our protocols to java.net.URL's list    System.getProperties().put("java.protocol.handler.pkgs", "org.jext.protocol|" +                               System.getProperty("java.protocol.handler.pkgs", ""));    initActions();    JARClassLoader.initPlugins();    initUI();    sortModes();    assocPluginsToModes();  }  /**   * Sets the current selected language.   * @param lang The label of the language   */  public static void setLanguage(String lang)  {    language = lang;  }  /**   * Returns current selected language.   */  public static String getLanguage()  {    return language;  }  /**   * Execute scripts found in user home directory.   */  public static void executeScripts(JextFrame parent)  {    String dir = SETTINGS_DIRECTORY + "scripts" + File.separator;    String[] scripts = Utilities.getWildCardMatches(dir, "*.jext-script", false);    if (scripts == null)      return;    for (int i = 0; i < scripts.length; i++)      org.jext.scripting.dawn.Run.runScript(dir + scripts[i], parent, false);    scripts = Utilities.getWildCardMatches(dir, "*.py", false);    if (scripts == null)      return;    for (int i = 0; i < scripts.length; i++)      org.jext.scripting.python.Run.runScript(dir + scripts[i], parent);  }  // sort modes alphabetically  private static void sortModes()  {    String[] modeNames = new String[modes.size()];    for (int i = 0; i < modeNames.length; i++)      modeNames[i] = ((Mode) modes.get(i)).getUserModeName();    Arrays.sort(modeNames);    ArrayList v = new ArrayList(modeNames.length);    for (int i = 0; i < modeNames.length; i++)    {      int j = 0;      String name = modeNames[i];      while (!((Mode) modes.get(j)).getUserModeName().equals(name))      {        if (j == modes.size() - 1)          break;        else          j++;      }      v.add(modes.get(j));    }    modes = v;    v = null;  }  // changes some default UI settings such as trees leaf icons or font size and style...  private static void initUI()  {    /*if (getBooleanProperty("useJextTheme"))      MetalLookAndFeel.setCurrentTheme(new JextMetalTheme());*/    SkinManager.applySelectedSkin();    // check if menus are flat or not    flatMenus = getBooleanProperty("flatMenus");    // check if buttons are highlighted or not    buttonsHighlight = getBooleanProperty("buttonsHighlight");    // rollover    JextButton.setRollover(getBooleanProperty("toolbarRollover"));  }  /**   * Initialize syntax colorizing modes.   */  private static void initModes()  {    StringTokenizer _tok = new StringTokenizer(getProperty("jext.modes"), " ");    Mode _mode;    modes = new ArrayList(_tok.countTokens());    modesFileFilters = new ArrayList(_tok.countTokens());    for ( ; _tok.hasMoreTokens(); )    {      modes.add(_mode = new Mode(_tok.nextToken()));      modesFileFilters.add(new ModeFileFilter(_mode));    }  }  /**   * Returns the mode according to its name.   */  public static Mode getMode(String modeName)  {    for (int i = 0; i < modes.size(); i++)    {      Mode _mode = (Mode) modes.get(i);      if (_mode.getModeName().equalsIgnoreCase(modeName))        return _mode;    }    return null;  }  /**   * Returns modes list.   */  public static ArrayList getModes()  {    return modes;  }  /**   * Adds a mode to Jext's syntax colorizing modes list   */  public static void addMode(Mode mode)  {    modes.add(mode);    modesFileFilters.add(new ModeFileFilter(mode));  }  /**   * Set a property.   * @param name Property's name   * @param value The value to store as <code>name</code>   */  public static void setProperty(String name, String value)  {    if (name == null || value == null)      return;    props.put(name, value);  }  /**   * Returns true if the property value equals to "on" or "true"   * @param name The name of the property to read   */  public static boolean getBooleanProperty(String name)  {    String p = getProperty(name);    if (p == null)      return false;    else      return p.equals("on") || p.equals("true");  }  /**   * Returns true if the property value equals to "on" or "true"   * @param name The name of the property to read   */  public static boolean getBooleanProperty(String name, String def)  {    String p = getProperty(name, def);    if (p == null)      return false;    else      return p.equals("on") || p.equals("true");  }  /**   * If we store properties, we need to read them, too !   * @param name The name of the property to read   * @return The value of the specified property   */  public static String getProperty(String name)  {    return props.getProperty(name);  }  /**   * Fetches a property, returning the default value if it's not   * defined.   * @param name The property   * @param def The default value   */  public static final String getProperty(String name, String def)  {    return props.getProperty(name, def);  }  /**   * Returns the property with the specified name, formatting it with   * the <code>java.text.MessageFormat.format()</code> method.   * @param name The property   * @param args The positional parameters   */  public static final String getProperty(String name, Object[] args)  {    if (name == null)      return null;    if (args == null)      return props.getProperty(name, name);    else      return MessageFormat.format(props.getProperty(name, name), args);  }  /**   * Unsets (clears) a property.   * @param name The property   */  public static void unsetProperty(String name)  {    if (defaultProps.get(name) != null)      props.put(name, "");    else      props.remove(name);  }  /**

⌨️ 快捷键说明

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