예제 #1
0
  public void showTask(String sTaskClass) {

    m_appview.waitCursorBegin();

    if (m_appuser.hasPermission(sTaskClass)) {

      JPanelView m_jMyView = (JPanelView) m_aCreatedViews.get(sTaskClass);

      // cierro la antigua
      if (m_jLastView == null || (m_jMyView != m_jLastView && m_jLastView.deactivate())) {

        // Construct the new view
        if (m_jMyView == null) {

          // Is the view prepared
          m_jMyView = m_aPreparedViews.get(sTaskClass);
          if (m_jMyView == null) {
            // The view is not prepared. Try to get as a Bean...
            try {
              m_jMyView = (JPanelView) m_appview.getBean(sTaskClass);
            } catch (BeanFactoryException e) {
              m_jMyView = new JPanelNull(m_appview, e);
            }
          }

          m_jPanelContainer.add(m_jMyView.getComponent(), sTaskClass);
          m_aCreatedViews.put(sTaskClass, m_jMyView);
        }

        // ejecuto la tarea
        try {
          m_jMyView.activate();
        } catch (BasicException e) {
          JMessageDialog.showMessage(
              this,
              new MessageInf(
                  MessageInf.SGN_WARNING, AppLocal.getIntString("message.notactive"), e));
        }

        // se tiene que mostrar el panel
        m_jLastView = m_jMyView;

        showView(sTaskClass);
        // Y ahora que he cerrado la antigua me abro yo
        String sTitle = m_jMyView.getTitle();
        m_jPanelTitle.setVisible(sTitle != null);
        m_jTitle.setText(sTitle);
      }
    } else {
      // No hay permisos para ejecutar la accion...
      JMessageDialog.showMessage(
          this,
          new MessageInf(MessageInf.SGN_WARNING, AppLocal.getIntString("message.notpermissions")));
    }
    m_appview.waitCursorEnd();
  }
예제 #2
0
 public boolean deactivate() {
   if (m_jLastView == null) {
     return true;
   } else if (m_jLastView.deactivate()) {
     m_jLastView = null;
     showView("<NULL>");
     return true;
   } else {
     return false;
   }
 }
예제 #3
0
  /** Creates new form JPrincipalApp */
  public JPrincipalApp(JRootApp appview, AppUser appuser) {

    m_appview = appview;
    m_appuser = appuser;

    m_dlSystem =
        (DataLogicSystem) m_appview.getBean("com.openbravo.pos.forms.DataLogicSystemCreate");

    // Cargamos los permisos del usuario
    m_appuser.fillPermissions(m_dlSystem);

    m_principalnotificator = new JPrincipalNotificator();

    m_actionfirst = null;
    m_jLastView = null;
    m_aPreparedViews = new HashMap<String, JPanelView>();
    m_aCreatedViews = new HashMap<String, JPanelView>();

    initComponents();

    // m_jPanelTitle.setUI(new GradientUI());
    m_jPanelTitle.setBorder(RoundedBorder.createGradientBorder());
    m_jPanelTitle.setVisible(false);

    // Anado el panel nulo
    m_jPanelContainer.add(new JPanel(), "<NULL>");
    showView("<NULL>");

    try {

      ScriptMenu menu = new ScriptMenu();

      ScriptEngine eng = ScriptFactory.getScriptEngine(ScriptFactory.BEANSHELL);
      eng.put("menu", menu);
      eng.eval(m_dlSystem.getResourceAsText("Menu.Root"));

      m_jPanelLeft.setViewportView(menu.getTaskPane());
    } catch (ScriptException e) {
      e.printStackTrace();
      // Error Message
    }
  }