Examples of TitledDialog


Examples of com.onpositive.commons.ui.dialogs.TitledDialog

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

Examples of com.onpositive.commons.ui.dialogs.TitledDialog

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

Examples of com.onpositive.commons.ui.dialogs.TitledDialog

        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.");

        dlg.open();
      }

      public String getName() {
        return "Choose";
      }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.