Exemple #1
0
        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);
          }
        }
  @Override
  protected void setup(VaadinRequest request) {
    final VerticalLayout uiLayout = new VerticalLayout();
    uiLayout.setMargin(true);
    setContent(uiLayout);

    final VerticalLayout windowLayout = new VerticalLayout();

    final Window testWindow = new Window("WebKitFail", windowLayout);
    testWindow.setWidth(300, Unit.PIXELS);

    GridLayout gl = new GridLayout();
    gl.setHeight(null);
    gl.setWidth(100, Unit.PERCENTAGE);
    windowLayout.addComponent(gl);

    ListSelect listSelect = new ListSelect();
    listSelect.setWidth(100, Unit.PERCENTAGE);
    gl.addComponent(listSelect);
    gl.setMargin(true);

    final Button testButton =
        new Button(
            "Open Window",
            new Button.ClickListener() {
              @Override
              public void buttonClick(ClickEvent event) {
                UI.getCurrent().addWindow(testWindow);
              }
            });
    uiLayout.addComponent(testButton);
  }
Exemple #3
0
 public void setComponentValue(final String name, final Object object) {
   super.setComponentValue(name, object);
   if (name.equals("title")) {
     dialog.setCaption((String) object);
   }
   if ("icon".equals(name)) {
     dialog.setIcon(getResource(object));
   }
   if ("h".equals(name)) {
     dialog.setHeight("" + object + "px");
   }
   if ("w".equals(name)) {
     dialog.setWidth("" + object + "px");
   }
   if ("x".equals(name)) {
     dialog.setPositionX((Integer) object);
   }
   if ("y".equals(name)) {
     dialog.setPositionY((Integer) object);
   }
   if ("closable".equals(name)) {
     dialog.setClosable((Boolean) object);
   }
   if ("resizable".equals(name)) {
     dialog.setResizable((Boolean) object);
   }
 }
  public void showWindowForm() {

    itemDetilModel = new PerubahanHargaItemModel();
    itemDetilView = new PerubahanHargaItemView(itemDetilModel);
    itemDetilPresenter = new PerubahanHargaItemPresenter(itemDetilModel, itemDetilView);

    itemDetilView.setSizeFull();
    panelFormDetil.setContent(itemDetilView);

    windowForm = new Window();
    windowForm.setModal(true);

    windowForm.center();

    windowForm.setWidth("650px");
    windowForm.setHeight("300px");
    windowForm.setClosable(true);
    windowForm.setResizable(false);

    VerticalLayout content = new VerticalLayout();
    content.setMargin(true);
    content.setSizeFull();
    content.addComponent(panelFormDetil);
    windowForm.setContent(content);

    getUI().addWindow(windowForm);
  }
 /** 增加 编辑 删除窗体初始化 * */
 private void createWindow(Item item) {
   Window window = new Window();
   window.setHeight(250, Unit.PIXELS);
   window.setWidth(300, Unit.PIXELS);
   window.setModal(true);
   window.setContent(createForm(item, window));
   window.close();
   getUI().addWindow(window);
 }
 private void tambahUserYayasanbaru(UserOprYayasan i) {
   final Window win = new Window("Tambah User Baru");
   Component c = new TambahUserYayasan(i, win);
   VerticalLayout vl = new VerticalLayout();
   vl.setMargin(true);
   vl.addComponent(c);
   win.setContent(vl);
   win.setModal(true);
   win.setWidth("600px");
   win.center();
   UI.getCurrent().addWindow(win);
 }
Exemple #7
0
  @Override
  protected void setup(VaadinRequest request) {
    Window def = new Window("default", new Label("Some content"));
    def.setWidth("300px");
    def.setHeight("100%");
    addWindow(def);

    Window light = new Window("WINDOW_LIGHT", new Label("Some content"));
    light.setStyleName(Reindeer.WINDOW_LIGHT);
    light.setPositionX(300);
    light.setWidth("300px");
    light.setHeight("100%");
    addWindow(light);

    Window black = new Window("WINDOW_BLACK", new Label("Some content"));
    black.setStyleName(Reindeer.WINDOW_BLACK);
    black.setPositionX(600);
    black.setWidth("300px");
    black.setHeight("100%");
    addWindow(black);
  }
  @Override
  protected void setup(VaadinRequest request) {

    Window w = new Window();
    w.setId(WINDOW_ID);
    w.setWidth("300px");
    w.setHeight("300px");
    w.center();

    VerticalLayout content = new VerticalLayout();
    w.setContent(content);
    content.setHeight("1000px");
    ComboBox<String> cb = new ComboBox<>();
    cb.setId(COMBOBOX_ID);
    content.addComponent(cb);
    content.setComponentAlignment(cb, Alignment.BOTTOM_CENTER);

    addWindow(w);
  }
  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);
  }
  /* 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);
  }
  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);
  }
Exemple #12
0
  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);
  }
  /* Initializes a modal window to edit schedule event. */
  private void createCalendarEventPopup() {
    VerticalLayout layout = new VerticalLayout();
    layout.setMargin(true);
    layout.setSpacing(true);

    scheduleEventPopup = new Window(null, layout);
    scheduleEventPopup.setWidth("400px");
    scheduleEventPopup.setModal(true);
    scheduleEventPopup.center();

    layout.addComponent(scheduleEventFieldLayout);

    applyEventButton =
        new Button(
            "Apply",
            new ClickListener() {

              private static final long serialVersionUID = 1L;

              @Override
              public void buttonClick(ClickEvent event) {
                try {
                  commitCalendarEvent();
                } catch (CommitException | ValidationException e) {
                  e.printStackTrace();
                }
              }
            });
    Button cancel =
        new Button(
            "Cancel",
            new ClickListener() {

              private static final long serialVersionUID = 1L;

              @Override
              public void buttonClick(ClickEvent event) {
                discardCalendarEvent();
              }
            });
    deleteEventButton =
        new Button(
            "Delete",
            new ClickListener() {

              private static final long serialVersionUID = 1L;

              @Override
              public void buttonClick(ClickEvent event) {
                deleteCalendarEvent();
              }
            });
    scheduleEventPopup.addCloseListener(
        new Window.CloseListener() {

          private static final long serialVersionUID = 1L;

          @Override
          public void windowClose(Window.CloseEvent e) {
            discardCalendarEvent();
          }
        });

    HorizontalLayout buttons = new HorizontalLayout();
    buttons.setSpacing(true);
    buttons.addComponent(deleteEventButton);
    buttons.addComponent(applyEventButton);
    buttons.addComponent(cancel);
    layout.addComponent(buttons);
    layout.setComponentAlignment(buttons, Alignment.BOTTOM_RIGHT);
  }
Exemple #14
0
  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();
  }
Exemple #15
0
  private void showNonMobileNotification() {
    try {
      URL appUrl = Page.getCurrent().getLocation().toURL();
      String myIp = Inet4Address.getLocalHost().getHostAddress();
      final String qrCodeUrl = appUrl.toString().replaceAll("localhost", myIp);

      Label info =
          new Label(
              "You appear to be running this demo on a non-portable device. "
                  + "Parking is intended for touch devices primarily. "
                  + "Please read the QR code on your touch device to access the demo.");
      info.setWidth("310px");

      Image qrCode = new Image();
      qrCode.addStyleName("qrcode-image");
      StreamResource resource =
          new StreamResource(
              new StreamSource() {
                @Override
                public InputStream getStream() {
                  InputStream result = null;
                  try {
                    final Map<EncodeHintType, ErrorCorrectionLevel> hintMap = Maps.newHashMap();
                    hintMap.put(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.L);
                    final QRCodeWriter qrCodeWriter = new QRCodeWriter();
                    final BitMatrix byteMatrix =
                        qrCodeWriter.encode(qrCodeUrl, BarcodeFormat.QR_CODE, 150, 150, hintMap);
                    final int width = byteMatrix.getWidth();
                    final BufferedImage image =
                        new BufferedImage(width, width, BufferedImage.TYPE_INT_RGB);
                    image.createGraphics();

                    final Graphics2D graphics = (Graphics2D) image.getGraphics();
                    graphics.setColor(Color.WHITE);
                    graphics.fillRect(0, 0, width, width);
                    graphics.setColor(Color.BLACK);

                    for (int i = 0; i < width; i++) {
                      for (int j = 0; j < width; j++) {
                        if (byteMatrix.get(i, j)) {
                          graphics.fillRect(i, j, 1, 1);
                        }
                      }
                    }
                    final ByteArrayOutputStream baos = new ByteArrayOutputStream();
                    try {
                      ImageIO.write(image, "png", baos);
                    } catch (final IOException e) {
                      e.printStackTrace();
                    }
                    result = new ByteArrayInputStream(baos.toByteArray());

                  } catch (WriterException e) {
                    e.printStackTrace();
                  }
                  return result;
                }
              },
              "qrcode-" + new Date().getTime() + ".png");
      resource.setCacheTime(0);
      qrCode.setSource(resource);

      CssLayout qrCodeLayout = new CssLayout(qrCode, info);
      qrCodeLayout.setSizeFull();

      Window window = new Window(null, qrCodeLayout);
      window.setWidth(500.0f, Unit.PIXELS);
      window.setHeight(200.0f, Unit.PIXELS);
      window.addStyleName("qr-code");
      window.setModal(true);
      window.setResizable(false);
      window.setDraggable(false);
      addWindow(window);
      window.center();
    } catch (MalformedURLException e) {
      e.printStackTrace();
    } catch (UnknownHostException e) {
      e.printStackTrace();
    }
  }
  private void openNotificationsPopup(final ClickEvent event) {
    VerticalLayout notificationsLayout = new VerticalLayout();

    Label title = new Label("Notifications");
    title.addStyleName(ValoTheme.LABEL_H3);
    title.addStyleName(ValoTheme.LABEL_NO_MARGIN);
    notificationsLayout.addComponent(title);

    Collection<DashboardNotification> notifications =
        DashboardUI.getDataProvider().getNotifications();
    DashboardEventBus.post(new NotificationsCountUpdatedEvent());

    for (DashboardNotification notification : notifications) {
      VerticalLayout notificationLayout = new VerticalLayout();
      notificationLayout.setMargin(false);
      notificationLayout.setSpacing(false);
      notificationLayout.addStyleName("notification-item");

      Label titleLabel =
          new Label(
              notification.getFirstName()
                  + " "
                  + notification.getLastName()
                  + " "
                  + notification.getAction());
      titleLabel.addStyleName("notification-title");

      Label timeLabel = new Label(notification.getPrettyTime());
      timeLabel.addStyleName("notification-time");

      Label contentLabel = new Label(notification.getContent());
      contentLabel.addStyleName("notification-content");

      notificationLayout.addComponents(titleLabel, timeLabel, contentLabel);
      notificationsLayout.addComponent(notificationLayout);
    }

    HorizontalLayout footer = new HorizontalLayout();
    footer.addStyleName(ValoTheme.WINDOW_BOTTOM_TOOLBAR);
    footer.setWidth("100%");
    footer.setSpacing(false);
    Button showAll =
        new Button(
            "View All Notifications",
            new ClickListener() {
              @Override
              public void buttonClick(final ClickEvent event) {
                Notification.show("Not implemented in this demo");
              }
            });
    showAll.addStyleName(ValoTheme.BUTTON_BORDERLESS_COLORED);
    showAll.addStyleName(ValoTheme.BUTTON_SMALL);
    footer.addComponent(showAll);
    footer.setComponentAlignment(showAll, Alignment.TOP_CENTER);
    notificationsLayout.addComponent(footer);

    if (notificationsWindow == null) {
      notificationsWindow = new Window();
      notificationsWindow.setWidth(300.0f, Unit.PIXELS);
      notificationsWindow.addStyleName("notifications");
      notificationsWindow.setClosable(false);
      notificationsWindow.setResizable(false);
      notificationsWindow.setDraggable(false);
      notificationsWindow.setCloseShortcut(KeyCode.ESCAPE, null);
      notificationsWindow.setContent(notificationsLayout);
    }

    if (!notificationsWindow.isAttached()) {
      notificationsWindow.setPositionY(event.getClientY() - event.getRelativeY() + 40);
      getUI().addWindow(notificationsWindow);
      notificationsWindow.focus();
    } else {
      notificationsWindow.close();
    }
  }
  @Override
  public void execute() {
    List<ChangeRecord> historyList = view.getUi().getStockService().findChanges(good);
    Window subWindow = new Window();
    subWindow.setModal(true);
    subWindow.setHeight("650px");
    subWindow.setWidth("700px");
    subWindow.setClosable(true);
    view.getUi().addWindow(subWindow);

    final Button pdfButton = new Button(bundle.getString("pdf.export"));
    pdfButton.setIcon(new ThemeResource("img/pdf.png"));
    pdfButton.setWidth("150");
    StreamResource pdfStream = getPDFStream(view.getUi().getStockService().findChanges(good));
    pdfStream.setMIMEType("application/pdf");
    FileDownloader pdfDownloader = new FileDownloader(pdfStream);
    pdfDownloader.extend(pdfButton);

    final VerticalLayout layout = new VerticalLayout();
    layout.setMargin(true);
    layout.setSpacing(true);
    layout.addComponent(pdfButton);

    for (ChangeRecord record : historyList) {
      for (ChangeRecord.PropertyChange p : record.getChangeList()) {
        p.setName(bundle.getString(p.getName()));
      }
      Panel panel = new Panel();
      BeanItemContainer<ChangeRecord.PropertyChange> container =
          new BeanItemContainer<>(ChangeRecord.PropertyChange.class, record.getChangeList());
      Table table = new Table();
      table.setContainerDataSource(container);
      table.setVisibleColumns("name", "oldValue", "newValue");
      table.setColumnHeaders(
          bundle.getString("history.property"),
          bundle.getString("history.old"),
          bundle.getString("history.new"));
      table.setColumnExpandRatio("name", 0.33f);
      table.setColumnExpandRatio("oldValue", 0.33f);
      table.setColumnExpandRatio("newValue", 0.33f);
      table.setPageLength(0);
      table.setWidth("100%");

      VerticalLayout panelLayout = new VerticalLayout();
      panelLayout.addComponent(
          new Label(
              "<b>"
                  + new SimpleDateFormat("dd-MM-YYYY HH:mm").format(record.getDate())
                  + ": "
                  + record.getUser().getName()
                  + " "
                  + record.getUser().getSurname()
                  + "</b><br/>",
              ContentMode.HTML));
      panelLayout.addComponent(table);
      panel.setContent(panelLayout);
      layout.addComponent(panel);
    }

    subWindow.setContent(layout);
  }