From 0f2577f77d324cbbc460ea73521b6bc7c69751d5 Mon Sep 17 00:00:00 2001 From: Dmitry Batrak Date: Sat, 21 Feb 2015 11:00:54 +0300 Subject: [PATCH 01/21] IDEA-136452 Can't surround with {} code starting from the comment under if statement second attempt. first one didn't account for cases when end-of-line comment is a statement's child node --- .../java-impl/src/com/intellij/codeInsight/CodeInsightUtil.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/java/java-impl/src/com/intellij/codeInsight/CodeInsightUtil.java b/java/java-impl/src/com/intellij/codeInsight/CodeInsightUtil.java index 65c6777bcbbb..e4103ce1a9c9 100644 --- a/java/java-impl/src/com/intellij/codeInsight/CodeInsightUtil.java +++ b/java/java-impl/src/com/intellij/codeInsight/CodeInsightUtil.java @@ -106,7 +106,7 @@ public class CodeInsightUtil { if (parent == null) return PsiElement.EMPTY_ARRAY; while (true) { if (parent instanceof PsiStatement) { - if (!(element1 instanceof PsiComment || element2 instanceof PsiComment)) { + if (!(element1 instanceof PsiComment)) { parent = parent.getParent(); } break; From d1caaab17bdb545fa4a7e1bd88484c9df85a56ba Mon Sep 17 00:00:00 2001 From: Dmitry Batkovich Date: Sat, 21 Feb 2015 16:38:03 +0300 Subject: [PATCH 02/21] i18n: added inspection to detect suspicious locale languages. Will help for people who has wrong resource bundle association --- plugins/java-i18n/src/META-INF/plugin.xml | 6 + .../SuspiciousLocalesLanguagesInspection.java | 239 ++++++++++++++++++ .../suspiciousLanguages/simple1/p.properties | 0 .../simple1/p_en.properties | 0 .../suspiciousLanguages/simple2/p.properties | 1 + .../simple2/p_asd.properties | 1 + .../withAdditionalLocales/p.properties | 0 .../withAdditionalLocales/p_asd.properties | 0 .../SuspiciousLanguagesInspectionTest.java | 60 +++++ .../messages/PropertiesBundle.properties | 6 + .../properties/ResourceBundleManager.java | 8 +- .../DissociateResourceBundleAction.java | 22 +- .../SuspiciousLocalesLanguages.html | 5 + 13 files changed, 337 insertions(+), 11 deletions(-) create mode 100644 plugins/java-i18n/src/com/intellij/codeInspection/SuspiciousLocalesLanguagesInspection.java create mode 100644 plugins/java-i18n/testData/inspections/suspiciousLanguages/simple1/p.properties create mode 100644 plugins/java-i18n/testData/inspections/suspiciousLanguages/simple1/p_en.properties create mode 100644 plugins/java-i18n/testData/inspections/suspiciousLanguages/simple2/p.properties create mode 100644 plugins/java-i18n/testData/inspections/suspiciousLanguages/simple2/p_asd.properties create mode 100644 plugins/java-i18n/testData/inspections/suspiciousLanguages/withAdditionalLocales/p.properties create mode 100644 plugins/java-i18n/testData/inspections/suspiciousLanguages/withAdditionalLocales/p_asd.properties create mode 100644 plugins/java-i18n/testSrc/com/intellij/codeInspection/SuspiciousLanguagesInspectionTest.java create mode 100644 resources-en/src/inspectionDescriptions/SuspiciousLocalesLanguages.html diff --git a/plugins/java-i18n/src/META-INF/plugin.xml b/plugins/java-i18n/src/META-INF/plugin.xml index c3e2c5aab225..3f042db7095e 100644 --- a/plugins/java-i18n/src/META-INF/plugin.xml +++ b/plugins/java-i18n/src/META-INF/plugin.xml @@ -54,6 +54,12 @@ enabledByDefault="true" level="WARNING" implementationClass="com.intellij.codeInspection.capitalization.TitleCapitalizationInspection"/> + com.intellij.codeInspection.capitalization.AnnotateCapitalizationIntention diff --git a/plugins/java-i18n/src/com/intellij/codeInspection/SuspiciousLocalesLanguagesInspection.java b/plugins/java-i18n/src/com/intellij/codeInspection/SuspiciousLocalesLanguagesInspection.java new file mode 100644 index 000000000000..b9ec80f1a5b5 --- /dev/null +++ b/plugins/java-i18n/src/com/intellij/codeInspection/SuspiciousLocalesLanguagesInspection.java @@ -0,0 +1,239 @@ +/* + * Copyright 2000-2015 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.codeInspection; + +import com.intellij.codeInspection.ex.BaseLocalInspectionTool; +import com.intellij.lang.properties.PropertiesBundle; +import com.intellij.lang.properties.PropertiesImplUtil; +import com.intellij.lang.properties.ResourceBundle; +import com.intellij.lang.properties.ResourceBundleManager; +import com.intellij.lang.properties.customizeActions.DissociateResourceBundleAction; +import com.intellij.lang.properties.psi.PropertiesFile; +import com.intellij.openapi.project.Project; +import com.intellij.openapi.ui.InputValidator; +import com.intellij.openapi.ui.Messages; +import com.intellij.openapi.util.Condition; +import com.intellij.openapi.util.InvalidDataException; +import com.intellij.openapi.util.WriteExternalException; +import com.intellij.openapi.util.text.StringUtil; +import com.intellij.psi.PsiFile; +import com.intellij.reference.SoftLazyValue; +import com.intellij.ui.AnActionButton; +import com.intellij.ui.AnActionButtonRunnable; +import com.intellij.ui.ToolbarDecorator; +import com.intellij.ui.components.JBList; +import com.intellij.util.Function; +import com.intellij.util.containers.ContainerUtil; +import com.intellij.util.containers.HashSet; +import org.jdom.Element; +import org.jetbrains.annotations.Nls; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.jetbrains.annotations.TestOnly; + +import javax.swing.*; +import java.awt.*; +import java.util.*; +import java.util.List; + +/** + * @author Dmitry Batkovich + */ +public class SuspiciousLocalesLanguagesInspection extends BaseLocalInspectionTool { + private static final String ADDITIONAL_LANGUAGES_ATTR_NAME = "additionalLanguages"; + private final static SoftLazyValue> JAVA_LOCALES = new SoftLazyValue>() { + @NotNull + @Override + protected Set compute() { + final Set result = new HashSet(); + for (Locale locale : Locale.getAvailableLocales()) { + result.add(locale.getLanguage()); + } + return result; + } + }; + + private final List myAdditionalLanguages = new ArrayList(); + + @Nls + @NotNull + @Override + public String getDisplayName() { + return "Suspicious resource bundle locale languages"; + } + + @TestOnly + public void setAdditionalLanguages(List additionalLanguages) { + myAdditionalLanguages.clear(); + myAdditionalLanguages.addAll(additionalLanguages); + } + + @Override + public void readSettings(@NotNull Element node) throws InvalidDataException { + final String rawLanguages = node.getAttributeValue(ADDITIONAL_LANGUAGES_ATTR_NAME); + if (rawLanguages != null) { + myAdditionalLanguages.clear(); + myAdditionalLanguages.addAll(StringUtil.split(rawLanguages, ",")); + } + } + + @Override + public void writeSettings(@NotNull Element node) throws WriteExternalException { + if (!myAdditionalLanguages.isEmpty()) { + final ArrayList uniqueLanguages = ContainerUtil.newArrayList(ContainerUtil.newHashSet(myAdditionalLanguages)); + Collections.sort(uniqueLanguages); + final String locales = StringUtil.join(uniqueLanguages, ","); + node.setAttribute(ADDITIONAL_LANGUAGES_ATTR_NAME, locales); + } + } + + @Nullable + @Override + public JComponent createOptionsPanel() { + return new MyOptions().getComponent(); + } + + @Nullable + @Override + public ProblemDescriptor[] checkFile(@NotNull PsiFile file, @NotNull InspectionManager manager, boolean isOnTheFly) { + final PropertiesFile propertiesFile = PropertiesImplUtil.getPropertiesFile(file); + if (propertiesFile == null) { + return null; + } + final ResourceBundle resourceBundle = propertiesFile.getResourceBundle(); + final List files = resourceBundle.getPropertiesFiles(); + if (files.isEmpty()) { + return null; + } + List bundleLocales = ContainerUtil.mapNotNull(files, new Function() { + @Override + public Locale fun(PropertiesFile propertiesFile) { + final Locale locale = propertiesFile.getLocale(); + return locale == ResourceBundleManager.DEFAULT_LOCALE ? null : locale; + } + }); + bundleLocales = ContainerUtil.filter(bundleLocales, new Condition() { + @Override + public boolean value(Locale locale) { + return !JAVA_LOCALES.getValue().contains(locale.getLanguage()) && !myAdditionalLanguages.contains(locale.getLanguage()); + } + }); + if (bundleLocales.isEmpty()) { + return null; + } + final ProblemDescriptor descriptor = manager.createProblemDescriptor(file, + PropertiesBundle.message( + "resource.bundle.contains.locales.with.suspicious.locale.languages.desciptor"), + new DissociateResourceBundleQuickFix(resourceBundle), + ProblemHighlightType.WEAK_WARNING, + true); + return new ProblemDescriptor[] {descriptor}; + } + + private static class DissociateResourceBundleQuickFix implements LocalQuickFix { + private final ResourceBundle myResourceBundle; + + private DissociateResourceBundleQuickFix(ResourceBundle bundle) { + myResourceBundle = bundle; + } + + @Nls + @NotNull + @Override + public String getName() { + return getFamilyName(); + } + + @NotNull + @Override + public String getFamilyName() { + return PropertiesBundle.message("dissociate.resource.bundle.quick.fix.name"); + } + + @Override + public void applyFix(@NotNull Project project, @NotNull ProblemDescriptor descriptor) { + DissociateResourceBundleAction.dissociate(Collections.singleton(myResourceBundle), project); + } + } + + private class MyOptions { + private JBList myAdditionalLocalesList; + + public MyOptions() { + myAdditionalLocalesList = new JBList(new MyListModel()); + myAdditionalLocalesList.setCellRenderer(new DefaultListCellRenderer()); + } + + public JPanel getComponent() { + final JPanel panel = new JPanel(new BorderLayout()); + panel.add(new JLabel(PropertiesBundle.message("dissociate.resource.bundle.quick.fix.options.label")), BorderLayout.NORTH); + panel.add( + ToolbarDecorator.createDecorator(myAdditionalLocalesList) + .setAddAction(new AnActionButtonRunnable() { + @Override + public void run(AnActionButton button) { + Messages.showInputDialog(panel, PropertiesBundle.message("dissociate.resource.bundle.quick.fix.options.input.text"), + PropertiesBundle.message("dissociate.resource.bundle.quick.fix.options.input.title"), null, "", new InputValidator() { + @Override + public boolean checkInput(String inputString) { + return 1 < inputString.length() && inputString.length() < 9 && !myAdditionalLanguages.contains(inputString); + } + + @Override + public boolean canClose(String inputString) { + if (inputString != null) { + myAdditionalLanguages.add(inputString); + ((MyListModel)myAdditionalLocalesList.getModel()).fireContentsChanged(); + } + return true; + } + }); + } + }) + .setRemoveAction(new AnActionButtonRunnable() { + @Override + public void run(AnActionButton button) { + final int index = myAdditionalLocalesList.getSelectedIndex(); + if (index > -1 && index < myAdditionalLanguages.size()) { + myAdditionalLanguages.remove(index); + ((MyListModel)myAdditionalLocalesList.getModel()).fireContentsChanged(); + } + } + }) + .setPreferredSize(new Dimension(-1, 100)) + .disableUpDownActions() + .createPanel(), + BorderLayout.CENTER); + return panel; + } + + private class MyListModel extends AbstractListModel { + @Override + public int getSize() { + return myAdditionalLanguages.size(); + } + + @Override + public Object getElementAt(int index) { + return myAdditionalLanguages.get(index); + } + + public void fireContentsChanged() { + fireContentsChanged(myAdditionalLanguages, -1, -1); + } + } + } +} diff --git a/plugins/java-i18n/testData/inspections/suspiciousLanguages/simple1/p.properties b/plugins/java-i18n/testData/inspections/suspiciousLanguages/simple1/p.properties new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/plugins/java-i18n/testData/inspections/suspiciousLanguages/simple1/p_en.properties b/plugins/java-i18n/testData/inspections/suspiciousLanguages/simple1/p_en.properties new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/plugins/java-i18n/testData/inspections/suspiciousLanguages/simple2/p.properties b/plugins/java-i18n/testData/inspections/suspiciousLanguages/simple2/p.properties new file mode 100644 index 000000000000..cb17b36e6685 --- /dev/null +++ b/plugins/java-i18n/testData/inspections/suspiciousLanguages/simple2/p.properties @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/plugins/java-i18n/testData/inspections/suspiciousLanguages/simple2/p_asd.properties b/plugins/java-i18n/testData/inspections/suspiciousLanguages/simple2/p_asd.properties new file mode 100644 index 000000000000..cb17b36e6685 --- /dev/null +++ b/plugins/java-i18n/testData/inspections/suspiciousLanguages/simple2/p_asd.properties @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/plugins/java-i18n/testData/inspections/suspiciousLanguages/withAdditionalLocales/p.properties b/plugins/java-i18n/testData/inspections/suspiciousLanguages/withAdditionalLocales/p.properties new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/plugins/java-i18n/testData/inspections/suspiciousLanguages/withAdditionalLocales/p_asd.properties b/plugins/java-i18n/testData/inspections/suspiciousLanguages/withAdditionalLocales/p_asd.properties new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/plugins/java-i18n/testSrc/com/intellij/codeInspection/SuspiciousLanguagesInspectionTest.java b/plugins/java-i18n/testSrc/com/intellij/codeInspection/SuspiciousLanguagesInspectionTest.java new file mode 100644 index 000000000000..784b6e9ea737 --- /dev/null +++ b/plugins/java-i18n/testSrc/com/intellij/codeInspection/SuspiciousLanguagesInspectionTest.java @@ -0,0 +1,60 @@ +/* + * Copyright 2000-2015 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.codeInspection; + +import com.intellij.openapi.application.PluginPathManager; +import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase; +import com.intellij.util.containers.ContainerUtil; + +import java.io.File; + +/** + * @author Dmitry Batkovich + */ +public class SuspiciousLanguagesInspectionTest extends LightCodeInsightFixtureTestCase { + @Override + protected String getBasePath() { + return PluginPathManager.getPluginHomePathRelative("java-i18n") + "/testData/inspections/suspiciousLanguages"; + } + + public void testSimple1() { + doTest(); + } + + public void testSimple2() { + doTest(); + } + + public void testWithAdditionalLocales() { + doTest("asd"); + } + + private void doTest(final String... additionalLocales) { + final File tesDataDir = new File(getHomePath() + File.separator + getBasePath() + File.separator + getTestName(true)); + final File[] files = tesDataDir.listFiles(); + assertNotNull(files); + for (File file : files) { + final String path = file.getAbsolutePath(); + myFixture.configureByFile(path); + } + final SuspiciousLocalesLanguagesInspection inspection = new SuspiciousLocalesLanguagesInspection(); + if (additionalLocales.length != 0) { + inspection.setAdditionalLanguages(ContainerUtil.newArrayList(additionalLocales)); + } + myFixture.enableInspections(inspection); + myFixture.checkHighlighting(); + } +} diff --git a/plugins/properties/properties-psi-api/resources/messages/PropertiesBundle.properties b/plugins/properties/properties-psi-api/resources/messages/PropertiesBundle.properties index aefabc574b38..1a58d5b832a4 100644 --- a/plugins/properties/properties-psi-api/resources/messages/PropertiesBundle.properties +++ b/plugins/properties/properties-psi-api/resources/messages/PropertiesBundle.properties @@ -60,3 +60,9 @@ inline.property.confirmation=Inline property ''{0}'' with value ''{1}''? alpha.unsorted.properties.file.inspection.display.name=Properties File or Resource Bundle is Alphabetically Unsorted trailing.spaces.in.property.inspection.ignore.visible.spaces=Ignore visible whitespaces + +resource.bundle.contains.locales.with.suspicious.locale.languages.desciptor=Resource bundle contains locales with suspicious locale languages +dissociate.resource.bundle.quick.fix.name=Dissociate Resource Bundle +dissociate.resource.bundle.quick.fix.options.label=Additional language codes\: +dissociate.resource.bundle.quick.fix.options.input.text=Inter language code +dissociate.resource.bundle.quick.fix.options.input.title=Additional Locale Languages diff --git a/plugins/properties/properties-psi-impl/src/com/intellij/lang/properties/ResourceBundleManager.java b/plugins/properties/properties-psi-impl/src/com/intellij/lang/properties/ResourceBundleManager.java index 5d8487d468a2..626961e8b9f2 100644 --- a/plugins/properties/properties-psi-impl/src/com/intellij/lang/properties/ResourceBundleManager.java +++ b/plugins/properties/properties-psi-impl/src/com/intellij/lang/properties/ResourceBundleManager.java @@ -47,7 +47,7 @@ import java.util.regex.Matcher; }) public class ResourceBundleManager implements PersistentStateComponent { private final static Logger LOG = Logger.getInstance(ResourceBundleManager.class); - private final static Locale DEFAULT_LOCALE = new Locale("", "", ""); + public final static Locale DEFAULT_LOCALE = new Locale("", "", ""); private ResourceBundleManagerState myState = new ResourceBundleManagerState(); @@ -172,7 +172,11 @@ public class ResourceBundleManager implements PersistentStateComponent resourceBundles = extractResourceBundles(e); assert resourceBundles.size() > 0; - final FileEditorManager fileEditorManager = FileEditorManager.getInstance(project); - for (ResourceBundle resourceBundle : resourceBundles) { - fileEditorManager.closeFile(new ResourceBundleAsVirtualFile(resourceBundle)); - for (final PropertiesFile propertiesFile : resourceBundle.getPropertiesFiles()) { - fileEditorManager.closeFile(propertiesFile.getVirtualFile()); - } - ResourceBundleManager.getInstance(e.getProject()).dissociateResourceBundle(resourceBundle); - } - ProjectView.getInstance(project).refresh(); + dissociate(resourceBundles, project); } @Override @@ -79,6 +71,18 @@ public class DissociateResourceBundleAction extends AnAction { } } + public static void dissociate(final Collection resourceBundles, final Project project) { + final FileEditorManager fileEditorManager = FileEditorManager.getInstance(project); + for (ResourceBundle resourceBundle : resourceBundles) { + fileEditorManager.closeFile(new ResourceBundleAsVirtualFile(resourceBundle)); + for (final PropertiesFile propertiesFile : resourceBundle.getPropertiesFiles()) { + fileEditorManager.closeFile(propertiesFile.getVirtualFile()); + } + ResourceBundleManager.getInstance(project).dissociateResourceBundle(resourceBundle); + } + ProjectView.getInstance(project).refresh(); + } + @NotNull private static Collection extractResourceBundles(final AnActionEvent event) { final Set targetResourceBundles = new HashSet(); diff --git a/resources-en/src/inspectionDescriptions/SuspiciousLocalesLanguages.html b/resources-en/src/inspectionDescriptions/SuspiciousLocalesLanguages.html new file mode 100644 index 000000000000..8a6f5535c32a --- /dev/null +++ b/resources-en/src/inspectionDescriptions/SuspiciousLocalesLanguages.html @@ -0,0 +1,5 @@ + + +Inspection detects locales which contain languages not included supported by Java. + + \ No newline at end of file From 05f1324905522d0af9b2fc4c2d6a1c5061b60129 Mon Sep 17 00:00:00 2001 From: Eugene Zhuravlev Date: Sat, 21 Feb 2015 21:35:33 +0100 Subject: [PATCH 03/21] speeding up netty initialization for some systems --- .../impl/src/com/intellij/compiler/server/BuildManager.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/java/compiler/impl/src/com/intellij/compiler/server/BuildManager.java b/java/compiler/impl/src/com/intellij/compiler/server/BuildManager.java index 9ceffac57eb4..9648285288a1 100644 --- a/java/compiler/impl/src/com/intellij/compiler/server/BuildManager.java +++ b/java/compiler/impl/src/com/intellij/compiler/server/BuildManager.java @@ -93,6 +93,7 @@ import io.netty.handler.codec.protobuf.ProtobufDecoder; import io.netty.handler.codec.protobuf.ProtobufEncoder; import io.netty.handler.codec.protobuf.ProtobufVarint32FrameDecoder; import io.netty.handler.codec.protobuf.ProtobufVarint32LengthFieldPrepender; +import io.netty.util.internal.ThreadLocalRandom; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.ide.PooledThreadExecutor; @@ -999,6 +1000,9 @@ public class BuildManager implements ApplicationComponent{ cmdLine.addParameter("-Didea.case.sensitive.fs=" + isFSCaseSensitive); } + // this will make netty initialization faster on some systems + cmdLine.addParameter("-Dio.netty.initialSeedUniquifier=" + ThreadLocalRandom.getInitialSeedUniquifier()); + boolean isProfilingMode = false; final String additionalOptions = config.COMPILER_PROCESS_ADDITIONAL_VM_OPTIONS; if (!StringUtil.isEmpty(additionalOptions)) { From 032be763669931ebaf4717081fd5e2e984054cc4 Mon Sep 17 00:00:00 2001 From: Konstantin Bulenkov Date: Sat, 21 Feb 2015 23:09:52 +0100 Subject: [PATCH 04/21] duplicate window shadows to avoid resizing on HiDPI --- platform/icons/src/ide/shadow/bottom-left@2x.png | Bin 0 -> 1510 bytes .../icons/src/ide/shadow/bottom-right@2x.png | Bin 0 -> 1525 bytes platform/icons/src/ide/shadow/bottom@2x.png | Bin 0 -> 313 bytes platform/icons/src/ide/shadow/left@2x.png | Bin 0 -> 233 bytes platform/icons/src/ide/shadow/right@2x.png | Bin 0 -> 245 bytes platform/icons/src/ide/shadow/top-left@2x.png | Bin 0 -> 1055 bytes platform/icons/src/ide/shadow/top-right@2x.png | Bin 0 -> 1169 bytes platform/icons/src/ide/shadow/top@2x.png | Bin 0 -> 175 bytes 8 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 platform/icons/src/ide/shadow/bottom-left@2x.png create mode 100644 platform/icons/src/ide/shadow/bottom-right@2x.png create mode 100644 platform/icons/src/ide/shadow/bottom@2x.png create mode 100644 platform/icons/src/ide/shadow/left@2x.png create mode 100644 platform/icons/src/ide/shadow/right@2x.png create mode 100644 platform/icons/src/ide/shadow/top-left@2x.png create mode 100644 platform/icons/src/ide/shadow/top-right@2x.png create mode 100644 platform/icons/src/ide/shadow/top@2x.png diff --git a/platform/icons/src/ide/shadow/bottom-left@2x.png b/platform/icons/src/ide/shadow/bottom-left@2x.png new file mode 100644 index 0000000000000000000000000000000000000000..10e5d1c9c5f60e1ed3d5fde61550594f0a8da45e GIT binary patch literal 1510 zcmeAS@N?(olHy`uVBq!ia0vp^ZXnFT3?e@WZDU|y3=Z%KasB`QKTu>8P%#AVH@#{F z8dq2n ztEX>ZXk=_+YG!U>X=QC=YiIA^=;Z9;>gMj@>E-R?>*pU37!({58WtWA85JE98yBCD zn3SB7nwFlCnU$TBo0ng3_L!s-0|WC#PZ!6Kh}NZH;Yr%&0?v|m|LeW9l>KbjdS~jq zT+L1PTX?w>90F7vCoRzk+?1l3WBsMT;*a#czaQ8RPtds?)^fP7KOyB7&+W1+_pJ>K zT&HT>?)tCnH7!N^4bxASwmdWWt}L@nF(opZZ=3@&H$Gy{Utny0QcZ@>b@Ps zOJum}8JrD`%!@XtfBju;U~<&KBg`jHCjXFvhb(h>i;`14Q02KFKMii$w>2J<2`_S* zDc%0BhI<+Nxd~e4oS(1vC$4B*So|pL#lwIfyb@Z85sREoy}9|3&qv?);f4F{RPNULq4H5w^5 zJ5roGMK}Z*j?bRVo48BNWm3Tg7tcuv2dDlN+T3xp(J|5|IP`?-iD^%5=I_#+@FZ!o zWS{~oXV9!O3#wx}D;p-XOmkRZYnPZYrF&;|YSp4Zmf%GWPmOQS;`Y(=-{>^S#zsSk zb^F94PtvNJ^VXeW3-Q9# zLfy_Z={whS5+?|;Wy+p*^V~Z3^vwH{T9!D8v<8cuJF9j0@xMaFYxRMF&)--cRcMUT ze!L{L<EU zo6?rXT`Q&pHdq~eduC~VRm3XUq`KIUV9s+sipk7h=MA>%^zzYsqVwrkHad z(w7>sGQF9B=L|>^j6*tRN^M71P@)yUUqd?7hKt zp0_@HO=TZ0?6mA#e@e}z**tu=#r(DstFygj4KhvflEn>iKSPZ8g0H82;VEjijK7h> zx9~>xgMUBX^5{qGso6iHJHB@BnK!>aJiYX4=6pH(pCyxaUEIO*bn6c3h0XstE9)Pa zo~iwFU3hz84ddrmJFm~%SNFeL_`Ko&N1tDP>MYq_YL(x&zv{I9ls`}Yz1OQ<`da#| h{f>vdyZ7z=Y5(p){$3S~6@vd$@?2>^W82M7QF literal 0 HcmV?d00001 diff --git a/platform/icons/src/ide/shadow/bottom-right@2x.png b/platform/icons/src/ide/shadow/bottom-right@2x.png new file mode 100644 index 0000000000000000000000000000000000000000..771dfef1db73f41b2ea7be0e40733473558d8f22 GIT binary patch literal 1525 zcmeAS@N?(olHy`uVBq!ia0vp^ZXnFT3?e@WZDU|y3=Z%KasB`QKTu>8P%#AVH@#{F z8dq2n ztEX>ZXk=_+YG!U>X=QC=YiIA^=;Z9;>gMj@>E-R?>*pU37!({58WtWA85JE98yBCD zn3SB7nwFlCnU$TBo0ng3_L!s-0|WB|PZ!6Kh{JQIJ5GCS!Q*`J<(&L;M&IiN|LJ&K zoHDs;>Xzz>Avp&bJe*!#cz=EW>z(sn|E#H6yLFyU^-UcEhK_o>2Ej>7I5;(by)XQ) zJR@Vx4#qdXd4=feSg0 z8Xj2BU<%r>zexEjC(oo7MZ-tE>-=weC?G9jsI)4oV~60c8%fKz1b)wVeOp%i z-S=iNg{E*_JbwK`LiZ+}Z#`}9w5!B)d7HDA9*C^~v5OgVr0MuYY5 z%|G|=P1}>Q`oxYaQ=8a!{Hfd$cYK=v&7{XB?qxUYH@#TnVWz~w=YBP7fy&}3&!@!C zHIaJpQKni$VpmXTNl$p2yp!0Yu)LRynSa)$NZ!&gvL zRTU?bHm-VgBYNAdbIu{}B_qABJFK16p1M1Sv1#HW6`sdS9%g->(;%`rq9{1U@9BqU zD^EYZ`+94_Rf7}U`Z;CqpBnT}n!jjEqE7VgnAM*a|71Ag=W@{?GEZ;LnYN{ip4{y( z{jlZSyWK9aTQ^-;bth6Q^V=!`Mv-uZ&rHd#=?DET=az2cyYAa4v-p8>zKqATIeWNU zPR&15AZ{I}qb3uyPa!^IWzF4*aSugpkKX$KrQ+QlO}(G1vVI#%>|3?<``W{gUI?yt z7P#BC;LPJEOJq;q;aMlJw=CJ+)cRV%EV1p&cZ=+mJsVJNr9Az)$`s}AXTQ%g7Z;i< zbwW0BF8}kN&!o<(Y%W#KGCwyXJU{I3gj?s0UB2ttteQ7_&icIu>565RCOYSyJ}un0 zpzP7yyV3r{O#w>_e5sq~`WS{h5vBAz3lA#{wt2!eB4&6^Um?*AB#G+#XrvW zvU+c(q4}MkM|OT$_cUYw_5aC*br1XM&d)M8*z^Bf^%ePF&(5~q)7zI_Q8Ksg!4>1* z#%)XN7jD1)G2_GG-uT3OdJm7Q|9`Q#JN}*hzq*%u{;_XgAT+0T-<)Tla?8`z&t;uc GLK6T(2Qp3o literal 0 HcmV?d00001 diff --git a/platform/icons/src/ide/shadow/bottom@2x.png b/platform/icons/src/ide/shadow/bottom@2x.png new file mode 100644 index 0000000000000000000000000000000000000000..ad69deefa9b67e4226fa9f50c71ab7ecb5087476 GIT binary patch literal 313 zcmeAS@N?(olHy`uVBq!ia0vp^j6iJ2!3-pIHX4fosonse5LX~Qc)+W6;~zlR=$8cf z1v9ebWo4(OB*te%gogzBdAYkd*uEal|5uGfMp1{=f-zVoxkB`8K!)F*$6`eUZtYC=|jXQDR#E}C_c$YLXF!YNt Uu|L{l_zV;Pp00i_>zopr0AS56tpET3 literal 0 HcmV?d00001 diff --git a/platform/icons/src/ide/shadow/left@2x.png b/platform/icons/src/ide/shadow/left@2x.png new file mode 100644 index 0000000000000000000000000000000000000000..78c558d74d75db1d5863832ed29a8a0275d9173d GIT binary patch literal 233 zcmeAS@N?(olHy`uVBq!ia0vp^%0SG>!3-pmlb?qHsk8u}5LX~g2T+hRf$rIH}O zU?xUp7FITP4lZt9egPp7aY<=81tm329epD+3tI;lcW=LCeGlb;ss%h<978x{lT-ej eKX9Z&o`FH7l2Q5mKAU)ugFRjST-G@yGywqWC>*^2 literal 0 HcmV?d00001 diff --git a/platform/icons/src/ide/shadow/right@2x.png b/platform/icons/src/ide/shadow/right@2x.png new file mode 100644 index 0000000000000000000000000000000000000000..d2afef8fd36d2cdc3f2c6a4a15d6bd6b587eddba GIT binary patch literal 245 zcmeAS@N?(olHy`uVBq!ia0vp^%0SG>!3-pmlb?qHsk8u}5LX~g2T+hRf$rIH}O zU?x9zZwFfo7bATgO*Lf&Gigb25g`G7UT!W9b~aWPW;sTu%=}$I)iRzgjv*Yf$tfwn q&i|S|apGrnWeJYj1Q%9*NfE~4N>*iMN$oQr$9uZ^xvXAt@y-BP%Dbps1v*qN=8@p{b>cH9a++?`&VTvH@#Mx0e$gHM3+%oNsAo6|98@`Gv&2fRTk^X;S4ZshisC25 zn=7~%JO0}367`KGXGUa1bCXN5L5Js6j#o>6-q4gi(6wgqE`R5aCYdX0yYJuTZ(-HA z6Z%zamZ?-pcbCT>bcNwu|@UP<3TIm?=zIB)JJ|ETKm2AZ?Z^oGB zUlM9CedWLW-kswu6LtyAK0RkuX0bu~>bW|*XBAvq(P?Jg`g7^w<1XKHk~f^6ojA>J zc3|I3(lANz7hlfAT_Po`+qy)`E6wSQTEE|1hvoEhn;KE*~OVzskLe8|>_-~UeJ zwtlcwi{~g7R=ATK?CHCuZ^ro=!>~(H0WU30XPvQF{zgL6ttsv1m8PV%dz}Qfteb!N z%^JyVyv|$HN@d=EpDT0j{GE$k0#|j?PGorg%Fg~(+OcfqJ@;^ty8j>Ir9VuN)>w5` zAahQWh}_Qgt0M3F&-wM~(yTR3%hLPh4V1S<)?}BiPx4R+wf>V>ta8bpf6LA#{JHAt@y-BP%Dbps1v*qN=8@p{b>?rw0T4JWd zrRsV+(QjVTI-3d>C$$bM zOr77A|2$`2x4grSRc#K}+3QXxwKwyXs7?FAs$%fRf6`aRg4hX$pR%sJQL++9Uo`21 znoQKg#Tv|ugr5yF4oXsrT((#lD6PO z{m@klS4;}AFnZi-ee>xw&fEz>?j46p5+pR;C0G>=Hc0S=hPE#_d@#_1Z$ZmsuSJ&_ zJ6^geurM?D_W4`z653yb4I1uKa&8$;DZH>-&?Yie~lK2#2v=6LlRUo(H~g&lLg&xyL9(Ubf|s+RX;thRwP_5DEWULn?=;L7s?3tK(A^Sr>Bc6_xhvJ|Ct67O z?(MccY`gNt_RnQ;>%FgbH2D7dXEF6s{i_gLSvvV>P}&k9pV#S0 kj<4o#K9Od1$)ffj|J9X|8$WJu6#^A3p00i_>zopr0E6O)EC2ui literal 0 HcmV?d00001 diff --git a/platform/icons/src/ide/shadow/top@2x.png b/platform/icons/src/ide/shadow/top@2x.png new file mode 100644 index 0000000000000000000000000000000000000000..a893e2458eec64fb9112636e507b4549b1388d9b GIT binary patch literal 175 zcmeAS@N?(olHy`uVBq!ia0vp^j6f{H!3-p;FD#!7q|5?*LR^6~8DM)^MiEe(P)U$q zFe3{y6B|1R7dJ1zfRKo|q_iAI)ah$LSusx+#}E$L Date: Sat, 21 Feb 2015 23:10:09 +0100 Subject: [PATCH 05/21] duplicate popup shadows to avoid resizing on HiDPI --- .../icons/src/ide/shadow/popup/bottom-left@2x.png | Bin 0 -> 356 bytes .../src/ide/shadow/popup/bottom-right@2x.png | Bin 0 -> 347 bytes platform/icons/src/ide/shadow/popup/bottom@2x.png | Bin 0 -> 134 bytes platform/icons/src/ide/shadow/popup/left@2x.png | Bin 0 -> 122 bytes platform/icons/src/ide/shadow/popup/right@2x.png | Bin 0 -> 122 bytes .../icons/src/ide/shadow/popup/top-left@2x.png | Bin 0 -> 242 bytes .../icons/src/ide/shadow/popup/top-right@2x.png | Bin 0 -> 242 bytes platform/icons/src/ide/shadow/popup/top@2x.png | Bin 0 -> 110 bytes 8 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 platform/icons/src/ide/shadow/popup/bottom-left@2x.png create mode 100644 platform/icons/src/ide/shadow/popup/bottom-right@2x.png create mode 100644 platform/icons/src/ide/shadow/popup/bottom@2x.png create mode 100644 platform/icons/src/ide/shadow/popup/left@2x.png create mode 100644 platform/icons/src/ide/shadow/popup/right@2x.png create mode 100644 platform/icons/src/ide/shadow/popup/top-left@2x.png create mode 100644 platform/icons/src/ide/shadow/popup/top-right@2x.png create mode 100644 platform/icons/src/ide/shadow/popup/top@2x.png diff --git a/platform/icons/src/ide/shadow/popup/bottom-left@2x.png b/platform/icons/src/ide/shadow/popup/bottom-left@2x.png new file mode 100644 index 0000000000000000000000000000000000000000..17b7f4d2682eef698c2dbe8be2715bf402228c7b GIT binary patch literal 356 zcmV-q0h|7bP)74PVwAMk~)4a_KT7K^B$fwty&hiAOu1D^qX z9Xbe%FoSuuY2Wi6j&O-vRr-jhfEPTtz^wX@)wZp2OS80XyAyDui!}ZmZQBK1 zPDMAqqiS3F(>M%hYu$bVBUPFALRYb_o3E+rM!>cng>h~Bp|;Wl3s};AmNehBA-iryJ-c-TKYr^LnObK+*Rs=bK@*_=*xHqjO-h~4I{9vF42(y0000 zOHaZ;6o%naE=80Y43WY@L&7aA3|>$cLI?(2xY8H`ZX_W_|Nk%Wt9eVBrem~h+T_`t zew{gUrk3^pCodDZmbQ4}iX&MoVc>&|q$dqI-ZyY2x6(~@;9cqi)7!(GOl2q?sYe5y zKPsRU8thiwU~lA0J`Fyod6O4;B=AC-aw=s$_7nIXdNIzHnzcO3f?Lv;bE(P^y|pch zRZv|$%GV;c*DIW=QeHsEy6*skBd0}d&B&fm4D)g?%>g*uUW0rp75mKdRE-Ne2yKFenWiU-#lvz=U tASW&?$zbQ%Vz5m+dX?-1GQo*PpKtrNBkwS|Y4iX9002ovPDHLkV1j5^k);3t literal 0 HcmV?d00001 diff --git a/platform/icons/src/ide/shadow/popup/bottom@2x.png b/platform/icons/src/ide/shadow/popup/bottom@2x.png new file mode 100644 index 0000000000000000000000000000000000000000..cb4fcb9fbb95e5d1c563a4fee4a4247edcea8b91 GIT binary patch literal 134 zcmeAS@N?(olHy`uVBq!ia0vp^j6lrA!VDza|7cbMDY*cj5LY0L2W;2K&jLzwl?3?( zr>BOwnW{_E)O!VDxIsIL4Aq(lRJLR^6~CJ_E)O!VDxIsIL4Aq(lRJLR^6~CJG;%8@`6Y(n+D8%dO;uyjqo173*<_k0~hT&95N)yOr22WQ%mvv4FO#m(W6tDmQ literal 0 HcmV?d00001 diff --git a/platform/icons/src/ide/shadow/popup/top-left@2x.png b/platform/icons/src/ide/shadow/popup/top-left@2x.png new file mode 100644 index 0000000000000000000000000000000000000000..3a6ca6530854f7ebf49c0aaa7056e4693b03dd95 GIT binary patch literal 242 zcmVPwx&W*E>rlRmLP>)ydvMfG24)w>oSr)pG zLjl^O6=*h>P(dFISg0MXDw+Yq4MP~i6lO5z_ZMtJJqAXcQvu(hc)f}tIei&wg0Gt8 zwbroXd^DJ|+5i>|9XTHj7JQpjTfqS?DM8J)PhbNlxbwi^Pz)Njc?)NFqy}sLBYEEy sUMaznL21k$ZtzYGTBo8k<{1lq0Lu*rNn`vHp8x;=07*qoM6N<$g0c}@WB>pF literal 0 HcmV?d00001 diff --git a/platform/icons/src/ide/shadow/popup/top-right@2x.png b/platform/icons/src/ide/shadow/popup/top-right@2x.png new file mode 100644 index 0000000000000000000000000000000000000000..567bd08fbc83ae7fcc17b681b334ebfe8069eb54 GIT binary patch literal 242 zcmV9U6a>(iG*)Xh;;Sks2uc^aaG`>36!HJR$+<8}&^Ars&`st(5~Y;VKU$vP*REh8 z0YjBV2A)3T(1Q$87D~KnzTXTA{--d35jYm=)`fKq;}yslHZi+Pc*!Z8*I73OrTP|D z9AC!naO7ZDIdFg-EMUm4HYRw6J*;8O+qO;P%7GgkVZ&YXm^~$UhZA=#_|~7>4F;cZ s;hu8_)0p53u2Ax6Tx{^c3;OH$2GwE*k^i4cxBvhE07*qoM6N<$f{52-7XSbN literal 0 HcmV?d00001 diff --git a/platform/icons/src/ide/shadow/popup/top@2x.png b/platform/icons/src/ide/shadow/popup/top@2x.png new file mode 100644 index 0000000000000000000000000000000000000000..495941809e23f40ae2667513dafcd6079e30a478 GIT binary patch literal 110 zcmeAS@N?(olHy`uVBq!ia0vp^j6lr7#0(^jw(VUBq<8{+LR^6~9GJc|p9bWxlmz(& vGqLfBGq_j10`hr1T^vI=WRnvU3K<+3m}W3s)D?Il0Mg~@>gTe~DWM4fzlRiE literal 0 HcmV?d00001 From c3602f3000cf1abff37c6c7dac0ad6b669d54060 Mon Sep 17 00:00:00 2001 From: Konstantin Bulenkov Date: Sat, 21 Feb 2015 23:10:50 +0100 Subject: [PATCH 06/21] resize non @2x images on HiDPI devices --- .../src/com/intellij/util/ImageLoader.java | 26 +++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/platform/util/src/com/intellij/util/ImageLoader.java b/platform/util/src/com/intellij/util/ImageLoader.java index 1fcc08ea333b..b8ac405c97f3 100644 --- a/platform/util/src/com/intellij/util/ImageLoader.java +++ b/platform/util/src/com/intellij/util/ImageLoader.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2014 JetBrains s.r.o. + * Copyright 2000-2015 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. @@ -30,6 +30,8 @@ import org.jetbrains.annotations.Nullable; import javax.swing.*; import java.awt.*; +import java.awt.geom.AffineTransform; +import java.awt.image.BufferedImage; import java.io.IOException; import java.io.InputStream; import java.io.Serializable; @@ -63,7 +65,14 @@ public class ImageLoader implements Serializable { public static Image loadFromUrl(@NotNull URL url) { for (Pair each : getFileNames(url.toString())) { try { - return loadFromStream(URLUtil.openStream(new URL(each.first)), each.second); + Image image = loadFromStream(URLUtil.openStream(new URL(each.first)), each.second); + + //we can't check all 3rd party plugins and convince the authors to add @2x icons. + // isHiDPI() != isRetina() => we should scale images manually + if (image != null && JBUI.isHiDPI() && !each.first.contains("@2x")) { + image = upscale(image); + } + return image; } catch (IOException ignore) { } @@ -71,6 +80,19 @@ public class ImageLoader implements Serializable { return null; } + @NotNull + private static Image upscale(Image image) { + float scale = JBUI.scale(1f); + int width = (int)(scale * image.getWidth(null)); + int height = (int)(scale * image.getHeight(null)); + @SuppressWarnings("UndesirableClassUsage") + BufferedImage tmp = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB); + Graphics2D g = tmp.createGraphics(); + g.drawImage(image, AffineTransform.getScaleInstance(scale, scale), null); + image = tmp; + return image; + } + @Nullable public static Image loadFromUrl(URL url, boolean dark, boolean retina) { for (Pair each : getFileNames(url.toString(), dark, retina || JBUI.isHiDPI())) { From d18c455ea92cff6a6b77f76b83c8a0ff239a7586 Mon Sep 17 00:00:00 2001 From: Konstantin Bulenkov Date: Sat, 21 Feb 2015 23:11:24 +0100 Subject: [PATCH 07/21] +is & +has methods --- .../util/src/com/intellij/util/SystemProperties.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/platform/util/src/com/intellij/util/SystemProperties.java b/platform/util/src/com/intellij/util/SystemProperties.java index 7929dd1ff629..14b6999cb868 100644 --- a/platform/util/src/com/intellij/util/SystemProperties.java +++ b/platform/util/src/com/intellij/util/SystemProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2012 JetBrains s.r.o. + * Copyright 2000-2015 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. @@ -135,4 +135,12 @@ public class SystemProperties { public static String getJavaVendor() { return System.getProperty("java.vendor"); } + + public static boolean is(String key) { + return getBooleanProperty(key, false); + } + + public static boolean has(String key) { + return System.getProperty(key) != null; + } } From fb80b1b9e8dc1429be0892c223792f38a8a41a68 Mon Sep 17 00:00:00 2001 From: Konstantin Bulenkov Date: Sat, 21 Feb 2015 23:12:05 +0100 Subject: [PATCH 08/21] rewrite calculation of isHiDPI --- .../util/src/com/intellij/util/ui/JBUI.java | 23 ++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/platform/util/src/com/intellij/util/ui/JBUI.java b/platform/util/src/com/intellij/util/ui/JBUI.java index 0c80b543d838..70f4539f958a 100644 --- a/platform/util/src/com/intellij/util/ui/JBUI.java +++ b/platform/util/src/com/intellij/util/ui/JBUI.java @@ -17,6 +17,7 @@ package com.intellij.util.ui; import com.intellij.openapi.util.SystemInfo; import com.intellij.ui.border.CustomLineBorder; +import com.intellij.util.SystemProperties; import javax.swing.*; import javax.swing.border.Border; @@ -26,7 +27,27 @@ import java.awt.*; * @author Konstantin Bulenkov */ public class JBUI { - private static boolean IS_HIDPI = !SystemInfo.isMac && ("true".equals(System.getProperty("hidpi")) || "true".equals(System.getProperty("is.hidpi"))); + private static boolean IS_HIDPI = calculateHiDPI(); + + private static boolean calculateHiDPI() { + if (SystemInfo.isMac) { + return false; + } + + if (SystemProperties.is("hidpi")) { + return true; + } + + if (SystemProperties.has("hidpi") && !SystemProperties.is("hidpi")) { + return false; + } + + if (SystemInfo.isWindows && getSystemDPI() > 144) { + return true; + } + + return false; + } private static int getSystemDPI() { try { From ae11763e7f5a58ed537bb1daf587a92d21d8facd Mon Sep 17 00:00:00 2001 From: Konstantin Bulenkov Date: Sat, 21 Feb 2015 23:22:57 +0100 Subject: [PATCH 09/21] HiDPI fix Splash custom paintings --- platform/platform-impl/src/com/intellij/ui/Splash.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/platform/platform-impl/src/com/intellij/ui/Splash.java b/platform/platform-impl/src/com/intellij/ui/Splash.java index 0bee1412af15..fcab3aa223ab 100644 --- a/platform/platform-impl/src/com/intellij/ui/Splash.java +++ b/platform/platform-impl/src/com/intellij/ui/Splash.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2014 JetBrains s.r.o. + * Copyright 2000-2015 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. @@ -47,7 +47,7 @@ public class Splash extends JDialog implements StartupProgress { @Nullable public static Rectangle BOUNDS; private final Icon myImage; - private int myProgressHeight = 2; + private int myProgressHeight = JBUI.scale(2); private Color myProgressColor = null; private int myProgressY; private float myProgress; @@ -102,7 +102,7 @@ public class Splash extends JDialog implements StartupProgress { this(info.getSplashImageUrl(), info.getSplashTextColor()); if (info instanceof ApplicationInfoImpl) { final ApplicationInfoImpl appInfo = (ApplicationInfoImpl)info; - myProgressHeight = 2; + myProgressHeight = JBUI.scale(2); myProgressColor = appInfo.getProgressColor(); myProgressY = appInfo.getProgressY(); myProgressTail = appInfo.getProgressTailIcon(); @@ -143,8 +143,8 @@ public class Splash extends JDialog implements StartupProgress { g.setColor(color); g.fillRect(1, getProgressY(), width, getProgressHeight()); if (myProgressTail != null) { - myProgressTail.paintIcon(this, g, width - (myProgressTail.getIconWidth()/2), - getProgressY() - (myProgressTail.getIconHeight() - getProgressHeight())/2); + myProgressTail.paintIcon(this, g, width - (myProgressTail.getIconWidth() / JBUI.scale(1) / 2 * JBUI.scale(1)), + getProgressY() - (myProgressTail.getIconHeight() - getProgressHeight()) / JBUI.scale(1) / 2 * JBUI.scale(1)); //I'll buy you a beer if you understand this line without playing with it } myProgressLastPosition = progressWidth; } From 4e10661379bce1856211e061203948cb81691145 Mon Sep 17 00:00:00 2001 From: Konstantin Bulenkov Date: Sun, 22 Feb 2015 02:00:38 +0100 Subject: [PATCH 10/21] HiDPI: get system font sizes on Linux --- .../src/com/intellij/ide/ui/laf/darcula/DarculaLaf.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform/platform-impl/src/com/intellij/ide/ui/laf/darcula/DarculaLaf.java b/platform/platform-impl/src/com/intellij/ide/ui/laf/darcula/DarculaLaf.java index 156c39657609..390c0190c71d 100644 --- a/platform/platform-impl/src/com/intellij/ide/ui/laf/darcula/DarculaLaf.java +++ b/platform/platform-impl/src/com/intellij/ide/ui/laf/darcula/DarculaLaf.java @@ -56,7 +56,7 @@ public class DarculaLaf extends BasicLookAndFeel { public DarculaLaf() { try { - if (SystemInfo.isWindows || SystemInfo.isLinux) { + if (SystemInfo.isWindows) { base = new IdeaLaf(); } else { final String name = UIManager.getSystemLookAndFeelClassName(); From 5bcf4c7f67a4e426b2d4c097d18ccc131acb16f8 Mon Sep 17 00:00:00 2001 From: Elizaveta Shashkova Date: Sun, 22 Feb 2015 14:30:44 +0300 Subject: [PATCH 11/21] Switch debugger reader's sleeping policy to BLOCKING (PY-15122) Because of changes in BaseOutputReader we can't call readAvailableBlocking if sleeping policy is not BLOCKING. --- .../com/jetbrains/python/debugger/pydev/RemoteDebugger.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/pydevSrc/com/jetbrains/python/debugger/pydev/RemoteDebugger.java b/python/pydevSrc/com/jetbrains/python/debugger/pydev/RemoteDebugger.java index cd2c6e2f0b4d..e39f45f1b3a9 100644 --- a/python/pydevSrc/com/jetbrains/python/debugger/pydev/RemoteDebugger.java +++ b/python/pydevSrc/com/jetbrains/python/debugger/pydev/RemoteDebugger.java @@ -488,7 +488,7 @@ public class RemoteDebugger implements ProcessDebugger { private StringBuilder myTextBuilder = new StringBuilder(); private DebuggerReader(final InputStream stream) throws IOException { - super(stream, CharsetToolkit.UTF8_CHARSET); //TODO: correct encoding? + super(stream, CharsetToolkit.UTF8_CHARSET, SleepingPolicy.BLOCKING); //TODO: correct encoding? start(); } From fae615a4702d0db7efc8e5120148370abc489fff Mon Sep 17 00:00:00 2001 From: Yaroslav Lepenkin Date: Sun, 22 Feb 2015 13:46:14 +0300 Subject: [PATCH 12/21] Show "Optional actions" label only if there are any (IDEA-136830) --- .../src/com/intellij/codeInsight/actions/LayoutCodeDialog.form | 2 +- .../src/com/intellij/codeInsight/actions/LayoutCodeDialog.java | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/platform/lang-impl/src/com/intellij/codeInsight/actions/LayoutCodeDialog.form b/platform/lang-impl/src/com/intellij/codeInsight/actions/LayoutCodeDialog.form index b6e07f4c8a5b..3c6a16512e86 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/actions/LayoutCodeDialog.form +++ b/platform/lang-impl/src/com/intellij/codeInsight/actions/LayoutCodeDialog.form @@ -107,7 +107,7 @@ - + diff --git a/platform/lang-impl/src/com/intellij/codeInsight/actions/LayoutCodeDialog.java b/platform/lang-impl/src/com/intellij/codeInsight/actions/LayoutCodeDialog.java index 6dc2971b800c..cd0a9c0890f2 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/actions/LayoutCodeDialog.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/actions/LayoutCodeDialog.java @@ -51,6 +51,7 @@ public class LayoutCodeDialog extends DialogWrapper { private JPanel myActionsPanel; private JPanel myScopePanel; + private JLabel myOptionalLabel; private LayoutCodeOptions myRunOptions; @@ -127,6 +128,8 @@ public class LayoutCodeDialog extends DialogWrapper { if (canRearrangeCode) { myRearrangeCodeCb.setSelected(myLastRunOptions.isRearrangeCode(myFile.getLanguage())); } + + myOptionalLabel.setVisible(canOptimizeImports || canRearrangeCode); } @Nullable From f0556a4a657bc07b4b371b0f04359b5768be8b9e Mon Sep 17 00:00:00 2001 From: Yaroslav Lepenkin Date: Sun, 22 Feb 2015 15:00:45 +0300 Subject: [PATCH 13/21] Do not show "Unnecessary fully qualified name" warning in javadocs if "fully qualify when not imported" is selected and fqn is not imported (IDEA-136680) --- ...necessaryFullyQualifiedNameInspection.java | 19 +++++++++++-------- .../DoubleQualify.java | 7 +++++++ .../Single.java | 5 +++++ .../expected.xml | 11 +++++++++++ ...ssaryFullyQualifiedNameInspectionTest.java | 2 +- 5 files changed, 35 insertions(+), 9 deletions(-) create mode 100644 plugins/InspectionGadgets/test/com/siyeh/igtest/style/unnecessary_fqn_javadoc_fully_qualify_if_not_imported/DoubleQualify.java create mode 100644 plugins/InspectionGadgets/test/com/siyeh/igtest/style/unnecessary_fqn_javadoc_fully_qualify_if_not_imported/Single.java create mode 100644 plugins/InspectionGadgets/test/com/siyeh/igtest/style/unnecessary_fqn_javadoc_fully_qualify_if_not_imported/expected.xml diff --git a/plugins/InspectionGadgets/src/com/siyeh/ig/style/UnnecessaryFullyQualifiedNameInspection.java b/plugins/InspectionGadgets/src/com/siyeh/ig/style/UnnecessaryFullyQualifiedNameInspection.java index 28669193d19a..9961a7103f18 100644 --- a/plugins/InspectionGadgets/src/com/siyeh/ig/style/UnnecessaryFullyQualifiedNameInspection.java +++ b/plugins/InspectionGadgets/src/com/siyeh/ig/style/UnnecessaryFullyQualifiedNameInspection.java @@ -15,7 +15,6 @@ */ package com.siyeh.ig.style; -import com.intellij.codeInsight.javadoc.JavaDocUtil; import com.intellij.codeInspection.CleanupLocalInspectionTool; import com.intellij.codeInspection.ProblemDescriptor; import com.intellij.openapi.diagnostic.Logger; @@ -26,6 +25,7 @@ import com.intellij.psi.*; import com.intellij.psi.codeStyle.CodeStyleSettings; import com.intellij.psi.codeStyle.CodeStyleSettingsManager; import com.intellij.psi.codeStyle.JavaCodeStyleSettings; +import com.intellij.psi.impl.source.codeStyle.ImportHelper; import com.intellij.psi.javadoc.PsiDocComment; import com.intellij.psi.util.PsiTreeUtil; import com.intellij.util.IncorrectOperationException; @@ -206,11 +206,6 @@ public class UnnecessaryFullyQualifiedNameInspection extends BaseInspection impl if (element != null) { return; } - final CodeStyleSettings styleSettings = CodeStyleSettingsManager.getSettings(reference.getProject()); - PsiDocComment containingComment = PsiTreeUtil.getParentOfType(reference, PsiDocComment.class); - if (containingComment != null && acceptFullyQualifiedNamesInJavadoc(containingComment, styleSettings)) { - return; - } final PsiFile containingFile = reference.getContainingFile(); if (!(containingFile instanceof PsiJavaFile)) { return; @@ -219,6 +214,11 @@ public class UnnecessaryFullyQualifiedNameInspection extends BaseInspection impl if (!(target instanceof PsiClass)) { return; } + final CodeStyleSettings styleSettings = CodeStyleSettingsManager.getSettings(reference.getProject()); + PsiDocComment containingComment = PsiTreeUtil.getParentOfType(reference, PsiDocComment.class); + if (containingComment != null && acceptFqnInJavadoc((PsiJavaFile)containingFile, reference.getQualifiedName(), styleSettings)) { + return; + } final PsiJavaCodeReferenceElement qualifierReference = (PsiJavaCodeReferenceElement)qualifier; final PsiElement qualifierTarget = qualifierReference.resolve(); if (!(qualifierTarget instanceof PsiPackage)) { @@ -262,11 +262,14 @@ public class UnnecessaryFullyQualifiedNameInspection extends BaseInspection impl } } - public static boolean acceptFullyQualifiedNamesInJavadoc(PsiDocComment comment, CodeStyleSettings styleSettings) { - if (JavaDocUtil.isInsidePackageInfo(comment)) { + private static boolean acceptFqnInJavadoc(PsiJavaFile javaFile, String fullyQualifiedName, CodeStyleSettings styleSettings) { + if ("package-info.java".equals(javaFile.getName())) { return true; } JavaCodeStyleSettings javaSettings = styleSettings.getCustomSettings(JavaCodeStyleSettings.class); + if (javaSettings.CLASS_NAMES_IN_JAVADOC == JavaCodeStyleSettings.FULLY_QUALIFY_NAMES_IF_NOT_IMPORTED) { + return !ImportHelper.isAlreadyImported(javaFile, fullyQualifiedName); + } return javaSettings.useFqNamesInJavadocAlways(); } } \ No newline at end of file diff --git a/plugins/InspectionGadgets/test/com/siyeh/igtest/style/unnecessary_fqn_javadoc_fully_qualify_if_not_imported/DoubleQualify.java b/plugins/InspectionGadgets/test/com/siyeh/igtest/style/unnecessary_fqn_javadoc_fully_qualify_if_not_imported/DoubleQualify.java new file mode 100644 index 000000000000..de1e31544974 --- /dev/null +++ b/plugins/InspectionGadgets/test/com/siyeh/igtest/style/unnecessary_fqn_javadoc_fully_qualify_if_not_imported/DoubleQualify.java @@ -0,0 +1,7 @@ +import java.util.HashMap; + +/** + * {@link java.util.HashMap} + */ +public class DoubleQualify { +} \ No newline at end of file diff --git a/plugins/InspectionGadgets/test/com/siyeh/igtest/style/unnecessary_fqn_javadoc_fully_qualify_if_not_imported/Single.java b/plugins/InspectionGadgets/test/com/siyeh/igtest/style/unnecessary_fqn_javadoc_fully_qualify_if_not_imported/Single.java new file mode 100644 index 000000000000..193c25f043c5 --- /dev/null +++ b/plugins/InspectionGadgets/test/com/siyeh/igtest/style/unnecessary_fqn_javadoc_fully_qualify_if_not_imported/Single.java @@ -0,0 +1,5 @@ +/** + * {@link java.util.HashMap} + */ +public class Single { +} \ No newline at end of file diff --git a/plugins/InspectionGadgets/test/com/siyeh/igtest/style/unnecessary_fqn_javadoc_fully_qualify_if_not_imported/expected.xml b/plugins/InspectionGadgets/test/com/siyeh/igtest/style/unnecessary_fqn_javadoc_fully_qualify_if_not_imported/expected.xml new file mode 100644 index 000000000000..05706352d657 --- /dev/null +++ b/plugins/InspectionGadgets/test/com/siyeh/igtest/style/unnecessary_fqn_javadoc_fully_qualify_if_not_imported/expected.xml @@ -0,0 +1,11 @@ + + + + + DoubleQualify.java + 4 + Unnecessary fully qualified name + Fully qualified name <code>java.util.HashMap</code> is unnecessary, and can be replaced with an import #loc + + + \ No newline at end of file diff --git a/plugins/InspectionGadgets/testsrc/com/siyeh/ig/style/UnnecessaryFullyQualifiedNameInspectionTest.java b/plugins/InspectionGadgets/testsrc/com/siyeh/ig/style/UnnecessaryFullyQualifiedNameInspectionTest.java index 8dc9ea7b861c..1856fc662a46 100644 --- a/plugins/InspectionGadgets/testsrc/com/siyeh/ig/style/UnnecessaryFullyQualifiedNameInspectionTest.java +++ b/plugins/InspectionGadgets/testsrc/com/siyeh/ig/style/UnnecessaryFullyQualifiedNameInspectionTest.java @@ -10,7 +10,7 @@ public class UnnecessaryFullyQualifiedNameInspectionTest extends IGInspectionTes private static final String BASE_DIR = "com/siyeh/igtest/style/"; public void testFqnInJavadoc_Unnecessary_WhenFullyQualifyIfNotImported() throws Exception { - doTestWithFqnInJavadocSetting(BASE_DIR + "unnecessary_fully_qualified_name/", JavaCodeStyleSettings.FULLY_QUALIFY_NAMES_IF_NOT_IMPORTED); + doTestWithFqnInJavadocSetting(BASE_DIR + "unnecessary_fqn_javadoc_fully_qualify_if_not_imported", JavaCodeStyleSettings.FULLY_QUALIFY_NAMES_IF_NOT_IMPORTED); } public void testFqnInJavadoc_Unnecessary_WhenShortNamesAlways() { From f02dc6c4ed1f212bbf335510dccf37f7447e0cb2 Mon Sep 17 00:00:00 2001 From: Dmitry Batkovich Date: Sun, 22 Feb 2015 16:29:06 +0300 Subject: [PATCH 14/21] test fixed --- .../SuspiciousLanguagesInspectionTest.java | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/plugins/java-i18n/testSrc/com/intellij/codeInspection/SuspiciousLanguagesInspectionTest.java b/plugins/java-i18n/testSrc/com/intellij/codeInspection/SuspiciousLanguagesInspectionTest.java index 784b6e9ea737..891b8fcffe34 100644 --- a/plugins/java-i18n/testSrc/com/intellij/codeInspection/SuspiciousLanguagesInspectionTest.java +++ b/plugins/java-i18n/testSrc/com/intellij/codeInspection/SuspiciousLanguagesInspectionTest.java @@ -31,25 +31,20 @@ public class SuspiciousLanguagesInspectionTest extends LightCodeInsightFixtureTe } public void testSimple1() { - doTest(); + doTest("p.properties", "p_en.properties"); } public void testSimple2() { - doTest(); + doTest("p.properties", "p_asd.properties"); } public void testWithAdditionalLocales() { - doTest("asd"); + doTest("p.properties", "p_asd.properties", "asd"); } - private void doTest(final String... additionalLocales) { - final File tesDataDir = new File(getHomePath() + File.separator + getBasePath() + File.separator + getTestName(true)); - final File[] files = tesDataDir.listFiles(); - assertNotNull(files); - for (File file : files) { - final String path = file.getAbsolutePath(); - myFixture.configureByFile(path); - } + private void doTest(final String file1, final String file2, final String... additionalLocales) { + myFixture.configureByFile(getTestName(true) + "/" + file1); + myFixture.configureByFile(getTestName(true) + "/" + file2); final SuspiciousLocalesLanguagesInspection inspection = new SuspiciousLocalesLanguagesInspection(); if (additionalLocales.length != 0) { inspection.setAdditionalLanguages(ContainerUtil.newArrayList(additionalLocales)); From d565ab8d2c2a2db19b4a44d7cd1b98dd2f0c2aac Mon Sep 17 00:00:00 2001 From: Dmitry Batkovich Date: Sun, 22 Feb 2015 21:06:10 +0300 Subject: [PATCH 15/21] SuspiciousLocalesLanguagesInspections: bundles with size < 2 ignored --- .../codeInspection/SuspiciousLocalesLanguagesInspection.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/java-i18n/src/com/intellij/codeInspection/SuspiciousLocalesLanguagesInspection.java b/plugins/java-i18n/src/com/intellij/codeInspection/SuspiciousLocalesLanguagesInspection.java index b9ec80f1a5b5..e88d46649c4e 100644 --- a/plugins/java-i18n/src/com/intellij/codeInspection/SuspiciousLocalesLanguagesInspection.java +++ b/plugins/java-i18n/src/com/intellij/codeInspection/SuspiciousLocalesLanguagesInspection.java @@ -115,7 +115,7 @@ public class SuspiciousLocalesLanguagesInspection extends BaseLocalInspectionToo } final ResourceBundle resourceBundle = propertiesFile.getResourceBundle(); final List files = resourceBundle.getPropertiesFiles(); - if (files.isEmpty()) { + if (files.size() < 2) { return null; } List bundleLocales = ContainerUtil.mapNotNull(files, new Function() { From 3702e6990391e7ccb0ec8d1a3e39ef0796ca363a Mon Sep 17 00:00:00 2001 From: Dmitry Batkovich Date: Sun, 22 Feb 2015 21:07:51 +0300 Subject: [PATCH 16/21] Slow updating of project view while resource bundle dissociation fixed --- .../DissociateResourceBundleAction.java | 14 +++++++++++++- .../properties/projectView/ResourceBundleNode.java | 9 +++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/plugins/properties/src/com/intellij/lang/properties/customizeActions/DissociateResourceBundleAction.java b/plugins/properties/src/com/intellij/lang/properties/customizeActions/DissociateResourceBundleAction.java index b36be1746912..25c0be113f69 100644 --- a/plugins/properties/src/com/intellij/lang/properties/customizeActions/DissociateResourceBundleAction.java +++ b/plugins/properties/src/com/intellij/lang/properties/customizeActions/DissociateResourceBundleAction.java @@ -17,6 +17,7 @@ package com.intellij.lang.properties.customizeActions; import com.intellij.icons.AllIcons; import com.intellij.ide.projectView.ProjectView; +import com.intellij.ide.util.treeView.AbstractTreeBuilder; import com.intellij.lang.properties.PropertiesImplUtil; import com.intellij.lang.properties.ResourceBundle; import com.intellij.lang.properties.ResourceBundleManager; @@ -27,12 +28,15 @@ import com.intellij.openapi.actionSystem.AnActionEvent; import com.intellij.openapi.actionSystem.LangDataKeys; import com.intellij.openapi.fileEditor.FileEditorManager; import com.intellij.openapi.project.Project; +import com.intellij.psi.PsiDirectory; import com.intellij.psi.PsiElement; import com.intellij.psi.PsiFile; +import com.intellij.psi.PsiFileSystemItem; import com.intellij.util.containers.ContainerUtil; import com.intellij.util.containers.HashSet; import org.jetbrains.annotations.NotNull; +import javax.swing.*; import java.util.*; /** @@ -73,14 +77,22 @@ public class DissociateResourceBundleAction extends AnAction { public static void dissociate(final Collection resourceBundles, final Project project) { final FileEditorManager fileEditorManager = FileEditorManager.getInstance(project); + final Set toUpdateInProjectView = new HashSet(); for (ResourceBundle resourceBundle : resourceBundles) { fileEditorManager.closeFile(new ResourceBundleAsVirtualFile(resourceBundle)); for (final PropertiesFile propertiesFile : resourceBundle.getPropertiesFiles()) { fileEditorManager.closeFile(propertiesFile.getVirtualFile()); + PsiDirectory containingDirectory = propertiesFile.getContainingFile().getContainingDirectory(); + if (containingDirectory != null) { + toUpdateInProjectView.add(containingDirectory); + } } ResourceBundleManager.getInstance(project).dissociateResourceBundle(resourceBundle); } - ProjectView.getInstance(project).refresh(); + AbstractTreeBuilder treeBuilder = ProjectView.getInstance(project).getCurrentProjectViewPane().getTreeBuilder(); + for (PsiFileSystemItem item : toUpdateInProjectView) { + treeBuilder.queueUpdateFrom(item, false); + } } @NotNull diff --git a/plugins/properties/src/com/intellij/lang/properties/projectView/ResourceBundleNode.java b/plugins/properties/src/com/intellij/lang/properties/projectView/ResourceBundleNode.java index b9f61643095d..20af8439004c 100644 --- a/plugins/properties/src/com/intellij/lang/properties/projectView/ResourceBundleNode.java +++ b/plugins/properties/src/com/intellij/lang/properties/projectView/ResourceBundleNode.java @@ -32,6 +32,7 @@ import com.intellij.openapi.fileEditor.FileEditorManager; import com.intellij.openapi.fileEditor.OpenFileDescriptor; import com.intellij.openapi.fileTypes.StdFileTypes; import com.intellij.openapi.project.Project; +import com.intellij.openapi.util.Comparing; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.psi.PsiFile; import com.intellij.psi.PsiManager; @@ -97,4 +98,12 @@ public class ResourceBundleNode extends ProjectViewNode{ public Comparable getTypeSortKey() { return new PsiFileNode.ExtensionSortKey(StdFileTypes.PROPERTIES.getDefaultExtension()); } + + @Override + public boolean validate() { + if (!super.validate()) { + return false; + } + return Comparing.equal(getValue().getDefaultPropertiesFile().getResourceBundle(), getValue()); + } } From fba83a2a034099beac9fbad09f3a3ff213adb367 Mon Sep 17 00:00:00 2001 From: Dmitry Batkovich Date: Sun, 22 Feb 2015 21:17:28 +0300 Subject: [PATCH 17/21] SuspiciousLocalesLanguagesInspection: custom resource bundles ignored --- .../SuspiciousLocalesLanguagesInspection.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/plugins/java-i18n/src/com/intellij/codeInspection/SuspiciousLocalesLanguagesInspection.java b/plugins/java-i18n/src/com/intellij/codeInspection/SuspiciousLocalesLanguagesInspection.java index e88d46649c4e..1dc726b8a2ee 100644 --- a/plugins/java-i18n/src/com/intellij/codeInspection/SuspiciousLocalesLanguagesInspection.java +++ b/plugins/java-i18n/src/com/intellij/codeInspection/SuspiciousLocalesLanguagesInspection.java @@ -16,10 +16,8 @@ package com.intellij.codeInspection; import com.intellij.codeInspection.ex.BaseLocalInspectionTool; -import com.intellij.lang.properties.PropertiesBundle; -import com.intellij.lang.properties.PropertiesImplUtil; +import com.intellij.lang.properties.*; import com.intellij.lang.properties.ResourceBundle; -import com.intellij.lang.properties.ResourceBundleManager; import com.intellij.lang.properties.customizeActions.DissociateResourceBundleAction; import com.intellij.lang.properties.psi.PropertiesFile; import com.intellij.openapi.project.Project; @@ -115,7 +113,7 @@ public class SuspiciousLocalesLanguagesInspection extends BaseLocalInspectionToo } final ResourceBundle resourceBundle = propertiesFile.getResourceBundle(); final List files = resourceBundle.getPropertiesFiles(); - if (files.size() < 2) { + if (!(resourceBundle instanceof ResourceBundleImpl) || files.size() < 2) { return null; } List bundleLocales = ContainerUtil.mapNotNull(files, new Function() { From 4a60c5a05ccda93fb6abd42e323ed3f60a93485c Mon Sep 17 00:00:00 2001 From: Dmitry Batkovich Date: Mon, 23 Feb 2015 01:16:11 +0300 Subject: [PATCH 18/21] inspection short name fixed --- plugins/java-i18n/src/META-INF/plugin.xml | 2 +- .../src/inspectionDescriptions/SuspiciousLocalesLanguages.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/java-i18n/src/META-INF/plugin.xml b/plugins/java-i18n/src/META-INF/plugin.xml index 3f042db7095e..9d4fc9a8f356 100644 --- a/plugins/java-i18n/src/META-INF/plugin.xml +++ b/plugins/java-i18n/src/META-INF/plugin.xml @@ -54,7 +54,7 @@ enabledByDefault="true" level="WARNING" implementationClass="com.intellij.codeInspection.capitalization.TitleCapitalizationInspection"/> - -Inspection detects locales which contain languages not included supported by Java. +Inspection detects locales which contain language codes not supported by Java. \ No newline at end of file From ece86046575e8294351962ff7380f4f8ddf24e4d Mon Sep 17 00:00:00 2001 From: Konstantin Bulenkov Date: Mon, 23 Feb 2015 00:03:53 +0100 Subject: [PATCH 19/21] install system fonts for Darcula on Linux --- .../ide/ui/laf/darcula/DarculaLaf.java | 29 +++++++++++++++---- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/platform/platform-impl/src/com/intellij/ide/ui/laf/darcula/DarculaLaf.java b/platform/platform-impl/src/com/intellij/ide/ui/laf/darcula/DarculaLaf.java index 390c0190c71d..8e9ca5a93e52 100644 --- a/platform/platform-impl/src/com/intellij/ide/ui/laf/darcula/DarculaLaf.java +++ b/platform/platform-impl/src/com/intellij/ide/ui/laf/darcula/DarculaLaf.java @@ -42,10 +42,8 @@ import java.io.InputStream; import java.lang.reflect.Field; import java.lang.reflect.Method; import java.net.URL; -import java.util.Arrays; +import java.util.*; import java.util.List; -import java.util.Locale; -import java.util.Properties; /** * @author Konstantin Bulenkov @@ -56,7 +54,7 @@ public class DarculaLaf extends BasicLookAndFeel { public DarculaLaf() { try { - if (SystemInfo.isWindows) { + if (SystemInfo.isWindows || SystemInfo.isLinux) { base = new IdeaLaf(); } else { final String name = UIManager.getSystemLookAndFeelClassName(); @@ -82,7 +80,7 @@ public class DarculaLaf extends BasicLookAndFeel { @SuppressWarnings("UnusedParameters") private static void log(Exception e) { // everything is gonna be alright -// e.printStackTrace(); + e.printStackTrace(); } @Override @@ -91,6 +89,7 @@ public class DarculaLaf extends BasicLookAndFeel { final Method superMethod = BasicLookAndFeel.class.getDeclaredMethod("getDefaults"); superMethod.setAccessible(true); final UIDefaults metalDefaults = (UIDefaults)superMethod.invoke(new MetalLookAndFeel()); + final UIDefaults defaults = (UIDefaults)superMethod.invoke(base); if (SystemInfo.isLinux) { if (!Registry.is("darcula.use.native.fonts.on.linux")) { @@ -124,6 +123,9 @@ public class DarculaLaf extends BasicLookAndFeel { if (SystemInfo.isWindows) { //JFrame.setDefaultLookAndFeelDecorated(true); } + if (SystemInfo.isLinux && JBUI.isHiDPI()) { + applySystemFonts(defaults); + } defaults.put("EditorPane.font", defaults.getFont("TextField.font")); return defaults; } @@ -133,6 +135,23 @@ public class DarculaLaf extends BasicLookAndFeel { return super.getDefaults(); } + private static void applySystemFonts(UIDefaults defaults) { + try { + String fqn = UIManager.getSystemLookAndFeelClassName(); + Object systemLookAndFeel = Class.forName(fqn).newInstance(); + final Method superMethod = BasicLookAndFeel.class.getDeclaredMethod("getDefaults"); + superMethod.setAccessible(true); + final UIDefaults systemDefaults = (UIDefaults)superMethod.invoke(systemLookAndFeel); + for (Map.Entry entry : systemDefaults.entrySet()) { + if (entry.getValue() instanceof Font) { + defaults.put(entry.getKey(), entry.getValue()); + } + } + } catch (Exception e) { + log(e); + } + } + protected DefaultMetalTheme createMetalTheme() { return new DarculaMetalTheme(); } From 34dd16ff20fec4f64a55b72ad8e5eef16d472958 Mon Sep 17 00:00:00 2001 From: Konstantin Bulenkov Date: Mon, 23 Feb 2015 00:04:38 +0100 Subject: [PATCH 20/21] do not redefine system fonts for IntelliJ Laf --- .../com/intellij/ide/ui/laf/IntelliJLaf.java | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) diff --git a/platform/platform-impl/src/com/intellij/ide/ui/laf/IntelliJLaf.java b/platform/platform-impl/src/com/intellij/ide/ui/laf/IntelliJLaf.java index 2df9bf7f6414..e1e77fb8354f 100644 --- a/platform/platform-impl/src/com/intellij/ide/ui/laf/IntelliJLaf.java +++ b/platform/platform-impl/src/com/intellij/ide/ui/laf/IntelliJLaf.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2015 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,11 +15,8 @@ */ package com.intellij.ide.ui.laf; -import com.intellij.ide.ui.LafManager; import com.intellij.ide.ui.laf.darcula.DarculaLaf; -import com.intellij.openapi.util.SystemInfo; -import javax.swing.*; import javax.swing.plaf.metal.DefaultMetalTheme; /** @@ -36,19 +33,6 @@ public class IntelliJLaf extends DarculaLaf { return "intellijlaf"; } - @Override - public UIDefaults getDefaults() { - UIDefaults defaults = super.getDefaults(); - if (SystemInfo.isLinux) { - try { - LafManagerImpl.initFontDefaults(defaults, "Dialog", 12); - } - catch (Exception ignore) { - } - } - return defaults; - } - @Override protected DefaultMetalTheme createMetalTheme() { return new IdeaBlueMetalTheme(); From 45087294907b0751d3dc6cecf0284b0b4a8f0d8b Mon Sep 17 00:00:00 2001 From: Konstantin Bulenkov Date: Mon, 23 Feb 2015 00:55:46 +0100 Subject: [PATCH 21/21] HiDPI: don't patch int values twice in UIDefaults --- .../src/com/intellij/ide/ui/laf/LafManagerImpl.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/platform/platform-impl/src/com/intellij/ide/ui/laf/LafManagerImpl.java b/platform/platform-impl/src/com/intellij/ide/ui/laf/LafManagerImpl.java index 779e326d2802..0a2ce8d93e67 100644 --- a/platform/platform-impl/src/com/intellij/ide/ui/laf/LafManagerImpl.java +++ b/platform/platform-impl/src/com/intellij/ide/ui/laf/LafManagerImpl.java @@ -560,6 +560,7 @@ public final class LafManagerImpl extends LafManager implements ApplicationCompo List myIntKeys = Arrays.asList("Tree.leftChildIndent", "Tree.rightChildIndent"); + List patched = new ArrayList(); for (Map.Entry entry : defaults.entrySet()) { Object value = entry.getValue(); String key = entry.getKey().toString(); @@ -569,10 +570,16 @@ public final class LafManagerImpl extends LafManager implements ApplicationCompo entry.setValue(JBUI.insets(((InsetsUIResource)value)).asUIResource()); } else if (value instanceof Integer) { if (key.endsWith(".maxGutterIconWidth") || myIntKeys.contains(key)) { - entry.setValue(Integer.valueOf(JBUI.scale((Integer)value))); + if (!"true".equals(defaults.get(key +".hidpi.patched"))) { + entry.setValue(Integer.valueOf(JBUI.scale((Integer)value))); + patched.add(key); + } } } } + for (String key : patched) { + defaults.put(key + ".hidpi.patched", "true"); + } } public static void updateToolWindows() {