package brn.gui.linktable.diagram.part;

import java.util.List;
import org.eclipse.gef.Tool;
import org.eclipse.gef.palette.PaletteContainer;
import org.eclipse.gef.palette.PaletteRoot;
import org.eclipse.gef.palette.ToolEntry;
import org.eclipse.jface.resource.ImageDescriptor;
import brn.gui.linktable.diagram.providers.ModelElementTypes;

import java.util.ArrayList;

import org.eclipse.gef.palette.PaletteGroup;

import org.eclipse.gmf.runtime.diagram.ui.tools.UnspecifiedTypeConnectionTool;
import org.eclipse.gmf.runtime.diagram.ui.tools.UnspecifiedTypeCreationTool;

/**
 * @generated
 */
public class ModelPaletteFactory {

  /**
   * @generated
   */
  public void fillPalette(PaletteRoot paletteRoot) {
    paletteRoot.add(createNodes1Group());
  }

  /**
   * @generated
   */
  private PaletteContainer createNodes1Group() {
    PaletteContainer paletteContainer = new PaletteGroup("Nodes");
    paletteContainer.add(createNode1CreationTool());
    paletteContainer.add(createLink2CreationTool());
    return paletteContainer;
  }

  /**
   * @generated
   */
  private ToolEntry createNode1CreationTool() {
    ImageDescriptor smallImage;
    ImageDescriptor largeImage;

    smallImage = ModelElementTypes
        .getImageDescriptor(ModelElementTypes.Node_1001);

    largeImage = smallImage;

    final List elementTypes = new ArrayList();
    elementTypes.add(ModelElementTypes.Node_1001);
    ToolEntry result = new NodeToolEntry("Node", "null", smallImage,
        largeImage, elementTypes);

    return result;
  }

  /**
   * @generated
   */
  private ToolEntry createLink2CreationTool() {
    ImageDescriptor smallImage;
    ImageDescriptor largeImage;

    smallImage = null;

    largeImage = smallImage;

    ToolEntry result = new ToolEntry("Link", "null", smallImage, largeImage) {
    };

    return result;
  }

  /**
   * @generated
   */
  private static class NodeToolEntry extends ToolEntry {

    /**
     * @generated
     */
    private final List elementTypes;

    /**
     * @generated
     */
    private NodeToolEntry(String title, String description,
        ImageDescriptor smallIcon, ImageDescriptor largeIcon, List elementTypes) {
      super(title, description, smallIcon, largeIcon);
      this.elementTypes = elementTypes;
    }

    /**
     * @generated
     */
    public Tool createTool() {
      Tool tool = new UnspecifiedTypeCreationTool(elementTypes);
      tool.setProperties(getToolProperties());
      return tool;
    }
  }

  /**
   * @generated
   */
  private static class LinkToolEntry extends ToolEntry {

    /**
     * @generated
     */
    private final List relationshipTypes;

    /**
     * @generated
     */
    private LinkToolEntry(String title, String description,
        ImageDescriptor smallIcon, ImageDescriptor largeIcon,
        List relationshipTypes) {
      super(title, description, smallIcon, largeIcon);
      this.relationshipTypes = relationshipTypes;
    }

    /**
     * @generated
     */
    public Tool createTool() {
      Tool tool = new UnspecifiedTypeConnectionTool(relationshipTypes);
      tool.setProperties(getToolProperties());
      return tool;
    }
  }
}
