@@ -1805,17 +1805,21 @@ private TransactionSummary addBuyTransaction(Transaction transaction) {
18051805 final JStock jstock = JStock .getInstance ();
18061806 final JStockOptions jStockOptions = jstock .getJStockOptions ();
18071807 final Country country = jStockOptions .getCountry ();
1808- final Currency stockCurrency = org .yccheok .jstock .portfolio .Utils .getStockCurrency (portfolioRealTimeInfo , transaction .getStock ().code );
1809- final Country localCountry = jStockOptions .getLocalCurrencyCountry (country );
1810- final Currency localCurrency = localCountry .localCurrency ;
1808+
1809+ final boolean currencyExchangeEnable = jStockOptions .isCurrencyExchangeEnable (country );
1810+ if (currencyExchangeEnable ) {
1811+ final Currency stockCurrency = org .yccheok .jstock .portfolio .Utils .getStockCurrency (portfolioRealTimeInfo , transaction .getStock ().code );
1812+ final Country localCountry = jStockOptions .getLocalCurrencyCountry (country );
1813+ final Currency localCurrency = localCountry .localCurrency ;
18111814
1812- if (stockCurrency .equals (localCurrency )) {
1813- break ;
1814- }
1815+ if (stockCurrency .equals (localCurrency )) {
1816+ break ;
1817+ }
18151818
1816- _exchangeRateMonitor .addCurrencyPair (CurrencyPair .create (stockCurrency , localCurrency ));
1817- _exchangeRateMonitor .startNewThreadsIfNecessary ();
1818- _exchangeRateMonitor .refresh ();
1819+ _exchangeRateMonitor .addCurrencyPair (CurrencyPair .create (stockCurrency , localCurrency ));
1820+ _exchangeRateMonitor .startNewThreadsIfNecessary ();
1821+ _exchangeRateMonitor .refresh ();
1822+ }
18191823 }
18201824 break ;
18211825 } while (true );
@@ -2408,6 +2412,16 @@ public boolean savePortfolio() {
24082412
24092413 private void refreshStatusBarExchangeRateVisibility () {
24102414 final JStock mainFrame = JStock .getInstance ();
2415+ final JStockOptions jStockOptions = mainFrame .getJStockOptions ();
2416+ final Country country = jStockOptions .getCountry ();
2417+
2418+ final boolean currencyExchangeEnable = jStockOptions .isCurrencyExchangeEnable (country );
2419+
2420+ if (!currencyExchangeEnable ) {
2421+ mainFrame .setStatusBarExchangeRateVisible (false );
2422+ mainFrame .setStatusBarExchangeRateToolTipText (null );
2423+ return ;
2424+ }
24112425
24122426 Set <CurrencyPair > currencyPairs = this .getCurrencyPairs ();
24132427
@@ -2417,9 +2431,17 @@ private void refreshStatusBarExchangeRateVisibility() {
24172431 return ;
24182432 }
24192433
2434+ final int size = currencyPairs .size ();
2435+
2436+ if (size > 1 ) {
2437+ mainFrame .setStatusBarExchangeRateVisible (false );
2438+ mainFrame .setStatusBarExchangeRateToolTipText (null );
2439+ return ;
2440+ }
2441+
24202442 // We will display the currency exchange rate, only if there is 1
24212443 // currency pair.
2422- if (currencyPairs . size () == 1 ) {
2444+ if (size == 1 ) {
24232445 // Update the tool tip text.
24242446 CurrencyPair currencyPair = currencyPairs .iterator ().next ();
24252447 Currency fromCurrency = currencyPair .from ();
@@ -2447,9 +2469,6 @@ private void refreshStatusBarExchangeRateVisibility() {
24472469 }
24482470 return ;
24492471 }
2450-
2451- mainFrame .setStatusBarExchangeRateVisible (false );
2452- mainFrame .setStatusBarExchangeRateToolTipText (null );
24532472 }
24542473
24552474 /**
@@ -2459,6 +2478,10 @@ public void initExchangeRateMonitor() {
24592478 final JStock jstock = JStock .getInstance ();
24602479 final JStockOptions jStockOptions = jstock .getJStockOptions ();
24612480
2481+ final Country country = jStockOptions .getCountry ();
2482+
2483+ final boolean currencyExchangeEnable = jStockOptions .isCurrencyExchangeEnable (country );
2484+
24622485 refreshStatusBarExchangeRateVisibility ();
24632486
24642487 final ExchangeRateMonitor oldExchangeRateMonitor = this .exchangeRateMonitor ;
@@ -2474,6 +2497,17 @@ public void run() {
24742497 });
24752498 }
24762499
2500+
2501+ if (!currencyExchangeEnable ) {
2502+ this .exchangeRateMonitor = null ;
2503+ if (oldExchangeRateMonitor != null ) {
2504+ this .updateWealthHeader ();
2505+ }
2506+ return ;
2507+ }
2508+
2509+ assert (currencyExchangeEnable );
2510+
24772511 this .exchangeRateMonitor = new ExchangeRateMonitor (
24782512 Constants .EXCHANGE_RATE_MONITOR_MAX_THREAD ,
24792513 Constants .EXCHANGE_RATE_MONITOR_MAX_STOCK_SIZE_PER_SCAN ,
@@ -2751,8 +2785,14 @@ private void updateWealthHeader() {
27512785 final SellPortfolioTreeTableModelEx sellPortfolioTreeTableModel = (SellPortfolioTreeTableModelEx )this .sellTreeTable .getTreeTableModel ();
27522786
27532787 final Country country = jStockOptions .getCountry ();
2754- final Country localCountry = jStockOptions .getLocalCurrencyCountry (country );
2755- final Currency localCurrency = localCountry .localCurrency ;
2788+ final boolean currencyExchangeEnable = jStockOptions .isCurrencyExchangeEnable (country );
2789+ final Currency localCurrency ;
2790+ if (currencyExchangeEnable ) {
2791+ final Country localCountry = jStockOptions .getLocalCurrencyCountry (country );
2792+ localCurrency = localCountry .localCurrency ;
2793+ } else {
2794+ localCurrency = null ;
2795+ }
27562796
27572797 final double share ;
27582798 final double cash ;
0 commit comments