Permalink
Browse files

Fixed TISTUD-1382: added element visiblity listener to ensure the sam…

…ples are reloaded at the right time.
  • Loading branch information...
1 parent 6fa3a38 commit 503d286870ba169647261c13b4bed7bc5daa79b9 mxia committed Apr 14, 2012
Showing with 23 additions and 0 deletions.
  1. +23 −0 plugins/com.aptana.samples/src/com/aptana/samples/internal/SamplesManager.java
View
23 plugins/com.aptana.samples/src/com/aptana/samples/internal/SamplesManager.java
@@ -35,7 +35,9 @@
import com.aptana.samples.SamplesPlugin;
import com.aptana.samples.model.SampleCategory;
import com.aptana.samples.model.SamplesReference;
+import com.aptana.scripting.model.AbstractElement;
import com.aptana.scripting.model.BundleManager;
+import com.aptana.scripting.model.ElementVisibilityListener;
import com.aptana.scripting.model.LoadCycleListener;
import com.aptana.scripting.model.ProjectSampleElement;
@@ -106,6 +108,26 @@ private boolean needLoadSamples(File script)
}
};
+ private ElementVisibilityListener elementListener = new ElementVisibilityListener()
+ {
+
+ public void elementBecameHidden(AbstractElement element)
+ {
+ if (element instanceof ProjectSampleElement)
+ {
+ loadBundleSampleElements();
+ }
+ }
+
+ public void elementBecameVisible(AbstractElement element)
+ {
+ if (element instanceof ProjectSampleElement)
+ {
+ addSample((ProjectSampleElement) element);
+ }
+ }
+ };
+
public SamplesManager()
{
categories = new HashMap<String, SampleCategory>();
@@ -120,6 +142,7 @@ public SamplesManager()
loadBundleSampleElements();
BundleManager.getInstance().addLoadCycleListener(loadCycleListener);
+ BundleManager.getInstance().addElementVisibilityListener(elementListener);
}
public List<SampleCategory> getCategories()

0 comments on commit 503d286

Please sign in to comment.