package brn.gui.fwdgraph.diagram.providers;

import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.gmf.runtime.common.core.service.AbstractProvider;
import org.eclipse.gmf.runtime.common.core.service.IOperation;
import org.eclipse.gmf.runtime.common.ui.services.parser.GetParserOperation;
import org.eclipse.gmf.runtime.common.ui.services.parser.IParser;
import org.eclipse.gmf.runtime.common.ui.services.parser.IParserProvider;
import org.eclipse.gmf.runtime.notation.View;
import brn.gui.fwdgraph.diagram.edit.parts.FwdLinkNoPacketsEditPart;
import brn.gui.fwdgraph.diagram.edit.parts.NodeIdEditPart;

import brn.gui.fwdgraph.diagram.part.ModelVisualIDRegistry;

import brn.gui.graph.model.ModelPackage;

/**
 * @generated
 */
public class ModelParserProvider extends AbstractProvider implements
    IParserProvider {

  /**
   * @generated
   */
  private IParser nodeNodeId_4001Parser;

  /**
   * @generated
   */
  private IParser getNodeNodeId_4001Parser() {
    if (nodeNodeId_4001Parser == null) {
      nodeNodeId_4001Parser = createNodeNodeId_4001Parser();
    }
    return nodeNodeId_4001Parser;
  }

  /**
   * @generated
   */
  protected IParser createNodeNodeId_4001Parser() {
    ModelStructuralFeatureParser parser = new ModelStructuralFeatureParser(
        ModelPackage.eINSTANCE.getNode().getEStructuralFeature("id")); //$NON-NLS-1$
    return parser;
  }

  /**
   * @generated
   */
  private IParser fwdLinkFwdLinkNoPackets_4002Parser;

  /**
   * @generated
   */
  private IParser getFwdLinkFwdLinkNoPackets_4002Parser() {
    if (fwdLinkFwdLinkNoPackets_4002Parser == null) {
      fwdLinkFwdLinkNoPackets_4002Parser = createFwdLinkFwdLinkNoPackets_4002Parser();
    }
    return fwdLinkFwdLinkNoPackets_4002Parser;
  }

  /**
   * @generated
   */
  protected IParser createFwdLinkFwdLinkNoPackets_4002Parser() {
    ModelStructuralFeatureParser parser = new ModelStructuralFeatureParser(
        ModelPackage.eINSTANCE.getFwdLink().getEStructuralFeature("noPackets")); //$NON-NLS-1$
    return parser;
  }

  /**
   * @generated
   */
  protected IParser getParser(int visualID) {
    switch (visualID) {
    case NodeIdEditPart.VISUAL_ID:
      return getNodeNodeId_4001Parser();
    case FwdLinkNoPacketsEditPart.VISUAL_ID:
      return getFwdLinkFwdLinkNoPackets_4002Parser();
    }
    return null;
  }

  /**
   * @generated
   */
  public IParser getParser(IAdaptable hint) {
    String vid = (String) hint.getAdapter(String.class);
    if (vid != null) {
      return getParser(ModelVisualIDRegistry.getVisualID(vid));
    }
    View view = (View) hint.getAdapter(View.class);
    if (view != null) {
      return getParser(ModelVisualIDRegistry.getVisualID(view));
    }
    return null;
  }

  /**
   * @generated
   */
  public boolean provides(IOperation operation) {
    if (operation instanceof GetParserOperation) {
      IAdaptable hint = ((GetParserOperation) operation).getHint();
      if (ModelElementTypes.getElement(hint) == null) {
        return false;
      }
      return getParser(hint) != null;
    }
    return false;
  }
}
