Package org.fusesource.ide.commons.util

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


  @Override
  protected void createColumns() {
    clearColumns();
    int bounds = 100;
    int column = 0;
    Function1 function = new Function1() {
      @Override
      public Object apply(Object element) {
        ProfileStatus status = asProfileStatus(element);
        if (status != null) {
          return status.getProfile();
        }
        return null;
      }
    };
    column = addColumnFunction(250, column, function, "Profile");
    function = new FunctionInteger() {
      @Override
      public Integer apply(Object element) {
        ProfileStatus status = asProfileStatus(element);
        if (status != null) {
          return status.getCount();
        }
        return null;
      }
    };
    column = addColumnFunction(bounds, column, function, "Count");
    function = new FunctionInteger() {
      @Override
      public Integer apply(Object element) {
        ProfileStatus status = asProfileStatus(element);
        if (status != null) {
          return status.getMinimumInstances();
        }
        return null;
      }
    };
    column = addColumnFunction(bounds, column, function, "Minumum");
    function = new FunctionInteger() {
      @Override
      public Integer apply(Object element) {
        ProfileStatus 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) {
        ProfileStatus 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 Double apply(Object element) {
        ProfileStatus 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) {
        ProfileStatus status = asProfileStatus(element);
        if (status != null) {
          return status.getDependentProfiles();
View Full Code Here


  @Override
  protected void createColumns() {
    int bounds = 100;
    int column = 0;
    clearColumns();
    Function1 function = new Function1() {
      @Override
      public Object apply(Object element) {
        LogEvent log = toLogEvent(element);
        if (log != null) {
          return log.getTimestamp();
        }
        return null;
      }
    };
    column = addColumnFunction(bounds, column, function, "Time");
    function = new Function1() {
      @Override
      public Object apply(Object element) {
        LogEvent log = toLogEvent(element);
        if (log != null) {
          return log.getHost();
        }
        return null;
      }
    };
    column = addColumnFunction(bounds, column, function, "Host");
    function = new Function1() {
      @Override
      public Object apply(Object element) {
        LogEvent log = toLogEvent(element);
        if (log != null) {
          return log.getContainerName();
        }
        return null;
      }
    };
    column = addColumnFunction(bounds, column, function, "Container");
    function = new Function1() {
      @Override
      public Object apply(Object element) {
        LogEvent log = toLogEvent(element);
        if (log != null) {
          return log.getLevel();
        }
        return null;
      }
    };
    column = addColumnFunction(bounds, column, function, "Level", new LogLevelImageProvider());
    function = new Function1() {
      @Override
      public Object apply(Object element) {
        LogEvent log = toLogEvent(element);
        if (log != null) {
          return log.getLogger();
        }
        return null;
      }
    };
    column = addColumnFunction(bounds, column, function, "Logger");
    function = new Function1() {
      @Override
      public Object apply(Object element) {
        LogEvent log = toLogEvent(element);
        if (log != null) {
          return log.getThread();
        }
        return null;
      }
    };
    column = addColumnFunction(bounds, column, function, "Thread");
    function = new Function1() {
      @Override
      public Object apply(Object element) {
        LogEvent log = toLogEvent(element);
        if (log != null) {
          return log.getMessage();
        }
        return null;
      }
    };
    column = addColumnFunction(bounds, column, function, "Message");
    function = new Function1() {
      @Override
      public Object apply(Object element) {
        return element;
      }
    };
    column = addColumnFunction(bounds, column, function, "Location", new LocationLabelProvider());
    function = new Function1() {
      @Override
      public Object apply(Object element) {
        LogEvent log = toLogEvent(element);
        if (log != null) {
          return log.getProperties();
        }
        return null;
      }
    };
    column = addColumnFunction(bounds, column, function, "Properties");
    function = new Function1() {
      @Override
      public Object apply(Object element) {
        LogEvent log = toLogEvent(element);
        if (log != null) {
          return log.getSeq();
        }
        return null;
      }
    };
    column = addColumnFunction(bounds, column, function, "ID");
    function = new Function1() {
      @Override
      public Object apply(Object element) {
        LogEvent log = toLogEvent(element);
        if (log != null && log.getException() != null) {
          StringBuffer sb = new StringBuffer();
View Full Code Here

      return;
    }
    String text = "";
    double percent = 0;
    if (labelProvider instanceof Function1) {
      Function1 fn = (Function1) labelProvider;
      Object value = fn.apply(element);
      if (value != null) {
        text = value.toString();
        double d = doubleValue(value);

        // lets find the maximum value
View Full Code Here

      IPropertyDescriptor[] descriptors = propertySource.getPropertyDescriptors();
      if (descriptors != null) {
        for (final IPropertyDescriptor descriptor : descriptors) {
          final Object id = descriptor.getId();
          String name = PropertyDescriptors.getReadablePropertyName(descriptor);
          Function1 function = new Function1WithReturnType() {
            @Override
            public Object apply(Object object) {
              if (object instanceof IPropertySource) {
                IPropertySource property = (IPropertySource) object;
                return property.getPropertyValue(id);
              }
              return null;
            }

            @Override
            public Class<?> getReturnType() {
              return PropertyDescriptors.getPropertyType(descriptor);
            }
          };
          headers.put(name, function);
        }
      }
    }
    Set<Entry<String, Function1>> entrySet = headers.entrySet();
    for (Entry<String, Function1> entry : entrySet) {
      String header = entry.getKey();
      Function1 function = entry.getValue();
      addFunction(function);
      TreeViewerColumn col = createTreeViewerColumn(header, bounds, column++);
      col.setLabelProvider(new FunctionColumnLabelProvider(function));
    }
  }
View Full Code Here

        IPropertyDescriptor[] descriptors = propertySource.getPropertyDescriptors();
        if (descriptors != null) {
          for (final IPropertyDescriptor descriptor : descriptors) {
            final Object id = descriptor.getId();
            String name = PropertyDescriptors.getReadablePropertyName(descriptor);
            Function1 function = new Function1WithReturnType() {
              @Override
              public Object apply(Object object) {
                IPropertySource property = PropertySources.asPropertySource(object);
                if (property != null) {
                  return property.getPropertyValue(id);
                }
                return null;
              }

              @Override
              public Class<?> getReturnType() {
                return PropertyDescriptors.getPropertyType(descriptor);
              }
            };
            headers.put(name, function);
          }
        }
      }
      int idx = 0;
      boolean pickedSortColumn = false;
      Set<Entry<String, Function1>> entrySet = headers.entrySet();
      for (Entry<String, Function1> entry : entrySet) {
        String header = entry.getKey();
        if (!pickedSortColumn && isDefaultSortColumn(header)) {
          setDefaultSortColumnIndex(idx);
          pickedSortColumn = true;
        }
        Function1 function = entry.getValue();
        addFunction(function);
        TableViewerColumn col = createTableViewerColumn(header, bounds, column++);
        col.setLabelProvider(createColumnLabelProvider(header, function));
        idx++;
      }
View Full Code Here

    protected int compareByColumn(Object e1, Object e2, int sortIndex) {
      int answer = 0;
      if (sortIndex < 0 || sortIndex >= functions.size()) {
        answer = compareDefaultSortColumn(e1, e2, sortIndex);
      } else {
        Function1 function = functions.get(sortIndex);
        Object v1 = function.apply(e1);
        Object v2 = function.apply(e2);
        answer = Objects.compare(v1, v2);
        if (answer == 0) {
          answer = compareDefaultSortColumn(e1, e2, sortIndex);
        }
      }
View Full Code Here

  @Override
  protected void createColumns() {
    clearColumns();
    int bounds = 100;
    int column = 0;
    Function1 function = new Function1() {
      @Override
      public Object apply(Object element) {
        ProfileStatus status = asProfileStatus(element);
        if (status != null) {
          return status.getProfile();
        }
        return null;
      }
    };
    column = addColumnFunction(250, column, function, "Profile");
    function = new FunctionInteger() {
      @Override
      public Integer apply(Object element) {
        ProfileStatus status = asProfileStatus(element);
        if (status != null) {
          return status.getCount();
        }
        return null;
      }
    };
    column = addColumnFunction(bounds, column, function, "Count");
    function = new FunctionInteger() {
      @Override
      public Integer apply(Object element) {
        ProfileStatus status = asProfileStatus(element);
        if (status != null) {
          return status.getMinimumInstances();
        }
        return null;
      }
    };
    column = addColumnFunction(bounds, column, function, "Minumum");
    function = new FunctionInteger() {
      @Override
      public Integer apply(Object element) {
        ProfileStatus 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) {
        ProfileStatus 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 Double apply(Object element) {
        ProfileStatus 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) {
        ProfileStatus status = asProfileStatus(element);
        if (status != null) {
          return status.getDependentProfiles();
View Full Code Here

  protected void createColumns() {
    int bounds = 100;
    int column = 0;
    clearColumns();

    Function1 function = new Function1() {
      @Override
      public Object apply(Object element) {
        SetHeaderDefinition sh = DetailsSection.toSetHeaderDefinition(element);
        if (sh != null) {
          return sh.getHeaderName();
        }
        return null;
      }
    };
    column = addColumnFunction(bounds, column, function, "Header");

    function = new Function1() {
      @Override
      public Object apply(Object element) {
        SetHeaderDefinition sh = DetailsSection.toSetHeaderDefinition(element);
        if (sh != null) {
          LanguageExpressionBean expression = LanguageExpressionBean.toLanguageExpressionBean(sh.getExpression());
          if (expression != null) {
            return expression.getExpression();
          }
        }
        return null;
      }
    };
    column = addColumnFunction(bounds, column, function, "Expression");

    function = new Function1() {
      @Override
      public Object apply(Object element) {
        SetHeaderDefinition sh = DetailsSection.toSetHeaderDefinition(element);
        if (sh != null) {
          LanguageExpressionBean expression = LanguageExpressionBean.toLanguageExpressionBean(sh.getExpression());
View Full Code Here

  protected void createColumns() {
    int bounds = 100;
    int column = 0;
    clearColumns();

    Function1 function = new Function1() {
      @Override
      public Object apply(Object element) {
        LogEventDTO log = (LogEventDTO)element;
        if (log != null) {
          return log.getEventTimestamp();
        }
        return null;
      }
    };
    column = addColumnFunction(bounds, column, function, "Time");
    function = new Function1() {
      @Override
      public Object apply(Object element) {
        LogEventDTO log = (LogEventDTO)element;
        if (log != null) {
          return log.getEventhost();
        }
        return null;
      }
    };
    column = addColumnFunction(bounds, column, function, "Host");


    function = new Function1() {
      @Override
      public Object apply(Object element) {
        LogEventDTO log = (LogEventDTO)element;
        if (log != null) {
          return log.getContainer();
        }
        return null;
      }
    };
    column = addColumnFunction(bounds, column, function, "Container");


    function = new Function1() {
      @Override
      public Object apply(Object element) {
        LogEventDTO log = (LogEventDTO)element;
        if (log != null) {
          return log.getLogLevel();
        }
        return null;
      }
    };
    column = addColumnFunction(bounds, column, function, "Level", new LogLevelImageProvider());

    function = new Function1() {
      @Override
      public Object apply(Object element) {
        LogEventDTO log = (LogEventDTO)element;
        if (log != null) {
          return log.getLogger();
        }
        return null;
      }
    };
    column = addColumnFunction(bounds, column, function, "Category");

    function = new Function1() {
      @Override
      public Object apply(Object element) {
        LogEventDTO log = (LogEventDTO)element;
        if (log != null) {
          return log.getThreadName();
        }
        return null;
      }
    };
    column = addColumnFunction(bounds, column, function, "Thread");

    function = new Function1() {
      @Override
      public Object apply(Object element) {
        LogEventDTO log = (LogEventDTO)element;
        if (log != null) {
          String msg = log.getLogMessage();
          if (msg.indexOf('\n') != -1) {
            return log.getLogMessage().substring(0, log.getLogMessage().indexOf('\n'));
          }
          return log.getLogMessage();
        }
        return null;
      }
    };
    column = addColumnFunction(bounds, column, function, "Message");

    function = new Function1() {
      @Override
      public Object apply(Object element) {
        return element;
      }
    };
    column = addColumnFunction(bounds, column, function, "Location", new LocationLabelProvider());

    function = new Function1() {
      @Override
      public Object apply(Object element) {
        LogEventDTO log = (LogEventDTO)element;
        if (log != null) {
          return log.getPropertiesMap();
        }
        return null;
      }
    };
    column = addColumnFunction(bounds, column, function, "Properties");

    function = new Function1() {
      @Override
      public Object apply(Object element) {
        LogEventDTO log = (LogEventDTO)element;
        if (log != null) {
          return log.getSeq();
        }
        return null;
      }
    };
    column = addColumnFunction(bounds, column, function, "ID");

    function = new Function1() {
      @Override
      public Object apply(Object element) {
        LogEventDTO log = (LogEventDTO)element;
        if (log != null) {
          return log.getException();
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.