org.eclipse.jst.jsf.facesconfig.ui_1.2.2.v201103292152

 while (children.hasNext()) {
          adapt((EObject)children.next());
        }
      }
    }
    adapt(facesConfig);
  }
  
  public void setFacesConfig(FacesConfigType facesConfig)
  {
    this.facesConfig = facesConfig;
    refreshFCAdapter(facesConfig);
  }
  
  public void setPageflow(Pageflow pageflow)
  {
    this.pageflow = pageflow;
    pageflow.eAdapters().add(this);
    refreshPFAdapter(pageflow);
  }
  
  public void adapt(EObject object)
  {
    if ((object != null) && (!isAdapted(object))) {
      if ((object instanceof PageflowElement)) {
        object.eAdapters().add(new PF2FCSynchronizer(this));
      } else {
        object.eAdapters().add(new FC2PFSynchronizer(this));
      }
    }
  }
  
  public void unAdapt(EObject object)
  {
    Iterator adapters = object.eAdapters().iterator();
    while (adapters.hasNext())
    {
      Object adapter = adapters.next();
      if (((adapter instanceof FC2PFSynchronizer)) || 
        ((adapter instanceof PF2FCSynchronizer))) {
        adapters.remove();
      }
    }
  }
  
  public boolean isAdapted(EObject object)
  {
    if (object != null)
    {
      Iterator adapters = object.eAdapters().iterator();
      while (adapters.hasNext())
      {
        Object adapter = adapters.next();
        if (((adapter instanceof FC2PFSynchronizer)) || 
          ((adapter instanceof PF2FCSynchronizer))) {
          return true;
        }
      }
    }
    return false;
  }
  
  public void clearCaches()
  {
    mapPaths2PF.clear();
    mapCases2Links.clear();
  }
  
  public void dispose()
  {
    clearCaches();
    Pageflow pageFlow = getPageflow();
    if (pageFlow != null) {
      pageFlow.dispose();
    }
  }
  
  public Notifier getTarget()
  {
    return null;
  }
  
  public boolean isAdapterForType(Object type)
  {
    return false;
  }
  
  public void setTarget(Notifier newTarget) {}
  
  public static FromViewIdType getSource(NavigationCaseType caseType)
  {
    if ((caseType.eContainer() instanceof NavigationRuleType))
    {
      NavigationRuleType rule = (NavigationRuleType)caseType
        .eContainer();
      return rule.getFromViewId();
    }
    return null;
  }
  
  private PageflowPage getOrCreateStartPage(NavigationCaseType navCase)
  {
    PageflowPage startPageflowNode = null;
    String path = "*";
    NavigationRuleType rule = (NavigationRuleType)navCase.eContainer();
    FromViewIdType source = getSource(navCase);
    if (source != null) {
      path = source.getTextContent();
    }
    if (getValidPFPageInCache(path) == null)
    {
      startPageflowNode = TransformUtil.findPage(path, pageflow);
      if (startPageflowNode == null)
      {
        startPageflowNode = createPFPage(path);
        pageflowChanged = true;
      }
      mapPaths2PF.put(path, startPageflowNode);
      PageflowTransform.getInstance().updatePageflowSourcePage(
        startPageflowNode, rule);
    }
    else
    {
      startPageflowNode = (PageflowPage)mapPaths2PF.get(path);
    }
    if (source != null)
    {
      ReferenceElement element = new PageReferenceElement(
        startPageflowNode);
      element.add(source);
      startPageflowNode
        .setReferenceLink(element.resolveReferenceString());
      startPageflowNode.getFCElements().add(source);
    }
    return startPageflowNode;
  }
  
  private PageflowPage getOrCreateEndPage(NavigationCaseType navCase)
  {
    PageflowPage endPageflowNode = null;
    ToViewIdType target_ = navCase.getToViewId();
    if (target_ != null)
    {
      String path = target_.getTextContent();
      if (getValidPFPageInCache(path) == null)
      {
        endPageflowNode = TransformUtil.findPage(path, pageflow);
        if (endPageflowNode == null)
        {
          endPageflowNode = createPFPage(path);
          
          pageflowChanged = true;
        }
        mapPaths2PF.put(path, endPageflowNode);
        PageflowTransform.getInstance().updatePageflowTargetPage(
          endPageflowNode, navCase);
      }
      else
      {
        endPageflowNode = (PageflowPage)mapPaths2PF.get(path);
      }
      if (target_ != null)
      {
        ReferenceElement element = new PageReferenceElement(
          endPageflowNode);
        element.add(target_);
        endPageflowNode.setReferenceLink(element
          .resolveReferenceString());
        endPageflowNode.getFCElements().add(target_);
      }
    }
    return endPageflowNode;
  }
  
  private PageflowPage getValidPFPageInCache(Object key)
  {
    EObject element = (EObject)mapPaths2PF.get(key);
    if ((!TransformUtil.isValidPageflowElement(element)) || 
      (!(element instanceof PageflowPage)) || 
      (!((PageflowPage)element).getPath().equals(key)))
    {
      mapPaths2PF.remove(key);
      element = null;
    }
    return (PageflowPage)element;
  }
  
  private PageflowLink getValidPFLinkInCache(EObject caseType)
  {
    PageflowLink link = (PageflowLink)mapCases2Links.get(caseType);
    if (!TransformUtil.isValidLink(link))
    {
      mapCases2Links.remove(caseType);
      link = null;
    }
    return link;
  }
  
  public boolean updatePageflowElements(Pageflow pageflow_, NavigationCaseType caseFC)
  {
    pageflowChanged = false;
    pageflow = pageflow_;
    ToViewIdType target_ = caseFC.getToViewId();
    if (target_ == null) {
      return false;
    }
    PageflowPage start = null;PageflowPage end = null;
    
    start = getOrCreateStartPage(caseFC);
    String action = null;
    if (caseFC.getFromAction() != null) {
      action = caseFC.getFromAction().getTextContent();
    }
    String fromOutCome = null;
    if (caseFC.getFromOutcome() != null) {
      fromOutCome = caseFC.getFromOutcome().getTextContent();
    }
    end = getOrCreateEndPage(caseFC);
    
    PageflowLink link = null;
    if (((link = findUnmappedLink(start, end, caseFC)) == null) && 
      (end != null))
    {
      link = createPFLink(start, end, action, fromOutCome);
      pageflowChanged = true;
    }
    if (link != null)
    {
      link.getFCElements().clear();
      link.getFCElements().add(caseFC);
      mapCases2Links.put(caseFC, link);
    }
    adapt(start);
    adapt(end);
    adapt(caseFC);
    adapt(link);
    return pageflowChanged;
  }
  
  private boolean cleanPageflowNavigationRule(Pageflow pageflow_)
  {
    boolean dirty = false;
    List links = pageflow_.getLinks();
    Iterator linksIterator = links.iterator();
    while (linksIterator.hasNext())
    {
      PageflowLink link = (PageflowLink)linksIterator.next();
      if (link.getFCElements().isEmpty())
      {
        linksIterator.remove();
        if (link.getSource() != null) {
          link.getSource().getOutlinks().remove(link);
        }
        if (link.getTarget() != null) {
          link.getTarget().getInlinks().remove(link);
        }
        dirty = true;
      }
    }
    return dirty;
  }
  
  private boolean updateNavigationRulesInPageflowFromFacesConfig(List rulesFC)
  {
    boolean isNew = false;
    if ((rulesFC == null) || (rulesFC.isEmpty()))
    {
      for (Iterator iterLink = pageflow.getLinks().iterator(); iterLink
            .hasNext();)
      {
        PageflowLink link = (PageflowLink)iterLink.next();
        link.getSource().getOutlinks().remove(link);
        link.getTarget().getInlinks().remove(link);
      }
      pageflow.getLinks().clear();
    }
    else
    {
      Iterator iterCasesFC;
      for (Iterator iterRulesFC = rulesFC.iterator(); iterRulesFC
            .hasNext(); iterCasesFC
            .hasNext())
      {
        NavigationRuleType ruleFC = 
          (NavigationRuleType)iterRulesFC.next();
        
        List casesFC = ruleFC.getNavigationCase();
        iterCasesFC = casesFC.iterator(); continue;
        
        NavigationCaseType navigationCaseFC = 
          (NavigationCaseType)iterCasesFC.next();
        isNew |= updatePageflowElements(pageflow, navigationCaseFC);
      }
    }
    isNew |= cleanPageflowNavigationRule(pageflow);
    return isNew;
  }
  
  private PageflowLink findUnmappedLink(PageflowPage start, PageflowPage end, NavigationCaseType caseFC)
  {
    List links = start.getOutlinks();
    int i = 0;
    for (int n = links.size(); i < n; i++)
    {
      PageflowLink link = (PageflowLink)links.get(i);
      if ((link.getSource() == start) && (link.getTarget() == end))
      {
        link.update();
        if ((link.getFCElements().isEmpty()) || 
          (link.getFCElements().getData().get(0) == caseFC)) {
          return link;
        }
      }
    }
    return null;
  }
  
  public PageflowLink createPFLink(String fromOutcome)
  {
    PageflowLink link = null;
    link = PageflowModelManager.getFactory().createPFLink();
    if ((fromOutcome != null) && (fromOutcome.length() > 0)) {
      link.setOutcome(fromOutcome.trim());
    }
    pageflow.getLinks().add(link);
    return link;
  }
  
  public PageflowLink createPFLink(PageflowNode start, PageflowNode target_, String action, String fromOutcome)
  {
    Assert.isTrue((start != null) && (target_ != null));
    PageflowLink link = null;
    link = createPFLink(fromOutcome);
    link.setFromaction(action);
    link.setSource(start);
    link.setTarget(target_);
    start.getOutlinks().add(link);
    target_.getInlinks().add(link);
    return link;
  }
  
  public PageflowPage createPFPage(String fromViewID)
  {
    PageflowPage page = PageflowFactory.eINSTANCE.createPFPage();
    if ((fromViewID != null) && (fromViewID.length() > 0))
    {
      page.setPath(fromViewID.trim());
      page.setName(WebrootUtil.getPageNameFromWebPath(fromViewID.trim()));
    }
    pageflow.getNodes().add(page);
    return page;
  }
  
  public boolean updatePageflowModelFromEMF()
  {
    if ((pageflow != null) && (facesConfig != null))
    {
      List navigationRulesInFacesconfig = facesConfig.getNavigationRule();
      clearCaches();
      
      return updateNavigationRulesInPageflowFromFacesConfig(navigationRulesInFacesconfig);
    }
    return false;
  }
  
  void refreshLink(NavigationCaseType caseType)
  {
    PageflowLink link = getValidPFLinkInCache(caseType);
    if (link != null) {
      removeLink(link);
    }
    if (TransformUtil.isValidFacesConfigElement(caseType)) {
      updatePageflowElements(pageflow, caseType);
    }
  }
  
  public void notifyChanged(Notification msg)
  {
    int type = msg.getEventType();
    switch (type)
    {
    case 11: 
      setNeedBatchOperations(true);
      break;
    case 12: 
      setNeedBatchOperations(false);
    }
  }
  
  public boolean isListenToNotify()
  {
    return (listenToNotify) && (!isInEvent);
  }
  
  public void setInEvent(boolean isInEvent)
  {
    this.isInEvent = isInEvent;
  }
  
  public FacesConfigType getFacesConfig()
  {
    return facesConfig;
  }
  
  public Pageflow getPageflow()
  {
    return pageflow;
  }
  
  public static FromViewIdType createRLFromViewID(String value)
  {
    FromViewIdType fromView = FacesConfigFactory.eINSTANCE
      .createFromViewIdType();
    fromView.setTextContent(value);
    return fromView;
  }
  
  public static ToViewIdType createFCToViewID(String value)
  {
    ToViewIdType toView = FacesConfigFactory.eINSTANCE.createToViewIdType();
    toView.setTextContent(value);
    return toView;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jst.jsf.facesconfig.ui.pageflow.synchronization.FC2PFTransformer
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jst.jsf.facesconfig.ui.pageflow.synchronization;

import java.util.List;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.Notifier;
import org.eclipse.emf.common.notify.impl.AdapterImpl;
import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.emf.ecore.InternalEObject;
import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.jst.jsf.common.ui.internal.logging.Logger;
import org.eclipse.jst.jsf.facesconfig.emf.NavigationCaseType;
import org.eclipse.jst.jsf.facesconfig.ui.EditorPlugin;
import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.Pageflow;
import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowElement;
import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowLink;
import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowNode;
import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowPackage;
import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowPage;
import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.impl.ReferenceElement;

public class PF2FCSynchronizer
  extends AdapterImpl
{
  FC2PFTransformer tranformer;
  private final boolean DEBUG = false;
  private static final Logger logger = EditorPlugin.getLogger(PF2FCSynchronizer.class);
  
  public PF2FCSynchronizer(FC2PFTransformer tranformer)
  {
    this.tranformer = tranformer;
  }
  
  public Notifier getTarget()
  {
    return null;
  }
  
  public void setTarget(Notifier newTarget) {}
  
  public boolean isAdapterForType(Object type)
  {
    return type == PF2FCSynchronizer.class;
  }
  
  /* Error */
  public void notifyChanged(Notification notification)
  {
    // Byte code:
    //   0: aload_0
    //   1: aload_1
    //   2: invokespecial 210	org/eclipse/jst/jsf/facesconfig/ui/pageflow/synchronization/PF2FCSynchronizer:isProcessorFor	(Lorg/eclipse/emf/common/notify/Notification;)Z
    //   5: ifne +4 -> 9
    //   8: return
    //   9: aload_0
    //   10: getfield 189	org/eclipse/jst/jsf/facesconfig/ui/pageflow/synchronization/PF2FCSynchronizer:tranformer	Lorg/eclipse/jst/jsf/facesconfig/ui/pageflow/synchronization/FC2PFTransformer;
    //   13: iconst_1
    //   14: invokevirtual 199	org/eclipse/jst/jsf/facesconfig/ui/pageflow/synchronization/FC2PFTransformer:setInEvent	(Z)V
    //   17: aload_1
    //   18: invokeinterface 221 1 0
    //   23: instanceof 100
    //   26: ifne +51 -> 77
    //   29: aload_1
    //   30: invokeinterface 217 1 0
    //   35: bipush 8
    //   37: if_icmpeq +31 -> 68
    //   40: aload_0
    //   41: getfield 189	org/eclipse/jst/jsf/facesconfig/ui/pageflow/synchronization/PF2FCSynchronizer:tranformer	Lorg/eclipse/jst/jsf/facesconfig/ui/pageflow/synchronization/FC2PFTransformer;
    //   44: aload_0
    //   45: getfield 189	org/eclipse/jst/jsf/facesconfig/ui/pageflow/synchronization/PF2FCSynchronizer:tranformer	Lorg/eclipse/jst/jsf/facesconfig/ui/pageflow/synchronization/FC2PFTransformer;
    //   48: invokevirtual 204	org/eclipse/jst/jsf/facesconfig/ui/pageflow/synchronization/FC2PFTransformer:getPageflow	()Lorg/eclipse/jst/jsf/facesconfig/ui/pageflow/model/Pageflow;
    //   51: invokevirtual 201	org/eclipse/jst/jsf/facesconfig/ui/pageflow/synchronization/FC2PFTransformer:refreshPFAdapter	(Lorg/eclipse/emf/ecore/EObject;)V
    //   54: aload_0
    //   55: getfield 189	org/eclipse/jst/jsf/facesconfig/ui/pageflow/synchronization/PF2FCSynchronizer:tranformer	Lorg/eclipse/jst/jsf/facesconfig/ui/pageflow/synchronization/FC2PFTransformer;
    //   58: aload_0
    //   59: getfield 189	org/eclipse/jst/jsf/facesconfig/ui/pageflow/synchronization/PF2FCSynchronizer:tranformer	Lorg/eclipse/jst/jsf/facesconfig/ui/pageflow/synchronization/FC2PFTransformer;
    //   62: invokevirtual 202	org/eclipse/jst/jsf/facesconfig/ui/pageflow/synchronization/FC2PFTransformer:getFacesConfig	()Lorg/eclipse/jst/jsf/facesconfig/emf/FacesConfigType;
    //   65: invokevirtual 200	org/eclipse/jst/jsf/facesconfig/ui/pageflow/synchronization/FC2PFTransformer:refreshFCAdapter	(Lorg/eclipse/emf/ecore/EObject;)V
    //   68: aload_0
    //   69: getfield 189	org/eclipse/jst/jsf/facesconfig/ui/pageflow/synchronization/PF2FCSynchronizer:tranformer	Lorg/eclipse/jst/jsf/facesconfig/ui/pageflow/synchronization/FC2PFTransformer;
    //   72: iconst_0
    //   73: invokevirtual 199	org/eclipse/jst/jsf/facesconfig/ui/pageflow/synchronization/FC2PFTransformer:setInEvent	(Z)V
    //   76: return
    //   77: aload_0
    //   78: aload_1
    //   79: invokespecial 208	org/eclipse/jst/jsf/facesconfig/ui/pageflow/synchronization/PF2FCSynchronizer:processChange	(Lorg/eclipse/emf/common/notify/Notification;)V
    //   82: goto +111 -> 193
    //   85: astore_2
    //   86: getstatic 188	org/eclipse/jst/jsf/facesconfig/ui/pageflow/synchronization/PF2FCSynchronizer:logger	Lorg/eclipse/jst/jsf/common/ui/internal/logging/Logger;
    //   89: aload_2
    //   90: invokevirtual 192	org/eclipse/jst/jsf/common/ui/internal/logging/Logger:error	(Ljava/lang/Throwable;)V
    //   93: aload_1
    //   94: invokeinterface 217 1 0
    //   99: bipush 8
    //   101: if_icmpeq +31 -> 132
    //   104: aload_0
    //   105: getfield 189	org/eclipse/jst/jsf/facesconfig/ui/pageflow/synchronization/PF2FCSynchronizer:tranformer	Lorg/eclipse/jst/jsf/facesconfig/ui/pageflow/synchronization/FC2PFTransformer;
    //   108: aload_0
    //   109: getfield 189	org/eclipse/jst/jsf/facesconfig/ui/pageflow/synchronization/PF2FCSynchronizer:tranformer	Lorg/eclipse/jst/jsf/facesconfig/ui/pageflow/synchronization/FC2PFTransformer;
    //   112: invokevirtual 204	org/eclipse/jst/jsf/facesconfig/ui/pageflow/synchronization/FC2PFTransformer:getPageflow	()Lorg/eclipse/jst/jsf/facesconfig/ui/pageflow/model/Pageflow;
    //   115: invokevirtual 201	org/eclipse/jst/jsf/facesconfig/ui/pageflow/synchronization/FC2PFTransformer:refreshPFAdapter	(Lorg/eclipse/emf/ecore/EObject;)V
    //   118: aload_0
    //   119: getfield 189	org/eclipse/jst/jsf/facesconfig/ui/pageflow/synchronization/PF2FCSynchronizer:tranformer	Lorg/eclipse/jst/jsf/facesconfig/ui/pageflow/synchronization/FC2PFTransformer;
    //   122: aload_0
    //   123: getfield 189	org/eclipse/jst/jsf/facesconfig/ui/pageflow/synchronization/PF2FCSynchronizer:tranformer	Lorg/eclipse/jst/jsf/facesconfig/ui/pageflow/synchronization/FC2PFTransformer;
    //   126: invokevirtual 202	org/eclipse/jst/jsf/facesconfig/ui/pageflow/synchronization/FC2PFTransformer:getFacesConfig	()Lorg/eclipse/jst/jsf/facesconfig/emf/FacesConfigType;
    //   129: invokevirtual 200	org/eclipse/jst/jsf/facesconfig/ui/pageflow/synchronization/FC2PFTransformer:refreshFCAdapter	(Lorg/eclipse/emf/ecore/EObject;)V
    //   132: aload_0
    //   133: getfield 189	org/eclipse/jst/jsf/facesconfig/ui/pageflow/synchronization/PF2FCSynchronizer:tranformer	Lorg/eclipse/jst/jsf/facesconfig/ui/pageflow/synchronization/FC2PFTransformer;
    //   136: iconst_0
    //   137: invokevirtual 199	org/eclipse/jst/jsf/facesconfig/ui/pageflow/synchronization/FC2PFTransformer:setInEvent	(Z)V
    //   140: goto +100 -> 240
    //   143: astore_3
    //   144: aload_1
    //   145: invokeinterface 217 1 0
    //   150: bipush 8
    //   152: if_icmpeq +31 -> 183
    //   155: aload_0
    //   156: getfield 189	org/eclipse/jst/jsf/facesconfig/ui/pageflow/synchronization/PF2FCSynchronizer:tranformer	Lorg/eclipse/jst/jsf/facesconfig/ui/pageflow/synchronization/FC2PFTransformer;
    //   159: aload_0
    //   160: getfield 189	org/eclipse/jst/jsf/facesconfig/ui/pageflow/synchronization/PF2FCSynchronizer:tranformer	Lorg/eclipse/jst/jsf/facesconfig/ui/pageflow/synchronization/FC2PFTransformer;
    //   163: invokevirtual 204	org/eclipse/jst/jsf/facesconfig/ui/pageflow/synchronization/FC2PFTransformer:getPageflow	()Lorg/eclipse/jst/jsf/facesconfig/ui/pageflow/model/Pageflow;
    //   166: invokevirtual 201	org/eclipse/jst/jsf/facesconfig/ui/pageflow/synchronization/FC2PFTransformer:refreshPFAdapter	(Lorg/eclipse/emf/ecore/EObject;)V
    //   169: aload_0
    //   170: getfield 189	org/eclipse/jst/jsf/facesconfig/ui/pageflow/synchronization/PF2FCSynchronizer:tranformer	Lorg/eclipse/jst/jsf/facesconfig/ui/pageflow/synchronization/FC2PFTransformer;
    //   173: aload_0
    //   174: getfield 189	org/eclipse/jst/jsf/facesconfig/ui/pageflow/synchronization/PF2FCSynchronizer:tranformer	Lorg/eclipse/jst/jsf/facesconfig/ui/pageflow/synchronization/FC2PFTransformer;
    //   177: invokevirtual 202	org/eclipse/jst/jsf/facesconfig/ui/pageflow/synchronization/FC2PFTransformer:getFacesConfig	()Lorg/eclipse/jst/jsf/facesconfig/emf/FacesConfigType;
    //   180: invokevirtual 200	org/eclipse/jst/jsf/facesconfig/ui/pageflow/synchronization/FC2PFTransformer:refreshFCAdapter	(Lorg/eclipse/emf/ecore/EObject;)V
    //   183: aload_0
    //   184: getfield 189	org/eclipse/jst/jsf/facesconfig/ui/pageflow/synchronization/PF2FCSynchronizer:tranformer	Lorg/eclipse/jst/jsf/facesconfig/ui/pageflow/synchronization/FC2PFTransformer;
    //   187: iconst_0
    //   188: invokevirtual 199	org/eclipse/jst/jsf/facesconfig/ui/pageflow/synchronization/FC2PFTransformer:setInEvent	(Z)V
    //   191: aload_3
    //   192: athrow
    //   193: aload_1
    //   194: invokeinterface 217 1 0
    //   199: bipush 8
    //   201: if_icmpeq +31 -> 232
    //   204: aload_0
    //   205: getfield 189	org/eclipse/jst/jsf/facesconfig/ui/pageflow/synchronization/PF2FCSynchronizer:tranformer	Lorg/eclipse/jst/jsf/facesconfig/ui/pageflow/synchronization/FC2PFTransformer;
    //   208: aload_0
    //   209: getfield 189	org/eclipse/jst/jsf/facesconfig/ui/pageflow/synchronization/PF2FCSynchronizer:tranformer	Lorg/eclipse/jst/jsf/facesconfig/ui/pageflow/synchronization/FC2PFTransformer;
    //   212: invokevirtual 204	org/eclipse/jst/jsf/facesconfig/ui/pageflow/synchronization/FC2PFTransformer:getPageflow	()Lorg/eclipse/jst/jsf/facesconfig/ui/pageflow/model/Pageflow;
    //   215: invokevirtual 201	org/eclipse/jst/jsf/facesconfig/ui/pageflow/synchronization/FC2PFTransformer:refreshPFAdapter	(Lorg/eclipse/emf/ecore/EObject;)V
    //   218: aload_0
    //   219: getfield 189	org/eclipse/jst/jsf/facesconfig/ui/pageflow/synchronization/PF2FCSynchronizer:tranformer	Lorg/eclipse/jst/jsf/facesconfig/ui/pageflow/synchronization/FC2PFTransformer;
    //   222: aload_0
    //   223: getfield 189	org/eclipse/jst/jsf/facesconfig/ui/pageflow/synchronization/PF2FCSynchronizer:tranformer	Lorg/eclipse/jst/jsf/facesconfig/ui/pageflow/synchronization/FC2PFTransformer;
    //   226: invokevirtual 202	org/eclipse/jst/jsf/facesconfig/ui/pageflow/synchronization/FC2PFTransformer:getFacesConfig	()Lorg/eclipse/jst/jsf/facesconfig/emf/FacesConfigType;
    //   229: invokevirtual 200	org/eclipse/jst/jsf/facesconfig/ui/pageflow/synchronization/FC2PFTransformer:refreshFCAdapter	(Lorg/eclipse/emf/ecore/EObject;)V
    //   232: aload_0
    //   233: getfield 189	org/eclipse/jst/jsf/facesconfig/ui/pageflow/synchronization/PF2FCSynchronizer:tranformer	Lorg/eclipse/jst/jsf/facesconfig/ui/pageflow/synchronization/FC2PFTransformer;
    //   236: iconst_0
    //   237: invokevirtual 199	org/eclipse/jst/jsf/facesconfig/ui/pageflow/synchronization/FC2PFTransformer:setInEvent	(Z)V
    //   240: return
    // Line number table:
    //   Java source line #66	-> byte code offset #0
    //   Java source line #67	-> byte code offset #8
    //   Java source line #69	-> byte code offset #9
    //   Java source line #71	-> byte code offset #17
    //   Java source line #78	-> byte code offset #29
    //   Java source line #79	-> byte code offset #40
    //   Java source line #80	-> byte code offset #54
    //   Java source line #82	-> byte code offset #68
    //   Java source line #72	-> byte code offset #76
    //   Java source line #74	-> byte code offset #77
    //   Java source line #75	-> byte code offset #85
    //   Java source line #76	-> byte code offset #86
    //   Java source line #78	-> byte code offset #93
    //   Java source line #79	-> byte code offset #104
    //   Java source line #80	-> byte code offset #118
    //   Java source line #82	-> byte code offset #132
    //   Java source line #77	-> byte code offset #143
    //   Java source line #78	-> byte code offset #144
    //   Java source line #79	-> byte code offset #155
    //   Java source line #80	-> byte code offset #169
    //   Java source line #82	-> byte code offset #183
    //   Java source line #83	-> byte code offset #191
    //   Java source line #78	-> byte code offset #193
    //   Java source line #79	-> byte code offset #204
    //   Java source line #80	-> byte code offset #218
    //   Java source line #82	-> byte code offset #232
    //   Java source line #84	-> byte code offset #240
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	241	0	this	PF2FCSynchronizer
    //   0	241	1	notification	Notification
    //   85	5	2	e	Exception
    //   143	49	3	localObject	Object
    // Exception table:
    //   from	to	target	type
    //   17	29	85	java/lang/Exception
    //   77	82	85	java/lang/Exception
    //   17	29	143	finally
    //   77	93	143	finally
  }
  
  private boolean isProcessorFor(Notification notification)
  {
    return tranformer.isListenToNotify();
  }
  
  private void processChange(Notification notification)
  {
    PageflowElement element = (PageflowElement)notification.getNotifier();
    int type = notification.getEventType();
    switch (type)
    {
    case 3: 
      int featureId = notification.getFeatureID(PageflowPackage.class);
      switch (featureId)
      {
      case 9: 
        addOutLink(notification, element);
        break;
      case 10: 
        addInLink(notification, element);
        break;
      }
      if (!tranformer.isNeedBatchOperations()) {
        updateAndNotify(notification);
      }
      break;
    case 1: 
      if (notification.getNewValue() != null)
      {
        processSet(notification, element);
        updateAndNotify(notification);
      }
      break;
    case 4: 
    case 6: 
      int featureId = notification.getFeatureID(PageflowPackage.class);
      switch (featureId)
      {
      case 5: 
        break;
      case 9: 
      case 10: 
        removeLink(notification, element);
      }
      if (!tranformer.isNeedBatchOperations()) {
        updateAndNotify(notification);
      }
      break;
    }
  }
  
  private void processSet(Notification notification, PageflowElement element)
  {
    if (notification.getNewValue() != null)
    {
      int value = notification.getFeatureID(PageflowPackage.class);
      if ((element instanceof PageflowPage)) {
        setProperties(notification, element, value);
      } else if ((element instanceof PageflowLink)) {
        setProperties(notification, element, value);
      }
    }
  }
  
  private void setProperties(Notification notification, PageflowElement element, int value)
  {
    if (notification.getFeature() == PageflowPackage.eINSTANCE
      .getPFLink_Source())
    {
      if ((notification.getNewValue() instanceof String)) {
        tranformer.changePFLinkStart((PageflowLink)element, 
          (String)notification.getNewValue());
      }
    }
    else if (notification.getFeature() == PageflowPackage.eINSTANCE
      .getPFLink_Target())
    {
      if ((notification.getNewValue() instanceof String)) {
        tranformer.changePFLinkEnd((PageflowLink)element, 
          (String)notification.getNewValue());
      }
    }
    else {
      element.getFCElements().set(
        (EStructuralFeature)notification.getFeature(), 
        notification.getNewValue());
    }
  }
  
  private void addInLink(Notification notification, PageflowElement element)
  {
    Object value = notification.getNewValue();
    PageflowLink link = (PageflowLink)value;
    if ((element instanceof PageflowPage))
    {
      PageflowNode source = link.getSource();
      if ((source instanceof PageflowPage)) {
        tranformer.addLink((PageflowPage)source, 
          (PageflowPage)element, link);
      }
    }
  }
  
  private void addOutLink(Notification notification, PageflowElement element)
  {
    Object value = notification.getNewValue();
    
    PageflowLink link = (PageflowLink)value;
    if ((element instanceof PageflowPage))
    {
      PageflowNode target_ = link.getTarget();
      if ((target_ instanceof PageflowPage)) {
        tranformer.addLink((PageflowPage)element, 
          (PageflowPage)target_, link);
      }
    }
  }
  
  private void removeLink(Notification notification, PageflowElement element)
  {
    Object value = notification.getOldValue();
    PageflowLink link = (PageflowLink)value;
    if (!link.getFCElements().isEmpty())
    {
      NavigationCaseType caseFC = 
        (NavigationCaseType)link.getFCElements().getData().get(0);
      if (caseFC != null) {
        tranformer.removeCase(caseFC);
      }
    }
    link.update();
  }
  
  private void updateAndNotify(Notification notification)
  {
    tranformer.getPageflow().notifyModelChanged(
      new ENotificationImpl(
      (InternalEObject)notification.getNotifier(), 1, 
      0, null, null));
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jst.jsf.facesconfig.ui.pageflow.synchronization.PF2FCSynchronizer
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jst.jsf.facesconfig.ui.pageflow.synchronization;

import org.eclipse.emf.common.notify.Notification;

class PFBatchAdapter$1
  implements Runnable
{
  PFBatchAdapter$1(PFBatchAdapter paramPFBatchAdapter, Notification paramNotification) {}
  
  public void run()
  {
    this$0.doNotifyChanged(val$msg);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jst.jsf.facesconfig.ui.pageflow.synchronization.PFBatchAdapter.1
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jst.jsf.facesconfig.ui.pageflow.synchronization;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.impl.AdapterImpl;
import org.eclipse.gef.editparts.AbstractGraphicalEditPart;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.PlatformUI;

public abstract class PFBatchAdapter
  extends AdapterImpl
{
  private boolean needPostpone;
  AbstractGraphicalEditPart editPart;
  
  public boolean isNeedPostpone(Notification msg)
  {
    return (needPostpone) && (msg.getEventType() != 11) && (msg.getEventType() != 12);
  }
  
  public void setNeedPostpone(boolean needPostpone)
  {
    this.needPostpone = needPostpone;
  }
  
  public final void notifyChanged(final Notification msg)
  {
    if (!isNeedPostpone(msg)) {
      if (Thread.currentThread() == PlatformUI.getWorkbench().getDisplay().getThread()) {
        doNotifyChanged(msg);
      } else {
        PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable()
        {
          public void run()
          {
            doNotifyChanged(msg);
          }
        });
      }
    }
  }
  
  public abstract void doNotifyChanged(Notification paramNotification);
}

/* Location:
 * Qualified Name:     org.eclipse.jst.jsf.facesconfig.ui.pageflow.synchronization.PFBatchAdapter
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jst.jsf.facesconfig.ui.pageflow.synchronization;

import java.util.List;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.jst.jsf.facesconfig.emf.FacesConfigType;
import org.eclipse.jst.jsf.facesconfig.emf.FromOutcomeType;
import org.eclipse.jst.jsf.facesconfig.emf.FromViewIdType;
import org.eclipse.jst.jsf.facesconfig.emf.NavigationCaseType;
import org.eclipse.jst.jsf.facesconfig.emf.NavigationRuleType;
import org.eclipse.jst.jsf.facesconfig.emf.ToViewIdType;
import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.Pageflow;
import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowLink;
import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowNode;
import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowPage;

public class TransformUtil
{
  public static boolean isValidFacesConfigElement(EObject object)
  {
    EObject parent = EcoreUtil.getRootContainer(object);
    boolean result = parent instanceof FacesConfigType;
    return result;
  }
  
  public static boolean isValidPageflowElement(EObject element)
  {
    EObject root = EcoreUtil.getRootContainer(element);
    boolean result = root instanceof Pageflow;
    return result;
  }
  
  public static boolean isValidLink(PageflowLink link)
  {
    return (isValidPageflowElement(link)) && (link.getSource() != null) && (link.getTarget() != null);
  }
  
  public static String getFromViewID(NavigationRuleType rule)
  {
    String result = "*";
    if (rule.getFromViewId() != null) {
      result = rule.getFromViewId().getTextContent();
    }
    return result;
  }
  
  public static String getToViewID(NavigationCaseType navCase)
  {
    String result = "*";
    if (navCase.getToViewId() != null) {
      result = navCase.getToViewId().getTextContent();
    }
    return result;
  }
  
  public static PageflowPage findPage(String path, Pageflow pageflow)
  {
    List nodes = pageflow.getNodes();
    for (int i = 0; i < nodes.size(); i++) {
      if (((nodes.get(i) instanceof PageflowPage)) && 
        (path != null) && 
        (path.equals(((PageflowPage)nodes.get(i)).getPath()))) {
        return (PageflowPage)nodes.get(i);
      }
    }
    return null;
  }
  
  public static PageflowNode findCaseEnd(PageflowPage action, FromOutcomeType outcome, Pageflow pageflow)
  {
    List links = action.getOutlinks();
    for (int i = 0; i < links.size(); i++)
    {
      PageflowLink link = (PageflowLink)links.get(i);
      String outcomeStr = "";
      if (outcome != null) {
        outcomeStr = outcome.getTextContent();
      }
      if (link.getOutcome().equals(outcomeStr)) {
        return link.getTarget();
      }
    }
    return null;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jst.jsf.facesconfig.ui.pageflow.synchronization.TransformUtil
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jst.jsf.facesconfig.ui.pageflow.util;

import java.util.Iterator;
import java.util.List;
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.gef.GraphicalEditPart;
import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowElement;
import org.eclipse.jst.jsf.facesconfig.ui.util.WebrootUtil;

public class EditPartMarkerUtil
{
  public static void removeAllMarkers(EObject model)
    throws CoreException
  {
    IResource resource = getResource(model);
    if (resource != null)
    {
      String[] markerTypes = { "org.eclipse.core.resources.problemmarker", "org.eclipse.core.resources.taskmarker" };
      for (int iMT = 0; iMT < markerTypes.length; iMT++)
      {
        IMarker[] markers = resource.findMarkers(markerTypes[iMT], 
          false, 1);
        for (int iMark = 0; iMark < markers.length; iMark++) {
          markers[iMark].delete();
        }
      }
    }
  }
  
  public static void removeAllMarkers(EObject model, String sMarkerType, int iSeverity)
    throws CoreException
  {
    IResource resource = getResource(model);
    if (resource != null)
    {
      IMarker[] markers = resource.findMarkers(sMarkerType, false, 
        1);
      for (int i = 0; i < markers.length; i++)
      {
        IMarker marker = markers[i];
        int iMarkerSeverity = marker.getAttribute("severity", 
          2);
        if ((iMarkerSeverity == iSeverity) || (iSeverity == -1)) {
          markers[i].delete();
        }
      }
    }
  }
  
  private static IResource getResource(EObject model)
  {
    IResource resource = null;
    resource = WebrootUtil.getResource(model);
    return resource;
  }
  
  public static void createMarker(EObject model, String sMarkerType, int severity, String message, String location)
    throws CoreException
  {
    IResource resource = getResource(model);
    if (resource != null)
    {
      IMarker marker = resource.createMarker(sMarkerType);
      marker.setAttribute("message", message);
      marker.setAttribute("severity", severity);
      if ((location != null) && (location.length() > 0)) {
        marker.setAttribute("location", location);
      }
    }
  }
  
  public static void removeMarker(EObject model, String sMarkerType)
    throws CoreException
  {
    IResource resource = getResource(model);
    if (resource != null)
    {
      IMarker[] markers = resource.findMarkers(sMarkerType, false, 
        1);
      for (int i = 0; i < markers.length; i++)
      {
        IMarker marker = markers[i];
        
        Object id = marker.getAttribute("location");
        if (((model instanceof PageflowElement)) && 
          (((PageflowElement)model).getId().equals(id))) {
          markers[i].delete();
        }
      }
    }
  }
  
  public static GraphicalEditPart findEditPart(GraphicalEditPart containerPart, String id)
  {
    Object model = containerPart.getModel();
    if ((model instanceof PageflowElement))
    {
      String modelId = ((PageflowElement)model).getId();
      if ((modelId != null) && (modelId.equals(id))) {
        return containerPart;
      }
    }
    Iterator iterNode = containerPart.getChildren().iterator();
    while (iterNode.hasNext())
    {
      GraphicalEditPart child = (GraphicalEditPart)iterNode.next();
      GraphicalEditPart foundPart = findEditPart(child, id);
      if (foundPart != null) {
        return foundPart;
      }
    }
    Iterator iterConnection = containerPart.getSourceConnections()
      .iterator();
    while (iterConnection.hasNext())
    {
      GraphicalEditPart child = (GraphicalEditPart)iterConnection.next();
      GraphicalEditPart foundPart = findEditPart(child, id);
      if (foundPart != null) {
        return foundPart;
      }
    }
    return null;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jst.jsf.facesconfig.ui.pageflow.util.EditPartMarkerUtil
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jst.jsf.facesconfig.ui.pageflow.util;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.jst.jsf.common.ui.internal.logging.Logger;
import org.eclipse.jst.jsf.context.resolver.structureddocument.ITaglibContextResolver;
import org.eclipse.jst.jsf.context.resolver.structureddocument.internal.IStructuredDocumentContextResolverFactory2;
import org.eclipse.jst.jsf.context.structureddocument.IStructuredDocumentContext;
import org.eclipse.jst.jsf.context.structureddocument.IStructuredDocumentContextFactory;
import org.eclipse.jst.jsf.facesconfig.ui.EditorPlugin;
import org.eclipse.wst.sse.core.StructuredModelManager;
import org.eclipse.wst.sse.core.internal.provisional.IModelManager;
import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument;
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel;
import org.w3c.dom.Document;
import org.w3c.dom.NodeList;

public class JSPDomAdapter
{
  private static final Logger log = EditorPlugin.getLogger(JSPDomAdapter.class);
  public static String JSP_TAGLIB_TAG = "jsp:directive.taglib";
  public static String JSF_HTML_TAGLIB = "http://java.sun.com/jsf/html";
  private static IModelManager modelManager;
  private IFile jspFile;
  private IStructuredModel model;
  private Document document;
  
  public boolean initialize(IFile file)
  {
    jspFile = file;
    if ((jspFile != null) && (jspFile.exists()))
    {
      try
      {
        model = getModel(jspFile);
      }
      catch (IOException e)
      {
        log.error("PageFlow.JSPDomAdapter.FailToGetStructuredModel", e);
      }
      catch (CoreException e)
      {
        log.error("PageFlow.JSPDomAdapter.FailToGetStructuredModel", e);
      }
      if ((model != null) && ((model instanceof IDOMModel))) {
        return true;
      }
    }
    return false;
  }
  
  public String getTagLibPrefix(String taglibURI)
  {
    String prefix = null;
    
    IStructuredDocument sdocument = model.getStructuredDocument();
    if (sdocument != null)
    {
      IStructuredDocumentContext context = 
        IStructuredDocumentContextFactory.INSTANCE.getContext(sdocument, -1);
      ITaglibCon
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40

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