private JPanel getClickableTagsPanel() { JPanel pnl = new JPanel(); pnl.setLayout(new GridLayout(0, 3)); ArrayList<Commontags> listTags = new ArrayList<>(mapAllTags.values()); Collections.sort(listTags); for (final Commontags ctag : listTags) { JCheckBox cb = new JCheckBox(ctag.getText()); cb.setForeground(GUITools.getColor(ctag.getColor())); cb.setFont(ctag.getType() == 0 ? SYSConst.ARIAL12 : SYSConst.ARIAL12BOLD); cb.setSelected(listSelectedTags.contains(ctag)); cb.addItemListener( e -> { if (e.getStateChange() == ItemEvent.SELECTED) { listSelectedTags.add(ctag); add(createButton(ctag)); } else { listSelectedTags.remove(ctag); mapButtons.remove(ctag); } notifyListeners(ctag); }); pnl.add(cb); } return pnl; }
@Override public Collection<DebuggerSession> getSessions() { synchronized (mySessions) { final Collection<DebuggerSession> values = mySessions.values(); return values.isEmpty() ? Collections.<DebuggerSession>emptyList() : new ArrayList<DebuggerSession>(values); } }
protected void setButtonsSize() { int nMaxWidth = 0, nMaxHeight = 0; Dimension objSize; Iterator objIterator = buttons.values().iterator(); while (objIterator.hasNext()) { JButton objButton = (JButton) objIterator.next(); objButton.setPreferredSize(null); objSize = objButton.getPreferredSize(); nMaxWidth = Math.max(nMaxWidth, objSize.width); nMaxHeight = Math.max(nMaxHeight, objSize.height); } objSize = new Dimension(nMaxWidth, nMaxHeight); d = objSize; objIterator = buttons.values().iterator(); while (objIterator.hasNext()) { ((JButton) objIterator.next()).setPreferredSize(objSize); } }
private boolean initializeOutstanding2( DataGrid grid, boolean ascend, boolean caseOn, BuySellType buySellType, BuySellType editOutstandingOrderBuySellType, IOpenCloseRelationSite openCloseRelationSite, Order mapOrder) { Boolean isSpot = openCloseRelationSite.getOrderType() == null ? null : openCloseRelationSite.getOrderType().isSpot(); this.setOutstandingOrders( buySellType, mapOrder, isSpot, openCloseRelationSite.isMakeLimitOrder(), openCloseRelationSite.isDelivery()); HashMap<Guid, RelationOrder> editOutstandingOrders = this.getEditOutstandingOrders(editOutstandingOrderBuySellType, mapOrder); boolean hasChange = this.hasChange(grid, editOutstandingOrders); if (hasChange) { this.unbindOutstanding(); this._outstandingKey = Guid.newGuid().toString(); this._bindingSourceForOutstanding = new tradingConsole.ui.grid.BindingSource(); boolean isMakeOrder2 = this._settingsManager.get_Customer().get_SingleAccountOrderType() == 2 || this._settingsManager.get_Customer().get_MultiAccountsOrderType() == 2; RelationOrder.initialize( isMakeOrder2, grid, this._outstandingKey, editOutstandingOrders.values(), this._bindingSourceForOutstanding, openCloseRelationSite, editOutstandingOrderBuySellType); int column = this._bindingSourceForOutstanding.getColumnByName(OutstandingOrderColKey.IsBuy); if (column != -1) { grid.sortColumn(column, false, ascend); TableColumnChooser.hideColumn(grid, column); } } else { this._outstandingKey = grid.get_BindingSource().get_DataSourceKey(); this._outstandingOrders.clear(); for (int row = 0; row < grid.getRowCount(); row++) { RelationOrder relationOrder = (RelationOrder) (grid.getObject(row)); this._outstandingOrders.put(relationOrder.get_OpenOrderId(), relationOrder); } } return hasChange; }
private JButton createButton(final Commontags commontag) { if (mapButtons.containsKey(commontag)) { OPDE.debug("shortcut"); return mapButtons.get(commontag); } final JButton jButton = new JButton( commontag.getText(), editmode ? SYSConst.icon16tagPurpleDelete2 : SYSConst.icon16tagPurple); jButton.setFont(SYSConst.ARIAL12); jButton.setBorder(new RoundedBorder(10)); jButton.setHorizontalTextPosition(SwingConstants.LEADING); jButton.setForeground(SYSConst.purple1[SYSConst.dark3]); if (editmode) { jButton.addActionListener( e -> { listSelectedTags.remove(commontag); mapButtons.remove(commontag); SwingUtilities.invokeLater( () -> { removeAll(); add(txtTags); if (btnPickTags != null) { add(btnPickTags); } int tagnum = 1; for (JButton btn : mapButtons.values()) { if (tagnum % MAXLINE == 0) { add(btn, RiverLayout.LINE_BREAK); } else { add(btn, RiverLayout.LEFT); } tagnum++; } remove(jButton); revalidate(); repaint(); notifyListeners(commontag); }); }); } mapButtons.put(commontag, jButton); return jButton; }
// for Instrument code with "#" // for IsBuy = true: // SumBuy = all confirmed order.Buy.LotBalance + all unconfirmed order.Buy.Lot // SumSell = all confirmed order.Sell.LotBalance // for IsBuy = false: // SumSell = all confirmed order.Sell.LotBalance + all unconfirmed order.Sell.Lot // SumBuy = all confirmed order.Buy.LotBalance public GetSumLotBSForOpenOrderWithFlagResult getSumLotBSForOpenOrderWithFlag(boolean isBuy) { BigDecimal[] sumLot = new BigDecimal[] {BigDecimal.ZERO, BigDecimal.ZERO}; boolean isExistsUnconfirmedOrder = false; HashMap<Guid, Transaction> accountInstrumentTransactions = this.getAccountInstrumentTransactions(); for (Iterator<Transaction> iterator = accountInstrumentTransactions.values().iterator(); iterator.hasNext(); ) { Transaction transaction = iterator.next(); if (transaction.get_Phase() == Phase.Executed || transaction.get_Phase() == Phase.Placing || transaction.get_Phase() == Phase.Placed) { for (Iterator<Order> iterator2 = transaction.get_Orders().values().iterator(); iterator2.hasNext(); ) { Order order = iterator2.next(); if (order.get_LotBalance().compareTo(BigDecimal.ZERO) > 0) { if (isBuy) { if (order.get_IsBuy()) { if (transaction.get_Phase() == Phase.Executed) { sumLot[0] = sumLot[0].add(order.get_LotBalance()); } else { sumLot[0] = sumLot[0].add(order.get_Lot()); isExistsUnconfirmedOrder = true; } } else { if (transaction.get_Phase() == Phase.Executed) { sumLot[1] = sumLot[1].add(order.get_LotBalance()); } } } else { if (order.get_IsBuy()) { if (transaction.get_Phase() == Phase.Executed) { sumLot[0] = sumLot[0].add(order.get_LotBalance()); } } else { if (transaction.get_Phase() == Phase.Executed) { sumLot[1] = sumLot[1].add(order.get_LotBalance()); } else { sumLot[1] = sumLot[1].add(order.get_Lot()); isExistsUnconfirmedOrder = true; } } } } } } } return new GetSumLotBSForOpenOrderWithFlagResult( sumLot[0], sumLot[1], isExistsUnconfirmedOrder); }
public HashMap<Guid, RelationOrder> getPlaceRelation() { HashMap<Guid, RelationOrder> placeRelation = null; HashMap<Guid, RelationOrder> outstandingOrders = this.getOutstandingOrders(); for (RelationOrder relationOrder : outstandingOrders.values()) { if (relationOrder.get_IsSelected() && relationOrder.get_CloseLot().compareTo(BigDecimal.ZERO) > 0) { if (placeRelation == null) placeRelation = new HashMap<Guid, RelationOrder>(); placeRelation.put(relationOrder.get_OpenOrderId(), relationOrder); } } return placeRelation; }
private HashMap<Guid, Transaction> getAccountInstrumentTransactions() { HashMap<Guid, Transaction> transactions = null; HashMap<Guid, Transaction> accountTransactions = this._account.get_Transactions(); HashMap<Guid, Transaction> instrumentTransactions = this._instrument.get_Transactions(); if (accountTransactions == null || instrumentTransactions == null) { return transactions; } transactions = new HashMap<Guid, Transaction>(); for (Iterator<Transaction> iterator = accountTransactions.values().iterator(); iterator.hasNext(); ) { Transaction accountTransaction = iterator.next(); Guid accountTransactionId = accountTransaction.get_Id(); if (instrumentTransactions.containsKey(accountTransactionId)) { transactions.put(accountTransactionId, accountTransaction); } } return transactions; }
private void updateParams(EDPCellData data) { paramComboBox.removeAllItems(); paramKeys = data.getPlugin().getPrintfDescrs(!m_isCrawlRuleEditor); if (!m_isCrawlRuleEditor) { paramComboBox.addItem(STRING_LITERAL); } for (Iterator it = paramKeys.values().iterator(); it.hasNext(); ) { ConfigParamDescr descr = (ConfigParamDescr) it.next(); int type = descr.getType(); if (!m_isCrawlRuleEditor && (type == ConfigParamDescr.TYPE_SET || type == ConfigParamDescr.TYPE_RANGE)) continue; paramComboBox.addItem(descr); } paramComboBox.setEnabled(true); paramComboBox.setSelectedIndex(0); paramComboBox.setToolTipText("Select a parameter to insert into the format string"); insertButton.setEnabled(true); }
private void writeAll() { List<MessageBean> beans = messageTable.getBeans(); HashMap<Integer, Message> map = new HashMap<Integer, Message>(2 * beans.size()); for (MessageBean mb : beans) { map.put(mb.m.hashCode(), mb.m); } if (fileChooser == null) fileChooser = new FileManager(null, null, null, (PreferencesExt) prefs.node("FileManager")); String defloc = (raf.getLocation() == null) ? "." : raf.getLocation(); String dirName = fileChooser.chooseDirectory(defloc); if (dirName == null) return; try { int count = 0; for (Message m : map.values()) { String header = m.getHeader(); if (header != null) { header = header.split(" ")[0]; } else { header = Integer.toString(Math.abs(m.hashCode())); } File file = new File(dirName + "/" + header + ".bufr"); FileOutputStream fos = new FileOutputStream(file); WritableByteChannel wbc = fos.getChannel(); wbc.write(ByteBuffer.wrap(m.getHeader().getBytes())); byte[] raw = scan.getMessageBytes(m); wbc.write(ByteBuffer.wrap(raw)); wbc.close(); count++; } JOptionPane.showMessageDialog( BufrMessageViewer.this, count + " successfully written to " + dirName); } catch (IOException e1) { JOptionPane.showMessageDialog(BufrMessageViewer.this, e1.getMessage()); e1.printStackTrace(); } }
/* Remarks sum (SellLotBalance) = all confirmed order.Sell.LotBalance + unconfirmed order (stop).Sell.Lot + iif("MOC/MOO allow New" = False, unconfirmed order (MOO/MOC).Sell.Lot, 0) sum (BuyLotBalance) = all confirmed order.Buy.LotBalance + unconfirmed order (stop).Buy.Lot + iif("MOC/MOO allow New" = False, unconfirmed order (MOO/MOC).Buy.Lot, 0) */ public BigDecimal[] getSumLotBSForMakeStopOrder() { BigDecimal[] sumLot = new BigDecimal[] {BigDecimal.ZERO, BigDecimal.ZERO}; TradePolicyDetail tradePolicyDetail = this.getTradePolicyDetail(); HashMap<Guid, Transaction> accountInstrumentTransactions = this.getAccountInstrumentTransactions(); for (Iterator<Transaction> iterator = accountInstrumentTransactions.values().iterator(); iterator.hasNext(); ) { Transaction transaction = iterator.next(); if (transaction.get_Phase() == Phase.Executed) { for (Iterator<Order> iterator2 = transaction.get_Orders().values().iterator(); iterator2.hasNext(); ) { Order order = iterator2.next(); if (order.get_LotBalance().compareTo(BigDecimal.ZERO) > 0) { if (order.get_IsBuy()) { sumLot[0] = sumLot[0].add(order.get_LotBalance()); } else { sumLot[1] = sumLot[1].add(order.get_LotBalance()); } } } } else if (transaction.get_Phase() == Phase.Placing || transaction.get_Phase() == Phase.Placed) { for (Iterator<Order> iterator2 = transaction.get_Orders().values().iterator(); iterator2.hasNext(); ) { Order order = iterator2.next(); if (order.get_TradeOption() == TradeOption.Stop || (!tradePolicyDetail.get_IsAcceptNewMOOMOC() && (transaction.get_OrderType() == OrderType.MarketOnOpen || transaction.get_OrderType() == OrderType.MarketOnClose))) { if (order.get_IsBuy()) { sumLot[0] = sumLot[0].add(order.get_Lot()); } else { sumLot[1] = sumLot[1].add(order.get_Lot()); } } } } } return sumLot; }
public BigDecimal[] getSumLotBSForOpenOrder() { BigDecimal[] sumLot = new BigDecimal[] {BigDecimal.ZERO, BigDecimal.ZERO}; HashMap<Guid, Transaction> accountInstrumentTransactions = this.getAccountInstrumentTransactions(); for (Iterator<Transaction> iterator = accountInstrumentTransactions.values().iterator(); iterator.hasNext(); ) { Transaction transaction = iterator.next(); if (transaction.get_Phase() == Phase.Executed) { for (Iterator<Order> iterator2 = transaction.get_Orders().values().iterator(); iterator2.hasNext(); ) { Order order = iterator2.next(); if (order.get_LotBalance().compareTo(BigDecimal.ZERO) > 0) { if (order.get_IsBuy()) { sumLot[0] = sumLot[0].add(order.get_LotBalance()); } else { sumLot[1] = sumLot[1].add(order.get_LotBalance()); } } } } } return sumLot; }
private void dumpDDS() { List<MessageBean> beans = messageTable.getBeans(); HashMap<Integer, Message> map = new HashMap<Integer, Message>(2 * beans.size()); for (MessageBean mb : beans) { map.put(mb.m.hashCode(), mb.m); } if (fileChooser == null) fileChooser = new FileManager(null, null, null, (PreferencesExt) prefs.node("FileManager")); String defloc = (raf.getLocation() == null) ? "." : raf.getLocation(); int pos = defloc.lastIndexOf("."); if (pos > 0) defloc = defloc.substring(0, pos); String filename = fileChooser.chooseFilenameToSave(defloc + ".txt"); if (filename == null) return; try { File file = new File(filename); FileOutputStream fos = new FileOutputStream(file); int count = 0; for (Message m : map.values()) { Formatter f = new Formatter(fos); m.dump(f); f.flush(); count++; } fos.close(); JOptionPane.showMessageDialog( BufrMessageViewer.this, count + " successfully written to " + filename); } catch (IOException e1) { JOptionPane.showMessageDialog(BufrMessageViewer.this, e1.getMessage()); e1.printStackTrace(); } }
// exclude make Liquidation order and make Limit,MOO,MOC,MKT,OCO for mapOrder..... private void setOutstandingOrders( BuySellType buySellType, Boolean isSpot, Boolean isMakeLimitOrder, boolean isDelivery) { /*if (this._outstandingOrders.size() > 0 || this._account.get_Type() == AccountType.Agent) { Iterator<RelationOrder> relationOrders = this._outstandingOrders.values().iterator(); while(relationOrders.hasNext()) { relationOrders.next().set_IsMakeLimitOrder(isMakeLimitOrder); } return; }*/ this._outstandingOrders.clear(); HashMap<Guid, Transaction> accountInstrumentTransactions = this.getAccountInstrumentTransactions(); for (Iterator<Transaction> iterator = accountInstrumentTransactions.values().iterator(); iterator.hasNext(); ) { Transaction transaction = iterator.next(); if (transaction.get_Phase().equals(Phase.Executed)) { for (Iterator<Order> iterator2 = transaction.get_Orders().values().iterator(); iterator2.hasNext(); ) { Order order = iterator2.next(); if (order.get_Phase() != Phase.Executed) continue; if (order.get_Transaction().get_Account().get_Type() == AccountType.Agent || order.get_Transaction().get_Account().get_Type() == AccountType.Transit) continue; BigDecimal availableLotBanlance = BigDecimal.ZERO; if (isDelivery) { if (order.canDelivery()) { availableLotBanlance = order.getAvailableDeliveryLot(); if (availableLotBanlance.compareTo(BigDecimal.ZERO) > 0) { Guid orderId = order.get_Id(); RelationOrder outstandingOrder = new RelationOrder( this._tradingConsole, this._settingsManager, order, false, null, true); this._outstandingOrders.put(orderId, outstandingOrder); } } } else { if (order.canClose()) { availableLotBanlance = order.get_LotBalance(); if (isSpot != null) availableLotBanlance = order.getAvailableLotBanlance(isSpot, isMakeLimitOrder); if (availableLotBanlance.compareTo(BigDecimal.ZERO) > 0) { Guid orderId = order.get_Id(); RelationOrder outstandingOrder = new RelationOrder(this._tradingConsole, this._settingsManager, order); outstandingOrder.set_IsMakeLimitOrder(isMakeLimitOrder); if (buySellType.equals(BuySellType.Both)) { this._outstandingOrders.put(orderId, outstandingOrder); } else if (order.get_IsBuy() && (buySellType.equals(BuySellType.Buy))) { this._outstandingOrders.put(orderId, outstandingOrder); } else if (!order.get_IsBuy() && (buySellType.equals(BuySellType.Sell))) { this._outstandingOrders.put(orderId, outstandingOrder); } } } } } } } }