Beispiel #1
0
  public void executeTask(String sTaskClass) {

    m_appview.waitCursorBegin();

    if (m_appuser.hasPermission(sTaskClass)) {
      try {
        ProcessAction myProcess = (ProcessAction) m_appview.getBean(sTaskClass);

        // execute the proces
        try {
          MessageInf m = myProcess.execute();
          if (m != null) {
            // si devuelve un mensaje, lo muestro
            JMessageDialog.showMessage(JPrincipalApp.this, m);
          }
        } catch (BasicException eb) {
          // Si se produce un error lo muestro.
          JMessageDialog.showMessage(JPrincipalApp.this, new MessageInf(eb));
        }
      } catch (BeanFactoryException e) {
        JMessageDialog.showMessage(
            JPrincipalApp.this,
            new MessageInf(MessageInf.SGN_WARNING, AppLocal.getIntString("Label.LoadError"), e));
      }
    } else {
      // No hay permisos para ejecutar la accion...
      JMessageDialog.showMessage(
          JPrincipalApp.this,
          new MessageInf(MessageInf.SGN_WARNING, AppLocal.getIntString("message.notpermissions")));
    }
    m_appview.waitCursorEnd();
  }
Beispiel #2
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();
  }
Beispiel #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
    }
  }