Package org.fusesource.ide.commons.util

Examples of org.fusesource.ide.commons.util.Function1


    clearColumns();

    int bounds = 100;
    int column = 0;

    Function1 function = new Function1() {
      @Override
      public Object apply(Object element) {
        ProfileStatusDTO status = asProfileStatus(element);
        if (status != null) {
          return status.getProfile();
        }
        return null;
      }
    };
    column = addColumnFunction(250, column, function, "Profile");

    function = new FunctionInteger() {
      @Override
      public BigInteger apply(Object element) {
        ProfileStatusDTO status = asProfileStatus(element);
        if (status != null) {
          return status.getCount();
        }
        return null;
      }
    };
    column = addColumnFunction(bounds, column, function, "Count");

    function = new FunctionInteger() {
      @Override
      public BigInteger apply(Object element) {
        ProfileStatusDTO status = asProfileStatus(element);
        if (status != null) {
          return status.getMinimumInstances();
        }
        return null;
      }
    };
    column = addColumnFunction(bounds, column, function, "Minumum");

    function = new FunctionInteger() {
      @Override
      public BigInteger apply(Object element) {
        ProfileStatusDTO status = asProfileStatus(element);
        if (status != null) {
          return status.getMaximumInstances();
        }
        return null;
      }
    };
    column = addColumnFunction(bounds, column, function, "Maximum");

    function = new Function1() {
      @Override
      public Object apply(Object element) {
        ProfileStatusDTO status = asProfileStatus(element);
        if (status != null) {
          return toHealth(status);
        }
        return null;
      }
    };
    column = addColumnFunction(bounds, column, function, "Status", new HealthLabelProvider(function));

    function = new Function1() {
      @Override
      public BigDecimal apply(Object element) {
        ProfileStatusDTO status = asProfileStatus(element);
        if (status != null) {
          return status.getHealth(status.getCount());
        }
        return null;
      }
    };
    column = addColumnFunction(bounds, column, function, "Health", new PercentFunctionLabelProvider(function));

    function = new Function1() {
      @Override
      public Object apply(Object element) {
        ProfileStatusDTO status = asProfileStatus(element);
        if (status != null) {
          return status.getDependentProfiles();
View Full Code Here


    int bounds = 100;
    int column = 0;
    clearColumns();

    if (browser instanceof ITraceExchangeBrowser) {
      final Function1 function = new Function1() {
        @Override
        public Object apply(Object element) {
          Exchange exchange = Exchanges.asExchange(element);
          if (exchange != null) {
            return exchange.getExchangeIndex();
          }
          return null;
        }
      };
      column = addColumnFunction(bounds, column, function, "Trace ID");
    }

    // TODO add exchange / message ID??
    if (browser instanceof ITraceExchangeBrowser) {
      if (showTraceExchangeId) {
        final Function1 function = new Function1() {
          @Override
          public Object apply(Object element) {
            Exchange exchange = Exchanges.asExchange(element);
            if (exchange != null) {
              return exchange.getId();
            }
            return null;
          }
        };
        column = addColumnFunction(bounds, column, function, "Exchange ID");
      }
    }
    if (showBody) {
      final Function1 function = new Function1() {
        @Override
        public Object apply(Object element) {
          if (element instanceof IExchange) {
            IExchange exchange = (IExchange) element;
            String answer = MessageUIHelper.getBody(exchange);
            if (answer != null) {
              // lets replace newlines
              return answer.replace('\n', ' ');
            }
          }
          return null;
        }
      };
      column = addColumnFunction(bounds, column, function, "Message Body");
    }

    SortedSet<String> headers = new TreeSet<String>();
    for (IExchange exchange : exchanges) {
      IMessage in = exchange.getIn();
      if (in != null) {
        headers.addAll(in.getHeaders().keySet());
      }
    }
    for (final String header : headers) {
      final Function1 function = new Function1() {
        @Override
        public Object apply(Object element) {
          if (element instanceof IExchange) {
            IExchange exchange = (IExchange) element;
            IMessage in = exchange.getIn();
            if (in != null) {
              return in.getHeaders().get(header);
            }
          }
          return null;
        }
      };
      column = addColumnFunction(bounds, column, function, header);
    }
    if (browser instanceof ITraceExchangeBrowser) {
      if (showToNode) {
        final Function1 function = new Function1() {
          @Override
          public Object apply(Object element) {
            IMessage message = Exchanges.asMessage(element);
            if (message != null) {
              return message.getToNode();
            }
            return null;
          }
        };
        column = addColumnFunction(bounds, column, function, "Trace Node Id");
      }
      if (showTimestamp) {
        final Function1 function = new Function1() {
          @Override
          public Object apply(Object element) {
            IMessage message = Exchanges.asMessage(element);
            if (message != null) {
              return message.getTimestamp();
            }
            return null;
          }
        };
        column = addColumnFunction(bounds, column, function, "Trace Timestamp");
      }
      if (showRelativeTime) {
        final Function1 function = new FunctionLong() {
          @Override
          public Long apply(Object element) {
            IMessage message = Exchanges.asMessage(element);
            if (message != null) {
              return message.getRelativeTime();
            }
            return null;
          }
        };
        column = addColumnFunction(bounds, column, function, "Relative Time (ms)");
      }
      if (showElapsedTime) {
        final Function1 function = new FunctionLong() {
          @Override
          public Long apply(Object element) {
            IMessage message = Exchanges.asMessage(element);
            if (message != null) {
              return message.getElapsedTime();
View Full Code Here

    clearColumns();

    int bounds = 150;
    int column = 0;

    Function1 function = new Function1() {
      @Override
      public Object apply(Object element) {
        ComputeMetadata value = JClouds.asComputeMetadata(element);
        if (value != null) {
          return value.getId();
        }
        return null;
      }
    };
    column = addColumnFunction(bounds, column, function, "Id");

    function = new Function1() {
      @Override
      public Object apply(Object element) {
        ComputeMetadata value = JClouds.asComputeMetadata(element);
        if (value != null) {
          return value.getName();
        }
        return null;
      }
    };
    column = addColumnFunction(bounds, column, function, "Name");

    function = new Function1() {
      @Override
      public Object apply(Object element) {
        NodeMetadata value = JClouds.asNodeMetadata(element);
        if (value != null) {
          return value.getStatus();
        }
        return null;
      }
    };
    column = addColumnFunction(bounds, column, function, "State");

    function = new Function1() {
      @Override
      public Object apply(Object element) {
        NodeMetadata value = JClouds.asNodeMetadata(element);
        if (value != null) {
          Hardware hardware = value.getHardware();
          if (hardware != null) {
            return JClouds.text(hardware);
          }
        }
        return null;
      }
    };
    column = addColumnFunction(bounds, column, function, "Hardware");

    function = new Function1() {
      @Override
      public Object apply(Object element) {
        NodeMetadata value = JClouds.asNodeMetadata(element);
        if (value != null) {
          return value.getImageId();
        }
        return null;
      }
    };
    column = addColumnFunction(bounds, column, function, "Image");

    function = new Function1() {
      @Override
      public Object apply(Object element) {
        NodeMetadata value = JClouds.asNodeMetadata(element);
        if (value != null) {
          OperatingSystem operatingSystem = value.getOperatingSystem();
          if (operatingSystem != null) {
            return JClouds.text(operatingSystem);
          }
        }
        return null;
      }
    };
    column = addColumnFunction(bounds, column, function, "OS");

    function = new Function1() {
      @Override
      public Object apply(Object element) {
        NodeMetadata value = JClouds.asNodeMetadata(element);
        if (value != null) {
          return value.getGroup();
        }
        return null;
      }
    };
    column = addColumnFunction(bounds, column, function, "Group");

    function = new Function1() {
      @Override
      public Object apply(Object element) {
        NodeMetadata value = JClouds.asNodeMetadata(element);
        if (value != null) {
          return joinSpaces(value.getPublicAddresses());
        }
        return null;
      }
    };
    column = addColumnFunction(bounds, column, function, "Public IPs");

    function = new Function1() {
      @Override
      public Object apply(Object element) {
        NodeMetadata value = JClouds.asNodeMetadata(element);
        if (value != null) {
          return joinSpaces(value.getPrivateAddresses());
        }
        return null;
      }
    };
    column = addColumnFunction(bounds, column, function, "Private IPs");

    function = new Function1() {
      @Override
      public Object apply(Object element) {
        Location value = JClouds.asLocation(element);
        if (value != null) {
          return value.getDescription();
        }
        return null;
      }
    };
    column = addColumnFunction(bounds, column, function, "Location");

    function = new Function1() {
      @Override
      public Object apply(Object element) {
        ComputeMetadata value = JClouds.asComputeMetadata(element);
        if (value != null) {
          return value.getUri();
        }
        return null;
      }
    };
    column = addColumnFunction(bounds, column, function, "URI");

    function = new Function1() {
      @Override
      public Object apply(Object element) {
        ComputeMetadata value = JClouds.asComputeMetadata(element);
        if (value != null) {
          return joinSpaces(value.getTags());
View Full Code Here

    clearColumns();

    int bounds = 150;
    int column = 0;

    Function1 function = new Function1() {
      @Override
      public Object apply(Object element) {
        CloudDetails exchange = CloudDetails.asCloudDetails(element);
        if (exchange != null) {
          return exchange.getName();
        }
        return null;
      }
    };
    column = addColumnFunction(bounds, column, function, "Name");

    function = new Function1() {
      @Override
      public Object apply(Object element) {
        CloudDetails exchange = CloudDetails.asCloudDetails(element);
        if (exchange != null) {
          return exchange.getProviderName();
        }
        return null;
      }
    };
    column = addColumnFunction(bounds, column, function, "Provider");

    function = new Function1() {
      @Override
      public Object apply(Object element) {
        CloudDetails exchange = CloudDetails.asCloudDetails(element);
        if (exchange != null) {
          return exchange.getApiName();
        }
        return null;
      }
    };
    column = addColumnFunction(bounds, column, function, "Api");
   
    function = new Function1() {
      @Override
      public Object apply(Object element) {
        CloudDetails exchange = CloudDetails.asCloudDetails(element);
        if (exchange != null) {
          return exchange.getEndpoint();
        }
        return null;
      }
    };
    column = addColumnFunction(bounds, column, function, "Endpoint");
   
    function = new Function1() {
      @Override
      public Object apply(Object element) {
        CloudDetails exchange = CloudDetails.asCloudDetails(element);
        if (exchange != null) {
          return exchange.getIdentity();
View Full Code Here

        clearColumns();

        int bounds = 100;
        int column = 0;

        Function1 function = new Function1() {
            @Override
            public Object apply(Object element) {
                ProfileStatusDTO status = asProfileStatus(element);
                if (status != null) {
                    return status.getProfile();
                }
                return null;
            }
        };
        column = addColumnFunction(250, column, function, "Profile");

        function = new FunctionInteger() {
            @Override
            public BigInteger apply(Object element) {
                ProfileStatusDTO status = asProfileStatus(element);
                if (status != null) {
                    return status.getCount();
                }
                return null;
            }
        };
        column = addColumnFunction(bounds, column, function, "Count");

        function = new FunctionInteger() {
            @Override
            public BigInteger apply(Object element) {
                ProfileStatusDTO status = asProfileStatus(element);
                if (status != null) {
                    return status.getMinimumInstances();
                }
                return null;
            }
        };
        column = addColumnFunction(bounds, column, function, "Minumum");

        function = new FunctionInteger() {
            @Override
            public BigInteger apply(Object element) {
                ProfileStatusDTO status = asProfileStatus(element);
                if (status != null) {
                    return status.getMaximumInstances();
                }
                return null;
            }
        };
        column = addColumnFunction(bounds, column, function, "Maximum");

        function = new Function1() {
            @Override
            public Object apply(Object element) {
                ProfileStatusDTO status = asProfileStatus(element);
                if (status != null) {
                    return toHealth(status);
                }
                return null;
            }
        };
        column = addColumnFunction(bounds, column, function, "Status", new HealthLabelProvider(function));

        function = new Function1() {
            @Override
            public BigDecimal apply(Object element) {
                ProfileStatusDTO status = asProfileStatus(element);
                if (status != null) {
                    return status.getHealth(status.getCount());
                }
                return null;
            }
        };
        column = addColumnFunction(bounds, column, function, "Health", new PercentFunctionLabelProvider(function));

        function = new Function1() {
            @Override
            public Object apply(Object element) {
                ProfileStatusDTO status = asProfileStatus(element);
                if (status != null) {
                    return status.getDependentProfiles();
View Full Code Here

        clearColumns();

        int bounds = 100;
        int column = 0;

        Function1 function = new Function1() {
            @Override
            public Object apply(Object element) {
                VersionDTO version = asVersionDTO(element);
                if (version != null) {
                    return version.getId();
                }
                return null;
            }
        };
        column = addColumnFunction(250, column, function, "Id");

        function = new Function1() {
            @Override
            public Boolean apply(Object element) {
              VersionDTO version = asVersionDTO(element);
                if (version != null) {
                    return version.isDefaultVersion();
View Full Code Here

TOP

Related Classes of org.fusesource.ide.commons.util.Function1

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.