Package org.springframework.ide.eclipse.webflow.ui.editor.hyperlink.webflow

Source Code of org.springframework.ide.eclipse.webflow.ui.editor.hyperlink.webflow.WebflowBeanReferenceHyperlinkCalculator

/*******************************************************************************
* Copyright (c) 2010 - 2013 Spring IDE Developers
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
*     Spring IDE Developers - initial API and implementation
*******************************************************************************/
package org.springframework.ide.eclipse.webflow.ui.editor.hyperlink.webflow;

import java.util.Set;

import org.eclipse.core.resources.IFile;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.IRegion;
import org.eclipse.jface.text.ITextViewer;
import org.eclipse.jface.text.hyperlink.IHyperlink;
import org.springframework.ide.eclipse.beans.core.model.IBean;
import org.springframework.ide.eclipse.beans.ui.editor.hyperlink.ExternalBeanHyperlink;
import org.springframework.ide.eclipse.beans.ui.editor.hyperlink.IHyperlinkCalculator;
import org.springframework.ide.eclipse.beans.ui.editor.util.BeansEditorUtils;
import org.springframework.ide.eclipse.webflow.core.Activator;
import org.springframework.ide.eclipse.webflow.core.internal.model.WebflowModelUtils;
import org.springframework.ide.eclipse.webflow.core.model.IWebflowConfig;
import org.w3c.dom.Node;

/**
* {@link IHyperlinkCalculator} for bean references.
* @author Christian Dupuis
* @author Leo Dos Santos
* @since 2.3.4
*/
public class WebflowBeanReferenceHyperlinkCalculator implements IHyperlinkCalculator {

  public IHyperlink createHyperlink(String name, String target, Node node,
      Node parentNode, IDocument document, ITextViewer textViewer,
      IRegion hyperlinkRegion, IRegion cursor) {
    IFile file = BeansEditorUtils.getFile(document);
    if (file != null && file.exists()) {
      IWebflowConfig config = Activator.getModel().getProject(file.getProject()).getConfig(
          file);
      if (config != null) {
        Set<IBean> beans = WebflowModelUtils.getBeans(config);
        for (IBean bean : beans) {
          if (bean.getElementName().equals(target)) {
            return new ExternalBeanHyperlink(bean, hyperlinkRegion);
          }
        }
      }
    }
    return null;
  }

}
TOP

Related Classes of org.springframework.ide.eclipse.webflow.ui.editor.hyperlink.webflow.WebflowBeanReferenceHyperlinkCalculator

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.