You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@uima.apache.org by pk...@apache.org on 2013/04/02 17:49:18 UTC
svn commit: r1463605 - in /uima/sandbox/textmarker/trunk/textmarker-ep-ide:
./ src/main/java/org/apache/uima/textmarker/ide/core/builder/
src/main/java/org/apache/uima/textmarker/ide/core/codeassist/
src/main/java/org/apache/uima/textmarker/ide/debug/u...
Author: pkluegl
Date: Tue Apr 2 15:49:18 2013
New Revision: 1463605
URL: http://svn.apache.org/r1463605
Log:
UIMA-2519
- added functionality to work with other java projects or with some jars
Modified:
uima/sandbox/textmarker/trunk/textmarker-ep-ide/plugin.xml
uima/sandbox/textmarker/trunk/textmarker-ep-ide/src/main/java/org/apache/uima/textmarker/ide/core/builder/TextMarkerBuilder.java
uima/sandbox/textmarker/trunk/textmarker-ep-ide/src/main/java/org/apache/uima/textmarker/ide/core/builder/TextMarkerProjectUtils.java
uima/sandbox/textmarker/trunk/textmarker-ep-ide/src/main/java/org/apache/uima/textmarker/ide/core/codeassist/TextMarkerCompletionEngine.java
uima/sandbox/textmarker/trunk/textmarker-ep-ide/src/main/java/org/apache/uima/textmarker/ide/debug/ui/launchConfiguration/TextMarkerMainLaunchConfigurationTab.java
uima/sandbox/textmarker/trunk/textmarker-ep-ide/src/main/java/org/apache/uima/textmarker/ide/debug/ui/launchConfiguration/TextMarkerTabGroup.java
uima/sandbox/textmarker/trunk/textmarker-ep-ide/src/main/java/org/apache/uima/textmarker/ide/launching/TextMarkerLaunchConfigurationDelegate.java
uima/sandbox/textmarker/trunk/textmarker-ep-ide/src/main/java/org/apache/uima/textmarker/ide/launching/TextMarkerLaunchConstants.java
uima/sandbox/textmarker/trunk/textmarker-ep-ide/src/main/java/org/apache/uima/textmarker/ide/launching/TextMarkerLauncher.java
uima/sandbox/textmarker/trunk/textmarker-ep-ide/src/main/java/org/apache/uima/textmarker/ide/validator/TextMarkerCheckerUtils.java
uima/sandbox/textmarker/trunk/textmarker-ep-ide/src/main/java/org/apache/uima/textmarker/ide/validator/TextMarkerTypeChecker.java
Modified: uima/sandbox/textmarker/trunk/textmarker-ep-ide/plugin.xml
URL: http://svn.apache.org/viewvc/uima/sandbox/textmarker/trunk/textmarker-ep-ide/plugin.xml?rev=1463605&r1=1463604&r2=1463605&view=diff
==============================================================================
--- uima/sandbox/textmarker/trunk/textmarker-ep-ide/plugin.xml (original)
+++ uima/sandbox/textmarker/trunk/textmarker-ep-ide/plugin.xml Tue Apr 2 15:49:18 2013
@@ -1404,6 +1404,7 @@ under the License.
nature="org.apache.uima.textmarker.ide.nature">
</validatorType>
</extension>
+ <!--
<extension
point="org.eclipse.dltk.ui.buildpathContainerPage">
<buildpathContainerPage
@@ -1412,5 +1413,6 @@ under the License.
name="Java Library"
nature="org.apache.uima.textmarker.ide.nature">
</buildpathContainerPage>
- </extension>
+ </extension>
+ -->
</plugin>
Modified: uima/sandbox/textmarker/trunk/textmarker-ep-ide/src/main/java/org/apache/uima/textmarker/ide/core/builder/TextMarkerBuilder.java
URL: http://svn.apache.org/viewvc/uima/sandbox/textmarker/trunk/textmarker-ep-ide/src/main/java/org/apache/uima/textmarker/ide/core/builder/TextMarkerBuilder.java?rev=1463605&r1=1463604&r2=1463605&view=diff
==============================================================================
--- uima/sandbox/textmarker/trunk/textmarker-ep-ide/src/main/java/org/apache/uima/textmarker/ide/core/builder/TextMarkerBuilder.java (original)
+++ uima/sandbox/textmarker/trunk/textmarker-ep-ide/src/main/java/org/apache/uima/textmarker/ide/core/builder/TextMarkerBuilder.java Tue Apr 2 15:49:18 2013
@@ -146,7 +146,7 @@ public class TextMarkerBuilder extends A
List<IFolder> descriptorFolders = TextMarkerProjectUtils.getAllDescriptorFolders(proj
.getProject());
descriptorPathList.addAll(TextMarkerProjectUtils.getFolderLocations(descriptorFolders));
- } catch (CoreException e) {
+ } catch (Exception e) {
TextMarkerIdePlugin.error(e);
}
Modified: uima/sandbox/textmarker/trunk/textmarker-ep-ide/src/main/java/org/apache/uima/textmarker/ide/core/builder/TextMarkerProjectUtils.java
URL: http://svn.apache.org/viewvc/uima/sandbox/textmarker/trunk/textmarker-ep-ide/src/main/java/org/apache/uima/textmarker/ide/core/builder/TextMarkerProjectUtils.java?rev=1463605&r1=1463604&r2=1463605&view=diff
==============================================================================
--- uima/sandbox/textmarker/trunk/textmarker-ep-ide/src/main/java/org/apache/uima/textmarker/ide/core/builder/TextMarkerProjectUtils.java (original)
+++ uima/sandbox/textmarker/trunk/textmarker-ep-ide/src/main/java/org/apache/uima/textmarker/ide/core/builder/TextMarkerProjectUtils.java Tue Apr 2 15:49:18 2013
@@ -23,11 +23,16 @@ import java.io.File;
import java.util.ArrayList;
import java.util.List;
+import javax.swing.UIManager;
+
import org.apache.commons.lang3.StringUtils;
import org.apache.uima.textmarker.ide.TextMarkerIdePlugin;
+import org.apache.uima.textmarker.ide.core.TextMarkerNature;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IProjectNature;
import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.QualifiedName;
@@ -36,9 +41,12 @@ import org.eclipse.dltk.core.IModelEleme
import org.eclipse.dltk.core.IScriptFolder;
import org.eclipse.dltk.core.IScriptProject;
import org.eclipse.dltk.core.ModelException;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.JavaCore;
public class TextMarkerProjectUtils {
+ public static final String JAVANATURE = "org.eclipse.jdt.core.javanature";
private static final String CDE_DATA_PATH = "CDEdataPath";
public static IPath getEngineDescriptorPath(IPath scriptPath, IProject project) {
@@ -80,8 +88,14 @@ public class TextMarkerProjectUtils {
public static List<IFolder> getScriptFolders(IScriptProject proj) {
List<IFolder> result = new ArrayList<IFolder>();
+ IScriptFolder[] scriptFolders = null;
try {
- IScriptFolder[] scriptFolders = proj.getScriptFolders();
+ scriptFolders = proj.getScriptFolders();
+ } catch (ModelException e) {
+ // referring to a non-textmarker project
+ // TextMarkerIdePlugin.error(e);
+ }
+ if (scriptFolders != null) {
for (IScriptFolder eachScriptFolder : scriptFolders) {
IModelElement parent = eachScriptFolder.getParent();
IResource resource = parent.getResource();
@@ -91,8 +105,6 @@ public class TextMarkerProjectUtils {
}
}
}
- } catch (ModelException e) {
- TextMarkerIdePlugin.error(e);
}
return result;
}
@@ -113,11 +125,28 @@ public class TextMarkerProjectUtils {
return result;
}
- public static List<IFolder> getDescriptorFolders(IProject proj) throws ModelException {
+ public static List<IFolder> getDescriptorFolders(IProject proj) throws CoreException {
List<IFolder> result = new ArrayList<IFolder>();
- IFolder findElement = proj.getFolder(getDefaultDescriptorLocation());
- if (findElement != null) {
- result.add((IFolder) findElement);
+ IProjectNature javaNature = proj.getNature(JAVANATURE);
+ if (javaNature != null) {
+ IJavaProject javaProject = JavaCore.create(proj);
+ IPath readOutputLocation = javaProject.readOutputLocation();
+ IFolder folder = ResourcesPlugin.getWorkspace().getRoot().getFolder(readOutputLocation);
+ result.add(folder);
+ }
+ IProjectNature pearNature = proj.getNature("org.apache.uima.pear.UimaNature");
+ if (pearNature != null) {
+ IFolder findElement = proj.getFolder("desc");
+ if (findElement != null) {
+ result.add((IFolder) findElement);
+ }
+ }
+ IProjectNature textmarkerNature = proj.getNature(TextMarkerNature.NATURE_ID);
+ if (textmarkerNature != null) {
+ IFolder findElement = proj.getFolder(getDefaultDescriptorLocation());
+ if (findElement != null) {
+ result.add((IFolder) findElement);
+ }
}
return result;
}
Modified: uima/sandbox/textmarker/trunk/textmarker-ep-ide/src/main/java/org/apache/uima/textmarker/ide/core/codeassist/TextMarkerCompletionEngine.java
URL: http://svn.apache.org/viewvc/uima/sandbox/textmarker/trunk/textmarker-ep-ide/src/main/java/org/apache/uima/textmarker/ide/core/codeassist/TextMarkerCompletionEngine.java?rev=1463605&r1=1463604&r2=1463605&view=diff
==============================================================================
--- uima/sandbox/textmarker/trunk/textmarker-ep-ide/src/main/java/org/apache/uima/textmarker/ide/core/codeassist/TextMarkerCompletionEngine.java (original)
+++ uima/sandbox/textmarker/trunk/textmarker-ep-ide/src/main/java/org/apache/uima/textmarker/ide/core/codeassist/TextMarkerCompletionEngine.java Tue Apr 2 15:49:18 2013
@@ -197,7 +197,7 @@ public class TextMarkerCompletionEngine
private void doCompletionOnComponentDeclaration(IModuleSource cu,
TextMarkerModuleDeclaration parsed, String startPart, int type, String complString)
- throws CoreException {
+ throws Exception {
if (type == ComponentDeclaration.SCRIPT) {
List<IFolder> scriptFolders = TextMarkerProjectUtils.getAllScriptFolders(sourceModule
.getModelElement().getScriptProject());
Modified: uima/sandbox/textmarker/trunk/textmarker-ep-ide/src/main/java/org/apache/uima/textmarker/ide/debug/ui/launchConfiguration/TextMarkerMainLaunchConfigurationTab.java
URL: http://svn.apache.org/viewvc/uima/sandbox/textmarker/trunk/textmarker-ep-ide/src/main/java/org/apache/uima/textmarker/ide/debug/ui/launchConfiguration/TextMarkerMainLaunchConfigurationTab.java?rev=1463605&r1=1463604&r2=1463605&view=diff
==============================================================================
--- uima/sandbox/textmarker/trunk/textmarker-ep-ide/src/main/java/org/apache/uima/textmarker/ide/debug/ui/launchConfiguration/TextMarkerMainLaunchConfigurationTab.java (original)
+++ uima/sandbox/textmarker/trunk/textmarker-ep-ide/src/main/java/org/apache/uima/textmarker/ide/debug/ui/launchConfiguration/TextMarkerMainLaunchConfigurationTab.java Tue Apr 2 15:49:18 2013
@@ -19,14 +19,52 @@
package org.apache.uima.textmarker.ide.debug.ui.launchConfiguration;
+import org.apache.uima.cas.CAS;
import org.apache.uima.textmarker.ide.TextMarkerIdePlugin;
import org.apache.uima.textmarker.ide.core.TextMarkerNature;
+import org.apache.uima.textmarker.ide.core.builder.TextMarkerProjectUtils;
+import org.apache.uima.textmarker.ide.launching.TextMarkerLaunchConstants;
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
+import org.eclipse.dltk.core.IScriptProject;
import org.eclipse.dltk.core.PreferencesLookupDelegate;
import org.eclipse.dltk.debug.core.DLTKDebugPreferenceConstants;
import org.eclipse.dltk.debug.ui.launchConfigurations.MainLaunchConfigurationTab;
+import org.eclipse.dltk.launching.AbstractScriptLaunchConfigurationDelegate;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.layout.GridDataFactory;
+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.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.dialogs.ContainerSelectionDialog;
+import org.eclipse.ui.dialogs.ElementTreeSelectionDialog;
+import org.eclipse.ui.model.WorkbenchContentProvider;
+import org.eclipse.ui.model.WorkbenchLabelProvider;
public class TextMarkerMainLaunchConfigurationTab extends MainLaunchConfigurationTab {
+ private Text inputText;
+
+ private Button recursivelyButton;
+
+ private Text outputFolderText;
+
+ private Text viewText;
+
public TextMarkerMainLaunchConfigurationTab(String mode) {
super(mode);
}
@@ -57,6 +95,190 @@ public class TextMarkerMainLaunchConfigu
return TextMarkerNature.NATURE_ID;
}
+ @Override
+ protected void doCreateControl(Composite composite) {
+ super.doCreateControl(composite);
+ // Input Resource Group
+ Group inputResourceGroup = new Group(composite, SWT.None);
+ inputResourceGroup.setText("Input Folder:");
+
+ GridDataFactory.swtDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false)
+ .applyTo(inputResourceGroup);
+
+ GridLayout inputResourceGroupLayout = new GridLayout(4, false);
+ inputResourceGroup.setLayout(inputResourceGroupLayout);
+
+ inputText = new Text(inputResourceGroup, SWT.BORDER);
+ GridDataFactory.swtDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).span(3,1).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");
+ dialog.setMessage("Select input folder");
+
+ dialog.setInput(getProject().getProject());
+ dialog.setInitialSelection(getWorkspaceRoot().findMember(inputText.getText()));
+ if (dialog.open() == IDialogConstants.OK_ID) {
+ IResource resource = (IResource) dialog.getFirstResult();
+ if (resource != null) {
+ String fileLoc = resource.getFullPath().toString();
+ inputText.setText(fileLoc);
+ }
+ }
+ }
+ });
+
+ recursivelyButton = new Button(inputResourceGroup, SWT.CHECK);
+ recursivelyButton.setText("Recursively");
+ 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) {
+ }
+ });
+
+
+
+ Label viewLabel = new Label(inputResourceGroup, SWT.NONE);
+ viewLabel.setText("View Name:");
+ viewText = new Text(inputResourceGroup, SWT.BORDER);
+ GridDataFactory.swtDefaults().hint(250, SWT.DEFAULT).align(SWT.LEFT, SWT.CENTER)
+ .grab(true, false).applyTo(viewText);
+ viewText.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent event) {
+ updateLaunchConfigurationDialog();
+ }
+ });
+
+ Group outputFolderGroup = new Group(composite, 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) {
+ 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);
+ }
+ }
+ });
+
+ }
+
+ private IContainer getContainer(String path) {
+ Path containerPath = new Path(path);
+ IResource resource = getWorkspaceRoot().findMember(containerPath);
+ if (resource instanceof IContainer)
+ return (IContainer) resource;
+
+ return null;
+ }
+
+ @Override
+ public void doInitializeForm(ILaunchConfiguration config) {
+ super.doInitializeForm(config);
+
+
+ IScriptProject proj = null;
+ try {
+ proj = AbstractScriptLaunchConfigurationDelegate.getScriptProject(config);
+ } catch (CoreException e) {
+ TextMarkerIdePlugin.error(e);
+ }
+ String defaultInputLocation = TextMarkerProjectUtils.getDefaultInputLocation();
+ String defaultOutputLocation = TextMarkerProjectUtils.getDefaultOutputLocation();
+ IResource inputFolder = proj.getProject().findMember(defaultInputLocation);
+ IResource outputFolder = proj.getProject().findMember(defaultOutputLocation);
+
+
+ try {
+ recursivelyButton.setSelection(config.getAttribute(TextMarkerLaunchConstants.RECURSIVE, false));
+ } catch (CoreException e) {
+ recursivelyButton.setSelection(false);
+ }
+
+ try {
+ viewText.setText(config.getAttribute(TextMarkerLaunchConstants.VIEW, CAS.NAME_DEFAULT_SOFA));
+ } catch (CoreException e) {
+ viewText.setText(CAS.NAME_DEFAULT_SOFA);
+ }
+
+ try {
+ inputText.setText(config.getAttribute(TextMarkerLaunchConstants.INPUT_FOLDER, inputFolder.getFullPath().toPortableString()));
+ } catch (CoreException e) {
+ inputText.setText(inputFolder.getFullPath().toPortableString());
+ }
+
+ try {
+ outputFolderText.setText(config.getAttribute(TextMarkerLaunchConstants.OUTPUT_FOLDER, outputFolder.getFullPath().toPortableString()));
+ } catch (CoreException e) {
+ outputFolderText.setText(outputFolder.getFullPath().toPortableString());
+ }
+
+ }
+
+ @Override
+ public void doPerformApply(ILaunchConfigurationWorkingCopy config) {
+ super.doPerformApply(config);
+
+ config.setAttribute(TextMarkerLaunchConstants.RECURSIVE, recursivelyButton.getSelection());
+ config.setAttribute(TextMarkerLaunchConstants.VIEW, viewText.getText());
+ config.setAttribute(TextMarkerLaunchConstants.INPUT_FOLDER, inputText.getText());
+ config.setAttribute(TextMarkerLaunchConstants.OUTPUT_FOLDER, outputFolderText.getText());
+
+ }
+
+ @Override
+ public void setDefaults(ILaunchConfigurationWorkingCopy config) {
+ super.setDefaults(config);
+ IScriptProject proj = null;
+ try {
+ proj = AbstractScriptLaunchConfigurationDelegate.getScriptProject(config);
+ } catch (CoreException e) {
+ TextMarkerIdePlugin.error(e);
+ }
+ String defaultInputLocation = TextMarkerProjectUtils.getDefaultInputLocation();
+ String defaultOutputLocation = TextMarkerProjectUtils.getDefaultOutputLocation();
+ IResource inputFolder = proj.getProject().findMember(defaultInputLocation);
+ IResource outputFolder = proj.getProject().findMember(defaultOutputLocation);
+ config.setAttribute(TextMarkerLaunchConstants.RECURSIVE, false);
+ config.setAttribute(TextMarkerLaunchConstants.INPUT_FOLDER, inputFolder.getFullPath().toPortableString());
+ config.setAttribute(TextMarkerLaunchConstants.OUTPUT_FOLDER, outputFolder.getFullPath().toPortableString());
+ }
}
Modified: uima/sandbox/textmarker/trunk/textmarker-ep-ide/src/main/java/org/apache/uima/textmarker/ide/debug/ui/launchConfiguration/TextMarkerTabGroup.java
URL: http://svn.apache.org/viewvc/uima/sandbox/textmarker/trunk/textmarker-ep-ide/src/main/java/org/apache/uima/textmarker/ide/debug/ui/launchConfiguration/TextMarkerTabGroup.java?rev=1463605&r1=1463604&r2=1463605&view=diff
==============================================================================
--- uima/sandbox/textmarker/trunk/textmarker-ep-ide/src/main/java/org/apache/uima/textmarker/ide/debug/ui/launchConfiguration/TextMarkerTabGroup.java (original)
+++ uima/sandbox/textmarker/trunk/textmarker-ep-ide/src/main/java/org/apache/uima/textmarker/ide/debug/ui/launchConfiguration/TextMarkerTabGroup.java Tue Apr 2 15:49:18 2013
@@ -15,7 +15,7 @@
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
-*/
+ */
package org.apache.uima.textmarker.ide.debug.ui.launchConfiguration;
@@ -25,13 +25,15 @@ import org.eclipse.debug.ui.EnvironmentT
import org.eclipse.debug.ui.ILaunchConfigurationDialog;
import org.eclipse.debug.ui.ILaunchConfigurationTab;
import org.eclipse.dltk.debug.ui.launchConfigurations.ScriptCommonTab;
+import org.eclipse.jdt.debug.ui.launchConfigurations.JavaClasspathTab;
+import org.eclipse.jdt.debug.ui.launchConfigurations.JavaJRETab;
public class TextMarkerTabGroup extends AbstractLaunchConfigurationTabGroup {
public void createTabs(ILaunchConfigurationDialog dialog, String mode) {
TextMarkerMainLaunchConfigurationTab main = new TextMarkerMainLaunchConfigurationTab(mode);
- ILaunchConfigurationTab[] tabs = new ILaunchConfigurationTab[] { main,
- new TextMarkerArgumentsTab(), new TextMarkerInterpreterTab(main), new EnvironmentTab(),
- new ScriptCommonTab(main) };
+ ILaunchConfigurationTab[] tabs = new ILaunchConfigurationTab[] { main, new JavaJRETab(),
+ new JavaClasspathTab(), new TextMarkerArgumentsTab(), new TextMarkerInterpreterTab(main),
+ new EnvironmentTab(), new ScriptCommonTab(main) };
setTabs(tabs);
}
}
Modified: uima/sandbox/textmarker/trunk/textmarker-ep-ide/src/main/java/org/apache/uima/textmarker/ide/launching/TextMarkerLaunchConfigurationDelegate.java
URL: http://svn.apache.org/viewvc/uima/sandbox/textmarker/trunk/textmarker-ep-ide/src/main/java/org/apache/uima/textmarker/ide/launching/TextMarkerLaunchConfigurationDelegate.java?rev=1463605&r1=1463604&r2=1463605&view=diff
==============================================================================
--- uima/sandbox/textmarker/trunk/textmarker-ep-ide/src/main/java/org/apache/uima/textmarker/ide/launching/TextMarkerLaunchConfigurationDelegate.java (original)
+++ uima/sandbox/textmarker/trunk/textmarker-ep-ide/src/main/java/org/apache/uima/textmarker/ide/launching/TextMarkerLaunchConfigurationDelegate.java Tue Apr 2 15:49:18 2013
@@ -29,10 +29,13 @@ import java.util.Enumeration;
import java.util.List;
import java.util.Map;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.uima.cas.CAS;
import org.apache.uima.textmarker.ide.TextMarkerIdePlugin;
import org.apache.uima.textmarker.ide.core.TextMarkerCorePreferences;
import org.apache.uima.textmarker.ide.core.builder.TextMarkerProjectUtils;
import org.eclipse.core.resources.IBuildConfiguration;
+import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IProjectNature;
import org.eclipse.core.resources.IResource;
@@ -62,43 +65,71 @@ import org.osgi.framework.Bundle;
public class TextMarkerLaunchConfigurationDelegate extends JavaLaunchDelegate {
+ private String mode;
+
@Override
public String getProgramArguments(ILaunchConfiguration configuration) throws CoreException {
StringBuilder cmdline = new StringBuilder();
IScriptProject proj = AbstractScriptLaunchConfigurationDelegate.getScriptProject(configuration);
String mainScriptAttribute = configuration.getAttribute("mainScript", "");
+
+ String encoding = proj.getProject().getDefaultCharset();
+ String view = configuration.getAttribute(TextMarkerLaunchConstants.VIEW, CAS.NAME_DEFAULT_SOFA);
+ if(StringUtils.isBlank(view)) {
+ view = CAS.NAME_DEFAULT_SOFA;
+ }
+ boolean recursive = configuration.getAttribute(TextMarkerLaunchConstants.RECURSIVE, false);
+
IResource member = proj.getProject().findMember(mainScriptAttribute);
IPath projectPath = proj.getResource().getLocation();
IPath inputDirPath = projectPath.append(TextMarkerProjectUtils.getDefaultInputLocation());
IPath outputDirPath = projectPath.append(TextMarkerProjectUtils.getDefaultOutputLocation());
String engine = TextMarkerProjectUtils.getEngineDescriptorPath(member.getLocation(),
proj.getProject()).toPortableString();
-
- File inputDirFile = new File(inputDirPath.toPortableString());
- File inputFile = new File(inputDirFile, "test.text");
- URI relativize1 = inputFile.toURI().relativize(inputDirFile.toURI());
- URI relativize2 = inputDirFile.toURI().relativize(inputFile.toURI());
-
- // String category = configuration.getCategory();
- // IFile file = configuration.getFile();
- // String name = configuration.getName();
- // ILaunchConfigurationType type = configuration.getType();
- // IResource[] mappedResources = configuration.getMappedResources();
- // Map attributes = configuration.getAttributes();
-
+ String input = configuration.getAttribute(TextMarkerLaunchConstants.INPUT_FOLDER,
+ inputDirPath.toPortableString());
+ if(StringUtils.isBlank(input)) {
+ input = inputDirPath.toPortableString();
+ }
+ String output = configuration.getAttribute(TextMarkerLaunchConstants.OUTPUT_FOLDER,
+ outputDirPath.toPortableString());
+ if(StringUtils.isBlank(output)) {
+ output = outputDirPath.toPortableString();
+ }
+
cmdline.append(TextMarkerLaunchConstants.ARG_DESCRIPTOR + " ");
cmdline.append(engine + " ");
cmdline.append(TextMarkerLaunchConstants.ARG_INPUT_FOLDER + " ");
- cmdline.append(inputDirPath.toPortableString() + " ");
+ cmdline.append(makeAbsolute(input, configuration) + " ");
cmdline.append(TextMarkerLaunchConstants.ARG_OUTPUT_FOLDER + " ");
- cmdline.append(outputDirPath.toPortableString() + " ");
+ cmdline.append(makeAbsolute(output, configuration) + " ");
+
+ cmdline.append(TextMarkerLaunchConstants.ARG_MODE + " ");
+ cmdline.append(mode + " ");
+
+ cmdline.append(TextMarkerLaunchConstants.ARG_ENCODING + " ");
+ cmdline.append(encoding + " ");
+
+ cmdline.append(TextMarkerLaunchConstants.ARG_VIEW + " ");
+ cmdline.append(view + " ");
+
+ cmdline.append(TextMarkerLaunchConstants.ARG_RECURSIVE + " ");
+ cmdline.append(recursive + " ");
return cmdline.toString();
}
+ private String makeAbsolute(String input, ILaunchConfiguration configuration) throws CoreException {
+ IResource member = ResourcesPlugin.getWorkspace().getRoot().findMember(input);
+ if(member != null) {
+ return member.getLocation().toPortableString();
+ }
+ return input;
+ }
+
@Override
public String getMainTypeName(ILaunchConfiguration configuration) throws CoreException {
return "org.apache.uima.textmarker.ide.launching.TextMarkerLauncher";
@@ -111,33 +142,17 @@ public class TextMarkerLaunchConfigurati
List<String> extendedClasspath = new ArrayList<String>();
Collections.addAll(extendedClasspath, super.getClasspath(configuration));
- // TODO mixed
- String projectName = configuration.getAttribute("project", "");
- IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
- IBuildConfiguration[] buildConfigs = project.getBuildConfigs();
- IProject[] referencedProjects = project.getReferencedProjects();
- for (IProject iProject : referencedProjects) {
- Map<QualifiedName, String> persistentProperties = iProject.getPersistentProperties();
- IProjectNature nature = iProject.getNature("org.eclipse.jdt.core.javanature");
- if(nature !=null) {
- IJavaProject javaProject = JavaCore.create(iProject);
- IClasspathEntry[] rawClasspath = javaProject.getRawClasspath();
- IClasspathEntry[] referencedClasspathEntries = javaProject.getReferencedClasspathEntries();
- IClasspathEntry[] resolvedClasspath = javaProject.getResolvedClasspath(true);
+ IScriptProject scriptProject = AbstractScriptLaunchConfigurationDelegate.getScriptProject(configuration);
+ IProject[] referencedProjects = scriptProject.getProject().getReferencedProjects();
+ for (IProject eachProject : referencedProjects) {
+ IProjectNature nature = eachProject.getNature(TextMarkerProjectUtils.JAVANATURE);
+ if(nature != null) {
+ IJavaProject javaProject = JavaCore.create(eachProject);
IPath readOutputLocation = javaProject.readOutputLocation();
- IClasspathEntry[] readRawClasspath = javaProject.readRawClasspath();
- IResource findMember = ResourcesPlugin.getWorkspace().getRoot().getFolder(readOutputLocation);
-
- extendedClasspath.add(findMember.getLocation().toPortableString());
-
+ IFolder folder = ResourcesPlugin.getWorkspace().getRoot().getFolder(readOutputLocation);
+ extendedClasspath.add(folder.getLocation().toPortableString());
}
}
- IScriptProject scriptProject = DLTKCore.create(project);
- IBuildpathEntry[] rawBuildpath = scriptProject.getRawBuildpath();
- IBuildpathEntry[] resolvedBuildpath = scriptProject.getResolvedBuildpath(true);
-
-
- Map attributes = configuration.getAttributes();
// Normal mode, add the launcher plugin and uima runtime jar to the classpath
if (!Platform.inDevelopmentMode()) {
@@ -159,13 +174,9 @@ public class TextMarkerLaunchConfigurati
// 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(d.pluginIdToJarPath(TextMarkerIdePlugin.PLUGIN_ID) + "target/classes");
-
- // Add org.apache.uima.runtime jar to class path
+ extendedClasspath
+ .add(d.pluginIdToJarPath(TextMarkerIdePlugin.PLUGIN_ID) + "target/classes");
Bundle bundle = TextMarkerIdePlugin.getDefault().getBundle("org.apache.uima.runtime");
-
- // Ignore the case when runtime bundle does not exist ...
if (bundle != null) {
Enumeration<?> jarEnum = bundle.findEntries("/", "*.jar", true);
if (jarEnum == null) {
@@ -177,13 +188,8 @@ public class TextMarkerLaunchConfigurati
}
}
- // TODO
-
- // Add org.apache.uima.runtime jar to class path
Bundle bundle2 = TextMarkerIdePlugin.getDefault().getBundle(
"org.apache.uima.textmarker.engine");
-
- // Ignore the case when runtime bundle does not exist ...
if (bundle2 != null) {
Enumeration<?> jarEnum = bundle2.findEntries("/", "*.jar", true);
while (jarEnum != null && jarEnum.hasMoreElements()) {
@@ -204,15 +210,8 @@ public class TextMarkerLaunchConfigurati
@Override
public void launch(ILaunchConfiguration configuration, String mode, ILaunch launch,
IProgressMonitor monitor) throws CoreException {
- // clearOutputFolder();
- super.launch(configuration, mode, launch, monitor);
- while (!launch.isTerminated()) {
- try {
- Thread.sleep(100);
- } catch (InterruptedException e) {
- Thread.interrupted();
- }
- }
+ this.mode = mode;
+ IResource ouputFolder = null;
IScriptProject proj = AbstractScriptLaunchConfigurationDelegate.getScriptProject(configuration);
IPath projectPath = proj.getResource().getLocation();
IPath outputDirPath = projectPath.append(TextMarkerProjectUtils.getDefaultOutputLocation());
@@ -220,26 +219,48 @@ public class TextMarkerLaunchConfigurati
TextMarkerLaunchConstants.ARG_OUTPUT_FOLDER, outputDirPath.toPortableString());
if (outputFolderPath.length() != 0) {
IPath path = Path.fromPortableString(outputFolderPath);
- IResource result = ResourcesPlugin.getWorkspace().getRoot().getContainerForLocation(path);
- if (result != null) {
- result.refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());
+ ouputFolder = ResourcesPlugin.getWorkspace().getRoot().getContainerForLocation(path);
+ }
+ boolean recursive = configuration.getAttribute(TextMarkerLaunchConstants.RECURSIVE, false);
+ clearOutputFolder(new File(ouputFolder.getLocation().toPortableString()), recursive);
+ super.launch(configuration, mode, launch, monitor);
+ while (!launch.isTerminated()) {
+ try {
+ Thread.sleep(100);
+ } catch (InterruptedException e) {
+ Thread.interrupted();
}
}
+
+ if (ouputFolder != null) {
+ ouputFolder.refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());
+ }
}
private void clearOutputFolder(File outputDir, boolean recursive) {
IPreferenceStore store = TextMarkerIdePlugin.getDefault().getPreferenceStore();
boolean clearOutput = store.getBoolean(TextMarkerCorePreferences.PROJECT_CLEAR_OUTPUT);
if (clearOutput) {
- // TODO
- // List<File> outputFiles = getFiles(outputDir, recursive);
- // for (File file : outputFiles) {
- // file.delete();
- // }
- // outputFolder.refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());
+ List<File> outputFiles = getFiles(outputDir, recursive);
+ for (File file : outputFiles) {
+ file.delete();
+ }
}
}
-
+ private static List<File> getFiles(File dir, boolean recusive) {
+ List<File> result = new ArrayList<File>();
+ 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;
+ }
}
Modified: uima/sandbox/textmarker/trunk/textmarker-ep-ide/src/main/java/org/apache/uima/textmarker/ide/launching/TextMarkerLaunchConstants.java
URL: http://svn.apache.org/viewvc/uima/sandbox/textmarker/trunk/textmarker-ep-ide/src/main/java/org/apache/uima/textmarker/ide/launching/TextMarkerLaunchConstants.java?rev=1463605&r1=1463604&r2=1463605&view=diff
==============================================================================
--- uima/sandbox/textmarker/trunk/textmarker-ep-ide/src/main/java/org/apache/uima/textmarker/ide/launching/TextMarkerLaunchConstants.java (original)
+++ uima/sandbox/textmarker/trunk/textmarker-ep-ide/src/main/java/org/apache/uima/textmarker/ide/launching/TextMarkerLaunchConstants.java Tue Apr 2 15:49:18 2013
@@ -15,14 +15,14 @@
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
-*/
+ */
package org.apache.uima.textmarker.ide.launching;
public class TextMarkerLaunchConstants {
public static final String ARG_INPUT_FOLDER = "-inputFolder";
-
+
public static final String ARG_OUTPUT_FOLDER = "-outputFolder";
public static final String ARG_DESCRIPTOR = "-descriptor";
@@ -30,10 +30,17 @@ public class TextMarkerLaunchConstants {
public static final String ARG_RECURSIVE = "-inputRecursive";
public static final String ARG_MODE = "-mode";
-
+
+ public static final String ARG_VIEW = "-view";
+
+ public static final String ARG_ENCODING = "-encoding";
+
public static final String INPUT_FOLDER = "org.apache.uima.textmarker.ide.launching.inputFolder";
-
+
public static final String OUTPUT_FOLDER = "org.apache.uima.textmarker.ide.launching.outputFolder";
-
-
+
+ public static final String RECURSIVE = "org.apache.uima.textmarker.ide.launching.recursive";
+
+ public static final String VIEW = "org.apache.uima.textmarker.ide.launching.view";
+
}
Modified: uima/sandbox/textmarker/trunk/textmarker-ep-ide/src/main/java/org/apache/uima/textmarker/ide/launching/TextMarkerLauncher.java
URL: http://svn.apache.org/viewvc/uima/sandbox/textmarker/trunk/textmarker-ep-ide/src/main/java/org/apache/uima/textmarker/ide/launching/TextMarkerLauncher.java?rev=1463605&r1=1463604&r2=1463605&view=diff
==============================================================================
--- uima/sandbox/textmarker/trunk/textmarker-ep-ide/src/main/java/org/apache/uima/textmarker/ide/launching/TextMarkerLauncher.java (original)
+++ uima/sandbox/textmarker/trunk/textmarker-ep-ide/src/main/java/org/apache/uima/textmarker/ide/launching/TextMarkerLauncher.java Tue Apr 2 15:49:18 2013
@@ -25,12 +25,16 @@ import java.io.FileOutputStream;
import java.io.IOException;
import java.net.URI;
import java.util.ArrayList;
+import java.util.Iterator;
import java.util.List;
import org.apache.uima.UIMAFramework;
import org.apache.uima.analysis_engine.AnalysisEngine;
+import org.apache.uima.analysis_engine.AnalysisEngineDescription;
import org.apache.uima.analysis_engine.AnalysisEngineProcessException;
+import org.apache.uima.analysis_engine.metadata.SofaMapping;
import org.apache.uima.cas.CAS;
+import org.apache.uima.cas.CASException;
import org.apache.uima.cas.impl.XmiCasDeserializer;
import org.apache.uima.cas.impl.XmiCasSerializer;
import org.apache.uima.resource.ResourceConfigurationException;
@@ -95,6 +99,11 @@ public class TextMarkerLauncher {
return false;
}
launchMode = args[index++];
+ } else if (TextMarkerLaunchConstants.ARG_VIEW.equals(each)) {
+ if (index >= args.length) {
+ return false;
+ }
+ view = args[index++];
}
}
return count ==2;
@@ -106,6 +115,7 @@ public class TextMarkerLauncher {
}
XMLInputSource in = new XMLInputSource(descriptor);
ResourceSpecifier specifier = UIMAFramework.getXMLParser().parseResourceSpecifier(in);
+
AnalysisEngine ae = UIMAFramework.produceAnalysisEngine(specifier);
configure(ae);
CAS cas = ae.newCAS();
@@ -122,16 +132,30 @@ public class TextMarkerLauncher {
private static void processFile(File file, AnalysisEngine ae, CAS cas) throws IOException,
AnalysisEngineProcessException, SAXException {
-
+ if(view != null) {
+ boolean found = false;
+ Iterator<CAS> viewIterator = cas.getViewIterator();
+ while (viewIterator.hasNext()) {
+ CAS each = (CAS) viewIterator.next();
+ String viewName = each.getViewName();
+ if(viewName.equals(view)) {
+ cas = cas.getView(view);
+ found = true;
+ break;
+ }
+ }
+ if(!found) {
+ cas = cas.createView(view);
+ }
+
+ }
if (file.getName().endsWith(".xmi")) {
XmiCasDeserializer.deserialize(new FileInputStream(file), cas, true);
} else {
String document = FileUtils.file2String(file, inputEncoding);
cas.setDocumentText(document);
}
-
ae.process(cas);
-
if (outputFolder != null) {
File outputFile = getOutputFile(file, inputFolder, outputFolder);
writeXmi(cas, outputFile);
@@ -155,7 +179,7 @@ public class TextMarkerLauncher {
List<File> result = new ArrayList<File>();
for (File each : dir.listFiles()) {
// TODO: find a solution for this hotfix
- if (each.getName().endsWith(".svn")) {
+ if (each.isHidden()) {
continue;
}
result.add(each);
Modified: uima/sandbox/textmarker/trunk/textmarker-ep-ide/src/main/java/org/apache/uima/textmarker/ide/validator/TextMarkerCheckerUtils.java
URL: http://svn.apache.org/viewvc/uima/sandbox/textmarker/trunk/textmarker-ep-ide/src/main/java/org/apache/uima/textmarker/ide/validator/TextMarkerCheckerUtils.java?rev=1463605&r1=1463604&r2=1463605&view=diff
==============================================================================
--- uima/sandbox/textmarker/trunk/textmarker-ep-ide/src/main/java/org/apache/uima/textmarker/ide/validator/TextMarkerCheckerUtils.java (original)
+++ uima/sandbox/textmarker/trunk/textmarker-ep-ide/src/main/java/org/apache/uima/textmarker/ide/validator/TextMarkerCheckerUtils.java Tue Apr 2 15:49:18 2013
@@ -171,7 +171,7 @@ public class TextMarkerCheckerUtils {
List<IFolder> allDescriptorFolders;
try {
allDescriptorFolders = TextMarkerProjectUtils.getAllDescriptorFolders(project.getProject());
- } catch (CoreException e) {
+ } catch (Exception e) {
return false;
}
for (IFolder folder : allDescriptorFolders) {
@@ -254,7 +254,7 @@ public class TextMarkerCheckerUtils {
List<IFolder> allDescriptorFolders;
try {
allDescriptorFolders = TextMarkerProjectUtils.getAllDescriptorFolders(project.getProject());
- } catch (CoreException e) {
+ } catch (Exception e) {
return false;
}
for (IFolder folder : allDescriptorFolders) {
Modified: uima/sandbox/textmarker/trunk/textmarker-ep-ide/src/main/java/org/apache/uima/textmarker/ide/validator/TextMarkerTypeChecker.java
URL: http://svn.apache.org/viewvc/uima/sandbox/textmarker/trunk/textmarker-ep-ide/src/main/java/org/apache/uima/textmarker/ide/validator/TextMarkerTypeChecker.java?rev=1463605&r1=1463604&r2=1463605&view=diff
==============================================================================
--- uima/sandbox/textmarker/trunk/textmarker-ep-ide/src/main/java/org/apache/uima/textmarker/ide/validator/TextMarkerTypeChecker.java (original)
+++ uima/sandbox/textmarker/trunk/textmarker-ep-ide/src/main/java/org/apache/uima/textmarker/ide/validator/TextMarkerTypeChecker.java Tue Apr 2 15:49:18 2013
@@ -524,7 +524,7 @@ public class TextMarkerTypeChecker imple
* @throws InvalidXMLException
* @throws IOException
* when file not found
- * @throws CoreException
+ * @throws Exception
*/
private Set<String> importTypeSystem(String xmlFilePath) throws InvalidXMLException, IOException,
CoreException {