Package org.fusesource.ide.camel.editor.features.custom

Source Code of org.fusesource.ide.camel.editor.features.custom.AddRouteFeature

/*******************************************************************************
* Copyright (c) 2013 Red Hat, Inc.
* Distributed under license by Red Hat, Inc. All rights reserved.
* This program is 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:
*     Red Hat, Inc. - initial API and implementation
******************************************************************************/

package org.fusesource.ide.camel.editor.features.custom;

import org.eclipse.graphiti.features.IFeatureProvider;
import org.eclipse.graphiti.features.context.IContext;
import org.eclipse.graphiti.features.context.ICustomContext;
import org.eclipse.graphiti.features.custom.AbstractCustomFeature;
import org.fusesource.ide.camel.editor.Activator;
import org.fusesource.ide.camel.editor.EditorMessages;
import org.fusesource.ide.camel.editor.editor.RiderDesignEditor;
import org.fusesource.ide.camel.editor.provider.ImageProvider;


/**
* @author lhein
*
*/
public class AddRouteFeature extends AbstractCustomFeature {

  public AddRouteFeature(IFeatureProvider fp) {
    super(fp);
  }

  /* (non-Javadoc)
   * @see org.eclipse.graphiti.features.impl.AbstractFeature#getName()
   */
  @Override
  public String getName() {
    return EditorMessages.addRouteInAddMenuLabel;
  }


  @Override
  public String getImageId() {
    String iconName = "route.png";
    //String iconName = new Route().getIconName();
    return ImageProvider.getKeyForSmallIcon(iconName);
  }

  /* (non-Javadoc)
   * @see org.eclipse.graphiti.features.impl.AbstractFeature#getDescription()
   */
  @Override
  public String getDescription() {
    return EditorMessages.addRouteDescription;
  }

  /* (non-Javadoc)
   * @see org.eclipse.graphiti.features.custom.AbstractCustomFeature#isAvailable(org.eclipse.graphiti.features.context.IContext)
   */
  @Override
  public boolean isAvailable(IContext context) {
    return true;
    /*
    RiderDesignEditor editor = Activator.getDiagramEditor();
    return editor.getSelectedNode() == null || editor.getSelectedNode() instanceof RouteSupport;
     */
  }

  /* (non-Javadoc)
   * @see org.eclipse.graphiti.features.custom.AbstractCustomFeature#canExecute(org.eclipse.graphiti.features.context.ICustomContext)
   */
  @Override
  public boolean canExecute(ICustomContext context) {
    return true;
  }

  /* (non-Javadoc)
   * @see org.eclipse.graphiti.features.custom.ICustomFeature#execute(org.eclipse.graphiti.features.context.ICustomContext)
   */
  @Override
  public void execute(ICustomContext context) {
    RiderDesignEditor editor = Activator.getDiagramEditor();
    if (editor != null) {
      editor.addNewRoute();
    }
  }
}
TOP

Related Classes of org.fusesource.ide.camel.editor.features.custom.AddRouteFeature

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.