Package com.onpositive.gae.baseviewer.BaseDataFacade

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


          }

          public void run() {
            Key parent = e.getKey();
            if (f instanceof CGAEField) {
              CGAEField cgf = (CGAEField) f;
              BaseDataFacade fac = new BaseDataFacade(
                  cgf.keyKind, facade.getProject(), facade
                      .isDebug());
              fac.setNamespace(facade.getNamespace());
              DataStoreTableUI dstui = new DataStoreTableUI();
              dstui.setFacade(fac);
              ApiProxy.setEnvironmentForCurrentThread(new FakeEnvironment(
                  facade.getAppId(), facade.namespace));
              // parent =
              // StringInputOutput.dublicateKey(parent,facade.namespace);

              Entity ent = new Entity(cgf.keyKind, parent);
              Map childrenMP = fac.getChildren(); // facade
              Object cMap = childrenMP.get(cgf.getKeyKind());
              Collection coll = null;
              if (cMap != null) {
                coll = ((Collection) ((HashMap) cMap)
                    .get(parent));
              }
              if (coll != null && coll.size() != 0) {
                Entity old = (Entity) coll
                    .toArray(new Object[coll.size()])[coll
                    .size() - 1];
                for (Iterator<String> it = old.getProperties()
                    .keySet().iterator(); it.hasNext();) {
                  ent.setProperty(it.next(), "");
                }
              }
              ArrayList<Entity> select = new ArrayList();
              select.add(ent);
              fac.determineFields(select);
              // v.addValue(ent);
              dstui.open(ent, false, false, new IUpdateList() {

                public void update(Entity e) {
                  v.addValue(e);
                }
              });// ((Collection)((HashMap)facade.getChildren().get(cgf.getKeyKind())).get(e.getKey()));

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


                    "/icons/add_exc.gif"));
          }

          public void run() {
            if (f instanceof CGAEField) {
              CGAEField cgf = (CGAEField) f;
              BaseDataFacade fac = new BaseDataFacade(
                  cgf.keyKind, facade.getProject(), facade
                      .isDebug());
              fac.setNamespace(facade.getNamespace());
              DataStoreTableUI dstui = new DataStoreTableUI();
              dstui.setFacade(fac);
              Entity ent = new Entity(cgf.keyKind, e.getKey());
              Collection coll = ((Collection) ((HashMap) facade
                  .getChildren().get(cgf.getKeyKind())).get(e
                  .getKey()));
              if (coll != null && coll.size() != 0) {
                Entity old = (Entity) coll
                    .toArray(new Object[coll.size()])[coll
                    .size() - 1];
                for (Iterator<String> it = old.getProperties()
                    .keySet().iterator(); it.hasNext();) {
                  ent.setProperty(it.next(), "");
                }
              }
              ArrayList<Entity> select = new ArrayList();
              select.add(ent);
              fac.determineFields(select);
              // v.addValue(ent);
              dstui.open(ent, false, new IUpdateList() {

                public void update(Entity e) {
                  v.addValue(e);
                }
              });// ((Collection)((HashMap)facade.getChildren().get(cgf.getKeyKind())).get(e.getKey()));

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

TOP

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

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.