Skip to content

Commit a7ba628

Browse files
committed
Crazy refactor by crazy dave!
1 parent c02d4fc commit a7ba628

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+255
-256
lines changed

src/org/yccheok/jstock/alert/SMSLimiter.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public enum SMSLimiter {
3232
private java.util.concurrent.atomic.AtomicInteger atomic = new java.util.concurrent.atomic.AtomicInteger();
3333

3434
public boolean isSMSAllowed() {
35-
final JStockOptions jStockOptions = JStock.getInstance().getJStockOptions();
35+
final JStockOptions jStockOptions = JStock.instance().getJStockOptions();
3636
final int max = jStockOptions.getMaxSMSPerDay();
3737

3838
if (max <= 0) {
@@ -53,7 +53,7 @@ public boolean isSMSAllowed() {
5353
}
5454

5555
public void inc() {
56-
final JStockOptions jStockOptions = JStock.getInstance().getJStockOptions();
56+
final JStockOptions jStockOptions = JStock.instance().getJStockOptions();
5757
final int max = jStockOptions.getMaxSMSPerDay();
5858

5959
if (max <= 0) {

src/org/yccheok/jstock/charting/Utils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ public static List<ChartData> getMonthlyChartData(StockHistoryServer stockHistor
341341
*/
342342
public static void applyChartThemeEx(JFreeChart chart) {
343343
final StandardChartTheme chartTheme;
344-
final JStockOptions.ChartTheme theme = JStock.getInstance().getJStockOptions().getChartTheme();
344+
final JStockOptions.ChartTheme theme = JStock.instance().getJStockOptions().getChartTheme();
345345

346346
if (theme == JStockOptions.ChartTheme.Light) {
347347
applyChartTheme(chart);

src/org/yccheok/jstock/engine/Utils.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -556,7 +556,7 @@ public static Code toNonYahooFormat(Code code)
556556
* @return Best search engine based on current selected country.
557557
*/
558558
public static boolean isPinyinTSTSearchEngineRequiredForSymbol() {
559-
final Country country = JStock.getInstance().getJStockOptions().getCountry();
559+
final Country country = JStock.instance().getJStockOptions().getCountry();
560560
return (country == Country.China || country == Country.Taiwan);
561561
}
562562

@@ -569,7 +569,7 @@ public static boolean isPinyinTSTSearchEngineRequiredForSymbol() {
569569
* @return <code>true</code> if we should maintain the symbol as database's.
570570
*/
571571
public static boolean isSymbolImmutable() {
572-
final Country country = JStock.getInstance().getJStockOptions().getCountry();
572+
final Country country = JStock.instance().getJStockOptions().getCountry();
573573
return (country == Country.China || country == Country.Taiwan);
574574
}
575575

@@ -582,7 +582,7 @@ public static boolean isSymbolImmutable() {
582582
* @return <code>true</code> if we should maintain the name as database's.
583583
*/
584584
public static boolean isNameImmutable() {
585-
final Country country = JStock.getInstance().getJStockOptions().getCountry();
585+
final Country country = JStock.instance().getJStockOptions().getCountry();
586586
return isNameImmutable(country);
587587
}
588588

@@ -598,7 +598,7 @@ private static boolean isNameImmutable(Country country) {
598598
* above". Green color to indicate "fall below".
599599
*/
600600
public static boolean isFallBelowAndRiseAboveColorReverse() {
601-
final Country country = JStock.getInstance().getJStockOptions().getCountry();
601+
final Country country = JStock.instance().getJStockOptions().getCountry();
602602
return (country == Country.China || country == Country.Taiwan);
603603
}
604604

src/org/yccheok/jstock/google/SimpleSwingBrowser.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public class SimpleSwingBrowser extends JDialog {
3535
private final JPanel panel = new JPanel(new BorderLayout());
3636

3737
public SimpleSwingBrowser() {
38-
super(JStock.getInstance(), JDialog.ModalityType.APPLICATION_MODAL);
38+
super(JStock.instance(), JDialog.ModalityType.APPLICATION_MODAL);
3939
initComponents();
4040
}
4141

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -529,10 +529,10 @@ private void changeMode(Mode mode) {
529529
if (mode == Mode.Offline) {
530530
// Check through JStockOptions, to determine which renderer to be
531531
// applied.
532-
if (JStock.getInstance().getJStockOptions().getStockInputSuggestionListOption() == JStockOptions.StockInputSuggestionListOption.OneColumn) {
532+
if (JStock.instance().getJStockOptions().getStockInputSuggestionListOption() == JStockOptions.StockInputSuggestionListOption.OneColumn) {
533533
me = oldListCellRenderer;
534534
} else {
535-
assert(JStock.getInstance().getJStockOptions().getStockInputSuggestionListOption() == JStockOptions.StockInputSuggestionListOption.TwoColumns);
535+
assert(JStock.instance().getJStockOptions().getStockInputSuggestionListOption() == JStockOptions.StockInputSuggestionListOption.TwoColumns);
536536
me = offlineModeCellRenderer;
537537
}
538538
} else if (mode == Mode.YahooOnline) {

src/org/yccheok/jstock/gui/BuyPortfolioChartJDialog.form

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,12 @@
5252
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jComboBox1ActionPerformed"/>
5353
</Events>
5454
<AuxValues>
55-
<AuxValue name="JavaCodeGenerator_InitCodePost" type="java.lang.String" value="final JStockOptions jStockOptions = org.yccheok.jstock.gui.JStock.getInstance().getJStockOptions();&#xd;&#xa;final boolean isFeeCalculationEnabled = jStockOptions.isFeeCalculationEnabled();&#xd;&#xa;Set&lt;String&gt; excludedStrings = new HashSet&lt;String&gt;();&#xd;&#xa;excludedStrings.add(GUIBundle.getString(&quot;BuyPortfolioTreeTableModel_Broker&quot;));&#xd;&#xa;excludedStrings.add(GUIBundle.getString(&quot;BuyPortfolioTreeTableModel_StampDuty&quot;));&#xd;&#xa;excludedStrings.add(GUIBundle.getString(&quot;BuyPortfolioTreeTableModel_ClearingFee&quot;));&#xd;&#xa;for(String cName : this.cNames) {&#xd;&#xa; if (isFeeCalculationEnabled == false) {&#xd;&#xa; if (excludedStrings.contains(cName)) {&#xd;&#xa; continue;&#xd;&#xa; }&#xd;&#xa; }&#xd;&#xa;&#xd;&#xa; this.jComboBox1.addItem(cName);&#xd;&#xa;}"/>
55+
<AuxValue name="JavaCodeGenerator_InitCodePost" type="java.lang.String" value="final JStockOptions jStockOptions = org.yccheok.jstock.gui.JStock.instance().getJStockOptions();&#xd;&#xa;final boolean isFeeCalculationEnabled = jStockOptions.isFeeCalculationEnabled();&#xd;&#xa;Set&lt;String&gt; excludedStrings = new HashSet&lt;String&gt;();&#xd;&#xa;excludedStrings.add(GUIBundle.getString(&quot;BuyPortfolioTreeTableModel_Broker&quot;));&#xd;&#xa;excludedStrings.add(GUIBundle.getString(&quot;BuyPortfolioTreeTableModel_StampDuty&quot;));&#xd;&#xa;excludedStrings.add(GUIBundle.getString(&quot;BuyPortfolioTreeTableModel_ClearingFee&quot;));&#xd;&#xa;for(String cName : this.cNames) {&#xd;&#xa; if (isFeeCalculationEnabled == false) {&#xd;&#xa; if (excludedStrings.contains(cName)) {&#xd;&#xa; continue;&#xd;&#xa; }&#xd;&#xa; }&#xd;&#xa;&#xd;&#xa; this.jComboBox1.addItem(cName);&#xd;&#xa;}"/>
5656
</AuxValues>
5757
</Component>
5858
</SubComponents>
5959
</Container>
6060
</SubComponents>
6161
</Container>
6262
</SubComponents>
63-
</Form>
63+
</Form>

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public BuyPortfolioChartJDialog(java.awt.Frame parent, boolean modal, BuyPortfol
7474
this.portfolioRealTimeInfo = portfolioRealTimeInfo;
7575

7676
final JFreeChart freeChart;
77-
final int lastSelectedBuyPortfolioChartIndex = JStock.getInstance().getJStockOptions().getLastSelectedBuyPortfolioChartIndex();
77+
final int lastSelectedBuyPortfolioChartIndex = JStock.instance().getJStockOptions().getLastSelectedBuyPortfolioChartIndex();
7878
if (lastSelectedBuyPortfolioChartIndex < this.jComboBox1.getItemCount() && lastSelectedBuyPortfolioChartIndex < cNames.length && lastSelectedBuyPortfolioChartIndex >= 0) {
7979
freeChart = createChart(cNames[lastSelectedBuyPortfolioChartIndex]);
8080
// Put it in next queue, so that it won't trigger jComBox1's event
@@ -129,7 +129,7 @@ private void initComponents() {
129129

130130
jPanel1.setLayout(new java.awt.BorderLayout());
131131

132-
final JStockOptions jStockOptions = JStock.getInstance().getJStockOptions();
132+
final JStockOptions jStockOptions = org.yccheok.jstock.gui.JStock.instance().getJStockOptions();
133133
final boolean isFeeCalculationEnabled = jStockOptions.isFeeCalculationEnabled();
134134
Set<String> excludedStrings = new HashSet<String>();
135135
excludedStrings.add(GUIBundle.getString("BuyPortfolioTreeTableModel_Broker"));
@@ -155,8 +155,8 @@ public void actionPerformed(java.awt.event.ActionEvent evt) {
155155

156156
getContentPane().add(jPanel1, java.awt.BorderLayout.SOUTH);
157157

158-
java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
159-
setBounds((screenSize.width-750)/2, (screenSize.height-600)/2, 750, 600);
158+
setSize(new java.awt.Dimension(750, 600));
159+
setLocationRelativeTo(null);
160160
}// </editor-fold>//GEN-END:initComponents
161161

162162
private static class DataEx implements Comparable<DataEx> {
@@ -179,7 +179,7 @@ public int compareTo(DataEx o) {
179179
}
180180

181181
private JFreeChart createChart(String name) {
182-
final JStockOptions jStockOptions = JStock.getInstance().getJStockOptions();
182+
final JStockOptions jStockOptions = JStock.instance().getJStockOptions();
183183
final boolean isFeeCalculationEnabled = jStockOptions.isFeeCalculationEnabled();
184184

185185
final Portfolio portfolio = (Portfolio)portfolioTreeTableModel.getRoot();
@@ -291,7 +291,7 @@ private void jComboBox1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FI
291291
String selected = ((javax.swing.JComboBox)evt.getSource()).getSelectedItem().toString();
292292

293293
final int selectedIndex = ((javax.swing.JComboBox)evt.getSource()).getSelectedIndex();
294-
JStock.getInstance().getJStockOptions().setLastSelectedBuyPortfolioChartIndex(selectedIndex);
294+
JStock.instance().getJStockOptions().setLastSelectedBuyPortfolioChartIndex(selectedIndex);
295295

296296
final JFreeChart freeChart = this.createChart(selected);
297297
org.yccheok.jstock.charting.Utils.applyChartTheme(freeChart);

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

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ private void jButton6ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRS
333333

334334
stop();
335335

336-
JStock m = JStock.getInstance();
336+
JStock m = JStock.instance();
337337
m.setStatusBar(false, GUIBundle.getString("IndicatorPanel_SimulationStopped"));
338338
}//GEN-LAST:event_jButton6ActionPerformed
339339

@@ -403,7 +403,7 @@ private void jList1ValueChanged(javax.swing.event.ListSelectionEvent evt) {//GEN
403403
}//GEN-LAST:event_jList1ValueChanged
404404

405405
private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed
406-
final JStock m = JStock.getInstance();
406+
final JStock m = JStock.instance();
407407
final IndicatorDefaultDrawing indicatorDefaultDrawing = (IndicatorDefaultDrawing)this.view.getDrawing();
408408
final OperatorIndicator operatorIndicator = indicatorDefaultDrawing.getOperatorIndicator();
409409

@@ -488,7 +488,7 @@ private boolean promptToSaveSignificantEdits(ListSelectionEx _listSelectionEx) {
488488
output = MessageFormat.format(MessagesBundle.getString("question_message_current_drawing_is_modified_save_it_template"), _listSelectionEx.projectName);
489489
}
490490
// We have a unsaved drawing. Prompt user to save it.
491-
final int result = javax.swing.JOptionPane.showConfirmDialog(JStock.getInstance(), output, MessagesBundle.getString("question_title_current_drawing_is_modified_save_it"), javax.swing.JOptionPane.YES_NO_CANCEL_OPTION, javax.swing.JOptionPane.QUESTION_MESSAGE);
491+
final int result = javax.swing.JOptionPane.showConfirmDialog(JStock.instance(), output, MessagesBundle.getString("question_title_current_drawing_is_modified_save_it"), javax.swing.JOptionPane.YES_NO_CANCEL_OPTION, javax.swing.JOptionPane.QUESTION_MESSAGE);
492492

493493
if (result == JOptionPane.YES_OPTION) {
494494
// Do not use this.Save(false). this.Save(false) will only save the
@@ -576,7 +576,7 @@ else if (this.jList2.getSelectedValue() != null) {
576576
output = MessageFormat.format(MessagesBundle.getString("question_message_current_drawing_is_modified_save_it_template"), this.jList2.getSelectedValue());
577577
}
578578
// We have a unsaved drawing. Prompt user to save it.
579-
final int result = javax.swing.JOptionPane.showConfirmDialog(JStock.getInstance(), output, MessagesBundle.getString("question_title_current_drawing_is_modified_save_it"), javax.swing.JOptionPane.YES_NO_CANCEL_OPTION, javax.swing.JOptionPane.QUESTION_MESSAGE);
579+
final int result = javax.swing.JOptionPane.showConfirmDialog(JStock.instance(), output, MessagesBundle.getString("question_title_current_drawing_is_modified_save_it"), javax.swing.JOptionPane.YES_NO_CANCEL_OPTION, javax.swing.JOptionPane.QUESTION_MESSAGE);
580580
if (result == JOptionPane.YES_OPTION) {
581581
// Do not use this.Save(false). this.Save(false) will only save the
582582
// project in current active tab and current selected project.
@@ -861,7 +861,7 @@ private void alertIndicatorDelete(boolean confirmationDialog) {
861861
}
862862
if (confirmationDialog) {
863863
final String output = MessageFormat.format(MessagesBundle.getString("question_message_delete_template"), projectName);
864-
final int result = javax.swing.JOptionPane.showConfirmDialog(JStock.getInstance(), output, MessagesBundle.getString("question_title_delete"), javax.swing.JOptionPane.YES_NO_OPTION, javax.swing.JOptionPane.QUESTION_MESSAGE);
864+
final int result = javax.swing.JOptionPane.showConfirmDialog(JStock.instance(), output, MessagesBundle.getString("question_title_delete"), javax.swing.JOptionPane.YES_NO_OPTION, javax.swing.JOptionPane.QUESTION_MESSAGE);
865865
if (result != javax.swing.JOptionPane.YES_OPTION) {
866866
return;
867867
}
@@ -881,7 +881,7 @@ private void moduleIndicatorDelete(boolean confirmationDialog) {
881881
}
882882
if (confirmationDialog) {
883883
final String output = MessageFormat.format(MessagesBundle.getString("question_message_delete_template"), projectName);
884-
final int result = javax.swing.JOptionPane.showConfirmDialog(JStock.getInstance(), output, MessagesBundle.getString("question_title_delete"), javax.swing.JOptionPane.YES_NO_OPTION, javax.swing.JOptionPane.QUESTION_MESSAGE);
884+
final int result = javax.swing.JOptionPane.showConfirmDialog(JStock.instance(), output, MessagesBundle.getString("question_title_delete"), javax.swing.JOptionPane.YES_NO_OPTION, javax.swing.JOptionPane.QUESTION_MESSAGE);
885885
if (result != javax.swing.JOptionPane.YES_OPTION) {
886886
return;
887887
}
@@ -1314,7 +1314,7 @@ private static Collection<Action> createSelectionActions(DrawingEditor editor) {
13141314
}
13151315

13161316
public void initAjaxProvider() {
1317-
JStockOptions jStockOptions = JStock.getInstance().getJStockOptions();
1317+
JStockOptions jStockOptions = JStock.instance().getJStockOptions();
13181318

13191319
Country country = jStockOptions.getCountry();
13201320

@@ -1357,7 +1357,7 @@ public void update(AutoCompleteJComboBox subject, MatchType matchType) {
13571357
addStockInfoFromAutoCompleteJComboBox(stockInfo);
13581358

13591359
// Remember to update our offline database as well.
1360-
JStock.getInstance().addUserDefinedStockInfo(stockInfo);
1360+
JStock.instance().addUserDefinedStockInfo(stockInfo);
13611361
}
13621362
};
13631363
}
@@ -1377,7 +1377,7 @@ public void update(AutoCompleteJComboBox subject, ResultType resultType) {
13771377
addStockInfoFromAutoCompleteJComboBox(stockInfo);
13781378

13791379
// Remember to update our offline database as well.
1380-
JStock.getInstance().addUserDefinedStockInfo(stockInfo);
1380+
JStock.instance().addUserDefinedStockInfo(stockInfo);
13811381
}
13821382
};
13831383
}
@@ -1407,7 +1407,7 @@ public Boolean doInBackground() {
14071407
Stock s = null;
14081408
int tries = 0;
14091409

1410-
JStock m = JStock.getInstance();
1410+
JStock m = JStock.instance();
14111411

14121412
if (m == null) {
14131413
publish(s);
@@ -1459,7 +1459,7 @@ protected void process(java.util.List<Stock> stocks) {
14591459
return;
14601460
}
14611461

1462-
final JStock m = JStock.getInstance();
1462+
final JStock m = JStock.instance();
14631463

14641464
if (stock != null) {
14651465
Stock new_stock = stock;
@@ -1548,7 +1548,7 @@ private void createToolTipTextForJTabbedPane() {
15481548

15491549
// Run by worker thread only.
15501550
private void simulate(final Stock stock) {
1551-
JStock m = JStock.getInstance();
1551+
JStock m = JStock.instance();
15521552

15531553
// First, check whether there is a need to get history.
15541554
final IndicatorDefaultDrawing indicatorDefaultDrawing = (IndicatorDefaultDrawing)this.view.getDrawing();
@@ -1777,7 +1777,7 @@ private IndicatorProjectManager getCurrentActiveIndicatorProjectManager() {
17771777
}
17781778

17791779
private Wizard getWizardDialog() {
1780-
final JStock m = JStock.getInstance();
1780+
final JStock m = JStock.instance();
17811781
final Wizard wizard = new Wizard(m);
17821782
wizard.getDialog().setTitle(java.util.ResourceBundle.getBundle("org/yccheok/jstock/data/gui").getString("IndicatorPanel_IndicatorInstallWizard"));
17831783
wizard.getDialog().setResizable(false);

0 commit comments

Comments
 (0)