Merge branch 'idea90' of git.labs.intellij.net:idea/community into idea90

This commit is contained in:
Dmitry Avdeev
2009-12-22 18:14:30 +03:00
4 changed files with 47 additions and 9 deletions
@@ -730,8 +730,7 @@ public class BackendCompilerWrapper {
if (paths == null || paths.isEmpty()) {
return;
}
final String prefix = packagePrefix != null && packagePrefix.length() > 0 ? packagePrefix.replace('.', '/') + "/" : "";
final String filePath = "/" + prefix + VfsUtil.getRelativePath(srcFile, sourceRoot, '/');
final String filePath = "/" + calcPackagePath(srcFile, sourceRoot, packagePrefix);
for (final CompiledClass cc : paths) {
myCompileContext.getProgressIndicator().checkCanceled();
if (LOG.isDebugEnabled()) {
@@ -768,6 +767,18 @@ public class BackendCompilerWrapper {
}
}
/**
*
* @param srcFile
* @param sourceRoot
* @param packagePrefix
* @return A 'package'-path to a given src file relative to a specified root. "/" slashes must be used
*/
protected String calcPackagePath(VirtualFile srcFile, VirtualFile sourceRoot, String packagePrefix) {
final String prefix = packagePrefix != null && packagePrefix.length() > 0 ? packagePrefix.replace('.', '/') + "/" : "";
return prefix + VfsUtil.getRelativePath(srcFile, sourceRoot, '/');
}
@Nullable
private Pair<String, String> moveToRealLocation(String tempOutputDir, String pathToClass, VirtualFile sourceFile, final List<File> filesToRefresh) {
final Module module = myCompileContext.getModuleByFile(sourceFile);
@@ -20,8 +20,10 @@ import com.intellij.debugger.DebuggerManager;
import com.intellij.debugger.SourcePosition;
import com.intellij.debugger.engine.evaluation.EvaluateException;
import com.intellij.debugger.engine.evaluation.EvaluateExceptionUtil;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.progress.ProcessCanceledException;
import com.intellij.openapi.util.Computable;
import com.intellij.openapi.util.Ref;
import com.intellij.psi.*;
import com.intellij.psi.jsp.JspFile;
@@ -213,8 +215,12 @@ public class JVMNameUtil {
throw EvaluateExceptionUtil.createEvaluateException(DebuggerBundle.message("error.class.not.loaded", getDisplayName(process)));
}
public String getDisplayName(DebugProcessImpl debugProcess) {
return getSourcePositionClassDisplayName(debugProcess, mySourcePosition);
public String getDisplayName(final DebugProcessImpl debugProcess) {
return ApplicationManager.getApplication().runReadAction(new Computable<String>() {
public String compute() {
return getSourcePositionClassDisplayName(debugProcess, mySourcePosition);
}
});
}
}
@@ -102,7 +102,6 @@ public class ProgressWindow extends BlockingProgressIndicator implements Disposa
else {
myDialog = new MyDialog(shouldShowBackground, myProject, myCancelText);
}
myDialog.changeCancelButtonText(myCancelText);
Disposer.register(this, myDialog);
@@ -494,6 +493,9 @@ public class ProgressWindow extends BlockingProgressIndicator implements Disposa
private void createCenterPanel() {
// Cancel button (if any)
if (myCancelText != null) {
myCancelButton.setText(myCancelText);
}
myCancelButton.setVisible(myShouldShowCancel);
myBackgroundButton.setVisible(myShouldShowBackground);
@@ -15,6 +15,8 @@
*/
package com.intellij.openapi.vcs.impl;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.project.DumbAwareRunnable;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.startup.StartupManager;
@@ -26,10 +28,15 @@ import java.util.LinkedList;
import java.util.List;
public class VcsInitialization {
private static final Logger LOG = Logger.getInstance("#com.intellij.openapi.vcs.impl.VcsInitialization");
private final Project myProject;
private final List<Pair<VcsInitObject, Runnable>> myList;
private final Object myLock;
private boolean myInitStarted;
public VcsInitialization(Project project) {
public VcsInitialization(final Project project) {
myLock = new Object();
myProject = project;
myList = new LinkedList<Pair<VcsInitObject, Runnable>>();
@@ -41,16 +48,28 @@ public class VcsInitialization {
}
public void add(final VcsInitObject vcsInitObject, final Runnable runnable) {
myList.add(new Pair<VcsInitObject, Runnable>(vcsInitObject, runnable));
synchronized (myLock) {
if (myInitStarted) {
LOG.info("Registering startup activity AFTER initialization ", new Throwable());
// post startup are normally called on awt thread
ApplicationManager.getApplication().invokeLater(runnable);
}
myList.add(new Pair<VcsInitObject, Runnable>(vcsInitObject, runnable));
}
}
public void execute() {
Collections.sort(myList, new Comparator<Pair<VcsInitObject, Runnable>>() {
final List<Pair<VcsInitObject, Runnable>> list;
synchronized (myLock) {
list = myList;
myInitStarted = true; // list would not be modified starting from this point
}
Collections.sort(list, new Comparator<Pair<VcsInitObject, Runnable>>() {
public int compare(Pair<VcsInitObject, Runnable> o1, Pair<VcsInitObject, Runnable> o2) {
return new Integer(o1.getFirst().getOrder()).compareTo(new Integer(o2.getFirst().getOrder()));
}
});
for (Pair<VcsInitObject, Runnable> pair : myList) {
for (Pair<VcsInitObject, Runnable> pair : list) {
pair.getSecond().run();
}
}