Exemple #1
1
  /** ************************************************************************** */
  public TracesSessions refreshTracesSessions() {
    TracesSessions retval = null;
    TracesSessions tss = new TracesSessions();
    String trace = null;
    try {
      if (this.logFile != null) {
        File file = new File(this.logFile);
        char[] cbuf = new char[(int) file.length()];
        FileReader fr = new FileReader(file);
        fr.read(cbuf);
        fr.close();
        trace = new String(cbuf);
      }
      // System.out.println("**** TRACE ******:\n"+trace+"\n");
      if (trace != null && !trace.equals("")) {
        LogFileParser parser = new LogFileParser();
        HashMap<String, MessageLogList> traces = parser.parseLogsFromString(trace);
        Enumeration<MessageLogList> elements = traces.elements();
        while (elements.hasMoreElements()) {
          MessageLogList mll = elements.nextElement();
          TracesSession ts = new TracesSession(mll);
          ts.setName(parser.logName);
          ts.setLogDescription(parser.logDescription);
          ts.setInfo(parser.auxInfo);
          tss.add(ts);
        }
        tss.setName(parser.logName);

        retval = tss;
      } else {
        TracesSession ts = new TracesSession();
        ts.setName("No available session, refresh");
        tss.add(ts);
        retval = tss;
      }
    } catch (Exception e) {
      System.out.println("*** Exception retrieving trace ***");
      e.printStackTrace();
      TracesSession ts = new TracesSession();
      ts.setName("No available session, refresh");
      tss.add(ts);
      retval = tss;
    }

    tracesSessions = retval;
    return tracesSessions;
  }
Exemple #2
1
  /**
   * Call this constructor when you want to construct a visualizer from traces that you have already
   * read.
   *
   * @param titles is an array containing the titles for the traces.
   * @param traces is an array containing an array of XML Formatted traces.
   */
  public TracesViewer(
      HashMap<String, MessageLogList> traces,
      String logName,
      String logDescription,
      String auxInfo) {
    // System.out.println("**** TRACE ******:\n"+trace+"\n");
    TracesSessions tss = new TracesSessions();
    Enumeration<MessageLogList> elements = traces.elements();
    tss.setName(logName);
    logFile = logName;
    while (elements.hasMoreElements()) {
      MessageLogList mll = elements.nextElement();
      TracesSession ts = new TracesSession(mll);
      ts.setName(logName);
      ts.setInfo(auxInfo);
      ts.setLogDescription(logDescription);
      tss.add(ts);
    }

    listenerTracesViewer = new ListenerTracesViewer(this);

    // The order is important!!!!!
    // Look at the rmi registry for new traces
    // tracesSessions=refreshTracesSessions();
    this.tracesSessions = tss;
    this.standaloneViewer = true;
    initComponents();
    // Initialisation of the tracesSessionsList:
    tracesSessionsList.setTracesSessions(this.tracesSessions);
    // Initialisation of the Thread for the animations:
    animationThread = new TracesAnimationThread(tracesCanvas);

    // width, height
    this.setSize(670, 620);
    this.setLocation(0, 0);
  }
Exemple #3
1
  // Constructor for the daemon only!!!!!
  public TracesViewer(
      String port,
      String logFile,
      HashMap<String, MessageLogList> traces,
      String logName,
      String logDescription,
      String auxInfo,
      String title,
      String back,
      String faces,
      String actors,
      String aLogoNist) {
    super(title);
    this.logFile = logFile;

    try {
      Toolkit toolkit = Toolkit.getDefaultToolkit();
      URL url = TracesViewer.class.getResource(back);
      backgroundImage = toolkit.getImage(url);
      url = TracesViewer.class.getResource(actors);
      actorsImage = toolkit.getImage(url);
      url = TracesViewer.class.getResource(faces);
      facesImage = toolkit.getImage(url);
      url = TracesViewer.class.getResource(aLogoNist);
      logoNist = toolkit.getImage(url);
    } catch (Exception e) {
      backgroundImage = null;
      actorsImage = null;
      facesImage = null;
      logoNist = null;
      System.out.println("Images are not loaded.");

      e.printStackTrace();
    }

    TracesSessions tss = new TracesSessions();
    tss.setName(logName);
    if (traces != null) {
      Enumeration elements = traces.elements();
      while (elements.hasMoreElements()) {
        MessageLogList mll = (MessageLogList) elements.nextElement();
        TracesSession ts = new TracesSession(mll);
        ts.setName(logName);
        ts.setInfo(auxInfo);
        ts.setLogDescription(logDescription);
        tss.add(ts);
      }
    }
    if (tss.isEmpty()) {
      TracesSession ts = new TracesSession();
      ts.setName("No available session, refresh");
      tss.add(ts);
    }

    listenerTracesViewer = new ListenerTracesViewer(this);

    this.tracesSessions = tss;
    initComponents();
    // Initialisation of the tracesSessionsList:
    tracesSessionsList.setTracesSessions(this.tracesSessions);
    // Initialisation of the Thread for the animations:
    animationThread = new TracesAnimationThread(tracesCanvas);

    // width, height
    this.setSize(670, 620);
    this.setLocation(0, 0);

    try {
      // Try to open a connection:
      TracesSocket ts = new TracesSocket(logFile, port);
      ts.start();
    } catch (Exception e) {
      e.printStackTrace();
    }
    this.setVisible(true);
  }