mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Multi thread access to theme resource
This commit is contained in:
+14
-16
@@ -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;
|
||||
}
|
||||
|
||||
+1
-1
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user