Changeset 1119


Ignore:
Timestamp:
Jun 28, 2011, 10:10:45 PM (6 years ago)
Author:
stefan
Message:
 
Location:
trunk
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/jlatexeditor/quickhelp/HelpUrlHandler.java

    r1118 r1119  
    33import de.endrullis.utils.CollectionUtils;
    44import jlatexeditor.PackagesExtractor;
     5import sun.net.www.protocol.file.FileURLConnection;
    56import util.ConfigurableStreamHandlerFactory;
    67import util.StreamUtils;
    78
    89import java.io.*;
     10import java.net.HttpURLConnection;
    911import java.net.URL;
    1012import java.net.URLConnection;
    1113import java.net.URLStreamHandler;
    1214import java.util.ArrayList;
     15import java.util.Collections;
    1316import java.util.HashSet;
    1417
     
    1821public class HelpUrlHandler extends URLStreamHandler {
    1922  protected URLConnection openConnection(final URL u) throws IOException {
    20     System.out.println("yeah help");
     23    String command = null;
    2124
    22     return new URLConnection(u) {
     25    String realUrlString = u.toExternalForm().substring(5);
     26    if (realUrlString.contains("#")) {
     27      int index = realUrlString.indexOf("#");
     28      command = realUrlString.substring(index + 1);
     29
     30      realUrlString = realUrlString.substring(0, index);
     31    }
     32    final URL realUrl = new URL(realUrlString);
     33
     34    final String finalCommand = command;
     35
     36    return new URLConnection(realUrl) {
    2337      @Override
    2438      public void connect() throws IOException {
     
    2640
    2741      @Override
    28       public Object getContent() throws IOException {
    29         /*
    30         InputStream in = (InputStream) realUrl.getContent();
    31         String content = new String(StreamUtils.readBytesFromInputStream(in));
    32         content = content.replace("href=\"", "href=\"help:");
    33 
    34         ByteArrayOutputStream out = new ByteArrayOutputStream();
    35         */
    36 
    37         String command = null;
    38 
    39         String realUrlString = u.toExternalForm().substring(5);
    40         if (realUrlString.contains("#")) {
    41           int index = realUrlString.indexOf("#");
    42           command = realUrlString.substring(index + 1);
    43 
    44           realUrlString = realUrlString.substring(0, index);
    45         }
    46         URL realUrl = new URL(realUrlString);
    47 
    48         String content = HelpUrlHandler.getHelpTextAt(command, realUrl);
     42      public InputStream getInputStream() throws IOException {
     43        String content = HelpUrlHandler.getHelpTextAt(finalCommand, realUrl);
    4944
    5045        return new ByteArrayInputStream(content.getBytes());
     
    9489      ArrayList<String> packs = new ArrayList<String>();
    9590      for (PackagesExtractor.Command cmd : commands) {
    96         packs.add(cmd.getPack().getName());
     91        packs.add("<span>" + cmd.getPack().getName() + "</span>");
    9792      }
     93      Collections.sort(packs);
    9894      return CollectionUtils.join(packs, ", ");
    9995    }
  • trunk/src/jlatexeditor/quickhelp/LatexQuickHelp.java

    r1118 r1119  
    6666    String toc_file = directory + "ltx-2.html";
    6767
     68    commands.put("<empty>", "empty.html");
     69
    6870    BufferedReader reader;
    6971    try {
     
    122124  public String getHelpUrl(String command) {
    123125    String fileName = commands.get(command);
    124     if (fileName == null) return null;
     126    if (fileName == null) fileName = commands.get("<empty>");
     127    // if (fileName == null) return null;
    125128
    126129    URL url = StreamUtils.getURL(directory + fileName);
    127130    if (url == null) return null;
    128131
    129     return "help:" + url.toString();
     132    return "help:" + url.toString() + "#" + command;
    130133  }
    131134
  • trunk/src/sce/quickhelp/QuickHelpPane.java

    r1117 r1119  
    5050    htmlPane.setEditable(false);
    5151    htmlPane.addPropertyChangeListener(this);
     52    htmlPane.setContentType("text/html");
    5253
    5354    // add the component to the viewport
     
    137138        }
    138139      } catch (IOException e1) {
    139         System.err.println("SCEPaneUI: " + e1);
     140        e1.printStackTrace();
    140141      }
    141142      e.consume();
Note: See TracChangeset for help on using the changeset viewer.