Package psconsole.UserItemRenderer

Examples of psconsole.UserItemRenderer.UserItemValue


        pnlRenderUsers = new UserItemRenderer();
        lstUsers.setCellRenderer(new DefaultListCellRenderer() {
            public Component getListCellRendererComponent(JList list,
                         Object value, int index, boolean isSelected,
                         boolean cellHasFocus) {
                UserItemValue val = (UserItemValue)value;
                if (val.accountID == -1) {
                    val.balance = 0.0;
                    val.profit = 0.0;
                    val.terminalCount = listModel.getSize() - 1;
                    for (int i = 0; i < listModel.getSize(); ++i) {
                        UserItemValue item = (UserItemValue)listModel.get(i);
                        if (item.accountID == -1) continue;
                        val.balance += item.balance;
                        val.profit += item.profit;
                    }
                }
                pnlRenderUsers.setItemSelected(isSelected);
                pnlRenderUsers.setValue(val, MainForm.this);
                pnlRenderUsers.setIconName(val.terminalConnected ? userActive3 : userActive1);
                return pnlRenderUsers;
            }
        });
        lstUsers.setFixedCellHeight(48);
        lstUsers.addListSelectionListener(new ListSelectionListener() {
            @Override
            public void valueChanged(ListSelectionEvent e) {
                List<UserItemValue> items = getSelectedUsers();
                onUserSelected(items, paneCurrent);
               
            }
        });
        //DefaultListSelectionModel smodel = (DefaultListSelectionModel)lstUsers.getSelectionModel();
        //smodel.
       
        listModel.addElement(new UserItemValue(-1, "Все счета", 0, 0));
        //<editor-fold desc=" test list ">
        /*UserItemValue[] bf = new UserItemValue[6];
        double d = 0;
        bf[0] = new UserItemValue(18051, "Быков А.П.",      doGDev(6192.01, 10), d);
        bf[1] = new UserItemValue(18505, "Гаер А.В.",       doGDev(3256.16, 10), d);
View Full Code Here


            if (item != null) {
                NodeList nl = item.getElementsByTagName("user");
                for (int i = 0; i < nl.getLength(); ++i) {
                    Element usr = (Element)nl.item(i);
                    long id = Long.parseLong(usr.getAttribute("id"));
                    UserItemValue userItem = new UserItemValue(id);
                    userItem.xmlImportFromNode(usr);
                    //userItem.loadOrdersHistory();
                    addUser(userItem);
                }
                lstUsers.updateUI();
            }
View Full Code Here

    }//GEN-LAST:event_pmUsersPopupMenuWillBecomeVisible

    private void btnSaveAccDataActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSaveAccDataActionPerformed
        List<UserItemValue> selection = getSelectedUsers();
        if (selection.size() != 1) return;
        UserItemValue user = selection.get(0);
        user.name = txtUserName.getText();
        user.traderComission = ((Byte)txtTraderComission.getValue()).byteValue();
        showGenAction("pnlTrading");
    }//GEN-LAST:event_btnSaveAccDataActionPerformed
View Full Code Here

    }//GEN-LAST:event_lstUsersMouseClicked

    private void lblRemoveAccountMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lblRemoveAccountMouseClicked
        List<UserItemValue> selection = getSelectedUsers();
        if (selection.size() != 1) return;
        UserItemValue user = selection.get(0);
        if (DialogForm.showMessage("Удаление аккаунта", "Подтвердите, "
                + "действительно ли вы хотите удалить аккаунт \"" + user.accountID
                + "\" из базы?", "Да", "Нет", this) != DialogForm.RET_OK) return;
        listModel.removeElement(user);
        lstUsers.updateUI();
View Full Code Here

     * @return null, если такого объекта нет
     */
    public UserItemValue getUser(long accID) {
        if (accID < 1) return null;
        for (int i = 0; i < listModel.getSize(); ++i) {
            UserItemValue vl = (UserItemValue)listModel.get(i);
            if (vl.accountID == accID) return vl;
        }
        return null;
    }
View Full Code Here

                        EventQueue.invokeLater(new Runnable() {
                            @Override
                            public void run() {
                                List<Terminal> list = form.server.getConnectionsList();
                                for (Terminal t : list) {
                                    UserItemValue item = form.getUser(t.getID());
                                    if (item == null) continue;
                                    PSPackage pkg = new PSPackage();
                                    pkg.set("cmd", "historyID");
                                    OrderList.OrderItem order = item.history.getLastByID();
                                    pkg.set("id", Long.toString(order != null ? order.id : -1));
View Full Code Here

                try {
                    EventQueue.invokeAndWait(new Runnable() {
                        @Override
                        public void run() {
                            boolean flag = false;
                            UserItemValue user = form.getUser(accID);
                            if (user == null) {
                                user = new UserItemValue(accID);
                                flag = true;
                            }
                            user.terminalAddress = _pkg.get("executableAddress");
                           
                            user.balance = bal;
                            user.profit = prof;
                            user.terminalConnected = true;
                            user.currency = crnc;
                            if (flag) {
                                form.addUser(user);
                                form.saveUserList();
                            }
                            ans.set("symbols", form.symbolList.getSymbolList());
                            OrderList.OrderItem order = user.history.getLastByID();
                            if (order != null)
                                ans.set("lastHistOrderID", Long.toString(order.id));
                            else ans.set("lastHistOrderID", Long.toString(-1));
                        }
                    });
                    // -- отправка ответа
                    sendPackage(ans);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
            //</editor-fold>
           
            //<editor-fold desc=" Обновление информации ">
            else if ("data-update".equals(cmd)) {
                final double b = Double.parseDouble(pkg.get("balance"));
                final double p = Double.parseDouble(pkg.get("profit"));
               
                String sbuf = pkg.get("time");
               
                final long tm = (sbuf == null ? 0L : Integer.parseInt(sbuf) * 1000L);
               
                // -- вытаскиваем ордера
                String str = pkg.get("orders");
                PSPackage orderspkg = null;
                if (str != null) {
                    orderspkg = new PSPackage();
                    if (!orderspkg.unpack(new StringBuilder(str)))
                        orderspkg = null;
                }
                final PSPackage _opkg = orderspkg;
               
                // -- обновление информации о символах
                final String symbolData = pkg.get("symbols");
                try {
                    EventQueue.invokeLater(new Runnable() {
                        @Override
                        public void run() {
                            UserItemValue item = form.getUser(accID);
                            if (item == null) return;
                           
                            // получение списока ордеров в аккаунте
                            if (_opkg != null) {
                                item.orders.refreshOrders(_opkg, true);
                            }
                           
                            // обновление серверного времени
                            if (tm != 0L)
                                form.setCurrentTime(tm);
                           
                            // обновление данных аккаунта
                            boolean flag =
                                    Math.abs(item.balance - b) > 1d ||
                                    Math.abs(item.profit - p) > 1d;
                            item.balance = b;
                            item.profit = p;
                            if (flag) form.lstUsers.repaint();
                           
                            // -- обновление MarketInfo
                            if (symbolData != null)
                                form.symbolList.refreshSymbolData(symbolData);
                           
                            // обновление панелей
                            List<UserItemValue> uList = form.getSelectedUsers();
                            if (uList.contains(item))
                                form.onUserSelected(uList, form.paneCurrent);
                        }
                    });
                } catch (Exception e) {
                    e.printStackTrace();
                }
               
            }
            //</editor-fold>
           
            //<editor-fold desc=" История ордеров ">
            else if ("orders-history".equals(cmd)) {
                try {
                    final PSPackage _pkg = pkg;
                    EventQueue.invokeAndWait(new Runnable() {
                        @Override
                        public void run() {
                            UserItemValue user = form.getUser(accID);
                            if (user != null) {
                                user.history.refreshOrders(_pkg, false);
                                user.saveOrdersHistory();
                            }
                           
                            // обновление панелей
                            List<UserItemValue> uList = form.getSelectedUsers();
                            if (uList.contains(user))
View Full Code Here

                    connections.remove(this);
                    System.out.println("count connections: " + connections.size());
                }
                if (accID != 0) {
                    synchronized (form) {
                        UserItemValue item = form.getUser(accID);
                        if (item != null) {
                            item.terminalConnected = false;
                            form.lstUsers.repaint();
                        }
                    }
View Full Code Here

TOP

Related Classes of psconsole.UserItemRenderer.UserItemValue

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.