Skip to content

Commit 3bfb7d0

Browse files
committed
Sync.
1 parent eee3305 commit 3bfb7d0

17 files changed

+134
-226
lines changed

docs/changelog.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
This file summarizes changes in JStock releases.
22
Numbers in parentheses refer to SourceForge.net tracker item numbers (#XXXXX)
33

4+
JStock 1.0.7.16 - 2016-09-04
5+
Feature: Support 7 new countries.
6+
47
JStock 1.0.7.15 - 2016-06-11
58
Bugfix: News sorted properly.
69
Bugfix: Give a fair policy usage info, before user begins indicator scanning.

installer/windows/jstock.nsi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Name ${PRODUCT_NAME}
1111
RequestExecutionLevel admin ;Workaround for Vista
1212

1313
; The file to write
14-
OutFile "jstock-1.0.7.15-setup.exe"
14+
OutFile "jstock-1.0.7.16-setup.exe"
1515
LicenseData "gpl-2.0.txt"
1616

1717
; The default installation directory

installer/windows/jstock.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@
2525
<maxHeapSize>512</maxHeapSize>
2626
</jre>
2727
<versionInfo>
28-
<fileVersion>1.1.4.4</fileVersion>
29-
<txtFileVersion>1.1.4.4</txtFileVersion>
28+
<fileVersion>1.1.4.5</fileVersion>
29+
<txtFileVersion>1.1.4.5</txtFileVersion>
3030
<fileDescription>JStock - Stock Market Software</fileDescription>
3131
<copyright>Yan Cheng Cheok &lt;[email protected]&gt;</copyright>
32-
<productVersion>1.1.4.4</productVersion>
33-
<txtProductVersion>1.1.4.4</txtProductVersion>
32+
<productVersion>1.1.4.5</productVersion>
33+
<txtProductVersion>1.1.4.5</txtProductVersion>
3434
<productName>JStock - Stock Market Software</productName>
3535
<companyName>Yan Cheng Cheok &lt;[email protected]&gt;</companyName>
3636
<internalName>jstock</internalName>

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

Lines changed: 21 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
import org.yccheok.jstock.engine.ResultSetType;
5353
import org.yccheok.jstock.engine.ResultType;
5454
import org.yccheok.jstock.engine.AjaxYahooSearchEngineMonitor;
55+
import org.yccheok.jstock.engine.DispType;
5556
import org.yccheok.jstock.engine.MatchSetType;
5657
import org.yccheok.jstock.engine.MatchType;
5758
import org.yccheok.jstock.engine.Observer;
@@ -74,22 +75,18 @@ public void notify(S subject, A arg) {
7475
}
7576
}
7677

77-
private final SubjectEx<AjaxAutoCompleteJComboBox, ResultType> resultSubject = new SubjectEx<AjaxAutoCompleteJComboBox, ResultType>();
78-
private final SubjectEx<AjaxAutoCompleteJComboBox, MatchType> matchSubject = new SubjectEx<AjaxAutoCompleteJComboBox, MatchType>();
78+
private final SubjectEx<AjaxAutoCompleteJComboBox, DispType> dispSubject = new SubjectEx<AjaxAutoCompleteJComboBox, DispType>();
7979
private final SubjectEx<AjaxAutoCompleteJComboBox, Boolean> busySubject = new SubjectEx<AjaxAutoCompleteJComboBox, Boolean>();
8080

8181
/**
8282
* Attach an observer to listen to ResultType available event.
8383
*
8484
* @param observer An observer to listen to ResultType available event
8585
*/
86-
public void attachResultObserver(Observer<AjaxAutoCompleteJComboBox, ResultType> observer) {
87-
resultSubject.attach(observer);
86+
public void attachDispObserver(Observer<AjaxAutoCompleteJComboBox, DispType> observer) {
87+
dispSubject.attach(observer);
8888
}
8989

90-
public void attachMatchObserver(Observer<AjaxAutoCompleteJComboBox, MatchType> observer) {
91-
matchSubject.attach(observer);
92-
}
9390

9491
/**
9592
* Attach an observer to listen to busy state event.
@@ -104,8 +101,7 @@ public void attachBusyObserver(Observer<AjaxAutoCompleteJComboBox, Boolean> obse
104101
* Dettach all observers.
105102
*/
106103
public void dettachAll() {
107-
resultSubject.dettachAll();
108-
matchSubject.dettachAll();
104+
dispSubject.dettachAll();
109105
busySubject.dettachAll();
110106
}
111107

@@ -140,7 +136,7 @@ public AjaxAutoCompleteJComboBox() {
140136
log.error("Unable to attach DocumentListener to AjaxAutoCompleteJComboBox.");
141137
}
142138

143-
this.setRenderer(new MatchSetOrResultSetCellRenderer());
139+
this.setRenderer(new DispTypeCellRenderer());
144140

145141
ajaxYahooSearchEngineMonitor.attach(getYahooMonitorObserver());
146142
ajaxGoogleSearchEngineMonitor.attach(getGoogleMonitorObserver());
@@ -169,12 +165,9 @@ public void actionPerformed(ActionEvent e) {
169165
// If user keys in the item, editor's item will be String.
170166
// If user clicks on the drop down list, editor's item will be
171167
// AjaxYahooSearchEngine.ResultType.
172-
if (object instanceof ResultType) {
173-
ResultType lastEnteredResult = (ResultType)object;
174-
AjaxAutoCompleteJComboBox.this.resultSubject.notify(AjaxAutoCompleteJComboBox.this, lastEnteredResult);
175-
} else if (object instanceof MatchType) {
176-
MatchType lastEnteredMatch = (MatchType)object;
177-
AjaxAutoCompleteJComboBox.this.matchSubject.notify(AjaxAutoCompleteJComboBox.this, lastEnteredMatch);
168+
if (object instanceof DispType) {
169+
DispType lastEnteredResult = (DispType)object;
170+
AjaxAutoCompleteJComboBox.this.dispSubject.notify(AjaxAutoCompleteJComboBox.this, lastEnteredResult);
178171
}
179172

180173
SwingUtilities.invokeLater(new Runnable() {
@@ -296,29 +289,22 @@ public void keyReleased(KeyEvent e) {
296289
// We are no longer busy.
297290
busySubject.notify(AjaxAutoCompleteJComboBox.this, false);
298291

299-
ResultType lastEnteredResultType = null;
300-
MatchType lastEnteredMatchType = null;
292+
DispType lastEnteredDispType = null;
301293

302294
if (AjaxAutoCompleteJComboBox.this.getItemCount() > 0) {
303295
int index = AjaxAutoCompleteJComboBox.this.getSelectedIndex();
304296

305297
if (index == -1) {
306298
Object object = AjaxAutoCompleteJComboBox.this.getItemAt(0);
307-
if (object instanceof ResultType) {
308-
lastEnteredResultType = (ResultType)object;
309-
} else {
310-
assert(object instanceof MatchType);
311-
lastEnteredMatchType = (MatchType)object;
299+
if (object instanceof DispType) {
300+
lastEnteredDispType = (DispType)object;
312301
}
313302
}
314303
else {
315304
Object object = AjaxAutoCompleteJComboBox.this.getItemAt(index);
316-
if (object instanceof ResultType) {
317-
lastEnteredResultType = (ResultType)object;
318-
} else {
319-
assert(object instanceof MatchType);
320-
lastEnteredMatchType = (MatchType)object;
321-
}
305+
if (object instanceof DispType) {
306+
lastEnteredDispType = (DispType)object;
307+
}
322308
}
323309
}
324310
else {
@@ -328,17 +314,15 @@ public void keyReleased(KeyEvent e) {
328314
// All upper-case, if the result is not coming from server.
329315
final String string = ((String)object).trim().toUpperCase();
330316
if (string.length() > 0) {
331-
lastEnteredResultType = new ResultType(string, string);
317+
lastEnteredDispType = new ResultType(string, string);
332318
}
333319
}
334320
}
335321

336322
AjaxAutoCompleteJComboBox.this.removeAllItems();
337-
if (lastEnteredResultType != null) {
338-
AjaxAutoCompleteJComboBox.this.resultSubject.notify(AjaxAutoCompleteJComboBox.this, lastEnteredResultType);
339-
} else if (lastEnteredMatchType != null) {
340-
AjaxAutoCompleteJComboBox.this.matchSubject.notify(AjaxAutoCompleteJComboBox.this, lastEnteredMatchType);
341-
}
323+
if (lastEnteredDispType != null) {
324+
AjaxAutoCompleteJComboBox.this.dispSubject.notify(AjaxAutoCompleteJComboBox.this, lastEnteredDispType);
325+
}
342326
return;
343327
} /* if(KeyEvent.VK_ENTER == e.getKeyCode()) */
344328

@@ -363,7 +347,7 @@ public void update(final AjaxGoogleSearchEngineMonitor subject, MatchSetType arg
363347
if (arg.Match.isEmpty()) {
364348
StockInfo stockInfo = ajaxStockInfoSearchEngine.search(arg.Query);
365349
if (stockInfo != null) {
366-
MatchType matchType = new MatchType(stockInfo.code.toString(), stockInfo.symbol.toString(), null, null);
350+
MatchType matchType = new MatchType(stockInfo.code.toString().toUpperCase(), stockInfo.symbol.toString(), null, null);
367351
List<MatchType> matchTypes = new ArrayList<>();
368352
matchTypes.add(matchType);
369353
MatchSetType matchSetType = MatchSetType.newInstance(arg.Query, matchTypes);
@@ -451,7 +435,7 @@ public void update(final AjaxYahooSearchEngineMonitor subject, ResultSetType arg
451435
if (arg.Result.isEmpty()) {
452436
StockInfo stockInfo = ajaxStockInfoSearchEngine.search(arg.Query);
453437
if (stockInfo != null) {
454-
ResultType resultType = new ResultType(stockInfo.code.toString(), stockInfo.symbol.toString());
438+
ResultType resultType = new ResultType(stockInfo.code.toString().toUpperCase(), stockInfo.symbol.toString());
455439
List<ResultType> resultTypes = new ArrayList<>();
456440
resultTypes.add(resultType);
457441
// Overwrite!

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

Lines changed: 18 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -136,18 +136,15 @@ public void actionPerformed(ActionEvent e) {
136136
if ((e.getModifiers() & java.awt.event.InputEvent.BUTTON1_MASK) == java.awt.event.InputEvent.BUTTON1_MASK) {
137137
final Object object = AutoCompleteJComboBox.this.getEditor().getItem();
138138
/* Let us be extra paranoid. */
139-
if (object instanceof ResultType) {
140-
// From Yahoo! Ajax result.
141-
ResultType lastEnteredResult = (ResultType)object;
142-
AutoCompleteJComboBox.this.resultSubject.notify(AutoCompleteJComboBox.this, lastEnteredResult);
139+
if (object instanceof DispType) {
140+
DispType lastEnteredDisp = (DispType)object;
141+
AutoCompleteJComboBox.this.dispSubject.notify(AutoCompleteJComboBox.this, lastEnteredDisp);
143142
} else if (object instanceof StockInfo) {
144143
// From our offline database.
145144
StockInfo lastEnteredStockInfo = (StockInfo)object;
146145
AutoCompleteJComboBox.this.stockInfoSubject.notify(AutoCompleteJComboBox.this, lastEnteredStockInfo);
147146
} else {
148-
assert(object instanceof MatchType);
149-
MatchType lastEnteredMatch = (MatchType)object;
150-
AutoCompleteJComboBox.this.matchSubject.notify(AutoCompleteJComboBox.this, lastEnteredMatch);
147+
assert(false);
151148
}
152149

153150
SwingUtilities.invokeLater(new Runnable() {
@@ -354,31 +351,24 @@ public void keyReleased(KeyEvent e) {
354351
busySubject.notify(AutoCompleteJComboBox.this, false);
355352

356353
StockInfo lastEnteredStockInfo = null;
357-
ResultType lastEnteredResultType = null;
358-
MatchType lastEnteredMatchType = null;
354+
DispType lastEnteredDispType = null;
359355

360356
if (AutoCompleteJComboBox.this.getItemCount() > 0) {
361357
int index = AutoCompleteJComboBox.this.getSelectedIndex();
362358
if (index == -1) {
363359
Object object = AutoCompleteJComboBox.this.getItemAt(0);
364360
if (object instanceof StockInfo) {
365361
lastEnteredStockInfo = (StockInfo)object;
366-
} else if (object instanceof ResultType) {
367-
lastEnteredResultType = (ResultType)object;
368-
} else {
369-
assert(object instanceof MatchType);
370-
lastEnteredMatchType = (MatchType)object;
362+
} else if (object instanceof DispType) {
363+
lastEnteredDispType = (DispType)object;
371364
}
372365
}
373366
else {
374367
Object object = AutoCompleteJComboBox.this.getItemAt(index);
375368
if (object instanceof StockInfo) {
376369
lastEnteredStockInfo = (StockInfo)object;
377-
} else if (object instanceof ResultType) {
378-
lastEnteredResultType = (ResultType)object;
379-
} else {
380-
assert(object instanceof MatchType);
381-
lastEnteredMatchType = (MatchType)object;
370+
} else if (object instanceof DispType) {
371+
lastEnteredDispType = (DispType)object;
382372
}
383373
}
384374
}
@@ -403,10 +393,8 @@ public void keyReleased(KeyEvent e) {
403393
AutoCompleteJComboBox.this.removeAllItems();
404394
if (lastEnteredStockInfo != null) {
405395
AutoCompleteJComboBox.this.stockInfoSubject.notify(AutoCompleteJComboBox.this, lastEnteredStockInfo);
406-
} else if (lastEnteredResultType != null) {
407-
AutoCompleteJComboBox.this.resultSubject.notify(AutoCompleteJComboBox.this, lastEnteredResultType);
408-
} else if (lastEnteredMatchType != null) {
409-
AutoCompleteJComboBox.this.matchSubject.notify(AutoCompleteJComboBox.this, lastEnteredMatchType);
396+
} else if (lastEnteredDispType != null) {
397+
AutoCompleteJComboBox.this.dispSubject.notify(AutoCompleteJComboBox.this, lastEnteredDispType);
410398
} else {
411399
// Do nothing.
412400
}
@@ -559,7 +547,7 @@ public void update(final AjaxGoogleSearchEngineMonitor subject, MatchSetType arg
559547
if (arg.Match.isEmpty()) {
560548
StockInfo stockInfo = ajaxStockInfoSearchEngine.search(arg.Query);
561549
if (stockInfo != null) {
562-
MatchType matchType = new MatchType(stockInfo.code.toString(), stockInfo.symbol.toString(), null, null);
550+
MatchType matchType = new MatchType(stockInfo.code.toString().toUpperCase(), stockInfo.symbol.toString(), null, null);
563551
List<MatchType> matchTypes = new ArrayList<>();
564552
matchTypes.add(matchType);
565553
MatchSetType matchSetType = MatchSetType.newInstance(arg.Query, matchTypes);
@@ -652,7 +640,7 @@ public void update(final AjaxYahooSearchEngineMonitor subject, ResultSetType arg
652640
if (arg.Result.isEmpty()) {
653641
StockInfo stockInfo = ajaxStockInfoSearchEngine.search(arg.Query);
654642
if (stockInfo != null) {
655-
ResultType resultType = new ResultType(stockInfo.code.toString(), stockInfo.symbol.toString());
643+
ResultType resultType = new ResultType(stockInfo.code.toString().toUpperCase(), stockInfo.symbol.toString());
656644
List<ResultType> resultTypes = new ArrayList<>();
657645
resultTypes.add(resultType);
658646
// Overwrite!
@@ -736,8 +724,7 @@ public void _update(AjaxYahooSearchEngineMonitor subject, ResultSetType arg) {
736724
};
737725
}
738726

739-
private final SubjectEx<AutoCompleteJComboBox, ResultType> resultSubject = new SubjectEx<AutoCompleteJComboBox, ResultType>();
740-
private final SubjectEx<AutoCompleteJComboBox, MatchType> matchSubject = new SubjectEx<AutoCompleteJComboBox, MatchType>();
727+
private final SubjectEx<AutoCompleteJComboBox, DispType> dispSubject = new SubjectEx<AutoCompleteJComboBox, DispType>();
741728
private final SubjectEx<AutoCompleteJComboBox, StockInfo> stockInfoSubject = new SubjectEx<AutoCompleteJComboBox, StockInfo>();
742729
private final SubjectEx<AutoCompleteJComboBox, Boolean> busySubject = new SubjectEx<AutoCompleteJComboBox, Boolean>();
743730

@@ -755,12 +742,8 @@ public void attachStockInfoObserver(Observer<AutoCompleteJComboBox, StockInfo> o
755742
*
756743
* @param observer an observer to listen to ResultType available event
757744
*/
758-
public void attachResultObserver(Observer<AutoCompleteJComboBox, ResultType> observer) {
759-
resultSubject.attach(observer);
760-
}
761-
762-
public void attachMatchObserver(Observer<AutoCompleteJComboBox, MatchType> observer) {
763-
matchSubject.attach(observer);
745+
public void attachDispObserver(Observer<AutoCompleteJComboBox, DispType> observer) {
746+
dispSubject.attach(observer);
764747
}
765748

766749
/**
@@ -779,8 +762,7 @@ public void dettachAll() {
779762
// For offline database feature.
780763
stockInfoSubject.dettachAll();
781764
// For online database feature.
782-
resultSubject.dettachAll();
783-
matchSubject.dettachAll();
765+
dispSubject.dettachAll();
784766
busySubject.dettachAll();
785767
}
786768

@@ -845,7 +827,7 @@ public int compare(StockInfo o1, StockInfo o2) {
845827
private List<String> codeExtensionSortingOption = java.util.Collections.emptyList();
846828

847829
private final ListCellRenderer offlineModeCellRenderer = new StockInfoCellRenderer();
848-
private final ListCellRenderer onlineModeCellRenderer = new MatchSetOrResultSetCellRenderer();
830+
private final ListCellRenderer onlineModeCellRenderer = new DispTypeCellRenderer();
849831
private final ListCellRenderer oldListCellRenderer;
850832
private ListCellRenderer currentListCellRenderer;
851833

0 commit comments

Comments
 (0)