Package com.onpositive.semantic.model.binding

Examples of com.onpositive.semantic.model.binding.Binding


    for (java.lang.reflect.Field f : fs) {
      String chId = f.getName();
      Class type = f.getType();

      Binding binding = bnd.getBinding(chId);
      binding.setName(chId);
      Object adapter = new ClassAdapterFactory().getAdapter(type,
          IValidator.class);
      if (adapter != null) {
        binding.setAdapter(IValidator.class, (IValidator) adapter);
      }
      binding.setAutoCommit(false);

      if (type == String.class) {
        OneLineTextElement<String> t = new OneLineTextElement<String>();
        t.setBinding(binding);
        editor.add(t);
      } else if (Number.class.isAssignableFrom(type)
          || type.isPrimitive()) {
        OneLineTextElement<Number> t = new OneLineTextElement<Number>();
        final Class tt = type;
        binding.addValidator(new ValidatorAdapter() {

          public CodeAndMessage isValid(IBinding context,
              Object object) {
            if (object == null) {
              return CodeAndMessage.OK_MESSAGE;
            }
            try {
              if (object instanceof String) {
                if (tt == Double.class) {
                  Double.parseDouble((String) object);
                } else if (tt == Long.class) {
                  Long.parseLong((String) object);
                } else if (tt == Float.class) {
                  Float.parseFloat((String) object);
                } else if (tt == Integer.class) {
                  Integer.parseInt((String) object);
                }
              } else {
                if (!Number.class.isAssignableFrom(object
                    .getClass())) {
                  return CodeAndMessage
                      .errorMessage("The number should be in this place");
                }
              }
              return CodeAndMessage.OK_MESSAGE;
            } catch (NumberFormatException e) {
              return CodeAndMessage
                  .errorMessage("The number should be in this place");
            }
            // return super.isValid(context, object);
          }

        });
        t.setBinding(binding);
        editor.add(t);

      } else if (type == Boolean.class) {
        ComboEnumeratedValueSelector<Boolean> t = new ComboEnumeratedValueSelector<Boolean>();
        t.setBinding(binding);
        editor.add(t);
      } else if (type == Text.class) {
        if (text == null) {
          text = new CTabFolderElement();
          text.setBordered(true);
          editor.setData("text", text);
          editor.add(text);
        }
        createText(editor, text, binding, false);
      } else if (type == Link.class) {
        createLink(editor, binding);
      } else if (type == Category.class) {
        createCategory(editor, binding);
      } else if (type == Email.class) {
        createEmail(editor, binding);
      } else if (type == PostalAddress.class) {
        createPostalAddress(editor, binding);
      } else if (type == PhoneNumber.class) {
        createPhoneNumber(editor, binding);
      } else if (type == Date.class) {
        createDate(editor, binding);
      } else if (type == IMHandle.class) {
        createIMHandle(editor, binding);
      } else if (type == GeoPt.class) {
        createGeoPt(editor, binding);
      } else if (type == User.class) {
        createUser(editor, binding);
      } else if (type == Blob.class || type == ShortBlob.class) {
        createBlob(editor, type, binding, project);
      } else if (type == Rating.class) {
        createRating(editor, binding);
      } else if (type == Key.class) {
        OneLineTextElement<String> t = new OneLineTextElement<String>();
        t.setBinding(binding);
        editor.add(t);
        // GAEField ff = f.new GAEField(chId, false);
        // createKey(editor, binding, ff);
      } else {
        if (!binding.allowsMultiValues()) {
          OneLineTextElement<String> t = new OneLineTextElement<String>();
          t.setBinding(binding);
          binding.allowsMultiValues();
          binding.setReadOnly(true);
          editor.add(t);
        } else {
          if (text == null) {
            text = new CTabFolderElement();
            text.setBordered(true);
            editor.setData("text", text);
            editor.add(text);
          }
          Container m = new Container();
          m.setLayout(new GridLayout(1, false));
          m.setCaption(binding.getName());
          final ListEnumeratedValueSelector<Object> v = new ListEnumeratedValueSelector<Object>();
          binding.addValueListener(new IValueListener<Object>() {

            public void valueChanged(Object oldValue,
                Object newValue) {
              return;
View Full Code Here


      if (f.isKey()) {
        continue;
      } else {
        Class<?> type = f.getType();
        if (type != null) {
          final Binding binding = bnd.getBinding(f.name);
          binding.setValue(e.getProperty(f.name), null);
          Object adapter = new ClassAdapterFactory().getAdapter(type,
              IValidator.class);
          if (adapter != null) {
            binding.setAdapter(IValidator.class,
                (IValidator) adapter);
          }
          adapter = new ClassAdapterFactory().getAdapter(type,
              ILabelLookup.class);
          if (adapter != null) {
            binding.setAdapter(ILabelLookup.class,
                (ILabelLookup) adapter);
          }
          adapter = new ClassAdapterFactory().getAdapter(type,
              IRealmProvider.class);
          if (adapter != null) {

            binding.setAdapter(IRealmProvider.class,
                (IRealmProvider) adapter);
          } else {
            IRealm<?> c = facade.getRealm(f);
            if (c != null) {
              binding.setRealm(c);
            }
          }
          binding.setReadOnly(false);
          binding.setName(f.getTitle());

          if (type == String.class) {
            OneLineTextElement<String> t = new OneLineTextElement<String>();
            t.setBinding(binding);
            editor.add(t);
View Full Code Here

    }
    manager.add(item);
    manager.add(new Action("Configure visible columns") {
      public void run() {
        CompositeEditor editor = new CompositeEditor();
        final Binding bnd = new Binding(String.class);
        bnd.setName("Visible Properties");
        bnd.setDescription("Please select properties which should be displayed in this view");
        editor.setBinding(bnd);

        final ListEnumeratedValueSelector<Field> vl = new ListEnumeratedValueSelector<Field>();
        vl.getLayoutHints().setMinimumSize(new Point(300, 500));
        vl.getLayoutHints().setHint(new Point(300, 500));
View Full Code Here

TOP

Related Classes of com.onpositive.semantic.model.binding.Binding

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.