Skip to content

Commit 865e569

Browse files
committed
Improve User friendliness
1 parent 1f73c80 commit 865e569

File tree

3 files changed

+24
-6
lines changed

3 files changed

+24
-6
lines changed

src/org/yccheok/jstock/gui/PortfolioManagementJPanel.java

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2465,6 +2465,8 @@ private void refreshStatusBarExchangeRateVisibility() {
24652465
}
24662466

24672467
Set<CurrencyPair> currencyPairs = this.getCurrencyPairs();
2468+
// Special handling for GBX.
2469+
currencyPairs.remove(CurrencyPair.create("GBX", "GBP"));
24682470

24692471
if (currencyPairs.isEmpty()) {
24702472
mainFrame.setStatusBarExchangeRateVisible(false);
@@ -3023,14 +3025,30 @@ public PortfolioRealTimeInfo getPortfolioRealTimeInfo() {
30233025
return this.portfolioRealTimeInfo;
30243026
}
30253027

3026-
public boolean shouldDisplayCurrencyInfoForValue() {
3028+
public boolean shouldDisplayCurrencyInfoForValue(Code code) {
30273029
final JStockOptions jStockOptions = JStock.getInstance().getJStockOptions();
30283030
final Country country = jStockOptions.getCountry();
30293031
final boolean isCurrencyExchangeEnable = jStockOptions.isCurrencyExchangeEnable(country);
30303032
if (false == isCurrencyExchangeEnable) {
30313033
return false;
30323034
}
3033-
return !this.getCurrencyPairs().isEmpty();
3035+
3036+
if (false == this.getCurrencyPairs().isEmpty()) {
3037+
final Currency stockCurrency = org.yccheok.jstock.portfolio.Utils.getStockCurrency(portfolioRealTimeInfo, code);
3038+
final Currency localCurrency = country.localCurrency;
3039+
if (stockCurrency.equals(localCurrency)) {
3040+
return false;
3041+
}
3042+
3043+
// Special handling for GBX.
3044+
if (stockCurrency.toString().equals("GBX") && localCurrency.toString().equals("GBP")) {
3045+
return false;
3046+
}
3047+
3048+
return true;
3049+
}
3050+
3051+
return false;
30343052
}
30353053

30363054
private static final Log log = LogFactory.getLog(PortfolioManagementJPanel.class);

src/org/yccheok/jstock/gui/treetable/BuyPortfolioTreeTableModelEx.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,7 @@ public Object getValueAt(Object node, int column) {
447447

448448
final boolean shouldConvertPenceToPound = org.yccheok.jstock.portfolio.Utils.shouldConvertPenceToPound(portfolioRealTimeInfo, code);
449449

450-
final boolean shouldDisplayCurrencyInfoForValue = this.portfolioManagementJPanel.shouldDisplayCurrencyInfoForValue();
450+
final boolean shouldDisplayCurrencyInfoForValue = this.portfolioManagementJPanel.shouldDisplayCurrencyInfoForValue(code);
451451

452452
final Currency stockCurrency = shouldDisplayCurrencyInfoForValue ? org.yccheok.jstock.portfolio.Utils.getStockCurrency(portfolioRealTimeInfo, code) : null;
453453

@@ -533,7 +533,7 @@ public Object getValueAt(Object node, int column) {
533533

534534
final boolean shouldConvertPenceToPound = org.yccheok.jstock.portfolio.Utils.shouldConvertPenceToPound(portfolioRealTimeInfo, code);
535535

536-
final boolean shouldDisplayCurrencyInfoForValue = this.portfolioManagementJPanel.shouldDisplayCurrencyInfoForValue();
536+
final boolean shouldDisplayCurrencyInfoForValue = this.portfolioManagementJPanel.shouldDisplayCurrencyInfoForValue(code);
537537

538538
final Currency stockCurrency = shouldDisplayCurrencyInfoForValue ? org.yccheok.jstock.portfolio.Utils.getStockCurrency(portfolioRealTimeInfo, code) : null;
539539

src/org/yccheok/jstock/gui/treetable/SellPortfolioTreeTableModelEx.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ public Object getValueAt(Object node, int column) {
291291

292292
final boolean shouldConvertPenceToPound = org.yccheok.jstock.portfolio.Utils.shouldConvertPenceToPound(portfolioRealTimeInfo, code);
293293

294-
final boolean shouldDisplayCurrencyInfoForValue = this.portfolioManagementJPanel.shouldDisplayCurrencyInfoForValue();
294+
final boolean shouldDisplayCurrencyInfoForValue = this.portfolioManagementJPanel.shouldDisplayCurrencyInfoForValue(code);
295295

296296
final Currency stockCurrency = shouldDisplayCurrencyInfoForValue ? org.yccheok.jstock.portfolio.Utils.getStockCurrency(portfolioRealTimeInfo, code) : null;
297297

@@ -389,7 +389,7 @@ public Object getValueAt(Object node, int column) {
389389

390390
final boolean shouldConvertPenceToPound = org.yccheok.jstock.portfolio.Utils.shouldConvertPenceToPound(portfolioRealTimeInfo, code);
391391

392-
final boolean shouldDisplayCurrencyInfoForValue = this.portfolioManagementJPanel.shouldDisplayCurrencyInfoForValue();
392+
final boolean shouldDisplayCurrencyInfoForValue = this.portfolioManagementJPanel.shouldDisplayCurrencyInfoForValue(code);
393393

394394
final Currency stockCurrency = shouldDisplayCurrencyInfoForValue ? org.yccheok.jstock.portfolio.Utils.getStockCurrency(portfolioRealTimeInfo, code) : null;
395395

0 commit comments

Comments
 (0)