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

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


            } else {
              Object firstElement = null;
              Binding bnd = new Binding(firstElement);
              bnd.setName("Edit");
              CompositeEditor m = new CompositeEditor(bnd);
              TitledDialog dlg = new TitledDialog(m);
              GAEField singleField = fm.getSingleField();
              ApiProxy.setEnvironmentForCurrentThread(new FakeEnvironment(
                  e.getAppId()));
              Entity c = new Entity("A");

              if (fm instanceof CGAEField) {
                c = new Entity(fm.getKeyKind(), parent);
                // Entity example =
              } else {
                c.setProperty(f.name, firstElement);
              }
              createBindingsWithButton(c, m, bnd,
                  new Field[] { singleField }, facade, false);

              int open = dlg.open();
              if (open == Dialog.OK) {
                Binding bb = bnd.getBinding(f.name);
                Object value = bb.getValue();
                if (value == null || bb.isReadOnly()) {
                  value = new NullValue();
                }
                v.addValue(value);
              }
              bnd.dispose();

            }
          }
        });
        manager.add(new Action("Edit selected") {
          {
            setImageDescriptor(AbstractUIPlugin
                .imageDescriptorFromPlugin(Activator.PLUGIN_ID,
                    "/icons/text_edit.gif"));
          }

          public void run() {
            if (f instanceof CGAEField) {
              CGAEField cgf = (CGAEField) f;

              Object[] selected = v.getSelection().toArray();
              if (selected.length == 1) {
                BaseDataFacade fac = new BaseDataFacade(
                    cgf.keyKind, facade.getProject(),
                    facade.isDebug());
                fac.setNamespace(facade.getNamespace());
                DataStoreTableUI dstui = new DataStoreTableUI();
                Object selecttedd = selected[0];
                if (selecttedd instanceof Entity) {
                  final Entity sel = (Entity) selecttedd;
                  ArrayList<Entity> select = new ArrayList();
                  select.add(sel);
                  fac.determineFields(select);
                  dstui.setFacade(fac);
                  dstui.open(sel, false, true,
                      new IUpdateList() {

                        public void update(Entity e) {
                          v.removeValue(sel);
                          v.addValue(e);
                        }
                      });
                }
              }
              return;
            } else {
              Object firstElement = v.getSelection()
                  .getFirstElement();
              Binding bnd = new Binding(firstElement);
              bnd.setName("Edit");
              CompositeEditor m = new CompositeEditor(bnd);
              TitledDialog dlg = new TitledDialog(m);
              GAEField singleField = fm.getSingleField();
              ApiProxy.setEnvironmentForCurrentThread(new FakeEnvironment(
                  e.getAppId()));
              Entity c = new Entity("A");
              if (firstElement instanceof NullValue) {
                c.setProperty(f.name, null);
              } else {
                c.setProperty(f.name, firstElement);
              }
              createBindingsWithButton(c, m, bnd,
                  new Field[] { singleField }, facade, false);
              int open = dlg.open();
              if (open == Dialog.OK) {
                StructuredViewer viewer = v.getViewer();
                if (viewer instanceof TableViewer) {
                  Binding bb = bnd.getBinding(f.name);
                  Object value = bb.getValue();
                  if (value == null || bb.isReadOnly()) {
                    value = new NullValue();
                  }
                 
                  TableViewer tv = (TableViewer)viewer;
                  int index = tv.getTable().getSelectionIndex();                 
                  v.editValue(value, index);                 
                  //tv.get
                 
                } else {
                  v.removeValue(firstElement);
                  Binding bb = bnd.getBinding(f.name);
                  Object value = bb.getValue();
                  if (value == null || bb.isReadOnly()) {
                    value = new NullValue();
                  }
                  v.addValue(value);
                }
              }
              bnd.dispose();
            }
          }
        });
        manager.add(new Action("Delete selected") {
          {
            setImageDescriptor(AbstractUIPlugin
                .imageDescriptorFromPlugin(Activator.PLUGIN_ID,
                    "/icons/delete.gif"));
          }

          @SuppressWarnings("unchecked")
          public void run() {
            final List selected = v.getSelection().toList();

            if (f instanceof CGAEField) {
              final CGAEField cgf = (CGAEField) f;
              BaseDataFacade fac = new BaseDataFacade(
                  cgf.keyKind, facade.getProject(), facade
                      .isDebug());
              fac.setNamespace(facade.getNamespace());
              fac.delete(selected.toArray(new Entity[selected
                  .size()]), new OperationCallback() {

                public void passed(Object object) {
                  Collection coll = (Collection) ((HashMap) facade
                      .getChildren()
                      .get(cgf.getKeyKind())).get(e
                      .getKey());
                  coll.removeAll(selected);
                  facade.updateChildren(e);
                  v.removeValues(selected);
                }

                public void failed(Exception exception) {
                  return;
                }
              });
              // facade.updateChildren(e);
            } else {
              v.removeValues(selected);
            }
          }
        });
        return manager.createControl(conComposite);
      }

    });

    v.setValueAsSelection(false);
    Binding binding = bnd.getBinding(f.name);
    binding.setReadOnly(false);
    Object property = null;
    if (f instanceof CGAEField) {

      HashMap hashMap = (HashMap) facade.getChildren().get(
          ((CGAEField) f).keyKind);
      if (hashMap != null) {
        Collection col = (Collection) (hashMap).get(e.getKey());
        if (col != null) {
          property = new ArrayList<Object>();
          for (Iterator i = col.iterator(); i.hasNext();) {
            Entity ent = (Entity) i.next();
            ((ArrayList<Object>) property).add(ent);
            v.setLabelProvider(new LabelProvider() {

              public String getText(Object element) {
                Entity e = (Entity) element;
                String res = "";

                String[] details = ((CGAEField) f)
                    .getKeyKindDetails();
                if (details != null && details.length != 0) {
                  StringBuilder sb = new StringBuilder();
                  int ch = 0;
                  for (String det : details) {
                    Object prop = e.getProperty(det);
                    String toStr = ((CGAEField) f)
                        .getObjectText2(e, prop);
                    sb.append(toStr);
                    if (ch != details.length - 1) {
                      sb.append(":");
                    }
                    ch++;
                  }
                  res = sb.toString();
                } else {
                  res = e.getKey().toString();
                }
                return res;
              }
            });
          }
        } else {
          property = "";// <empty>
        }
      } else {
        property = "";// <empty>
      }

    } else if (f instanceof PGAEField) {
      property = e.getProperty(f.name);
    } else {
      property = e.getProperty(f.name);
    }
    if (property instanceof Collection<?>) {
      Collection c = (Collection) property;
      boolean remove = c.remove(null);
      if (remove) {
        c.add(new NullValue());
      }
    }
    binding.setValue(property, null);
    v.setBinding(binding);
    v.setLayoutData(GridDataFactory.fillDefaults().grab(true, true)
        .create());
    m.add(v);
    if (needIndexable) {
      addNotIndexableButton(binding, m, fm);
    }
    text.add(m);
    return binding;
View Full Code Here


            } else {
              Object firstElement = null;
              Binding bnd = new Binding(firstElement);
              bnd.setName("Edit");
              CompositeEditor m = new CompositeEditor(bnd);
              m.setLayoutManager(new HorizontalLayouter());
              TitledDialog dlg = new TitledDialog(m);
              GAEField singleField = fm.getSingleField();
              ApiProxy.setEnvironmentForCurrentThread(new FakeEnvironment(
                  e.getAppId()));
              Entity c = new Entity("A");

              if (fm instanceof CGAEField) {
                c = new Entity(fm.getKeyKind(), e.getKey());
                // Entity example =
              } else {
                c.setProperty(f.name, firstElement);
              }
              createBindings(c, m, bnd,
                  new Field[] { singleField }, facade);

              int open = dlg.open();
              if (open == Dialog.OK) {
                Object value = bnd.getBinding(f.name)
                    .getValue();
                if (value == null) {
                  value = new NullValue();
                }
                v.addValue(value);
              }
              bnd.dispose();

            }
          }
        });
        manager.add(new Action("Edit selected") {
          {
            setImageDescriptor(AbstractUIPlugin
                .imageDescriptorFromPlugin(Activator.PLUGIN_ID,
                    "/icons/text_edit.gif"));
          }

          public void run() {
            if (f instanceof CGAEField) {
              CGAEField cgf = (CGAEField) f;

              Object[] selected = v.getSelection().toArray();
              if (selected.length == 1) {
                BaseDataFacade fac = new BaseDataFacade(
                    cgf.keyKind, facade.getProject(),
                    facade.isDebug());
                fac.setNamespace(facade.getNamespace());
                DataStoreTableUI dstui = new DataStoreTableUI();
                final Entity sel = (Entity) selected[0];
                ArrayList<Entity> select = new ArrayList();
                select.add(sel);
                fac.determineFields(select);
                dstui.setFacade(fac);
                dstui.open(sel, false, new IUpdateList() {

                  public void update(Entity e) {
                    v.removeValue(sel);
                    v.addValue(e);
                  }
                });
              }
              return;
            } else {
              Object firstElement = v.getSelection()
                  .getFirstElement();
              Binding bnd = new Binding(firstElement);
              bnd.setName("Edit");
              CompositeEditor m = new CompositeEditor(bnd);
              TitledDialog dlg = new TitledDialog(m);
              GAEField singleField = fm.getSingleField();
              ApiProxy.setEnvironmentForCurrentThread(new FakeEnvironment(
                  e.getAppId()));
              Entity c = new Entity("A");
              if (firstElement instanceof NullValue) {
                c.setProperty(f.name, null);
              } else {
                c.setProperty(f.name, firstElement);
              }
              createBindings(c, m, bnd,
                  new Field[] { singleField }, facade);
              int open = dlg.open();
              if (open == Dialog.OK) {
                v.removeValue(firstElement);
                Object value = bnd.getBinding(f.name)
                    .getValue();
                if (value == null) {
                  value = new NullValue();
                }
                v.addValue(value);
              }
              bnd.dispose();
            }
          }
        });
        manager.add(new Action("Delete selected") {
          {
            setImageDescriptor(AbstractUIPlugin
                .imageDescriptorFromPlugin(Activator.PLUGIN_ID,
                    "/icons/delete.gif"));
          }

          @SuppressWarnings("unchecked")
          public void run() {
            final List selected = v.getSelection().toList();

            if (f instanceof CGAEField) {
              final CGAEField cgf = (CGAEField) f;
              BaseDataFacade fac = new BaseDataFacade(
                  cgf.keyKind, facade.getProject(), facade
                      .isDebug());
              fac.setNamespace(facade.getNamespace());
              fac.delete(selected.toArray(new Entity[selected
                  .size()]), new OperationCallback() {

                public void passed(Object object) {
                  Collection coll = (Collection) ((HashMap) facade
                      .getChildren()
                      .get(cgf.getKeyKind())).get(e
                      .getKey());
                  coll.removeAll(selected);
                  facade.updateChildren(e);
                  v.removeValues(selected);
                }

                public void failed(Exception exception) {
                  return;
                }
              });
              // facade.updateChildren(e);
            } else {
              v.removeValues(selected);
            }
          }
        });
        return manager.createControl(conComposite);
      }

    });

    v.setValueAsSelection(false);
    Binding binding = bnd.getBinding(f.name);
    binding.setReadOnly(false);
    Object property = null;
    if (f instanceof CGAEField) {

      HashMap hashMap = (HashMap) facade.getChildren().get(
          ((CGAEField) f).keyKind);
      if (hashMap != null) {
        Collection col = (Collection) (hashMap).get(e.getKey());
        if (col != null) {
          property = new ArrayList<Object>();
          for (Iterator i = col.iterator(); i.hasNext();) {
            Entity ent = (Entity) i.next();
            ((ArrayList<Object>) property).add(ent);
            v.setLabelProvider(new LabelProvider() {

              public String getText(Object element) {
                Entity e = (Entity) element;
                String res = "";

                String[] details = ((CGAEField) f)
                    .getKeyKindDetails();
                if (details != null && details.length != 0) {
                  StringBuilder sb = new StringBuilder();
                  int ch = 0;
                  for (String det : details) {
                    Object prop = e.getProperty(det);
                    String toStr = ((CGAEField) f)
                        .getObjectText2(e, prop);
                    sb.append(toStr);
                    if (ch != details.length - 1) {
                      sb.append(":");
                    }
                    ch++;
                  }
                  res = sb.toString();
                } else {
                  res = e.getKey().toString();
                }
                return res;
              }
            });
          }
        } else {
          property = new NullValue();// "<empty>";
        }
      } else {
        property = new NullValue();// "<empty>";
      }

    } else if (f instanceof PGAEField) {
      property = e.getProperty(f.name);
    } else {
      property = e.getProperty(f.name);
    }
    if (property instanceof Collection<?>) {
      Collection c = (Collection) property;
      boolean remove = c.remove(null);
      if (remove) {
        c.add(new NullValue());
      }
    }
    binding.setValue(property, null);
    v.setBinding(binding);
    v.setLayoutData(GridDataFactory.fillDefaults().grab(true, true)
        .create());
    m.add(v);
    text.add(m);
    return binding;
  }
View Full Code Here

            return null;
          }
          d.keyKind = kinds[0];
        }

        final CompositeEditor rd = new CompositeEditor();
        rd.setLayout(new GridLayout());
        rd.setBinding(binding);
        binding.setAutoCommit(false);
        final TitledDialog titledDialog = new TitledDialog(rd) {

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

        };
        binding.setDescription("Select entity to refer on");
        UniversalUIElement<Composite> element = new UniversalUIElement<Composite>(
            Composite.class, SWT.BORDER) {

          protected Composite createControl(Composite conComposite) {
            Composite c = new Composite(conComposite, SWT.NONE);

            DataStoreTableUI ui = new DataStoreTableUI() {

              public void open(Object selection) {
                binding.commit();
                titledDialog.close();
              }

            };
            c.setLayout(new GridLayout(1, false));
            ToolBarManager man = new ToolBarManager();
            Action action = ui.createActions(man, false);
            man.createControl(c);

            GAEField d = (GAEField) f;
            if (d.keyKind == null) {
              final String[] kinds = new String[1];
              Binding bnd = new Binding("");
              final Binding kind = bnd.getBinding("Kind");

              CompositeEditor bb = new CompositeEditor(bnd);

              final InputElementDialog dlg = new InputElementDialog(
                  bb);

              bb.setLayoutManager(new OneElementOnLineLayouter());
              CompositeEditor pe = new CompositeEditor();
              pe.setLayout(new FillLayout());
              OneLineTextElement<String> keyKind = new OneLineTextElement<String>(
                  kind);
              pe.add(keyKind);
              bb.add(pe);

              CompositeEditor buttons = new CompositeEditor();
              buttons.setLayoutManager(new HorizontalLayouter());

              ButtonSelector ok = new ButtonSelector();
              ok.setText("submit");
              ok.setValue(new Runnable() {

                public void run() {
                  kinds[0] = (String) kind.getValue();
                  dlg.close();
                }
              });
              buttons.add(ok);
              bb.add(buttons);
              DisposeBindingListener
                  .linkBindingLifeCycle(bnd, bb);
              dlg.open();
              d.keyKind = kinds[0];
            }
            BaseViewer bv = new BaseViewer(action, ui, d
                .getProject(), d.keyKind) {

              public void selectionChanged(
                  IStructuredSelection selection) {
                if (!selection.isEmpty()) {
                  Entity firstElement = (Entity) selection
                      .getFirstElement();
                  rd.getBinding().setValue(
                      firstElement.getKey(), null);
                }
              }

            };

            bv.createControl(c);
            BaseDataFacade createFacade = d.createFacade(d.keyKind,
                bv.getRefreshCallback(), bv.getSingleCallback());
            String namespace = d.getFacade().getNamespace();
            createFacade.setNamespace(namespace);
            ui.setFacade(createFacade);
            bv.getControl().setLayoutData(
                GridDataFactory.fillDefaults().grab(true, true)
                    .create());
            bv.kind = createFacade.getKind();
            bv.setDataFacade(createFacade);
            return c;
          }

        };
        element.getLayoutHints().setGrabHorizontal(true);
        element.getLayoutHints().setGrabVertical(true);
        rd.add(element);
        rd.getLayoutHints().setGrabHorizontal(true);
        rd.getLayoutHints().setGrabVertical(true);

        titledDialog.setResizable(true);
        titledDialog.open();
        return null;
      }

      public void kindCheck(final String[] kinds) {
        Binding bnd = new Binding("Parameters");
        final Binding kind = bnd.getBinding("Kind");
        kind.addValidator(new ValidatorAdapter<String>() {

          public CodeAndMessage isValid(IBinding context,
              String object) {
            if (object == null || object.length() == 0) {
              return CodeAndMessage
                  .errorMessage("Kind should not be empty");
            }
            return CodeAndMessage.OK_MESSAGE;
          }
        });
        kind.setReadOnly(false);
        kind.setName("Kind for key:");
        CompositeEditor bb = new CompositeEditor(bnd);

        final TitledDialog dlg = new TitledDialog(bb) {

          protected void okPressed() {
            kinds[0] = (String) kind.getValue();
            super.okPressed();
          }
          //
          // protected void cancelPressed() {
          // close();
          // kindCheck(kinds);
          // }
        };

        bb.setLayoutManager(new OneElementOnLineLayouter());
        CompositeEditor pe = new CompositeEditor();
        pe.setLayout(new FillLayout());
        OneLineTextElement<String> keyKind = new OneLineTextElement<String>(
            kind);
        pe.add(keyKind);
        bb.add(pe);
        dlg.create();

        dlg.setMessage("Please specify kind for key.");
View Full Code Here

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

  private static void createUser(CompositeEditor editor, final Binding binding) {
    CompositeEditor tr = new CompositeEditor(binding, Container.GROUP);

    tr.setCaption(binding.getName());
    tr.setLayoutManager(new HorizontalLayouter());

    tr.setLayoutManager(new HorizontalLayouter());
    if (binding.getValue() == null) {
      binding.setValue(new User("", "", ""), null);// setValueSilent
    }
    binding.addBindingChangeListener(new IBindingChangeListener<Object>() {

      public void valueChanged(ISetDelta<Object> valueElements) {
        // TODO Auto-generated method stub

      }

      public void enablementChanged(boolean isEnabled) {
        Collection<String> childs = binding.getKnownChilds();
        for (String ch : childs) {
          Binding b = binding.getBinding(ch);
          b.setReadOnly(!isEnabled);
        }
      }

      public void changed() {
        // TODO Auto-generated method stub

      }
    });
    final Binding binding2 = new Binding(binding, "userId"); // binding.getBinding("userId");
    binding2.setName("userId");
    binding2.setAutoCommit(true);

    tr.add(new OneLineTextElement<String>(binding2));
    final Binding binding3 = new Binding(binding, "email"); // binding.getBinding("email");
    binding3.setName("email");
    binding3.setAutoCommit(true);

    tr.add(new OneLineTextElement<String>(binding3));
    final Binding binding4 = new Binding(binding, "authDomain"); // binding.getBinding("authDomain");
    binding4.setName("authDomain");
    binding4.setAutoCommit(true);

    tr.add(new OneLineTextElement<String>(binding4));
    // binding.setReadOnly(false);
    editor.add(tr);
  }
View Full Code Here

    editor.add(tr);
  }

  private static void createGeoPt(CompositeEditor editor,
      final Binding binding) {
    CompositeEditor tr = new CompositeEditor(binding, Container.GROUP);

    tr.setCaption(binding.getName());
    tr.setLayoutManager(new HorizontalLayouter());
    if (binding.getValue() == null) {
      binding.setValue(new GeoPt(0f, 0f), null); // Silent
    }

    binding.addBindingChangeListener(new IBindingChangeListener<Object>() {

      public void valueChanged(ISetDelta<Object> valueElements) {
        // TODO Auto-generated method stub
        return;
      }

      public void enablementChanged(boolean isEnabled) {
        Collection<String> childs = binding.getKnownChilds();
        for (String ch : childs) {
          Binding b = binding.getBinding(ch);
          b.setReadOnly(!isEnabled);
        }
      }

      public void changed() {
        // TODO Auto-generated method stub
        return;
      }
    });

    final Binding binding2 = new Binding(binding, "Latitude");
    final Binding binding3 = new Binding(binding, "Longitude");

    // binding2.refresh();
    // binding3.refresh();
    IBindingChangeListener<Object> l = new IBindingChangeListener<Object>() {

      public void changed() {

      }

      public void enablementChanged(boolean isEnabled) {

      }

      public void valueChanged(ISetDelta<Object> valueElements) {
        Object val1 = binding2.getValue();
        Object val2 = binding3.getValue();

        if (val1 instanceof GeoPt) {
          val1 = ((GeoPt) val1).getLatitude();
        }

        if (val2 instanceof GeoPt) {
          val2 = ((GeoPt) val2).getLongitude();
        }

        if (val1 instanceof Number && val2 instanceof Number) {
          Number value = (Number) val1;
          Number value2 = (Number) val2;
          GeoPt pt = new GeoPt((value.floatValue()/* / 1000000 */),
              value2.floatValue()/* / 1000000 */);

          binding.setValueSilent(pt);
        }
      }
    };

    binding2.setAutoCommit(true);
    binding2.addBindingChangeListener(l);
    binding2.setReadOnly(false);
    binding2.setName("Latitude");
    // binding2.setValue(vv.getLatitude(),null);
    SpinnerEditor sp2 = new SpinnerEditor() {
      protected void configure(IBinding binding, Spinner control) {
        // super.configure(binding,control);
        control.setMinimum(-90000000);
        control.setMaximum(90000000);
        control.setDigits(6);
        this.scale = 1000000;
        isFloat = true;
        control.setIncrement(1);
        Object value = binding.getValue();
        if (value == null) {
          value = 0f;
        }

        initValue(control, ((Float) value)/* * 1000000 */);

      }
    };
    sp2.setBinding(binding2);

    tr.add(sp2);
    binding3.setName("Longitude");
    // binding3.setValue(vv.getLongitude(),null);
    binding3.setReadOnly(false);
    binding3.setRequired(true);
    binding3.setAutoCommit(true);
    binding3.addBindingChangeListener(l);

    SpinnerEditor sp = new SpinnerEditor() {
      protected void configure(IBinding binding, Spinner control) {
        control.setMinimum(-180000000);
        control.setMaximum(180000000);
        control.setDigits(6);
        control.setIncrement(1);
        isFloat = true;
        // super.configure(binding3, control);
        this.scale = 1000000;
        Object value = binding.getValue();
        if (value == null) {
          value = 0f;
        }
        initValue(control, (Float) value/* * 1000000 */);

      }
    };
    sp.setBinding(binding3);
    tr.add(sp);
    editor.add(tr);
  }
 
View Full Code Here

    editor.add(tr);
  }

  private static void createIMHandle(CompositeEditor editor,
      final Binding binding) {
    CompositeEditor tr = new CompositeEditor(binding, Container.GROUP);

    tr.setCaption(binding.getName());
    tr.setLayoutManager(new HorizontalLayouter());
    final Binding binding2 = binding.getBinding("Address");
    final Binding binding3 = binding.getBinding("Protocol");
    IBindingChangeListener<Object> l = new IBindingChangeListener<Object>() {

      public void changed() {

      }

      public void enablementChanged(boolean isEnabled) {

      }

      public void valueChanged(ISetDelta<Object> valueElements) {
        IMHandle value = new IMHandle((Scheme) binding3.getValue(),
            (String) binding2.getValue());
        binding.setValueSilent(value);
      }
    };

    binding2.setAutoCommit(true);
    binding2.addBindingChangeListener(l);
    binding2.setReadOnly(false);
    binding2.setName("Address");
    tr.add(new OneLineTextElement<Object>(binding2));
    binding3.setName("Protocol");
    binding3.setReadOnly(false);
    binding3.setRequired(true);
    binding3.setAutoCommit(true);
    Object value = binding3.getValue();
    binding3.setValue(
        Scheme.valueOf((String) (value != null ? value : "xmpp")), null);
    binding3.addBindingChangeListener(l);
    Scheme[] values = IMHandle.Scheme.values();
    binding3.setRealm(new Realm<IMHandle.Scheme>(values));
    tr.add(new ComboEnumeratedValueSelector<Object>(binding3));
    editor.add(tr);
  }
View Full Code Here

      Realm<Field> realm = new Realm<Field>(rStr);

      Binding bnd = new Binding("");
      bnd.setName("Choose property for initializing.");
      final CompositeEditor editor = new CompositeEditor(bnd);
      editor.setLayout(new GridLayout(1, true));

      final Binding value = new EditingBinding(res, res, false) {
        public void commit() {
          for (String b : getKnownChilds()) {
            // if(facade.getKindsOfChildren().containsKey(b)){
            // continue;
            // }
            Binding binding = getBinding(b);
            Object value = binding.getValue();

            if (binding instanceof EditingBinding) {
              if (((EditingBinding) binding).isResetToNull()) {
                ((EditingBinding) binding)
                    .setResetToNull(false);
                setPropValue(b, binding, null);
                continue;
              }

            }

            // int count = 0;
            // if (value instanceof Collection<?>) {
            // Collection c = (Collection) value;
            // for (Iterator iterator = c.iterator(); iterator
            // .hasNext();) {
            // Object object = (Object) iterator.next();
            // if (object instanceof NullValue) {
            // iterator.remove();
            // count++;
            // }
            // }
            // for (int a = 0; a < count; a++) {
            // c.add(null);
            // }
            // }
            try {
              // if (value instanceof Collection) {
              // Collection c = (Collection) value;
              // if (c.size() != 0) {
              // Object obj = c
              // .toArray(new Object[c.size()])[c
              // .size() - 1];
              // if (isSupported(obj)) {
              // setPropValue(b, binding, value);
              // }
              // } else {
              // setPropValue(b, binding, value);
              // }
              // } else {
              // if (isSupported(value)) {
              // setPropValue(b, binding, value);
              // }
              // }
              setPropValue(b, binding, value);
            } catch (Exception e) {
              MessageDialog.openError(Display.getDefault()
                  .getActiveShell(), "Error", e.getMessage());
              throw new RuntimeException(e);
            }
          }
        }
      };
      value.setName("New Value");
      value.setReadOnly(false);

      Binding combo = bnd.getBinding("combo");
      combo.setName("All Available Properties");
      combo.setReadOnly(false);
      combo.setAutoCommit(true);
      combo.setRealm(realm);
      combo.setRequired(true);

      combo.setAdapter(ITextLabelProvider.class,
          new TextProviderAdapter() {

            public String getText(Object object) {
              return ((Field) object).name;
            }
          });

      ComboEnumeratedValueSelector<Field> fields = new ComboEnumeratedValueSelector<Field>(
          combo);
      fields.setLayoutData(new GridData(SWT.FILL, SWT.TOP, false, false));

      IValueListener l = new VCHListener(value, editor, res, inner);
      combo.addValueListener(l);

      editor.add(fields);

      if (rStr.size() != 0) {
        combo.setValue(rStr.toArray()[0], null);
      }
View Full Code Here

        for (String id : coll) {
          value.getBinding(id).dispose();
        }
      }
      e.setProperty(newPr, null);
      arr[0] = new CompositeEditor(value, Container.GROUP);
      arr[0].setLayoutData(new GridData(SWT.FILL, SWT.BOTTOM, true, true));

      EditorUtility.createBindingsWithButton(e, arr[0], value,
          new Field[] { fN }, facade, false);
      parent.add(arr[0]);
View Full Code Here

      com.google.apphosting.api.ApiProxy
          .setEnvironmentForCurrentThread(new FakeEnvironment(
              getAppId()));
      final Entity entity = new Entity(facade.getKind());

      CompositeEditor editor = new CompositeEditor();
      final EditingBinding bnd = new EditingBinding(entity, entity, false);
      bnd.setName("New " + facade.getKind());
      bnd.switchParsingMode(true);
      editor.setBinding(bnd);
      // Field[] full = getAllFields();
      EditorUtility.createBindingsWithButton(entity, editor, bnd,
          facade.getFields(), facade, true);

      final TitledDialog dlg = new EditDialog(editor, true);
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));
        final OrderedRealm<Field> realm = new OrderedRealm<Field>();
        final SelectColumnsDialog dlg = new SelectColumnsDialog(editor,
            vl) {

          protected void createButtonsForButtonBar(Composite parent) {
            Button createButton = createButton(parent, 4,
                "Select All", true);
            createButton.addListener(SWT.Selection, new Listener() {

              public void handleEvent(Event event) {
                vl.setSelection(new StructuredSelection(realm
                    .getContents().toArray()));
                vl.addValues(realm.getContents());

              }
            });
            Button createButton2 = createButton(parent, 5,
                "Deselect All", true);
            createButton2.addListener(SWT.Selection,
                new Listener() {

                  public void handleEvent(Event event) {
                    vl.setSelection(new StructuredSelection());
                    vl.addValues(new ArrayList<Field>());
                  }
                });
            super.createButtonsForButtonBar(parent);
          }

        };
        vl.setAsCheckBox(true);
        vl.setValueAsSelection(true);
        dlg.setResizable(true);
        editor.add(vl);

        for (Field f : getFields()) {
          realm.add(f);
        }
        vl.setRealm(realm);
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.