Esempio n. 1
0
 @Override
 public void dispose() {
   for (MarketDataViewItem item : mItemMap.values()) {
     item.dispose();
   }
   mItemMap = null;
   mItems = null;
   if (mClipboard != null) {
     mClipboard.dispose();
   }
   super.dispose();
 }
Esempio n. 2
0
 @Override
 protected void setValue(Object element, Object value) {
   if (StringUtils.isBlank(value.toString())) return;
   final MarketDataViewItem item = (MarketDataViewItem) element;
   final Equity equity = item.getEquity();
   if (equity.getSymbol().equals(value)) return;
   final Equity newEquity = new Equity(value.toString());
   if (mItemMap.containsKey(newEquity)) {
     PhotonPlugin.getMainConsoleLogger().warn(DUPLICATE_SYMBOL.getText(newEquity.getSymbol()));
     return;
   }
   busyRun(
       new Runnable() {
         @Override
         public void run() {
           mItemMap.remove(equity);
           item.setEquity(newEquity);
           mItemMap.put(newEquity, item);
         }
       });
 }
Esempio n. 3
0
 @Override
 public int compare(Viewer viewer, Object e1, Object e2) {
   if (mIndex == -1) return 0;
   MarketDataViewItem item1 = (MarketDataViewItem) e1;
   MarketDataViewItem item2 = (MarketDataViewItem) e2;
   int compare;
   switch (mIndex) {
     case 0:
       String symbol1 = item1.getEquity().getSymbol();
       String symbol2 = item2.getEquity().getSymbol();
       compare = compareNulls(symbol1, symbol2);
       if (compare == 0) {
         compare = symbol1.compareTo(symbol2);
       }
       break;
     case 1:
       BigDecimal tradePrice1 = item1.getLatestTick().getPrice();
       BigDecimal tradePrice2 = item2.getLatestTick().getPrice();
       compare = compareNulls(tradePrice1, tradePrice2);
       if (compare == 0) {
         compare = tradePrice1.compareTo(tradePrice2);
       }
       break;
     case 2:
       BigDecimal tradeSize1 = item1.getLatestTick().getSize();
       BigDecimal tradeSize2 = item2.getLatestTick().getSize();
       compare = compareNulls(tradeSize1, tradeSize2);
       if (compare == 0) {
         compare = tradeSize1.compareTo(tradeSize2);
       }
       break;
     case 3:
       BigDecimal bidSize1 = item1.getTopOfBook().getBidSize();
       BigDecimal bidSize2 = item2.getTopOfBook().getBidSize();
       compare = compareNulls(bidSize1, bidSize2);
       if (compare == 0) {
         compare = bidSize1.compareTo(bidSize2);
       }
       break;
     case 4:
       BigDecimal bidPrice1 = item1.getTopOfBook().getBidPrice();
       BigDecimal bidPrice2 = item2.getTopOfBook().getBidPrice();
       compare = compareNulls(bidPrice1, bidPrice2);
       if (compare == 0) {
         compare = bidPrice1.compareTo(bidPrice2);
       }
       break;
     case 5:
       BigDecimal askPrice1 = item1.getTopOfBook().getAskPrice();
       BigDecimal askPrice2 = item2.getTopOfBook().getAskPrice();
       compare = compareNulls(askPrice1, askPrice2);
       if (compare == 0) {
         compare = askPrice1.compareTo(askPrice2);
       }
       break;
     case 6:
       BigDecimal askSize1 = item1.getTopOfBook().getAskSize();
       BigDecimal askSize2 = item2.getTopOfBook().getAskSize();
       compare = compareNulls(askSize1, askSize2);
       if (compare == 0) {
         compare = askSize1.compareTo(askSize2);
       }
       break;
     default:
       throw new AssertionFailedException("Invalid column index"); // $NON-NLS-1$
   }
   return mDirection * compare;
 }
Esempio n. 4
0
 private void remove(final MarketDataViewItem item) {
   mItemMap.remove(item.getEquity());
   mItems.remove(item);
   item.dispose();
 }