Package com.onpositive.semantic.model.ui.property.editors

Examples of com.onpositive.semantic.model.ui.property.editors.CompositeEditor


            "Error", e1.getMessage());
        return;
      }
    }
    final com.google.appengine.api.datastore.Entity e = (Entity) selection;
    final CompositeEditor editor = new CompositeEditor();
    final EditingBinding bnd = new EditingBinding(selection, e, true);

    bnd.setAutoCommit(true);
    bnd.setName(e.getKey().toString());
    editor.setBinding(bnd);

    final TitledDialog dlg = new EditDialog(editor, true);
    dlg.setResizable(true);
    ArrayList<Entity> al = new ArrayList();
    al.add((Entity) selection);
View Full Code Here


            "Error", e1.getMessage());
        return false;
      }
    }
    final com.google.appengine.api.datastore.Entity e = (Entity) selection;
    final CompositeEditor editor = new CompositeEditor();
    editor.setLayout(new GridLayout());
    final EditingBinding bnd = new EditingBinding(selection, e, true);

    bnd.setAutoCommit(true);
    bnd.setName(e.getKey().toString());
    editor.setBinding(bnd);

    final TitledDialog dlg = new EditDialog(editor, drawParentLink);//
    dlg.setResizable(true);

    // Field[] p = facade.getpFields();
View Full Code Here

        return;
      }
    }

    final com.google.appengine.api.datastore.Entity e = (Entity) selection;
    final CompositeEditor editor = new CompositeEditor();
    final EditingBinding bnd = new EditingBinding(selection, e, edit);

    bnd.setAutoCommit(true);
    bnd.setName(e.getKey().toString());
    editor.setBinding(bnd);

    final TitledDialog dlg = new EditDialog(editor, drawParentLink);//
    if (callBList != null)
      ;
    ((EditDialog) dlg).setUpdatingCallback(callBList);
View Full Code Here

        return;
      }
    }

    final com.google.appengine.api.datastore.Entity e = (Entity) selection;
    final CompositeEditor editor = new CompositeEditor();
    final EditingBinding bnd = new EditingBinding(selection, e, true);

    bnd.setAutoCommit(true);
    bnd.setName(e.getKey().toString());
    editor.setBinding(bnd);

    final TitledDialog dlg = new EditDialog(editor, drawParentLink);//
    if (callBList != null)
      ;
    ((EditDialog) dlg).setUpdatingCallback(callBList);
View Full Code Here

    bnd.setAutoCommit(true);

    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();
View Full Code Here

    com.google.apphosting.api.ApiProxy
        .setEnvironmentForCurrentThread(new FakeEnvironment(getAppId()));

    final Entity entity = (Entity) selection;

    CompositeEditor editor = new CompositeEditor();
    final EditingBinding bnd = new EditingBinding(entity, entity, edit);
    if (!edit) {
      bnd.setName("New " + facade.kind);
    } else {
      bnd.setName("Store " + facade.kind);
    }
    editor.setBinding(bnd);
    for (Field f : facade.getFields()) {
      final Binding binding = bnd.getBinding(f.name);
      if (!edit) {
        binding.setName(f.getTitle());
      } else {
        binding.setName(f.getTitle());
      }
      // Object o = binding.getValue();
      if (f.name.equals(BlobStoreDataFacade.FILENAME_PROP)) {
        binding.setReadOnly(false);
        String tmpS = "";
        if (edit && false) {
          tmpS = (String) entity.getProperty(f.name);
          binding.setValue(tmpS, null);
        }
        final String fname = tmpS;

        binding.setFactory(new IFactory() {

          public Object getValue(Object context) {
            FileDialog fd = null;
            if (!edit) {
              fd = new FileDialog(Display.getCurrent()
                  .getActiveShell(), SWT.OPEN);
              fd.setText("Select file");
              String open = ((FileDialog) fd).open();
              return open;
            } else {
              DirectoryDialog dd = new DirectoryDialog(Display
                  .getCurrent().getActiveShell(), SWT.SAVE);
              dd.setText("Store file");
              String choosenDir = dd.open();

              binding.setValue(fname, null);
              if (choosenDir == null) {
              }
              return choosenDir;// + File.pathSeparator + fname;
            }

          }

          public String getName() {
            if (!edit) {
              return "Import File";
            } else {
              return "Change Directory";
            }
          }

          public String getDescription() {
            return "";
          }

        });
        OneLineTextElement<Object> m = new OneLineTextElement<Object>(
            binding) {
          protected void onValue(Object value) {
            commitToBinding(value);
          }

        };
        m.setReadOnly(true);
        editor.add(m);

      } /*
       * else if (f.name.equals(BlobStoreDataFacade.BLOBKEY_PROP)) {
       * binding.setReadOnly(true); OneLineTextElement<String> t = new
       * OneLineTextElement<String>(); t.setBinding(binding);
View Full Code Here

        if (serialized != null) {
          final Binding parentBnd = new Binding(serialized);

          final Class clz = serialized.getClass();
          parentBnd.setName(clz.getCanonicalName());
          CompositeEditor editor = new CompositeEditor(parentBnd);
          EditorUtility.createBindingsForType(clz, parentBnd, editor,
              project);
          TitledDialog td = new TitledDialog(parentBnd, editor) {
            protected void okPressed() {
              parentBnd.commit();
View Full Code Here

            OneLineTextElement<String> idel = new OneLineTextElement<String>(
                id);

            // OneLineTextElement<String>nl=new
            // 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
                          && id.equals(o.toString())) {
                        ce.getParent().remove(ce);
                      }
                    }
                  } else {
                    parent2.remove(findEditor);

                    if (parent2 instanceof CompositeEditor) {
                      CompositeEditor ce = (CompositeEditor) parent2;
                      if (ce.getId().equals(o.toString())) {
                        ce.getParent().remove(ce);
                      }
                    }
                  }

                  Binding binding = bnd.getBinding(o
View Full Code Here

      text = null;
      for (String group : sorted.keySet()) {
        if (group.equals(facade.getKind())) {
          continue;
        }
        CompositeEditor container = new CompositeEditor();
        container.setText(group);
        Collection<Field> fs = sorted.get(group);
        for (final Field f : fs) {
          text = createAppropriateControl(e, container, bnd, facade,
              text, f, needIndexable);
        }
View Full Code Here

      final com.google.appengine.api.datastore.Entity e,
      final CompositeEditor editor, final Binding bnd,
      final BaseDataFacade facade, Container text, final Field f,
      final boolean needIndexable) {
    final GAEField fm = (GAEField) f;
    final CompositeEditor ed = new CompositeEditor();
    ed.setLayout(new GridLayout());
    ed.setLayoutManager(new HorizontalLayouter());
    if (fm.multiplicity) {
      if (text == null) {
        text = new CTabFolderElement();
        text.setBordered(true);
        ed.setData("text", text);
        ed.add(text);
      }
      IBinding bb = createSpecialMultiEdit(e, bnd, facade, text, f, fm,
          needIndexable);
      // addButtonSelector(bb, ed,null);
      ed.setId(bnd.getId());
      editor.add(ed);
      return text;
    }
    if (f.isKey()) {
      return text;
    } else {
      final 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);
          ed.add(t);

          addIsNullButtonSelector(binding, ed, null);
          if (needIndexable) {
            addNotIndexableButton(binding, ed, f);
          }
        } else if (Number.class.isAssignableFrom(type)
            || type.isPrimitive()) {
         
          binding.setSubjectClass(type);
          OneLineTextElement<Number> t = new OneLineTextElement<Number>();
          binding.addValidator(new ValidatorAdapter() {

            public CodeAndMessage isValid(IBinding context,
                Object object) {
              if (object == null) {
                return CodeAndMessage.OK_MESSAGE;
              }
              try {
                if (object instanceof String) {
                  if (type == Double.class) {
                    Double.parseDouble((String) object);
                  } else if (type == Long.class) {
                    Long.parseLong((String) object);
                  } else if (type == Float.class) {
                    Float.parseFloat((String) object);
                  } else if (type == 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);
          ed.add(t);

          addIsNullButtonSelector(binding, ed, null);
          if (needIndexable) {
            addNotIndexableButton(binding, ed, f);
          }
        } else if (type == Boolean.class) {
          binding.setSubjectClass(type);
          ComboEnumeratedValueSelector<Boolean> t = new ComboEnumeratedValueSelector<Boolean>();
          t.setBinding(binding);
          ed.add(t);

          addIsNullButtonSelector(binding, ed, null);
          if (needIndexable) {
            addNotIndexableButton(binding, ed, f);
          }
        } else if (type == Text.class) {
          if (text == null) {
            text = new CTabFolderElement();
            text.setBordered(true);
            ed.setData("text", text);
            ed.add(text);
          }
          createText(ed, text, binding, true);

          // addIsNullButtonSelector(binding, ed, null);
          if (needIndexable) {
            addNotIndexableButton(binding, ed, f);
          }
        } else if (type == Link.class) {
          createLink(ed, binding);

          addIsNullButtonSelector(binding, ed, null);
          if (needIndexable) {
            addNotIndexableButton(binding, ed, f);
          }
        } else if (type == Category.class) {
          createCategory(ed, binding);

          addIsNullButtonSelector(binding, ed, null);
          if (needIndexable) {
            addNotIndexableButton(binding, ed, f);
          }
        } else if (type == Email.class) {
          createEmail(ed, binding);

          addIsNullButtonSelector(binding, ed, null);
          if (needIndexable) {
            addNotIndexableButton(binding, ed, f);
          }
        } else if (type == PostalAddress.class) {
          createPostalAddress(ed, binding);

          addIsNullButtonSelector(binding, ed, null);
          if (needIndexable) {
            addNotIndexableButton(binding, ed, f);
          }
        } else if (type == PhoneNumber.class) {
          createPhoneNumber(ed, binding);

          addIsNullButtonSelector(binding, ed, null);
          if (needIndexable) {
            addNotIndexableButton(binding, ed, f);
          }
        } else if (type == Date.class) {
          createDate(ed, binding);

          addIsNullButtonSelector(binding, ed, null);
          if (needIndexable) {
            addNotIndexableButton(binding, ed, f);
          }
        } else if (type == IMHandle.class) {
          createIMHandle(ed, binding);

          addIsNullButtonSelector(binding, ed, null);
          if (needIndexable) {
            addNotIndexableButton(binding, ed, f);
          }
        } else if (type == GeoPt.class) {
          createGeoPt(ed, binding);

          addIsNullButtonSelector(binding, ed, null);
          if (needIndexable) {
            addNotIndexableButton(binding, ed, f);
          }
        } else if (type == User.class) {
          createUser(ed, binding);

          addIsNullButtonSelector(binding, ed, null);
          if (needIndexable) {
            addNotIndexableButton(binding, ed, f);
          }
        } else if (type == Blob.class || type == ShortBlob.class) {
          createBlob(ed, type, binding, facade.getProject());

          addIsNullButtonSelector(binding, ed, null);
          if (needIndexable) {
            addNotIndexableButton(binding, ed, f);
          }
        } else if (type == Rating.class) {
          createRating(ed, binding);

          addIsNullButtonSelector(binding, ed, null);
          if (needIndexable) {
            addNotIndexableButton(binding, ed, f);
          }
        } else if (type == Key.class) {
          createKey(ed, binding, f);

          addIsNullButtonSelector(binding, ed, null);
          if (needIndexable) {
            addNotIndexableButton(binding, ed, f);
          }
        }
        // editor.setId(binding.getId());
      } else {
        final Binding binding = bnd.getBinding(f.name);
        final Container txt = text;

        binding.setReadOnly(false);
        binding.setName(f.getTitle());

        final LinkElement bs = new LinkElement();
        bs.setId(binding.getId());
        ed.setId(binding.getId());
        bs.getLayoutHints().setGrabVertical(false);
        bs.setText("Specify type");
        bs.setCaption(f.getTitle());
        bs.addHyperLinkListener(new IHyperlinkListener() {

          public void linkExited(HyperlinkEvent e) {
            // TODO Auto-generated method stub

          }

          public void linkEntered(HyperlinkEvent e) {
            return;

          }

          public void linkActivated(HyperlinkEvent event) {
            final Binding tmpBinding = new Binding("");
            tmpBinding.setName("Specify type for property");

            final Binding type = tmpBinding.getBinding("type");
            type.setReadOnly(false);
            type.setRequired(true);
            type.setName("Select type");
            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 ComboEnumeratedValueSelector ce = new ComboEnumeratedValueSelector(
                type);

            final CompositeEditor c1 = new CompositeEditor();
            c1.setLayoutManager(new OneElementOnLineLayouter());
            c1.add(ce);

            final Binding multi = tmpBinding.getBinding("multi");
            multi.setReadOnly(false);
            multi.setName("Multivalue");
            multi.setValue(false, null);

            ButtonSelector multiB = new ButtonSelector(multi,
                SWT.CHECK);
            c1.add(multiB);

            final Binding kk = tmpBinding.getBinding("KeyKind");
            kk.setName("Kind");
            kk.setValue(e.getKind(), null);
            kk.setReadOnly(false);
            kk.setRequired(false);

            final OneLineTextElement<String> keyKind = new OneLineTextElement<String>(
                kk);

            type.addValueListener(new IValueListener<Class<?>>() {

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

              }

            });

            CompositeEditor c2 = new CompositeEditor();
            c2.setLayoutManager(new HorizontalLayouter());
            ButtonSelector ok = new ButtonSelector();
            ok.setText("submit");
            ButtonSelector canc = new ButtonSelector();
            canc.setText("cancel");

            c2.add(ok);
            c2.add(canc);

            CompositeEditor finall = new CompositeEditor(tmpBinding);
            finall.setLayoutManager(new OneElementOnLineLayouter());
            finall.add(c1);
            finall.add(c2);

            final InputElementDialog ied = new InputElementDialog(
                finall);

            ok.setValue(new Runnable() {
View Full Code Here

TOP

Related Classes of com.onpositive.semantic.model.ui.property.editors.CompositeEditor

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.