From 91ed2272c9cfca41637e420746287d6d42814758 Mon Sep 17 00:00:00 2001 From: Konstantin Bulenkov Date: Fri, 9 Dec 2011 16:34:30 +0100 Subject: [PATCH 01/11] can't find actions if using uppercase (WI-8444) --- .../ide/util/gotoByName/GotoActionModel.java | 83 ++++--------------- 1 file changed, 14 insertions(+), 69 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/ide/util/gotoByName/GotoActionModel.java b/platform/lang-impl/src/com/intellij/ide/util/gotoByName/GotoActionModel.java index d06890a8d9c1..b773ec6cfcba 100644 --- a/platform/lang-impl/src/com/intellij/ide/util/gotoByName/GotoActionModel.java +++ b/platform/lang-impl/src/com/intellij/ide/util/gotoByName/GotoActionModel.java @@ -284,7 +284,6 @@ public class GotoActionModel implements ChooseByNameModel, CustomMatcherModel { myPattern = pattern; } if (myCompiledPattern == null) { - boolean allowToLower = true; final int eol = pattern.indexOf('\n'); if (eol != -1) { pattern = pattern.substring(0, eol); @@ -293,70 +292,25 @@ public class GotoActionModel implements ChooseByNameModel, CustomMatcherModel { pattern = pattern.substring(0, 80); } - final @NonNls StringBuffer buffer = new StringBuffer(); - - if (containsOnlyUppercaseLetters(pattern)) { - allowToLower = false; - } - - if (allowToLower) { - buffer.append(".*"); - } - - boolean firstIdentifierLetter = true; + final @NonNls StringBuffer buffer = new StringBuffer(".*"); + pattern = pattern.toLowerCase(); for (int i = 0; i < pattern.length(); i++) { final char c = pattern.charAt(i); if (Character.isLetterOrDigit(c)) { - // This logic allows to use uppercase letters only to catch the name like PDM for PsiDocumentManager - if (Character.isUpperCase(c) || Character.isDigit(c)) { - - if (!firstIdentifierLetter) { - buffer.append("[^A-Z]*"); - } - - buffer.append("["); - buffer.append(c); - if (allowToLower || i == 0) { - buffer.append('|'); - buffer.append(Character.toLowerCase(c)); - } - buffer.append("]"); - } - else if (Character.isLowerCase(c)) { - buffer.append('['); - buffer.append(c); - buffer.append('|'); - buffer.append(Character.toUpperCase(c)); - buffer.append(']'); - } - else { + if (Character.isLowerCase(c)) { + buffer.append('[') + .append(c) + .append('|') + .append(Character.toUpperCase(c)) + .append(']'); + } else { buffer.append(c); } - - firstIdentifierLetter = false; - } - else if (c == '*') { - buffer.append(".*"); - firstIdentifierLetter = true; - } - else if (c == '.') { - buffer.append("\\."); - firstIdentifierLetter = true; - } - else if (c == ' ') { - buffer.append("[^A-Z]*\\ "); - firstIdentifierLetter = true; - } - else { - firstIdentifierLetter = true; - // for standard RegExp engine - // buffer.append("\\u"); - // buffer.append(Integer.toHexString(c + 0x20000).substring(1)); - - // for OROMATCHER RegExp engine - buffer.append("\\x"); - buffer.append(Integer.toHexString(c + 0x20000).substring(3)); } + else if (c == '*') buffer.append(".*"); + else if (c == '.') buffer.append("\\."); + else if (c == ' ') buffer.append("[^A-Z]*\\ "); + else buffer.append("\\x").append(Integer.toHexString(c + 0x20000).substring(3)); } buffer.append(".*"); @@ -365,21 +319,12 @@ public class GotoActionModel implements ChooseByNameModel, CustomMatcherModel { try { myCompiledPattern = new Perl5Compiler().compile(buffer.toString()); } - catch (MalformedPatternException e) { - //do nothing - } + catch (MalformedPatternException ignore) {} } return myCompiledPattern; } - private static boolean containsOnlyUppercaseLetters(String s) { - for (int i = 0; i < s.length(); i++) { - char c = s.charAt(i); - if (c != '*' && c != ' ' && !Character.isUpperCase(c)) return false; - } - return true; - } @Override public boolean willOpenEditor() { From fea83b914a4b40b5dc648b8f739b4a2c54b91c4e Mon Sep 17 00:00:00 2001 From: Eugene Zhuravlev Date: Fri, 9 Dec 2011 16:28:58 +0100 Subject: [PATCH 02/11] recalculate invalid psi elements if possible --- .../intellij/debugger/impl/DebuggerContextImpl.java | 3 ++- .../src/com/intellij/debugger/SourcePosition.java | 13 ++++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/java/debugger/impl/src/com/intellij/debugger/impl/DebuggerContextImpl.java b/java/debugger/impl/src/com/intellij/debugger/impl/DebuggerContextImpl.java index 7ea88795fee8..576251768e26 100644 --- a/java/debugger/impl/src/com/intellij/debugger/impl/DebuggerContextImpl.java +++ b/java/debugger/impl/src/com/intellij/debugger/impl/DebuggerContextImpl.java @@ -101,7 +101,8 @@ public final class DebuggerContextImpl implements DebuggerContext { public PsiElement getContextElement() { LOG.assertTrue(myInitialized); - if(myContextElement != null && !myContextElement.isValid()) { + PsiElement contextElement = myContextElement; + if(contextElement != null && !contextElement.isValid()) { myContextElement = ContextUtil.getContextElement(mySourcePosition); } return myContextElement; diff --git a/java/debugger/openapi/src/com/intellij/debugger/SourcePosition.java b/java/debugger/openapi/src/com/intellij/debugger/SourcePosition.java index d400ad21cdff..287ca5acea26 100644 --- a/java/debugger/openapi/src/com/intellij/debugger/SourcePosition.java +++ b/java/debugger/openapi/src/com/intellij/debugger/SourcePosition.java @@ -107,7 +107,7 @@ public abstract class SourcePosition implements Navigatable{ } private void updateData() { - if(myModificationStamp != myFile.getModificationStamp()) { + if(dataUpdateNeeded()) { myModificationStamp = myFile.getModificationStamp(); myLine = null; myOffset = null; @@ -115,6 +115,17 @@ public abstract class SourcePosition implements Navigatable{ } } + private boolean dataUpdateNeeded() { + if (myModificationStamp != myFile.getModificationStamp()) { + return true; + } + final PsiElement psiElement = myPsiElement; + if (psiElement != null && !psiElement.isValid()) { + return true; + } + return false; + } + public int getLine() { updateData(); if (myLine == null) { From 524751e07a275e482607f3c1a131025bf7824584 Mon Sep 17 00:00:00 2001 From: Eugene Zhuravlev Date: Fri, 9 Dec 2011 16:38:03 +0100 Subject: [PATCH 03/11] do not use disposed alarm --- .../intellij/debugger/impl/DebuggerSession.java | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/java/debugger/impl/src/com/intellij/debugger/impl/DebuggerSession.java b/java/debugger/impl/src/com/intellij/debugger/impl/DebuggerSession.java index 756ea44af65f..986821bc0697 100644 --- a/java/debugger/impl/src/com/intellij/debugger/impl/DebuggerSession.java +++ b/java/debugger/impl/src/com/intellij/debugger/impl/DebuggerSession.java @@ -584,13 +584,15 @@ public class DebuggerSession implements AbstractDebuggerSession { } private void notifyThreadsRefresh() { - myUpdateAlarm.cancelAllRequests(); - myUpdateAlarm.addRequest(new Runnable() { - public void run() { - final DebuggerStateManager contextManager = getContextManager(); - contextManager.fireStateChanged(contextManager.getContext(), EVENT_THREADS_REFRESH); - } - }, 100, ModalityState.NON_MODAL); + if (!myUpdateAlarm.isDisposed()) { + myUpdateAlarm.cancelAllRequests(); + myUpdateAlarm.addRequest(new Runnable() { + public void run() { + final DebuggerStateManager contextManager = getContextManager(); + contextManager.fireStateChanged(contextManager.getContext(), EVENT_THREADS_REFRESH); + } + }, 100, ModalityState.NON_MODAL); + } } } From 5c288c7b498cd09a4c34d57ede2721a3eafe4619 Mon Sep 17 00:00:00 2001 From: "Maxim.Mossienko" Date: Fri, 9 Dec 2011 19:28:59 +0400 Subject: [PATCH 04/11] add item for suppress / edit settings for non fair js inspections --- ...stomEditInspectionToolsSettingsAction.java | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 platform/lang-impl/src/com/intellij/codeInspection/ex/CustomEditInspectionToolsSettingsAction.java diff --git a/platform/lang-impl/src/com/intellij/codeInspection/ex/CustomEditInspectionToolsSettingsAction.java b/platform/lang-impl/src/com/intellij/codeInspection/ex/CustomEditInspectionToolsSettingsAction.java new file mode 100644 index 000000000000..8fa18d9129af --- /dev/null +++ b/platform/lang-impl/src/com/intellij/codeInspection/ex/CustomEditInspectionToolsSettingsAction.java @@ -0,0 +1,27 @@ +package com.intellij.codeInspection.ex; + +import com.intellij.codeInsight.daemon.HighlightDisplayKey; +import com.intellij.openapi.util.Computable; +import org.jetbrains.annotations.NotNull; + +/** +* Created by IntelliJ IDEA. +* User: Maxim.Mossienko +* Date: 12/9/11 +* Time: 5:29 PM +* To change this template use File | Settings | File Templates. +*/ +public class CustomEditInspectionToolsSettingsAction extends EditInspectionToolsSettingsAction { + private final Computable myText; + + public CustomEditInspectionToolsSettingsAction(HighlightDisplayKey displayKey, Computable text) { + super(displayKey); + myText = text; + } + + @NotNull + @Override + public String getText() { + return myText.compute(); + } +} From 0f31b1251bfdfbec25b01a3a0a705844cabcf4f7 Mon Sep 17 00:00:00 2001 From: "Denis.Zhdanov" Date: Fri, 9 Dec 2011 16:36:37 +0400 Subject: [PATCH 05/11] IDEA-78616 Soft wraps: Correct processing when tab size is changed 1. Soft wraps are recalculated if tad width is changed; 2. Corresponding test has been added; --- .../openapi/editor/impl/EditorImpl.java | 2 +- .../editor/impl/SoftWrapModelImpl.java | 27 ++++++++++++++++++- ...apApplianceOnDocumentModificationTest.java | 23 ++++++++++++++++ 3 files changed, 50 insertions(+), 2 deletions(-) diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorImpl.java b/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorImpl.java index 238cc7a0472e..6ecddea85a1e 100644 --- a/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorImpl.java @@ -590,10 +590,10 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi boolean softWrapsUsedBefore = mySoftWrapModel.isSoftWrappingEnabled(); + mySettings.reinitSettings(); mySoftWrapModel.reinitSettings(); myCaretModel.reinitSettings(); mySelectionModel.reinitSettings(); - mySettings.reinitSettings(); ourCaretBlinkingCommand.setBlinkCaret(mySettings.isBlinkCaret()); ourCaretBlinkingCommand.setBlinkPeriod(mySettings.getCaretBlinkPeriod()); mySizeContainer.reset(); diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/impl/SoftWrapModelImpl.java b/platform/platform-impl/src/com/intellij/openapi/editor/impl/SoftWrapModelImpl.java index 934dff74cecd..74c0dc309a23 100644 --- a/platform/platform-impl/src/com/intellij/openapi/editor/impl/SoftWrapModelImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/editor/impl/SoftWrapModelImpl.java @@ -25,6 +25,10 @@ import com.intellij.openapi.editor.ex.*; import com.intellij.openapi.editor.ex.util.EditorUtil; import com.intellij.openapi.editor.impl.softwrap.*; import com.intellij.openapi.editor.impl.softwrap.mapping.*; +import com.intellij.openapi.vfs.VirtualFile; +import com.intellij.psi.codeStyle.CodeStyleSettings; +import com.intellij.psi.codeStyle.CodeStyleSettingsManager; +import com.intellij.psi.codeStyle.CommonCodeStyleSettings; import com.intellij.reference.SoftReference; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -92,6 +96,7 @@ public class SoftWrapModelImpl implements SoftWrapModelEx, PrioritizedDocumentLi /** Holds number of 'active' calls, i.e. number of methods calls of the current object within the current call stack. */ private int myActive; private boolean myUseSoftWraps; + private int myTabWidth = -1; /** * Standard IJ editor starts showing horizontal scroll bar event when text line ends couple of symbols before the right visual @@ -191,7 +196,13 @@ public class SoftWrapModelImpl implements SoftWrapModelEx, PrioritizedDocumentLi boolean softWrapsUsedBefore = myUseSoftWraps; EditorSettings settings = myEditor.getSettings(); myUseSoftWraps = settings.isUseSoftWraps(); - if (myUseSoftWraps && (!softWrapsUsedBefore || settings.getAdditionalColumnsCount() > 0)) { + + int tabWidthBefore = myTabWidth; + myTabWidth = getCurrentTabWidth(); + + if ((myUseSoftWraps && (!softWrapsUsedBefore || settings.getAdditionalColumnsCount() > 0)) + || (tabWidthBefore >= 0 && myTabWidth != tabWidthBefore)) + { myApplianceManager.reset(); myDeferredFoldRegions.clear(); myAdditionalColumnsCount = settings.getAdditionalColumnsCount(); @@ -203,6 +214,20 @@ public class SoftWrapModelImpl implements SoftWrapModelEx, PrioritizedDocumentLi myEditor.getScrollingModel().scrollToCaret(ScrollType.CENTER); } + /** + * @return tab width for the file used at the current editor (if it's possible to calculate the one); + * '-1' otherwise + */ + private int getCurrentTabWidth() { + final CodeStyleSettings settings = CodeStyleSettingsManager.getSettings(myEditor.getProject()); + final VirtualFile file = myEditor.getVirtualFile(); + if (file == null) { + return -1; + } + final CommonCodeStyleSettings.IndentOptions indentOptions = settings.getIndentOptions(file.getFileType()); + return indentOptions.TAB_SIZE; + } + @Override public boolean isSoftWrappingEnabled() { if (!myUseSoftWraps || myEditor.isOneLineMode()) { diff --git a/platform/platform-impl/testSrc/com/intellij/openapi/editor/impl/softwrap/mapping/SoftWrapApplianceOnDocumentModificationTest.java b/platform/platform-impl/testSrc/com/intellij/openapi/editor/impl/softwrap/mapping/SoftWrapApplianceOnDocumentModificationTest.java index 1f6a4865e5c4..28ffb0cbe25e 100644 --- a/platform/platform-impl/testSrc/com/intellij/openapi/editor/impl/softwrap/mapping/SoftWrapApplianceOnDocumentModificationTest.java +++ b/platform/platform-impl/testSrc/com/intellij/openapi/editor/impl/softwrap/mapping/SoftWrapApplianceOnDocumentModificationTest.java @@ -21,6 +21,7 @@ import com.intellij.openapi.editor.impl.AbstractEditorProcessingOnDocumentModifi import com.intellij.openapi.editor.impl.EditorImpl; import com.intellij.openapi.editor.impl.SoftWrapModelImpl; import com.intellij.openapi.editor.markup.TextAttributes; +import com.intellij.psi.codeStyle.CommonCodeStyleSettings; import com.intellij.testFramework.TestFileType; import gnu.trove.TIntHashSet; import gnu.trove.TIntProcedure; @@ -848,6 +849,28 @@ public class SoftWrapApplianceOnDocumentModificationTest extends AbstractEditorP assertEquals(visualPosition, getEditor().logicalToVisualPosition(logicalPosition)); assertEquals(logicalPosition, getEditor().visualToLogicalPosition(visualPosition)); } + + public void testSoftWrapsRecalculationOnTabWidthChange() throws IOException { + // Inspired by IDEA-78616 - the point is to recalculate soft wraps when tab width is changed. + String text = + "\t my text"; + + // Build soft wraps cache. + init(300, text); + + VisualPosition caretPositionBefore = getEditor().getCaretModel().getVisualPosition(); + + // Change tab size. + final CommonCodeStyleSettings.IndentOptions indentOptions = getCurrentCodeStyleSettings().getIndentOptions(); + assertNotNull(indentOptions); + indentOptions.TAB_SIZE++; + + ((EditorImpl)getEditor()).reinitSettings(); + assertEquals( + new VisualPosition(caretPositionBefore.line, caretPositionBefore.column + 1), + getEditor().getCaretModel().getVisualPosition() + ); + } private void init(final int visibleWidth, @NotNull String fileText) throws IOException { init(visibleWidth, fileText, TestFileType.TEXT); From 11d383c9964d5934f1f24be03106455f6700b136 Mon Sep 17 00:00:00 2001 From: "Denis.Zhdanov" Date: Fri, 9 Dec 2011 18:54:11 +0400 Subject: [PATCH 06/11] IDEA-74108 Editor always scrolled to the top when selected using 'Recent Files' action (Ctrl-e) EditorHistoryManager is notified by active editor change after it. The problem is that it's not possible to derive FileEditorProvider for the old editor when no tabs are shown. However, the provider is known during the event construction, so, it's just wrapped there. --- .../fileEditor/FileEditorManagerEvent.java | 54 +++++++++++++++---- .../fileEditor/impl/EditorHistoryManager.java | 26 ++++++--- .../impl/FileEditorManagerImpl.java | 45 ++++++++++------ 3 files changed, 93 insertions(+), 32 deletions(-) diff --git a/platform/platform-api/src/com/intellij/openapi/fileEditor/FileEditorManagerEvent.java b/platform/platform-api/src/com/intellij/openapi/fileEditor/FileEditorManagerEvent.java index 390c16a32678..3509643e267d 100644 --- a/platform/platform-api/src/com/intellij/openapi/fileEditor/FileEditorManagerEvent.java +++ b/platform/platform-api/src/com/intellij/openapi/fileEditor/FileEditorManagerEvent.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2011 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. @@ -16,44 +16,78 @@ package com.intellij.openapi.fileEditor; import com.intellij.openapi.vfs.VirtualFile; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; import java.util.EventObject; public final class FileEditorManagerEvent extends EventObject { - private final VirtualFile myOldFile; - private final FileEditor myOldEditor; - private final VirtualFile myNewFile; - private final FileEditor myNewEditor; - public FileEditorManagerEvent(FileEditorManager source, - VirtualFile oldFile, - FileEditor oldEditor, - VirtualFile newFile, - FileEditor newEditor) { + private final VirtualFile myOldFile; + private final FileEditor myOldEditor; + private final VirtualFile myNewFile; + private final FileEditor myNewEditor; + private final FileEditorProvider myOldProvider; + private final FileEditorProvider myNewProvider; + + public FileEditorManagerEvent(@NotNull FileEditorManager source, + @Nullable VirtualFile oldFile, + @Nullable FileEditor oldEditor, + @Nullable VirtualFile newFile, + @Nullable FileEditor newEditor) + { + this(source, oldFile, oldEditor, null, newFile, newEditor, null); + } + + public FileEditorManagerEvent(@NotNull FileEditorManager source, + @Nullable VirtualFile oldFile, + @Nullable FileEditor oldEditor, + @Nullable FileEditorProvider oldProvider, + @Nullable VirtualFile newFile, + @Nullable FileEditor newEditor, + @Nullable FileEditorProvider newProvider) + { super(source); myOldFile = oldFile; myOldEditor = oldEditor; myNewFile = newFile; myNewEditor = newEditor; + myOldProvider = oldProvider; + myNewProvider = newProvider; } + @NotNull public FileEditorManager getManager(){ return (FileEditorManager)getSource(); } + @Nullable public VirtualFile getOldFile() { return myOldFile; } + @Nullable public VirtualFile getNewFile() { return myNewFile; } + @Nullable public FileEditor getOldEditor() { return myOldEditor; } + @Nullable public FileEditor getNewEditor() { return myNewEditor; } + + @Nullable + public FileEditorProvider getOldProvider() { + return myOldProvider; + } + + @Nullable + public FileEditorProvider getNewProvider() { + return myNewProvider; + } } \ No newline at end of file diff --git a/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/EditorHistoryManager.java b/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/EditorHistoryManager.java index c9126d1b3371..a6d987f4f0ff 100644 --- a/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/EditorHistoryManager.java +++ b/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/EditorHistoryManager.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2011 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. @@ -34,6 +34,7 @@ import com.intellij.openapi.vfs.VirtualFileManager; import com.intellij.util.ArrayUtil; import org.jdom.Element; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; import java.util.ArrayList; import java.util.List; @@ -143,14 +144,28 @@ public final class EditorHistoryManager extends AbstractProjectComponent impleme trimToSize(); } } - - private void updateHistoryEntry(final VirtualFile file, final boolean changeEntryOrderOnly){ + + private void updateHistoryEntry(@Nullable final VirtualFile file, final boolean changeEntryOrderOnly) { + updateHistoryEntry(file, null, null, changeEntryOrderOnly); + } + + private void updateHistoryEntry(@Nullable final VirtualFile file, + @Nullable final FileEditor fallbackEditor, + @Nullable FileEditorProvider fallbackProvider, + final boolean changeEntryOrderOnly) + { if (file == null){ return; } final FileEditorManagerEx editorManager = FileEditorManagerEx.getInstanceEx(myProject); final Pair editorsWithProviders = editorManager.getEditorsWithProviders(file); - final FileEditor[] editors = editorsWithProviders.getFirst(); + FileEditor[] editors = editorsWithProviders.getFirst(); + FileEditorProvider[] providers = editorsWithProviders.getSecond(); + if (editors.length <= 0 && fallbackEditor != null) { + editors = new FileEditor[] {fallbackEditor}; + providers = new FileEditorProvider[] {fallbackProvider}; + } + if (editors.length == 0) { // obviously not opened in any editor at the moment, // makes no sense to put the file in the history @@ -167,7 +182,6 @@ public final class EditorHistoryManager extends AbstractProjectComponent impleme } if (!changeEntryOrderOnly) { // update entry state - final FileEditorProvider [] providers = editorsWithProviders.getSecond(); //LOG.assertTrue(editors.length > 0); for (int i = editors.length - 1; i >= 0; i--) { final FileEditor editor = editors [i]; @@ -311,7 +325,7 @@ public final class EditorHistoryManager extends AbstractProjectComponent impleme } public void selectionChanged(final FileEditorManagerEvent event){ - updateHistoryEntry(event.getOldFile(), false); + updateHistoryEntry(event.getOldFile(), event.getOldEditor(), event.getOldProvider(), false); updateHistoryEntry(event.getNewFile(), true); } } diff --git a/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/FileEditorManagerImpl.java b/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/FileEditorManagerImpl.java index e2877d3d6831..1406ba0523b2 100644 --- a/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/FileEditorManagerImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/FileEditorManagerImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2011 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. @@ -1318,26 +1318,20 @@ public class FileEditorManagerImpl extends FileEditorManagerEx implements Projec } public void fireSelectionChanged(final EditorComposite oldSelectedComposite, final EditorComposite newSelectedComposite) { - final VirtualFile oldSelectedFile = oldSelectedComposite != null ? oldSelectedComposite.getFile() : null; - final VirtualFile newSelectedFile = newSelectedComposite != null ? newSelectedComposite.getFile() : null; - - final FileEditor oldSelectedEditor = - oldSelectedComposite != null && !oldSelectedComposite.isDisposed() ? oldSelectedComposite.getSelectedEditor() : null; - final FileEditor newSelectedEditor = - newSelectedComposite != null && !newSelectedComposite.isDisposed() ? newSelectedComposite.getSelectedEditor() : null; - - final boolean filesEqual = oldSelectedFile == null ? newSelectedFile == null : oldSelectedFile.equals(newSelectedFile); - final boolean editorsEqual = oldSelectedEditor == null ? newSelectedEditor == null : oldSelectedEditor.equals(newSelectedEditor); + final Trinity oldData = extract(oldSelectedComposite); + final Trinity newData = extract(newSelectedComposite); + final boolean filesEqual = oldData.first == null ? newData.first == null : oldData.first.equals(newData.first); + final boolean editorsEqual = oldData.second == null ? newData.second == null : oldData.second.equals(newData.second); if (!filesEqual || !editorsEqual) { final FileEditorManagerEvent event = - new FileEditorManagerEvent(this, oldSelectedFile, oldSelectedEditor, newSelectedFile, newSelectedEditor); + new FileEditorManagerEvent(this, oldData.first, oldData.second, oldData.third, newData.first, newData.second, newData.third); final FileEditorManagerListener publisher = getProject().getMessageBus().syncPublisher(FileEditorManagerListener.FILE_EDITOR_MANAGER); - if (newSelectedEditor != null) { - final JComponent component = newSelectedEditor.getComponent(); + if (newData.first != null) { + final JComponent component = newData.second.getComponent(); final EditorWindowHolder holder = UIUtil.getParentOfType(EditorWindowHolder.class, component); if (holder != null) { - addSelectionRecord(newSelectedFile, holder.getEditorWindow()); + addSelectionRecord(newData.first, holder.getEditorWindow()); } } notifyPublisher(new Runnable() { @@ -1348,7 +1342,26 @@ public class FileEditorManagerImpl extends FileEditorManagerEx implements Projec }); } } - + + @NotNull + private static Trinity extract(@Nullable EditorComposite composite) { + final VirtualFile file; + final FileEditor editor; + final FileEditorProvider provider; + if (composite == null || composite.isDisposed()) { + file = null; + editor = null; + provider = null; + } + else { + file = composite.getFile(); + final Pair pair = composite.getSelectedEditorWithProvider(); + editor = pair.first; + provider = pair.second; + } + return new Trinity(file, editor, provider); + } + public boolean isChanged(@NotNull final EditorComposite editor) { final FileStatusManager fileStatusManager = FileStatusManager.getInstance(myProject); if (fileStatusManager != null) { From 018be273355bb9adf754e313d543ba8eb97feb3e Mon Sep 17 00:00:00 2001 From: anna Date: Fri, 9 Dec 2011 16:46:00 +0100 Subject: [PATCH 07/11] applet configuration (IDEA-77954; IDEA-77955) --- .../execution/applet/AppletConfigurable.java | 40 +++++-------------- 1 file changed, 11 insertions(+), 29 deletions(-) diff --git a/java/execution/impl/src/com/intellij/execution/applet/AppletConfigurable.java b/java/execution/impl/src/com/intellij/execution/applet/AppletConfigurable.java index 51ab7fdf97dc..30f79a225ed1 100644 --- a/java/execution/impl/src/com/intellij/execution/applet/AppletConfigurable.java +++ b/java/execution/impl/src/com/intellij/execution/applet/AppletConfigurable.java @@ -26,10 +26,7 @@ import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.LabeledComponent; import com.intellij.openapi.ui.TextFieldWithBrowseButton; import com.intellij.openapi.util.text.StringUtil; -import com.intellij.ui.EditorTextFieldWithBrowseButton; -import com.intellij.ui.PanelWithAnchor; -import com.intellij.ui.RawCommandLineEditor; -import com.intellij.ui.ScrollPaneFactory; +import com.intellij.ui.*; import com.intellij.ui.components.JBLabel; import com.intellij.ui.table.TableView; import com.intellij.util.ui.ColumnInfo; @@ -162,19 +159,18 @@ public class AppletConfigurable extends SettingsEditor impl } private void removeParameter() { - final int selectedRow = myTable.getSelectedRow(); - if (selectedRow < 0 || selectedRow >= myTable.getRowCount()) return; - final ArrayList newItems = - new ArrayList(myParameters.getItems()); - newItems.remove(selectedRow); - myParameters.setItems(newItems); + TableUtil.removeSelectedItems(myTable); } private void addParameter() { - final ArrayList newItems = - new ArrayList(myParameters.getItems()); - newItems.add(new AppletConfiguration.AppletParameter("newParameter", "")); + final ArrayList newItems = new ArrayList(myParameters.getItems()); + final AppletConfiguration.AppletParameter parameter = new AppletConfiguration.AppletParameter("newParameter", ""); + newItems.add(parameter); myParameters.setItems(newItems); + + int index = newItems.size() - 1; + myTable.getSelectionModel().setSelectionInterval(index, index); + myTable.scrollRectToVisible(myTable.getCellRect(index, 0, true)); } private JComboBox getModuleComponent() { @@ -185,14 +181,9 @@ public class AppletConfigurable extends SettingsEditor impl return myPolicyFile.getComponent(); } - private void getConfigurationTo(final AppletConfiguration configuration) { - - } - - private List cloneParameters(final List items) { + private static List cloneParameters(final List items) { final List params = new ArrayList(); - for (Iterator iterator = items.iterator(); iterator.hasNext();) { - AppletConfiguration.AppletParameter appletParameter = iterator.next(); + for (AppletConfiguration.AppletParameter appletParameter : items) { params.add(new AppletConfiguration.AppletParameter(appletParameter.getName(), appletParameter.getValue())); } return params; @@ -311,15 +302,6 @@ public class AppletConfigurable extends SettingsEditor impl super(name); } - public Comparator getComparator() { - return new Comparator() { - public int compare(final AppletConfiguration.AppletParameter parameter1, - final AppletConfiguration.AppletParameter parameter2) { - return valueOf(parameter1).compareTo(valueOf(parameter2)); - } - }; - } - public TableCellEditor getEditor(final AppletConfiguration.AppletParameter item) { final JTextField textField = new JTextField(); textField.setBorder(BorderFactory.createLineBorder(Color.BLACK)); From 56723c4b173ca4e4cf29adf0fc5bf96ecc5c744b Mon Sep 17 00:00:00 2001 From: Maxim Shafirov Date: Fri, 9 Dec 2011 19:58:41 +0400 Subject: [PATCH 08/11] IDEA-78370 --- .../codeInspection/dataFlow/DfaMemoryStateImpl.java | 2 ++ .../inspection/dataFlow/IDEADEV78370/expected.xml | 3 +++ .../inspection/dataFlow/IDEADEV78370/src/NoWarnings.java | 8 ++++++++ .../intellij/codeInspection/DataFlowInspectionTest.java | 1 + 4 files changed, 14 insertions(+) create mode 100644 java/java-tests/testData/inspection/dataFlow/IDEADEV78370/expected.xml create mode 100644 java/java-tests/testData/inspection/dataFlow/IDEADEV78370/src/NoWarnings.java diff --git a/java/java-impl/src/com/intellij/codeInspection/dataFlow/DfaMemoryStateImpl.java b/java/java-impl/src/com/intellij/codeInspection/dataFlow/DfaMemoryStateImpl.java index f28f743b041f..e291c92f2bcd 100644 --- a/java/java-impl/src/com/intellij/codeInspection/dataFlow/DfaMemoryStateImpl.java +++ b/java/java-impl/src/com/intellij/codeInspection/dataFlow/DfaMemoryStateImpl.java @@ -257,6 +257,8 @@ public class DfaMemoryStateImpl implements DfaMemoryState { } public void setVarValue(DfaVariableValue var, DfaValue value) { + if (var == value) return; + flushVariable(var); if (value instanceof DfaUnknownValue) return; diff --git a/java/java-tests/testData/inspection/dataFlow/IDEADEV78370/expected.xml b/java/java-tests/testData/inspection/dataFlow/IDEADEV78370/expected.xml new file mode 100644 index 000000000000..ec272abeaa3a --- /dev/null +++ b/java/java-tests/testData/inspection/dataFlow/IDEADEV78370/expected.xml @@ -0,0 +1,3 @@ + + + diff --git a/java/java-tests/testData/inspection/dataFlow/IDEADEV78370/src/NoWarnings.java b/java/java-tests/testData/inspection/dataFlow/IDEADEV78370/src/NoWarnings.java new file mode 100644 index 000000000000..ace2d06e1df9 --- /dev/null +++ b/java/java-tests/testData/inspection/dataFlow/IDEADEV78370/src/NoWarnings.java @@ -0,0 +1,8 @@ +import org.jetbrains.annotations.Nullable; + +public class NoWarnings { + int f(@Nullable String value) { + value = value == null ? "" : value; + return value.hashCode(); + } +} diff --git a/java/java-tests/testSrc/com/intellij/codeInspection/DataFlowInspectionTest.java b/java/java-tests/testSrc/com/intellij/codeInspection/DataFlowInspectionTest.java index c2b1a252839e..dc0428ae3fa8 100644 --- a/java/java-tests/testSrc/com/intellij/codeInspection/DataFlowInspectionTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInspection/DataFlowInspectionTest.java @@ -81,6 +81,7 @@ public class DataFlowInspectionTest extends InspectionTestCase { public void testIDEADEV74518() throws Exception { doTest(); } public void testIDEADEV74518_2() throws Exception { doTest(); } public void testIDEADEV77819() throws Exception { doTest(); } + public void testIDEADEV78370() throws Exception { doTest(); } public void testRegressionByPti() throws Exception { doTest(); } From 61f59b7789e6580d3e3def79beb3f76d83936e8f Mon Sep 17 00:00:00 2001 From: Bas Leijdekkers Date: Fri, 9 Dec 2011 17:15:59 +0100 Subject: [PATCH 09/11] Cleanup cvs root settings --- .../intellij/cvsSupport2/CvsBundle.properties | 17 +++++------ .../actions/GlobalSettingsAction.java | 4 +-- .../ui/ConfigureCvsGlobalSettingsDialog.java | 6 ++-- .../config/ui/Cvs2SettingsEditPanel.java | 4 +-- .../config/ui/CvsConfigurationPanel.java | 30 ++++++++----------- .../ui/CvsConfigurationsListEditor.java | 4 ++- .../config/ui/GlobalCvsSettingsPanel.java | 18 +++++------ .../ext/ui/ExtConnectionDualPanel.java | 11 ++++--- .../ext/ui/ExtConnectionSettingsPanel.java | 10 ++++--- .../ui/LocalConnectionSettingsPanel.java | 5 ++-- .../pserver/ui/PServerSettingsPanel.java | 12 +++++--- .../ssh/ui/SshConnectionSettingsPanel.java | 21 +++++++------ .../cvsSupport2/ui/CvsTabbedWindow.java | 2 +- 13 files changed, 72 insertions(+), 72 deletions(-) diff --git a/plugins/cvs/cvs-core/src/com/intellij/cvsSupport2/CvsBundle.properties b/plugins/cvs/cvs-core/src/com/intellij/cvsSupport2/CvsBundle.properties index c3667c19fe9f..4118ea92db76 100644 --- a/plugins/cvs/cvs-core/src/com/intellij/cvsSupport2/CvsBundle.properties +++ b/plugins/cvs/cvs-core/src/com/intellij/cvsSupport2/CvsBundle.properties @@ -98,9 +98,9 @@ cvs.root.description.ssh.internal.implementation=ssh (internal implementation) cvs.root.description.local=local error.message.cannot.establish.external.connection=Cannot establish external connection error.message.connection.already.open=Connection already open -checkbox.text.use.internal.ssh.implementation=Use &internal ssh implementation -dialog.title.select.path.to.external.rsh=Select Path to External Rsh -dialog.title.select.path.to.ssh.private.key=Select Path to Ssh Private Key +checkbox.text.use.internal.ssh.implementation=Use &internal SSH implementation +dialog.title.select.path.to.external.rsh=Select path to external rsh +dialog.title.select.path.to.ssh.private.key=Select path to SSH private key dialog.title.select.path.to.cvs.client=Select path to CVS executable error.title.invalid.cvs.root=Invalid CVS Root error.message.timeout.error=Timeout error. @@ -115,11 +115,10 @@ error.message.cannot.store.password=Cannot Store Password: {0} error.title.storing.cvs.password=Storing CVS Password prompt.text.enter.password.for.cvs.root=Enter password for {0} prompt.title.enter.password.for.cvs.root=CVS Login -dialog.title.select.path.to.cvs.password.file=Select Path to CVS Password File +dialog.title.select.path.to.cvs.password.file=Select path to CVS password file exception.message.invalid.timeout.value=Invalid timeout value: {0} error.dialog.title.cannot.connect.to.cvs=Cannot Connect -dialog.title.path.to.private.key.file=Path to Private Key File -dialog.description.path.to.private.key.file=Path to private key file +dialog.title.path.to.private.key.file=Path to private key file prompt.text.enter.private.key.file.password.for=Enter private key file password for {0} error.message.path.to.private.key.file.must.not.be.empty=Path to private key file must not be empty dialog.title.ssh.password=SSH Password @@ -299,8 +298,8 @@ label.configure.pserver.seconds=seconds button.configure.ssh.change.password=Change Password checkbox.configure.ssh.use.private.key.file=Use &private key file label.configure.ssh.port=Port: -radio.configure.ssh.ssh.version.force.ssh2=Force ssh2 -radio.configure.ssh.ssh.version.force.ssh1=Force ssh1 +radio.configure.ssh.ssh.version.force.ssh2=Force SSH2 +radio.configure.ssh.ssh.version.force.ssh1=Force SSH1 radio.configure.ssh.ssh.version.allow.both=Allow both checkbox.store.scrambled.password.to.the.config=Store scrambled password to the config dummy.label.xxx=XXX @@ -347,7 +346,7 @@ border.title.update.options.other.settings=Other Settings border.title.update.options.updating.group=Updating border.title.ext.protocol.settings=Ext Protocol Settings border.title.local.protocol.settings=Local Protocol Settings -border.title.configure.ssh.private.key.file=Private Key File +border.title.configure.ssh.private.key.file=Internal SSH Settings border.title.configure.ssh.ssh.version=SSH version border.title.configure.proxy.proxy.settings=Proxy Settings border.title.branch.merging=Branch Merging diff --git a/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/actions/GlobalSettingsAction.java b/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/actions/GlobalSettingsAction.java index daff46d03ae5..dc22ee746412 100644 --- a/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/actions/GlobalSettingsAction.java +++ b/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/actions/GlobalSettingsAction.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2011 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. @@ -23,6 +23,6 @@ import com.intellij.openapi.actionSystem.AnActionEvent; */ public class GlobalSettingsAction extends CvsGlobalAction{ public void actionPerformed(AnActionEvent e) { - new ConfigureCvsGlobalSettingsDialog().show(); + new ConfigureCvsGlobalSettingsDialog(e.getProject()).show(); } } diff --git a/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/config/ui/ConfigureCvsGlobalSettingsDialog.java b/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/config/ui/ConfigureCvsGlobalSettingsDialog.java index c10b7eb1b558..e096cd15cfec 100644 --- a/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/config/ui/ConfigureCvsGlobalSettingsDialog.java +++ b/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/config/ui/ConfigureCvsGlobalSettingsDialog.java @@ -18,6 +18,7 @@ package com.intellij.cvsSupport2.config.ui; import com.intellij.CvsBundle; import com.intellij.cvsSupport2.config.CvsApplicationLevelConfiguration; import com.intellij.openapi.help.HelpManager; +import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.DialogWrapper; import com.intellij.openapi.ui.InputException; @@ -27,11 +28,12 @@ import javax.swing.*; * author: lesya */ public class ConfigureCvsGlobalSettingsDialog extends DialogWrapper { - private final GlobalCvsSettingsPanel myGlobalCvsSettingsPanel = new GlobalCvsSettingsPanel(); + private final GlobalCvsSettingsPanel myGlobalCvsSettingsPanel; - public ConfigureCvsGlobalSettingsDialog() { + public ConfigureCvsGlobalSettingsDialog(Project project) { super(true); setTitle(CvsBundle.message("dialog.title.global.cvs.settings")); + myGlobalCvsSettingsPanel = new GlobalCvsSettingsPanel(project); myGlobalCvsSettingsPanel.updateFrom(CvsApplicationLevelConfiguration.getInstance()); init(); } diff --git a/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/config/ui/Cvs2SettingsEditPanel.java b/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/config/ui/Cvs2SettingsEditPanel.java index bdd8a1e53b60..7f55cdc024c8 100644 --- a/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/config/ui/Cvs2SettingsEditPanel.java +++ b/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/config/ui/Cvs2SettingsEditPanel.java @@ -89,8 +89,8 @@ public class Cvs2SettingsEditPanel { myCvsRootConfigurationPanel.add(myCvsRootConfigurationPanelView.getPanel(), BorderLayout.CENTER); myConnectionSettingsPanel.setLayout(new CardLayout()); - myExtConnectionSettingsEditor = new ExtConnectionDualPanel(); - mySshConnectionSettingsEditor = new SshConnectionSettingsPanel(); + myExtConnectionSettingsEditor = new ExtConnectionDualPanel(project); + mySshConnectionSettingsEditor = new SshConnectionSettingsPanel(project); myLocalConnectionSettingsPanel = new LocalConnectionSettingsPanel(project); myConnectionSettingsPanel.add(myExtConnectionSettingsEditor.getPanel(), CvsMethod.EXT_METHOD.getDisplayName()); myConnectionSettingsPanel.add(new JPanel(), CvsMethod.PSERVER_METHOD.getDisplayName()); diff --git a/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/config/ui/CvsConfigurationPanel.java b/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/config/ui/CvsConfigurationPanel.java index 4dde0552544c..3b473e7048c2 100644 --- a/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/config/ui/CvsConfigurationPanel.java +++ b/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/config/ui/CvsConfigurationPanel.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2011 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. @@ -41,7 +41,6 @@ public class CvsConfigurationPanel { private JPanel myPanel; - private JCheckBox myMakeNewFilesReadOnly; private JComboBox myDefaultTextFileKeywordSubstitution; private JCheckBox myShowOutput; @@ -54,7 +53,7 @@ public class CvsConfigurationPanel { private JRadioButton myShowDialogOnMergedWithConflict; private final JRadioButton[] myOnFileMergedWithConflictGroup; - public CvsConfigurationPanel(Project project) { + public CvsConfigurationPanel(final Project project) { myOnFileMergedWithConflictGroup = new JRadioButton[]{ myShowDialogOnMergedWithConflict, myGetLatestVersionOnMergedWithConflict, @@ -63,20 +62,20 @@ public class CvsConfigurationPanel { myConfigureGlobalButton.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e) { - ConfigureCvsGlobalSettingsDialog dialog = new ConfigureCvsGlobalSettingsDialog(); + final ConfigureCvsGlobalSettingsDialog dialog = new ConfigureCvsGlobalSettingsDialog(project); dialog.show(); } }); - } - public static void addBrowseHandler(final TextFieldWithBrowseButton field, final String title) { - FileChooserDescriptor descriptor = FileChooserDescriptorFactory.createSingleFileNoJarsDescriptor(); - descriptor.setTitle(title); - field.addBrowseFolderListener(null, null, null, descriptor, new TextComponentAccessor() { + public static void addBrowseHandler(Project project, final TextFieldWithBrowseButton field, final String title) { + final FileChooserDescriptor descriptor = FileChooserDescriptorFactory.createSingleFileNoJarsDescriptor(); + field.addBrowseFolderListener(title, null, project, descriptor, new TextComponentAccessor() { public String getText(JTextField textField) { String text = textField.getText(); - if (text.length() > 0) text = CvsApplicationLevelConfiguration.convertToIOFilePath(text); + if (text.length() > 0) { + text = CvsApplicationLevelConfiguration.convertToIOFilePath(text); + } return text; } @@ -86,14 +85,10 @@ public class CvsConfigurationPanel { }); } - public void updateFrom(CvsConfiguration config, - CvsApplicationLevelConfiguration appLevelConfiguration) { + public void updateFrom(CvsConfiguration config, CvsApplicationLevelConfiguration appLevelConfiguration) { myConfigurations = new ArrayList(appLevelConfiguration.CONFIGURATIONS); - - myShowOutput.setSelected(config.SHOW_OUTPUT); myMakeNewFilesReadOnly.setSelected(config.MAKE_NEW_FILES_READONLY); - myOnFileMergedWithConflictGroup[config.SHOW_CORRUPTED_PROJECT_FILES].setSelected(true); myDefaultTextFileKeywordSubstitution.removeAllItems(); @@ -106,7 +101,7 @@ public class CvsConfigurationPanel { private static int getSelected(JRadioButton[] group) { for (int i = 0; i < group.length; i++) { - JRadioButton jRadioButton = group[i]; + final JRadioButton jRadioButton = group[i]; if (jRadioButton.isSelected()) return i; } LOG.assertTrue(false); @@ -124,8 +119,7 @@ public class CvsConfigurationPanel { } private String selectedSubstitution() { - return ((KeywordSubstitutionWrapper)myDefaultTextFileKeywordSubstitution.getSelectedItem()).getSubstitution() - .toString(); + return ((KeywordSubstitutionWrapper)myDefaultTextFileKeywordSubstitution.getSelectedItem()).getSubstitution().toString(); } public boolean equalsTo(CvsConfiguration config, diff --git a/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/config/ui/CvsConfigurationsListEditor.java b/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/config/ui/CvsConfigurationsListEditor.java index 4d7f480e8850..a919ec6fe195 100644 --- a/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/config/ui/CvsConfigurationsListEditor.java +++ b/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/config/ui/CvsConfigurationsListEditor.java @@ -46,6 +46,7 @@ import java.util.List; * author: lesya */ public class CvsConfigurationsListEditor extends DialogWrapper implements DataProvider{ + private final Project myProject; private final JList myList = new JBList(); private final DefaultListModel myModel = new DefaultListModel(); private CvsRootConfiguration mySelection; @@ -59,6 +60,7 @@ public class CvsConfigurationsListEditor extends DialogWrapper implements DataPr public CvsConfigurationsListEditor(List configs, Project project, boolean readOnly) { super(true); + myProject = project; myCvs2SettingsEditPanel = new Cvs2SettingsEditPanel(project, readOnly); setTitle(CvsBundle.message("operation.name.edit.configurations")); myList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); @@ -106,7 +108,7 @@ public class CvsConfigurationsListEditor extends DialogWrapper implements DataPr final AbstractAction globalSettingsAction = new AbstractAction(CvsBundle.message("button.text.global.settings")) { @Override public void actionPerformed(ActionEvent e) { - new ConfigureCvsGlobalSettingsDialog().show(); + new ConfigureCvsGlobalSettingsDialog(myProject).show(); } }; return new Action[]{globalSettingsAction}; diff --git a/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/config/ui/GlobalCvsSettingsPanel.java b/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/config/ui/GlobalCvsSettingsPanel.java index 7ef1ce72fddb..93654b31f358 100644 --- a/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/config/ui/GlobalCvsSettingsPanel.java +++ b/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/config/ui/GlobalCvsSettingsPanel.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2011 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. @@ -15,11 +15,12 @@ */ package com.intellij.cvsSupport2.config.ui; +import com.intellij.cvsSupport2.application.CvsEntriesManager; import com.intellij.cvsSupport2.config.CvsApplicationLevelConfiguration; import com.intellij.cvsSupport2.connections.pserver.ui.PServerSettingsPanel; -import com.intellij.cvsSupport2.application.CvsEntriesManager; -import com.intellij.openapi.vfs.CharsetToolkit; +import com.intellij.openapi.project.Project; import com.intellij.openapi.util.Comparing; +import com.intellij.openapi.vfs.CharsetToolkit; import javax.swing.*; import java.awt.*; @@ -29,7 +30,7 @@ import java.nio.charset.Charset; * author: lesya */ public class GlobalCvsSettingsPanel { - private final PServerSettingsPanel myPServerSettingsPanel = new PServerSettingsPanel(); + private final PServerSettingsPanel myPServerSettingsPanel; private JComponent myPanel; private JPanel myPServerPanel; private JCheckBox myUseGZIPCompression; @@ -37,17 +38,16 @@ public class GlobalCvsSettingsPanel { private JCheckBox myLogOutput; private JCheckBox mySendEnvironment; - public GlobalCvsSettingsPanel() { + public GlobalCvsSettingsPanel(Project project) { myPServerPanel.setLayout(new BorderLayout()); + myPServerSettingsPanel = new PServerSettingsPanel(project); myPServerPanel.add(myPServerSettingsPanel.getPanel(), BorderLayout.CENTER); - Charset[] availableCharsets = CharsetToolkit.getAvailableCharsets(); - myCharset.addItem(CvsApplicationLevelConfiguration.DEFAULT); + final Charset[] availableCharsets = CharsetToolkit.getAvailableCharsets(); for (Charset charset : availableCharsets) { myCharset.addItem(charset.name()); } - } public void updateFrom(CvsApplicationLevelConfiguration config) { @@ -60,7 +60,7 @@ public class GlobalCvsSettingsPanel { public void saveTo(CvsApplicationLevelConfiguration config) { myPServerSettingsPanel.saveTo(config); - String oldEncoding = config.ENCODING; + final String oldEncoding = config.ENCODING; config.ENCODING = myCharset.getSelectedItem().toString(); if (!Comparing.equal(oldEncoding, config.ENCODING)) { CvsEntriesManager.getInstance().encodingChanged(); diff --git a/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/connections/ext/ui/ExtConnectionDualPanel.java b/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/connections/ext/ui/ExtConnectionDualPanel.java index b43582167189..aa53dec5e96a 100644 --- a/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/connections/ext/ui/ExtConnectionDualPanel.java +++ b/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/connections/ext/ui/ExtConnectionDualPanel.java @@ -19,6 +19,7 @@ import com.intellij.CvsBundle; import com.intellij.cvsSupport2.config.ExtConfiguration; import com.intellij.cvsSupport2.config.SshSettings; import com.intellij.cvsSupport2.connections.ssh.ui.SshConnectionSettingsPanel; +import com.intellij.openapi.project.Project; import org.jetbrains.annotations.NonNls; import javax.swing.*; @@ -38,14 +39,13 @@ public class ExtConnectionDualPanel { @NonNls private static final String EXT = "EXT"; @NonNls private static final String SSH = "SSH"; - public ExtConnectionDualPanel() { - myExtSettingsPanel = new ExtConnectionSettingsPanel(); - mySshSettingsPanel = new SshConnectionSettingsPanel(); + public ExtConnectionDualPanel(Project project) { + myExtSettingsPanel = new ExtConnectionSettingsPanel(project); + mySshSettingsPanel = new SshConnectionSettingsPanel(project); myDualPanel.add(myExtSettingsPanel.getPanel(), EXT); myDualPanel.add(mySshSettingsPanel.getPanel(), SSH); - myPanel.add(myUseInternalImplementationCheckBox, BorderLayout.NORTH); myPanel.add(myDualPanel, BorderLayout.CENTER); @@ -57,8 +57,7 @@ public class ExtConnectionDualPanel { } private void updatePage() { - CardLayout cardLayout = ((CardLayout)myDualPanel.getLayout()); - + final CardLayout cardLayout = ((CardLayout)myDualPanel.getLayout()); if (myUseInternalImplementationCheckBox.isSelected()){ cardLayout.show(myDualPanel, SSH); } else { diff --git a/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/connections/ext/ui/ExtConnectionSettingsPanel.java b/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/connections/ext/ui/ExtConnectionSettingsPanel.java index a32b9c619297..fb588dd640a6 100644 --- a/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/connections/ext/ui/ExtConnectionSettingsPanel.java +++ b/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/connections/ext/ui/ExtConnectionSettingsPanel.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2011 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. @@ -15,8 +15,10 @@ */ package com.intellij.cvsSupport2.connections.ext.ui; +import com.intellij.CvsBundle; import com.intellij.cvsSupport2.config.ExtConfiguration; import com.intellij.cvsSupport2.config.ui.CvsConfigurationPanel; +import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.TextFieldWithBrowseButton; import com.intellij.openapi.util.Comparing; @@ -34,9 +36,9 @@ public class ExtConnectionSettingsPanel { private JLabel myAdditionalParametersLabel; private JLabel myPathToPPKLabel; - public ExtConnectionSettingsPanel() { - CvsConfigurationPanel.addBrowseHandler(myPathToRsh, com.intellij.CvsBundle.message("dialog.title.select.path.to.external.rsh")); - CvsConfigurationPanel.addBrowseHandler(myPathToPrivateKeyFile, com.intellij.CvsBundle.message("dialog.title.select.path.to.ssh.private.key")); + public ExtConnectionSettingsPanel(Project project) { + CvsConfigurationPanel.addBrowseHandler(project, myPathToRsh, CvsBundle.message("dialog.title.select.path.to.external.rsh")); + CvsConfigurationPanel.addBrowseHandler(project, myPathToPrivateKeyFile, CvsBundle.message("dialog.title.select.path.to.ssh.private.key")); myRshLabel.setLabelFor(myPathToRsh.getTextField()); myAdditionalParametersLabel.setLabelFor(myAdditionalParameters); myPathToPPKLabel.setLabelFor(myPathToPrivateKeyFile.getTextField()); diff --git a/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/connections/local/ui/LocalConnectionSettingsPanel.java b/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/connections/local/ui/LocalConnectionSettingsPanel.java index 81ab9c2fc40b..46012b088816 100644 --- a/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/connections/local/ui/LocalConnectionSettingsPanel.java +++ b/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/connections/local/ui/LocalConnectionSettingsPanel.java @@ -17,7 +17,7 @@ package com.intellij.cvsSupport2.connections.local.ui; import com.intellij.CvsBundle; import com.intellij.cvsSupport2.config.LocalSettings; -import com.intellij.openapi.fileChooser.FileChooserDescriptorFactory; +import com.intellij.cvsSupport2.config.ui.CvsConfigurationPanel; import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.TextFieldWithBrowseButton; @@ -32,8 +32,7 @@ public class LocalConnectionSettingsPanel { private JPanel myPanel; public LocalConnectionSettingsPanel(Project project) { - myPathToCvsClient.addBrowseFolderListener(CvsBundle.message("dialog.title.select.path.to.cvs.client"), null, project, - FileChooserDescriptorFactory.createSingleFileNoJarsDescriptor()); + CvsConfigurationPanel.addBrowseHandler(project, myPathToCvsClient, CvsBundle.message("dialog.title.select.path.to.cvs.client")); } public void updateFrom(LocalSettings localConfiguration) { diff --git a/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/connections/pserver/ui/PServerSettingsPanel.java b/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/connections/pserver/ui/PServerSettingsPanel.java index c5e1ee0fa2bf..fdc57c3d9bfa 100644 --- a/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/connections/pserver/ui/PServerSettingsPanel.java +++ b/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/connections/pserver/ui/PServerSettingsPanel.java @@ -18,6 +18,7 @@ package com.intellij.cvsSupport2.connections.pserver.ui; import com.intellij.CvsBundle; import com.intellij.cvsSupport2.config.CvsApplicationLevelConfiguration; import com.intellij.cvsSupport2.config.ui.CvsConfigurationPanel; +import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.InputException; import com.intellij.openapi.ui.Messages; import com.intellij.openapi.ui.TextFieldWithBrowseButton; @@ -36,8 +37,9 @@ public class PServerSettingsPanel { private JLabel myConnectionTimeoutLabel; private JLabel myPasswordFileLabel; - public PServerSettingsPanel() { - CvsConfigurationPanel.addBrowseHandler(myPathToPasswordFile, CvsBundle.message("dialog.title.select.path.to.cvs.password.file")); + public PServerSettingsPanel(Project project) { + CvsConfigurationPanel.addBrowseHandler(project, myPathToPasswordFile, + CvsBundle.message("dialog.title.select.path.to.cvs.password.file")); myConnectionTimeoutLabel.setLabelFor(myTimeout); myPasswordFileLabel.setLabelFor(myPathToPasswordFile.getTextField()); } @@ -71,8 +73,10 @@ public class PServerSettingsPanel { } config.setPathToPasswordFile(pathToPasswordFile); try { - int timeout = Integer.parseInt(myTimeout.getText()); - if (timeout < 0) throwInvalidTimeoutException(); + final int timeout = Integer.parseInt(myTimeout.getText()); + if (timeout < 0) { + throwInvalidTimeoutException(); + } config.TIMEOUT = timeout; } catch (NumberFormatException ex) { diff --git a/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/connections/ssh/ui/SshConnectionSettingsPanel.java b/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/connections/ssh/ui/SshConnectionSettingsPanel.java index 198fd4d9ce66..fd49751db614 100644 --- a/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/connections/ssh/ui/SshConnectionSettingsPanel.java +++ b/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/connections/ssh/ui/SshConnectionSettingsPanel.java @@ -17,7 +17,8 @@ package com.intellij.cvsSupport2.connections.ssh.ui; import com.intellij.CvsBundle; import com.intellij.cvsSupport2.config.SshSettings; -import com.intellij.openapi.fileChooser.FileChooserDescriptorFactory; +import com.intellij.cvsSupport2.config.ui.CvsConfigurationPanel; +import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.InputException; import com.intellij.openapi.ui.TextFieldWithBrowseButton; @@ -33,17 +34,14 @@ public class SshConnectionSettingsPanel { private JCheckBox myUsePrivateKeyFile; private JPanel myPanel; - public SshConnectionSettingsPanel() { - myPathToPrivateKeyFile.addBrowseFolderListener(CvsBundle.message("dialog.title.path.to.private.key.file"), - CvsBundle.message("dialog.description.path.to.private.key.file"), - null, FileChooserDescriptorFactory.createSingleFileNoJarsDescriptor()); - final ActionListener actionListener = new ActionListener() { + public SshConnectionSettingsPanel(Project project) { + CvsConfigurationPanel.addBrowseHandler(project, myPathToPrivateKeyFile, CvsBundle.message("dialog.title.path.to.private.key.file")); + myUsePrivateKeyFile.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { setPathToPPKEnabled(); } - }; - myUsePrivateKeyFile.addActionListener(actionListener); + }); } public JPanel getPanel() { @@ -77,8 +75,9 @@ public class SshConnectionSettingsPanel { } public boolean equalsTo(SshSettings ssh_configuration) { - if (ssh_configuration.USE_PPK != myUsePrivateKeyFile.isSelected()) return false; - if (!ssh_configuration.PATH_TO_PPK.equals(myPathToPrivateKeyFile.getText().trim())) return false; - return true; + if (ssh_configuration.USE_PPK != myUsePrivateKeyFile.isSelected()) { + return false; + } + return ssh_configuration.PATH_TO_PPK.equals(myPathToPrivateKeyFile.getText().trim()); } } diff --git a/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/ui/CvsTabbedWindow.java b/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/ui/CvsTabbedWindow.java index 3c4212d1b537..9e3f48ba014e 100644 --- a/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/ui/CvsTabbedWindow.java +++ b/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/ui/CvsTabbedWindow.java @@ -225,7 +225,7 @@ public class CvsTabbedWindow { } public void actionPerformed(AnActionEvent e) { - new ConfigureCvsGlobalSettingsDialog().show(); + new ConfigureCvsGlobalSettingsDialog(e.getProject()).show(); } } From e73a6c3ec42d775b885c72a486bdbb414eb6869b Mon Sep 17 00:00:00 2001 From: anna Date: Fri, 9 Dec 2011 17:38:22 +0100 Subject: [PATCH 10/11] plugins: strip plugin url from plugin.xml etc; hide bundle when no space (IDEA-77192 ) --- .../plugins/InstalledPluginsTableModel.java | 26 ++++++++----------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/platform/platform-impl/src/com/intellij/ide/plugins/InstalledPluginsTableModel.java b/platform/platform-impl/src/com/intellij/ide/plugins/InstalledPluginsTableModel.java index 4b57faa754d6..851644840a94 100644 --- a/platform/platform-impl/src/com/intellij/ide/plugins/InstalledPluginsTableModel.java +++ b/platform/platform-impl/src/com/intellij/ide/plugins/InstalledPluginsTableModel.java @@ -29,6 +29,7 @@ import com.intellij.openapi.util.IconLoader; import com.intellij.openapi.util.JDOMExternalizableStringList; import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.vcs.FileStatus; +import com.intellij.openapi.vfs.VfsUtil; import com.intellij.ui.BooleanTableCellEditor; import com.intellij.ui.BooleanTableCellRenderer; import com.intellij.util.Function; @@ -482,7 +483,7 @@ public class InstalledPluginsTableModel extends PluginTableModel { private JLabel myNameLabel = new JLabel(); private JLabel myBundledLabel = new JLabel(); - private JPanel myPanel = new JPanel(new GridBagLayout()); + private JPanel myPanel = new JPanel(new BorderLayout()); private final IdeaPluginDescriptor myPluginDescriptor; @@ -493,19 +494,9 @@ public class InstalledPluginsTableModel extends PluginTableModel { myBundledLabel.setFont(UIUtil.getLabelFont(UIUtil.FontSize.SMALL)); myPanel.setBorder(BorderFactory.createEmptyBorder(1, 0, 1, 1)); - final GridBagConstraints gn = - new GridBagConstraints(GridBagConstraints.RELATIVE, 0, 1, 1, 0, 0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, - new Insets(0, 0, 0, 0), 0, 0); - myPanel.add(myNameLabel, gn); - gn.insets.left = 5; - gn.anchor = GridBagConstraints.NORTHWEST; - gn.weightx = 1; - gn.fill = GridBagConstraints.HORIZONTAL; - myPanel.add(Box.createHorizontalBox(), gn); - gn.fill = GridBagConstraints.NONE; - gn.weightx = 0; - gn.anchor = GridBagConstraints.EAST; - myPanel.add(myBundledLabel, gn); + myNameLabel.setOpaque(true); + myPanel.add(myNameLabel, BorderLayout.WEST); + myPanel.add(myBundledLabel, BorderLayout.EAST); } @Override @@ -520,7 +511,12 @@ public class InstalledPluginsTableModel extends PluginTableModel { } else { final String host = myPlugin2host.get(idString); if (host != null) { - myBundledLabel.setText("From: " + host); + String presentableUrl = VfsUtil.urlToPath(host); + final int idx = presentableUrl.indexOf('/'); + if (idx > -1) { + presentableUrl = presentableUrl.substring(0, idx); + } + myBundledLabel.setText("From " + presentableUrl); } else { if (PluginManagerUISettings.getInstance().myInstalledPlugins.contains(idString)) { myBundledLabel.setText("From repository"); From 525e680af256a673261d0bd202fb4505611e726e Mon Sep 17 00:00:00 2001 From: Maxim Shafirov Date: Fri, 9 Dec 2011 20:46:37 +0400 Subject: [PATCH 11/11] [r=kirillk] IDEA-61534 Split Editor retains scroll position --- .../openapi/fileEditor/impl/EditorWindow.java | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/EditorWindow.java b/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/EditorWindow.java index f68ddb0b21fc..f45103218bae 100644 --- a/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/EditorWindow.java +++ b/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/EditorWindow.java @@ -23,6 +23,7 @@ import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.editor.Editor; import com.intellij.openapi.editor.ScrollType; +import com.intellij.openapi.editor.ScrollingModel; import com.intellij.openapi.fileEditor.FileEditor; import com.intellij.openapi.fileEditor.FileEditorManagerListener; import com.intellij.openapi.fileEditor.TextEditor; @@ -702,7 +703,9 @@ public class EditorWindow { if (offset <= 0) { return; } - + + final int scrollOffset = editorFrom.getScrollingModel().getVerticalScrollOffset(); + for (FileEditor fileEditor : toSync) { if (!(fileEditor instanceof TextEditor)) { continue; @@ -710,7 +713,16 @@ public class EditorWindow { final Editor editor = ((TextEditor)fileEditor).getEditor(); if (editorFrom.getDocument() == editor.getDocument()) { editor.getCaretModel().moveToOffset(offset); - editor.getScrollingModel().scrollToCaret(ScrollType.CENTER); + final ScrollingModel scrollingModel = editor.getScrollingModel(); + scrollingModel.scrollVertically(scrollOffset); + + SwingUtilities.invokeLater(new Runnable() { + public void run() { + if (!editor.isDisposed()) { + scrollingModel.scrollToCaret(ScrollType.MAKE_VISIBLE); + } + } + }); } } }