You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@uima.apache.org by al...@apache.org on 2006/11/22 17:50:31 UTC

svn commit: r478232 [18/22] - in /incubator/uima/uimaj/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima: taeconfigurator/ taeconfigurator/editors/ taeconfigurator/editors/ui/ taeconfigurator/editors/ui/dialogs/ taeconfigurator/editors/xml/ tae...

Modified: incubator/uima/uimaj/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/ui/dialogs/SearchThread.java
URL: http://svn.apache.org/viewvc/incubator/uima/uimaj/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/ui/dialogs/SearchThread.java?view=diff&rev=478232&r1=478231&r2=478232
==============================================================================
--- incubator/uima/uimaj/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/ui/dialogs/SearchThread.java (original)
+++ incubator/uima/uimaj/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/ui/dialogs/SearchThread.java Wed Nov 22 08:50:24 2006
@@ -37,191 +37,176 @@
 import org.apache.uima.taeconfigurator.editors.MultiPageEditor;
 import org.apache.uima.taeconfigurator.editors.ui.AbstractSection;
 
-public class SearchThread implements Runnable /*extends Thread*/ {
-  private String m_fileNameSearch,
-		m_inputTypeSearch,
-		m_outputTypeSearch,
-		m_projectToSearch;
-	FindComponentDialog m_dialog;
-	private AbstractSection m_aggregateSection;
-	private List m_matchingDelegateComponentDescriptors;
-	private List m_matchingDelegateComponentDescriptions;
-	
-	int m_nWhichStatusMsg;
-	String m_statusMsg;
+public class SearchThread implements Runnable /* extends Thread */{
+  private String m_fileNameSearch, m_inputTypeSearch, m_outputTypeSearch, m_projectToSearch;
+
+  FindComponentDialog m_dialog;
+
+  private AbstractSection m_aggregateSection;
+
+  private List m_matchingDelegateComponentDescriptors;
+
+  private List m_matchingDelegateComponentDescriptions;
+
+  int m_nWhichStatusMsg;
+
+  String m_statusMsg;
+
   private String[] m_componentHeaders;
 
-	public SearchThread(
-		FindComponentDialog dialog,
-		AbstractSection aggregateSection,
-		String fileNameSearch,
-		String inputTypeSearch,
-		String outputTypeSearch,
-		String projectToSearch,
-    String [] componentHeaders) {
-			
-		m_dialog = dialog;
-		m_aggregateSection = aggregateSection;
-		m_fileNameSearch = fileNameSearch;
-		m_inputTypeSearch = inputTypeSearch;
-		m_outputTypeSearch = outputTypeSearch;
-		m_projectToSearch = projectToSearch;
+  public SearchThread(FindComponentDialog dialog, AbstractSection aggregateSection,
+                  String fileNameSearch, String inputTypeSearch, String outputTypeSearch,
+                  String projectToSearch, String[] componentHeaders) {
+
+    m_dialog = dialog;
+    m_aggregateSection = aggregateSection;
+    m_fileNameSearch = fileNameSearch;
+    m_inputTypeSearch = inputTypeSearch;
+    m_outputTypeSearch = outputTypeSearch;
+    m_projectToSearch = projectToSearch;
     m_componentHeaders = componentHeaders;
-	}
+  }
 
-	private boolean m_bDieNow = false;
-	private boolean m_bDone = false;
+  private boolean m_bDieNow = false;
 
-	public void setDieNow() {
-		m_bDieNow = true;
-	}
+  private boolean m_bDone = false;
 
-	public boolean getDieNow() {
-		return m_bDieNow;
-	}
+  public void setDieNow() {
+    m_bDieNow = true;
+  }
 
-	public boolean isDone() {
-		return m_bDone;
-	}
+  public boolean getDieNow() {
+    return m_bDieNow;
+  }
 
-	public void run() {
-		m_matchingDelegateComponentDescriptors = new ArrayList();
-		m_matchingDelegateComponentDescriptions = new ArrayList();
+  public boolean isDone() {
+    return m_bDone;
+  }
 
-		getDelegateComponentsByInputOutputTypes(m_projectToSearch);		
+  public void run() {
+    m_matchingDelegateComponentDescriptors = new ArrayList();
+    m_matchingDelegateComponentDescriptions = new ArrayList();
 
-		m_bDone = true;
-	}
+    getDelegateComponentsByInputOutputTypes(m_projectToSearch);
 
-  private void testOneResource (IResource resource) {
+    m_bDone = true;
+  }
+
+  private void testOneResource(IResource resource) {
     switch (resource.getType()) {
-    case IResource.FILE :
-      if (resource.getName().toLowerCase().endsWith(".xml")
-          // exclude potentially many data files, not descriptors
-        && !resource.getName().toLowerCase().endsWith(".txt.xml")
-        && (m_fileNameSearch == null || 
-            resource.getName().matches(m_fileNameSearch))) {
-        String fileDescriptorRelPath =
-          m_aggregateSection.editor.getDescriptorRelativePath(
-              resource.getLocation().toString());
-        setStatusMsg(2,
-          "Examining "
-          + getBriefDisplayVersion(fileDescriptorRelPath));
-        ResourceSpecifier rs =
-          MultiPageEditor.getDelegateResourceSpecifier((IFile) resource, 
-              m_componentHeaders);
-        // rs == null if wrong kind of descriptor
-        if (null == rs)
-          return;
-        if (!(rs instanceof ResourceCreationSpecifier)) // is a remote descriptor
-          if (m_inputTypeSearch != null || m_outputTypeSearch != null)
-            return; // don't find remote descriptors when types are wanted
-           
-        if (!(rs instanceof ResourceCreationSpecifier) || // is a remote descriptor
-            delegateComponentMatchesCapabilityReqs(
-                (ResourceCreationSpecifier)rs, m_inputTypeSearch, m_outputTypeSearch)) {
-          m_matchingDelegateComponentDescriptors.add(fileDescriptorRelPath);
-          m_matchingDelegateComponentDescriptions.add(rs);
+      case IResource.FILE:
+        if (resource.getName().toLowerCase().endsWith(".xml")
+                        // exclude potentially many data files, not descriptors
+                        && !resource.getName().toLowerCase().endsWith(".txt.xml")
+                        && (m_fileNameSearch == null || resource.getName()
+                                        .matches(m_fileNameSearch))) {
+          String fileDescriptorRelPath = m_aggregateSection.editor
+                          .getDescriptorRelativePath(resource.getLocation().toString());
+          setStatusMsg(2, "Examining " + getBriefDisplayVersion(fileDescriptorRelPath));
+          ResourceSpecifier rs = MultiPageEditor.getDelegateResourceSpecifier((IFile) resource,
+                          m_componentHeaders);
+          // rs == null if wrong kind of descriptor
+          if (null == rs)
+            return;
+          if (!(rs instanceof ResourceCreationSpecifier)) // is a remote descriptor
+            if (m_inputTypeSearch != null || m_outputTypeSearch != null)
+              return; // don't find remote descriptors when types are wanted
+
+          if (!(rs instanceof ResourceCreationSpecifier) || // is a remote descriptor
+                          delegateComponentMatchesCapabilityReqs((ResourceCreationSpecifier) rs,
+                                          m_inputTypeSearch, m_outputTypeSearch)) {
+            m_matchingDelegateComponentDescriptors.add(fileDescriptorRelPath);
+            m_matchingDelegateComponentDescriptions.add(rs);
+          }
+        }
+        break;
+      case IResource.FOLDER:
+        getDelegateComponentsByIOTypesBeginningAt((IFolder) resource);
+        break;
+    }
+
+  }
+
+  // populates the Vector of matchingAnalysisEngineDescriptors and
+  // matchingAnalysisEngineDescriptions
+  private void getDelegateComponentsByInputOutputTypes(String projectToSearch) {
+
+    IWorkspace workspace = TAEConfiguratorPlugin.getWorkspace();
+    IProject[] projects = workspace.getRoot().getProjects();
+    if (projectToSearch.equals(FindComponentDialog.ALL_PROJECTS)) {
+      setStatusMsg(1, "0 of " + projects.length + " projects processed.");
+    }
+
+    for (int i = 0; i < projects.length; i++) {
+      try {
+        if (projectToSearch.equals(FindComponentDialog.ALL_PROJECTS)
+                        || projects[i].getName().equals(projectToSearch)) {
+
+          if (projectToSearch.equals(FindComponentDialog.ALL_PROJECTS)) {
+            setStatusMsg(2, "Looking in " + projects[i].getName() + "....");
+          } else {
+            setStatusMsg(2, "Searching " + projects[i].getName() + " for matching TAEs...");
+          }
+
+          IResource[] projectContents = projects[i].members();
+          for (int j = 0; j < projectContents.length; j++) {
+            testOneResource(projectContents[j]);
+          }
+
+          if (projectToSearch.equals(FindComponentDialog.ALL_PROJECTS)) {
+            setStatusMsg(1, (i + 1) + " of " + projects.length + " projects processed.");
+          }
         }
+      } catch (Exception ex) {
+        System.out.println(ex.getMessage());
       }
-      break;
-    case IResource.FOLDER :
-      getDelegateComponentsByIOTypesBeginningAt((IFolder) resource);
-      break;
-  }
-    
-  }
-	//populates the Vector of matchingAnalysisEngineDescriptors and matchingAnalysisEngineDescriptions
-	private void getDelegateComponentsByInputOutputTypes(String projectToSearch) {
-
-		IWorkspace workspace = TAEConfiguratorPlugin.getWorkspace();
-		IProject[] projects = workspace.getRoot().getProjects();
-		if (projectToSearch.equals(FindComponentDialog.ALL_PROJECTS)) {
-			setStatusMsg(1, "0 of " + projects.length + " projects processed.");
-		}
-
-		for (int i = 0; i < projects.length; i++) {
-			try {
-				if (projectToSearch.equals(FindComponentDialog.ALL_PROJECTS)
-					|| projects[i].getName().equals(projectToSearch)) {
-
-					if (projectToSearch.equals(FindComponentDialog.ALL_PROJECTS)) {
-						setStatusMsg(2, 
-							"Looking in " + projects[i].getName() + "....");
-					}
-					else {
-						setStatusMsg(2, 
-							"Searching "
-								+ projects[i].getName()
-								+ " for matching TAEs...");
-					}
-
-					IResource[] projectContents = projects[i].members();
-					for (int j = 0; j < projectContents.length; j++) {
-						testOneResource(projectContents[j]);
-					}
-					
-					if (projectToSearch.equals(FindComponentDialog.ALL_PROJECTS)) {
-						setStatusMsg(1, 
-							(i + 1)
-								+ " of "
-								+ projects.length
-								+ " projects processed.");
-					}
-				}
-			}
-			catch (Exception ex) {
-				System.out.println(ex.getMessage());
-			}
-		}
-	}
-
-	//populates the Vector of matchingAnalysisEngineDescriptors and matchingAnalysisEngineDescriptions
-	private void getDelegateComponentsByIOTypesBeginningAt(IFolder beginFolder) {
-
-		if (m_bDieNow) {
-			return;
-		}
+    }
+  }
+
+  // populates the Vector of matchingAnalysisEngineDescriptors and
+  // matchingAnalysisEngineDescriptions
+  private void getDelegateComponentsByIOTypesBeginningAt(IFolder beginFolder) {
+
+    if (m_bDieNow) {
+      return;
+    }
 
-		try {
-			for (int i = 0; i < beginFolder.members().length; i++) {
+    try {
+      for (int i = 0; i < beginFolder.members().length; i++) {
         testOneResource(beginFolder.members()[i]);
-			}
-		}
-		catch (Exception ex) {
-			ex.printStackTrace();
-		}
-	}
-	
-
-	private boolean delegateComponentMatchesCapabilityReqs(
-		ResourceCreationSpecifier rs,
-		String inputTypeSearch,
-		String outputTypeSearch) {
-
-		if (inputTypeSearch == null && outputTypeSearch == null) {
-			return true;
-		}
-
-		Capability[] capabilities = AbstractSection.getCapabilities(rs);
-		if (capabilities == null || capabilities.length == 0) {
-			return false;
-		}
-		
-    boolean inputSatisfied =  matchCapabilitiesTo(capabilities, inputTypeSearch, INPUT);
+      }
+    } catch (Exception ex) {
+      ex.printStackTrace();
+    }
+  }
+
+  private boolean delegateComponentMatchesCapabilityReqs(ResourceCreationSpecifier rs,
+                  String inputTypeSearch, String outputTypeSearch) {
+
+    if (inputTypeSearch == null && outputTypeSearch == null) {
+      return true;
+    }
+
+    Capability[] capabilities = AbstractSection.getCapabilities(rs);
+    if (capabilities == null || capabilities.length == 0) {
+      return false;
+    }
+
+    boolean inputSatisfied = matchCapabilitiesTo(capabilities, inputTypeSearch, INPUT);
     boolean outputSatisfied = matchCapabilitiesTo(capabilities, outputTypeSearch, OUTPUT);
-    return 	inputSatisfied && outputSatisfied;
-	}
-	private static final boolean INPUT = true;
-	private static final boolean OUTPUT = false;
-	
-	private boolean matchCapabilitiesTo(Capability [] capabilities, String search, boolean isInput) {
+    return inputSatisfied && outputSatisfied;
+  }
+
+  private static final boolean INPUT = true;
+
+  private static final boolean OUTPUT = false;
+
+  private boolean matchCapabilitiesTo(Capability[] capabilities, String search, boolean isInput) {
     if (null == search)
       return true;
-    for (int i = 0; i < capabilities.length; i++) { 
-      TypeOrFeature [] typeOrFeatures = isInput ? 
-          capabilities[i].getInputs() :
-          capabilities[i].getOutputs();
+    for (int i = 0; i < capabilities.length; i++) {
+      TypeOrFeature[] typeOrFeatures = isInput ? capabilities[i].getInputs() : capabilities[i]
+                      .getOutputs();
       if (null != typeOrFeatures) {
         for (int j = 0; j < typeOrFeatures.length; j++) {
           if (typeOrFeatures[j].getName().matches(search)) {
@@ -230,46 +215,42 @@
         }
       }
     }
-	  return false;
-	}
-	  
-
-	public List getMatchingDelegateComponentDescriptors() {
-		return m_matchingDelegateComponentDescriptors;
-	}
-
-	public List getMatchingDelegateComponentDescriptions() {
-		return m_matchingDelegateComponentDescriptions;
-	}
-	
-	private void setStatusMsg(int nWhich, String msg) {
-		m_nWhichStatusMsg = nWhich;
-		m_statusMsg = msg;
-		
+    return false;
+  }
+
+  public List getMatchingDelegateComponentDescriptors() {
+    return m_matchingDelegateComponentDescriptors;
+  }
+
+  public List getMatchingDelegateComponentDescriptions() {
+    return m_matchingDelegateComponentDescriptions;
+  }
+
+  private void setStatusMsg(int nWhich, String msg) {
+    m_nWhichStatusMsg = nWhich;
+    m_statusMsg = msg;
+
     if (m_dialog.getStatusLabel1().isDisposed())
       return;
-		Display display = m_dialog.getStatusLabel1().getDisplay();
-		display.syncExec(
-			new Runnable() {
-				public void run() {
-					if(m_nWhichStatusMsg == 1) {
-						m_dialog.getStatusLabel1().setText(m_statusMsg);
-					}
-					else {
-						m_dialog.getStatusLabel2().setText(m_statusMsg);
-					}					
-				}
-			}
-		);
-				
-	}
-	
-	private String getBriefDisplayVersion(String filePathName) {
-		if(filePathName == null) {
-			return null;
-		}
-		filePathName = AbstractSection.maybeShortenFileName(filePathName);
-		return filePathName;
-	}
+    Display display = m_dialog.getStatusLabel1().getDisplay();
+    display.syncExec(new Runnable() {
+      public void run() {
+        if (m_nWhichStatusMsg == 1) {
+          m_dialog.getStatusLabel1().setText(m_statusMsg);
+        } else {
+          m_dialog.getStatusLabel2().setText(m_statusMsg);
+        }
+      }
+    });
+
+  }
+
+  private String getBriefDisplayVersion(String filePathName) {
+    if (filePathName == null) {
+      return null;
+    }
+    filePathName = AbstractSection.maybeShortenFileName(filePathName);
+    return filePathName;
+  }
 
 }

Modified: incubator/uima/uimaj/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/xml/ColorManager.java
URL: http://svn.apache.org/viewvc/incubator/uima/uimaj/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/xml/ColorManager.java?view=diff&rev=478232&r1=478231&r2=478232
==============================================================================
--- incubator/uima/uimaj/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/xml/ColorManager.java (original)
+++ incubator/uima/uimaj/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/xml/ColorManager.java Wed Nov 22 08:50:24 2006
@@ -29,19 +29,20 @@
 
 public class ColorManager {
 
-	protected Map fColorTable = new HashMap(10);
+  protected Map fColorTable = new HashMap(10);
 
-	public void dispose() {
-		Iterator e = fColorTable.values().iterator();
-		while (e.hasNext())
-			 ((Color) e.next()).dispose();
-	}
-	public Color getColor(RGB rgb) {
-		Color color = (Color) fColorTable.get(rgb);
-		if (color == null) {
-			color = new Color(Display.getCurrent(), rgb);
-			fColorTable.put(rgb, color);
-		}
-		return color;
-	}
+  public void dispose() {
+    Iterator e = fColorTable.values().iterator();
+    while (e.hasNext())
+      ((Color) e.next()).dispose();
+  }
+
+  public Color getColor(RGB rgb) {
+    Color color = (Color) fColorTable.get(rgb);
+    if (color == null) {
+      color = new Color(Display.getCurrent(), rgb);
+      fColorTable.put(rgb, color);
+    }
+    return color;
+  }
 }

Modified: incubator/uima/uimaj/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/xml/IXMLColorConstants.java
URL: http://svn.apache.org/viewvc/incubator/uima/uimaj/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/xml/IXMLColorConstants.java?view=diff&rev=478232&r1=478231&r2=478232
==============================================================================
--- incubator/uima/uimaj/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/xml/IXMLColorConstants.java (original)
+++ incubator/uima/uimaj/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/xml/IXMLColorConstants.java Wed Nov 22 08:50:24 2006
@@ -22,9 +22,13 @@
 import org.eclipse.swt.graphics.RGB;
 
 public interface IXMLColorConstants {
-	RGB XML_COMMENT = new RGB(128, 0, 0);
-	RGB PROC_INSTR = new RGB(128, 128, 128);
-	RGB STRING = new RGB(0, 128, 0);
-	RGB DEFAULT = new RGB(0, 0, 0);
-	RGB TAG = new RGB(0, 0, 128);
+  RGB XML_COMMENT = new RGB(128, 0, 0);
+
+  RGB PROC_INSTR = new RGB(128, 128, 128);
+
+  RGB STRING = new RGB(0, 128, 0);
+
+  RGB DEFAULT = new RGB(0, 0, 0);
+
+  RGB TAG = new RGB(0, 0, 128);
 }

Modified: incubator/uima/uimaj/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/xml/NonRuleBasedDamagerRepairer.java
URL: http://svn.apache.org/viewvc/incubator/uima/uimaj/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/xml/NonRuleBasedDamagerRepairer.java?view=diff&rev=478232&r1=478231&r2=478232
==============================================================================
--- incubator/uima/uimaj/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/xml/NonRuleBasedDamagerRepairer.java (original)
+++ incubator/uima/uimaj/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/xml/NonRuleBasedDamagerRepairer.java Wed Nov 22 08:50:24 2006
@@ -32,126 +32,107 @@
 import org.eclipse.jface.util.Assert;
 import org.eclipse.swt.custom.StyleRange;
 
-public class NonRuleBasedDamagerRepairer
-	implements IPresentationDamager, IPresentationRepairer {
+public class NonRuleBasedDamagerRepairer implements IPresentationDamager, IPresentationRepairer {
 
-	/** The document this object works on */
-	protected IDocument fDocument;
-	/** The default text attribute if non is returned as data by the current token */
-	protected TextAttribute fDefaultTextAttribute;
-	
-	/**
-	 * Constructor for NonRuleBasedDamagerRepairer.
-	 */
-	public NonRuleBasedDamagerRepairer(TextAttribute defaultTextAttribute) {
-		Assert.isNotNull(defaultTextAttribute);
-
-		fDefaultTextAttribute = defaultTextAttribute;
-	}
-
-	/**
-	 * @see IPresentationRepairer#setDocument(IDocument)
-	 */
-	public void setDocument(IDocument document) {
-		fDocument = document;
-	}
-
-	/**
-	 * Returns the end offset of the line that contains the specified offset or
-	 * if the offset is inside a line delimiter, the end offset of the next line.
-	 *
-	 * @param offset the offset whose line end offset must be computed
-	 * @return the line end offset for the given offset
-	 * @exception BadLocationException if offset is invalid in the current document
-	 */
-	protected int endOfLineOf(int offset) throws BadLocationException {
-
-		IRegion info = fDocument.getLineInformationOfOffset(offset);
-		if (offset <= info.getOffset() + info.getLength())
-			return info.getOffset() + info.getLength();
-
-		int line = fDocument.getLineOfOffset(offset);
-		try {
-			info = fDocument.getLineInformation(line + 1);
-			return info.getOffset() + info.getLength();
-		} catch (BadLocationException x) {
-			return fDocument.getLength();
-		}
-	}
-
-	/**
-	 * @see IPresentationDamager#getDamageRegion(ITypedRegion, DocumentEvent, boolean)
-	 */
-	public IRegion getDamageRegion(
-		ITypedRegion partition,
-		DocumentEvent event,
-		boolean documentPartitioningChanged) {
-		if (!documentPartitioningChanged) {
-			try {
-
-				IRegion info =
-					fDocument.getLineInformationOfOffset(event.getOffset());
-				int start = Math.max(partition.getOffset(), info.getOffset());
-
-				int end =
-					event.getOffset()
-						+ (event.getText() == null
-							? event.getLength()
-							: event.getText().length());
-
-				if (info.getOffset() <= end
-					&& end <= info.getOffset() + info.getLength()) {
-					// optimize the case of the same line
-					end = info.getOffset() + info.getLength();
-				} else
-					end = endOfLineOf(end);
-
-				end =
-					Math.min(
-						partition.getOffset() + partition.getLength(),
-						end);
-				return new Region(start, end - start);
-
-			} catch (BadLocationException x) {
-			}
-		}
-
-		return partition;
-	}
-
-	/**
-	 * @see IPresentationRepairer#createPresentation(TextPresentation, ITypedRegion)
-	 */
-	public void createPresentation(
-		TextPresentation presentation,
-		ITypedRegion region) {
-		addRange(
-			presentation,
-			region.getOffset(),
-			region.getLength(),
-			fDefaultTextAttribute);
-	}
-
-	/**
-	 * Adds style information to the given text presentation.
-	 *
-	 * @param presentation the text presentation to be extended
-	 * @param offset the offset of the range to be styled
-	 * @param length the length of the range to be styled
-	 * @param attr the attribute describing the style of the range to be styled
-	 */
-	protected void addRange(
-		TextPresentation presentation,
-		int offset,
-		int length,
-		TextAttribute attr) {
-		if (attr != null)
-			presentation.addStyleRange(
-				new StyleRange(
-					offset,
-					length,
-					attr.getForeground(),
-					attr.getBackground(),
-					attr.getStyle()));
-	}
+  /** The document this object works on */
+  protected IDocument fDocument;
+
+  /** The default text attribute if non is returned as data by the current token */
+  protected TextAttribute fDefaultTextAttribute;
+
+  /**
+   * Constructor for NonRuleBasedDamagerRepairer.
+   */
+  public NonRuleBasedDamagerRepairer(TextAttribute defaultTextAttribute) {
+    Assert.isNotNull(defaultTextAttribute);
+
+    fDefaultTextAttribute = defaultTextAttribute;
+  }
+
+  /**
+   * @see IPresentationRepairer#setDocument(IDocument)
+   */
+  public void setDocument(IDocument document) {
+    fDocument = document;
+  }
+
+  /**
+   * Returns the end offset of the line that contains the specified offset or if the offset is
+   * inside a line delimiter, the end offset of the next line.
+   * 
+   * @param offset
+   *          the offset whose line end offset must be computed
+   * @return the line end offset for the given offset
+   * @exception BadLocationException
+   *              if offset is invalid in the current document
+   */
+  protected int endOfLineOf(int offset) throws BadLocationException {
+
+    IRegion info = fDocument.getLineInformationOfOffset(offset);
+    if (offset <= info.getOffset() + info.getLength())
+      return info.getOffset() + info.getLength();
+
+    int line = fDocument.getLineOfOffset(offset);
+    try {
+      info = fDocument.getLineInformation(line + 1);
+      return info.getOffset() + info.getLength();
+    } catch (BadLocationException x) {
+      return fDocument.getLength();
+    }
+  }
+
+  /**
+   * @see IPresentationDamager#getDamageRegion(ITypedRegion, DocumentEvent, boolean)
+   */
+  public IRegion getDamageRegion(ITypedRegion partition, DocumentEvent event,
+                  boolean documentPartitioningChanged) {
+    if (!documentPartitioningChanged) {
+      try {
+
+        IRegion info = fDocument.getLineInformationOfOffset(event.getOffset());
+        int start = Math.max(partition.getOffset(), info.getOffset());
+
+        int end = event.getOffset()
+                        + (event.getText() == null ? event.getLength() : event.getText().length());
+
+        if (info.getOffset() <= end && end <= info.getOffset() + info.getLength()) {
+          // optimize the case of the same line
+          end = info.getOffset() + info.getLength();
+        } else
+          end = endOfLineOf(end);
+
+        end = Math.min(partition.getOffset() + partition.getLength(), end);
+        return new Region(start, end - start);
+
+      } catch (BadLocationException x) {
+      }
+    }
+
+    return partition;
+  }
+
+  /**
+   * @see IPresentationRepairer#createPresentation(TextPresentation, ITypedRegion)
+   */
+  public void createPresentation(TextPresentation presentation, ITypedRegion region) {
+    addRange(presentation, region.getOffset(), region.getLength(), fDefaultTextAttribute);
+  }
+
+  /**
+   * Adds style information to the given text presentation.
+   * 
+   * @param presentation
+   *          the text presentation to be extended
+   * @param offset
+   *          the offset of the range to be styled
+   * @param length
+   *          the length of the range to be styled
+   * @param attr
+   *          the attribute describing the style of the range to be styled
+   */
+  protected void addRange(TextPresentation presentation, int offset, int length, TextAttribute attr) {
+    if (attr != null)
+      presentation.addStyleRange(new StyleRange(offset, length, attr.getForeground(), attr
+                      .getBackground(), attr.getStyle()));
+  }
 }

Modified: incubator/uima/uimaj/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/xml/TagRule.java
URL: http://svn.apache.org/viewvc/incubator/uima/uimaj/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/xml/TagRule.java?view=diff&rev=478232&r1=478231&r2=478232
==============================================================================
--- incubator/uima/uimaj/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/xml/TagRule.java (original)
+++ incubator/uima/uimaj/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/xml/TagRule.java Wed Nov 22 08:50:24 2006
@@ -23,28 +23,26 @@
 
 public class TagRule extends MultiLineRule {
 
-	public TagRule(IToken token) {
-		super("<", ">", token);
-	}
-	protected boolean sequenceDetected(
-		ICharacterScanner scanner,
-		char[] sequence,
-		boolean eofAllowed) {
-		int c = scanner.read();
-		if (sequence[0] == '<') {
-			if (c == '?') {
-				// processing instruction - abort
-				scanner.unread();
-				return false;
-			}
-			if (c == '!') {
-				scanner.unread();
-				// comment - abort
-				return false;
-			}
-		} else if (sequence[0] == '>') {
-			scanner.unread();
-		}
-		return super.sequenceDetected(scanner, sequence, eofAllowed);
-	}
+  public TagRule(IToken token) {
+    super("<", ">", token);
+  }
+
+  protected boolean sequenceDetected(ICharacterScanner scanner, char[] sequence, boolean eofAllowed) {
+    int c = scanner.read();
+    if (sequence[0] == '<') {
+      if (c == '?') {
+        // processing instruction - abort
+        scanner.unread();
+        return false;
+      }
+      if (c == '!') {
+        scanner.unread();
+        // comment - abort
+        return false;
+      }
+    } else if (sequence[0] == '>') {
+      scanner.unread();
+    }
+    return super.sequenceDetected(scanner, sequence, eofAllowed);
+  }
 }

Modified: incubator/uima/uimaj/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/xml/XMLConfiguration.java
URL: http://svn.apache.org/viewvc/incubator/uima/uimaj/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/xml/XMLConfiguration.java?view=diff&rev=478232&r1=478231&r2=478232
==============================================================================
--- incubator/uima/uimaj/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/xml/XMLConfiguration.java (original)
+++ incubator/uima/uimaj/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/xml/XMLConfiguration.java Wed Nov 22 08:50:24 2006
@@ -32,84 +32,78 @@
 import org.apache.uima.taeconfigurator.editors.MultiPageEditorContributor;
 
 public class XMLConfiguration extends SourceViewerConfiguration {
-	private XMLDoubleClickStrategy doubleClickStrategy;
-	private XMLTagScanner tagScanner;
-	private XMLScanner scanner;
-	private ColorManager colorManager;
-
-	public XMLConfiguration(ColorManager colorManager) {
-		this.colorManager = colorManager;
-	}
-	public String[] getConfiguredContentTypes(ISourceViewer sourceViewer) {
-		return new String[] {
-			IDocument.DEFAULT_CONTENT_TYPE,
-			XMLPartitionScanner.XML_COMMENT,
-			XMLPartitionScanner.XML_TAG };
-	}
-	public ITextDoubleClickStrategy getDoubleClickStrategy(
-		ISourceViewer sourceViewer,
-		String contentType) {
-		if (doubleClickStrategy == null)
-			doubleClickStrategy = new XMLDoubleClickStrategy();
-		return doubleClickStrategy;
-	}
-
-	protected XMLScanner getXMLScanner() {
-		if (scanner == null) {
-			scanner = new XMLScanner(colorManager);
-			scanner.setDefaultReturnToken(
-				new Token(
-					new TextAttribute(
-						colorManager.getColor(IXMLColorConstants.DEFAULT))));
-		}
-		return scanner;
-	}
-	protected XMLTagScanner getXMLTagScanner() {
-		if (tagScanner == null) {
-			tagScanner = new XMLTagScanner(colorManager);
-			tagScanner.setDefaultReturnToken(
-				new Token(
-					new TextAttribute(
-						colorManager.getColor(IXMLColorConstants.TAG))));
-		}
-		return tagScanner;
-	}
-
-	public IPresentationReconciler getPresentationReconciler(ISourceViewer sourceViewer) {
-		PresentationReconciler reconciler = new PresentationReconciler();
-
-		DefaultDamagerRepairer dr =
-			new DefaultDamagerRepairer(getXMLTagScanner());
-		reconciler.setDamager(dr, XMLPartitionScanner.XML_TAG);
-		reconciler.setRepairer(dr, XMLPartitionScanner.XML_TAG);
-
-		dr = new DefaultDamagerRepairer(getXMLScanner());
-		reconciler.setDamager(dr, IDocument.DEFAULT_CONTENT_TYPE);
-		reconciler.setRepairer(dr, IDocument.DEFAULT_CONTENT_TYPE);
-
-		NonRuleBasedDamagerRepairer ndr =
-			new NonRuleBasedDamagerRepairer(
-				new TextAttribute(
-					colorManager.getColor(IXMLColorConstants.XML_COMMENT)));
-		reconciler.setDamager(ndr, XMLPartitionScanner.XML_COMMENT);
-		reconciler.setRepairer(ndr, XMLPartitionScanner.XML_COMMENT);
-
-		return reconciler;
-	}
-	
-	// these 2 functions don't seem to control indent
-	public int getTabWidth(ISourceViewer sourceViewer) {
-		return MultiPageEditorContributor.getXMLindent();
-	}
- 	
-	public String[] getIndentPrefixes(ISourceViewer sourceViewer, String contentType) {
-	  StringBuffer spaces = new StringBuffer(4);
-	  int indent = getTabWidth(null);
-	  for (int i = 0; i < indent; i++)
-	    spaces.append(' ');
-		return new String[] { 
-		    "\t", 
-		    spaces.toString()/*, ""*/ }; //$NON-NLS-1$ //$NON-NLS-2$ 
-	}
-	
+  private XMLDoubleClickStrategy doubleClickStrategy;
+
+  private XMLTagScanner tagScanner;
+
+  private XMLScanner scanner;
+
+  private ColorManager colorManager;
+
+  public XMLConfiguration(ColorManager colorManager) {
+    this.colorManager = colorManager;
+  }
+
+  public String[] getConfiguredContentTypes(ISourceViewer sourceViewer) {
+    return new String[] { IDocument.DEFAULT_CONTENT_TYPE, XMLPartitionScanner.XML_COMMENT,
+        XMLPartitionScanner.XML_TAG };
+  }
+
+  public ITextDoubleClickStrategy getDoubleClickStrategy(ISourceViewer sourceViewer,
+                  String contentType) {
+    if (doubleClickStrategy == null)
+      doubleClickStrategy = new XMLDoubleClickStrategy();
+    return doubleClickStrategy;
+  }
+
+  protected XMLScanner getXMLScanner() {
+    if (scanner == null) {
+      scanner = new XMLScanner(colorManager);
+      scanner.setDefaultReturnToken(new Token(new TextAttribute(colorManager
+                      .getColor(IXMLColorConstants.DEFAULT))));
+    }
+    return scanner;
+  }
+
+  protected XMLTagScanner getXMLTagScanner() {
+    if (tagScanner == null) {
+      tagScanner = new XMLTagScanner(colorManager);
+      tagScanner.setDefaultReturnToken(new Token(new TextAttribute(colorManager
+                      .getColor(IXMLColorConstants.TAG))));
+    }
+    return tagScanner;
+  }
+
+  public IPresentationReconciler getPresentationReconciler(ISourceViewer sourceViewer) {
+    PresentationReconciler reconciler = new PresentationReconciler();
+
+    DefaultDamagerRepairer dr = new DefaultDamagerRepairer(getXMLTagScanner());
+    reconciler.setDamager(dr, XMLPartitionScanner.XML_TAG);
+    reconciler.setRepairer(dr, XMLPartitionScanner.XML_TAG);
+
+    dr = new DefaultDamagerRepairer(getXMLScanner());
+    reconciler.setDamager(dr, IDocument.DEFAULT_CONTENT_TYPE);
+    reconciler.setRepairer(dr, IDocument.DEFAULT_CONTENT_TYPE);
+
+    NonRuleBasedDamagerRepairer ndr = new NonRuleBasedDamagerRepairer(new TextAttribute(
+                    colorManager.getColor(IXMLColorConstants.XML_COMMENT)));
+    reconciler.setDamager(ndr, XMLPartitionScanner.XML_COMMENT);
+    reconciler.setRepairer(ndr, XMLPartitionScanner.XML_COMMENT);
+
+    return reconciler;
+  }
+
+  // these 2 functions don't seem to control indent
+  public int getTabWidth(ISourceViewer sourceViewer) {
+    return MultiPageEditorContributor.getXMLindent();
+  }
+
+  public String[] getIndentPrefixes(ISourceViewer sourceViewer, String contentType) {
+    StringBuffer spaces = new StringBuffer(4);
+    int indent = getTabWidth(null);
+    for (int i = 0; i < indent; i++)
+      spaces.append(' ');
+    return new String[] { "\t", spaces.toString() /* , "" */}; //$NON-NLS-1$ //$NON-NLS-2$ 
+  }
+
 }

Modified: incubator/uima/uimaj/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/xml/XMLDocumentProvider.java
URL: http://svn.apache.org/viewvc/incubator/uima/uimaj/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/xml/XMLDocumentProvider.java?view=diff&rev=478232&r1=478231&r2=478232
==============================================================================
--- incubator/uima/uimaj/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/xml/XMLDocumentProvider.java (original)
+++ incubator/uima/uimaj/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/xml/XMLDocumentProvider.java Wed Nov 22 08:50:24 2006
@@ -27,18 +27,14 @@
 
 public class XMLDocumentProvider extends FileDocumentProvider {
 
-	protected IDocument createDocument(Object element) throws CoreException {
-		IDocument document = super.createDocument(element);
-		if (document != null) {
-			IDocumentPartitioner partitioner =
-				new DefaultPartitioner(
-					new XMLPartitionScanner(),
-					new String[] {
-						XMLPartitionScanner.XML_TAG,
-						XMLPartitionScanner.XML_COMMENT });
-			partitioner.connect(document);
-			document.setDocumentPartitioner(partitioner);
-		}
-		return document;
-	}
+  protected IDocument createDocument(Object element) throws CoreException {
+    IDocument document = super.createDocument(element);
+    if (document != null) {
+      IDocumentPartitioner partitioner = new DefaultPartitioner(new XMLPartitionScanner(),
+                      new String[] { XMLPartitionScanner.XML_TAG, XMLPartitionScanner.XML_COMMENT });
+      partitioner.connect(document);
+      document.setDocumentPartitioner(partitioner);
+    }
+    return document;
+  }
 }

Modified: incubator/uima/uimaj/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/xml/XMLDoubleClickStrategy.java
URL: http://svn.apache.org/viewvc/incubator/uima/uimaj/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/xml/XMLDoubleClickStrategy.java?view=diff&rev=478232&r1=478231&r2=478232
==============================================================================
--- incubator/uima/uimaj/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/xml/XMLDoubleClickStrategy.java (original)
+++ incubator/uima/uimaj/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/xml/XMLDoubleClickStrategy.java Wed Nov 22 08:50:24 2006
@@ -22,110 +22,112 @@
 import org.eclipse.jface.text.*;
 
 public class XMLDoubleClickStrategy implements ITextDoubleClickStrategy {
-	protected ITextViewer fText;
+  protected ITextViewer fText;
 
-	public void doubleClicked(ITextViewer part) {
-		int pos = part.getSelectedRange().x;
+  public void doubleClicked(ITextViewer part) {
+    int pos = part.getSelectedRange().x;
 
-		if (pos < 0)
-			return;
+    if (pos < 0)
+      return;
 
-		fText = part;
-
-		if (!selectComment(pos)) {
-			selectWord(pos);
-		}
-	}
-	protected boolean selectComment(int caretPos) {
-		IDocument doc = fText.getDocument();
-		int startPos, endPos;
-
-		try {
-			int pos = caretPos;
-			char c = ' ';
-
-			while (pos >= 0) {
-				c = doc.getChar(pos);
-				if (c == '\\') {
-					pos -= 2;
-					continue;
-				}
-				if (c == '\n' || c == '\"')
-					break;
-				--pos;
-			}
-
-			if (c != '\"')
-				return false;
-
-			startPos = pos;
-
-			pos = caretPos;
-			int length = doc.getLength();
-			c = ' ';
-
-			while (pos < length) {
-				c = doc.getChar(pos);
-				if (c == Character.LINE_SEPARATOR || c == '\"')
-					break;
-				++pos;
-			}
-			if (c != '\"')
-				return false;
-
-			endPos = pos;
-
-			int offset = startPos + 1;
-			int len = endPos - offset;
-			fText.setSelectedRange(offset, len);
-			return true;
-		} catch (BadLocationException x) {
-		}
-
-		return false;
-	}
-	protected boolean selectWord(int caretPos) {
-
-		IDocument doc = fText.getDocument();
-		int startPos, endPos;
-
-		try {
-
-			int pos = caretPos;
-			char c;
-
-			while (pos >= 0) {
-				c = doc.getChar(pos);
-				if (!Character.isJavaIdentifierPart(c))
-					break;
-				--pos;
-			}
-
-			startPos = pos;
-
-			pos = caretPos;
-			int length = doc.getLength();
-
-			while (pos < length) {
-				c = doc.getChar(pos);
-				if (!Character.isJavaIdentifierPart(c))
-					break;
-				++pos;
-			}
-
-			endPos = pos;
-			selectRange(startPos, endPos);
-			return true;
-
-		} catch (BadLocationException x) {
-		}
-
-		return false;
-	}
-
-	private void selectRange(int startPos, int stopPos) {
-		int offset = startPos + 1;
-		int length = stopPos - offset;
-		fText.setSelectedRange(offset, length);
-	}
+    fText = part;
+
+    if (!selectComment(pos)) {
+      selectWord(pos);
+    }
+  }
+
+  protected boolean selectComment(int caretPos) {
+    IDocument doc = fText.getDocument();
+    int startPos, endPos;
+
+    try {
+      int pos = caretPos;
+      char c = ' ';
+
+      while (pos >= 0) {
+        c = doc.getChar(pos);
+        if (c == '\\') {
+          pos -= 2;
+          continue;
+        }
+        if (c == '\n' || c == '\"')
+          break;
+        --pos;
+      }
+
+      if (c != '\"')
+        return false;
+
+      startPos = pos;
+
+      pos = caretPos;
+      int length = doc.getLength();
+      c = ' ';
+
+      while (pos < length) {
+        c = doc.getChar(pos);
+        if (c == Character.LINE_SEPARATOR || c == '\"')
+          break;
+        ++pos;
+      }
+      if (c != '\"')
+        return false;
+
+      endPos = pos;
+
+      int offset = startPos + 1;
+      int len = endPos - offset;
+      fText.setSelectedRange(offset, len);
+      return true;
+    } catch (BadLocationException x) {
+    }
+
+    return false;
+  }
+
+  protected boolean selectWord(int caretPos) {
+
+    IDocument doc = fText.getDocument();
+    int startPos, endPos;
+
+    try {
+
+      int pos = caretPos;
+      char c;
+
+      while (pos >= 0) {
+        c = doc.getChar(pos);
+        if (!Character.isJavaIdentifierPart(c))
+          break;
+        --pos;
+      }
+
+      startPos = pos;
+
+      pos = caretPos;
+      int length = doc.getLength();
+
+      while (pos < length) {
+        c = doc.getChar(pos);
+        if (!Character.isJavaIdentifierPart(c))
+          break;
+        ++pos;
+      }
+
+      endPos = pos;
+      selectRange(startPos, endPos);
+      return true;
+
+    } catch (BadLocationException x) {
+    }
+
+    return false;
+  }
+
+  private void selectRange(int startPos, int stopPos) {
+    int offset = startPos + 1;
+    int length = stopPos - offset;
+    fText.setSelectedRange(offset, length);
+  }
 }

Modified: incubator/uima/uimaj/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/xml/XMLEditor.java
URL: http://svn.apache.org/viewvc/incubator/uima/uimaj/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/xml/XMLEditor.java?view=diff&rev=478232&r1=478231&r2=478232
==============================================================================
--- incubator/uima/uimaj/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/xml/XMLEditor.java (original)
+++ incubator/uima/uimaj/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/xml/XMLEditor.java Wed Nov 22 08:50:24 2006
@@ -48,162 +48,156 @@
 
 public class XMLEditor extends TextEditor {
 
-	MultiPageEditor editor;
-	private ColorManager colorManager;  
-	private EditorsTextListener m_textListener = 
-		new EditorsTextListener();
-	//next set to true when we are setting the text of the
-	//editor so that just switching to source page doesn't
-	//cause editor to think source file is dirty
-	boolean m_bIgnoreTextEvent = false;
-	
-	public class EditorsTextListener implements ITextListener {
-
-		/* (non-Javadoc)
-		 * @see org.eclipse.jface.text.ITextListener#textChanged(org.eclipse.jface.text.TextEvent)
-		 */
-		public void textChanged(TextEvent event) {
-			if(!m_bIgnoreTextEvent) {
-			  editor.sourceChanged = true;
-				editor.setFileDirty();
-			}
-		}
-	}
-
-	public XMLEditor(MultiPageEditor editor) {
-		super();
-		colorManager = new ColorManager();
-		setSourceViewerConfiguration(new XMLConfiguration(colorManager));
-		setDocumentProvider(new XMLDocumentProvider());
-		this.editor = editor;
-	}
-	
-	public void createPartControl(Composite parent) {
-		super.createPartControl(parent);
-		getSourceViewer().addTextListener(m_textListener);
-	}
-	public void dispose() {
-		colorManager.dispose(); 
-		super.dispose();
-	}
-	
-	public void doSaveAs() {
-		IProgressMonitor progressMonitor = getProgressMonitor();
-		Shell shell = getSite().getShell();
-		IEditorInput input = getEditorInput();
-
-		SaveAsDialog dialog = new SaveAsDialog(shell);
-
-		IFile original =
-			(input instanceof IFileEditorInput)
-				? ((IFileEditorInput) input).getFile()
-				: null;
-		if (original != null)
-			dialog.setOriginalFile(original);
-
-		dialog.create();
-
-		IDocumentProvider provider = getDocumentProvider();
-		if (provider == null) {
-			// editor has programatically been  closed while the dialog was open
-			return;
-		}
-
-		if (provider.isDeleted(input) && original != null) {
-			String message = "The original file, '" + original.getName() +  "' has been deleted"; 
-			dialog.setErrorMessage(null);
-			dialog.setMessage(message, IMessageProvider.WARNING);
-		}
-
-		if (dialog.open() == Dialog.CANCEL) {
-			if (progressMonitor != null)
-				progressMonitor.setCanceled(true);
-			editor.setSaveAsStatus(
-				MultiPageEditor.SAVE_AS_CANCELLED);
-			return;
-		}
-
-		IPath filePath = dialog.getResult();
-		if (filePath == null) {
-			if (progressMonitor != null)
-				progressMonitor.setCanceled(true);
-			editor.setSaveAsStatus(
-				MultiPageEditor.SAVE_AS_CANCELLED);
-			return;
-		}
-
-		IWorkspace workspace = ResourcesPlugin.getWorkspace();
-		IFile file = workspace.getRoot().getFile(filePath);
-		final IEditorInput newInput = new FileEditorInput(file);
-
-		WorkspaceModifyOperation op = new WorkspaceModifyOperation() {
-			public void execute(final IProgressMonitor monitor)
-				throws CoreException {
-				getDocumentProvider().saveDocument(
-					monitor,
-					newInput,
-					getDocumentProvider().getDocument(getEditorInput()),
-					true);
-			}
-		};
-
-		boolean success = false;
-		try {
-
-			provider.aboutToChange(newInput);
-			new ProgressMonitorDialog(shell).run(false, true, op);
-			success = true;
-
-		}
-		catch (InterruptedException x) {
-		}
-		catch (InvocationTargetException x) {
-
-			Throwable targetException = x.getTargetException();
-
-			String title = "Error saving"; //TextEditorMessages.getString("Editor.error.save.title"); //$NON-NLS-1$
-			String msg = "Error occurred during save operation"; //MessageFormat.format(TextEditorMessages.getString("Editor.error.save.message"), new Object[] { targetException.getMessage()}); //$NON-NLS-1$
-
-			if (targetException instanceof CoreException) {
-				CoreException coreException = (CoreException) targetException;
-				IStatus status = coreException.getStatus();
-				if (status != null) {
-					switch (status.getSeverity()) {
-						case IStatus.INFO :
-							MessageDialog.openInformation(shell, title, msg);
-							break;
-						case IStatus.WARNING :
-							MessageDialog.openWarning(shell, title, msg);
-							break;
-						default :
-							MessageDialog.openError(shell, title, msg);
-					}
-				}
-				else {
-					MessageDialog.openError(shell, title, msg);
-				}
-			}
-
-		}
-		finally {
-			provider.changed(newInput);
-			if (success) {
-				setInput(newInput);	
-				editor.setSaveAsStatus(
-					MultiPageEditor.SAVE_AS_CONFIRMED);
-			}
-			else {
-				editor.setSaveAsStatus(
-					MultiPageEditor.SAVE_AS_CANCELLED);
-			}	
-		}
-
-		if (progressMonitor != null)
-			progressMonitor.setCanceled(!success);
-	}
-	
-	public void setIgnoreTextEvent(boolean bIgnoreTextEvent) {
-		m_bIgnoreTextEvent = bIgnoreTextEvent;
-	}
+  MultiPageEditor editor;
+
+  private ColorManager colorManager;
+
+  private EditorsTextListener m_textListener = new EditorsTextListener();
+
+  // next set to true when we are setting the text of the
+  // editor so that just switching to source page doesn't
+  // cause editor to think source file is dirty
+  boolean m_bIgnoreTextEvent = false;
+
+  public class EditorsTextListener implements ITextListener {
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.eclipse.jface.text.ITextListener#textChanged(org.eclipse.jface.text.TextEvent)
+     */
+    public void textChanged(TextEvent event) {
+      if (!m_bIgnoreTextEvent) {
+        editor.sourceChanged = true;
+        editor.setFileDirty();
+      }
+    }
+  }
+
+  public XMLEditor(MultiPageEditor editor) {
+    super();
+    colorManager = new ColorManager();
+    setSourceViewerConfiguration(new XMLConfiguration(colorManager));
+    setDocumentProvider(new XMLDocumentProvider());
+    this.editor = editor;
+  }
+
+  public void createPartControl(Composite parent) {
+    super.createPartControl(parent);
+    getSourceViewer().addTextListener(m_textListener);
+  }
+
+  public void dispose() {
+    colorManager.dispose();
+    super.dispose();
+  }
+
+  public void doSaveAs() {
+    IProgressMonitor progressMonitor = getProgressMonitor();
+    Shell shell = getSite().getShell();
+    IEditorInput input = getEditorInput();
+
+    SaveAsDialog dialog = new SaveAsDialog(shell);
+
+    IFile original = (input instanceof IFileEditorInput) ? ((IFileEditorInput) input).getFile()
+                    : null;
+    if (original != null)
+      dialog.setOriginalFile(original);
+
+    dialog.create();
+
+    IDocumentProvider provider = getDocumentProvider();
+    if (provider == null) {
+      // editor has programatically been closed while the dialog was open
+      return;
+    }
+
+    if (provider.isDeleted(input) && original != null) {
+      String message = "The original file, '" + original.getName() + "' has been deleted";
+      dialog.setErrorMessage(null);
+      dialog.setMessage(message, IMessageProvider.WARNING);
+    }
+
+    if (dialog.open() == Dialog.CANCEL) {
+      if (progressMonitor != null)
+        progressMonitor.setCanceled(true);
+      editor.setSaveAsStatus(MultiPageEditor.SAVE_AS_CANCELLED);
+      return;
+    }
+
+    IPath filePath = dialog.getResult();
+    if (filePath == null) {
+      if (progressMonitor != null)
+        progressMonitor.setCanceled(true);
+      editor.setSaveAsStatus(MultiPageEditor.SAVE_AS_CANCELLED);
+      return;
+    }
+
+    IWorkspace workspace = ResourcesPlugin.getWorkspace();
+    IFile file = workspace.getRoot().getFile(filePath);
+    final IEditorInput newInput = new FileEditorInput(file);
+
+    WorkspaceModifyOperation op = new WorkspaceModifyOperation() {
+      public void execute(final IProgressMonitor monitor) throws CoreException {
+        getDocumentProvider().saveDocument(monitor, newInput,
+                        getDocumentProvider().getDocument(getEditorInput()), true);
+      }
+    };
+
+    boolean success = false;
+    try {
+
+      provider.aboutToChange(newInput);
+      new ProgressMonitorDialog(shell).run(false, true, op);
+      success = true;
+
+    } catch (InterruptedException x) {
+    } catch (InvocationTargetException x) {
+
+      Throwable targetException = x.getTargetException();
+
+      String title = "Error saving"; // TextEditorMessages.getString("Editor.error.save.title");
+                                      // //$NON-NLS-1$
+      String msg = "Error occurred during save operation"; // MessageFormat.format(TextEditorMessages.getString("Editor.error.save.message"),
+                                                            // new Object[] {
+                                                            // targetException.getMessage()});
+                                                            // //$NON-NLS-1$
+
+      if (targetException instanceof CoreException) {
+        CoreException coreException = (CoreException) targetException;
+        IStatus status = coreException.getStatus();
+        if (status != null) {
+          switch (status.getSeverity()) {
+            case IStatus.INFO:
+              MessageDialog.openInformation(shell, title, msg);
+              break;
+            case IStatus.WARNING:
+              MessageDialog.openWarning(shell, title, msg);
+              break;
+            default:
+              MessageDialog.openError(shell, title, msg);
+          }
+        } else {
+          MessageDialog.openError(shell, title, msg);
+        }
+      }
+
+    } finally {
+      provider.changed(newInput);
+      if (success) {
+        setInput(newInput);
+        editor.setSaveAsStatus(MultiPageEditor.SAVE_AS_CONFIRMED);
+      } else {
+        editor.setSaveAsStatus(MultiPageEditor.SAVE_AS_CANCELLED);
+      }
+    }
+
+    if (progressMonitor != null)
+      progressMonitor.setCanceled(!success);
+  }
+
+  public void setIgnoreTextEvent(boolean bIgnoreTextEvent) {
+    m_bIgnoreTextEvent = bIgnoreTextEvent;
+  }
 
 }

Modified: incubator/uima/uimaj/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/xml/XMLPartitionScanner.java
URL: http://svn.apache.org/viewvc/incubator/uima/uimaj/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/xml/XMLPartitionScanner.java?view=diff&rev=478232&r1=478231&r2=478232
==============================================================================
--- incubator/uima/uimaj/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/xml/XMLPartitionScanner.java (original)
+++ incubator/uima/uimaj/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/xml/XMLPartitionScanner.java Wed Nov 22 08:50:24 2006
@@ -22,20 +22,22 @@
 import org.eclipse.jface.text.rules.*;
 
 public class XMLPartitionScanner extends RuleBasedPartitionScanner {
-	public final static String XML_DEFAULT = "__xml_default";
-	public final static String XML_COMMENT = "__xml_comment";
-	public final static String XML_TAG = "__xml_tag";
+  public final static String XML_DEFAULT = "__xml_default";
 
-	public XMLPartitionScanner() {
+  public final static String XML_COMMENT = "__xml_comment";
 
-		IToken xmlComment = new Token(XML_COMMENT);
-		IToken tag = new Token(XML_TAG);
+  public final static String XML_TAG = "__xml_tag";
 
-		IPredicateRule[] rules = new IPredicateRule[2];
+  public XMLPartitionScanner() {
 
-		rules[0] = new MultiLineRule("<!--", "-->", xmlComment);
-		rules[1] = new TagRule(tag);
+    IToken xmlComment = new Token(XML_COMMENT);
+    IToken tag = new Token(XML_TAG);
 
-		setPredicateRules(rules);
-	}
+    IPredicateRule[] rules = new IPredicateRule[2];
+
+    rules[0] = new MultiLineRule("<!--", "-->", xmlComment);
+    rules[1] = new TagRule(tag);
+
+    setPredicateRules(rules);
+  }
 }

Modified: incubator/uima/uimaj/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/xml/XMLScanner.java
URL: http://svn.apache.org/viewvc/incubator/uima/uimaj/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/xml/XMLScanner.java?view=diff&rev=478232&r1=478231&r2=478232
==============================================================================
--- incubator/uima/uimaj/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/xml/XMLScanner.java (original)
+++ incubator/uima/uimaj/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/xml/XMLScanner.java Wed Nov 22 08:50:24 2006
@@ -24,18 +24,15 @@
 
 public class XMLScanner extends RuleBasedScanner {
 
-	public XMLScanner(ColorManager manager) {
-		IToken procInstr =
-			new Token(
-				new TextAttribute(
-					manager.getColor(IXMLColorConstants.PROC_INSTR)));
+  public XMLScanner(ColorManager manager) {
+    IToken procInstr = new Token(new TextAttribute(manager.getColor(IXMLColorConstants.PROC_INSTR)));
 
-		IRule[] rules = new IRule[2];
-		//Add rule for processing instructions
-		rules[0] = new SingleLineRule("<?", "?>", procInstr);
-		// Add generic whitespace rule.
-		rules[1] = new WhitespaceRule(new XMLWhitespaceDetector());
+    IRule[] rules = new IRule[2];
+    // Add rule for processing instructions
+    rules[0] = new SingleLineRule("<?", "?>", procInstr);
+    // Add generic whitespace rule.
+    rules[1] = new WhitespaceRule(new XMLWhitespaceDetector());
 
-		setRules(rules);
-	}
+    setRules(rules);
+  }
 }

Modified: incubator/uima/uimaj/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/xml/XMLTagScanner.java
URL: http://svn.apache.org/viewvc/incubator/uima/uimaj/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/xml/XMLTagScanner.java?view=diff&rev=478232&r1=478231&r2=478232
==============================================================================
--- incubator/uima/uimaj/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/xml/XMLTagScanner.java (original)
+++ incubator/uima/uimaj/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/xml/XMLTagScanner.java Wed Nov 22 08:50:24 2006
@@ -24,20 +24,18 @@
 
 public class XMLTagScanner extends RuleBasedScanner {
 
-	public XMLTagScanner(ColorManager manager) {
-		IToken string =
-			new Token(
-				new TextAttribute(manager.getColor(IXMLColorConstants.STRING)));
+  public XMLTagScanner(ColorManager manager) {
+    IToken string = new Token(new TextAttribute(manager.getColor(IXMLColorConstants.STRING)));
 
-		IRule[] rules = new IRule[3];
+    IRule[] rules = new IRule[3];
 
-		// Add rule for double quotes
-		rules[0] = new SingleLineRule("\"", "\"", string, '\\');
-		// Add a rule for single quotes
-		rules[1] = new SingleLineRule("'", "'", string, '\\');
-		// Add generic whitespace rule.
-		rules[2] = new WhitespaceRule(new XMLWhitespaceDetector());
+    // Add rule for double quotes
+    rules[0] = new SingleLineRule("\"", "\"", string, '\\');
+    // Add a rule for single quotes
+    rules[1] = new SingleLineRule("'", "'", string, '\\');
+    // Add generic whitespace rule.
+    rules[2] = new WhitespaceRule(new XMLWhitespaceDetector());
 
-		setRules(rules);
-	}
+    setRules(rules);
+  }
 }

Modified: incubator/uima/uimaj/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/xml/XMLWhitespaceDetector.java
URL: http://svn.apache.org/viewvc/incubator/uima/uimaj/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/xml/XMLWhitespaceDetector.java?view=diff&rev=478232&r1=478231&r2=478232
==============================================================================
--- incubator/uima/uimaj/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/xml/XMLWhitespaceDetector.java (original)
+++ incubator/uima/uimaj/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/xml/XMLWhitespaceDetector.java Wed Nov 22 08:50:24 2006
@@ -23,7 +23,7 @@
 
 public class XMLWhitespaceDetector implements IWhitespaceDetector {
 
-	public boolean isWhitespace(char c) {
-		return (c == ' ' || c == '\t' || c == '\n' || c == '\r');
-	}
+  public boolean isWhitespace(char c) {
+    return (c == ' ' || c == '\t' || c == '\n' || c == '\r');
+  }
 }

Modified: incubator/uima/uimaj/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/files/ContextForPartDialog.java
URL: http://svn.apache.org/viewvc/incubator/uima/uimaj/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/files/ContextForPartDialog.java?view=diff&rev=478232&r1=478231&r2=478232
==============================================================================
--- incubator/uima/uimaj/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/files/ContextForPartDialog.java (original)
+++ incubator/uima/uimaj/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/files/ContextForPartDialog.java Wed Nov 22 08:50:24 2006
@@ -43,161 +43,166 @@
 import org.apache.uima.taeconfigurator.editors.ui.AbstractSection;
 import org.apache.uima.util.XMLizable;
 
-public class ContextForPartDialog
-	extends LimitedResourceSelectionDialog 
-  implements ICheckStateListener {
+public class ContextForPartDialog extends LimitedResourceSelectionDialog implements
+                ICheckStateListener {
 
-//	private MultiPageEditor editor;
+  // private MultiPageEditor editor;
   private Text contextPathGUI;
+
   public String contextPath;
+
   private String initialPath;
+
   private XMLizable tbe;
 
-	public ContextForPartDialog(
-		Shell parentShell,
-		IAdaptable rootElement,
-    XMLizable thingBeingEdited,
-		IPath aExcludeDescriptor,
-		MultiPageEditor aEditor,
-    String aInitialPath) {
+  public ContextForPartDialog(Shell parentShell, IAdaptable rootElement,
+                  XMLizable thingBeingEdited, IPath aExcludeDescriptor, MultiPageEditor aEditor,
+                  String aInitialPath) {
 
-		super(parentShell, rootElement, "Context for importable part");
-//		editor = aEditor;
+    super(parentShell, rootElement, "Context for importable part");
+    // editor = aEditor;
     initialPath = aInitialPath;
-		setTitle("Context for importable part");
+    setTitle("Context for importable part");
     tbe = thingBeingEdited;
-		setShellStyle(getShellStyle() | SWT.RESIZE);
-	}
+    setShellStyle(getShellStyle() | SWT.RESIZE);
+  }
 
-	protected Control createDialogArea(Composite parent) {
-    parent = new Composite(parent,SWT.NONE);
+  protected Control createDialogArea(Composite parent) {
+    parent = new Composite(parent, SWT.NONE);
     parent.setLayout(new GridLayout(1, true));
-    parent.setLayoutData(new GridData(SWT.LEAD,SWT.BEGINNING,true,false));
-    ((GridLayout)parent.getLayout()).marginWidth = 15;
-		// Show a text field with the path, allow editing
+    parent.setLayoutData(new GridData(SWT.LEAD, SWT.BEGINNING, true, false));
+    ((GridLayout) parent.getLayout()).marginWidth = 15;
+    // Show a text field with the path, allow editing
     // anything picked overrides the text field
     AbstractSection.spacer(parent);
     Label instructions = new Label(parent, SWT.WRAP);
-    instructions.setText(MessageFormat.format(
-        "You are about to edit a UIMA {0} descriptor.  \n" +
-        "In order to do this, you need to specify another UIMA descriptor, which will supply " +
-        "the needed context for this file.\n" +
-        "It can be any of the following kinds of descriptors:\n\n    " +
-        "{1}\n\n" +
-        "The file below is a suggested context.  \n\n" +
-        "     >>>  If it is correct, just push OK.  <<<\n\n" +
-        "Otherwise you can change it by overtyping it,\n" +
-        "or use the project explorer window below to pick the context file to use.",
-        new Object[]{
-           (tbe instanceof FsIndexCollection) ? "Index Definition" :
-           (tbe instanceof TypePriorities) ? "Type Priority Definition" :
-           (tbe instanceof ResourceManagerConfiguration) ? "Resource Manager Configuration" : "unhandled - error",
-          
-           (tbe instanceof FsIndexCollection) ? "A Type System or any descriptor containing or " +
-              "importing the type system associated with this Index Definition,\n    other than a Collection Processing Engine" :
-           (tbe instanceof TypePriorities) ? "A Type System or any descriptor containing or " +
-               "importing the type system associated with this TypePriority Definition,\n    other than a Collection Processing Engine" :     
-           (tbe instanceof ResourceManagerConfiguration) ?  "A descriptor (such as an Analysis Engine) containing " +
-              "(directly or via aggregate delegates)\n    " +
-              "the External Resource Dependencies referenced by this Resource Manager Configuration" : "unhandled - error"  
-        }));
-      
+    instructions
+                    .setText(MessageFormat
+                                    .format(
+                                                    "You are about to edit a UIMA {0} descriptor.  \n"
+                                                                    + "In order to do this, you need to specify another UIMA descriptor, which will supply "
+                                                                    + "the needed context for this file.\n"
+                                                                    + "It can be any of the following kinds of descriptors:\n\n    "
+                                                                    + "{1}\n\n"
+                                                                    + "The file below is a suggested context.  \n\n"
+                                                                    + "     >>>  If it is correct, just push OK.  <<<\n\n"
+                                                                    + "Otherwise you can change it by overtyping it,\n"
+                                                                    + "or use the project explorer window below to pick the context file to use.",
+                                                    new Object[] {
+                                                        (tbe instanceof FsIndexCollection) ? "Index Definition"
+                                                                        : (tbe instanceof TypePriorities) ? "Type Priority Definition"
+                                                                                        : (tbe instanceof ResourceManagerConfiguration) ? "Resource Manager Configuration"
+                                                                                                        : "unhandled - error",
+
+                                                        (tbe instanceof FsIndexCollection) ? "A Type System or any descriptor containing or "
+                                                                        + "importing the type system associated with this Index Definition,\n    other than a Collection Processing Engine"
+                                                                        : (tbe instanceof TypePriorities) ? "A Type System or any descriptor containing or "
+                                                                                        + "importing the type system associated with this TypePriority Definition,\n    other than a Collection Processing Engine"
+                                                                                        : (tbe instanceof ResourceManagerConfiguration) ? "A descriptor (such as an Analysis Engine) containing "
+                                                                                                        + "(directly or via aggregate delegates)\n    "
+                                                                                                        + "the External Resource Dependencies referenced by this Resource Manager Configuration"
+                                                                                                        : "unhandled - error" }));
+
     AbstractSection.spacer(parent);
-    
+
     contextPathGUI = new Text(parent, SWT.BORDER);
     contextPathGUI.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
     contextPathGUI.setText(null == initialPath ? "" : initialPath);
-//    AbstractSection.spacer(parent);  
-    
-		Composite composite = (Composite) super.createDialogArea(parent);
-//		FormToolkit factory = new FormToolkit(TAEConfiguratorPlugin.getDefault().getFormColors(parent.getDisplay()));
-//		Label label = new Label(composite, SWT.WRAP /*SWT.CENTER*/);
-//		label.setText(Messages.getString("MultiResourceSelectionDialog.Or")); //$NON-NLS-1$
-//		browseButton =
-//			factory.createButton(
-//				composite,
-//				Messages.getString("MultiResourceSelectionDialog.BrowseFileSys"), //$NON-NLS-1$
-//				SWT.PUSH);
-//		browseButton.setLayoutData(
-//			new GridData(GridData.VERTICAL_ALIGN_BEGINNING));
-//		browseButton.pack(false);
-//		browseButton.addListener(SWT.MouseUp, new Listener() {	  
-//			public void handleEvent(Event event) {
-//				FileDialog dialog = new FileDialog(getShell(), /*SWT.OPEN |*/
-//				SWT.MULTI);
-//				String[] extensions = { Messages.getString("MultiResourceSelectionDialog.starDotXml") }; //$NON-NLS-1$
-//				dialog.setFilterExtensions(extensions);
-//				String sStartDir =
-//					TAEConfiguratorPlugin
-//						.getWorkspace()
-//						.getRoot()
-//						.getLocation()
-//						.toOSString();
-//				dialog.setFilterPath(sStartDir);
-//				String file = dialog.open();
-//
-//				if (file != null && !file.equals("")) { //$NON-NLS-1$
-//					//close();
-//					okPressed();
-//					ArrayList list = new ArrayList();
-//					IPath iPath = new Path(file);
-//					list.add(iPath);
-//					localSetResult(list);
-//				}
-//			}
-//
-//		});
-//
-//		new Label(composite, SWT.NONE).setText("");
-//		importByNameUI = new Button(composite, SWT.RADIO);
-//		importByNameUI.setText("Import by Name");
-//		importByNameUI.setToolTipText(
-//		  "Importing by name looks up the name on the datapath, and if not found there, on the classpath.");
-//
-//		
-//		importByLocationUI = new Button(composite, SWT.RADIO);
-//		importByLocationUI.setText("Import By Location");
-//		importByLocationUI.setToolTipText(
-//				"Importing by location requires a relative or absolute URL");
-//		
-//		String defaultBy = CDEpropertyPage.getImportByDefault(editor.getProject());
-//		if (defaultBy.equals("location")) {
-//			importByNameUI.setSelection(false);
-//			importByLocationUI.setSelection(true);
-//		}
-//		else {
-//			importByNameUI.setSelection(true);
-//			importByLocationUI.setSelection(false);
-//		}
-		return composite;
-	}
-
-	protected void okPressed() {
-//		isImportByName = importByNameUI.getSelection();
-//		CDEpropertyPage.setImportByDefault(editor.getProject(), isImportByName ? "name" : "location");
+    // AbstractSection.spacer(parent);
+
+    Composite composite = (Composite) super.createDialogArea(parent);
+    // FormToolkit factory = new
+    // FormToolkit(TAEConfiguratorPlugin.getDefault().getFormColors(parent.getDisplay()));
+    // Label label = new Label(composite, SWT.WRAP /*SWT.CENTER*/);
+    // label.setText(Messages.getString("MultiResourceSelectionDialog.Or")); //$NON-NLS-1$
+    // browseButton =
+    // factory.createButton(
+    // composite,
+    // Messages.getString("MultiResourceSelectionDialog.BrowseFileSys"), //$NON-NLS-1$
+    // SWT.PUSH);
+    // browseButton.setLayoutData(
+    // new GridData(GridData.VERTICAL_ALIGN_BEGINNING));
+    // browseButton.pack(false);
+    // browseButton.addListener(SWT.MouseUp, new Listener() {
+    // public void handleEvent(Event event) {
+    // FileDialog dialog = new FileDialog(getShell(), /*SWT.OPEN |*/
+    // SWT.MULTI);
+    // String[] extensions = { Messages.getString("MultiResourceSelectionDialog.starDotXml") };
+    // //$NON-NLS-1$
+    // dialog.setFilterExtensions(extensions);
+    // String sStartDir =
+    // TAEConfiguratorPlugin
+    // .getWorkspace()
+    // .getRoot()
+    // .getLocation()
+    // .toOSString();
+    // dialog.setFilterPath(sStartDir);
+    // String file = dialog.open();
+    //
+    // if (file != null && !file.equals("")) { //$NON-NLS-1$
+    // //close();
+    // okPressed();
+    // ArrayList list = new ArrayList();
+    // IPath iPath = new Path(file);
+    // list.add(iPath);
+    // localSetResult(list);
+    // }
+    // }
+    //
+    // });
+    //
+    // new Label(composite, SWT.NONE).setText("");
+    // importByNameUI = new Button(composite, SWT.RADIO);
+    // importByNameUI.setText("Import by Name");
+    // importByNameUI.setToolTipText(
+    // "Importing by name looks up the name on the datapath, and if not found there, on the
+    // classpath.");
+    //
+    //		
+    // importByLocationUI = new Button(composite, SWT.RADIO);
+    // importByLocationUI.setText("Import By Location");
+    // importByLocationUI.setToolTipText(
+    // "Importing by location requires a relative or absolute URL");
+    //		
+    // String defaultBy = CDEpropertyPage.getImportByDefault(editor.getProject());
+    // if (defaultBy.equals("location")) {
+    // importByNameUI.setSelection(false);
+    // importByLocationUI.setSelection(true);
+    // }
+    // else {
+    // importByNameUI.setSelection(true);
+    // importByLocationUI.setSelection(false);
+    // }
+    return composite;
+  }
+
+  protected void okPressed() {
+    // isImportByName = importByNameUI.getSelection();
+    // CDEpropertyPage.setImportByDefault(editor.getProject(), isImportByName ? "name" :
+    // "location");
     contextPath = contextPathGUI.getText();
-		super.okPressed();
-	}
+    super.okPressed();
+  }
 
-	// This is to avoid synthetic access method warning
+  // This is to avoid synthetic access method warning
   protected void localSetResult(ArrayList list) {
     setResult(list);
   }
-  
+
   public void checkStateChanged(CheckStateChangedEvent event) {
-//    event.getChecked();  // true if checked
-//    event.getElement();  // File with workspace-relative path
+    // event.getChecked(); // true if checked
+    // event.getElement(); // File with workspace-relative path
     if (event.getChecked() && event.getElement() instanceof IFile) {
-      contextPathGUI.setText(((IFile)event.getElement()).getLocation().toString());
+      contextPathGUI.setText(((IFile) event.getElement()).getLocation().toString());
     }
-    getOkButton().setEnabled(selectionGroup.getCheckedElementCount() > 0 ||
-        contextPathGUI.getText().length() > 0);
+    getOkButton().setEnabled(
+                    selectionGroup.getCheckedElementCount() > 0
+                                    || contextPathGUI.getText().length() > 0);
   }
-  
+
   protected void initializeDialog() {
     selectionGroup.addCheckStateListener(this);
-    getOkButton().setEnabled(contextPathGUI.getText().length() > 0); 
+    getOkButton().setEnabled(contextPathGUI.getText().length() > 0);
   }
-  
 
 }

Modified: incubator/uima/uimaj/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/files/LimitedResourceSelectionDialog.java
URL: http://svn.apache.org/viewvc/incubator/uima/uimaj/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/files/LimitedResourceSelectionDialog.java?view=diff&rev=478232&r1=478231&r2=478232
==============================================================================
--- incubator/uima/uimaj/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/files/LimitedResourceSelectionDialog.java (original)
+++ incubator/uima/uimaj/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/files/LimitedResourceSelectionDialog.java Wed Nov 22 08:50:24 2006
@@ -40,204 +40,208 @@
 import org.apache.uima.taeconfigurator.Messages;
 
 /**
- * A standard resource selection dialog which solicits a list of resources from
- * the user. The <code>getResult</code> method returns the selected resources.
+ * A standard resource selection dialog which solicits a list of resources from the user. The
+ * <code>getResult</code> method returns the selected resources.
  * <p>
  * This class may be instantiated; it is not intended to be subclassed.
  * </p>
  * <p>
  * Example:
+ * 
  * <pre>
- * 	ResourceSelectionDialog dialog =
- *		new ResourceSelectionDialog(getShell(), rootResource, msg);
- *	dialog.setInitialSelections(selectedResources));
- *	dialog.open();
- *	return dialog.getResult();
+ *  	ResourceSelectionDialog dialog =
+ * 		new ResourceSelectionDialog(getShell(), rootResource, msg);
+ * 	dialog.setInitialSelections(selectedResources));
+ * 	dialog.open();
+ * 	return dialog.getResult();
  * </pre>
+ * 
  * </p>
  * 
  */
 public class LimitedResourceSelectionDialog extends SelectionDialog {
-	// the root element to populate the viewer with
-	private Object root;  // was IAdaptable
+  // the root element to populate the viewer with
+  private Object root; // was IAdaptable
+
+  // the visual selection widget group
+  TreeGroup selectionGroup;
+
+  // constants
+  protected final static int SIZING_SELECTION_WIDGET_WIDTH = 400;
 
-	// the visual selection widget group
-	TreeGroup selectionGroup;
-	// constants
-	protected final static int SIZING_SELECTION_WIDGET_WIDTH = 400;
-	protected final static int SIZING_SELECTION_WIDGET_HEIGHT = 300;
-
-	/**
-	 * Creates a resource selection dialog rooted at the given element.
-	 *
-	 * @param parentShell the parent shell
-	 * @param rootElement the root element to populate this dialog with
-	 * @param message the message to be displayed at the top of this dialog, or
-	 *    <code>null</code> to display a default message
-	 */
-	public LimitedResourceSelectionDialog(Shell parentShell, Object rootElement, String message) {
-		super(parentShell);
-		setTitle(Messages.getString("LimitedResourceSelectionDialog.ResourceSelectionDialog")); //$NON-NLS-1$
-		root = rootElement;
-		if (message != null)
-			setMessage(message);
-		else
-			setMessage(Messages.getString("LimitedResourceSelectionDialog.ResourceSelectionDialog")); //$NON-NLS-1$
-		setShellStyle(getShellStyle() | SWT.RESIZE);
-	}
-
-	/**
-	 * Visually checks the previously-specified elements in the container (left)
-	 * portion of this dialog's resource selection viewer.
-	 */
-	private void checkInitialSelections() {
-		Iterator itemsToCheck = getInitialElementSelections().iterator();
-
-		while (itemsToCheck.hasNext()) {
-			IResource currentElement = (IResource)itemsToCheck.next();
-
-			if (currentElement.getType() == IResource.FILE)
-				selectionGroup.initialCheckListItem(currentElement);
-			else
-				selectionGroup.initialCheckTreeItem(currentElement);
-		}
-	}
-
-	/* 
-	 * Method declared on ICheckStateListener.
-	 */
-	public void checkStateChanged(CheckStateChangedEvent event) {
-		getOkButton().setEnabled(selectionGroup.getCheckedElementCount() > 0);
-	}
-
-	/* 
-	 * Method declared in Window.
-	 */
-	protected void configureShell(Shell shell) {
-		super.configureShell(shell);
-		//WorkbenchHelp.setHelp(shell, IHelpContextIds.RESOURCE_SELECTION_DIALOG);
-	}
-
-	public void create() {
-		super.create();
-		initializeDialog();
-	}
-
-	/* 
-	 * Method declared on Dialog.
-	 */
-	protected Control createDialogArea(Composite parent) {
-		// page group
-		Composite composite = (Composite)super.createDialogArea(parent);
-
-		//create the input element, which has the root resource
-		//as its only child
-		ArrayList input = new ArrayList();
-		input.add(root);
-
-		createMessageArea(composite);
-		selectionGroup = createTreeGroup(composite, input);
-
-		composite.addControlListener(new ControlListener() {
-			public void controlMoved(ControlEvent e) {
-			};
-			public void controlResized(ControlEvent e) {
-				//Also try and reset the size of the columns as appropriate
-				TableColumn[] columns = selectionGroup.getListTable().getColumns();
-				for (int i = 0; i < columns.length; i++) {
-					columns[i].pack();
-				}
-			}
-		});
-		return composite;
-	}
-
-	protected TreeGroup createTreeGroup(Composite composite, Object rootObject) {
-		return new TreeGroup(
-				composite,
-				rootObject,
-				getResourceProvider(IResource.FOLDER | IResource.PROJECT | IResource.ROOT),
-				WorkbenchLabelProvider.getDecoratingWorkbenchLabelProvider(),
-				getResourceProvider(IResource.FILE),
-				WorkbenchLabelProvider.getDecoratingWorkbenchLabelProvider(),
-				SWT.NONE,
-			  // since this page has no other significantly-sized
-		    // widgets we need to hardcode the combined widget's
-		    // size, otherwise it will open too small
-	      SIZING_SELECTION_WIDGET_WIDTH, 
-	      SIZING_SELECTION_WIDGET_HEIGHT); 
-	}
-	/**
-	 * Returns a content provider for <code>IResource</code>s that returns 
-	 * only children of the given resource type.
-	 */
-	private ITreeContentProvider getResourceProvider(final int resourceType) {
-		return new WbContentProvider() {
-			public Object[] getChildren(Object o) {
-				if (o instanceof IContainer) {
-					IResource[] members = null;
-					try {
-						members = ((IContainer)o).members();
-					} catch (CoreException e) {
-						//just return an empty set of children
-						return new Object[0];
-					}
-
-					//filter out the desired resource types
-					ArrayList results = new ArrayList();
-					for (int i = 0; i < members.length; i++) {
-						IResource mbr = members[i];
-						int mbrType = mbr.getType();
-						//And the test bits with the resource types to see if they are what we want
-						if ((mbrType & resourceType) > 0) {
-							if ((mbrType & IResource.FILE) > 0) {
-								String fileExtension = mbr.getFileExtension();
-								if (null != fileExtension && !"xml".equals(fileExtension.toLowerCase()))
-									continue;
-							}
-							results.add(mbr);
-						}
-					}
-					return results.toArray();
-				} else {
-					//input element case
-					if (o instanceof ArrayList) {
-						return ((ArrayList)o).toArray();
-					} else {
-						return new Object[0];
-					}
-				}
-			}
-		};
-	}
-
-	/**
-	 * Initializes this dialog's controls.
-	 */
-	protected void initializeDialog() {
-		selectionGroup.addCheckStateListener(new ICheckStateListener() {
-			public void checkStateChanged(CheckStateChangedEvent event) {
-				getOkButton().setEnabled(selectionGroup.getCheckedElementCount() > 0);
-			}
-		});
-
-		if (getInitialElementSelections().isEmpty())
-			getOkButton().setEnabled(false);
-		else
-			checkInitialSelections();
-	}
-
-	/**
-	 * The <code>ResourceSelectionDialog</code> implementation of this 
-	 * <code>Dialog</code> method builds a list of the selected resources for later 
-	 * retrieval by the client and closes this dialog.
-	 */
-	protected void okPressed() {
-		Iterator resultEnum = selectionGroup.getAllCheckedListItems();
-		ArrayList list = new ArrayList();
-		while (resultEnum.hasNext())
-			list.add(resultEnum.next());
-		setResult(list);
-		super.okPressed();
-	}
+  protected final static int SIZING_SELECTION_WIDGET_HEIGHT = 300;
+
+  /**
+   * Creates a resource selection dialog rooted at the given element.
+   * 
+   * @param parentShell
+   *          the parent shell
+   * @param rootElement
+   *          the root element to populate this dialog with
+   * @param message
+   *          the message to be displayed at the top of this dialog, or <code>null</code> to
+   *          display a default message
+   */
+  public LimitedResourceSelectionDialog(Shell parentShell, Object rootElement, String message) {
+    super(parentShell);
+    setTitle(Messages.getString("LimitedResourceSelectionDialog.ResourceSelectionDialog")); //$NON-NLS-1$
+    root = rootElement;
+    if (message != null)
+      setMessage(message);
+    else
+      setMessage(Messages.getString("LimitedResourceSelectionDialog.ResourceSelectionDialog")); //$NON-NLS-1$
+    setShellStyle(getShellStyle() | SWT.RESIZE);
+  }
+
+  /**
+   * Visually checks the previously-specified elements in the container (left) portion of this
+   * dialog's resource selection viewer.
+   */
+  private void checkInitialSelections() {
+    Iterator itemsToCheck = getInitialElementSelections().iterator();
+
+    while (itemsToCheck.hasNext()) {
+      IResource currentElement = (IResource) itemsToCheck.next();
+
+      if (currentElement.getType() == IResource.FILE)
+        selectionGroup.initialCheckListItem(currentElement);
+      else
+        selectionGroup.initialCheckTreeItem(currentElement);
+    }
+  }
+
+  /*
+   * Method declared on ICheckStateListener.
+   */
+  public void checkStateChanged(CheckStateChangedEvent event) {
+    getOkButton().setEnabled(selectionGroup.getCheckedElementCount() > 0);
+  }
+
+  /*
+   * Method declared in Window.
+   */
+  protected void configureShell(Shell shell) {
+    super.configureShell(shell);
+    // WorkbenchHelp.setHelp(shell, IHelpContextIds.RESOURCE_SELECTION_DIALOG);
+  }
+
+  public void create() {
+    super.create();
+    initializeDialog();
+  }
+
+  /*
+   * Method declared on Dialog.
+   */
+  protected Control createDialogArea(Composite parent) {
+    // page group
+    Composite composite = (Composite) super.createDialogArea(parent);
+
+    // create the input element, which has the root resource
+    // as its only child
+    ArrayList input = new ArrayList();
+    input.add(root);
+
+    createMessageArea(composite);
+    selectionGroup = createTreeGroup(composite, input);
+
+    composite.addControlListener(new ControlListener() {
+      public void controlMoved(ControlEvent e) {
+      }
+
+      public void controlResized(ControlEvent e) {
+        // Also try and reset the size of the columns as appropriate
+        TableColumn[] columns = selectionGroup.getListTable().getColumns();
+        for (int i = 0; i < columns.length; i++) {
+          columns[i].pack();
+        }
+      }
+    });
+    return composite;
+  }
+
+  protected TreeGroup createTreeGroup(Composite composite, Object rootObject) {
+    return new TreeGroup(composite, rootObject, getResourceProvider(IResource.FOLDER
+                    | IResource.PROJECT | IResource.ROOT), WorkbenchLabelProvider
+                    .getDecoratingWorkbenchLabelProvider(), getResourceProvider(IResource.FILE),
+                    WorkbenchLabelProvider.getDecoratingWorkbenchLabelProvider(), SWT.NONE,
+                    // since this page has no other significantly-sized
+                    // widgets we need to hardcode the combined widget's
+                    // size, otherwise it will open too small
+                    SIZING_SELECTION_WIDGET_WIDTH, SIZING_SELECTION_WIDGET_HEIGHT);
+  }
+
+  /**
+   * Returns a content provider for <code>IResource</code>s that returns only children of the
+   * given resource type.
+   */
+  private ITreeContentProvider getResourceProvider(final int resourceType) {
+    return new WbContentProvider() {
+      public Object[] getChildren(Object o) {
+        if (o instanceof IContainer) {
+          IResource[] members = null;
+          try {
+            members = ((IContainer) o).members();
+          } catch (CoreException e) {
+            // just return an empty set of children
+            return new Object[0];
+          }
+
+          // filter out the desired resource types
+          ArrayList results = new ArrayList();
+          for (int i = 0; i < members.length; i++) {
+            IResource mbr = members[i];
+            int mbrType = mbr.getType();
+            // And the test bits with the resource types to see if they are what we want
+            if ((mbrType & resourceType) > 0) {
+              if ((mbrType & IResource.FILE) > 0) {
+                String fileExtension = mbr.getFileExtension();
+                if (null != fileExtension && !"xml".equals(fileExtension.toLowerCase()))
+                  continue;
+              }
+              results.add(mbr);
+            }
+          }
+          return results.toArray();
+        } else {
+          // input element case
+          if (o instanceof ArrayList) {
+            return ((ArrayList) o).toArray();
+          } else {
+            return new Object[0];
+          }
+        }
+      }
+    };
+  }
+
+  /**
+   * Initializes this dialog's controls.
+   */
+  protected void initializeDialog() {
+    selectionGroup.addCheckStateListener(new ICheckStateListener() {
+      public void checkStateChanged(CheckStateChangedEvent event) {
+        getOkButton().setEnabled(selectionGroup.getCheckedElementCount() > 0);
+      }
+    });
+
+    if (getInitialElementSelections().isEmpty())
+      getOkButton().setEnabled(false);
+    else
+      checkInitialSelections();
+  }
+
+  /**
+   * The <code>ResourceSelectionDialog</code> implementation of this <code>Dialog</code> method
+   * builds a list of the selected resources for later retrieval by the client and closes this
+   * dialog.
+   */
+  protected void okPressed() {
+    Iterator resultEnum = selectionGroup.getAllCheckedListItems();
+    ArrayList list = new ArrayList();
+    while (resultEnum.hasNext())
+      list.add(resultEnum.next());
+    setResult(list);
+    super.okPressed();
+  }
 }