Package de.innovationgate.eclipse.wgadesigner.console

Source Code of de.innovationgate.eclipse.wgadesigner.console.TMLWarningPatternMatcher

/*******************************************************************************
* Copyright (c) 2009, 2010 Innovation Gate GmbH.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
*     Innovation Gate GmbH - initial API and implementation
******************************************************************************/
package de.innovationgate.eclipse.wgadesigner.console;

import org.eclipse.debug.ui.console.IConsole;
import org.eclipse.jface.text.IDocument;
import org.eclipse.ui.console.IPatternMatchListenerDelegate;
import org.eclipse.ui.console.PatternMatchEvent;
import org.eclipse.ui.console.TextConsole;

import de.innovationgate.eclipse.wgadesigner.WGADesignerPlugin;
import de.innovationgate.eclipse.wgadesigner.tomcat.TomcatUtils;

public class TMLWarningPatternMatcher implements IPatternMatchListenerDelegate {

  public void connect(TextConsole console) {
  }

  public void disconnect() {
  }

  public void matchFound(PatternMatchEvent event) {
    if (event.getSource() instanceof IConsole) {
      IConsole console = (IConsole)event.getSource();
      if (TomcatUtils.getInstance().isTomcatProcess(console.getProcess())) {
        try {
          // parse TML Warning
          IDocument document = console.getDocument();
          String content = document.get(event.getOffset(), event.getLength());
          TMLWarning warning = TMLWarning.parse(content);
         
          // compute link offset & length
          int linkOffset = event.getOffset();
          int linkLength = event.getLength();
          int linkStart = content.indexOf(" - ");
          if (linkStart != -1) {
            linkStart += " - ".length();
            int linkEnd = content.indexOf(" - ", linkStart);
            if (linkEnd != -1) {
              linkOffset += linkStart;
              linkLength = linkEnd - linkStart;
            }
          }
         
          // add hyperlink
          console.addLink(new TMLWarningHyperLink(warning), linkOffset, linkLength);
        } catch (Exception e) {
          WGADesignerPlugin.getDefault().logError(e.getMessage(), e);
       
      }
    }
  }


}
TOP

Related Classes of de.innovationgate.eclipse.wgadesigner.console.TMLWarningPatternMatcher

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.