Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Make caching of TestRuns also work on MolTable.
  • Loading branch information
olas committed Jun 28, 2010
1 parent ecbbf93 commit fbd8726
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 23 deletions.
Expand Up @@ -710,7 +710,6 @@ private void doRunAllTests() {
//We need to clear previous tests if already run
if (isExecuted()==true){
doClearAndSetUpNewTestRuns( mol );
activeTestRuns=molTestMap.get( mol );
// partActivated( jcp );
viewer.refresh();
}
Expand Down Expand Up @@ -1289,25 +1288,31 @@ public void partClosed(IWorkbenchPartReference partRef) {
}

//If no more editor, clear all
if (getSite()==null) return;
if (getSite().getWorkbenchWindow()==null) return;
if (getSite().getWorkbenchWindow().getActivePage()==null) return;
if (getSite().getWorkbenchWindow().getActivePage().getActiveEditor()==null){
molTestMap.clear();
activeTestRuns=null;
IDSManager ds = net.bioclipse.ds.Activator.getDefault().getJavaManager();
try {
for (Endpoint ep : ds.getFullEndpoints()){
if (ep.getTestruns()!=null)
ep.getTestruns().clear();
}
} catch (BioclipseException e) {
e.printStackTrace();
}

deactivateView();
}

updateView();

}

private void deactivateView() {
// molTestMap.clear();
activeTestRuns=null;
IDSManager ds = net.bioclipse.ds.Activator.getDefault().getJavaManager();
try {
for (Endpoint ep : ds.getFullEndpoints()){
if (ep.getTestruns()!=null)
ep.getTestruns().clear();
}
} catch (BioclipseException e) {
e.printStackTrace();
}
}

@Override
public void partDeactivated(IWorkbenchPartReference partRef) {
// logger.debug("Part Deactivated: " + partRef.getId() + " detected in Eventview.");
Expand Down Expand Up @@ -1341,14 +1346,15 @@ public void partVisible(IWorkbenchPartReference partRef) {


private void handlePartRef(IWorkbenchPartReference partRef){
if (!(partRef instanceof IEditorReference)) return;
IEditorPart editor = getSupportedEditor(partRef);
if (editor!=null)
handleEditor(editor);

}

private IEditorPart getSupportedEditor(IWorkbenchPartReference partRef) {
if (!(partRef instanceof IEditorReference)) return null;

IEditorReference editorRef = (IEditorReference) partRef;

IEditorPart editor=null;
Expand Down Expand Up @@ -1380,9 +1386,23 @@ public void pageChanged(PageChangedEvent event) {
if (obj instanceof JChemPaintEditor) {
JChemPaintEditor jcp = (JChemPaintEditor) obj;
registerJCPListeners(jcp);

ICDKMolecule mol = jcp.getCDKMolecule();
//Use cached if exists, else set up new
if (molTestMap.containsKey(mol)){

doSetUpTestRuns(mol);

updateView();
}else{
doClearAndSetUpNewTestRuns(mol);
}

}
else {
logger.debug("No JCP visible anymore.");
logger.debug("No JCP page visible anymore in moltable.");
deactivateView();
updateView();
}
}
});
Expand Down Expand Up @@ -1454,16 +1474,11 @@ else if(event.getProperty().equals( JChemPaintEditor.
};
jcp.addPropertyChangedListener(jcplistener);
molListenerMap.put(jcp.getCDKMolecule(), jcplistener);

//Ok, we have LOADED now
ICDKMolecule cdkmol = jcp.getCDKMolecule();
JCPModelLoaded(cdkmol);

}

private void JCPModelLoaded(ICDKMolecule cdkmol){
logger.debug ("EventView reacting: JCP model is loaded. Molecule: " + cdkmol);
doClearAndSetUpNewTestRuns(cdkmol);
doSetUpTestRuns(cdkmol);
//TODO: VERIFY
}

Expand Down Expand Up @@ -1526,5 +1541,47 @@ else if (test.isExcluded()){
setExecuted( false );
updateView();
}



private void doSetUpTestRuns( ICDKMolecule mol ) {

//Use cached, if no cached, clear and create new
activeTestRuns=molTestMap.get(mol);
if (activeTestRuns==null){
doClearAndSetUpNewTestRuns(mol);
return;
}

//For all endpoints, clear old and add these testruns
IDSManager ds = net.bioclipse.ds.Activator.getDefault().getJavaManager();
try {
for (Endpoint ep : ds.getFullEndpoints()){

//First remove any old TestRuns
if (ep.getTestruns()!=null)
ep.getTestruns().clear();

if (ep.getTests()!=null){
//Loop over all tests in this Endpoint
for (IDSTest epTest : ep.getTests()){
//For the active testruns, locate those who are of this test
for (TestRun tr : activeTestRuns){
if (tr.getTest().getId().equals( epTest.getId() )){
ep.addTestRun( tr );
logger.debug("Added cached TestRun: " + tr);
}
}

}
}
}
} catch (BioclipseException e) {
e.printStackTrace();
}

updateView();

}

}
Expand Up @@ -105,9 +105,9 @@ public String toString() {
// return tr.getConsensusString();
// else
if (results!=null)
return getConsensusString() + " [" + results.size() + " hits]";
return getTest().getName() + " - " + getConsensusString() + " [" + results.size() + " hits]";
else
return getConsensusString();
return getTest().getName() + " - " + getConsensusString();
}

public boolean hasMatches() {
Expand Down

0 comments on commit fbd8726

Please sign in to comment.