mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Merge remote-tracking branch 'origin/master'
This commit is contained in:
Binary file not shown.
@@ -1563,7 +1563,6 @@ com/intellij/openapi/project/impl/ProjectManagerImpl$1.class:/lib/idea.jar
|
||||
com/intellij/openapi/project/impl/ProjectManagerImpl$2.class:/lib/idea.jar
|
||||
com/intellij/openapi/project/impl/ProjectManagerImpl$6.class:/lib/idea.jar
|
||||
idea/IdeaApplicationInfo.xml:/lib/resources.jar
|
||||
idea/PropertiesComponent.xml:/lib/resources.jar
|
||||
com/intellij/openapi/fileTypes/impl/FileTypeAssocTable.class:/lib/idea.jar
|
||||
com/intellij/openapi/fileTypes/impl/FileTypeManagerImpl$2.class:/lib/idea.jar
|
||||
com/intellij/ide/highlighter/custom/impl/ReadFileType.class:/lib/idea.jar
|
||||
|
||||
@@ -25,12 +25,10 @@ import com.intellij.debugger.impl.EditorTextProvider;
|
||||
import com.intellij.debugger.ui.impl.watch.NodeManagerImpl;
|
||||
import com.intellij.debugger.ui.impl.watch.WatchItemDescriptor;
|
||||
import com.intellij.openapi.editor.Document;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.openapi.util.Ref;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.psi.PsiDocumentManager;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiFile;
|
||||
@@ -39,7 +37,6 @@ import com.intellij.xdebugger.XSourcePosition;
|
||||
import com.intellij.xdebugger.evaluation.EvaluationMode;
|
||||
import com.intellij.xdebugger.evaluation.XDebuggerEvaluator;
|
||||
import com.intellij.xdebugger.impl.breakpoints.XExpressionImpl;
|
||||
import com.intellij.xdebugger.impl.ui.XDebuggerEditorBase;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -133,14 +130,11 @@ public class JavaDebuggerEvaluator extends XDebuggerEvaluator {
|
||||
}
|
||||
|
||||
@Override
|
||||
public XExpression getEditorExpression(@NotNull Editor editor, @Nullable PsiFile psiFile) {
|
||||
String text = editor.getSelectionModel().getSelectedText();
|
||||
if (psiFile == null || StringUtil.isEmpty(text)) {
|
||||
return super.getEditorExpression(editor, psiFile);
|
||||
public EvaluationMode getEvaluationMode(@NotNull String text, int startOffset, int endOffset, @Nullable PsiFile psiFile) {
|
||||
if (psiFile != null) {
|
||||
PsiElement[] range = CodeInsightUtil.findStatementsInRange(psiFile, startOffset, endOffset);
|
||||
return range.length > 1 ? EvaluationMode.CODE_FRAGMENT : EvaluationMode.EXPRESSION;
|
||||
}
|
||||
PsiElement[] range = CodeInsightUtil.findStatementsInRange(psiFile, editor.getSelectionModel().getSelectionStart(),
|
||||
editor.getSelectionModel().getSelectionEnd());
|
||||
return new XExpressionImpl(formatTextForEvaluation(text), XDebuggerEditorBase.getFileTypeLanguage(psiFile.getFileType()), null,
|
||||
range.length > 1 ? EvaluationMode.CODE_FRAGMENT : EvaluationMode.EXPRESSION);
|
||||
return super.getEvaluationMode(text, startOffset, endOffset, null);
|
||||
}
|
||||
}
|
||||
|
||||
+4
-4
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
* Copyright 2000-2014 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.
|
||||
@@ -24,13 +24,13 @@ import org.jetbrains.annotations.NotNull;
|
||||
@State(
|
||||
name = "RecentProjectsManager",
|
||||
storages = {
|
||||
@Storage(file = StoragePathMacros.APP_CONFIG + "/other.xml", roamingType = RoamingType.DISABLED),
|
||||
@Storage(file = StoragePathMacros.APP_CONFIG + "/other.xml"),
|
||||
@Storage(file = StoragePathMacros.APP_CONFIG + "/recentProjects.xml", roamingType = RoamingType.DISABLED)
|
||||
},
|
||||
storageChooser = LastStorageChooserForWrite.class
|
||||
)
|
||||
public class RecentProjectsManager extends RecentProjectsManagerBase {
|
||||
public RecentProjectsManager(MessageBus messageBus) {
|
||||
public class RecentProjectsManagerImpl extends RecentProjectsManagerBase {
|
||||
public RecentProjectsManagerImpl(MessageBus messageBus) {
|
||||
super(messageBus);
|
||||
}
|
||||
|
||||
+1
-1
@@ -352,7 +352,7 @@ public class ProjectStructureConfigurable extends BaseConfigurable implements Se
|
||||
public void reset() {
|
||||
// need this to ensure VFS operations will not block because of storage flushing
|
||||
// and other maintenance IO tasks run in background
|
||||
HeavyProcessLatch.INSTANCE.processStarted();
|
||||
HeavyProcessLatch.INSTANCE.processStarted("Resetting Project Structure");
|
||||
|
||||
try {
|
||||
myWasUiDisposed = false;
|
||||
|
||||
+50
-1
@@ -15,11 +15,16 @@
|
||||
*/
|
||||
package com.intellij.codeInspection.unusedSymbol;
|
||||
|
||||
import com.intellij.codeInsight.daemon.GroupNames;
|
||||
import com.intellij.codeInsight.daemon.impl.HighlightInfoType;
|
||||
import com.intellij.codeInspection.BaseJavaLocalInspectionTool;
|
||||
import com.intellij.codeInspection.deadCode.UnusedDeclarationInspectionBase;
|
||||
import com.intellij.codeInspection.ex.PairedUnfairLocalInspectionTool;
|
||||
import org.intellij.lang.annotations.Pattern;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class UnusedSymbolLocalInspectionBase extends BaseJavaLocalInspectionTool {
|
||||
public class UnusedSymbolLocalInspectionBase extends BaseJavaLocalInspectionTool implements PairedUnfairLocalInspectionTool {
|
||||
@NonNls public static final String SHORT_NAME = HighlightInfoType.UNUSED_SYMBOL_SHORT_NAME;
|
||||
@NonNls public static final String DISPLAY_NAME = HighlightInfoType.UNUSED_SYMBOL_DISPLAY_NAME;
|
||||
@NonNls public static final String UNUSED_PARAMETERS_SHORT_NAME = "UnusedParameters";
|
||||
@@ -30,4 +35,48 @@ public class UnusedSymbolLocalInspectionBase extends BaseJavaLocalInspectionTool
|
||||
public boolean CLASS = true;
|
||||
public boolean PARAMETER = true;
|
||||
public boolean REPORT_PARAMETER_FOR_PUBLIC_METHODS = true;
|
||||
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public String getGroupDisplayName() {
|
||||
return GroupNames.DECLARATION_REDUNDANCY;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public String getDisplayName() {
|
||||
return DISPLAY_NAME;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
@NonNls
|
||||
public String getShortName() {
|
||||
return SHORT_NAME;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Pattern(VALID_ID_PATTERN)
|
||||
@NotNull
|
||||
@NonNls
|
||||
public String getID() {
|
||||
return "unused";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAlternativeID() {
|
||||
return UnusedDeclarationInspectionBase.ALTERNATIVE_ID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabledByDefault() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getInspectionForBatchShortName() {
|
||||
return UnusedDeclarationInspectionBase.SHORT_NAME;
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -40,7 +40,7 @@ public class JavaCodeStyleSettingsProvider extends CodeStyleSettingsProvider {
|
||||
|
||||
@Override
|
||||
public DisplayPriority getPriority() {
|
||||
return PlatformUtils.isIdeaUltimate() ? DisplayPriority.KEY_LANGUAGE_SETTINGS : DisplayPriority.LANGUAGE_SETTINGS;
|
||||
return PlatformUtils.isIntelliJ() ? DisplayPriority.KEY_LANGUAGE_SETTINGS : DisplayPriority.LANGUAGE_SETTINGS;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+1
-50
@@ -16,12 +16,6 @@
|
||||
|
||||
package com.intellij.codeInspection.unusedSymbol;
|
||||
|
||||
import com.intellij.codeInsight.daemon.GroupNames;
|
||||
import com.intellij.codeInspection.deadCode.UnusedDeclarationInspection;
|
||||
import com.intellij.codeInspection.ex.PairedUnfairLocalInspectionTool;
|
||||
import org.intellij.lang.annotations.Pattern;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
@@ -32,7 +26,7 @@ import java.awt.event.ActionListener;
|
||||
* User: anna
|
||||
* Date: 17-Feb-2006
|
||||
*/
|
||||
public class UnusedSymbolLocalInspection extends UnusedSymbolLocalInspectionBase implements PairedUnfairLocalInspectionTool {
|
||||
public class UnusedSymbolLocalInspection extends UnusedSymbolLocalInspectionBase {
|
||||
|
||||
/**
|
||||
* use {@link com.intellij.codeInspection.deadCode.UnusedDeclarationInspection} instead
|
||||
@@ -41,49 +35,6 @@ public class UnusedSymbolLocalInspection extends UnusedSymbolLocalInspectionBase
|
||||
public UnusedSymbolLocalInspection() {
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public String getGroupDisplayName() {
|
||||
return GroupNames.DECLARATION_REDUNDANCY;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public String getDisplayName() {
|
||||
return DISPLAY_NAME;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
@NonNls
|
||||
public String getShortName() {
|
||||
return SHORT_NAME;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Pattern(VALID_ID_PATTERN)
|
||||
@NotNull
|
||||
@NonNls
|
||||
public String getID() {
|
||||
return "unused";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAlternativeID() {
|
||||
return UnusedDeclarationInspection.ALTERNATIVE_ID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabledByDefault() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getInspectionForBatchShortName() {
|
||||
return UnusedDeclarationInspection.SHORT_NAME;
|
||||
}
|
||||
|
||||
public class OptionsPanel {
|
||||
private JCheckBox myCheckLocalVariablesCheckBox;
|
||||
private JCheckBox myCheckClassesCheckBox;
|
||||
|
||||
@@ -184,7 +184,7 @@ public class JavaLanguageCodeStyleSettingsProvider extends LanguageCodeStyleSett
|
||||
|
||||
@Override
|
||||
public DisplayPriority getDisplayPriority() {
|
||||
if (PlatformUtils.isIdeaUltimate()) return DisplayPriority.KEY_LANGUAGE_SETTINGS;
|
||||
if (PlatformUtils.isIntelliJ()) return DisplayPriority.KEY_LANGUAGE_SETTINGS;
|
||||
return DisplayPriority.LANGUAGE_SETTINGS;
|
||||
}
|
||||
|
||||
|
||||
@@ -16,13 +16,8 @@
|
||||
package com.intellij.psi;
|
||||
|
||||
import com.intellij.openapi.application.ex.PathManagerEx;
|
||||
import com.intellij.openapi.command.CommandProcessor;
|
||||
import com.intellij.openapi.command.WriteCommandAction;
|
||||
import com.intellij.psi.codeStyle.JavaCodeStyleManager;
|
||||
import com.intellij.psi.impl.source.PostprocessReformattingAspect;
|
||||
import com.intellij.testFramework.PsiTestCase;
|
||||
|
||||
public class OptimizeImportsTest extends PsiTestCase{
|
||||
public class OptimizeImportsTest extends OptimizeImportsTestCase {
|
||||
private static final String BASE_PATH = PathManagerEx.getTestDataPath() + "/psi/optimizeImports";
|
||||
|
||||
@Override
|
||||
@@ -44,37 +39,6 @@ public class OptimizeImportsTest extends PsiTestCase{
|
||||
public void testNewImportListIsEmptyAndJavaDocWithInvalidCodePreserved() throws Exception { doTest(); }
|
||||
|
||||
private void doTest() throws Exception {
|
||||
final String extension = ".java";
|
||||
doTest(extension);
|
||||
}
|
||||
|
||||
private void doTest(final String extension) throws Exception {
|
||||
CommandProcessor.getInstance().executeCommand(
|
||||
getProject(), new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
WriteCommandAction.runWriteCommandAction(null, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
String fileName = getTestName(false) + extension;
|
||||
try {
|
||||
String text = loadFile(fileName);
|
||||
PsiFile file = createFile(fileName, text);
|
||||
|
||||
JavaCodeStyleManager.getInstance(myProject).optimizeImports(file);
|
||||
PostprocessReformattingAspect.getInstance(getProject()).doPostponedFormatting();
|
||||
PsiDocumentManager.getInstance(getProject()).commitAllDocuments();
|
||||
String textAfter = loadFile(getTestName(false) + "_after" + extension);
|
||||
String fileText = file.getText();
|
||||
assertEquals(textAfter, fileText);
|
||||
}
|
||||
catch (Exception e) {
|
||||
LOG.error(e);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}, "", "");
|
||||
|
||||
doTest(".java");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* Copyright 2000-2014 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.psi;
|
||||
|
||||
import com.intellij.openapi.command.CommandProcessor;
|
||||
import com.intellij.openapi.command.WriteCommandAction;
|
||||
import com.intellij.psi.codeStyle.JavaCodeStyleManager;
|
||||
import com.intellij.psi.impl.source.PostprocessReformattingAspect;
|
||||
import com.intellij.testFramework.PsiTestCase;
|
||||
|
||||
/**
|
||||
* @author Dmitry Avdeev
|
||||
*/
|
||||
public abstract class OptimizeImportsTestCase extends PsiTestCase {
|
||||
protected void doTest(final String extension) throws Exception {
|
||||
CommandProcessor.getInstance().executeCommand(
|
||||
getProject(), new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
WriteCommandAction.runWriteCommandAction(null, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
String fileName = getTestName(false) + extension;
|
||||
try {
|
||||
String text = loadFile(fileName);
|
||||
PsiFile file = createFile(fileName, text);
|
||||
|
||||
JavaCodeStyleManager.getInstance(myProject).optimizeImports(file);
|
||||
PostprocessReformattingAspect.getInstance(getProject()).doPostponedFormatting();
|
||||
PsiDocumentManager.getInstance(getProject()).commitAllDocuments();
|
||||
String textAfter = loadFile(getTestName(false) + "_after" + extension);
|
||||
String fileText = file.getText();
|
||||
assertEquals(textAfter, fileText);
|
||||
}
|
||||
catch (Exception e) {
|
||||
LOG.error(e);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}, "", "");
|
||||
|
||||
}
|
||||
}
|
||||
@@ -67,7 +67,7 @@ static NSString *const JVMOptions = @"JVMOptions";
|
||||
|
||||
|
||||
void appendBundle(NSString *path, NSMutableArray *sink) {
|
||||
if ([path hasSuffix:@".jdk"] || [path hasSuffix:@".jre"]) {
|
||||
if ([path hasSuffix:@"jdk"] || [path hasSuffix:@".jre"]) {
|
||||
NSBundle *bundle = [NSBundle bundleWithPath:path];
|
||||
if (bundle != nil) {
|
||||
[sink addObject:bundle];
|
||||
|
||||
+5
-8
@@ -43,7 +43,7 @@ import com.intellij.util.ArrayUtil;
|
||||
import com.intellij.util.Consumer;
|
||||
import com.intellij.util.Function;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.containers.WeakStringInterner;
|
||||
import com.intellij.util.containers.StringInterner;
|
||||
import com.intellij.util.graph.CachingSemiGraph;
|
||||
import com.intellij.util.graph.DFSTBuilder;
|
||||
import com.intellij.util.graph.GraphGenerator;
|
||||
@@ -267,15 +267,12 @@ public class InspectionProfileImpl extends ProfileEx implements ModifiableModel,
|
||||
((SeverityProvider)getProfileManager()).getOwnSeverityRegistrar().readExternal(highlightElement);
|
||||
}
|
||||
|
||||
WeakStringInterner interner = new WeakStringInterner();
|
||||
for (final Object o : element.getChildren(INSPECTION_TOOL_TAG)) {
|
||||
StringInterner interner = new StringInterner();
|
||||
for (Element toolElement : element.getChildren(INSPECTION_TOOL_TAG)) {
|
||||
// make clone to avoid retaining memory via o.parent pointers
|
||||
Element toolElement = ((Element)o).clone();
|
||||
toolElement = toolElement.clone();
|
||||
JDOMUtil.internElement(toolElement, interner);
|
||||
|
||||
String toolClassName = toolElement.getAttributeValue(CLASS_TAG);
|
||||
|
||||
myDeinstalledInspectionsSettings.put(toolClassName, toolElement);
|
||||
myDeinstalledInspectionsSettings.put(toolElement.getAttributeValue(CLASS_TAG), toolElement);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -96,4 +96,8 @@ public class VFileMoveEvent extends VFileEvent {
|
||||
result = 31 * result + myNewParent.hashCode();
|
||||
return result;
|
||||
}
|
||||
|
||||
public String getOldPath() {
|
||||
return myOldParent.getPath() + "/" + myFile.getName();
|
||||
}
|
||||
}
|
||||
|
||||
+10
@@ -139,4 +139,14 @@ public class VFilePropertyChangeEvent extends VFileEvent {
|
||||
return "VfsEvent[property(" + myPropertyName + ") changed for '" + myFile + "':" +
|
||||
" oldValue = " + myOldValue + ", newValue = " + myNewValue + "]";
|
||||
}
|
||||
|
||||
public String getOldPath() {
|
||||
String path = getPath();
|
||||
if (VirtualFile.PROP_NAME.equals(myPropertyName) && myNewValue instanceof String && myOldValue instanceof String) {
|
||||
String newName = (String)myNewValue;
|
||||
int i = path.lastIndexOf(newName);
|
||||
if (i != -1) path = new StringBuilder(path).replace(i, i + newName.length(), (String)myOldValue).toString();
|
||||
}
|
||||
return path;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,6 +31,7 @@ import com.intellij.openapi.util.JDOMUtil;
|
||||
import com.intellij.openapi.util.NullableLazyValue;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import com.intellij.util.SmartList;
|
||||
import com.intellij.util.containers.MultiMap;
|
||||
import com.intellij.util.containers.StringInterner;
|
||||
import com.intellij.util.containers.WeakStringInterner;
|
||||
@@ -120,19 +121,19 @@ public class IdeaPluginDescriptorImpl implements IdeaPluginDescriptor {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static List<Element> copyElements(final Element[] elements, final WeakStringInterner interner) {
|
||||
if (elements != null) {
|
||||
List<Element> result = new ArrayList<Element>();
|
||||
for (Element extensionsRoot : elements) {
|
||||
for (final Object o : extensionsRoot.getChildren()) {
|
||||
Element element = (Element)o;
|
||||
JDOMUtil.internElement(element, interner);
|
||||
result.add(element);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
private static List<Element> copyElements(@Nullable Element[] elements, StringInterner interner) {
|
||||
if (elements == null || elements.length == 0) {
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
|
||||
List<Element> result = new SmartList<Element>();
|
||||
for (Element extensionsRoot : elements) {
|
||||
for (Element element : extensionsRoot.getChildren()) {
|
||||
JDOMUtil.internElement(element, interner);
|
||||
result.add(element);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@SuppressWarnings({"HardCodedStringLiteral"})
|
||||
@@ -167,7 +168,7 @@ public class IdeaPluginDescriptorImpl implements IdeaPluginDescriptor {
|
||||
public void readExternal(@NotNull Document document, @NotNull URL url, boolean ignoreMissingInclude) throws InvalidDataException, FileNotFoundException {
|
||||
document = JDOMXIncluder.resolve(document, url.toExternalForm(), ignoreMissingInclude);
|
||||
Element rootElement = document.getRootElement();
|
||||
JDOMUtil.internElement(rootElement, new WeakStringInterner());
|
||||
JDOMUtil.internElement(rootElement, new StringInterner());
|
||||
readExternal(document.getRootElement());
|
||||
}
|
||||
|
||||
@@ -267,7 +268,7 @@ public class IdeaPluginDescriptorImpl implements IdeaPluginDescriptor {
|
||||
if (myProjectComponents == null) myProjectComponents = ComponentConfig.EMPTY_ARRAY;
|
||||
if (myModuleComponents == null) myModuleComponents = ComponentConfig.EMPTY_ARRAY;
|
||||
|
||||
WeakStringInterner interner = new WeakStringInterner();
|
||||
StringInterner interner = new StringInterner();
|
||||
List<Element> extensions = copyElements(pluginBean.extensions, interner);
|
||||
if (extensions != null) {
|
||||
myExtensions = new MultiMap<String, Element>();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
* Copyright 2000-2014 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.
|
||||
@@ -38,7 +38,6 @@ import com.intellij.openapi.wm.StatusBarWidget;
|
||||
import com.intellij.openapi.wm.WindowManager;
|
||||
import com.intellij.openapi.wm.impl.status.StatusBarUtil;
|
||||
import com.intellij.util.Function;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.io.storage.HeavyProcessLatch;
|
||||
import com.intellij.util.text.DateFormatUtil;
|
||||
import com.intellij.vcs.log.TimedVcsCommit;
|
||||
@@ -191,7 +190,7 @@ public class DvcsUtil {
|
||||
}
|
||||
|
||||
public static void workingTreeChangeStarted(@NotNull Project project) {
|
||||
HeavyProcessLatch.INSTANCE.processStarted();
|
||||
HeavyProcessLatch.INSTANCE.processStarted("Changing DVCS working tree");
|
||||
ApplicationManager.getApplication().getMessageBus().syncPublisher(BatchFileChangeListener.TOPIC).batchChangeStarted(project);
|
||||
}
|
||||
|
||||
|
||||
@@ -214,6 +214,10 @@ public final class Presentation implements Cloneable {
|
||||
|
||||
public void setIcon(@Nullable Icon icon) {
|
||||
Icon oldIcon = myIcon;
|
||||
if (oldIcon == icon) {
|
||||
return;
|
||||
}
|
||||
|
||||
myIcon = icon;
|
||||
myChangeSupport.firePropertyChange(PROP_ICON, oldIcon, myIcon);
|
||||
}
|
||||
|
||||
+2
-3
@@ -65,7 +65,7 @@ public class RunConfigurationExtensionsManager<U extends RunConfigurationBase, T
|
||||
if (!found) {
|
||||
List<Element> copy = new ArrayList<Element>(children.size());
|
||||
for (Element child : children) {
|
||||
Element clone = (Element)child.clone();
|
||||
Element clone = child.clone();
|
||||
JDOMUtil.internElement(clone, myInterner);
|
||||
copy.add(clone);
|
||||
}
|
||||
@@ -87,8 +87,7 @@ public class RunConfigurationExtensionsManager<U extends RunConfigurationBase, T
|
||||
final List<Element> elements = configuration.getCopyableUserData(RUN_EXTENSIONS);
|
||||
if (elements != null) {
|
||||
for (Element el : elements) {
|
||||
final String name = el.getAttributeValue(getIdAttrName());
|
||||
map.put(name, (Element)el.clone());
|
||||
map.put(el.getAttributeValue(getIdAttrName()), el.clone());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -15,8 +15,8 @@
|
||||
*/
|
||||
package com.intellij.ide.util.projectWizard;
|
||||
|
||||
import com.intellij.ide.GeneralSettings;
|
||||
import com.intellij.ide.IdeBundle;
|
||||
import com.intellij.ide.RecentProjectsManager;
|
||||
import com.intellij.openapi.application.ApplicationNamesInfo;
|
||||
import com.intellij.openapi.components.StorageScheme;
|
||||
import com.intellij.openapi.project.Project;
|
||||
@@ -93,7 +93,7 @@ public class WizardContext extends UserDataHolderBase {
|
||||
if (myProjectFileDirectory != null) {
|
||||
return myProjectFileDirectory;
|
||||
}
|
||||
final String lastProjectLocation = GeneralSettings.getInstance().getLastProjectCreationLocation();
|
||||
final String lastProjectLocation = RecentProjectsManager.getInstance().getLastProjectCreationLocation();
|
||||
if (lastProjectLocation != null) {
|
||||
return lastProjectLocation.replace('/', File.separatorChar);
|
||||
}
|
||||
|
||||
@@ -597,7 +597,9 @@ public class CodeStyleSettings extends CommonCodeStyleSettings implements Clonea
|
||||
|
||||
for (final CustomCodeStyleSettings settings : customSettings) {
|
||||
final CustomCodeStyleSettings parentCustomSettings = parentSettings.getCustomSettings(settings.getClass());
|
||||
assert parentCustomSettings != null : "Custom settings are null for " + settings.getClass();
|
||||
if (parentCustomSettings == null) {
|
||||
throw new WriteExternalException("Custom settings are null for " + settings.getClass());
|
||||
}
|
||||
settings.writeExternal(element, parentCustomSettings);
|
||||
}
|
||||
|
||||
|
||||
+4
-3
@@ -23,7 +23,8 @@ import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.extensions.ExtensionException;
|
||||
import com.intellij.openapi.util.*;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.util.containers.WeakStringInterner;
|
||||
import com.intellij.util.SmartList;
|
||||
import com.intellij.util.containers.StringInterner;
|
||||
import org.jdom.Element;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -229,7 +230,7 @@ public class RunnerAndConfigurationSettingsImpl implements JDOMExternalizable, C
|
||||
myConfiguration.readExternal(element);
|
||||
List<Element> runners = element.getChildren(RUNNER_ELEMENT);
|
||||
myUnloadedRunnerSettings = null;
|
||||
WeakStringInterner interner = new WeakStringInterner();
|
||||
StringInterner interner = new StringInterner();
|
||||
for (final Element runnerElement : runners) {
|
||||
String id = runnerElement.getAttributeValue(RUNNER_ID);
|
||||
ProgramRunner runner = RunnerRegistry.getInstance().findRunnerById(id);
|
||||
@@ -241,7 +242,7 @@ public class RunnerAndConfigurationSettingsImpl implements JDOMExternalizable, C
|
||||
myRunnerSettings.put(runner, settings);
|
||||
}
|
||||
else {
|
||||
if (myUnloadedRunnerSettings == null) myUnloadedRunnerSettings = new ArrayList<Element>(1);
|
||||
if (myUnloadedRunnerSettings == null) myUnloadedRunnerSettings = new SmartList<Element>();
|
||||
JDOMUtil.internElement(runnerElement, interner);
|
||||
myUnloadedRunnerSettings.add(runnerElement);
|
||||
}
|
||||
|
||||
@@ -463,7 +463,7 @@ public class MemberChooser<T extends ClassMember> extends DialogWrapper implemen
|
||||
ShowContainersAction showContainersAction = getShowContainersAction();
|
||||
showContainersAction.registerCustomShortcutSet(new CustomShortcutSet(KeyStroke.getKeyStroke(KeyEvent.VK_C, InputEvent.ALT_MASK)),
|
||||
myTree);
|
||||
setShowClasses(PropertiesComponent.getInstance().isTrueValue(PROP_SHOWCLASSES));
|
||||
setShowClasses(PropertiesComponent.getInstance().getBoolean(PROP_SHOWCLASSES, true));
|
||||
group.add(showContainersAction);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1521,8 +1521,9 @@ public abstract class ChooseByNameBase {
|
||||
ApplicationAdapter listener = new ApplicationAdapter() {
|
||||
@Override
|
||||
public void beforeWriteActionStart(Object action) {
|
||||
cancel();
|
||||
scheduleRestart();
|
||||
if (cancel()) {
|
||||
scheduleRestart(); //don't restart if already canceled explicitly
|
||||
}
|
||||
ApplicationManager.getApplication().removeApplicationListener(this);
|
||||
}
|
||||
};
|
||||
|
||||
+1
-1
@@ -57,7 +57,7 @@ public class ModuleDeleteProvider implements DeleteProvider, TitledHandler {
|
||||
|
||||
private static boolean isPrimaryModule(Module[] modules) {
|
||||
if (!ProjectAttachProcessor.canAttachToProject()) {
|
||||
return !PlatformUtils.isIdeaUltimate();
|
||||
return !PlatformUtils.isIntelliJ();
|
||||
}
|
||||
for (Module module : modules) {
|
||||
final File moduleFile = new File(module.getModuleFilePath());
|
||||
|
||||
+25
-3
@@ -86,6 +86,8 @@ import javax.swing.tree.DefaultTreeModel;
|
||||
import javax.swing.tree.TreeNode;
|
||||
import javax.swing.tree.TreePath;
|
||||
import java.awt.*;
|
||||
import java.beans.PropertyChangeEvent;
|
||||
import java.beans.PropertyChangeListener;
|
||||
import java.io.IOException;
|
||||
import java.io.StringReader;
|
||||
import java.util.*;
|
||||
@@ -902,8 +904,15 @@ public class SingleInspectionProfilePanel extends JPanel {
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
final ToolbarDecorator wrappedTable = ToolbarDecorator.createDecorator(scopesAndScopesAndSeveritiesTable).disableUpDownActions();
|
||||
final ToolbarDecorator wrappedTable = ToolbarDecorator.createDecorator(scopesAndScopesAndSeveritiesTable).disableUpDownActions().setRemoveActionUpdater(
|
||||
new AnActionButtonUpdater() {
|
||||
@Override
|
||||
public boolean isEnabled(AnActionEvent e) {
|
||||
final int selectedRow = scopesAndScopesAndSeveritiesTable.getSelectedRow();
|
||||
final int rowCount = scopesAndScopesAndSeveritiesTable.getRowCount();
|
||||
return rowCount - 1 != selectedRow;
|
||||
}
|
||||
});
|
||||
final JPanel panel = wrappedTable.createPanel();
|
||||
panel.setMinimumSize(new Dimension(getMinimumSize().width, 3 * scopesAndScopesAndSeveritiesTable.getRowHeight()));
|
||||
severityPanel.add(new JBLabel("Severity by Scope"),
|
||||
@@ -961,7 +970,20 @@ public class SingleInspectionProfilePanel extends JPanel {
|
||||
configPanelAnchor.removeAll();
|
||||
final JComponent additionalConfigPanel = state.getAdditionalConfigPanel();
|
||||
if (additionalConfigPanel != null) {
|
||||
configPanelAnchor.add(ScrollPaneFactory.createScrollPane(additionalConfigPanel, SideBorder.NONE));
|
||||
final JScrollPane pane = ScrollPaneFactory.createScrollPane(additionalConfigPanel, SideBorder.NONE);
|
||||
FocusManager.getCurrentManager().addPropertyChangeListener("focusOwner", new PropertyChangeListener() {
|
||||
@Override
|
||||
public void propertyChange(PropertyChangeEvent evt) {
|
||||
if (!(evt.getNewValue() instanceof JComponent)) {
|
||||
return;
|
||||
}
|
||||
final JComponent component = (JComponent)evt.getNewValue();
|
||||
if (component.isAncestorOf(pane)) {
|
||||
pane.scrollRectToVisible(component.getBounds());
|
||||
}
|
||||
}
|
||||
});
|
||||
configPanelAnchor.add(pane);
|
||||
}
|
||||
UIUtil.setEnabled(configPanelAnchor, state.isEnabled(), true);
|
||||
}
|
||||
|
||||
@@ -19,7 +19,6 @@ package com.intellij.psi.impl.include;
|
||||
import com.intellij.openapi.extensions.Extensions;
|
||||
import com.intellij.openapi.fileTypes.FileTypes;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Condition;
|
||||
import com.intellij.openapi.util.Key;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.openapi.vfs.VfsUtilCore;
|
||||
@@ -33,7 +32,10 @@ import com.intellij.psi.PsiManager;
|
||||
import com.intellij.psi.impl.source.PsiFileImpl;
|
||||
import com.intellij.psi.impl.source.resolve.reference.impl.providers.FileReferenceSet;
|
||||
import com.intellij.psi.search.GlobalSearchScope;
|
||||
import com.intellij.psi.util.*;
|
||||
import com.intellij.psi.util.CachedValueProvider;
|
||||
import com.intellij.psi.util.CachedValuesManager;
|
||||
import com.intellij.psi.util.ParameterizedCachedValue;
|
||||
import com.intellij.psi.util.ParameterizedCachedValueProvider;
|
||||
import com.intellij.util.Processor;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.containers.HashMap;
|
||||
@@ -74,6 +76,7 @@ public class FileIncludeManagerImpl extends FileIncludeManager {
|
||||
return VfsUtilCore.toVirtualFileArray(files);
|
||||
}
|
||||
};
|
||||
private final Map<String, FileIncludeProvider> myProviderMap;
|
||||
|
||||
public void processIncludes(PsiFile file, Processor<FileIncludeInfo> processor) {
|
||||
GlobalSearchScope scope = GlobalSearchScope.allScope(myProject);
|
||||
@@ -127,9 +130,9 @@ public class FileIncludeManagerImpl extends FileIncludeManager {
|
||||
myPsiFileFactory = psiFileFactory;
|
||||
|
||||
FileIncludeProvider[] providers = Extensions.getExtensions(FileIncludeProvider.EP_NAME);
|
||||
Map<String, FileIncludeProvider> providerMap = new HashMap<String, FileIncludeProvider>(providers.length);
|
||||
myProviderMap = new HashMap<String, FileIncludeProvider>(providers.length);
|
||||
for (FileIncludeProvider provider : providers) {
|
||||
FileIncludeProvider old = providerMap.put(provider.getId(), provider);
|
||||
FileIncludeProvider old = myProviderMap.put(provider.getId(), provider);
|
||||
assert old == null;
|
||||
}
|
||||
myCachedValuesManager = cachedValuesManager;
|
||||
@@ -163,14 +166,8 @@ public class FileIncludeManagerImpl extends FileIncludeManager {
|
||||
@Nullable
|
||||
private PsiFileSystemItem doResolve(@NotNull final FileIncludeInfo info, @NotNull final PsiFile context) {
|
||||
if (info instanceof FileIncludeInfoImpl) {
|
||||
final FileIncludeProvider provider =
|
||||
ContainerUtil.find(FileIncludeProvider.EP_NAME.getExtensions(), new Condition<FileIncludeProvider>() {
|
||||
@Override
|
||||
public boolean value(final FileIncludeProvider provider) {
|
||||
return provider.getId().equals(((FileIncludeInfoImpl)info).providerId);
|
||||
}
|
||||
});
|
||||
|
||||
String id = ((FileIncludeInfoImpl)info).providerId;
|
||||
FileIncludeProvider provider = id == null ? null : myProviderMap.get(id);
|
||||
final PsiFileSystemItem resolvedByProvider = provider == null ? null : provider.resolveIncludedFile(info, context);
|
||||
if (resolvedByProvider != null) {
|
||||
return resolvedByProvider;
|
||||
|
||||
@@ -151,7 +151,7 @@ public class PsiElementRenameHandler implements RenameHandler {
|
||||
rename(element, project, nameSuggestionContext, editor, null);
|
||||
}
|
||||
|
||||
private static void rename(PsiElement element, final Project project, PsiElement nameSuggestionContext, Editor editor, String defaultName) {
|
||||
public static void rename(PsiElement element, final Project project, PsiElement nameSuggestionContext, Editor editor, String defaultName) {
|
||||
RenamePsiElementProcessor processor = RenamePsiElementProcessor.forElement(element);
|
||||
PsiElement substituted = processor.substituteElementToRename(element, editor);
|
||||
if (substituted == null || !canRename(project, editor, substituted)) return;
|
||||
|
||||
@@ -48,7 +48,6 @@ public class GeneralSettings implements NamedJDOMExternalizable, ExportableAppli
|
||||
private final PropertyChangeSupport myPropertyChangeSupport;
|
||||
private boolean myUseDefaultBrowser = true;
|
||||
private boolean myConfirmExtractFiles = true;
|
||||
private String myLastProjectLocation;
|
||||
private boolean mySearchInBackground;
|
||||
private boolean myConfirmExit = true;
|
||||
private int myConfirmOpenNewProject = OPEN_PROJECT_ASK;
|
||||
@@ -73,7 +72,6 @@ public class GeneralSettings implements NamedJDOMExternalizable, ExportableAppli
|
||||
@NonNls private static final String OPTION_CONFIRM_EXIT = "confirmExit";
|
||||
@NonNls private static final String OPTION_CONFIRM_OPEN_NEW_PROJECT = "confirmOpenNewProject2";
|
||||
@NonNls private static final String OPTION_CYCLIC_BUFFER_SIZE = "cyclicBufferSize";
|
||||
@NonNls private static final String OPTION_LAST_PROJECT_LOCATION = "lastProjectLocation";
|
||||
|
||||
public static GeneralSettings getInstance(){
|
||||
return ApplicationManager.getApplication().getComponent(GeneralSettings.class);
|
||||
@@ -103,15 +101,21 @@ public class GeneralSettings implements NamedJDOMExternalizable, ExportableAppli
|
||||
return myBrowserPath;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@Deprecated
|
||||
/**
|
||||
* @return a path pointing to a directory where the last project was created or null if not available
|
||||
* Use RecentProjectsManagerBase
|
||||
*/
|
||||
public String getLastProjectCreationLocation() {
|
||||
return myLastProjectLocation;
|
||||
return null;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@Deprecated
|
||||
/**
|
||||
* Use RecentProjectsManagerBase
|
||||
*/
|
||||
public void setLastProjectCreationLocation(String lastProjectLocation) {
|
||||
myLastProjectLocation = lastProjectLocation;
|
||||
}
|
||||
|
||||
public void setBrowserPath(String browserPath) {
|
||||
@@ -323,15 +327,6 @@ public class GeneralSettings implements NamedJDOMExternalizable, ExportableAppli
|
||||
myConfirmOpenNewProject = OPEN_PROJECT_ASK;
|
||||
}
|
||||
}
|
||||
|
||||
if (OPTION_LAST_PROJECT_LOCATION.equals(name)) {
|
||||
try {
|
||||
myLastProjectLocation = value;
|
||||
}
|
||||
catch (Exception ex) {
|
||||
myLastProjectLocation = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!safeWriteSettingRead && "true".equals(System.getProperty("idea.no.safe.write"))) {
|
||||
@@ -417,13 +412,6 @@ public class GeneralSettings implements NamedJDOMExternalizable, ExportableAppli
|
||||
optionElement.setAttribute(ATTRIBUTE_NAME, OPTION_CONFIRM_OPEN_NEW_PROJECT);
|
||||
optionElement.setAttribute(ATTRIBUTE_VALUE, Integer.toString(myConfirmOpenNewProject));
|
||||
parentNode.addContent(optionElement);
|
||||
|
||||
if (myLastProjectLocation != null) {
|
||||
optionElement = new Element(ELEMENT_OPTION);
|
||||
optionElement.setAttribute(ATTRIBUTE_NAME, OPTION_LAST_PROJECT_LOCATION);
|
||||
optionElement.setAttribute(ATTRIBUTE_VALUE, myLastProjectLocation);
|
||||
parentNode.addContent(optionElement);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* Copyright 2000-2014 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.ide;
|
||||
|
||||
import com.intellij.openapi.actionSystem.AnAction;
|
||||
import com.intellij.openapi.components.ServiceManager;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public abstract class RecentProjectsManager {
|
||||
public static RecentProjectsManager getInstance() {
|
||||
return ServiceManager.getService(RecentProjectsManager.class);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public abstract String getLastProjectCreationLocation();
|
||||
|
||||
public abstract void setLastProjectCreationLocation(@Nullable String lastProjectLocation);
|
||||
|
||||
public abstract void clearNameCache();
|
||||
|
||||
public abstract void updateLastProjectPath();
|
||||
|
||||
public abstract String getLastProjectPath();
|
||||
|
||||
public abstract void removePath(@Nullable String path);
|
||||
|
||||
/**
|
||||
* @param addClearListItem whether the "Clear List" action should be added to the end of the list.
|
||||
*/
|
||||
public abstract AnAction[] getRecentProjectsActions(boolean addClearListItem);
|
||||
}
|
||||
@@ -19,6 +19,7 @@ import com.intellij.icons.AllIcons;
|
||||
import com.intellij.openapi.options.OptionsBundle;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.registry.Registry;
|
||||
import com.intellij.ui.RelativeFont;
|
||||
import com.intellij.ui.components.labels.LinkLabel;
|
||||
import com.intellij.ui.components.labels.LinkListener;
|
||||
import com.intellij.ui.components.panels.NonOpaquePanel;
|
||||
@@ -133,14 +134,13 @@ class Banner extends NonOpaquePanel implements PropertyChangeListener{
|
||||
myText.removeAll();
|
||||
for (int i = 0; i < text.length; i++) {
|
||||
final JLabel eachLabel = new JLabel(text[i], SwingConstants.CENTER);
|
||||
final int gap = eachLabel.getIconTextGap();
|
||||
eachLabel.setBorder(new EmptyBorder(0, 0, 0, gap));
|
||||
eachLabel.setVerticalTextPosition(SwingConstants.TOP);
|
||||
eachLabel.setFont(eachLabel.getFont().deriveFont(Font.BOLD, eachLabel.getFont().getSize()));
|
||||
eachLabel.setBorder(new EmptyBorder(0, 0, 0, 5));
|
||||
eachLabel.setFont(RelativeFont.BOLD.derive(eachLabel.getFont()));
|
||||
myText.add(eachLabel);
|
||||
if (i < text.length - 1) {
|
||||
final JLabel eachIcon = new JLabel(AllIcons.General.ComboArrowRight, SwingConstants.CENTER);
|
||||
eachIcon.setBorder(new EmptyBorder(0, 0, 0, gap));
|
||||
final JLabel eachIcon = new JLabel("\u203A", SwingConstants.CENTER);
|
||||
eachIcon.setFont(RelativeFont.HUGE.derive(eachIcon.getFont()));
|
||||
eachIcon.setBorder(new EmptyBorder(0, 0, 0, 5));
|
||||
myText.add(eachIcon);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -74,7 +74,7 @@ public abstract class ArchiveFileSystem extends NewVirtualFileSystem {
|
||||
protected abstract String extractLocalPath(@NotNull String rootPath);
|
||||
|
||||
@NotNull
|
||||
protected abstract String convertLocalPathToRootPath(@NotNull String localPath);
|
||||
protected abstract String convertLocalToRootPath(@NotNull String localPath);
|
||||
|
||||
@NotNull
|
||||
protected abstract ArchiveHandler getHandler(@NotNull VirtualFile entryFile);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
* Copyright 2000-2014 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.
|
||||
@@ -56,6 +56,7 @@ public class LinkLabel<T> extends JLabel {
|
||||
private boolean myClickIsBeingProcessed;
|
||||
private boolean myPaintDefaultIcon;
|
||||
protected static final int DEFAULT_ICON_GAP = 2;
|
||||
protected boolean myPaintUnderline = true;
|
||||
|
||||
public LinkLabel() {
|
||||
this("", AllIcons.Ide.Link);
|
||||
@@ -141,7 +142,7 @@ public class LinkLabel<T> extends JLabel {
|
||||
int x = myIconWidth;
|
||||
int y = getTextBaseLine();
|
||||
|
||||
if (myUnderline) {
|
||||
if (myUnderline && myPaintUnderline) {
|
||||
int k = 1;
|
||||
if (getFont().getSize() > 11) {
|
||||
k += (getFont().getSize() - 11);
|
||||
@@ -181,6 +182,9 @@ public class LinkLabel<T> extends JLabel {
|
||||
return size;
|
||||
}
|
||||
|
||||
public void setPaintUnderline(boolean paintUnderline) {
|
||||
myPaintUnderline = paintUnderline;
|
||||
}
|
||||
|
||||
public void removeNotify() {
|
||||
super.removeNotify();
|
||||
|
||||
@@ -20,13 +20,20 @@ import java.awt.Component;
|
||||
import java.awt.Container;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Insets;
|
||||
import java.awt.LayoutManager;
|
||||
import java.awt.LayoutManager2;
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* This class is intended to lay out added components horizontally.
|
||||
* It allows to add them into the LEFT, CENTER, or RIGHT group, which are aligned separately.
|
||||
* Every group can contain any amount of components. The specified gap is added between components,
|
||||
* and the double gap is added between groups of components.
|
||||
* <p><b>NB!: this class must be modified together with the <code>VerticalLayout</code> class accordingly</b></p>
|
||||
*
|
||||
* @author Sergey.Malenkov
|
||||
* @see VerticalLayout
|
||||
*/
|
||||
public final class HorizontalLayout implements LayoutManager {
|
||||
public final class HorizontalLayout implements LayoutManager2 {
|
||||
public static final String LEFT = "LEFT";
|
||||
public static final String RIGHT = "RIGHT";
|
||||
public static final String CENTER = "CENTER";
|
||||
@@ -73,6 +80,35 @@ public final class HorizontalLayout implements LayoutManager {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addLayoutComponent(Component component, Object constraints) {
|
||||
if ((constraints == null) || (constraints instanceof String)) {
|
||||
addLayoutComponent((String)constraints, component);
|
||||
}
|
||||
else {
|
||||
throw new IllegalArgumentException("unsupported constraints: " + constraints);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dimension maximumLayoutSize(Container target) {
|
||||
return new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getLayoutAlignmentX(Container target) {
|
||||
return .5f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getLayoutAlignmentY(Container target) {
|
||||
return .5f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invalidateLayout(Container target) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addLayoutComponent(String name, Component component) {
|
||||
synchronized (component.getTreeLock()) {
|
||||
@@ -154,19 +190,21 @@ public final class HorizontalLayout implements LayoutManager {
|
||||
|
||||
private int layout(ArrayList<Component> list, int x, int height, Insets insets) {
|
||||
for (Component component : list) {
|
||||
Dimension size = component.getPreferredSize();
|
||||
int y = 0;
|
||||
if (myAlignment == -1) {
|
||||
size.height = height;
|
||||
}
|
||||
else if (myAlignment != SwingConstants.TOP) {
|
||||
y = height - size.height;
|
||||
if (myAlignment == SwingConstants.CENTER) {
|
||||
y /= 2;
|
||||
if (component.isVisible()) {
|
||||
Dimension size = component.getPreferredSize();
|
||||
int y = 0;
|
||||
if (myAlignment == -1) {
|
||||
size.height = height;
|
||||
}
|
||||
else if (myAlignment != SwingConstants.TOP) {
|
||||
y = height - size.height;
|
||||
if (myAlignment == SwingConstants.CENTER) {
|
||||
y /= 2;
|
||||
}
|
||||
}
|
||||
component.setBounds(x + insets.left, y + insets.top, size.width, size.height);
|
||||
x += size.width + myGap;
|
||||
}
|
||||
component.setBounds(x + insets.left, y + insets.top, size.width, size.height);
|
||||
x += size.width + myGap;
|
||||
}
|
||||
return x;
|
||||
}
|
||||
@@ -188,7 +226,9 @@ public final class HorizontalLayout implements LayoutManager {
|
||||
private Dimension getPreferredSize(ArrayList<Component> list) {
|
||||
Dimension result = null;
|
||||
for (Component component : list) {
|
||||
result = join(result, myGap, component.getPreferredSize());
|
||||
if (component.isVisible()) {
|
||||
result = join(result, myGap, component.getPreferredSize());
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,256 @@
|
||||
/*
|
||||
* Copyright 2000-2014 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.ui.components.panels;
|
||||
|
||||
import javax.swing.SwingConstants;
|
||||
import java.awt.Component;
|
||||
import java.awt.Container;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Insets;
|
||||
import java.awt.LayoutManager2;
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* This class is intended to lay out added components vertically.
|
||||
* It allows to add them into the TOP, CENTER, or BOTTOM group, which are aligned separately.
|
||||
* Every group can contain any amount of components. The specified gap is added between components,
|
||||
* and the double gap is added between groups of components.
|
||||
* <p><b>NB!: this class must be modified together with the <code>HorizontalLayout</code> class accordingly</b></p>
|
||||
*
|
||||
* @author Sergey.Malenkov
|
||||
* @see HorizontalLayout
|
||||
*/
|
||||
public final class VerticalLayout implements LayoutManager2 {
|
||||
public static final String TOP = "TOP";
|
||||
public static final String BOTTOM = "BOTTOM";
|
||||
public static final String CENTER = "CENTER";
|
||||
|
||||
private final ArrayList<Component> myTop = new ArrayList<Component>();
|
||||
private final ArrayList<Component> myBottom = new ArrayList<Component>();
|
||||
private final ArrayList<Component> myCenter = new ArrayList<Component>();
|
||||
private final int myAlignment;
|
||||
private final int myGap;
|
||||
|
||||
/**
|
||||
* Creates a layout with the specified gap.
|
||||
* All components will have preferred widths,
|
||||
* but their widths will be set according to the container.
|
||||
*
|
||||
* @param gap vertical gap between components
|
||||
*/
|
||||
public VerticalLayout(int gap) {
|
||||
myGap = gap;
|
||||
myAlignment = -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a layout with the specified gap and vertical alignment.
|
||||
* All components will have preferred sizes.
|
||||
*
|
||||
* @param gap vertical gap between components
|
||||
* @param alignment horizontal alignment for components
|
||||
*
|
||||
* @see SwingConstants#LEFT
|
||||
* @see SwingConstants#RIGHT
|
||||
* @see SwingConstants#CENTER
|
||||
*/
|
||||
public VerticalLayout(int gap, int alignment) {
|
||||
myGap = gap;
|
||||
switch (alignment) {
|
||||
case SwingConstants.LEFT:
|
||||
case SwingConstants.RIGHT:
|
||||
case SwingConstants.CENTER:
|
||||
myAlignment = alignment;
|
||||
break;
|
||||
default:
|
||||
throw new IllegalArgumentException("unsupported alignment: " + alignment);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addLayoutComponent(Component component, Object constraints) {
|
||||
if ((constraints == null) || (constraints instanceof String)) {
|
||||
addLayoutComponent((String)constraints, component);
|
||||
}
|
||||
else {
|
||||
throw new IllegalArgumentException("unsupported constraints: " + constraints);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dimension maximumLayoutSize(Container target) {
|
||||
return new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getLayoutAlignmentX(Container target) {
|
||||
return .5f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getLayoutAlignmentY(Container target) {
|
||||
return .5f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invalidateLayout(Container target) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addLayoutComponent(String name, Component component) {
|
||||
synchronized (component.getTreeLock()) {
|
||||
if (name == null || CENTER.equalsIgnoreCase(name)) {
|
||||
myCenter.add(component);
|
||||
}
|
||||
else if (TOP.equalsIgnoreCase(name)) {
|
||||
myTop.add(component);
|
||||
}
|
||||
else if (BOTTOM.equalsIgnoreCase(name)) {
|
||||
myBottom.add(component);
|
||||
}
|
||||
else {
|
||||
throw new IllegalArgumentException("unsupported name: " + name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeLayoutComponent(Component component) {
|
||||
myTop.remove(component);
|
||||
myBottom.remove(component);
|
||||
myCenter.remove(component);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dimension preferredLayoutSize(Container container) {
|
||||
return getPreferredSize(container, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dimension minimumLayoutSize(Container container) {
|
||||
return getPreferredSize(container, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void layoutContainer(Container container) {
|
||||
synchronized (container.getTreeLock()) {
|
||||
Dimension top = getPreferredSize(myTop);
|
||||
Dimension bottom = getPreferredSize(myBottom);
|
||||
Dimension center = getPreferredSize(myCenter);
|
||||
|
||||
Insets insets = container.getInsets();
|
||||
int width = container.getWidth() - insets.left - insets.right;
|
||||
int height = container.getHeight() - insets.top - insets.bottom;
|
||||
|
||||
int topY = 0;
|
||||
if (top != null) {
|
||||
topY = myGap + layout(myTop, 0, width, insets);
|
||||
}
|
||||
int bottomY = height;
|
||||
if (bottom != null) {
|
||||
bottomY -= bottom.height;
|
||||
}
|
||||
if (bottomY < topY) {
|
||||
bottomY = topY;
|
||||
}
|
||||
if (center != null) {
|
||||
int centerY = (height - center.height) / 2;
|
||||
if (centerY > topY) {
|
||||
int centerBottomY = centerY + center.height + myGap + myGap;
|
||||
if (centerBottomY > bottomY) {
|
||||
centerY = bottomY - center.height - myGap - myGap;
|
||||
}
|
||||
}
|
||||
if (centerY < topY) {
|
||||
centerY = topY;
|
||||
}
|
||||
centerY = myGap + layout(myCenter, centerY, width, insets);
|
||||
if (bottomY < centerY) {
|
||||
bottomY = centerY;
|
||||
}
|
||||
}
|
||||
if (bottom != null) {
|
||||
layout(myBottom, bottomY, width, insets);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private int layout(ArrayList<Component> list, int y, int width, Insets insets) {
|
||||
for (Component component : list) {
|
||||
if (component.isVisible()) {
|
||||
Dimension size = component.getPreferredSize();
|
||||
int x = 0;
|
||||
if (myAlignment == -1) {
|
||||
size.width = width;
|
||||
}
|
||||
else if (myAlignment != SwingConstants.LEFT) {
|
||||
x = width - size.width;
|
||||
if (myAlignment == SwingConstants.CENTER) {
|
||||
x /= 2;
|
||||
}
|
||||
}
|
||||
component.setBounds(x + insets.left, y + insets.top, size.width, size.height);
|
||||
y += size.height + myGap;
|
||||
}
|
||||
}
|
||||
return y;
|
||||
}
|
||||
|
||||
private static Dimension join(Dimension result, int gap, Dimension size) {
|
||||
if (size == null) {
|
||||
return result;
|
||||
}
|
||||
if (result == null) {
|
||||
return new Dimension(size);
|
||||
}
|
||||
result.height += gap + size.height;
|
||||
if (result.width < size.width) {
|
||||
result.width = size.width;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private Dimension getPreferredSize(ArrayList<Component> list) {
|
||||
Dimension result = null;
|
||||
for (Component component : list) {
|
||||
if (component.isVisible()) {
|
||||
result = join(result, myGap, component.getPreferredSize());
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private Dimension getPreferredSize(Container container, boolean aligned) {
|
||||
synchronized (container.getTreeLock()) {
|
||||
Dimension top = getPreferredSize(myTop);
|
||||
Dimension bottom = getPreferredSize(myBottom);
|
||||
Dimension center = getPreferredSize(myCenter);
|
||||
Dimension result = join(join(join(null, myGap + myGap, top), myGap + myGap, center), myGap + myGap, bottom);
|
||||
if (result == null) {
|
||||
result = new Dimension();
|
||||
}
|
||||
else if (aligned) {
|
||||
int topHeight = top == null ? 0 : top.height;
|
||||
int bottomHeight = bottom == null ? 0 : bottom.height;
|
||||
result.width += Math.abs(topHeight - bottomHeight);
|
||||
}
|
||||
Insets insets = container.getInsets();
|
||||
result.width += insets.left + insets.right;
|
||||
result.height += insets.top + insets.bottom;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -20,7 +20,6 @@ import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.openapi.actionSystem.Separator;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.components.PersistentStateComponent;
|
||||
import com.intellij.openapi.components.ServiceManager;
|
||||
import com.intellij.openapi.project.DumbAwareAction;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.project.ProjectManager;
|
||||
@@ -34,7 +33,7 @@ import com.intellij.openapi.util.registry.Registry;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.wm.impl.SystemDock;
|
||||
import com.intellij.openapi.wm.impl.welcomeScreen.WelcomeFrame;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import com.intellij.util.SmartList;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.messages.MessageBus;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -46,17 +45,19 @@ import java.util.*;
|
||||
/**
|
||||
* @author yole
|
||||
*/
|
||||
public abstract class RecentProjectsManagerBase implements ProjectManagerListener, PersistentStateComponent<RecentProjectsManagerBase.State> {
|
||||
public static RecentProjectsManagerBase getInstance() {
|
||||
return ServiceManager.getService(RecentProjectsManagerBase.class);
|
||||
public abstract class RecentProjectsManagerBase extends RecentProjectsManager implements ProjectManagerListener, PersistentStateComponent<RecentProjectsManagerBase.State> {
|
||||
public static RecentProjectsManagerBase getInstanceEx() {
|
||||
return (RecentProjectsManagerBase)RecentProjectsManager.getInstance();
|
||||
}
|
||||
|
||||
public static class State {
|
||||
public List<String> recentPaths = ContainerUtil.newArrayList();
|
||||
public List<String> openPaths = ContainerUtil.newArrayList();
|
||||
public List<String> recentPaths = new SmartList<String>();
|
||||
public List<String> openPaths = new SmartList<String>();
|
||||
public Map<String, String> names = ContainerUtil.newLinkedHashMap();
|
||||
public String lastPath;
|
||||
|
||||
public String lastProjectLocation;
|
||||
|
||||
void validateRecentProjects() {
|
||||
//noinspection StatementWithEmptyBody
|
||||
while (recentPaths.remove(null)) ;
|
||||
@@ -70,11 +71,6 @@ public abstract class RecentProjectsManagerBase implements ProjectManagerListene
|
||||
recentPaths.remove(index);
|
||||
}
|
||||
}
|
||||
|
||||
void removePath(String path) {
|
||||
recentPaths.remove(path);
|
||||
names.remove(path);
|
||||
}
|
||||
}
|
||||
|
||||
private final Object myStateLock = new Object();
|
||||
@@ -96,52 +92,69 @@ public abstract class RecentProjectsManagerBase implements ProjectManagerListene
|
||||
|
||||
@Override
|
||||
public void loadState(final State state) {
|
||||
synchronized (myStateLock) {
|
||||
myState = state;
|
||||
if (myState.lastPath != null && !new File(myState.lastPath).exists()) {
|
||||
myState.lastPath = null;
|
||||
}
|
||||
if (myState.lastPath != null) {
|
||||
File lastFile = new File(myState.lastPath);
|
||||
if (lastFile.isDirectory() && !new File(lastFile, Project.DIRECTORY_STORE_FOLDER).exists()) {
|
||||
myState.lastPath = null;
|
||||
}
|
||||
if (state.lastPath != null && !new File(state.lastPath).exists()) {
|
||||
state.lastPath = null;
|
||||
}
|
||||
if (state.lastPath != null) {
|
||||
File lastFile = new File(state.lastPath);
|
||||
if (lastFile.isDirectory() && !new File(lastFile, Project.DIRECTORY_STORE_FOLDER).exists()) {
|
||||
state.lastPath = null;
|
||||
}
|
||||
}
|
||||
myState = state;
|
||||
}
|
||||
|
||||
public void removePath(final String path) {
|
||||
if (path == null) return;
|
||||
@Override
|
||||
public void removePath(@Nullable String path) {
|
||||
if (path == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
synchronized (myStateLock) {
|
||||
if (SystemInfo.isFileSystemCaseSensitive) {
|
||||
myState.removePath(path);
|
||||
myState.recentPaths.remove(path);
|
||||
myState.names.remove(path);
|
||||
}
|
||||
else {
|
||||
for (String p : ArrayUtil.toStringArray(myState.recentPaths)) {
|
||||
if (path.equalsIgnoreCase(p)) {
|
||||
myState.removePath(path);
|
||||
for (Iterator<String> iterator = myState.recentPaths.iterator(); iterator.hasNext(); ) {
|
||||
if (path.equalsIgnoreCase(iterator.next())) {
|
||||
iterator.remove();
|
||||
myState.names.remove(path);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public String getLastProjectPath() {
|
||||
synchronized (myStateLock) {
|
||||
return myState.lastPath;
|
||||
}
|
||||
/**
|
||||
* @return a path pointing to a directory where the last project was created or null if not available
|
||||
*/
|
||||
@Override
|
||||
@Nullable
|
||||
public String getLastProjectCreationLocation() {
|
||||
return myState.lastProjectLocation;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLastProjectCreationLocation(@Nullable String lastProjectLocation) {
|
||||
myState.lastProjectLocation = StringUtil.nullize(lastProjectLocation, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLastProjectPath() {
|
||||
return myState.lastPath;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateLastProjectPath() {
|
||||
final Project[] openProjects = ProjectManager.getInstance().getOpenProjects();
|
||||
synchronized (myStateLock) {
|
||||
myState.openPaths.clear();
|
||||
if (openProjects.length == 0) {
|
||||
myState.lastPath = null;
|
||||
myState.openPaths = Collections.emptyList();
|
||||
}
|
||||
else {
|
||||
myState.lastPath = getProjectPath(openProjects[openProjects.length - 1]);
|
||||
myState.openPaths = ContainerUtil.newArrayList();
|
||||
for (Project openProject : openProjects) {
|
||||
String path = getProjectPath(openProject);
|
||||
if (path != null) {
|
||||
@@ -169,9 +182,7 @@ public abstract class RecentProjectsManagerBase implements ProjectManagerListene
|
||||
return duplicates;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param addClearListItem whether the "Clear List" action should be added to the end of the list.
|
||||
*/
|
||||
@Override
|
||||
public AnAction[] getRecentProjectsActions(boolean addClearListItem) {
|
||||
final Set<String> paths;
|
||||
synchronized (myStateLock) {
|
||||
@@ -187,7 +198,7 @@ public abstract class RecentProjectsManagerBase implements ProjectManagerListene
|
||||
paths.remove(null);
|
||||
paths.removeAll(openedPaths);
|
||||
|
||||
List<AnAction> actions = new ArrayList<AnAction>();
|
||||
List<AnAction> actions = new SmartList<AnAction>();
|
||||
Set<String> duplicates = getDuplicateProjectNames(openedPaths, paths);
|
||||
for (final String path : paths) {
|
||||
String projectName = getProjectName(path);
|
||||
@@ -295,6 +306,7 @@ public abstract class RecentProjectsManagerBase implements ProjectManagerListene
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearNameCache() {
|
||||
myNameCache.clear();
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@ package com.intellij.ide;
|
||||
import com.intellij.openapi.actionSystem.AnAction;
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.openapi.actionSystem.CommonDataKeys;
|
||||
import com.intellij.openapi.actionSystem.PlatformDataKeys;
|
||||
import com.intellij.openapi.actionSystem.Presentation;
|
||||
import com.intellij.openapi.project.DumbAware;
|
||||
import com.intellij.openapi.project.Project;
|
||||
@@ -46,6 +45,7 @@ public class ReopenProjectAction extends AnAction implements DumbAware {
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void actionPerformed(AnActionEvent e) {
|
||||
final int modifiers = e.getModifiers();
|
||||
final boolean forceOpenInNewFrame = (modifiers & InputEvent.CTRL_MASK) != 0 || (modifiers & InputEvent.SHIFT_MASK) != 0;
|
||||
@@ -54,11 +54,11 @@ public class ReopenProjectAction extends AnAction implements DumbAware {
|
||||
if (Messages.showDialog(project, "The path " + FileUtil.toSystemDependentName(myProjectPath) + " does not exist.\n" +
|
||||
"If it is on a removable or network drive, please make sure that the drive is connected.",
|
||||
"Reopen Project", new String[]{"OK", "&Remove From List"}, 0, Messages.getErrorIcon()) == 1) {
|
||||
RecentProjectsManagerBase.getInstance().removePath(myProjectPath);
|
||||
RecentProjectsManager.getInstance().removePath(myProjectPath);
|
||||
}
|
||||
return;
|
||||
}
|
||||
RecentProjectsManagerBase.getInstance().doOpenProject(myProjectPath, project, forceOpenInNewFrame);
|
||||
RecentProjectsManagerBase.getInstanceEx().doOpenProject(myProjectPath, project, forceOpenInNewFrame);
|
||||
}
|
||||
|
||||
public String getProjectPath() {
|
||||
|
||||
@@ -15,12 +15,11 @@
|
||||
*/
|
||||
package com.intellij.ide.actions;
|
||||
|
||||
import com.intellij.ide.RecentProjectsManagerBase;
|
||||
import com.intellij.ide.RecentProjectsManager;
|
||||
import com.intellij.ide.impl.ProjectUtil;
|
||||
import com.intellij.openapi.actionSystem.AnAction;
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.openapi.actionSystem.CommonDataKeys;
|
||||
import com.intellij.openapi.actionSystem.PlatformDataKeys;
|
||||
import com.intellij.openapi.actionSystem.Presentation;
|
||||
import com.intellij.openapi.module.ModuleManager;
|
||||
import com.intellij.openapi.project.DumbAware;
|
||||
@@ -29,15 +28,17 @@ import com.intellij.openapi.wm.impl.welcomeScreen.WelcomeFrame;
|
||||
import com.intellij.projectImport.ProjectAttachProcessor;
|
||||
|
||||
public class CloseProjectAction extends AnAction implements DumbAware {
|
||||
@Override
|
||||
public void actionPerformed(AnActionEvent e) {
|
||||
Project project = CommonDataKeys.PROJECT.getData(e.getDataContext());
|
||||
assert project != null;
|
||||
|
||||
ProjectUtil.closeAndDispose(project);
|
||||
RecentProjectsManagerBase.getInstance().updateLastProjectPath();
|
||||
RecentProjectsManager.getInstance().updateLastProjectPath();
|
||||
WelcomeFrame.showIfNoProjectOpened();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(AnActionEvent event){
|
||||
Presentation presentation = event.getPresentation();
|
||||
Project project = event.getData(CommonDataKeys.PROJECT);
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
*/
|
||||
package com.intellij.ide.actions;
|
||||
|
||||
import com.intellij.ide.RecentProjectsManagerBase;
|
||||
import com.intellij.ide.RecentProjectsManager;
|
||||
import com.intellij.idea.ActionsBundle;
|
||||
import com.intellij.openapi.actionSystem.ActionGroup;
|
||||
import com.intellij.openapi.actionSystem.AnAction;
|
||||
@@ -32,13 +32,15 @@ public class RecentProjectsGroup extends ActionGroup implements DumbAware {
|
||||
presentation.setText(ActionsBundle.message(SystemInfo.isMac ? "group.reopen.mac.text": "group.reopen.win.text"));
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public AnAction[] getChildren(@Nullable AnActionEvent e) {
|
||||
return RecentProjectsManagerBase.getInstance().getRecentProjectsActions(true);
|
||||
return RecentProjectsManager.getInstance().getRecentProjectsActions(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(AnActionEvent event) {
|
||||
Presentation presentation = event.getPresentation();
|
||||
presentation.setEnabled(RecentProjectsManagerBase.getInstance().getRecentProjectsActions(true).length > 0);
|
||||
presentation.setEnabled(RecentProjectsManager.getInstance().getRecentProjectsActions(true).length > 0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ package com.intellij.ide.impl;
|
||||
import com.intellij.CommonBundle;
|
||||
import com.intellij.ide.GeneralSettings;
|
||||
import com.intellij.ide.IdeBundle;
|
||||
import com.intellij.ide.RecentProjectsManager;
|
||||
import com.intellij.ide.highlighter.ProjectFileType;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.application.ApplicationNamesInfo;
|
||||
@@ -75,7 +76,7 @@ public class ProjectUtil {
|
||||
LOG.info(e);
|
||||
return;
|
||||
}
|
||||
GeneralSettings.getInstance().setLastProjectCreationLocation(path.replace(File.separatorChar, '/'));
|
||||
RecentProjectsManager.getInstance().setLastProjectCreationLocation(path.replace(File.separatorChar, '/'));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -275,7 +276,7 @@ public class ProjectUtil {
|
||||
}
|
||||
|
||||
public static String getBaseDir() {
|
||||
final String lastProjectLocation = GeneralSettings.getInstance().getLastProjectCreationLocation();
|
||||
final String lastProjectLocation = RecentProjectsManager.getInstance().getLastProjectCreationLocation();
|
||||
if (lastProjectLocation != null) {
|
||||
return lastProjectLocation.replace('/', File.separatorChar);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
* Copyright 2000-2014 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.
|
||||
@@ -110,9 +110,10 @@ public class StartupManagerImpl extends StartupManagerEx {
|
||||
|
||||
public void runStartupActivities() {
|
||||
ApplicationManager.getApplication().runReadAction(new Runnable() {
|
||||
@Override
|
||||
@SuppressWarnings("SynchronizeOnThis")
|
||||
public void run() {
|
||||
HeavyProcessLatch.INSTANCE.processStarted();
|
||||
HeavyProcessLatch.INSTANCE.processStarted("Running Startup Activities");
|
||||
try {
|
||||
runActivities(myPreStartupActivities);
|
||||
|
||||
@@ -141,6 +142,7 @@ public class StartupManagerImpl extends StartupManagerEx {
|
||||
public void runPostStartupActivitiesFromExtensions() {
|
||||
for (final StartupActivity extension : Extensions.getExtensions(StartupActivity.POST_STARTUP_ACTIVITY)) {
|
||||
final Runnable runnable = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (!myProject.isDisposed()) {
|
||||
extension.runActivity(myProject);
|
||||
@@ -173,6 +175,7 @@ public class StartupManagerImpl extends StartupManagerEx {
|
||||
|
||||
runActivities(myDumbAwarePostStartupActivities);
|
||||
DumbService.getInstance(myProject).runWhenSmart(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
//noinspection SynchronizeOnThis
|
||||
synchronized (StartupManagerImpl.this) {
|
||||
@@ -199,6 +202,7 @@ public class StartupManagerImpl extends StartupManagerEx {
|
||||
|
||||
public void scheduleInitialVfsRefresh() {
|
||||
UIUtil.invokeLaterIfNeeded(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (myProject.isDisposed()) return;
|
||||
|
||||
@@ -318,6 +322,7 @@ public class StartupManagerImpl extends StartupManagerEx {
|
||||
final Runnable runnable;
|
||||
if (DumbService.isDumbAware(action)) {
|
||||
runnable = new DumbAwareRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
action.run();
|
||||
}
|
||||
@@ -325,6 +330,7 @@ public class StartupManagerImpl extends StartupManagerEx {
|
||||
}
|
||||
else {
|
||||
runnable = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
action.run();
|
||||
}
|
||||
@@ -335,6 +341,7 @@ public class StartupManagerImpl extends StartupManagerEx {
|
||||
// in tests which simulate project opening, post-startup activities could have been run already.
|
||||
// Then we should act as if the project was initialized
|
||||
UIUtil.invokeLaterIfNeeded(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (!myProject.isDisposed()) {
|
||||
runnable.run();
|
||||
|
||||
+1
-1
@@ -502,7 +502,7 @@ public class ApplicationImpl extends PlatformComponentManagerImpl implements App
|
||||
myIsFiringLoadingEvent = false;
|
||||
}
|
||||
|
||||
HeavyProcessLatch.INSTANCE.processStarted();
|
||||
HeavyProcessLatch.INSTANCE.processStarted("Loading application components");
|
||||
try {
|
||||
store.load();
|
||||
}
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2011 JetBrains s.r.o.
|
||||
* Copyright 2000-2014 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.
|
||||
@@ -184,7 +184,7 @@ public class ServiceManagerImpl implements BaseComponent {
|
||||
@Override
|
||||
public Object compute() {
|
||||
// prevent storages from flushing and blocking FS
|
||||
HeavyProcessLatch.INSTANCE.processStarted();
|
||||
HeavyProcessLatch.INSTANCE.processStarted("Creating component '" + myDescriptor.getImplementation()+"'");
|
||||
try {
|
||||
synchronized (MyComponentAdapter.this) {
|
||||
Object instance = myInitializedComponentInstance;
|
||||
|
||||
@@ -21,10 +21,9 @@ import com.intellij.openapi.project.Project;
|
||||
import com.intellij.ui.JBColor;
|
||||
import com.intellij.ui.RelativeFont;
|
||||
import com.intellij.ui.components.labels.SwingActionLink;
|
||||
import com.intellij.ui.components.panels.HorizontalLayout;
|
||||
|
||||
import javax.swing.Action;
|
||||
import javax.swing.BorderFactory;
|
||||
import javax.swing.BoxLayout;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
import java.awt.BorderLayout;
|
||||
@@ -39,7 +38,7 @@ final class Banner extends JPanel {
|
||||
|
||||
Banner(Action action) {
|
||||
super(new BorderLayout(10, 0));
|
||||
myLeftPanel.setLayout(new BoxLayout(myLeftPanel, BoxLayout.X_AXIS));
|
||||
myLeftPanel.setLayout(new HorizontalLayout(5));
|
||||
myProjectIcon.setIcon(AllIcons.General.ProjectConfigurableBanner);
|
||||
myProjectIcon.setForeground(JBColor.GRAY);
|
||||
myProjectIcon.setVisible(false);
|
||||
@@ -48,27 +47,31 @@ final class Banner extends JPanel {
|
||||
add(BorderLayout.EAST, RelativeFont.BOLD.install(new SwingActionLink(action)));
|
||||
}
|
||||
|
||||
void setText(String... text) {
|
||||
void setText(String... names) {
|
||||
Component[] components = myLeftPanel.getComponents();
|
||||
int length = text == null ? 0 : text.length;
|
||||
for (int i = 0; i < length; i++) {
|
||||
if (i < components.length) {
|
||||
components[i].setVisible(true);
|
||||
if (components[i] instanceof JLabel) {
|
||||
((JLabel)components[i]).setText(text[i]);
|
||||
}
|
||||
}
|
||||
else {
|
||||
JLabel label = new JLabel(text[i]);
|
||||
label.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 5));
|
||||
if (i > 0) {
|
||||
label.setIcon(AllIcons.General.Divider);
|
||||
}
|
||||
myLeftPanel.add(RelativeFont.BOLD.install(label));
|
||||
}
|
||||
for (Component component : components) {
|
||||
component.setVisible(false);
|
||||
}
|
||||
while (length < components.length) {
|
||||
components[length++].setVisible(false);
|
||||
if (names != null) {
|
||||
int i = 0;
|
||||
for (String name : names) {
|
||||
if (i < components.length) {
|
||||
if (i > 0) {
|
||||
components[i - 1].setVisible(true);
|
||||
}
|
||||
components[i].setVisible(true);
|
||||
if (components[i] instanceof JLabel) {
|
||||
((JLabel)components[i]).setText(name);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (i > 0) {
|
||||
myLeftPanel.add(HorizontalLayout.LEFT, RelativeFont.HUGE.install(new JLabel("\u203A")));
|
||||
}
|
||||
myLeftPanel.add(HorizontalLayout.LEFT, RelativeFont.BOLD.install(new JLabel(name)));
|
||||
}
|
||||
i += 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -153,7 +153,7 @@ public class DumbServiceImpl extends DumbService implements Disposable {
|
||||
indicator.pushState();
|
||||
}
|
||||
try {
|
||||
HeavyProcessLatch.INSTANCE.processStarted();
|
||||
HeavyProcessLatch.INSTANCE.processStarted("Performing indexing task");
|
||||
task.performInDumbMode(indicator != null ? indicator : new EmptyProgressIndicator());
|
||||
}
|
||||
finally {
|
||||
@@ -309,6 +309,7 @@ public class DumbServiceImpl extends DumbService implements Disposable {
|
||||
return wrapper;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void smartInvokeLater(@NotNull final Runnable runnable) {
|
||||
ApplicationManager.getApplication().invokeLater(new Runnable() {
|
||||
@Override
|
||||
@@ -318,6 +319,7 @@ public class DumbServiceImpl extends DumbService implements Disposable {
|
||||
}, myProject.getDisposed());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void smartInvokeLater(@NotNull final Runnable runnable, @NotNull ModalityState modalityState) {
|
||||
ApplicationManager.getApplication().invokeLater(new Runnable() {
|
||||
@Override
|
||||
@@ -335,7 +337,7 @@ public class DumbServiceImpl extends DumbService implements Disposable {
|
||||
final ShutDownTracker shutdownTracker = ShutDownTracker.getInstance();
|
||||
final Thread self = Thread.currentThread();
|
||||
try {
|
||||
HeavyProcessLatch.INSTANCE.processStarted();
|
||||
HeavyProcessLatch.INSTANCE.processStarted("Performing indexing tasks");
|
||||
shutdownTracker.registerStopperThread(self);
|
||||
|
||||
if (visibleIndicator instanceof ProgressIndicatorEx) {
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
package com.intellij.openapi.project.impl;
|
||||
|
||||
import com.intellij.diagnostic.PluginException;
|
||||
import com.intellij.ide.RecentProjectsManagerBase;
|
||||
import com.intellij.ide.RecentProjectsManager;
|
||||
import com.intellij.ide.plugins.IdeaPluginDescriptor;
|
||||
import com.intellij.ide.plugins.PluginManagerCore;
|
||||
import com.intellij.ide.startup.StartupManagerEx;
|
||||
@@ -349,7 +349,7 @@ public class ProjectImpl extends PlatformComponentManagerImpl implements Project
|
||||
catch (IOException e) {
|
||||
LOG.info("Unable to store project name to: " + nameFile.getPath());
|
||||
}
|
||||
RecentProjectsManagerBase.getInstance().clearNameCache();
|
||||
RecentProjectsManager.getInstance().clearNameCache();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+6
-3
@@ -19,7 +19,7 @@ import com.intellij.CommonBundle;
|
||||
import com.intellij.conversion.ConversionResult;
|
||||
import com.intellij.conversion.ConversionService;
|
||||
import com.intellij.ide.AppLifecycleListener;
|
||||
import com.intellij.ide.RecentProjectsManagerBase;
|
||||
import com.intellij.ide.RecentProjectsManager;
|
||||
import com.intellij.ide.impl.ProjectUtil;
|
||||
import com.intellij.ide.plugins.PluginManager;
|
||||
import com.intellij.ide.startup.impl.StartupManagerImpl;
|
||||
@@ -29,8 +29,11 @@ import com.intellij.openapi.application.*;
|
||||
import com.intellij.openapi.application.ex.ApplicationManagerEx;
|
||||
import com.intellij.openapi.application.impl.ApplicationImpl;
|
||||
import com.intellij.openapi.components.*;
|
||||
import com.intellij.openapi.components.impl.stores.*;
|
||||
import com.intellij.openapi.components.impl.stores.ComponentStoreImpl;
|
||||
import com.intellij.openapi.components.impl.stores.ComponentStoreImpl.ReloadComponentStoreStatus;
|
||||
import com.intellij.openapi.components.impl.stores.FileBasedStorage;
|
||||
import com.intellij.openapi.components.impl.stores.StateStorageManager;
|
||||
import com.intellij.openapi.components.impl.stores.StorageUtil;
|
||||
import com.intellij.openapi.components.store.StateStorageBase;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.fileEditor.FileDocumentManager;
|
||||
@@ -124,7 +127,7 @@ public class ProjectManagerImpl extends ProjectManagerEx implements PersistentSt
|
||||
|
||||
/** @noinspection UnusedParameters*/
|
||||
public ProjectManagerImpl(@NotNull VirtualFileManager virtualFileManager,
|
||||
RecentProjectsManagerBase recentProjectsManager,
|
||||
RecentProjectsManager recentProjectsManager,
|
||||
ProgressManager progressManager) {
|
||||
myProgressManager = progressManager;
|
||||
Application app = ApplicationManager.getApplication();
|
||||
|
||||
+2
-2
@@ -15,7 +15,7 @@
|
||||
*/
|
||||
package com.intellij.openapi.ui.playback.util;
|
||||
|
||||
import com.intellij.ide.RecentProjectsManagerBase;
|
||||
import com.intellij.ide.RecentProjectsManager;
|
||||
import com.intellij.openapi.project.*;
|
||||
import com.intellij.openapi.startup.StartupManager;
|
||||
import com.intellij.openapi.ui.playback.PlaybackContext;
|
||||
@@ -44,7 +44,7 @@ public class ProjectPlaybackCall {
|
||||
}
|
||||
|
||||
public static AsyncResult<String> openLastProject(final PlaybackContext context) {
|
||||
return openProject(context, RecentProjectsManagerBase.getInstance().getLastProjectPath());
|
||||
return openProject(context, RecentProjectsManager.getInstance().getLastProjectPath());
|
||||
}
|
||||
|
||||
public static AsyncResult<String> openProject(final PlaybackContext context, final String path) {
|
||||
|
||||
@@ -105,7 +105,7 @@ public class JarFileSystemImpl extends JarFileSystem {
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
protected String convertLocalPathToRootPath(@NotNull String localPath) {
|
||||
protected String convertLocalToRootPath(@NotNull String localPath) {
|
||||
return localPath + JAR_SEPARATOR;
|
||||
}
|
||||
|
||||
@@ -123,7 +123,7 @@ public class JarFileSystemImpl extends JarFileSystem {
|
||||
@Nullable
|
||||
@Override
|
||||
public VirtualFile getRootByLocal(@NotNull VirtualFile file) {
|
||||
return findFileByPath(convertLocalPathToRootPath(file.getPath()));
|
||||
return findFileByPath(convertLocalToRootPath(file.getPath()));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -74,7 +74,7 @@ public class RefreshQueueImpl extends RefreshQueue {
|
||||
public void run() {
|
||||
try {
|
||||
myRefreshIndicator.start();
|
||||
HeavyProcessLatch.INSTANCE.processStarted();
|
||||
HeavyProcessLatch.INSTANCE.processStarted("Doing file refresh. "+session.toString());
|
||||
try {
|
||||
doScan(session);
|
||||
}
|
||||
|
||||
@@ -31,10 +31,7 @@ import com.intellij.util.concurrency.Semaphore;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
|
||||
/**
|
||||
@@ -207,7 +204,7 @@ public class RefreshSessionImpl extends RefreshSession {
|
||||
}
|
||||
|
||||
private List<VFileEvent> mergeEventsAndReset() {
|
||||
LinkedHashSet<VFileEvent> mergedEvents = new LinkedHashSet<VFileEvent>(myEvents);
|
||||
Set<VFileEvent> mergedEvents = new LinkedHashSet<VFileEvent>(myEvents);
|
||||
List<VFileEvent> events = new ArrayList<VFileEvent>(mergedEvents);
|
||||
myEvents = new ArrayList<VFileEvent>();
|
||||
return events;
|
||||
@@ -217,4 +214,9 @@ public class RefreshSessionImpl extends RefreshSession {
|
||||
public ModalityState getModalityState() {
|
||||
return myModalityState;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return myWorkQueue.size() <= 1 ? "" : myWorkQueue.size() + " roots in queue.";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,6 +29,7 @@ import com.intellij.openapi.vfs.VirtualFileManager;
|
||||
import com.intellij.openapi.vfs.impl.ArchiveHandler;
|
||||
import com.intellij.openapi.vfs.newvfs.events.VFileCreateEvent;
|
||||
import com.intellij.openapi.vfs.newvfs.events.VFileEvent;
|
||||
import com.intellij.openapi.vfs.newvfs.events.VFileMoveEvent;
|
||||
import com.intellij.openapi.vfs.newvfs.events.VFilePropertyChangeEvent;
|
||||
import com.intellij.util.Function;
|
||||
import com.intellij.util.Processor;
|
||||
@@ -243,7 +244,7 @@ public class VfsImplUtil {
|
||||
bus.connect().subscribe(VirtualFileManager.VFS_CHANGES, new BulkFileListener.Adapter() {
|
||||
@Override
|
||||
public void after(@NotNull List<? extends VFileEvent> events) {
|
||||
Map<String, VirtualFile> rootsToRefresh = null;
|
||||
InvalidationState state = null;
|
||||
|
||||
synchronized (ourLock) {
|
||||
for (VFileEvent event : events) {
|
||||
@@ -252,56 +253,75 @@ public class VfsImplUtil {
|
||||
if (event instanceof VFileCreateEvent) continue; // created file should not invalidate + getFile is costly
|
||||
|
||||
if (event instanceof VFilePropertyChangeEvent &&
|
||||
VirtualFile.PROP_HIDDEN.equals(((VFilePropertyChangeEvent)event).getPropertyName())) {
|
||||
!VirtualFile.PROP_NAME.equals(((VFilePropertyChangeEvent)event).getPropertyName())) {
|
||||
continue;
|
||||
}
|
||||
|
||||
VirtualFile file = event.getFile();
|
||||
String path = event.getPath(); // todo: this path is new file path for moved / renamed file and invalidation doesn't take place
|
||||
String path = event.getPath();
|
||||
if (event instanceof VFilePropertyChangeEvent) {
|
||||
path = ((VFilePropertyChangeEvent)event).getOldPath();
|
||||
} else if (event instanceof VFileMoveEvent) {
|
||||
path = ((VFileMoveEvent)event).getOldPath();
|
||||
}
|
||||
if (file == null || !file.isDirectory()) {
|
||||
rootsToRefresh = invalidateHandlerForPath(path, rootsToRefresh);
|
||||
if (state == null) state = new InvalidationState();
|
||||
state.invalidateHandlerForPath(path);
|
||||
} else {
|
||||
Collection<String> affectedPaths = ourDominatorsMap.get(path);
|
||||
if (affectedPaths != null) {
|
||||
affectedPaths = new ArrayList<String>(affectedPaths); // defensive copying, we will modify original during invalidate
|
||||
for (String affectedPath : affectedPaths) rootsToRefresh = invalidateHandlerForPath(affectedPath, rootsToRefresh);
|
||||
if (state == null) state = new InvalidationState();
|
||||
for (String affectedPath : affectedPaths) state.invalidateHandlerForPath(affectedPath);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (rootsToRefresh != null) {
|
||||
ZipFileCache.reset(rootsToRefresh.keySet());
|
||||
boolean async = !ApplicationManager.getApplication().isUnitTestMode();
|
||||
RefreshQueue.getInstance().refresh(async, true, null, rootsToRefresh.values());
|
||||
}
|
||||
if (state != null) state.scheduleRefresh();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private static Map<String, VirtualFile> invalidateHandlerForPath(final String path, Map<String, VirtualFile> rootsToRefresh) {
|
||||
Pair<ArchiveFileSystem, ArchiveHandler> handlerPair = ourHandlers.remove(path);
|
||||
if (handlerPair != null) {
|
||||
String rootPath = handlerPair.first.convertLocalPathToRootPath(path);
|
||||
private static class InvalidationState {
|
||||
private Map<String, VirtualFile> rootsToRefresh;
|
||||
|
||||
boolean invalidateHandlerForPath(final String path) {
|
||||
Pair<ArchiveFileSystem, ArchiveHandler> handlerPair = ourHandlers.remove(path);
|
||||
if (handlerPair != null) {
|
||||
forEachDirectoryComponent(path, new Processor<String>() {
|
||||
@Override
|
||||
public boolean process(String containingDirectoryPath) {
|
||||
Set<String> handlers = ourDominatorsMap.get(containingDirectoryPath);
|
||||
if (handlers != null) {
|
||||
if(handlers.remove(path) && handlers.size() == 0) {
|
||||
ourDominatorsMap.remove(containingDirectoryPath);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
});
|
||||
registerPathToRefresh(handlerPair, path);
|
||||
}
|
||||
return handlerPair != null;
|
||||
}
|
||||
|
||||
private void registerPathToRefresh(Pair<ArchiveFileSystem, ArchiveHandler> handlerPair, String path) {
|
||||
String rootPath = handlerPair.first.convertLocalToRootPath(path);
|
||||
NewVirtualFile root = ManagingFS.getInstance().findRoot(rootPath, handlerPair.first);
|
||||
if (root != null) {
|
||||
root.markDirtyRecursively();
|
||||
if (rootsToRefresh == null) rootsToRefresh = ContainerUtil.newHashMap();
|
||||
rootsToRefresh.put(rootPath, root);
|
||||
}
|
||||
forEachDirectoryComponent(path, new Processor<String>() {
|
||||
@Override
|
||||
public boolean process(String containingDirectoryPath) {
|
||||
Set<String> handlers = ourDominatorsMap.get(containingDirectoryPath);
|
||||
if (handlers != null) {
|
||||
if(handlers.remove(path) && handlers.size() == 0) {
|
||||
ourDominatorsMap.remove(containingDirectoryPath);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
return rootsToRefresh;
|
||||
|
||||
void scheduleRefresh() {
|
||||
if (rootsToRefresh != null) {
|
||||
ZipFileCache.reset(rootsToRefresh.keySet());
|
||||
boolean async = !ApplicationManager.getApplication().isUnitTestMode();
|
||||
RefreshQueue.getInstance().refresh(async, true, null, rootsToRefresh.values());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+357
@@ -0,0 +1,357 @@
|
||||
/*
|
||||
* Copyright 2000-2014 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.wm.impl.welcomeScreen;
|
||||
|
||||
import com.intellij.ide.DataManager;
|
||||
import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.MnemonicHelper;
|
||||
import com.intellij.openapi.actionSystem.*;
|
||||
import com.intellij.openapi.application.Application;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.application.ApplicationNamesInfo;
|
||||
import com.intellij.openapi.application.ModalityState;
|
||||
import com.intellij.openapi.application.ex.ApplicationInfoEx;
|
||||
import com.intellij.openapi.application.ex.ApplicationManagerEx;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.project.DumbAwareRunnable;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.project.ProjectManager;
|
||||
import com.intellij.openapi.project.ProjectManagerAdapter;
|
||||
import com.intellij.openapi.util.Disposer;
|
||||
import com.intellij.openapi.util.IconLoader;
|
||||
import com.intellij.openapi.util.registry.Registry;
|
||||
import com.intellij.openapi.wm.*;
|
||||
import com.intellij.openapi.wm.impl.IdeGlassPaneImpl;
|
||||
import com.intellij.ui.*;
|
||||
import com.intellij.ui.components.labels.ActionLink;
|
||||
import com.intellij.ui.components.panels.NonOpaquePanel;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.border.CompoundBorder;
|
||||
import javax.swing.border.EmptyBorder;
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import java.io.File;
|
||||
import java.io.InputStream;
|
||||
import java.net.URL;
|
||||
|
||||
/**
|
||||
* @author Konstantin Bulenkov
|
||||
*/
|
||||
public class FlatWelcomeFrame extends JFrame implements WelcomeFrameProvider, IdeFrame {
|
||||
private final BalloonLayout myBalloonLayout;
|
||||
private final FlatWelcomeScreen myScreen;
|
||||
|
||||
public FlatWelcomeFrame() {
|
||||
JRootPane rootPane = getRootPane();
|
||||
myScreen = new FlatWelcomeScreen();
|
||||
|
||||
final IdeGlassPaneImpl glassPane = new IdeGlassPaneImpl(rootPane);
|
||||
setGlassPane(glassPane);
|
||||
glassPane.setVisible(false);
|
||||
setUndecorated(true);
|
||||
setContentPane(myScreen.getWelcomePanel());
|
||||
setTitle(ApplicationNamesInfo.getInstance().getFullProductName());
|
||||
AppUIUtil.updateWindowIcon(this);
|
||||
Rectangle bounds = ScreenUtil.getMainScreenBounds();
|
||||
setSize(666, 450);
|
||||
int x = bounds.x + (bounds.width - getWidth()) / 2;
|
||||
int y = bounds.y + (bounds.height - getHeight()) / 2;
|
||||
setLocation(x, y);
|
||||
ProjectManager.getInstance().addProjectManagerListener(new ProjectManagerAdapter() {
|
||||
@Override
|
||||
public void projectOpened(Project project) {
|
||||
dispose();
|
||||
}
|
||||
});
|
||||
|
||||
myBalloonLayout = new BalloonLayoutImpl(rootPane, new Insets(8, 8, 8, 8));
|
||||
|
||||
setupCloseAction();
|
||||
new MnemonicHelper().register(this);
|
||||
Disposer.register(ApplicationManager.getApplication(), new Disposable() {
|
||||
@Override
|
||||
public void dispose() {
|
||||
FlatWelcomeFrame.this.dispose();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dispose() {
|
||||
Disposer.dispose(myScreen);
|
||||
super.dispose();
|
||||
WelcomeFrame.resetInstance();
|
||||
}
|
||||
|
||||
private static void saveLocation(Rectangle location) {
|
||||
Point middle = new Point(location.x + location.width / 2, location.y = location.height / 2);
|
||||
//DimensionService.getInstance().setLocation(DIMENSION_KEY, middle, null);
|
||||
}
|
||||
|
||||
private void setupCloseAction() {
|
||||
setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
|
||||
addWindowListener(
|
||||
new WindowAdapter() {
|
||||
public void windowClosing(final WindowEvent e) {
|
||||
dispose();
|
||||
|
||||
final Application app = ApplicationManager.getApplication();
|
||||
app.invokeLater(new DumbAwareRunnable() {
|
||||
public void run() {
|
||||
if (app.isDisposed()) {
|
||||
ApplicationManagerEx.getApplicationEx().exit();
|
||||
return;
|
||||
}
|
||||
|
||||
final Project[] openProjects = ProjectManager.getInstance().getOpenProjects();
|
||||
if (openProjects.length == 0) {
|
||||
ApplicationManagerEx.getApplicationEx().exit();
|
||||
}
|
||||
}
|
||||
}, ModalityState.NON_MODAL);
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public StatusBar getStatusBar() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static Color getMainBackground() {
|
||||
return Color.WHITE;
|
||||
}
|
||||
|
||||
public static Color getProjectsBackGround() {
|
||||
return Gray._245;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IdeFrame createFrame() {
|
||||
return Registry.is("ide.new.welcome.screen") ? this : null;
|
||||
}
|
||||
|
||||
private static class FlatWelcomeScreen extends JPanel implements WelcomeScreen {
|
||||
public FlatWelcomeScreen() {
|
||||
super(new BorderLayout());
|
||||
setBackground(getMainBackground());
|
||||
add(createRecentProjects(), BorderLayout.WEST);
|
||||
add(createBody(), BorderLayout.CENTER);
|
||||
}
|
||||
|
||||
@Override
|
||||
public JComponent getWelcomePanel() {
|
||||
return this;
|
||||
}
|
||||
|
||||
private JComponent createBody() {
|
||||
NonOpaquePanel panel = new NonOpaquePanel(new BorderLayout());
|
||||
panel.add(createLogo(), BorderLayout.NORTH);
|
||||
panel.add(createActionPanel(), BorderLayout.CENTER);
|
||||
//panel.add(createSettingsAndDocs(), BorderLayout.SOUTH);
|
||||
return panel;
|
||||
}
|
||||
|
||||
private JComponent createSettingsAndDocs() {
|
||||
return null;
|
||||
}
|
||||
|
||||
private JComponent createActionPanel() {
|
||||
JPanel actions = new JPanel();
|
||||
actions.setOpaque(false);
|
||||
actions.setLayout(new BoxLayout(actions, BoxLayout.Y_AXIS));
|
||||
ActionManager actionManager = ActionManager.getInstance();
|
||||
ActionGroup quickStart = (ActionGroup)actionManager.getAction(IdeActions.GROUP_WELCOME_SCREEN_QUICKSTART);
|
||||
DefaultActionGroup group = new DefaultActionGroup();
|
||||
for (AnAction action : quickStart.getChildren(null)) {
|
||||
if (action instanceof ActionGroup) {
|
||||
group.addAll((ActionGroup)action);
|
||||
} else {
|
||||
group.add(action);
|
||||
}
|
||||
}
|
||||
|
||||
// so, we sure this is the last action
|
||||
final AnAction register = actionManager.getAction("WelcomeScreen.Register");
|
||||
if (register != null) {
|
||||
group.add(register);
|
||||
}
|
||||
|
||||
for (AnAction action : group.getChildren(null)) {
|
||||
JPanel button = new JPanel(new BorderLayout()) {
|
||||
@Override
|
||||
public Dimension getPreferredSize() {
|
||||
return new Dimension(250, super.getPreferredSize().height);
|
||||
}
|
||||
};
|
||||
button.setOpaque(false);
|
||||
button.setBorder(new EmptyBorder(4, 30, 0, 30));
|
||||
Presentation presentation = action.getTemplatePresentation();
|
||||
action.update(new AnActionEvent(null, DataManager.getInstance().getDataContext(this),
|
||||
ActionPlaces.WELCOME_SCREEN, presentation, ActionManager.getInstance(), 0));
|
||||
if (presentation.isVisible()) {
|
||||
ActionLink link = new ActionLink(presentation.getText(), presentation.getIcon(), action);
|
||||
link.setBorder(new EmptyBorder(2, 5, 2, 5));
|
||||
installFocusable(link, action);
|
||||
button.add(link);
|
||||
actions.add(button);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
actions.setBorder(new EmptyBorder(0, 0, 0, 0));
|
||||
JPanel panel = new NonOpaquePanel(new BorderLayout());
|
||||
panel.add(actions, BorderLayout.NORTH);
|
||||
return panel;
|
||||
}
|
||||
|
||||
private JComponent createLogo() {
|
||||
NonOpaquePanel panel = new NonOpaquePanel(new BorderLayout());
|
||||
JLabel logo = new JLabel(IconLoader.getIcon(ApplicationInfoEx.getInstanceEx().getWelcomeScreenLogoUrl()));
|
||||
logo.setBorder(new EmptyBorder(20, 0, 0, 30));
|
||||
logo.setHorizontalAlignment(SwingConstants.CENTER);
|
||||
panel.add(logo, BorderLayout.NORTH);
|
||||
JLabel appName = new JLabel(ApplicationNamesInfo.getInstance().getFullProductName());
|
||||
Font font = getProductFont();
|
||||
appName.setFont(font.deriveFont(36f).deriveFont(Font.PLAIN));
|
||||
appName.setForeground(Gray._0);
|
||||
appName.setHorizontalAlignment(SwingConstants.CENTER);
|
||||
JLabel version = new JLabel("Version " + ApplicationInfoEx.getInstanceEx().getFullVersion());
|
||||
version.setFont(font.deriveFont(16f).deriveFont(Font.PLAIN));
|
||||
version.setHorizontalAlignment(SwingConstants.CENTER);
|
||||
version.setForeground(Gray._128);
|
||||
|
||||
panel.add(appName);
|
||||
panel.add(version, BorderLayout.SOUTH);
|
||||
return panel;
|
||||
}
|
||||
|
||||
private static Font getProductFont() {
|
||||
String name = "/fonts/Roboto-Light.ttf";
|
||||
URL url = AppUIUtil.class.getResource(name);
|
||||
if (url == null) {
|
||||
Logger.getInstance(AppUIUtil.class).warn("Resource missing: " + name);
|
||||
} else {
|
||||
|
||||
try {
|
||||
InputStream is = url.openStream();
|
||||
try {
|
||||
return Font.createFont(Font.TRUETYPE_FONT, is);
|
||||
}
|
||||
finally {
|
||||
is.close();
|
||||
}
|
||||
}
|
||||
catch (Throwable t) {
|
||||
Logger.getInstance(AppUIUtil.class).warn("Cannot load font: " + url, t);
|
||||
}
|
||||
}
|
||||
return UIUtil.getLabelFont();
|
||||
}
|
||||
|
||||
private JComponent createRecentProjects() {
|
||||
JPanel panel = new JPanel(new BorderLayout());
|
||||
panel.add(new NewRecentProjectPanel(this), BorderLayout.NORTH);
|
||||
panel.setBackground(getProjectsBackGround());
|
||||
return panel;
|
||||
}
|
||||
|
||||
private void installFocusable(final JComponent comp, final AnAction action) {
|
||||
comp.setBorder(new EmptyBorder(2, 2, 2, 2));
|
||||
comp.setFocusable(true);
|
||||
comp.setFocusTraversalKeysEnabled(true);
|
||||
comp.addKeyListener(new KeyAdapter() {
|
||||
@Override
|
||||
public void keyPressed(KeyEvent e) {
|
||||
if (e.getKeyCode() == KeyEvent.VK_ENTER) {
|
||||
action.actionPerformed(new AnActionEvent(e,
|
||||
DataManager.getInstance().getDataContext(),
|
||||
ActionPlaces.WELCOME_SCREEN,
|
||||
action.getTemplatePresentation().clone(),
|
||||
ActionManager.getInstance(),
|
||||
0));
|
||||
}
|
||||
}
|
||||
});
|
||||
comp.addFocusListener(new FocusListener() {
|
||||
@Override
|
||||
public void focusGained(FocusEvent e) {
|
||||
comp.setBorder(new CompoundBorder(new DottedBorder(new Insets(1, 1, 1, 1), Gray._128), new EmptyBorder(1,1,1,1)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void focusLost(FocusEvent e) {
|
||||
comp.setBorder(new EmptyBorder(2, 2, 2, 2));
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setupFrame(JFrame frame) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dispose() {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public BalloonLayout getBalloonLayout() {
|
||||
return myBalloonLayout;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Rectangle suggestChildFrameBounds() {
|
||||
return getBounds();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Project getProject() {
|
||||
return ProjectManager.getInstance().getDefaultProject();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFrameTitle(String title) {
|
||||
setTitle(title);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFileTitle(String fileTitle, File ioFile) {
|
||||
setTitle(fileTitle);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IdeRootPaneNorthExtension getNorthExtension(String key) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JComponent getComponent() {
|
||||
return getRootPane();
|
||||
}
|
||||
|
||||
public static void notifyFrameClosed(JFrame frame) {
|
||||
saveLocation(frame.getBounds());
|
||||
}
|
||||
}
|
||||
+91
@@ -0,0 +1,91 @@
|
||||
/*
|
||||
* Copyright 2000-2014 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.wm.impl.welcomeScreen;
|
||||
|
||||
import com.intellij.ide.ReopenProjectAction;
|
||||
import com.intellij.openapi.actionSystem.AnAction;
|
||||
import com.intellij.openapi.util.io.UniqueNameBuilder;
|
||||
import com.intellij.openapi.wm.WelcomeScreen;
|
||||
import com.intellij.ui.components.JBList;
|
||||
import com.intellij.ui.speedSearch.ListWithFilter;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.border.EmptyBorder;
|
||||
import java.awt.*;
|
||||
|
||||
/**
|
||||
* @author Konstantin Bulenkov
|
||||
*/
|
||||
public class NewRecentProjectPanel extends RecentProjectPanel {
|
||||
public NewRecentProjectPanel(WelcomeScreen screen) {
|
||||
super(screen);
|
||||
setBorder(null);
|
||||
setBackground(FlatWelcomeFrame.getProjectsBackGround());
|
||||
JScrollPane scrollPane = UIUtil.findComponentOfType(this, JScrollPane.class);
|
||||
if (scrollPane != null) {
|
||||
scrollPane.setBackground(FlatWelcomeFrame.getProjectsBackGround());
|
||||
}
|
||||
ListWithFilter panel = UIUtil.findComponentOfType(this, ListWithFilter.class);
|
||||
if (panel != null) {
|
||||
panel.setBackground(FlatWelcomeFrame.getProjectsBackGround());
|
||||
}
|
||||
}
|
||||
|
||||
protected Dimension getPreferredScrollableViewportSize() {
|
||||
return new Dimension(250, 420);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addMouseMotionListener() {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected JBList createList(AnAction[] recentProjectActions, Dimension size) {
|
||||
JBList list = super.createList(recentProjectActions, size);
|
||||
list.setBackground(FlatWelcomeFrame.getProjectsBackGround());
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ListCellRenderer createRenderer(UniqueNameBuilder<ReopenProjectAction> pathShortener) {
|
||||
return new RecentProjectItemRenderer(myPathShortener) {
|
||||
{
|
||||
setBorder(new EmptyBorder(0, 10, 0, 0));
|
||||
}
|
||||
@Override
|
||||
protected Color getListBackground(boolean isSelected, boolean hasFocus) {
|
||||
return isSelected && hasFocus ? new Color(0x2484fd) : FlatWelcomeFrame.getProjectsBackGround();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Color getListForeground(boolean isSelected, boolean hasFocus) {
|
||||
return UIUtil.getListForeground(isSelected && hasFocus);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
protected JPanel createTitle() {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
+91
-53
@@ -19,6 +19,7 @@
|
||||
*/
|
||||
package com.intellij.openapi.wm.impl.welcomeScreen;
|
||||
|
||||
import com.intellij.ide.RecentProjectsManager;
|
||||
import com.intellij.ide.RecentProjectsManagerBase;
|
||||
import com.intellij.ide.ReopenProjectAction;
|
||||
import com.intellij.openapi.actionSystem.ActionPlaces;
|
||||
@@ -40,6 +41,7 @@ import com.intellij.util.Function;
|
||||
import com.intellij.util.SystemProperties;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.border.LineBorder;
|
||||
@@ -48,13 +50,13 @@ import java.awt.event.*;
|
||||
import java.io.File;
|
||||
|
||||
public class RecentProjectPanel extends JPanel {
|
||||
private final JBList myList;
|
||||
private final UniqueNameBuilder<ReopenProjectAction> myPathShortener;
|
||||
protected final JBList myList;
|
||||
protected final UniqueNameBuilder<ReopenProjectAction> myPathShortener;
|
||||
|
||||
public RecentProjectPanel(WelcomeScreen screen) {
|
||||
super(new BorderLayout());
|
||||
|
||||
final AnAction[] recentProjectActions = RecentProjectsManagerBase.getInstance().getRecentProjectsActions(false);
|
||||
final AnAction[] recentProjectActions = RecentProjectsManager.getInstance().getRecentProjectsActions(false);
|
||||
|
||||
myPathShortener = new UniqueNameBuilder<ReopenProjectAction>(SystemProperties.getUserHome(), File.separator, 40);
|
||||
for (AnAction action : recentProjectActions) {
|
||||
@@ -62,8 +64,8 @@ public class RecentProjectPanel extends JPanel {
|
||||
myPathShortener.addPath(item, item.getProjectPath());
|
||||
}
|
||||
|
||||
myList = new MyList(recentProjectActions);
|
||||
myList.setCellRenderer(new RecentProjectItemRenderer());
|
||||
myList = createList(recentProjectActions, getPreferredScrollableViewportSize());
|
||||
myList.setCellRenderer(createRenderer(myPathShortener));
|
||||
|
||||
new ClickListener(){
|
||||
@Override
|
||||
@@ -112,7 +114,7 @@ public class RecentProjectPanel extends JPanel {
|
||||
"Remove Recent Project",
|
||||
Messages.getQuestionIcon());
|
||||
if (rc == Messages.OK) {
|
||||
final RecentProjectsManagerBase manager = RecentProjectsManagerBase.getInstance();
|
||||
RecentProjectsManager manager = RecentProjectsManagerBase.getInstance();
|
||||
for (Object projectAction : selection) {
|
||||
manager.removePath(((ReopenProjectAction)projectAction).getProjectPath());
|
||||
}
|
||||
@@ -127,27 +129,7 @@ public class RecentProjectPanel extends JPanel {
|
||||
}
|
||||
}.registerCustomShortcutSet(CustomShortcutSet.fromString("DELETE", "BACK_SPACE"), myList, screen);
|
||||
|
||||
myList.addMouseMotionListener(new MouseMotionAdapter() {
|
||||
boolean myIsEngaged = false;
|
||||
public void mouseMoved(MouseEvent e) {
|
||||
if (myIsEngaged && !UIUtil.isSelectionButtonDown(e)) {
|
||||
Point point = e.getPoint();
|
||||
int index = myList.locationToIndex(point);
|
||||
myList.setSelectedIndex(index);
|
||||
|
||||
final Rectangle bounds = myList.getCellBounds(index, index);
|
||||
if (bounds != null && bounds.contains(point)) {
|
||||
myList.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
|
||||
}
|
||||
else {
|
||||
myList.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
|
||||
}
|
||||
}
|
||||
else {
|
||||
myIsEngaged = true;
|
||||
}
|
||||
}
|
||||
});
|
||||
addMouseMotionListener();
|
||||
|
||||
myList.setSelectedIndex(0);
|
||||
|
||||
@@ -170,6 +152,53 @@ public class RecentProjectPanel extends JPanel {
|
||||
});
|
||||
add(list, BorderLayout.CENTER);
|
||||
|
||||
JPanel title = createTitle();
|
||||
|
||||
if (title != null) {
|
||||
add(title, BorderLayout.NORTH);
|
||||
}
|
||||
|
||||
setBorder(new LineBorder(WelcomeScreenColors.BORDER_COLOR));
|
||||
}
|
||||
|
||||
protected Dimension getPreferredScrollableViewportSize() {
|
||||
return new Dimension(250, 400);
|
||||
}
|
||||
|
||||
protected void addMouseMotionListener() {
|
||||
myList.addMouseMotionListener(new MouseMotionAdapter() {
|
||||
boolean myIsEngaged = false;
|
||||
public void mouseMoved(MouseEvent e) {
|
||||
if (myIsEngaged && !UIUtil.isSelectionButtonDown(e)) {
|
||||
Point point = e.getPoint();
|
||||
int index = myList.locationToIndex(point);
|
||||
myList.setSelectedIndex(index);
|
||||
|
||||
final Rectangle bounds = myList.getCellBounds(index, index);
|
||||
if (bounds != null && bounds.contains(point)) {
|
||||
myList.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
|
||||
}
|
||||
else {
|
||||
myList.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
|
||||
}
|
||||
}
|
||||
else {
|
||||
myIsEngaged = true;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
protected JBList createList(AnAction[] recentProjectActions, Dimension size) {
|
||||
return new MyList(size, recentProjectActions);
|
||||
}
|
||||
|
||||
protected ListCellRenderer createRenderer(UniqueNameBuilder<ReopenProjectAction> pathShortener) {
|
||||
return new RecentProjectItemRenderer(pathShortener);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
protected JPanel createTitle() {
|
||||
JPanel title = new JPanel() {
|
||||
@Override
|
||||
public Dimension getPreferredSize() {
|
||||
@@ -183,57 +212,53 @@ public class RecentProjectPanel extends JPanel {
|
||||
titleLabel.setHorizontalAlignment(SwingConstants.CENTER);
|
||||
titleLabel.setForeground(WelcomeScreenColors.CAPTION_FOREGROUND);
|
||||
title.setBackground(WelcomeScreenColors.CAPTION_BACKGROUND);
|
||||
|
||||
add(title, BorderLayout.NORTH);
|
||||
|
||||
setBorder(new LineBorder(WelcomeScreenColors.BORDER_COLOR));
|
||||
}
|
||||
|
||||
private String getTitle2Text(ReopenProjectAction action, JComponent pathLabel) {
|
||||
String fullText = action.getProjectPath();
|
||||
if (fullText == null || fullText.length() == 0) return " ";
|
||||
|
||||
fullText = FileUtil.getLocationRelativeToUserHome(fullText, false);
|
||||
|
||||
int labelWidth = pathLabel.getWidth();
|
||||
if (pathLabel.getFontMetrics(pathLabel.getFont()).stringWidth(fullText) > labelWidth) {
|
||||
return myPathShortener.getShortPath(action);
|
||||
}
|
||||
|
||||
return fullText;
|
||||
return title;
|
||||
}
|
||||
|
||||
private static class MyList extends JBList {
|
||||
private MyList(@NotNull Object... listData) {
|
||||
private final Dimension mySize;
|
||||
|
||||
private MyList(Dimension size, @NotNull Object... listData) {
|
||||
super(listData);
|
||||
mySize = size;
|
||||
setEmptyText(" No Project Open Yet ");
|
||||
setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dimension getPreferredScrollableViewportSize() {
|
||||
return new Dimension(250, 400);
|
||||
return mySize;
|
||||
}
|
||||
}
|
||||
|
||||
private class RecentProjectItemRenderer extends JPanel implements ListCellRenderer {
|
||||
private final JLabel myName = new JLabel();
|
||||
private final JLabel myPath = new JLabel();
|
||||
protected static class RecentProjectItemRenderer extends JPanel implements ListCellRenderer {
|
||||
protected final JLabel myName = new JLabel();
|
||||
protected final JLabel myPath = new JLabel();
|
||||
private final UniqueNameBuilder<ReopenProjectAction> myShortener;
|
||||
|
||||
private RecentProjectItemRenderer() {
|
||||
protected RecentProjectItemRenderer(UniqueNameBuilder<ReopenProjectAction> pathShortener) {
|
||||
super(new VerticalFlowLayout());
|
||||
myShortener = pathShortener;
|
||||
setFocusable(true);
|
||||
myPath.setFont(myPath.getFont().deriveFont((float)10));
|
||||
add(myName);
|
||||
add(myPath);
|
||||
}
|
||||
|
||||
protected Color getListBackground(boolean isSelected, boolean hasFocus) {
|
||||
return UIUtil.getListBackground(isSelected);
|
||||
}
|
||||
|
||||
protected Color getListForeground(boolean isSelected, boolean hasFocus) {
|
||||
return UIUtil.getListForeground(isSelected);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
|
||||
ReopenProjectAction item = (ReopenProjectAction)value;
|
||||
|
||||
Color fore = UIUtil.getListForeground(isSelected);
|
||||
Color back = UIUtil.getListBackground(isSelected);
|
||||
Color fore = getListForeground(isSelected, cellHasFocus);
|
||||
Color back = getListBackground(isSelected, cellHasFocus);
|
||||
|
||||
myName.setForeground(fore);
|
||||
myPath.setForeground(isSelected ? fore : UIUtil.getInactiveTextColor());
|
||||
@@ -246,6 +271,19 @@ public class RecentProjectPanel extends JPanel {
|
||||
return this;
|
||||
}
|
||||
|
||||
private String getTitle2Text(ReopenProjectAction action, JComponent pathLabel) {
|
||||
String fullText = action.getProjectPath();
|
||||
if (fullText == null || fullText.length() == 0) return " ";
|
||||
|
||||
fullText = FileUtil.getLocationRelativeToUserHome(fullText, false);
|
||||
|
||||
int labelWidth = pathLabel.getWidth();
|
||||
if (pathLabel.getFontMetrics(pathLabel.getFont()).stringWidth(fullText) > labelWidth) {
|
||||
return myShortener.getShortPath(action);
|
||||
}
|
||||
|
||||
return fullText;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dimension getPreferredSize() {
|
||||
|
||||
+7
-7
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2014 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,7 +15,7 @@
|
||||
*/
|
||||
package com.intellij.openapi.wm.impl.welcomeScreen;
|
||||
|
||||
import com.intellij.ide.RecentProjectsManagerBase;
|
||||
import com.intellij.ide.RecentProjectsManager;
|
||||
import com.intellij.openapi.actionSystem.AnAction;
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.openapi.actionSystem.DataContext;
|
||||
@@ -27,22 +27,22 @@ import javax.swing.*;
|
||||
|
||||
/**
|
||||
* This action is not visible in the UI but we keep it available to let users invoke it from keyboard.
|
||||
*
|
||||
* @author pti
|
||||
* Date: Mar 2, 2005
|
||||
*/
|
||||
public class RecentProjectsAction extends WelcomePopupAction {
|
||||
@Override
|
||||
protected void fillActions(final DefaultActionGroup group) {
|
||||
final AnAction[] recentProjectActions = RecentProjectsManagerBase.getInstance().getRecentProjectsActions(false);
|
||||
final AnAction[] recentProjectActions = RecentProjectsManager.getInstance().getRecentProjectsActions(false);
|
||||
for (AnAction action : recentProjectActions) {
|
||||
group.add(action);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getTextForEmpty() {
|
||||
return UIBundle.message("welcome.screen.recent.projects.action.no.recent.projects.to.display.action.name");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getCaption() {
|
||||
return "";
|
||||
}
|
||||
@@ -54,7 +54,7 @@ public class RecentProjectsAction extends WelcomePopupAction {
|
||||
|
||||
@Override
|
||||
public void update(final AnActionEvent e) {
|
||||
e.getPresentation().setVisible(RecentProjectsManagerBase.getInstance().getRecentProjectsActions(false).length > 0);
|
||||
e.getPresentation().setVisible(RecentProjectsManager.getInstance().getRecentProjectsActions(false).length > 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+12
-2
@@ -158,11 +158,21 @@ public class WelcomeFrame extends JFrame implements IdeFrame {
|
||||
}
|
||||
return screen;
|
||||
}
|
||||
|
||||
|
||||
public static void resetInstance() {
|
||||
ourInstance = null;
|
||||
}
|
||||
|
||||
public static void showNow() {
|
||||
if (ourInstance == null) {
|
||||
IdeFrame frame = EP.getExtensions().length == 0 ? new WelcomeFrame() : EP.getExtensions()[0].createFrame();
|
||||
IdeFrame frame = null;
|
||||
for (WelcomeFrameProvider provider : EP.getExtensions()) {
|
||||
frame = provider.createFrame();
|
||||
if (frame != null) break;
|
||||
}
|
||||
if (frame == null) {
|
||||
frame = new WelcomeFrame();
|
||||
}
|
||||
IdeMenuBar.installAppMenuIfNeeded((JFrame)frame);
|
||||
((JFrame)frame).setVisible(true);
|
||||
ourInstance = frame;
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
*/
|
||||
package com.intellij.platform;
|
||||
|
||||
import com.intellij.ide.GeneralSettings;
|
||||
import com.intellij.ide.RecentProjectsManager;
|
||||
import com.intellij.idea.ActionsBundle;
|
||||
import com.intellij.internal.statistic.UsageTrigger;
|
||||
import com.intellij.internal.statistic.beans.ConvertUsagesUtil;
|
||||
@@ -96,7 +96,7 @@ public class NewDirectoryProjectAction extends AnAction implements DumbAware {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
GeneralSettings.getInstance().setLastProjectCreationLocation(location.getParent());
|
||||
RecentProjectsManager.getInstance().setLastProjectCreationLocation(location.getParent());
|
||||
final Object finalSettings = settings;
|
||||
return PlatformProjectOpenProcessor.doOpenProject(baseDir, null, false, -1, new ProjectOpenedCallback() {
|
||||
@Override
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
package com.intellij.ui.mac;
|
||||
|
||||
import com.intellij.ide.DataManager;
|
||||
import com.intellij.ide.RecentProjectsManagerBase;
|
||||
import com.intellij.ide.RecentProjectsManager;
|
||||
import com.intellij.ide.ReopenProjectAction;
|
||||
import com.intellij.openapi.actionSystem.ActionManager;
|
||||
import com.intellij.openapi.actionSystem.ActionPlaces;
|
||||
@@ -35,7 +35,6 @@ import java.lang.reflect.Method;
|
||||
* @author Denis Fokin
|
||||
*/
|
||||
public class MacDockDelegate implements SystemDock.Delegate {
|
||||
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.ui.mac.MacDockDelegate");
|
||||
|
||||
private static boolean initialized = false;
|
||||
@@ -57,8 +56,9 @@ public class MacDockDelegate implements SystemDock.Delegate {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateRecentProjectsMenu () {
|
||||
final AnAction[] recentProjectActions = RecentProjectsManagerBase.getInstance().getRecentProjectsActions(false);
|
||||
final AnAction[] recentProjectActions = RecentProjectsManager.getInstance().getRecentProjectsActions(false);
|
||||
recentProjectsMenu.removeAll();
|
||||
|
||||
for (final AnAction action : recentProjectActions) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
* Copyright 2000-2014 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,19 +15,19 @@
|
||||
*/
|
||||
package com.intellij.ui.win;
|
||||
|
||||
import com.intellij.ide.RecentProjectsManagerBase;
|
||||
import com.intellij.ide.RecentProjectsManager;
|
||||
import com.intellij.ide.ReopenProjectAction;
|
||||
import com.intellij.idea.StartupUtil;
|
||||
import com.intellij.openapi.actionSystem.AnAction;
|
||||
import com.intellij.openapi.application.PathManager;
|
||||
import com.intellij.openapi.wm.impl.SystemDock;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
/**
|
||||
* @author Denis Fokin
|
||||
*/
|
||||
public class WinDockDelegate implements SystemDock.Delegate {
|
||||
|
||||
private static final String javaExe = System.getProperty("java.home") + File.separatorChar + "bin" + File.separatorChar + "javaw.exe";
|
||||
private static final String argsToExecute = " -classpath \"" +
|
||||
PathManager.getJarPathForClass(SocketControlHelper.class) +
|
||||
@@ -40,8 +40,9 @@ public class WinDockDelegate implements SystemDock.Delegate {
|
||||
|
||||
private WinDockDelegate() {}
|
||||
|
||||
@Override
|
||||
public void updateRecentProjectsMenu () {
|
||||
final AnAction[] recentProjectActions = RecentProjectsManagerBase.getInstance().getRecentProjectsActions(false);
|
||||
final AnAction[] recentProjectActions = RecentProjectsManager.getInstance().getRecentProjectsActions(false);
|
||||
RecentTasks.clear();
|
||||
Task[] tasks = new Task[recentProjectActions.length];
|
||||
for (int i = 0; i < recentProjectActions.length; i ++) {
|
||||
|
||||
@@ -207,6 +207,8 @@
|
||||
|
||||
<projectService serviceInterface="com.intellij.openapi.project.ProjectReloadState"
|
||||
serviceImplementation="com.intellij.openapi.project.impl.ProjectReloadStateImpl"/>
|
||||
|
||||
<welcomeFrameProvider implementation="com.intellij.openapi.wm.impl.welcomeScreen.FlatWelcomeFrame"/>
|
||||
|
||||
<!-- General -->
|
||||
<applicationConfigurable groupId="appearance" groupWeight="120" key="title.general" bundle="messages.IdeBundle" id="preferences.general"
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
<xi:include href="/META-INF/VcsExtensions.xml" xpointer="xpointer(/idea-plugin/extensions/*)"/>
|
||||
<xi:include href="/META-INF/LangExtensions.xml" xpointer="xpointer(/idea-plugin/extensions/*)"/>
|
||||
|
||||
<applicationService serviceInterface="com.intellij.ide.RecentProjectsManagerBase"
|
||||
<applicationService serviceInterface="com.intellij.ide.RecentProjectsManager"
|
||||
serviceImplementation="com.intellij.ide.RecentDirectoryProjectsManagerEx"/>
|
||||
|
||||
<applicationService serviceInterface="com.intellij.packageDependencies.DependenciesVisitorFactory"
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
<xi:include href="/META-INF/PlatformExtensions.xml" xpointer="xpointer(/idea-plugin/extensions/*)"/>
|
||||
<xi:include href="/META-INF/VcsExtensions.xml" xpointer="xpointer(/idea-plugin/extensions/*)"/>
|
||||
|
||||
<applicationService serviceInterface="com.intellij.ide.RecentProjectsManagerBase"
|
||||
<applicationService serviceInterface="com.intellij.ide.RecentProjectsManager"
|
||||
serviceImplementation="com.intellij.ide.RecentDirectoryProjectsManager"/>
|
||||
|
||||
<applicationService serviceInterface="com.intellij.codeStyle.CodeStyleFacade"
|
||||
|
||||
Binary file not shown.
Binary file not shown.
+70
-16
@@ -15,8 +15,13 @@
|
||||
*/
|
||||
package com.intellij.openapi.vfs.local;
|
||||
|
||||
import com.intellij.openapi.actionSystem.CommonDataKeys;
|
||||
import com.intellij.openapi.actionSystem.DataContext;
|
||||
import com.intellij.openapi.actionSystem.LangDataKeys;
|
||||
import com.intellij.openapi.actionSystem.impl.SimpleDataContext;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.application.ex.PathManagerEx;
|
||||
import com.intellij.openapi.command.WriteCommandAction;
|
||||
import com.intellij.openapi.util.Ref;
|
||||
import com.intellij.openapi.util.io.IoTestUtil;
|
||||
import com.intellij.openapi.vfs.JarFileSystem;
|
||||
@@ -26,8 +31,17 @@ import com.intellij.openapi.vfs.VirtualFileManager;
|
||||
import com.intellij.openapi.vfs.newvfs.BulkFileListener;
|
||||
import com.intellij.openapi.vfs.newvfs.events.VFileContentChangeEvent;
|
||||
import com.intellij.openapi.vfs.newvfs.events.VFileEvent;
|
||||
import com.intellij.psi.PsiDirectory;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.psi.PsiNamedElement;
|
||||
import com.intellij.refactoring.move.MoveHandler;
|
||||
import com.intellij.refactoring.rename.PsiElementRenameHandler;
|
||||
import com.intellij.refactoring.rename.RenameHandler;
|
||||
import com.intellij.refactoring.rename.RenameHandlerRegistry;
|
||||
import com.intellij.testFramework.PlatformLangTestCase;
|
||||
import com.intellij.testFramework.PlatformTestUtil;
|
||||
import com.intellij.testFramework.PsiTestUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.File;
|
||||
@@ -70,27 +84,67 @@ public class JarFileSystemTest extends PlatformLangTestCase {
|
||||
|
||||
public void testJarRefreshOnRenameOrMove() throws IOException {
|
||||
File jar = IoTestUtil.createTestJar();
|
||||
assertTrue(jar.setLastModified(jar.lastModified() - 1000));
|
||||
VirtualFile vFile = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(jar);
|
||||
final VirtualFile vFile = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(jar);
|
||||
assertNotNull(vFile);
|
||||
new WriteCommandAction.Simple(myProject) {
|
||||
|
||||
ApplicationManager.getApplication().getMessageBus().connect(myTestRootDisposable).subscribe(
|
||||
VirtualFileManager.VFS_CHANGES,
|
||||
new BulkFileListener.Adapter() {
|
||||
@Override
|
||||
public void before(@NotNull List<? extends VFileEvent> events) {
|
||||
for (VFileEvent event : events) {
|
||||
//if (event instanceof VFileContentChangeEvent && entry.equals(event.getFile())) {
|
||||
// updated.set(true);
|
||||
// break;
|
||||
//}
|
||||
}
|
||||
}
|
||||
@Override
|
||||
protected void run() throws Throwable {
|
||||
PsiTestUtil.addContentRoot(myModule, vFile.getParent());
|
||||
}
|
||||
);
|
||||
}.execute();
|
||||
|
||||
assertTrue(jar.renameTo(new File(jar.getParentFile(), jar.getName() + ".jar")));
|
||||
VirtualFile jarRoot = findByPath(jar.getPath() + JarFileSystem.JAR_SEPARATOR);
|
||||
final PsiFile file = getPsiManager().findFile(vFile);
|
||||
final String newName = vFile.getName() + ".jar";
|
||||
rename(file, newName);
|
||||
|
||||
assertFalse(jarRoot.isValid());
|
||||
|
||||
checkMove(jar, vFile, file);
|
||||
}
|
||||
|
||||
private void checkMove(File jar, VirtualFile vFile, final PsiFile file) {
|
||||
VirtualFile jarRoot;
|
||||
File libDir = new File(jar.getParent(), "lib");
|
||||
assertTrue(libDir.mkdir());
|
||||
final VirtualFile vLibDir = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(libDir);
|
||||
assertNotNull(vLibDir);
|
||||
|
||||
jarRoot = findByPath(vFile.getPath() + JarFileSystem.JAR_SEPARATOR);
|
||||
assertTrue(jarRoot.isValid());
|
||||
PsiDirectory directory = getPsiManager().findDirectory(vLibDir);
|
||||
final DataContext
|
||||
psiDataContext = SimpleDataContext.getSimpleContext(LangDataKeys.TARGET_PSI_ELEMENT.getName(), directory);
|
||||
new WriteCommandAction.Simple(myProject) {
|
||||
|
||||
@Override
|
||||
protected void run() throws Throwable {
|
||||
new MoveHandler().invoke(myProject, new PsiElement[] {file}, psiDataContext);
|
||||
}
|
||||
}.execute();
|
||||
assertFalse(jarRoot.isValid());
|
||||
|
||||
jarRoot = findByPath(vFile.getPath() + JarFileSystem.JAR_SEPARATOR);
|
||||
assertTrue(jarRoot.isValid());
|
||||
rename(directory, "lib2");
|
||||
assertFalse(jarRoot.isValid());
|
||||
}
|
||||
|
||||
private static void rename(final PsiNamedElement file, final String newName) {
|
||||
final DataContext psiDataContext = SimpleDataContext.getSimpleContext(CommonDataKeys.PSI_ELEMENT.getName(), file);
|
||||
final RenameHandler renameHandler =
|
||||
RenameHandlerRegistry.getInstance().getRenameHandler(psiDataContext);
|
||||
assertNotNull(renameHandler);
|
||||
|
||||
new WriteCommandAction.Simple(file.getProject()) {
|
||||
@Override
|
||||
public void run() {
|
||||
PsiElementRenameHandler.rename(file, file.getProject(), file, null, newName);
|
||||
}
|
||||
}.execute();
|
||||
}
|
||||
|
||||
public void testJarRefresh() throws IOException {
|
||||
File jar = IoTestUtil.createTestJar();
|
||||
assertTrue(jar.setLastModified(jar.lastModified() - 1000));
|
||||
|
||||
+3
@@ -23,6 +23,7 @@ import com.intellij.openapi.util.JDOMUtil;
|
||||
import com.intellij.openapi.util.text.StringUtilRt;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.util.SmartList;
|
||||
import com.intellij.util.containers.StringInterner;
|
||||
import gnu.trove.THashMap;
|
||||
import gnu.trove.TObjectObjectProcedure;
|
||||
import org.jdom.Element;
|
||||
@@ -71,6 +72,7 @@ public class DirectoryStorageData extends StorageDataBase {
|
||||
return;
|
||||
}
|
||||
|
||||
StringInterner interner = new StringInterner();
|
||||
for (VirtualFile file : dir.getChildren()) {
|
||||
if (!isStorageFile(file)) {
|
||||
continue;
|
||||
@@ -94,6 +96,7 @@ public class DirectoryStorageData extends StorageDataBase {
|
||||
}
|
||||
|
||||
Element state = (Element)elementChildren.get(0).detach();
|
||||
JDOMUtil.internElement(state, interner);
|
||||
if (pathMacroSubstitutor != null) {
|
||||
pathMacroSubstitutor.expandPaths(state);
|
||||
pathMacroSubstitutor.addUnknownMacros(name, PathMacrosCollector.getMacroNames(state));
|
||||
|
||||
+2
-3
@@ -26,7 +26,7 @@ import com.intellij.openapi.util.JDOMUtil;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import com.intellij.util.containers.SmartHashSet;
|
||||
import com.intellij.util.containers.WeakStringInterner;
|
||||
import com.intellij.util.containers.StringInterner;
|
||||
import org.jdom.Attribute;
|
||||
import org.jdom.Element;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
@@ -67,8 +67,7 @@ public class StorageData extends StorageDataBase {
|
||||
pathMacroSubstitutor.expandPaths(rootElement);
|
||||
}
|
||||
|
||||
WeakStringInterner interner = intern ? new WeakStringInterner() : null;
|
||||
|
||||
StringInterner interner = intern ? new StringInterner() : null;
|
||||
for (Iterator<Element> iterator = rootElement.getChildren(COMPONENT).iterator(); iterator.hasNext(); ) {
|
||||
Element element = iterator.next();
|
||||
String name = getComponentNameIfValid(element);
|
||||
|
||||
@@ -456,3 +456,4 @@ editor.disable.rtl.description=Disables RTL support in editor (which is broken n
|
||||
decompiler.use.line.table=false
|
||||
ide.transparency.mode.for.windows=false
|
||||
ide.transparency.mode.for.windows.description=Allow to add transparency to floating windows
|
||||
ide.new.welcome.screen=false
|
||||
|
||||
@@ -132,7 +132,12 @@ public class JDOMUtil {
|
||||
return i * 31 + s.hashCode();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@NotNull
|
||||
@Deprecated
|
||||
/**
|
||||
* to remove in IDEA 15
|
||||
*/
|
||||
public static Object[] getChildNodesWithAttrs(@NotNull Element e) {
|
||||
ArrayList<Object> result = new ArrayList<Object>();
|
||||
result.addAll(e.getContent());
|
||||
|
||||
@@ -1227,6 +1227,14 @@ public class ContainerUtil extends ContainerUtilRt {
|
||||
if (list1.isEmpty() && list2.isEmpty()) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
else if (list1.isEmpty()) {
|
||||
//noinspection unchecked
|
||||
return (List<T>)list2;
|
||||
}
|
||||
else if (list2.isEmpty()) {
|
||||
//noinspection unchecked
|
||||
return (List<T>)list1;
|
||||
}
|
||||
|
||||
final int size1 = list1.size();
|
||||
final int size = size1 + list2.size();
|
||||
|
||||
@@ -24,31 +24,46 @@ import com.intellij.util.EventDispatcher;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.EventListener;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.Stack;
|
||||
|
||||
public class HeavyProcessLatch {
|
||||
public static final HeavyProcessLatch INSTANCE = new HeavyProcessLatch();
|
||||
|
||||
private final AtomicInteger myHeavyProcessCounter = new AtomicInteger();
|
||||
private final Stack<String> myHeavyProcesses = new Stack<String>();
|
||||
private final EventDispatcher<HeavyProcessListener> myEventDispatcher = EventDispatcher.create(HeavyProcessListener.class);
|
||||
|
||||
private HeavyProcessLatch() {
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated use {@link #processStarted(java.lang.String)} instead
|
||||
*/
|
||||
@Deprecated
|
||||
public void processStarted() {
|
||||
myHeavyProcessCounter.incrementAndGet();
|
||||
processStarted("");
|
||||
}
|
||||
|
||||
public void processStarted(@NotNull String operationName) {
|
||||
myHeavyProcesses.push(operationName);
|
||||
myEventDispatcher.getMulticaster().processStarted();
|
||||
}
|
||||
|
||||
public void processFinished() {
|
||||
myHeavyProcessCounter.decrementAndGet();
|
||||
myHeavyProcesses.pop();
|
||||
myEventDispatcher.getMulticaster().processFinished();
|
||||
}
|
||||
|
||||
public boolean isRunning() {
|
||||
return myHeavyProcessCounter.get() != 0;
|
||||
return !myHeavyProcesses.isEmpty();
|
||||
}
|
||||
|
||||
public String getRunningOperationName() {
|
||||
synchronized (myHeavyProcesses) {
|
||||
return myHeavyProcesses.isEmpty() ? null : myHeavyProcesses.peek();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public interface HeavyProcessListener extends EventListener {
|
||||
public void processStarted();
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
* Copyright 2000-2014 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.
|
||||
@@ -19,12 +19,15 @@ package com.intellij.util.xmlb;
|
||||
import com.intellij.util.SmartList;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.xmlb.annotations.AbstractCollection;
|
||||
import gnu.trove.THashMap;
|
||||
import org.jdom.Content;
|
||||
import org.jdom.Element;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
abstract class AbstractCollectionBinding implements Binding {
|
||||
private Map<Class, Binding> myElementBindings;
|
||||
@@ -67,14 +70,11 @@ abstract class AbstractCollectionBinding implements Binding {
|
||||
|
||||
private synchronized Map<Class, Binding> getElementBindings() {
|
||||
if (myElementBindings == null) {
|
||||
myElementBindings = new HashMap<Class, Binding>();
|
||||
|
||||
myElementBindings = new THashMap<Class, Binding>();
|
||||
myElementBindings.put(myElementType, getBinding(myElementType));
|
||||
|
||||
if (myAnnotation != null) {
|
||||
for (Class aClass : myAnnotation.elementTypes()) {
|
||||
myElementBindings.put(aClass, getBinding(aClass));
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -145,34 +145,41 @@ abstract class AbstractCollectionBinding implements Binding {
|
||||
@Override
|
||||
public Object deserialize(Object o, @NotNull Object... nodes) {
|
||||
Collection result;
|
||||
if (getTagName(o) != null) {
|
||||
assert nodes.length == 1;
|
||||
Element e = (Element)nodes[0];
|
||||
result = createCollection(e.getName());
|
||||
List<Content> content = e.getContent();
|
||||
//noinspection ForLoopReplaceableByForEach
|
||||
for (int i = 0, size = content.size(); i < size; i++) {
|
||||
Content child = content.get(i);
|
||||
if (!XmlSerializerImpl.isIgnoredNode(child)) {
|
||||
//noinspection unchecked
|
||||
result.add(getElementBinding(child).deserialize(o, child));
|
||||
}
|
||||
if (getTagName(o) == null) {
|
||||
if (o instanceof Collection) {
|
||||
result = (Collection)o;
|
||||
result.clear();
|
||||
}
|
||||
else {
|
||||
result = new SmartList();
|
||||
}
|
||||
}
|
||||
else {
|
||||
result = new SmartList();
|
||||
for (Object node : nodes) {
|
||||
if (!XmlSerializerImpl.isIgnoredNode(node)) {
|
||||
//noinspection unchecked
|
||||
result.add(getElementBinding(node).deserialize(o, node));
|
||||
}
|
||||
}
|
||||
|
||||
if (result == o) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
else {
|
||||
assert nodes.length == 1;
|
||||
Element e = (Element)nodes[0];
|
||||
result = createCollection(e.getName());
|
||||
for (Content child : e.getContent()) {
|
||||
if (!XmlSerializerImpl.isIgnoredNode(child)) {
|
||||
//noinspection unchecked
|
||||
result.add(getElementBinding(child).deserialize(o, child));
|
||||
}
|
||||
}
|
||||
}
|
||||
return processResult(result, o);
|
||||
}
|
||||
|
||||
protected Collection createCollection(final String tagName) {
|
||||
return new ArrayList();
|
||||
protected Collection createCollection(@NotNull String tagName) {
|
||||
return new SmartList();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
* Copyright 2000-2014 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.
|
||||
@@ -13,7 +13,6 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.intellij.util.xmlb;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -23,7 +22,7 @@ class AccessorBindingWrapper implements Binding {
|
||||
private final Accessor myAccessor;
|
||||
private final Binding myBinding;
|
||||
|
||||
public AccessorBindingWrapper(final Accessor accessor, final Binding binding) {
|
||||
public AccessorBindingWrapper(@NotNull Accessor accessor, @NotNull Binding binding) {
|
||||
myAccessor = accessor;
|
||||
myBinding = binding;
|
||||
}
|
||||
@@ -41,7 +40,11 @@ class AccessorBindingWrapper implements Binding {
|
||||
@Override
|
||||
@Nullable
|
||||
public Object deserialize(Object context, @NotNull Object... nodes) {
|
||||
myAccessor.write(context, myBinding.deserialize(myAccessor.read(context), nodes));
|
||||
Object currentValue = myAccessor.read(context);
|
||||
Object deserializedValue = myBinding.deserialize(currentValue, nodes);
|
||||
if (currentValue != deserializedValue) {
|
||||
myAccessor.write(context, deserializedValue);
|
||||
}
|
||||
return context;
|
||||
}
|
||||
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.intellij.util.xmlb;
|
||||
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
@@ -22,12 +21,13 @@ import com.intellij.openapi.util.JDOMUtil;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import com.intellij.util.ReflectionUtil;
|
||||
import com.intellij.util.containers.ConcurrentSoftValueHashMap;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.containers.MultiMap;
|
||||
import com.intellij.util.containers.hash.LinkedHashMap;
|
||||
import com.intellij.util.xmlb.annotations.*;
|
||||
import org.jdom.Element;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -36,23 +36,20 @@ import java.beans.Introspector;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.util.*;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
class BeanBinding implements Binding {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.util.xmlb.BeanBinding");
|
||||
private static final Logger LOG = Logger.getInstance(BeanBinding.class);
|
||||
|
||||
private static final Map<Class, List<Accessor>> ourAccessorCache = new ConcurrentSoftValueHashMap<Class, List<Accessor>>();
|
||||
|
||||
private final String myTagName;
|
||||
private final Map<Binding, Accessor> myPropertyBindings = new HashMap<Binding, Accessor>();
|
||||
private final List<Binding> myPropertyBindingsList = new ArrayList<Binding>();
|
||||
private final LinkedHashMap<Binding, Accessor> myPropertyBindings = new LinkedHashMap<Binding, Accessor>();
|
||||
private final Class<?> myBeanClass;
|
||||
@NonNls private static final String CLASS_PROPERTY = "class";
|
||||
private final Accessor myAccessor;
|
||||
|
||||
public BeanBinding(Class<?> beanClass, @Nullable Accessor accessor) {
|
||||
myAccessor = accessor;
|
||||
public BeanBinding(Class<?> beanClass) {
|
||||
assert !beanClass.isArray() : "Bean is an array: " + beanClass;
|
||||
assert !beanClass.isPrimitive() : "Bean is primitive type: " + beanClass;
|
||||
myBeanClass = beanClass;
|
||||
@@ -67,9 +64,7 @@ class BeanBinding implements Binding {
|
||||
|
||||
private synchronized void initPropertyBindings(Class<?> beanClass) {
|
||||
for (Accessor accessor : getAccessors(beanClass)) {
|
||||
final Binding binding = createBindingByAccessor(accessor);
|
||||
myPropertyBindingsList.add(binding);
|
||||
myPropertyBindings.put(binding, accessor);
|
||||
myPropertyBindings.put(createBindingByAccessor(accessor), accessor);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -82,20 +77,21 @@ class BeanBinding implements Binding {
|
||||
}
|
||||
|
||||
public void serializeInto(@NotNull Object o, @NotNull Element element, @NotNull SerializationFilter filter) {
|
||||
for (Binding binding : myPropertyBindingsList) {
|
||||
for (Binding binding : myPropertyBindings.keySet()) {
|
||||
Accessor accessor = myPropertyBindings.get(binding);
|
||||
if (!filter.accepts(accessor, o)) continue;
|
||||
if (!filter.accepts(accessor, o)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
//todo: optimize. Cache it.
|
||||
final Property property = XmlSerializerImpl.findAnnotation(accessor.getAnnotations(), Property.class);
|
||||
if (property != null) {
|
||||
Property property = XmlSerializerImpl.findAnnotation(accessor.getAnnotations(), Property.class);
|
||||
if (property != null && property.filter() != SerializationFilter.class) {
|
||||
try {
|
||||
if (!property.filter().newInstance().accepts(accessor, o)) continue;
|
||||
if (!ReflectionUtil.newInstance(property.filter()).accepts(accessor, o)) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
catch (InstantiationException e) {
|
||||
throw new XmlSerializationException(e);
|
||||
}
|
||||
catch (IllegalAccessException e) {
|
||||
catch (RuntimeException e) {
|
||||
throw new XmlSerializationException(e);
|
||||
}
|
||||
}
|
||||
@@ -112,39 +108,30 @@ class BeanBinding implements Binding {
|
||||
}
|
||||
}
|
||||
|
||||
public void deserializeInto(final Object bean, @NotNull Element element) {
|
||||
_deserializeInto(bean, element);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object deserialize(Object o, @NotNull Object... nodes) {
|
||||
return _deserializeInto(instantiateBean(), nodes);
|
||||
Element element = null;
|
||||
for (Object aNode : nodes) {
|
||||
if (!XmlSerializerImpl.isIgnoredNode(aNode)) {
|
||||
element = (Element)aNode;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (element == null) {
|
||||
return o;
|
||||
}
|
||||
return deserializeInto(XmlSerializerImpl.newInstance(myBeanClass), element);
|
||||
}
|
||||
|
||||
private Object _deserializeInto(final Object result, @NotNull Object... aNodes) {
|
||||
List<Object> nodes = new ArrayList<Object>();
|
||||
for (Object aNode : aNodes) {
|
||||
if (XmlSerializerImpl.isIgnoredNode(aNode)) continue;
|
||||
nodes.add(aNode);
|
||||
}
|
||||
|
||||
if (nodes.size() != 1) {
|
||||
if (nodes.isEmpty()) {
|
||||
return result;
|
||||
}
|
||||
throw new XmlSerializationException("Wrong set of nodes: " + nodes + " for bean" + myBeanClass + " in " + myAccessor);
|
||||
}
|
||||
assert nodes.get(0) instanceof Element : "Wrong node: " + nodes;
|
||||
Element e = (Element)nodes.get(0);
|
||||
|
||||
ArrayList<Binding> bindings = new ArrayList<Binding>(myPropertyBindings.keySet());
|
||||
|
||||
MultiMap<Binding, Object> data = new MultiMap<Binding, Object>();
|
||||
|
||||
final Object[] children = JDOMUtil.getChildNodesWithAttrs(e);
|
||||
public Object deserializeInto(@NotNull Object result, @NotNull Element element) {
|
||||
Set<Binding> bindings = myPropertyBindings.keySet();
|
||||
MultiMap<Binding, Object> data = MultiMap.createSmartList();
|
||||
nextNode:
|
||||
for (Object child : children) {
|
||||
if (XmlSerializerImpl.isIgnoredNode(child)) continue;
|
||||
for (Object child : ContainerUtil.concat(element.getContent(), element.getAttributes())) {
|
||||
if (XmlSerializerImpl.isIgnoredNode(child)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (Binding binding : bindings) {
|
||||
if (binding.isBoundTo(child)) {
|
||||
@@ -153,27 +140,19 @@ class BeanBinding implements Binding {
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
final String message = "Format error: no binding for " + child + " inside " + this;
|
||||
LOG.debug(message);
|
||||
Logger.getInstance(myBeanClass.getName()).debug(message);
|
||||
Logger.getInstance("#" + myBeanClass.getName()).debug(message);
|
||||
}
|
||||
final String message = "Format error: no binding for " + child + " inside " + this;
|
||||
LOG.debug(message);
|
||||
Logger.getInstance(myBeanClass.getName()).debug(message);
|
||||
Logger.getInstance("#" + myBeanClass.getName()).debug(message);
|
||||
}
|
||||
|
||||
for (Object o1 : data.keySet()) {
|
||||
Binding binding = (Binding)o1;
|
||||
Collection<Object> nn = data.get(binding);
|
||||
binding.deserialize(result, ArrayUtil.toObjectArray(nn));
|
||||
for (Binding binding : data.keySet()) {
|
||||
binding.deserialize(result, ArrayUtil.toObjectArray(data.get(binding)));
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private Object instantiateBean() {
|
||||
return XmlSerializerImpl.newInstance(myBeanClass);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBoundTo(Object node) {
|
||||
return node instanceof Element && ((Element)node).getName().equals(myTagName);
|
||||
@@ -224,7 +203,7 @@ class BeanBinding implements Binding {
|
||||
for (Method method : aClass.getMethods()) {
|
||||
if (!Modifier.isPublic(method.getModifiers())) continue;
|
||||
final Pair<String, Boolean> propertyData = getPropertyData(method.getName()); // (name,isSetter)
|
||||
if (propertyData == null || propertyData.first.equals(CLASS_PROPERTY)) continue;
|
||||
if (propertyData == null || propertyData.first.equals("class")) continue;
|
||||
if (method.getParameterTypes().length != (propertyData.second ? 1 : 0)) continue;
|
||||
|
||||
Couple<Method> candidate = candidates.get(propertyData.first);
|
||||
@@ -276,7 +255,7 @@ class BeanBinding implements Binding {
|
||||
return "BeanBinding[" + myBeanClass.getName() + ", tagName=" + myTagName + "]";
|
||||
}
|
||||
|
||||
private static Binding createBindingByAccessor(final Accessor accessor) {
|
||||
private static Binding createBindingByAccessor(@NotNull Accessor accessor) {
|
||||
final Binding binding = _createBinding(accessor);
|
||||
binding.init();
|
||||
return binding;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
* Copyright 2000-2014 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.
|
||||
@@ -13,7 +13,6 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.intellij.util.xmlb;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -35,10 +34,11 @@ class CollectionBinding extends AbstractCollectionBinding {
|
||||
return (Class)arg;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
Object processResult(Collection result, Object target) {
|
||||
if (myAccessor == null) return result;
|
||||
if (myAccessor == null) {
|
||||
return result;
|
||||
}
|
||||
|
||||
assert target != null: "Null target in " + myAccessor;
|
||||
assert target instanceof Collection : "Wrong target: " + target.getClass() + " in " + myAccessor;
|
||||
@@ -69,9 +69,7 @@ class CollectionBinding extends AbstractCollectionBinding {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Collection createCollection(final String tagName) {
|
||||
if (tagName.equals(Constants.SET)) return new HashSet();
|
||||
if (tagName.equals(Constants.LIST)) return new ArrayList();
|
||||
return super.createCollection(tagName);
|
||||
protected Collection createCollection(@NotNull String tagName) {
|
||||
return tagName.equals(Constants.SET) ? new HashSet() : super.createCollection(tagName);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,24 +0,0 @@
|
||||
/*
|
||||
* Copyright 2000-2013 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.util.xmlb;
|
||||
|
||||
public class DefaultSerializationFilter implements SerializationFilter {
|
||||
@Override
|
||||
public boolean accepts(Accessor accessor, Object bean) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -97,10 +97,7 @@ public class XmlSerializer {
|
||||
|
||||
public static void deserializeInto(@NotNull Object bean, @NotNull Element element) {
|
||||
try {
|
||||
final Binding binding = XmlSerializerImpl.getBinding(bean.getClass());
|
||||
assert binding instanceof BeanBinding;
|
||||
|
||||
((BeanBinding)binding).deserializeInto(bean, element);
|
||||
((BeanBinding)XmlSerializerImpl.getBinding(bean.getClass())).deserializeInto(bean, element);
|
||||
}
|
||||
catch (XmlSerializationException e) {
|
||||
throw e;
|
||||
|
||||
@@ -123,7 +123,7 @@ class XmlSerializerImpl {
|
||||
if (Date.class.isAssignableFrom(aClass)) return new DateBinding();
|
||||
if (aClass.isEnum()) return new PrimitiveValueBinding(aClass);
|
||||
|
||||
return new BeanBinding(aClass, accessor);
|
||||
return new BeanBinding(aClass);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2014 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.
|
||||
@@ -13,10 +13,8 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.intellij.util.xmlb.annotations;
|
||||
|
||||
import com.intellij.util.xmlb.DefaultSerializationFilter;
|
||||
import com.intellij.util.xmlb.SerializationFilter;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
@@ -31,5 +29,6 @@ import java.lang.annotation.Target;
|
||||
@Target({ElementType.FIELD, ElementType.TYPE, ElementType.METHOD})
|
||||
public @interface Property {
|
||||
boolean surroundWithTag() default true;
|
||||
Class<? extends SerializationFilter> filter() default DefaultSerializationFilter.class;
|
||||
|
||||
Class<? extends SerializationFilter> filter() default SerializationFilter.class;
|
||||
}
|
||||
|
||||
@@ -33,4 +33,7 @@ public interface VcsLogUi {
|
||||
|
||||
void setBranchesPanelVisible(boolean visible);
|
||||
|
||||
boolean isMultipleRoots();
|
||||
boolean isShowRootNames();
|
||||
void setShowRootNames(boolean showRootNames);
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ public class VcsLogQuickSettingsActions extends DumbAwareAction {
|
||||
@NotNull
|
||||
@Override
|
||||
public AnAction[] getChildren(@Nullable AnActionEvent e) {
|
||||
return new AnAction[]{new ShowBranchesPanelAction()};
|
||||
return new AnAction[]{new ShowBranchesPanelAction(), new ShowRootsColumnAction()};
|
||||
}
|
||||
|
||||
private class ShowBranchesPanelAction extends ToggleAction implements DumbAware {
|
||||
@@ -89,5 +89,31 @@ public class VcsLogQuickSettingsActions extends DumbAwareAction {
|
||||
myUi.setBranchesPanelVisible(state);
|
||||
}
|
||||
}
|
||||
|
||||
private class ShowRootsColumnAction extends ToggleAction implements DumbAware {
|
||||
|
||||
public ShowRootsColumnAction() {
|
||||
super("Show Root Names");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(AnActionEvent e) {
|
||||
super.update(e);
|
||||
|
||||
boolean visible = myUi.isMultipleRoots();
|
||||
e.getPresentation().setVisible(visible);
|
||||
e.getPresentation().setEnabled(visible);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSelected(AnActionEvent e) {
|
||||
return myUi.isShowRootNames();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSelected(AnActionEvent e, boolean state) {
|
||||
myUi.setShowRootNames(state);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -190,6 +190,7 @@ public class VcsLogUiImpl implements VcsLogUi, Disposable {
|
||||
|
||||
public void setShowRootNames(boolean isShowRootNames) {
|
||||
myUiProperties.setShowRootNames(isShowRootNames);
|
||||
myMainFrame.getGraphTable().rootColumnUpdated();
|
||||
}
|
||||
|
||||
public boolean isShowRootNames() {
|
||||
@@ -286,6 +287,11 @@ public class VcsLogUiImpl implements VcsLogUi, Disposable {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isMultipleRoots() {
|
||||
return myColorManager.isMultipleRoots(); // somewhy color manager knows about this
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public VcsLogColorManager getColorManager() {
|
||||
return myColorManager;
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package com.intellij.vcs.log.ui.frame;
|
||||
|
||||
import com.intellij.icons.AllIcons;
|
||||
import com.intellij.ide.CopyProvider;
|
||||
import com.intellij.openapi.actionSystem.*;
|
||||
import com.intellij.openapi.ide.CopyPasteManager;
|
||||
@@ -74,7 +75,9 @@ import static com.intellij.vcs.log.printer.idea.PrintParameters.HEIGHT_CELL;
|
||||
|
||||
public class VcsLogGraphTable extends JBTable implements TypeSafeDataProvider, CopyProvider {
|
||||
|
||||
private static final int ROOT_INDICATOR_WIDTH = 5;
|
||||
private static final int ROOT_INDICATOR_COLORED_WIDTH = 8;
|
||||
private static final int ROOT_INDICATOR_WHITE_WIDTH = 5;
|
||||
private static final int ROOT_INDICATOR_WIDTH = ROOT_INDICATOR_WHITE_WIDTH + ROOT_INDICATOR_COLORED_WIDTH;
|
||||
private static final int ROOT_NAME_MAX_WIDTH = 200;
|
||||
private static final int MAX_DEFAULT_AUTHOR_COLUMN_WIDTH = 200;
|
||||
private static final int MAX_ROWS_TO_CALC_WIDTH = 1000;
|
||||
@@ -103,8 +106,7 @@ public class VcsLogGraphTable extends JBTable implements TypeSafeDataProvider, C
|
||||
myUI = UI;
|
||||
myLogDataHolder = logDataHolder;
|
||||
myDataPack = initialDataPack;
|
||||
myGraphCommitCellRender = new GraphCommitCellRender(myUI.getColorManager(), logDataHolder, myGraphCellPainter,
|
||||
myDataPack.getVisibleGraph(), this);
|
||||
myGraphCommitCellRender = new GraphCommitCellRender(myUI.getColorManager(), logDataHolder, myGraphCellPainter, myDataPack.getVisibleGraph(), this);
|
||||
|
||||
setDefaultRenderer(VirtualFile.class, new RootCellRenderer(myUI));
|
||||
setDefaultRenderer(GraphCommitCell.class, myGraphCommitCellRender);
|
||||
@@ -117,6 +119,9 @@ public class VcsLogGraphTable extends JBTable implements TypeSafeDataProvider, C
|
||||
MouseAdapter mouseAdapter = new MyMouseAdapter();
|
||||
addMouseMotionListener(mouseAdapter);
|
||||
addMouseListener(mouseAdapter);
|
||||
MyHeaderMouseAdapter headerAdapter = new MyHeaderMouseAdapter();
|
||||
getTableHeader().addMouseListener(headerAdapter);
|
||||
getTableHeader().addMouseMotionListener(headerAdapter);
|
||||
|
||||
getTableHeader().setReorderingAllowed(false);
|
||||
|
||||
@@ -132,6 +137,8 @@ public class VcsLogGraphTable extends JBTable implements TypeSafeDataProvider, C
|
||||
myColumnsSizeInitialized = true;
|
||||
setColumnPreferredSize();
|
||||
setAutoCreateColumnsFromModel(false); // otherwise sizes are recalculated after each TableColumn re-initialization
|
||||
|
||||
getColumnModel().getColumn(GraphTableModel.ROOT_COLUMN).setHeaderRenderer(new RootHeaderRenderer());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -164,7 +171,7 @@ public class VcsLogGraphTable extends JBTable implements TypeSafeDataProvider, C
|
||||
|
||||
private void setRootColumnSize(TableColumn column) {
|
||||
int rootWidth;
|
||||
if (!myUI.getColorManager().isMultipleRoots()) {
|
||||
if (!myUI.isMultipleRoots()) {
|
||||
rootWidth = 0;
|
||||
}
|
||||
else if (!myUI.isShowRootNames()) {
|
||||
@@ -209,7 +216,7 @@ public class VcsLogGraphTable extends JBTable implements TypeSafeDataProvider, C
|
||||
if (column == GraphTableModel.ROOT_COLUMN) {
|
||||
Object at = getValueAt(row, column);
|
||||
if (at instanceof VirtualFile) {
|
||||
return "<html><b>" + ((VirtualFile)at).getPresentableUrl() + "</b><br/>Double-click to " + (myUI.isShowRootNames() ? "collapse" : "expand") + "</html>";
|
||||
return "<html><b>" + ((VirtualFile)at).getPresentableUrl() + "</b><br/>Click to " + (myUI.isShowRootNames() ? "collapse" : "expand") + "</html>";
|
||||
}
|
||||
}
|
||||
return null;
|
||||
@@ -338,6 +345,52 @@ public class VcsLogGraphTable extends JBTable implements TypeSafeDataProvider, C
|
||||
});
|
||||
}
|
||||
|
||||
private boolean expandOrCollapseRoots(MouseEvent e) {
|
||||
TableColumn column = getRootColumnOrNull(e);
|
||||
if (column != null) {
|
||||
myUI.setShowRootNames(!myUI.isShowRootNames());
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void rootColumnUpdated() {
|
||||
setColumnPreferredSize();
|
||||
setRootColumnSize(getColumnModel().getColumn(GraphTableModel.ROOT_COLUMN));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private TableColumn getRootColumnOrNull(MouseEvent e) {
|
||||
if (!myLogDataHolder.isMultiRoot()) return null;
|
||||
int column = convertColumnIndexToModel(columnAtPoint(e.getPoint()));
|
||||
if (column == GraphTableModel.ROOT_COLUMN) {
|
||||
return getColumnModel().getColumn(column);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private class MyHeaderMouseAdapter extends MouseAdapter {
|
||||
@Override
|
||||
public void mouseMoved(MouseEvent e) {
|
||||
Component component = e.getComponent();
|
||||
if (component != null) {
|
||||
if (getRootColumnOrNull(e) != null) {
|
||||
component.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
|
||||
}
|
||||
else {
|
||||
component.setCursor(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
if (e.getClickCount() == 1) {
|
||||
expandOrCollapseRoots(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class MyMouseAdapter extends MouseAdapter {
|
||||
private final TableLinkMouseListener myLinkListener;
|
||||
|
||||
@@ -351,16 +404,15 @@ public class VcsLogGraphTable extends JBTable implements TypeSafeDataProvider, C
|
||||
return;
|
||||
}
|
||||
|
||||
if (e.getClickCount() > 1) {
|
||||
expandOrCollapseRoots(e);
|
||||
} else if (e.getClickCount() == 1) {
|
||||
if (e.getClickCount() == 1) {
|
||||
if (expandOrCollapseRoots(e)) return;
|
||||
performAction(e, MyGraphMouseAction.Type.CLICK);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseMoved(MouseEvent e) {
|
||||
if (isAboveLink(e)) {
|
||||
if (isAboveLink(e) || isAboveRoots(e)) {
|
||||
setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
|
||||
}
|
||||
else {
|
||||
@@ -368,17 +420,6 @@ public class VcsLogGraphTable extends JBTable implements TypeSafeDataProvider, C
|
||||
}
|
||||
}
|
||||
|
||||
private boolean expandOrCollapseRoots(MouseEvent e) {
|
||||
int column = convertColumnIndexToModel(columnAtPoint(e.getPoint()));
|
||||
if (column == GraphTableModel.ROOT_COLUMN && myLogDataHolder.isMultiRoot()) {
|
||||
myUI.setShowRootNames(!myUI.isShowRootNames());
|
||||
setColumnPreferredSize();
|
||||
setRootColumnSize(getColumnModel().getColumn(column));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void performAction(@NotNull MouseEvent e, @NotNull final MyGraphMouseAction.Type actionType) {
|
||||
int row = PositionUtil.getRowIndex(e.getPoint());
|
||||
if (row > getRowCount() - 1) {
|
||||
@@ -397,6 +438,12 @@ public class VcsLogGraphTable extends JBTable implements TypeSafeDataProvider, C
|
||||
return myLinkListener.getTagAt(e) != null;
|
||||
}
|
||||
|
||||
private boolean isAboveRoots(MouseEvent e) {
|
||||
TableColumn column = getRootColumnOrNull(e);
|
||||
int row = rowAtPoint(e.getPoint());
|
||||
return column != null && (row >= 0 && row < getRowCount());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseEntered(MouseEvent e) {
|
||||
// Do nothing
|
||||
@@ -443,7 +490,8 @@ public class VcsLogGraphTable extends JBTable implements TypeSafeDataProvider, C
|
||||
private static class RootCellRenderer extends JBLabel implements TableCellRenderer {
|
||||
@NotNull private final VcsLogUiImpl myUi;
|
||||
@NotNull private Color myColor = UIUtil.getTableBackground();
|
||||
private boolean myHasBorder;
|
||||
@NotNull private Color myBorderColor = UIUtil.getTableBackground();
|
||||
private boolean isNarrow = true;
|
||||
|
||||
RootCellRenderer(@NotNull VcsLogUiImpl ui) {
|
||||
super("", CENTER);
|
||||
@@ -456,13 +504,14 @@ public class VcsLogGraphTable extends JBTable implements TypeSafeDataProvider, C
|
||||
|
||||
int width = getWidth();
|
||||
|
||||
if (myHasBorder) {
|
||||
g.fillRect(0, 0, width - 1, HEIGHT_CELL);
|
||||
UIUtil.drawLine((Graphics2D)g, width - 1, 0, width - 1, HEIGHT_CELL, null, myUi.getColorManager().getRootIndicatorBorder());
|
||||
}
|
||||
else {
|
||||
if (isNarrow) {
|
||||
g.fillRect(0, 0, width - ROOT_INDICATOR_WHITE_WIDTH, HEIGHT_CELL);
|
||||
g.setColor(myBorderColor);
|
||||
g.fillRect(width - ROOT_INDICATOR_WHITE_WIDTH, 0, ROOT_INDICATOR_WHITE_WIDTH, HEIGHT_CELL);
|
||||
} else {
|
||||
g.fillRect(0, 0, width, HEIGHT_CELL);
|
||||
}
|
||||
|
||||
super.paintComponent(g);
|
||||
}
|
||||
|
||||
@@ -488,28 +537,20 @@ public class VcsLogGraphTable extends JBTable implements TypeSafeDataProvider, C
|
||||
color = UIUtil.getTableBackground(isSelected);
|
||||
}
|
||||
|
||||
if (myUi.isShowRootNames()) {
|
||||
// pale colors, honors selection, does not have border
|
||||
if (isSelected) {
|
||||
myColor = UIUtil.getTableBackground(isSelected);
|
||||
}
|
||||
else {
|
||||
//we create JBColor later
|
||||
//noinspection UseJBColor
|
||||
Color transparentColor = new Color(color.getRed(), color.getGreen(), color.getBlue(), 50);
|
||||
myColor = new JBColor(transparentColor, transparentColor);
|
||||
}
|
||||
//we create JBColor later
|
||||
//noinspection UseJBColor
|
||||
Color transparentColor = new Color(color.getRed(), color.getGreen(), color.getBlue(), 50);
|
||||
myColor = new JBColor(transparentColor, transparentColor);
|
||||
myBorderColor = UIUtil.getTableBackground(isSelected);
|
||||
setForeground(UIUtil.getTableForeground(false));
|
||||
|
||||
setForeground(UIUtil.getTableForeground(isSelected));
|
||||
if (myUi.isShowRootNames()) {
|
||||
setText(text);
|
||||
myHasBorder = false;
|
||||
isNarrow = false;
|
||||
}
|
||||
else {
|
||||
// bright colors, does not know about the selection, has border
|
||||
setForeground(UIUtil.getTableForeground(false));
|
||||
myColor = color;
|
||||
setText("");
|
||||
myHasBorder = true;
|
||||
isNarrow = true;
|
||||
}
|
||||
|
||||
return this;
|
||||
@@ -528,4 +569,18 @@ public class VcsLogGraphTable extends JBTable implements TypeSafeDataProvider, C
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private class RootHeaderRenderer implements TableCellRenderer {
|
||||
private final JLabel myRightArrow = new JLabel(AllIcons.General.ComboArrowRight);
|
||||
private final JLabel myDownArrow = new JLabel("Root", SwingConstants.CENTER);
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
|
||||
if (myUI.isShowRootNames()) {
|
||||
return myDownArrow;
|
||||
}
|
||||
return myRightArrow;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+3
-20
@@ -174,27 +174,10 @@ public abstract class XDebuggerEvaluator {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns expression that is selected or under the cursor in the Editor
|
||||
* Returns mode which should be used to evaluate the text
|
||||
*/
|
||||
public XExpression getEditorExpression(@NotNull Editor editor, @Nullable PsiFile psiFile) {
|
||||
String text = editor.getSelectionModel().getSelectedText();
|
||||
if (text != null) {
|
||||
text = formatTextForEvaluation(text);
|
||||
}
|
||||
else if (editor.getProject() != null) {
|
||||
Document document = editor.getDocument();
|
||||
ExpressionInfo info = getExpressionInfoAtOffset(editor.getProject(), document, editor.getCaretModel().getOffset(), true);
|
||||
if (info != null) {
|
||||
text = info.getExpressionText();
|
||||
if (text == null) {
|
||||
text = document.getText(info.getTextRange());
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!StringUtil.isEmpty(text)) {
|
||||
return XDebuggerUtil.getInstance().createExpression(text, null, null, text.contains("\n") ? EvaluationMode.CODE_FRAGMENT : EvaluationMode.EXPRESSION);
|
||||
}
|
||||
return null;
|
||||
public EvaluationMode getEvaluationMode(@NotNull String text, int startOffset, int endOffset, @Nullable PsiFile psiFile) {
|
||||
return text.contains("\n") ? EvaluationMode.CODE_FRAGMENT : EvaluationMode.EXPRESSION;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
|
||||
+8
-2
@@ -19,8 +19,14 @@ import com.intellij.xdebugger.frame.XStackFrame;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* @author egor
|
||||
*/
|
||||
* Subclass to allow to recalculate instance value in a different context
|
||||
*
|
||||
* @author egor
|
||||
*/
|
||||
public interface XInstanceEvaluator {
|
||||
/**
|
||||
* Recalculates instance value in the context of the provided stack frame
|
||||
* @see XDebuggerEvaluator
|
||||
*/
|
||||
void evaluate(@NotNull XDebuggerEvaluator.XEvaluationCallback callback, @NotNull XStackFrame frame);
|
||||
}
|
||||
|
||||
+18
-23
@@ -21,12 +21,12 @@ import com.intellij.openapi.actionSystem.DataContext;
|
||||
import com.intellij.openapi.editor.Document;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.xdebugger.XDebugSession;
|
||||
import com.intellij.xdebugger.XExpression;
|
||||
import com.intellij.xdebugger.XSourcePosition;
|
||||
import com.intellij.xdebugger.evaluation.EvaluationMode;
|
||||
import com.intellij.xdebugger.evaluation.ExpressionInfo;
|
||||
import com.intellij.xdebugger.evaluation.XDebuggerEditorsProvider;
|
||||
import com.intellij.xdebugger.evaluation.XDebuggerEvaluator;
|
||||
@@ -54,34 +54,28 @@ public class XDebuggerEvaluateActionHandler extends XDebuggerActionHandler {
|
||||
|
||||
Editor editor = CommonDataKeys.EDITOR.getData(dataContext);
|
||||
|
||||
XExpression expression = null;
|
||||
if (editor != null) {
|
||||
expression = evaluator.getEditorExpression(editor, CommonDataKeys.PSI_FILE.getData(dataContext));
|
||||
EvaluationMode mode = EvaluationMode.EXPRESSION;
|
||||
String selectedText = editor != null ? editor.getSelectionModel().getSelectedText() : null;
|
||||
if (selectedText != null) {
|
||||
selectedText = evaluator.formatTextForEvaluation(selectedText);
|
||||
mode = evaluator.getEvaluationMode(selectedText,
|
||||
editor.getSelectionModel().getSelectionStart(),
|
||||
editor.getSelectionModel().getSelectionEnd(),
|
||||
CommonDataKeys.PSI_FILE.getData(dataContext));
|
||||
}
|
||||
String text = selectedText;
|
||||
|
||||
if (text == null && editor != null) {
|
||||
text = getExpressionText(evaluator, CommonDataKeys.PROJECT.getData(dataContext), editor);
|
||||
}
|
||||
|
||||
Language language = calcLanguage(stackFrame, dataContext);
|
||||
|
||||
if (expression != null && !Comparing.equal(language, expression.getLanguage())) { // may need to change language
|
||||
expression = new XExpressionImpl(expression.getExpression(), language, expression.getCustomInfo(), expression.getMode());
|
||||
}
|
||||
|
||||
if (expression == null) {
|
||||
if (text == null) {
|
||||
XValue value = XDebuggerTreeActionBase.getSelectedValue(dataContext);
|
||||
if (value != null) {
|
||||
String text = value.getEvaluationExpression();
|
||||
if (!StringUtil.isEmpty(text)) {
|
||||
expression = new XExpressionImpl(text, language, null);
|
||||
}
|
||||
text = value.getEvaluationExpression();
|
||||
}
|
||||
}
|
||||
|
||||
if (expression == null) {
|
||||
expression = new XExpressionImpl("", language, null);
|
||||
}
|
||||
new XDebuggerEvaluationDialog(session, editorsProvider, evaluator, expression, stackFrame == null ? null : stackFrame.getSourcePosition()).show();
|
||||
}
|
||||
|
||||
private static Language calcLanguage(XStackFrame stackFrame, DataContext dataContext) {
|
||||
Language language = null;
|
||||
if (stackFrame != null) {
|
||||
XSourcePosition position = stackFrame.getSourcePosition();
|
||||
@@ -95,7 +89,8 @@ public class XDebuggerEvaluateActionHandler extends XDebuggerActionHandler {
|
||||
language = XDebuggerEditorBase.getFileTypeLanguage(file.getFileType());
|
||||
}
|
||||
}
|
||||
return language;
|
||||
XExpression expression = new XExpressionImpl(StringUtil.notNullize(text), language, null, mode);
|
||||
new XDebuggerEvaluationDialog(session, editorsProvider, evaluator, expression, stackFrame == null ? null : stackFrame.getSourcePosition()).show();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
+4
@@ -323,6 +323,10 @@ public class XDebuggerEvaluationDialog extends DialogWrapper {
|
||||
}
|
||||
}
|
||||
|
||||
public void evaluationDone() {
|
||||
mySession.rebuildViews();
|
||||
}
|
||||
|
||||
@Override
|
||||
public JComponent getPreferredFocusedComponent() {
|
||||
return getInputEditor().getPreferredFocusedComponent();
|
||||
|
||||
+3
@@ -22,6 +22,7 @@ import com.intellij.ui.AppUIUtil;
|
||||
import com.intellij.ui.SimpleColoredComponent;
|
||||
import com.intellij.xdebugger.frame.XValueModifier;
|
||||
import com.intellij.xdebugger.frame.presentation.XValuePresentation;
|
||||
import com.intellij.xdebugger.impl.XDebuggerUtilImpl;
|
||||
import com.intellij.xdebugger.impl.breakpoints.XExpressionImpl;
|
||||
import com.intellij.xdebugger.impl.ui.XDebuggerUIConstants;
|
||||
import com.intellij.xdebugger.impl.ui.tree.nodes.XValueNodeImpl;
|
||||
@@ -82,6 +83,7 @@ public class SetValueInplaceEditor extends XDebuggerTreeInplaceEditor {
|
||||
myTree.rebuildAndRestore(treeState);
|
||||
}
|
||||
});
|
||||
XDebuggerUtilImpl.rebuildAllSessionsViews(getProject());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -100,6 +102,7 @@ public class SetValueInplaceEditor extends XDebuggerTreeInplaceEditor {
|
||||
}
|
||||
}
|
||||
});
|
||||
XDebuggerUtilImpl.rebuildAllSessionsViews(getProject());
|
||||
}
|
||||
});
|
||||
super.doOKAction();
|
||||
|
||||
@@ -49,7 +49,7 @@ public class XInspectDialog extends DialogWrapper {
|
||||
@NotNull String name,
|
||||
@NotNull XValue value,
|
||||
XValueMarkers<?, ?> markers,
|
||||
XDebugSession session,
|
||||
@NotNull XDebugSession session,
|
||||
boolean rebuildOnSessionEvents) {
|
||||
super(project, false);
|
||||
myRebuildOnSessionEvents = rebuildOnSessionEvents;
|
||||
|
||||
+12
-9
@@ -18,6 +18,7 @@ package com.intellij.xdebugger.impl.ui.tree.actions;
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.xdebugger.XDebugSession;
|
||||
import com.intellij.xdebugger.XDebuggerBundle;
|
||||
import com.intellij.xdebugger.XDebuggerManager;
|
||||
import com.intellij.xdebugger.frame.XReferrersProvider;
|
||||
import com.intellij.xdebugger.impl.ui.tree.XDebuggerTree;
|
||||
import com.intellij.xdebugger.impl.ui.tree.XInspectDialog;
|
||||
@@ -39,15 +40,17 @@ public class ShowReferringObjectsAction extends XDebuggerTreeActionBase {
|
||||
XReferrersProvider referrersProvider = node.getValueContainer().getReferrersProvider();
|
||||
if (referrersProvider != null) {
|
||||
XDebuggerTree tree = node.getTree();
|
||||
XDebugSession session = e.getData(XDebugSession.DATA_KEY);
|
||||
XInspectDialog dialog = new XInspectDialog(tree.getProject(),
|
||||
tree.getEditorsProvider(),
|
||||
tree.getSourcePosition(),
|
||||
nodeName,
|
||||
referrersProvider.getReferringObjectsValue(),
|
||||
tree.getValueMarkers(), session, false);
|
||||
dialog.setTitle(XDebuggerBundle.message("showReferring.dialog.title", nodeName));
|
||||
dialog.show();
|
||||
XDebugSession session = XDebuggerManager.getInstance(tree.getProject()).getCurrentSession();
|
||||
if (session != null) {
|
||||
XInspectDialog dialog = new XInspectDialog(tree.getProject(),
|
||||
tree.getEditorsProvider(),
|
||||
tree.getSourcePosition(),
|
||||
nodeName,
|
||||
referrersProvider.getReferringObjectsValue(),
|
||||
tree.getValueMarkers(), session, false);
|
||||
dialog.setTitle(XDebuggerBundle.message("showReferring.dialog.title", nodeName));
|
||||
dialog.show();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+7
-4
@@ -17,6 +17,7 @@ package com.intellij.xdebugger.impl.ui.tree.actions;
|
||||
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.xdebugger.XDebugSession;
|
||||
import com.intellij.xdebugger.XDebuggerManager;
|
||||
import com.intellij.xdebugger.frame.XValue;
|
||||
import com.intellij.xdebugger.impl.ui.tree.XDebuggerTree;
|
||||
import com.intellij.xdebugger.impl.ui.tree.XInspectDialog;
|
||||
@@ -29,11 +30,13 @@ import org.jetbrains.annotations.NotNull;
|
||||
public class XInspectAction extends XDebuggerTreeActionBase {
|
||||
@Override
|
||||
protected void perform(XValueNodeImpl node, @NotNull final String nodeName, AnActionEvent e) {
|
||||
XDebugSession session = e.getData(XDebugSession.DATA_KEY);
|
||||
XDebuggerTree tree = node.getTree();
|
||||
XValue value = node.getValueContainer();
|
||||
XInspectDialog dialog = new XInspectDialog(tree.getProject(), tree.getEditorsProvider(), tree.getSourcePosition(), nodeName, value,
|
||||
tree.getValueMarkers(), session, true);
|
||||
dialog.show();
|
||||
XDebugSession session = XDebuggerManager.getInstance(tree.getProject()).getCurrentSession();
|
||||
if (session != null) {
|
||||
XInspectDialog dialog = new XInspectDialog(tree.getProject(), tree.getEditorsProvider(), tree.getSourcePosition(), nodeName, value,
|
||||
tree.getValueMarkers(), session, true);
|
||||
dialog.show();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+2
@@ -53,11 +53,13 @@ public class EvaluatingExpressionRootNode extends XValueContainerNode<Evaluating
|
||||
public void evaluated(@NotNull final XValue result) {
|
||||
String name = UIUtil.removeMnemonic(XDebuggerBundle.message("xdebugger.evaluate.result"));
|
||||
node.addChildren(XValueChildrenList.singleton(name, result), true);
|
||||
myDialog.evaluationDone();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void errorOccurred(@NotNull final String errorMessage) {
|
||||
node.setErrorMessage(errorMessage);
|
||||
myDialog.evaluationDone();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
+2
-1
@@ -2450,7 +2450,8 @@
|
||||
key="unqualified.static.usage.display.name" groupBundle="messages.InspectionsBundle"
|
||||
groupKey="group.names.code.style.issues" enabledByDefault="false" level="WARNING"
|
||||
implementationClass="com.siyeh.ig.style.UnqualifiedStaticUsageInspection" cleanupTool="true"/>
|
||||
<localInspection language="JAVA" shortName="UnclearBinaryExpression" bundle="com.siyeh.InspectionGadgetsBundle"
|
||||
<localInspection language="JAVA" suppressId="UnclearExpression" alternativeId="UnclearBinaryExpression"
|
||||
shortName="UnclearBinaryExpression" bundle="com.siyeh.InspectionGadgetsBundle"
|
||||
key="unclear.binary.expression.display.name" groupBundle="messages.InspectionsBundle"
|
||||
groupKey="group.names.code.style.issues" enabledByDefault="false" level="WARNING"
|
||||
implementationClass="com.siyeh.ig.style.UnclearBinaryExpressionInspection"/>
|
||||
|
||||
+1
@@ -2121,6 +2121,7 @@ return.of.inner.class.display.name=Return of instance of anonymous, local or inn
|
||||
return.of.anonymous.class.problem.descriptor=Return of instance of anonymous class #loc
|
||||
return.of.local.class.problem.descriptor=Return of instance of local class <code>{0}</code> #loc
|
||||
return.of.inner.class.problem.descriptor=Return of instance of non-static inner class <code>{0}</code> #loc
|
||||
return.of.inner.class.ignore.non.public.option=Ignore returns from non-public methods
|
||||
parameter.type.prevents.overriding.display.name=Parameter type prevents overriding
|
||||
parameter.type.prevents.overriding.problem.descriptor=Parameter type <code>#ref</code> is located in ''{0}'' while super method parameter type is located in ''{1}'' preventing overriding
|
||||
parameter.type.prevents.overriding.quickfix=Change type of parameter to ''{0}''
|
||||
|
||||
+18
-1
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package com.siyeh.ig.memory;
|
||||
|
||||
import com.intellij.codeInspection.ui.SingleCheckboxOptionsPanel;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.psi.util.PsiUtil;
|
||||
@@ -24,12 +25,17 @@ import com.siyeh.ig.BaseInspectionVisitor;
|
||||
import com.siyeh.ig.psiutils.ParenthesesUtils;
|
||||
import org.jetbrains.annotations.Nls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
/**
|
||||
* @author Bas Leijdekkers
|
||||
*/
|
||||
public class ReturnOfInnerClassInspection extends BaseInspection {
|
||||
|
||||
@SuppressWarnings("PublicField") public boolean ignoreNonPublic = false;
|
||||
|
||||
private enum ClassType { ANONYMOUS_CLASS, LOCAL_CLASS, INNER_CLASS }
|
||||
|
||||
@Nls
|
||||
@@ -58,12 +64,19 @@ public class ReturnOfInnerClassInspection extends BaseInspection {
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public JComponent createOptionsPanel() {
|
||||
return new SingleCheckboxOptionsPanel(InspectionGadgetsBundle.message("return.of.inner.class.ignore.non.public.option"),
|
||||
this, "ignoreNonPublic");
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseInspectionVisitor buildVisitor() {
|
||||
return new ReturnOfInnerClassVisitor();
|
||||
}
|
||||
|
||||
private static class ReturnOfInnerClassVisitor extends BaseInspectionVisitor {
|
||||
private class ReturnOfInnerClassVisitor extends BaseInspectionVisitor {
|
||||
|
||||
@Override
|
||||
public void visitReturnStatement(PsiReturnStatement statement) {
|
||||
@@ -76,6 +89,10 @@ public class ReturnOfInnerClassInspection extends BaseInspection {
|
||||
if (method == null || method.hasModifierProperty(PsiModifier.PRIVATE)) {
|
||||
return;
|
||||
}
|
||||
else if (ignoreNonPublic &&
|
||||
(method.hasModifierProperty(PsiModifier.PROTECTED) || method.hasModifierProperty(PsiModifier.PACKAGE_LOCAL))) {
|
||||
return;
|
||||
}
|
||||
if (expression instanceof PsiNewExpression) {
|
||||
final PsiNewExpression newExpression = (PsiNewExpression)expression;
|
||||
final PsiAnonymousClass anonymousClass = newExpression.getAnonymousClass();
|
||||
|
||||
+4
-1
@@ -207,7 +207,10 @@ public class UnclearBinaryExpressionInspection extends BaseInspection {
|
||||
|
||||
private static boolean isSimpleAssignment(PsiAssignmentExpression assignmentExpression, PsiElement parent) {
|
||||
final IElementType parentTokenType;
|
||||
if (parent instanceof PsiAssignmentExpression) {
|
||||
if (parent instanceof PsiExpressionStatement) {
|
||||
return true;
|
||||
}
|
||||
else if (parent instanceof PsiAssignmentExpression) {
|
||||
final PsiAssignmentExpression parentAssignmentExpression = (PsiAssignmentExpression)parent;
|
||||
parentTokenType = parentAssignmentExpression.getOperationTokenType();
|
||||
}
|
||||
|
||||
@@ -5,6 +5,9 @@ Such instances keep an implicit reference to the outer instance.
|
||||
Which means the instance can prevent the outer instance from being garbage collected.
|
||||
Any caller of a method which returns such an instance might cause a memory leak by holding on to the instance returned.
|
||||
<p>
|
||||
Use the checkbox below to ignore returns from <b>protected</b> or package-local methods.
|
||||
Returns from <b>private</b> methods are always ignored.
|
||||
<p>
|
||||
<small>New in 14</small>
|
||||
</body>
|
||||
</html>
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
class SimpleAssignment {
|
||||
|
||||
public void baz() {
|
||||
int a = 2;
|
||||
int b = 3;
|
||||
int c = 4;
|
||||
int d;
|
||||
d = (a / b) * c;
|
||||
}
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
class SimpleAssignment {
|
||||
|
||||
public void baz() {
|
||||
int a = 2;
|
||||
int b = 3;
|
||||
int c = 4;
|
||||
int d;
|
||||
d = <caret>a / b * c;
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user