Package org.springframework.ide.eclipse.webflow.ui.graph

Source Code of org.springframework.ide.eclipse.webflow.ui.graph.WebflowEditorInputFactory

/*******************************************************************************
* Copyright (c) 2007 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.graph;

import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.ui.IElementFactory;
import org.eclipse.ui.IMemento;
import org.springframework.ide.eclipse.webflow.core.Activator;
import org.springframework.ide.eclipse.webflow.core.model.IWebflowConfig;

/**
* @author Christian Dupuis
* @since 2.0
*/
public class WebflowEditorInputFactory implements IElementFactory {

  /**
   * Factory id. The workbench plug-in registers a factory by this name with
   * the "org.eclipse.ui.elementFactories" extension point.
   */
  private static final String ID_FACTORY = "org.springframework.ide.eclipse.webflow.ui.graph.webFlowEditorInputFactory"; //$NON-NLS-1$

  /**
   * Tag for the IFile.fullPath of the file resource.
   */
  private static final String TAG_PATH = "elementId"; //$NON-NLS-1$

  /*
   * (non-Javadoc) Method declared on IElementFactory.
   */
  public IAdaptable createElement(IMemento memento) {
    String elementId = memento.getString(TAG_PATH);
    if (elementId == null) {
      return null;
    }

    IWebflowConfig config = (IWebflowConfig) Activator.getModel()
        .getElement(elementId);
    if (config != null) {
      return new WebflowEditorInput(config);
    }
    return null;
  }

  /**
   * Returns the element factory id for this class.
   *
   * @return the element factory id
   */
  public static String getFactoryId() {
    return ID_FACTORY;
  }

  /**
   * Saves the state of the given file editor input into the given memento.
   *
   * @param memento the storage area for element state
   * @param input the file editor input
   */
  public static void saveState(IMemento memento, WebflowEditorInput input) {
    String elementId = input.getConfig().getElementID();
    memento.putString(TAG_PATH, elementId);
  }
}
TOP

Related Classes of org.springframework.ide.eclipse.webflow.ui.graph.WebflowEditorInputFactory

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.