Beispiel #1
0
  public ConfirmDialog(
      String caption, String message, String okButtonText, String cancelButtonText) {
    super(caption);
    super.setModal(true);
    super.setClosable(false);
    super.setResizable(false);

    VerticalLayout windowLayout = new VerticalLayout();
    windowLayout.setMargin(true);

    // confirmation message
    windowLayout.addComponent(new Label(message, ContentMode.HTML));
    windowLayout.setSpacing(true);

    // buttons
    HorizontalLayout buttonsLayout = new HorizontalLayout();
    buttonsLayout.setWidth(100.0f, Unit.PERCENTAGE);
    windowLayout.addComponent(buttonsLayout);

    okButton = new Button(okButtonText);
    buttonsLayout.addComponent(okButton);
    okButton.setTabIndex(1);
    okButton.addClickListener(this);
    buttonsLayout.setComponentAlignment(okButton, Alignment.MIDDLE_CENTER);

    cancelButton = new Button(cancelButtonText);
    buttonsLayout.addComponent(cancelButton);
    cancelButton.setTabIndex(0);
    cancelButton.setClickShortcut(KeyCode.ESCAPE, null);
    cancelButton.addClickListener(this);
    buttonsLayout.setComponentAlignment(cancelButton, Alignment.MIDDLE_CENTER);

    super.setContent(windowLayout);
  }
  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);
  }
Beispiel #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);
   }
 }
Beispiel #4
0
  public Login() {
    // TODO Auto-generated constructor stub
    VaadinSession.getCurrent().setAttribute("municipaldata", null);
    VaadinSession.getCurrent().setAttribute("barangaydata", null);
    VaadinSession.getCurrent().setAttribute("id", null);
    setSizeFull();
    dialog = new Window("Login");
    dialog.setClosable(false);
    dialog.setResizable(false);
    dialog.center();

    //		new CreateAccount();

    VerticalLayout content = new VerticalLayout();
    content.setSpacing(true);
    content.setMargin(new MarginInfo(false, true, true, true));
    dialog.setContent(content);

    Label title = new Label("Login");
    title.addStyleName(ValoTheme.LABEL_H2);
    title.addStyleName(ValoTheme.LABEL_COLORED);

    HorizontalLayout form = new HorizontalLayout();
    form.setSpacing(true);
    form.addStyleName("wrapping");
    content.addComponent(form);

    username.setIcon(FontAwesome.USER);
    username.focus();
    form.addComponent(username);

    password.setIcon(FontAwesome.LOCK);
    form.addComponent(password);

    Button submit = new Button("Login");
    submit.addStyleName(ValoTheme.BUTTON_ICON_ALIGN_RIGHT);
    submit.addStyleName(ValoTheme.BUTTON_PRIMARY);
    submit.setIcon(FontAwesome.ARROW_RIGHT);
    submit.setWidth("100%");
    submit.addListener(ClickEvent.class, this, "gotoMain");
    content.addComponent(submit);
  }
Beispiel #5
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);
  }
  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();
    }
  }
Beispiel #7
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();
  }
  @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);
  }