示例#1
0
  @Override
  public void enter(ViewChangeEvent event) {
    if (((MyUI) UI.getCurrent()).getLogged() == false) {
      getUI().getNavigator().navigateTo(MyUI.LOGIN_USER);
    }
    this.layout = new VerticalLayout();
    setCompositionRoot(this.layout);
    this.layout.setSizeFull();
    this.layout.setMargin(true);
    this.layout.setSpacing(true);

    this.panel = new HorizontalLayout();
    this.panel.setSpacing(true);
    this.buttonMainSite.setIcon(FontAwesome.HOME);
    this.panel.addComponent(this.buttonMainSite);
    this.layout.addComponent(this.panel);

    this.imageLogo.setSource(ImageTasslegro.getImageSource());
    this.layout.addComponent(this.imageLogo);

    ((MyUI) UI.getCurrent()).setLogged(false);
    ((MyUI) UI.getCurrent()).setUserLogin(null);
    ((MyUI) UI.getCurrent()).setUserPass(null);
    ((MyUI) UI.getCurrent()).setUserId(-1);
    getUI().getNavigator().navigateTo(MyUI.MAIN);
  }
示例#2
0
  @Override
  public void enter(ViewChangeEvent event) {
    this.layout = new VerticalLayout();
    setCompositionRoot(this.layout);
    this.layout.setSizeFull();
    this.layout.setMargin(true);
    this.layout.setSpacing(true);

    this.panel = new HorizontalLayout();
    this.panel.setSpacing(true);
    this.buttonMainSite.setIcon(FontAwesome.HOME);
    this.panel.addComponent(this.buttonMainSite);
    if (((MyUI) UI.getCurrent()).getLogged()) {
      this.labelLogged = new Label("Zalogowany jako: " + ((MyUI) UI.getCurrent()).getUserLogin());
      this.panel.addComponent(this.labelLogged);
      this.buttonLogoutUser.setIcon(FontAwesome.LOCK);
      this.panel.addComponent(this.buttonLogoutUser);
    } else {
      this.panel.addComponent(this.labelNoLogged);
      this.buttonLoginUser.setIcon(FontAwesome.LOCK);
      this.panel.addComponent(this.buttonLoginUser);
    }
    this.layout.addComponent(this.panel);

    this.imageLogo.setSource(ImageTasslegro.getImageSource());
    this.layout.addComponent(this.imageLogo);

    this.idAuction = ((MyUI) UI.getCurrent()).getIdAuction();
    if (((MyUI) UI.getCurrent()).getLogged() == false) {
      this.layout.addComponent(new Label("Zaloguj się!"));
    } else if (this.idAuction == null) {
      this.layout.addComponent(new Label("Nie wybrano aukcji!"));
    } else {
      try {
        Http_Get get = new Http_Get(this.httpGetURL + this.idAuction);
        this.responseString = get.getStrinResponse();
        if (get.getStatusCode() == 200) {
        } else {
          this.notification =
              new Notification("Error!", this.responseString, Notification.Type.ERROR_MESSAGE);
          this.notification.setDelayMsec(5000);
          this.notification.show(Page.getCurrent());
          this.responseString = null;
          return;
        }
      } catch (IOException e) {
        System.err.println("[ERROR] " + new Date() + ": " + e.getMessage());
        this.notification =
            new Notification("Error!", "Problem z połączeniem!", Notification.Type.ERROR_MESSAGE);
        this.notification.setDelayMsec(5000);
        this.notification.show(Page.getCurrent());
        this.responseString = null;
        return;
      }

      if (this.responseString == null) {
      } else {
        JSONObject objects = new JSONObject(this.responseString);
        if (objects.getInt("user_ID") != (((MyUI) UI.getCurrent()).getUserId())) {
          this.layout.addComponent(new Label("Wybierz aukcjię do edycji!"));
          return;
        }
        this.layout.addComponent(this.labelTitle);
        this.auctionTitle.setValue(objects.getString("title"));
        this.layout.addComponent(this.auctionTitle);
        this.layout.addComponent(this.labelDescription);
        this.auctionDescription.setValue(objects.getString("description"));
        this.layout.addComponent(this.auctionDescription);
        this.layout.addComponent(this.Price);
        this.auctionPrice.setValue(String.valueOf(objects.getDouble("price")));
        this.layout.addComponent(this.auctionPrice);
        try {
          this.dateStart =
              DateUtils.parseDateStrictly(
                  objects.getString("start_Date"), new String[] {"yyyy-MM-dd HH:mm:ss.S"});
        } catch (JSONException e) {
          System.err.println("[ERROR] " + new Date() + ": " + e.getMessage());
        } catch (ParseException e) {
          System.err.println("[ERROR] " + new Date() + ": " + e.getMessage());
        }
        this.auctionDateStart = new Label("Wystawiono: " + this.dateFormat.format(this.dateStart));
        this.layout.addComponent(this.auctionDateStart);
        try {
          this.dateEnd =
              DateUtils.parseDateStrictly(
                  objects.getString("end_Date"), new String[] {"yyyy-MM-dd HH:mm:ss.S"});
        } catch (JSONException e) {
          System.err.println("[ERROR] " + new Date() + ": " + e.getMessage());
        } catch (ParseException e) {
          System.err.println("[ERROR] " + new Date() + ": " + e.getMessage());
        }
        this.auctionDateEnd = new Label("Koniec: " + this.dateFormat.format(this.dateEnd));
        this.layout.addComponent(this.auctionDateEnd);
        this.buttonSend.addClickListener(this);
        this.buttonSend.setIcon(FontAwesome.SEND_O);
        this.layout.addComponent(this.buttonSend);
      }
    }
  }