Example #1
0
  public void renderHomeTab() {
    homeTab.getChildren().clear();

    dashboardController.render(homeTab, this, true);

    West w = layout.getWest();
    w.getChildren().clear();
    sideController.render(w, this, false);
  }
Example #2
0
  @SuppressWarnings("serial")
  protected Component doCreatePart(Component parent) {
    PageDefinition pagedef =
        Executions.getCurrent()
            .getPageDefinition(ThemeManager.getThemeResource("zul/desktop/desktop.zul"));
    Component page = Executions.createComponents(pagedef, parent, null);
    layout = (Borderlayout) page.getFellow("layout");
    headerContainer = page.getFellow("northBody");
    pnlHead = (HeaderPanel) headerContainer.getFellow("header");

    layout.addEventListener("onZoom", this);
    layout.addEventListener(DrillEvent.ON_DRILL_DOWN, this);

    West w = layout.getWest();
    w.addEventListener(
        Events.ON_OPEN,
        new EventListener<Event>() {
          @Override
          public void onEvent(Event event) throws Exception {
            OpenEvent oe = (OpenEvent) event;
            updateMenuCollapsedPreference(!oe.isOpen());
          }
        });
    w.addEventListener(
        Events.ON_SWIPE,
        new EventListener<SwipeEvent>() {

          @Override
          public void onEvent(SwipeEvent event) throws Exception {
            if ("left".equals(event.getSwipeDirection())) {
              West w = (West) event.getTarget();
              if (w.isOpen()) {
                w.setOpen(false);
                updateMenuCollapsedPreference(true);
              }
            }
          }
        });

    w.addEventListener(
        Events.ON_SIZE,
        new EventListener<Event>() {

          @Override
          public void onEvent(Event event) throws Exception {
            West west = (West) event.getTarget();
            updateSideControllerWidthPreference(west.getWidth());
          }
        });

    UserPreference pref = SessionManager.getSessionApplication().getUserPreference();
    boolean menuCollapsed = pref.isPropertyBool(UserPreference.P_MENU_COLLAPSED);
    w.setOpen(!menuCollapsed);

    East e = layout.getEast();
    e.addEventListener(
        Events.ON_OPEN,
        new EventListener<Event>() {
          @Override
          public void onEvent(Event event) throws Exception {
            OpenEvent oe = (OpenEvent) event;
            updateHelpCollapsedPreference(!oe.isOpen());
            HtmlBasedComponent comp = windowContainer.getComponent();
            if (comp != null) {
              contextHelp.setVisible(!oe.isOpen());
              if (!oe.isOpen()) layout.getEast().setVisible(false);
            }
          }
        });

    e.addEventListener(
        Events.ON_SWIPE,
        new EventListener<SwipeEvent>() {

          @Override
          public void onEvent(SwipeEvent event) throws Exception {
            if ("right".equals(event.getSwipeDirection())) {
              East e = (East) event.getTarget();
              if (e.isOpen()) {
                e.setOpen(false);
                updateHelpCollapsedPreference(true);
              }
            }
          }
        });

    e.addEventListener(
        Events.ON_SIZE,
        new EventListener<Event>() {

          @Override
          public void onEvent(Event event) throws Exception {
            East east = (East) event.getTarget();
            updateHelpWidthPreference(east.getWidth());
          }
        });

    String westWidth = getWestWidthPreference();
    String eastWidth = getEastWidthPreference();

    // Set preference width
    if (westWidth != null || eastWidth != null) {

      // If both panels have prefered size check that the sum is not bigger than the browser
      if (westWidth != null && eastWidth != null) {
        ClientInfo browserInfo = getClientInfo();
        int browserWidth = browserInfo.desktopWidth;
        int wWidth = Integer.valueOf(westWidth.replace("px", ""));
        int eWidth = Integer.valueOf(eastWidth.replace("px", ""));

        if (eWidth + wWidth <= browserWidth) {
          w.setWidth(westWidth);
          e.setWidth(eastWidth);
        }

      } else if (westWidth != null) w.setWidth(westWidth);
      else if (eastWidth != null) e.setWidth(eastWidth);
    }

    boolean helpCollapsed = pref.isPropertyBool(UserPreference.P_HELP_COLLAPSED);
    e.setVisible(!helpCollapsed);

    helpController.render(e, this);

    Center windowArea = layout.getCenter();

    windowContainer.createPart(windowArea);

    homeTab = new Tabpanel();
    windowContainer.addWindow(
        homeTab, Util.cleanAmp(Msg.getMsg(Env.getCtx(), "Home")), false, null);
    homeTab.getLinkedTab().setSclass("desktop-hometab");
    homeTab.setSclass("desktop-home-tabpanel");
    BusyDialog busyDialog = new BusyDialog();
    busyDialog.setShadow(false);
    homeTab.appendChild(busyDialog);

    // register as 0
    registerWindow(homeTab);

    BroadcastMessageWindow messageWindow = new BroadcastMessageWindow(pnlHead);
    BroadcastMsgUtil.showPendingMessage(Env.getAD_User_ID(Env.getCtx()), messageWindow);

    if (!layout.getDesktop().isServerPushEnabled()) {
      layout.getDesktop().enableServerPush(true);
    }

    Runnable runnable =
        new Runnable() {
          public void run() {
            try {
              Thread.sleep(100);
            } catch (InterruptedException e) {
            }

            IServerPushCallback callback =
                new IServerPushCallback() {
                  public void updateUI() {
                    Properties ctx =
                        (Properties)
                            layout
                                .getDesktop()
                                .getSession()
                                .getAttribute(SessionContextListener.SESSION_CTX);
                    try {
                      ServerContext.setCurrentInstance(ctx);
                      renderHomeTab();
                    } finally {
                      ServerContext.dispose();
                    }
                  }
                };
            ServerPushTemplate template = new ServerPushTemplate(layout.getDesktop());
            template.executeAsync(callback);
          }
        };

    Adempiere.getThreadPoolExecutor().submit(new DesktopRunnable(runnable, layout.getDesktop()));

    ToolBar toolbar = new ToolBar();
    windowContainer.getComponent().appendChild(toolbar);

    showHeader =
        new ToolBarButton() {
          @Override
          public void onPageDetached(Page page) {
            super.onPageDetached(page);
            if (DefaultDesktop.this.headerPopup != null) {
              DefaultDesktop.this.headerPopup.setPage(null);
            }
          }
        };
    toolbar.appendChild(showHeader);
    showHeader.setImage(ThemeManager.getThemeResource(IMAGES_THREELINE_MENU_PNG));
    showHeader.addEventListener(Events.ON_CLICK, this);
    showHeader.setSclass("window-container-toolbar-btn");
    showHeader.setStyle("cursor: pointer; border: 1px solid transparent; padding: 2px;");
    showHeader.setVisible(false);

    max = new ToolBarButton();
    toolbar.appendChild(max);
    max.setImage(ThemeManager.getThemeResource(IMAGES_UPARROW_PNG));
    max.addEventListener(Events.ON_CLICK, this);
    max.setSclass("window-container-toolbar-btn");
    max.setStyle("cursor: pointer; border: 1px solid transparent; padding: 2px;");

    contextHelp = new ToolBarButton();
    toolbar.appendChild(contextHelp);
    contextHelp.setImage(ThemeManager.getThemeResource(IMAGES_CONTEXT_HELP_PNG));
    contextHelp.addEventListener(Events.ON_CLICK, this);
    contextHelp.setSclass("window-container-toolbar-btn context-help-btn");
    contextHelp.setStyle("cursor: pointer; border: 1px solid transparent; padding: 2px;");
    contextHelp.setTooltiptext(Util.cleanAmp(Msg.getElement(Env.getCtx(), "AD_CtxHelp_ID")));
    contextHelp.setVisible(!e.isVisible());

    boolean headerCollapsed = pref.isPropertyBool(UserPreference.P_HEADER_COLLAPSED);
    if (headerCollapsed) {
      collapseHeader();
    }

    return layout;
  }
Example #3
0
  /** Ststic Init */
  void jbInit() throws Exception {
    label.setText("Label");

    Tabs tabs = new Tabs();
    tabbox.appendChild(tabs);

    Tabpanels tabpanels = new Tabpanels();
    tabbox.appendChild(tabpanels);

    tabs.appendChild(new Tab(Msg.getMsg(Env.getCtx(), "PriceHistory")));
    tabs.appendChild(new Tab(Msg.translate(Env.getCtx(), "QtyReserved")));
    tabs.appendChild(new Tab(Msg.translate(Env.getCtx(), "QtyOrdered")));
    tabs.appendChild(new Tab(Msg.getMsg(Env.getCtx(), "QtyUnconfirmed")));

    if (m_M_Product_ID != 0) tabs.appendChild(new Tab(Msg.getMsg(Env.getCtx(), "ATP")));

    pricePane.setHeight("100%");
    pricePane.appendChild(m_tablePrice);
    tabpanels.appendChild(pricePane);

    reservedPane.setHeight("100%");
    reservedPane.appendChild(m_tableReserved);
    tabpanels.appendChild(reservedPane);

    orderedPane.setHeight("100%");
    orderedPane.appendChild(m_tableOrdered);
    tabpanels.appendChild(orderedPane);

    unconfirmedPane.setHeight("100%");
    unconfirmedPane.appendChild(m_tableUnconfirmed);
    tabpanels.appendChild(unconfirmedPane);

    if (m_M_Product_ID != 0) {
      atpPane.setHeight("100%");
      atpPane.appendChild(m_tableAtp);
      tabpanels.appendChild(atpPane);
    }

    tabbox.setSelectedIndex(0);
    tabbox.addEventListener(Events.ON_SELECT, this);
    confirmPanel.addActionListener(this);

    Borderlayout borderlayout = new Borderlayout();
    this.setWidth("700px");
    this.setHeight("400px");
    borderlayout.setStyle("border: none; position: relative");
    this.appendChild(borderlayout);
    this.setClosable(true);

    North north = new North();
    north.setStyle("border: none");
    borderlayout.appendChild(north);
    north.appendChild(label);

    Center center = new Center();
    center.setSclass("dialog-content");
    center.setAutoscroll(true);
    borderlayout.appendChild(center);
    center.appendChild(tabbox);
    tabbox.setVflex("1");
    tabbox.setHflex("1");

    South south = new South();
    south.setSclass("dialog-footer");
    borderlayout.appendChild(south);
    south.appendChild(confirmPanel);
  } //	jbInit