org.eclipse.wst.html.ui_1.0.602.v201202091936

16:49:02.042 INFO  jd.cli.Main - Decompiling org.eclipse.wst.html.ui_1.0.602.v201202091936.jar
package org.eclipse.wst.html.internal.validation;

import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.wst.html.core.internal.validate.MessageFactory;
import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument;
import org.eclipse.wst.sse.core.internal.validate.ErrorInfo;
import org.eclipse.wst.sse.core.internal.validate.ValidationMessage;
import org.eclipse.wst.sse.core.internal.validate.ValidationReporter;
import org.eclipse.wst.validation.internal.provisional.core.IMessage;
import org.eclipse.wst.validation.internal.provisional.core.IReporter;
import org.eclipse.wst.validation.internal.provisional.core.IValidator;

public class HTMLValidationReporter
  implements ValidationReporter
{
  private IValidator owner = null;
  private IReporter reporter = null;
  private IFile file = null;
  private IStructuredModel model = null;
  private HTMLValidationResult result = null;
  private MessageFactory fFactory = null;
  
  public HTMLValidationReporter(IValidator owner, IReporter reporter, IFile file, IStructuredModel model)
  {
    this.owner = owner;
    this.reporter = reporter;
    this.file = file;
    this.model = model;
    fFactory = new MessageFactory(file != null ? file.getProject() : null);
  }
  
  public void clear()
  {
    if (file == null) {
      return;
    }
    result = null;
    if (reporter != null)
    {
      reporter.removeAllMessages(owner, file);
    }
    else
    {
      String id = HTMLValidator.class.getName();
      try
      {
        TaskListHelper.getTaskList().removeAllTasks(file, id, null);
      }
      catch (CoreException localCoreException) {}
    }
  }
  
  public HTMLValidationResult getResult()
  {
    if (result == null) {
      result = new HTMLValidationResult();
    }
    return result;
  }
  
  public void report(ValidationMessage message)
  {
    if ((message == null) || (message.getSeverity() == -1)) {
      return;
    }
    IMessage mes = translateMessage(message);
    if (reporter != null)
    {
      reporter.addMessage(owner, mes);
    }
    else
    {
      if (file == null) {
        return;
      }
      String id = HTMLValidator.class.getName();
      String location = Integer.toString(mes.getLineNumber());
      String name = "";
      IPath filePath = file.getFullPath();
      if (filePath != null) {
        name = filePath.toString();
      }
      try
      {
        TaskListHelper.getTaskList().addTask(id, file, location, mes.getId(), mes.getText(), mes.getSeverity(), name, mes.getGroupName(), mes.getOffset(), mes.getLength());
      }
      catch (CoreException localCoreException) {}
    }
  }
  
  private IMessage translateMessage(ValidationMessage message)
  {
    int severity = 4;
    HTMLValidationResult result = getResult();
    switch (message.getSeverity())
    {
    case 1: 
      severity = 1;
      result.addError();
      break;
    case 2: 
      severity = 2;
      result.addWarning();
      break;
    case 3: 
      result.addInformation();
      break;
    }
    IMessage mes = new LocalizedMessage(severity, message.getMessage(), file);
    mes.setOffset(message.getOffset());
    mes.setLength(message.getLength());
    if (model != null)
    {
      IStructuredDocument flatModel = model.getStructuredDocument();
      if (flatModel != null)
      {
        int line = flatModel.getLineOfOffset(message.getOffset());
        mes.setLineNo(line + 1);
      }
    }
    return mes;
  }
  
  public void report(ErrorInfo info)
  {
    report(fFactory.createMessage(info));
  }
}

/* Location:
 * Qualified Name:     org.eclipse.wst.html.internal.validation.HTMLValidationReporter
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.wst.html.internal.validation;

public class HTMLValidationResult
{
  private int errors = 0;
  private int warnings = 0;
  private int informations = 0;
  
  public void addError()
  {
    errors += 1;
  }
  
  public void addInformation()
  {
    informations += 1;
  }
  
  public void addWarning()
  {
    warnings += 1;
  }
  
  public int getErrors()
  {
    return errors;
  }
  
  public int getInformations()
  {
    return informations;
  }
  
  public int getWarnings()
  {
    return warnings;
  }
  
  public boolean isValid()
  {
    return (errors == 0) && (warnings == 0) && (informations == 0);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.wst.html.internal.validation.HTMLValidationResult
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.wst.html.internal.validation;

import org.eclipse.core.resources.IFile;
import org.eclipse.wst.validation.internal.operations.WorkbenchContext;

public class HTMLValidationWorkbenchHelper
  extends WorkbenchContext
{
  public String getTargetObjectName(Object object)
  {
    if (object == null) {
      return null;
    }
    if ((object instanceof IFile)) {
      return getPortableName((IFile)object);
    }
    return object.toString();
  }
}

/* Location:
 * Qualified Name:     org.eclipse.wst.html.internal.validation.HTMLValidationWorkbenchHelper
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.wst.html.internal.validation;

import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
import java.util.List;
import org.eclipse.core.filebuffers.ITextFileBuffer;
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IExecutableExtension;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.OperationCanceledException;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.content.IContentDescription;
import org.eclipse.core.runtime.content.IContentType;
import org.eclipse.core.runtime.content.IContentTypeManager;
import org.eclipse.core.runtime.jobs.ISchedulingRule;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.IRegion;
import org.eclipse.wst.html.core.internal.validate.HTMLValidationAdapterFactory;
import org.eclipse.wst.html.ui.internal.Logger;
import org.eclipse.wst.sse.core.StructuredModelManager;
import org.eclipse.wst.sse.core.internal.FileBufferModelManager;
import org.eclipse.wst.sse.core.internal.provisional.IModelManager;
import org.eclipse.wst.sse.core.internal.provisional.INodeAdapterFactory;
import org.eclipse.wst.sse.core.internal.provisional.INodeNotifier;
import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
import org.eclipse.wst.sse.core.internal.provisional.IndexedRegion;
import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument;
import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion;
import org.eclipse.wst.sse.core.internal.util.URIResolver;
import org.eclipse.wst.sse.core.internal.validate.ValidationAdapter;
import org.eclipse.wst.sse.core.utils.StringUtils;
import org.eclipse.wst.sse.ui.internal.reconcile.validator.ISourceValidator;
import org.eclipse.wst.validation.AbstractValidator;
import org.eclipse.wst.validation.ValidationResult;
import org.eclipse.wst.validation.ValidationState;
import org.eclipse.wst.validation.internal.core.Message;
import org.eclipse.wst.validation.internal.core.ValidationException;
import org.eclipse.wst.validation.internal.operations.IWorkbenchContext;
import org.eclipse.wst.validation.internal.operations.WorkbenchReporter;
import org.eclipse.wst.validation.internal.provisional.core.IReporter;
import org.eclipse.wst.validation.internal.provisional.core.IValidationContext;
import org.eclipse.wst.validation.internal.provisional.core.IValidatorJob;
import org.eclipse.wst.xml.core.internal.document.DocumentTypeAdapter;
import org.eclipse.wst.xml.core.internal.document.NodeImpl;
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument;
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel;
import org.w3c.dom.Text;

public class HTMLValidator
  extends AbstractValidator
  implements IValidatorJob, ISourceValidator, IExecutableExtension
{
  private static final String ORG_ECLIPSE_WST_HTML_CORE_HTMLSOURCE = "org.eclipse.wst.html.core.htmlsource";
  private IDocument fDocument;
  private IContentTypeManager fContentTypeManager;
  
  static boolean shouldValidate(IFile file)
  {
    IResource resource = file;
    do
    {
      if ((resource.isDerived()) || (resource.isTeamPrivateMember()) || (!resource.isAccessible()) || ((resource.getName().charAt(0) == '.') && (resource.getType() == 2))) {
        return false;
      }
      resource = resource.getParent();
    } while ((resource.getType() & 0x4) == 0);
    return true;
  }
  
  private IContentType[] fOtherSupportedContentTypes = null;
  private String[] fAdditionalContentTypesIDs = null;
  private IContentType fHTMLContentType;
  
  public HTMLValidator()
  {
    fContentTypeManager = Platform.getContentTypeManager();
    fHTMLContentType = fContentTypeManager.getContentType("org.eclipse.wst.html.core.htmlsource");
  }
  
  public void cleanup(IReporter reporter) {}
  
  private IContentType[] getOtherSupportedContentTypes()
  {
    if (fOtherSupportedContentTypes == null)
    {
      List contentTypes = new ArrayList(3);
      if (fAdditionalContentTypesIDs != null) {
        for (int i = 0; i < fAdditionalContentTypesIDs.length; i++)
        {
          IContentType type = Platform.getContentTypeManager().getContentType(fAdditionalContentTypesIDs[i]);
          if (type != null) {
            contentTypes.add(type);
          }
        }
      }
      fOtherSupportedContentTypes = ((IContentType[])contentTypes.toArray(new IContentType[contentTypes.size()]));
    }
    return fOtherSupportedContentTypes;
  }
  
  protected IDOMModel getModel(IProject project, IFile file)
  {
    if ((project == null) || (file == null)) {
      return null;
    }
    if (!file.exists()) {
      return null;
    }
    if (!canHandle(file)) {
      return null;
    }
    IModelManager manager = StructuredModelManager.getModelManager();
    if (manager == null) {
      return null;
    }
    IStructuredModel model = null;
    try
    {
      file.refreshLocal(0, new NullProgressMonitor());
    }
    catch (CoreException e)
    {
      Logger.logException(e);
    }
    try
    {
      try
      {
        model = manager.getModelForRead(file);
      }
      catch (UnsupportedEncodingException localUnsupportedEncodingException1)
      {
        model = manager.getModelForRead(file, new String(), null);
      }
      if (model != null) {
        break label123;
      }
    }
    catch (UnsupportedEncodingException localUnsupportedEncodingException2) {}catch (IOException localIOException) {}catch (CoreException e)
    {
      Logger.logException(e);
    }
    return null;
    label123:
    if (!(model instanceof IDOMModel))
    {
      releaseModel(model);
      return null;
    }
    return (IDOMModel)model;
  }
  
  protected HTMLValidationReporter getReporter(IReporter reporter, IFile file, IDOMModel model)
  {
    return new HTMLValidationReporter(this, reporter, file, model);
  }
  
  private boolean canHandle(IFile file)
  {
    boolean result = false;
    if (file != null) {
      try
      {
        IContentDescription contentDescription = file.getContentDescription();
        if (contentDescription != null)
        {
          IContentType fileContentType = contentDescription.getContentType();
          if (fileContentType.isKindOf(fHTMLContentType))
          {
            result = true;
          }
          else
          {
            IContentType[] otherTypes = getOtherSupportedContentTypes();
            for (int i = 0; i < otherTypes.length; i++) {
              result = (result) || (fileContentType.isKindOf(otherTypes[i]));
            }
          }
        }
        else if (fHTMLContentType != null)
        {
          result = fHTMLContentType.isAssociatedWith(file.getName());
        }
      }
      catch (CoreException localCoreException) {}
    }
    return result;
  }
  
  private boolean hasHTMLFeature(IDOMDocument document)
  {
    DocumentTypeAdapter adapter = (DocumentTypeAdapter)document.getAdapterFor(DocumentTypeAdapter.class);
    if (adapter == null) {
      return false;
    }
    return adapter.hasFeature("HTML");
  }
  
  protected void releaseModel(IStructuredModel model)
  {
    if (model != null) {
      model.releaseFromRead();
    }
  }
  
  public void validate(IValidationContext helper, IReporter reporter)
  {
    if (helper == null) {
      return;
    }
    if ((reporter != null) && (reporter.isCancelled())) {
      throw new OperationCanceledException();
    }
    String[] deltaArray = helper.getURIs();
    if ((deltaArray != null) && (deltaArray.length > 0)) {
      validateDelta(helper, reporter);
    } else {
      validateFull(helper, reporter);
    }
  }
  
  public void validate(IRegion dirtyRegion, IValidationContext helper, IReporter reporter)
  {
    if ((helper == null) || (fDocument == null)) {
      return;
    }
    if ((reporter != null) && (reporter.isCancelled())) {
      throw new OperationCanceledException();
    }
    IStructuredModel model = StructuredModelManager.getModelManager().getExistingModelForRead(fDocument);
    if (model == null) {
      return;
    }
    try
    {
      IDOMDocument document = null;
      if ((model instanceof IDOMModel)) {
        document = ((IDOMModel)model).getDocument();
      }
      if ((document == null) || (!hasHTMLFeature(document))) {}
      IPath filePath;
      IFile file;
      IndexedRegion ir;
      ValidationAdapter adapter;
      do
      {
        return;
        
        filePath = null;
        file = null;
        
        ITextFileBuffer fb = FileBufferModelManager.getInstance().getBuffer(fDocument);
        if (fb != null)
        {
          filePath = fb.getLocation();
          if (filePath.segmentCount() > 1)
          {
            file = ResourcesPlugin.getWorkspace().getRoot().getFile(filePath);
            if (!file.isAccessible()) {
              file = null;
            }
          }
        }
        else
        {
          filePath = new Path(model.getId());
        }
        ir = getCoveringNode(dirtyRegion);
        if ((ir instanceof Text)) {
          while ((ir != null) && ((ir instanceof Text))) {
            ir = model.getIndexedRegion(ir.getEndOffset());
          }
        }
        if (!(ir instanceof INodeNotifier)) {
          break;
        }
        INodeAdapterFactory factory = HTMLValidationAdapterFactory.getInstance();
        adapter = (ValidationAdapter)factory.adapt((INodeNotifier)ir);
      } while (adapter == null);
      if (reporter != null)
      {
        HTMLValidationReporter rep = null;
        rep = getReporter(reporter, file, (IDOMModel)model);
        rep.clear();
        adapter.setReporter(rep);
        
        Message mess = new LocalizedMessage(4, filePath.toString().substring(1));
        reporter.displaySubtask(this, mess);
      }
      adapter.validate(ir);
    }
    finally
    {
      if (model != null) {
        model.releaseFromRead();
      }
    }
    jsr -16;
  }
  
  private IndexedRegion getCoveringNode(IRegion dirtyRegion)
  {
    IndexedRegion largestRegion = null;
    if ((fDocument instanceof IStructuredDocument))
    {
      IStructuredDocumentRegion[] regions = ((IStructuredDocument)fDocument).getStructuredDocumentRegions(dirtyRegion.getOffset(), dirtyRegion.getLength());
      largestRegion = getLargest(regions);
    }
    return largestRegion;
  }
  
  protected IndexedRegion getLargest(IStructuredDocumentRegion[] sdRegions)
  {
    if ((sdRegions == null) || (sdRegions.length == 0)) {
      return null;
    }
    IndexedRegion currentLargest = getCorrespondingNode(sdRegions[0]);
    for (int i = 0; i < sdRegions.length; i++) {
      if (!sdRegions[i].isDeleted())
      {
        IndexedRegion corresponding = getCorrespondingNode(sdRegions[i]);
        if ((currentLargest instanceof Text)) {
          currentLargest = corresponding;
        }
        if ((corresponding != null) && 
          (!(corresponding instanceof Text)) && 
          (corresponding.getStartOffset() <= currentLargest.getStartOffset()) && 
          (corresponding.getEndOffset() >= currentLargest.getEndOffset())) {
          currentLargest = corresponding;
        }
      }
    }
    return currentLargest;
  }
  
  protected IndexedRegion getCorrespondingNode(IStructuredDocumentRegion sdRegion)
  {
    IStructuredModel sModel = StructuredModelManager.getModelManager().getExistingModelForRead(fDocument);
    IndexedRegion indexedRegion = null;
    try
    {
      if (sModel != null) {
        indexedRegion = sModel.getIndexedRegion(sdRegion.getStart());
      }
    }
    finally
    {
      if (sModel != null) {
        sModel.releaseFromRead();
      }
    }
    return indexedRegion;
  }
  
  public void connect(IDocument document)
  {
    fDocument = document;
  }
  
  public void disconnect(IDocument document)
  {
    fDocument = null;
  }
  
  protected HTMLValidationResult validate(IDOMModel model, IFile file)
  {
    IProject prj = null;
    if (file != null) {
      prj = file.getProject();
    }
    if ((prj == null) && (model != null))
    {
      URIResolver res = model.getResolver();
      if (res != null) {
        prj = res.getProject();
      }
    }
    WorkbenchReporter reporter = new WorkbenchReporter(prj, new NullProgressMonitor());
    return validate(reporter, file, model);
  }
  
  private HTMLValidationResult validate(IReporter reporter, IFile file, IDOMModel model)
  {
    if ((file == null) || (model == null)) {
      return null;
    }
    IDOMDocument document = model.getDocument();
    if (document == null) {
      return null;
    }
    if (!hasHTMLFeature(document)) {
      return null;
    }
    INodeAdapterFactory factory = HTMLValidationAdapterFactory.getInstance();
    ValidationAdapter adapter = (ValidationAdapter)factory.adapt(document);
    if (adapter == null) {
      return null;
    }
    HTMLValidationReporter rep = getReporter(reporter, file, model);
    rep.clear();
    adapter.setReporter(rep);
    adapter.validate(document);
    return rep.getResult();
  }
  
  private void validateContainer(IValidationContext helper, IReporter reporter, IContainer container)
  {
    try
    {
      IResource[] resourceArray = container.members(false);
      for (int i = 0; i < resourceArray.length; i++)
      {
        IResource resource = resourceArray[i];
        if ((resource != null) && (!reporter.isCancelled())) {
          if ((resource instanceof IFile))
          {
            Message message = new LocalizedMessage(4, resource.getFullPath().toString().substring(1));
            reporter.displaySubtask(this, message);
            validateFile(helper, reporter, (IFile)resource, null);
          }
          else if ((resource instanceof IContainer))
          {
            validateContainer(helper, reporter, (IContainer)resource);
          }
        }
      }
    }
    catch (CoreException localCoreException) {}
  }
  
  private void validateDelta(IValidationContext helper, IReporter reporter)
  {
    String[] deltaArray = helper.getURIs();
    for (int i = 0; i < deltaArray.length; i++)
    {
      String delta = deltaArray[i];
      if (delta != null)
      {
        if (reporter != null)
        {
          Message message = new LocalizedMessage(4, delta.substring(1));
          reporter.displaySubtask(this, message);
        }
        IResource resource = getResource(delta);
        if ((resource != null) && ((resource instanceof IFile))) {
          validateFile(helper, reporter, (IFile)resource, null);
        }
      }
    }
  }
  
  private void validateFile(IValidationContext helper, IReporter reporter, IFile file, ValidationResult result)
  {
    if ((reporter != null) && (reporter.isCancelled())) {
      throw new OperationCanceledException();
    }
    if (!shouldValidate(file)) {
      return;
    }
    IDOMModel model = getModel(file.getProject(), file);
    if (model == null) {
      return;
    }
    try
    {
      Collection dependencies = null;
      NodeImpl document = null;
      if ((model.getDocument() instanceof NodeImpl)) {
        document = (NodeImpl)model.getDocument();
      }
      if ((result != null) && (document != null))
      {
        dependencies = new HashSet();
        document.setUserData("org.eclipse.wst.html.validator.dependencies", dependencies, null);
      }
      validate(reporter, file, model);
      if ((result != null) && (document != null))
      {
        document.setUserData("org.eclipse.wst.html.validator.dependencies", null, null);
        result.setDependsOn((IResource[])dependencies.toArray(new IResource[dependencies.size()]));
      }
    }
    finally
    {
      releaseModel(model);
    }
  }
  
  private void validateFull(IValidationContext helper, IReporter reporter)
  {
    IProject project = null;
    String[] fileDelta = helper.getURIs();
    if ((helper instanceof IWorkbenchContext))
    {
      IWorkbenchContext wbHelper = (IWorkbenchContext)helper;
      project = wbHelper.getProject();
    }
    else if (fileDelta.length > 0)
    {
      project = getResource(fileDelta[0]).getProject();
    }
    if (project == null) {
      return;
    }
    validateContainer(helper, reporter, project);
  }
  
  public IResource getResource(String delta)
  {
    Path path = new Path(delta);
    if (path.segmentCount() > 1) {
      return ResourcesPlugin.getWorkspace().getRoot().getFile(path);
    }
    if (path.segmentCount() == 1) {
      return ResourcesPlugin.getWorkspace().getRoot().getProject(delta);
    }
    return null;
  }
  
  public ISchedulingRule getSchedulingRule(IValidationContext helper)
  {
    return null;
  }
  
  public IStatus validateInJob(IValidationContext helper, IReporter reporter)
    throws ValidationException
  {
    IStatus status = Status.OK_STATUS;
    validate(helper, reporter);
    return status;
  }
  
  public void setInitializationData(IConfigurationElement config, String propertyName, Object data)
    throws CoreException
  {
    fAdditionalContentTypesIDs = new String[0];
    if ((data != null) && 
      ((data instanceof String)) && (data.toString().length() > 0)) {
      fAdditionalContentTypesIDs = StringUtils.unpack(data.toString());
    }
  }
  
  public ValidationResult validate(IResource resource, int kind, ValidationState state, IProgressMonitor monitor)
  {
    if (resource.getType() != 1) {
      return null;
    }
    ValidationResult result = new ValidationResult();
    IReporter reporter = result.getReporter(monitor);
    validateFile(null, reporter, (IFile)resource, result);
    return result;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.wst.html.internal.validation.HTMLValidator
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.wst.html.internal.validation;

import java.util.Locale;
import org.eclipse.core.resources.IResource;
import org.eclipse.wst.validation.internal.core.Message;

public class LocalizedMessage
  extends Message
{
  private String _message = null;
  
  public LocalizedMessage(int severity, String messageText)
  {
    this(severity, messageText, null);
  }
  
  public LocalizedMessage(int severity, String messageText, IResource targetObject)
  {
    this(severity, messageText, targetObject);
  }
  
  public LocalizedMessage(int severity, String messageText, Object targetObject)
  {
    super(null, severity, null);
    setLocalizedMessage(messageText);
    setTargetObject(targetObject);
  }
  
  public void setLocalizedMessage(String message)
  {
    _message = message;
  }
  
  public String getLocalizedMessage()
  {
    return _message;
  }
  
  public String getText()
  {
    return getLocalizedMessage();
  }
  
  public String getText(ClassLoader cl)
  {
    return getLocalizedMessage();
  }
  
  public String getText(Locale l)
  {
    return getLocalizedMessage();
  }
  
  public String getText(Locale l, ClassLoader cl)
  {
    return getLocalizedMessage();
  }
}

/* Location:
 * Qualified Name:     org.eclipse.wst.html.internal.validation.LocalizedMessage
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.wst.html.internal.validation;

import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;

class TaskListHelper
{
  private static TaskListHelper _taskListHelper = null;
  
  public static TaskListHelper getTaskList()
  {
    if (_taskListHelper == null) {
      _taskListHelper = new TaskListHelper();
    }
    return _taskListHelper;
  }
  
  public void addTask(String pluginId, IResource resource, String location, String messageId, String message, int markerType, String targetObjectName, String groupName, int offset, int length)
    throws CoreException
  {
    TaskListUtility.addTask(pluginId, resource, location, messageId, message, markerType, targetObjectName, groupName, offset, length);
  }
  
  public void removeAllTasks(IResource resource, String owner, String objectName)
    throws CoreException
  {
    TaskListUtility.removeAllTasks(resource, owner, objectName);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.wst.html.internal.validation.TaskListHelper
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.wst.html.internal.validation;

import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;

public class TaskListUtility
{
  private static final String PLUGIN_ID = "org.eclipse.wst.html.ui";
  private static final String VALIDATION_MARKER = "org.eclipse.wst.html.ui.problemmarker";
  private static final String VALIDATION_MARKER_OWNER = "owner";
  private static final String VALIDATION_MARKER_SEVERITY = "validationSeverity";
  private static final String VALIDATION_MARKER_TARGETOBJECT = "targetObject";
  private static final String VALIDATION_MARKER_GROUP = "groupName";
  private static final String VALIDATION_MARKER_MESSAGEID = "messageId";
  private static final int DEPTH_INFINITE = 2;
  private static final int DEPTH_ZERO = 0;
  private static final IMarker[] NO_MARKERS = new IMarker[0];
  
  public static IMarker addTask(String pluginId, IResource resource, String location, String messageId, String message, int markerType, String targetObjectName, String groupName, int offset, int length)
    throws CoreException
  {
    if ((message == null) || (resource == null)) {
      return null;
    }
    int severity = getSeverity(markerType);
    
    IMarker item = resource.createMarker("org.eclipse.wst.html.ui.problemmarker");
    
    boolean offsetSet = (offset != -1) && (length != -1);
    int size = offsetSet ? 10 : 8;
    
    String[] attribNames = new String[size];
    Object[] attribValues = new Object[size];
    
    attribNames[0] = "owner";
    attribValues[0] = pluginId;
    attribNames[1] = "validationSeverity";
    
    attribValues[1] = new Integer(markerType);
    attribNames[2] = "targetObject";
    
    attribValues[2] = (targetObjectName == null ? "" : targetObjectName);
    attribNames[3] = "groupName";
    attribValues[3] = (groupName == null ? "" : groupName);
    attribNames[4] = "message";
    attribValues[4] = message;
    attribNames[5] = "messageId";
    attribValues[5] = messageId;
    
    attribNames[6] = "severity";
    
    attribValues[6] = new Integer(severity);
    try
    {
      Integer lineNumber = Integer.valueOf(location);
      attribNames[7] = "lineNumber";
      attribValues[7] = lineNumber;
    }
    catch (NumberFormatException localNumberFormatException)
    {
      attribNames[7] = "location";
      attribValues[7] = location;
    }
    if (offsetSet)
    {
      attribNames[8] = "charStart";
      attribValues[8] = new Integer(offset);
      attribNames[9] = "charEnd";
      attribValues[9] = new Integer(offset + length);
    }
    item.setAttributes(attribNames, attribValues);
    
    return item;
  }
  
  private static int getSeverity(int severityEnumValue)
  {
    switch (severityEnumValue)
    {
    case 1: 
      return 2;
    case 4: 
      return 0;
    case 2: 
      return 1;
    }
    return 1;
  }
  
  private static int getDepth(IResource resource)
  {
    if ((resource instanceof IProject)) {
      return 2;
    }
    if ((resource instanceof IWorkspaceRoot)) {
      return 2;
    }
    return 0;
  }
  
  private static IMarker[] getValidationTasks(IResource resource, int severity, int depth)
  {
    IMarker[] tempMarkers = (IMarker[])null;
    int validCount = 0;
    try
    {
      IMarker[] allMarkers = (IMarker[])null;
      try
      {
        allMarkers = resource.findMarkers("org.eclipse.wst.html.ui.problemmarker", false, depth);
      }
      catch (CoreException localCoreException1)
      {
        return NO_MARKERS;
      }
      if (allMarkers.length != 0)
      {
        tempMarkers = new IMarker[allMarkers.length];
        for (int i = 0; i < allMarkers.length; i++)
        {
          IMarker marker = allMarkers[i];
          Integer filterSeverity = (Integer)marker.getAttribute("validationSeverity");
          if (filterSeverity == null) {
            try
            {
              marker.setAttribute("severity", getSeverity(severity));
            }
            catch (CoreException localCoreException2)
            {
              continue;
            }
            catch (Exception localException)
            {
              continue;
            }
          } else {
            if ((severity & filterSeverity.intValue()) == 0) {
              continue;
            }
          }
          tempMarkers[(validCount++)] = marker;
        }
      }
    }
    catch (CoreException localCoreException3) {}
    if (validCount == 0) {
      return NO_MARKERS;
    }
    IMarker[] validMarkers = new IMarker[validCount];
    System.arraycopy(tempMarkers, 0, validMarkers, 0, validCount);
    return validMarkers;
  }
  
  private static IMarker[] getValidationTasks(IResource resource, String[] messageOwners, int depth)
  {
    IMarker[] markers = getValidationTasks(resource, 7, depth);
    if (markers.length == 0) {
      return NO_MARKERS;
    }
    IMarker[] temp = new IMarker[markers.length];
    int validCount = 0;
    for (int i = 0; i < markers.length; i++)
    {
      IMarker marker = markers[i];
      try
      {
        Object owner = marker.getAttribute("owner");
        if ((owner != null) && ((owner instanceof String))) {
          for (int j = 0; j < messageOwners.length; j++)
          {
            String messageOwner = messageOwners[j];
            if (((String)owner).equals(messageOwner))
            {
              temp[(validCount++)] = marker;
              break;
            }
          }
        }
      }
      catch (CoreException localCoreException)
      {
        return NO_MARKERS;
      }
    }
    IMarker[] result = new IMarker[validCount];
    System.arraycopy(temp, 0, result, 0, validCount);
    return result;
  }
  
  private static IMarker[] getValidationTasks(IResource resource, String[] messageOwner, String objectName, String groupName, int depth)
    throws CoreException
  {
    if ((messageOwner == null) || (resource == null)) {
      return NO_MARKERS;
    }
    int validCount = 0;
    IMarker[] validList = (IMarker[])null;
    IMarker[] markers = getValidationTasks(resource, messageOwner, depth);
    if (markers != null)
    {
      validList = new IMarker[markers.length];
      for (int i = 0; i < markers.length; i++)
      {
        IMarker marker = markers[i];
        if (objectName != null)
        {
          Object targetObject = marker.getAttribute("targetObject");
          if ((targetObject == null) || (!(targetObject instanceof String)) || (!((String)targetObject).equals(objectName))) {}
        }
        else if (groupName != null)
        {
          Object group = marker.getAttribute("groupName");
          if ((group == null) || (!(group instanceof String)) || (!((String)group).equals(groupName))) {}
        }
        else
        {
          validList[(validCount++)] = marker;
        }
      }
    }
    if (validCount == 0) {
      return NO_MARKERS;
    }
    IMarker[] result = new IMarker[validCount];
    System.arraycopy(validList, 0, result, 0, validCount);
    return result;
  }
  
  public static void removeAllTasks(IResource resource, String owner, String objectName)
    throws CoreException
  {
    removeAllTasks(resource, new String[] { owner }, objectName);
  }
  
  public static void removeAllTasks(IResource resource, String[] owners, String objectName)
    throws CoreException
  {
    removeAllTasks(resource, owners, objectName, getDepth(resource));
  }
  
  protected static void removeAllTasks(IResource resource, String[] owners, String objectName, int depth)
    throws CoreException
  {
    removeTaskSubset(resource, owners, objectName, null, depth);
  }
  
  protected static void removeTaskSubset(IResource resource, String[] owners, String objectName, String groupName, int depth)
    throws CoreException
  {
    if ((owners == null) || (resource == null)) {
      return;
    }
    IMarker[] allTasks = getValidationTasks(resource, owners, objectName, groupName, depth);
    if (allTasks.length > 0) {
      ResourcesPlugin.getWorkspace().deleteMarkers(allTasks);
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.wst.html.internal.validation.TaskListUtility
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.wst.html.ui;

import org.eclipse.wst.xml.ui.internal.contentoutline.JFaceNodeLabelProvider;
import org.w3c.dom.Attr;
import org.w3c.dom.Node;

class StructuredTextViewerConfigurationHTML$1
  extends JFaceNodeLabelProvider
{
  final StructuredTextViewerConfigurationHTML this$0;
  
  StructuredTextViewerConfigurationHTML$1(StructuredTextViewerConfigurationHTML paramStructuredTextViewerConfigurationHTML)
  {
    this$0 = paramStructuredTextViewerConfigurationHTML;
  }
  
  public String getText(Object element)
  {
    if (element == null) {
      return null;
    }
    StringBuffer s = new StringBuffer();
    Node node = (Node)element;
    while (node != null)
    {
      if (node.getNodeType() != 9) {
        s.insert(0, super.getText(node));
      }
      if (node.getNodeType() == 2) {
        node = ((Attr)node).getOwnerElement();
      } else {
        node = node.getParentNode();
      }
      if ((node != null) && (node.getNodeType() != 9)) {
        s.insert(0, '/');
      }
    }
    return s.toString();
  }
}

/* Location:
 * Qualified Name:     org.eclipse.wst.html.ui.StructuredTextViewerConfigurationHTML.1
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.wst.html.ui;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Vector;
import org.eclipse.core.runtime.Preferences;
import org.eclipse.jface.text.IAutoEditStrategy;
import org.eclipse.jface.text.ITextDoubleClickStrategy;
import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
import org.eclipse.jface.text.formatter.IContentFormatter;
import org.eclipse.jface.text.formatter.MultiPassContentFormatter;
import org.eclipse.jface.text.source.ISourceViewer;
import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.wst.css.ui.internal.style.LineStyleProviderForEmbeddedCSS;
import org.eclipse.wst.html.core.internal.HTMLCorePlugin;
import org.eclipse.wst.html.core.internal.format.HTMLFormatProcessorImpl;
import org.eclipse.wst.html.core.internal.provisional.contenttype.ContentTypeIdForHTML;
import org.eclipse.wst.html.core.internal.text.StructuredTextPartitionerForHTML;
import org.eclipse.wst.html.ui.internal.autoedit.AutoEditStrategyForTabs;
import org.eclipse.wst.html.ui.internal.contentassist.HTMLStructuredContentAssistProcessor;
import org.eclipse.wst.html.ui.internal.style.LineStyleProviderForHTML;
import org.eclipse.wst.sse.ui.StructuredTextViewerConfiguration;
import org.eclipse.wst.sse.ui.internal.format.StructuredFormattingStrategy;
import org.eclipse.wst.sse.ui.internal.provisional.style.LineStyleProvider;
import org.eclipse.wst.xml.core.internal.provisional.contenttype.ContentTypeIdForXML;
import org.eclipse.wst.xml.core.internal.text.rules.StructuredTextPartitionerForXML;
import org.eclipse.wst.xml.ui.StructuredTextViewerConfigurationXML;
import org.eclipse.wst.xml.ui.internal.contentoutline.JFaceNodeLabelProvider;
import org.w3c.dom.Attr;
import org.w3c.dom.Node;

public class StructuredTextViewerConfigurationHTML
  extends StructuredTextViewerConfiguration
{
  private String[] fConfiguredContentTypes;
  private LineStyleProvider fLineStyleProviderForEmbeddedCSS;
  private LineStyleProvider fLineStyleProviderForHTML;
  private StructuredTextViewerConfiguration fXMLSourceViewerConfiguration;
  private ILabelProvider fStatusLineLabelProvider;
  
  public IAutoEditStrategy[] getAutoEditStrategies(ISourceViewer sourceViewer, String contentType)
  {
    List allStrategies = new ArrayList(0);
    
    IAutoEditStrategy[] superStrategies = super.getAutoEditStrategies(sourceViewer, contentType);
    for (int i = 0; i < superStrategies.length; i++) {
      allStrategies.add(superStrategies[i]);
    }
    allStrategies.add(new AutoEditStrategyForTabs());
    
    return (IAutoEditStrategy[])allStrategies.toArray(new IAutoEditStrategy[allStrategies.size()]);
  }
  
  public String[] getConfiguredContentTypes(ISourceViewer sourceViewer)
  {
    if (fConfiguredContentTypes == null)
    {
      String[] xmlTypes = StructuredTextPartitionerForXML.getConfiguredContentTypes();
      String[] htmlTypes = StructuredTextPartitionerForHTML.getConfiguredContentTypes();
      fConfiguredContentTypes = new String[2 + xmlTypes.length + htmlTypes.length];
      
      fConfiguredContentTypes[0] = "org.eclipse.wst.sse.ST_DEFAULT";
      fConfiguredContentTypes[1] = "org.eclipse.wst.sse.UNKNOWN_PARTITION_TYPE";
      
      int index = 0;
      index += 2;System.arraycopy(xmlTypes, 0, fConfiguredContentTypes, index, xmlTypes.length);
      System.arraycopy(htmlTypes, 0, fConfiguredContentTypes, index += xmlTypes.length, htmlTypes.length);
    }
    return fConfiguredContentTypes;
  }
  
  protected IContentAssistProcessor[] getContentAssistProcessors(ISourceViewer sourceViewer, String partitionType)
  {
    IContentAssistProcessor processor = new HTMLStructuredContentAssistProcessor(
      getContentAssistant(), partitionType, sourceViewer);
    return new IContentAssistProcessor[] { processor };
  }
  
  public IContentFormatter getContentFormatter(ISourceViewer sourceViewer)
  {
    IContentFormatter formatter = super.getContentFormatter(sourceViewer);
    if (!(formatter instanceof MultiPassContentFormatter)) {
      formatter = new MultiPassContentFormatter(getConfiguredDocumentPartitioning(sourceViewer), "org.
1 2 3 4 5 6 7 8 9 10 11 12

Further reading...

For more information on Java 1.5 Tiger, you may find Java 1.5 Tiger, A developer's Notebook by D. Flanagan and B. McLaughlin from O'Reilly of interest.

New!JAR listings


Copyright 2006-2017. Infinite Loop Ltd