3939public class CodeTimeMachineAction extends AnAction
4040{
4141 final boolean AUTOMATICALLY_CHOOSE_SAMPLE_FILES = false ;
42- final int MAX_NUM_OF_FILES = 2 ;
4342 //////////////////////////////
4443
4544 static Map <Project , CodeTimeMachine > runningCodeTimeMachines = new HashMap <>();
@@ -60,17 +59,19 @@ public void actionPerformed(AnActionEvent e)
6059 if (chosenVirtualFiles [0 ] == null )
6160 chosenVirtualFiles = selectVirtualFiles_manually (project );
6261
63- if (chosenVirtualFiles == null || chosenVirtualFiles .length ==0 || chosenVirtualFiles . length > MAX_NUM_OF_FILES )
62+ if (chosenVirtualFiles == null || chosenVirtualFiles .length ==0 )
6463 return ;
6564
6665 VcsHistoryProvider myGitVcsHistoryProvider = getGitHistoryProvider (project );
67- ArrayList <List <VcsFileRevision >> _fileRevisionsLists = getRevisionListForSubjectAndTestClass (myGitVcsHistoryProvider , chosenVirtualFiles );
6866
69- ArrayList <CommitWrapper >[] subjectAndTestClassCommitsList = new ArrayList [2 ];
67+ ArrayList <CommitWrapper >[] subjectAndTestClassCommitsList = new ArrayList [chosenVirtualFiles . length ];
7068 CommitWrapper aCommitWrapper = null ;
7169 for (int i =0 ; i < chosenVirtualFiles .length ; i ++)
7270 {
73- int realCommitsSize = _fileRevisionsLists .get (i ).size ();
71+
72+ List <VcsFileRevision > _fileRevisionsLists = getRevisionListForSubjectAndTestClass (myGitVcsHistoryProvider , chosenVirtualFiles [i ]);
73+
74+ int realCommitsSize = _fileRevisionsLists .size ();
7475 subjectAndTestClassCommitsList [i ] = new ArrayList <>(realCommitsSize + 1 );
7576
7677
@@ -88,25 +89,24 @@ public void actionPerformed(AnActionEvent e)
8889 }
8990
9091 String mostRecentCommitContent = "" ;
91- if (_fileRevisionsLists .get ( i ). size ()> 0 )
92- mostRecentCommitContent = VcsFileRevisionHelper .getContent (_fileRevisionsLists .get (i ). get ( 0 ));
92+ if (_fileRevisionsLists .size () > 0 )
93+ mostRecentCommitContent = VcsFileRevisionHelper .getContent (_fileRevisionsLists .get (0 ));
9394
94- if (! mostRecentCommitContent .equals (currentContent ) )
95+ if (! mostRecentCommitContent .equals (currentContent ))
9596 {
96- final String UNCOMMITED_CHANGE_TEXT = "Uncommitted Changes" ;
97- aCommitWrapper = new CommitWrapper (currentContent , UNCOMMITED_CHANGE_TEXT ,new Date (),UNCOMMITED_CHANGE_TEXT , -1 );
98- subjectAndTestClassCommitsList [i ].add (0 ,aCommitWrapper );
97+ final String UNCOMMITED_CHANGE_TEXT = "Uncommitted Changes" ;
98+ aCommitWrapper = new CommitWrapper (currentContent , UNCOMMITED_CHANGE_TEXT , new Date (), UNCOMMITED_CHANGE_TEXT , -1 );
99+ subjectAndTestClassCommitsList [i ].add (0 , aCommitWrapper );
99100 }
100101
101102 ///// Other Real
102- for (int j = 0 ; j < realCommitsSize ; j ++)
103+ for (int j = 0 ; j < realCommitsSize ; j ++)
103104 {
104- aCommitWrapper = new CommitWrapper (_fileRevisionsLists .get (i ). get ( j ),-1 );
105+ aCommitWrapper = new CommitWrapper (_fileRevisionsLists .get (j ), -1 );
105106 subjectAndTestClassCommitsList [i ].add (aCommitWrapper );
106107 }
107108
108109
109-
110110 /// Sort by Date all commits
111111 // index 0 will contain most recent commit
112112 Collections .sort (subjectAndTestClassCommitsList [i ], new Comparator <CommitWrapper >()
@@ -120,18 +120,15 @@ public int compare(CommitWrapper o1, CommitWrapper o2)
120120
121121
122122 // Assign cIndex
123- for (int j = 0 ; j < subjectAndTestClassCommitsList [i ].size (); j ++)
123+ for (int j = 0 ; j < subjectAndTestClassCommitsList [i ].size (); j ++)
124124 {
125125 subjectAndTestClassCommitsList [i ].get (j ).cIndex = j ;
126126 }
127127
128-
128+ String contentName = chosenVirtualFiles [i ].getName ();
129+ TTMSingleFileView mainWindow = new TTMSingleFileView (project , chosenVirtualFiles [i ], subjectAndTestClassCommitsList [i ]);
130+ getCodeTimeMachine (project ).addNewContent (mainWindow , contentName );
129131 }
130-
131-
132- String contentName = chosenVirtualFiles [0 ].getName ();
133- TTMSingleFileView mainWindow = new TTMSingleFileView (project , chosenVirtualFiles [0 ], subjectAndTestClassCommitsList [0 ]);
134- getCodeTimeMachine (project ).addNewContent (mainWindow , contentName );
135132 }
136133
137134 static public CodeTimeMachine getCodeTimeMachine (Project project )
@@ -181,24 +178,21 @@ public void visitFile(final PsiFile file) {
181178 "All packages in selected module" , Messages .getInformationIcon ());
182179 }
183180
184- private ArrayList < List <VcsFileRevision >> getRevisionListForSubjectAndTestClass (VcsHistoryProvider myGitVcsHistoryProvider , VirtualFile [] chosenVirtualFiles )
181+ private List <VcsFileRevision > getRevisionListForSubjectAndTestClass (VcsHistoryProvider myGitVcsHistoryProvider , VirtualFile virtualFiles )
185182 {
186- ArrayList <List <VcsFileRevision >> _fileRevisionsLists = new ArrayList <>(chosenVirtualFiles .length );
187183
188- for (int i = 0 ; i < chosenVirtualFiles .length ; i ++)
184+ FilePath filePathOn = VcsContextFactory .SERVICE .getInstance ().createFilePathOn (virtualFiles );
185+ VcsHistorySession sessionFor = null ;
186+ try
189187 {
190- FilePath filePathOn = VcsContextFactory .SERVICE .getInstance ().createFilePathOn (chosenVirtualFiles [i ]);
191- VcsHistorySession sessionFor = null ;
192- try
193- {
194- sessionFor = myGitVcsHistoryProvider .createSessionFor (filePathOn );
195- } catch (VcsException e1 )
196- {
197- e1 .printStackTrace ();
198- }
199- _fileRevisionsLists .add (sessionFor .getRevisionList ());
188+ sessionFor = myGitVcsHistoryProvider .createSessionFor (filePathOn );
189+ } catch (VcsException e1 )
190+ {
191+ e1 .printStackTrace ();
200192 }
201- return _fileRevisionsLists ;
193+ List <VcsFileRevision > revisionList = sessionFor .getRevisionList ();
194+
195+ return revisionList ;
202196 }
203197
204198 private VcsHistoryProvider getGitHistoryProvider (Project project )
0 commit comments