From bd3d1c201ecbb44d727b164122a7658dbea8a1c3 Mon Sep 17 00:00:00 2001 From: Konstantin Bulenkov Date: Thu, 14 Jan 2016 18:19:11 +0100 Subject: [PATCH] dpi aware insets --- .../com/intellij/facet/impl/ui/FacetEditorImpl.java | 7 ++++--- .../AddSupportForFrameworksPanel.java | 5 ++--- .../ide/util/projectWizard/NamePathComponent.java | 11 ++++++----- .../ide/util/projectWizard/ProjectNameStep.java | 8 ++++---- .../roots/ui/configuration/ClasspathEditor.java | 5 +++-- .../openapi/roots/ui/configuration/OutputEditor.java | 5 +++-- 6 files changed, 22 insertions(+), 19 deletions(-) diff --git a/java/idea-ui/src/com/intellij/facet/impl/ui/FacetEditorImpl.java b/java/idea-ui/src/com/intellij/facet/impl/ui/FacetEditorImpl.java index 41868ba87529..d7a7baab0f51 100644 --- a/java/idea-ui/src/com/intellij/facet/impl/ui/FacetEditorImpl.java +++ b/java/idea-ui/src/com/intellij/facet/impl/ui/FacetEditorImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2014 JetBrains s.r.o. + * Copyright 2000-2016 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. @@ -27,6 +27,7 @@ import com.intellij.openapi.options.UnnamedConfigurable; import com.intellij.openapi.options.UnnamedConfigurableGroup; import com.intellij.openapi.util.Disposer; import com.intellij.ui.TabbedPaneWrapper; +import com.intellij.util.ui.JBUI; import com.intellij.util.ui.UIUtil; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -96,14 +97,14 @@ public class FacetEditorImpl extends UnnamedConfigurableGroup implements Unnamed } else if (myEditorTabs.length == 1) { editorComponent = myEditorTabs[0].createComponent(); - UIUtil.addInsets(editorComponent, new Insets(0, 5, 0, 0)); + UIUtil.addInsets(editorComponent, JBUI.insets(0, 5, 0, 0)); } else { editorComponent = new JPanel(); } final JComponent errorComponent = myErrorPanel.getComponent(); - UIUtil.addInsets(errorComponent, new Insets(0, 5, 5, 0)); + UIUtil.addInsets(errorComponent, JBUI.insets(0, 5, 5, 0)); final JPanel panel = new JPanel(new BorderLayout()); panel.add(BorderLayout.CENTER, editorComponent); diff --git a/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/AddSupportForFrameworksPanel.java b/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/AddSupportForFrameworksPanel.java index ea88dcd3698e..b3d3d05a1fbc 100644 --- a/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/AddSupportForFrameworksPanel.java +++ b/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/AddSupportForFrameworksPanel.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2015 JetBrains s.r.o. + * Copyright 2000-2016 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -34,7 +34,6 @@ import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.module.Module; import com.intellij.openapi.project.DumbModePermission; import com.intellij.openapi.project.DumbService; -import com.intellij.openapi.project.ProjectManager; import com.intellij.openapi.roots.IdeaModifiableModelsProvider; import com.intellij.openapi.roots.ModifiableRootModel; import com.intellij.openapi.roots.libraries.Library; @@ -176,7 +175,7 @@ public class AddSupportForFrameworksPanel implements Disposable { private static void addAssociatedFrameworkComponent(JPanel component, JPanel panel) { panel.add(component, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 2, 1, 1.0, 0, GridBagConstraints.NORTHWEST, - GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); + GridBagConstraints.HORIZONTAL, JBUI.emptyInsets(), 0, 0)); } protected void onFrameworkStateChanged() {} diff --git a/java/idea-ui/src/com/intellij/ide/util/projectWizard/NamePathComponent.java b/java/idea-ui/src/com/intellij/ide/util/projectWizard/NamePathComponent.java index 4541ba7b8693..a7d433a5fc87 100644 --- a/java/idea-ui/src/com/intellij/ide/util/projectWizard/NamePathComponent.java +++ b/java/idea-ui/src/com/intellij/ide/util/projectWizard/NamePathComponent.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2014 JetBrains s.r.o. + * Copyright 2000-2016 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. @@ -28,6 +28,7 @@ import com.intellij.openapi.util.io.FileUtil; import com.intellij.openapi.util.text.StringUtil; import com.intellij.ui.DocumentAdapter; import com.intellij.ui.FieldPanel; +import com.intellij.util.ui.JBUI; import com.intellij.util.ui.UIUtil; import org.jetbrains.annotations.NotNull; @@ -91,11 +92,11 @@ public class NamePathComponent extends JPanel{ myNameLabel = new JLabel(nameLabelText); if (bold) myNameLabel.setFont(UIUtil.getLabelFont().deriveFont(Font.BOLD)); myNameLabel.setLabelFor(myTfName); - Insets insets = new Insets(0, 0, 5, 4); + Insets insets = JBUI.insets(0, 0, 5, 4); this.add(myNameLabel, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, insets, 0, 0)); - insets = new Insets(0, 0, 5, 0); + insets = JBUI.insets(0, 0, 5, 0); this.add(myTfName, new GridBagConstraints(1, GridBagConstraints.RELATIVE, 1, 1, 1.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, insets, 0, 0)); // todo: review texts @@ -111,10 +112,10 @@ public class NamePathComponent extends JPanel{ myPathLabel = new JLabel(pathLabelText); myPathLabel.setLabelFor(myTfPath); if (bold) myPathLabel.setFont(UIUtil.getLabelFont().deriveFont(Font.BOLD)); - insets = new Insets(0, 0, 5, 4); + insets = JBUI.insets(0, 0, 5, 4); this.add(myPathLabel, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, insets, 0, 0)); - insets = new Insets(0, 0, 5, 0); + insets = JBUI.insets(0, 0, 5, 0); this.add(myPathPanel, new GridBagConstraints(1, GridBagConstraints.RELATIVE, 1, 1, 1.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, insets, 0, 0)); } diff --git a/java/idea-ui/src/com/intellij/ide/util/projectWizard/ProjectNameStep.java b/java/idea-ui/src/com/intellij/ide/util/projectWizard/ProjectNameStep.java index 398515f72b62..fea2114fc386 100644 --- a/java/idea-ui/src/com/intellij/ide/util/projectWizard/ProjectNameStep.java +++ b/java/idea-ui/src/com/intellij/ide/util/projectWizard/ProjectNameStep.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2016 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,12 +19,12 @@ import com.intellij.ide.IdeBundle; import com.intellij.ide.highlighter.ModuleFileType; import com.intellij.ide.highlighter.ProjectFileType; import com.intellij.openapi.application.ApplicationInfo; -import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.options.ConfigurationException; import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.Messages; import com.intellij.openapi.util.io.FileUtil; import com.intellij.openapi.util.text.StringUtil; +import com.intellij.util.ui.JBUI; import org.jetbrains.annotations.NonNls; import javax.swing.*; @@ -55,9 +55,9 @@ public class ProjectNameStep extends ModuleWizardStep { ApplicationInfo info = ApplicationInfo.getInstance(); String appName = info.getVersionName(); myPanel.add(new JLabel(IdeBundle.message("label.please.enter.project.name", appName, wizardContext.getPresentationName())), - new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 1.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(8, 10, 8, 10), 0, 0)); + new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 1.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, JBUI.insets(8, 10), 0, 0)); - myPanel.add(myNamePathComponent, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 1.0, 1.0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(8, 10, 8, 10), 0, 0)); + myPanel.add(myNamePathComponent, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 1.0, 1.0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, JBUI.insets(8, 10), 0, 0)); } public JComponent getPreferredFocusedComponent() { diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/ClasspathEditor.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/ClasspathEditor.java index 44ddcce6ff65..9337892a9ba9 100644 --- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/ClasspathEditor.java +++ b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/ClasspathEditor.java @@ -30,6 +30,7 @@ import com.intellij.openapi.roots.impl.storage.ClasspathStorageProvider; import com.intellij.openapi.roots.ui.configuration.classpath.ClasspathPanelImpl; import com.intellij.openapi.ui.ComboBox; import com.intellij.openapi.util.Disposer; +import com.intellij.util.ui.JBUI; import gnu.trove.THashMap; import org.jetbrains.annotations.NotNull; @@ -163,7 +164,7 @@ public class ClasspathEditor extends ModuleElementsEditor implements ModuleRootL super(new GridBagLayout()); add(new JLabel(ProjectBundle.message("project.roots.classpath.format.label")), - new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(10, 6, 6, 0), 0, 0)); + new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, JBUI.insets(10, 6, 6, 0), 0, 0)); formatIdToDescription.put(ClassPathStorageUtil.DEFAULT_STORAGE, ProjectBundle.message("project.roots.classpath.format.default.descr")); for (ClasspathStorageProvider provider : providers) { @@ -173,7 +174,7 @@ public class ClasspathEditor extends ModuleElementsEditor implements ModuleRootL comboBoxClasspathFormat = new ComboBox(formatIdToDescription.values().toArray()); updateClasspathFormat(); add(comboBoxClasspathFormat, - new GridBagConstraints(1, 0, 1, 1, 1.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(6, 6, 6, 0), 0, 0)); + new GridBagConstraints(1, 0, 1, 1, 1.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, JBUI.insets(6, 6, 6, 0), 0, 0)); } private void updateClasspathFormat() { diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/OutputEditor.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/OutputEditor.java index fe3ce1a82f7c..44d3fed6eb78 100644 --- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/OutputEditor.java +++ b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/OutputEditor.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2016 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,6 +24,7 @@ package com.intellij.openapi.roots.ui.configuration; import com.intellij.openapi.project.ProjectBundle; import com.intellij.ui.IdeBorderFactory; +import com.intellij.util.ui.JBUI; import com.intellij.util.ui.UIUtil; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.Nullable; @@ -49,7 +50,7 @@ public class OutputEditor extends ModuleElementsEditor { final JPanel panel = new JPanel(new GridBagLayout()); panel.setBorder(new EmptyBorder(UIUtil.PANEL_SMALL_INSETS)); final GridBagConstraints gc = - new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 1, 0, GridBagConstraints.NORTHWEST, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0); + new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 1, 0, GridBagConstraints.NORTHWEST, GridBagConstraints.BOTH, JBUI.emptyInsets(), 0, 0); panel.add(myCompilerOutputEditor.createComponentImpl(), gc); final JPanel javadocPanel = (JPanel)myJavadocEditor.createComponentImpl(); javadocPanel.setBorder(IdeBorderFactory.createTitledBorder(myJavadocEditor.getDisplayName(), false));