Package org.eclipse.e4.core.contexts

Examples of org.eclipse.e4.core.contexts.IEclipseContext


    return null;
  }

  public void setValue(Object target, Object value) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException, SecurityException, NoSuchFieldException {
    if (!(value instanceof Style)) {
      throw new XWTException("Style is expected.");
    }
    Style style = (Style) value;
    style.apply(target);
  }
View Full Code Here


      if (!ObjectUtil.isAssignableFrom(fieldType, value.getClass())) {
        IConverter converter = XWT.findConvertor(valueType, fieldType);
        if (converter != null) {
          value = converter.convert(value);
        } else {
          throw new XWTException("Converter " + valueType.getName() + "->" + fieldType.getName());
        }
      }
    }
    field.set(target, value);
    fireSetPostAction(target, this, value);
View Full Code Here

            String className = path.substring(0, index);
            segment = path.substring(index + 1);
            type = dataProvider.getModelService().loadModelType(
                className);
            if (type == null) {
              throw new XWTException("Class " + className
                  + " not found");
            }
            dataProvider = XWT.findDataProvider(type);
          }
        }

        type = dataProvider.getDataType(segment);

        if (type != null) {
          dataProvider = XWT.findDataProvider(type);
          if (dataProvider == null) {
            throw new XWTException(
                "Data probider is not found for the type "
                    + type.toString());
          }
        } else {
          throw new XWTException(
              "Type is not found for the property " + segment);
        }
      }
      String segment = segments[last];

      int length = segment.length();
      if (length > 1 && segment.charAt(0) == '('
          && segment.charAt(length - 1) == ')') {
        // It is class
        String path = segment.substring(1, segment.length() - 1);
        int index = path.lastIndexOf('.');
        if (index != -1) {
          String className = path.substring(0, index);
          segment = path.substring(index + 1);
          type = dataProvider.getModelService().loadModelType(
              className);
          if (type == null) {
            throw new XWTException("Class " + className
                + " not found");
          }
          dataProvider = XWT.findDataProvider(type);
        }
      }
View Full Code Here

              if (type != null) {
                segment = null;
              }
            }
            if (type == null) {
              throw new XWTException("Class " + className
                  + " not found");
            }
            dataProvider = XWT.findDataProvider(type);
          }
        }
      }
      if (currentPath == null) {
        currentPath = segment;
      } else if (segment != null) {
        currentPath = currentPath + '.' + segment;
      }

      IObservable segmentValue = scopeManager.getObservableValue(widget,
          value, currentPath);
      try {
        if (segmentValue == null) {
          if (segment != null) {
            segmentValue = createValueProperty(dataValue, segment,
                type);
            if (segmentValue == null) {
              throw new XWTException(" Property " + segment
                  + " is not found in "
                  + expressionPath.getFullPath());
              // maybe to
              // raise an
              // exception
            }
            scopeManager.addObservableValue(widget, value,
                currentPath, segmentValue);
          } else  if (dataValue instanceof IObservable){
            segmentValue = (IObservable)dataValue;
          }
        }
        else if (segment == null && type != null) {
          if (segmentValue instanceof TypedViewerObservableValueDecorator) {
            TypedViewerObservableValueDecorator typedViewerObservableValueDecorator = (TypedViewerObservableValueDecorator) segmentValue;
            typedViewerObservableValueDecorator.setElementType(type);
          }
        }
      } catch (IllegalArgumentException e) {
        // Property is not found
        String message = e.getMessage();
        if (!message.startsWith("Could not find property with name")) {
          throw e;
        }
        throw new XWTException(" Property " + segment
            + " is not found in " + expressionPath.getFullPath()); // maybe
                                        // to
                                        // raise
                                        // an
        // exception
View Full Code Here

      switch (array[i]) {
      case '}':
        {
          Character character = separators.pop();
          if (character.charValue() != '{') {
            throw new XWTException("Syntax error is binding expression " + value + " at " + i);
          }
        }
        level --;
        break;
      case ']':
        {
          Character character = separators.pop();
          if (character.charValue() != '[') {
            throw new XWTException("Syntax error is binding expression " + value + " at " + i);
          }
        }
        level --;
        break;
      case ')':
        {
          Character character = separators.pop();
          if (character.charValue() != '(') {
            throw new XWTException("Syntax error is binding expression " + value + " at " + i);
          }
        }
        level --;
        if (level == 0) {
          stripEnd = i - 1;
View Full Code Here

      Element element = null;
      if (stream == null) {
        element = manager.load(input, (IBeforeParsingCallback) options.get(IXWTLoader.BEFORE_PARSING_CALLBACK));
      }
      else {
        IBeforeParsingCallback callback = (IBeforeParsingCallback) options.get(IXWTLoader.BEFORE_PARSING_CALLBACK);
        InputStream inputStream = stream;
        if (callback != null) {
          int size = stream.read();
          byte[] buffer = new byte[size];
          stream.read(buffer);
          String content = new String(buffer);
          stream.close();
          content = callback.onParsing(content);
          inputStream = new ByteArrayInputStream(content.getBytes());
          element = manager.load(stream, input);         
        }
        element = manager.load(inputStream, input);
      }
View Full Code Here

    if (source == target
        || (source != Object.class && source.isAssignableFrom(target))) {
      return ObjectToObject.instance;
    }
    if (String.class == source && target.isEnum()) {
      return new StringToEnum(target);
    }
    ValueConvertorRegister convertorRegister = (ValueConvertorRegister)
        getService(ValueConvertorRegister.class);
    if (convertorRegister == null) {
      return null;
View Full Code Here

    if (dataContext == null) {
      Object dataContextHost = getDataContextHost();
      if (dataContextHost != null) {
        dataContext = UserData.getLocalDataContext(dataContextHost);
        if (dataContext instanceof IDynamicBinding) {
          IDynamicBinding dynamicBinding = (IDynamicBinding) dataContext;
          Object boundSource = dynamicBinding.createBoundSource();
          if (boundSource != null) {
            dataContext = boundSource;
          }
        }
      }
View Full Code Here

          inputStream = new ByteArrayInputStream(content.getBytes());
          element = manager.load(stream, input);         
        }
        element = manager.load(inputStream, input);
      }
      IRenderingContext context = new ExtensionContext(loadingContext,
          manager, manager.getRootElement().getNamespace());
      Object visual = createCLRElement(context, element, options);
      if (TRACE_BENCH) {
        System.out.println("Loaded: "
            + (System.currentTimeMillis() - start) + "  "
View Full Code Here

  public void registerService(Class<?> serviceType, Object service) {
    registrations.put(serviceType, service);
  }

  protected Object createCLRElement(IRenderingContext context, Element element, Map<String, Object> options) {
    IVisualElementLoader loader = findElementLoader(element);
    if (loader != null) {
      return loader.createCLRElement(element, options);
    }
    loader = createElementLoader(context, element);
    Object visualObject = loader.createCLRElement(element, options);
    removeElementLoader(element);
    return visualObject;
  }
View Full Code Here

TOP

Related Classes of org.eclipse.e4.core.contexts.IEclipseContext

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.