Esempio n. 1
0
  /**
   * Forces the action set to be loaded. Plugins and macros should not call this method.
   *
   * @since jEdit 4.2pre1
   */
  public void load() {
    if (loaded) return;

    loaded = true;
    // actions.clear();

    if (uri == null) return;
    try {
      Log.log(Log.DEBUG, this, "Loading actions from " + uri);
      ActionListHandler ah = new ActionListHandler(uri.toString(), this);
      InputStream in = uri.openStream();
      if (in == null) {
        // this happened when calling generateCache() in the context of 'find orphan jars'
        // in org.gjt.sp.jedit.pluginmgr.ManagePanel.FindOrphan.actionPerformed(ActionEvent)
        // because for not loaded plugins, the plugin will not be added to the list of pluginJars
        // so the org.gjt.sp.jedit.proto.jeditresource.PluginResURLConnection will not find the
        // plugin
        // to read the resource from.
        // Better log a small error message than a big stack trace
        Log.log(Log.WARNING, this, "Unable to open: " + uri);
      } else if (XMLUtilities.parseXML(in, ah)) {
        Log.log(Log.ERROR, this, "Unable to parse: " + uri);
      }
    } catch (IOException e) {
      Log.log(Log.ERROR, this, uri, e);
    }
  } // }}}
Esempio n. 2
0
  /**
   * loads a pluginSet xml file and updates the model to reflect certain checked selections
   *
   * @since jEdit 4.3pre10
   * @author Alan Ezust
   */
  boolean loadPluginSet(String path) {
    pluginSet.clear();
    pluginModel.restoreSelection(new HashSet<String>(), new HashSet<String>());

    VFS vfs = VFSManager.getVFSForPath(path);
    Object session = vfs.createVFSSession(path, InstallPanel.this);
    try {
      InputStream is = vfs._createInputStream(session, path, false, InstallPanel.this);
      XMLUtilities.parseXML(is, new StringMapHandler());
    } catch (Exception e) {
      Log.log(Log.WARNING, this, "Loading Pluginset failed:" + e.getMessage());
      return false;
    }
    pluginModel.update();
    return true;
  } // }}}
 @Override
 public InputSource resolveEntity(String publicId, String systemId) {
   return XMLUtilities.findEntity(systemId, "recent.dtd", getClass());
 }
  // {{{ save() method
  public static void save() {
    if (recentXML == null) return;

    if (recentXML.hasChangedOnDisk()) {
      Log.log(
          Log.WARNING,
          BufferHistory.class,
          recentXML + " changed on disk; will not save recent" + " files");
      return;
    }

    Log.log(Log.MESSAGE, BufferHistory.class, "Saving " + recentXML);

    String lineSep = System.getProperty("line.separator");

    SettingsXML.Saver out = null;

    try {
      out = recentXML.openSaver();
      out.writeXMLDeclaration();

      out.write("<!DOCTYPE RECENT SYSTEM \"recent.dtd\">");
      out.write(lineSep);
      out.write("<RECENT>");
      out.write(lineSep);

      // Make a snapshot to avoid long locking period
      // which may be required by file I/O.
      List<Entry> snapshot = getHistory();

      for (Entry entry : snapshot) {
        out.write("<ENTRY>");
        out.write(lineSep);

        out.write("<PATH>");
        out.write(XMLUtilities.charsToEntities(entry.path, false));
        out.write("</PATH>");
        out.write(lineSep);

        out.write("<CARET>");
        out.write(String.valueOf(entry.caret));
        out.write("</CARET>");
        out.write(lineSep);

        if (entry.selection != null && entry.selection.length() > 0) {
          out.write("<SELECTION>");
          out.write(entry.selection);
          out.write("</SELECTION>");
          out.write(lineSep);
        }

        if (entry.encoding != null) {
          out.write("<ENCODING>");
          out.write(entry.encoding);
          out.write("</ENCODING>");
          out.write(lineSep);
        }

        if (entry.mode != null) {
          out.write("<MODE>");
          out.write(entry.mode);
          out.write("</MODE>");
          out.write(lineSep);
        }

        out.write("</ENTRY>");
        out.write(lineSep);
      }

      out.write("</RECENT>");
      out.write(lineSep);

      out.finish();
    } catch (Exception e) {
      Log.log(Log.ERROR, BufferHistory.class, e);
    } finally {
      IOUtilities.closeQuietly(out);
    }
  } // }}}
Esempio n. 5
0
 // {{{ resolveEntity() method
 public InputSource resolveEntity(String publicId, String systemId) {
   return XMLUtilities.findEntity(systemId, "mirrors.dtd", PluginOptions.class);
 } // }}}