Multi thread access to theme resource

This commit is contained in:
Alexander Lobas
2012-03-07 20:44:21 +04:00
parent 4f5afa0719
commit e31f2d7798
3 changed files with 20 additions and 19 deletions
@@ -78,12 +78,26 @@ public final class AndroidDesignerEditorPanel extends DesignerEditorPanel {
public AndroidDesignerEditorPanel(@NotNull Module module, @NotNull VirtualFile file) {
super(module, file);
myXmlFile = (XmlFile)ApplicationManager.getApplication().runReadAction(new Computable<PsiFile>() {
@Override
public PsiFile compute() {
return PsiManager.getInstance(getProject()).findFile(myFile);
}
});
myPSIChangeListener = new ExternalPSIChangeListener(this, myXmlFile, 100, new Runnable() {
@Override
public void run() {
reparseFile();
}
});
showProgress("Load configuration");
myProfileAction = new ProfileAction(this, new Runnable() {
@Override
public void run() {
myActionPanel.update();
if (myRootComponent == null) {
myPSIChangeListener.start();
myPSIChangeListener.addRequest();
}
else {
@@ -96,22 +110,6 @@ public final class AndroidDesignerEditorPanel extends DesignerEditorPanel {
}
}
});
myXmlFile = (XmlFile)ApplicationManager.getApplication().runReadAction(new Computable<PsiFile>() {
@Override
public PsiFile compute() {
return PsiManager.getInstance(getProject()).findFile(myFile);
}
});
myPSIChangeListener = new ExternalPSIChangeListener(this, myXmlFile, 100, new Runnable() {
@Override
public void run() {
reparseFile();
}
});
// TODO: work over activate() / deactivate()
myPSIChangeListener.start();
}
private void reparseFile() {
@@ -39,6 +39,7 @@ public class AndroidTargetData {
private volatile AttributeDefinitions myAttrDefs;
private volatile RenderServiceFactory myRenderServiceFactory;
private volatile Set<String> myThemes;
private volatile boolean myThemesLoaded;
public AndroidTargetData(@NotNull AndroidSdkData sdkData, @NotNull IAndroidTarget target) {
mySdkData = sdkData;
@@ -76,11 +77,11 @@ public class AndroidTargetData {
}
public boolean areThemesCached() {
return myThemes != null;
return myThemesLoaded;
}
@NotNull
public Set<String> getThemes(@NotNull final AndroidFacet facet) {
public synchronized Set<String> getThemes(@NotNull final AndroidFacet facet) {
if (myThemes == null) {
myThemes = new HashSet<String>();
final Module module = facet.getModule();
@@ -125,6 +126,8 @@ public class AndroidTargetData {
}
}
}
myThemesLoaded = true;
}
return myThemes;
}
@@ -94,7 +94,7 @@ public abstract class AbstractComboBoxAction<T> extends ComboBoxAction {
}
public void update() {
update(mySelection, myPresentation, false);
update(mySelection, myPresentation == null ? getTemplatePresentation() : myPresentation, false);
}
@NotNull