From 1f6089536fd0de7da32363736372cb167602a2ba Mon Sep 17 00:00:00 2001 From: Roman Shevchenko Date: Wed, 11 Apr 2012 14:52:28 +0200 Subject: [PATCH 01/21] Fix FileWatcher test --- .../openapi/vfs/local/FileWatcherTest.java | 40 ++++++++++++++----- 1 file changed, 29 insertions(+), 11 deletions(-) diff --git a/platform/platform-tests/testSrc/com/intellij/openapi/vfs/local/FileWatcherTest.java b/platform/platform-tests/testSrc/com/intellij/openapi/vfs/local/FileWatcherTest.java index 23d615fd2871..533f55ef7733 100644 --- a/platform/platform-tests/testSrc/com/intellij/openapi/vfs/local/FileWatcherTest.java +++ b/platform/platform-tests/testSrc/com/intellij/openapi/vfs/local/FileWatcherTest.java @@ -17,6 +17,7 @@ package com.intellij.openapi.vfs.local; import com.intellij.execution.configurations.GeneralCommandLine; import com.intellij.idea.Bombed; +import com.intellij.openapi.application.AccessToken; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.util.SystemInfo; import com.intellij.openapi.util.io.FileUtil; @@ -36,6 +37,7 @@ import com.intellij.util.messages.MessageBusConnection; import org.jetbrains.annotations.NotNull; import java.io.File; +import java.io.IOException; import java.util.*; public class FileWatcherTest extends PlatformLangTestCase { @@ -105,7 +107,7 @@ public class FileWatcherTest extends PlatformLangTestCase { } finally { myFileSystem.removeWatchedRoot(request); - FileUtil.delete(file); + delete(file); } } @@ -132,7 +134,7 @@ public class FileWatcherTest extends PlatformLangTestCase { } finally { myFileSystem.removeWatchedRoot(request); - FileUtil.delete(file); + delete(file); } } @@ -160,7 +162,7 @@ public class FileWatcherTest extends PlatformLangTestCase { } finally { myFileSystem.removeWatchedRoot(request); - FileUtil.delete(topDir); + delete(topDir); } } @@ -181,7 +183,7 @@ public class FileWatcherTest extends PlatformLangTestCase { } finally { myFileSystem.removeWatchedRoot(request); - FileUtil.delete(topDir); + delete(topDir); } } @@ -202,7 +204,7 @@ public class FileWatcherTest extends PlatformLangTestCase { } finally { myFileSystem.removeWatchedRoot(request); - FileUtil.delete(topDir); + delete(topDir); } } @@ -247,7 +249,7 @@ public class FileWatcherTest extends PlatformLangTestCase { } finally { myFileSystem.removeWatchedRoots(Arrays.asList(request1, request2)); - FileUtil.delete(topDir); + delete(topDir); } } @@ -274,8 +276,8 @@ public class FileWatcherTest extends PlatformLangTestCase { } finally { myFileSystem.removeWatchedRoot(request); - FileUtil.delete(topLink); - FileUtil.delete(topDir); + delete(topLink); + delete(topDir); } } @@ -303,8 +305,8 @@ public class FileWatcherTest extends PlatformLangTestCase { } finally { myFileSystem.removeWatchedRoot(request); - FileUtil.delete(linkDir); - FileUtil.delete(targetDir); + delete(linkDir); + delete(targetDir); } } @@ -367,7 +369,7 @@ public class FileWatcherTest extends PlatformLangTestCase { } finally { VirtualDirectoryImpl.disallowRootAccess(substRoot); - FileUtil.delete(targetDir); + delete(targetDir); new GeneralCommandLine("subst", subst + ":", "/d").createProcess().waitFor(); } } @@ -424,6 +426,22 @@ public class FileWatcherTest extends PlatformLangTestCase { return vFile; } + private void delete(@NotNull final File file) throws IOException { + final VirtualFile vFile = myFileSystem.findFileByIoFile(file); + if (vFile != null) { + final AccessToken token = ApplicationManager.getApplication().acquireWriteActionLock(getClass()); + try { + vFile.delete(this); + } + finally { + token.finish(); + } + } + if (file.exists()) { + FileUtil.delete(file); + } + } + private void assertEvent(final Class type, final String... paths) throws InterruptedException { final List events = getEvents(); assertEquals(events.toString(), paths.length, events.size()); From 73d5f046e303a816684aff8486eaf3bdbeff1473 Mon Sep 17 00:00:00 2001 From: anna Date: Wed, 11 Apr 2012 14:47:47 +0200 Subject: [PATCH 02/21] do not select empty method body when create from template (IDEA-84274) --- .../daemon/impl/quickfix/CreateFromUsageUtils.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/CreateFromUsageUtils.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/CreateFromUsageUtils.java index bef51af9bdbb..d4d178428a33 100644 --- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/CreateFromUsageUtils.java +++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/CreateFromUsageUtils.java @@ -29,6 +29,7 @@ import com.intellij.ide.fileTemplates.JavaTemplateUtil; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.editor.Editor; +import com.intellij.openapi.editor.EditorModificationUtil; import com.intellij.openapi.editor.ScrollType; import com.intellij.openapi.fileTypes.FileType; import com.intellij.openapi.fileTypes.FileTypeManager; @@ -182,7 +183,7 @@ public class CreateFromUsageUtils { } } - public static void setupEditor(PsiMethod method, Editor newEditor) { + public static void setupEditor(PsiMethod method, final Editor newEditor) { PsiCodeBlock body = method.getBody(); if (body != null) { PsiElement l = PsiTreeUtil.skipSiblingsForward(body.getLBrace(), PsiWhiteSpace.class); @@ -191,7 +192,14 @@ public class CreateFromUsageUtils { int start = l.getTextRange().getStartOffset(); int end = r.getTextRange().getEndOffset(); newEditor.getCaretModel().moveToOffset(Math.max(start, end)); - newEditor.getSelectionModel().setSelection(Math.min(start, end), Math.max(start, end)); + if (end < start) { + newEditor.getCaretModel().moveToOffset(end + 1); + CodeStyleManager styleManager = CodeStyleManager.getInstance(method.getProject()); + final String lineIndent = styleManager.getLineIndent(method.getContainingFile(), Math.min(start, end)); + EditorModificationUtil.insertStringAtCaret(newEditor, lineIndent); + } else { + newEditor.getSelectionModel().setSelection(Math.min(start, end), Math.max(start, end)); + } newEditor.getScrollingModel().scrollToCaret(ScrollType.RELATIVE); } } From 6f1f4c1cebc062ba3a9b3ff281dec2c4c0552ec1 Mon Sep 17 00:00:00 2001 From: anna Date: Wed, 11 Apr 2012 15:51:54 +0200 Subject: [PATCH 03/21] restore offline inspections results --- .../codeInspection/ex/CommonInspectionToolWrapper.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/platform/lang-impl/src/com/intellij/codeInspection/ex/CommonInspectionToolWrapper.java b/platform/lang-impl/src/com/intellij/codeInspection/ex/CommonInspectionToolWrapper.java index d2c272630bf2..3858734b488c 100644 --- a/platform/lang-impl/src/com/intellij/codeInspection/ex/CommonInspectionToolWrapper.java +++ b/platform/lang-impl/src/com/intellij/codeInspection/ex/CommonInspectionToolWrapper.java @@ -22,6 +22,7 @@ import com.intellij.codeInspection.InspectionManager; import com.intellij.codeInspection.reference.RefEntity; import com.intellij.codeInspection.ui.InspectionNode; import com.intellij.codeInspection.ui.InspectionTreeNode; +import org.jdom.Element; import org.jetbrains.annotations.NotNull; import java.util.Map; @@ -109,5 +110,8 @@ public class CommonInspectionToolWrapper extends InspectionToolWrapper Date: Wed, 11 Apr 2012 17:57:49 +0400 Subject: [PATCH 04/21] Improved non-incremental switch analysis a bit (compile-server). --- .../ether/dependencyView/ClassRepr.java | 5 +++ .../ether/dependencyView/Difference.java | 18 +++++++++- .../ether/dependencyView/Mappings.java | 33 ++++++++----------- .../ether/dependencyView/MethodRepr.java | 5 +++ .../jetbrains/ether/dependencyView/Proto.java | 14 ++++---- .../ether/dependencyView/ProtoMember.java | 5 +++ 6 files changed, 54 insertions(+), 26 deletions(-) diff --git a/jps/model/src/org/jetbrains/ether/dependencyView/ClassRepr.java b/jps/model/src/org/jetbrains/ether/dependencyView/ClassRepr.java index 7243b484fca3..9463e1f6fdc0 100644 --- a/jps/model/src/org/jetbrains/ether/dependencyView/ClassRepr.java +++ b/jps/model/src/org/jetbrains/ether/dependencyView/ClassRepr.java @@ -136,6 +136,11 @@ public class ClassRepr extends Proto { public boolean hadValue() { return false; } + + @Override + public boolean weakedAccess() { + return diff.weakedAccess(); + } }; } diff --git a/jps/model/src/org/jetbrains/ether/dependencyView/Difference.java b/jps/model/src/org/jetbrains/ether/dependencyView/Difference.java index a761581b7a39..38f875f33d92 100644 --- a/jps/model/src/org/jetbrains/ether/dependencyView/Difference.java +++ b/jps/model/src/org/jetbrains/ether/dependencyView/Difference.java @@ -1,6 +1,7 @@ package org.jetbrains.ether.dependencyView; import com.intellij.openapi.util.Pair; +import org.jetbrains.asm4.Opcodes; import java.util.*; @@ -12,6 +13,16 @@ import java.util.*; * To change this template use File | Settings | File Templates. */ abstract class Difference { + public static boolean isPackageLocal(final int access) { + return (access & (Opcodes.ACC_PRIVATE | Opcodes.ACC_PROTECTED | Opcodes.ACC_PUBLIC)) == 0; + } + + public static boolean weakerAccess(final int me, final int then) { + return ((me & Opcodes.ACC_PRIVATE) > 0 && (then & Opcodes.ACC_PRIVATE) == 0) || + ((me & Opcodes.ACC_PROTECTED) > 0 && (then & Opcodes.ACC_PUBLIC) > 0) || + (isPackageLocal(me) && (then & Opcodes.ACC_PROTECTED) > 0); + } + public static final int NONE = 0; public static final int ACCESS = 1; public static final int TYPE = 2; @@ -21,8 +32,11 @@ abstract class Difference { public interface Specifier { Collection added(); + Collection removed(); + Collection> changed(); + boolean unchanged(); } @@ -105,11 +119,13 @@ abstract class Difference { public abstract boolean no(); + public abstract boolean weakedAccess(); + public abstract int addedModifiers(); public abstract int removedModifiers(); public abstract boolean packageLocalOn(); - public abstract boolean hadValue (); + public abstract boolean hadValue(); } diff --git a/jps/model/src/org/jetbrains/ether/dependencyView/Mappings.java b/jps/model/src/org/jetbrains/ether/dependencyView/Mappings.java index 9f306aab8caa..1b8630e83fd8 100644 --- a/jps/model/src/org/jetbrains/ether/dependencyView/Mappings.java +++ b/jps/model/src/org/jetbrains/ether/dependencyView/Mappings.java @@ -733,19 +733,9 @@ public class Mappings { } } - private static boolean isPackageLocal(final int access) { - return (access & (Opcodes.ACC_PRIVATE | Opcodes.ACC_PROTECTED | Opcodes.ACC_PUBLIC)) == 0; - } - - private static boolean weakerAccess(final int me, final int then) { - return ((me & Opcodes.ACC_PRIVATE) > 0 && (then & Opcodes.ACC_PRIVATE) == 0) || - ((me & Opcodes.ACC_PROTECTED) > 0 && (then & Opcodes.ACC_PUBLIC) > 0) || - (isPackageLocal(me) && (then & Opcodes.ACC_PROTECTED) > 0); - } - private static boolean isVisibleIn(final ClassRepr c, final ProtoMember m, final ClassRepr scope) { final boolean privacy = ((m.access & Opcodes.ACC_PRIVATE) > 0) && c.name != scope.name; - final boolean packageLocality = isPackageLocal(m.access) && !c.getPackageName().equals(scope.getPackageName()); + final boolean packageLocality = Difference.isPackageLocal(m.access) && !c.getPackageName().equals(scope.getPackageName()); return !privacy && !packageLocality; } @@ -1080,7 +1070,7 @@ public class Mappings { final Option subtypeOf = u.isSubtypeOf(mm.type, m.type); - if (weakerAccess(mm.access, m.access) || + if (Difference.weakerAccess(mm.access, m.access) || ((m.access & Opcodes.ACC_STATIC) > 0 && (mm.access & Opcodes.ACC_STATIC) == 0) || ((m.access & Opcodes.ACC_STATIC) == 0 && (mm.access & Opcodes.ACC_STATIC) > 0) || ((m.access & Opcodes.ACC_FINAL) > 0) || @@ -1382,7 +1372,7 @@ public class Mappings { final boolean ffPrivate = (ff.access & Opcodes.ACC_PRIVATE) > 0; final boolean ffProtected = (ff.access & Opcodes.ACC_PROTECTED) > 0; final boolean ffPublic = (ff.access & Opcodes.ACC_PUBLIC) > 0; - final boolean ffPLocal = isPackageLocal(ff.access); + final boolean ffPLocal = Difference.isPackageLocal(ff.access); if (!ffPrivate) { final TIntHashSet propagated = o.propagateFieldAccess(ff.name, cc.name); @@ -1444,12 +1434,17 @@ public class Mappings { debug("Field: ", it.name); if ((field.access & Opcodes.ACC_PRIVATE) == 0 && (field.access & mask) == mask) { - if ((d.base() & Difference.ACCESS) > 0 || ((d.base() & Difference.VALUE) > 0 && d.hadValue())) { - debug("Inline field changed its access or value => a switch to non-incremental mode requested"); - if (!incrementalDecision(it.name, field, affectedFiles, filter)) { - debug("End of Differentiate, returning false"); - return false; - } + final int changedModifiers = d.addedModifiers() | d.removedModifiers(); + final boolean harmful = (changedModifiers & (Opcodes.ACC_STATIC | Opcodes.ACC_FINAL)) > 0; + final boolean accessChanged = (changedModifiers & (Opcodes.ACC_PUBLIC | Opcodes.ACC_PRIVATE | Opcodes.ACC_PROTECTED)) > 0; + final boolean valueChanged = (d.base() & Difference.VALUE) > 0 && d.hadValue(); + + if (harmful || valueChanged || (accessChanged && !d.weakedAccess())) { + debug("Inline field changed it's access or value => a switch to non-incremental mode requested"); + if (!incrementalDecision(it.name, field, affectedFiles, filter)) { + debug("End of Differentiate, returning false"); + return false; + } } } diff --git a/jps/model/src/org/jetbrains/ether/dependencyView/MethodRepr.java b/jps/model/src/org/jetbrains/ether/dependencyView/MethodRepr.java index 357807351b75..64641c47b5f6 100644 --- a/jps/model/src/org/jetbrains/ether/dependencyView/MethodRepr.java +++ b/jps/model/src/org/jetbrains/ether/dependencyView/MethodRepr.java @@ -85,6 +85,11 @@ class MethodRepr extends ProtoMember { public boolean hadValue() { return ((MethodRepr)past).hasValue(); } + + @Override + public boolean weakedAccess() { + return diff.weakedAccess(); + } }; } diff --git a/jps/model/src/org/jetbrains/ether/dependencyView/Proto.java b/jps/model/src/org/jetbrains/ether/dependencyView/Proto.java index 0c4dbf18e50a..39aaf0b36ed2 100644 --- a/jps/model/src/org/jetbrains/ether/dependencyView/Proto.java +++ b/jps/model/src/org/jetbrains/ether/dependencyView/Proto.java @@ -1,6 +1,6 @@ package org.jetbrains.ether.dependencyView; -import groovyjarjarasm.asm.Opcodes; +import org.jetbrains.asm4.Opcodes; import org.jetbrains.ether.RW; import java.io.DataInput; @@ -86,17 +86,19 @@ class Proto implements RW.Savable { public boolean packageLocalOn() { return ((past.access & Opcodes.ACC_PRIVATE) != 0 || (past.access & Opcodes.ACC_PUBLIC) != 0 || - (past.access & Opcodes.ACC_PROTECTED) != 0) - - && - - ((access & Opcodes.ACC_PRIVATE) == 0 && (access & Opcodes.ACC_PROTECTED) == 0 && (access & Opcodes.ACC_PUBLIC) == 0); + (past.access & Opcodes.ACC_PROTECTED) != 0) && + Difference.isPackageLocal(access); } @Override public boolean hadValue() { return false; } + + @Override + public boolean weakedAccess() { + return Difference.weakerAccess(past.access, access); + } }; } } diff --git a/jps/model/src/org/jetbrains/ether/dependencyView/ProtoMember.java b/jps/model/src/org/jetbrains/ether/dependencyView/ProtoMember.java index bdfee422d6bd..ed1e350a2ec4 100644 --- a/jps/model/src/org/jetbrains/ether/dependencyView/ProtoMember.java +++ b/jps/model/src/org/jetbrains/ether/dependencyView/ProtoMember.java @@ -172,6 +172,11 @@ abstract class ProtoMember extends Proto { public boolean hadValue() { return ((ProtoMember)past).hasValue(); } + + @Override + public boolean weakedAccess() { + return diff.weakedAccess(); + } }; } } From 1e68c690afa79c8c11b43f3e5d229ff0ff592392 Mon Sep 17 00:00:00 2001 From: Sergey Evdokimov Date: Wed, 11 Apr 2012 16:26:12 +0400 Subject: [PATCH 05/21] Optimize MavenJDOMUtil --- .../maven/project/MavenProjectReader.java | 2 +- .../idea/maven/utils/MavenJDOMUtil.java | 44 ++++++++++++------- 2 files changed, 28 insertions(+), 18 deletions(-) diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/MavenProjectReader.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/MavenProjectReader.java index cc9fdd942cb0..70bd3d6942f6 100644 --- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/MavenProjectReader.java +++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/MavenProjectReader.java @@ -145,7 +145,7 @@ public class MavenProjectReader { return new RawModelReadResult(result, problems, alwaysOnProfiles); } - private void readModelBody(MavenModelBase mavenModelBase, MavenBuildBase mavenBuildBase, Element xmlModel) { + private static void readModelBody(MavenModelBase mavenModelBase, MavenBuildBase mavenBuildBase, Element xmlModel) { mavenModelBase.setModules(MavenJDOMUtil.findChildrenValuesByPath(xmlModel, "modules", "module")); collectProperties(MavenJDOMUtil.findChildByPath(xmlModel, "properties"), mavenModelBase); diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/utils/MavenJDOMUtil.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/utils/MavenJDOMUtil.java index 707fae5105a6..1b4721e121a0 100644 --- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/utils/MavenJDOMUtil.java +++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/utils/MavenJDOMUtil.java @@ -33,8 +33,6 @@ import java.util.Collections; import java.util.LinkedList; import java.util.List; -import static com.intellij.openapi.util.text.StringUtil.isEmptyOrSpaces; - public class MavenJDOMUtil { @Nullable public static Element read(final VirtualFile file, @Nullable final ErrorHandler handler) { @@ -95,7 +93,7 @@ public class MavenJDOMUtil { public void endTag(CharSequence localName, String namespace, int startoffset, int endoffset) { String name = localName.toString(); - if (isEmptyOrSpaces(name)) return; + if (StringUtil.isEmptyOrSpaces(name)) return; int index = -1; for (int i = stack.size() - 1; i >= 0; i--) { @@ -129,22 +127,27 @@ public class MavenJDOMUtil { return result[0]; } + @Nullable public static Element findChildByPath(@Nullable Element element, String path) { - if (element == null) return null; + int i = 0; + while (element != null) { + int dot = path.indexOf('.', i); + if (dot == -1) { + return element.getChild(path.substring(i)); + } - List parts = StringUtil.split(path, "."); - Element current = element; - for (String each : parts) { - current = current.getChild(each); - if (current == null) break; + element = element.getChild(path.substring(i, dot)); + i = dot + 1; } - return current; + + return null; } public static String findChildValueByPath(@Nullable Element element, String path, String defaultValue) { Element child = findChildByPath(element, path); - String childValue = child == null ? null : child.getTextTrim(); - return StringUtil.isEmptyOrSpaces(childValue) ? defaultValue : childValue; + if (child == null) return defaultValue; + String childValue = child.getTextTrim(); + return childValue.isEmpty() ? defaultValue : childValue; } public static String findChildValueByPath(@Nullable Element element, String path) { @@ -163,7 +166,7 @@ public class MavenJDOMUtil { List result = new ArrayList(); for (Element each : findChildrenByPath(element, path, childrenName)) { String value = each.getTextTrim(); - if (!StringUtil.isEmptyOrSpaces(value)) { + if (!value.isEmpty()) { result.add(value); } } @@ -173,13 +176,20 @@ public class MavenJDOMUtil { private static List collectChildren(@Nullable Element container, String subPath) { if (container == null) return Collections.emptyList(); - List subParts = StringUtil.split(subPath, "."); - String childName = subParts.get(0); - String pathInChild = subParts.size() > 1 ? StringUtil.join(subParts.subList(1, subParts.size()), ".") : null; + int firstDot = subPath.indexOf('.'); + + if (firstDot == -1) { + //noinspection unchecked + return (List)container.getChildren(subPath); + } + + String childName = subPath.substring(0, firstDot); + String pathInChild = subPath.substring(firstDot + 1); List result = new ArrayList(); + //noinspection unchecked for (Element each : (Iterable)container.getChildren(childName)) { - Element child = pathInChild == null ? each : findChildByPath(each, pathInChild); + Element child = findChildByPath(each, pathInChild); if (child != null) result.add(child); } return result; From b402b5ba036886199421d09d9d77199480dfa151 Mon Sep 17 00:00:00 2001 From: Sergey Evdokimov Date: Wed, 11 Apr 2012 17:09:36 +0400 Subject: [PATCH 06/21] Fix bad code: don't modify collection that is returned from getter!!! --- .../idea/maven/project/actions/ToggleProfileAction.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/actions/ToggleProfileAction.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/actions/ToggleProfileAction.java index 2dbefe8798d4..3e9bf7f92ddd 100644 --- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/actions/ToggleProfileAction.java +++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/actions/ToggleProfileAction.java @@ -23,7 +23,9 @@ import org.jetbrains.idea.maven.utils.actions.MavenAction; import org.jetbrains.idea.maven.utils.actions.MavenActionUtil; import java.util.Collection; +import java.util.HashSet; import java.util.List; +import java.util.Set; public class ToggleProfileAction extends MavenAction { public void update(AnActionEvent e) { @@ -55,7 +57,7 @@ public class ToggleProfileAction extends MavenAction { return activeCount == 0 || activeCount == selectedProfiles.size(); } - private boolean isActive(MavenProjectsManager projectsManager, List profiles) { + private static boolean isActive(MavenProjectsManager projectsManager, List profiles) { return projectsManager.getExplicitProfiles().contains(profiles.get(0)); } @@ -64,7 +66,7 @@ public class ToggleProfileAction extends MavenAction { MavenProjectsManager manager = MavenActionUtil.getProjectsManager(e.getDataContext()); List selectedProfiles = e.getData(MavenDataKeys.MAVEN_PROFILES); - Collection activeProfiles = manager.getExplicitProfiles(); + Set activeProfiles = new HashSet(manager.getExplicitProfiles()); if (isActive(manager, selectedProfiles)) { activeProfiles.removeAll(selectedProfiles); } From 0f236a66b40f308c9c2b5c29e1fe92fd0398f02c Mon Sep 17 00:00:00 2001 From: Sergey Evdokimov Date: Wed, 11 Apr 2012 18:10:02 +0400 Subject: [PATCH 07/21] IDEA-84359 A settings.xml file in Android /res folder is shown with the wrong icon --- .../idea/maven/dom/MavenDomUtil.java | 35 +++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/MavenDomUtil.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/MavenDomUtil.java index c46daa9e26b6..5b8a55bc7efb 100644 --- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/MavenDomUtil.java +++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/MavenDomUtil.java @@ -36,6 +36,7 @@ import com.intellij.psi.util.PsiTreeUtil; import com.intellij.psi.xml.XmlElement; import com.intellij.psi.xml.XmlFile; import com.intellij.psi.xml.XmlTag; +import com.intellij.util.containers.CollectionFactory; import com.intellij.util.xml.*; import com.intellij.util.xml.reflect.DomCollectionChildDescription; import org.jetbrains.annotations.NotNull; @@ -50,10 +51,18 @@ import org.jetbrains.idea.maven.utils.MavenLog; import org.jetbrains.idea.maven.vfs.MavenPropertiesVirtualFileSystem; import java.util.List; +import java.util.Set; import java.util.regex.Matcher; import java.util.regex.Pattern; public class MavenDomUtil { + + // see http://maven.apache.org/settings.html + private static final Set SUBTAGS_IN_SETTINGS_FILE = CollectionFactory.newSet("localRepository", "interactiveMode", + "usePluginRegistry", "offline", "pluginGroups", + "servers", "mirrors", "proxies", "profiles", + "activeProfiles"); + public static boolean isMavenFile(PsiFile file) { return isProjectFile(file) || isProfilesFile(file) || isSettingsFile(file); } @@ -71,14 +80,36 @@ public class MavenDomUtil { if (!(file instanceof XmlFile)) return false; String name = file.getName(); - return name.equals(MavenConstants.PROFILES_XML); + if (!name.equals(MavenConstants.PROFILES_XML)) return false; + + XmlTag rootTag = ((XmlFile)file).getRootTag(); + return rootTag != null && "profilesXml".equals(rootTag.getName()); } public static boolean isSettingsFile(PsiFile file) { if (!(file instanceof XmlFile)) return false; String name = file.getName(); - return name.equals(MavenConstants.SETTINGS_XML); + if (!name.equals(MavenConstants.SETTINGS_XML)) return false; + + XmlTag rootTag = ((XmlFile)file).getRootTag(); + if (rootTag == null || !"settings".equals(rootTag.getName())) return false; + + String xmlns = rootTag.getAttributeValue("xmlns"); + if (xmlns != null) { + return xmlns.contains("maven"); + } + + boolean hasTag = false; + + for (PsiElement e = rootTag.getFirstChild(); e != null; e = e.getNextSibling()) { + if (e instanceof XmlTag) { + if (SUBTAGS_IN_SETTINGS_FILE.contains(((XmlTag)e).getName())) return true; + hasTag = true; + } + } + + return !hasTag; } public static boolean isMavenFile(PsiElement element) { From 813fcf3c6a0866f14021ce53fc6d0525345df4c8 Mon Sep 17 00:00:00 2001 From: Dmitry Avdeev Date: Wed, 11 Apr 2012 16:58:49 +0400 Subject: [PATCH 08/21] javadoc --- .../src/com/intellij/openapi/startup/StartupManager.java | 1 + 1 file changed, 1 insertion(+) diff --git a/platform/platform-api/src/com/intellij/openapi/startup/StartupManager.java b/platform/platform-api/src/com/intellij/openapi/startup/StartupManager.java index 25f8624a5339..2c6cef0f7e65 100644 --- a/platform/platform-api/src/com/intellij/openapi/startup/StartupManager.java +++ b/platform/platform-api/src/com/intellij/openapi/startup/StartupManager.java @@ -58,6 +58,7 @@ public abstract class StartupManager { * progress bar is displayed. You may access the PSI structures from the activity. * * @param runnable the activity to execute. + * @see StartupActivity#POST_STARTUP_ACTIVITY */ public abstract void registerPostStartupActivity(@NotNull Runnable runnable); From fb23876a0f09e9884225028179c11364b2847539 Mon Sep 17 00:00:00 2001 From: Dmitry Boulytchev Date: Wed, 11 Apr 2012 18:24:05 +0400 Subject: [PATCH 09/21] Improved non-incremental switch analysis a bit (compile-server). --- .../ether/dependencyView/Mappings.java | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/jps/model/src/org/jetbrains/ether/dependencyView/Mappings.java b/jps/model/src/org/jetbrains/ether/dependencyView/Mappings.java index 1b8630e83fd8..2b0ad81be653 100644 --- a/jps/model/src/org/jetbrains/ether/dependencyView/Mappings.java +++ b/jps/model/src/org/jetbrains/ether/dependencyView/Mappings.java @@ -1431,7 +1431,7 @@ public class Mappings { final Difference d = f.second; final FieldRepr field = f.first; - debug("Field: ", it.name); + debug("Field: ", field.name); if ((field.access & Opcodes.ACC_PRIVATE) == 0 && (field.access & mask) == mask) { final int changedModifiers = d.addedModifiers() | d.removedModifiers(); @@ -1441,10 +1441,10 @@ public class Mappings { if (harmful || valueChanged || (accessChanged && !d.weakedAccess())) { debug("Inline field changed it's access or value => a switch to non-incremental mode requested"); - if (!incrementalDecision(it.name, field, affectedFiles, filter)) { - debug("End of Differentiate, returning false"); - return false; - } + if (!incrementalDecision(it.name, field, affectedFiles, filter)) { + debug("End of Differentiate, returning false"); + return false; + } } } @@ -1638,7 +1638,10 @@ public class Mappings { } } - private void cleanupRemovedClass(@NotNull ClassRepr cr, Collection clusters, IntIntMultiMaplet subclassesTrashBin, IntIntMultiMaplet dependenciesTrashBin) { + private void cleanupRemovedClass(@NotNull ClassRepr cr, + Collection clusters, + IntIntMultiMaplet subclassesTrashBin, + IntIntMultiMaplet dependenciesTrashBin) { final int className = cr.name; for (final int superSomething : cr.getSupers()) { @@ -1806,7 +1809,6 @@ public class Mappings { return true; } }); - } finally { delta.close(); @@ -2021,7 +2023,7 @@ public class Mappings { @NotNull private Set getDeletedClasses() { - return myDeletedClasses != null? Collections.emptySet() : Collections.unmodifiableSet(myDeletedClasses); + return myDeletedClasses != null ? Collections.emptySet() : Collections.unmodifiableSet(myDeletedClasses); } private TIntHashSet getChangedClasses() { @@ -2047,5 +2049,4 @@ public class Mappings { private void debug(final String comment, final boolean s) { myDebugS.debug(comment, s); } - } From 099a44eb333a6a066e0a3f23608494ed34eedb38 Mon Sep 17 00:00:00 2001 From: Kirill Likhodedov Date: Wed, 11 Apr 2012 18:49:18 +0400 Subject: [PATCH 10/21] Additional logging for git-ssh --- .../jetbrains/git4idea/ssh/GitSSHXmlRpcClient.java | 6 ++++++ .../src/org/jetbrains/git4idea/ssh/SSHConfig.java | 7 +++++++ .../rt/src/org/jetbrains/git4idea/ssh/SSHMain.java | 14 +++++++++++++- .../git4idea/src/git4idea/commands/GitHandler.java | 4 +++- 4 files changed, 29 insertions(+), 2 deletions(-) diff --git a/plugins/git4idea/rt/src/org/jetbrains/git4idea/ssh/GitSSHXmlRpcClient.java b/plugins/git4idea/rt/src/org/jetbrains/git4idea/ssh/GitSSHXmlRpcClient.java index 0f2f668a5caf..a000949f1ce6 100644 --- a/plugins/git4idea/rt/src/org/jetbrains/git4idea/ssh/GitSSHXmlRpcClient.java +++ b/plugins/git4idea/rt/src/org/jetbrains/git4idea/ssh/GitSSHXmlRpcClient.java @@ -218,9 +218,11 @@ public class GitSSHXmlRpcClient implements GitSSHHandler { return (String)myClient.execute(methodName("getLastSuccessful"), parameters); } catch (XmlRpcException e) { + log("getLastSuccessful failed. handlerNo: " + handlerNo + ", userName: " + userName + ", client: " + myClient.getURL()); throw new RuntimeException("Invocation failed " + e.getMessage(), e); } catch (IOException e) { + log("getLastSuccessful failed. handlerNo: " + handlerNo + ", userName: " + userName + ", client: " + myClient.getURL()); throw new RuntimeException("Invocation failed " + e.getMessage(), e); } } @@ -248,4 +250,8 @@ public class GitSSHXmlRpcClient implements GitSSHHandler { private static Vector adjustNull(final Vector s) { return s.size() == 0 ? null : s; } + + private static void log(String s) { + System.err.println(s); + } } diff --git a/plugins/git4idea/rt/src/org/jetbrains/git4idea/ssh/SSHConfig.java b/plugins/git4idea/rt/src/org/jetbrains/git4idea/ssh/SSHConfig.java index 5799db2270f4..82dace3f7910 100644 --- a/plugins/git4idea/rt/src/org/jetbrains/git4idea/ssh/SSHConfig.java +++ b/plugins/git4idea/rt/src/org/jetbrains/git4idea/ssh/SSHConfig.java @@ -573,5 +573,12 @@ public class SSHConfig { private static T mergeValue(T first, T second) { return first == null ? second : first; } + + @Override + public String toString() { + return String.format("Host{myUser='%s', myHostName='%s', myPort=%d, myIdentityFile='%s'}", + myUser, myHostName, myPort, myIdentityFile); + } + } } diff --git a/plugins/git4idea/rt/src/org/jetbrains/git4idea/ssh/SSHMain.java b/plugins/git4idea/rt/src/org/jetbrains/git4idea/ssh/SSHMain.java index 858a2d3e0317..46c3fdf131bd 100644 --- a/plugins/git4idea/rt/src/org/jetbrains/git4idea/ssh/SSHMain.java +++ b/plugins/git4idea/rt/src/org/jetbrains/git4idea/ssh/SSHMain.java @@ -191,8 +191,9 @@ public class SSHMain { */ private void authenticate(final Connection c) throws IOException { LinkedList methods = new LinkedList(myHost.getPreferredMethods()); + //log("authenticating... " + this); String lastSuccessfulMethod = myXmlRpcClient.getLastSuccessful(myHandlerNo, getUserHostString()); - System.err.println("SSH: authentication methods: " + methods + " last successful method: " + lastSuccessfulMethod); + //log("SSH: authentication methods: " + methods + " last successful method: " + lastSuccessfulMethod); if (lastSuccessfulMethod != null && lastSuccessfulMethod.length() > 0 && methods.remove(lastSuccessfulMethod)) { methods.addFirst(lastSuccessfulMethod); } @@ -588,4 +589,15 @@ public class SSHMain { } } } + + @Override + public String toString() { + return String + .format("SSHMain{myHost=%s, myHandlerNo=%d, myCommand='%s', myExitCode=%d, myLastError='%s'}", myHost, myHandlerNo, myCommand, + myExitCode, myLastError); + } + + private static void log(String s) { + System.err.println(s); + } } diff --git a/plugins/git4idea/src/git4idea/commands/GitHandler.java b/plugins/git4idea/src/git4idea/commands/GitHandler.java index fbd6d581fa36..f08a21597a60 100644 --- a/plugins/git4idea/src/git4idea/commands/GitHandler.java +++ b/plugins/git4idea/src/git4idea/commands/GitHandler.java @@ -399,7 +399,9 @@ public abstract class GitHandler { myHandlerNo = ssh.registerHandler(new GitSSHGUIHandler(myProject)); myEnvironmentCleanedUp = false; myEnv.put(GitSSHHandler.SSH_HANDLER_ENV, Integer.toString(myHandlerNo)); - myEnv.put(GitSSHHandler.SSH_PORT_ENV, Integer.toString(ssh.getXmlRcpPort())); + int port = ssh.getXmlRcpPort(); + myEnv.put(GitSSHHandler.SSH_PORT_ENV, Integer.toString(port)); + LOG.debug(String.format("handler=%s, port=%s", myHandlerNo, port)); } myCommandLine.setEnvParams(myEnv); // start process From 5885fca3b97ea4a6b9bd7eabd54cc10e232c72f8 Mon Sep 17 00:00:00 2001 From: Eugene Zhuravlev Date: Wed, 11 Apr 2012 17:20:21 +0200 Subject: [PATCH 11/21] IDEA-84343 Remove empty section from 'Messages Make' right-click menu --- .../src/com/intellij/compiler/impl/CompilerErrorTreeView.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/java/compiler/impl/src/com/intellij/compiler/impl/CompilerErrorTreeView.java b/java/compiler/impl/src/com/intellij/compiler/impl/CompilerErrorTreeView.java index 3e2bc2b342de..d3414f3d4528 100644 --- a/java/compiler/impl/src/com/intellij/compiler/impl/CompilerErrorTreeView.java +++ b/java/compiler/impl/src/com/intellij/compiler/impl/CompilerErrorTreeView.java @@ -197,7 +197,6 @@ public class CompilerErrorTreeView extends NewErrorTreeViewPanel { final String[] text = messageElement.getText(); if (text.length > 0) { if (text[0].startsWith("[") && text[0].indexOf("]") != -1) { - presentation.setVisible(true); final Navigatable navigatable = messageElement.getNavigatable(); if (navigatable instanceof OpenFileDescriptor) { final OpenFileDescriptor fileDescriptor = (OpenFileDescriptor)navigatable; @@ -217,6 +216,7 @@ public class CompilerErrorTreeView extends NewErrorTreeViewPanel { final SuppressFix suppressInspectionFix = getSuppressAction(id); final boolean available = suppressInspectionFix.isAvailable(project, null, context); presentation.setEnabled(available); + presentation.setVisible(available); if (available) { presentation.setText(suppressInspectionFix.getText()); } From 636ffb3631e151c0920e51d64458e6c29978458e Mon Sep 17 00:00:00 2001 From: peter Date: Wed, 11 Apr 2012 16:25:14 +0200 Subject: [PATCH 12/21] IDEA-84338 "Code -> Code Completion" is a valid choice for unopened files --- .../src/com/intellij/openapi/actionSystem/impl/Utils.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/Utils.java b/platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/Utils.java index 71a45bffc87c..056870f32628 100644 --- a/platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/Utils.java +++ b/platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/Utils.java @@ -33,7 +33,7 @@ import org.jetbrains.annotations.NotNull; import javax.swing.*; import java.awt.*; -import java.util.*; +import java.util.ArrayList; import java.util.List; /** @@ -135,7 +135,9 @@ public class Utils{ if (actionGroup.hideIfNoVisibleChildren() && !visibleChildren) { continue; } - presentation.setEnabled(actionGroup.canBePerformed(context) || visibleChildren); + if (!actionGroup.canBePerformed(context) && !visibleChildren) { + presentation.setEnabled(false); + } list.add(child); } else { From e49ec61490da68aae7b9dbcf8622c1b9dc2a481a Mon Sep 17 00:00:00 2001 From: peter Date: Wed, 11 Apr 2012 16:41:35 +0200 Subject: [PATCH 13/21] IDEA-84428 Basic completion not working for methods from static imports --- .../codeInsight/completion/JavaCompletionUtil.java | 2 +- .../StaticallyImportedMethodsBeforeExpression.java | 11 +++++++++++ ...aticallyImportedMethodsBeforeExpression_after.java | 11 +++++++++++ .../completion/NormalCompletionTest.groovy | 1 + 4 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 java/java-tests/testData/codeInsight/completion/normal/StaticallyImportedMethodsBeforeExpression.java create mode 100644 java/java-tests/testData/codeInsight/completion/normal/StaticallyImportedMethodsBeforeExpression_after.java diff --git a/java/java-impl/src/com/intellij/codeInsight/completion/JavaCompletionUtil.java b/java/java-impl/src/com/intellij/codeInsight/completion/JavaCompletionUtil.java index 76f0fa24b0b9..06b9574b6450 100644 --- a/java/java-impl/src/com/intellij/codeInsight/completion/JavaCompletionUtil.java +++ b/java/java-impl/src/com/intellij/codeInsight/completion/JavaCompletionUtil.java @@ -459,7 +459,7 @@ public class JavaCompletionUtil { } } - if (javaReference instanceof PsiReferenceExpression && !((PsiReferenceExpression)javaReference).isQualified()) { + if (javaReference instanceof PsiJavaCodeReferenceElement && !((PsiJavaCodeReferenceElement)javaReference).isQualified()) { final StaticMemberProcessor memberProcessor = JavaGlobalMemberNameCompletionContributor.completeStaticMembers(parameters); memberProcessor.processMembersOfRegisteredClasses(matcher, new PairConsumer() { @Override diff --git a/java/java-tests/testData/codeInsight/completion/normal/StaticallyImportedMethodsBeforeExpression.java b/java/java-tests/testData/codeInsight/completion/normal/StaticallyImportedMethodsBeforeExpression.java new file mode 100644 index 000000000000..d27cd96b9e4d --- /dev/null +++ b/java/java-tests/testData/codeInsight/completion/normal/StaticallyImportedMethodsBeforeExpression.java @@ -0,0 +1,11 @@ +import static Foo.assertNotNull; + +class Foo { + static void assertNotNull() {} +} + +class Bar { + { + asnn lists.get(0).size() > 0); + } +} \ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/completion/normal/StaticallyImportedMethodsBeforeExpression_after.java b/java/java-tests/testData/codeInsight/completion/normal/StaticallyImportedMethodsBeforeExpression_after.java new file mode 100644 index 000000000000..bcc1d55c1423 --- /dev/null +++ b/java/java-tests/testData/codeInsight/completion/normal/StaticallyImportedMethodsBeforeExpression_after.java @@ -0,0 +1,11 @@ +import static Foo.assertNotNull; + +class Foo { + static void assertNotNull() {} +} + +class Bar { + { + assertNotNull(); lists.get(0).size() > 0); + } +} \ No newline at end of file diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/completion/NormalCompletionTest.groovy b/java/java-tests/testSrc/com/intellij/codeInsight/completion/NormalCompletionTest.groovy index 89576fded6b9..293d6206aaab 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/completion/NormalCompletionTest.groovy +++ b/java/java-tests/testSrc/com/intellij/codeInsight/completion/NormalCompletionTest.groovy @@ -1328,5 +1328,6 @@ public class ListUtils { public void testListArrayListCast() { doTest('\n') } public void testInterfaceImplementationNoCast() { doTest() } + public void testStaticallyImportedMethodsBeforeExpression() { doTest() } } From 459c30214bfbe309c6d95cd5a118a77a8ff1e04b Mon Sep 17 00:00:00 2001 From: Evgeny Zakrevsky Date: Wed, 11 Apr 2012 20:40:00 +0400 Subject: [PATCH 14/21] Using toolbar decorator as regular toolbar --- .../src/com/intellij/ui/ToolbarDecorator.java | 36 +++++++++++-------- .../com/intellij/ui/TreeToolbarDecorator.java | 5 ++- .../idea/svn/history/SvnHistoryProvider.java | 2 +- 3 files changed, 24 insertions(+), 19 deletions(-) diff --git a/platform/platform-api/src/com/intellij/ui/ToolbarDecorator.java b/platform/platform-api/src/com/intellij/ui/ToolbarDecorator.java index f50793c7edd5..54d27084edef 100644 --- a/platform/platform-api/src/com/intellij/ui/ToolbarDecorator.java +++ b/platform/platform-api/src/com/intellij/ui/ToolbarDecorator.java @@ -17,6 +17,7 @@ package com.intellij.ui; import com.intellij.ide.DataManager; import com.intellij.openapi.actionSystem.*; +import com.intellij.openapi.util.SystemInfo; import com.intellij.ui.border.CustomLineBorder; import com.intellij.ui.table.TableView; import com.intellij.util.ui.ElementProducer; @@ -78,6 +79,7 @@ public abstract class ToolbarDecorator implements DataProvider, CommonActionsPan private Dimension myPreferredSize; private CommonActionsPanel myPanel; private Comparator myButtonComparator; + private boolean myAsTopToolbar = false; protected abstract JComponent getComponent(); @@ -87,33 +89,31 @@ public abstract class ToolbarDecorator implements DataProvider, CommonActionsPan return myPanel; } - public ToolbarDecorator initPositionAndBorder() { - myToolbarPosition = UIUtil.isUnderAquaLookAndFeel() ? ActionToolbarPosition.BOTTOM : ActionToolbarPosition.RIGHT; - myBorder = new CustomLineBorder(0, - myToolbarPosition == ActionToolbarPosition.RIGHT ? 1 : 0, - myToolbarPosition == ActionToolbarPosition.TOP ? 1 : 0, - myToolbarPosition == ActionToolbarPosition.LEFT ? 1 : 0); - final JComponent c = getComponent(); - if (c != null) { - c.setBorder(IdeBorderFactory.createEmptyBorder(0)); - } + public ToolbarDecorator initPosition() { + setToolbarPosition(SystemInfo.isMac ? ActionToolbarPosition.BOTTOM : ActionToolbarPosition.RIGHT); + return this; + } + + public ToolbarDecorator setAsTopToolbar() { + myAsTopToolbar = true; + setToolbarPosition(ActionToolbarPosition.TOP); return this; } public static ToolbarDecorator createDecorator(@NotNull JTable table) { - return new TableToolbarDecorator(table, null).initPositionAndBorder(); + return new TableToolbarDecorator(table, null).initPosition(); } public static ToolbarDecorator createDecorator(@NotNull JTree tree) { - return new TreeToolbarDecorator(tree).initPositionAndBorder(); + return new TreeToolbarDecorator(tree).initPosition(); } public static ToolbarDecorator createDecorator(@NotNull JList list) { - return new ListToolbarDecorator(list).initPositionAndBorder(); + return new ListToolbarDecorator(list).initPosition(); } public static ToolbarDecorator createDecorator(@NotNull TableView table, @Nullable ElementProducer producer) { - return new TableToolbarDecorator(table, producer).initPositionAndBorder(); + return new TableToolbarDecorator(table, producer).initPosition(); } public ToolbarDecorator disableAddAction() { @@ -301,9 +301,15 @@ public abstract class ToolbarDecorator implements DataProvider, CommonActionsPan installUpdaters(); updateButtons(); installDnD(); - panel.setBorder(new LineBorder(UIUtil.getBorderColor())); panel.putClientProperty(ActionToolbar.ACTION_TOOLBAR_PROPERTY_KEY, myPanel.getComponent(0)); DataManager.registerDataProvider(panel, this); + if (!myAsTopToolbar) { + panel.setBorder(new LineBorder(UIUtil.getBorderColor())); + final JComponent c = getComponent(); + if (contextComponent != null) { + contextComponent.setBorder(IdeBorderFactory.createEmptyBorder(0)); + } + } return panel; } diff --git a/platform/platform-api/src/com/intellij/ui/TreeToolbarDecorator.java b/platform/platform-api/src/com/intellij/ui/TreeToolbarDecorator.java index 99d71127a323..667d89a274d6 100644 --- a/platform/platform-api/src/com/intellij/ui/TreeToolbarDecorator.java +++ b/platform/platform-api/src/com/intellij/ui/TreeToolbarDecorator.java @@ -31,9 +31,8 @@ class TreeToolbarDecorator extends ToolbarDecorator { } @Override - public ToolbarDecorator initPositionAndBorder() { - return super.initPositionAndBorder() - .setToolbarPosition(SystemInfo.isMac ? ActionToolbarPosition.BOTTOM : ActionToolbarPosition.TOP); + public ToolbarDecorator initPosition() { + return setToolbarPosition(SystemInfo.isMac ? ActionToolbarPosition.BOTTOM : ActionToolbarPosition.TOP); } @Override diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/history/SvnHistoryProvider.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/history/SvnHistoryProvider.java index 30e6488daec5..39c77be94815 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/history/SvnHistoryProvider.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/history/SvnHistoryProvider.java @@ -101,7 +101,7 @@ public class SvnHistoryProvider @Override protected void updateButtons() { } - }.initPositionAndBorder() + }.initPosition() .addExtraAction(AnActionButton.fromAction(sourceAction)) .createPanel(); fieldPanel.setBorder(IdeBorderFactory.createBorder(SideBorder.LEFT | SideBorder.TOP)); From f0709a8d4341f0ae0fac03c73f513963ccae5fd4 Mon Sep 17 00:00:00 2001 From: Evgeny Zakrevsky Date: Wed, 11 Apr 2012 20:41:12 +0400 Subject: [PATCH 15/21] IDEA-83795 File types panel: inconsistent UI --- .../src/com/intellij/util/IconUtil.java | 8 + .../icons/src/toolbarDecorator/export.png | Bin 0 -> 1441 bytes .../icons/src/toolbarDecorator/import.png | Bin 0 -> 1472 bytes .../fileTypes/impl/FileTypeConfigurable.java | 223 +++++++++--------- .../fileTypes/impl/RecognizedFileTypes.form | 82 ------- .../custom/impl/CustomFileTypeEditor.java | 33 +-- 6 files changed, 134 insertions(+), 212 deletions(-) create mode 100644 platform/icons/src/toolbarDecorator/export.png create mode 100644 platform/icons/src/toolbarDecorator/import.png delete mode 100644 platform/lang-impl/src/com/intellij/openapi/fileTypes/impl/RecognizedFileTypes.form diff --git a/platform/core-api/src/com/intellij/util/IconUtil.java b/platform/core-api/src/com/intellij/util/IconUtil.java index 95cccedcc9e8..1bca832cf114 100644 --- a/platform/core-api/src/com/intellij/util/IconUtil.java +++ b/platform/core-api/src/com/intellij/util/IconUtil.java @@ -211,6 +211,14 @@ public class IconUtil { return getToolbarDecoratorIcon("addClass.png"); } + public static Icon getImportIcon() { + return IconLoader.getIcon("/toolbarDecorator/import.png"); + } + + public static Icon getExportIcon() { + return IconLoader.getIcon("/toolbarDecorator/export.png"); + } + public static Icon getToolbarDecoratorIcon(String name) { return IconLoader.getIcon(getToolbarDecoratorIconsFolder() + name); } diff --git a/platform/icons/src/toolbarDecorator/export.png b/platform/icons/src/toolbarDecorator/export.png new file mode 100644 index 0000000000000000000000000000000000000000..b3ece155aca8dc9992e4f9e5f39bfce663b7a6eb GIT binary patch literal 1441 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`k|nMYCBgY=CFO}lsSJ)O`AMk? zp1FzXsX?iUDV2pMQ*9U+n3Xa^B1$5BeXNr6bM+EIYV;~{3xK*A7;Nk-3KEmEQ%e+* zQqwc@Y?a>c-mj#PnPRIHZt82`Ti~3Uk?B!Ylp0*+7m{3+ootz+WN)WnQ(*-(AUCxn zQK2F?C$HG5!d3}vt`(3C64qBz04piUwpD^SD#ABF!8yMuRl!uxKsVXI%uvD1M9IxIyg#@@$ndN=gc>^!3Zj z%k|2Q_413-^$jg8E%gnI^o@*kfhu&1EAvVcD|GXUm0>2hq!uR^WfqiV=I1GZOiWD5 zFD$Tv3bSNU;+l1ennz|zM-B0$V)JVzP|XC=H|jx7ncO3BHWAB;NpiyW)Z+ZoqGVvir744~DzI`cN=+=uFAB-e&w+(vKt_H^esM;Afr4|esh*)icxGNo zet9uiy|1s8XI^nhVqS8pr;Du;&;-5A%oHmZXA5IvOBZKzV>3%bLsvr!XBP_#6C*b# zGiL*HXH#>SUYGpj(%jU%5}4i;gkBe%dO=Acw*Y9fOKMSOS!#+~QGTuh*vnR#xZUE2 z(>$o&6x?oc!l_pu=oo!a#3DsBObD2IKumbD1#;jCKQ#}S+KYh6dhKfMUn`82V0%}UK}pN4X)Z_DR!Tp6wrzKD-+jy7vu@A5!2W#R`#GQg?tB0J z@6K5QOhNPd_uh5b%CS&>mGFqRqWKo-fX)sdv><)oi~!Z$Eh&)rfX4L@M#_+03-QkrI z(sw%XMDP&DvsJqkME>rd*17l6K4JafNiln@{`}4C-S#xIoV#USr)s`S z{y8P`;l)*xM^y}G)k_t3Ca?4>_?SQAkFVOJmrQI*fh_s<2ajB+cy#)A)r?sMMj0Qk z%Zk4K(Ee$L-k!MhQ)=NM`W;6$P36hZ`+51{$N4|>FZOL=W@KZ~ZvQjM_>YMLsL=Fu L^>bP0l+XkK`^_Lr literal 0 HcmV?d00001 diff --git a/platform/icons/src/toolbarDecorator/import.png b/platform/icons/src/toolbarDecorator/import.png new file mode 100644 index 0000000000000000000000000000000000000000..be19d32757cac07f912ce2023a5f1ccfadff9b89 GIT binary patch literal 1472 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`k|nMYCBgY=CFO}lsSJ)O`AMk? zp1FzXsX?iUDV2pMQ*9U+n3Xa^B1$5BeXNr6bM+EIYV;~{3xK*A7;Nk-3KEmEQ%e+* zQqwc@Y?a>c-mj#PnPRIHZt82`Ti~3Uk?B!Ylp0*+7m{3+ootz+WN)WnQ(*-(AUCxn zQK2F?C$HG5!d3}vt`(3C64qBz04piUwpD^SD#ABF!8yMuRl!uxKsVXI%uvD1M9IxIyg#@@$ndN=gc>^!3Zj z%k|2Q_413-^$jg8E%gnI^o@*kfhu&1EAvVcD|GXUm0>2hq!uR^WfqiV=I1GZOiWD5 zFD$Tv3bSNU;+l1ennz|zM-B0$V)JVzP|XC=H|jx7ncO3BHWAB;NpiyW)Z+ZoqGVvir744~DzI`cN=+=uFAB-e&w+(vKt_H^esM;Afr4|esh*)icxGNo zet9uiy|1s8XI^nhVqS8pr;Du;&;-5A%oHmZ6K4xECudW0V>3%bLsvr!XH!ELBSR+> zQ)6>WM^_h^UYGpj(%jU%5}4i;gkCe8dO=Acw*Y9fOKMSOS!#+~QGTuh*vnR#xZPrm z(>$o&6x?nx!Kqgt=oo!a#3DsBObD2IKumbD1#;jCKQ#}S+KYh6nk9BOGXn#YiKmNW zNX4z5;Pc)hi4t|s+I=5i5}IbdS>Zb0YSmQ7Z;um>hlTkXm`xCEQqp=Ma>?~&!1Pc2 zFBDkiRCaO59l1 zzmZ*|mz}xUz1Ap)M^ghIRP}lMo7B5lQzGr;{*d_#p0zWtVUzBNXKOt>vq5@tb41vp z9d~ANXx|7_U^*OqvT?iE(eMX(|5?~L=EQHjaAyI#&XZh^ZpMVQ%bUKvkC!@rbXy){ zS>y@LD@XT*3;8b#uiIpNJjvjCjtNipqSx|Eg~m!f2>#hd2<;9GlQM*XSK+We#xLR)zj6_Wt~$(696kDC{q9c literal 0 HcmV?d00001 diff --git a/platform/lang-impl/src/com/intellij/openapi/fileTypes/impl/FileTypeConfigurable.java b/platform/lang-impl/src/com/intellij/openapi/fileTypes/impl/FileTypeConfigurable.java index 5d5d0b33f93b..182decab5fa2 100644 --- a/platform/lang-impl/src/com/intellij/openapi/fileTypes/impl/FileTypeConfigurable.java +++ b/platform/lang-impl/src/com/intellij/openapi/fileTypes/impl/FileTypeConfigurable.java @@ -22,6 +22,7 @@ import com.intellij.application.options.SchemesToImportPopup; import com.intellij.ide.highlighter.custom.SyntaxTable; import com.intellij.ide.highlighter.custom.impl.ReadFileType; import com.intellij.lang.Language; +import com.intellij.openapi.actionSystem.AnActionEvent; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.fileTypes.*; import com.intellij.openapi.fileTypes.ex.FileTypeManagerEx; @@ -35,7 +36,7 @@ import com.intellij.openapi.util.text.StringUtil; import com.intellij.psi.templateLanguages.TemplateDataLanguagePatterns; import com.intellij.ui.*; import com.intellij.ui.components.JBList; -import com.intellij.util.ui.UIUtil; +import com.intellij.util.IconUtil; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -43,8 +44,6 @@ import javax.swing.*; import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionListener; import java.awt.*; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import java.util.*; @@ -134,13 +133,13 @@ public class FileTypeConfigurable extends BaseConfigurable implements Searchable public void reset() { myTempPatternsTable = myManager.getExtensionMap().copy(); myTempTemplateDataLanguages = TemplateDataLanguagePatterns.getInstance().getAssocTable(); - + myTempFileTypes = new HashSet(Arrays.asList(getModifiableFileTypes())); myOriginalToEditedMap.clear(); updateFileTypeList(); updateExtensionList(); - + myFileTypePanel.myIgnoreFilesField.setText(myManager.getIgnoredFilesList()); } @@ -148,7 +147,8 @@ public class FileTypeConfigurable extends BaseConfigurable implements Searchable if (!myManager.isIgnoredFilesListEqualToCurrent(myFileTypePanel.myIgnoreFilesField.getText())) return true; HashSet types = new HashSet(Arrays.asList(getModifiableFileTypes())); return !myTempPatternsTable.equals(myManager.getExtensionMap()) || !myTempFileTypes.equals(types) || - !myOriginalToEditedMap.isEmpty() || !myTempTemplateDataLanguages.equals(TemplateDataLanguagePatterns.getInstance().getAssocTable()); + !myOriginalToEditedMap.isEmpty() || + !myTempTemplateDataLanguages.equals(TemplateDataLanguagePatterns.getInstance().getAssocTable()); } public void disposeUIResources() { @@ -194,7 +194,7 @@ public class FileTypeConfigurable extends BaseConfigurable implements Searchable UserFileType ftToEdit = myOriginalToEditedMap.get(fileType); if (ftToEdit == null) ftToEdit = ((UserFileType)fileType).clone(); TypeEditor editor = - new TypeEditor(myRecognizedFileType.myEditButton, ftToEdit, FileTypesBundle.message("filetype.edit.existing.title")); + new TypeEditor(myRecognizedFileType.myFileTypesList, ftToEdit, FileTypesBundle.message("filetype.edit.existing.title")); editor.show(); if (editor.isOK()) { myOriginalToEditedMap.put((UserFileType)fileType, ftToEdit); @@ -220,7 +220,8 @@ public class FileTypeConfigurable extends BaseConfigurable implements Searchable private void addFileType() { //TODO: support adding binary file types... AbstractFileType type = new AbstractFileType(new SyntaxTable()); - TypeEditor editor = new TypeEditor(myRecognizedFileType.myAddButton, type, FileTypesBundle.message("filetype.edit.new.title")); + TypeEditor editor = + new TypeEditor(myRecognizedFileType.myFileTypesList, type, FileTypesBundle.message("filetype.edit.new.title")); editor.show(); if (editor.isOK()) { myTempFileTypes.add(type); @@ -242,7 +243,9 @@ public class FileTypeConfigurable extends BaseConfigurable implements Searchable if (type == null) return; final String title = - item == null ? FileTypesBundle.message("filetype.edit.add.pattern.title") : FileTypesBundle.message("filetype.edit.edit.pattern.title"); + item == null + ? FileTypesBundle.message("filetype.edit.add.pattern.title") + : FileTypesBundle.message("filetype.edit.edit.pattern.title"); final Language oldLanguage = item == null ? null : myTempTemplateDataLanguages.findAssociatedFileType(item); final FileTypePatternDialog dialog = new FileTypePatternDialog(item, type, oldLanguage); @@ -259,20 +262,21 @@ public class FileTypeConfigurable extends BaseConfigurable implements Searchable FileType registeredFileType = findExistingFileType(matcher); if (registeredFileType != null && registeredFileType != type) { if (registeredFileType.isReadOnly()) { - Messages.showMessageDialog(myPatterns.myAddButton, + Messages.showMessageDialog(myPatterns.myPatternsList, FileTypesBundle.message("filetype.edit.add.pattern.exists.error", registeredFileType.getDescription()), title, Messages.getErrorIcon()); return; } else { - if (0 == Messages.showOkCancelDialog(myPatterns.myAddButton, FileTypesBundle.message("filetype.edit.add.pattern.exists.message", - registeredFileType.getDescription()), - FileTypesBundle.message("filetype.edit.add.pattern.exists.title"), - FileTypesBundle.message("filetype.edit.add.pattern.reassign.button"), - CommonBundle.getCancelButtonText(), Messages.getQuestionIcon())) { + if (0 == Messages.showOkCancelDialog(myPatterns.myPatternsList, FileTypesBundle.message("filetype.edit.add.pattern.exists.message", + registeredFileType.getDescription()), + FileTypesBundle.message("filetype.edit.add.pattern.exists.title"), + FileTypesBundle.message("filetype.edit.add.pattern.reassign.button"), + CommonBundle.getCancelButtonText(), Messages.getQuestionIcon())) { myTempPatternsTable.removeAssociation(matcher, registeredFileType); myTempTemplateDataLanguages.removeAssociation(matcher, oldLanguage); - } else { + } + else { return; } } @@ -345,16 +349,13 @@ public class FileTypeConfigurable extends BaseConfigurable implements Searchable public static class RecognizedFileTypes extends JPanel { private JList myFileTypesList; - private JButton myAddButton; - private JButton myEditButton; - private JButton myRemoveButton; - private JPanel myWholePanel; - private JButton myExportButton; - private JButton myImportButton; + private FileTypeConfigurable myController; public RecognizedFileTypes() { super(new BorderLayout()); - add(myWholePanel, BorderLayout.CENTER); + + myFileTypesList = new JBList(new DefaultListModel()); + myFileTypesList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); myFileTypesList.setCellRenderer(new FileTypeRenderer(myFileTypesList.getCellRenderer(), new FileTypeRenderer.FileTypeListProvider() { public Iterable getCurrentFileTypeList() { ArrayList result = new ArrayList(); @@ -364,16 +365,80 @@ public class FileTypeConfigurable extends BaseConfigurable implements Searchable return result; } })); - myFileTypesList.setModel(new DefaultListModel()); + myFileTypesList.addMouseListener(new MouseAdapter() { + public void mouseClicked(MouseEvent e) { + if (e.getClickCount() == 2) myController.editFileType(); + } + }); - if (getSchemesManager().isImportAvailable()) { - myImportButton.setVisible(true); - } - if (getSchemesManager().isExportAvailable()) { - myExportButton.setVisible(true); - } + ToolbarDecorator toolbarDecorator = ToolbarDecorator.createDecorator(myFileTypesList) + .setAddAction(new AnActionButtonRunnable() { + @Override + public void run(AnActionButton button) { + myController.addFileType(); + } + }).setRemoveAction(new AnActionButtonRunnable() { + @Override + public void run(AnActionButton button) { + myController.removeFileType(); + } + }).setEditAction(new AnActionButtonRunnable() { + @Override + public void run(AnActionButton button) { + myController.editFileType(); + } + }).setEditActionUpdater(new AnActionButtonUpdater() { + @Override + public boolean isEnabled(AnActionEvent e) { + final FileType fileType = getSelectedFileType(); + return canBeModified(fileType); + } + }).setRemoveActionUpdater(new AnActionButtonUpdater() { + @Override + public boolean isEnabled(AnActionEvent e) { + final FileType fileType = getSelectedFileType(); + final boolean modified = canBeModified(fileType); + final boolean shared = getSchemesManager().isShared(fileType); + return shared || modified; + } + }).disableUpDownActions(); + //if (getSchemesManager().isImportAvailable()) { + toolbarDecorator.addExtraAction(new AnActionButton("Import Shared...", IconUtil.getImportIcon()) { + @Override + public void actionPerformed(AnActionEvent e) { + new SchemesToImportPopup(myFileTypesList) { + protected void onSchemeSelected(final AbstractFileType scheme) { + myController.importFileType(scheme); + } + }.show(getSchemesManager(), collectRegisteredFileTypes()); + } + }); + //} + + //if (getSchemesManager().isExportAvailable()) { + toolbarDecorator.addExtraAction(new AnActionButton("Share...", IconUtil.getExportIcon()) { + @Override + public void actionPerformed(AnActionEvent e) { + FileType selected = (FileType)myFileTypesList.getSelectedValue(); + if (selected instanceof AbstractFileType) { + ExportSchemeAction.doExport((AbstractFileType)selected, getSchemesManager()); + } + } + + @Override + public void updateButton(AnActionEvent e) { + FileType fileType = getSelectedFileType(); + boolean b = canBeModified(fileType); + boolean shared = getSchemesManager().isShared(fileType); + setEnabled(b && !shared); + } + }); + //} + + add(toolbarDecorator.createPanel(), BorderLayout.CENTER); + setBorder(IdeBorderFactory.createTitledBorder(FileTypesBundle.message("filetypes.recognized.group"), false)); } private SchemesManager getSchemesManager() { @@ -381,58 +446,7 @@ public class FileTypeConfigurable extends BaseConfigurable implements Searchable } public void attachActions(final FileTypeConfigurable controller) { - myAddButton.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - controller.addFileType(); - } - }); - myEditButton.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - controller.editFileType(); - } - }); - myFileTypesList.addListSelectionListener(new ListSelectionListener() { - public void valueChanged(ListSelectionEvent e) { - FileType fileType = getSelectedFileType(); - boolean b = canBeModified(fileType); - myEditButton.setEnabled(b); - myRemoveButton.setEnabled(b); - boolean shared = getSchemesManager().isShared(fileType); - myExportButton.setEnabled(b && !shared); - if (shared) { - myRemoveButton.setEnabled(true); - } - } - }); - myRemoveButton.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - controller.removeFileType(); - } - }); - myFileTypesList.addMouseListener(new MouseAdapter() { - public void mouseClicked(MouseEvent e) { - if (e.getClickCount() == 2) controller.editFileType(); - } - }); - - myImportButton.addActionListener(new ActionListener(){ - public void actionPerformed(final ActionEvent e) { - new SchemesToImportPopup(myWholePanel){ - protected void onSchemeSelected(final AbstractFileType scheme) { - controller.importFileType(scheme); - } - }.show(getSchemesManager(), collectRegisteredFileTypes()); - } - }); - - myExportButton.addActionListener(new ActionListener(){ - public void actionPerformed(final ActionEvent e) { - FileType selected = (FileType)myFileTypesList.getSelectedValue(); - if (selected instanceof AbstractFileType) { - ExportSchemeAction.doExport((AbstractFileType)selected, getSchemesManager()); - } - } - }); + myController = controller; } private Collection collectRegisteredFileTypes() { @@ -448,7 +462,7 @@ public class FileTypeConfigurable extends BaseConfigurable implements Searchable } public JComponent getComponent() { - return myWholePanel; + return this; } public void setFileTypes(FileType[] types) { @@ -489,13 +503,10 @@ public class FileTypeConfigurable extends BaseConfigurable implements Searchable updateFileTypeList(); updateExtensionList(); myRecognizedFileType.selectFileType(type); - } public static class PatternsPanel extends JPanel { private JBList myPatternsList; - private JComponent myAddButton; - private JPanel myWholePanel; private FileTypeConfigurable myController; public PatternsPanel() { @@ -505,27 +516,25 @@ public class FileTypeConfigurable extends BaseConfigurable implements Searchable myPatternsList.setCellRenderer(new ExtensionRenderer()); myPatternsList.getEmptyText().setText(FileTypesBundle.message("filetype.settings.no.patterns")); - myWholePanel = ToolbarDecorator.createDecorator(myPatternsList) - .setAddAction(new AnActionButtonRunnable() { - @Override - public void run(AnActionButton button) { - myController.addPattern(); - } - }).setEditAction(new AnActionButtonRunnable() { - @Override - public void run(AnActionButton button) { - myController.editPattern(); - } - }).setRemoveAction(new AnActionButtonRunnable() { - @Override - public void run(AnActionButton button) { - myController.removePattern(); - } - }).disableUpDownActions().createPanel(); - UIUtil.addBorder(myWholePanel, IdeBorderFactory.createTitledBorder(FileTypesBundle.message("filetype.registered.patterns.group"), false)); - myAddButton = ToolbarDecorator.findAddButton(myWholePanel).getContextComponent(); + add(ToolbarDecorator.createDecorator(myPatternsList) + .setAddAction(new AnActionButtonRunnable() { + @Override + public void run(AnActionButton button) { + myController.addPattern(); + } + }).setEditAction(new AnActionButtonRunnable() { + @Override + public void run(AnActionButton button) { + myController.editPattern(); + } + }).setRemoveAction(new AnActionButtonRunnable() { + @Override + public void run(AnActionButton button) { + myController.removePattern(); + } + }).disableUpDownActions().createPanel(), BorderLayout.CENTER); - add(myWholePanel, BorderLayout.CENTER); + setBorder(IdeBorderFactory.createTitledBorder(FileTypesBundle.message("filetype.registered.patterns.group"), false)); } public void attachActions(final FileTypeConfigurable controller) { @@ -533,7 +542,7 @@ public class FileTypeConfigurable extends BaseConfigurable implements Searchable } public JComponent getComponent() { - return myWholePanel; + return this; } public void clearList() { diff --git a/platform/lang-impl/src/com/intellij/openapi/fileTypes/impl/RecognizedFileTypes.form b/platform/lang-impl/src/com/intellij/openapi/fileTypes/impl/RecognizedFileTypes.form deleted file mode 100644 index c633e980ad11..000000000000 --- a/platform/lang-impl/src/com/intellij/openapi/fileTypes/impl/RecognizedFileTypes.form +++ /dev/null @@ -1,82 +0,0 @@ - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
diff --git a/platform/platform-impl/src/com/intellij/ide/highlighter/custom/impl/CustomFileTypeEditor.java b/platform/platform-impl/src/com/intellij/ide/highlighter/custom/impl/CustomFileTypeEditor.java index f82cdebc9c6c..5cc6a593a1bb 100644 --- a/platform/platform-impl/src/com/intellij/ide/highlighter/custom/impl/CustomFileTypeEditor.java +++ b/platform/platform-impl/src/com/intellij/ide/highlighter/custom/impl/CustomFileTypeEditor.java @@ -24,6 +24,7 @@ import com.intellij.openapi.options.SettingsEditor; import com.intellij.openapi.util.text.StringUtil; import com.intellij.ui.*; import com.intellij.ui.components.JBList; +import com.intellij.util.ui.FormBuilder; import com.intellij.util.ui.GridBag; import com.intellij.util.ui.UIUtil; import org.jetbrains.annotations.NotNull; @@ -136,25 +137,10 @@ public class CustomFileTypeEditor extends SettingsEditor { JPanel panel = new JPanel(new BorderLayout()); JPanel fileTypePanel = new JPanel(new BorderLayout()); - JPanel info = new JPanel(new GridBagLayout()); - GridBagConstraints gc = new GridBagConstraints(); - gc.gridx = 0; - gc.gridy = 0; - gc.anchor = GridBagConstraints.WEST; - gc.fill = GridBagConstraints.BOTH; - info.add(new JLabel(IdeBundle.message("editbox.customfiletype.name")), gc); - gc.gridx = 1; - gc.gridy = 0; - gc.weightx = 1; - info.add(myFileTypeName, gc); - - gc.weightx = 0; - gc.gridx = 0; - gc.gridy = 1; - info.add(new JLabel(IdeBundle.message("editbox.customfiletype.description")), gc); - gc.gridx = 1; - info.add(myFileTypeDescr, gc); - info.setBorder(BorderFactory.createEmptyBorder(5, 0, 5, 5)); + JPanel info = FormBuilder.createFormBuilder() + .addLabeledComponent(IdeBundle.message("editbox.customfiletype.name"), myFileTypeName) + .addLabeledComponent(IdeBundle.message("editbox.customfiletype.description"), myFileTypeDescr).getPanel(); + info.setBorder(BorderFactory.createEmptyBorder(0, 0, 10, 0)); fileTypePanel.add(info, BorderLayout.NORTH); JPanel highlighterPanel = new JPanel(); @@ -164,10 +150,11 @@ public class CustomFileTypeEditor extends SettingsEditor { commentsAndNumbersPanel.setLayout(new GridBagLayout()); JPanel _panel1 = new JPanel(new BorderLayout()); - GridBag gb = new GridBag().setDefaultFill(GridBagConstraints.HORIZONTAL).setDefaultAnchor(GridBagConstraints.WEST).setDefaultInsets(1, - 5, - 1, - 5); + GridBag gb = new GridBag() + .setDefaultFill(GridBagConstraints.HORIZONTAL) + .setDefaultAnchor(GridBagConstraints.WEST) + .setDefaultInsets(1, 5, 1, 5); + commentsAndNumbersPanel.add(new JLabel(IdeBundle.message("editbox.customfiletype.line.comment")), gb.nextLine().next()); commentsAndNumbersPanel.add(myLineComment, gb.next()); commentsAndNumbersPanel.add(myCommentAtLineStart, gb.next().coverLine(2)); From a7965b9770925eb01a0c3113c8b172f756b5457f Mon Sep 17 00:00:00 2001 From: Evgeny Zakrevsky Date: Wed, 11 Apr 2012 20:41:59 +0400 Subject: [PATCH 16/21] IDEA-83957 No scrollbars in Settings->Version Control --- .../VcsDirectoryConfigurationPanel.java | 53 ++++++++----------- .../configurable/VcsManagerConfigurable.java | 2 +- 2 files changed, 22 insertions(+), 33 deletions(-) diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/configurable/VcsDirectoryConfigurationPanel.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/configurable/VcsDirectoryConfigurationPanel.java index c8b4d9e78e9a..b30e1467d767 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/configurable/VcsDirectoryConfigurationPanel.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/configurable/VcsDirectoryConfigurationPanel.java @@ -360,36 +360,25 @@ public class VcsDirectoryConfigurationPanel extends PanelWithButtons implements removeMapping(); updateRootCheckers(); } + }).setAddActionUpdater(new AnActionButtonUpdater() { + @Override + public boolean isEnabled(AnActionEvent e) { + return !myIsDisabled; + } + }).setEditActionUpdater(new AnActionButtonUpdater() { + @Override + public boolean isEnabled(AnActionEvent e) { + final boolean hasSelection = myDirectoryMappingTable.getSelectedObject() != null; + return (!myIsDisabled) && hasSelection; + } + }).setRemoveActionUpdater(new AnActionButtonUpdater() { + @Override + public boolean isEnabled(AnActionEvent e) { + final boolean hasSelection = myDirectoryMappingTable.getSelectedObject() != null; + return (!myIsDisabled) && hasSelection; + } }).disableUpDownActions().createPanel(); - - AnActionButton addButton = ToolbarDecorator.findAddButton(panelForTable); - assert addButton != null; - addButton.addCustomUpdater(new AnActionButtonUpdater() { - @Override - public boolean isEnabled(AnActionEvent e) { - return !myIsDisabled; - } - }); - - AnActionButton editButton = ToolbarDecorator.findEditButton(panelForTable); - assert editButton != null; - editButton.addCustomUpdater(new AnActionButtonUpdater() { - @Override - public boolean isEnabled(AnActionEvent e) { - final boolean hasSelection = myDirectoryMappingTable.getSelectedObject() != null; - return (!myIsDisabled) && hasSelection; - } - }); - - AnActionButton removeButton = ToolbarDecorator.findRemoveButton(panelForTable); - assert removeButton != null; - removeButton.addCustomUpdater(new AnActionButtonUpdater() { - @Override - public boolean isEnabled(AnActionEvent e) { - final boolean hasSelection = myDirectoryMappingTable.getSelectedObject() != null; - return (!myIsDisabled) && hasSelection; - } - }); + panelForTable.setPreferredSize(new Dimension(-1, 200)); return panelForTable; } @@ -523,8 +512,9 @@ public class VcsDirectoryConfigurationPanel extends PanelWithButtons implements VcsRootErrorLabel(String title) { super(new BorderLayout(DEFAULT_HGAP, DEFAULT_VGAP)); - CompoundBorder outsideBorder = BorderFactory.createCompoundBorder(BorderFactory.createMatteBorder(5, 0, 5, 0, UIUtil.getPanelBackground()), - BorderFactory.createLineBorder(UIUtil.getPanelBackground().darker())); + CompoundBorder outsideBorder = + BorderFactory.createCompoundBorder(BorderFactory.createMatteBorder(5, 0, 5, 0, UIUtil.getPanelBackground()), + BorderFactory.createLineBorder(UIUtil.getPanelBackground().darker())); setBorder(BorderFactory.createCompoundBorder(outsideBorder, BorderFactory.createEmptyBorder(DEFAULT_VGAP, DEFAULT_HGAP, DEFAULT_VGAP, DEFAULT_HGAP))); setOpaque(true); @@ -553,5 +543,4 @@ public class VcsDirectoryConfigurationPanel extends PanelWithButtons implements }, null); } } - } diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/configurable/VcsManagerConfigurable.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/configurable/VcsManagerConfigurable.java index 71613ab35ee3..86dc3940cd42 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/configurable/VcsManagerConfigurable.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/configurable/VcsManagerConfigurable.java @@ -36,7 +36,7 @@ import java.util.Arrays; import java.util.Collection; import java.util.List; -public class VcsManagerConfigurable extends SearchableConfigurable.Parent.Abstract implements Configurable.NoScroll { +public class VcsManagerConfigurable extends SearchableConfigurable.Parent.Abstract { public static final Icon ICON = IconLoader.getIcon("/general/configurableVcs.png"); private final Project myProject; private VcsDirectoryConfigurationPanel myMappings; From 8facb88755d63b2b90cedadf06f6390bb9f05649 Mon Sep 17 00:00:00 2001 From: Roman Shevchenko Date: Wed, 11 Apr 2012 15:04:18 +0200 Subject: [PATCH 17/21] Drop unneeded inspection from project profile --- .idea/inspectionProfiles/idea_default.xml | 1 - 1 file changed, 1 deletion(-) diff --git a/.idea/inspectionProfiles/idea_default.xml b/.idea/inspectionProfiles/idea_default.xml index cd8ff3afdb36..78549253c339 100644 --- a/.idea/inspectionProfiles/idea_default.xml +++ b/.idea/inspectionProfiles/idea_default.xml @@ -314,7 +314,6 @@ - From 6a99032acac5edda2beb0eb99b13ad6813928de8 Mon Sep 17 00:00:00 2001 From: Roman Shevchenko Date: Wed, 11 Apr 2012 19:25:08 +0200 Subject: [PATCH 18/21] Cleanup --- .../vfs/impl/local/LocalFileSystemImpl.java | 138 ++++++------------ 1 file changed, 47 insertions(+), 91 deletions(-) diff --git a/platform/platform-impl/src/com/intellij/openapi/vfs/impl/local/LocalFileSystemImpl.java b/platform/platform-impl/src/com/intellij/openapi/vfs/impl/local/LocalFileSystemImpl.java index 3a983be0cc52..2e528457a167 100644 --- a/platform/platform-impl/src/com/intellij/openapi/vfs/impl/local/LocalFileSystemImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/vfs/impl/local/LocalFileSystemImpl.java @@ -21,7 +21,6 @@ import com.intellij.openapi.application.ModalityState; import com.intellij.openapi.components.ApplicationComponent; import com.intellij.openapi.fileEditor.FileDocumentManager; import com.intellij.openapi.util.Computable; -import com.intellij.openapi.util.SystemInfo; import com.intellij.openapi.util.io.FileAttributes; import com.intellij.openapi.util.io.FileSystemUtil; import com.intellij.openapi.util.io.FileUtil; @@ -34,9 +33,6 @@ import com.intellij.openapi.vfs.newvfs.RefreshQueue; import com.intellij.openapi.vfs.newvfs.impl.VirtualDirectoryImpl; import com.intellij.openapi.vfs.newvfs.persistent.PersistentFS; import com.intellij.util.TimeoutUtil; -import com.intellij.util.concurrency.JBLock; -import com.intellij.util.concurrency.JBReentrantReadWriteLock; -import com.intellij.util.concurrency.LockFactory; import com.intellij.util.containers.HashSet; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; @@ -47,51 +43,30 @@ import java.io.IOException; import java.util.*; public final class LocalFileSystemImpl extends LocalFileSystemBase implements ApplicationComponent { - private final JBReentrantReadWriteLock LOCK = LockFactory.createReadWriteLock(); - private final JBLock WRITE_LOCK = LOCK.writeLock(); - + private final Object myLock = new Object(); private final List myRootsToWatch = new ArrayList(); - private WatchRequest[] myCachedNormalizedRequests = null; - + private WatchRequestImpl[] myCachedNormalizedRequests = null; private final FileWatcher myWatcher; private static class WatchRequestImpl implements WatchRequest { - public final String myRootPath; - - public String myFSRootPath; - public final boolean myToWatchRecursively; - boolean myDominated; + private final String myRootPath; + private final boolean myToWatchRecursively; + private String myFSRootPath; + private boolean myDominated; public WatchRequestImpl(String rootPath, final boolean toWatchRecursively) { - myToWatchRecursively = toWatchRecursively; final int index = rootPath.indexOf(JarFileSystem.JAR_SEPARATOR); if (index >= 0) rootPath = rootPath.substring(0, index); - final File file = new File(rootPath.replace('/', File.separatorChar)); - if (!file.isDirectory()) { - final File parentFile = file.getParentFile(); - if (parentFile != null) { - if (SystemInfo.isFileSystemCaseSensitive) { - myFSRootPath = parentFile.getAbsolutePath(); // fixes problem with symlinks under Unix (however does not under Windows!) - } - else { - try { - myFSRootPath = parentFile.getCanonicalPath(); - } - catch (IOException e) { - myFSRootPath = rootPath; //need something - } - } - } - else { - myFSRootPath = rootPath.replace('/', File.separatorChar); - } - myRootPath = myFSRootPath.replace(File.separatorChar, '/'); - } - else { - myRootPath = rootPath.replace(File.separatorChar, '/'); - myFSRootPath = rootPath.replace('/', File.separatorChar); + File rootFile = new File(FileUtil.toSystemDependentName(rootPath)); + if (index > 0 || !rootFile.isDirectory()) { + rootFile = rootFile.getParentFile(); + assert rootFile != null : rootPath; } + + myFSRootPath = rootFile.getAbsolutePath(); + myRootPath = FileUtil.toSystemIndependentName(myFSRootPath); + myToWatchRecursively = toWatchRecursively; } @Override @@ -100,6 +75,7 @@ public final class LocalFileSystemImpl extends LocalFileSystemBase implements Ap return myRootPath; } + /** @deprecated implementation details (to remove in IDEA 13) */ @Override @NotNull public String getFileSystemRootPath() { @@ -111,13 +87,10 @@ public final class LocalFileSystemImpl extends LocalFileSystemBase implements Ap return myToWatchRecursively; } + /** @deprecated implementation details (to remove in IDEA 13) */ @Override public boolean dominates(@NotNull WatchRequest other) { - if (myToWatchRecursively) { - return other.getRootPath().startsWith(myRootPath); - } - - return !other.isToWatchRecursively() && myRootPath.equals(other.getRootPath()); + return LocalFileSystemImpl.dominates(this, (WatchRequestImpl)other); } @Override @@ -160,13 +133,12 @@ public final class LocalFileSystemImpl extends LocalFileSystemBase implements Ap myRootsToWatch.clear(); } - private WatchRequest[] normalizeRootsForRefresh() { + private WatchRequestImpl[] normalizeRootsForRefresh() { if (myCachedNormalizedRequests != null) return myCachedNormalizedRequests; List result = new ArrayList(); // No need to call for a read action here since we're only called with it on hands already. - WRITE_LOCK.lock(); - try { + synchronized (myLock) { NextRoot: for (WatchRequestImpl request : myRootsToWatch) { String rootPath = request.getRootPath(); @@ -189,20 +161,17 @@ public final class LocalFileSystemImpl extends LocalFileSystemBase implements Ap request.myDominated = false; } } - finally { - WRITE_LOCK.unlock(); - } - myCachedNormalizedRequests = result.toArray(new WatchRequest[result.size()]); + myCachedNormalizedRequests = result.toArray(new WatchRequestImpl[result.size()]); return myCachedNormalizedRequests; } private void storeRefreshStatusToFiles() { - if (FileWatcher.getInstance().isOperational()) { + if (myWatcher.isOperational()) { // TODO: different ways to mark dirty for all these cases - markPathsDirty(FileWatcher.getInstance().getDirtyPaths()); - markFlatDirsDirty(FileWatcher.getInstance().getDirtyDirs()); - markRecursiveDirsDirty(FileWatcher.getInstance().getDirtyRecursivePaths()); + markPathsDirty(myWatcher.getDirtyPaths()); + markFlatDirsDirty(myWatcher.getDirtyDirs()); + markRecursiveDirsDirty(myWatcher.getDirtyRecursivePaths()); } } @@ -269,26 +238,22 @@ public final class LocalFileSystemImpl extends LocalFileSystemBase implements Ap application.runReadAction(new Runnable() { @Override public void run() { - WRITE_LOCK.lock(); - try { - final WatchRequest[] watchRequests = normalizeRootsForRefresh(); + synchronized (myLock) { + final WatchRequestImpl[] watchRequests = normalizeRootsForRefresh(); List myRecursiveRoots = new ArrayList(); List myFlatRoots = new ArrayList(); - for (WatchRequest root : watchRequests) { + for (WatchRequestImpl root : watchRequests) { if (root.isToWatchRecursively()) { - myRecursiveRoots.add(root.getFileSystemRootPath()); + myRecursiveRoots.add(root.myFSRootPath); } else { - myFlatRoots.add(root.getFileSystemRootPath()); + myFlatRoots.add(root.myFSRootPath); } } myWatcher.setWatchRoots(myRecursiveRoots, myFlatRoots); } - finally { - WRITE_LOCK.unlock(); - } } }); } @@ -298,8 +263,7 @@ public final class LocalFileSystemImpl extends LocalFileSystemBase implements Ap private static final long PERIOD = 1000; public StoreRefreshStatusThread() { - //noinspection HardCodedStringLiteral - super("StoreRefreshStatusThread"); + super(StoreRefreshStatusThread.class.getSimpleName()); setPriority(MIN_PRIORITY); setDaemon(true); } @@ -324,14 +288,13 @@ public final class LocalFileSystemImpl extends LocalFileSystemBase implements Ap @Override public WatchRequest addRootToWatch(@NotNull final String rootPath, final boolean toWatchRecursively) { - if (rootPath.length() == 0 || !FileWatcher.getInstance().isOperational()) return null; + if (rootPath.length() == 0 || !myWatcher.isOperational()) return null; Application app = ApplicationManager.getApplication(); return app.runReadAction(new Computable() { @Override public WatchRequest compute() { - WRITE_LOCK.lock(); - try { + synchronized (myLock) { final WatchRequestImpl result = new WatchRequestImpl(rootPath, toWatchRecursively); boolean alreadyWatched = isAlreadyWatched(result); if (!alreadyWatched) { @@ -355,24 +318,29 @@ public final class LocalFileSystemImpl extends LocalFileSystemBase implements Ap setUpFileWatcher(); return result; } - finally { - WRITE_LOCK.unlock(); - } } }); } - private boolean isAlreadyWatched(final WatchRequest request) { - for (final WatchRequest current : normalizeRootsForRefresh()) { - if (current.dominates(request)) return true; + private boolean isAlreadyWatched(final WatchRequestImpl request) { + for (final WatchRequestImpl current : normalizeRootsForRefresh()) { + if (dominates(current, request)) return true; } return false; } + private static boolean dominates(final WatchRequestImpl request, final WatchRequestImpl other) { + if (request.myToWatchRecursively) { + return other.myRootPath.startsWith(request.myRootPath); + } + + return !other.myToWatchRecursively && request.myRootPath.equals(other.myRootPath); + } + @Override @NotNull public Set addRootsToWatch(@NotNull final Collection rootPaths, final boolean toWatchRecursively) { - if (!FileWatcher.getInstance().isOperational()) return Collections.emptySet(); + if (!myWatcher.isOperational()) return Collections.emptySet(); final Set result = new HashSet(); final Set filesToSynchronize = new HashSet(); @@ -380,8 +348,7 @@ public final class LocalFileSystemImpl extends LocalFileSystemBase implements Ap Application application = ApplicationManager.getApplication(); application.runReadAction(new Runnable() { public void run() { - WRITE_LOCK.lock(); - try { + synchronized (myLock) { for (String rootPath : rootPaths) { LOG.assertTrue(rootPath != null); if (rootPath.length() > 0) { @@ -399,9 +366,6 @@ public final class LocalFileSystemImpl extends LocalFileSystemBase implements Ap myCachedNormalizedRequests = null; setUpFileWatcher(); } - finally { - WRITE_LOCK.unlock(); - } } }); @@ -421,16 +385,12 @@ public final class LocalFileSystemImpl extends LocalFileSystemBase implements Ap public void removeWatchedRoot(@NotNull final WatchRequest watchRequest) { ApplicationManager.getApplication().runReadAction(new Runnable() { public void run() { - WRITE_LOCK.lock(); - try { + synchronized (myLock) { if (myRootsToWatch.remove((WatchRequestImpl)watchRequest) && !((WatchRequestImpl)watchRequest).myDominated) { myCachedNormalizedRequests = null; setUpFileWatcher(); } } - finally { - WRITE_LOCK.unlock(); - } } }); } @@ -439,16 +399,12 @@ public final class LocalFileSystemImpl extends LocalFileSystemBase implements Ap public void removeWatchedRoots(@NotNull final Collection rootsToWatch) { ApplicationManager.getApplication().runReadAction(new Runnable() { public void run() { - WRITE_LOCK.lock(); - try { + synchronized (myLock) { if (myRootsToWatch.removeAll(rootsToWatch)) { myCachedNormalizedRequests = null; setUpFileWatcher(); } } - finally { - WRITE_LOCK.unlock(); - } } }); } From 9472570d1bdf937727db65f78e752b7da16cd7ba Mon Sep 17 00:00:00 2001 From: Alexander Lobas Date: Wed, 11 Apr 2012 21:52:18 +0400 Subject: [PATCH 19/21] TableLayout --- .../android/designer/icons/TableLayout.png | Bin 0 -> 467 bytes .../android/designer/icons/TableRow.png | Bin 0 -> 475 bytes .../intellij/android/designer/icons/View.png | Bin 0 -> 1022 bytes .../designer/model/layout/RadTableLayout.java | 75 ++++++++++++++++++ .../model/layout/RadTableRowLayout.java | 75 ++++++++++++++++++ .../designer/model/views-meta-model.xml | 49 +++++++++++- 6 files changed, 198 insertions(+), 1 deletion(-) create mode 100644 plugins/android-designer/src/com/intellij/android/designer/icons/TableLayout.png create mode 100644 plugins/android-designer/src/com/intellij/android/designer/icons/TableRow.png create mode 100644 plugins/android-designer/src/com/intellij/android/designer/icons/View.png create mode 100644 plugins/android-designer/src/com/intellij/android/designer/model/layout/RadTableLayout.java create mode 100644 plugins/android-designer/src/com/intellij/android/designer/model/layout/RadTableRowLayout.java diff --git a/plugins/android-designer/src/com/intellij/android/designer/icons/TableLayout.png b/plugins/android-designer/src/com/intellij/android/designer/icons/TableLayout.png new file mode 100644 index 0000000000000000000000000000000000000000..31e668e8f589e063e0e68c6dd586115da8173c7f GIT binary patch literal 467 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|*pj^6T^Rm@ z;DWu&Cj&(|3p^r=85p>QL70(Y)*K0-AbW|YuPgg)MoAGx!N?fT5TKA`iEBiObAE1a zYF-J0b5UwyNotBhd1gt5g1e`0KzJjcIM6CRPZ!4!i_>c-8RjuL3b06bp7-rjp7fhR zNZz1>UEtxA9{Uf9I*o>G${z~f_-${twctx;Z|f{uI(Od7SGhB0emFnNZ#nObnR=_s z)StfNQe0snS9*fq$oOr!^;|add`)jAPY;%v=awi4G6*Ew>|e|I;nBg=V4=c*ler(f z7JL+7a}CruUtIh4yOD8i-u7ELW>NKPzV3_4+!>SgaodF&yXiAumYS_L<}h?pIg)ZP zS?7AW1?R^jOSTB?J@;Vc)m3Y+e1?yjs)^ERqn_iBXA7tDcK)pcHUW;xBqP~dO4O2osdWlz$V4HB~%J{U>ORWIEg%hP_?WNuS;dbP^O zJFgesf1hk15hAw8`cCBURiZBb0#hIDNh|p8zi0bC#={BuGxhH*Y6Au@gQu&X%Q~lo FCIF))w2uG) literal 0 HcmV?d00001 diff --git a/plugins/android-designer/src/com/intellij/android/designer/icons/TableRow.png b/plugins/android-designer/src/com/intellij/android/designer/icons/TableRow.png new file mode 100644 index 0000000000000000000000000000000000000000..dad799c8bde15c3f72fb0a875945e42e530bb67b GIT binary patch literal 475 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|*pj^6T^Rm@ z;DWu&Cj&(|3p^r=85p>QL70(Y)*K0-AbW|YuPgg)MoAGx4qNkwQ-DH}C9V-A&iT2y zsd*&~&PAz-C8;S2<(VZJ3hti10pX2&;y|m+JY5_^EKaYTWSDozLBQ2sX!=8zj;1Xc z{f9g66tGS3Xq}+pEZFCu!l7uvk#y$WpZQ6=#{`#f_@sJU=YQLOb5^n6k91zPW~n*F zyVj_9o{|qrQ+vPn)8oMQHw#oex7>eQA{DdWZ5qp@2^>aslbc)^95^1VPHtKKwq<`@COIJL`AmX6I)GL6~c=xm~_q zE#J%M`Sm@pp{@otivg(XgSO};O$p$H}>Y{wFhMfJT7aA-z=Dxq3{Gz>IF!U{4JV-d&* zBZy^)^cqH{s+$Od=_7J)S-53(-PY6>KUw0CvDAccG#W{xxWhz-MlNQSap;}*4i zoG`zrCHX?d;F3JZqLf860VSh9p!>`cxzghh;?(m_h?9JpD4sG{_$kB^f^l5NHL=cF zm;8}&s&(EQrv!FMPWQ8b*JEp;0`uIR?Wi>5YRvmt#EatZx-{62Ny6H$CGtN~7==7V zO9*3KLAs2zC5#QFZrd%_a9m^?Hqt7N)38|99Y@hM)zEc}n|Mi;8x5=?)o@!a+ih0Z zc9Jtc2}tEP;(jr9kJ8<$13E*>Xg;JVa5hv41J4hlq`WB$bR4fs zvgk1hTN#bPB*SKOiUOqk8@b)!(bSQq+pdmn*A}PP@PD!fxfocs$6xJIUGW|)w decorators, List selection) { + super.addStaticDecorators(decorators, selection); // TODO: Auto-generated method stub + } + + @Override + public ComponentDecorator getChildSelectionDecorator(RadComponent component, List selection) { + return super.getChildSelectionDecorator(component, selection); // TODO: Auto-generated method stub + } + + ////////////////////////////////////////////////////////////////////////////////////////// + // + // Actions + // + ////////////////////////////////////////////////////////////////////////////////////////// + + @Override + public void addContainerSelectionActions(DesignerEditorPanel designer, + DefaultActionGroup actionGroup, + JComponent shortcuts, + List selection) { + super.addContainerSelectionActions(designer, actionGroup, shortcuts, selection); // TODO: Auto-generated method stub + } + + @Override + public void addSelectionActions(DesignerEditorPanel designer, + DefaultActionGroup actionGroup, + JComponent shortcuts, + List selection) { + super.addSelectionActions(designer, actionGroup, shortcuts, selection); // TODO: Auto-generated method stub + } +} \ No newline at end of file diff --git a/plugins/android-designer/src/com/intellij/android/designer/model/layout/RadTableRowLayout.java b/plugins/android-designer/src/com/intellij/android/designer/model/layout/RadTableRowLayout.java new file mode 100644 index 000000000000..4554a3d6c905 --- /dev/null +++ b/plugins/android-designer/src/com/intellij/android/designer/model/layout/RadTableRowLayout.java @@ -0,0 +1,75 @@ +/* + * Copyright 2000-2012 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.android.designer.model.layout; + +import com.intellij.android.designer.model.RadViewLayoutWithData; +import com.intellij.designer.designSurface.*; +import com.intellij.designer.model.RadComponent; +import com.intellij.openapi.actionSystem.DefaultActionGroup; +import org.jetbrains.annotations.NotNull; + +import javax.swing.*; +import java.util.List; + +/** + * @author Alexander Lobas + */ +public class RadTableRowLayout extends RadViewLayoutWithData implements ILayoutDecorator { + private static final String[] LAYOUT_PARAMS = {"TableRow_Cell", "LinearLayout_Layout", "ViewGroup_MarginLayout"}; + + @Override + @NotNull + public String[] getLayoutParams() { + return LAYOUT_PARAMS; + } + + @Override + public EditOperation processChildOperation(OperationContext context) { + return super.processChildOperation(context); // TODO: Auto-generated method stub + } + + @Override + public void addStaticDecorators(List decorators, List selection) { + super.addStaticDecorators(decorators, selection); // TODO: Auto-generated method stub + } + + @Override + public ComponentDecorator getChildSelectionDecorator(RadComponent component, List selection) { + return super.getChildSelectionDecorator(component, selection); // TODO: Auto-generated method stub + } + + ////////////////////////////////////////////////////////////////////////////////////////// + // + // Actions + // + ////////////////////////////////////////////////////////////////////////////////////////// + + @Override + public void addContainerSelectionActions(DesignerEditorPanel designer, + DefaultActionGroup actionGroup, + JComponent shortcuts, + List selection) { + super.addContainerSelectionActions(designer, actionGroup, shortcuts, selection); // TODO: Auto-generated method stub + } + + @Override + public void addSelectionActions(DesignerEditorPanel designer, + DefaultActionGroup actionGroup, + JComponent shortcuts, + List selection) { + super.addSelectionActions(designer, actionGroup, shortcuts, selection); // TODO: Auto-generated method stub + } +} \ No newline at end of file diff --git a/plugins/android-designer/src/com/intellij/android/designer/model/views-meta-model.xml b/plugins/android-designer/src/com/intellij/android/designer/model/views-meta-model.xml index 8f9b927d0e53..26969c811864 100644 --- a/plugins/android-designer/src/com/intellij/android/designer/model/views-meta-model.xml +++ b/plugins/android-designer/src/com/intellij/android/designer/model/views-meta-model.xml @@ -25,11 +25,17 @@ - + + + + + @@ -1038,6 +1044,7 @@ tooltip="A Layout that arranges its children in a single column or a single row."/> @@ -1092,6 +1099,44 @@ + + + + + + + + + + ]]> + + + + + + + + + + + ]]> + + + @@ -1153,6 +1198,8 @@ + + From cd11836e646e955ae2d6d99946347e0ffbea9460 Mon Sep 17 00:00:00 2001 From: nik Date: Thu, 12 Apr 2012 09:11:50 +0400 Subject: [PATCH 20/21] IDEA-84216: Provide different icons for NodeJS and client JavaScript debug toolwindows --- .../intellij/xdebugger/XDebuggerManager.java | 15 ++++++++++-- .../xdebugger/impl/XDebugSessionImpl.java | 24 +++++++++---------- .../xdebugger/impl/XDebuggerManagerImpl.java | 11 ++++++++- .../xdebugger/impl/ui/XDebugSessionTab.java | 7 ++++-- 4 files changed, 40 insertions(+), 17 deletions(-) diff --git a/platform/xdebugger-api/src/com/intellij/xdebugger/XDebuggerManager.java b/platform/xdebugger-api/src/com/intellij/xdebugger/XDebuggerManager.java index d92fb5d41231..dea7f5f61214 100644 --- a/platform/xdebugger-api/src/com/intellij/xdebugger/XDebuggerManager.java +++ b/platform/xdebugger-api/src/com/intellij/xdebugger/XDebuggerManager.java @@ -26,6 +26,7 @@ import com.intellij.xdebugger.breakpoints.XBreakpointManager; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import javax.swing.*; import java.util.Collection; /** @@ -78,8 +79,18 @@ public abstract class XDebuggerManager { * @param showToolWindowOnSuspendOnly if {@code true} 'Debug' tool window won't be shown until debug process is suspended on a breakpoint */ @NotNull - public abstract XDebugSession startSessionAndShowTab(@NotNull String sessionName, - @Nullable RunContentDescriptor contentToReuse, + public abstract XDebugSession startSessionAndShowTab(@NotNull String sessionName, @Nullable RunContentDescriptor contentToReuse, boolean showToolWindowOnSuspendOnly, @NotNull XDebugProcessStarter starter) throws ExecutionException; + + /** + * Start a new debugging session and open 'Debug' tool window + * @param sessionName title of 'Debug' tool window + * @param icon icon of 'Debug' tool window + * @param showToolWindowOnSuspendOnly if {@code true} 'Debug' tool window won't be shown until debug process is suspended on a breakpoint + */ + @NotNull + public abstract XDebugSession startSessionAndShowTab(@NotNull String sessionName, @Nullable Icon icon, + @Nullable RunContentDescriptor contentToReuse, boolean showToolWindowOnSuspendOnly, + @NotNull XDebugProcessStarter starter) throws ExecutionException; } diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/XDebugSessionImpl.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/XDebugSessionImpl.java index e11978e3d91e..a26c52860416 100644 --- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/XDebugSessionImpl.java +++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/XDebugSessionImpl.java @@ -85,29 +85,28 @@ public class XDebugSessionImpl implements XDebugSession { private boolean myPaused; private MyDependentBreakpointListener myDependentBreakpointListener; private XValueMarkers myValueMarkers; - private String mySessionName; + private final String mySessionName; private XDebugSessionTab mySessionTab; private XDebugSessionData mySessionData; private XBreakpoint myActiveNonLineBreakpoint; private final EventDispatcher myDispatcher = EventDispatcher.create(XDebugSessionListener.class); - private Project myProject; - private @Nullable ExecutionEnvironment myEnvironment; - private ProgramRunner myRunner; + private final Project myProject; + private final @Nullable ExecutionEnvironment myEnvironment; + private final ProgramRunner myRunner; private boolean myStopped; private boolean myPauseActionSupported; private boolean myShowTabOnSuspend; private ConsoleView myConsoleView; + private final Icon myIcon; - public XDebugSessionImpl(final @NotNull ExecutionEnvironment env, - final @NotNull ProgramRunner runner, + public XDebugSessionImpl(final @NotNull ExecutionEnvironment env, final @NotNull ProgramRunner runner, XDebuggerManagerImpl debuggerManager) { - this(env, runner, debuggerManager, env.getRunProfile().getName(), false); + this(env, runner, debuggerManager, env.getRunProfile().getName(), env.getRunProfile().getIcon(), false); } - public XDebugSessionImpl(final @Nullable ExecutionEnvironment env, - final @Nullable ProgramRunner runner, - XDebuggerManagerImpl debuggerManager, - final @NotNull String sessionName, final boolean showTabOnSuspend) { + public XDebugSessionImpl(final @Nullable ExecutionEnvironment env, final @Nullable ProgramRunner runner, + XDebuggerManagerImpl debuggerManager, final @NotNull String sessionName, + final @Nullable Icon icon, final boolean showTabOnSuspend) { myEnvironment = env; myRunner = runner; mySessionName = sessionName; @@ -115,6 +114,7 @@ public class XDebugSessionImpl implements XDebugSession { myShowTabOnSuspend = showTabOnSuspend; myProject = debuggerManager.getProject(); ValueLookupManager.getInstance(myProject).startListening(); + myIcon = icon; } @NotNull @@ -232,7 +232,7 @@ public class XDebugSessionImpl implements XDebugSession { } private void initSessionTab() { - mySessionTab = new XDebugSessionTab(myProject, mySessionName); + mySessionTab = new XDebugSessionTab(myProject, mySessionName, myIcon); if (myEnvironment != null) { mySessionTab.setEnvironment(myEnvironment); } diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/XDebuggerManagerImpl.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/XDebuggerManagerImpl.java index e032e88cc876..1e752b4a1680 100644 --- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/XDebuggerManagerImpl.java +++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/XDebuggerManagerImpl.java @@ -55,6 +55,7 @@ import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import javax.swing.*; import java.util.*; /** @@ -181,8 +182,16 @@ public class XDebuggerManagerImpl extends XDebuggerManager implements ProjectCom public XDebugSession startSessionAndShowTab(@NotNull String sessionName, @Nullable RunContentDescriptor contentToReuse, boolean showToolWindowOnSuspendOnly, @NotNull XDebugProcessStarter starter) throws ExecutionException { + return startSessionAndShowTab(sessionName, null, contentToReuse, showToolWindowOnSuspendOnly, starter); + } + + @NotNull + @Override + public XDebugSession startSessionAndShowTab(@NotNull String sessionName, final Icon icon, @Nullable RunContentDescriptor contentToReuse, + boolean showToolWindowOnSuspendOnly, + @NotNull XDebugProcessStarter starter) throws ExecutionException { XDebugSessionImpl session = startSession(contentToReuse, starter, new XDebugSessionImpl(null, null, this, sessionName, - showToolWindowOnSuspendOnly)); + icon, showToolWindowOnSuspendOnly)); if (!showToolWindowOnSuspendOnly) { session.showSessionTab(); } diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/XDebugSessionTab.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/XDebugSessionTab.java index f3dadf64bf25..19ee9aded2ea 100644 --- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/XDebugSessionTab.java +++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/XDebugSessionTab.java @@ -48,6 +48,7 @@ import com.intellij.xdebugger.impl.ui.tree.actions.SortValuesToggleAction; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import javax.swing.*; import java.util.ArrayList; import java.util.List; @@ -57,9 +58,11 @@ import java.util.List; public class XDebugSessionTab extends DebuggerSessionTabBase { private XWatchesView myWatchesView; private final List myViews = new ArrayList(); + private final Icon myIcon; - public XDebugSessionTab(@NotNull final Project project, @NotNull final String sessionName) { + public XDebugSessionTab(@NotNull final Project project, @NotNull final String sessionName, final @Nullable Icon icon) { super(project, "Debug", sessionName); + myIcon = icon; } private static ActionGroup getActionGroup(final String id) { @@ -129,7 +132,7 @@ public class XDebugSessionTab extends DebuggerSessionTabBase { final XDebugProcess debugProcess = session.getDebugProcess(); ProcessHandler processHandler = debugProcess.getProcessHandler(); myConsole = consoleView; - myRunContentDescriptor = new RunContentDescriptor(myConsole, processHandler, myUi.getComponent(), mySessionName); + myRunContentDescriptor = new RunContentDescriptor(myConsole, processHandler, myUi.getComponent(), mySessionName, myIcon); myUi.addContent(createFramesContent(session), 0, PlaceInGrid.left, false); myUi.addContent(createVariablesContent(session), 0, PlaceInGrid.center, false); From c2bc019dd918393989814f906ac529a9257b2af2 Mon Sep 17 00:00:00 2001 From: nik Date: Thu, 12 Apr 2012 11:02:01 +0400 Subject: [PATCH 21/21] IDEA-84476: Remote JS debug run configuration: open mappings tree for the first mapping --- .../src/com/intellij/util/ui/tree/AbstractFileTreeTable.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/platform/lang-impl/src/com/intellij/util/ui/tree/AbstractFileTreeTable.java b/platform/lang-impl/src/com/intellij/util/ui/tree/AbstractFileTreeTable.java index 76dbeefae243..ec32b3994d56 100644 --- a/platform/lang-impl/src/com/intellij/util/ui/tree/AbstractFileTreeTable.java +++ b/platform/lang-impl/src/com/intellij/util/ui/tree/AbstractFileTreeTable.java @@ -37,6 +37,7 @@ import com.intellij.util.containers.HashMap; import com.intellij.util.ui.UIUtil; import gnu.trove.THashMap; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; import javax.swing.*; import javax.swing.table.TableColumn; @@ -200,7 +201,7 @@ public abstract class AbstractFileTreeTable extends TreeTable { getTree().setModel(myModel); } - public void select(final VirtualFile toSelect) { + public void select(final @Nullable VirtualFile toSelect) { if (toSelect != null) { select(toSelect, (TreeNode)myModel.getRoot()); }