Return-Path: X-Original-To: apmail-uima-commits-archive@www.apache.org Delivered-To: apmail-uima-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id B4EF87476 for ; Mon, 1 Aug 2011 14:39:36 +0000 (UTC) Received: (qmail 8867 invoked by uid 500); 1 Aug 2011 14:39:36 -0000 Delivered-To: apmail-uima-commits-archive@uima.apache.org Received: (qmail 8771 invoked by uid 500); 1 Aug 2011 14:39:36 -0000 Mailing-List: contact commits-help@uima.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@uima.apache.org Delivered-To: mailing list commits@uima.apache.org Received: (qmail 8736 invoked by uid 99); 1 Aug 2011 14:39:36 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 01 Aug 2011 14:39:36 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 01 Aug 2011 14:39:31 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 2450A2388A66 for ; Mon, 1 Aug 2011 14:38:48 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: svn commit: r1152804 [6/15] - in /uima/sandbox/trunk/TextMarker: org.apache.uima.tm.dltk.debug.ui/ org.apache.uima.tm.dltk.debug.ui/META-INF/ org.apache.uima.tm.dltk.debug.ui/bin/ org.apache.uima.tm.dltk.debug.ui/icons/ org.apache.uima.tm.dltk.debug.ui... Date: Mon, 01 Aug 2011 14:38:36 -0000 To: commits@uima.apache.org From: joern@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20110801143848.2450A2388A66@eris.apache.org> Added: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.launching/src/main/java/org/apache/uima/tm/dltk/textmarker/internal/launching/TextMarkerInterpreterRunner.java URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.launching/src/main/java/org/apache/uima/tm/dltk/textmarker/internal/launching/TextMarkerInterpreterRunner.java?rev=1152804&view=auto ============================================================================== --- uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.launching/src/main/java/org/apache/uima/tm/dltk/textmarker/internal/launching/TextMarkerInterpreterRunner.java (added) +++ uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.launching/src/main/java/org/apache/uima/tm/dltk/textmarker/internal/launching/TextMarkerInterpreterRunner.java Mon Aug 1 14:37:34 2011 @@ -0,0 +1,349 @@ +package org.apache.uima.tm.dltk.textmarker.internal.launching; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import java.util.logging.Handler; +import java.util.logging.LogRecord; +import java.util.logging.Logger; + +import org.apache.uima.UIMAFramework; +import org.apache.uima.analysis_engine.AnalysisEngine; +import org.apache.uima.cas.CAS; +import org.apache.uima.cas.impl.XmiCasDeserializer; +import org.apache.uima.cas.impl.XmiCasSerializer; +import org.apache.uima.resource.ResourceManager; +import org.apache.uima.resource.ResourceSpecifier; +import org.apache.uima.tm.dltk.internal.core.builder.TextMarkerProjectUtils; +import org.apache.uima.tm.dltk.textmarker.launching.IConfigurableRunner; +import org.apache.uima.tm.dltk.textmarker.launching.ITextMarkerInterpreterRunnerConfig; +import org.apache.uima.tm.dltk.textmarker.launching.TextMarkerLaunchConfigurationConstants; +import org.apache.uima.tm.dltk.textmarker.launching.TextMarkerLaunchingPlugin; +import org.apache.uima.tm.textmarker.action.LogAction; +import org.apache.uima.tm.textmarker.engine.TextMarkerEngine; +import org.apache.uima.util.FileUtils; +import org.apache.uima.util.XMLInputSource; +import org.apache.uima.util.XMLSerializer; +import org.eclipse.core.resources.IFolder; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.NullProgressMonitor; +import org.eclipse.core.runtime.Status; +import org.eclipse.core.runtime.SubProgressMonitor; +import org.eclipse.debug.core.ILaunch; +import org.eclipse.dltk.core.DLTKCore; +import org.eclipse.dltk.core.IScriptProject; +import org.eclipse.dltk.launching.AbstractInterpreterRunner; +import org.eclipse.dltk.launching.AbstractScriptLaunchConfigurationDelegate; +import org.eclipse.dltk.launching.IInterpreterInstall; +import org.eclipse.dltk.launching.InterpreterConfig; +import org.eclipse.dltk.launching.ScriptLaunchConfigurationConstants; +import org.eclipse.jdt.core.IJavaProject; +import org.eclipse.jdt.launching.JavaRuntime; +import org.eclipse.jdt.launching.VMRunnerConfiguration; +import org.eclipse.ui.console.ConsolePlugin; +import org.eclipse.ui.console.IConsole; +import org.eclipse.ui.console.IConsoleManager; +import org.eclipse.ui.console.MessageConsole; +import org.eclipse.ui.console.MessageConsoleStream; +import org.xml.sax.SAXException; + + +public class TextMarkerInterpreterRunner extends AbstractInterpreterRunner implements + IConfigurableRunner { + + public static final ITextMarkerInterpreterRunnerConfig DEFAULT_CONFIG = new ITextMarkerInterpreterRunnerConfig() { + + public void adjustRunnerConfiguration(VMRunnerConfiguration vconfig, InterpreterConfig iconfig, + ILaunch launch, IJavaProject project) { + System.out.println("adjust runner"); + } + + public String[] computeClassPath(InterpreterConfig config, ILaunch launch, IJavaProject project) + throws Exception { + return TextMarkerInterpreterRunner.getClassPath(project); + } + + public String[] getProgramArguments(InterpreterConfig config, ILaunch launch, + IJavaProject project) { + return new String[0]; + } + + public String getRunnerClassName(InterpreterConfig config, ILaunch launch, IJavaProject project) { + return "TextMarkerRunner"; + } + + }; + + private ITextMarkerInterpreterRunnerConfig config = DEFAULT_CONFIG; + + @Override + public void run(InterpreterConfig config, ILaunch launch, IProgressMonitor monitor) + throws CoreException { + doRunImpl(config, launch, this.config, monitor); + } + + private static Handler initConsoleLink(String module) { + final MessageConsole console; + final MessageConsoleStream out; + console = findConsole(module); + out = console.newMessageStream(); + + Handler handler = new Handler() { + + @Override + public void publish(LogRecord record) { + String message = record.getMessage(); + if (message.equals("\\n")) { + out.println(); + } + String[] split = message.split("\\\\n"); + for (String string : split) { + out.println(string); + } + console.activate(); + } + + @Override + public void flush() { + + } + + @Override + public void close() throws SecurityException { + + } + }; + Logger.getLogger(LogAction.LOGGER_NAME).addHandler(handler); + return handler; + } + + private static void clearConsoleLink(Handler handler) { + Logger.getLogger(LogAction.LOGGER_NAME).removeHandler(handler); + } + + private static MessageConsole findConsole(String name) { + ConsolePlugin plugin = ConsolePlugin.getDefault(); + IConsoleManager conMan = plugin.getConsoleManager(); + IConsole[] existing = conMan.getConsoles(); + for (int i = 0; i < existing.length; i++) + if (name.equals(existing[i].getName())) + return (MessageConsole) existing[i]; + MessageConsole myConsole = new MessageConsole(name, null); + conMan.addConsoles(new IConsole[] { myConsole }); + return myConsole; + } + + public static List getFiles(File dir, boolean recusive) { + List result = new ArrayList(); + for (File each : dir.listFiles()) { + // TODO: find a solution for this hotfix + if (each.getName().endsWith(".svn")) { + continue; + } + result.add(each); + if (each.isDirectory() && recusive) { + result.addAll(getFiles(each, recusive)); + } + } + return result; + } + + public static void doRunImpl(InterpreterConfig config, ILaunch launch, + ITextMarkerInterpreterRunnerConfig iconfig, IProgressMonitor monitor) + throws CoreException { + String launchMode = launch.getLaunchMode(); + IScriptProject proj = AbstractScriptLaunchConfigurationDelegate.getScriptProject(launch + .getLaunchConfiguration()); + + IPath projectPath = proj.getResource().getLocation(); + IPath inputDirPath = projectPath.append(TextMarkerProjectUtils.getDefaultInputLocation()); + IPath outputDirPath = projectPath.append(TextMarkerProjectUtils.getDefaultOutputLocation()); + String engine = TextMarkerProjectUtils.getEngineDescriptorPath(config.getScriptFilePath(), + proj.getProject()).toPortableString(); + IPath rootPath = TextMarkerProjectUtils.getDescriptorRootPath(proj.getProject()); + + File inputDir = inputDirPath.makeAbsolute().toFile(); + File outputDir = outputDirPath.makeAbsolute().toFile(); + + List inputFiles = getFiles(inputDir, false); + + int ticks = (inputFiles.size() * 2) + 1; + SubProgressMonitor mon = new SubProgressMonitor(monitor, ticks); + + mon.setTaskName("Initializing"); + Handler handler = initConsoleLink(config.getScriptFilePath().lastSegment()); + + CAS cas = null; + + AnalysisEngine ae = null; + try { + File specFile = new File(engine); + XMLInputSource in = new XMLInputSource(specFile); + ResourceSpecifier specifier = UIMAFramework.getXMLParser().parseResourceSpecifier(in); + ResourceManager resMgr = UIMAFramework.newDefaultResourceManager(); + resMgr.setDataPath(rootPath.toPortableString()); + ae = UIMAFramework.produceAnalysisEngine(specifier, resMgr, null); + } catch (Exception e) { + String message = e.getMessage(); + DLTKCore.error(message, e); + clearConsoleLink(handler); + throw new CoreException(new Status(IStatus.ERROR, TextMarkerLaunchingPlugin.PLUGIN_ID, + ScriptLaunchConfigurationConstants.ERR_INTERNAL_ERROR, message, e)); + } + + AnalysisEngine mae = null; + try { + // modifier + IPath modifierPath = rootPath.append("Modifier.xml"); + File modifierFile = new File(modifierPath.toPortableString()); + if (modifierFile.exists()) { + XMLInputSource min = new XMLInputSource(modifierFile); + ResourceSpecifier mspecifier = UIMAFramework.getXMLParser().parseResourceSpecifier(min); + mae = UIMAFramework.produceAnalysisEngine(mspecifier); + String sml = (String) ae.getConfigParameterValue(TextMarkerEngine.STYLE_MAP); + mae.setConfigParameterValue(TextMarkerEngine.STYLE_MAP, sml); + mae.setConfigParameterValue(TextMarkerEngine.DESCRIPTOR_PATHS, ae + .getConfigParameterValue(TextMarkerEngine.DESCRIPTOR_PATHS)); + mae.reconfigure(); + } + } catch (Exception e) { + String message = e.getMessage(); + DLTKCore.error(message, e); + clearConsoleLink(handler); + throw new CoreException(new Status(IStatus.ERROR, TextMarkerLaunchingPlugin.PLUGIN_ID, + ScriptLaunchConfigurationConstants.ERR_INTERNAL_ERROR, message, e)); + } + try { + if ("debug".equals(launchMode)) { + ae.setConfigParameterValue(TextMarkerEngine.CREATE_DEBUG_INFO, true); + ae.setConfigParameterValue(TextMarkerEngine.CREATE_MATCH_DEBUG_INFO, true); + ae.setConfigParameterValue(TextMarkerEngine.CREATE_PROFILING_INFO, true); + ae.setConfigParameterValue(TextMarkerEngine.CREATE_STATISTIC_INFO, true); + ae.reconfigure(); + } + } catch (Exception e) { + clearConsoleLink(handler); + String message = e.getMessage(); + DLTKCore.error(message, e); + throw new CoreException(new Status(IStatus.ERROR, TextMarkerLaunchingPlugin.PLUGIN_ID, + ScriptLaunchConfigurationConstants.ERR_INTERNAL_ERROR, message, e)); + } + mon.worked(1); + for (File each : inputFiles) { + + mon.setTaskName("Processing " + each.getName()); + try { + if (cas == null) { + cas = ae.newCAS(); + } else { + cas.reset(); + } + if (each.getName().endsWith("xmi")) { + XmiCasDeserializer.deserialize(new FileInputStream(each), cas, true); + } else { + cas.setDocumentText(getText(each)); + } + TextMarkerEngine.removeSourceDocumentInformation(cas); + TextMarkerEngine.addSourceDocumentInformation(cas, each); + + ae.process(cas); + if (mae != null) { + mae.process(cas); + } + mon.worked(1); + File outputFile = new File(outputDir, each.getName() + ".xmi"); + mon.setTaskName("Saving " + outputFile.getName()); + writeXmi(cas, outputFile); + if (mae != null) { + CAS modifiedCas = cas.getView(TextMarkerEngine.MODIFIED_SOFA); + String documentText = modifiedCas.getDocumentText(); + if (documentText != null) { + FileUtils.saveString2File(documentText, new File(outputDir, each.getName() + + ".modified.html")); + } + } + mon.worked(1); + } catch (Exception e) { + if (cas != null) { + cas.release(); + } + clearConsoleLink(handler); + String message = e.getMessage(); + DLTKCore.error(message, e); + throw new CoreException(new Status(IStatus.ERROR, TextMarkerLaunchingPlugin.PLUGIN_ID, + ScriptLaunchConfigurationConstants.ERR_INTERNAL_ERROR, message, e)); + } + } + if (outputDir.listFiles().length == 1) { + // show it...? + } + if (cas != null) { + cas.release(); + } + + IFolder folder = proj.getProject().getFolder(TextMarkerProjectUtils.getDefaultOutputLocation()); + folder.refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor()); + clearConsoleLink(handler); + mon.done(); + } + + private static String getText(File each) { + try { + return org.apache.uima.pear.util.FileUtil.loadTextFile(each, "UTF-8"); + } catch (IOException e) { + DLTKCore.error(e.getMessage(), e); + } + return ""; + } + + private static void writeXmi(CAS aCas, File name) throws IOException, SAXException { + FileOutputStream out = null; + + try { + // write XMI + out = new FileOutputStream(name); + XmiCasSerializer ser = new XmiCasSerializer(aCas.getTypeSystem()); + XMLSerializer xmlSer = new XMLSerializer(out, false); + ser.serialize(aCas, xmlSer.getContentHandler()); + } finally { + if (out != null) { + out.close(); + } + } + } + + public static String[] getClassPath(IJavaProject myJavaProject) { + String[] newClassPath = new String[0];// classPath.length + 2]; + return newClassPath; + } + + protected static String[] computeBaseClassPath(IJavaProject myJavaProject) throws CoreException { + if (!myJavaProject.exists()) + return new String[0]; + return JavaRuntime.computeDefaultRuntimeClassPath(myJavaProject); + } + + protected String constructProgramString(InterpreterConfig config) { + return ""; + } + + public TextMarkerInterpreterRunner(IInterpreterInstall install) { + super(install); + } + + @Override + protected String getProcessType() { + return TextMarkerLaunchConfigurationConstants.ID_TM_PROCESS_TYPE; + } + + public void setRunnerConfig(ITextMarkerInterpreterRunnerConfig config) { + this.config = config; + } +} Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.launching/src/main/java/org/apache/uima/tm/dltk/textmarker/internal/launching/TextMarkerInterpreterRunner.java ------------------------------------------------------------------------------ svn:executable = * Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.launching/src/main/java/org/apache/uima/tm/dltk/textmarker/internal/launching/TextMarkerInterpreterRunner.java ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.launching/src/main/java/org/apache/uima/tm/dltk/textmarker/internal/launching/builtins.tm URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.launching/src/main/java/org/apache/uima/tm/dltk/textmarker/internal/launching/builtins.tm?rev=1152804&view=auto ============================================================================== --- uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.launching/src/main/java/org/apache/uima/tm/dltk/textmarker/internal/launching/builtins.tm (added) +++ uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.launching/src/main/java/org/apache/uima/tm/dltk/textmarker/internal/launching/builtins.tm Mon Aug 1 14:37:34 2011 @@ -0,0 +1 @@ +PACKAGE org.apache.uima.tm; \ No newline at end of file Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.launching/src/main/java/org/apache/uima/tm/dltk/textmarker/internal/launching/builtins.tm ------------------------------------------------------------------------------ svn:executable = * Added: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.launching/src/main/java/org/apache/uima/tm/dltk/textmarker/launching/IConfigurableRunner.java URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.launching/src/main/java/org/apache/uima/tm/dltk/textmarker/launching/IConfigurableRunner.java?rev=1152804&view=auto ============================================================================== --- uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.launching/src/main/java/org/apache/uima/tm/dltk/textmarker/launching/IConfigurableRunner.java (added) +++ uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.launching/src/main/java/org/apache/uima/tm/dltk/textmarker/launching/IConfigurableRunner.java Mon Aug 1 14:37:34 2011 @@ -0,0 +1,6 @@ +package org.apache.uima.tm.dltk.textmarker.launching; + +public interface IConfigurableRunner { + + public void setRunnerConfig(ITextMarkerInterpreterRunnerConfig config); +} Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.launching/src/main/java/org/apache/uima/tm/dltk/textmarker/launching/IConfigurableRunner.java ------------------------------------------------------------------------------ svn:executable = * Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.launching/src/main/java/org/apache/uima/tm/dltk/textmarker/launching/IConfigurableRunner.java ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.launching/src/main/java/org/apache/uima/tm/dltk/textmarker/launching/ITextMarkerInterpreterRunnerConfig.java URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.launching/src/main/java/org/apache/uima/tm/dltk/textmarker/launching/ITextMarkerInterpreterRunnerConfig.java?rev=1152804&view=auto ============================================================================== --- uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.launching/src/main/java/org/apache/uima/tm/dltk/textmarker/launching/ITextMarkerInterpreterRunnerConfig.java (added) +++ uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.launching/src/main/java/org/apache/uima/tm/dltk/textmarker/launching/ITextMarkerInterpreterRunnerConfig.java Mon Aug 1 14:37:34 2011 @@ -0,0 +1,19 @@ +package org.apache.uima.tm.dltk.textmarker.launching; + +import org.eclipse.debug.core.ILaunch; +import org.eclipse.dltk.launching.InterpreterConfig; +import org.eclipse.jdt.core.IJavaProject; +import org.eclipse.jdt.launching.VMRunnerConfiguration; + +public interface ITextMarkerInterpreterRunnerConfig { + + public String getRunnerClassName(InterpreterConfig config, ILaunch launch, IJavaProject project); + + public String[] computeClassPath(InterpreterConfig config, ILaunch launch, IJavaProject project) + throws Exception; + + public String[] getProgramArguments(InterpreterConfig config, ILaunch launch, IJavaProject project); + + public void adjustRunnerConfiguration(VMRunnerConfiguration vconfig, InterpreterConfig iconfig, + ILaunch launch, IJavaProject project); +} Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.launching/src/main/java/org/apache/uima/tm/dltk/textmarker/launching/ITextMarkerInterpreterRunnerConfig.java ------------------------------------------------------------------------------ svn:executable = * Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.launching/src/main/java/org/apache/uima/tm/dltk/textmarker/launching/ITextMarkerInterpreterRunnerConfig.java ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.launching/src/main/java/org/apache/uima/tm/dltk/textmarker/launching/TextMarkerDebuggingEngineSelector.java URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.launching/src/main/java/org/apache/uima/tm/dltk/textmarker/launching/TextMarkerDebuggingEngineSelector.java?rev=1152804&view=auto ============================================================================== --- uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.launching/src/main/java/org/apache/uima/tm/dltk/textmarker/launching/TextMarkerDebuggingEngineSelector.java (added) +++ uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.launching/src/main/java/org/apache/uima/tm/dltk/textmarker/launching/TextMarkerDebuggingEngineSelector.java Mon Aug 1 14:37:34 2011 @@ -0,0 +1,16 @@ +package org.apache.uima.tm.dltk.textmarker.launching; + +import org.apache.uima.tm.dltk.internal.debug.TextMarkerDebugConstants; +import org.apache.uima.tm.dltk.internal.debug.TextMarkerDebugPlugin; +import org.eclipse.dltk.core.DLTKIdContributionSelector; +import org.eclipse.dltk.core.PreferencesLookupDelegate; + + +public class TextMarkerDebuggingEngineSelector extends DLTKIdContributionSelector { + @Override + protected String getSavedContributionId(PreferencesLookupDelegate delegate) { + return delegate.getString(TextMarkerDebugPlugin.PLUGIN_ID, + TextMarkerDebugConstants.DEBUGGING_ENGINE_ID_KEY); + } + +} Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.launching/src/main/java/org/apache/uima/tm/dltk/textmarker/launching/TextMarkerDebuggingEngineSelector.java ------------------------------------------------------------------------------ svn:executable = * Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.launching/src/main/java/org/apache/uima/tm/dltk/textmarker/launching/TextMarkerDebuggingEngineSelector.java ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.launching/src/main/java/org/apache/uima/tm/dltk/textmarker/launching/TextMarkerLaunchConfigurationConstants.java URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.launching/src/main/java/org/apache/uima/tm/dltk/textmarker/launching/TextMarkerLaunchConfigurationConstants.java?rev=1152804&view=auto ============================================================================== --- uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.launching/src/main/java/org/apache/uima/tm/dltk/textmarker/launching/TextMarkerLaunchConfigurationConstants.java (added) +++ uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.launching/src/main/java/org/apache/uima/tm/dltk/textmarker/launching/TextMarkerLaunchConfigurationConstants.java Mon Aug 1 14:37:34 2011 @@ -0,0 +1,13 @@ +package org.apache.uima.tm.dltk.textmarker.launching; + +import org.eclipse.dltk.launching.ScriptLaunchConfigurationConstants; + +public class TextMarkerLaunchConfigurationConstants extends ScriptLaunchConfigurationConstants { + protected TextMarkerLaunchConfigurationConstants() { + + } + + public static final String ID_TM_SCRIPT = "org.apache.uima.tm.dltk.launching.TextMarkerLaunchConfigurationType"; //$NON-NLS-1$ + + public static final String ID_TM_PROCESS_TYPE = "textmarkerInterpreter"; //$NON-NLS-1$ +} Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.launching/src/main/java/org/apache/uima/tm/dltk/textmarker/launching/TextMarkerLaunchConfigurationConstants.java ------------------------------------------------------------------------------ svn:executable = * Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.launching/src/main/java/org/apache/uima/tm/dltk/textmarker/launching/TextMarkerLaunchConfigurationConstants.java ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.launching/src/main/java/org/apache/uima/tm/dltk/textmarker/launching/TextMarkerLaunchConfigurationDelegate.java URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.launching/src/main/java/org/apache/uima/tm/dltk/textmarker/launching/TextMarkerLaunchConfigurationDelegate.java?rev=1152804&view=auto ============================================================================== --- uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.launching/src/main/java/org/apache/uima/tm/dltk/textmarker/launching/TextMarkerLaunchConfigurationDelegate.java (added) +++ uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.launching/src/main/java/org/apache/uima/tm/dltk/textmarker/launching/TextMarkerLaunchConfigurationDelegate.java Mon Aug 1 14:37:34 2011 @@ -0,0 +1,37 @@ +package org.apache.uima.tm.dltk.textmarker.launching; + +import org.apache.uima.tm.dltk.core.TextMarkerNature; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.debug.core.ILaunch; +import org.eclipse.debug.core.ILaunchConfiguration; +import org.eclipse.dltk.launching.AbstractScriptLaunchConfigurationDelegate; +import org.eclipse.dltk.launching.IInterpreterRunner; +import org.eclipse.dltk.launching.InterpreterConfig; + + +public class TextMarkerLaunchConfigurationDelegate extends + AbstractScriptLaunchConfigurationDelegate { + + @Override + protected void runRunner(ILaunchConfiguration configuration, IInterpreterRunner runner, + InterpreterConfig config, ILaunch launch, IProgressMonitor monitor) throws CoreException { + if (runner instanceof IConfigurableRunner) { + ITextMarkerInterpreterRunnerConfig runnerConfig = getConfig(); + if (runnerConfig != null) { + IConfigurableRunner rc = (IConfigurableRunner) runner; + rc.setRunnerConfig(runnerConfig); + } + } + runner.run(config, launch, monitor); + } + + public ITextMarkerInterpreterRunnerConfig getConfig() { + return null; + } + + @Override + public String getLanguageId() { + return TextMarkerNature.NATURE_ID; + } +} Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.launching/src/main/java/org/apache/uima/tm/dltk/textmarker/launching/TextMarkerLaunchConfigurationDelegate.java ------------------------------------------------------------------------------ svn:executable = * Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.launching/src/main/java/org/apache/uima/tm/dltk/textmarker/launching/TextMarkerLaunchConfigurationDelegate.java ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.launching/src/main/java/org/apache/uima/tm/dltk/textmarker/launching/TextMarkerLaunchingPlugin.java URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.launching/src/main/java/org/apache/uima/tm/dltk/textmarker/launching/TextMarkerLaunchingPlugin.java?rev=1152804&view=auto ============================================================================== --- uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.launching/src/main/java/org/apache/uima/tm/dltk/textmarker/launching/TextMarkerLaunchingPlugin.java (added) +++ uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.launching/src/main/java/org/apache/uima/tm/dltk/textmarker/launching/TextMarkerLaunchingPlugin.java Mon Aug 1 14:37:34 2011 @@ -0,0 +1,49 @@ +package org.apache.uima.tm.dltk.textmarker.launching; + +import java.io.IOException; + +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.Plugin; +import org.eclipse.dltk.core.environment.IDeployment; +import org.eclipse.dltk.core.environment.IExecutionEnvironment; +import org.eclipse.dltk.core.environment.IFileHandle; +import org.osgi.framework.BundleContext; + +public class TextMarkerLaunchingPlugin extends Plugin { + + public static final String PLUGIN_ID = "org.apache.uima.tm.dltk.launching"; + + private static TextMarkerLaunchingPlugin plugin; + + public TextMarkerLaunchingPlugin() { + plugin = this; + } + + @Override + public void start(BundleContext context) throws Exception { + super.start(context); + } + + @Override + public void stop(BundleContext context) throws Exception { + plugin = null; + super.stop(context); + } + + public static TextMarkerLaunchingPlugin getDefault() { + return plugin; + } + + public static String getUniqueIdentifier() { + return PLUGIN_ID; + } + + public IFileHandle getConsoleProxy(IExecutionEnvironment exeEnv) throws IOException { + IDeployment deployment = exeEnv.createDeployment(); + IPath path = deployment.add(this.getBundle(), "console"); + path.append("ConsoleProxy.js"); + return deployment.getFile(path); + + } + +} \ No newline at end of file Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.launching/src/main/java/org/apache/uima/tm/dltk/textmarker/launching/TextMarkerLaunchingPlugin.java ------------------------------------------------------------------------------ svn:executable = * Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.launching/src/main/java/org/apache/uima/tm/dltk/textmarker/launching/TextMarkerLaunchingPlugin.java ------------------------------------------------------------------------------ svn:mime-type = text/plain Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.testing/ ------------------------------------------------------------------------------ --- svn:ignore (added) +++ svn:ignore Mon Aug 1 14:37:34 2011 @@ -0,0 +1 @@ +.settings Added: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.testing/.classpath URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.testing/.classpath?rev=1152804&view=auto ============================================================================== --- uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.testing/.classpath (added) +++ uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.testing/.classpath Mon Aug 1 14:37:34 2011 @@ -0,0 +1,7 @@ + + + + + + + Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.testing/.classpath ------------------------------------------------------------------------------ svn:executable = * Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.testing/.classpath ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.testing/.project URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.testing/.project?rev=1152804&view=auto ============================================================================== --- uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.testing/.project (added) +++ uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.testing/.project Mon Aug 1 14:37:34 2011 @@ -0,0 +1,28 @@ + + + org.apache.uima.tm.dltk.testing + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.pde.ManifestBuilder + + + + + org.eclipse.pde.SchemaBuilder + + + + + + org.eclipse.pde.PluginNature + org.eclipse.jdt.core.javanature + + Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.testing/.project ------------------------------------------------------------------------------ svn:executable = * Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.testing/.project ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.testing/META-INF/MANIFEST.MF URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.testing/META-INF/MANIFEST.MF?rev=1152804&view=auto ============================================================================== --- uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.testing/META-INF/MANIFEST.MF (added) +++ uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.testing/META-INF/MANIFEST.MF Mon Aug 1 14:37:34 2011 @@ -0,0 +1,34 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: TextMarker DLTK Testing Plugin +Bundle-SymbolicName: org.apache.uima.tm.dltk.testing;singleton:=true +Bundle-Version: 1.0.0.qualifier +Bundle-Localization: plugin +Require-Bundle: org.eclipse.ui, + org.eclipse.core.runtime, + org.eclipse.ui.views, + org.eclipse.dltk.testing;bundle-version="[1.0.0,2.0.0)", + org.eclipse.debug.core, + org.eclipse.debug.ui, + org.eclipse.ui, + org.eclipse.core.runtime, + org.eclipse.core.expressions, + org.eclipse.core.variables, + org.eclipse.dltk.core;bundle-version="[1.0.0,2.0.0)", + org.eclipse.dltk.debug;bundle-version="[1.0.0,2.0.0)", + org.eclipse.dltk.debug.ui;bundle-version="[1.0.0,2.0.0)", + org.eclipse.dltk.ui;bundle-version="[1.0.0,2.0.0)", + org.eclipse.dltk.launching;bundle-version="[1.0.0,2.0.0)", + org.apache.uima.tm.dltk.core, + org.eclipse.ui.ide, + org.apache.uima.tm.dltk.debug, + org.apache.uima.tm.dltk.debug.ui, + org.apache.uima.tm.dltk.launching, + org.eclipse.ui.console, + org.eclipse.jface.text, + org.apache.uima.tm.dltk.antlr, + org.apache.uima.tm.textmarker.engine +Bundle-Activator: org.apache.uima.tm.dltk.internal.testing.TextMarkerTestingPlugin +Bundle-ActivationPolicy: lazy +Bundle-RequiredExecutionEnvironment: JavaSE-1.6 +Bundle-Vendor: University of Würzburg Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.testing/META-INF/MANIFEST.MF ------------------------------------------------------------------------------ svn:executable = * Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.testing/META-INF/MANIFEST.MF ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.testing/build.properties URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.testing/build.properties?rev=1152804&view=auto ============================================================================== --- uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.testing/build.properties (added) +++ uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.testing/build.properties Mon Aug 1 14:37:34 2011 @@ -0,0 +1,7 @@ +source.. = src/ +output.. = bin/ +bin.includes = META-INF/,\ + .,\ + plugin.xml,\ + icons/,\ + plugin.properties Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.testing/build.properties ------------------------------------------------------------------------------ svn:executable = * Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.testing/build.properties ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.testing/icons/full/eview16/xuniterr.gif URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.testing/icons/full/eview16/xuniterr.gif?rev=1152804&view=auto ============================================================================== Binary file - no diff available. Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.testing/icons/full/eview16/xuniterr.gif ------------------------------------------------------------------------------ svn:executable = * Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.testing/icons/full/eview16/xuniterr.gif ------------------------------------------------------------------------------ svn:mime-type = application/octet-stream Added: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.testing/icons/full/eview16/xuniterrq.gif URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.testing/icons/full/eview16/xuniterrq.gif?rev=1152804&view=auto ============================================================================== Binary file - no diff available. Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.testing/icons/full/eview16/xuniterrq.gif ------------------------------------------------------------------------------ svn:executable = * Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.testing/icons/full/eview16/xuniterrq.gif ------------------------------------------------------------------------------ svn:mime-type = application/octet-stream Added: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.testing/icons/full/eview16/xunitsucc.gif URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.testing/icons/full/eview16/xunitsucc.gif?rev=1152804&view=auto ============================================================================== Binary file - no diff available. Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.testing/icons/full/eview16/xunitsucc.gif ------------------------------------------------------------------------------ svn:executable = * Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.testing/icons/full/eview16/xunitsucc.gif ------------------------------------------------------------------------------ svn:mime-type = application/octet-stream Added: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.testing/icons/full/eview16/xunitsuccq.gif URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.testing/icons/full/eview16/xunitsuccq.gif?rev=1152804&view=auto ============================================================================== Binary file - no diff available. Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.testing/icons/full/eview16/xunitsuccq.gif ------------------------------------------------------------------------------ svn:executable = * Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.testing/icons/full/eview16/xunitsuccq.gif ------------------------------------------------------------------------------ svn:mime-type = application/octet-stream Added: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.testing/icons/full/obj16/textmarker.png URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.testing/icons/full/obj16/textmarker.png?rev=1152804&view=auto ============================================================================== Binary file - no diff available. Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.testing/icons/full/obj16/textmarker.png ------------------------------------------------------------------------------ svn:executable = * Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.testing/icons/full/obj16/textmarker.png ------------------------------------------------------------------------------ svn:mime-type = application/octet-stream Added: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.testing/plugin.properties URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.testing/plugin.properties?rev=1152804&view=auto ============================================================================== --- uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.testing/plugin.properties (added) +++ uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.testing/plugin.properties Mon Aug 1 14:37:34 2011 @@ -0,0 +1,5 @@ +pluginName=Dynamic Laguages Toolkit TextMarker testing support +providerName=Eclipse.org + +TextMarkerLaunchShortcut.name = TextMarker Testing +TextMarkerLaunchShortcut.description = TextMarker Testing \ No newline at end of file Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.testing/plugin.properties ------------------------------------------------------------------------------ svn:executable = * Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.testing/plugin.properties ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.testing/plugin.xml URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.testing/plugin.xml?rev=1152804&view=auto ============================================================================== --- uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.testing/plugin.xml (added) +++ uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.testing/plugin.xml Mon Aug 1 14:37:34 2011 @@ -0,0 +1,93 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.testing/plugin.xml ------------------------------------------------------------------------------ svn:executable = * Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.testing/plugin.xml ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.testing/schema/tmTestEngine.exsd URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.testing/schema/tmTestEngine.exsd?rev=1152804&view=auto ============================================================================== --- uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.testing/schema/tmTestEngine.exsd (added) +++ uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.testing/schema/tmTestEngine.exsd Mon Aug 1 14:37:34 2011 @@ -0,0 +1,119 @@ + + + + + + + + + [Enter description of this extension point.] + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + [Enter the first release in which this extension point appears.] + + + + + + + + + [Enter extension point usage example here.] + + + + + + + + + [Enter API information here.] + + + + + + + + + [Enter information about supplied implementation of this extension point.] + + + + + + + + + + + + + Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.testing/schema/tmTestEngine.exsd ------------------------------------------------------------------------------ svn:executable = * Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.testing/schema/tmTestEngine.exsd ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.testing/scripts/tmtestEngine.tm URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.testing/scripts/tmtestEngine.tm?rev=1152804&view=auto ============================================================================== (empty) Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.testing/scripts/tmtestEngine.tm ------------------------------------------------------------------------------ svn:executable = * Added: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.testing/src/main/java/org/apache/uima/tm/dltk/internal/testing/TextMarkerOutputProcessor.java URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.testing/src/main/java/org/apache/uima/tm/dltk/internal/testing/TextMarkerOutputProcessor.java?rev=1152804&view=auto ============================================================================== --- uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.testing/src/main/java/org/apache/uima/tm/dltk/internal/testing/TextMarkerOutputProcessor.java (added) +++ uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.testing/src/main/java/org/apache/uima/tm/dltk/internal/testing/TextMarkerOutputProcessor.java Mon Aug 1 14:37:34 2011 @@ -0,0 +1,66 @@ +package org.apache.uima.tm.dltk.internal.testing; + +import org.eclipse.debug.core.ILaunch; +import org.eclipse.dltk.testing.DLTKTestingPlugin; +import org.eclipse.dltk.testing.ITestingClient; +import org.eclipse.dltk.testing.ITestingProcessor; +import org.eclipse.dltk.testing.model.ITestRunSession; + +class TextMarkerOutputProcessor implements ITestingProcessor { + private ILaunch launch; + + public TextMarkerOutputProcessor(ILaunch launch) { + this.launch = launch; + } + + public void done() { + client.testTerminated(0); + } + + static int i = 0; + + private ITestRunSession session; + + private ITestingClient client; + + public void processLine(String line) { + + // System.out.println("#" + line); + if (line.length() == 0) { + return; + } + final String name = line; + + int id = ++i; + client.testTree(id, name, false, 0); + client.testStarted(id, name); + // client.receiveMessage(MessageIds.TRACE_START); + // client.receiveMessage("This is Trace"); + // client.receiveMessage(MessageIds.TRACE_END); + session.setTotalCount(id); + if (i % 3 == 0) { + client.testFailed(id, name); + client.traceMessage("This is trace"); + } else if (i % 4 == 0) { + client.testError(id, name); + client.traceMessage("This is trace"); + } else { + client.testEnded(id, name); + } + // client.receiveMessage(MessageIds.TEST_END + name + "," + // + name); + + } + + public void start() { + i = 0; + session = DLTKTestingPlugin.getTestRunSession(launch); + if (session == null) + return; + + client = session.getTestRunnerClient(); + + client.testRunStart(100); + + } +} \ No newline at end of file Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.testing/src/main/java/org/apache/uima/tm/dltk/internal/testing/TextMarkerOutputProcessor.java ------------------------------------------------------------------------------ svn:executable = * Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.testing/src/main/java/org/apache/uima/tm/dltk/internal/testing/TextMarkerOutputProcessor.java ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.testing/src/main/java/org/apache/uima/tm/dltk/internal/testing/TextMarkerTestingEngineManager.java URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.testing/src/main/java/org/apache/uima/tm/dltk/internal/testing/TextMarkerTestingEngineManager.java?rev=1152804&view=auto ============================================================================== --- uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.testing/src/main/java/org/apache/uima/tm/dltk/internal/testing/TextMarkerTestingEngineManager.java (added) +++ uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.testing/src/main/java/org/apache/uima/tm/dltk/internal/testing/TextMarkerTestingEngineManager.java Mon Aug 1 14:37:34 2011 @@ -0,0 +1,20 @@ +package org.apache.uima.tm.dltk.internal.testing; + +import org.apache.uima.tm.dltk.testing.ITextMarkerTestingEngine; +import org.eclipse.dltk.core.PriorityClassDLTKExtensionManager; +import org.eclipse.dltk.core.PriorityDLTKExtensionManager.ElementInfo; + + +public final class TextMarkerTestingEngineManager { + private static PriorityClassDLTKExtensionManager manager = new PriorityClassDLTKExtensionManager( + TextMarkerTestingPlugin.PLUGIN_ID + ".tmTestEngine", "id"); + + public static ITextMarkerTestingEngine[] getEngines() { + ElementInfo[] elementInfos = manager.getElementInfos(); + ITextMarkerTestingEngine[] engines = new ITextMarkerTestingEngine[elementInfos.length]; + for (int i = 0; i < elementInfos.length; i++) { + engines[i] = (ITextMarkerTestingEngine) manager.getInitObject(elementInfos[i]); + } + return engines; + } +} Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.testing/src/main/java/org/apache/uima/tm/dltk/internal/testing/TextMarkerTestingEngineManager.java ------------------------------------------------------------------------------ svn:executable = * Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.testing/src/main/java/org/apache/uima/tm/dltk/internal/testing/TextMarkerTestingEngineManager.java ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.testing/src/main/java/org/apache/uima/tm/dltk/internal/testing/TextMarkerTestingLaunchConfigurationDelegate.java URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.testing/src/main/java/org/apache/uima/tm/dltk/internal/testing/TextMarkerTestingLaunchConfigurationDelegate.java?rev=1152804&view=auto ============================================================================== --- uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.testing/src/main/java/org/apache/uima/tm/dltk/internal/testing/TextMarkerTestingLaunchConfigurationDelegate.java (added) +++ uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.testing/src/main/java/org/apache/uima/tm/dltk/internal/testing/TextMarkerTestingLaunchConfigurationDelegate.java Mon Aug 1 14:37:34 2011 @@ -0,0 +1,49 @@ +package org.apache.uima.tm.dltk.internal.testing; + +import org.apache.uima.tm.dltk.testing.ITextMarkerTestingEngine; +import org.apache.uima.tm.dltk.textmarker.launching.TextMarkerLaunchConfigurationDelegate; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.debug.core.ILaunch; +import org.eclipse.debug.core.ILaunchConfiguration; +import org.eclipse.debug.core.model.ILaunchConfigurationDelegate; +import org.eclipse.dltk.compiler.util.Util; +import org.eclipse.dltk.launching.IInterpreterRunner; +import org.eclipse.dltk.launching.InterpreterConfig; +import org.eclipse.dltk.testing.DLTKTestingConstants; +import org.eclipse.dltk.testing.DLTKTestingCore; + + +public class TextMarkerTestingLaunchConfigurationDelegate extends + TextMarkerLaunchConfigurationDelegate implements ILaunchConfigurationDelegate { + private ITextMarkerTestingEngine engine; + + @Override + protected InterpreterConfig createInterpreterConfig(ILaunchConfiguration configuration, + ILaunch launch) throws CoreException { + // We need to create correct execute script for this element. + InterpreterConfig config = super.createInterpreterConfig(configuration, launch); + ITextMarkerTestingEngine[] engines = TextMarkerTestingEngineManager.getEngines(); + String engineId = configuration.getAttribute(DLTKTestingConstants.ATTR_ENGINE_ID, + Util.EMPTY_STRING); + for (int i = 0; i < engines.length; i++) { + if (engines[i].getId().equals(engineId)) { + engines[i].correctLaunchConfiguration(config, configuration); + this.engine = engines[i]; + break; + } + } + return config; + } + + @Override + protected void runRunner(ILaunchConfiguration configuration, IInterpreterRunner runner, + InterpreterConfig config, ILaunch launch, IProgressMonitor monitor) throws CoreException { + + if (engine != null) { + DLTKTestingCore.registerTestingProcessor(launch, engine.getProcessor(launch)); + } + + super.runRunner(configuration, runner, config, launch, monitor); + } +} Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.testing/src/main/java/org/apache/uima/tm/dltk/internal/testing/TextMarkerTestingLaunchConfigurationDelegate.java ------------------------------------------------------------------------------ svn:executable = * Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.testing/src/main/java/org/apache/uima/tm/dltk/internal/testing/TextMarkerTestingLaunchConfigurationDelegate.java ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.testing/src/main/java/org/apache/uima/tm/dltk/internal/testing/TextMarkerTestingLaunchShortcut.java URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.testing/src/main/java/org/apache/uima/tm/dltk/internal/testing/TextMarkerTestingLaunchShortcut.java?rev=1152804&view=auto ============================================================================== --- uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.testing/src/main/java/org/apache/uima/tm/dltk/internal/testing/TextMarkerTestingLaunchShortcut.java (added) +++ uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.testing/src/main/java/org/apache/uima/tm/dltk/internal/testing/TextMarkerTestingLaunchShortcut.java Mon Aug 1 14:37:34 2011 @@ -0,0 +1,385 @@ +package org.apache.uima.tm.dltk.internal.testing; + +import java.util.ArrayList; +import java.util.List; + +import org.apache.uima.tm.dltk.core.TextMarkerNature; +import org.apache.uima.tm.dltk.testing.ITextMarkerTestingEngine; +import org.eclipse.core.resources.IFolder; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IAdaptable; +import org.eclipse.core.runtime.IPath; +import org.eclipse.debug.core.DebugPlugin; +import org.eclipse.debug.core.ILaunchConfiguration; +import org.eclipse.debug.core.ILaunchConfigurationType; +import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; +import org.eclipse.debug.core.ILaunchManager; +import org.eclipse.debug.ui.DebugUITools; +import org.eclipse.debug.ui.IDebugModelPresentation; +import org.eclipse.debug.ui.IDebugUIConstants; +import org.eclipse.debug.ui.ILaunchShortcut; +import org.eclipse.dltk.core.IMethod; +import org.eclipse.dltk.core.IModelElement; +import org.eclipse.dltk.core.IScriptProject; +import org.eclipse.dltk.core.ISourceModule; +import org.eclipse.dltk.core.IType; +import org.eclipse.dltk.internal.testing.util.ExceptionHandler; +import org.eclipse.dltk.launching.ScriptLaunchConfigurationConstants; +import org.eclipse.dltk.testing.DLTKTestingConstants; +import org.eclipse.dltk.ui.DLTKUIPlugin; +import org.eclipse.dltk.ui.ModelElementLabelProvider; +import org.eclipse.dltk.ui.ScriptElementLabels; +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.jface.window.Window; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.ui.IEditorPart; +import org.eclipse.ui.dialogs.ElementListSelectionDialog; + + +public class TextMarkerTestingLaunchShortcut implements ILaunchShortcut { + + private static final String EMPTY_STRING = ""; //$NON-NLS-1$ + + /** + * Default constructor. + */ + public TextMarkerTestingLaunchShortcut() { + } + + /* + * (non-Javadoc) + * + * @see de.uniwue.debug.ui.ILaunchShortcut#launch(de.uniwue.ui.IEditorPart, java.lang.String) + */ + public void launch(IEditorPart editor, String mode) { + IModelElement element = DLTKUIPlugin.getEditorInputModelElement(editor.getEditorInput()); + if (element != null) { + launch(new Object[] { element }, mode); + } else { + showNoTestsFoundDialog(); + } + } + + /* + * (non-Javadoc) + * + * @see de.uniwue.debug.ui.ILaunchShortcut#launch(de.uniwue.jface.viewers.ISelection, + * java.lang.String) + */ + public void launch(ISelection selection, String mode) { + if (selection instanceof IStructuredSelection) { + launch(((IStructuredSelection) selection).toArray(), mode); + } else { + showNoTestsFoundDialog(); + } + } + + private void launch(Object[] elements, String mode) { + try { + IModelElement elementToLaunch = null; + + if (elements.length == 1) { + Object selected = elements[0]; + if (selected instanceof IFolder) { + performLaunch((IFolder) selected, mode); + return; + } + if (!(selected instanceof IModelElement) && selected instanceof IAdaptable) { + selected = ((IAdaptable) selected).getAdapter(IModelElement.class); + } + if (selected instanceof IModelElement) { + IModelElement element = (IModelElement) selected; + switch (element.getElementType()) { + case IModelElement.SCRIPT_PROJECT: { + IProject project = ((IScriptProject) element).getProject(); + IFolder specFolder = project.getFolder("test"); + if (specFolder != null && specFolder.exists()) { + performLaunch(specFolder, mode); + return; + } + } + break; + case IModelElement.PROJECT_FRAGMENT: + case IModelElement.SCRIPT_FOLDER: { + performLaunch((IFolder) element.getResource(), mode); + return; + } + case IModelElement.SOURCE_MODULE: + case IModelElement.METHOD: + elementToLaunch = element; + break; + } + } + } + if (elementToLaunch == null) { + showNoTestsFoundDialog(); + return; + } + performLaunch(elementToLaunch, mode); + } catch (InterruptedException e) { + // OK, silently move on + } catch (CoreException e) { + ExceptionHandler.handle(e, getShell(), "XUnit Launch", + "Launching of XUnit tests unexpectedly failed. Check log for details."); + } + } + + private void showNoTestsFoundDialog() { + MessageDialog.openInformation(getShell(), "XUnit Launch", "No XUnit tests found."); + } + + private void performLaunch(IModelElement element, String mode) throws InterruptedException, + CoreException { + ILaunchConfigurationWorkingCopy temparary = createLaunchConfiguration(element); + if (temparary == null) { + return; + } + ILaunchConfiguration config = findExistingLaunchConfiguration(temparary, mode); + if (config == null) { + // no existing found: create a new one + config = temparary.doSave(); + } + DebugUITools.launch(config, mode); + } + + private void performLaunch(IFolder folder, String mode) throws InterruptedException, + CoreException { + String name = folder.getName(); + String testName = name.substring(name.lastIndexOf(IPath.SEPARATOR) + 1); + + ILaunchConfigurationType configType = getLaunchManager().getLaunchConfigurationType( + getLaunchConfigurationTypeId()); + ILaunchConfigurationWorkingCopy wc = configType.newInstance(null, getLaunchManager() + .generateUniqueLaunchConfigurationNameFrom(testName)); + + wc.setAttribute(ScriptLaunchConfigurationConstants.ATTR_PROJECT_NAME, folder.getProject() + .getName()); + + // wc.setAttribute(ScriptLaunchConfigurationConstants.ATTR_TEST_NAME, EMPTY_STRING); + // wc.setAttribute(ScriptLaunchConfigurationConstants.ATTR_CONTAINER_PATH, + // folder.getFullPath().toPortableString()); + // wc.setAttribute(ScriptLaunchConfigurationConstants.ATTR_TEST_ELEMENT_NAME, EMPTY_STRING); + + ILaunchConfiguration config = findExistingLaunchConfiguration(wc, mode); + if (config == null) { + // no existing found: create a new one + config = wc.doSave(); + } + DebugUITools.launch(config, mode); + } + + private IType chooseType(IType[] types, String mode) throws InterruptedException { + ElementListSelectionDialog dialog = new ElementListSelectionDialog(getShell(), + new ModelElementLabelProvider(ModelElementLabelProvider.SHOW_POST_QUALIFIED)); + dialog.setElements(types); + dialog.setTitle("Test Selection"); + if (mode.equals(ILaunchManager.DEBUG_MODE)) { + dialog.setMessage("Select Test to debug"); + } else { + dialog.setMessage("Select Test to run"); + } + dialog.setMultipleSelection(false); + if (dialog.open() == Window.OK) { + return (IType) dialog.getFirstResult(); + } + throw new InterruptedException(); // cancelled by user + } + + private Shell getShell() { + return DLTKUIPlugin.getActiveWorkbenchShell(); + } + + private ILaunchManager getLaunchManager() { + return DebugPlugin.getDefault().getLaunchManager(); + } + + /** + * Show a selection dialog that allows the user to choose one of the specified launch + * configurations. Return the chosen config, or null if the user cancelled the + * dialog. + * + * @param configList + * @param mode + * @return ILaunchConfiguration + * @throws InterruptedException + */ + private ILaunchConfiguration chooseConfiguration(List configList, String mode) + throws InterruptedException { + IDebugModelPresentation labelProvider = DebugUITools.newDebugModelPresentation(); + ElementListSelectionDialog dialog = new ElementListSelectionDialog(getShell(), labelProvider); + dialog.setElements(configList.toArray()); + dialog.setTitle("Select a Test Configuration"); + if (mode.equals(ILaunchManager.DEBUG_MODE)) { + dialog.setMessage("Select configuration to debug"); + } else { + dialog.setMessage("Select configuration to run"); + } + dialog.setMultipleSelection(false); + int result = dialog.open(); + if (result == Window.OK) { + return (ILaunchConfiguration) dialog.getFirstResult(); + } + throw new InterruptedException(); // cancelled by user + } + + /** + * Returns the launch configuration type id of the launch configuration this shortcut will create. + * Clients can override this method to return the id of their launch configuration. + * + * @return the launch configuration type id of the launch configuration this shortcut will create + */ + protected String getLaunchConfigurationTypeId() { + return "org.apache.uima.tm.dltk.testing.launchConfig"; + } + + /** + * Creates a launch configuration working copy for the given element. The launch configuration + * type created will be of the type returned by {@link #getLaunchConfigurationTypeId}. The element + * type can only be of type {@link IJavaProject}, {@link IPackageFragmentRoot}, + * {@link IPackageFragment}, {@link IType} or {@link IMethod}. + * + * Clients can extend this method (should call super) to configure additional attributes on the + * launch configuration working copy. + * + * @return a launch configuration working copy for the given element + */ + protected ILaunchConfigurationWorkingCopy createLaunchConfiguration(IModelElement element) + throws CoreException { + String testFileName; + String containerHandleId; + String testElementName; + + String name = ScriptElementLabels.getDefault().getTextLabel(element, + ScriptElementLabels.F_FULLY_QUALIFIED); + String testName = name.substring(name.lastIndexOf(IPath.SEPARATOR) + 1); + + switch (element.getElementType()) { + case IModelElement.SOURCE_MODULE: { + containerHandleId = EMPTY_STRING; + testFileName = element.getResource().getProjectRelativePath().toPortableString(); + testElementName = EMPTY_STRING; + } + break; + case IModelElement.METHOD: { + containerHandleId = EMPTY_STRING; + testFileName = element.getResource().getProjectRelativePath().toPortableString(); + testElementName = element.getElementName(); + // testName+= "[" + testElementName + "]"; + } + break; + default: + throw new IllegalArgumentException( + "Invalid element type to create a launch configuration: " + element.getClass().getName()); //$NON-NLS-1$ + } + + ILaunchConfigurationType configType = getLaunchManager().getLaunchConfigurationType( + getLaunchConfigurationTypeId()); + ILaunchConfigurationWorkingCopy wc = configType.newInstance(null, getLaunchManager() + .generateUniqueLaunchConfigurationNameFrom(testName)); + + wc.setAttribute(ScriptLaunchConfigurationConstants.ATTR_PROJECT_NAME, element + .getScriptProject().getElementName()); + // wc.setAttribute(ITestKind.LAUNCH_ATTR_TEST_KIND, "#"); + wc.setAttribute(ScriptLaunchConfigurationConstants.ATTR_MAIN_SCRIPT_NAME, testFileName); + wc.setAttribute(ScriptLaunchConfigurationConstants.ATTR_SCRIPT_NATURE, + TextMarkerNature.NATURE_ID); + wc.setAttribute(IDebugUIConstants.ATTR_CAPTURE_IN_CONSOLE, "true"); + // wc.setAttribute(XUnitLaunchConfigurationConstants.ATTR_TEST_NAME, testFileName); + // wc.setAttribute(ScriptLaunchConfigurationConstants.ATTR_CONTAINER_PATH, containerHandleId); + // wc.setAttribute(XUnitLaunchConfigurationConstants.ATTR_TEST_ELEMENT_NAME, testElementName); + // XUnitMigrationDelegate.mapResources(wc); + ITextMarkerTestingEngine[] engines = TextMarkerTestingEngineManager.getEngines(); + ISourceModule module = (ISourceModule) element.getAncestor(IModelElement.SOURCE_MODULE); + boolean engineFound = false; + for (int i = 0; i < engines.length; i++) { + if (engines[i].isValidModule(module)) {// TODO!!! + wc.setAttribute(DLTKTestingConstants.ATTR_ENGINE_ID, engines[i].getId()); + engineFound = true; + break; + } + } + // if( engineFound == false ) { + // return null; + // } + + return wc; + } + + /** + * Returns the attribute names of the attributes that are compared when looking for an existing + * similar launch configuration. Clients can override and replace to customize. + * + * @return the attribute names of the attributes that are compared + */ + protected String[] getAttributeNamesToCompare() { + return new String[] { ScriptLaunchConfigurationConstants.ATTR_PROJECT_NAME, + ScriptLaunchConfigurationConstants.ATTR_MAIN_SCRIPT_NAME, + // IDLTKTestingConstants.ENGINE_ID_ATR, + ScriptLaunchConfigurationConstants.ATTR_SCRIPT_NATURE + // XUnitLaunchConfigurationConstants.ATTR_TEST_NAME, + // XUnitLaunchConfigurationConstants.ATTR_TEST_CONTAINER, + // XUnitLaunchConfigurationConstants.ATTR_TEST_ELEMENT_NAME + }; + } + + private static boolean hasSameAttributes(ILaunchConfiguration config1, + ILaunchConfiguration config2, String[] attributeToCompare) { + try { + for (int i = 0; i < attributeToCompare.length; i++) { + String val1 = config1.getAttribute(attributeToCompare[i], EMPTY_STRING); + String val2 = config2.getAttribute(attributeToCompare[i], EMPTY_STRING); + if (!val1.equals(val2)) { + return false; + } + } + return true; + } catch (CoreException e) { + // ignore access problems here, return false + } + return false; + } + + private ILaunchConfiguration findExistingLaunchConfiguration( + ILaunchConfigurationWorkingCopy temporary, String mode) throws InterruptedException, + CoreException { + ILaunchConfigurationType configType = temporary.getType(); + + ILaunchConfiguration[] configs = getLaunchManager().getLaunchConfigurations(configType); + String[] attributeToCompare = getAttributeNamesToCompare(); + + ArrayList candidateConfigs = new ArrayList(configs.length); + for (int i = 0; i < configs.length; i++) { + ILaunchConfiguration config = configs[i]; + if (hasSameAttributes(config, temporary, attributeToCompare)) { + candidateConfigs.add(config); + } + } + + // If there are no existing configs associated with the IType, create + // one. + // If there is exactly one config associated with the IType, return it. + // Otherwise, if there is more than one config associated with the + // IType, prompt the + // user to choose one. + int candidateCount = candidateConfigs.size(); + if (candidateCount == 0) { + return null; + } else if (candidateCount == 1) { + return (ILaunchConfiguration) candidateConfigs.get(0); + } else { + // Prompt the user to choose a config. A null result means the user + // cancelled the dialog, in which case this method returns null, + // since cancelling the dialog should also cancel launching + // anything. + ILaunchConfiguration config = chooseConfiguration(candidateConfigs, mode); + if (config != null) { + return config; + } + } + return null; + } + +} Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.testing/src/main/java/org/apache/uima/tm/dltk/internal/testing/TextMarkerTestingLaunchShortcut.java ------------------------------------------------------------------------------ svn:executable = * Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.testing/src/main/java/org/apache/uima/tm/dltk/internal/testing/TextMarkerTestingLaunchShortcut.java ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.testing/src/main/java/org/apache/uima/tm/dltk/internal/testing/TextMarkerTestingMainLaunchConfigurationTab.java URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.testing/src/main/java/org/apache/uima/tm/dltk/internal/testing/TextMarkerTestingMainLaunchConfigurationTab.java?rev=1152804&view=auto ============================================================================== --- uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.testing/src/main/java/org/apache/uima/tm/dltk/internal/testing/TextMarkerTestingMainLaunchConfigurationTab.java (added) +++ uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.testing/src/main/java/org/apache/uima/tm/dltk/internal/testing/TextMarkerTestingMainLaunchConfigurationTab.java Mon Aug 1 14:37:34 2011 @@ -0,0 +1,159 @@ +package org.apache.uima.tm.dltk.internal.testing; + +import java.util.HashMap; +import java.util.Map; + +import org.apache.uima.tm.dltk.internal.debug.ui.launchConfigurations.TextMarkerMainLaunchConfigurationTab; +import org.apache.uima.tm.dltk.testing.ITextMarkerTestingEngine; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.debug.core.ILaunchConfiguration; +import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; +import org.eclipse.dltk.core.DLTKCore; +import org.eclipse.dltk.core.ISourceModule; +import org.eclipse.dltk.debug.ui.messages.DLTKLaunchConfigurationsMessages; +import org.eclipse.dltk.testing.DLTKTestingConstants; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.ModifyEvent; +import org.eclipse.swt.events.ModifyListener; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.graphics.Font; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Combo; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Group; + + +public class TextMarkerTestingMainLaunchConfigurationTab extends + TextMarkerMainLaunchConfigurationTab { + public TextMarkerTestingMainLaunchConfigurationTab(String mode) { + super(mode); + } + + private Button detect; + + private Combo engineType; + + private Map nameToId = new HashMap(); + + @Override + protected void doCreateControl(Composite composite) { + createMainModuleEditor(composite, DLTKLaunchConfigurationsMessages.mainTab_mainModule); + createVerticalSpacer(composite, 1); + createTestEngineEditor(composite, "TextMarker Testing engine"); + + } + + protected void createTestEngineEditor(Composite parent, String text) { + Font font = parent.getFont(); + Group mainGroup = new Group(parent, SWT.NONE); + mainGroup.setText(text); + GridData gd = new GridData(GridData.FILL_HORIZONTAL); + mainGroup.setLayoutData(gd); + GridLayout layout = new GridLayout(); + layout.numColumns = 2; + mainGroup.setLayout(layout); + mainGroup.setFont(font); + engineType = new Combo(mainGroup, SWT.SINGLE | SWT.BORDER | SWT.DROP_DOWN); + gd = new GridData(GridData.FILL_HORIZONTAL); + engineType.setLayoutData(gd); + engineType.setFont(font); + engineType.addModifyListener(new ModifyListener() { + public void modifyText(ModifyEvent e) { + updateLaunchConfigurationDialog(); + } + }); + detect = createPushButton(mainGroup, "Detect", null); + + ITextMarkerTestingEngine[] engines = TextMarkerTestingEngineManager.getEngines(); + for (int i = 0; i < engines.length; i++) { + String name = engines[i].getName(); + this.engineType.add(name); + nameToId.put(name, engines[i].getId()); + } + detect.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + handleDetectButtonSelected(); + } + }); + handleDetectButtonSelected(); + } + + private void handleDetectButtonSelected() { + ITextMarkerTestingEngine[] engines = TextMarkerTestingEngineManager.getEngines(); + // this.engineType.select(0); + ISourceModule module = getSourceModule(); + if (module != null && module.exists()) { + for (int i = 0; i < engines.length; i++) { + if (engines[i].isValidModule(module)) { + this.engineType.select(i); + } + } + } + } + + // private ISourceModule getSourceModule() { + // IScriptProject project = this.getProject(); + // if (project == null) { + // return null; + // } + // IProject prj = project.getProject(); + // String scriptName = this.getScriptName(); + // ISourceModule module = null; + // IResource res = prj.getFile(scriptName); + // module = (ISourceModule) DLTKCore.create(res); + // return module; + // } + private boolean validateEngine() { + ISourceModule module = getSourceModule(); + if (module != null) { + ITextMarkerTestingEngine[] engines = TextMarkerTestingEngineManager.getEngines(); + for (int i = 0; i < engines.length; i++) { + String selectedEngine = this.getEngineId(); + if (engines[i].getId().equals(selectedEngine) && engines[i].isValidModule(module)) { + return true; + } + } + } + setErrorMessage("Testing engine not support specified script"); + return true; + } + + @Override + protected void doPerformApply(ILaunchConfigurationWorkingCopy config) { + super.doPerformApply(config); + config.setAttribute(DLTKTestingConstants.ATTR_ENGINE_ID, getEngineId()); + } + + private String getEngineId() { + return (String) this.nameToId.get(this.engineType.getText()); + } + + @Override + protected void doInitializeForm(ILaunchConfiguration config) { + super.doInitializeForm(config); + ITextMarkerTestingEngine[] engines = TextMarkerTestingEngineManager.getEngines(); + String id = null; + try { + id = config.getAttribute(DLTKTestingConstants.ATTR_ENGINE_ID, ""); + } catch (CoreException e) { + if (DLTKCore.DEBUG) { + e.printStackTrace(); + } + } + if (id == null || id.length() == 0) { + handleDetectButtonSelected(); + } else { + // this.engineType.select(0); + for (int i = 0; i < engines.length; i++) { + if (engines[i].getId().equals(id)) { + this.engineType.select(i); + } + } + } + // handleDetectButtonSelected(); + } +} Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.testing/src/main/java/org/apache/uima/tm/dltk/internal/testing/TextMarkerTestingMainLaunchConfigurationTab.java ------------------------------------------------------------------------------ svn:executable = * Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.testing/src/main/java/org/apache/uima/tm/dltk/internal/testing/TextMarkerTestingMainLaunchConfigurationTab.java ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.testing/src/main/java/org/apache/uima/tm/dltk/internal/testing/TextMarkerTestingPlugin.java URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.testing/src/main/java/org/apache/uima/tm/dltk/internal/testing/TextMarkerTestingPlugin.java?rev=1152804&view=auto ============================================================================== --- uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.testing/src/main/java/org/apache/uima/tm/dltk/internal/testing/TextMarkerTestingPlugin.java (added) +++ uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.testing/src/main/java/org/apache/uima/tm/dltk/internal/testing/TextMarkerTestingPlugin.java Mon Aug 1 14:37:34 2011 @@ -0,0 +1,41 @@ +package org.apache.uima.tm.dltk.internal.testing; + +import org.eclipse.ui.plugin.AbstractUIPlugin; +import org.osgi.framework.BundleContext; + +public class TextMarkerTestingPlugin extends AbstractUIPlugin { + + public static final String PLUGIN_ID = "org.apache.uima.tm.dltk.testing"; + + private static TextMarkerTestingPlugin plugin; + + public TextMarkerTestingPlugin() { + } + + /* + * (non-Javadoc) + * + * @see de.uniwue.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext) + */ + @Override + public void start(BundleContext context) throws Exception { + super.start(context); + plugin = this; + } + + /* + * (non-Javadoc) + * + * @see de.uniwue.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext) + */ + @Override + public void stop(BundleContext context) throws Exception { + plugin = null; + super.stop(context); + } + + public static TextMarkerTestingPlugin getDefault() { + return plugin; + } + +} Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.testing/src/main/java/org/apache/uima/tm/dltk/internal/testing/TextMarkerTestingPlugin.java ------------------------------------------------------------------------------ svn:executable = * Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.testing/src/main/java/org/apache/uima/tm/dltk/internal/testing/TextMarkerTestingPlugin.java ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.testing/src/main/java/org/apache/uima/tm/dltk/internal/testing/TextMarkerTestingTabGroup.java URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.testing/src/main/java/org/apache/uima/tm/dltk/internal/testing/TextMarkerTestingTabGroup.java?rev=1152804&view=auto ============================================================================== --- uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.testing/src/main/java/org/apache/uima/tm/dltk/internal/testing/TextMarkerTestingTabGroup.java (added) +++ uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.testing/src/main/java/org/apache/uima/tm/dltk/internal/testing/TextMarkerTestingTabGroup.java Mon Aug 1 14:37:34 2011 @@ -0,0 +1,31 @@ +package org.apache.uima.tm.dltk.internal.testing; + +import org.apache.uima.tm.dltk.internal.debug.ui.interpreters.TextMarkerInterpreterTab; +import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; +import org.eclipse.debug.ui.AbstractLaunchConfigurationTabGroup; +import org.eclipse.debug.ui.CommonTab; +import org.eclipse.debug.ui.EnvironmentTab; +import org.eclipse.debug.ui.IDebugUIConstants; +import org.eclipse.debug.ui.ILaunchConfigurationDialog; +import org.eclipse.debug.ui.ILaunchConfigurationTab; +import org.eclipse.dltk.debug.ui.launchConfigurations.ScriptArgumentsTab; + + +public class TextMarkerTestingTabGroup extends AbstractLaunchConfigurationTabGroup { + + public void createTabs(ILaunchConfigurationDialog dialog, String mode) { + TextMarkerTestingMainLaunchConfigurationTab main = new TextMarkerTestingMainLaunchConfigurationTab( + mode); + ILaunchConfigurationTab[] tabs = new ILaunchConfigurationTab[] { main, + new ScriptArgumentsTab(), new TextMarkerInterpreterTab(main), new EnvironmentTab(), + new CommonTab() { + @Override + public void performApply(ILaunchConfigurationWorkingCopy configuration) { + super.performApply(configuration); + configuration.setAttribute(IDebugUIConstants.ATTR_CAPTURE_IN_CONSOLE, (String) null); + } + } }; + setTabs(tabs); + } + +} Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.testing/src/main/java/org/apache/uima/tm/dltk/internal/testing/TextMarkerTestingTabGroup.java ------------------------------------------------------------------------------ svn:executable = * Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.testing/src/main/java/org/apache/uima/tm/dltk/internal/testing/TextMarkerTestingTabGroup.java ------------------------------------------------------------------------------ svn:mime-type = text/plain