You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@uima.apache.org by jo...@apache.org on 2011/03/29 10:37:25 UTC
svn commit: r1086519 - in /uima/uimaj/trunk/uimaj-ep-launcher: ./ META-INF/
src/ src/main/ src/main/java/ src/main/java/org/ src/main/java/org/apache/
src/main/java/org/apache/uima/ src/main/java/org/apache/uima/ep_launcher/
src/main/java/org/apache/ui...
Author: joern
Date: Tue Mar 29 08:37:24 2011
New Revision: 1086519
URL: http://svn.apache.org/viewvc?rev=1086519&view=rev
Log:
UIMA-2100 Initial check in
Added:
uima/uimaj/trunk/uimaj-ep-launcher/META-INF/
uima/uimaj/trunk/uimaj-ep-launcher/META-INF/MANIFEST.MF (with props)
uima/uimaj/trunk/uimaj-ep-launcher/marker-file-identifying-eclipse-plugin
uima/uimaj/trunk/uimaj-ep-launcher/plugin.xml (with props)
uima/uimaj/trunk/uimaj-ep-launcher/pom.xml (with props)
uima/uimaj/trunk/uimaj-ep-launcher/src/
uima/uimaj/trunk/uimaj-ep-launcher/src/main/
uima/uimaj/trunk/uimaj-ep-launcher/src/main/java/
uima/uimaj/trunk/uimaj-ep-launcher/src/main/java/org/
uima/uimaj/trunk/uimaj-ep-launcher/src/main/java/org/apache/
uima/uimaj/trunk/uimaj-ep-launcher/src/main/java/org/apache/uima/
uima/uimaj/trunk/uimaj-ep-launcher/src/main/java/org/apache/uima/ep_launcher/
uima/uimaj/trunk/uimaj-ep-launcher/src/main/java/org/apache/uima/ep_launcher/AnalysisEngineLaunchConfigurationDelegate.java (with props)
uima/uimaj/trunk/uimaj-ep-launcher/src/main/java/org/apache/uima/ep_launcher/LauncherConstants.java (with props)
uima/uimaj/trunk/uimaj-ep-launcher/src/main/java/org/apache/uima/ep_launcher/LauncherPlugin.java (with props)
uima/uimaj/trunk/uimaj-ep-launcher/src/main/java/org/apache/uima/ep_launcher/RemoteLauncher.java (with props)
uima/uimaj/trunk/uimaj-ep-launcher/src/main/java/org/apache/uima/ep_launcher/ui/
uima/uimaj/trunk/uimaj-ep-launcher/src/main/java/org/apache/uima/ep_launcher/ui/AnalysisEngineMainTab.java (with props)
uima/uimaj/trunk/uimaj-ep-launcher/src/main/java/org/apache/uima/ep_launcher/ui/AnalysisEngineTabGroup.java (with props)
Modified:
uima/uimaj/trunk/uimaj-ep-launcher/ (props changed)
Propchange: uima/uimaj/trunk/uimaj-ep-launcher/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Tue Mar 29 08:37:24 2011
@@ -0,0 +1,7 @@
+.project
+
+.classpath
+
+target
+
+.settings
Added: uima/uimaj/trunk/uimaj-ep-launcher/META-INF/MANIFEST.MF
URL: http://svn.apache.org/viewvc/uima/uimaj/trunk/uimaj-ep-launcher/META-INF/MANIFEST.MF?rev=1086519&view=auto
==============================================================================
--- uima/uimaj/trunk/uimaj-ep-launcher/META-INF/MANIFEST.MF (added)
+++ uima/uimaj/trunk/uimaj-ep-launcher/META-INF/MANIFEST.MF Tue Mar 29 08:37:24 2011
@@ -0,0 +1,25 @@
+Manifest-Version: 1.0
+Eclipse-AutoStart: true
+Ignore-Package: org.eclipse.core.runtime
+Tool: Bnd-0.0.357
+Bundle-Name: UIMA Eclipse: uimaj-ep-launcher
+Created-By: 1.6.0_24 (Apple Inc.)
+Require-Bundle: org.eclipse.core.runtime
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.3.2.SNAPSHOT
+Bnd-LastModified: 1301318607109
+Bundle-Activator: org.apache.uima.ep_launcher.LauncherPlugin
+Bundle-ManifestVersion: 2
+Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
+Bundle-Description: Adds launch support for Analysis Engines
+Import-Package: org.eclipse.core.resources,org.eclipse.core.runtime.mo
+ del,org.eclipse.core.variables,org.eclipse.debug.core,org.eclipse.deb
+ ug.ui,org.eclipse.debug.ui.sourcelookup,org.eclipse.jdt.debug.ui.laun
+ chConfigurations,org.eclipse.jdt.launching,org.eclipse.jface.layout,o
+ rg.eclipse.jface.preference,org.eclipse.jface.viewers,org.eclipse.swt
+ .events,org.eclipse.swt.layout,org.eclipse.swt.widgets,org.eclipse.ui
+ ,org.eclipse.ui.dialogs,org.eclipse.ui.model,org.eclipse.ui.plugin,or
+ g.osgi.framework;version="1.3"
+Bundle-SymbolicName: org.apache.uima.launcher;singleton:=true
+Bundle-DocURL: http://www.apache.org/
+
Propchange: uima/uimaj/trunk/uimaj-ep-launcher/META-INF/MANIFEST.MF
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: uima/uimaj/trunk/uimaj-ep-launcher/marker-file-identifying-eclipse-plugin
URL: http://svn.apache.org/viewvc/uima/uimaj/trunk/uimaj-ep-launcher/marker-file-identifying-eclipse-plugin?rev=1086519&view=auto
==============================================================================
(empty)
Added: uima/uimaj/trunk/uimaj-ep-launcher/plugin.xml
URL: http://svn.apache.org/viewvc/uima/uimaj/trunk/uimaj-ep-launcher/plugin.xml?rev=1086519&view=auto
==============================================================================
--- uima/uimaj/trunk/uimaj-ep-launcher/plugin.xml (added)
+++ uima/uimaj/trunk/uimaj-ep-launcher/plugin.xml Tue Mar 29 08:37:24 2011
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.0"?>
+ <!--
+ ***************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ ***************************************************************
+ -->
+<plugin>
+ <extension point="org.eclipse.debug.core.launchConfigurationTypes">
+ <launchConfigurationType
+ name="UIMA Analysis Engine"
+ delegate="org.apache.uima.ep_launcher.AnalysisEngineLaunchConfigurationDelegate"
+ modes="run, debug"
+ id="org.apache.uima.ep_launcher.analysisEngine">
+ </launchConfigurationType>
+ </extension>
+
+ <extension point="org.eclipse.debug.ui.launchConfigurationTabGroups">
+ <launchConfigurationTabGroup
+ type="org.apache.uima.ep_launcher.analysisEngine"
+ class="org.apache.uima.ep_launcher.ui.AnalysisEngineTabGroup"
+ id="org.apache.uima.ep_launcher.ui.launchConfigurationTabGroup.analysisEngine">
+ </launchConfigurationTabGroup>
+ </extension>
+</plugin>
Propchange: uima/uimaj/trunk/uimaj-ep-launcher/plugin.xml
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: uima/uimaj/trunk/uimaj-ep-launcher/pom.xml
URL: http://svn.apache.org/viewvc/uima/uimaj/trunk/uimaj-ep-launcher/pom.xml?rev=1086519&view=auto
==============================================================================
--- uima/uimaj/trunk/uimaj-ep-launcher/pom.xml (added)
+++ uima/uimaj/trunk/uimaj-ep-launcher/pom.xml Tue Mar 29 08:37:24 2011
@@ -0,0 +1,244 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.uima</groupId>
+ <artifactId>uimaj-parent</artifactId>
+ <version>2.3.2-SNAPSHOT</version>
+ <relativePath>../uimaj-parent/pom.xml</relativePath>
+ </parent>
+
+ <artifactId>uimaj-ep-launcher</artifactId>
+ <version>2.3.2-SNAPSHOT</version>
+ <packaging>jar</packaging>
+ <name>UIMA Eclipse: ${project.artifactId}</name>
+ <!-- continuation lines need to start in col 1 else manifest has extra blanks -->
+ <description>Adds launch support for Analysis Engines </description>
+ <url>${uimaWebsiteUrl}</url>
+
+ <!-- Special inheritance note
+ even though the <scm> element that follows is exactly the
+ same as those in super poms, it cannot be inherited because
+ there is some special code that incorrectly computes the
+ connection elements from the chain of parent poms, if this is omitted.
+
+ Keeping this a bit factored allows cutting/pasting the <scm>
+ element, and just changing the following two properties -->
+ <scm>
+ <connection>
+ scm:svn:http://svn.apache.org/repos/asf/uima/uimaj/trunk/uimaj-ep-launcher
+ </connection>
+ <developerConnection>
+ scm:svn:https://svn.apache.org/repos/asf/uima/uimaj/trunk/uimaj-ep-launcher
+ </developerConnection>
+ <url>
+ http://svn.apache.org/viewvc/uima/uimaj/trunk/uimaj-ep-launcher
+ </url>
+ </scm>
+
+ <properties>
+ <uimaScmProject>${project.artifactId}</uimaScmProject>
+ </properties>
+
+ <dependencies>
+ <!-- depending on the ep-runtime doesn't work without manual intervention because
+ eclipse:eclipse on the ep-runtime doesn't mark the embedded things as "exported".
+ It doesn't matter which scope - compile or provided - is used, both fail
+
+ Other posts indicate that plugins should have explicit dependencies, anyway.
+ And, it lets these plugins work when the library plugin is "open" in the same workspace.
+ -->
+ <!--dependency>
+ <groupId>org.apache.uima</groupId>
+ <artifactId>uimaj-ep-runtime</artifactId>
+ <version>${uimaj-release-eclipse-version}</version>
+ <scope>compile</scope>
+ </dependency-->
+
+ <dependency>
+ <groupId>org.apache.uima</groupId>
+ <artifactId>uimaj-core</artifactId>
+ <version>${project.parent.version}</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <!-- next dependency is commented out due to Maven 2.0.7 throwing NPE
+ Might be related to http://jira.codehaus.org/browse/MNG-3086 -->
+ <!--dependency>
+ <groupId>org.eclipse.ui</groupId>
+ <artifactId>org.eclipse.ui</artifactId>
+ <version>3.2.0</version>
+ <scope>provided</scope>
+ </dependency-->
+ <dependency>
+ <groupId>org.eclipse.swt</groupId>
+ <artifactId>org.eclipse.swt.win32.win32.x86</artifactId>
+ <!-- changing the lower version number to 3.2.0,
+ was 3.3.0
+ because only 3.2.0 and 3.2.1 are in
+ repo -->
+ <version>[3.2.0.0,4.0.0)</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.eclipse.jdt</groupId>
+ <artifactId>org.eclipse.jdt.debug.ui</artifactId>
+ <version>3.2.0</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <!-- dependencies added to overcome 3.6 maven central corrupted upload -->
+ <dependency>
+ <groupId>org.eclipse.core</groupId>
+ <artifactId>org.eclipse.core.filesystem</artifactId>
+ <version>1.0.0</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.eclipse.core</groupId>
+ <artifactId>org.eclipse.core.resources</artifactId>
+ <version>3.2.1</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.eclipse.core</groupId>
+ <artifactId>org.eclipse.core.runtime</artifactId>
+ <version>3.2.0</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.eclipse.equinox</groupId>
+ <artifactId>org.eclipse.equinox.common</artifactId>
+ <version>3.2.0</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.eclipse.osgi</groupId>
+ <artifactId>org.eclipse.osgi</artifactId>
+ <version>3.2.1</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.eclipse.core</groupId>
+ <artifactId>org.eclipse.core.expressions</artifactId>
+ <version>3.2.1</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.eclipse.core</groupId>
+ <artifactId>org.eclipse.core.variables</artifactId>
+ <version>3.1.100</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.eclipse.ant</groupId>
+ <artifactId>org.eclipse.ant.core</artifactId>
+ <version>3.1.100</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.eclipse.equinox</groupId>
+ <artifactId>org.eclipse.equinox.registry</artifactId>
+ <version>3.2.1</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.eclipse.core</groupId>
+ <artifactId>org.eclipse.core.jobs</artifactId>
+ <version>3.2.0</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.eclipse.equinox</groupId>
+ <artifactId>org.eclipse.equinox.preferences</artifactId>
+ <version>3.2.1</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.eclipse.core</groupId>
+ <artifactId>org.eclipse.core.contenttype</artifactId>
+ <version>3.2.0</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.eclipse.core</groupId>
+ <artifactId>org.eclipse.core.runtime.compatibility.auth</artifactId>
+ <version>3.2.0</version>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <!-- don't use artifactId as first part of finalName, follow instead the eclipse convention -->
+ <finalName>org.apache.uima.launcher_${parsedVersion.osgiVersion}</finalName>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <configuration>
+ <instructions>
+ <!-- turn off "uses" generation because Eclipse 3.2.x doesn't work with them -->
+ <_nouses>true</_nouses>
+ <Export-Package>
+ org.apache.uima.launcher
+ </Export-Package>
+
+ <!-- handle split packages in Eclipse.
+ We do this by using Require-Bundle, and excluding from the Import-Package those
+ split packages covered by those bundles - this is required by OSGi.
+
+ org.eclipse.core.runtime has combined apis (that were split in later
+ point releases of 3.x)
+ -->
+ <!-- NOTE: ANY CONTINUATION LINES for Require-Bundle MUST START IN Col1 else manifest is potentially wrong -->
+ <Require-Bundle>org.eclipse.core.runtime</Require-Bundle>
+ <Import-Package>
+ !org.eclipse.core.runtime,
+ org.eclipse.core.resources,
+ org.eclipse.core.runtime.model,
+ org.eclipse.core.variables,
+ org.eclipse.debug.core,
+ org.eclipse.debug.ui,
+ org.eclipse.debug.ui.sourcelookup,
+ org.eclipse.jdt.debug.ui.launchConfigurations,
+ org.eclipse.jdt.launching,
+ org.eclipse.jface.layout,
+ org.eclipse.jface.preference,
+ org.eclipse.jface.viewers,
+ org.eclipse.swt.events,
+ org.eclipse.swt.layout,
+ org.eclipse.swt.widgets,
+ org.eclipse.ui,
+ org.eclipse.ui.dialogs,
+ org.eclipse.ui.model,
+ org.eclipse.ui.plugin,
+ org.osgi.framework;version="1.3"
+ </Import-Package>
+ <Bundle-SymbolicName>org.apache.uima.launcher;singleton:=true</Bundle-SymbolicName>
+ <Bundle-Activator>org.apache.uima.ep_launcher.LauncherPlugin</Bundle-Activator>
+ <Eclipse-AutoStart>true</Eclipse-AutoStart>
+ </instructions>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
\ No newline at end of file
Propchange: uima/uimaj/trunk/uimaj-ep-launcher/pom.xml
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: uima/uimaj/trunk/uimaj-ep-launcher/src/main/java/org/apache/uima/ep_launcher/AnalysisEngineLaunchConfigurationDelegate.java
URL: http://svn.apache.org/viewvc/uima/uimaj/trunk/uimaj-ep-launcher/src/main/java/org/apache/uima/ep_launcher/AnalysisEngineLaunchConfigurationDelegate.java?rev=1086519&view=auto
==============================================================================
--- uima/uimaj/trunk/uimaj-ep-launcher/src/main/java/org/apache/uima/ep_launcher/AnalysisEngineLaunchConfigurationDelegate.java (added)
+++ uima/uimaj/trunk/uimaj-ep-launcher/src/main/java/org/apache/uima/ep_launcher/AnalysisEngineLaunchConfigurationDelegate.java Tue Mar 29 08:37:24 2011
@@ -0,0 +1,173 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.uima.ep_launcher;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.List;
+
+import org.apache.uima.ep_launcher.LauncherConstants.InputFormat;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.debug.core.ILaunch;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.jdt.launching.JavaLaunchDelegate;
+import org.osgi.framework.Bundle;
+
+/**
+ * This delegate is responsible to to configure the VM and to create command line args which will be
+ * passed to the {@link RemoteLauncher}s main method.
+ */
+public class AnalysisEngineLaunchConfigurationDelegate extends JavaLaunchDelegate {
+
+ @Override
+ public String getMainTypeName(ILaunchConfiguration configuration) throws CoreException {
+ return "org.apache.uima.ep_launcher.RemoteLauncher";
+ }
+
+ private String pluginIdToJarPath(String pluginId) throws IOException {
+ Bundle bundle = LauncherPlugin.getDefault().getBundle(pluginId);
+
+ URL url = bundle.getEntry("/");
+
+ if (url == null)
+ throw new IOException();
+
+ return FileLocator.toFileURL(url).getFile();
+ }
+
+ @Override
+ public String getProgramArguments(ILaunchConfiguration configuration) throws CoreException {
+
+ // Build the command line which is passed to the launched processed, in case the
+ // parameters are not configured correctly (can only happen trough bugs in this plugin) then
+ // the launched process will fail
+
+ StringBuilder cmdline = new StringBuilder();
+ cmdline.append(RemoteLauncher.DESCRIPTOR_PARAM + " ");
+ cmdline.append(configuration.getAttribute(LauncherConstants.ATTR_DESCRIPTOR_NAME, "") + " ");
+ cmdline.append(RemoteLauncher.INPUT_RESOURCE_PARAM + " ");
+ cmdline.append(configuration.getAttribute(LauncherConstants.ATTR_INPUT_NAME, "") + " ");
+
+ String formatName = configuration.getAttribute(LauncherConstants.ATTR_INPUT_FORMAT_NAME,
+ " ");
+ cmdline.append(RemoteLauncher.INPUT_FORMAT_PARAM + " ");
+ cmdline.append(formatName + " ");
+
+ // if format equals PLAIN_TEXT
+ if (InputFormat.PLAIN_TEXT.toString().equals(formatName)) {
+ cmdline.append(RemoteLauncher.INPUT_ENCODING_PARAM + " ");
+ cmdline.append(configuration.getAttribute(LauncherConstants.ATTR_INPUT_ENCODING_NAME, "")
+ + " ");
+ }
+
+ cmdline.append(RemoteLauncher.INPUT_RECURSIVE_PARAM + " ");
+ cmdline.append(configuration.getAttribute(LauncherConstants.ATTR_INPUT_RECURSIVELY_NAME, false) + " ");
+ cmdline.append(RemoteLauncher.OUTPUT_FOLDER_PARAM + " ");
+ cmdline.append(configuration.getAttribute(LauncherConstants.ATTR_OUTPUT_FOLDER_NAME, "") + " ");
+ cmdline.append(RemoteLauncher.OUTPUT_CLEAR_PARAM + " ");
+ cmdline.append(configuration.getAttribute(LauncherConstants.ATTR_OUTPUT_CLEAR_NAME, false));
+
+ return cmdline.toString();
+ }
+
+
+ @Override
+ public String[] getClasspath(ILaunchConfiguration configuration) throws CoreException {
+
+ List<String> extendedClasspath = new ArrayList<String>();
+ Collections.addAll(extendedClasspath, super.getClasspath(configuration));
+
+ // Normal mode, add the launcher plugin and uima runtime jar to the classpath
+ if (!Platform.inDevelopmentMode()) {
+ try {
+ // Add this plugin jar to the classpath
+ extendedClasspath.add(pluginIdToJarPath(LauncherPlugin.ID));
+
+ // UIMA jar should be added the end of the class path, because user uima jars
+ // (maybe a different version) should appear first on the class path
+ extendedClasspath.add(pluginIdToJarPath("org.apache.uima.runtime"));
+ } catch (IOException e) {
+ throw new CoreException(new Status(IStatus.ERROR, LauncherPlugin.ID, IStatus.OK,
+ "Failed to compose classpath!", e));
+ }
+ }
+ // When running inside eclipse with PDE in development mode the plugins
+ // are not installed inform of jar files and the classes must be loaded
+ // from the target/classes folder or target/org.apache.uima.runtime.*.jar file
+ else {
+ try {
+ // Add classes folder of this plugin to class path
+ extendedClasspath.add(pluginIdToJarPath(LauncherPlugin.ID) + "target/classes");
+
+ // Add org.apache.uima.runtime jar to class path
+ Bundle bundle = LauncherPlugin.getDefault().getBundle("org.apache.uima.runtime");
+
+ // Ignore the case when runtime bundle does not exist ...
+ if (bundle != null) {
+ Enumeration<?> jarEnum = bundle.findEntries("/", "*.jar", true);
+ while (jarEnum != null && jarEnum.hasMoreElements()) {
+ URL element = (URL) jarEnum.nextElement();
+ extendedClasspath.add(FileLocator.toFileURL(element).getFile());
+ }
+ }
+ } catch (IOException e) {
+ throw new CoreException(new Status(IStatus.ERROR, LauncherPlugin.ID, IStatus.OK,
+ "Failed to compose classpath!", e));
+ }
+ }
+
+ return extendedClasspath.toArray(new String[extendedClasspath.size()]);
+ }
+
+ @Override
+ public void launch(ILaunchConfiguration configuration, String mode, ILaunch launch,
+ IProgressMonitor monitor) throws CoreException {
+
+ super.launch(configuration, mode, launch, monitor);
+
+ // This method is called from a worker thread, so it seems
+ // safe to block this tread until the VM terminates
+ while (!launch.isTerminated()) {
+ try {
+ Thread.sleep(100);
+ } catch (InterruptedException e) {
+ Thread.interrupted();
+ }
+ }
+
+ // It is assumed that the working directory is the project directory,
+ // otherwise the refresh will not occur
+ File workingDir = getWorkingDirectory(configuration);
+ IResource result = ResourcesPlugin.getWorkspace().getRoot().findMember(workingDir.getName());
+ if (result != null)
+ result.refreshLocal(IResource.DEPTH_INFINITE, null);
+ }
+}
Propchange: uima/uimaj/trunk/uimaj-ep-launcher/src/main/java/org/apache/uima/ep_launcher/AnalysisEngineLaunchConfigurationDelegate.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: uima/uimaj/trunk/uimaj-ep-launcher/src/main/java/org/apache/uima/ep_launcher/LauncherConstants.java
URL: http://svn.apache.org/viewvc/uima/uimaj/trunk/uimaj-ep-launcher/src/main/java/org/apache/uima/ep_launcher/LauncherConstants.java?rev=1086519&view=auto
==============================================================================
--- uima/uimaj/trunk/uimaj-ep-launcher/src/main/java/org/apache/uima/ep_launcher/LauncherConstants.java (added)
+++ uima/uimaj/trunk/uimaj-ep-launcher/src/main/java/org/apache/uima/ep_launcher/LauncherConstants.java Tue Mar 29 08:37:24 2011
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.uima.ep_launcher;
+
+public class LauncherConstants {
+ public static final String ATTR_DESCRIPTOR_NAME = "org.apache.uima.ep_launcher.DESCRIPTOR_ATTR";
+ public static final String ATTR_INPUT_NAME = "org.apache.uima.ep_launcher.INPUT_ATTR";
+ public static final String ATTR_INPUT_RECURSIVELY_NAME = "org.apache.uima.ep_launcher.INPUT_RECURSIVELY_ATTR";
+ public static final String ATTR_INPUT_ENCODING_NAME = "org.apache.uima.ep_launcher.INPUT_ENCODING_ATTR";
+
+ public static final String ATTR_INPUT_FORMAT_NAME = "org.apache.uima.ep_launcher.INPUT_FORMAT_ATTR";
+ public static final String ATTR_OUTPUT_FOLDER_NAME = "org.apache.uima.ep_launcher.OUTPUT_FOLDER_ATTR";
+ public static final String ATTR_OUTPUT_CLEAR_NAME = "org.apache.uima.ep_launcher.OUTPUT_CLEAR_ATTR";
+
+ public enum InputFormat {
+ CAS,
+ PLAIN_TEXT
+ }
+}
Propchange: uima/uimaj/trunk/uimaj-ep-launcher/src/main/java/org/apache/uima/ep_launcher/LauncherConstants.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: uima/uimaj/trunk/uimaj-ep-launcher/src/main/java/org/apache/uima/ep_launcher/LauncherPlugin.java
URL: http://svn.apache.org/viewvc/uima/uimaj/trunk/uimaj-ep-launcher/src/main/java/org/apache/uima/ep_launcher/LauncherPlugin.java?rev=1086519&view=auto
==============================================================================
--- uima/uimaj/trunk/uimaj-ep-launcher/src/main/java/org/apache/uima/ep_launcher/LauncherPlugin.java (added)
+++ uima/uimaj/trunk/uimaj-ep-launcher/src/main/java/org/apache/uima/ep_launcher/LauncherPlugin.java Tue Mar 29 08:37:24 2011
@@ -0,0 +1,85 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.uima.ep_launcher;
+
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.Plugin;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.service.packageadmin.PackageAdmin;
+
+public class LauncherPlugin extends Plugin {
+
+
+ public static final String ID = "org.apache.uima.launcher";
+
+ private static LauncherPlugin plugin;
+
+ private BundleContext bundleContext;
+
+ public LauncherPlugin() {
+ plugin = this;
+ }
+
+ @Override
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+
+ bundleContext = context;
+ }
+
+ @Override
+ public void stop(BundleContext context) throws Exception {
+ super.stop(context);
+ plugin = null;
+ }
+
+ public Bundle[] getBundles(String bundleName, String version) {
+
+ Bundle[] bundles = Platform.getBundles(bundleName, version);
+ if (bundles != null)
+ return bundles;
+
+ // Accessing bundle which is not resolved
+ PackageAdmin admin = (PackageAdmin) bundleContext.getService(
+ bundleContext.getServiceReference(PackageAdmin.class.getName()));
+ bundles = admin.getBundles(bundleName, version);
+ if (bundles != null && bundles.length > 0)
+ return bundles;
+
+ return null;
+ }
+
+ public Bundle getBundle(String bundleName) {
+ Bundle[] bundles = getBundles(bundleName, null);
+ if (bundles != null && bundles.length > 0)
+ // return fist bundle, if multiple
+ return bundles[0];
+
+ return null;
+ }
+
+ /**
+ * Returns the shared instance.
+ */
+ public static LauncherPlugin getDefault() {
+ return plugin;
+ }
+}
Propchange: uima/uimaj/trunk/uimaj-ep-launcher/src/main/java/org/apache/uima/ep_launcher/LauncherPlugin.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: uima/uimaj/trunk/uimaj-ep-launcher/src/main/java/org/apache/uima/ep_launcher/RemoteLauncher.java
URL: http://svn.apache.org/viewvc/uima/uimaj/trunk/uimaj-ep-launcher/src/main/java/org/apache/uima/ep_launcher/RemoteLauncher.java?rev=1086519&view=auto
==============================================================================
--- uima/uimaj/trunk/uimaj-ep-launcher/src/main/java/org/apache/uima/ep_launcher/RemoteLauncher.java (added)
+++ uima/uimaj/trunk/uimaj-ep-launcher/src/main/java/org/apache/uima/ep_launcher/RemoteLauncher.java Tue Mar 29 08:37:24 2011
@@ -0,0 +1,324 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.uima.ep_launcher;
+
+import java.io.File;
+import java.io.FileFilter;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+
+import org.apache.uima.UIMAFramework;
+import org.apache.uima.analysis_engine.AnalysisEngine;
+import org.apache.uima.analysis_engine.AnalysisEngineProcessException;
+import org.apache.uima.cas.CAS;
+import org.apache.uima.cas.impl.XCASDeserializer;
+import org.apache.uima.cas.impl.XmiCasDeserializer;
+import org.apache.uima.cas.impl.XmiCasSerializer;
+import org.apache.uima.ep_launcher.LauncherConstants.InputFormat;
+import org.apache.uima.resource.ResourceSpecifier;
+import org.apache.uima.util.FileUtils;
+import org.apache.uima.util.XMLInputSource;
+import org.apache.uima.util.XMLSerializer;
+import org.xml.sax.SAXException;
+
+/**
+ * The RemoteLauncher runs the actual Analysis Engine in the launched VM.
+ */
+public class RemoteLauncher {
+
+ public static final String DESCRIPTOR_PARAM = "-descriptor";
+ public static final String INPUT_RESOURCE_PARAM = "-inputResource";
+ public static final String INPUT_RECURSIVE_PARAM = "-recursive";
+ public static final String INPUT_FORMAT_PARAM = "-format";
+ public static final String INPUT_ENCODING_PARAM = "-encoding";
+ public static final String OUTPUT_FOLDER_PARAM = "-output";
+ public static final String OUTPUT_CLEAR_PARAM = "-clear";
+
+ private static File descriptor;
+ private static File inputResource;
+ private static boolean inputRecursive;
+ private static InputFormat inputFormat = InputFormat.CAS;
+ private static String inputEncoding = java.nio.charset.Charset.defaultCharset().name();
+ private static File outputFolder;
+ private static boolean outputFolderClear;
+
+ private static boolean parseCmdLineArgs(String[] args) {
+
+ int necessaryArgCount = 0;
+
+ int index = 0;
+ while (index < args.length) {
+
+ String arg = args[index++];
+
+ if (DESCRIPTOR_PARAM.equals(arg)) {
+ if (index >= args.length) {
+ return false;
+ }
+
+ descriptor = new File(args[index++]);
+ necessaryArgCount++;
+ }
+ else if (INPUT_RESOURCE_PARAM.equals(arg)) {
+ if (index >= args.length) {
+ return false;
+ }
+
+ inputResource = new File(args[index++]);
+ necessaryArgCount++;
+ }
+ else if (INPUT_RECURSIVE_PARAM.equals(arg)) {
+ if (index >= args.length) {
+ return false;
+ }
+
+ inputRecursive = Boolean.parseBoolean(args[index++]);
+ }
+ else if (INPUT_FORMAT_PARAM.equals(arg)) {
+ if (index >= args.length) {
+ return false;
+ }
+
+ String inputFormatName = args[index++];
+
+ if (InputFormat.CAS.toString().equals(inputFormatName)) {
+ inputFormat = InputFormat.CAS;
+ }
+ else if (InputFormat.PLAIN_TEXT.toString().equals(inputFormatName)) {
+ inputFormat = InputFormat.PLAIN_TEXT;
+ }
+ else {
+ System.err.println("Unkown input format: " + inputFormatName);
+ return false;
+ }
+
+ }
+ else if (INPUT_ENCODING_PARAM.equals(arg)) {
+ if (index >= args.length) {
+ return false;
+ }
+
+ inputEncoding = args[index++];
+ }
+ else if (OUTPUT_FOLDER_PARAM.equals(arg)) {
+ if (index >= args.length) {
+ return false;
+ }
+
+ outputFolder = new File(args[index++]);
+ }
+ else if (OUTPUT_CLEAR_PARAM.equals(arg)) {
+ if (index >= args.length) {
+ return false;
+ }
+
+ outputFolderClear = Boolean.parseBoolean(args[index++]);
+ }
+ }
+
+ return necessaryArgCount == 2;
+ }
+
+ private static void processFile(File inputFile, InputFormat format,
+ AnalysisEngine aAE, CAS aCAS) throws IOException,
+ AnalysisEngineProcessException {
+
+ if (InputFormat.PLAIN_TEXT.equals(format)) {
+ String document = FileUtils.file2String(inputFile, inputEncoding);
+ document = document.trim();
+
+ // put document text in CAS
+ aCAS.setDocumentText(document);
+ }
+ else if (InputFormat.CAS.equals(format)) {
+ if (inputFile.getName().endsWith(".xmi")) {
+ FileInputStream inputStream = new FileInputStream(inputFile);
+ try {
+ XmiCasDeserializer.deserialize(inputStream, aCAS, true);
+ } catch (SAXException e) {
+ throw new IOException(e);
+ } finally {
+ inputStream.close();
+ }
+ }
+ else if (inputFile.getName().endsWith(".xcas")) {
+ FileInputStream inputStream = new FileInputStream(inputFile);
+ try {
+ XCASDeserializer.deserialize(inputStream, aCAS, true);
+ } catch (SAXException e) {
+ throw new IOException(e);
+ } finally {
+ inputStream.close();
+ }
+ }
+ }
+ else {
+ throw new IllegalStateException("Unexpected format!");
+ }
+
+ // process
+ aAE.process(aCAS);
+
+ if (outputFolder != null) {
+
+ File inputDirectory;
+ if (inputResource.isFile()) {
+ inputDirectory = inputResource.getParentFile();
+ }
+ else {
+ inputDirectory = inputResource;
+ }
+
+ String outputFilePath = inputFile.getPath();
+ outputFilePath = outputFilePath.replaceFirst(inputDirectory.getName(),
+ outputFolder.getName());
+
+ // cutoff file ending
+ int fileTypeIndex = outputFilePath.lastIndexOf(".");
+ if (fileTypeIndex != -1) {
+ outputFilePath = outputFilePath.substring(0, fileTypeIndex);
+ }
+
+ File outputFile = new File(outputFilePath + ".xmi");
+
+ // Create sub-directories
+ if (!outputFile.getParentFile().exists()) {
+ outputFile.getParentFile().mkdirs();
+ }
+
+ FileOutputStream out = new FileOutputStream(outputFile);
+
+ try {
+ // write XMI
+ XmiCasSerializer ser = new XmiCasSerializer(aCAS.getTypeSystem());
+ XMLSerializer xmlSer = new XMLSerializer(out, false);
+ try {
+ ser.serialize(aCAS, xmlSer.getContentHandler());
+ } catch (SAXException e) {
+ throw new IOException(e);
+ }
+ } finally {
+ if (out != null) {
+ out.close();
+ }
+ }
+ }
+
+ // reset the CAS to prepare it for processing the next document
+ aCAS.reset();
+ }
+
+ private static void findAndProcessFiles(File inputResource, FileFilter fileFilter,
+ AnalysisEngine aAE, CAS aCAS) throws IOException,
+ AnalysisEngineProcessException {
+
+ // Figure out if input resource is file or directory
+ if (inputResource.isDirectory()) {
+ // get all files in the input directory
+ File[] files = inputResource.listFiles(fileFilter);
+ if (files != null) {
+ for (int i = 0; i < files.length; i++) {
+ if (!files[i].isDirectory()) {
+ processFile(files[i], inputFormat, aAE, aCAS);
+ }
+ else {
+ findAndProcessFiles(files[i], fileFilter, aAE, aCAS);
+ }
+ }
+ }
+ }
+ else if (inputResource.isFile()) {
+ // Just process the single file
+ processFile(inputResource, inputFormat, aAE, aCAS);
+ }
+ }
+
+ private static boolean deleteFile(File file) {
+
+ if (file.isDirectory()) {
+ File subFiles[] = file.listFiles();
+
+ boolean success = true;
+ for (File subFile : subFiles) {
+ success = success && deleteFile(subFile);
+ }
+
+ return success;
+ }
+ else {
+ return file.delete();
+ }
+ }
+
+ public static void main(String[] args) throws Exception {
+
+ if (!parseCmdLineArgs(args)) {
+ throw new IllegalArgumentException("Passed arguments are invalid!");
+ }
+
+ if (outputFolder != null && outputFolderClear) {
+ File filesToDelete[] = outputFolder.listFiles();
+
+ for (File file : filesToDelete) {
+ deleteFile(file);
+ }
+ }
+
+ // get Resource Specifier from XML file
+ XMLInputSource in = new XMLInputSource(descriptor);
+ ResourceSpecifier specifier = UIMAFramework.getXMLParser().parseResourceSpecifier(in);
+
+ // create Analysis Engine
+ AnalysisEngine ae = UIMAFramework.produceAnalysisEngine(specifier);
+
+ // create a CAS
+ CAS cas = ae.newCAS();
+
+ // Create a file filter depending on the format
+ // to filter out all file which do not have the
+ // expected file ending
+ FileFilter fileFilter;
+ if (InputFormat.CAS.equals(inputFormat)) {
+ fileFilter = new FileFilter() {
+
+ public boolean accept(File file) {
+ return file.getName().endsWith(".xmi") || file.getName().endsWith(".xcas") ||
+ (inputRecursive && file.isDirectory());
+ }
+ };
+ }
+ else if (InputFormat.PLAIN_TEXT.equals(inputFormat)) {
+ fileFilter = new FileFilter() {
+
+ public boolean accept(File file) {
+ return file.getName().endsWith(".txt") || (inputRecursive && file.isDirectory());
+ }
+ };
+ }
+ else {
+ throw new IllegalStateException("Unexpected input format!");
+ }
+
+ findAndProcessFiles(inputResource, fileFilter, ae, cas);
+
+ ae.destroy();
+ }
+}
Propchange: uima/uimaj/trunk/uimaj-ep-launcher/src/main/java/org/apache/uima/ep_launcher/RemoteLauncher.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: uima/uimaj/trunk/uimaj-ep-launcher/src/main/java/org/apache/uima/ep_launcher/ui/AnalysisEngineMainTab.java
URL: http://svn.apache.org/viewvc/uima/uimaj/trunk/uimaj-ep-launcher/src/main/java/org/apache/uima/ep_launcher/ui/AnalysisEngineMainTab.java?rev=1086519&view=auto
==============================================================================
--- uima/uimaj/trunk/uimaj-ep-launcher/src/main/java/org/apache/uima/ep_launcher/ui/AnalysisEngineMainTab.java (added)
+++ uima/uimaj/trunk/uimaj-ep-launcher/src/main/java/org/apache/uima/ep_launcher/ui/AnalysisEngineMainTab.java Tue Mar 29 08:37:24 2011
@@ -0,0 +1,551 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.uima.ep_launcher.ui;
+
+import java.nio.charset.Charset;
+import java.nio.charset.IllegalCharsetNameException;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.eclipse.core.runtime.IPath;
+import org.apache.uima.ep_launcher.LauncherConstants;
+import org.apache.uima.ep_launcher.LauncherConstants.InputFormat;
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
+import org.eclipse.jdt.debug.ui.launchConfigurations.JavaLaunchTab;
+import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.layout.GridDataFactory;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.window.Window;
+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.events.SelectionListener;
+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;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.dialogs.ElementListSelectionDialog;
+import org.eclipse.ui.dialogs.ElementTreeSelectionDialog;
+import org.eclipse.ui.model.WorkbenchContentProvider;
+import org.eclipse.ui.model.WorkbenchLabelProvider;
+import org.eclipse.ui.dialogs.ContainerSelectionDialog;
+
+/**
+ * The Analysis Engine Main Tab is responsible to display/edit
+ * the UIMA related settings, such as project, descriptor file,
+ * input folders, etc.
+ */
+// TODO: Add an icon for the main tab
+public class AnalysisEngineMainTab extends JavaLaunchTab {
+
+ private Text projectText;
+
+ private Text descriptorText;
+
+ private Text inputText;
+ private Button recursivelyButton;
+
+ private Button casButton;
+ private Button plainTextButton;
+ private Combo encodingCombo;
+
+ private Text outputFolderText;
+ private Button clearFolderButton;
+
+ private IWorkspaceRoot getWorkspaceRoot() {
+ return ResourcesPlugin.getWorkspace().getRoot();
+ }
+
+ private IProject getSelectedProject() {
+ IResource project = ResourcesPlugin.getWorkspace().getRoot().findMember(projectText.getText());
+ if (project instanceof IProject) {
+ return (IProject) project;
+ }
+
+ return null;
+ }
+
+ private IContainer getContainer(String path) {
+ IProject project = getSelectedProject();
+
+ if (project != null) {
+ Path containerPath = new Path(path);
+ IResource resource = project.findMember(containerPath);
+ if (resource instanceof IContainer)
+ return (IContainer) resource;
+ }
+
+ return null;
+ }
+
+ public void createControl(Composite composite) {
+
+ Composite projectComposite = new Composite(composite, SWT.NONE);
+ GridLayout projectGridLayout = new GridLayout();
+ projectGridLayout.numColumns = 1;
+ projectGridLayout.horizontalSpacing = SWT.FILL;
+ projectComposite.setLayout(projectGridLayout);
+
+ // Project Group
+ Group projectGroup = new Group(projectComposite, SWT.None);
+ projectGroup.setText("Project:");
+
+ GridData projectGroupData = new GridData();
+ projectGroupData.grabExcessHorizontalSpace = true;
+ projectGroupData.horizontalAlignment = SWT.FILL;
+ projectGroup.setLayoutData(projectGroupData);
+
+ GridLayout projectGroupLayout = new GridLayout(2, false);
+ projectGroup.setLayout(projectGroupLayout);
+
+ projectText = new Text(projectGroup, SWT.BORDER);
+ GridDataFactory.swtDefaults().align(SWT.FILL, SWT.CENTER).
+ grab(true, false).applyTo(projectText);
+ projectText.addModifyListener(new ModifyListener() {
+
+ public void modifyText(ModifyEvent event) {
+ updateLaunchConfigurationDialog();
+ }
+ });
+
+ Button browseProject = new Button(projectGroup, SWT.NONE);
+ browseProject.setText("Browse ...");
+ browseProject.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ ILabelProvider labelProvider = new WorkbenchLabelProvider();
+
+ ElementListSelectionDialog dialog = new ElementListSelectionDialog(getShell(),
+ labelProvider);
+ dialog.setTitle("Project Selection");
+ dialog.setMessage("Select a project");
+ dialog.setElements(getWorkspaceRoot().getProjects());
+ IProject project = getSelectedProject();
+ if (project != null) {
+ dialog.setInitialSelections(new Object[] { project });
+ }
+
+ if (dialog.open() == Window.OK) {
+ IProject selectedProject = (IProject) dialog.getFirstResult();
+ projectText.setText(selectedProject.getName());
+ }
+ }
+ });
+
+ // Descriptor Group
+ Group descriptorGroup = new Group(projectComposite, SWT.None);
+ descriptorGroup.setText("Descriptor:");
+
+ GridData descriptorGroupData = new GridData();
+ descriptorGroupData.grabExcessHorizontalSpace = true;
+ descriptorGroupData.horizontalAlignment = SWT.FILL;
+ descriptorGroup.setLayoutData(projectGroupData);
+
+ GridLayout descriptorGroupLayout = new GridLayout(2, false);
+ descriptorGroup.setLayout(descriptorGroupLayout);
+
+ descriptorText = new Text(descriptorGroup, SWT.BORDER);
+ GridDataFactory.swtDefaults().align(SWT.FILL, SWT.CENTER).
+ grab(true, false).applyTo(descriptorText);
+ descriptorText.addModifyListener(new ModifyListener() {
+
+ public void modifyText(ModifyEvent event) {
+ updateLaunchConfigurationDialog();
+ }
+ });
+ Button browseDescriptor = new Button(descriptorGroup, SWT.NONE);
+ browseDescriptor.setText("Browse ...");
+ browseDescriptor.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(getShell(),
+ new WorkbenchLabelProvider(), new WorkbenchContentProvider());
+ dialog.setTitle("Select descriptor");
+ dialog.setMessage("Select descriptor");
+ dialog.setInput(getSelectedProject());
+ if (dialog.open() == IDialogConstants.OK_ID) {
+ IResource resource = (IResource) dialog.getFirstResult();
+ if (resource != null) {
+ String fileLoc = resource.getProjectRelativePath().toString();
+ descriptorText.setText(fileLoc);
+ }
+ }
+ }
+ });
+
+ // Input Resource Group
+ Group inputResourceGroup = new Group(projectComposite, SWT.None);
+ inputResourceGroup.setText("Input Resource:");
+
+ GridDataFactory.swtDefaults().align(SWT.FILL, SWT.CENTER).
+ grab(true, false).applyTo(inputResourceGroup);
+
+ GridLayout inputResourceGroupLayout = new GridLayout(2, false);
+ inputResourceGroup.setLayout(inputResourceGroupLayout);
+
+ inputText = new Text(inputResourceGroup, SWT.BORDER);
+ GridDataFactory.swtDefaults().align(SWT.FILL, SWT.CENTER).
+ grab(true, false).applyTo(inputText);
+ inputText.addModifyListener(new ModifyListener() {
+
+ public void modifyText(ModifyEvent event) {
+ updateLaunchConfigurationDialog();
+ }
+ });
+
+ Button browseInputResource = new Button(inputResourceGroup, SWT.NONE);
+ browseInputResource.setText("Browse ...");
+ browseInputResource.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(getShell(),
+ new WorkbenchLabelProvider(), new WorkbenchContentProvider());
+ dialog.setTitle("Select input folder or file");
+ dialog.setMessage("Select input folder or file");
+ dialog.setInput(getSelectedProject());
+ if (dialog.open() == IDialogConstants.OK_ID) {
+ IResource resource = (IResource) dialog.getFirstResult();
+ if (resource != null) {
+ String fileLoc = resource.getProjectRelativePath().toString();
+ inputText.setText(fileLoc);
+ }
+ }
+ }
+ });
+
+ recursivelyButton = new Button(inputResourceGroup, SWT.CHECK);
+ recursivelyButton.setText("Recursively, read all files under each directory");
+ GridDataFactory.swtDefaults().align(SWT.FILL, SWT.CENTER).
+ grab(true, false).applyTo(recursivelyButton);
+ recursivelyButton.addSelectionListener(new SelectionListener() {
+
+ public void widgetSelected(SelectionEvent event) {
+ updateLaunchConfigurationDialog();
+ }
+
+ public void widgetDefaultSelected(SelectionEvent event) {
+ }
+ });
+
+ Group inputFormatGroup = new Group(projectComposite, SWT.None);
+ inputFormatGroup.setText("Input Format:");
+
+ GridDataFactory.swtDefaults().align(SWT.FILL, SWT.CENTER).
+ grab(true, false).applyTo(inputFormatGroup);
+
+ GridLayout inputFormatGroupLayout = new GridLayout(2, false);
+ inputFormatGroup.setLayout(inputFormatGroupLayout);
+
+ casButton = new Button(inputFormatGroup, SWT.RADIO);
+ casButton.setText("CASes (XMI or XCAS format)");
+ GridDataFactory.swtDefaults().align(SWT.FILL, SWT.CENTER).
+ grab(true, false).span(2, 1).applyTo(casButton);
+ casButton.addSelectionListener(new SelectionListener() {
+
+ public void widgetSelected(SelectionEvent event) {
+ updateLaunchConfigurationDialog();
+ }
+
+ public void widgetDefaultSelected(SelectionEvent event) {
+ }
+ });
+
+ plainTextButton = new Button(inputFormatGroup, SWT.RADIO);
+ GridDataFactory.swtDefaults().align(SWT.LEFT, SWT.CENTER).
+ grab(false, false).applyTo(plainTextButton);
+ plainTextButton.addSelectionListener(new SelectionListener() {
+
+ public void widgetSelected(SelectionEvent event) {
+ encodingCombo.setEnabled(plainTextButton.getSelection());
+ updateLaunchConfigurationDialog();
+ }
+
+ public void widgetDefaultSelected(SelectionEvent event) {
+ }
+ });
+ plainTextButton.setText("Plain Text, encoding:");
+
+ encodingCombo = new Combo(inputFormatGroup, SWT.NONE);
+ GridDataFactory.swtDefaults().align(SWT.LEFT, SWT.CENTER).
+ grab(false, false).applyTo(encodingCombo);
+
+ encodingCombo.addModifyListener(new ModifyListener() {
+
+ public void modifyText(ModifyEvent event) {
+ updateLaunchConfigurationDialog();
+ }
+ });
+
+ String defaultEncoding = Charset.defaultCharset().displayName();
+
+ Set<String> charsets = new HashSet<String>();
+ charsets.add("US-ASCII");
+ charsets.add("ISO-8859-1");
+ charsets.add("UTF-8");
+ charsets.add("UTF-16BE");
+ charsets.add("UTF-16LE");
+ charsets.add("UTF-16");
+ charsets.add(defaultEncoding);
+
+ encodingCombo.setItems(charsets.toArray(new String[charsets.size()]));
+ // Will be enabled by initializeForm if format is plain text
+ encodingCombo.setEnabled(false);
+
+ // Output Folder
+ Group outputFolderGroup = new Group(projectComposite, SWT.None);
+ outputFolderGroup.setText("Output Folder:");
+ GridDataFactory.swtDefaults().align(SWT.FILL, SWT.CENTER).
+ grab(true, false).applyTo(outputFolderGroup);
+ GridLayout outputFolderGroupLayout = new GridLayout(2, false);
+ outputFolderGroup.setLayout(outputFolderGroupLayout);
+ outputFolderText = new Text(outputFolderGroup, SWT.BORDER);
+ GridDataFactory.swtDefaults().align(SWT.FILL, SWT.CENTER).
+ grab(true, false).applyTo(outputFolderText);
+ outputFolderText.addModifyListener(new ModifyListener() {
+
+ public void modifyText(ModifyEvent event) {
+ updateLaunchConfigurationDialog();
+ }
+ });
+
+ Button browseOutputFolderButton = new Button(outputFolderGroup, SWT.NONE);
+ browseOutputFolderButton.setText("Browse ...");
+ browseOutputFolderButton.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ // TODO: Only select elements within project
+ String currentContainerString = outputFolderText.getText();
+ IContainer currentContainer = getContainer(currentContainerString);
+ ContainerSelectionDialog dialog = new ContainerSelectionDialog(getShell(),
+ currentContainer, false, "Select output folder");
+ dialog.showClosedProjects(false);
+ dialog.open();
+ Object[] results = dialog.getResult();
+ if ((results != null) && (results.length > 0) && (results[0] instanceof IPath)) {
+ IPath path = (IPath) results[0];
+ String containerName = path.toOSString();
+ outputFolderText.setText(containerName);
+ }
+ }
+ });
+
+ clearFolderButton = new Button(outputFolderGroup, SWT.CHECK);
+ clearFolderButton.setText("Clear the output folder");
+ GridDataFactory.swtDefaults().align(SWT.FILL, SWT.CENTER).
+ grab(true, false).applyTo(clearFolderButton);
+ clearFolderButton.addSelectionListener(new SelectionListener() {
+ public void widgetSelected(SelectionEvent event) {
+ updateLaunchConfigurationDialog();
+ }
+
+ public void widgetDefaultSelected(SelectionEvent event) {
+ }
+ });
+ setControl(projectComposite);
+ }
+
+ public String getName() {
+ return "Main";
+ }
+
+ @Override
+ public boolean isValid(ILaunchConfiguration launchConfig) {
+
+ setErrorMessage(null);
+
+
+ // Project must be set, check that project does exist
+ String projectName = projectText.getText();
+
+ IResource projectResource = ResourcesPlugin.getWorkspace().getRoot().findMember(projectName);
+ if (!(projectResource instanceof IProject)) {
+ setErrorMessage("Project does not exist!");
+ return false;
+ }
+
+ IProject project = (IProject) projectResource;
+
+ // Descriptor must be set and valid file
+ IResource descriptorResource = project.findMember(descriptorText.getText());
+ if (!(descriptorResource instanceof IFile)) {
+ setErrorMessage("Descriptor must be an existing file!");
+ return false;
+ }
+
+ // Input folder or file must be set
+ IResource inputResource = project.findMember(inputText.getText());
+ if (inputResource == null) {
+ setErrorMessage("Input resource must be an existing file or folder!");
+ return false;
+ }
+
+ // Validate the input encoding
+ if (plainTextButton.getSelection()) {
+ String inptuEncoding = encodingCombo.getText();
+
+ boolean isEncodingValid;
+ try {
+ isEncodingValid = Charset.isSupported(inptuEncoding);
+ }
+ catch (IllegalCharsetNameException e) {
+ isEncodingValid = false;
+ }
+
+ if (!isEncodingValid) {
+ setErrorMessage("Invalid input format encoding!");
+ return false;
+ }
+ }
+
+ // Validate output folder
+ if (outputFolderText.getText().length() > 0) {
+ IResource outputResource = project.findMember(outputFolderText.getText());
+ if (!(outputResource instanceof IFolder)) {
+ setErrorMessage("The output folder must be a valid folder or not be set!");
+ return false;
+ }
+ }
+
+ return super.isValid(launchConfig);
+ }
+
+ public void performApply(ILaunchConfigurationWorkingCopy config) {
+ config.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME,
+ (String) projectText.getText());
+
+ config.setAttribute(LauncherConstants.ATTR_DESCRIPTOR_NAME, descriptorText.getText());
+
+ config.setAttribute(LauncherConstants.ATTR_INPUT_NAME, inputText.getText());
+ config.setAttribute(LauncherConstants.ATTR_INPUT_RECURSIVELY_NAME,
+ Boolean.valueOf(recursivelyButton.getSelection()));
+
+ String formatName;
+ if (casButton.getSelection()) {
+ formatName = InputFormat.CAS.toString();
+ }
+ else if (plainTextButton.getSelection()) {
+ formatName = InputFormat.PLAIN_TEXT.toString();
+ }
+ else {
+ throw new IllegalStateException("One button must always be selected!");
+ }
+
+ config.setAttribute(LauncherConstants.ATTR_INPUT_FORMAT_NAME, formatName);
+
+ config.setAttribute(LauncherConstants.ATTR_INPUT_ENCODING_NAME, encodingCombo.getText());
+
+ config.setAttribute(LauncherConstants.ATTR_OUTPUT_FOLDER_NAME, outputFolderText.getText());
+ config.setAttribute(LauncherConstants.ATTR_OUTPUT_CLEAR_NAME,
+ Boolean.valueOf(clearFolderButton.getSelection()));
+ }
+
+ public void setDefaults(ILaunchConfigurationWorkingCopy config) {
+ // no defaults are provided yet
+ }
+
+ @Override
+ public void initializeFrom(ILaunchConfiguration config) {
+
+ // TODO: Log errors if reading fails?
+
+ // write values to launch configuration ...
+ try {
+ projectText.setText(config.getAttribute(IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME, ""));
+ } catch (CoreException e) {
+ projectText.setText("");
+ }
+
+ try {
+ descriptorText.setText(config.getAttribute(LauncherConstants.ATTR_DESCRIPTOR_NAME, ""));
+ } catch (CoreException e) {
+ descriptorText.setText("");
+ }
+
+ try {
+ inputText.setText(config.getAttribute(LauncherConstants.ATTR_INPUT_NAME, ""));
+ } catch (CoreException e) {
+ inputText.setText("");
+ }
+
+ // recursive button
+ try {
+ recursivelyButton.setSelection((Boolean) config.getAttribute(
+ LauncherConstants.ATTR_INPUT_RECURSIVELY_NAME, false));
+ } catch (CoreException e) {
+ recursivelyButton.setSelection(false);
+ }
+
+ // Format buttons
+ String formatName;
+ try {
+ formatName = config.getAttribute(LauncherConstants.ATTR_INPUT_FORMAT_NAME, InputFormat.CAS.toString());
+ } catch (CoreException e) {
+ formatName = InputFormat.CAS.toString();
+ }
+
+ if (InputFormat.CAS.toString().equals(formatName)) {
+ casButton.setSelection(true);
+ }
+ else if (InputFormat.PLAIN_TEXT.toString().equals(formatName)) {
+ plainTextButton.setSelection(true);
+ encodingCombo.setEnabled(true);
+
+ }
+
+ // Always remember the input encoding, even so plain text is not selected,
+ // it might be convenient for the user
+ String inputEncoding = Charset.defaultCharset().displayName();
+ try {
+ inputEncoding = config.getAttribute(LauncherConstants.ATTR_INPUT_ENCODING_NAME, inputEncoding);
+ } catch (CoreException e) {
+ }
+
+ encodingCombo.setText(inputEncoding);
+
+ // output folder
+ try {
+ outputFolderText.setText(config.getAttribute(LauncherConstants.ATTR_OUTPUT_FOLDER_NAME, ""));
+ } catch (CoreException e) {
+ outputFolderText.setText("");
+ }
+
+ // clear folder button
+ try {
+ clearFolderButton.setSelection((Boolean) config.getAttribute(
+ LauncherConstants.ATTR_OUTPUT_CLEAR_NAME, false));
+ } catch (CoreException e) {
+ clearFolderButton.setSelection(false);
+ }
+
+ super.initializeFrom(config);
+ }
+}
Propchange: uima/uimaj/trunk/uimaj-ep-launcher/src/main/java/org/apache/uima/ep_launcher/ui/AnalysisEngineMainTab.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: uima/uimaj/trunk/uimaj-ep-launcher/src/main/java/org/apache/uima/ep_launcher/ui/AnalysisEngineTabGroup.java
URL: http://svn.apache.org/viewvc/uima/uimaj/trunk/uimaj-ep-launcher/src/main/java/org/apache/uima/ep_launcher/ui/AnalysisEngineTabGroup.java?rev=1086519&view=auto
==============================================================================
--- uima/uimaj/trunk/uimaj-ep-launcher/src/main/java/org/apache/uima/ep_launcher/ui/AnalysisEngineTabGroup.java (added)
+++ uima/uimaj/trunk/uimaj-ep-launcher/src/main/java/org/apache/uima/ep_launcher/ui/AnalysisEngineTabGroup.java Tue Mar 29 08:37:24 2011
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.uima.ep_launcher.ui;
+
+import org.eclipse.debug.ui.AbstractLaunchConfigurationTabGroup;
+import org.eclipse.debug.ui.CommonTab;
+import org.eclipse.debug.ui.EnvironmentTab;
+import org.eclipse.debug.ui.ILaunchConfigurationDialog;
+import org.eclipse.debug.ui.ILaunchConfigurationTab;
+import org.eclipse.jdt.debug.ui.launchConfigurations.JavaClasspathTab;
+import org.eclipse.jdt.debug.ui.launchConfigurations.JavaJRETab;
+
+/**
+ * The tab group to set up all the parameters which are necessary to run
+ * an analysis engine.
+ */
+public class AnalysisEngineTabGroup extends AbstractLaunchConfigurationTabGroup {
+
+ public void createTabs(ILaunchConfigurationDialog dialog, String mode) {
+
+ ILaunchConfigurationTab[] tabs = new ILaunchConfigurationTab[] {
+ new AnalysisEngineMainTab(),
+ new JavaJRETab(),
+ new JavaClasspathTab(),
+ // TODO: Error launch configuration does not support source lookup, why not?
+ // It should be on the tab.
+ // new SourceLookupTab(),
+ new EnvironmentTab(),
+ new CommonTab()
+ };
+
+ setTabs(tabs);
+ }
+}
Propchange: uima/uimaj/trunk/uimaj-ep-launcher/src/main/java/org/apache/uima/ep_launcher/ui/AnalysisEngineTabGroup.java
------------------------------------------------------------------------------
svn:mime-type = text/plain