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/08/12 13:00:51 UTC

svn commit: r1157047 [26/27] - in /uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide: ./ .settings/ META-INF/ icons/ schema/ 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...

Added: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/ui/wizards/TextMarkerProjectCreationWizard.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/ui/wizards/TextMarkerProjectCreationWizard.java?rev=1157047&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/ui/wizards/TextMarkerProjectCreationWizard.java (added)
+++ uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/ui/wizards/TextMarkerProjectCreationWizard.java Fri Aug 12 11:00:38 2011
@@ -0,0 +1,257 @@
+/*
+ * 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.textmarker.ide.ui.wizards;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.uima.textmarker.ide.core.builder.TextMarkerProjectUtils;
+import org.apache.uima.textmarker.ide.ui.TextMarkerImages;
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExecutableExtension;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.SubProgressMonitor;
+import org.eclipse.dltk.core.DLTKCore;
+import org.eclipse.dltk.core.IBuildpathEntry;
+import org.eclipse.dltk.core.IModelElement;
+import org.eclipse.dltk.internal.ui.util.CoreUtility;
+import org.eclipse.dltk.internal.ui.wizards.buildpath.BPListElement;
+import org.eclipse.dltk.ui.DLTKUIPlugin;
+import org.eclipse.dltk.ui.wizards.BuildpathsBlock;
+import org.eclipse.dltk.ui.wizards.NewElementWizard;
+import org.eclipse.dltk.ui.wizards.ProjectWizardFirstPage;
+import org.eclipse.dltk.ui.wizards.ProjectWizardSecondPage;
+import org.eclipse.ui.INewWizard;
+import org.eclipse.ui.wizards.newresource.BasicNewProjectResourceWizard;
+
+public class TextMarkerProjectCreationWizard extends NewElementWizard implements INewWizard,
+        IExecutableExtension {
+
+  public static final String ID_WIZARD = "org.apache.uima.textmarker.ide.ui.wizards.TextMarkerProjectWizard"; //$NON-NLS-1$
+
+  private ProjectWizardFirstPage fFirstPage;
+
+  private ProjectWizardSecondPage fSecondPage;
+
+  private IConfigurationElement fConfigElement;
+
+  public TextMarkerProjectCreationWizard() {
+    setDefaultPageImageDescriptor(TextMarkerImages.DESC_WIZBAN_PROJECT_CREATION);
+    setDialogSettings(DLTKUIPlugin.getDefault().getDialogSettings());
+    setWindowTitle(TextMarkerWizardMessages.ProjectCreationWizard_title);
+  }
+
+  @Override
+  public void addPages() {
+    super.addPages();
+    fFirstPage = new TextMarkerProjectWizardFirstPage();
+
+    fFirstPage.setTitle(TextMarkerWizardMessages.ProjectCreationWizardFirstPage_title);
+    fFirstPage.setDescription(TextMarkerWizardMessages.ProjectCreationWizardFirstPage_description);
+    addPage(fFirstPage);
+    fSecondPage = new TextMarkerProjectWizardSecondPage(fFirstPage);
+    addPage(fSecondPage);
+  }
+
+  @Override
+  protected void finishPage(IProgressMonitor monitor) throws InterruptedException, CoreException {
+
+    fSecondPage.performFinish(monitor); // use the full progress monitor
+    createProject(monitor);
+  }
+
+  public void createProject(IProgressMonitor monitor) throws CoreException {
+    IProject project = fSecondPage.getScriptProject().getProject();
+    IFolder folder = project.getFolder(TextMarkerProjectUtils.getDefaultInputLocation());
+    if (!folder.exists()) {
+      CoreUtility.createFolder(folder, true, true, new SubProgressMonitor(monitor, 1));
+    }
+    folder = project.getFolder(TextMarkerProjectUtils.getDefaultOutputLocation());
+    if (!folder.exists()) {
+      CoreUtility.createFolder(folder, true, true, new SubProgressMonitor(monitor, 1));
+    }
+    folder = project.getFolder(TextMarkerProjectUtils.getDefaultTestLocation());
+    if (!folder.exists()) {
+      CoreUtility.createFolder(folder, true, true, new SubProgressMonitor(monitor, 1));
+    }
+    IFolder descFolder = project.getFolder(TextMarkerProjectUtils.getDefaultDescriptorLocation());
+    if (!descFolder.exists()) {
+      CoreUtility.createFolder(descFolder, true, true, new SubProgressMonitor(monitor, 1));
+    }
+    IFolder srcFolder = project.getFolder(TextMarkerProjectUtils.getDefaultScriptLocation());
+    if (!srcFolder.exists()) {
+      CoreUtility.createFolder(srcFolder, true, true, new SubProgressMonitor(monitor, 1));
+    }
+    IFolder rsrcFolder = project.getFolder(TextMarkerProjectUtils.getDefaultResourcesLocation());
+    if (!rsrcFolder.exists()) {
+      CoreUtility.createFolder(rsrcFolder, true, true, new SubProgressMonitor(monitor, 1));
+    }
+
+    List<BPListElement> buildpathEntries = new ArrayList<BPListElement>();
+    for (IBuildpathEntry buildpathEntry : fSecondPage.getRawBuildPath()) {
+      BPListElement createFromExisting = BPListElement.createFromExisting(buildpathEntry,
+              fSecondPage.getScriptProject());
+      if (createFromExisting.getBuildpathEntry().getEntryKind() != IBuildpathEntry.BPE_SOURCE) {
+        buildpathEntries.add(createFromExisting);
+      }
+    }
+    IBuildpathEntry newSourceEntry = DLTKCore.newSourceEntry(srcFolder.getFullPath());
+    buildpathEntries.add(BPListElement.createFromExisting(newSourceEntry,
+            fSecondPage.getScriptProject()));
+    // IBuildpathEntry newSourceEntry = DLTKCore.newSourceEntry(descFolder
+    // .getFullPath());
+    // buildpathEntries.add(BPListElement.createFromExisting(newSourceEntry,
+    // fSecondPage.getScriptProject()));
+
+    BuildpathsBlock.flush(buildpathEntries, fSecondPage.getScriptProject(), monitor);
+    copyDescriptors(descFolder);
+    // modifyDescriptors(descFolder, rsrcFolder);
+
+    TextMarkerProjectUtils.setProjectDataPath(project, descFolder);
+
+    descFolder.refreshLocal(IResource.DEPTH_INFINITE, monitor);
+
+  }
+
+  // private void modifyDescriptors(IFolder descFolder, IFolder rsrcFolder) {
+  // File beFile = new File(descFolder.getLocation().toFile(), "BasicEngine.xml");
+  // try {
+  // AnalysisEngineDescription beDescription = UIMAFramework.getXMLParser()
+  // .parseAnalysisEngineDescription(new XMLInputSource(beFile));
+  // String resourcesLocation = rsrcFolder.getRawLocation().makeAbsolute().toFile()
+  // .getAbsolutePath();
+  // beDescription.getAnalysisEngineMetaData().getConfigurationParameterSettings()
+  // .setParameterValue(TextMarkerEngine.RESOURCES_LOCATION, resourcesLocation);
+  // OutputStream out = new FileOutputStream(beFile);
+  // XMLSerializer sax = new XMLSerializer(out);
+  // ContentHandler ch = sax.getContentHandler();
+  // ch.startDocument();
+  // beDescription.toXML(ch);
+  // ch.endDocument();
+  // } catch (Exception e) {
+  // e.printStackTrace();
+  // }
+  // }
+
+  private void copyDescriptors(IFolder descFolder) {
+    InputStream in = null;
+    OutputStream out = null;
+    try {
+      in = this.getClass().getResourceAsStream("BasicTypeSystem.xml");
+      out = new FileOutputStream(new File(descFolder.getLocation().toFile(), "BasicTypeSystem.xml"));
+      if (in != null && out != null) {
+        copy(in, out);
+      }
+
+      in = this.getClass().getResourceAsStream("BasicEngine.xml");
+      out = new FileOutputStream(new File(descFolder.getLocation().toFile(), "BasicEngine.xml"));
+      if (in != null && out != null) {
+        copy(in, out);
+      }
+
+      in = this.getClass().getResourceAsStream("Modifier.xml");
+      out = new FileOutputStream(new File(descFolder.getLocation().toFile(), "Modifier.xml"));
+      if (in != null && out != null) {
+        copy(in, out);
+      }
+
+      in = this.getClass().getResourceAsStream("InternalTypeSystem.xml");
+      out = new FileOutputStream(new File(descFolder.getLocation().toFile(),
+              "InternalTypeSystem.xml"));
+      if (in != null && out != null) {
+        copy(in, out);
+      }
+    } catch (Exception e) {
+      e.printStackTrace();
+    } finally {
+      if (in != null) {
+        try {
+          in.close();
+        } catch (IOException e) {
+          e.printStackTrace();
+        }
+      }
+      if (out != null) {
+        try {
+          out.close();
+        } catch (IOException e) {
+          e.printStackTrace();
+        }
+      }
+    }
+  }
+
+  static void copy(InputStream fis, OutputStream fos) {
+    try {
+      byte[] buffer = new byte[0xFFFF];
+      for (int len; (len = fis.read(buffer)) != -1;)
+        fos.write(buffer, 0, len);
+    } catch (IOException e) {
+      System.err.println(e);
+    } finally {
+      if (fis != null)
+        try {
+          fis.close();
+        } catch (IOException e) {
+          e.printStackTrace();
+        }
+      if (fos != null)
+        try {
+          fos.close();
+        } catch (IOException e) {
+          e.printStackTrace();
+        }
+    }
+  }
+
+  @Override
+  public boolean performFinish() {
+    boolean res = super.performFinish();
+    if (res) {
+      BasicNewProjectResourceWizard.updatePerspective(fConfigElement);
+      selectAndReveal(fSecondPage.getScriptProject().getProject());
+    }
+    return res;
+  }
+
+  public void setInitializationData(IConfigurationElement cfig, String propertyName, Object data) {
+    fConfigElement = cfig;
+  }
+
+  @Override
+  public boolean performCancel() {
+    fSecondPage.performCancel();
+    return super.performCancel();
+  }
+
+  @Override
+  public IModelElement getCreatedElement() {
+    return DLTKCore.create(fFirstPage.getProjectHandle());
+  }
+}

Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/ui/wizards/TextMarkerProjectCreationWizard.java
------------------------------------------------------------------------------
    svn:executable = *

Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/ui/wizards/TextMarkerProjectCreationWizard.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/ui/wizards/TextMarkerProjectWizardFirstPage.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/ui/wizards/TextMarkerProjectWizardFirstPage.java?rev=1157047&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/ui/wizards/TextMarkerProjectWizardFirstPage.java (added)
+++ uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/ui/wizards/TextMarkerProjectWizardFirstPage.java Fri Aug 12 11:00:38 2011
@@ -0,0 +1,109 @@
+/*
+ * 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.textmarker.ide.ui.wizards;
+
+import org.apache.uima.textmarker.ide.core.TextMarkerNature;
+import org.eclipse.dltk.ui.wizards.ProjectWizardFirstPage;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
+
+final class TextMarkerProjectWizardFirstPage extends ProjectWizardFirstPage {
+
+  private Button useAnalysis;
+
+  private Group packagesGroup;
+
+  private Label labelElement;
+
+  public TextMarkerProjectWizardFirstPage() {
+    setTitle(TextMarkerWizardMessages.ProjectCreationWizardFirstPage_title);
+    setDescription(TextMarkerWizardMessages.ProjectCreationWizardFirstPage_description);
+  }
+
+  final class TextMarkerInterpreterGroup extends AbstractInterpreterGroup {
+
+    public TextMarkerInterpreterGroup(Composite composite) {
+      super(composite);
+    }
+
+    @Override
+    protected String getCurrentLanguageNature() {
+      return TextMarkerNature.NATURE_ID;
+    }
+
+    @Override
+    protected String getIntereprtersPreferencePageId() {
+      return "org.apache.uima.textmarker.ide.preferences.interpreters"; //$NON-NLS-1$
+    }
+  }
+
+  @Override
+  protected IInterpreterGroup createInterpreterGroup(Composite parent) {
+    return new TextMarkerInterpreterGroup(parent);
+  }
+
+  @Override
+  protected boolean interpeterRequired() {
+    /* Specially allow to create TCL project without interpreter */
+    return false;
+  }
+
+  // protected void createCustomGroups(Composite composite) {
+  // super.createCustomGroups(composite);
+  //
+  // packagesGroup = new Group(composite, SWT.NONE);
+  // GridData gridData = new GridData(GridData.FILL, SWT.FILL, true, false);
+  // gridData.widthHint = convertWidthInCharsToPixels(50);
+  // packagesGroup.setLayoutData(gridData);
+  // packagesGroup.setLayout(new GridLayout(1, false));
+  // packagesGroup
+  // .setText(TextMarkerWizardMessages.TextMarkerProjectWizardFirstPage_packageDetector);
+  // this.useAnalysis = new Button(packagesGroup, SWT.CHECK);
+  // this.useAnalysis
+  // .setText(TextMarkerWizardMessages.TextMarkerProjectWizardFirstPage_packageDetector_checkbox);
+  // this.useAnalysis.setSelection(true);
+  // labelElement = new Label(packagesGroup, SWT.NONE);
+  // labelElement
+  // .setText(TextMarkerWizardMessages.TextMarkerProjectWizardFirstPage_packageDetector_description);
+  // Observer o = new Observer() {
+  // public void update(Observable o, Object arg) {
+  // boolean inWorkspace = fLocationGroup.isInWorkspace();
+  // packagesGroup.setEnabled(!inWorkspace);
+  // useAnalysis.setEnabled(!inWorkspace);
+  // labelElement.setEnabled(!inWorkspace);
+  // }
+  // };
+  // fLocationGroup.addObserver(o);
+  // ((TextMarkerInterpreterGroup) getInterpreterGroup()).addObserver(o);
+  // }
+
+  public boolean useAnalysis() {
+    final boolean result[] = { false };
+    useAnalysis.getDisplay().syncExec(new Runnable() {
+      public void run() {
+        result[0] = useAnalysis.getSelection();
+      }
+    });
+    return result[0];
+  }
+
+}

Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/ui/wizards/TextMarkerProjectWizardFirstPage.java
------------------------------------------------------------------------------
    svn:executable = *

Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/ui/wizards/TextMarkerProjectWizardFirstPage.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/ui/wizards/TextMarkerProjectWizardSecondPage.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/ui/wizards/TextMarkerProjectWizardSecondPage.java?rev=1157047&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/ui/wizards/TextMarkerProjectWizardSecondPage.java (added)
+++ uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/ui/wizards/TextMarkerProjectWizardSecondPage.java Fri Aug 12 11:00:38 2011
@@ -0,0 +1,78 @@
+/*
+ * 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.textmarker.ide.ui.wizards;
+
+import org.apache.uima.textmarker.ide.TextMarkerIdePlugin;
+import org.apache.uima.textmarker.ide.core.TextMarkerNature;
+import org.apache.uima.textmarker.ide.ui.preferences.TextMarkerBuildPathsBlock;
+import org.eclipse.dltk.ui.util.BusyIndicatorRunnableContext;
+import org.eclipse.dltk.ui.util.IStatusChangeListener;
+import org.eclipse.dltk.ui.wizards.BuildpathsBlock;
+import org.eclipse.dltk.ui.wizards.ProjectWizardFirstPage;
+import org.eclipse.dltk.ui.wizards.ProjectWizardSecondPage;
+import org.eclipse.jface.preference.IPreferenceStore;
+
+final class TextMarkerProjectWizardSecondPage extends ProjectWizardSecondPage {
+  TextMarkerProjectWizardSecondPage(ProjectWizardFirstPage mainPage) {
+    super(mainPage);
+  }
+
+  @Override
+  protected BuildpathsBlock createBuildpathBlock(IStatusChangeListener listener) {
+    return new TextMarkerBuildPathsBlock(new BusyIndicatorRunnableContext(), listener, 0,
+            useNewSourcePage(), null);
+  }
+
+  @Override
+  protected String getScriptNature() {
+    return TextMarkerNature.NATURE_ID;
+  }
+
+  @Override
+  protected IPreferenceStore getPreferenceStore() {
+    return TextMarkerIdePlugin.getDefault().getPreferenceStore();
+  }
+
+  // protected BuildpathDetector createBuildpathDetector(
+  // IProgressMonitor monitor, IDLTKLanguageToolkit toolkit)
+  // throws CoreException {
+  // TextMarkerBuildpathDetector detector = new TextMarkerBuildpathDetector(
+  // getCurrProject(), toolkit);
+  //
+  // TextMarkerProjectWizardFirstPage page = (TextMarkerProjectWizardFirstPage) this
+  // .getFirstPage();
+  // detector.setUseAnalysis(page.useAnalysis());
+  // detector.detectBuildpath(new SubProgressMonitor(monitor, 20));
+  // return detector;
+  // }
+
+  // protected void postConfigureProject() throws CoreException {
+  // final IProject project = getCurrProject();
+  // final IEnvironment environment = EnvironmentManager
+  // .getEnvironment(project);
+  // if (environment != null && !environment.isLocal()) {
+  // final Map options = new HashMap();
+  // options.put(DLTKCore.INDEXER_ENABLED, DLTKCore.DISABLED);
+  // options.put(DLTKCore.BUILDER_ENABLED, DLTKCore.DISABLED);
+  // DLTKCore.create(project).setOptions(options);
+  // }
+  // }
+
+}

Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/ui/wizards/TextMarkerProjectWizardSecondPage.java
------------------------------------------------------------------------------
    svn:executable = *

Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/ui/wizards/TextMarkerProjectWizardSecondPage.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/ui/wizards/TextMarkerWizardMessages.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/ui/wizards/TextMarkerWizardMessages.java?rev=1157047&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/ui/wizards/TextMarkerWizardMessages.java (added)
+++ uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/ui/wizards/TextMarkerWizardMessages.java Fri Aug 12 11:00:38 2011
@@ -0,0 +1,40 @@
+/*
+ * 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.textmarker.ide.ui.wizards;
+
+import org.eclipse.osgi.util.NLS;
+
+public class TextMarkerWizardMessages extends NLS {
+
+  private static final String BUNDLE_NAME = "org.apache.uima.textmarker.ide.ui.wizards.TextMarkerWizardMessages";//$NON-NLS-1$
+
+  private TextMarkerWizardMessages() {
+  }
+
+  public static String ProjectCreationWizard_title;
+
+  public static String ProjectCreationWizardFirstPage_title;
+
+  public static String ProjectCreationWizardFirstPage_description;
+
+  static {
+    NLS.initializeMessages(BUNDLE_NAME, TextMarkerWizardMessages.class);
+  }
+}

Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/ui/wizards/TextMarkerWizardMessages.java
------------------------------------------------------------------------------
    svn:executable = *

Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/ui/wizards/TextMarkerWizardMessages.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/ui/wizards/TextMarkerWizardMessages.properties
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/ui/wizards/TextMarkerWizardMessages.properties?rev=1157047&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/ui/wizards/TextMarkerWizardMessages.properties (added)
+++ uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/ui/wizards/TextMarkerWizardMessages.properties Fri Aug 12 11:00:38 2011
@@ -0,0 +1,23 @@
+# ***************************************************************
+#  * 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.
+# ***************************************************************
+
+ProjectCreationWizard_title=Create TextMarker project
+
+ProjectCreationWizardFirstPage_title=Create a TextMarker project
+ProjectCreationWizardFirstPage_description=Create a TextMarker project in the workspace or in an external location

Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/ui/wizards/TextMarkerWizardMessages.properties
------------------------------------------------------------------------------
    svn:executable = *

Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/ui/wizards/TextMarkerWizardMessages.properties
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/ui/wizards/TypePrioritites.xml
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/ui/wizards/TypePrioritites.xml?rev=1157047&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/ui/wizards/TypePrioritites.xml (added)
+++ uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/ui/wizards/TypePrioritites.xml Fri Aug 12 11:00:38 2011
@@ -0,0 +1,35 @@
+<?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.
+-->
+
+<typePriorities xmlns="http://uima.apache.org/resourceSpecifier">
+<name>TypePrioritites</name>
+<description></description>
+<version>1.0</version>
+<vendor></vendor>
+
+      <priorityList>
+        <type>org.apache.uima.textmarker.type.TextMarkerFrame</type>
+        <type>uima.tcas.Annotation</type>
+        <type>org.apache.uima.textmarker.type.TextMarkerBasic</type>
+      </priorityList>
+    
+    
+</typePriorities>
+

Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/ui/wizards/TypePrioritites.xml
------------------------------------------------------------------------------
    svn:executable = *

Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/ui/wizards/TypePrioritites.xml
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/validator/CheckValidator.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/validator/CheckValidator.java?rev=1157047&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/validator/CheckValidator.java (added)
+++ uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/validator/CheckValidator.java Fri Aug 12 11:00:38 2011
@@ -0,0 +1,38 @@
+/*
+ * 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.textmarker.ide.validator;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.dltk.core.IScriptProject;
+import org.eclipse.dltk.core.builder.AbstractBuildParticipantType;
+import org.eclipse.dltk.core.builder.IBuildParticipant;
+
+public class CheckValidator extends AbstractBuildParticipantType {
+
+  private static final String ID = "org.apache.uima.textmarker.ide.validator.checkvalidator"; //$NON-NLS-1$
+
+  private static final String NAME = "TextMarker Checker"; //$NON-NLS-1$
+
+  @Override
+  public IBuildParticipant createBuildParticipant(IScriptProject project) throws CoreException {
+    return new TextMarkerChecker(project);
+  }
+
+}

Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/validator/CheckValidator.java
------------------------------------------------------------------------------
    svn:executable = *

Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/validator/CheckValidator.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/validator/TextMarkerChecker.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/validator/TextMarkerChecker.java?rev=1157047&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/validator/TextMarkerChecker.java (added)
+++ uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/validator/TextMarkerChecker.java Fri Aug 12 11:00:38 2011
@@ -0,0 +1,89 @@
+/*
+ * 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.textmarker.ide.validator;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.dltk.ast.declarations.ModuleDeclaration;
+import org.eclipse.dltk.core.IScriptProject;
+import org.eclipse.dltk.core.ISourceModule;
+import org.eclipse.dltk.core.SourceParserUtil;
+import org.eclipse.dltk.core.builder.IBuildContext;
+import org.eclipse.dltk.core.builder.IBuildParticipant;
+import org.eclipse.dltk.core.builder.IBuildParticipantExtension;
+
+public class TextMarkerChecker implements IBuildParticipant, IBuildParticipantExtension {
+  List<IBuildParticipant> buildParticipants = null;
+
+  public TextMarkerChecker(IScriptProject project) {
+    buildParticipants = new ArrayList<IBuildParticipant>();
+    try {
+      buildParticipants.add(new TextMarkerTypeChecker(project));
+      buildParticipants.add(new TextMarkerVarRefChecker());
+      buildParticipants.add(new TextMarkerEngineAndCallChecker(project));
+      buildParticipants.add(new TextMarkerRessourceChecker(project));
+    } catch (CoreException e) {
+      e.printStackTrace();
+    }
+  }
+
+  /*
+   * (non-Javadoc)
+   * 
+   * @see org.eclipse.dltk.core.builder.IBuildParticipant#build(org.eclipse.dltk
+   * .core.builder.IBuildContext)
+   */
+  public void build(IBuildContext context) throws CoreException {
+    // if ast not declared in context ..
+    Object mdObj = context.get(IBuildContext.ATTR_MODULE_DECLARATION);
+    if (!(mdObj instanceof ModuleDeclaration)) {
+      // ...temporary inefficient hack to get live error msgs
+      // TODO refactor
+      ISourceModule sourceModule = context.getSourceModule();
+      ModuleDeclaration md = SourceParserUtil.getModuleDeclaration(sourceModule, null);
+      context.set(IBuildContext.ATTR_MODULE_DECLARATION, md);
+    }
+    for (IBuildParticipant buildP : buildParticipants) {
+      buildP.build(context);
+    }
+  }
+
+  /*
+   * (non-Javadoc)
+   * 
+   * @see org.eclipse.dltk.core.builder.IBuildParticipantExtension#beginBuild(int)
+   */
+  public boolean beginBuild(int buildType) {
+    return true;
+  }
+
+  /*
+   * (non-Javadoc)
+   * 
+   * @see org.eclipse.dltk.core.builder.IBuildParticipantExtension#endBuild(org
+   * .eclipse.core.runtime.IProgressMonitor)
+   */
+  public void endBuild(IProgressMonitor monitor) {
+  }
+
+}

Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/validator/TextMarkerChecker.java
------------------------------------------------------------------------------
    svn:executable = *

Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/validator/TextMarkerChecker.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/validator/TextMarkerCheckerDefaultProblem.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/validator/TextMarkerCheckerDefaultProblem.java?rev=1157047&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/validator/TextMarkerCheckerDefaultProblem.java (added)
+++ uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/validator/TextMarkerCheckerDefaultProblem.java Fri Aug 12 11:00:38 2011
@@ -0,0 +1,61 @@
+/*
+ * 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.textmarker.ide.validator;
+
+import org.apache.uima.textmarker.ide.parser.ast.TextMarkerAbstractDeclaration;
+import org.eclipse.dltk.ast.ASTNode;
+import org.eclipse.dltk.compiler.problem.DefaultProblem;
+import org.eclipse.dltk.compiler.problem.ProblemSeverities;
+
+public class TextMarkerCheckerDefaultProblem extends DefaultProblem {
+  public static final int WARNING = ProblemSeverities.Warning;
+
+  public static final int ERROR = ProblemSeverities.Error;
+
+  // public TextMarkerCheckerDefaultProblem(String message, int id, String[]
+  // stringArguments,
+  // int severity, int start, int end) {
+  // super(message, id, stringArguments, severity, start,
+  // end, 10);
+  // }
+
+  public TextMarkerCheckerDefaultProblem(String fileName, String message,
+          TextMarkerAbstractDeclaration node, int line, int severity) {
+    super(fileName, message, 0, new String[] {}, severity, node.getNameStart(), node.getNameEnd(),
+            line);
+  }
+
+  public TextMarkerCheckerDefaultProblem(String fileName, String message,
+          TextMarkerAbstractDeclaration node, int line) {
+    super(fileName, message, 0, new String[] {}, ERROR, node.getNameStart(), node.getNameEnd(),
+            line);
+  }
+
+  public TextMarkerCheckerDefaultProblem(String fileName, String message, ASTNode node, int line) {
+    this(fileName, message, node, line, ERROR);
+  }
+
+  public TextMarkerCheckerDefaultProblem(String fileName, String message, ASTNode node, int line,
+          int severity) {
+    super(fileName, message, 0, new String[] {}, severity, node.sourceStart(), node.sourceEnd(),
+            line);
+  }
+
+}

Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/validator/TextMarkerCheckerDefaultProblem.java
------------------------------------------------------------------------------
    svn:executable = *

Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/validator/TextMarkerCheckerDefaultProblem.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/validator/TextMarkerCheckerProblemFactory.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/validator/TextMarkerCheckerProblemFactory.java?rev=1157047&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/validator/TextMarkerCheckerProblemFactory.java (added)
+++ uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/validator/TextMarkerCheckerProblemFactory.java Fri Aug 12 11:00:38 2011
@@ -0,0 +1,161 @@
+/*
+ * 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.textmarker.ide.validator;
+
+import java.util.List;
+
+import org.apache.uima.textmarker.ide.parser.ast.TextMarkerAbstractDeclaration;
+import org.apache.uima.textmarker.ide.parser.ast.TextMarkerFeatureDeclaration;
+import org.apache.uima.textmarker.ide.parser.ast.TextMarkerVariableReference;
+import org.eclipse.dltk.ast.ASTListNode;
+import org.eclipse.dltk.ast.ASTNode;
+import org.eclipse.dltk.ast.expressions.Expression;
+import org.eclipse.dltk.ast.expressions.StringLiteral;
+import org.eclipse.dltk.compiler.problem.IProblem;
+import org.eclipse.dltk.core.ISourceModule;
+import org.eclipse.dltk.core.builder.ISourceLineTracker;
+
+public class TextMarkerCheckerProblemFactory {
+  // private static final String errMsgHead = "Type \"";
+  // private static final String errMsgTailDefault =
+  // " \" not defined in this script!";
+
+  private ISourceLineTracker linetracker;
+
+  private String fileName;
+
+  public TextMarkerCheckerProblemFactory(String fileName, ISourceLineTracker linetracker) {
+    this.fileName = fileName;
+    this.linetracker = linetracker;
+  }
+
+  public IProblem createIdConflictsWithVariableProblem(TextMarkerAbstractDeclaration varRef) {
+    String message = generateVarAlreadyDeclaredProblemMsg(varRef);
+    return new TextMarkerCheckerDefaultProblem(this.fileName, message, varRef, getLine(varRef));
+  }
+
+  public IProblem createIdConflictsWithTypeProblem(TextMarkerAbstractDeclaration varRef) {
+    String message = generateVarConflictsWithTypeProblem(varRef);
+    return new TextMarkerCheckerDefaultProblem(this.fileName, message, varRef, getLine(varRef));
+  }
+
+  public IProblem createFileNotFoundProblem(ASTNode node, String localPath) {
+    return new TextMarkerCheckerDefaultProblem(this.fileName,
+            generateFileNotFoundProblemMsg(localPath), node, getLine(node));
+  }
+
+  public IProblem createFileNotFoundProblem(ASTNode fileNode) {
+    return createFileNotFoundProblem(fileNode, fileNode.toString());
+    // generateFileNotFoundProblemMsg(fileNode));
+  }
+
+  public IProblem createDuplicateShortNameInImported(ASTNode node, String localPath,
+          List<String> checkDuplicateShortNames, int severity) {
+    StringBuilder sb = new StringBuilder();
+    for (String string : checkDuplicateShortNames) {
+      sb.append(string);
+      sb.append(", ");
+    }
+
+    return new TextMarkerCheckerDefaultProblem(this.fileName, "Types in " + localPath
+            + " share same short name, but with different namespaces: " + sb.toString(), node,
+            getLine(node), severity);
+  }
+
+  public IProblem createDuplicateShortName(TextMarkerAbstractDeclaration var, int severity) {
+    return new TextMarkerCheckerDefaultProblem(this.fileName, "The type " + var.getName()
+            + " conflicts with other types with same short name, but different namespace.", var,
+            getLine(var), severity);
+  }
+
+  public IProblem createXMLProblem(ASTNode node, String localPath) {
+    return new TextMarkerCheckerDefaultProblem(this.fileName, generateXMLProblemMsg(localPath),
+            node, getLine(node));
+  }
+
+  public IProblem createTypeProblem(TextMarkerVariableReference ref, ISourceModule currentFile) {
+
+    String errMsgHead = "Type \"";
+
+    String errMsgTailDefault = " \" not defined in this script/block!";
+    String errMsg = errMsgHead + ref.getName() + errMsgTailDefault;
+    IProblem problem = new TextMarkerCheckerDefaultProblem(currentFile.getElementName(), errMsg,
+            ref, linetracker.getLineNumberOfOffset(ref.sourceStart()));
+    return problem;
+  }
+
+  private String generateFileNotFoundProblemMsg(ASTNode node) {
+    return generateFileNotFoundProblemMsg(node.toString());
+  }
+
+  private String generateFileNotFoundProblemMsg(String fileName) {
+    return "error: \"" + fileName + "\" not found.";
+  }
+
+  private String generateXMLProblemMsg(String fileName) {
+    return "error: " + fileName + " causes xml problem.";
+  }
+
+  private int getLine(ASTNode varRef) {
+    return this.linetracker.getLineNumberOfOffset(varRef.sourceStart());
+  }
+
+  private String generateVarAlreadyDeclaredProblemMsg(TextMarkerAbstractDeclaration var) {
+    return "error: Id \"" + var.getName() + "\" conflicts with already declared variable.";
+  }
+
+  private String generateVarConflictsWithTypeProblem(TextMarkerAbstractDeclaration var) {
+    return "error: Identifier \"" + var.getName()
+            + "\" conflicts with already declared annotation type.";
+  }
+
+  public IProblem createUnknownFeatureTypeProblem(TextMarkerFeatureDeclaration var) {
+    String message = "error: Type \"" + var.getType() + "\" of Feature \"" + var.getName()
+            + "\" is not defined.";
+    return new TextMarkerCheckerDefaultProblem(this.fileName, message, var, getLine(var));
+  }
+
+  public IProblem createUnknownFeatureProblem(Expression var) {
+    // TODO refactor and find better solution
+    String feat = var.toString();
+    List childs = var.getChilds();
+    if (childs != null && !childs.isEmpty()) {
+      Object object = childs.get(0);
+      if (object instanceof ASTListNode) {
+        List childs2 = ((ASTListNode) object).getChilds();
+        if (childs2 != null && !childs2.isEmpty()) {
+          Object object2 = childs2.get(0);
+          if (object2 instanceof StringLiteral) {
+            StringLiteral sl = (StringLiteral) object2;
+            feat = sl.getValue().replaceAll("\"", "");
+          }
+        }
+      }
+    }
+    String message = "error: Feature \"" + feat + "\" is not defined.";
+    return new TextMarkerCheckerDefaultProblem(this.fileName, message, var, getLine(var));
+  }
+
+  public IProblem createInheritenceFinalProblem(TextMarkerVariableReference parent) {
+    String message = "Type \"" + parent.getName()
+            + "\" is final and cannot be used as a parent type.";
+    return new TextMarkerCheckerDefaultProblem(this.fileName, message, parent, getLine(parent));
+  }
+}

Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/validator/TextMarkerCheckerProblemFactory.java
------------------------------------------------------------------------------
    svn:executable = *

Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/validator/TextMarkerCheckerProblemFactory.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/validator/TextMarkerCheckerUtils.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/validator/TextMarkerCheckerUtils.java?rev=1157047&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/validator/TextMarkerCheckerUtils.java (added)
+++ uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/validator/TextMarkerCheckerUtils.java Fri Aug 12 11:00:38 2011
@@ -0,0 +1,267 @@
+/*
+ * 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.textmarker.ide.validator;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.net.URL;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import java.util.Stack;
+
+import org.apache.uima.UIMAFramework;
+import org.apache.uima.analysis_engine.AnalysisEngineDescription;
+import org.apache.uima.resource.metadata.ConfigurationParameterSettings;
+import org.apache.uima.textmarker.engine.TextMarkerEngine;
+import org.apache.uima.textmarker.ide.core.builder.TextMarkerProjectUtils;
+import org.apache.uima.util.InvalidXMLException;
+import org.apache.uima.util.XMLInputSource;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.dltk.core.DLTKCore;
+import org.eclipse.dltk.core.IMethod;
+import org.eclipse.dltk.core.IModelElement;
+import org.eclipse.dltk.core.IScriptFolder;
+import org.eclipse.dltk.core.IScriptProject;
+import org.eclipse.dltk.core.ISourceModule;
+import org.eclipse.dltk.core.ModelException;
+
+public class TextMarkerCheckerUtils {
+
+  public static Set<String> importScript(String path, int type, IScriptProject project)
+          throws InvalidXMLException, IOException, ModelException {
+    return importScript(path, type, project, false);
+  }
+
+  /**
+   * @param path
+   *          relative to script folder of the project.<br>
+   *          i.e.: "org.apache.uima.MyScript"
+   * @param type
+   *          i.e. IModelElement.FIELD for fields to be collected and returned
+   * @return
+   * @throws InvalidXMLException
+   * @throws IOException
+   * @throws ModelException
+   */
+  public static Set<String> importScript(String path, int type, IScriptProject project,
+          boolean appendPath) throws InvalidXMLException, IOException, ModelException {
+    Stack<String> namespaceStack = new Stack<String>();
+
+    final Set<String> imports = new HashSet<String>();
+    List<IFolder> scriptFolders = null;
+    try {
+      scriptFolders = TextMarkerProjectUtils.getAllScriptFolders(project);
+    } catch (CoreException e) {
+      e.printStackTrace();
+    }
+    String fileNameWithoutExtension = path.substring(path.lastIndexOf('.') + 1);
+    String fileNameWithExtension = fileNameWithoutExtension + ".tm";
+    ISourceModule sourceModule = null;
+    boolean found = false;
+    for (IFolder eachFolder : scriptFolders) {
+
+      IScriptProject sp = DLTKCore.create(eachFolder.getProject());
+      IScriptFolder[] scriptFolders2 = sp.getScriptFolders();
+      for (IScriptFolder iScriptFolder : scriptFolders2) {
+        sourceModule = iScriptFolder.getSourceModule(fileNameWithExtension);
+        if (sourceModule.exists() && sourceModule.getResource() != null
+                && sourceModule.getResource().exists()) {
+          found = true;
+          break;
+        }
+        if (found)
+          break;
+      }
+    }
+    IModelElement elements[] = null;
+    namespaceStack.push(fileNameWithoutExtension);
+    try {
+      elements = sourceModule.getChildren();
+      for (int i = 0; i < elements.length; i++) {
+        IModelElement modelElement = elements[i];
+        int elementType = modelElement.getElementType();
+        if (elementType == type) {
+          if (elementType == IModelElement.METHOD) {
+            imports.add(namespaceStack.peek() + "." + modelElement.getElementName());
+          } else if (appendPath) {
+            imports.add(path + "." + modelElement.getElementName());
+          } else {
+            imports.add(modelElement.getElementName());
+          }
+        }
+        if (elementType == IModelElement.METHOD) {
+          String nSpace = namespaceStack.empty() ? modelElement.getElementName() : namespaceStack
+                  .peek() + "." + modelElement.getElementName();
+          namespaceStack.push(nSpace);
+          imports.addAll(collectElements((IMethod) modelElement, type, namespaceStack));
+          namespaceStack.pop();
+        }
+      }
+    } catch (ModelException e) {
+      throw new FileNotFoundException();
+    }
+    return imports;
+  }
+
+  private static Set<String> collectElements(IMethod element, int type, Stack stack)
+          throws ModelException {
+    Set<String> fieldsCollection = new HashSet<String>();
+    IModelElement elements[] = element.getChildren();
+    if (elements == null) {
+      return fieldsCollection;
+    }
+    for (int i = 0; i < elements.length; i++) {
+      IModelElement modelElement = elements[i];
+      int elementType = modelElement.getElementType();
+      if (elementType == type) {
+        if (elementType == IModelElement.FIELD) {
+          fieldsCollection.add(modelElement.getElementName());
+        }
+        fieldsCollection.add(stack.peek() + "." + modelElement.getElementName());
+      }
+      if (elementType == IModelElement.METHOD) {
+        stack.push(stack.peek() + "." + modelElement.getElementName());
+        fieldsCollection.addAll(collectElements((IMethod) modelElement, type, stack));
+        stack.pop();
+      }
+    }
+    return fieldsCollection;
+  }
+
+  public static IFile getFile(IFolder folder, String filePath) {
+    int lastDot = filePath.lastIndexOf('.');
+    int sndLastDot = filePath.lastIndexOf('.', lastDot - 1);
+    String fName = filePath;
+    if (sndLastDot >= 0) {
+      String subFolder = filePath.substring(0, sndLastDot);
+      folder = folder.getFolder(subFolder);
+      fName = filePath.substring(sndLastDot + 1);
+    }
+    return folder.getFile(fName);
+  }
+
+  /**
+   * @param xmlFilePath
+   *          absolute full path. i.e.: "org.apache.uima.myengine" ".xml" will be added.
+   * @return file.exists
+   */
+  public static boolean checkEngineImport(String xmlFilePath, IScriptProject project) {
+    boolean result = false;
+    List<IFolder> allDescriptorFolders;
+    try {
+      allDescriptorFolders = TextMarkerProjectUtils.getAllDescriptorFolders(project.getProject());
+    } catch (CoreException e) {
+      return false;
+    }
+    for (IFolder folder : allDescriptorFolders) {
+      String fileExtended = xmlFilePath.replaceAll("[.]", "/") + ".xml";
+      IFile iFile = TextMarkerCheckerUtils.getFile(folder, fileExtended);
+      result |= iFile.exists();
+    }
+    return result;
+  }
+
+  public static boolean checkScriptImport(String xmlFilePath, IScriptProject project) {
+    boolean result = false;
+    List<IFolder> allDescriptorFolders;
+    try {
+      allDescriptorFolders = TextMarkerProjectUtils.getAllScriptFolders(project);
+    } catch (CoreException e) {
+      return false;
+    }
+    for (IFolder folder : allDescriptorFolders) {
+      String fileExtended = xmlFilePath.replaceAll("[.]", "/") + ".tm";
+      IFile iFile = TextMarkerCheckerUtils.getFile(folder, fileExtended);
+      result |= iFile.exists();
+    }
+    return result;
+  }
+
+  /**
+   * @param resourceFilePath
+   *          absolute full path. i.e.: "org.apache.uima.TestList.txt"
+   * @return file.exists
+   */
+  public static boolean checkRessourceExistence(String resourceFilePath, IScriptProject project) {
+    IFolder ddlFolder = project.getProject().getFolder(
+            TextMarkerProjectUtils.getDefaultDescriptorLocation());
+    final String basicXML = "BasicEngine.xml";
+    IFile file = getFile(ddlFolder, basicXML);
+    AnalysisEngineDescription aed;
+    try {
+      URL url = file.getLocationURI().toURL();
+      aed = UIMAFramework.getXMLParser().parseAnalysisEngineDescription(new XMLInputSource(url));
+    } catch (Exception e) {
+      e.printStackTrace();
+      return false;
+    }
+    ConfigurationParameterSettings configurationParameterSettings = aed.getAnalysisEngineMetaData()
+            .getConfigurationParameterSettings();
+    String[] paths = (String[]) configurationParameterSettings
+            .getParameterValue(TextMarkerEngine.RESOURCE_PATHS);
+    if (paths == null) {
+      IFolder folder = project.getProject().getFolder(
+              TextMarkerProjectUtils.getDefaultResourcesLocation());
+      String defaultPath = folder.getLocation().toPortableString();
+      paths = new String[] { defaultPath };
+    }
+    for (String string : paths) {
+      File iFile = new File(string, resourceFilePath);
+      // IFile iFile = getFile(folder, ressourceFilePath);
+      if (iFile.exists()) {
+        return true;
+      }
+
+    }
+    return false;
+  }
+
+  /**
+   * @param xmlFilePath
+   *          absolute full path. i.e.: "org.apache.uima.myengine" ".xml" will be added.
+   * @return file.exists
+   */
+  public static IFile getEngine(String xmlFilePath, IScriptProject project) {
+    IFolder folder = project.getProject().getFolder(
+            TextMarkerProjectUtils.getDefaultDescriptorLocation());
+    String fileExtended = xmlFilePath + ".xml";
+    return getFile(folder, fileExtended);
+  }
+
+  public static boolean checkTypeSystemImport(String localPath, IScriptProject project) {
+    boolean result = false;
+    List<IFolder> allDescriptorFolders;
+    try {
+      allDescriptorFolders = TextMarkerProjectUtils.getAllDescriptorFolders(project.getProject());
+    } catch (CoreException e) {
+      return false;
+    }
+    for (IFolder folder : allDescriptorFolders) {
+      String fileExtended = localPath.replaceAll("[.]", "/") + ".xml";
+      IFile iFile = TextMarkerCheckerUtils.getFile(folder, fileExtended);
+      result |= iFile.exists();
+    }
+    return result;
+  }
+}

Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/validator/TextMarkerCheckerUtils.java
------------------------------------------------------------------------------
    svn:executable = *

Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/validator/TextMarkerCheckerUtils.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/validator/TextMarkerEngineAndCallChecker.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/validator/TextMarkerEngineAndCallChecker.java?rev=1157047&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/validator/TextMarkerEngineAndCallChecker.java (added)
+++ uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/validator/TextMarkerEngineAndCallChecker.java Fri Aug 12 11:00:38 2011
@@ -0,0 +1,232 @@
+/*
+ * 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.textmarker.ide.validator;
+
+import java.io.IOException;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.apache.uima.textmarker.ide.parser.ast.TMActionConstants;
+import org.apache.uima.textmarker.ide.parser.ast.TMStatementConstants;
+import org.apache.uima.textmarker.ide.parser.ast.TextMarkerAction;
+import org.apache.uima.textmarker.ide.parser.ast.TextMarkerImportStatement;
+import org.apache.uima.util.InvalidXMLException;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.dltk.ast.ASTVisitor;
+import org.eclipse.dltk.ast.declarations.MethodDeclaration;
+import org.eclipse.dltk.ast.declarations.ModuleDeclaration;
+import org.eclipse.dltk.ast.declarations.TypeDeclaration;
+import org.eclipse.dltk.ast.expressions.Expression;
+import org.eclipse.dltk.ast.references.SimpleReference;
+import org.eclipse.dltk.ast.statements.Statement;
+import org.eclipse.dltk.compiler.problem.IProblem;
+import org.eclipse.dltk.compiler.problem.IProblemReporter;
+import org.eclipse.dltk.core.IModelElement;
+import org.eclipse.dltk.core.IScriptProject;
+import org.eclipse.dltk.core.ISourceModule;
+import org.eclipse.dltk.core.ModelException;
+import org.eclipse.dltk.core.builder.IBuildContext;
+import org.eclipse.dltk.core.builder.IBuildParticipant;
+import org.eclipse.dltk.core.builder.IBuildParticipantExtension;
+import org.eclipse.dltk.core.builder.ISourceLineTracker;
+
+public class TextMarkerEngineAndCallChecker implements IBuildParticipant,
+        IBuildParticipantExtension {
+
+  private class EngineAndCallCheckerVisitor extends ASTVisitor {
+    private IProblemReporter rep;
+
+    private TextMarkerCheckerProblemFactory problemFactory;
+
+    private Set<String> engines;
+
+    private Set<String> scripts;
+
+    private String curFile;
+
+    private HashSet<String> scriptsInnerBlocks;
+
+    public EngineAndCallCheckerVisitor(IProblemReporter rep, ISourceLineTracker linetracker,
+            String curFile) {
+      this.problemFactory = new TextMarkerCheckerProblemFactory(curFile, linetracker);
+      this.rep = rep;
+      this.engines = new HashSet<String>();
+      this.scripts = new HashSet<String>();
+      this.scriptsInnerBlocks = new HashSet<String>();
+      this.curFile = curFile;
+
+      if (curFile != null && curFile.endsWith(".tm")) {
+        scripts.add(curFile.substring(0, curFile.length() - 3));
+      }
+      try {
+        String fnwe = curFile.substring(0, curFile.length() - 3);
+        scriptsInnerBlocks.addAll(TextMarkerCheckerUtils.importScript(fnwe, IModelElement.METHOD,
+                project));
+      } catch (InvalidXMLException e) {
+      } catch (IOException e) {
+      } catch (ModelException e) {
+      }
+    }
+
+    @Override
+    public boolean visit(Statement s) throws Exception {
+      if (s instanceof TextMarkerImportStatement) {
+        // handle engine imports
+        if (((TextMarkerImportStatement) s).getType() == TMStatementConstants.S_IMPORT_ENGINE) {
+          SimpleReference sRef = (SimpleReference) ((TextMarkerImportStatement) s).getExpression();
+          if (TextMarkerCheckerUtils.checkEngineImport(sRef.getName(), project)) {
+            importEngine(sRef.getName());
+          } else {
+            IProblem problem = problemFactory.createFileNotFoundProblem(sRef);
+            rep.reportProblem(problem);
+          }
+        }
+        // handle script imports
+        if (((TextMarkerImportStatement) s).getType() == TMStatementConstants.S_IMPORT_SCRIPT) {
+          SimpleReference stRef = (SimpleReference) ((TextMarkerImportStatement) s).getExpression();
+          String sRefName = stRef.getName();
+          try {
+            Set<String> blocks = TextMarkerCheckerUtils.importScript(sRefName,
+                    IModelElement.METHOD, project);
+            scripts.add(sRefName);
+            if (!blocks.isEmpty()) {
+              scriptsInnerBlocks.addAll(blocks);
+            }
+          } catch (Exception e) {
+          }
+        }
+        return false;
+      }
+      return true;
+    }
+
+    private void importEngine(String name) {
+      engines.add(name);
+      int i = name.lastIndexOf('.');
+      if (i > 1) {
+        // TODO emit errors for doublettes (names in scripts and
+        // engines)
+        String lastPart = name.substring(i + 1);
+        if (lastPart != null && lastPart.length() != 0) {
+          engines.add(lastPart);
+        }
+      }
+    }
+
+    @Override
+    public boolean visit(Expression s) throws Exception {
+      if (s instanceof TextMarkerAction) {
+        TextMarkerAction action = (TextMarkerAction) s;
+        if (action.getKind() == TMActionConstants.A_CALL) {
+          // TODO see antlr grammar: no viable child defined!
+          if (action.getChilds().size() > 0) {
+            SimpleReference ref = (SimpleReference) action.getChilds().get(0);
+            if (ref != null && !engines.contains(ref.getName())) {
+              String required = ref.getName();
+              for (String script : scripts) {
+                // check direct script-call
+                boolean a = script.endsWith(required);
+                if (a) {
+                  return false;
+                }
+              }
+              for (String block : scriptsInnerBlocks) {
+                boolean b = block.equals(required);
+                if (b) {
+                  return false;
+                }
+              }
+              IProblem problem = problemFactory.createFileNotFoundProblem(ref);
+              rep.reportProblem(problem);
+            }
+          }
+          return false;
+        }
+        return true;
+      }
+      return true;
+    }
+
+    @Override
+    public boolean visit(MethodDeclaration s) throws Exception {
+      return true;
+    }
+
+    @Override
+    public boolean visit(TypeDeclaration s) throws Exception {
+      return false;
+    }
+  }
+
+  public TextMarkerEngineAndCallChecker(IScriptProject project) throws CoreException {
+    this.project = project;
+  }
+
+  private IScriptProject project;
+
+  public boolean beginBuild(int buildType) {
+    return true;
+  }
+
+  public void endBuild(IProgressMonitor monitor) {
+  }
+
+  public void build(IBuildContext context) throws CoreException {
+    // getAST:
+    Object mdObj = context.get(IBuildContext.ATTR_MODULE_DECLARATION);
+    if (!(mdObj instanceof ModuleDeclaration)) {
+      return;
+    }
+    ModuleDeclaration md = (ModuleDeclaration) mdObj;
+    IProblemReporter problemReporter = context.getProblemReporter();
+    ISourceModule smod = context.getSourceModule();
+
+    // traverse:
+    ISourceLineTracker linetracker = context.getLineTracker();
+    String fileName = smod.getElementName();
+    try {
+      ASTVisitor visitor = new EngineAndCallCheckerVisitor(problemReporter, linetracker, fileName);
+      md.traverse(visitor);
+    } catch (Exception e) {
+      e.printStackTrace();
+    }
+  }
+
+  // /**
+  // * @param filePath
+  // * absolute full path. i.e.: "org.apache.uima.myengine" ".xml" will be
+  // * added.
+  // * @return file.exists
+  // */
+  // private boolean checkBlockCall(String filePath) {
+  // // try engine
+  // if (checkEngineImport(filePath)) {
+  // return true;
+  // }
+  // String fileExtended = filePath + ".tm";
+  // IFolder scriptFolder = project.getProject().getFolder(
+  // TextMarkerLanguageToolkit.getDefault()
+  // .getDefaultDescriptorLocation());
+  // IFile iFile = getFile(scriptFolder, fileExtended);
+  // return iFile.exists();
+  // }
+
+}

Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/validator/TextMarkerEngineAndCallChecker.java
------------------------------------------------------------------------------
    svn:executable = *

Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/validator/TextMarkerEngineAndCallChecker.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/validator/TextMarkerRessourceChecker.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/validator/TextMarkerRessourceChecker.java?rev=1157047&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/validator/TextMarkerRessourceChecker.java (added)
+++ uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/validator/TextMarkerRessourceChecker.java Fri Aug 12 11:00:38 2011
@@ -0,0 +1,220 @@
+/*
+ * 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.textmarker.ide.validator;
+
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.apache.uima.UIMAFramework;
+import org.apache.uima.resource.metadata.TypeDescription;
+import org.apache.uima.resource.metadata.TypeSystemDescription;
+import org.apache.uima.textmarker.ide.core.builder.TextMarkerProjectUtils;
+import org.apache.uima.textmarker.ide.parser.ast.TextMarkerRessourceReference;
+import org.apache.uima.util.InvalidXMLException;
+import org.apache.uima.util.XMLInputSource;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.dltk.ast.ASTVisitor;
+import org.eclipse.dltk.ast.declarations.ModuleDeclaration;
+import org.eclipse.dltk.ast.expressions.Expression;
+import org.eclipse.dltk.compiler.problem.IProblem;
+import org.eclipse.dltk.compiler.problem.IProblemReporter;
+import org.eclipse.dltk.core.IScriptProject;
+import org.eclipse.dltk.core.ISourceModule;
+import org.eclipse.dltk.core.builder.IBuildContext;
+import org.eclipse.dltk.core.builder.IBuildParticipant;
+import org.eclipse.dltk.core.builder.IBuildParticipantExtension;
+import org.eclipse.dltk.core.builder.ISourceLineTracker;
+
+public class TextMarkerRessourceChecker implements IBuildParticipant, IBuildParticipantExtension {
+
+  private class TypeCheckerVisitor extends ASTVisitor {
+    private IProblemReporter rep;
+
+    private String currentFile;
+
+    private ISourceLineTracker linetracker;
+
+    private Set<String> types;
+
+    private TextMarkerCheckerProblemFactory problemFactory;
+
+    private String packageName;
+
+    private static final String errMsgHead = "Cannot find resource \"";
+
+    private static final String errMsgTailDefault = " \" in resource location.";
+
+    public TypeCheckerVisitor(IProblemReporter rep, ISourceLineTracker linetracker, String curFile,
+            Set<String> types) {
+      this.problemFactory = new TextMarkerCheckerProblemFactory(curFile, linetracker);
+      this.linetracker = linetracker;
+      this.rep = rep;
+      this.packageName = "";
+      this.currentFile = curFile;
+      this.types = types;
+    }
+
+    @Override
+    public boolean visit(Expression s) throws Exception {
+      // traverse everything but RessourceReference
+      if (!(s instanceof TextMarkerRessourceReference)) {
+        return true;
+      }
+      TextMarkerRessourceReference resRef = (TextMarkerRessourceReference) s;
+      if (TextMarkerCheckerUtils.checkRessourceExistence(resRef.getValue(), project)) {
+        return false;
+      }
+      // ressource not valid
+      String errMsg = errMsgHead + resRef.getValue() + errMsgTailDefault;
+      IProblem problem = new TextMarkerCheckerDefaultProblem(currentFile, errMsg, resRef,
+              linetracker.getLineNumberOfOffset(resRef.sourceStart()));
+      rep.reportProblem(problem);
+      return false;
+    }
+  }
+
+  public TextMarkerRessourceChecker(IScriptProject project) throws CoreException {
+    this.project = project;
+  }
+
+  private IScriptProject project;
+
+  public boolean beginBuild(int buildType) {
+    return true;
+  }
+
+  public void endBuild(IProgressMonitor monitor) {
+  }
+
+  public void build(IBuildContext context) throws CoreException {
+    // getAST:
+    Object mdObj = context.get(IBuildContext.ATTR_MODULE_DECLARATION);
+    if (!(mdObj instanceof ModuleDeclaration)) {
+      return;
+    }
+    ModuleDeclaration md = (ModuleDeclaration) mdObj;
+    IProblemReporter problemReporter = context.getProblemReporter();
+    ISourceModule smod = context.getSourceModule();
+
+    // get Types:
+    Set<String> types = null;
+    try {
+      types = importBasicTypeSystem();
+    } catch (InvalidXMLException e1) {
+      System.err.println("ERROR: Failed to get BasicTypeSystem!! " + this.toString());
+      // problemReporter.reportProblem(problem)
+    } catch (IOException e1) {
+      System.err.println("ERROR: Failed to get BasicTypeSystem!! " + this.toString());
+    }
+    if (types == null) {
+      types = new HashSet<String>();
+    }
+
+    // traverse:
+    ISourceLineTracker linetracker = context.getLineTracker();
+    String fileName = smod.getElementName();
+    try {
+      ASTVisitor visitor = new TypeCheckerVisitor(problemReporter, linetracker, fileName, types);
+      md.traverse(visitor);
+    } catch (Exception e) {
+      e.printStackTrace();
+    }
+  }
+
+  private Set<String> importBasicTypeSystem() throws InvalidXMLException, IOException {
+    final String basicXmlFile = "BasicTypeSystem";
+    Set<String> types = importTypeSystem(basicXmlFile);
+    types.add("Annotation");
+    types.add("DocumentAnnotation");
+    return types;
+  }
+
+  /**
+   * @param xmlFilePath
+   *          absolute full path. i.e.: "org.apache.uima.mytypes" ".xml" will be added.
+   * @return
+   * @throws InvalidXMLException
+   * @throws IOException
+   *           when file not found
+   */
+  private Set<String> importTypeSystem(String xmlFilePath) throws InvalidXMLException, IOException {
+    IFolder folder = project.getProject().getFolder(
+            TextMarkerProjectUtils.getDefaultDescriptorLocation());
+    String fileExtended = xmlFilePath + ".xml";
+    return getTypes(folder, fileExtended);
+  }
+
+  private Set<String> getTypes(IFolder folder, String filePath) throws InvalidXMLException,
+          IOException {
+    Set<String> types = new HashSet<String>();
+    IFile iFile = getFile(folder, filePath);
+    URL url;
+    try {
+      url = iFile.getLocationURI().toURL();
+      types = getTypes(url);
+    } catch (MalformedURLException e) {
+      e.printStackTrace();
+    }
+    return types;
+  }
+
+  private IFile getFile(IFolder folder, String filePath) {
+    int lastDot = filePath.lastIndexOf('.');
+    int sndLastDot = filePath.lastIndexOf('.', lastDot - 1);
+    String fName = filePath;
+    if (sndLastDot >= 0) {
+      String subFolder = filePath.substring(0, sndLastDot);
+      folder = folder.getFolder(subFolder);
+      fName = filePath.substring(sndLastDot + 1);
+    }
+    return folder.getFile(fName);
+  }
+
+  private Set<String> getTypes(URL resource) throws IOException, InvalidXMLException {
+    Set<String> types = new HashSet<String>();
+    TypeSystemDescription typeSysDescr = null;
+    typeSysDescr = UIMAFramework.getXMLParser().parseTypeSystemDescription(
+            new XMLInputSource(resource));
+    for (TypeDescription each : typeSysDescr.getTypes()) {
+      String name = each.getName();
+      String[] nameSpace = name.split("[.]");
+      types.add(nameSpace[nameSpace.length - 1]);
+      StringBuffer fullName = new StringBuffer();
+      if (nameSpace.length > 0) {
+        fullName.append(nameSpace[0]);
+      }
+      for (int i = 1; i < nameSpace.length; i++) {
+        // TODO fix workaround
+        if (!nameSpace[i].equals("type")) {
+          fullName.append('.');
+          fullName.append(nameSpace[i]);
+        }
+      }
+      types.add(fullName.toString());
+    }
+    return types;
+  }
+}

Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/validator/TextMarkerRessourceChecker.java
------------------------------------------------------------------------------
    svn:executable = *

Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/validator/TextMarkerRessourceChecker.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain