Skip to content

Commit 07fdc61

Browse files
committed
Solving shite screen problem in TextEdit (main Code Editor)
1 parent b6066fe commit 07fdc61

2 files changed

Lines changed: 27 additions & 30 deletions

File tree

src/com/reveal/codetimemachine/Commits3DView.java

Lines changed: 5 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -945,11 +945,13 @@ private void loadMainEditorWindowContent()
945945
public void run()
946946
{
947947
mainEditorWindow.setText(content);
948+
mainEditorWindow.getEditor().getScrollingModel().scroll(0,0);
949+
// To solve the white screen problem (earlier, I resized the window to solve the problem)
950+
mainEditorWindow.revalidate();
948951
}
949952
});
950953

951954
updateMainEditorWindowBoundaryAfterComponentResize();
952-
//mainEditorWindow.getEditor().getScrollingModel().scroll(0,0);
953955
mainEditorWindow.setVisible(true);
954956

955957
}
@@ -1041,7 +1043,7 @@ public void setTopBarHighlight(int cIndex, boolean newStatus, Color c)
10411043
repaint();
10421044
}
10431045

1044-
public void displatMetric(CKNumberReader.MetricTypes newMetric)
1046+
public void displayMetric(CKNumberReader.MetricTypes newMetric)
10451047
{
10461048
currentMetric = newMetric;
10471049
render();
@@ -1291,9 +1293,7 @@ private void draw_topBarText(Graphics g, Rectangle drawingRect)
12911293
// If window's width be little => maxPossible->0 => path.indexOf(..) found nothing: -1 => HERE
12921294
path = virtualFile.getName();
12931295
}
1294-
//path = fit(path, 70, g2);
1295-
text = new String(path);
1296-
DrawingHelper.drawStringCenter(g2, text, drawingRect.x+drawingRect.width/2, drawingRect.y+20);
1296+
DrawingHelper.drawStringCenter(g2, path, drawingRect.x+drawingRect.width/2, drawingRect.y+20);
12971297
}
12981298
else
12991299
{
@@ -1330,18 +1330,6 @@ private void draw_mainRect(Graphics2D g2d, Rectangle drawingRect)
13301330
g2d.fillRect(drawingRect.x, drawingRect.y, drawingRect.width, drawingRect.height);
13311331
}
13321332

1333-
public int getMetricValue(Metrics.Types metric)
1334-
{
1335-
/*switch (metric)
1336-
{
1337-
case METRIC1:
1338-
return someRandomMetric1;
1339-
case METRIC2:
1340-
return someRandomMetric2;
1341-
}*/
1342-
return 0;
1343-
}
1344-
13451333
public Color getMetricColor()
13461334
{
13471335
return someRandomMetric1Color;
@@ -1357,15 +1345,6 @@ private String getTopBarMessage()
13571345
return text;
13581346
}
13591347

1360-
private String fit(String s, int maxCharacterCount, Graphics g)
1361-
{
1362-
String result = s;
1363-
1364-
1365-
return result;
1366-
}
1367-
1368-
13691348
} // End of VirtualEditorWindow class
13701349

13711350
class CustomEditorTextField extends EditorTextField

src/com/reveal/codetimemachine/TTMSingleFileView.java

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,14 @@
1717
import javax.swing.*;
1818
import java.awt.*;
1919
import java.awt.event.ActionEvent;
20+
import java.awt.event.ActionListener;
2021
import java.awt.event.KeyEvent;
2122
import java.io.BufferedWriter;
2223
import java.io.File;
2324
import java.io.FileWriter;
2425
import java.io.IOException;
2526
import java.util.*;
27+
import javax.swing.Timer;
2628

2729
///////// ++ UI ++ /////////
2830
///////// ++ UI -- /////////
@@ -167,7 +169,8 @@ private void addKeyBindings()
167169
final String DECREASE_RENDERER_Y_OFFSET = "decreaseRendererYOffset";
168170
final String MARK_AS_FIRST = "markAsFirst";
169171
final String MARK_AS_SECOND = "markAsSecond";
170-
final String TOGGLE_CHART_TYPE = "toggleChartType";
172+
final String NEXT_CHART_TYPE = "nextChartType";
173+
final String PREV_CHART_TYPE = "prevChartType";
171174
final String TOGGLE_COMMITS_BAR_TYPE = "toggleCommitsBarType";
172175
final String SHOW_ALL_FILES = "showAllFiles";
173176
final String SHOW_CHANGED_FILES = "showChangedFiles";
@@ -438,19 +441,34 @@ public void actionPerformed(ActionEvent e)
438441
}
439442
});
440443

441-
thisComponent.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_C,0), TOGGLE_CHART_TYPE);
442-
thisComponent.getActionMap().put(TOGGLE_CHART_TYPE, new AbstractAction()
444+
thisComponent.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_Z,0), PREV_CHART_TYPE);
445+
thisComponent.getActionMap().put(PREV_CHART_TYPE, new AbstractAction()
446+
{
447+
@Override
448+
public void actionPerformed(ActionEvent e)
449+
{
450+
CKNumberReader.MetricTypes[] allMetrics = CKNumberReader.MetricTypes.values();
451+
int nextMetricIndex = (currentMetricType.ordinal()-1);
452+
if(nextMetricIndex<0) nextMetricIndex = allMetrics.length-1;
453+
currentMetricType = allMetrics[nextMetricIndex];
454+
codeHistory3DView.displayMetric(currentMetricType);
455+
}
456+
});
457+
458+
thisComponent.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_X,0), NEXT_CHART_TYPE);
459+
thisComponent.getActionMap().put(NEXT_CHART_TYPE, new AbstractAction()
443460
{
444461
@Override
445462
public void actionPerformed(ActionEvent e)
446463
{
447464
CKNumberReader.MetricTypes[] allMetrics = CKNumberReader.MetricTypes.values();
448465
int nextMetricIndex = (currentMetricType.ordinal()+1)%allMetrics.length;
449466
currentMetricType = allMetrics[nextMetricIndex];
450-
codeHistory3DView.displatMetric(currentMetricType);
467+
codeHistory3DView.displayMetric(currentMetricType);
451468
}
452469
});
453470

471+
454472
thisComponent.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_F,0), TOGGLE_COMMITS_BAR_TYPE);
455473
thisComponent.getActionMap().put(TOGGLE_COMMITS_BAR_TYPE, new AbstractAction()
456474
{

0 commit comments

Comments
 (0)