コード例 #1
0
ファイル: SsamMenu.java プロジェクト: GianeFerreira/SSAM_v3
        public void menuSelected(MenuItem selectedItem) {
          if (selectedItem.getText().equals("Cadastrar")) {
            SsamUsuario U = new SsamUsuario();
            Window mainWindow3 = new Window("Cadastrar");
            // System.out.println("PARENT " + getWindow().getParent());
            mainWindow3.setWidth(1500, Window.UNITS_PIXELS);
            mainWindow3.setHeight(1500, Window.UNITS_PIXELS);
            mainWindow3.addComponent(U);
            getWindow().getParent().addWindow(mainWindow3);

          } else if (selectedItem.getText().equals("Consultar")) {
            SsamConsulta U;
            try {
              U = new SsamConsulta(verificaTpUsuario(Logou));
              Window mainWindow3 = new Window("Consultar");
              // System.out.println("PARENT " + getWindow().getParent());
              mainWindow3.setWidth(1200, Window.UNITS_PIXELS);
              mainWindow3.setHeight(1000, Window.UNITS_PIXELS);
              mainWindow3.addComponent(U);
              getWindow().getParent().addWindow(mainWindow3);
            } catch (SQLException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
            }
          } else if (selectedItem.getText().equals("Seleção")) {
            SsamSelecao S;
            SelecaoDao aprovados = new SelecaoDao();
            try {
              S = new SsamSelecao(aprovados.calcula(), aprovados.getNome());
              Window mainWindow3 = new Window("Seleção");
              mainWindow3.setWidth(1200, Window.UNITS_PIXELS);
              mainWindow3.setHeight(1000, Window.UNITS_PIXELS);
              mainWindow3.addComponent(S);
              getWindow().getParent().addWindow(mainWindow3);

            } catch (SQLException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
            }

            ///// //Colocar na tela SSamSelecao

          } else if (selectedItem.getText().equals("Alterar Senha")) {
            SsamAlterarSenha U = new SsamAlterarSenha();
            Window mainWindow3 = new Window("Alterar Senha");
            // System.out.println("PARENT " + getWindow().getParent());
            mainWindow3.setWidth(400, Window.UNITS_PIXELS);
            mainWindow3.setHeight(300, Window.UNITS_PIXELS);
            mainWindow3.addComponent(U);
            getWindow().getParent().addWindow(mainWindow3);
          }
        }
コード例 #2
0
  void confirmDelete() {

    // Create the window...
    subwindow = new Window("Xoa ??");
    // ...and make it modal
    subwindow.setModal(true);

    // Configure the windws layout; by default a VerticalLayout
    VerticalLayout layout = (VerticalLayout) subwindow.getContent();
    layout.setMargin(true);
    layout.setSpacing(true);

    // Add some content; a label and a close-button
    Label message = new Label("Ban co chac chan muon xoa ?");
    subwindow.addComponent(message);

    Button close =
        new Button(
            "Co",
            new Button.ClickListener() {

              @Override
              public void buttonClick(ClickEvent event) {

                (subwindow.getParent()).removeWindow(subwindow);
              }
            });
    // The components added to the window are actually added to the window's
    // layout; you can use either. Alignments are set using the layout
    layout.addComponent(close);
    layout.setComponentAlignment(close, Alignment.TOP_RIGHT);
  } // end of confirmDelete
コード例 #3
0
ファイル: Launcher.java プロジェクト: slytherator/BlueSmoke
  @Override
  public void init() {
    setMainWindow(mainWindow);
    setTheme("bluesmoke");

    helper = new SpringContextHelper(this);
    feed = (OHLCFeed) helper.getBean("feed");
    correlatorPool = (CorrelatorPool) helper.getBean("correlatorPool");
    correlatorBuilderManager =
        (CorrelatorBuilderManager) helper.getBean("correlatorBuilderManager");
    emulator = (PassageOfTimeEmulationWorker) helper.getBean("emulator");

    buildMainLayout();
    mainWindow.setContent(mainLayout);
    mainLayout.setSizeFull();
    mainWindow.addListener(
        new Window.CloseListener() {
          public void windowClose(Window.CloseEvent e) {
            analytics.terminate();
          }
        });
    mainWindow.addListener(
        new Window.ResizeListener() {
          public void windowResized(Window.ResizeEvent e) {
            analytics.resize();
          }
        });
    mainWindow.addComponent(pusher);
  }
コード例 #4
0
 private void showComponent(final Component component, final String name) {
   final VerticalLayout layout = new VerticalLayout();
   layout.setSizeUndefined();
   layout.setMargin(true);
   final Window window = new Window(name, layout);
   window.setSizeUndefined();
   component.setSizeUndefined();
   window.addComponent(component);
   getWindow().addWindow(window);
 }
コード例 #5
0
  @Override
  public void init() {
    window = new Window("Vaadin DB Tester");
    window.setSizeFull();
    setMainWindow(window);
    setTheme("runo");

    Panel panel = new MainPanel();
    window.addComponent(panel);
  }
コード例 #6
0
  public void showWindow() {

    subwindow = new Window("Change Category Type");
    subwindow.setModal(true);

    VerticalLayout layout = new VerticalLayout();
    layout.setMargin(true);
    layout.setSpacing(true);

    final TextField txtField = new TextField("Change Category Type");
    txtField.setValue(categoryType);
    subwindow.addComponent(txtField);

    Button close =
        new Button(
            "Close",
            new Button.ClickListener() {
              @Override
              public void buttonClick(ClickEvent event) {
                (subwindow.getParent()).removeWindow(subwindow);
              }
            });
    Button save =
        new Button(
            "Save",
            new Button.ClickListener() {
              @Override
              public void buttonClick(ClickEvent event) {
                String newCatType = txtField.getValue().toString();
                controller.updateComponentCategory(componentId, newCatType, itemId);
                (subwindow.getParent()).removeWindow(subwindow);
              }
            });
    HorizontalLayout hl = new HorizontalLayout();
    hl.addComponent(save);
    hl.addComponent(close);

    layout.addComponent(hl);
    subwindow.setWidth("350px");
    subwindow.addComponent(layout);
    router.getMainWindow().addWindow(subwindow);
  }
コード例 #7
0
 @Override
 public void init() {
   window = new Window("My Vaadin Application");
   setMainWindow(window);
   Button button = new Button("Click M e");
   button.addListener(
       new Button.ClickListener() {
         public void buttonClick(ClickEvent event) {
           window.addComponent(new Label("Thank you for clicking"));
         }
       });
   window.addComponent(button);
 }
コード例 #8
0
  public void init() {
    Window window = new Window();

    setMainWindow(window);
    final HorizontalLayout hp = new HorizontalLayout();
    final Label label1 = new Label("Avec une tempature de ");
    label1.setWidth("150px");
    hp.addComponent(label1);
    final TextField temp = new TextField();
    temp.setWidth("20px");
    hp.addComponent(temp);
    final Label label2 = new Label("¡ et un vent ˆ ");
    label2.setWidth("100px");
    hp.addComponent(label2);
    final TextField wind = new TextField();
    wind.setWidth("20px");
    hp.addComponent(wind);
    final Label label3 = new Label(" km/h  produit une tempŽrateure ressentie ");
    label3.setWidth("200px");
    hp.addComponent(label3);
    final Label resultLabel = new Label();

    final Button submit =
        new Button(
            "de",
            new ClickListener() {

              @Override
              public void buttonClick(ClickEvent event) {
                Double result =
                    getTemperatureRessentie(
                        Double.valueOf((String) temp.getValue()),
                        Double.valueOf((String) wind.getValue()));
                resultLabel.setValue(result);

                hp.addComponent(resultLabel);
              }
            });
    hp.addComponent(submit);
    window.addComponent(hp);
  }
コード例 #9
0
  /* second version, using popup */
  public void onCreateUser() throws ViewFactoryException {
    // create view
    UserView view = this.createView(UserView.class);

    // configure the form with bean item
    this.userForm = view.getUserForm();
    User u = new User();
    u.setUserName("newuser");
    u.setFirstName("First name");
    u.setLastName("Last name");
    BeanItem<User> beanItem = new BeanItem<User>(u);
    this.userForm.setItemDataSource(beanItem);

    // create a window using caption from view
    this.dialog = new Window(view.getCaption());
    view.setCaption(null);
    this.dialog.setModal(true);
    dialog.addComponent(view);
    dialog.setWidth("300px");
    this.eventBus.showDialog(this.dialog);
  }
コード例 #10
0
  private void cargarWindowRegistroPolicia() {
    pnlMantenPolicia = new PanelMantenPolicia(new ArrayList<Opcion>(), "400px");
    pnlMantenPolicia.setParent(this.getParent());

    Window window =
        new Window() {

          private static final long serialVersionUID = 1L;

          protected void close() {
            getApplication().getMainWindow().removeWindow(getWindow());
          }
        };

    window.setCaption("Registrar Policia");
    window.addComponent(pnlMantenPolicia);
    window.setModal(true);
    window.setResizable(false);
    window.setWidth("1000px");
    window.setHeight("-1px");
    getWindow().addWindow(window);
  }
コード例 #11
0
ファイル: TestApplication.java プロジェクト: lgervela/Demo
  @Override
  public void init() {
    Window mainWindow = new Window("Test Application");
    Form form = new Form();
    form.setCaption("Form Caption");
    form.setDescription(
        "This is a description of the Form that is "
            + "displayed in the upper part of the form. You normally "
            + "enter some descriptive text about the form and its "
            + "use here.");
    // Add a field and bind it to an named item property.
    form.addField("nom", new TextField("Nom"));
    form.addField("prenom", new TextField("Prenom"));
    form.addField("age", new TextField("Age"));
    // Set the footer layout.
    form.setFooter(new VerticalLayout());

    form.getFooter()
        .addComponent(
            new Label(
                "This is the footer area of the Form. "
                    + "You can use any layout here. "
                    + "This is nice for buttons."));

    // Have a button bar in the footer.
    HorizontalLayout okbar = new HorizontalLayout();
    okbar.setHeight("25px");
    form.getFooter().addComponent(okbar);
    Button okbutton = new Button("OK", form, "commit");
    okbutton.addListener(new OkListener(form));
    okbar.addComponent(okbutton);
    okbar.setComponentAlignment(okbutton, Alignment.TOP_RIGHT);
    Button resetbutton = new Button("Reset", form, "discard");
    resetbutton.addListener(new ResetListener(form));
    okbar.addComponent(resetbutton);
    mainWindow.addComponent(form);
    setMainWindow(mainWindow);
  }
コード例 #12
0
  @Override
  public void init() {
    window = new Window("My Vaadin Application");
    setMainWindow(window);

    // Click & Fails Me buttons
    Button clickButton = new Button("Click Me");
    Button failsButton = new Button("Fail Me");

    // Notification displayed when click button is called
    final Window.Notification notif =
        new Window.Notification(
            "The time is " + new Date(), Window.Notification.TYPE_WARNING_MESSAGE);
    // Notification position.
    notif.setPosition(Window.Notification.POSITION_CENTERED_BOTTOM);

    // Add a listener on Click button
    clickButton.addListener(
        new Button.ClickListener() {
          public void buttonClick(ClickEvent event) {
            window.addComponent(new Label("Thank you for clicking"));
            window.showNotification(notif);
          }
        });

    // Add a listener for Fails button
    failsButton.addListener(
        new Button.ClickListener() {
          public void buttonClick(ClickEvent event) {
            // Throw some exception.
            throw new RuntimeException("You can't catch this.");
          }
        });

    window.addComponent(clickButton);
    window.addComponent(failsButton);
  }
コード例 #13
0
ファイル: MainWindow.java プロジェクト: llyys/processbase
  void openLogoutWindow() {
    Window logout = new Window(getPbMessages("btnLogout"));
    logout.setModal(true);
    //        logout.setStyleName(Reindeer.WINDOW_BLACK);
    logout.setWidth("260px");
    logout.setResizable(false);
    logout.setClosable(false);
    logout.setDraggable(false);
    logout.setCloseShortcut(KeyCode.ESCAPE, null);

    Label helpText = new Label("Are you sure you want to log out?", Label.CONTENT_XHTML);
    logout.addComponent(helpText);

    HorizontalLayout buttons = new HorizontalLayout();
    buttons.setSpacing(true);
    Button yes =
        new Button(
            getPbMessages("btnLogout"),
            new Button.ClickListener() {

              public void buttonClick(ClickEvent event) {

                PbApplication app = (PbApplication) getApplication();
                app.setUser(null);
                Cookie cookie = null;
                for (Cookie c : app.getHttpServletRequest().getCookies()) {
                  if ("username".equals(c.getName())) {
                    cookie = c;
                    break;
                  }
                }
                if (cookie != null) {
                  Cookie del = new Cookie("username", "");
                  cookie.setMaxAge(0); // Delete
                  app.getHttpServletResponse().addCookie(del);
                }
                WebApplicationContext applicationContext =
                    (WebApplicationContext) getApplication().getContext();
                getApplication().close();
                applicationContext.getHttpSession().invalidate();
              }
            });
    yes.setStyleName(Reindeer.BUTTON_DEFAULT);
    yes.focus();
    buttons.addComponent(yes);
    Button no =
        new Button(
            getPbMessages("btnCancel"),
            new Button.ClickListener() {

              public void buttonClick(ClickEvent event) {
                removeWindow(event.getButton().getWindow());
              }
            });
    buttons.addComponent(no);

    logout.addComponent(buttons);
    ((VerticalLayout) logout.getContent()).setComponentAlignment(buttons, Alignment.MIDDLE_CENTER);
    ((VerticalLayout) logout.getContent()).setSpacing(true);

    addWindow(logout);
  }
コード例 #14
0
 @Override
 public void init() {
   Window window = new Window("Unsupported browser");
   window.addComponent(new Label(MSG, Label.CONTENT_XHTML));
   setMainWindow(window);
 }
コード例 #15
0
  public void init(final Window main) {
    VerticalLayout mainLayout = new VerticalLayout();
    main.setContent(mainLayout);
    mainLayout.setSizeFull();

    HorizontalLayout titlebar = new HorizontalLayout();
    titlebar.addStyleName("titlebar");
    titlebar.setWidth("100%");
    Label title = new Label("Book of Vaadin Examples");
    title.addStyleName("title");
    titlebar.addComponent(title);
    titlebar.setComponentAlignment(title, Alignment.MIDDLE_RIGHT);
    Embedded logo = new Embedded(null, new ThemeResource("img/vaadin-logo.png"));
    titlebar.addComponent(logo);
    titlebar.setComponentAlignment(logo, Alignment.MIDDLE_RIGHT);
    main.addComponent(titlebar);

    HorizontalLayout hor = new HorizontalLayout();
    hor.setSizeFull();
    main.addComponent(hor);
    mainLayout.setExpandRatio(hor, 1.0f);

    final Panel menupanel = new Panel("Examples");
    menupanel.addStyleName("menupanel");
    menupanel.setWidth(null);
    menupanel.setHeight("100%");
    menupanel.getContent().setWidth(null);
    // menupanel.getContent().setHeight("100%");
    hor.addComponent(menupanel);

    final Tree menu = new Tree();
    menu.setWidth(null);
    // menu.setHeight("100%");
    menu.setImmediate(true);
    menupanel.addComponent(menu);

    final Panel viewpanel = new Panel("Selected Example");
    viewpanel.addStyleName("viewpanel");
    viewpanel.setSizeFull();
    VerticalLayout viewlayout = new VerticalLayout();
    viewlayout.addStyleName("viewlayout");
    viewlayout.setSpacing(true);
    viewlayout.setMargin(true);
    viewpanel.setContent(viewlayout);

    hor.addComponent(viewpanel);
    hor.setExpandRatio(viewpanel, 1.0f);

    WebApplicationContext ctx = (WebApplicationContext) getContext();
    BookExampleLibrary library = BookExampleLibrary.getInstance(ctx.getBaseDirectory());

    AbstractExampleItem[] examples = library.getAllExamples();

    // Collect redirects here
    final HashMap<String, String> redirects = new HashMap<String, String>();

    // Collect examples here
    final HashMap<String, CaptionedExampleItem> exampleitems =
        new HashMap<String, CaptionedExampleItem>();

    // Build the menu and collect redirections
    for (int i = 0; i < examples.length; i++)
      if (examples[i] instanceof BookExample || examples[i] instanceof ExampleCtgr) {
        CaptionedExampleItem example = (CaptionedExampleItem) examples[i];
        exampleitems.put(example.getExampleId(), example);

        String itemid = example.getExampleId();
        menu.addItem(itemid);
        menu.setItemCaption(itemid, example.getShortName());

        if (examples[i].getParentId() != null) menu.setParent(itemid, examples[i].getParentId());
      } else if (examples[i] instanceof RedirctItem) {
        RedirctItem redirect = (RedirctItem) examples[i];
        redirects.put(redirect.getExampleId(), redirect.redirectid);
      }

    // Expand the menu
    for (int i = 0; i < examples.length; i++) {
      if (examples[i].getParentId() == null)
        menu.expandItemsRecursively(examples[i].getExampleId());

      if (examples[i].isCollapsed()) menu.collapseItem(examples[i].getExampleId());

      if (menu.getChildren(examples[i].getExampleId()) == null)
        menu.setChildrenAllowed(examples[i].getExampleId(), false);
    }

    // Set selected example as given in the URI fragment
    final UriFragmentUtility urifu = new UriFragmentUtility();
    urifu.addListener(
        new FragmentChangedListener() {
          private static final long serialVersionUID = -6588416218607827834L;

          public void fragmentChanged(FragmentChangedEvent source) {
            String fragment = source.getUriFragmentUtility().getFragment();
            if (fragment != null) {
              // Handle redirection
              while (redirects.containsKey(fragment)) fragment = redirects.get(fragment);

              menu.setValue(fragment);

              // Open the tree nodes leading to the example
              for (Object parent = menu.getParent(fragment);
                  parent != null;
                  parent = menu.getParent(parent)) menu.expandItem(parent);
            }
          }
        });
    mainLayout.addComponent(urifu);

    // Handle menu selection
    menu.addListener(
        new Property.ValueChangeListener() {
          private static final long serialVersionUID = 8236533959795019956L;

          public void valueChange(ValueChangeEvent event) {
            viewpanel.removeAllComponents();

            String selection = (String) event.getProperty().getValue();

            // Find the example
            CaptionedExampleItem exampleItem = exampleitems.get(selection);
            if (selection != null && exampleItem == null)
              main.showNotification("Invalid item " + selection);
            else if (exampleItem != null) {
              if (exampleItem.getClass().isAssignableFrom(ExampleCtgr.class)) {
                if (menu.hasChildren(exampleItem.getExampleId())) {
                  menu.select((String) menu.getChildren(exampleItem.getExampleId()).toArray()[0]);
                }
              } else { // A leaf
                BookExample example = (BookExample) exampleItem;

                // Load unless already loaded
                WebApplicationContext ctx = (WebApplicationContext) getContext();
                example.loadExample(ctx.getBaseDirectory());

                if (example.getDescription() != null) {
                  Label descLabel = new Label(example.getDescription(), Label.CONTENT_XHTML);
                  descLabel.addStyleName("example-description");
                  viewpanel.addComponent(descLabel);
                }

                // The actual example component
                viewpanel.addComponent(example.createInstance());

                // Java sources on the left, CSS on the right
                HorizontalLayout horizontalOrder = new HorizontalLayout();
                horizontalOrder.addStyleName("sourcecontainer");
                horizontalOrder.setSpacing(true);
                horizontalOrder.setMargin(true);

                Panel bookRefs = null;
                Panel forumLinks = null;
                Panel kbRefs = null;

                List<SourceFragment> fragments = example.getSourceFragments();
                if (fragments != null) {
                  // Java Sources are laid out vertically
                  VerticalLayout verticalListings = new VerticalLayout();
                  verticalListings.setSizeUndefined();
                  verticalListings.setSpacing(true);
                  horizontalOrder.addComponent(verticalListings);

                  // Find the widest source fragment
                  int widestIndex = 0;
                  int widestWidth = 0;
                  for (int fragmentNum = 0; fragmentNum < fragments.size(); fragmentNum++)
                    if (fragments.get(fragmentNum).getSrcWidth() > widestWidth) {
                      widestIndex = fragmentNum;
                      widestWidth = fragments.get(fragmentNum).getSrcWidth();
                    }
                  System.out.println("Widest listing: " + widestIndex + " which is " + widestWidth);

                  for (int fragmentNum = 0; fragmentNum < fragments.size(); fragmentNum++) {
                    SourceFragment fragment = fragments.get(fragmentNum);

                    // Have caption only in the beginning of the listings
                    String listingCaption = fragmentNum == 0 ? "Source Code" : "";

                    String srcurl =
                        "http://dev.vaadin.com/browser/doc/book-examples/trunk/src"
                            + fragment.getSrcName();
                    SourceListing listing = new SourceListing(listingCaption, srcurl, fragment);
                    verticalListings.addComponent(listing);

                    // Use the width of the widest listing for all listings
                    if (fragmentNum == widestIndex) listing.setWidth(Sizeable.SIZE_UNDEFINED, 0);
                    else listing.setWidth("100%");

                    if (!fragment.getBookRefs().isEmpty()) {
                      bookRefs = new Panel("Book References");
                      bookRefs.setSizeUndefined();
                      for (Iterator<String> iter = fragment.getBookRefs().iterator();
                          iter.hasNext(); ) {
                        String ref = iter.next();
                        int hashPos = ref.indexOf('#');
                        String refFragment = "";
                        if (hashPos != -1) {
                          refFragment = "#" + ref.replace('#', '.');
                          ref = ref.substring(0, hashPos);
                        }
                        String bookUrl =
                            "http://vaadin.com/book/-/page/" + ref + ".html" + refFragment;
                        Link link = new Link(bookUrl, new ExternalResource(bookUrl));
                        link.setTargetName("_new");
                        bookRefs.addComponent(link);
                      }
                    }

                    if (!fragment.getForumLinks().isEmpty()) {
                      forumLinks = new Panel("Forum Messages");
                      forumLinks.setSizeUndefined();
                      for (Iterator<String> iter = fragment.getForumLinks().iterator();
                          iter.hasNext(); ) {
                        String url = iter.next();
                        Link link = new Link(url, new ExternalResource(url));
                        link.setTargetName("_new");
                        forumLinks.addComponent(link);
                      }
                    }

                    if (!fragment.getKbRefs().isEmpty()) {
                      kbRefs = new Panel("Pro Account Knowledge Base Articles");
                      kbRefs.setSizeUndefined();
                      for (Iterator<SourceFragment.Ref> iter = fragment.getKbRefs().iterator();
                          iter.hasNext(); ) {
                        SourceFragment.Ref ref = iter.next();
                        String url = "http://vaadin.com/knowledge-base#" + ref.ref;
                        Link link = new Link(ref.caption, new ExternalResource(url));
                        link.setTargetName("_new");
                        forumLinks.addComponent(link);
                      }
                    }
                  }
                }

                // Show associated CSS
                if (example.getCssFragments() != null && example.getCssFragments().size() > 0) {
                  SourceFragment csscode = example.getCssFragments().get(0);
                  String srcurl =
                      "http://dev.vaadin.com/browser/doc/book-examples/trunk/WebContent/VAADIN/themes/book-examples/styles.css";
                  horizontalOrder.addComponent(new SourceListing("CSS Code", srcurl, csscode));
                }

                if (horizontalOrder.getComponentIterator().hasNext())
                  viewpanel.addComponent(horizontalOrder);
                if (bookRefs != null) viewpanel.addComponent(bookRefs);
                if (forumLinks != null) viewpanel.addComponent(forumLinks);
                if (kbRefs != null) viewpanel.addComponent(kbRefs);

                urifu.setFragment(example.getExampleId());
              }
            }
          }
        });

    Tree.ItemStyleGenerator itemStyleGenerator =
        new Tree.ItemStyleGenerator() {
          private static final long serialVersionUID = -3231268865512947125L;

          public String getStyle(Object itemId) {
            // Chapter title items do not contain a period
            if (!((String) itemId).contains(".")) return "chaptertitle";
            return null;
          }
        };
    menu.setItemStyleGenerator(itemStyleGenerator);
  }
コード例 #16
0
ファイル: GriddemoApplication.java プロジェクト: p4elkin/Grid
  @Override
  public void init() {
    Window mainWindow = new Window("GridDemo");
    mainWindow.getContent().setSizeFull();
    ((VerticalLayout) mainWindow.getContent()).setSpacing(true);
    Indexed c = getTestContainer();
    final Table table = new Table();
    table.setImmediate(true);
    table.setSizeUndefined();
    table.setHeight("100%");
    table.setWidth("100%");
    table.setContainerDataSource(c);
    table.setCacheRate(0.5d);

    table.setNullSelectionAllowed(false);
    final Grid grid = new Grid(c);
    grid.setWidth("100%");
    grid.setHeight("100%");

    mainWindow.addComponent(grid);
    grid.getBody().setCelEditingEnabled(true);
    grid.setColumnWidth("p1", 200);
    grid.setImmediate(true);
    grid.setColumnAlignment("p1", Align.RIGHT);
    grid.setColumnAlignment("p2", Align.CENTER);
    grid.getHeader()
        .setHeaderFactory(
            new HeaderComponentFactory() {
              @Override
              public Component createComponent(final Grid grid, final Object propertyId) {
                final TextField l = new TextField("<b>" + propertyId + "<\b>");
                l.setImmediate(true);
                l.setWidth("100%");
                l.addListener(
                    new ValueChangeListener() {
                      @Override
                      public void valueChange(ValueChangeEvent event) {
                        ((Filterable) grid.getContainerDataSource())
                            .addContainerFilter(
                                new Filter() {

                                  @Override
                                  public boolean passesFilter(Object itemId, Item item)
                                      throws UnsupportedOperationException {
                                    return item.getItemProperty(propertyId)
                                        .getValue()
                                        .toString()
                                        .contains(l.getValue().toString());
                                  }

                                  @Override
                                  public boolean appliesToProperty(Object id) {
                                    return id.equals(propertyId);
                                  }
                                });
                      }
                    });
                return l;
              }
            });
    table.setEditable(true);
    // mainWindow.addComponent(table);
    setMainWindow(mainWindow);
    setTheme("griddemotheme");
  }
コード例 #17
0
ファイル: TipiBrowseBinary.java プロジェクト: flyaruu/navajo
  protected void execute(TipiEvent event) throws TipiBreakException, TipiException {
    Operand value = getEvaluatedParameter("property", event);
    if (value == null) {
      throw new TipiException("TipiBrowseBinary: no value supplied");
    }
    if (value.value == null) {
      throw new TipiException("TipiBrowseBinary: null value supplied");
    }
    if (!(value.value instanceof Property)) {
      throw new TipiException(
          "TipiOpenBinary: Type of value is not Property, but: " + value.value.getClass());
    }
    final Property pp = (Property) value.value;
    if (!pp.getType().equals(Property.BINARY_PROPERTY)) {
      throw new TipiException("TipiOpenBinary: Property is not type binary , but: " + pp.getType());
    }

    final Window w = new Window("Upload binary");
    w.setModal(true);
    w.setClosable(true);
    w.setWidth(320, Sizeable.UNITS_PIXELS);
    w.setHeight(70, Sizeable.UNITS_PIXELS);
    Upload u =
        new Upload(
            "",
            new Upload.Receiver() {

              private static final long serialVersionUID = 1L;

              @Override
              public OutputStream receiveUpload(String filename, String mimeType) {
                outputBinary = new Binary();
                return outputBinary.getOutputStream();
              }
            });
    u.addListener(
        new Upload.SucceededListener() {

          private static final long serialVersionUID = 8118852698370774496L;

          @Override
          public void uploadSucceeded(SucceededEvent event) {
            try {
              pp.setAnyValue(outputBinary);
              getApplication().getMainWindow().removeWindow(w);
              continueAction(getEvent());
            } catch (TipiBreakException e) {
            } catch (TipiSuspendException e) {
            } catch (TipiException e) {
              e.printStackTrace();
            }
          }
        });
    u.addListener(
        new Upload.FailedListener() {

          private static final long serialVersionUID = 4791549173755572186L;

          @Override
          public void uploadFailed(FailedEvent event) {
            System.err.println("Upload failed?");
            throw new TipiBreakException();
          }
        });

    w.addComponent(u);
    getApplication().getMainWindow().addWindow(w);
    suspend();
  }