mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Merge branch 'master' of git@git.labs.intellij.net:idea/community
This commit is contained in:
Regular → Executable
+7
-3
@@ -26,7 +26,11 @@ if [ -z "$IDEA_JDK" ]; then
|
||||
fi
|
||||
if [ -z "$IDEA_JDK" ]; then
|
||||
echo ERROR: cannot start IntelliJ IDEA.
|
||||
echo No JDK found to run IDEA. Please validate either IDEA_JDK or JDK_HOME points to valid JDK installation
|
||||
echo No JDK found to run IDEA. Please validate either IDEA_JDK, JDK_HOME or JAVA_HOME points to valid JDK installation.
|
||||
echo
|
||||
echo Press Enter to continue.
|
||||
read IGNORE
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
@@ -36,7 +40,7 @@ grep 'OpenJDK' $VERSION_LOG
|
||||
OPEN_JDK=$?
|
||||
grep '64-Bit' $VERSION_LOG
|
||||
BITS=$?
|
||||
rm /tmp/java.version.log
|
||||
rm $VERSION_LOG
|
||||
if [ $OPEN_JDK -eq 0 ]; then
|
||||
echo WARNING: You are launching IDE using OpenJDK Java runtime
|
||||
echo
|
||||
@@ -84,7 +88,7 @@ fi
|
||||
|
||||
REQUIRED_JVM_ARGS="-Xbootclasspath/a:../lib/boot.jar $IDEA_PROPERTIES_PROPERTY $REQUIRED_JVM_ARGS"
|
||||
JVM_ARGS=`tr '\n' ' ' < "$IDEA_VM_OPTIONS"`
|
||||
JVM_ARGS="$JVM_ARGS $REQUIRED_JVM_ARGS"
|
||||
JVM_ARGS=`eval echo $JVM_ARGS $REQUIRED_JVM_ARGS`
|
||||
|
||||
CLASSPATH=../lib/bootstrap.jar
|
||||
CLASSPATH=$CLASSPATH:../lib/util.jar
|
||||
|
||||
+1
-1
@@ -159,7 +159,7 @@ public class JikesCompiler extends ExternalCompiler {
|
||||
|
||||
private void _createStartupCommand(final ModuleChunk chunk, final ArrayList<String> commandLine, @NotNull final String outputPath) throws IOException {
|
||||
|
||||
myTempFile = File.createTempFile("jikes", ".tmp");
|
||||
myTempFile = FileUtil.createTempFile("jikes", ".tmp");
|
||||
myTempFile.deleteOnExit();
|
||||
|
||||
final List<VirtualFile> files = chunk.getFilesToCompile();
|
||||
|
||||
+3
-2
@@ -21,6 +21,7 @@ package com.intellij.compiler.impl.packagingCompiler;
|
||||
|
||||
import com.intellij.openapi.compiler.make.BuildInstruction;
|
||||
import com.intellij.openapi.util.UserDataHolderBase;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import gnu.trove.THashSet;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
|
||||
@@ -64,8 +65,8 @@ public abstract class BuildInstructionBase extends UserDataHolderBase implements
|
||||
}
|
||||
|
||||
protected File createTempFile(final String prefix, final String suffix) throws IOException {
|
||||
final File tempFile = File.createTempFile(prefix +"___",suffix);
|
||||
final File tempFile = FileUtil.createTempFile(prefix + "___", suffix);
|
||||
addFileToDelete(tempFile);
|
||||
return tempFile;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -583,7 +583,7 @@ public class CompilerTask extends Task.Backgroundable {
|
||||
connection.subscribe(CompilerTopics.COMPILATION_STATUS, new CompilationStatusListener() {
|
||||
public void compilationFinished(boolean aborted, int errors, int warnings, final CompileContext compileContext) {
|
||||
connection.disconnect();
|
||||
ProjectUtil.closeProject(project);
|
||||
ProjectUtil.closeAndDispose(project);
|
||||
}
|
||||
});
|
||||
cancel();
|
||||
|
||||
@@ -105,7 +105,7 @@ public class RunHotswapDialog extends OptionsDialog {
|
||||
JLabel label = new JLabel(DebuggerBundle.message("hotswap.dialog.run.prompt"));
|
||||
JPanel panel = new JPanel(new BorderLayout());
|
||||
panel.add(label, BorderLayout.CENTER);
|
||||
Icon icon = UIUtil.getOptionPanelQuestionIcon();
|
||||
Icon icon = UIUtil.getQuestionIcon();
|
||||
if (icon != null) {
|
||||
label.setIcon(icon);
|
||||
label.setIconTextGap(7);
|
||||
|
||||
+13
@@ -53,4 +53,17 @@ public class EvaluateException extends Exception {
|
||||
public void setTargetException(final ObjectReference targetException) {
|
||||
myTargetException = targetException;
|
||||
}
|
||||
|
||||
public String getMessage() {
|
||||
final String errorMessage = super.getMessage();
|
||||
if (errorMessage != null) {
|
||||
return errorMessage;
|
||||
}
|
||||
final Throwable cause = getCause();
|
||||
final String causeMessage = cause != null? cause.getMessage() : null;
|
||||
if (causeMessage != null) {
|
||||
return causeMessage;
|
||||
}
|
||||
return "unknown error";
|
||||
}
|
||||
}
|
||||
@@ -32,6 +32,7 @@ import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.openapi.util.DefaultJDOMExternalizer;
|
||||
import com.intellij.openapi.util.InvalidDataException;
|
||||
import com.intellij.openapi.util.WriteExternalException;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.psi.PsiClass;
|
||||
import com.intellij.psi.PsiElement;
|
||||
@@ -301,7 +302,7 @@ public class AppletConfiguration extends ModuleBasedConfiguration<JavaRunConfigu
|
||||
}
|
||||
|
||||
private AppletHtmlFile generateAppletTempPage() throws IOException {
|
||||
final File tempFile = File.createTempFile("AppletPage", ".html");
|
||||
final File tempFile = FileUtil.createTempFile("AppletPage", ".html");
|
||||
@NonNls final FileWriter writer = new FileWriter(tempFile);
|
||||
try {
|
||||
writer.write("<html>\n" +
|
||||
|
||||
@@ -129,7 +129,7 @@ public class ExceptionFilter implements Filter, DumbAware {
|
||||
final OpenFileHyperlinkInfo linkInfo = new OpenFileHyperlinkInfo(myProject, virtualFile, lineNumber - 1);
|
||||
TextAttributes attributes = HYPERLINK_ATTRIBUTES.clone();
|
||||
if (!ProjectRootManager.getInstance(myProject).getFileIndex().isInContent(virtualFile)) {
|
||||
Color color = UIUtil.getTextInactiveTextColor();
|
||||
Color color = UIUtil.getInactiveTextColor();
|
||||
attributes.setForegroundColor(color);
|
||||
attributes.setEffectColor(color);
|
||||
}
|
||||
|
||||
@@ -197,7 +197,7 @@ public class NewProjectUtil {
|
||||
Messages.getQuestionIcon(), new ProjectNewWindowDoNotAskOption());
|
||||
}
|
||||
if (exitCode == 1) { // "No" option
|
||||
ProjectUtil.closeProject(projectToClose != null ? projectToClose : openProjects[openProjects.length - 1]);
|
||||
ProjectUtil.closeAndDispose(projectToClose != null ? projectToClose : openProjects[openProjects.length - 1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -75,7 +75,7 @@ public abstract class AbstractStepWithProgress<Result> extends ModuleWizardStep
|
||||
private JPanel createProgressPanel() {
|
||||
final JPanel progressPanel = new JPanel(new GridBagLayout());
|
||||
myTitleLabel = new JLabel();
|
||||
myTitleLabel.setFont(UIManager.getFont("Label.font").deriveFont(Font.BOLD));
|
||||
myTitleLabel.setFont(UIUtil.getLabelFont().deriveFont(Font.BOLD));
|
||||
progressPanel.add(myTitleLabel, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 2, 1, 1.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(8, 10, 5, 10), 0, 0));
|
||||
|
||||
myProgressLabel = new JLabel();
|
||||
|
||||
@@ -81,7 +81,6 @@ public class NameLocationStep extends ModuleWizardStep {
|
||||
myPanel.add(myNamePathComponent, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 2, 1, 1.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(8, 10, 0, 10), 0, 0));
|
||||
|
||||
final JLabel label = new JLabel(IdeBundle.message("label.module.file.will.be.saved.in"));
|
||||
//label.setFont(UIManager.getFont("Label.font").deriveFont(Font.BOLD));
|
||||
myPanel.add(label, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 2, 1, 1.0, 1.0, GridBagConstraints.SOUTHWEST, GridBagConstraints.HORIZONTAL, new Insets(30, 10, 0, 10), 0, 0));
|
||||
|
||||
myTfModuleFilePath = new JTextField();
|
||||
|
||||
+3
-2
@@ -524,8 +524,9 @@ public class ConfigurationErrorsComponent extends JPanel implements Disposable,
|
||||
if (myModel.getSize() == 0) {
|
||||
setBorder(null);
|
||||
} else {
|
||||
if (getBorder() == null) setBorder(BorderFactory.createCompoundBorder(BorderFactory.createMatteBorder(5, 0, 5, 0, UIUtil.getPanelBackground()),
|
||||
BorderFactory.createLineBorder(UIUtil.getPanelBackgound().darker())));
|
||||
if (getBorder() == null) setBorder(
|
||||
BorderFactory.createCompoundBorder(BorderFactory.createMatteBorder(5, 0, 5, 0, UIUtil.getPanelBackground()),
|
||||
BorderFactory.createLineBorder(UIUtil.getPanelBackground().darker())));
|
||||
}
|
||||
|
||||
final List<ConfigurationError> errors = myModel.getErrors();
|
||||
|
||||
@@ -60,6 +60,7 @@ import java.util.List;
|
||||
@SuppressWarnings({"AssignmentToStaticFieldFromInstanceMethod"})
|
||||
public abstract class ModuleEditor implements Place.Navigator, Disposable {
|
||||
|
||||
public static final String MODULE_TAB = "moduleTab";
|
||||
private final Project myProject;
|
||||
private JPanel myGenericSettingsPanel;
|
||||
private ModifiableRootModel myModifiableRootModel; // important: in order to correctly update OrderEntries UI use corresponding proxy for the model
|
||||
@@ -246,12 +247,12 @@ public abstract class ModuleEditor implements Place.Navigator, Disposable {
|
||||
}
|
||||
|
||||
public ActionCallback navigateTo(@Nullable final Place place, final boolean requestFocus) {
|
||||
myTabbedPane.setSelectedTitle((String)place.getPath("moduleTab"));
|
||||
myTabbedPane.setSelectedTitle((String)place.getPath(MODULE_TAB));
|
||||
return new ActionCallback.Done();
|
||||
}
|
||||
|
||||
public void queryPlace(@NotNull final Place place) {
|
||||
place.putPath("moduleTab", ourSelectedTabName);
|
||||
place.putPath(MODULE_TAB, ourSelectedTabName);
|
||||
}
|
||||
|
||||
public static String getSelectedTab(){
|
||||
|
||||
+1
-1
@@ -359,7 +359,7 @@ public class ProjectStructureConfigurable extends BaseConfigurable implements Se
|
||||
if (moduleToSelect != null) {
|
||||
final Module module = ModuleManager.getInstance(myProject).findModuleByName(moduleToSelect);
|
||||
assert module != null;
|
||||
place = place.putPath(ModuleStructureConfigurable.TREE_OBJECT, module);
|
||||
place = place.putPath(ModuleStructureConfigurable.TREE_OBJECT, module).putPath(ModuleEditor.MODULE_TAB, tab);
|
||||
}
|
||||
return navigateTo(place, requestFocus);
|
||||
}
|
||||
|
||||
+1
-1
@@ -193,7 +193,7 @@ public abstract class BaseStructureConfigurable extends MasterDetailsComponent i
|
||||
final boolean invalid = level != null;
|
||||
if (unused || invalid) {
|
||||
Color fg = unused
|
||||
? UIUtil.getTextInactiveTextColor()
|
||||
? UIUtil.getInactiveTextColor()
|
||||
: selected && hasFocus ? UIUtil.getTreeSelectionForeground() : UIUtil.getTreeForeground();
|
||||
textAttributes = new SimpleTextAttributes(invalid ? SimpleTextAttributes.STYLE_WAVED : SimpleTextAttributes.STYLE_PLAIN, fg,
|
||||
level == ProjectStructureProblemDescription.Severity.ERROR ? Color.RED : Color.GRAY);
|
||||
|
||||
@@ -40,6 +40,7 @@ import com.intellij.openapi.projectRoots.Sdk;
|
||||
import com.intellij.openapi.projectRoots.ex.PathUtilEx;
|
||||
import com.intellij.openapi.roots.*;
|
||||
import com.intellij.openapi.util.*;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.*;
|
||||
@@ -250,7 +251,7 @@ public class JavadocConfiguration implements ModuleRunProfile, JDOMExternalizabl
|
||||
}
|
||||
|
||||
try {
|
||||
File sourcepathTempFile = File.createTempFile("javadoc", "args.txt");
|
||||
File sourcepathTempFile = FileUtil.createTempFile("javadoc", "args.txt");
|
||||
sourcepathTempFile.deleteOnExit();
|
||||
parameters.add("@" + sourcepathTempFile.getCanonicalPath());
|
||||
final PrintWriter writer = new PrintWriter(new FileWriter(sourcepathTempFile));
|
||||
|
||||
@@ -21,6 +21,7 @@ import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.fileTypes.StdFileTypes;
|
||||
import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.codeStyle.CodeStyleManager;
|
||||
import com.intellij.psi.codeStyle.CodeStyleSettings;
|
||||
@@ -468,7 +469,7 @@ public class ImportHelper{
|
||||
return array;
|
||||
}
|
||||
|
||||
private static PsiClass findSingleImportByShortName(@NotNull PsiJavaFile file, @NotNull String shortClassName){
|
||||
private static PsiClass findSingleImportByShortName(@NotNull final PsiJavaFile file, @NotNull String shortClassName){
|
||||
PsiClass[] refs = file.getSingleClassImports(true);
|
||||
for (PsiClass ref : refs) {
|
||||
String className = ref.getQualifiedName();
|
||||
@@ -482,6 +483,33 @@ public class ImportHelper{
|
||||
return aClass;
|
||||
}
|
||||
}
|
||||
|
||||
// there maybe a class imported implicitly from current package
|
||||
String packageName = file.getPackageName();
|
||||
if (!StringUtil.isEmptyOrSpaces(packageName)) {
|
||||
String fqn = packageName + "." + shortClassName;
|
||||
final PsiClass aClass = JavaPsiFacade.getInstance(file.getProject()).findClass(fqn, file.getResolveScope());
|
||||
if (aClass != null) {
|
||||
final boolean[] foundRef = {false};
|
||||
// check if that short name referenced in the file
|
||||
file.accept(new JavaRecursiveElementWalkingVisitor() {
|
||||
@Override
|
||||
public void visitElement(PsiElement element) {
|
||||
if (foundRef[0]) return;
|
||||
super.visitElement(element);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitReferenceElement(PsiJavaCodeReferenceElement reference) {
|
||||
if (file.getManager().areElementsEquivalent(reference.resolve(), aClass)) {
|
||||
foundRef[0] = true;
|
||||
}
|
||||
super.visitReferenceElement(reference);
|
||||
}
|
||||
});
|
||||
if (foundRef[0]) return aClass;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
+5
-2
@@ -462,8 +462,9 @@ public abstract class IntroduceVariableBase extends IntroduceHandlerBase impleme
|
||||
final IntroduceVariableSettings settings =
|
||||
getSettings(project, editor, expr, occurrences, typeSelectorManager, inFinalContext, hasWriteAccess, validator, choice);
|
||||
if (!settings.isOK()) return;
|
||||
typeSelectorManager.setAllOccurences(choice != OccurrencesChooser.ReplaceChoice.NO);
|
||||
final RangeMarker exprMarker = editor.getDocument().createRangeMarker(expr.getTextRange());
|
||||
final SuggestedNameInfo suggestedName = getSuggestedName(typeSelectorManager.getDefaultType(), expr);
|
||||
final SuggestedNameInfo suggestedName = getSuggestedName(settings.getSelectedType(), expr);
|
||||
final Runnable runnable =
|
||||
introduce(project, expr, editor, anchorStatement, tempContainer, occurrences, anchorStatementIfAll, settings, variable);
|
||||
CommandProcessor.getInstance().executeCommand(
|
||||
@@ -501,6 +502,7 @@ public abstract class IntroduceVariableBase extends IntroduceHandlerBase impleme
|
||||
editor.getCaretModel().moveToOffset(startOffset);
|
||||
}
|
||||
editor.putUserData(ReassignVariableUtil.DECLARATION_KEY, null);
|
||||
typeSelectorManager.typeSelected(ReassignVariableUtil.getVariableType(declarationStatement));
|
||||
exprMarker.dispose();
|
||||
}
|
||||
});
|
||||
@@ -816,7 +818,8 @@ public abstract class IntroduceVariableBase extends IntroduceHandlerBase impleme
|
||||
|
||||
@Override
|
||||
public PsiType getSelectedType() {
|
||||
return typeSelectorManager.getDefaultType();
|
||||
final PsiType selectedType = typeSelectorManager.getTypeSelector().getSelectedType();
|
||||
return selectedType != null ? selectedType : typeSelectorManager.getDefaultType();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+3
-2
@@ -14,6 +14,7 @@ package com.intellij.refactoring.introduceVariable;
|
||||
|
||||
import com.intellij.codeInsight.lookup.LookupElement;
|
||||
import com.intellij.codeInsight.lookup.LookupElementBuilder;
|
||||
import com.intellij.codeInsight.lookup.PsiTypeLookupItem;
|
||||
import com.intellij.codeInsight.template.Expression;
|
||||
import com.intellij.codeInsight.template.ExpressionContext;
|
||||
import com.intellij.codeInsight.template.TextResult;
|
||||
@@ -97,7 +98,7 @@ public class ReassignVariableUtil {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static PsiType getVariableType(@Nullable PsiDeclarationStatement declaration) {
|
||||
static PsiType getVariableType(@Nullable PsiDeclarationStatement declaration) {
|
||||
if (declaration != null) {
|
||||
final PsiElement[] declaredElements = declaration.getDeclaredElements();
|
||||
if (declaredElements.length > 0 && declaredElements[0] instanceof PsiVariable) {
|
||||
@@ -167,7 +168,7 @@ public class ReassignVariableUtil {
|
||||
public LookupElement[] calculateLookupItems(ExpressionContext context) {
|
||||
LookupElement[] result = new LookupElement[types.length];
|
||||
for (int i = 0, typesLength = types.length; i < typesLength; i++) {
|
||||
result[i] = LookupElementBuilder.create(types[i], types[i].getPresentableText());
|
||||
result[i] = PsiTypeLookupItem.createLookupItem(types[i], null);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -65,7 +65,7 @@ public class InfoDialog extends DialogWrapper{
|
||||
myTextArea = new JTextArea(myText);
|
||||
textPanel.add(myTextArea, BorderLayout.CENTER);
|
||||
myTextArea.setEditable(false);
|
||||
myTextArea.setBackground(UIUtil.getPanelBackgound());
|
||||
myTextArea.setBackground(UIUtil.getPanelBackground());
|
||||
Font font = myShowInFutureCheckBox.getFont();
|
||||
font = new Font(font.getName(), font.getStyle(), font.getSize() + 1);
|
||||
myTextArea.setFont(font);
|
||||
|
||||
@@ -150,8 +150,8 @@ public class ImportHelperTest extends DaemonAnalyzerTestCase {
|
||||
ImportHelper importHelper = new ImportHelper(settings);
|
||||
|
||||
PsiClass psiClass = JavaPsiFacade.getInstance(getProject()).findClass(fqn, GlobalSearchScope.allScope(getProject()));
|
||||
boolean b = importHelper.addImport(file, psiClass);
|
||||
assertTrue(b);
|
||||
boolean b = importHelper.addImport(file, psiClass);
|
||||
assertTrue(b);
|
||||
|
||||
assertOrder(file, expectedOrder);
|
||||
}
|
||||
@@ -193,6 +193,22 @@ public class ImportHelperTest extends DaemonAnalyzerTestCase {
|
||||
String text = LoadTextUtil.loadText(vFile).toString();
|
||||
assertEquals(text, getFile().getText());
|
||||
}
|
||||
public void testConflictingClassesFromCurrentPackage() throws Throwable {
|
||||
final PsiFile file = configureByText(StdFileTypes.JAVA, "package java.util; class X{ Date d;}");
|
||||
assertEmpty(filter(doHighlighting(), HighlightSeverity.ERROR));
|
||||
|
||||
new WriteCommandAction.Simple(getProject()) {
|
||||
@Override
|
||||
protected void run() throws Throwable {
|
||||
CodeStyleSettings settings = CodeStyleSettingsManager.getSettings(getProject());
|
||||
ImportHelper importHelper = new ImportHelper(settings);
|
||||
|
||||
PsiClass psiClass = JavaPsiFacade.getInstance(getProject()).findClass("java.sql.Date", GlobalSearchScope.allScope(getProject()));
|
||||
boolean b = importHelper.addImport((PsiJavaFile)file, psiClass);
|
||||
assertFalse(b); // must fail
|
||||
}
|
||||
}.execute().throwException();
|
||||
}
|
||||
|
||||
@DoNotWrapInCommand
|
||||
public void testAutoImportCaretLocation() throws Throwable {
|
||||
|
||||
@@ -7,6 +7,7 @@ import com.intellij.openapi.roots.ModifiableRootModel;
|
||||
import com.intellij.openapi.roots.ModuleRootManager;
|
||||
import com.intellij.openapi.roots.OrderRootType;
|
||||
import com.intellij.openapi.roots.libraries.Library;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.vfs.LocalFileSystem;
|
||||
import com.intellij.openapi.vfs.VfsUtil;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
@@ -27,7 +28,7 @@ public class SCR17650Test extends PsiTestCase {
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
|
||||
final File root = File.createTempFile(getName(), "");
|
||||
final File root = FileUtil.createTempFile(getName(), "");
|
||||
root.delete();
|
||||
root.mkdir();
|
||||
myFilesToDelete.add(root);
|
||||
|
||||
@@ -12,6 +12,7 @@ import com.intellij.openapi.roots.*;
|
||||
import com.intellij.openapi.roots.impl.ModuleRootManagerImpl;
|
||||
import com.intellij.openapi.roots.libraries.Library;
|
||||
import com.intellij.openapi.roots.libraries.LibraryTable;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.vfs.LocalFileSystem;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.testFramework.ModuleTestCase;
|
||||
@@ -42,7 +43,7 @@ public class ModuleRootsExternalizationTest extends ModuleTestCase {
|
||||
}
|
||||
|
||||
private ModuleRootManagerImpl createTempModuleRootManager() throws IOException {
|
||||
File tmpModule = File.createTempFile("tst", ModuleFileType.DOT_DEFAULT_EXTENSION);
|
||||
File tmpModule = FileUtil.createTempFile("tst", ModuleFileType.DOT_DEFAULT_EXTENSION);
|
||||
myFilesToDelete.add(tmpModule);
|
||||
final Module module = createModule(tmpModule);
|
||||
final ModuleRootManagerImpl moduleRootManager =
|
||||
|
||||
@@ -139,7 +139,7 @@ public abstract class CodeInsightTestCase extends PsiTestCase {
|
||||
final String extension = _extension == null ? fileType.getDefaultExtension():_extension;
|
||||
|
||||
File dir = createTempDirectory();
|
||||
final File tempFile = File.createTempFile("aaa", "." + extension, dir);
|
||||
final File tempFile = FileUtil.createTempFile(dir, "aaa", "." + extension, true);
|
||||
final FileTypeManager fileTypeManager = FileTypeManager.getInstance();
|
||||
if (fileTypeManager.getFileTypeByExtension(extension) != fileType) {
|
||||
new WriteCommandAction(getProject()) {
|
||||
|
||||
@@ -18,6 +18,7 @@ package com.intellij.idea;
|
||||
|
||||
import com.intellij.ide.Bootstrap;
|
||||
import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
|
||||
import javax.swing.*;
|
||||
@@ -90,7 +91,7 @@ public class Main {
|
||||
List<String> args = new ArrayList<String>();
|
||||
if (System.getProperty("os.name").toLowerCase().startsWith("windows")) {
|
||||
File launcherFile = new File(ideaHomeDir, "bin/vistalauncher.exe");
|
||||
File launcherCopy = File.createTempFile("vistalauncher", ".exe");
|
||||
File launcherCopy = FileUtil.createTempFile("vistalauncher", ".exe");
|
||||
launcherCopy.deleteOnExit();
|
||||
copyFile(launcherFile, launcherCopy);
|
||||
args.add(launcherCopy.getPath());
|
||||
|
||||
@@ -52,4 +52,8 @@ public interface RunnerAndConfigurationSettings {
|
||||
void setTemporary(boolean temporary);
|
||||
|
||||
Factory<RunnerAndConfigurationSettings> createFactory();
|
||||
|
||||
void setEditBeforeRun(boolean b);
|
||||
|
||||
boolean isEditBeforeRun();
|
||||
}
|
||||
|
||||
@@ -47,6 +47,10 @@ public abstract class FacetType<F extends Facet, C extends FacetConfiguration> {
|
||||
private final @NotNull String myPresentableName;
|
||||
private final @Nullable FacetTypeId myUnderlyingFacetType;
|
||||
|
||||
public static <T extends FacetType> T findInstance(Class<T> aClass) {
|
||||
return EP_NAME.findExtension(aClass);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param id unique instance of {@link FacetTypeId}
|
||||
* @param stringId unique string id of the facet type
|
||||
|
||||
@@ -48,7 +48,7 @@ public class ProgramRunnerUtil {
|
||||
}
|
||||
|
||||
public static void executeConfiguration(@NotNull final Project project, @NotNull final RunnerAndConfigurationSettings configuration,
|
||||
@NotNull final Executor executor) {
|
||||
@NotNull final Executor executor, final boolean showSettings) {
|
||||
ProgramRunner runner = getRunner(executor.getId(), configuration);
|
||||
if (runner == null) {
|
||||
LOG.error("Runner MUST not be null! Cannot find runner for " + executor.getId() + " and " + configuration.getConfiguration().getFactory().getName());
|
||||
@@ -58,7 +58,7 @@ public class ProgramRunnerUtil {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!RunManagerImpl.canRunConfiguration(configuration, executor)) {
|
||||
if (!RunManagerImpl.canRunConfiguration(configuration, executor) || (showSettings && RunManagerImpl.isEditBeforeRun(configuration))) {
|
||||
final boolean result = RunDialog.editConfiguration(project, configuration, "Edit configuration", executor.getActionName(), executor.getIcon());
|
||||
if (!result) {
|
||||
return;
|
||||
@@ -84,6 +84,11 @@ public class ProgramRunnerUtil {
|
||||
}
|
||||
}
|
||||
|
||||
public static void executeConfiguration(@NotNull final Project project, @NotNull final RunnerAndConfigurationSettings configuration,
|
||||
@NotNull final Executor executor) {
|
||||
executeConfiguration(project, configuration, executor, true);
|
||||
}
|
||||
|
||||
public static Icon getConfigurationIcon(final Project project, final RunnerAndConfigurationSettings settings, final boolean invalid) {
|
||||
final RunManager runManager = RunManager.getInstance(project);
|
||||
return getConfigurationIcon(settings, invalid, runManager.isTemporary(settings.getConfiguration()));
|
||||
|
||||
@@ -48,6 +48,8 @@ public abstract class RunManagerEx extends RunManager {
|
||||
|
||||
public abstract void setTemporaryConfiguration(RunnerAndConfigurationSettings tempConfiguration);
|
||||
|
||||
public abstract void setEditBeforeRun(RunConfiguration settings, boolean edit);
|
||||
|
||||
public abstract RunManagerConfig getConfig();
|
||||
|
||||
@NotNull
|
||||
|
||||
+1
-1
@@ -220,7 +220,7 @@ public class ChooseRunConfigurationAction extends AnAction {
|
||||
PropertiesComponent.getInstance().setValue("run.configuration.edit.ad", Boolean.toString(true));
|
||||
if (RunDialog.editConfiguration(project, configuration, "Edit configuration settings", executor.getActionName(), executor.getIcon())) {
|
||||
RunManagerEx.getInstanceEx(project).setSelectedConfiguration(configuration);
|
||||
ProgramRunnerUtil.executeConfiguration(project, configuration, executor);
|
||||
ProgramRunnerUtil.executeConfiguration(project, configuration, executor, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+22
-9
@@ -18,6 +18,7 @@ package com.intellij.execution.impl;
|
||||
|
||||
import com.intellij.execution.BeforeRunTask;
|
||||
import com.intellij.execution.BeforeRunTaskProvider;
|
||||
import com.intellij.execution.ExecutionBundle;
|
||||
import com.intellij.execution.RunnerAndConfigurationSettings;
|
||||
import com.intellij.execution.configurations.RunConfiguration;
|
||||
import com.intellij.execution.configurations.UnknownRunConfiguration;
|
||||
@@ -55,10 +56,12 @@ public class ConfigurationSettingsEditorWrapper extends SettingsEditor<RunnerAnd
|
||||
private JPanel myWholePanel;
|
||||
|
||||
private JPanel myStepsPanel;
|
||||
private JCheckBox myShowSettingsBeforeRunCheckBox;
|
||||
private Map<Key<? extends BeforeRunTask>, BeforeRunTask> myStepsBeforeLaunch;
|
||||
private final Map<Key<? extends BeforeRunTask>, StepBeforeLaunchRow> myStepBeforeLaunchRows = new THashMap<Key<? extends BeforeRunTask>, StepBeforeLaunchRow>();
|
||||
|
||||
private boolean myStoreProjectConfiguration;
|
||||
private boolean myEditBeforeRun;
|
||||
|
||||
private final ConfigurationSettingsEditor myEditor;
|
||||
|
||||
@@ -78,7 +81,7 @@ public class ConfigurationSettingsEditorWrapper extends SettingsEditor<RunnerAnd
|
||||
final BeforeRunTaskProvider<BeforeRunTask>[] providers = Extensions.getExtensions(BeforeRunTaskProvider.EXTENSION_POINT_NAME,
|
||||
runConfiguration.getProject());
|
||||
myStepsPanel.removeAll();
|
||||
if (providers.length == 0 || runConfiguration instanceof UnknownRunConfiguration) {
|
||||
if (runConfiguration instanceof UnknownRunConfiguration) {
|
||||
myStepsPanel.setVisible(false);
|
||||
}
|
||||
else {
|
||||
@@ -92,17 +95,25 @@ public class ConfigurationSettingsEditorWrapper extends SettingsEditor<RunnerAnd
|
||||
}
|
||||
}
|
||||
|
||||
if (!stepsRows.isEmpty()) {
|
||||
myStepsPanel.setLayout(new GridLayout(stepsRows.size(), 1));
|
||||
for (StepBeforeLaunchRow stepRow : stepsRows) {
|
||||
myStepsPanel.add(stepRow);
|
||||
}
|
||||
}
|
||||
else {
|
||||
myStepsPanel.setVisible(false);
|
||||
myStepsPanel.setLayout(new GridLayout(stepsRows.size(), 1));
|
||||
for (StepBeforeLaunchRow stepRow : stepsRows) {
|
||||
myStepsPanel.add(stepRow);
|
||||
}
|
||||
}
|
||||
|
||||
myEditBeforeRun = settings.isEditBeforeRun();
|
||||
myShowSettingsBeforeRunCheckBox = new JCheckBox(ExecutionBundle.message("configuration.edit.before.run"));
|
||||
myShowSettingsBeforeRunCheckBox.setEnabled(!(runConfiguration instanceof UnknownRunConfiguration));
|
||||
myShowSettingsBeforeRunCheckBox.setSelected(myEditBeforeRun);
|
||||
myShowSettingsBeforeRunCheckBox.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
myEditBeforeRun = myShowSettingsBeforeRunCheckBox.isSelected();
|
||||
}
|
||||
});
|
||||
myShowSettingsBeforeRunCheckBox.setVisible(!settings.isTemplate());
|
||||
myStepsPanel.add(myShowSettingsBeforeRunCheckBox);
|
||||
|
||||
myStoreProjectConfiguration = runManager.isConfigurationShared(settings);
|
||||
myCbStoreProjectConfiguration.setEnabled(!(runConfiguration instanceof UnknownRunConfiguration));
|
||||
myCbStoreProjectConfiguration.setSelected(myStoreProjectConfiguration);
|
||||
@@ -111,6 +122,7 @@ public class ConfigurationSettingsEditorWrapper extends SettingsEditor<RunnerAnd
|
||||
myStoreProjectConfiguration = myCbStoreProjectConfiguration.isSelected();
|
||||
}
|
||||
});
|
||||
|
||||
myCbStoreProjectConfiguration.setVisible(!settings.isTemplate());
|
||||
}
|
||||
|
||||
@@ -151,6 +163,7 @@ public class ConfigurationSettingsEditorWrapper extends SettingsEditor<RunnerAnd
|
||||
final RunManagerImpl runManager = RunManagerImpl.getInstanceImpl(runConfiguration.getProject());
|
||||
runManager.setBeforeRunTasks(runConfiguration, myStepsBeforeLaunch);
|
||||
runManager.shareConfiguration(runConfiguration, myStoreProjectConfiguration);
|
||||
runManager.setEditBeforeRun(runConfiguration, myEditBeforeRun);
|
||||
}
|
||||
|
||||
public Map<Key<? extends BeforeRunTask>, BeforeRunTask> getStepsBeforeLaunch() {
|
||||
|
||||
@@ -619,6 +619,15 @@ public class RunManagerImpl extends RunManagerEx implements JDOMExternalizable,
|
||||
setActiveConfiguration(tempConfiguration);
|
||||
}
|
||||
|
||||
public static boolean isEditBeforeRun(@NotNull final RunnerAndConfigurationSettings configuration) {
|
||||
return configuration.isEditBeforeRun();
|
||||
}
|
||||
|
||||
public void setEditBeforeRun(@NotNull final RunConfiguration configuration, final boolean edit) {
|
||||
final RunnerAndConfigurationSettings settings = getSettings(configuration);
|
||||
if (settings != null) settings.setEditBeforeRun(edit);
|
||||
}
|
||||
|
||||
public void setActiveConfiguration(final RunnerAndConfigurationSettings configuration) {
|
||||
setSelectedConfiguration(configuration);
|
||||
}
|
||||
|
||||
+17
-1
@@ -57,6 +57,9 @@ public class RunnerAndConfigurationSettingsImpl implements JDOMExternalizable, C
|
||||
protected static final String DUMMY_ELEMENT_NANE = "dummy";
|
||||
@NonNls
|
||||
private static final String TEMPORARY_ATTRIBUTE = "temporary";
|
||||
@NonNls
|
||||
private static final String EDIT_BEFORE_RUN = "editBeforeRun";
|
||||
|
||||
|
||||
/** for compatibility */
|
||||
@NonNls
|
||||
@@ -73,6 +76,7 @@ public class RunnerAndConfigurationSettingsImpl implements JDOMExternalizable, C
|
||||
private List<Element> myUnloadedConfigurationPerRunnerSettings = null;
|
||||
|
||||
private boolean myTemporary;
|
||||
private boolean myEditBeforeRun;
|
||||
|
||||
public RunnerAndConfigurationSettingsImpl(RunManagerImpl manager) {
|
||||
myManager = manager;
|
||||
@@ -122,6 +126,16 @@ public class RunnerAndConfigurationSettingsImpl implements JDOMExternalizable, C
|
||||
return myConfiguration.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setEditBeforeRun(boolean b) {
|
||||
myEditBeforeRun = b;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEditBeforeRun() {
|
||||
return myEditBeforeRun;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private ConfigurationFactory getFactory(final Element element) {
|
||||
final String typeName = element.getAttributeValue(CONFIGURATION_TYPE_ATTRIBUTE);
|
||||
@@ -130,9 +144,9 @@ public class RunnerAndConfigurationSettingsImpl implements JDOMExternalizable, C
|
||||
}
|
||||
|
||||
public void readExternal(Element element) throws InvalidDataException {
|
||||
|
||||
myIsTemplate = Boolean.valueOf(element.getAttributeValue(TEMPLATE_FLAG_ATTRIBUTE)).booleanValue();
|
||||
myTemporary = Boolean.valueOf(element.getAttributeValue(TEMPORARY_ATTRIBUTE)).booleanValue() || TEMP_CONFIGURATION.equals(element.getName());
|
||||
myEditBeforeRun = Boolean.valueOf(element.getAttributeValue(EDIT_BEFORE_RUN)).booleanValue();
|
||||
|
||||
final ConfigurationFactory factory = getFactory(element);
|
||||
if (factory == null) return;
|
||||
@@ -192,6 +206,8 @@ public class RunnerAndConfigurationSettingsImpl implements JDOMExternalizable, C
|
||||
}
|
||||
element.setAttribute(CONFIGURATION_TYPE_ATTRIBUTE, factory.getType().getId());
|
||||
element.setAttribute(FACTORY_NAME_ATTRIBUTE, factory.getName());
|
||||
|
||||
if (isEditBeforeRun()) element.setAttribute(EDIT_BEFORE_RUN, String.valueOf(true));
|
||||
if (myTemporary) {
|
||||
element.setAttribute(TEMPORARY_ATTRIBUTE, Boolean.toString(myTemporary));
|
||||
}
|
||||
|
||||
@@ -42,6 +42,10 @@ public abstract class RemoteProcessSupport<Target, EntryPoint, Parameters> {
|
||||
private final HashMap<Pair<Target, Parameters>, Object> myProcMap =
|
||||
new HashMap<Pair<Target, Parameters>, Object>();
|
||||
|
||||
static {
|
||||
RemoteServer.setupRMI();
|
||||
}
|
||||
|
||||
public RemoteProcessSupport(Class<EntryPoint> valueClass) {
|
||||
myValueClass = valueClass;
|
||||
}
|
||||
|
||||
@@ -34,6 +34,17 @@ public abstract class GotoActionBase extends AnAction {
|
||||
|
||||
protected static Class myInAction = null;
|
||||
|
||||
public static String getInitialText(Editor editor) {
|
||||
if (editor == null) {
|
||||
return "";
|
||||
}
|
||||
final String selectedText = editor.getSelectionModel().getSelectedText();
|
||||
if (selectedText != null && selectedText.indexOf("\n") < 0) {
|
||||
return selectedText;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
public final void actionPerformed(AnActionEvent e) {
|
||||
LOG.assertTrue (!getClass ().equals (myInAction));
|
||||
try {
|
||||
|
||||
@@ -47,7 +47,8 @@ public class GotoClassAction extends GotoActionBase implements DumbAware {
|
||||
PsiDocumentManager.getInstance(project).commitAllDocuments();
|
||||
|
||||
final GotoClassModel2 model = new GotoClassModel2(project);
|
||||
final ChooseByNamePopup popup = ChooseByNamePopup.createPopup(project, model, getPsiContext(e));
|
||||
final ChooseByNamePopup popup = ChooseByNamePopup.createPopup(project, model, getPsiContext(e),
|
||||
getInitialText(e.getData(PlatformDataKeys.EDITOR)));
|
||||
final ChooseByNameFilter filterUI = new ChooseByNameLanguageFilter(popup, model, GotoClassSymbolConfiguration.getInstance(project), project);
|
||||
|
||||
popup.invoke(new ChooseByNamePopupComponent.Callback() {
|
||||
|
||||
@@ -52,7 +52,8 @@ public class GotoFileAction extends GotoActionBase implements DumbAware {
|
||||
FeatureUsageTracker.getInstance().triggerFeatureUsed("navigation.popup.file");
|
||||
final Project project = e.getData(PlatformDataKeys.PROJECT);
|
||||
final GotoFileModel gotoFileModel = new GotoFileModel(project);
|
||||
final ChooseByNamePopup popup = ChooseByNamePopup.createPopup(project, gotoFileModel, getPsiContext(e));
|
||||
final ChooseByNamePopup popup = ChooseByNamePopup.createPopup(project, gotoFileModel, getPsiContext(e),
|
||||
getInitialText(e.getData(PlatformDataKeys.EDITOR)));
|
||||
final ChooseByNameFilter filterUI = new GotoFileFilter(popup, gotoFileModel, project);
|
||||
popup.invoke(new ChooseByNamePopupComponent.Callback() {
|
||||
public void onClose() {
|
||||
|
||||
@@ -36,7 +36,8 @@ public class GotoSymbolAction extends GotoActionBase {
|
||||
PsiDocumentManager.getInstance(project).commitAllDocuments();
|
||||
|
||||
final GotoSymbolModel2 model = new GotoSymbolModel2(project);
|
||||
final ChooseByNamePopup popup = ChooseByNamePopup.createPopup(project, model, getPsiContext(e));
|
||||
final ChooseByNamePopup popup = ChooseByNamePopup.createPopup(project, model, getPsiContext(e),
|
||||
getInitialText(e.getData(PlatformDataKeys.EDITOR)));
|
||||
final ChooseByNameFilter filterUI = new ChooseByNameLanguageFilter(popup, model, GotoClassSymbolConfiguration.getInstance(project),
|
||||
project);
|
||||
popup.invoke(new ChooseByNamePopupComponent.Callback() {
|
||||
|
||||
+7
-1
@@ -25,10 +25,11 @@ import com.intellij.openapi.roots.ui.configuration.ProjectSettingsService;
|
||||
import com.intellij.openapi.vfs.JarFileSystem;
|
||||
import com.intellij.openapi.vfs.VfsUtil;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.pom.NavigatableWithText;
|
||||
import com.intellij.ui.SimpleTextAttributes;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public abstract class AbstractModuleNode extends ProjectViewNode<Module> {
|
||||
public abstract class AbstractModuleNode extends ProjectViewNode<Module> implements NavigatableWithText {
|
||||
protected AbstractModuleNode(Project project, Module module, ViewSettings viewSettings) {
|
||||
super(project, module, viewSettings);
|
||||
}
|
||||
@@ -84,6 +85,11 @@ public abstract class AbstractModuleNode extends ProjectViewNode<Module> {
|
||||
ProjectSettingsService.getInstance(myProject).openModuleSettings(getValue());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNavigateActionText(boolean focusEditor) {
|
||||
return "Open Module Settings";
|
||||
}
|
||||
|
||||
public boolean canNavigate() {
|
||||
return true;
|
||||
}
|
||||
|
||||
+7
-1
@@ -33,6 +33,7 @@ import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.VfsUtil;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.pom.NavigatableWithText;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.*;
|
||||
@@ -40,7 +41,7 @@ import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
public class NamedLibraryElementNode extends ProjectViewNode<NamedLibraryElement>{
|
||||
public class NamedLibraryElementNode extends ProjectViewNode<NamedLibraryElement> implements NavigatableWithText {
|
||||
private static final Icon GENERIC_JDK_ICON = IconLoader.getIcon("/general/jdk.png");
|
||||
private static final Icon LIB_ICON_OPEN = IconLoader.getIcon("/nodes/ppLibOpen.png");
|
||||
private static final Icon LIB_ICON_CLOSED = IconLoader.getIcon("/nodes/ppLibClosed.png");
|
||||
@@ -123,4 +124,9 @@ public class NamedLibraryElementNode extends ProjectViewNode<NamedLibraryElement
|
||||
public boolean canNavigate() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNavigateActionText(boolean focusEditor) {
|
||||
return "Open Library Settings";
|
||||
}
|
||||
}
|
||||
|
||||
+26
-2
@@ -35,6 +35,7 @@ import com.intellij.openapi.util.Iconable;
|
||||
import com.intellij.openapi.vfs.LocalFileSystem;
|
||||
import com.intellij.openapi.vfs.VfsUtil;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.pom.NavigatableWithText;
|
||||
import com.intellij.psi.PsiDirectory;
|
||||
import com.intellij.psi.impl.file.PsiDirectoryFactory;
|
||||
import com.intellij.ui.LayeredIcon;
|
||||
@@ -47,7 +48,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
import javax.swing.*;
|
||||
import java.util.Collection;
|
||||
|
||||
public class PsiDirectoryNode extends BasePsiNode<PsiDirectory> {
|
||||
public class PsiDirectoryNode extends BasePsiNode<PsiDirectory> implements NavigatableWithText {
|
||||
public PsiDirectoryNode(Project project, PsiDirectory value, ViewSettings viewSettings) {
|
||||
super(project, value, viewSettings);
|
||||
}
|
||||
@@ -190,15 +191,38 @@ public class PsiDirectoryNode extends BasePsiNode<PsiDirectory> {
|
||||
public void navigate(final boolean requestFocus) {
|
||||
Module module = ModuleUtil.findModuleForPsiElement(getValue());
|
||||
if (module != null) {
|
||||
if (ProjectRootsUtil.isModuleContentRoot(getVirtualFile(), getProject())) {
|
||||
final VirtualFile file = getVirtualFile();
|
||||
final Project project = getProject();
|
||||
if (ProjectRootsUtil.isModuleContentRoot(file, project)) {
|
||||
ProjectSettingsService.getInstance(myProject).openModuleSettings(module);
|
||||
}
|
||||
else if (ProjectRootsUtil.isLibraryRoot(file, project)) {
|
||||
ProjectSettingsService.getInstance(myProject).openModuleLibrarySettings(module);
|
||||
}
|
||||
else {
|
||||
ProjectSettingsService.getInstance(myProject).openContentEntriesSettings(module);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNavigateActionText(boolean focusEditor) {
|
||||
VirtualFile file = getVirtualFile();
|
||||
Project project = getProject();
|
||||
|
||||
if (file != null) {
|
||||
if (ProjectRootsUtil.isModuleContentRoot(file, project) ||
|
||||
ProjectRootsUtil.isSourceOrTestRoot(file, project)) {
|
||||
return "Open Module Settings";
|
||||
}
|
||||
if (ProjectRootsUtil.isLibraryRoot(file, project)) {
|
||||
return "Open Library Settings";
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public int getWeight() {
|
||||
return isFQNameShown() ? 70 : 0;
|
||||
}
|
||||
|
||||
+1
-1
@@ -76,7 +76,7 @@ public abstract class LangScriptingContextConfigurable implements Configurable,
|
||||
|
||||
@Override
|
||||
public void reset() {
|
||||
myLibManager.dropChanges();
|
||||
myLibManager.reset();
|
||||
myPanel.resetTable();
|
||||
}
|
||||
|
||||
|
||||
+3
-2
@@ -16,10 +16,9 @@
|
||||
package com.intellij.ide.scriptingContext;
|
||||
|
||||
import com.intellij.lang.Language;
|
||||
import com.intellij.openapi.extensions.ExtensionPointName;
|
||||
import com.intellij.openapi.extensions.Extensions;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.roots.libraries.LibraryType;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
@@ -36,4 +35,6 @@ public abstract class LangScriptingContextProvider {
|
||||
|
||||
public abstract ScriptingLibraryMappings getLibraryMappings(Project project);
|
||||
|
||||
public abstract boolean isCompact(VirtualFile file);
|
||||
|
||||
}
|
||||
|
||||
@@ -75,6 +75,7 @@ public class ScriptingLibraryMappings extends LanguagePerFileMappings<ScriptingL
|
||||
|
||||
@Override
|
||||
public Collection<ScriptingLibraryTable.LibraryModel> getAvailableValues(VirtualFile file) {
|
||||
myLibraryManager.reset();
|
||||
List<ScriptingLibraryTable.LibraryModel> libraries = getSingleLibraries();
|
||||
if (myCompoundLibMap.containsKey(file)) {
|
||||
libraries.add(myCompoundLibMap.get(file));
|
||||
|
||||
+18
-10
@@ -3,7 +3,7 @@
|
||||
<grid id="cbd77" binding="contentPane" layout-manager="GridLayoutManager" row-count="2" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="10" left="10" bottom="10" right="10"/>
|
||||
<constraints>
|
||||
<xy x="48" y="54" width="741" height="297"/>
|
||||
<xy x="48" y="54" width="775" height="297"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
@@ -47,7 +47,7 @@
|
||||
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="Add..."/>
|
||||
<text value="Attach..."/>
|
||||
</properties>
|
||||
</component>
|
||||
<scrollpane id="2fb19" class="com.intellij.ui.components.JBScrollPane">
|
||||
@@ -70,19 +70,27 @@
|
||||
</component>
|
||||
</children>
|
||||
</scrollpane>
|
||||
<component id="1dade" class="javax.swing.JButton" binding="myRemoveFileButton">
|
||||
<constraints>
|
||||
<grid row="1" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="Remove"/>
|
||||
</properties>
|
||||
</component>
|
||||
<vspacer id="36d74">
|
||||
<constraints>
|
||||
<grid row="3" column="1" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
</vspacer>
|
||||
<component id="1dade" class="javax.swing.JButton" binding="myRemoveFileButton">
|
||||
<constraints>
|
||||
<grid row="2" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="Detach"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="ec28f" class="javax.swing.JButton" binding="myAttachFromButton">
|
||||
<constraints>
|
||||
<grid row="1" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="Attach From..."/>
|
||||
</properties>
|
||||
</component>
|
||||
</children>
|
||||
</grid>
|
||||
</children>
|
||||
|
||||
@@ -50,6 +50,7 @@ public class EditLibraryDialog extends DialogWrapper {
|
||||
private JButton myAddFileButton;
|
||||
private JButton myRemoveFileButton;
|
||||
private JBTable myFileTable;
|
||||
private JButton myAttachFromButton;
|
||||
private Project myProject;
|
||||
private FileTableModel myFileTableModel;
|
||||
private VirtualFile mySelectedFile;
|
||||
@@ -65,6 +66,14 @@ public class EditLibraryDialog extends DialogWrapper {
|
||||
addFiles();
|
||||
}
|
||||
});
|
||||
|
||||
myAttachFromButton.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
attachFromDirectory();
|
||||
}
|
||||
});
|
||||
|
||||
myFileTableModel = new FileTableModel();
|
||||
myFileTable.setModel(myFileTableModel);
|
||||
|
||||
@@ -135,14 +144,31 @@ public class EditLibraryDialog extends DialogWrapper {
|
||||
FileChooserDescriptor chooserDescriptor = new LibFileChooserDescriptor();
|
||||
VirtualFile[] files = FileChooser.chooseFiles(myProject, chooserDescriptor);
|
||||
if (files.length == 1 && files[0] != null) {
|
||||
myFileTableModel.addFile(files[0], false);
|
||||
myFileTableModel.addFile(files[0]);
|
||||
}
|
||||
}
|
||||
|
||||
private void attachFromDirectory() {
|
||||
FileChooserDescriptor chooserDescriptor = new FileChooserDescriptor(false, true, false, false, false, false);
|
||||
chooserDescriptor.setTitle("Select a directory to attach files from"); //TODO<rv> Move to resources
|
||||
VirtualFile[] files = FileChooser.chooseFiles(myProject, chooserDescriptor);
|
||||
if (files.length == 1 && files[0] != null) {
|
||||
VirtualFile chosenDir = files[0];
|
||||
if (chosenDir.isDirectory() && chosenDir.isValid()) {
|
||||
if (myLibName.getText().isEmpty()) myLibName.setText(chosenDir.getName());
|
||||
for (VirtualFile file : chosenDir.getChildren()) {
|
||||
if (file.isValid() && !file.isDirectory() && myProvider.acceptsExtension(file.getExtension())) {
|
||||
myFileTableModel.addFile(file);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class LibFileChooserDescriptor extends FileChooserDescriptor {
|
||||
public LibFileChooserDescriptor() {
|
||||
super (true, false, false, true, false, false);
|
||||
setTitle("Select library file");
|
||||
setTitle("Select library file"); //TODO<rv> Move to resources
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -158,14 +184,14 @@ public class EditLibraryDialog extends DialogWrapper {
|
||||
}
|
||||
}
|
||||
|
||||
private static class FileTableModel extends AbstractTableModel {
|
||||
private class FileTableModel extends AbstractTableModel {
|
||||
|
||||
@Override
|
||||
public String getColumnName(int column) {
|
||||
switch(column) {
|
||||
case FILE_LOCATION_COL:
|
||||
return "Location";
|
||||
case FILE_TYPE_COL:
|
||||
return "Location"; //TODO<rv> Move to resources
|
||||
case FILE_TYPE_COL: //TODO<rv> Move to resources
|
||||
return "Type";
|
||||
}
|
||||
return "";
|
||||
@@ -182,9 +208,9 @@ public class EditLibraryDialog extends DialogWrapper {
|
||||
private ArrayList<VirtualFile> myFiles = new ArrayList<VirtualFile>();
|
||||
private HashSet<VirtualFile> myCompactFiles = new HashSet<VirtualFile>();
|
||||
|
||||
public void addFile(VirtualFile file, boolean isCompact) {
|
||||
public void addFile(VirtualFile file) {
|
||||
myFiles.add(file);
|
||||
if (isCompact) {
|
||||
if (myProvider.isCompact(file)) {
|
||||
myCompactFiles.add(file);
|
||||
}
|
||||
fireTableDataChanged();
|
||||
@@ -286,7 +312,7 @@ public class EditLibraryDialog extends DialogWrapper {
|
||||
@Override
|
||||
protected void doOKAction() {
|
||||
if (!isLibNameValid(myLibName.getText())) {
|
||||
Messages.showErrorDialog(myProject, "Invalid library name", "Error");
|
||||
Messages.showErrorDialog(myProject, "Invalid library name", "Error"); //TODO<rv> Move to resources
|
||||
return;
|
||||
}
|
||||
super.doOKAction();
|
||||
|
||||
@@ -300,7 +300,9 @@ public class MemberChooser<T extends ClassMember> extends DialogWrapper implemen
|
||||
final TreeSpeedSearch treeSpeedSearch = new TreeSpeedSearch(myTree, new Convertor<TreePath, String>() {
|
||||
@Nullable
|
||||
public String convert(TreePath path) {
|
||||
final MemberChooserObject delegate = ((ElementNode)path.getLastPathComponent()).getDelegate();
|
||||
final ElementNode lastPathComponent = (ElementNode)path.getLastPathComponent();
|
||||
if (lastPathComponent == null) return null;
|
||||
final MemberChooserObject delegate = lastPathComponent.getDelegate();
|
||||
return delegate.getText();
|
||||
}
|
||||
});
|
||||
|
||||
+1
-1
@@ -110,7 +110,7 @@ public class ScriptingLibraryManager {
|
||||
}
|
||||
}
|
||||
|
||||
public void dropChanges() {
|
||||
public void reset() {
|
||||
myLibTable = null;
|
||||
}
|
||||
|
||||
|
||||
@@ -44,8 +44,7 @@ public class PsiCachedValuesFactory implements CachedValuesFactory {
|
||||
protected Object[] getDependencies(CachedValueProvider.Result<T> result) {
|
||||
return getDependenciesPlusValue(result);
|
||||
}
|
||||
} : new PsiCachedValueImpl<T>(myManager, provider) {
|
||||
};
|
||||
} : new PsiCachedValueImpl<T>(myManager, provider);
|
||||
}
|
||||
|
||||
public <T, P> ParameterizedCachedValue<T, P> createParameterizedCachedValue(@NotNull ParameterizedCachedValueProvider<T, P> provider,
|
||||
|
||||
+9
-28
@@ -154,7 +154,8 @@ public class CodeStyleManagerImpl extends CodeStyleManager {
|
||||
// }
|
||||
// Formatter removes such white spaces, i.e. keeps only line feed symbol. But we want to preserve caret position then.
|
||||
// So, we check if it should be preserved and restore it after formatting if necessary
|
||||
boolean fixCaretPosition = false;
|
||||
int visualColumnToRestore = -1;
|
||||
|
||||
if (editor != null) {
|
||||
Document document = editor.getDocument();
|
||||
int caretOffset = editor.getCaretModel().getOffset();
|
||||
@@ -162,7 +163,7 @@ public class CodeStyleManagerImpl extends CodeStyleManager {
|
||||
CharSequence text = document.getCharsSequence();
|
||||
int caretLine = document.getLineNumber(caretOffset);
|
||||
int lineStartOffset = document.getLineStartOffset(caretLine);
|
||||
fixCaretPosition = true;
|
||||
boolean fixCaretPosition = true;
|
||||
for (int i = caretOffset; i>= lineStartOffset; i--) {
|
||||
char c = text.charAt(i);
|
||||
if (c != ' ' && c != '\t' && c != '\n') {
|
||||
@@ -170,6 +171,9 @@ public class CodeStyleManagerImpl extends CodeStyleManager {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (fixCaretPosition) {
|
||||
visualColumnToRestore = editor.getCaretModel().getVisualPosition().column;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -190,38 +194,15 @@ public class CodeStyleManagerImpl extends CodeStyleManager {
|
||||
formatToEnd ? file.getTextLength() : endElement.getTextRange().getEndOffset()));
|
||||
}
|
||||
|
||||
if (!fixCaretPosition) {
|
||||
if (visualColumnToRestore < 0) {
|
||||
return;
|
||||
}
|
||||
CaretModel caretModel = editor.getCaretModel();
|
||||
String indent = getLineIndent(file, caretModel.getOffset());
|
||||
if (indent == null) {
|
||||
return;
|
||||
}
|
||||
int tabSize = getSettings().getTabSize(file.getFileType());
|
||||
int indentColumn = indentInVisualColumns(indent, tabSize);
|
||||
VisualPosition position = caretModel.getVisualPosition();
|
||||
if (indentColumn != position.column) {
|
||||
caretModel.moveToVisualPosition(new VisualPosition(position.line, indentColumn));
|
||||
if (visualColumnToRestore != position.column) {
|
||||
caretModel.moveToVisualPosition(new VisualPosition(position.line, visualColumnToRestore));
|
||||
}
|
||||
}
|
||||
|
||||
private static int indentInVisualColumns(String indent, int tabSize) {
|
||||
if (tabSize <= 1) {
|
||||
return indent.length();
|
||||
}
|
||||
int result = 0;
|
||||
for (int i = 0; i < indent.length(); i++) {
|
||||
char c = indent.charAt(i);
|
||||
if (c == '\t') {
|
||||
result += tabSize - result % tabSize;
|
||||
}
|
||||
else {
|
||||
result++;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private PsiElement reformatRangeImpl(final PsiElement element,
|
||||
final int startOffset,
|
||||
|
||||
@@ -387,13 +387,7 @@ public class StubIndexImpl extends StubIndex implements ApplicationComponent, Pe
|
||||
|
||||
public void flush(StubIndexKey key) throws StorageException {
|
||||
final MyIndex<?> index = myIndices.get(key);
|
||||
index.getReadLock().lock();
|
||||
try {
|
||||
index.flush();
|
||||
}
|
||||
finally {
|
||||
index.getReadLock().unlock();
|
||||
}
|
||||
index.flush();
|
||||
}
|
||||
|
||||
public <K> void updateIndex(StubIndexKey key, int fileId, final Map<K, TIntArrayList> oldValues, Map<K, TIntArrayList> newValues) {
|
||||
|
||||
@@ -27,6 +27,7 @@ import com.intellij.openapi.util.Ref;
|
||||
import com.intellij.util.Alarm;
|
||||
import com.intellij.util.Function;
|
||||
import com.intellij.util.ui.EmptyIcon;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.plaf.TreeUI;
|
||||
@@ -47,7 +48,7 @@ public class DeferredIconImpl<T> implements DeferredIcon {
|
||||
private boolean myNeedReadAction;
|
||||
private boolean myDone;
|
||||
|
||||
private Disposer<T> myDisposer;
|
||||
private IconDisposer<T> myDisposer;
|
||||
|
||||
public DeferredIconImpl(Icon baseIcon, T param, Function<T, Icon> evaluator) {
|
||||
this(baseIcon, param, true, evaluator);
|
||||
@@ -139,7 +140,7 @@ public class DeferredIconImpl<T> implements DeferredIcon {
|
||||
final TreeUI ui = ((JTree)actualTarget).getUI();
|
||||
if (ui instanceof BasicTreeUI) {
|
||||
// this call is "fake" and only need to reset tree layout cache
|
||||
((BasicTreeUI)ui).setLeftChildIndent(((Integer)UIManager.get("Tree.leftChildIndent")).intValue());
|
||||
((BasicTreeUI)ui).setLeftChildIndent(UIUtil.getTreeLeftChildIndent());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -276,12 +277,12 @@ public class DeferredIconImpl<T> implements DeferredIcon {
|
||||
}
|
||||
|
||||
|
||||
public DeferredIconImpl setDisposer(Disposer<T> disposer) {
|
||||
public DeferredIconImpl setDisposer(IconDisposer<T> disposer) {
|
||||
myDisposer = disposer;
|
||||
return this;
|
||||
}
|
||||
|
||||
public interface Disposer<T> {
|
||||
public interface IconDisposer<T> {
|
||||
|
||||
void dispose(T key);
|
||||
|
||||
|
||||
@@ -19,22 +19,18 @@
|
||||
*/
|
||||
package com.intellij.ui;
|
||||
|
||||
import com.intellij.ProjectTopics;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.project.impl.ProjectLifecycleListener;
|
||||
import com.intellij.openapi.vfs.VirtualFileManager;
|
||||
import com.intellij.openapi.vfs.newvfs.BulkFileListener;
|
||||
import com.intellij.openapi.vfs.newvfs.events.VFileEvent;
|
||||
import com.intellij.psi.util.PsiModificationTracker;
|
||||
import com.intellij.util.Function;
|
||||
import com.intellij.util.messages.MessageBus;
|
||||
import com.intellij.util.messages.MessageBusConnection;
|
||||
import com.intellij.util.messages.MessageHandler;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -75,7 +71,7 @@ public class IconDeferrerImpl extends IconDeferrer {
|
||||
synchronized (LOCK) {
|
||||
Icon result = myIconsCache.get(param);
|
||||
if (result == null) {
|
||||
result = new DeferredIconImpl<T>(base, param, f).setDisposer(new DeferredIconImpl.Disposer<T>() {
|
||||
result = new DeferredIconImpl<T>(base, param, f).setDisposer(new DeferredIconImpl.IconDisposer<T>() {
|
||||
@Override
|
||||
public void dispose(T key) {
|
||||
synchronized (LOCK) {
|
||||
|
||||
@@ -19,6 +19,7 @@ package com.intellij.ui.tabs;
|
||||
import com.intellij.ui.FileColorManager;
|
||||
import com.intellij.util.ui.EmptyIcon;
|
||||
import com.intellij.openapi.ui.StripeTable;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.*;
|
||||
@@ -243,7 +244,7 @@ public abstract class FileColorSettingsTable extends StripeTable {
|
||||
setBackground(isSelected ? table.getSelectionBackground() : table.getBackground());
|
||||
setForeground(isSelected ? table.getSelectionForeground() : table.getForeground());
|
||||
|
||||
setBorder(hasFocus ? (UIManager.getBorder("Table.focusCellHighlightBorder"))
|
||||
setBorder(hasFocus ? UIUtil.getTableFocusCellHighlightBorder()
|
||||
: NO_FOCUS_BORDER);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -126,7 +126,7 @@ public class BrowserUtil {
|
||||
private static String redirectUrl(String url, @NonNls String urlString) throws IOException {
|
||||
if (url.indexOf('&') == -1 && (!urlString.startsWith("file:") || urlString.indexOf("#") == -1)) return urlString;
|
||||
|
||||
File redirect = File.createTempFile("redirect", ".html");
|
||||
File redirect = FileUtil.createTempFile("redirect", ".html");
|
||||
redirect.deleteOnExit();
|
||||
FileWriter writer = new FileWriter(redirect);
|
||||
writer.write("<html><head></head><body><script type=\"text/javascript\">window.location=\"" + url + "\";</script></body></html>");
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package com.intellij.openapi.ui;
|
||||
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
@@ -28,7 +29,7 @@ public class DescriptionLabel extends JLabel {
|
||||
@Override
|
||||
public void updateUI() {
|
||||
super.updateUI();
|
||||
setForeground(UIManager.getColor("Panel.background").darker());
|
||||
setForeground(UIUtil.getPanelBackground().darker());
|
||||
int size = getFont().getSize();
|
||||
if (size >= 12) {
|
||||
size -= 2;
|
||||
|
||||
@@ -308,7 +308,7 @@ public class FixedComboBoxEditor implements ComboBoxEditor {
|
||||
g.setColor(bottomColor);
|
||||
g.drawLine(x + 4, y + height - 4, x + width - 2, y + height - 4);
|
||||
|
||||
g.setColor(UIManager.getColor("Panel.background"));
|
||||
g.setColor(UIUtil.getPanelBackground());
|
||||
|
||||
g.fillRect(x, y, width, 3);
|
||||
g.fillRect(x, y, 3, height);
|
||||
|
||||
@@ -173,7 +173,7 @@ public class LoadingDecorator {
|
||||
final Graphics2D g = mySnapshot.createGraphics();
|
||||
myPane.paint(g);
|
||||
final Component opaque = UIUtil.findNearestOpaque(this);
|
||||
mySnapshotBg = opaque != null ? opaque.getBackground() : UIUtil.getPanelBackgound();
|
||||
mySnapshotBg = opaque != null ? opaque.getBackground() : UIUtil.getPanelBackground();
|
||||
g.dispose();
|
||||
}
|
||||
myProgress.resume();
|
||||
|
||||
@@ -34,7 +34,7 @@ import java.util.Enumeration;
|
||||
* User: spLeaner
|
||||
*/
|
||||
public class TreeComboBox extends JComboBox {
|
||||
final static int INDENT = UIManager.getInt("Tree.leftChildIndent");
|
||||
final static int INDENT = UIUtil.getTreeLeftChildIndent();
|
||||
private TreeModel myTreeModel;
|
||||
|
||||
public TreeComboBox(@NotNull final TreeModel model) {
|
||||
|
||||
@@ -91,7 +91,7 @@ public interface StatusBarWidget extends Disposable {
|
||||
private static final Color PIXEL = LEFT1_FROM_INACTIVE;
|
||||
private static final Color LEFT1_TO_INACTIVE = new Color(180, 180, 180);
|
||||
|
||||
private static final Color SEPARATOR_COLOR = UIUtil.getPanelBackgound().darker();
|
||||
private static final Color SEPARATOR_COLOR = UIUtil.getPanelBackground().darker();
|
||||
|
||||
public void paintBorder(final Component c, final Graphics g, final int x, final int y, final int width, final int height) {
|
||||
final Graphics2D g2 = (Graphics2D)g.create();
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* Copyright 2000-2010 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.pom;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* @author yole
|
||||
*/
|
||||
public interface NavigatableWithText extends Navigatable {
|
||||
@Nullable
|
||||
String getNavigateActionText(boolean focusEditor);
|
||||
}
|
||||
@@ -15,18 +15,16 @@
|
||||
*/
|
||||
package com.intellij.ui;
|
||||
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.border.Border;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
|
||||
public class ColorPanel extends JPanel {
|
||||
public static final Color[] fixedColors;
|
||||
public static final Color DARK_MAGENTA = new Color(128, 0, 128);
|
||||
@@ -35,7 +33,7 @@ public class ColorPanel extends JPanel {
|
||||
public static final Color BLUE_GREEN = new Color(0, 128, 128);
|
||||
public static final Color DARK_YELLOW = new Color(128, 128, 0);
|
||||
public static final Color DARK_RED = new Color(128, 0, 0);
|
||||
public static final Color DISABLED_COLOR = UIUtil.getPanelBackgound();
|
||||
public static final Color DISABLED_COLOR = UIUtil.getPanelBackground();
|
||||
private static Color[] myCustomColors;
|
||||
@NonNls private String myActionCommand = "colorPanelChanged";
|
||||
private boolean isFiringEvent = false;
|
||||
|
||||
@@ -318,12 +318,12 @@ public class GuiUtils {
|
||||
if (component instanceof JPanel) {
|
||||
final Border border = ((JPanel)component).getBorder();
|
||||
if (border instanceof TitledBorder) {
|
||||
Color color = enabled ? component.getForeground() : UIUtil.getTextInactiveTextColor();
|
||||
Color color = enabled ? component.getForeground() : UIUtil.getInactiveTextColor();
|
||||
((TitledBorder)border).setTitleColor(color);
|
||||
}
|
||||
}
|
||||
else if (component instanceof JLabel) {
|
||||
Color color = UIUtil.getTextInactiveTextColor();
|
||||
Color color = UIUtil.getInactiveTextColor();
|
||||
if (color == null) color = component.getForeground();
|
||||
@NonNls String changeColorString = "<font color=#" + colorToHex(color) +">";
|
||||
final JLabel label = (JLabel)component;
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package com.intellij.ui;
|
||||
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
|
||||
import javax.swing.*;
|
||||
@@ -30,8 +31,7 @@ public class SeparatorWithText extends JComponent {
|
||||
|
||||
public SeparatorWithText() {
|
||||
setBorder(BorderFactory.createEmptyBorder(VGAP, 0, VGAP, 0));
|
||||
@NonNls final String labelFont = "Label.font";
|
||||
setFont(UIManager.getFont(labelFont));
|
||||
setFont(UIUtil.getLabelFont());
|
||||
setFont(getFont().deriveFont(Font.BOLD));
|
||||
}
|
||||
|
||||
|
||||
@@ -278,7 +278,7 @@ public class SimpleColoredComponent extends JComponent implements Accessible {
|
||||
|
||||
Font font = getFont();
|
||||
if (font == null) {
|
||||
font = UIManager.getFont("Label.font");
|
||||
font = UIUtil.getLabelFont();
|
||||
}
|
||||
|
||||
LOG.assertTrue(font != null);
|
||||
@@ -429,7 +429,7 @@ public class SimpleColoredComponent extends JComponent implements Accessible {
|
||||
color = getForeground();
|
||||
}
|
||||
if (!isEnabled()) {
|
||||
color = UIUtil.getTextInactiveTextColor();
|
||||
color = UIUtil.getInactiveTextColor();
|
||||
}
|
||||
g.setColor(color);
|
||||
|
||||
|
||||
@@ -45,8 +45,8 @@ public final class SimpleTextAttributes {
|
||||
public static final SimpleTextAttributes REGULAR_ITALIC_ATTRIBUTES = new SimpleTextAttributes(STYLE_ITALIC, null);
|
||||
public static final SimpleTextAttributes ERROR_ATTRIBUTES = new SimpleTextAttributes(STYLE_PLAIN, Color.red);
|
||||
|
||||
public static final SimpleTextAttributes GRAYED_ATTRIBUTES = new SimpleTextAttributes(STYLE_PLAIN, UIUtil.getTextInactiveTextColor());
|
||||
public static final SimpleTextAttributes GRAYED_BOLD_ATTRIBUTES = new SimpleTextAttributes(STYLE_BOLD, UIUtil.getTextInactiveTextColor());
|
||||
public static final SimpleTextAttributes GRAYED_ATTRIBUTES = new SimpleTextAttributes(STYLE_PLAIN, UIUtil.getInactiveTextColor());
|
||||
public static final SimpleTextAttributes GRAYED_BOLD_ATTRIBUTES = new SimpleTextAttributes(STYLE_BOLD, UIUtil.getInactiveTextColor());
|
||||
|
||||
public static final SimpleTextAttributes SYNTHETIC_ATTRIBUTES = new SimpleTextAttributes(STYLE_PLAIN, Color.BLUE);
|
||||
public static final SimpleTextAttributes GRAY_ATTRIBUTES = new SimpleTextAttributes(STYLE_PLAIN, Color.GRAY);
|
||||
|
||||
@@ -62,7 +62,7 @@ public class UI {
|
||||
ourColors.put("tooltip.error", Color.red);
|
||||
ourColors.put("tooltip.warning", Color.yellow.darker());
|
||||
|
||||
ourColors.put("toolbar.background", UIUtil.getPanelBackgound());
|
||||
ourColors.put("toolbar.background", UIUtil.getPanelBackground());
|
||||
ourColors.put("toolbar.hover.background", UIUtil.getTreeSelectionBackground());
|
||||
ourColors.put("toolbar.selected.background", getColor("panel.custom.background"));
|
||||
ourColors.put("toolbar.hover.frame.foreground", UIUtil.getTreeSelectionBackground().darker());
|
||||
|
||||
+3
-1
@@ -15,6 +15,8 @@
|
||||
*/
|
||||
package com.intellij.ui.components.panels;
|
||||
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
|
||||
@@ -24,7 +26,7 @@ import java.awt.*;
|
||||
* A label with possible error text is placed under validated component.
|
||||
*/
|
||||
public abstract class ValidatingComponent<T extends JComponent> extends NonOpaquePanel {
|
||||
private static final Font ERROR_FONT = UIManager.getFont("Label.font").deriveFont(Font.PLAIN, 10f);
|
||||
private static final Font ERROR_FONT = UIUtil.getLabelFont().deriveFont(Font.PLAIN, 10f);
|
||||
|
||||
private JLabel myErrorLabel;
|
||||
private T myMainComponent;
|
||||
|
||||
@@ -1502,8 +1502,8 @@ public class JBTabsImpl extends JComponent
|
||||
if (isPaintFocus()) {
|
||||
if (bgColor == null) {
|
||||
alpha = 150;
|
||||
shapeInfo.from = UIUtil.toAlpha(UIUtil.getPanelBackgound().brighter(), alpha);
|
||||
shapeInfo.to = UIUtil.toAlpha(UIUtil.getPanelBackgound(), alpha);
|
||||
shapeInfo.from = UIUtil.toAlpha(UIUtil.getPanelBackground().brighter(), alpha);
|
||||
shapeInfo.to = UIUtil.toAlpha(UIUtil.getPanelBackground(), alpha);
|
||||
}
|
||||
else {
|
||||
alpha = 255;
|
||||
|
||||
@@ -25,6 +25,7 @@ import com.intellij.openapi.application.ModalityState;
|
||||
import com.intellij.openapi.util.SystemInfo;
|
||||
import com.intellij.ui.TreeUIHelper;
|
||||
import com.intellij.util.ui.EmptyIcon;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import com.intellij.util.ui.tree.TreeUtil;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -95,7 +96,7 @@ public class SimpleTree extends Tree implements CellEditorListener {
|
||||
}
|
||||
});
|
||||
|
||||
putClientProperty("JTree.lineStyle", "Angled");
|
||||
UIUtil.setLineStyleAngled(this);
|
||||
if (SystemInfo.isWindowsXP) {
|
||||
setUI(new BasicTreeUI()); // In WindowsXP UI handles are not shown :(
|
||||
}
|
||||
@@ -584,7 +585,7 @@ public class SimpleTree extends Tree implements CellEditorListener {
|
||||
|
||||
public Icon getExpandedHandle() {
|
||||
if (myExpandedHandle == null) {
|
||||
myExpandedHandle = UIManager.getIcon("Tree.expandedIcon");
|
||||
myExpandedHandle = UIUtil.getTreeExpandedIcon();
|
||||
}
|
||||
|
||||
return myExpandedHandle;
|
||||
@@ -592,7 +593,7 @@ public class SimpleTree extends Tree implements CellEditorListener {
|
||||
|
||||
public Icon getCollapsedHandle() {
|
||||
if (myCollapsedHandle == null) {
|
||||
myCollapsedHandle = UIManager.getIcon("Tree.collapsedIcon");
|
||||
myCollapsedHandle = UIUtil.getTreeCollapsedIcon();
|
||||
}
|
||||
|
||||
return myCollapsedHandle;
|
||||
|
||||
@@ -156,7 +156,7 @@ public abstract class AnimatedIcon extends JComponent implements Disposable {
|
||||
if (parent instanceof JComponent) {
|
||||
opaque = (JComponent)UIUtil.findNearestOpaque((JComponent)parent);
|
||||
}
|
||||
Color bg = opaque != null ? opaque.getBackground() : UIManager.getColor("Panel.background");
|
||||
Color bg = opaque != null ? opaque.getBackground() : UIUtil.getPanelBackground();
|
||||
g.setColor(bg);
|
||||
g.fillRect(0, 0, getWidth(), getHeight());
|
||||
}
|
||||
|
||||
@@ -32,9 +32,7 @@ import com.intellij.ui.HintHint;
|
||||
import com.intellij.ui.awt.RelativePoint;
|
||||
import com.intellij.util.Alarm;
|
||||
import com.intellij.util.IJSwingUtilities;
|
||||
import com.intellij.util.containers.ComparatorUtil;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import com.intellij.util.ui.update.ComparableObjectCheck;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -284,7 +282,7 @@ public class IdeTooltipManager implements ApplicationComponent, AWTEventListener
|
||||
|
||||
|
||||
public Color getTextForeground(boolean awtTooltip) {
|
||||
return useGraphite(awtTooltip) ? Color.white : UIManager.getColor("ToolTip.foreground");
|
||||
return useGraphite(awtTooltip) ? Color.white : UIUtil.getToolTipForeground();
|
||||
}
|
||||
|
||||
public Color getLinkForeground(boolean awtTooltip) {
|
||||
@@ -292,7 +290,7 @@ public class IdeTooltipManager implements ApplicationComponent, AWTEventListener
|
||||
}
|
||||
|
||||
public Color getTextBackground(boolean awtTooltip) {
|
||||
return useGraphite(awtTooltip) ? new Color(100, 100, 100, 230) : UIManager.getColor("ToolTip.background");
|
||||
return useGraphite(awtTooltip) ? new Color(100, 100, 100, 230) : UIUtil.getToolTipBackground();
|
||||
}
|
||||
|
||||
public String getUlImg(boolean awtTooltip) {
|
||||
|
||||
+20
-5
@@ -18,6 +18,7 @@ package com.intellij.ide.actions;
|
||||
import com.intellij.openapi.actionSystem.*;
|
||||
import com.intellij.openapi.project.DumbAware;
|
||||
import com.intellij.pom.Navigatable;
|
||||
import com.intellij.pom.NavigatableWithText;
|
||||
import com.intellij.util.OpenSourceUtil;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -34,25 +35,39 @@ public abstract class BaseNavigateToSourceAction extends AnAction implements Dum
|
||||
}
|
||||
|
||||
|
||||
public void update(AnActionEvent event){
|
||||
public void update(AnActionEvent event) {
|
||||
DataContext dataContext = event.getDataContext();
|
||||
final boolean enabled = isEnabled(dataContext);
|
||||
final Navigatable target = getTarget(dataContext);
|
||||
boolean enabled = target != null;
|
||||
if (ActionPlaces.isPopupPlace(event.getPlace())) {
|
||||
event.getPresentation().setVisible(enabled);
|
||||
}
|
||||
else {
|
||||
event.getPresentation().setEnabled(enabled);
|
||||
}
|
||||
if (target != null && target instanceof NavigatableWithText) {
|
||||
final String navigateActionText = ((NavigatableWithText)target).getNavigateActionText(myFocusEditor);
|
||||
if (navigateActionText != null) {
|
||||
event.getPresentation().setText(navigateActionText);
|
||||
}
|
||||
else {
|
||||
event.getPresentation().setText(getTemplatePresentation().getText());
|
||||
}
|
||||
}
|
||||
else {
|
||||
event.getPresentation().setText(getTemplatePresentation().getText());
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isEnabled(final DataContext dataContext) {
|
||||
@Nullable
|
||||
private Navigatable getTarget(final DataContext dataContext) {
|
||||
Navigatable[] navigatables = getNavigatables(dataContext);
|
||||
if (navigatables != null) {
|
||||
for (Navigatable navigatable : navigatables) {
|
||||
if (navigatable.canNavigate()) return true;
|
||||
if (navigatable.canNavigate()) return navigatable;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
+1
@@ -68,6 +68,7 @@ public class ChooseComponentsToExportDialog extends DialogWrapper {
|
||||
}
|
||||
final Set<ComponentElementProperties> componentElementProperties = new LinkedHashSet<ComponentElementProperties>(componentToContainingListElement.values());
|
||||
myChooser = new ElementsChooser<ComponentElementProperties>(true);
|
||||
myChooser.setColorUnmarkedElements(false);
|
||||
for (final ComponentElementProperties componentElementProperty : componentElementProperties) {
|
||||
myChooser.addElement(componentElementProperty, true, componentElementProperty);
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ public class CloseProjectAction extends AnAction implements DumbAware {
|
||||
Project project = PlatformDataKeys.PROJECT.getData(e.getDataContext());
|
||||
assert project != null;
|
||||
|
||||
ProjectUtil.closeProject(project);
|
||||
ProjectUtil.closeAndDispose(project);
|
||||
RecentProjectsManagerBase.getInstance().updateLastProjectPath();
|
||||
}
|
||||
|
||||
|
||||
+1
-2
@@ -31,7 +31,6 @@ import com.intellij.openapi.vfs.LocalFileSystem;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* @author spleaner
|
||||
@@ -63,7 +62,7 @@ public class SaveAsDirectoryBasedFormatAction extends AnAction implements DumbAw
|
||||
|
||||
projectStore.setProjectFilePath(baseDir.getPath());
|
||||
project.save();
|
||||
ProjectUtil.closeProject(project);
|
||||
ProjectUtil.closeAndDispose(project);
|
||||
ProjectUtil.openProject(baseDir.getPath(), null, false);
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -17,6 +17,7 @@ package com.intellij.ide.dnd;
|
||||
|
||||
import com.intellij.openapi.util.IconLoader;
|
||||
import com.intellij.openapi.util.SystemInfo;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
|
||||
import javax.accessibility.Accessible;
|
||||
import javax.swing.*;
|
||||
@@ -137,7 +138,7 @@ public class Highlighters implements DnDEvent.DropTargetHighlightingType {
|
||||
}
|
||||
};
|
||||
myLabel.setFont(myLabel.getFont().deriveFont(Font.BOLD));
|
||||
myLabel.setForeground(UIManager.getColor("ToolTip.foreground"));
|
||||
myLabel.setForeground(UIUtil.getToolTipForeground());
|
||||
|
||||
setFocusable(false);
|
||||
|
||||
@@ -179,10 +180,10 @@ public class Highlighters implements DnDEvent.DropTargetHighlightingType {
|
||||
Object old = g2d.getRenderingHint(RenderingHints.KEY_ANTIALIASING);
|
||||
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
|
||||
|
||||
g.setColor(UIManager.getColor("ToolTip.background"));
|
||||
g.setColor(UIUtil.getToolTipBackground());
|
||||
g.fillRoundRect(0, 0, getSize().width - 1, getSize().height - 1, 6, 6);
|
||||
|
||||
g.setColor(UIManager.getColor("ToolTip.foreground"));
|
||||
g.setColor(UIUtil.getToolTipForeground());
|
||||
g.drawRoundRect(0, 0, getSize().width - 1, getSize().height - 1, 6, 6);
|
||||
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, old);
|
||||
}
|
||||
|
||||
@@ -21,7 +21,6 @@ import com.intellij.ide.IdeBundle;
|
||||
import com.intellij.ide.highlighter.ModuleFileType;
|
||||
import com.intellij.ide.highlighter.ProjectFileType;
|
||||
import com.intellij.ide.highlighter.WorkspaceFileType;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.components.StorageScheme;
|
||||
import com.intellij.openapi.components.impl.stores.IProjectStore;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
@@ -32,8 +31,6 @@ import com.intellij.openapi.project.ex.ProjectEx;
|
||||
import com.intellij.openapi.project.ex.ProjectManagerEx;
|
||||
import com.intellij.openapi.ui.Messages;
|
||||
import com.intellij.openapi.util.ActionCallback;
|
||||
import com.intellij.openapi.util.Computable;
|
||||
import com.intellij.openapi.util.Disposer;
|
||||
import com.intellij.openapi.util.InvalidDataException;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.vfs.LocalFileSystem;
|
||||
@@ -89,14 +86,8 @@ public class ProjectUtil {
|
||||
/**
|
||||
* @param project cannot be null
|
||||
*/
|
||||
public static boolean closeProject(@NotNull final Project project) {
|
||||
return ApplicationManager.getApplication().runWriteAction(new Computable<Boolean>() {
|
||||
public Boolean compute() {
|
||||
if (!ProjectManagerEx.getInstanceEx().closeProject(project)) return false;
|
||||
Disposer.dispose(project);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
public static boolean closeAndDispose(@NotNull final Project project) {
|
||||
return ProjectManagerEx.getInstanceEx().closeAndDispose(project);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -158,7 +149,7 @@ public class ProjectUtil {
|
||||
if (!forceOpenInNewFrame && openProjects.length > 0) {
|
||||
int exitCode = confirmOpenNewProject();
|
||||
if (exitCode == 1) { // "No" option
|
||||
if (!closeProject(projectToClose != null ? projectToClose : openProjects[openProjects.length - 1])) return null;
|
||||
if (!closeAndDispose(projectToClose != null ? projectToClose : openProjects[openProjects.length - 1])) return null;
|
||||
}
|
||||
else if (exitCode != 0) { // not "Yes"
|
||||
return null;
|
||||
|
||||
@@ -601,15 +601,6 @@ public final class LafManagerImpl extends LafManager implements ApplicationCompo
|
||||
initIdeaDefaults(table);
|
||||
}
|
||||
|
||||
protected void initSystemColorDefaults(UIDefaults table) {
|
||||
super.initSystemColorDefaults(table);
|
||||
/*
|
||||
table.put("control", new ColorUIResource(236, 233, 216));
|
||||
table.put("controlHighlight", new ColorUIResource(255, 255, 255));
|
||||
table.put("controlShadow", new ColorUIResource(172, 167, 153));
|
||||
*/
|
||||
}
|
||||
|
||||
@SuppressWarnings({"HardCodedStringLiteral"})
|
||||
private static void initIdeaDefaults(UIDefaults defaults) {
|
||||
defaults.put("Menu.maxGutterIconWidth", 18);
|
||||
|
||||
+2
-2
@@ -379,7 +379,7 @@ public class NotificationsListPanel extends JPanel implements NotificationModelL
|
||||
}
|
||||
});
|
||||
|
||||
setBackground(UIUtil.getPanelBackgound());
|
||||
setBackground(UIUtil.getPanelBackground());
|
||||
|
||||
addMouseMotionListener(new MouseMotionListener() {
|
||||
public void mouseMoved(MouseEvent e) {
|
||||
@@ -657,7 +657,7 @@ public class NotificationsListPanel extends JPanel implements NotificationModelL
|
||||
scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
|
||||
|
||||
scrollPane.setBorder(null);
|
||||
scrollPane.getViewport().setBackground(UIUtil.getPanelBackgound());
|
||||
scrollPane.getViewport().setBackground(UIUtil.getPanelBackground());
|
||||
|
||||
final JComponent buttonBar = buildFilterBar(list, project);
|
||||
model.addListDataListener(new ListDataListener() {
|
||||
|
||||
+1
-1
@@ -56,7 +56,7 @@ public class ActionButtonWithText extends ActionButton {
|
||||
final int textHeight = fontMetrics.getMaxAscent() + fontMetrics.getMaxDescent();
|
||||
|
||||
UIUtil.applyRenderingHints(g);
|
||||
g.setColor(isButtonEnabled() ? UIUtil.getLabelForeground() : UIUtil.getTextInactiveTextColor());
|
||||
g.setColor(isButtonEnabled() ? UIUtil.getLabelForeground() : UIUtil.getInactiveTextColor());
|
||||
final int iconTextDifference = (int)Math.ceil((icon.getIconHeight() - textHeight) / 2);
|
||||
final int textStartX = x + icon.getIconWidth() + ICON_TEXT_SPACE;
|
||||
g.drawString(text, textStartX, y + iconTextDifference + fontMetrics.getMaxAscent());
|
||||
|
||||
+1
-1
@@ -278,7 +278,7 @@ public class ApplicationImpl extends ComponentManagerImpl implements Application
|
||||
try {
|
||||
commandProcessor.executeCommand(project, new Runnable() {
|
||||
public void run() {
|
||||
canClose.set(ProjectUtil.closeProject(project));
|
||||
canClose.set(ProjectUtil.closeAndDispose(project));
|
||||
}
|
||||
}, ApplicationBundle.message("command.exit"), null);
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ public class DiffStatusBar extends JPanel {
|
||||
private void addComponent(final LegendTypeDescriptor diffType) {
|
||||
JComponent component = new JPanel() {
|
||||
public void paint(Graphics g) {
|
||||
setBackground(UIUtil.getPanelBackgound());
|
||||
setBackground(UIUtil.getPanelBackground());
|
||||
super.paint(g);
|
||||
FontMetrics metrics = getFontMetrics(getFont());
|
||||
|
||||
|
||||
+3
-2
@@ -21,6 +21,7 @@ import com.intellij.openapi.diff.impl.DiffUtil;
|
||||
import com.intellij.openapi.fileTypes.FileType;
|
||||
import com.intellij.openapi.fileTypes.FileTypeManager;
|
||||
import com.intellij.openapi.fileTypes.FileTypes;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
|
||||
@@ -75,10 +76,10 @@ class ExtCompareFiles extends BaseExternalTool {
|
||||
if (name.length() <= 3) name = "___" + name;
|
||||
File tempFile;
|
||||
try {
|
||||
tempFile = File.createTempFile(name, extension);
|
||||
tempFile = FileUtil.createTempFile(name, extension);
|
||||
}
|
||||
catch (IOException e) {
|
||||
tempFile = File.createTempFile(STD_PREFIX, extension);
|
||||
tempFile = FileUtil.createTempFile(STD_PREFIX, extension);
|
||||
}
|
||||
FileOutputStream stream = null;
|
||||
try {
|
||||
|
||||
+11
-3
@@ -40,10 +40,16 @@ import java.awt.datatransfer.StringSelection;
|
||||
|
||||
public class CutLineEndAction extends EditorAction {
|
||||
public CutLineEndAction() {
|
||||
super(new Handler());
|
||||
super(new Handler(true));
|
||||
}
|
||||
|
||||
private static class Handler extends EditorWriteActionHandler {
|
||||
static class Handler extends EditorWriteActionHandler {
|
||||
private final boolean myCopyToClipboard;
|
||||
|
||||
Handler(boolean copyToClipboard) {
|
||||
myCopyToClipboard = copyToClipboard;
|
||||
}
|
||||
|
||||
public void executeWriteAction(Editor editor, DataContext dataContext) {
|
||||
final Document doc = editor.getDocument();
|
||||
if (doc.getLineCount() == 0) return;
|
||||
@@ -56,7 +62,9 @@ public class CutLineEndAction extends EditorAction {
|
||||
return;
|
||||
}
|
||||
|
||||
copyToClipboard(doc, caretOffset, lineEndOffset, dataContext, editor);
|
||||
if (myCopyToClipboard) {
|
||||
copyToClipboard(doc, caretOffset, lineEndOffset, dataContext, editor);
|
||||
}
|
||||
|
||||
final int lineStartOffset = doc.getLineStartOffset(lineNumber);
|
||||
if (StringUtil.isEmptyOrSpaces(doc.getCharsSequence().subSequence(lineStartOffset, lineEndOffset).toString())) {
|
||||
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
* Copyright 2000-2010 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.openapi.editor.actions;
|
||||
|
||||
import com.intellij.openapi.editor.actionSystem.EditorAction;
|
||||
|
||||
/**
|
||||
* @author yole
|
||||
*/
|
||||
public class DeleteToLineEndAction extends EditorAction {
|
||||
public DeleteToLineEndAction() {
|
||||
super(new CutLineEndAction.Handler(false));
|
||||
}
|
||||
}
|
||||
@@ -148,13 +148,13 @@ public class DocumentImpl extends UserDataHolderBase implements DocumentEx {
|
||||
|
||||
VisualPosition visualCaret = editor == null ? null : editor.getCaretModel().getVisualPosition();
|
||||
int caretLine = editor == null ? -1 : editor.getCaretModel().getLogicalPosition().line;
|
||||
int caretOffset = editor == null ? -1 : editor.getCaretModel().getOffset();
|
||||
|
||||
boolean isTestMode = ApplicationManager.getApplication().isUnitTestMode();
|
||||
boolean markAsNeedsStrippingLater = false;
|
||||
CharSequence text = myText.getCharArray();
|
||||
for (int line = 0; line < myLineSet.getLineCount(); line++) {
|
||||
if (inChangedLinesOnly && !myLineSet.isModified(line)) continue;
|
||||
int start = -1;
|
||||
int whiteSpaceStart = -1;
|
||||
final int lineEnd = myLineSet.getLineEnd(line) - myLineSet.getSeparatorLength(line);
|
||||
int lineStart = myLineSet.getLineStart(line);
|
||||
for (int offset = lineEnd - 1; offset >= lineStart; offset--) {
|
||||
@@ -162,16 +162,16 @@ public class DocumentImpl extends UserDataHolderBase implements DocumentEx {
|
||||
if (c != ' ' && c != '\t') {
|
||||
break;
|
||||
}
|
||||
start = offset;
|
||||
whiteSpaceStart = offset;
|
||||
}
|
||||
if (start == -1) continue;
|
||||
if (!isTestMode && !isVirtualSpaceEnabled && caretLine == line) {
|
||||
if (whiteSpaceStart == -1) continue;
|
||||
if (!isVirtualSpaceEnabled && caretLine == line && whiteSpaceStart < caretOffset) {
|
||||
// mark this as a document that needs stripping later
|
||||
// otherwise the caret would jump madly
|
||||
markAsNeedsStrippingLater = true;
|
||||
}
|
||||
else {
|
||||
final int finalStart = start;
|
||||
final int finalStart = whiteSpaceStart;
|
||||
ApplicationManager.getApplication().runWriteAction(new DocumentRunnable(this, editor == null ? null : editor.getProject()) {
|
||||
public void run() {
|
||||
CommandProcessor.getInstance().runUndoTransparentAction(new Runnable() {
|
||||
|
||||
+2
-4
@@ -57,9 +57,6 @@ import com.intellij.openapi.wm.IdeFocusManager;
|
||||
import com.intellij.openapi.wm.ToolWindowManager;
|
||||
import com.intellij.openapi.wm.WindowManager;
|
||||
import com.intellij.openapi.wm.ex.StatusBarEx;
|
||||
import com.intellij.openapi.wm.ex.WindowManagerEx;
|
||||
import com.intellij.openapi.wm.impl.FrameTitleBuilder;
|
||||
import com.intellij.openapi.wm.impl.IdeFrameImpl;
|
||||
import com.intellij.ui.docking.DockContainer;
|
||||
import com.intellij.ui.docking.DockManager;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
@@ -76,7 +73,6 @@ import javax.swing.border.Border;
|
||||
import java.awt.*;
|
||||
import java.beans.PropertyChangeEvent;
|
||||
import java.beans.PropertyChangeListener;
|
||||
import java.io.File;
|
||||
import java.util.*;
|
||||
import java.util.List;
|
||||
|
||||
@@ -1430,6 +1426,8 @@ private final class MyVirtualFileListener extends VirtualFileAdapter {
|
||||
VirtualFile[] files = eachWindow.getFiles();
|
||||
for (int i = 0; i < files.length - 1 + 1; i++) {
|
||||
VirtualFile eachFile = files[i];
|
||||
if (!eachFile.isValid()) continue;
|
||||
|
||||
VirtualFile newFile = null;
|
||||
for (EditorFileSwapper each : swappers) {
|
||||
newFile = each.getFileToSwapTo(myProject, eachFile);
|
||||
|
||||
+1
-1
@@ -79,7 +79,7 @@ class MouseShortcutDialog extends DialogWrapper{
|
||||
myTarConflicts=new JTextArea();
|
||||
myTarConflicts.setFocusable(false);
|
||||
myTarConflicts.setEditable(false);
|
||||
myTarConflicts.setBackground(UIUtil.getPanelBackgound());
|
||||
myTarConflicts.setBackground(UIUtil.getPanelBackground());
|
||||
myTarConflicts.setLineWrap(true);
|
||||
myTarConflicts.setWrapStyleWord(true);
|
||||
|
||||
|
||||
@@ -330,7 +330,7 @@ public class QuickListPanel {
|
||||
setForeground(getSelectionForeground(tree));
|
||||
}
|
||||
else {
|
||||
Color foreground = used ? UIUtil.getTextInactiveTextColor() :UIUtil.getTreeForeground();
|
||||
Color foreground = used ? UIUtil.getInactiveTextColor() :UIUtil.getTreeForeground();
|
||||
setForeground(foreground);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -349,8 +349,8 @@ public class OptionsTree extends JPanel implements Disposable, OptionsEditorColl
|
||||
|
||||
int nestingLevel = tree.isRootVisible() ? path.getPathCount() - 1 : path.getPathCount() - 2;
|
||||
|
||||
final int left = UIManager.getInt("Tree.leftChildIndent");
|
||||
final int right = UIManager.getInt("Tree.rightChildIndent");
|
||||
final int left = UIUtil.getTreeLeftChildIndent();
|
||||
final int right = UIUtil.getTreeRightChildIndent();
|
||||
|
||||
final Insets treeInsets = tree.getInsets();
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@ import com.intellij.openapi.project.ProjectManager;
|
||||
import com.intellij.openapi.util.InvalidDataException;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import org.jdom.JDOMException;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.annotations.TestOnly;
|
||||
|
||||
@@ -62,4 +63,7 @@ public abstract class ProjectManagerEx extends ProjectManager {
|
||||
|
||||
@Nullable
|
||||
public abstract Project loadAndOpenProject(String filePath, boolean convert) throws IOException, JDOMException, InvalidDataException;
|
||||
|
||||
// returns true on success
|
||||
public abstract boolean closeAndDispose(@NotNull Project project);
|
||||
}
|
||||
|
||||
@@ -322,7 +322,7 @@ public class ProjectImpl extends ComponentManagerImpl implements ProjectEx {
|
||||
ApplicationEx application = ApplicationManagerEx.getApplicationEx();
|
||||
assert application.isDispatchThread();
|
||||
|
||||
// can call dispose only via com.intellij.ide.impl.ProjectUtil.closeProject()
|
||||
// can call dispose only via com.intellij.ide.impl.ProjectUtil.closeAndDispose()
|
||||
LOG.assertTrue(ApplicationManager.getApplication().isUnitTestMode() || !ProjectManagerEx.getInstanceEx().isProjectOpened(this));
|
||||
|
||||
LOG.assertTrue(!isDisposed());
|
||||
|
||||
+28
-13
@@ -389,7 +389,7 @@ public class ProjectManagerImpl extends ProjectManagerEx implements NamedJDOMExt
|
||||
}, ProjectBundle.message("project.load.progress"), true, project);
|
||||
|
||||
if (!ok) {
|
||||
closeProject(project, false);
|
||||
closeProject(project, false, false);
|
||||
notifyProjectOpenFailed();
|
||||
return false;
|
||||
}
|
||||
@@ -850,7 +850,7 @@ public class ProjectManagerImpl extends ProjectManagerEx implements NamedJDOMExt
|
||||
return;
|
||||
}
|
||||
|
||||
if (project[0].isDisposed() || ProjectUtil.closeProject(project[0])) {
|
||||
if (project[0].isDisposed() || ProjectUtil.closeAndDispose(project[0])) {
|
||||
application.runWriteAction(new Runnable() {
|
||||
public void run() {
|
||||
for (final IFile originalFile : original) {
|
||||
@@ -874,10 +874,10 @@ public class ProjectManagerImpl extends ProjectManagerEx implements NamedJDOMExt
|
||||
*/
|
||||
|
||||
public boolean closeProject(final Project project) {
|
||||
return closeProject(project, true);
|
||||
return closeProject(project, true, false);
|
||||
}
|
||||
|
||||
private boolean closeProject(final Project project, final boolean save) {
|
||||
private boolean closeProject(final Project project, final boolean save, final boolean dispose) {
|
||||
if (!isProjectOpened(project)) return true;
|
||||
if (!canClose(project)) return false;
|
||||
|
||||
@@ -889,16 +889,26 @@ public class ProjectManagerImpl extends ProjectManagerEx implements NamedJDOMExt
|
||||
project.save();
|
||||
}
|
||||
|
||||
if (ensureCouldCloseIfUnableToSave(project)) {
|
||||
fireProjectClosing(project);
|
||||
|
||||
myOpenProjects.remove(project);
|
||||
cacheOpenProjects();
|
||||
|
||||
myChangedProjectFiles.remove(project);
|
||||
fireProjectClosed(project);
|
||||
if (!ensureCouldCloseIfUnableToSave(project)) {
|
||||
return false;
|
||||
}
|
||||
else return false;
|
||||
|
||||
fireProjectClosing(project); // somebody can start progress here, do not wrap in write action
|
||||
|
||||
ApplicationManager.getApplication().runWriteAction(new Runnable() {
|
||||
public void run() {
|
||||
myOpenProjects.remove(project);
|
||||
cacheOpenProjects();
|
||||
|
||||
myChangedProjectFiles.remove(project);
|
||||
|
||||
fireProjectClosed(project);
|
||||
|
||||
if (dispose) {
|
||||
Disposer.dispose(project);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
finally {
|
||||
shutDownTracker.unregisterStopperThread(Thread.currentThread());
|
||||
@@ -907,6 +917,11 @@ public class ProjectManagerImpl extends ProjectManagerEx implements NamedJDOMExt
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean closeAndDispose(@NotNull final Project project) {
|
||||
return closeProject(project, true, true);
|
||||
}
|
||||
|
||||
private void fireProjectClosing(Project project) {
|
||||
if (LOG.isDebugEnabled()) {
|
||||
LOG.debug("enter: fireProjectClosing()");
|
||||
|
||||
+1
-1
@@ -208,7 +208,7 @@ public class PluginDownloader {
|
||||
pluginsTemp.mkdirs();
|
||||
}
|
||||
|
||||
File file = File.createTempFile("plugin", "download", pluginsTemp);
|
||||
File file = FileUtil.createTempFile(pluginsTemp, "plugin", "download", true);
|
||||
|
||||
int responseCode = connection.getResponseCode();
|
||||
switch (responseCode) {
|
||||
|
||||
+12
-11
@@ -62,21 +62,14 @@ public class VirtualFilePointerImpl extends UserDataHolderBase implements Virtua
|
||||
if (myFile != null) {
|
||||
return myFile.getName();
|
||||
}
|
||||
else {
|
||||
int index = myUrl.lastIndexOf('/');
|
||||
return index >= 0 ? myUrl.substring(index + 1) : myUrl;
|
||||
}
|
||||
int index = myUrl.lastIndexOf('/');
|
||||
return index >= 0 ? myUrl.substring(index + 1) : myUrl;
|
||||
}
|
||||
|
||||
public VirtualFile getFile() {
|
||||
checkDisposed();
|
||||
|
||||
update();
|
||||
if (myFile != null && !myFile.isValid()) {
|
||||
myUrl = myFile.getUrl();
|
||||
myFile = null;
|
||||
update();
|
||||
}
|
||||
return myFile;
|
||||
}
|
||||
|
||||
@@ -84,6 +77,10 @@ public class VirtualFilePointerImpl extends UserDataHolderBase implements Virtua
|
||||
public String getUrl() {
|
||||
//checkDisposed(); no check here since Disposer might want to compute hashcode during dispose()
|
||||
update();
|
||||
return getUrlNoUpdate();
|
||||
}
|
||||
|
||||
private String getUrlNoUpdate() {
|
||||
return myUrl == null ? myFile.getUrl() : myUrl;
|
||||
}
|
||||
|
||||
@@ -151,6 +148,10 @@ public class VirtualFilePointerImpl extends UserDataHolderBase implements Virtua
|
||||
if (myLastUpdated == fsModCount) return;
|
||||
myLastUpdated = fsModCount;
|
||||
|
||||
if (myFile != null && !myFile.isValid()) {
|
||||
myUrl = myFile.getUrl();
|
||||
myFile = null;
|
||||
}
|
||||
if (myFile == null) {
|
||||
LOG.assertTrue(myUrl != null, "Both file & url are null");
|
||||
myFile = myVirtualFileManager.findFileByUrl(myUrl);
|
||||
@@ -166,7 +167,7 @@ public class VirtualFilePointerImpl extends UserDataHolderBase implements Virtua
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return myFile == null ? myUrl : myFile.getUrl();
|
||||
return getUrlNoUpdate();
|
||||
}
|
||||
|
||||
public void dispose() {
|
||||
@@ -177,7 +178,7 @@ public class VirtualFilePointerImpl extends UserDataHolderBase implements Virtua
|
||||
if (TRACE_CREATION) {
|
||||
putUserData(KILL_TRACE, new Throwable());
|
||||
}
|
||||
String url = getUrl();
|
||||
String url = getUrlNoUpdate();
|
||||
disposed = true;
|
||||
((VirtualFilePointerManagerImpl)VirtualFilePointerManager.getInstance()).clearPointerCaches(url, myListener);
|
||||
}
|
||||
|
||||
@@ -162,7 +162,7 @@ public class IdeFrameImpl extends JFrame implements IdeFrame, DataProvider {
|
||||
final Project[] openProjects = ProjectManager.getInstance().getOpenProjects();
|
||||
if (openProjects.length > 1) {
|
||||
if (myProject != null && myProject.isOpen()) {
|
||||
ProjectUtil.closeProject(myProject);
|
||||
ProjectUtil.closeAndDispose(myProject);
|
||||
}
|
||||
app.getMessageBus().syncPublisher(AppLifecycleListener.TOPIC).projectFrameClosed();
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ import com.intellij.openapi.keymap.ex.KeymapManagerEx;
|
||||
import com.intellij.openapi.keymap.ex.WeakKeymapManagerListener;
|
||||
import com.intellij.openapi.util.Disposer;
|
||||
import com.intellij.openapi.wm.ToolWindowAnchor;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
@@ -333,7 +334,7 @@ final class Stripe extends JPanel{
|
||||
}
|
||||
|
||||
public void setOverlayed(boolean overlayed) {
|
||||
Color bg = UIManager.getColor("Panel.background");
|
||||
Color bg = UIUtil.getPanelBackground();
|
||||
if (overlayed) {
|
||||
setBackground(new Color(bg.getRed(), bg.getGreen(), bg.getBlue(), 190));
|
||||
} else {
|
||||
|
||||
@@ -402,7 +402,7 @@ public final class ToolWindowManagerImpl extends ToolWindowManagerEx implements
|
||||
label.setOpaque(true);
|
||||
final Color treeBg = UIManager.getColor("Tree.background");
|
||||
label.setBackground(new Color(treeBg.getRed(), treeBg.getGreen(), treeBg.getBlue(), 180));
|
||||
final Color treeFg = UIManager.getColor("Tree.foreground");
|
||||
final Color treeFg = UIUtil.getTreeForeground();
|
||||
label.setForeground(new Color(treeFg.getRed(), treeFg.getGreen(), treeFg.getBlue(), 180));
|
||||
final ToolWindowFactory factory = bean.getToolWindowFactory();
|
||||
final ToolWindowImpl toolWindow =
|
||||
|
||||
+3
-3
@@ -112,7 +112,7 @@ public class InlineProgressIndicator extends ProgressIndicatorBase implements Di
|
||||
size = (aqua ? 8 : 10);
|
||||
}
|
||||
myProcessName.setFont(font.deriveFont(Font.PLAIN, size));
|
||||
myProcessName.setForeground(UIManager.getColor("Panel.background").brighter().brighter());
|
||||
myProcessName.setForeground(UIUtil.getPanelBackground().brighter().brighter());
|
||||
myProcessName.setBorder(new EmptyBorder(2, 2, 2, 2));
|
||||
myProcessName.setDecorate(false);
|
||||
|
||||
@@ -346,7 +346,7 @@ public class InlineProgressIndicator extends ProgressIndicatorBase implements Di
|
||||
|
||||
int arc = 8;
|
||||
|
||||
g.setColor(UIManager.getColor("Panel.background"));
|
||||
g.setColor(UIUtil.getPanelBackground());
|
||||
g.fillRoundRect(0, 0, getWidth() - 1, getHeight() - 1, arc, arc);
|
||||
|
||||
Color bg = getBackground().darker().darker();
|
||||
@@ -360,7 +360,7 @@ public class InlineProgressIndicator extends ProgressIndicatorBase implements Di
|
||||
|
||||
g.fillRoundRect(0, 0, getWidth() - 1, getHeight() - 1, arc, arc);
|
||||
|
||||
g.setColor(UIManager.getColor("Panel.background"));
|
||||
g.setColor(UIUtil.getPanelBackground());
|
||||
g.fillRoundRect(0, getHeight() / 2, getWidth() - 1, getHeight() / 2, arc, arc);
|
||||
g.fillRect(0, (int)label.getMaxY() + 1, getWidth() - 1, getHeight() / 2);
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user