Exemplo n.º 1
0
 public void actionPerformed(ActionEvent evt) {
   // String sPassword = m_actionuser.getPassword();
   if (m_actionuser.authenticate()) {
     // p'adentro directo, no tiene password
     openAppView(m_actionuser);
   } else {
     // comprobemos la clave antes de entrar...
     String sPassword =
         JPasswordDialog.showEditPassword(
             JRootApp.this,
             AppLocal.getIntString("Label.Password"),
             m_actionuser.getName(),
             m_actionuser.getIcon());
     if (sPassword != null) {
       if (m_actionuser.authenticate(sPassword)) {
         openAppView(m_actionuser);
       } else {
         MessageInf msg =
             new MessageInf(
                 MessageInf.SGN_WARNING, AppLocal.getIntString("message.BadPassword"));
         msg.show(JRootApp.this);
       }
     }
   }
 }
Exemplo n.º 2
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();
  }
Exemplo n.º 3
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();
  }
Exemplo n.º 4
0
  private void processKey(char c) {

    if (c == '\n') {

      AppUser user = null;
      try {
        user = m_dlSystem.findPeopleByCard(inputtext.toString());
      } catch (BasicException e) {
        e.printStackTrace();
      }

      if (user == null) {
        // user not found
        MessageInf msg =
            new MessageInf(MessageInf.SGN_WARNING, AppLocal.getIntString("message.nocard"));
        msg.show(this);
      } else {
        openAppView(user);
      }

      inputtext = new StringBuffer();
    } else {
      inputtext.append(c);
    }
  }
Exemplo n.º 5
0
 private ScriptGroup(String key) {
   //            taskGroup = new JTaskPaneGroup();
   taskGroup = new JXTaskPane();
   taskGroup.setFocusable(false);
   taskGroup.setRequestFocusEnabled(false);
   taskGroup.setTitle(AppLocal.getIntString(key));
   taskGroup.setVisible(false); // Only groups with sons are visible.
 }
Exemplo n.º 6
0
    public void actionPerformed(ActionEvent evt) {

      String sNewPassword = Hashcypher.changePassword(JPrincipalApp.this, m_appuser.getPassword());
      if (sNewPassword != null) {
        try {

          m_dlSystem.execChangePassword(new Object[] {sNewPassword, m_appuser.getId()});
          m_appuser.setPassword(sNewPassword);
        } catch (BasicException e) {
          JMessageDialog.showMessage(
              JPrincipalApp.this,
              new MessageInf(
                  MessageInf.SGN_WARNING, AppLocal.getIntString("message.cannotchangepassword")));
        }
      }
    }
Exemplo n.º 7
0
 public ChangePasswordAction(String icon, String keytext) {
   putValue(Action.SMALL_ICON, new ImageIcon(JPrincipalApp.class.getResource(icon)));
   putValue(Action.NAME, AppLocal.getIntString(keytext));
   putValue(AppUserView.ACTION_TASKNAME, keytext);
 }
Exemplo n.º 8
0
  public boolean initApp(AppProperties props) {

    m_props = props;
    // setPreferredSize(new java.awt.Dimension(800, 600));

    // support for different component orientation languages.
    applyComponentOrientation(ComponentOrientation.getOrientation(Locale.getDefault()));

    // Database start
    try {
      session = AppViewConnection.createSession(m_props);
    } catch (BasicException e) {
      JMessageDialog.showMessage(this, new MessageInf(MessageInf.SGN_DANGER, e.getMessage(), e));
      return false;
    }

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

    // Create or upgrade the database if database version is not the expected
    String sDBVersion = readDataBaseVersion();
    if (!AppLocal.APP_VERSION.equals(sDBVersion)) {

      // Create or upgrade database

      String sScript =
          sDBVersion == null
              ? m_dlSystem.getInitScript() + "-create.sql"
              : m_dlSystem.getInitScript() + "-upgrade-" + sDBVersion + ".sql";

      if (JRootApp.class.getResource(sScript) == null) {
        JMessageDialog.showMessage(
            this,
            new MessageInf(
                MessageInf.SGN_DANGER,
                sDBVersion == null
                    ? AppLocal.getIntString(
                        "message.databasenotsupported",
                        session.DB
                            .getName()) // Create script does not exists. Database not supported
                    : AppLocal.getIntString(
                        "message.noupdatescript"))); // Upgrade script does not exist.
        session.close();
        return false;
      } else {
        // Create or upgrade script exists.
        if (JOptionPane.showConfirmDialog(
                this,
                AppLocal.getIntString(
                    sDBVersion == null ? "message.createdatabase" : "message.updatedatabase"),
                AppLocal.getIntString("message.title"),
                JOptionPane.YES_NO_OPTION,
                JOptionPane.QUESTION_MESSAGE)
            == JOptionPane.YES_OPTION) {

          try {
            BatchSentence bsentence = new BatchSentenceResource(session, sScript);
            bsentence.putParameter("APP_ID", Matcher.quoteReplacement(AppLocal.APP_ID));
            bsentence.putParameter("APP_NAME", Matcher.quoteReplacement(AppLocal.APP_NAME));
            bsentence.putParameter("APP_VERSION", Matcher.quoteReplacement(AppLocal.APP_VERSION));

            java.util.List l = bsentence.list();
            if (l.size() > 0) {
              JMessageDialog.showMessage(
                  this,
                  new MessageInf(
                      MessageInf.SGN_WARNING,
                      AppLocal.getIntString("Database.ScriptWarning"),
                      l.toArray(new Throwable[l.size()])));
            }
          } catch (BasicException e) {
            JMessageDialog.showMessage(
                this,
                new MessageInf(
                    MessageInf.SGN_DANGER, AppLocal.getIntString("Database.ScriptError"), e));
            session.close();
            return false;
          }
        } else {
          session.close();
          return false;
        }
      }
    }

    // Cargamos las propiedades de base de datos
    m_propsdb = m_dlSystem.getResourceAsProperties(m_props.getHost() + "/properties");

    // creamos la caja activa si esta no existe
    try {
      String sActiveCashIndex = m_propsdb.getProperty("activecash");
      Object[] valcash =
          sActiveCashIndex == null ? null : m_dlSystem.findActiveCash(sActiveCashIndex);
      if (valcash == null || !m_props.getHost().equals(valcash[0])) {
        // no la encuentro o no es de mi host por tanto creo una...
        setActiveCash(
            UUID.randomUUID().toString(),
            m_dlSystem.getSequenceCash(m_props.getHost()) + 1,
            new Date(),
            null);

        // creamos la caja activa
        m_dlSystem.execInsertCash(
            new Object[] {
              getActiveCashIndex(),
              m_props.getHost(),
              getActiveCashSequence(),
              getActiveCashDateStart(),
              getActiveCashDateEnd()
            });
      } else {
        setActiveCash(sActiveCashIndex, (Integer) valcash[1], (Date) valcash[2], (Date) valcash[3]);
      }
    } catch (BasicException e) {
      // Casco. Sin caja no hay pos
      MessageInf msg =
          new MessageInf(
              MessageInf.SGN_NOTICE, AppLocal.getIntString("message.cannotclosecash"), e);
      msg.show(this);
      session.close();
      return false;
    }

    // Leo la localizacion de la caja (Almacen).
    m_sInventoryLocation = m_propsdb.getProperty("location");
    if (m_sInventoryLocation == null) {
      m_sInventoryLocation = "0";
      m_propsdb.setProperty("location", m_sInventoryLocation);
      m_dlSystem.setResourceAsProperties(m_props.getHost() + "/properties", m_propsdb);
    }

    // Inicializo la impresora...
    m_TP = new DeviceTicket(this, m_props);

    // Inicializamos
    m_TTP = new TicketParser(getDeviceTicket(), m_dlSystem);
    printerStart();

    // Inicializamos la bascula
    m_Scale = new DeviceScale(this, m_props);

    // Inicializamos la scanpal
    m_Scanner = DeviceScannerFactory.createInstance(m_props);

    // Leemos los recursos basicos
    BufferedImage imgicon = m_dlSystem.getResourceAsImage("Window.Logo");
    m_jLblTitle.setIcon(imgicon == null ? null : new ImageIcon(imgicon));
    m_jLblTitle.setText(m_dlSystem.getResourceAsText("Window.Title"));

    String sWareHouse;
    try {
      sWareHouse = m_dlSystem.findLocationName(m_sInventoryLocation);
    } catch (BasicException e) {
      sWareHouse = null; // no he encontrado el almacen principal
    }

    // Show Hostname, Warehouse and URL in taskbar
    String url;
    try {
      url = session.getURL();
    } catch (SQLException e) {
      url = "";
    }
    m_jHost.setText("<html>" + m_props.getHost() + " - " + sWareHouse + "<br>" + url);

    showLogin();

    return true;
  }
Exemplo n.º 9
0
  // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
  private void initComponents() {

    m_jPanelTitle = new javax.swing.JPanel();
    m_jLblTitle = new javax.swing.JLabel();
    poweredby = new javax.swing.JLabel();
    jLabel2 = new javax.swing.JLabel();
    m_jPanelContainer = new javax.swing.JPanel();
    m_jPanelLogin = new javax.swing.JPanel();
    jPanel4 = new javax.swing.JPanel();
    jLabel1 = new javax.swing.JLabel();
    jPanel5 = new javax.swing.JPanel();
    m_jLogonName = new javax.swing.JPanel();
    jScrollPane1 = new javax.swing.JScrollPane();
    jPanel2 = new javax.swing.JPanel();
    jPanel8 = new javax.swing.JPanel();
    m_jClose = new javax.swing.JButton();
    jPanel1 = new javax.swing.JPanel();
    m_txtKeys = new javax.swing.JTextField();
    m_jPanelDown = new javax.swing.JPanel();
    panelTask = new javax.swing.JPanel();
    m_jHost = new javax.swing.JLabel();
    jPanel3 = new javax.swing.JPanel();

    setPreferredSize(new java.awt.Dimension(1024, 768));
    setLayout(new java.awt.BorderLayout());

    m_jPanelTitle.setBorder(
        javax.swing.BorderFactory.createMatteBorder(
            0, 0, 1, 0, javax.swing.UIManager.getDefaults().getColor("Button.darkShadow")));
    m_jPanelTitle.setLayout(new java.awt.BorderLayout());

    m_jLblTitle.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    m_jLblTitle.setText("Window.Title");
    m_jPanelTitle.add(m_jLblTitle, java.awt.BorderLayout.CENTER);

    poweredby.setIcon(
        new javax.swing.ImageIcon(
            getClass().getResource("/com/openbravo/images/poweredby.png"))); // NOI18N
    poweredby.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 5, 0, 5));
    m_jPanelTitle.add(poweredby, java.awt.BorderLayout.LINE_END);

    jLabel2.setPreferredSize(new java.awt.Dimension(142, 34));
    m_jPanelTitle.add(jLabel2, java.awt.BorderLayout.LINE_START);

    add(m_jPanelTitle, java.awt.BorderLayout.NORTH);

    m_jPanelContainer.setLayout(new java.awt.CardLayout());

    m_jPanelLogin.setLayout(new java.awt.BorderLayout());

    jPanel4.setLayout(new javax.swing.BoxLayout(jPanel4, javax.swing.BoxLayout.Y_AXIS));

    jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    jLabel1.setIcon(
        new javax.swing.ImageIcon(
            getClass().getResource("/com/openbravo/images/logo.png"))); // NOI18N
    jLabel1.setText(
        "<html><center>SysNeo POS es un software de punto de venta intuitivo, de f&aacute;cil uso e ideal para las PyMes Peruanas.<br>"
            + "Copyright \u00A9 2012-2014 SysNeo POS, <br>"
            + "http://www.sysneoconsulting.com/ptoventa<br>"
            + "<br>"
            + "SysNeo POS est&aacute; basado en Openbravo POS, sistema de codigo abierto que mantiene los derechos bajo los t&eacute;minos de la GNU General Public License mantenido por la Free Software Foundation.<br>"
            + "<br>"
            + "SysNeo POS es ejecutado bajo autorización de uso y/o licencia de SysNeo Consulting.<br>"
            + "<br>"
            + "SysNeo Consulting, empresa responsable de SysNeo POS. http://www.sysneoconsulting.com<br>"
            + "</center>");
    jLabel1.setAlignmentX(0.5F);
    jLabel1.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
    jLabel1.setMaximumSize(new java.awt.Dimension(800, 1024));
    jLabel1.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
    jPanel4.add(jLabel1);

    m_jPanelLogin.add(jPanel4, java.awt.BorderLayout.CENTER);

    m_jLogonName.setBorder(javax.swing.BorderFactory.createEmptyBorder(5, 5, 5, 5));
    m_jLogonName.setLayout(new java.awt.BorderLayout());

    jScrollPane1.setHorizontalScrollBarPolicy(
        javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    jScrollPane1.setVerticalScrollBarPolicy(
        javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
    jScrollPane1.setPreferredSize(new java.awt.Dimension(510, 118));
    m_jLogonName.add(jScrollPane1, java.awt.BorderLayout.CENTER);

    jPanel2.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 5, 0, 5));
    jPanel2.setLayout(new java.awt.BorderLayout());

    jPanel8.setLayout(new java.awt.GridLayout(0, 1, 5, 5));

    m_jClose.setIcon(
        new javax.swing.ImageIcon(
            getClass().getResource("/com/openbravo/images/exit.png"))); // NOI18N
    m_jClose.setText(AppLocal.getIntString("Button.Close")); // NOI18N
    m_jClose.setFocusPainted(false);
    m_jClose.setFocusable(false);
    m_jClose.setPreferredSize(new java.awt.Dimension(115, 35));
    m_jClose.setRequestFocusEnabled(false);
    m_jClose.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            m_jCloseActionPerformed(evt);
          }
        });
    jPanel8.add(m_jClose);

    jPanel2.add(jPanel8, java.awt.BorderLayout.NORTH);

    jPanel1.setLayout(null);

    m_txtKeys.setPreferredSize(new java.awt.Dimension(0, 0));
    m_txtKeys.addKeyListener(
        new java.awt.event.KeyAdapter() {
          public void keyTyped(java.awt.event.KeyEvent evt) {
            m_txtKeysKeyTyped(evt);
          }
        });
    jPanel1.add(m_txtKeys);
    m_txtKeys.setBounds(0, 0, 0, 0);

    jPanel2.add(jPanel1, java.awt.BorderLayout.CENTER);

    m_jLogonName.add(jPanel2, java.awt.BorderLayout.LINE_END);

    jPanel5.add(m_jLogonName);

    m_jPanelLogin.add(jPanel5, java.awt.BorderLayout.SOUTH);

    m_jPanelContainer.add(m_jPanelLogin, "login");

    add(m_jPanelContainer, java.awt.BorderLayout.CENTER);

    m_jPanelDown.setBorder(
        javax.swing.BorderFactory.createMatteBorder(
            1, 0, 0, 0, javax.swing.UIManager.getDefaults().getColor("Button.darkShadow")));
    m_jPanelDown.setLayout(new java.awt.BorderLayout());

    m_jHost.setIcon(
        new javax.swing.ImageIcon(
            getClass().getResource("/com/openbravo/images/display.png"))); // NOI18N
    m_jHost.setText("*Hostname");
    panelTask.add(m_jHost);

    m_jPanelDown.add(panelTask, java.awt.BorderLayout.LINE_START);
    m_jPanelDown.add(jPanel3, java.awt.BorderLayout.LINE_END);

    add(m_jPanelDown, java.awt.BorderLayout.SOUTH);
  } // </editor-fold>//GEN-END:initComponents