Package org.fusesource.ide.camel.model

Examples of org.fusesource.ide.camel.model.AbstractNode


  /* (non-Javadoc)
   * @see org.eclipse.graphiti.func.IAdd#add(org.eclipse.graphiti.features.context.IAddContext)
   */
  @Override
  public PictogramElement add(IAddContext context) {
    final AbstractNode addedClass = (AbstractNode) context.getNewObject();
    //    final EClass addedClass = (EClass) context.getNewObject();
    final Diagram targetDiagram = (Diagram) context.getTargetContainer();

    // CONTAINER SHAPE WITH ROUNDED RECTANGLE
    final IPeCreateService peCreateService = Graphiti.getPeCreateService();
    final ContainerShape containerShape = peCreateService.createContainerShape(targetDiagram, true);

    String label = DiagramUtils.filterFigureLabel(addedClass.getDisplayText());
   
    // check whether the context has a size (e.g. from a create feature)
    // otherwise define a default size for the shape
    // now try to use the image dimension as figure dimension plus some height spacing
    // for the display label
    Font f = StyleUtil.getStyleForCamelText(getDiagram()).getFont();
    IDimension fontDimension = GraphitiUi.getUiLayoutService().calculateTextSize(label, f);
    Dimension imageDimension = ImageUtils.getImageSize(addedClass.getIconName());

    int image_width = imageDimension.width;
    int image_height = imageDimension.height;
   
    int label_width = fontDimension.getWidth() + LABEL_SPACER_X + LABEL_SPACER_X;
    int label_height = Math.max(fontDimension.getHeight(), TEXT_LABEL_SIZE);

    int content_width = Math.max(Math.max(label_width, image_width), DEFAULT_FIGURE_CONTENT_WIDTH);
   
    // now lets define the shape dimensions
    org.eclipse.swt.graphics.Rectangle baseRect = new org.eclipse.swt.graphics.Rectangle(context.getX(), context.getY(), content_width + BASE_RECT_SPACE_X + BASE_RECT_SPACE_X + SHADOW_WIDTH + INVISIBLE_RIGHT_SPACE, BASE_RECT_SPACE_Y + BASE_RECT_SPACE_Y + image_height + SHADOW_HEIGHT + IMAGE_LABEL_SPACE + label_height + TOP_BOTTOM_SPACE + TOP_BOTTOM_SPACE);
    org.eclipse.swt.graphics.Rectangle shadowRect = new org.eclipse.swt.graphics.Rectangle(0 + BASE_RECT_SPACE_X + SHADOW_WIDTH, 0 + BASE_RECT_SPACE_Y + SHADOW_HEIGHT, content_width, image_height + label_height + IMAGE_LABEL_SPACE + TOP_BOTTOM_SPACE + TOP_BOTTOM_SPACE);
    org.eclipse.swt.graphics.Rectangle contentRect = new org.eclipse.swt.graphics.Rectangle(0 + BASE_RECT_SPACE_X, 0 + BASE_RECT_SPACE_Y, content_width, image_height + label_height + IMAGE_LABEL_SPACE + TOP_BOTTOM_SPACE + TOP_BOTTOM_SPACE);
    org.eclipse.swt.graphics.Rectangle imageRect = new org.eclipse.swt.graphics.Rectangle(0 + BASE_RECT_SPACE_X, 0 + BASE_RECT_SPACE_Y + TOP_BOTTOM_SPACE, content_width, image_height);
    org.eclipse.swt.graphics.Rectangle labelRect = new org.eclipse.swt.graphics.Rectangle(0 + BASE_RECT_SPACE_X, 0 + BASE_RECT_SPACE_Y + image_height + IMAGE_LABEL_SPACE, content_width, label_height + TOP_BOTTOM_SPACE);
   
    final IGaService gaService = Graphiti.getGaService();
    final RoundedRectangle baseRectangle = gaService.createRoundedRectangle(containerShape, ROUNDED_RECTANGLE_WIDTH, ROUNDED_RECTANGLE_HEIGHT);

    // create invisible outer rectangle expanded by
    // the width needed for the anchor
    gaService.setLocationAndSize(baseRectangle, baseRect.x, baseRect.y, baseRect.width, baseRect.height);
    baseRectangle.setFilled(false);
    baseRectangle.setLineVisible(false);
   
    // shadow
    RoundedRectangle shadowRectangle; // need to access it later
    {
      // create and set visible rectangle inside invisible rectangle
      shadowRectangle = gaService.createRoundedRectangle(baseRectangle, ROUNDED_RECTANGLE_WIDTH, ROUNDED_RECTANGLE_HEIGHT);
      shadowRectangle.setParentGraphicsAlgorithm(baseRectangle);
      shadowRectangle.setStyle(StyleUtil.getShadowStyleForCamelClass(getDiagram()));
      shadowRectangle.setLineVisible(false);
      shadowRectangle.setFilled(true);
      gaService.setLocationAndSize(shadowRectangle, shadowRect.x, shadowRect.y, shadowRect.width, shadowRect.height);
    }

    // the real figure
    RoundedRectangle roundedRectangle; // need to access it later
    {
      // create and set visible rectangle inside invisible rectangle
      roundedRectangle = gaService.createRoundedRectangle(baseRectangle, ROUNDED_RECTANGLE_WIDTH, ROUNDED_RECTANGLE_HEIGHT);
      roundedRectangle.setParentGraphicsAlgorithm(baseRectangle);
      roundedRectangle.setStyle(StyleUtil.getStyleForCamelClass(getDiagram()));
      gaService.setLocationAndSize(roundedRectangle, contentRect.x, contentRect.y, contentRect.width, contentRect.height);
    }
   
    // image
    {
      // create shape for image
      final Shape shape = peCreateService.createShape(containerShape, false);

      // create and set image
      final Image image = gaService.createImage(shape, ImageProvider.getKeyForLargeIcon(addedClass.getIconName()));
      gaService.setLocationAndSize(image, imageRect.x, imageRect.y, imageRect.width, imageRect.height);

      // if addedClass has no resource we add it to the resource of the diagram
      // in a real scenario the business model would have its own resource
//      if (addedClass.eResource() == null) {
View Full Code Here


      PictogramElement _pe = context.getPictogramElements()[0] instanceof Connection ? ((Connection) context.getPictogramElements()[0])
                .getStart().getParent() : context.getPictogramElements()[0];
        final Object bo = getBusinessObjectForPictogramElement(_pe);
       
        if (bo instanceof AbstractNode) {
          AbstractNode _ep = (AbstractNode)bo;
            try {
              IFile contextFile = getContextFile();
              String fileName = contextFile.getName();
              String projectName = contextFile.getProject().getName();
                IBreakpoint bp = CamelDebugUtils.getBreakpointForSelection(_ep.getId(), fileName, projectName);
                if (bp != null) {
                  bp.delete();
                }
            } catch (CoreException e) {
              final IDiagramContainer container = getDiagramBehavior().getDiagramContainer();
View Full Code Here

    PictogramElement _pe = cc.getPictogramElements()[0] instanceof Connection ? ((Connection) cc.getPictogramElements()[0])
                .getStart().getParent() : cc.getPictogramElements()[0];
        final Object bo = getBusinessObjectForPictogramElement(_pe);
       
        if (bo instanceof AbstractNode) {
          AbstractNode _ep = (AbstractNode)bo;
          IFile contextFile = getContextFile();
          String fileName = contextFile.getName();
          String projectName = contextFile.getProject().getName();
          return CamelDebugUtils.getBreakpointForSelection(_ep.getId(), fileName, projectName) != null;
        }
        return false;
  }
View Full Code Here

    ISelection selection = event.getSelection();
    if (!selection.isEmpty() && selection instanceof IStructuredSelection) {
      selectedConnections = new HashSet<AbstractNode>();
      for (Object o : ((IStructuredSelection) selection).toList()) {
        if (o instanceof AbstractNode) {
          AbstractNode node = (AbstractNode) o;
          viewer.reveal(node);
          selectedConnections.add(node);
          /*
          AbstractNode output = (AbstractNode) o;
          for (AbstractNode node : output.getOutputs()) {
View Full Code Here

   */
  @Override
  public Image getImage(Object element) {
    if (isShowIcon()) {
      if (isRouteNode(element)) {
        AbstractNode node = (AbstractNode) element;
        return node.getSmallImage();
      }
      if (element instanceof ImageProvider) {
        ImageProvider node = (ImageProvider) element;
        return node.getImage();
      }
    }
    return null;
  }
View Full Code Here

   */
  @Override
  public String getText(Object element) {
    try {
      if (isRouteNode(element)) {
        AbstractNode node = (AbstractNode) element;
        String label = DiagramUtils.filterFigureLabel(node.getDisplayText(useNodeIdForLabel));
        return label;
      } else if (element instanceof HasName) {
        HasName h = (HasName) element;
        return h.getName();
      } else if (element instanceof Flow) {
View Full Code Here

   * @see org.eclipse.zest.core.viewers.IEntityStyleProvider#getTooltip(java.lang.Object)
   */
  @Override
  public IFigure getTooltip(Object entity) {
    if (isRouteNode(entity)) {
      AbstractNode node = (AbstractNode) entity;
      String label = node.getDisplayToolTip();

      String id = node.getId();
      if (id != null) {
        label = "[" + id + "] " + label;
      }
      // TODO add link to docs!
      return new Label(label);
View Full Code Here

  }

  protected INodeStatistics getStatsFor(Flow flow) {
    NodeStatisticsContainer traceExchangeList = view.getNodeStatisticsContainer();
    INodeStatistics stats = null;
    AbstractNode node = flow.getTarget();
    if (traceExchangeList != null && node != null) {
      stats = traceExchangeList.getNodeStats(node.getId());
    }
    return stats;
  }
View Full Code Here

TOP

Related Classes of org.fusesource.ide.camel.model.AbstractNode

Copyright © 2018 www.massapicom. 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.