Exemple #1
0
 /* (non-Javadoc)
  * @see org.eclipse.ui.views.properties.IPropertySource#setPropertyValue(java.lang.Object, java.lang.Object)
  */
 @Override
 public void setPropertyValue(Object id, Object value) {
   if (PROPERTY_REF.equals(id)) {
     setRef(Objects.convertTo(value, String.class));
   } else {
     super.setPropertyValue(id, value);
   }
 }
Exemple #2
0
 @SuppressWarnings("rawtypes")
 @Override
 public ProcessorDefinition createCamelDefinition() {
   PolicyDefinition answer = new PolicyDefinition();
   answer.setRef(toXmlPropertyValue(PROPERTY_REF, this.getRef()));
   super.savePropertiesToCamelDefinition(answer);
   return answer;
 }
Exemple #3
0
  /*
   * (non-Javadoc)
   * @see org.fusesource.ide.camel.model.AbstractNode#addCustomProperties(java.util.Map)
   */
  @Override
  protected void addCustomProperties(Map<String, PropertyDescriptor> descriptors) {
    super.addCustomProperties(descriptors);

    PropertyDescriptor descRef =
        new TextPropertyDescriptor(PROPERTY_REF, Messages.propertyLabelPolicyRef);
    descriptors.put(PROPERTY_REF, descRef);
  }
Exemple #4
0
 @SuppressWarnings("rawtypes")
 @Override
 public ProcessorDefinition createCamelDefinition() {
   LoopDefinition answer = new LoopDefinition();
   answer.setExpression(toXmlPropertyValue(PROPERTY_EXPRESSION, this.getExpression()));
   answer.setCopy(toXmlPropertyValue(PROPERTY_COPY, this.getCopy()));
   super.savePropertiesToCamelDefinition(answer);
   return answer;
 }
Exemple #5
0
 /* (non-Javadoc)
  * @see org.eclipse.ui.views.properties.IPropertySource#setPropertyValue(java.lang.Object, java.lang.Object)
  */
 @Override
 public void setPropertyValue(Object id, Object value) {
   if (PROPERTY_EXPRESSION.equals(id)) {
     setExpression(Objects.convertTo(value, ExpressionDefinition.class));
   } else if (PROPERTY_COPY.equals(id)) {
     setCopy(Objects.convertTo(value, Boolean.class));
   } else {
     super.setPropertyValue(id, value);
   }
 }
 /*
  * (non-Javadoc)
  *
  * @see org.fusesource.ide.camel.editor.propertysheet.NodeSectionSupport#
  * onNodeChanged(org.fusesource.ide.camel.model.AbstractNode)
  */
 @Override
 protected void onNodeChanged(AbstractNode node) {
   this.node = node;
   form.setText(
       node != null
           ? String.format(
               "%s - %s", EditorMessages.propertiesDocumentationTitle, node.getPatternName())
           : EditorMessages.propertiesDocumentationTitle);
   showDocumentationPage();
 }
Exemple #7
0
  /*
   * (non-Javadoc)
   * @see org.fusesource.ide.camel.model.AbstractNode#addCustomProperties(java.util.Map)
   */
  @Override
  protected void addCustomProperties(Map<String, PropertyDescriptor> descriptors) {
    super.addCustomProperties(descriptors);

    PropertyDescriptor descExpression =
        new ExpressionPropertyDescriptor(PROPERTY_EXPRESSION, Messages.propertyLabelLoopExpression);
    PropertyDescriptor descCopy =
        new BooleanPropertyDescriptor(PROPERTY_COPY, Messages.propertyLabelLoopCopy);
    descriptors.put(PROPERTY_EXPRESSION, descExpression);
    descriptors.put(PROPERTY_COPY, descCopy);
  }
  @SuppressWarnings("rawtypes")
  @Override
  public ProcessorDefinition createCamelDefinition() {
    ConvertBodyDefinition answer = new ConvertBodyDefinition();

    answer.setType(toXmlPropertyValue(PROPERTY_TYPE, this.getType()));
    answer.setCharset(toXmlPropertyValue(PROPERTY_CHARSET, this.getCharset()));

    super.savePropertiesToCamelDefinition(answer);
    return answer;
  }
  @Override
  protected void addCustomProperties(Map<String, PropertyDescriptor> descriptors) {
    super.addCustomProperties(descriptors);

    PropertyDescriptor descType =
        new TextPropertyDescriptor(PROPERTY_TYPE, Messages.propertyLabelConvertBodyType);
    PropertyDescriptor descCharset =
        new TextPropertyDescriptor(PROPERTY_CHARSET, Messages.propertyLabelConvertBodyCharset);

    descriptors.put(PROPERTY_TYPE, descType);
    descriptors.put(PROPERTY_CHARSET, descCharset);
  }
 /* (non-Javadoc)
  * @see org.eclipse.ui.views.properties.IPropertySource\#setPropertyValue(java.lang.Object, java.lang.Object)
  */
 @Override
 public void setPropertyValue(Object id, Object value) {
   if (PROPERTY_TYPE.equals(id)) {
     setType(Objects.convertTo(value, String.class));
     return;
   }
   if (PROPERTY_CHARSET.equals(id)) {
     setCharset(Objects.convertTo(value, String.class));
     return;
   }
   super.setPropertyValue(id, value);
 }
Exemple #11
0
 @SuppressWarnings("rawtypes")
 @Override
 public ProcessorDefinition createCamelDefinition() {
   DelayDefinition answer = new DelayDefinition();
   answer.setExpression(toXmlPropertyValue(PROPERTY_EXPRESSION, this.getExpression()));
   answer.setExecutorServiceRef(
       toXmlPropertyValue(PROPERTY_EXECUTORSERVICEREF, this.getExecutorServiceRef()));
   answer.setAsyncDelayed(toXmlPropertyValue(PROPERTY_ASYNCDELAYED, this.getAsyncDelayed()));
   answer.setCallerRunsWhenRejected(
       toXmlPropertyValue(PROPERTY_CALLERRUNSWHENREJECTED, this.getCallerRunsWhenRejected()));
   super.savePropertiesToCamelDefinition(answer);
   return answer;
 }
Exemple #12
0
 /* (non-Javadoc)
  * @see org.eclipse.ui.views.properties.IPropertySource#setPropertyValue(java.lang.Object, java.lang.Object)
  */
 @Override
 public void setPropertyValue(Object id, Object value) {
   if (PROPERTY_EXPRESSION.equals(id)) {
     setExpression(Objects.convertTo(value, ExpressionDefinition.class));
   } else if (PROPERTY_EXECUTORSERVICEREF.equals(id)) {
     setExecutorServiceRef(Objects.convertTo(value, String.class));
   } else if (PROPERTY_ASYNCDELAYED.equals(id)) {
     setAsyncDelayed(Objects.convertTo(value, Boolean.class));
   } else if (PROPERTY_CALLERRUNSWHENREJECTED.equals(id)) {
     setCallerRunsWhenRejected(Objects.convertTo(value, Boolean.class));
   } else {
     super.setPropertyValue(id, value);
   }
 }
Exemple #13
0
  @SuppressWarnings("rawtypes")
  @Override
  protected void loadPropertiesFromCamelDefinition(ProcessorDefinition processor) {
    super.loadPropertiesFromCamelDefinition(processor);

    if (processor instanceof PolicyDefinition) {
      PolicyDefinition node = (PolicyDefinition) processor;
      this.setRef(node.getRef());
    } else {
      throw new IllegalArgumentException(
          "ProcessorDefinition not an instanceof PolicyDefinition. Was "
              + processor.getClass().getName());
    }
  }
  @SuppressWarnings("rawtypes")
  @Override
  public ProcessorDefinition createCamelDefinition() {
    LoadBalanceDefinition answer = new LoadBalanceDefinition();

    answer.setInheritErrorHandler(
        toXmlPropertyValue(
            PROPERTY_INHERITERRORHANDLER, Objects.<Boolean>getField(this, "inheritErrorHandler")));
    answer.setRef(toXmlPropertyValue(PROPERTY_REF, this.getRef()));
    answer.setLoadBalancerType(
        toXmlPropertyValue(PROPERTY_LOADBALANCERTYPE, this.getLoadBalancerType()));

    super.savePropertiesToCamelDefinition(answer);
    return answer;
  }
 /* (non-Javadoc)
  * @see org.eclipse.ui.views.properties.IPropertySource\#setPropertyValue(java.lang.Object, java.lang.Object)
  */
 @Override
 public void setPropertyValue(Object id, Object value) {
   if (PROPERTY_INHERITERRORHANDLER.equals(id)) {
     setInheritErrorHandler(Objects.convertTo(value, Boolean.class));
     return;
   }
   if (PROPERTY_REF.equals(id)) {
     setRef(Objects.convertTo(value, String.class));
     return;
   }
   if (PROPERTY_LOADBALANCERTYPE.equals(id)) {
     setLoadBalancerType(Objects.convertTo(value, LoadBalancerDefinition.class));
     return;
   }
   super.setPropertyValue(id, value);
 }
  @SuppressWarnings("rawtypes")
  @Override
  protected void loadPropertiesFromCamelDefinition(ProcessorDefinition processor) {
    super.loadPropertiesFromCamelDefinition(processor);

    if (processor instanceof LoadBalanceDefinition) {
      LoadBalanceDefinition node = (LoadBalanceDefinition) processor;

      this.setInheritErrorHandler(Objects.<Boolean>getField(node, "inheritErrorHandler"));
      this.setRef(node.getRef());
      this.setLoadBalancerType(node.getLoadBalancerType());
    } else {
      throw new IllegalArgumentException(
          "ProcessorDefinition not an instanceof LoadBalanceDefinition. Was "
              + processor.getClass().getName());
    }
  }
Exemple #17
0
  @SuppressWarnings("rawtypes")
  @Override
  protected void loadPropertiesFromCamelDefinition(ProcessorDefinition processor) {
    super.loadPropertiesFromCamelDefinition(processor);

    if (processor instanceof DelayDefinition) {
      DelayDefinition node = (DelayDefinition) processor;
      this.setExpression(node.getExpression());
      this.setExecutorServiceRef(node.getExecutorServiceRef());
      this.setAsyncDelayed(node.getAsyncDelayed());
      this.setCallerRunsWhenRejected(node.getCallerRunsWhenRejected());
    } else {
      throw new IllegalArgumentException(
          "ProcessorDefinition not an instanceof DelayDefinition. Was "
              + processor.getClass().getName());
    }
  }
  @Override
  protected void addCustomProperties(Map<String, PropertyDescriptor> descriptors) {
    super.addCustomProperties(descriptors);

    PropertyDescriptor descInheritErrorHandler =
        new BooleanPropertyDescriptor(
            PROPERTY_INHERITERRORHANDLER, Messages.propertyLabelLoadBalanceInheritErrorHandler);
    PropertyDescriptor descRef =
        new TextPropertyDescriptor(PROPERTY_REF, Messages.propertyLabelLoadBalanceRef);
    PropertyDescriptor descLoadBalancerType =
        new ComplexUnionPropertyDescriptor(
            PROPERTY_LOADBALANCERTYPE,
            Messages.propertyLabelLoadBalanceLoadBalancerType,
            LoadBalancerDefinition.class,
            new UnionTypeValue[] {
              new UnionTypeValue(
                  "failover",
                  org.apache.camel.model.loadbalancer.FailoverLoadBalancerDefinition.class),
              new UnionTypeValue(
                  "random", org.apache.camel.model.loadbalancer.RandomLoadBalancerDefinition.class),
              new UnionTypeValue(
                  "custom", org.apache.camel.model.loadbalancer.CustomLoadBalancerDefinition.class),
              new UnionTypeValue(
                  "roundRobin",
                  org.apache.camel.model.loadbalancer.RoundRobinLoadBalancerDefinition.class),
              new UnionTypeValue(
                  "sticky", org.apache.camel.model.loadbalancer.StickyLoadBalancerDefinition.class),
              new UnionTypeValue(
                  "topic", org.apache.camel.model.loadbalancer.TopicLoadBalancerDefinition.class),
              new UnionTypeValue(
                  "weighted",
                  org.apache.camel.model.loadbalancer.WeightedLoadBalancerDefinition.class),
              new UnionTypeValue(
                  "circuitBreaker",
                  org.apache.camel.model.loadbalancer.CircuitBreakerLoadBalancerDefinition.class),
            });

    descriptors.put(PROPERTY_INHERITERRORHANDLER, descInheritErrorHandler);
    descriptors.put(PROPERTY_REF, descRef);
    descriptors.put(PROPERTY_LOADBALANCERTYPE, descLoadBalancerType);
  }
Exemple #19
0
  /*
   * (non-Javadoc)
   * @see org.fusesource.ide.camel.model.AbstractNode#addCustomProperties(java.util.Map)
   */
  @Override
  protected void addCustomProperties(Map<String, PropertyDescriptor> descriptors) {
    super.addCustomProperties(descriptors);

    PropertyDescriptor descExpression =
        new ExpressionPropertyDescriptor(
            PROPERTY_EXPRESSION, Messages.propertyLabelDelayExpression);
    PropertyDescriptor descExecutorServiceRef =
        new TextPropertyDescriptor(
            PROPERTY_EXECUTORSERVICEREF, Messages.propertyLabelDelayExecutorServiceRef);
    PropertyDescriptor descAsyncDelayed =
        new BooleanPropertyDescriptor(
            PROPERTY_ASYNCDELAYED, Messages.propertyLabelDelayAsyncDelayed);
    PropertyDescriptor descCallerRunsWhenRejected =
        new BooleanPropertyDescriptor(
            PROPERTY_CALLERRUNSWHENREJECTED, Messages.propertyLabelDelayCallerRunsWhenRejected);
    descriptors.put(PROPERTY_EXPRESSION, descExpression);
    descriptors.put(PROPERTY_EXECUTORSERVICEREF, descExecutorServiceRef);
    descriptors.put(PROPERTY_ASYNCDELAYED, descAsyncDelayed);
    descriptors.put(PROPERTY_CALLERRUNSWHENREJECTED, descCallerRunsWhenRejected);
  }
Exemple #20
0
  @Override
  protected synchronized void onNodeChanged(AbstractNode node) {
    if (form != null && !form.isDisposed()) {
      try {
        form.dispose();
      } catch (Exception e) {
        // ignore any expose exceptions
      }
    }
    form = null;

    if (parent.isDisposed()) return;

    parent.setLayout(new GridLayout());
    // parent.setLayout(new GridLayout(1, false));
    parent.setLayoutData(new GridData(GridData.FILL_BOTH));

    form = toolkit.createForm(parent);
    form.setLayoutData(new GridData(GridData.FILL_BOTH));
    form.setText(EditorMessages.propertiesDetailsTitle);
    toolkit.decorateFormHeading(form);

    form.getBody().setLayout(new GridLayout(2, false));

    Composite sbody = form.getBody();

    if (node != null) {
      final IMessageManager mmng = form.getMessageManager();

      form.setText(node.getPatternName());

      IPropertyDescriptor idDescriptor = null;
      IPropertyDescriptor descriptionDescriptor = null;

      IPropertyDescriptor[] propertyDescriptors = node.getPropertyDescriptors();

      for (int i = 0; i < 2; i++) {
        for (IPropertyDescriptor descriptor : propertyDescriptors) {
          final Object id = descriptor.getId();
          if ("AbstractNode.Id".equals(id)) {
            idDescriptor = descriptor;
          } else if (NODE_DESCRIPTION.equals(id)) {
            descriptionDescriptor = descriptor;
          } else {
            String propertyName = getPropertyName(id);
            boolean mandatory =
                descriptor instanceof ExpressionPropertyDescriptor
                    || isMandatory(node, propertyName);
            if ((mandatory && i == 0) || (!mandatory && i == 1)) {
              createDecoratedTextField(descriptor, toolkit, sbody, mmng);
            }
          }
        }
      }

      if (idDescriptor != null || descriptionDescriptor != null) {
        if (idDescriptor != null) {
          createDecoratedTextField(idDescriptor, toolkit, sbody, mmng);
        }
        if (descriptionDescriptor != null) {
          createDecoratedTextField(descriptionDescriptor, toolkit, sbody, mmng);
        }
      }

      // ref ECLIPSE-1012: unsaved nodes may be disposed
      // mmng.update();
    } else {
      form.setText(EditorMessages.propertiesDetailsTitle);
    }

    layoutForm();
  }
Exemple #21
0
  protected boolean isMandatory(Object bean, String propertyName) {
    // lets look at the setter method and see if its got a @Required
    // annotation
    if (bean instanceof AbstractNode) {
      AbstractNode node = (AbstractNode) bean;
      Class<?> camelClass = node.getCamelDefinitionClass();
      if (camelClass != null) {
        XmlAccessorType accessorType = camelClass.getAnnotation(XmlAccessorType.class);
        boolean useMethods = true;
        if (accessorType != null) {
          if (accessorType.value().equals(XmlAccessType.FIELD)) {
            useMethods = false;
          }
        }
        try {
          BeanInfo beanInfo = Introspector.getBeanInfo(camelClass);
          PropertyDescriptor[] propertyDescriptors = beanInfo.getPropertyDescriptors();
          if (propertyDescriptors != null) {
            for (PropertyDescriptor propertyDescriptor : propertyDescriptors) {
              if (propertyName.equals(propertyDescriptor.getName())) {
                Method writeMethod = propertyDescriptor.getWriteMethod();
                if (writeMethod != null) {
                  Required annotation = writeMethod.getAnnotation(Required.class);
                  if (annotation != null) {
                    return true;
                  }
                  if (useMethods) {
                    XmlElement element = writeMethod.getAnnotation(XmlElement.class);
                    if (element != null && element.required()) {
                      return true;
                    }
                    XmlAttribute attribute = writeMethod.getAnnotation(XmlAttribute.class);
                    if (attribute != null && attribute.required()) {
                      return true;
                    }
                  }
                }
                break;
              }
            }
          }
          if (!useMethods) {
            Field[] fields = camelClass.getDeclaredFields();
            for (Field field : fields) {
              if (propertyName.equals(field.getName())) {
                Required annotation = field.getAnnotation(Required.class);
                if (annotation != null) {
                  return true;
                }
                XmlElement element = field.getAnnotation(XmlElement.class);
                if (element != null && element.required()) {
                  return true;
                }
                XmlAttribute attribute = field.getAnnotation(XmlAttribute.class);
                if (attribute != null && attribute.required()) {
                  return true;
                }
              }
            }
          }
        } catch (IntrospectionException e) {
          // ignore
        }
      }
    }

    // expression is mandatory on resequence
    if (node instanceof Resequence && "expression".equals(propertyName)) {
      return true;
    }

    // lets make all URI properties mandatory by default to avoid complex
    // validation with ref v uri
    boolean answer =
        ("uri".equals(propertyName) || propertyName.endsWith("Uri"))
            || (bean instanceof Aggregate && "strategyRef".equals(propertyName))
            || (bean instanceof ConvertBody && "type".equals(propertyName))
            || (bean instanceof ExpressionDefinition && isMandatoryExpression())
            || (bean instanceof Log && "message".equals(propertyName))
            || (bean instanceof Process && "ref".equals(propertyName))
            || (bean instanceof RemoveHeader && "headerName".equals(propertyName))
            || (bean instanceof RemoveProperty && "propertyName".equals(propertyName))
            || (bean instanceof SetHeader && "headerName".equals(propertyName))
            || (bean instanceof SetOutHeader && "headerName".equals(propertyName))
            || (bean instanceof SetProperty && "propertyName".equals(propertyName));
    return answer;
  }