Package com.onpositive.commons.elements

Examples of com.onpositive.commons.elements.Container


    menuManager.add(new Action("Settings") {
      public void run() {
        final Binding bnd=new Binding(LogViewPart.this);
        bnd.setAutoCommit(false);
        bnd.setReadOnly(false);
        Container r=new Container();
        IContainerLayoutManager ca=new OneElementOnLineLayouter();
        OneLineTextElement<Integer>str=new OneLineTextElement<Integer>(bnd.getBinding("days"));
        ComboEnumeratedValueSelector<Integer>sev=new ComboEnumeratedValueSelector<Integer>();
        sev.setOrdered(true);
        sev.setBinding(bnd.getBinding("minSeverityToFetch"));
        r.add(str);
        r.add(sev);       
        Container buttons=new Container();       
        HorizontalLayouter horizontalLayouter = new HorizontalLayouter();
        buttons.setLayoutManager(horizontalLayouter);
        r.add(buttons);
        final InputElementDialog inputElementDialog = new InputElementDialog(bnd,r,"Settings","you may configure settings here");
        ButtonSelector bs=new ButtonSelector();
        bs.setValue(new Runnable() {
          public void run() {
            bnd.commit();
            inputElementDialog.close();
          }
        });
        bs.setText("Apply");
        buttons.add(bs);       
        ButtonSelector bs1=new ButtonSelector();
        bs1.setValue(new Runnable() {
          public void run() {
            inputElementDialog.close();
          }
        });
        //buttons.add(bs);
        buttons.add(bs1);
        bs1.setText("Cancel");
        r.setLayoutManager(ca);
        DisposeBindingListener.linkBindingLifeCycle(bnd, r);
        inputElementDialog.open();
      }
View Full Code Here


    r.add(element);
    r.add(element1);
    r.add(elementL);
    r.add(elementP);

    Container element2 = new Container(Container.GROUP);
    element2.getLayoutHints().setGrabHorizontal(true);
    element2.setLayoutManager(new HorizontalLayouter());
    element2.setText("Class Path");

    final ListEnumeratedValueSelector<String> classpath = new ListEnumeratedValueSelector<String>(
        bndr.getBinding("jdbcDriverClassPath")) {

      protected void updateSize(TableViewer newCheckList) {
        // TODO Auto-generated method stub
        TableColumn tableColumn = (TableColumn) columnWidget;
        tableColumn.pack();
        // int width = tableColumn.getWidth();
        // int width2 = newCheckList.getTable().getBounds().width;
        // if (width < width2) {
        // ((TableColumn) columnWidget).setWidth(width2 - 5);
        // }
      }
    };
    ButtonSelector addButton = new ButtonSelector();
    addButton.setText("add jar");
    GridData addDat = new GridData(GridData.FILL_HORIZONTAL);
    addButton.setLayoutData(addDat);
    addButton.addListener(SWT.Selection, new SWTEventListener<Button>() {

      public void handleEvent(AbstractUIElement<Button> element,
          Event event) {

        FileDialog dialog = new FileDialog(Display.getCurrent()
            .getActiveShell(), SWT.MULTI | SWT.SELECTED);
        dialog.setFilterExtensions(new String[] { "*.jar" });
        dialog.setFilterNames(new String[] { "*.jar" });
        dialog.setOverwrite(false);
        dialog.open();

        String[] names = dialog.getFileNames();
        String path = dialog.getFilterPath();

        for (String name : names) {
          String result = path + File.separator + name;
          classpath.addValue(result);
          ((TableViewer) classpath.getViewer()).getTable()
              .getParent().layout();
        }
      }
    });

    ButtonSelector removeButton = new ButtonSelector();
    removeButton.setText("remove jar");
    GridData removeDat = new GridData(GridData.FILL_HORIZONTAL);
    removeButton.setLayoutData(removeDat);

    removeButton.addListener(SWT.Selection, new SWTEventListener<Button>() {

      public void handleEvent(AbstractUIElement<Button> element,
          Event event) {
        for (Iterator i = classpath.getSelection().iterator(); i
            .hasNext();) {
          String str = (String) i.next();
          classpath.removeValue(str);
        }
      }
    });
    Container buttonContainer = new Container();
    buttonContainer.setLayout(new GridLayout(1, true));
    buttonContainer.getLayoutHints().setGrabHorizontal(false);
    buttonContainer.setBordered(false);
    buttonContainer.add(addButton);
    buttonContainer.add(removeButton);

    element2.add(classpath);
    element2.add(buttonContainer);
    r.add(element2);
    // r.add(classpath);
View Full Code Here

  private static CompositeEditor createOptionsPageForBulkImport(
      final Binding bndr) {
    CompositeEditor r = new CompositeEditor(bndr);

    Container c = new Container(Container.GROUP);
    c.setCaption("Output format");
    c.setLayoutManager(new OneElementOnLineLayouter());
    c.add(new ButtonSelector(bndr.getBinding("asCsv"), SWT.RADIO));
    c.add(new ButtonSelector(bndr.getBinding("asXML"), SWT.RADIO));

    r.add(c);
    return r;
  }
View Full Code Here

    return r;
  }

  private static CompositeEditor createOptionsPage(final Binding bndr) {
    CompositeEditor r = new CompositeEditor(bndr);
    Container c = new Container(Container.GROUP);
    c.setCaption("Output format");
    c.setLayoutManager(new OneElementOnLineLayouter());
    c.add(new ButtonSelector(bndr.getBinding("asCsv"), SWT.RADIO));
    c.add(new ButtonSelector(bndr.getBinding("asXML"), SWT.RADIO));
    c.add(new ButtonSelector(bndr.getBinding("asBinary"), SWT.RADIO));

    r.add(c);

    Container cm = new Container(Container.GROUP);
    cm.setCaption("Scope of import");
    cm.setLayoutManager(new OneElementOnLineLayouter());
    cm.add(new ButtonSelector(bndr.getBinding("allEntitiesOf"), SWT.RADIO));
    cm.add(new ButtonSelector(bndr.getBinding("selectedEntitiesOf"),
        SWT.RADIO));
    cm.add(new ButtonSelector(bndr.getBinding("entitiesOfSelectedKinds"),
        SWT.RADIO));
    r.add(cm);

    return r;
  }
View Full Code Here

    return r;
  }

  private static CompositeEditor createOptionsPageForExport(final Binding bndr) {
    CompositeEditor r = new CompositeEditor(bndr);
    Container c = new Container(Container.GROUP);
    c.setCaption("Type of import");
    c.setLayoutManager(new OneElementOnLineLayouter());
    c.add(new ButtonSelector(bndr.getBinding("asCsv"), SWT.RADIO));
    c.add(new ButtonSelector(bndr.getBinding("asXML"), SWT.RADIO));
    c.add(new ButtonSelector(bndr.getBinding("asBinary"), SWT.RADIO));

    r.add(c);

    Container cm = new Container(Container.GROUP);
    cm.setCaption("Scope of export");
    cm.setLayoutManager(new OneElementOnLineLayouter());
    cm.add(new ButtonSelector(bndr.getBinding("multiExport"), SWT.CHECK));

    r.add(cm);

    return r;
  }
View Full Code Here

  }

  private static CompositeEditor createOptionsPageForBulkExport(
      final Binding bndr) {
    CompositeEditor r = new CompositeEditor(bndr);
    Container c = new Container(Container.GROUP);
    c.setCaption("Type of import");
    c.setLayoutManager(new OneElementOnLineLayouter());
    c.add(new ButtonSelector(bndr.getBinding("asCsv"), SWT.RADIO));
    c.add(new ButtonSelector(bndr.getBinding("asXML"), SWT.RADIO));

    r.add(c);

    // Container cm = new Container(Container.GROUP);
    // cm.setCaption("Scope of export");
View Full Code Here

    bnd.setName("Namespace list");
    bnd.setDescription("Please choose namespace");

    CompositeEditor editor = new CompositeEditor(bnd);
    Container c1 = new Container();
    c1.setLayoutManager(new OneElementOnLineLayouter());
    Container c2 = new Container();
    Container all = new Container();

    GridData c1gd = new GridData(SWT.FILL, SWT.FILL, true, true);
    c1gd.horizontalIndent = 0;
    c1gd.verticalIndent = 0;
    c1.setLayoutData(c1gd);
    // c1.setBordered(true);

    c2.setLayout(new GridLayout(1, false));
    c2.setLayoutData(new GridData(SWT.RIGHT, SWT.BOTTOM, false, false));
    // c2.setBordered(true);

    GridLayout alll = new GridLayout(2, false);
    alll.marginWidth = 1;
    alll.marginHeight = 1;
    all.setLayout(alll);

    GridData allgd = new GridData(SWT.FILL, SWT.FILL, true, true);
    allgd.horizontalAlignment = 0;
    allgd.verticalAlignment = 0;
    all.setLayoutData(allgd);
    // all.setBordered(true);

    final Binding currNSBinding = bnd.getBinding("current");

    final OneLineTextElement<String> current = new OneLineTextElement(
        currNSBinding);
    current.setReadOnly(true);

    final Binding nsListBinding = bnd.getBinding("namespaces");
    nsListBinding.setMaxCardinality(1);
    final ListEnumeratedValueSelector<String> l = new ListEnumeratedValueSelector<String>(
        nsListBinding) {

      protected void updateSize(TableViewer newCheckList) {
        TableColumn tableColumn = (TableColumn) columnWidget;
        tableColumn.pack();
      }
    };

    l.addSelectionChangedListener(new ISelectionChangedListener() {

      public void selectionChanged(SelectionChangedEvent event) {
        ISelection s = event.getSelection();
        if (s instanceof StructuredSelection) {
          StructuredSelection ss = (StructuredSelection) s;
          String selected = (String) ss.getFirstElement();
          if (selected != null) {
            currNSBinding.setValue(selected, null);
          }

        }
        return;
      }
    });

    c1.add(current);
    c1.add(l);

    ButtonSelector add = new ButtonSelector();
    add.addListener(SWT.Selection, new SWTEventListener() {

      public void handleEvent(AbstractUIElement element, Event event) {
        currNSBinding.setName("Current Namespace");
        currNSBinding.setDescription("Add New Namespace");
        currNSBinding.setValue("", null);
        CompositeEditor ce = new CompositeEditor(currNSBinding) {

          protected void update(AbstractUIElement<?> container) {
            super.update(container);
            getControl().pack(true);
          }
        };

        OneLineTextElement<String> f = new OneLineTextElement(
            currNSBinding);
        ce.setLayout(new FillLayout());
        ce.add(f);

        TitledDialog td = new TitledDialog(ce) {

          protected void okPressed() {
            currNSBinding.commit();
            super.okPressed();
          }

          public int open() {
            int ch = super.open();
            return ch;
          }
        };
        td.create();
        td.getShell().setSize(300, 190);
        td.open();

        String curr = (String) currNSBinding.getValue();

        if (!l.getRealm().contains(curr)) {// curr.length() != 0) {
          l.addValue(curr);
        }
        return;
      }

    });
    add.setText("add");
    add.setLayoutData(new GridData(SWT.FILL, SWT.BOTTOM, false, false));

    ButtonSelector remove = new ButtonSelector();
    remove.addListener(SWT.Selection, new SWTEventListener() {

      public void handleEvent(AbstractUIElement element, Event event) {
        IStructuredSelection s = l.getSelection();
        StructuredSelection ss = (StructuredSelection) s;
        String selected = (String) ss.getFirstElement();
        if (selected.length() != 0) {
          l.removeValue(selected);
        }
        return;
      }

    });
    remove.setText("remove");
    remove.setLayoutData(new GridData(SWT.FILL, SWT.TOP, false, true));

    c2.add(add);
    c2.add(remove);

    all.add(c1);
    all.add(c2);
    editor.add(all);

    ShowNSListDialog dlg = new ShowNSListDialog(editor);
    dlg.open();
  }
View Full Code Here

            // OneLineTextElement<String>(name);
            CompositeEditor ed = new CompositeEditor(b);
            ed.setLayoutManager(new OneElementOnLineLayouter());
            ed.add(idel);
            // ed.add(nl);
            Container buttons = new Container();
            buttons.setLayoutManager(new HorizontalLayouter());
            ButtonSelector ba = new ButtonSelector();
            ba.setText("Ok");
            final InputElementDialog dlg = new InputElementDialog(
                ed);
            ba.setValue(new Runnable() {

              public void run() {
                String value = (String) id.getValue();
                Key k = null;
                Entity value2 = (Entity) editor.getBinding()
                    .getValue();
                Key c = (Key) value2.getKey();
                if (c != null && c.isComplete()) {
                  if (!value2.hasProperty("$$OLD_KEY_SET")) {
                    value2.setProperty("$$OLD_KEY_SET",
                        Boolean.TRUE);
                    value2.setProperty("$$OLD_KEY"
                        + Entity.KEY_RESERVED_PROPERTY,
                        c);
                  }
                }
                if (value != null && value.trim().length() != 0) {
                  String vl = value.trim();
                  try {
                    long l = Long.parseLong(vl);

                    k = KeyFactory.createKey(
                        value2.getKind(), l);
                  } catch (Exception e) {
                    k = KeyFactory.createKey(
                        ((Entity) editor.getBinding()
                            .getValue()).getKind(),
                        vl);
                  }
                } else {
                  return;
                }
                // value2.setProperty(Entity.KEY_RESERVED_PROPERTY,
                // k);
                try {
                  java.lang.reflect.Field f = value2
                      .getClass().getDeclaredField("key");
                  f.setAccessible(true);
                  f.set(value2, k);
                } catch (Exception e) {
                  Activator.log(e);
                }
                if (k != null) {
                  String string = "" + k.toString();
                  ((Binding) editor.getBinding())
                      .setName(string);
                  EditDialog.this.setTitle(string);
                  ;
                  dlg.close();
                }
              }
            });
            ButtonSelector ba1 = new ButtonSelector();
            ba1.setValue(new Runnable() {

              public void run() {
                dlg.close();
              }
            });
            ba1.setText("Cancel");
            buttons.add(ba);
            buttons.add(ba1);
            ed.add(buttons);
            DisposeBindingListener.linkBindingLifeCycle(b, ed);
            dlg.open();
            super.widgetSelected(e);
          }
        });
      }
      Link l1 = new Link(cm, SWT.NONE);
      l1.setText("<a>Add new property</a>");
      l1.addSelectionListener(new SelectionListener() {

        public void widgetSelected(SelectionEvent e) {
          Binding b = new Binding("");
          b.setName("Configure new Property");
          final Binding binding = b.getBinding("name");
          binding.setName("Name");
          binding.setReadOnly(false);

          binding.addValidator(new ValidatorAdapter<String>() {

            public CodeAndMessage isValid(IBinding context,
                String object) {
              if (object == null || object.length() == 0) {
                return CodeAndMessage
                    .errorMessage("please define property name");
              }
              Binding b = (Binding) editor.getBinding();
              if (b.getKnownChilds().contains(object)) {
                return CodeAndMessage
                    .errorMessage("property with this name already exits");
              }
              return super.isValid(context, object);
            }
          });
          final Binding type = b.getBinding("type");
          final Binding kc = b.getBinding("keyKind");
          kc.setName("Kind:");
          kc.setValue(
              ((Entity) editor.getBinding().getValue()).getKind(),
              null);
          kc.setReadOnly(false);
          kc.setRequired(false);
          type.setName("Type");
          type.setReadOnly(false);
          type.setRequired(true);
          final OneLineTextElement<String> keyKind = new OneLineTextElement<String>(
              kc);
          type.setAdapter(ITextLabelProvider.class,
              new TextProviderAdapter() {

                public String getText(Object object) {
                  Class<?> c = (Class<?>) object;
                  return c.getSimpleName();
                }
              });
          type.setValue(String.class, null);
          type.setRealm(new Realm<Class<?>>(
              EditorUtility.SUPPORTED_TYPES));
          final Binding multi = b.getBinding("multi");
          multi.setReadOnly(false);
          multi.setName("Multivalue");
          type.setName("Type");
          multi.setValue(false, null);
          CompositeEditor z = new CompositeEditor(b);
          final Container m = new Container();
          m.setLayoutManager(new OneElementOnLineLayouter());
          OneLineTextElement<String> t = new OneLineTextElement<String>(
              binding);
          // t.setCaption("Name:");
          m.add(t);
          ComboEnumeratedValueSelector<Class<?>> element2 = new ComboEnumeratedValueSelector<Class<?>>(
              type);
          type.addValueListener(new IValueListener<Class<?>>() {

            public void valueChanged(Class<?> oldValue,
                Class<?> newValue) {
              if (newValue == Key.class) {
                m.add(2, keyKind);
                m.getControl().getShell().pack(true);
              } else if (oldValue == Key.class) {
                m.remove(keyKind);
                m.getControl().getShell().pack(true);
              }

            }

          });
          ButtonSelector sl = new ButtonSelector(SWT.CHECK);
          sl.setBinding(multi);
          m.add(element2);
          m.add(sl);
          z.setLayoutManager(new OneElementOnLineLayouter());
          z.add(m);
          Container m1 = new Container();
          m1.setLayoutManager(new HorizontalLayouter());
          final InputElementDialog dl = new InputElementDialog(z);
          final ButtonSelector ok = new ButtonSelector();
          ok.setText("Ok");
          ok.setValue(new Runnable() {

            public void run() {
              String value = (String) binding.getValue();
              BaseDataFacade.GAEField gaeField = facade
                  .createField(value,
                      (Class<?>) type.getValue(),
                      (Boolean) (multi.getValue()),
                      (String) kc.getValue());
              EditingBinding binding2 = (EditingBinding) editor
                  .getBinding();
              binding2.removedElements.remove(value);
              binding2.fieldsChanged = true;
              binding2.getBinding(value).setValue(null, null);
              EditorUtility.createBindingsWithButton(
                  (Entity) binding2.getValue(), editor,
                  (Binding) binding2,
                  new Field[] { gaeField }, facade, true);
              dl.close();
              editor.getControl().getShell().layout(true, true);
              editor.getControl().getShell().pack(true);
            }
          });
          ok.setEnabled(false);
          b.addStatusChangeListener(new IStatusChangeListener() {

            public void statusChanged(IBinding bnd,
                CodeAndMessage cm) {
              ok.setEnabled(cm.getCode() == 0);

            }
          });
          ButtonSelector cancel = new ButtonSelector();
          cancel.setText("Cancel");
          m1.add(ok);
          m1.add(cancel);
          cancel.setValue(new Runnable() {

            public void run() {
              dl.close();
            }
          });
          m1.getLayoutHints().setGrabHorizontal(true);
          m1.getLayoutHints().setAlignmentHorizontal(SWT.RIGHT);
          z.add(m1);
          DisposeBindingListener.linkBindingLifeCycle(b, z);
          dl.open();
        }

        public void widgetDefaultSelected(SelectionEvent e) {

        }
      });
      Link l2 = new Link(cm, SWT.NONE);
      l2.setText("<a>Remove property</a>");
      l2.addSelectionListener(new SelectionListener() {

        public void widgetSelected(SelectionEvent e) {
          Binding bnd2 = new Binding("");
          bnd2.setName("Select property to remove");
          CompositeEditor ed = new CompositeEditor(bnd2);
          ed.setLayoutManager(new OneElementOnLineLayouter());
          final ListEnumeratedValueSelector<String> element2 = new ListEnumeratedValueSelector<String>();
          ed.add(element2);
          final Binding bnd = (Binding) editor.getBinding();
          Collection<String> str = bnd.getKnownChilds();
          element2.setRealm(new Realm<String>(str));
          element2.setValue(str);
          element2.getLayoutHints().setHint(new Point(200, 300));
          final InputElementDialog em = new InputElementDialog(ed);

          DisposeBindingListener.linkBindingLifeCycle(bnd2, ed);
          Container b = new Container();
          b.setLayoutManager(new HorizontalLayouter());
          final ButtonSelector ok = new ButtonSelector();
          ok.setText("Ok");
          ok.setEnabled(false);
          element2.addSelectionChangedListener(new ISelectionChangedListener() {

            public void selectionChanged(SelectionChangedEvent event) {
              ok.setEnabled(!event.getSelection().isEmpty());
            }
          });
          b.add(ok);
          ok.setValue(new Runnable() {

            public void run() {
              for (Object o : element2.getSelection().toArray()) {
                AbstractUIElement<?> findEditor = findEditor(
                    editor, o.toString());
                if (findEditor != null) {
                  Container parent2 = findEditor.getParent();
                  if (parent2.getParent() instanceof CTabFolderElement) {
                    Container parent3 = parent2.getParent();
                    parent3.remove(parent2);
                    Container p4 = parent3.getParent();

                    if (p4 instanceof CompositeEditor) {
                      CompositeEditor ce = (CompositeEditor) p4;
                      String id = ce.getId();
                      if (id != null
View Full Code Here

    java.lang.reflect.Field[] fs = parentType.getDeclaredFields();
    if (editor.getLayoutManager() == null) {
      editor.setLayoutManager(new OneElementOnLineLayouter());
    }

    Container text = (Container) editor.getData("text");

    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;

            }
          });
          v.setBinding(binding);
          v.setLayoutData(GridDataFactory.fillDefaults()
              .grab(true, true).create());
          m.add(v);
          text.add(m);
        }
      }
    }
  }
View Full Code Here

  public static void createBindings(
      final com.google.appengine.api.datastore.Entity e,
      CompositeEditor editor, final Binding bnd, Field[] fields,
      final BaseDataFacade facade) {
    Container text = (Container) editor.getData("text");
    for (final Field f : fields) {
      final GAEField fm = (GAEField) f;
      if (fm.multiplicity) {
        if (text == null) {
          text = new CTabFolderElement();
          text.setBordered(true);
          editor.setData("text", text);
          editor.add(text);
        }
        createMultiEdit(e, bnd, facade, text, f, fm);
        continue;
      }
      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);
          } else if (Number.class.isAssignableFrom(type)) {
            OneLineTextElement<String> t = new OneLineTextElement<String>();
            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, facade.getProject());
          } else if (type == Rating.class) {
            createRating(editor, binding);
          } else if (type == Key.class) {
            createKey(editor, binding, f);
          }
        }
      }
    }
    if (text != null) {
      text.getLayoutHints().setHint(new Point(400, 200));
      text.getLayoutHints().setGridy(true);
    }
  }
View Full Code Here

TOP

Related Classes of com.onpositive.commons.elements.Container

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.