Permalink
Browse files

Handle case when switching between active editors.

  • Loading branch information...
1 parent 61b0bda commit b24acd5091aaf220257344bd3a50a7752a3b7097 @olas committed Jun 29, 2010
Showing with 41 additions and 2 deletions.
  1. +41 −2 plugins/net.bioclipse.ds.ui/src/net/bioclipse/ds/ui/views/DSView.java
@@ -1288,6 +1288,7 @@ public void partClosed(IWorkbenchPartReference partRef) {
if (getSite().getWorkbenchWindow().getActivePage()==null) return;
if (getSite().getWorkbenchWindow().getActivePage().getActiveEditor()==null){
deactivateView();
+ return;
}
updateView();
@@ -1328,7 +1329,6 @@ public void partVisible(IWorkbenchPartReference partRef) {
==============================*/
private void deactivateView() {
-// molTestMap.clear();
activeTestRuns=null;
IDSManager ds = net.bioclipse.ds.Activator.getDefault().getJavaManager();
try {
@@ -1339,6 +1339,7 @@ private void deactivateView() {
} catch (BioclipseException e) {
e.printStackTrace();
}
+ updateView();
}
@@ -1417,6 +1418,45 @@ private void activateEditor(IEditorPart editor){
}
else if (editor instanceof MultiPageMoleculesEditorPart) {
MultiPageMoleculesEditorPart moltable = (MultiPageMoleculesEditorPart) editor;
+ if (!moltable.isJCPVisible()){
+ logger.debug("JCP is not the visible page. Deactivate view.");
+ if (getSite()==null) return;
+ if (getSite().getWorkbenchWindow()==null) return;
+ if (getSite().getWorkbenchWindow().getActivePage()==null) return;
+ deactivateView();
+ }else{
+ //TODO: Handle case when switch to MolTable with JCP open
+ //This should mean we have a cached mol.
+ logger.debug("JCP is the visible page. Probably cached.");
+
+ Object obj = moltable.getSelectedPage();
+ if (obj instanceof JChemPaintEditor) {
+
+ JChemPaintEditor jcp = (JChemPaintEditor) obj;
+ jcp.addPropertyChangedListener(DSView.getInstance());
+ logger.debug("Added prop-listener to JCP");
+
+ ICDKMolecule mol = jcp.getCDKMolecule();
+ if (mol==null){
+ logger.debug("Molecule is null, not loaded yet?");
+ return;
+ }
+
+ //Use cached if exists, else set up new
+ if (molTestMap.containsKey(mol)){
+
+ doSetUpTestRuns(mol);
+
+ updateView();
+ }else{
+ doClearAndSetUpNewTestRuns(mol);
+ }
+ }else{
+ logger.error("JCP is visible but class is not JCP!");
+ }
+
+ }
+
moltable.addPageChangedListener(new IPageChangedListener() {
@@ -1449,7 +1489,6 @@ public void pageChanged(PageChangedEvent event) {
else {
logger.debug("No JCP page visible anymore in moltable.");
deactivateView();
- updateView();
return;
}
}

0 comments on commit b24acd5

Please sign in to comment.