Package com.onpositive.gae.baseviewer.BaseDataFacade

Examples of com.onpositive.gae.baseviewer.BaseDataFacade.GAEField


    public void preprocess(IProgressMonitor monitor) throws Exception {
      // lets determine target area;
      for (Filter f : query.filters) {
        if (f.kind == Filter.COMPLEX_FILTER) {
          ComplexFilter cFilter = (ComplexFilter) f.value;
          GAEField field = cFilter.field;
          int indexOf = cFilter.value.indexOf('=');
          ArrayList<Filter> filters = new ArrayList<Filter>();
          // we should understand filters here
          if (indexOf == -1) {
          } else {
            if (field.keyKindDetails != null) {

            }
          }
          if (filters.size() > 0) {
            ArrayList<Key> keys = new ArrayList<Key>();
            Query c = new Query(filters.toArray(new Filter[filters
                .size()]), new Sort("", false), 100, 0);
            c.keysOnly = true;
            BaseDataFacade createFacade = field
                .createFacade(field.keyKind);
            Entity[] query2 = createFacade.query(c, monitor);
            for (Entity e : query2) {
              keys.add(e.getKey());
            }
View Full Code Here


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

  private static Container createAppropriateControl(
      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) {
View Full Code Here

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

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

  private static void createKey(CompositeEditor editor,
      final Binding binding, final Field f) {
    binding.setFactory(new IFactory() {

      public Object getValue(Object context) {
        GAEField d = (GAEField) f;

        if (d.keyKind == null) {
          final String[] kinds = new String[1];
          kindCheck(kinds);
          if (kinds[0] == null || kinds[0].length() == 0) {
            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());
View Full Code Here

    manager.add(new Separator());
    MenuManager item = new MenuManager("Details Formatting");
    Field[] fields = getFields();
    for (Field f : fields) {
      if (f.getType() == Key.class || f.getType() == Entity.class) {
        final GAEField fr = (GAEField) f;
        if (fr.keyKindDetails == null) {
          item.add(new Action("Enable details formatting for "
              + f.name) {

            public void run() {
              fr.enableDetailFormatting();
            }
          });
        } else {
          item.add(new Action("Disable details formatting for "
              + f.name) {

            public void run() {
              fr.disableDetailFormatting();
            }
          });
        }
      }
    }
View Full Code Here

TOP

Related Classes of com.onpositive.gae.baseviewer.BaseDataFacade.GAEField

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.