Package org.fusesource.ide.camel.model

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


    @Override
    protected EditPart convert(EditPartViewer viewer, EditPart part) {
        
        Object o = part.getModel();
        if (o instanceof RouteSupport) {
            RouteSupport newRoute = (RouteSupport)o;
            RouteSupport oldRoute = editor.getSelectedRoute();
            if (!oldRoute.equals(newRoute)) {
                // user selected a route which is not currently displayed in the diagram editor -> we need to load the route into the editor now first
                editor.switchRoute(newRoute);
            }
            // the route was selected - so we need to return the topmost editPart
            return viewer.getRootEditPart();
        } else if (o instanceof RouteContainer) {
            return viewer.getRootEditPart();
        } else if (o instanceof AbstractNode) {
            PictogramElement[] pes = editor.getFeatureProvider().getAllPictogramElementsForBusinessObject(o);
            if (pes.length>0) {
                AbstractNode node = (AbstractNode)o;
                RouteSupport oldRoute = editor.getSelectedRoute();
                RouteSupport newRoute = (RouteSupport)node.getParent();
                if (!oldRoute.equals(newRoute)) {
                    editor.switchRoute(newRoute);
                    editor.autoLayoutRoute();
                }
            }
            if (pes.length == 0) {
                // an element from another route was selected - we need to load the route into the diagram
                AbstractNode node = (AbstractNode)o;
                editor.switchRoute((RouteSupport)node.getParent());
                editor.getDiagramBehavior().refreshContent();
                Iterator<?> it = viewer.getEditPartRegistry().entrySet().iterator();
                while (it.hasNext()) {
                    Entry<?, ?> e = (Entry<?, ?>)it.next();
                    Object key = e.getKey();
                    EditPart value = (EditPart)e.getValue();
                    if (key instanceof ContainerShape) {
                        ContainerShape cs = (ContainerShape)key;
                        if (cs.getLink() != null &&
                            cs.getLink().getBusinessObjects() != null &&
                            cs.getLink().getBusinessObjects().size() > 0 &&
                            cs.getLink().getBusinessObjects().get(0) != null &&
                            cs.getLink().getBusinessObjects().get(0).equals(o)) {
                            // found the correct entry
                            return value;
                        }
                    }
                    continue;
                }
                // if all fails return the root edit part
                return viewer.getRootEditPart();
            }
            return editor.getDiagramBehavior().getEditPartForPictogramElement(pes[0]);
        } else if (o instanceof Diagram) {
            // someone selected the route inside the diagram editor
            RouteSupport route = editor.getSelectedRoute();
            return getEditPart(viewer, route);
        } else if (o instanceof ContainerShape) {
            // someone selected a diagram figure in the diagram editor
          AbstractNode node = null;
          node = (AbstractNode)Activator.getDiagramEditor().getFeatureProvider().getBusinessObjectForPictogramElement(((ContainerShape)o));
View Full Code Here


    routeContainer = getCamelContextNode().getModelContainer();
    if (routeContainer != null) {
      List<AbstractNode> children = routeContainer.getChildren();
      for (AbstractNode node : children) {
        if (node instanceof RouteSupport) {
          RouteSupport route = (RouteSupport) node;
          RouteNode routeNode = new RouteNode(this, route);
          String id = route.getId();
          if (id != null) {
            routeMap .put(id, routeNode);
          }
          addChild(routeNode);
        }
View Full Code Here

    Otherwise otherwise = new Otherwise();
    choice.addTargetNode(otherwise);
    otherwise.addTargetNode(ep3);

   
    RouteSupport route = new Route();
    route.addChildren(ep1, choice, when, otherwise, ep2, ep3, ep4);

    // now lets turn into the camel model...
    RouteDefinition routeDef = route.createRouteDefinition();
    System.out.println("Created: " + routeDef);

    assertSingleInput(routeDef, FromDefinition.class);
    assertSize(routeDef.getOutputs(), 2);
    ChoiceDefinition c1 = assertOutput(routeDef, 0, ChoiceDefinition.class);
    ToDefinition ed4 = assertOutput(routeDef, 1, ToDefinition.class);
    assertEquals("choice -> to", "seda:d", ed4.getUri());

    List<WhenDefinition> whenClauses = c1.getWhenClauses();
    assertSize(whenClauses, 1);
    WhenDefinition wd1 = whenClauses.get(0);
    ToDefinition ed2 = assertSingleOutput(wd1, ToDefinition.class);
    assertEquals("when -> to", "seda:b", ed2.getUri());
   
    OtherwiseDefinition od1 = c1.getOtherwise();
    assertNotNull("Should have Otherwise", od1);
    ToDefinition ed3 = assertSingleOutput(od1, ToDefinition.class);
    assertEquals("otherwise -> to", "seda:c", ed3.getUri());

    RouteContainer routeContainer = new RouteContainer();
    RouteSupport route2 = new Route(routeDef, routeContainer);
    System.out.println("Created route: " + route2);
    assertRoute(route);
   
    /** TODO: commented out as this fails for unknown reason - needs further investigation
    assertRoute(route2);
View Full Code Here

   
    // wire them up...
    ep1.addTargetNode(filter1);
    filter1.addTargetNode(ep2);
   
    RouteSupport route = new Route();
    assertValidNode(route, "route");
   
    route.addChildren(ep1, filter1, ep2);
   
    // now lets turn into the camel model...
    RouteDefinition routeDef = route.createRouteDefinition();
    System.out.println("Created: " + routeDef);

    FromDefinition ed1 = assertSingleInput(routeDef, FromDefinition.class);
    FilterDefinition fd1 = assertSingleOutput(routeDef, FilterDefinition.class);
    ToDefinition ed2 = assertSingleOutput(fd1, ToDefinition.class);
View Full Code Here

  @Test
  public void testEndpointSummary() throws Exception {
    RouteContainer routeContainer = new RouteContainer();
   
    // from seda:a -> filter -> seda:b
    RouteSupport route1 = new Route();
    routeContainer.addChild(route1);
   
    Endpoint endpoint1 = new Endpoint("seda:a");
    route1.addChild(endpoint1);
   
    Filter filter1 = new Filter();
    endpoint1.addTargetNode(filter1);
   
    Endpoint endpoint2 = new Endpoint("seda:b");
    filter1.addTargetNode(endpoint2);

    // from seda:b -> filter -> seda:c
    RouteSupport route2 = new Route();
    routeContainer.addChild(route2);
   
    Endpoint endpoint3 = new Endpoint("seda:b");
    route2.addChild(endpoint3);
   
    Filter filter2 = new Filter();
    endpoint3.addTargetNode(filter2);
   
    Endpoint endpoint4 = new Endpoint("seda:c");
View Full Code Here

   
    Unmarshal um = new Unmarshal();
    ep1.addTargetNode(um);
    um.addTargetNode(ep2);

    RouteSupport route = new Route();
    route.addChildren(ep1, um, ep2);

    // now lets turn into the camel model...
    RouteDefinition routeDef = route.createRouteDefinition();
    System.out.println("Created: " + routeDef);

    assertSingleInput(routeDef, FromDefinition.class);
    assertSize(routeDef.getOutputs(), 2);
    assertOutput(routeDef, 0, UnmarshalDefinition.class);
View Full Code Here

  public Object[] getConnectedTo(Object entity) {
    if (entity instanceof GraphableNodeConnected) {
      GraphableNodeConnected gn = (GraphableNodeConnected) entity;
      return gn.getGraphConnectedTo().toArray();
    } else if (entity instanceof RouteSupport) {
      RouteSupport route = (RouteSupport) entity;
      return route.getRootNodes().toArray();
    } else if (entity instanceof AbstractNode) {
      AbstractNode node = (AbstractNode) entity;
      node.getOutputs().toArray();
    }
    else if (entity instanceof ConnectedNode) {
View Full Code Here

  protected boolean selectEndpointUri(String uri) {
    if (node != null) {
      RouteContainer parent = getParentContainer();
      if (parent instanceof RouteSupport) {
        RouteSupport route = (RouteSupport) parent;
        AbstractNode newSelection = route.findEndpoint(uri);
        if (newSelection == null) {
          // lets try iterate through any children
          List<AbstractNode> children = parent.getChildren();
          for (AbstractNode child : children) {
            if (child instanceof RouteSupport) {
              route = (RouteSupport) child;
              newSelection = route.findEndpoint(uri);
              if (newSelection != null) {
                break;
              }
            }
          }
View Full Code Here

      @Override
      public void selectionChanged(SelectionChangedEvent event) {
        final ISelection selection = event.getSelection();
        nodeListener.selectionChanged(part, selection);
        AbstractNode node = AbstractNodes.getSelectedNode(selection);
        RouteSupport route = AbstractNodes.getRoute(node);
        if (route != null && route != previousSelection) {
          // lets potentially update the selected route
          previousSelection = route;
          // only set the route if it differs from the currently selected one in the editor
          if (editor.getSelectedRoute() != route) {
View Full Code Here

     * (non-Javadoc)
     * @see org.eclipse.gef.editparts.AbstractEditPart#getModelChildren()
     */
    @Override
    protected List<AbstractNode> getModelChildren() {
        RouteSupport container = (RouteSupport)getModel();
        return container.getRootNodes();
    }
View Full Code Here

TOP

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

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.