Merge remote branch 'origin/master'

This commit is contained in:
Kirill Kalishev
2011-12-02 21:58:16 +03:00
6 changed files with 78 additions and 14 deletions
@@ -120,6 +120,14 @@ public class RunConfigurationAction extends ComboBoxAction implements DumbAware
LOG.assertTrue(frame != null);
frame.getComponent().getRootPane().putClientProperty(BUTTON_KEY, this);
}
@Override
public void removeNotify() {
final IdeFrame frame = findFrame(this);
LOG.assertTrue(frame != null);
frame.getComponent().getRootPane().putClientProperty(BUTTON_KEY, null);
super.removeNotify();
}
};
final JPanel panel = new JPanel(new BorderLayout());
@@ -70,7 +70,7 @@ public class ToolWindowContentUi extends JPanel implements ContentUI, PropertyCh
ContentLayout myComboLayout = new ComboContentLayout(this);
private ToolWindowContentUiType myType = ToolWindowContentUiType.TABBED;
private static DefaultActionGroup myGroup;
private DefaultActionGroup myGroup;
public ToolWindowContentUi(ToolWindowImpl window) {
myWindow = window;
@@ -252,7 +252,7 @@ public class ToolWindowContentUi extends JPanel implements ContentUI, PropertyCh
return true;
}
static void initMouseListeners(final JComponent c, final ToolWindowContentUi ui) {
void initMouseListeners(final JComponent c, final ToolWindowContentUi ui) {
if (c.getClientProperty(ui) != null) return;
@@ -257,6 +257,11 @@ public class IdeStatusBarImpl extends JComponent implements StatusBarEx {
public void dispose() {
myWidgetMap.clear();
myChildren.clear();
myLeftPanel.removeAll();
myRightPanel.removeAll();
myCenterPanel.removeAll();
}
private void addWidget(@NotNull final StatusBarWidget widget, @NotNull final Position pos, @NotNull final String anchor) {
@@ -19,11 +19,15 @@ import com.intellij.openapi.compiler.CompilerManager;
import com.intellij.openapi.components.AbstractProjectComponent;
import com.intellij.openapi.project.Project;
import org.jetbrains.android.compiler.AndroidPrecompileTask;
import org.jetbrains.annotations.NotNull;
/**
* @author Eugene.Kudelevsky
*/
public class AndroidProjectComponent extends AbstractProjectComponent {
private volatile boolean myCompilationRunning = false;
private final Object COMPILATION_FLAG_LOCK = new Object();
protected AndroidProjectComponent(Project project) {
super(project);
}
@@ -31,6 +35,26 @@ public class AndroidProjectComponent extends AbstractProjectComponent {
@Override
public void projectOpened() {
final CompilerManager manager = CompilerManager.getInstance(myProject);
manager.addBeforeTask(new AndroidPrecompileTask());
manager.addBeforeTask(new AndroidPrecompileTask(this));
}
public void setCompilationStarted() {
synchronized (COMPILATION_FLAG_LOCK) {
myCompilationRunning = true;
}
}
public void setCompilationFinished() {
synchronized (COMPILATION_FLAG_LOCK) {
myCompilationRunning = false;
}
}
public void runIfNotInCompilation(@NotNull Runnable r) {
synchronized (COMPILATION_FLAG_LOCK) {
if (!myCompilationRunning) {
r.run();
}
}
}
}
@@ -44,6 +44,7 @@ import com.intellij.psi.PsiFile;
import com.intellij.psi.search.GlobalSearchScope;
import com.intellij.util.ArrayUtil;
import com.intellij.util.containers.HashSet;
import org.jetbrains.android.AndroidProjectComponent;
import org.jetbrains.android.dom.resources.Attr;
import org.jetbrains.android.dom.resources.DeclareStyleable;
import org.jetbrains.android.dom.resources.ResourceElement;
@@ -340,19 +341,24 @@ public class AndroidCompileUtil {
}
}
public static void generate(final Module module, GeneratingCompiler compiler) {
assert !ApplicationManager.getApplication().isDispatchThread();
final CompileContext[] contextWrapper = new CompileContext[1];
ApplicationManager.getApplication().runReadAction(new Runnable() {
public static void generate(final Module module, final GeneratingCompiler compiler) {
module.getProject().getComponent(AndroidProjectComponent.class).runIfNotInCompilation(new Runnable() {
@Override
public void run() {
Project project = module.getProject();
if (project.isDisposed()) return;
CompilerTask task = new CompilerTask(project, true, "Android auto-generation", true);
CompileScope scope = new ModuleCompileScope(module, false);
contextWrapper[0] = new CompileContextImpl(project, task, scope, null, false, false);
assert !ApplicationManager.getApplication().isDispatchThread();
final CompileContext[] contextWrapper = new CompileContext[1];
ApplicationManager.getApplication().runReadAction(new Runnable() {
public void run() {
Project project = module.getProject();
if (project.isDisposed()) return;
CompilerTask task = new CompilerTask(project, true, "Android auto-generation", true);
CompileScope scope = new ModuleCompileScope(module, false);
contextWrapper[0] = new CompileContextImpl(project, task, scope, null, false, false);
}
});
generate(compiler, contextWrapper[0]);
}
});
generate(compiler, contextWrapper[0]);
}
public static boolean isModuleAffected(CompileContext context, Module module) {
@@ -34,6 +34,7 @@ import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vfs.LocalFileSystem;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.util.containers.hash.HashSet;
import org.jetbrains.android.AndroidProjectComponent;
import org.jetbrains.android.facet.AndroidFacet;
import org.jetbrains.android.facet.AndroidRootUtil;
import org.jetbrains.android.sdk.AndroidPlatform;
@@ -48,11 +49,19 @@ import java.util.Set;
* @author Eugene.Kudelevsky
*/
public class AndroidPrecompileTask implements CompileTask {
private static final Logger LOG = Logger.getInstance("#org.jetbrains.android.compiler.AndroidPrecompileTask");
private final AndroidProjectComponent myOwner;
private static final Logger LOG = Logger.getInstance("#org.jetbrains.android.compiler.AndroidPrecompileTask");
public AndroidPrecompileTask(@NotNull AndroidProjectComponent owner) {
myOwner = owner;
}
@Override
public boolean execute(CompileContext context) {
final Project project = context.getProject();
myOwner.setCompilationStarted();
ExcludedEntriesConfiguration configuration =
((CompilerConfigurationImpl)CompilerConfiguration.getInstance(project)).getExcludedEntriesConfiguration();
@@ -96,6 +105,18 @@ public class AndroidPrecompileTask implements CompileTask {
CompilerManager.getInstance(project).addCompilationStatusListener(new MyCompilationStatusListener(project, addedEntries), project);
}
CompilerManager.getInstance(project).addCompilationStatusListener(new CompilationStatusListener() {
@Override
public void compilationFinished(boolean aborted, int errors, int warnings, final CompileContext compileContext) {
ApplicationManager.getApplication().executeOnPooledThread(new Runnable() {
@Override
public void run() {
myOwner.setCompilationFinished();
}
});
}
}, project);
return true;
}